diff --git a/draft/library/wsf_js_widget/kernel/dropdown/wsf_dropdown_control.e b/draft/library/wsf_js_widget/kernel/dropdown/wsf_dropdown_control.e index 3693c02a..c7001da8 100644 --- a/draft/library/wsf_js_widget/kernel/dropdown/wsf_dropdown_control.e +++ b/draft/library/wsf_js_widget/kernel/dropdown/wsf_dropdown_control.e @@ -9,7 +9,7 @@ class inherit - WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL] + WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL] rename make as make_multi_control, make_with_tag_name as make_multi_control_with_tag_name diff --git a/draft/library/wsf_js_widget/kernel/webcontrol/wsf_control.e b/draft/library/wsf_js_widget/kernel/webcontrol/wsf_control.e index c65d7d9b..c7fffb10 100644 --- a/draft/library/wsf_js_widget/kernel/webcontrol/wsf_control.e +++ b/draft/library/wsf_js_widget/kernel/webcontrol/wsf_control.e @@ -33,38 +33,41 @@ feature {NONE} -- Initialization feature -- Actions - start_modal (url: STRING; title: STRING) + start_modal (url: STRING; title: STRING; big: BOOLEAN) --Start a modal window containg an other or the same page local modal: WSF_JSON_OBJECT do create modal.make - modal.put_string ("start_modal", "type") + if big then + modal.put_string ("start_modal_big", "type") + else + modal.put_string ("start_modal", "type") + end modal.put_string (url, "url") modal.put_string (title, "title") actions.add (modal) end - start_modal_big (url: STRING; title: STRING) - --Start a modal window containg an other or the same page - local - modal: WSF_JSON_OBJECT - do - create modal.make - modal.put_string ("start_modal_big", "type") - modal.put_string (url, "url") - modal.put_string (title, "title") - actions.add (modal) - end - - show_alert (mesage: STRING) + show_alert (message: STRING) --Start a modal window containg an other or the same page local modal: WSF_JSON_OBJECT do create modal.make modal.put_string ("show_alert", "type") - modal.put_string (mesage, "message") + modal.put_string (message, "message") + actions.add (modal) + end + + redirect (url: STRING) + --Redirect to an other page + local + modal: WSF_JSON_OBJECT + do + create modal.make + modal.put_string ("redirect", "type") + modal.put_string (url, "url") actions.add (modal) end diff --git a/examples/widgetapp/assets/widget.coffee b/examples/widgetapp/assets/widget.coffee index 289bab4d..aed793aa 100644 --- a/examples/widgetapp/assets/widget.coffee +++ b/examples/widgetapp/assets/widget.coffee @@ -79,6 +79,7 @@ parseSuggestions = (data)-> return d return null loaded = {} + lazy_load = (requirements,fn,that)-> if requirements.length == 0 return ()-> @@ -249,8 +250,6 @@ class WSF_CONTROL cache: no .done (new_states)-> #Update all classes - if new_states.actions? - self.process_actions(new_states.actions) self.get_page().process_update(new_states) #Simple event listener @@ -290,13 +289,14 @@ class WSF_PAGE_CONTROL extends WSF_CONTROL @load_subcontrols() process_update: (new_states)-> + if new_states.actions? + @process_actions(new_states.actions) for control in @controls if control? control.process_update(new_states) return - get_full_control_name: ()-> "" @@ -599,6 +599,8 @@ class WSF_REPEATER_CONTROL extends WSF_CONTROL #### actions +redirect = (action) -> + document.location.href = action.url show_alert = (action)-> alert(action.message) diff --git a/examples/widgetapp/assets/widget.js b/examples/widgetapp/assets/widget.js index abfe580e..a4215d29 100644 --- a/examples/widgetapp/assets/widget.js +++ b/examples/widgetapp/assets/widget.js @@ -1,5 +1,5 @@ // Generated by CoffeeScript 1.6.1 -var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PASSWORD_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, show_alert, start_modal, start_modal_big, template, tmpl, +var Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CODEVIEW_CONTROL, WSF_CONTROL, WSF_DROPDOWN_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_NAVLIST_ITEM_CONTROL, WSF_PAGE_CONTROL, WSF_PAGINATION_CONTROL, WSF_PASSWORD_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_SLIDER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, build_control, cache, controls, lazy_load, loaded, parseSuggestions, redirect, show_alert, start_modal, start_modal_big, template, tmpl, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; @@ -394,9 +394,6 @@ WSF_CONTROL = (function() { contentType: 'application/json', cache: false }).done(function(new_states) { - if (new_states.actions != null) { - self.process_actions(new_states.actions); - } return self.get_page().process_update(new_states); }); }; @@ -456,6 +453,9 @@ WSF_PAGE_CONTROL = (function(_super) { WSF_PAGE_CONTROL.prototype.process_update = function(new_states) { var control, _i, _len, _ref; + if (new_states.actions != null) { + this.process_actions(new_states.actions); + } _ref = this.controls; for (_i = 0, _len = _ref.length; _i < _len; _i++) { control = _ref[_i]; @@ -1029,6 +1029,10 @@ WSF_REPEATER_CONTROL = (function(_super) { })(WSF_CONTROL); +redirect = function(action) { + return document.location.href = action.url; +}; + show_alert = function(action) { return alert(action.message); }; diff --git a/examples/widgetapp/base_page.e b/examples/widgetapp/base_page.e index 6602a52e..7e05d5d1 100644 --- a/examples/widgetapp/base_page.e +++ b/examples/widgetapp/base_page.e @@ -46,7 +46,7 @@ feature show_code do - start_modal_big ("/codeview?file=" + generator.as_lower, "Eiffel code " + generator) + start_modal ("/codeview?file=" + generator.as_lower, "Eiffel code " + generator, true) end feature diff --git a/examples/widgetapp/sample_page.e b/examples/widgetapp/sample_page.e index c7b70f15..9015dc24 100644 --- a/examples/widgetapp/sample_page.e +++ b/examples/widgetapp/sample_page.e @@ -71,7 +71,7 @@ feature form.add_control (button1) --Button 2 create button2.make ("Start Modal Grid") - button2.set_click_event (agent handle_click) + button2.set_click_event (agent run_modal) form.add_control (button2) --Result create result_html.make ("p", "") @@ -109,6 +109,11 @@ feature end end + run_modal + do + start_modal("/","Test Modal", true); + end + process do end