Fixed WSF_MULTI_CONTROL (wrong order of subcontrols), completed navbar, improved slider
This commit is contained in:
@@ -19,13 +19,16 @@ inherit
|
|||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_repeater (n: STRING; a_datasource: WSF_DATASOURCE [G])
|
make_repeater (n: STRING; a_datasource: WSF_DATASOURCE [G])
|
||||||
|
local
|
||||||
|
p: WSF_PAGINATION_CONTROL [G]
|
||||||
do
|
do
|
||||||
make_multi_control (n)
|
make_multi_control (n)
|
||||||
datasource := a_datasource
|
datasource := a_datasource
|
||||||
datasource.set_on_update_agent (agent update)
|
datasource.set_on_update_agent (agent update)
|
||||||
if attached {WSF_PAGABLE_DATASOURCE [G]} a_datasource as ds then
|
if attached {WSF_PAGABLE_DATASOURCE [G]} a_datasource as ds then
|
||||||
create pagination_control.make_paging (n + "_paging", ds)
|
create p.make_paging (n + "_paging", ds)
|
||||||
add_control (pagination_control)
|
add_control (p)
|
||||||
|
pagination_control := p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,7 +56,6 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
|||||||
Result.put (datasource.state, "datasource")
|
Result.put (datasource.state, "datasource")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
feature -- Rendering
|
feature -- Rendering
|
||||||
|
|
||||||
render_item (item: G): STRING
|
render_item (item: G): STRING
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ feature {NONE} -- Initialization
|
|||||||
--Initialize
|
--Initialize
|
||||||
do
|
do
|
||||||
make_multi_control (n)
|
make_multi_control (n)
|
||||||
|
active_set := false
|
||||||
add_class ("navbar navbar-inverse navbar-fixed-top")
|
add_class ("navbar navbar-inverse navbar-fixed-top")
|
||||||
create nav.make_with_tag_name (control_name + "_nav", "ul")
|
create nav.make_with_tag_name (control_name + "_nav", "ul")
|
||||||
create nav_right.make_with_tag_name (control_name + "_nav_right", "ul")
|
create nav_right.make_with_tag_name (control_name + "_nav_right", "ul")
|
||||||
nav.add_class ("nav navbar-nav")
|
nav.add_class ("nav navbar-nav")
|
||||||
|
nav_right.add_class ("nav navbar-nav navbar-right")
|
||||||
end
|
end
|
||||||
|
|
||||||
make_navbar_with_brand (n, b: STRING)
|
make_navbar_with_brand (n, b: STRING)
|
||||||
@@ -62,17 +64,43 @@ feature -- Rendering
|
|||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
set_active (tab: INTEGER)
|
set_active (tab: INTEGER)
|
||||||
|
-- Sets the given tab as current active tab
|
||||||
require
|
require
|
||||||
tab >= 0 and tab < nav.controls.count + nav_right.controls.count
|
tab >= 1 and tab <= tab_count and not active_set
|
||||||
do
|
do
|
||||||
if tab < nav.controls.count then
|
if tab <= nav.controls.count then
|
||||||
nav.controls.i_th (tab).add_class ("active")
|
nav.controls.i_th (tab).add_class ("active")
|
||||||
else
|
else
|
||||||
nav_right.controls.i_th (tab - nav.controls.count).add_class ("active")
|
nav_right.controls.i_th (tab - nav.controls.count).add_class ("active")
|
||||||
end
|
end
|
||||||
|
active_set := true
|
||||||
end
|
end
|
||||||
|
|
||||||
add_list_element_right (c: WSF_STATELESS_CONTROL)
|
add_dropdown (l: WSF_STATELESS_CONTROL; d: WSF_STATELESS_CONTROL)
|
||||||
|
-- Add dropdown menu (in li tag with class dropdown) to navbar
|
||||||
|
local
|
||||||
|
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
|
do
|
||||||
|
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
|
||||||
|
li.add_class ("dropdown")
|
||||||
|
li.add_control (l)
|
||||||
|
li.add_control (d)
|
||||||
|
add_element (li)
|
||||||
|
end
|
||||||
|
|
||||||
|
add_dropdown_right (l: WSF_STATELESS_CONTROL; d: WSF_STATELESS_CONTROL)
|
||||||
|
-- Add dropdown menu (in li tag with class dropdown) to right aligned part of navbar
|
||||||
|
local
|
||||||
|
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
|
do
|
||||||
|
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
|
||||||
|
li.add_class ("dropdown")
|
||||||
|
li.add_control (l)
|
||||||
|
li.add_control (d)
|
||||||
|
add_element_right (li)
|
||||||
|
end
|
||||||
|
|
||||||
|
add_list_element_right (l: WSF_STATELESS_CONTROL)
|
||||||
-- Add element in li tag to right aligned part of navbar
|
-- Add element in li tag to right aligned part of navbar
|
||||||
local
|
local
|
||||||
name: STRING
|
name: STRING
|
||||||
@@ -81,33 +109,24 @@ feature -- Change
|
|||||||
name := control_name + "_rightlink";
|
name := control_name + "_rightlink";
|
||||||
name := name + nav_right.controls.count.out
|
name := name + nav_right.controls.count.out
|
||||||
create li.make_with_tag_name (name, "li")
|
create li.make_with_tag_name (name, "li")
|
||||||
li.add_control (c)
|
li.add_control (l)
|
||||||
add_element_right (li)
|
add_element_right (li)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_list_element (c: WSF_STATELESS_CONTROL)
|
add_list_element (l: WSF_STATELESS_CONTROL)
|
||||||
-- Add element in li tag to main nav
|
-- Add element in li tag to main nav
|
||||||
local
|
local
|
||||||
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
do
|
do
|
||||||
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
|
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
|
||||||
li.add_control (c)
|
li.add_control (l)
|
||||||
add_element (li)
|
add_element (li)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_element_right (c: WSF_STATELESS_CONTROL)
|
add_element_right (c: WSF_STATELESS_CONTROL)
|
||||||
-- Add element to right aligned part of navbar
|
-- Add element to right aligned part of navbar
|
||||||
local
|
|
||||||
right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
|
||||||
do
|
do
|
||||||
if attached nav_right as r then
|
nav_right.add_control (c)
|
||||||
right := r
|
|
||||||
else
|
|
||||||
create right.make_with_tag_name (control_name + "_rightnav", "ul")
|
|
||||||
right.add_class ("nav navbar-nav navbar-right")
|
|
||||||
nav_right := right
|
|
||||||
end
|
|
||||||
right.add_control (c)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_element (c: WSF_STATELESS_CONTROL)
|
add_element (c: WSF_STATELESS_CONTROL)
|
||||||
@@ -116,8 +135,19 @@ feature -- Change
|
|||||||
nav.add_control (c)
|
nav.add_control (c)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
tab_count: INTEGER
|
||||||
|
-- Current sum of the number of items in left and right navbar
|
||||||
|
do
|
||||||
|
Result := nav.controls.count + nav_right.controls.count
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Properties
|
feature -- Properties
|
||||||
|
|
||||||
|
active_set: BOOLEAN
|
||||||
|
-- This flag is set once a tab has been set as active tab
|
||||||
|
|
||||||
brand: detachable STRING
|
brand: detachable STRING
|
||||||
-- Optional brand of the navbar
|
-- Optional brand of the navbar
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ feature -- Change
|
|||||||
local
|
local
|
||||||
caption_control: detachable WSF_STATELESS_CONTROL
|
caption_control: detachable WSF_STATELESS_CONTROL
|
||||||
do
|
do
|
||||||
if attached caption as c then
|
if attached caption as c and then not c.is_empty then
|
||||||
caption_control := create {WSF_BASIC_CONTROL}.make_with_body ("p", "", c)
|
caption_control := create {WSF_BASIC_CONTROL}.make_with_body ("p", "", c)
|
||||||
end
|
end
|
||||||
add_image_with_caption_control (src, alt, caption_control)
|
add_image_with_caption_control (src, alt, caption_control)
|
||||||
@@ -72,16 +72,8 @@ feature -- Change
|
|||||||
|
|
||||||
add_image_with_caption_control (src, alt: STRING; caption: detachable WSF_STATELESS_CONTROL)
|
add_image_with_caption_control (src, alt: STRING; caption: detachable WSF_STATELESS_CONTROL)
|
||||||
-- Add a new image to the slider, with specified url, alternative text and caption element
|
-- Add a new image to the slider, with specified url, alternative text and caption element
|
||||||
local
|
|
||||||
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
|
||||||
do
|
do
|
||||||
create item.make_multi_control (control_name + "_item" + slide_wrapper.controls.count.out)
|
add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", "", ""), Void)
|
||||||
item.add_class ("item")
|
|
||||||
item.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", "", ""))
|
|
||||||
if attached caption as c then
|
|
||||||
item.add_control (c)
|
|
||||||
end
|
|
||||||
add_control (item)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_image (src, alt: STRING)
|
add_image (src, alt: STRING)
|
||||||
@@ -90,17 +82,24 @@ feature -- Change
|
|||||||
add_image_with_caption (src, alt, "")
|
add_image_with_caption (src, alt, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_control (c: WSF_STATELESS_CONTROL)
|
add_control (c: WSF_STATELESS_CONTROL; caption: detachable WSF_STATELESS_CONTROL)
|
||||||
-- Add a new control to the slider
|
-- Add a new control to the slider
|
||||||
local
|
local
|
||||||
cl: STRING
|
cl: STRING
|
||||||
|
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
do
|
do
|
||||||
|
create item.make_multi_control (control_name + "_item" + slide_wrapper.controls.count.out)
|
||||||
|
item.add_class ("item")
|
||||||
|
item.add_control (c)
|
||||||
|
if attached caption as capt then
|
||||||
|
item.add_control (capt)
|
||||||
|
end
|
||||||
cl := ""
|
cl := ""
|
||||||
if slide_wrapper.controls.count = 0 then
|
if slide_wrapper.controls.count = 0 then
|
||||||
cl := "active"
|
cl := "active"
|
||||||
c.add_class (cl)
|
item.add_class (cl)
|
||||||
end
|
end
|
||||||
slide_wrapper.add_control (c)
|
slide_wrapper.add_control (item)
|
||||||
list.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "data-target=%"#" + control_name + "%" data-slide-to=%"" + list.controls.count.out + "%"", cl, ""));
|
list.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "data-target=%"#" + control_name + "%" data-slide-to=%"" + list.controls.count.out + "%"", cl, ""));
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -120,19 +120,17 @@ feature -- Rendering
|
|||||||
across
|
across
|
||||||
controls as c
|
controls as c
|
||||||
loop
|
loop
|
||||||
Result := c.item.render + Result
|
Result := Result + c.item.render
|
||||||
end
|
end
|
||||||
Result := render_tag (Result, "")
|
Result := render_tag (Result, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
add_control (c: detachable G)
|
add_control (c: G)
|
||||||
-- Add a control to this multi control
|
-- Add a control to this multi control
|
||||||
do
|
do
|
||||||
if attached c as d then
|
controls.extend (c)
|
||||||
controls.put_front (d)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Properties
|
feature -- Properties
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ feature -- Execution
|
|||||||
|
|
||||||
slider_demo (request: WSF_REQUEST; response: WSF_RESPONSE)
|
slider_demo (request: WSF_REQUEST; response: WSF_RESPONSE)
|
||||||
local
|
local
|
||||||
page: IMAGE_SLIDER_PAGE
|
page: SLIDER_PAGE
|
||||||
do
|
do
|
||||||
-- To send a response we need to setup, the status code and
|
-- To send a response we need to setup, the status code and
|
||||||
-- the response headers.
|
-- the response headers.
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ feature
|
|||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/%"", "Home"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/%"", "Home"))
|
||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/grid%"", "Grid"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/grid%"", "Grid"))
|
||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/repeater%"", "Repeater"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/repeater%"", "Repeater"))
|
||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Image Slider"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Slider"))
|
||||||
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"#%"", "About"))
|
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/about%"", "About"))
|
||||||
if not attached get_parameter ("ajax") then
|
if not attached get_parameter ("ajax") then
|
||||||
control.add_control (navbar)
|
control.add_control (navbar)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ class
|
|||||||
inherit
|
inherit
|
||||||
|
|
||||||
BASE_PAGE
|
BASE_PAGE
|
||||||
redefine
|
redefine
|
||||||
initialize_controls
|
initialize_controls
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
@@ -22,16 +22,16 @@ feature
|
|||||||
initialize_controls
|
initialize_controls
|
||||||
do
|
do
|
||||||
Precursor
|
Precursor
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h1","","Grid Demo"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "Grid Demo"))
|
||||||
create datasource.make_news
|
create datasource.make_news
|
||||||
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
|
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
|
||||||
search_query.add_class ("form-control")
|
search_query.add_class ("form-control")
|
||||||
search_query.set_change_event (agent change_query)
|
search_query.set_change_event (agent change_query)
|
||||||
control.add_control (search_query)
|
control.add_control (search_query)
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
||||||
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make ("Title", "title"),
|
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make ("Title", "title"), create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
|
||||||
create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
|
|
||||||
control.add_control (grid)
|
control.add_control (grid)
|
||||||
|
navbar.set_active (2)
|
||||||
end
|
end
|
||||||
|
|
||||||
change_query
|
change_query
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
IMAGE_SLIDER_PAGE
|
SLIDER_PAGE
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
|
|
||||||
@@ -20,14 +20,20 @@ create
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
|
local
|
||||||
|
form: WSF_FORM_CONTROL
|
||||||
do
|
do
|
||||||
Precursor
|
Precursor
|
||||||
create slider.make_slider ("myslider")
|
create slider.make_slider ("myslider")
|
||||||
|
create form.make_form_control ("sliderform")
|
||||||
|
form.add_control (create {WSF_FORM_ELEMENT_CONTROL[STRING]}.make_form_element ("Input", create {WSF_INPUT_CONTROL}.make_input ("sliderformtext", "Test")))
|
||||||
|
slider.add_control (form, Void)
|
||||||
slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
||||||
slider.add_image ("http://24.media.tumblr.com/0fcec9a7dde5b405a46b6fcda1ffad0c/tumblr_mtagkyYVIT1st5lhmo1_1280.jpg", "car")
|
slider.add_image ("http://24.media.tumblr.com/0fcec9a7dde5b405a46b6fcda1ffad0c/tumblr_mtagkyYVIT1st5lhmo1_1280.jpg", "car")
|
||||||
slider.add_image ("http://25.media.tumblr.com/d9e791508eb9a532aa7f258fa4e0fedc/tumblr_mtag5zve3g1st5lhmo1_1280.jpg", "landscape")
|
slider.add_image ("http://25.media.tumblr.com/d9e791508eb9a532aa7f258fa4e0fedc/tumblr_mtag5zve3g1st5lhmo1_1280.jpg", "landscape")
|
||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
|
||||||
control.add_control (slider)
|
control.add_control (slider)
|
||||||
|
navbar.set_active (4)
|
||||||
end
|
end
|
||||||
|
|
||||||
process
|
process
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ feature
|
|||||||
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
|
||||||
create repeater.make_repeater ("myrepeater", datasource)
|
create repeater.make_repeater ("myrepeater", datasource)
|
||||||
control.add_control (repeater)
|
control.add_control (repeater)
|
||||||
|
navbar.set_active (3)
|
||||||
end
|
end
|
||||||
|
|
||||||
change_query
|
change_query
|
||||||
|
|||||||
Reference in New Issue
Block a user