Merge branch 'widget' of github.com:souvarin/EWF into widget
Conflicts: library/server/wsf_html/wsf_html-safe.ecf
This commit is contained in:
@@ -35,6 +35,8 @@ feature {NONE} -- Initialization
|
|||||||
map_agent_uri ("/", agent execute_hello, Void)
|
map_agent_uri ("/", agent execute_hello, Void)
|
||||||
map_agent_uri ("/grid", agent grid_demo, Void)
|
map_agent_uri ("/grid", agent grid_demo, Void)
|
||||||
map_agent_uri ("/widget.js", agent load_js, Void)
|
map_agent_uri ("/widget.js", agent load_js, Void)
|
||||||
|
map_agent_uri ("/widget.css", agent load_css, Void)
|
||||||
|
map_agent_uri ("/bootstrap.min.css", agent load_bootstrap, Void)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Helper: mapping
|
feature -- Helper: mapping
|
||||||
@@ -74,4 +76,20 @@ feature -- Execution
|
|||||||
res.send (f)
|
res.send (f)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
load_css (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
local
|
||||||
|
f: WSF_FILE_RESPONSE
|
||||||
|
do
|
||||||
|
create f.make_html ("widget.css")
|
||||||
|
res.send (f)
|
||||||
|
end
|
||||||
|
|
||||||
|
load_bootstrap (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
local
|
||||||
|
f: WSF_FILE_RESPONSE
|
||||||
|
do
|
||||||
|
create f.make_html ("bootstrap.min.css")
|
||||||
|
res.send (f)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
9
examples/widgetapp/bootstrap.min.css
vendored
Normal file
9
examples/widgetapp/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
48
examples/widgetapp/flag_autocompletion.e
Normal file
48
examples/widgetapp/flag_autocompletion.e
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {FLAG_AUTOCOMPLETION}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
FLAG_AUTOCOMPLETION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
WSF_AUTOCOMPLETION
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (l: ITERABLE [TUPLE [STRING, STRING]])
|
||||||
|
do
|
||||||
|
template := "<img src=%"http://www.famfamfam.com/lab/icons/flags/icons/gif/{{=flag}}.gif%"> {{=value}}";
|
||||||
|
list := l
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Implementation
|
||||||
|
|
||||||
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
local
|
||||||
|
o: JSON_OBJECT
|
||||||
|
do
|
||||||
|
create Result.make_array
|
||||||
|
across
|
||||||
|
list as c
|
||||||
|
loop
|
||||||
|
if attached {STRING} c.item.item (1) as first and attached {STRING} c.item.item (2) as second then
|
||||||
|
if second.as_lower.has_substring (input.as_lower) then
|
||||||
|
create o.make
|
||||||
|
o.put (create {JSON_STRING}.make_json (first), "flag")
|
||||||
|
o.put (create {JSON_STRING}.make_json (second), "value")
|
||||||
|
Result.add (o)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
list: ITERABLE [TUPLE [STRING, STRING]]
|
||||||
|
|
||||||
|
end
|
||||||
@@ -21,10 +21,14 @@ feature
|
|||||||
form: WSF_FORM_CONTROL
|
form: WSF_FORM_CONTROL
|
||||||
n1_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n1_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
n2_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n2_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
|
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||||
|
s: FLAG_AUTOCOMPLETION
|
||||||
do
|
do
|
||||||
|
create s.make(<<["dz", "Algeria"], ["be", "Belgium"] , ["ca", "Canada"],["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>)
|
||||||
create textbox1.make_input ("txtBox1", "1")
|
create textbox1.make_input ("txtBox1", "1")
|
||||||
create textbox2.make_input ("txtBox2", "2")
|
create textbox2.make_input ("txtBox2", "2")
|
||||||
|
create autocompletion1.make_autocomplete ("autocompletion1", s)
|
||||||
create button1.make_button ("sample_button1", "SUM")
|
create button1.make_button ("sample_button1", "SUM")
|
||||||
create textbox_result.make_html ("txtBox3", "p", "")
|
create textbox_result.make_html ("txtBox3", "p", "")
|
||||||
button1.set_click_event (agent handle_click)
|
button1.set_click_event (agent handle_click)
|
||||||
@@ -39,8 +43,10 @@ feature
|
|||||||
n1_container.add_validator (create {OWN_VALIDATOR}.make_own)
|
n1_container.add_validator (create {OWN_VALIDATOR}.make_own)
|
||||||
create n2_container.make_form_element ("Number2", textbox2)
|
create n2_container.make_form_element ("Number2", textbox2)
|
||||||
n2_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
|
n2_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
|
||||||
|
create n3_container.make_form_element ("Autoc1", autocompletion1)
|
||||||
form.add_control (n1_container)
|
form.add_control (n1_container)
|
||||||
form.add_control (n2_container)
|
form.add_control (n2_container)
|
||||||
|
form.add_control (n3_container)
|
||||||
create cats_container.make_form_element ("Categories", cklist)
|
create cats_container.make_form_element ("Categories", cklist)
|
||||||
cats_container.add_validator (create {WSF_MIN_VALIDATOR [STRING]}.make_min_validator (1, "Choose at least one category"))
|
cats_container.add_validator (create {WSF_MIN_VALIDATOR [STRING]}.make_min_validator (1, "Choose at least one category"))
|
||||||
cats_container.add_validator (create {WSF_MAX_VALIDATOR [STRING]}.make_max_validator (1, "Choose at most one category"))
|
cats_container.add_validator (create {WSF_MAX_VALIDATOR [STRING]}.make_max_validator (1, "Choose at most one category"))
|
||||||
@@ -82,6 +88,8 @@ feature
|
|||||||
|
|
||||||
textbox2: WSF_INPUT_CONTROL
|
textbox2: WSF_INPUT_CONTROL
|
||||||
|
|
||||||
|
autocompletion1: WSF_AUTOCOMPLETE_CONTROL
|
||||||
|
|
||||||
cklist: WSF_CHECKBOX_LIST_CONTROL
|
cklist: WSF_CHECKBOX_LIST_CONTROL
|
||||||
|
|
||||||
textbox_result: WSF_HTML_CONTROL
|
textbox_result: WSF_HTML_CONTROL
|
||||||
|
|||||||
@@ -1,9 +1,22 @@
|
|||||||
|
cache = {}
|
||||||
|
template = tmpl = (str, data) ->
|
||||||
|
# Simple JavaScript Templating
|
||||||
|
# John Resig - http://ejohn.org/ - MIT Licensed
|
||||||
|
fn = (if not /\W/.test(str) then cache[str] = cache[str] or tmpl(str) else new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + str.replace(/[\r\t\n]/g, " ").split("{{").join("\t").replace(/((^|}})[^\t]*)'/g, "$1\r").replace(/\t=(.*?)}}/g, "',$1,'").split("\t").join("');").split("}}").join("p.push('").split("\r").join("\\'") + "');}return p.join('');"))
|
||||||
|
(if data then fn(data) else fn)
|
||||||
|
|
||||||
|
Mini =
|
||||||
|
compile:(t)->
|
||||||
|
{
|
||||||
|
render:template(t)
|
||||||
|
}
|
||||||
|
|
||||||
trigger_callback = (control_name,event)->
|
trigger_callback = (control_name,event)->
|
||||||
$.ajax
|
$.ajax
|
||||||
data:
|
data:
|
||||||
control_name: control_name
|
control_name: control_name
|
||||||
event: event
|
event: event
|
||||||
states: JSON.stringify(states)
|
states: JSON.stringify(window.states)
|
||||||
cache: no
|
cache: no
|
||||||
.done (new_states)->
|
.done (new_states)->
|
||||||
#Update all classes
|
#Update all classes
|
||||||
@@ -113,45 +126,27 @@ class WSF_INPUT_CONTROL extends WSF_CONTROL
|
|||||||
window.states[@control_name]['text'] = state.text
|
window.states[@control_name]['text'] = state.text
|
||||||
@$el.val(state.text)
|
@$el.val(state.text)
|
||||||
|
|
||||||
class WSF_TEXTAREA_CONTROL extends WSF_CONTROL
|
class WSF_TEXTAREA_CONTROL extends WSF_INPUT_CONTROL
|
||||||
|
|
||||||
|
class WSF_AUTOCOMPLETE_CONTROL extends WSF_INPUT_CONTROL
|
||||||
attach_events: () ->
|
attach_events: () ->
|
||||||
|
super
|
||||||
self = @
|
self = @
|
||||||
@$el.change () ->
|
@$el.typeahead({
|
||||||
self.change()
|
name: @control_name
|
||||||
|
template: window.states[@control_name]['template']
|
||||||
change: () ->
|
engine: Mini
|
||||||
window.states[@control_name]['text'] = @$el.val()
|
remote:
|
||||||
if window.states[@control_name]['callback_change']
|
url:""
|
||||||
trigger_callback(@control_name, 'change')
|
replace: (url, uriEncodedQuery) ->
|
||||||
@trigger('change')
|
window.states[self.control_name]['text'] = self.$el.val()
|
||||||
|
'?' + $.param
|
||||||
value:()->
|
control_name: self.control_name
|
||||||
return @$el.val()
|
event: 'autocomplete'
|
||||||
|
states: JSON.stringify(window.states)
|
||||||
update: (state) ->
|
filter: (parsedResponse) ->
|
||||||
if state.text?
|
parsedResponse[self.control_name]['suggestions']
|
||||||
window.states[@control_name]['text'] = state.text
|
})
|
||||||
@$el.val(state.text)
|
|
||||||
|
|
||||||
class WSF_TEXTAREA_CONTROL extends WSF_CONTROL
|
|
||||||
attach_events: () ->
|
|
||||||
self = @
|
|
||||||
@$el.change () ->
|
|
||||||
self.change()
|
|
||||||
|
|
||||||
change: () ->
|
|
||||||
window.states[@control_name]['text'] = @$el.val()
|
|
||||||
if window.states[@control_name]['callback_change']
|
|
||||||
trigger_callback(@control_name, 'change')
|
|
||||||
@trigger('change')
|
|
||||||
|
|
||||||
value:()->
|
|
||||||
return @$el.val()
|
|
||||||
|
|
||||||
update: (state) ->
|
|
||||||
if state.text?
|
|
||||||
window.states[@control_name]['text'] = state.text
|
|
||||||
@$el.val(state.text)
|
|
||||||
|
|
||||||
class WSF_CHECKBOX_CONTROL extends WSF_CONTROL
|
class WSF_CHECKBOX_CONTROL extends WSF_CONTROL
|
||||||
attach_events: ()->
|
attach_events: ()->
|
||||||
@@ -257,6 +252,7 @@ typemap =
|
|||||||
"WSF_BUTTON_CONTROL":WSF_BUTTON_CONTROL
|
"WSF_BUTTON_CONTROL":WSF_BUTTON_CONTROL
|
||||||
"WSF_INPUT_CONTROL":WSF_INPUT_CONTROL
|
"WSF_INPUT_CONTROL":WSF_INPUT_CONTROL
|
||||||
"WSF_TEXTAREA_CONTROL":WSF_TEXTAREA_CONTROL
|
"WSF_TEXTAREA_CONTROL":WSF_TEXTAREA_CONTROL
|
||||||
|
"WSF_AUTOCOMPLETE_CONTROL":WSF_AUTOCOMPLETE_CONTROL
|
||||||
"WSF_CHECKBOX_CONTROL":WSF_CHECKBOX_CONTROL
|
"WSF_CHECKBOX_CONTROL":WSF_CHECKBOX_CONTROL
|
||||||
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL
|
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL
|
||||||
"WSF_HTML_CONTROL": WSF_HTML_CONTROL
|
"WSF_HTML_CONTROL": WSF_HTML_CONTROL
|
||||||
|
|||||||
77
examples/widgetapp/widget.css
Normal file
77
examples/widgetapp/widget.css
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/* ignore this line */
|
||||||
|
.container { margin:30px; }
|
||||||
|
|
||||||
|
.twitter-typeahead {
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.twitter-typeahead .tt-query,
|
||||||
|
.twitter-typeahead .tt-hint {
|
||||||
|
margin-bottom: 0;
|
||||||
|
width:100%;
|
||||||
|
height: 34px;
|
||||||
|
position: absolute;
|
||||||
|
top:0;
|
||||||
|
left:0;
|
||||||
|
}
|
||||||
|
.twitter-typeahead .tt-hint {
|
||||||
|
color:#a1a1a1;
|
||||||
|
z-index: 1;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border:1px solid transparent;
|
||||||
|
}
|
||||||
|
.twitter-typeahead .tt-query {
|
||||||
|
z-index: 2;
|
||||||
|
border-radius: 4px!important;
|
||||||
|
/* add these 2 statements if you have an appended input group */
|
||||||
|
border-top-right-radius: 0!important;
|
||||||
|
border-bottom-right-radius: 0!important;
|
||||||
|
/* add these 2 statements if you have an prepended input group */
|
||||||
|
/* border-top-left-radius: 0!important;
|
||||||
|
border-bottom-left-radius: 0!important; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-dropdown-menu {
|
||||||
|
min-width: 160px;
|
||||||
|
margin-top: 2px;
|
||||||
|
padding: 5px 0;
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border: 1px solid rgba(0,0,0,.2);
|
||||||
|
*border-right-width: 2px;
|
||||||
|
*border-bottom-width: 2px;
|
||||||
|
-webkit-border-radius: 6px;
|
||||||
|
-moz-border-radius: 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||||
|
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||||
|
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||||
|
-webkit-background-clip: padding-box;
|
||||||
|
-moz-background-clip: padding;
|
||||||
|
background-clip: padding-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-suggestion {
|
||||||
|
display: block;
|
||||||
|
padding: 3px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-suggestion.tt-is-under-cursor {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #0081c2;
|
||||||
|
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
|
||||||
|
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
|
||||||
|
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
|
||||||
|
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
|
||||||
|
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
|
||||||
|
background-repeat: repeat-x;
|
||||||
|
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-suggestion.tt-is-under-cursor a {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-suggestion p {
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
@@ -1,15 +1,35 @@
|
|||||||
// Generated by CoffeeScript 1.6.1
|
// Generated by CoffeeScript 1.6.1
|
||||||
(function() {
|
(function() {
|
||||||
var $el, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_REGEXP_VALIDATOR, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, controls, name, state, trigger_callback, type, typemap, validatormap, _ref, _ref1, _ref2,
|
var $el, Mini, WSF_AUTOCOMPLETE_CONTROL, WSF_BUTTON_CONTROL, WSF_CHECKBOX_CONTROL, WSF_CHECKBOX_LIST_CONTROL, WSF_CONTROL, WSF_FORM_ELEMENT_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_REGEXP_VALIDATOR, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, cache, controls, name, state, template, tmpl, trigger_callback, type, typemap, validatormap, _ref, _ref1, _ref2,
|
||||||
__hasProp = {}.hasOwnProperty,
|
__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; };
|
__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; };
|
||||||
|
|
||||||
|
cache = {};
|
||||||
|
|
||||||
|
template = tmpl = function(str, data) {
|
||||||
|
var fn;
|
||||||
|
fn = (!/\W/.test(str) ? cache[str] = cache[str] || tmpl(str) : new Function("obj", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(obj){p.push('" + str.replace(/[\r\t\n]/g, " ").split("{{").join("\t").replace(/((^|}})[^\t]*)'/g, "$1\r").replace(/\t=(.*?)}}/g, "',$1,'").split("\t").join("');").split("}}").join("p.push('").split("\r").join("\\'") + "');}return p.join('');"));
|
||||||
|
if (data) {
|
||||||
|
return fn(data);
|
||||||
|
} else {
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Mini = {
|
||||||
|
compile: function(t) {
|
||||||
|
return {
|
||||||
|
render: template(t)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
trigger_callback = function(control_name, event) {
|
trigger_callback = function(control_name, event) {
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
data: {
|
data: {
|
||||||
control_name: control_name,
|
control_name: control_name,
|
||||||
event: event,
|
event: event,
|
||||||
states: JSON.stringify(states)
|
states: JSON.stringify(window.states)
|
||||||
},
|
},
|
||||||
cache: false
|
cache: false
|
||||||
}).done(function(new_states) {
|
}).done(function(new_states) {
|
||||||
@@ -228,75 +248,46 @@
|
|||||||
return WSF_TEXTAREA_CONTROL.__super__.constructor.apply(this, arguments);
|
return WSF_TEXTAREA_CONTROL.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.attach_events = function() {
|
|
||||||
var self;
|
|
||||||
self = this;
|
|
||||||
return this.$el.change(function() {
|
|
||||||
return self.change();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.change = function() {
|
|
||||||
window.states[this.control_name]['text'] = this.$el.val();
|
|
||||||
if (window.states[this.control_name]['callback_change']) {
|
|
||||||
trigger_callback(this.control_name, 'change');
|
|
||||||
}
|
|
||||||
return this.trigger('change');
|
|
||||||
};
|
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.value = function() {
|
|
||||||
return this.$el.val();
|
|
||||||
};
|
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.update = function(state) {
|
|
||||||
if (state.text != null) {
|
|
||||||
window.states[this.control_name]['text'] = state.text;
|
|
||||||
return this.$el.val(state.text);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return WSF_TEXTAREA_CONTROL;
|
return WSF_TEXTAREA_CONTROL;
|
||||||
|
|
||||||
})(WSF_CONTROL);
|
})(WSF_INPUT_CONTROL);
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL = (function(_super) {
|
WSF_AUTOCOMPLETE_CONTROL = (function(_super) {
|
||||||
|
|
||||||
__extends(WSF_TEXTAREA_CONTROL, _super);
|
__extends(WSF_AUTOCOMPLETE_CONTROL, _super);
|
||||||
|
|
||||||
function WSF_TEXTAREA_CONTROL() {
|
function WSF_AUTOCOMPLETE_CONTROL() {
|
||||||
return WSF_TEXTAREA_CONTROL.__super__.constructor.apply(this, arguments);
|
return WSF_AUTOCOMPLETE_CONTROL.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.attach_events = function() {
|
WSF_AUTOCOMPLETE_CONTROL.prototype.attach_events = function() {
|
||||||
var self;
|
var self;
|
||||||
|
WSF_AUTOCOMPLETE_CONTROL.__super__.attach_events.apply(this, arguments);
|
||||||
self = this;
|
self = this;
|
||||||
return this.$el.change(function() {
|
return this.$el.typeahead({
|
||||||
return self.change();
|
name: this.control_name,
|
||||||
|
template: window.states[this.control_name]['template'],
|
||||||
|
engine: Mini,
|
||||||
|
remote: {
|
||||||
|
url: "",
|
||||||
|
replace: function(url, uriEncodedQuery) {
|
||||||
|
window.states[self.control_name]['text'] = self.$el.val();
|
||||||
|
return '?' + $.param({
|
||||||
|
control_name: self.control_name,
|
||||||
|
event: 'autocomplete',
|
||||||
|
states: JSON.stringify(window.states)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
filter: function(parsedResponse) {
|
||||||
|
return parsedResponse[self.control_name]['suggestions'];
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.change = function() {
|
return WSF_AUTOCOMPLETE_CONTROL;
|
||||||
window.states[this.control_name]['text'] = this.$el.val();
|
|
||||||
if (window.states[this.control_name]['callback_change']) {
|
|
||||||
trigger_callback(this.control_name, 'change');
|
|
||||||
}
|
|
||||||
return this.trigger('change');
|
|
||||||
};
|
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.value = function() {
|
})(WSF_INPUT_CONTROL);
|
||||||
return this.$el.val();
|
|
||||||
};
|
|
||||||
|
|
||||||
WSF_TEXTAREA_CONTROL.prototype.update = function(state) {
|
|
||||||
if (state.text != null) {
|
|
||||||
window.states[this.control_name]['text'] = state.text;
|
|
||||||
return this.$el.val(state.text);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return WSF_TEXTAREA_CONTROL;
|
|
||||||
|
|
||||||
})(WSF_CONTROL);
|
|
||||||
|
|
||||||
WSF_CHECKBOX_CONTROL = (function(_super) {
|
WSF_CHECKBOX_CONTROL = (function(_super) {
|
||||||
|
|
||||||
@@ -476,6 +467,7 @@
|
|||||||
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL,
|
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL,
|
||||||
"WSF_INPUT_CONTROL": WSF_INPUT_CONTROL,
|
"WSF_INPUT_CONTROL": WSF_INPUT_CONTROL,
|
||||||
"WSF_TEXTAREA_CONTROL": WSF_TEXTAREA_CONTROL,
|
"WSF_TEXTAREA_CONTROL": WSF_TEXTAREA_CONTROL,
|
||||||
|
"WSF_AUTOCOMPLETE_CONTROL": WSF_AUTOCOMPLETE_CONTROL,
|
||||||
"WSF_CHECKBOX_CONTROL": WSF_CHECKBOX_CONTROL,
|
"WSF_CHECKBOX_CONTROL": WSF_CHECKBOX_CONTROL,
|
||||||
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL,
|
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL,
|
||||||
"WSF_HTML_CONTROL": WSF_HTML_CONTROL,
|
"WSF_HTML_CONTROL": WSF_HTML_CONTROL,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/>
|
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/>
|
||||||
|
<library name="json" location="..\..\contrib\library\text\parser\json\library\json-safe.ecf"/>
|
||||||
<cluster name="widgetapp" location=".\" recursive="true"/>
|
<cluster name="widgetapp" location=".\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
<target name="widgetapp_cgi" extends="common">
|
<target name="widgetapp_cgi" extends="common">
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WSF_AUTOCOMPLETION}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
deferred class
|
||||||
|
WSF_AUTOCOMPLETION
|
||||||
|
|
||||||
|
feature
|
||||||
|
|
||||||
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
template: detachable STRING
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WSF_SIMPLE_AUTOCOMPLETION}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
WSF_SIMPLE_AUTOCOMPLETION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
WSF_AUTOCOMPLETION
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE}
|
||||||
|
|
||||||
|
make (l: ITERABLE [STRING])
|
||||||
|
do
|
||||||
|
list := l
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Implementation
|
||||||
|
|
||||||
|
autocompletion (input: STRING): JSON_ARRAY
|
||||||
|
local
|
||||||
|
o: JSON_OBJECT
|
||||||
|
do
|
||||||
|
create Result.make_array
|
||||||
|
across
|
||||||
|
list as c
|
||||||
|
loop
|
||||||
|
if c.item.as_lower.has_substring (input.as_lower) then
|
||||||
|
create o.make
|
||||||
|
o.put (create {JSON_STRING}.make_json (c.item), "value")
|
||||||
|
Result.add (o)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature
|
||||||
|
|
||||||
|
list: ITERABLE [STRING]
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WSF_AUTOCOMPLETE_CONTROL}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
WSF_AUTOCOMPLETE_CONTROL
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
WSF_INPUT_CONTROL
|
||||||
|
redefine
|
||||||
|
handle_callback,
|
||||||
|
state
|
||||||
|
end
|
||||||
|
|
||||||
|
create
|
||||||
|
make_autocomplete, make_autocomplete_with_agent
|
||||||
|
|
||||||
|
feature {NONE} -- Creation
|
||||||
|
|
||||||
|
make_autocomplete (n: STRING; c: WSF_AUTOCOMPLETION)
|
||||||
|
do
|
||||||
|
make_autocomplete_with_agent (n, agent c.autocompletion)
|
||||||
|
if attached c.template as t then
|
||||||
|
template := t
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
make_autocomplete_with_agent (n: STRING; c: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY])
|
||||||
|
do
|
||||||
|
make_input (n, "")
|
||||||
|
create_json_list := c
|
||||||
|
template := "{{=value}}"
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- State
|
||||||
|
|
||||||
|
state: JSON_OBJECT
|
||||||
|
do
|
||||||
|
Result := Precursor {WSF_INPUT_CONTROL}
|
||||||
|
Result.put (create {JSON_STRING}.make_json (template), create {JSON_STRING}.make_json ("template"))
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Callback
|
||||||
|
|
||||||
|
handle_callback (cname: STRING; event: STRING)
|
||||||
|
do
|
||||||
|
Precursor {WSF_INPUT_CONTROL} (cname, event)
|
||||||
|
if cname.is_equal (control_name) and event.is_equal ("autocomplete") then
|
||||||
|
state_changes.put (create_json_list.item ([text]), create {JSON_STRING}.make_json ("suggestions"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Autocomplete
|
||||||
|
|
||||||
|
create_json_list: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY]
|
||||||
|
|
||||||
|
template: STRING
|
||||||
|
|
||||||
|
end
|
||||||
@@ -5,10 +5,11 @@ note
|
|||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
class
|
class
|
||||||
WSF_max_VALIDATOR[G]
|
WSF_max_VALIDATOR [G]
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
WSF_VALIDATOR [LIST[G]]
|
|
||||||
|
WSF_VALIDATOR [LIST [G]]
|
||||||
redefine
|
redefine
|
||||||
state
|
state
|
||||||
end
|
end
|
||||||
@@ -18,7 +19,7 @@ create
|
|||||||
|
|
||||||
feature {NONE}
|
feature {NONE}
|
||||||
|
|
||||||
make_max_validator (m:INTEGER; e: STRING)
|
make_max_validator (m: INTEGER; e: STRING)
|
||||||
do
|
do
|
||||||
make (e)
|
make (e)
|
||||||
max := m
|
max := m
|
||||||
@@ -26,10 +27,9 @@ feature {NONE}
|
|||||||
|
|
||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
is_valid (input:LIST[G]): BOOLEAN
|
is_valid (input: LIST [G]): BOOLEAN
|
||||||
do
|
do
|
||||||
Result:= input.count < max or input.count = max
|
Result := input.count < max or input.count = max
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
feature --EVENT HANDLING
|
feature --EVENT HANDLING
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING)
|
handle_callback (cname: STRING; event: STRING)
|
||||||
-- Method called if any callback recived. In this method you can route the callback to the event handler
|
-- Method called if any callback received. In this method you can route the callback to the event handler
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -77,13 +77,15 @@ feature
|
|||||||
create states.make
|
create states.make
|
||||||
control.read_state (states)
|
control.read_state (states)
|
||||||
data := "<html><head>"
|
data := "<html><head>"
|
||||||
data.append ("<link href=%"//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css%" rel=%"stylesheet%">")
|
data.append ("<link href=%"/bootstrap.min.css%" rel=%"stylesheet%">")
|
||||||
|
data.append ("<link href=%"/widget.css%" rel=%"stylesheet%">")
|
||||||
data.append ("</head><body>")
|
data.append ("</head><body>")
|
||||||
data.append (control.render)
|
data.append (control.render)
|
||||||
data.append ("<script type=%"text/javascript%">window.states=")
|
data.append ("<script type=%"text/javascript%">window.states=")
|
||||||
data.append (states.representation)
|
data.append (states.representation)
|
||||||
data.append (";</script>")
|
data.append (";</script>")
|
||||||
data.append ("<script src=%"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js%"></script>")
|
data.append ("<script src=%"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js%"></script>")
|
||||||
|
data.append ("<script src=%"//cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.9.3/typeahead.min.js%"></script>")
|
||||||
data.append ("<script src=%"/widget.js%"></script>")
|
data.append ("<script src=%"/widget.js%"></script>")
|
||||||
data.append ("</body></html>")
|
data.append ("</body></html>")
|
||||||
create page.make
|
create page.make
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<cluster name="validators" location=".\webcontrol\validators\"/>
|
<cluster name="validators" location=".\webcontrol\validators\"/>
|
||||||
<cluster name="input" location=".\webcontrol\input\"/>
|
<cluster name="input" location=".\webcontrol\input\"/>
|
||||||
<cluster name="grid" location=".\webcontrol\grid\"/>
|
<cluster name="grid" location=".\webcontrol\grid\"/>
|
||||||
|
<cluster name="autocompletions" location=".\webcontrol\autocompletions\"/>
|
||||||
</cluster>
|
</cluster>
|
||||||
<cluster name="widget" location=".\widget\" recursive="true"/>
|
<cluster name="widget" location=".\widget\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
Reference in New Issue
Block a user