From 09544ba6d2b40e2a31917b1307260e6b63b42507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Severin=20M=C3=BCnger?= Date: Fri, 13 Sep 2013 23:24:49 +0200 Subject: [PATCH] Fixed rendering, added navbar --- examples/widgetapp/demo_datasource.e | 2 +- examples/widgetapp/sample_page.e | 8 ++- examples/widgetapp/widget.css | 5 +- .../webcontrol/navbar/wsf_navbar_control.e | 20 ++++++-- .../wsf_html/webcontrol/wsf_basic_control.e | 49 +++++++++++++++++++ .../server/wsf_html/webcontrol/wsf_control.e | 2 +- .../wsf_html/webcontrol/wsf_multi_control.e | 24 ++++++--- .../webcontrol/wsf_stateless_control.e | 9 +--- 8 files changed, 96 insertions(+), 23 deletions(-) create mode 100644 library/server/wsf_html/webcontrol/wsf_basic_control.e diff --git a/examples/widgetapp/demo_datasource.e b/examples/widgetapp/demo_datasource.e index 50cbb30c..87f9f4ec 100644 --- a/examples/widgetapp/demo_datasource.e +++ b/examples/widgetapp/demo_datasource.e @@ -30,7 +30,7 @@ feature across ((page - 1) * page_size) |..| (page * page_size - 1) as c loop - list.extend (create {DEMO_DATA}.make(c.item,"Name"+c.item.out,"desc "+c.item.out)) + list.extend (create {DEMO_DATA}.make (c.item, "Name" + c.item.out, "desc " + c.item.out)) end Result := list end diff --git a/examples/widgetapp/sample_page.e b/examples/widgetapp/sample_page.e index 5d626c98..90c6b1a7 100644 --- a/examples/widgetapp/sample_page.e +++ b/examples/widgetapp/sample_page.e @@ -18,6 +18,8 @@ feature initialize_controls local + container: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL] + navbar: WSF_NAVBAR_CONTROL form: WSF_FORM_CONTROL n1_container: WSF_FORM_ELEMENT_CONTROL [STRING] n2_container: WSF_FORM_ELEMENT_CONTROL [STRING] @@ -26,6 +28,8 @@ feature s: FLAG_AUTOCOMPLETION do create s.make(<<["dz", "Algeria"], ["be", "Belgium"] , ["ca", "Canada"],["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>) + create container.make_multi_control ("container") + create navbar.make_navbar ("Sample Page") create textbox1.make_input ("txtBox1", "1") create textbox2.make_input ("txtBox2", "2") create autocompletion1.make_autocomplete ("autocompletion1", s) @@ -53,7 +57,9 @@ feature form.add_control (cats_container) form.add_control (button1) form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING]}.make_form_element ("Result", textbox_result)) - control := form + container.add_control (navbar) + container.add_control (form) + control := container end handle_click diff --git a/examples/widgetapp/widget.css b/examples/widgetapp/widget.css index a915272e..cc8042c2 100644 --- a/examples/widgetapp/widget.css +++ b/examples/widgetapp/widget.css @@ -1,5 +1,6 @@ -/* ignore this line */ -.container { margin:30px; } +body { + padding-top: 30px; +} .twitter-typeahead { width: 100%; diff --git a/library/server/wsf_html/webcontrol/navbar/wsf_navbar_control.e b/library/server/wsf_html/webcontrol/navbar/wsf_navbar_control.e index 343333e8..435df76c 100644 --- a/library/server/wsf_html/webcontrol/navbar/wsf_navbar_control.e +++ b/library/server/wsf_html/webcontrol/navbar/wsf_navbar_control.e @@ -22,11 +22,13 @@ feature feature {NONE} -- Initialization - make_navbar (brand: STRING) + make_navbar (b: STRING) local container: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] header: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] collapse_button: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] + brand: WSF_BASIC_CONTROL + icon_bar: WSF_BASIC_CONTROL do make_multi_control add_class ("navbar navbar-inverse navbar-fixed-top") @@ -34,11 +36,23 @@ feature {NONE} -- Initialization create header.make_multi_control create collapse_button.make_with_tag_name ("button") create collapse.make_multi_control - create nav.make_multi_control + create nav.make_with_tag_name ("ul") + create brand.make_control ("a") + create icon_bar.make_control ("span") container.add_class ("container") header.add_class ("navbar-header") collapse_button.add_class ("navbar-toggle") - collapse_button.set_attributes ("data-target=%".navbar-collapse%" data-toggle=%"collapse%" type=%"button%"") + icon_bar.add_class ("icon-bar") + collapse_button.add_control (icon_bar) + collapse_button.add_control (icon_bar) + collapse_button.add_control (icon_bar) + --collapse_button.set_attributes ("data-target=%".navbar-collapse%" data-toggle=%"collapse%" type=%"button%"") + brand.add_class ("navbar-brand") + brand.set_attributes ("href=%"#%"") + brand.set_content (b) + header.add_control (collapse_button) + header.add_control (brand) + nav.add_class ("nav navbar-nav") collapse.add_class ("navbar-collapse") collapse.add_control (nav) container.add_control (header) diff --git a/library/server/wsf_html/webcontrol/wsf_basic_control.e b/library/server/wsf_html/webcontrol/wsf_basic_control.e new file mode 100644 index 00000000..9b423a3e --- /dev/null +++ b/library/server/wsf_html/webcontrol/wsf_basic_control.e @@ -0,0 +1,49 @@ +note + description: "Summary description for {WSF_BASIC_CONTROL}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_BASIC_CONTROL + +inherit + + WSF_STATELESS_CONTROL + +create + make_control + +feature {NONE} -- Initialization + + attributes: STRING + + content: STRING + + make_control (t: STRING) + do + make (t) + attributes := "" + content := "" + end + +feature -- Rendering + + render: STRING + do + Result := render_tag (content, attributes) + end + +feature + + set_attributes (a: STRING) + do + attributes := a + end + + set_content (c: STRING) + do + content := c + end + +end diff --git a/library/server/wsf_html/webcontrol/wsf_control.e b/library/server/wsf_html/webcontrol/wsf_control.e index 54c40ccd..8f1dadc9 100644 --- a/library/server/wsf_html/webcontrol/wsf_control.e +++ b/library/server/wsf_html/webcontrol/wsf_control.e @@ -1,4 +1,4 @@ -note + note description: "Summary description for {WSF_CONTROL}." author: "" date: "$Date$" diff --git a/library/server/wsf_html/webcontrol/wsf_multi_control.e b/library/server/wsf_html/webcontrol/wsf_multi_control.e index 3f11a0d4..b31c7f39 100644 --- a/library/server/wsf_html/webcontrol/wsf_multi_control.e +++ b/library/server/wsf_html/webcontrol/wsf_multi_control.e @@ -5,7 +5,7 @@ note revision: "$Revision$" class - WSF_MULTI_CONTROL [G -> WSF_CONTROL] + WSF_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL] inherit @@ -23,7 +23,7 @@ feature {NONE} -- Initialization make_multi_control (n: STRING) do - make_with_tag_name(n, "div") + make_with_tag_name (n, "div") end make_with_tag_name (n, t: STRING) @@ -41,7 +41,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT across controls as c loop - c.item.load_state (new_states) + if attached {WSF_CONTROL} c.item as cont then + cont.load_state (new_states) + end end end @@ -50,7 +52,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT across controls as c loop - c.item.set_state (new_state) + if attached {WSF_CONTROL} c.item as cont then + cont.set_state (new_state) + end end end @@ -61,7 +65,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT across controls as c loop - c.item.read_state (states) + if attached {WSF_CONTROL} c.item as cont then + cont.read_state (states) + end end end @@ -72,7 +78,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT across controls as c loop - c.item.read_state_changes (states) + if attached {WSF_CONTROL} c.item as cont then + cont.read_state_changes (states) + end end end @@ -92,7 +100,9 @@ feature --EVENT HANDLING across controls as c loop - c.item.handle_callback (cname, event) + if attached {WSF_CONTROL} c.item as cont then + cont.handle_callback (cname, event) + end end end end diff --git a/library/server/wsf_html/webcontrol/wsf_stateless_control.e b/library/server/wsf_html/webcontrol/wsf_stateless_control.e index e317808e..4c033a75 100644 --- a/library/server/wsf_html/webcontrol/wsf_stateless_control.e +++ b/library/server/wsf_html/webcontrol/wsf_stateless_control.e @@ -15,8 +15,6 @@ feature --TODO: Maybe improve - attributes: detachable STRING - feature {NONE} make (a_tag_name: STRING) @@ -29,11 +27,6 @@ feature {NONE} feature - set_attributes (a: STRING) - do - attributes := a - end - add_class (c: STRING) do css_classes.extend (c) @@ -61,7 +54,7 @@ feature l_attributes := l_attributes + " class=%"" + css_classes_string + "%"" end Result := "<" + tag + " " + l_attributes - if body.is_empty and not tag.is_equal ("textarea") then + if body.is_empty and not tag.is_equal ("textarea") and not tag.is_equal ("span") and not tag.is_equal ("button") then Result := Result + " />" else Result := Result + " >" + body + ""