Added dropdown control
This commit is contained in:
@@ -11,17 +11,61 @@ inherit
|
||||
|
||||
WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
rename
|
||||
make as make_multi_control
|
||||
make as make_multi_control,
|
||||
make_with_tag_name as make_multi_control_with_tag_name
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
make, make_with_tag_name
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (n: STRING)
|
||||
make (n, title: STRING)
|
||||
-- Make a dropdown control with div tag name and specified menu title
|
||||
do
|
||||
make_multi_control (n)
|
||||
make_with_tag_name (n, title, "div")
|
||||
end
|
||||
|
||||
make_with_tag_name (n, 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)
|
||||
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")
|
||||
dropdown_menu.add_class ("dropdown-menu")
|
||||
add_control (dropdown_toggle)
|
||||
add_control (dropdown_menu)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_item (c: WSF_STATELESS_CONTROL)
|
||||
local
|
||||
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create li.make_with_tag_name (control_name + "_item" + dropdown_menu.controls.count.out, "li")
|
||||
li.add_control (c)
|
||||
dropdown_menu.add_control (li)
|
||||
end
|
||||
|
||||
add_link_item (label, link: STRING)
|
||||
local
|
||||
c: WSF_BASIC_CONTROL
|
||||
do
|
||||
create c.make_with_body ("a", "href=%"" + link + "%"", label)
|
||||
add_item (c)
|
||||
end
|
||||
|
||||
add_divider
|
||||
do
|
||||
dropdown_menu.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "", "divider", ""))
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
dropdown_toggle: WSF_STATELESS_CONTROL
|
||||
|
||||
dropdown_menu: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
|
||||
end
|
||||
|
||||
@@ -10,16 +10,18 @@ class
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
rename
|
||||
make as make_stateless_control
|
||||
redefine
|
||||
attributes
|
||||
end
|
||||
|
||||
create
|
||||
make_control, make_with_body, make_with_body_class
|
||||
make, make_with_body, make_with_body_class
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_control (t: STRING)
|
||||
make (t: STRING)
|
||||
-- Initialize
|
||||
do
|
||||
make_with_body_class (t, "", "", "")
|
||||
@@ -28,7 +30,7 @@ feature {NONE} -- Initialization
|
||||
make_with_body (t, attr, b: STRING)
|
||||
-- Initialize with specific attributes and body
|
||||
do
|
||||
make (t)
|
||||
make_stateless_control (t)
|
||||
attributes := attr
|
||||
body := b
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,14 +19,20 @@ feature
|
||||
initialize_controls
|
||||
local
|
||||
btn: WSF_BUTTON_CONTROL
|
||||
dropdown:WSF_DROPDOWN_CONTROL
|
||||
do
|
||||
create control.make ("container")
|
||||
control.add_class ("container")
|
||||
create dropdown.make_with_tag_name ("mydropdown", "Dropdown", "li")
|
||||
dropdown.add_link_item ("Example link 1", "#")
|
||||
dropdown.add_divider
|
||||
dropdown.add_link_item ("Example link 2", "#")
|
||||
create navbar.make_with_brand ("navbar1", "Example")
|
||||
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=%"/repeater%"", "Repeater"))
|
||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Slider"))
|
||||
navbar.add_element (dropdown)
|
||||
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/about%"", "About"))
|
||||
create btn.make ("scode", "Show Code")
|
||||
btn.set_click_event (agent show_code)
|
||||
|
||||
Reference in New Issue
Block a user