Removed add_dropdown methods from navbar, some cleanup in different controls

This commit is contained in:
severin
2014-01-04 13:43:51 +01:00
parent e675e8aad9
commit c9599f449f
6 changed files with 20 additions and 47 deletions

View File

@@ -31,9 +31,10 @@ feature {NONE} -- Initialization
do do
make_multi_control_with_tag_name (t) make_multi_control_with_tag_name (t)
add_class ("dropdown") 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 {WSF_BASIC_CONTROL} dropdown_toggle.make_with_body_class ("a", "data-toggle=%"dropdown%" href=%"#%" type=%"button%" id=%"" + control_name + "_toggle%"", "dropdown-toggle", title + " <strong class=%"caret%"></strong>")
create dropdown_menu.make_with_tag_name ("ul") create dropdown_menu.make_with_tag_name ("ul")
dropdown_menu.add_class ("dropdown-menu") dropdown_menu.add_class ("dropdown-menu")
dropdown_menu.append_attribute ("role=%"menu%" aria-labelledby=%"" + control_name + "_toggle%"")
add_control (dropdown_toggle) add_control (dropdown_toggle)
add_control (dropdown_menu) add_control (dropdown_menu)
end end
@@ -46,6 +47,7 @@ feature -- Change
do do
create li.make_with_tag_name ("li") create li.make_with_tag_name ("li")
li.append_attribute ("role=%"presentation%"") li.append_attribute ("role=%"presentation%"")
c.append_attribute ("role=%"menuitem%" tabindex=%"-1%"")
li.add_control (c) li.add_control (c)
dropdown_menu.add_control (li) dropdown_menu.add_control (li)
end end

View File

@@ -29,8 +29,8 @@ feature {NONE} -- Initialization
add_class ("navbar navbar-inverse navbar-fixed-top") add_class ("navbar navbar-inverse navbar-fixed-top")
create nav.make_with_tag_name ("ul") create nav.make_with_tag_name ("ul")
create nav_right.make_with_tag_name ("ul") create nav_right.make_with_tag_name ("ul")
controls.extend (nav) add_control (nav)
controls.extend (nav_right) add_control (nav_right)
nav.add_class ("nav navbar-nav") nav.add_class ("nav navbar-nav")
nav_right.add_class ("nav navbar-nav navbar-right") nav_right.add_class ("nav navbar-nav navbar-right")
end end
@@ -80,30 +80,6 @@ feature -- Change
active_set := true active_set := true
end end
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 ("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 ("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_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

View File

@@ -25,24 +25,22 @@ create
feature {NONE} -- Initialization feature {NONE} -- Initialization
make (a_label: STRING; c: WSF_VALUE_CONTROL [G]) make (a_label: detachable STRING; c: WSF_VALUE_CONTROL [G])
-- Initialize form element control with a specific label and value control -- Initialize form element control with a specific label and value control
do do
make_with_validators (a_label, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0)) make_with_validators (a_label, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
end end
make_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]]) make_with_validators (a_label: detachable STRING; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]])
-- Initialize form element control with a specific label, value control and list of validators -- Initialize form element control with a specific label, value control and list of validators
do do
make_control ("div") make_control ("div")
add_class ("form-group") add_class ("form-group")
if not attached {WSF_VALUE_CONTROL [LIST [ANY]]} c then if not attached {WSF_VALUE_CONTROL [LIST [ANY]]} c then
c.add_class ("form-control") c.add_class ("form-control")
else else
c.add_class ("form-control-static") c.add_class ("form-control-static")
end end
label_width := 2 label_width := 2
value_control := c value_control := c
validators := v validators := v
@@ -146,10 +144,12 @@ feature -- Implementation
body: STRING body: STRING
do do
body := "" body := ""
if not label.is_empty then if attached label as l and then not l.is_empty then
body.append ("<label class=%"col-lg-"+label_width.out+" control-label%" for=%"" + value_control.control_name + "%">" + label + "</label>") body.append ("<label class=%"col-lg-" + label_width.out + " control-label%" for=%"" + value_control.control_name + "%">" + l + "</label>")
end
body.append ("<div class=%"col-lg-" + (12 - label_width).out + "%">") body.append ("<div class=%"col-lg-" + (12 - label_width).out + "%">")
else
body.append ("<div class=%"col-lg-12%">")
end
body.append (value_control.render) body.append (value_control.render)
body.append ("</div>") body.append ("</div>")
Result := render_tag (body, "") Result := render_tag (body, "")
@@ -203,7 +203,7 @@ feature -- Properties
validators: LIST [WSF_VALIDATOR [G]] validators: LIST [WSF_VALIDATOR [G]]
-- The validators which check the input when validaton is performed -- The validators which check the input when validaton is performed
label: STRING label: detachable STRING
-- The label of this form element control -- The label of this form element control
error: STRING error: STRING

View File

@@ -164,7 +164,7 @@ feature -- Rendering
Result := Result + c.item.render Result := Result + c.item.render
end end
if not tag_name.is_empty then if not tag_name.is_empty then
Result := render_tag (Result, "") Result := render_tag (Result, attributes)
end end
end end

View File

@@ -86,6 +86,7 @@ feature -- Rendering
l_attributes.append_character ('%"') l_attributes.append_character ('%"')
end end
Result := "<" + tag + " " + l_attributes Result := "<" + tag + " " + l_attributes
-- Check if we have to render a body. For some elements, this is not the case (like textareas) or only if the body is not empty.
if body.is_empty and not tag.same_string ("textarea") and not tag.same_string ("span") and not tag.same_string ("button") and not tag.same_string ("ul") and not tag.same_string ("div") then if body.is_empty and not tag.same_string ("textarea") and not tag.same_string ("span") and not tag.same_string ("button") and not tag.same_string ("ul") and not tag.same_string ("div") then
Result.append (" />") Result.append (" />")
else else
@@ -96,11 +97,7 @@ feature -- Rendering
render_tag_with_body (body: STRING): STRING render_tag_with_body (body: STRING): STRING
-- Generate HTML of this control with the specified body -- Generate HTML of this control with the specified body
do do
if attached attributes as attrs then Result := render_tag (body, attributes)
Result := render_tag (body, attrs)
else
Result := render_tag (body, "")
end
end end
render: STRING render: STRING

View File

@@ -1,4 +1,3 @@
note note
description: "Summary description for {WSF_STATELESS_MULTI_CONTROL}." description: "Summary description for {WSF_STATELESS_MULTI_CONTROL}."
author: "" author: ""
@@ -38,8 +37,6 @@ feature {NONE} -- Initialization
feature feature
set_control_id (d: INTEGER) set_control_id (d: INTEGER)
do do
control_id := d control_id := d
@@ -74,6 +71,7 @@ feature
d.control_name_prefix := control_name_prefix + control_id.out + "_" d.control_name_prefix := control_name_prefix + control_id.out + "_"
end end
end end
feature -- Event handling feature -- Event handling
handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY) handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY)