From 0721384b60878e42da22177aa41f3869c35a7139 Mon Sep 17 00:00:00 2001 From: YNH Webdev Date: Fri, 8 Nov 2013 09:27:56 +0100 Subject: [PATCH] Adjust layout control and fix navlist --- .../wsf_js_widget/kernel/navlist/wsf_navlist_item.e | 10 +++++++--- .../kernel/webcontrol/wsf_layout_control.e | 12 +++++++++--- examples/widgetapp/assets/widget.coffee | 1 + examples/widgetapp/assets/widget.js | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/draft/library/wsf_js_widget/kernel/navlist/wsf_navlist_item.e b/draft/library/wsf_js_widget/kernel/navlist/wsf_navlist_item.e index f589313e..ee0d51cd 100644 --- a/draft/library/wsf_js_widget/kernel/navlist/wsf_navlist_item.e +++ b/draft/library/wsf_js_widget/kernel/navlist/wsf_navlist_item.e @@ -22,19 +22,20 @@ create feature {NONE} -- Initialization - make ( link, t: STRING) + make (link, t: STRING) do make_control ("a") text := t attributes := "href=%"" + link + "%""; add_class ("list-group-item") end + feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management set_state (new_state: JSON_OBJECT) -- Restore text from json do - Precursor {WSF_BUTTON_CONTROL}(new_state) + Precursor {WSF_BUTTON_CONTROL} (new_state) if attached {JSON_BOOLEAN} new_state.item ("active") as new_active then active := new_active.item end @@ -44,7 +45,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management -- Return state which contains the current text and if there is an event handle attached do Result := Precursor {WSF_BUTTON_CONTROL} - Result.put_boolean (true, "active") + Result.put_boolean (active, "active") end feature -- Change @@ -52,9 +53,12 @@ feature -- Change set_active (a: BOOLEAN) -- Set text of that button do + if active /= a then active := a state_changes.replace (create {JSON_BOOLEAN}.make_boolean (a), "active") + end end + feature -- Properties active: BOOLEAN diff --git a/draft/library/wsf_js_widget/kernel/webcontrol/wsf_layout_control.e b/draft/library/wsf_js_widget/kernel/webcontrol/wsf_layout_control.e index 1ff8c24c..0ce05128 100644 --- a/draft/library/wsf_js_widget/kernel/webcontrol/wsf_layout_control.e +++ b/draft/library/wsf_js_widget/kernel/webcontrol/wsf_layout_control.e @@ -12,7 +12,7 @@ inherit WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] rename make as make_multi_control, - add_control as add_control_raw + add_control as add_control_raw end create @@ -38,13 +38,19 @@ feature -- Add control add_control_raw (div) end - add_control (c: WSF_STATELESS_CONTROL; span: INTEGER) + add_control (col:INTEGER; c: WSF_STATELESS_CONTROL) + do + if attached {WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]}controls[col] as div then + div.add_control (c) + end + end + + add_column (span:INTEGER) local div: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] do create div.make_with_tag_name ("div") div.add_class ("col-md-" + span.out) - div.add_control (c) add_control_raw (div) end diff --git a/examples/widgetapp/assets/widget.coffee b/examples/widgetapp/assets/widget.coffee index a4847fe4..939e7360 100644 --- a/examples/widgetapp/assets/widget.coffee +++ b/examples/widgetapp/assets/widget.coffee @@ -358,6 +358,7 @@ class WSF_NAVLIST_ITEM_CONTROL extends WSF_BUTTON_CONTROL update: (state) -> super if state.active? + @state['active'] = state.active if state.active @$el.addClass("active") else diff --git a/examples/widgetapp/assets/widget.js b/examples/widgetapp/assets/widget.js index 00281b07..a3f197e3 100644 --- a/examples/widgetapp/assets/widget.js +++ b/examples/widgetapp/assets/widget.js @@ -598,6 +598,7 @@ WSF_NAVLIST_ITEM_CONTROL = (function(_super) { WSF_NAVLIST_ITEM_CONTROL.prototype.update = function(state) { WSF_NAVLIST_ITEM_CONTROL.__super__.update.apply(this, arguments); if (state.active != null) { + this.state['active'] = state.active; if (state.active) { return this.$el.addClass("active"); } else {