New Control structure
This commit is contained in:
@@ -18,7 +18,7 @@ feature {NONE}
|
||||
|
||||
make_grid (n: STRING; a_columns: ITERABLE [WSF_GRID_COLUMN]; a_datasource: WSF_DATASOURCE [G])
|
||||
do
|
||||
make (n, "div")
|
||||
make_control (n, "div")
|
||||
columns := a_columns
|
||||
datasource := a_datasource
|
||||
end
|
||||
@@ -79,7 +79,7 @@ feature -- Implementation
|
||||
end
|
||||
Result.append (render_tag_with_tagname ("tr", row, "", ""))
|
||||
end
|
||||
Result :=render_tag_with_tagname ("tbody", Result, "", "")
|
||||
Result := render_tag_with_tagname ("tbody", Result, "", "")
|
||||
end
|
||||
|
||||
render: STRING
|
||||
|
||||
@@ -18,7 +18,7 @@ feature {NONE}
|
||||
|
||||
make_checkbox (n: STRING; l: STRING; c: STRING)
|
||||
do
|
||||
make (n, "input")
|
||||
make_control (n, "input")
|
||||
label := l
|
||||
checked_value := c
|
||||
end
|
||||
|
||||
@@ -31,18 +31,15 @@ feature {NONE}
|
||||
feature
|
||||
|
||||
value: LIST [STRING]
|
||||
local
|
||||
l: LINKED_LIST [STRING]
|
||||
do
|
||||
create l.make
|
||||
create {LINKED_LIST [STRING]} Result.make
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if c.item.value then
|
||||
l.extend (c.item.checked_value)
|
||||
Result.extend (c.item.checked_value)
|
||||
end
|
||||
end
|
||||
Result := l
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ feature {NONE}
|
||||
|
||||
make_input (n: STRING; v: STRING)
|
||||
do
|
||||
make (n, "input")
|
||||
make_control (n, "input")
|
||||
type := "text"
|
||||
text := v
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ feature {NONE}
|
||||
|
||||
make_button (n: STRING; t: STRING)
|
||||
do
|
||||
make (n, "button")
|
||||
make_control (n, "button")
|
||||
add_class ("btn")
|
||||
add_class ("btn-default")
|
||||
text := t
|
||||
|
||||
@@ -7,25 +7,23 @@ note
|
||||
deferred class
|
||||
WSF_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
feature
|
||||
|
||||
control_name: STRING
|
||||
|
||||
tag_name: STRING
|
||||
|
||||
css_classes: LINKED_LIST [STRING]
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make (n, a_tag_name: STRING)
|
||||
make_control (n, a_tag_name: STRING)
|
||||
do
|
||||
make (a_tag_name)
|
||||
control_name := n
|
||||
tag_name := a_tag_name
|
||||
create css_classes.make
|
||||
create state_changes.make
|
||||
ensure
|
||||
attached state_changes
|
||||
attached css_classes
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
@@ -71,45 +69,4 @@ feature --EVENT HANDLING
|
||||
deferred
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
add_class (c: STRING)
|
||||
do
|
||||
css_classes.extend (c)
|
||||
end
|
||||
|
||||
render_tag (body, attributes: STRING): STRING
|
||||
local
|
||||
css_classes_string: STRING
|
||||
do
|
||||
css_classes_string := ""
|
||||
across
|
||||
css_classes as c
|
||||
loop
|
||||
css_classes_string := css_classes_string + " " + c.item
|
||||
end
|
||||
Result := render_tag_with_tagname (tag_name, body, attributes, css_classes_string)
|
||||
end
|
||||
|
||||
render_tag_with_tagname (tag, body, attributes, css_classes_string: STRING): STRING
|
||||
local
|
||||
l_attributes: STRING
|
||||
do
|
||||
l_attributes := attributes
|
||||
if not css_classes_string.is_empty then
|
||||
l_attributes := l_attributes + " class=%"" + css_classes_string + "%""
|
||||
end
|
||||
Result := "<" + tag + " id=%"" + control_name + "%" data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + l_attributes
|
||||
if body.is_empty and not tag.is_equal ("textarea") then
|
||||
Result := Result + " />"
|
||||
else
|
||||
Result := Result + " >" + body + "</" + tag + ">"
|
||||
end
|
||||
end
|
||||
|
||||
render: STRING
|
||||
-- Return html representaion of control
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ feature {NONE}
|
||||
|
||||
make_form_element_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LINKED_LIST [WSF_VALIDATOR [G]])
|
||||
do
|
||||
make (c.control_name + "_container", "div")
|
||||
make_control (c.control_name + "_container", "div")
|
||||
add_class ("form-group")
|
||||
if attached {WSF_INPUT_CONTROL} c or attached {WSF_TEXTAREA_CONTROL} c then
|
||||
c.add_class ("form-control")
|
||||
|
||||
@@ -18,7 +18,7 @@ feature {NONE}
|
||||
|
||||
make_html (n,t,v: STRING)
|
||||
do
|
||||
make (n, t)
|
||||
make_control (n, t)
|
||||
html := v
|
||||
end
|
||||
|
||||
|
||||
@@ -17,15 +17,18 @@ inherit
|
||||
end
|
||||
|
||||
create
|
||||
make_multi_control
|
||||
make_multi_control, make_with_tag_name
|
||||
|
||||
feature {NONE}
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_multi_control (n: STRING)
|
||||
do
|
||||
make (n, "div")
|
||||
make_with_tag_name(n, "div")
|
||||
end
|
||||
|
||||
make_with_tag_name (n, t: STRING)
|
||||
do
|
||||
make_control (n, t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
end
|
||||
|
||||
@@ -112,4 +115,6 @@ feature
|
||||
controls.put_front (c)
|
||||
end
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
|
||||
end
|
||||
|
||||
112
library/server/wsf_html/webcontrol/wsf_navbar_control.e
Normal file
112
library/server/wsf_html/webcontrol/wsf_navbar_control.e
Normal file
@@ -0,0 +1,112 @@
|
||||
note
|
||||
description: "Summary description for {WSF_NAVBAR_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_NAVBAR_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
|
||||
create
|
||||
make_navbar
|
||||
|
||||
feature
|
||||
|
||||
collapse: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
nav: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
|
||||
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_navbar(brand:STRING)
|
||||
local
|
||||
container: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
header: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
make_multi_control
|
||||
add_class ("navbar navbar-inverse navbar-fixed-top")
|
||||
create header.make_multi_control
|
||||
create nav.make_multi_control
|
||||
create collapse.make_multi_control
|
||||
add_control (header)
|
||||
header.add_class ("navbar-header")
|
||||
-- <div class="navbar navbar-inverse navbar-fixed-top">
|
||||
-- <div class="container">
|
||||
-- <div class="navbar-header">
|
||||
-- <button class="navbar-toggle" data-target=".navbar-collapse" data-toggle="collapse" type="button">
|
||||
-- <span class="icon-bar"></span>
|
||||
-- </button>
|
||||
-- <a class="navbar-brand" href="#">WG Manager
|
||||
-- </a>
|
||||
-- </div>
|
||||
-- <div class="navbar-collapse in" style="height: auto;">
|
||||
-- <ul class="nav navbar-nav">
|
||||
-- <li class="active">
|
||||
-- <a href="/wgmanager">
|
||||
-- <span class="glyphicon glyphicon-home"></span> Home
|
||||
-- </a>
|
||||
-- </li>
|
||||
-- <li>
|
||||
-- <a href="users">Users
|
||||
-- </a>
|
||||
-- </li>
|
||||
-- <li>
|
||||
-- <a href="about">About
|
||||
-- </a>
|
||||
-- </li>
|
||||
-- </ul>
|
||||
-- <ul class="nav navbar-nav navbar-right" id="loginnavbar">
|
||||
-- <li>
|
||||
-- <a href="register">
|
||||
-- <span class="glyphicon glyphicon-pencil"></span> Register
|
||||
-- </a>
|
||||
-- </li>
|
||||
-- <li class="dropdown">
|
||||
-- <a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
-- <span class="glyphicon glyphicon-log-in"></span> Sign In
|
||||
-- <strong class="caret"></strong>
|
||||
-- </a>
|
||||
-- <ul class="dropdown-menu" style="min-width: 250px; padding: 15px; padding-bottom: 0px">
|
||||
-- <form id="signinform" onsubmit="check_login();return false;">
|
||||
-- <div class="alert alert-danger" id="login_alert" style="display: none"></div>
|
||||
-- <div class="form-group">
|
||||
-- <input class="form-control" id="username" autofocus="autofocus" placeholder="username" name="username" type="text">
|
||||
-- </div>
|
||||
-- <div class="form-group">
|
||||
-- <input class="form-control" id="password" placeholder="password" name="password" type="password">
|
||||
-- </div>
|
||||
-- <div class="checkbox">
|
||||
-- <label>
|
||||
-- <input type="checkbox"> Remember me
|
||||
-- </label>
|
||||
-- </div>
|
||||
-- <div class="form-group">
|
||||
-- <input class="btn btn-primary btn-block form-control" id="signin" value="Sign In" type="submit">
|
||||
-- </div>
|
||||
-- </form>
|
||||
-- </ul>
|
||||
-- </li>
|
||||
-- </ul>
|
||||
-- <ul class="nav navbar-nav navbar-right" id="accountnavbar" style="display: none">
|
||||
-- <li>
|
||||
-- <a id="account" href="account">
|
||||
-- <span class="glyphicon glyphicon-user"></span>
|
||||
-- </a>
|
||||
-- </li>
|
||||
-- <li>
|
||||
-- <a href="javascript:logout()">
|
||||
-- <span class="glyphicon glyphicon-log-out"></span> Logout
|
||||
-- </a>
|
||||
-- </li>
|
||||
-- </ul>
|
||||
-- </div>
|
||||
-- </div>
|
||||
-- </div>
|
||||
end
|
||||
|
||||
end
|
||||
@@ -76,7 +76,7 @@ feature
|
||||
do
|
||||
create states.make
|
||||
control.read_state (states)
|
||||
data := "<html><head>"
|
||||
data := "<!DOCTYPE html><html><head>"
|
||||
data.append ("<link href=%"/bootstrap.min.css%" rel=%"stylesheet%">")
|
||||
data.append ("<link href=%"/widget.css%" rel=%"stylesheet%">")
|
||||
data.append ("</head><body>")
|
||||
|
||||
67
library/server/wsf_html/webcontrol/wsf_stateless_control.e
Normal file
67
library/server/wsf_html/webcontrol/wsf_stateless_control.e
Normal file
@@ -0,0 +1,67 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STATELESS_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
feature
|
||||
|
||||
tag_name: STRING
|
||||
|
||||
css_classes: LINKED_LIST [STRING]
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make (a_tag_name: STRING)
|
||||
do
|
||||
tag_name := a_tag_name
|
||||
create css_classes.make
|
||||
ensure
|
||||
attached css_classes
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
add_class (c: STRING)
|
||||
do
|
||||
css_classes.extend (c)
|
||||
end
|
||||
|
||||
render_tag (body, attributes: STRING): STRING
|
||||
local
|
||||
css_classes_string: STRING
|
||||
do
|
||||
css_classes_string := ""
|
||||
across
|
||||
css_classes as c
|
||||
loop
|
||||
css_classes_string := css_classes_string + " " + c.item
|
||||
end
|
||||
Result := render_tag_with_tagname (tag_name, body, attributes, css_classes_string)
|
||||
end
|
||||
|
||||
render_tag_with_tagname (tag, body, attributes, css_classes_string: STRING): STRING
|
||||
local
|
||||
l_attributes: STRING
|
||||
do
|
||||
l_attributes := attributes
|
||||
if not css_classes_string.is_empty then
|
||||
l_attributes := l_attributes + " class=%"" + css_classes_string + "%""
|
||||
end
|
||||
Result := "<" + tag + l_attributes
|
||||
if body.is_empty and not tag.is_equal ("textarea") then
|
||||
Result := Result + " />"
|
||||
else
|
||||
Result := Result + " >" + body + "</" + tag + ">"
|
||||
end
|
||||
end
|
||||
|
||||
render: STRING
|
||||
-- Return html representaion of control
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STATELESS_MULTI_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_STATELESS_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
create
|
||||
make_multi_control, make_with_tag_name
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_multi_control
|
||||
do
|
||||
make_with_tag_name ("div")
|
||||
end
|
||||
|
||||
make_with_tag_name (t: STRING)
|
||||
do
|
||||
make (t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
Result := c.item.render + Result
|
||||
end
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
add_control (c: G)
|
||||
do
|
||||
controls.put_front (c)
|
||||
end
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user