Add stateless widgets

This commit is contained in:
YNH Webdev
2013-11-06 15:44:31 +01:00
parent 6838089570
commit c9102af0aa
8 changed files with 78 additions and 29 deletions

View File

@@ -9,7 +9,7 @@ class
inherit
WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
rename
make as make_multi_control,
make_with_tag_name as make_multi_control_with_tag_name
@@ -20,19 +20,19 @@ create
feature {NONE} -- Initialization
make (n, title: STRING)
make ( title: STRING)
-- Make a dropdown control with div tag name and specified menu title
do
make_with_tag_name (n, title, "div")
make_with_tag_name ( title, "div")
end
make_with_tag_name (n, title, t: STRING)
make_with_tag_name ( title, t: STRING)
-- Make a dropdown control with specified tag name and menu title (such as li)
do
make_multi_control_with_tag_name (n, t)
make_multi_control_with_tag_name ( t)
add_class ("dropdown")
create {WSF_BASIC_CONTROL} dropdown_toggle.make_with_body_class ("a", "data-toggle=%"dropdown%" href=%"#%"", "dropdown-toggle", title + " <strong class=%"caret%"></strong>")
create dropdown_menu.make_with_tag_name (n + "_menu", "ul")
create dropdown_menu.make_with_tag_name ( "ul")
dropdown_menu.add_class ("dropdown-menu")
add_control (dropdown_toggle)
add_control (dropdown_menu)
@@ -66,6 +66,6 @@ feature -- Properties
dropdown_toggle: WSF_STATELESS_CONTROL
dropdown_menu: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
dropdown_menu: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
end

View File

@@ -27,8 +27,8 @@ feature {NONE} -- Initialization
make_multi_control (n)
active_set := false
add_class ("navbar navbar-inverse navbar-fixed-top")
create nav.make_with_tag_name (control_name + "_nav", "ul")
create nav_right.make_with_tag_name (control_name + "_nav_right", "ul")
create nav.make_with_tag_name ("ul")
create nav_right.make_with_tag_name ( "ul")
controls.extend (nav)
controls.extend (nav_right)
nav.add_class ("nav navbar-nav")
@@ -155,10 +155,10 @@ feature -- Properties
brand: detachable STRING
-- Optional brand of the navbar
nav: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
nav: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- Middle nav
nav_right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
nav_right: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- Right nav
end

View File

@@ -24,9 +24,9 @@ feature {NONE} -- Initialization
do
make_control (n, "div")
add_class ("carousel slide")
create list.make_with_tag_name (control_name + "_links", "ol")
create list.make_with_tag_name ( "ol")
list.add_class ("carousel-indicators")
create slide_wrapper.make (control_name + "_wrapper")
create slide_wrapper.make_with_tag_name ("div")
slide_wrapper.add_class ("carousel-inner")
end
@@ -108,10 +108,10 @@ feature -- Change
feature -- Properties
list: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
list: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- List of slider links
slide_wrapper: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
slide_wrapper: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- List of the single slides
end

View File

@@ -9,7 +9,7 @@ class
inherit
WSF_MULTI_CONTROL [WSF_CONTROL]
WSF_STATELESS_MULTI_CONTROL [WSF_CONTROL]
rename
make as make_multi_control
end

View File

@@ -9,7 +9,7 @@ class
inherit
WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
rename
make as make_multi_control,
add_control as add_control_raw
@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
make (n: STRING)
do
make_with_tag_name (n, "div")
make_with_tag_name ("div")
add_class ("row")
end

View File

@@ -43,13 +43,20 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
Precursor (new_states)
if attached {JSON_OBJECT} new_states.item ("controls") as ct then
across
controls as c
loop
if attached {WSF_CONTROL} c.item as cont then
if attached {JSON_OBJECT} ct.item (cont.control_name) as value_state then
cont.load_state (value_state)
end
load_subcontrol_state (ct)
end
end
load_subcontrol_state (newstate: JSON_OBJECT)
do
across
controls as c
loop
if attached {WSF_STATELESS_MULTI_CONTROL[WSF_STATELESS_CONTROL]} c.item as cont then
cont.load_subcontrol_state (newstate)
elseif attached {WSF_CONTROL} c.item as cont then
if attached {JSON_OBJECT} newstate.item (cont.control_name) as value_state then
cont.load_state (value_state)
end
end
end
@@ -67,14 +74,21 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
Result := Precursor
create controls_state.make
read_subcontrol_state (controls_state)
Result.put (controls_state, "controls")
end
read_subcontrol_state (controls_state: JSON_OBJECT)
do
across
controls as c
loop
if attached {WSF_CONTROL} c.item as cont then
if attached {WSF_STATELESS_MULTI_CONTROL[WSF_STATELESS_CONTROL]} c.item as mcont then
mcont.read_subcontrol_state (controls_state)
elseif attached {WSF_CONTROL} c.item as cont then
controls_state.put (cont.full_state, cont.control_name)
end
end
Result.put (controls_state, "controls")
end
read_state_changes (states: WSF_JSON_OBJECT)
@@ -124,7 +138,9 @@ feature -- Rendering
loop
Result := Result + c.item.render
end
Result := render_tag (Result, "")
if not tag_name.is_empty then
Result := render_tag (Result, "")
end
end
feature -- Change
@@ -137,6 +153,8 @@ feature -- Change
feature -- Properties
stateless: BOOLEAN
controls: ARRAYED_LIST [G]
-- List of current controls in this multi control

View File

@@ -0,0 +1,31 @@
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_MULTI_CONTROL [G]
rename
make_with_tag_name as make_with_tag_name_and_name
end
create
make_with_tag_name, make_tag_less
feature {NONE} -- Initialization
make_with_tag_name(t:STRING)
do
make_with_tag_name_and_name("",t)
end
make_tag_less
do
make_with_tag_name_and_name ("", "")
stateless := True
end
end