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
|
||||
|
||||
make_repeater (n: STRING; a_datasource: WSF_DATASOURCE [G])
|
||||
local
|
||||
p: WSF_PAGINATION_CONTROL [G]
|
||||
do
|
||||
make_multi_control (n)
|
||||
datasource := a_datasource
|
||||
datasource.set_on_update_agent (agent update)
|
||||
if attached {WSF_PAGABLE_DATASOURCE [G]} a_datasource as ds then
|
||||
create pagination_control.make_paging (n + "_paging", ds)
|
||||
add_control (pagination_control)
|
||||
create p.make_paging (n + "_paging", ds)
|
||||
add_control (p)
|
||||
pagination_control := p
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,7 +56,6 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
Result.put (datasource.state, "datasource")
|
||||
end
|
||||
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render_item (item: G): STRING
|
||||
|
||||
@@ -23,10 +23,12 @@ feature {NONE} -- Initialization
|
||||
--Initialize
|
||||
do
|
||||
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")
|
||||
nav.add_class ("nav navbar-nav")
|
||||
nav_right.add_class ("nav navbar-nav navbar-right")
|
||||
end
|
||||
|
||||
make_navbar_with_brand (n, b: STRING)
|
||||
@@ -62,17 +64,43 @@ feature -- Rendering
|
||||
feature -- Change
|
||||
|
||||
set_active (tab: INTEGER)
|
||||
-- Sets the given tab as current active tab
|
||||
require
|
||||
tab >= 0 and tab < nav.controls.count + nav_right.controls.count
|
||||
tab >= 1 and tab <= tab_count and not active_set
|
||||
do
|
||||
if tab < nav.controls.count then
|
||||
if tab <= nav.controls.count then
|
||||
nav.controls.i_th (tab).add_class ("active")
|
||||
else
|
||||
nav_right.controls.i_th (tab - nav.controls.count).add_class ("active")
|
||||
end
|
||||
active_set := true
|
||||
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
|
||||
local
|
||||
name: STRING
|
||||
@@ -81,33 +109,24 @@ feature -- Change
|
||||
name := control_name + "_rightlink";
|
||||
name := name + nav_right.controls.count.out
|
||||
create li.make_with_tag_name (name, "li")
|
||||
li.add_control (c)
|
||||
li.add_control (l)
|
||||
add_element_right (li)
|
||||
end
|
||||
|
||||
add_list_element (c: WSF_STATELESS_CONTROL)
|
||||
add_list_element (l: WSF_STATELESS_CONTROL)
|
||||
-- Add element in li tag to main nav
|
||||
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_control (c)
|
||||
li.add_control (l)
|
||||
add_element (li)
|
||||
end
|
||||
|
||||
add_element_right (c: WSF_STATELESS_CONTROL)
|
||||
-- Add element to right aligned part of navbar
|
||||
local
|
||||
right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
if attached nav_right as r then
|
||||
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)
|
||||
nav_right.add_control (c)
|
||||
end
|
||||
|
||||
add_element (c: WSF_STATELESS_CONTROL)
|
||||
@@ -116,8 +135,19 @@ feature -- Change
|
||||
nav.add_control (c)
|
||||
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
|
||||
|
||||
active_set: BOOLEAN
|
||||
-- This flag is set once a tab has been set as active tab
|
||||
|
||||
brand: detachable STRING
|
||||
-- Optional brand of the navbar
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ feature -- Change
|
||||
local
|
||||
caption_control: detachable WSF_STATELESS_CONTROL
|
||||
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)
|
||||
end
|
||||
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 a new image to the slider, with specified url, alternative text and caption element
|
||||
local
|
||||
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create item.make_multi_control (control_name + "_item" + slide_wrapper.controls.count.out)
|
||||
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)
|
||||
add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", "", ""), Void)
|
||||
end
|
||||
|
||||
add_image (src, alt: STRING)
|
||||
@@ -90,17 +82,24 @@ feature -- Change
|
||||
add_image_with_caption (src, alt, "")
|
||||
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
|
||||
local
|
||||
cl: STRING
|
||||
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
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 := ""
|
||||
if slide_wrapper.controls.count = 0 then
|
||||
cl := "active"
|
||||
c.add_class (cl)
|
||||
item.add_class (cl)
|
||||
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, ""));
|
||||
end
|
||||
|
||||
|
||||
@@ -120,19 +120,17 @@ feature -- Rendering
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
Result := c.item.render + Result
|
||||
Result := Result + c.item.render
|
||||
end
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_control (c: detachable G)
|
||||
add_control (c: G)
|
||||
-- Add a control to this multi control
|
||||
do
|
||||
if attached c as d then
|
||||
controls.put_front (d)
|
||||
end
|
||||
controls.extend (c)
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
Reference in New Issue
Block a user