Merge branch 'widget_grid' into widget
Conflicts: examples/widgetapp/widget.coffee examples/widgetapp/widget.js
This commit is contained in:
@@ -34,6 +34,7 @@ feature {NONE} -- Initialization
|
||||
-- router.map (create {WSF_URI_MAPPING}.make ("/hello", create {WSF_AGENT_URI_HANDLER}.make (agent execute_hello)))
|
||||
map_agent_uri ("/", agent execute_hello, Void)
|
||||
map_agent_uri ("/grid", agent grid_demo, Void)
|
||||
map_agent_uri ("/repeater", agent repeater_demo, 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)
|
||||
@@ -68,6 +69,16 @@ feature -- Execution
|
||||
page.execute
|
||||
end
|
||||
|
||||
repeater_demo (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
page: REPEATER_PAGE
|
||||
do
|
||||
-- To send a response we need to setup, the status code and
|
||||
-- the response headers.
|
||||
create page.make (req, res)
|
||||
page.execute
|
||||
end
|
||||
|
||||
load_js (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
local
|
||||
f: WSF_FILE_RESPONSE
|
||||
|
||||
@@ -21,6 +21,7 @@ feature {NONE}
|
||||
id := a_id
|
||||
name := a_name
|
||||
description := a_description
|
||||
image := "http://placehold.it/20x20&text=" + id.out
|
||||
end
|
||||
|
||||
feature
|
||||
@@ -31,6 +32,8 @@ feature
|
||||
|
||||
description: STRING
|
||||
|
||||
image: STRING
|
||||
|
||||
get (field: STRING): detachable ANY
|
||||
do
|
||||
if field.is_equal ("id") then
|
||||
@@ -39,6 +42,8 @@ feature
|
||||
Result := name
|
||||
elseif field.is_equal ("description") then
|
||||
Result := description
|
||||
elseif field.is_equal ("image") then
|
||||
Result := image
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class
|
||||
|
||||
inherit
|
||||
|
||||
WSF_DATASOURCE [DEMO_DATA]
|
||||
WSF_PAGABLE_DATASOURCE [DEMO_DATA]
|
||||
|
||||
create
|
||||
make_demo
|
||||
@@ -28,11 +28,12 @@ feature
|
||||
do
|
||||
create list.make
|
||||
across
|
||||
((page - 1) * page_size) |..| (page * page_size - 1) as c
|
||||
((page - 1) * page_size + 1) |..| (page * page_size).min (131) as c
|
||||
loop
|
||||
list.extend (create {DEMO_DATA}.make (c.item, "Name" + c.item.out, "desc " + c.item.out))
|
||||
end
|
||||
Result := list
|
||||
row_count := 132
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {DEMO_PROGRESSSOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
DEMO_PROGRESSSOURCE
|
||||
|
||||
inherit
|
||||
|
||||
WSF_PROGRESSSOURCE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
prog := 20
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
progress: INTEGER
|
||||
do
|
||||
if prog < 100 then
|
||||
prog := prog + 1
|
||||
end
|
||||
Result := prog
|
||||
end
|
||||
|
||||
prog: INTEGER
|
||||
|
||||
end
|
||||
72
examples/widgetapp/google_autocompletion.e
Normal file
72
examples/widgetapp/google_autocompletion.e
Normal file
@@ -0,0 +1,72 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_AUTOCOMPLETION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
GOOGLE_AUTOCOMPLETION
|
||||
|
||||
inherit
|
||||
|
||||
WSF_AUTOCOMPLETION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make ()
|
||||
do
|
||||
template := "{{=value}}";
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
autocompletion (input: STRING): JSON_ARRAY
|
||||
local
|
||||
o: JSON_OBJECT
|
||||
l_result: INTEGER
|
||||
l_curl_string: CURL_STRING
|
||||
json_parser: JSON_PARSER
|
||||
query_str: STRING
|
||||
do
|
||||
query_str := input
|
||||
query_str.replace_substring_all (" ", "+")
|
||||
curl_handle := curl_easy.init
|
||||
create Result.make_array
|
||||
if curl_handle /= default_pointer then
|
||||
create l_curl_string.make_empty
|
||||
curl_easy.setopt_string (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_url, "http://google.com/complete/search?client=chrome&q=" + query_str)
|
||||
curl_easy.set_write_function (curl_handle)
|
||||
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_writedata, l_curl_string.object_id)
|
||||
l_result := curl_easy.perform (curl_handle)
|
||||
|
||||
-- Always cleanup
|
||||
curl_easy.cleanup (curl_handle)
|
||||
create json_parser.make_parser (l_curl_string.out)
|
||||
if attached {JSON_ARRAY} json_parser.parse_json as data and then attached {JSON_ARRAY} data.i_th (2) as list then
|
||||
across
|
||||
1 |..| list.count as c
|
||||
loop
|
||||
if attached {JSON_STRING} list.i_th (c.item) as row then
|
||||
create o.make
|
||||
o.put (create {JSON_STRING}.make_json (row.unescaped_string_32), "value")
|
||||
Result.add (o)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
curl_easy: CURL_EASY_EXTERNALS
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
curl_handle: POINTER;
|
||||
-- cURL handle
|
||||
|
||||
end
|
||||
51
examples/widgetapp/google_news.e
Normal file
51
examples/widgetapp/google_news.e
Normal file
@@ -0,0 +1,51 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_NEWS}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
GOOGLE_NEWS
|
||||
|
||||
inherit
|
||||
|
||||
WSF_ENTITY
|
||||
|
||||
create
|
||||
make_from_json
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_from_json (json: JSON_OBJECT)
|
||||
do
|
||||
if attached {JSON_STRING} json.item (create {JSON_STRING}.make_json ("title")) as a_title then
|
||||
title := a_title.unescaped_string_32
|
||||
end
|
||||
if attached {JSON_STRING} json.item (create {JSON_STRING}.make_json ("content")) as a_content then
|
||||
content := a_content.unescaped_string_32
|
||||
end
|
||||
if attached {JSON_OBJECT} json.item (create {JSON_STRING}.make_json ("image")) as img and then attached {JSON_STRING} img.item (create {JSON_STRING}.make_json ("url")) as a_image then
|
||||
image := a_image.item
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
title: detachable STRING
|
||||
|
||||
content: detachable STRING
|
||||
|
||||
image: detachable STRING
|
||||
|
||||
get (field: STRING): detachable ANY
|
||||
do
|
||||
if field.is_equal ("title") then
|
||||
Result := title
|
||||
elseif field.is_equal ("content") then
|
||||
Result := content
|
||||
elseif field.is_equal ("image") then
|
||||
Result := image
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
107
examples/widgetapp/google_news_datasource.e
Normal file
107
examples/widgetapp/google_news_datasource.e
Normal file
@@ -0,0 +1,107 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_NEWS_DATASOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
GOOGLE_NEWS_DATASOURCE
|
||||
|
||||
inherit
|
||||
|
||||
WSF_PAGABLE_DATASOURCE [GOOGLE_NEWS]
|
||||
redefine
|
||||
state,
|
||||
set_state
|
||||
end
|
||||
|
||||
create
|
||||
make_news
|
||||
|
||||
feature --States
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
do
|
||||
Result := Precursor
|
||||
Result.put (create {JSON_STRING}.make_json (query), create {JSON_STRING}.make_json ("query"))
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
Precursor (new_state)
|
||||
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("query")) as new_query then
|
||||
query := new_query.item
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
make_news
|
||||
do
|
||||
page := 1
|
||||
page_size := 8
|
||||
query := "eiffel"
|
||||
end
|
||||
|
||||
data: ITERABLE [GOOGLE_NEWS]
|
||||
local
|
||||
list: LINKED_LIST [GOOGLE_NEWS]
|
||||
l_result: INTEGER
|
||||
l_curl_string: CURL_STRING
|
||||
json_parser: JSON_PARSER
|
||||
query_str: STRING
|
||||
do
|
||||
curl_handle := curl_easy.init
|
||||
create list.make
|
||||
row_count := 0
|
||||
if curl_handle /= default_pointer then
|
||||
create l_curl_string.make_empty
|
||||
query_str := query.out
|
||||
query_str.replace_substring_all (" ", "+")
|
||||
curl_easy.setopt_string (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_url, "https://ajax.googleapis.com/ajax/services/search/news?v=1.0&q=" + query_str + "&rsz=" + page_size.out + "&start=" + (page_size * (page - 1)).out)
|
||||
curl_easy.set_write_function (curl_handle)
|
||||
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_writedata, l_curl_string.object_id)
|
||||
l_result := curl_easy.perform (curl_handle)
|
||||
|
||||
-- Always cleanup
|
||||
curl_easy.cleanup (curl_handle)
|
||||
create json_parser.make_parser (l_curl_string.out)
|
||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||
if attached {JSON_OBJECT} sp.item (create {JSON_STRING}.make_json ("responseData")) as responsedata and then attached {JSON_ARRAY} responsedata.item (create {JSON_STRING}.make_json ("results")) as results then
|
||||
if attached {JSON_OBJECT} responsedata.item (create {JSON_STRING}.make_json ("cursor")) as cursor and then attached {JSON_STRING} cursor.item (create {JSON_STRING}.make_json ("estimatedResultCount")) as count then
|
||||
row_count := count.item.to_integer.min (64)
|
||||
end
|
||||
across
|
||||
1 |..| results.count as c
|
||||
loop
|
||||
if attached {JSON_OBJECT} results.i_th (c.item) as j then
|
||||
list.extend (create {GOOGLE_NEWS}.make_from_json (j))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Result := list
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_query (q: STRING)
|
||||
do
|
||||
query := q
|
||||
end
|
||||
|
||||
query: STRING
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
curl_easy: CURL_EASY_EXTERNALS
|
||||
once
|
||||
create Result
|
||||
end
|
||||
|
||||
curl_handle: POINTER;
|
||||
-- cURL handle
|
||||
|
||||
end
|
||||
38
examples/widgetapp/google_news_repeater.e
Normal file
38
examples/widgetapp/google_news_repeater.e
Normal file
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_NEWS_REPEATER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
GOOGLE_NEWS_REPEATER
|
||||
|
||||
inherit
|
||||
|
||||
WSF_REPEATER_CONTROL [GOOGLE_NEWS]
|
||||
|
||||
create
|
||||
make_repeater
|
||||
|
||||
feature
|
||||
|
||||
render_item (item: GOOGLE_NEWS): STRING
|
||||
local
|
||||
body: STRING
|
||||
do
|
||||
Result := ""
|
||||
if attached item.image as image then
|
||||
Result.append (render_tag_with_tagname ("a", render_tag_with_tagname ("img", "", "style=%"max-width: 200px;%" src=%"" + image + "%"", "media-object"), "href=%"#%"", "pull-left"))
|
||||
end
|
||||
body := ""
|
||||
if attached item.title as title then
|
||||
body.append (render_tag_with_tagname ("h4", title, "", "media-heading"))
|
||||
end
|
||||
if attached item.content as content then
|
||||
body.append (content)
|
||||
end
|
||||
Result.append (render_tag_with_tagname ("div", body, "", "media-body"))
|
||||
Result := render_tag_with_tagname ("div", Result, "", "media") + "<hr />"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -18,17 +18,37 @@ feature
|
||||
|
||||
initialize_controls
|
||||
local
|
||||
ds: DEMO_DATASOURCE
|
||||
container: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create ds.make_demo
|
||||
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make_column ("#", "id"), create {WSF_GRID_COLUMN}.make_column ("Name", "name"), create {WSF_GRID_COLUMN}.make_column ("Description", "description")>>, ds)
|
||||
control := grid
|
||||
create container.make_multi_control ("container")
|
||||
container.add_class ("container")
|
||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h1","","Grid Demo"))
|
||||
create datasource.make_news
|
||||
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
|
||||
search_query.add_class ("form-control")
|
||||
search_query.set_change_event (agent change_query)
|
||||
container.add_control (search_query)
|
||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
|
||||
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make_column ("Title", "title"), create {WSF_GRID_COLUMN}.make_column ("Content", "content")>>, datasource)
|
||||
container.add_control (grid)
|
||||
control := container
|
||||
end
|
||||
|
||||
change_query
|
||||
do
|
||||
datasource.set_query (search_query.value)
|
||||
datasource.set_page (1)
|
||||
datasource.update
|
||||
end
|
||||
|
||||
process
|
||||
do
|
||||
end
|
||||
|
||||
grid: WSF_GRID_CONTROL [DEMO_DATA]
|
||||
grid: WSF_GRID_CONTROL [GOOGLE_NEWS]
|
||||
|
||||
search_query: WSF_AUTOCOMPLETE_CONTROL
|
||||
|
||||
datasource: GOOGLE_NEWS_DATASOURCE
|
||||
|
||||
end
|
||||
|
||||
54
examples/widgetapp/repeater_page.e
Normal file
54
examples/widgetapp/repeater_page.e
Normal file
@@ -0,0 +1,54 @@
|
||||
note
|
||||
description: "Summary description for {REPEATER_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
REPEATER_PAGE
|
||||
inherit
|
||||
|
||||
WSF_PAGE_CONTROL
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
|
||||
initialize_controls
|
||||
local
|
||||
container: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create container.make_multi_control ("container")
|
||||
container.add_class ("container")
|
||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h1","","Repeater Demo"))
|
||||
create datasource.make_news
|
||||
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
|
||||
search_query.add_class ("form-control")
|
||||
search_query.set_change_event (agent change_query)
|
||||
container.add_control (search_query)
|
||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
|
||||
create repeater.make_repeater ("myrepeater", datasource)
|
||||
container.add_control (repeater)
|
||||
control := container
|
||||
end
|
||||
|
||||
change_query
|
||||
do
|
||||
datasource.set_query (search_query.value)
|
||||
datasource.set_page (1)
|
||||
datasource.update
|
||||
end
|
||||
|
||||
process
|
||||
do
|
||||
end
|
||||
|
||||
repeater: GOOGLE_NEWS_REPEATER
|
||||
|
||||
search_query: WSF_AUTOCOMPLETE_CONTROL
|
||||
|
||||
datasource: GOOGLE_NEWS_DATASOURCE
|
||||
|
||||
end
|
||||
|
||||
@@ -20,35 +20,27 @@ feature
|
||||
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]
|
||||
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||
progress: WSF_PROGRESS_CONTROL
|
||||
progress_source: WSF_PROGRESSSOURCE
|
||||
link1: WSF_BASIC_CONTROL
|
||||
link2: WSF_BASIC_CONTROL
|
||||
|
||||
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")
|
||||
container.add_class ("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)
|
||||
create button1.make_button ("sample_button1", "SUM")
|
||||
create textbox_result.make_html ("txtBox3", "p", "")
|
||||
create {DEMO_PROGRESSSOURCE} progress_source.make
|
||||
create progress.make_progress ("progress1", progress_source)
|
||||
create link1.make_control ("a")
|
||||
create link2.make_control ("a")
|
||||
link1.set_content ("Home")
|
||||
link1.set_attributes ("href=%"#%"")
|
||||
link2.set_content ("About")
|
||||
link2.set_attributes ("href=%"#%"")
|
||||
navbar.add_element (link1)
|
||||
navbar.add_element_right (link2)
|
||||
create progress.make_progress ("progress1")
|
||||
navbar.add_element (create {WSF_BASIC_CONTROL}.make_with_body("a","href=%"/%"","Home"))
|
||||
navbar.add_element (create {WSF_BASIC_CONTROL}.make_with_body("a","href=%"/grid%"","Grid"))
|
||||
navbar.add_element (create {WSF_BASIC_CONTROL}.make_with_body("a","href=%"/repeater%"","Repeater"))
|
||||
navbar.add_element_right (create {WSF_BASIC_CONTROL}.make_with_body("a","href=%"#%"","About"))
|
||||
button1.set_click_event (agent handle_click)
|
||||
button1.add_class ("col-lg-offset-2")
|
||||
create form.make_form_control ("panel")
|
||||
@@ -81,21 +73,20 @@ feature
|
||||
local
|
||||
text: STRING
|
||||
do
|
||||
if attached {WSF_FORM_CONTROL} control as form then
|
||||
form.validate
|
||||
if form.is_valid then
|
||||
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
||||
text.append ("<ul>")
|
||||
across
|
||||
cklist.value as s
|
||||
loop
|
||||
text.append ("<li>" + s.item + "</li>")
|
||||
end
|
||||
text.append ("</ul>")
|
||||
textbox_result.set_html (text)
|
||||
else
|
||||
textbox_result.set_html ("VALIDATION ERROR")
|
||||
form.validate
|
||||
if form.is_valid then
|
||||
progress.set_progress ((textbox1.text.to_integer_64 / textbox2.text.to_integer_64*100).ceiling)
|
||||
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
||||
text.append ("<ul>")
|
||||
across
|
||||
cklist.value as s
|
||||
loop
|
||||
text.append ("<li>" + s.item + "</li>")
|
||||
end
|
||||
text.append ("</ul>")
|
||||
textbox_result.set_html (text)
|
||||
else
|
||||
textbox_result.set_html ("VALIDATION ERROR")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,4 +106,7 @@ feature
|
||||
|
||||
textbox_result: WSF_HTML_CONTROL
|
||||
|
||||
form: WSF_FORM_CONTROL
|
||||
|
||||
progress: WSF_PROGRESS_CONTROL
|
||||
end
|
||||
|
||||
@@ -11,11 +11,12 @@ Mini =
|
||||
render:template(t)
|
||||
}
|
||||
|
||||
trigger_callback = (control_name,event)->
|
||||
trigger_callback = (control_name,event,event_parameter)->
|
||||
$.ajax
|
||||
data:
|
||||
control_name: control_name
|
||||
event: event
|
||||
event_parameter: event_parameter
|
||||
states: JSON.stringify(window.states)
|
||||
cache: no
|
||||
.done (new_states)->
|
||||
@@ -131,7 +132,6 @@ class WSF_TEXTAREA_CONTROL extends WSF_INPUT_CONTROL
|
||||
|
||||
class WSF_AUTOCOMPLETE_CONTROL extends WSF_INPUT_CONTROL
|
||||
attach_events: () ->
|
||||
super
|
||||
self = @
|
||||
@$el.typeahead({
|
||||
name: @control_name
|
||||
@@ -148,6 +148,10 @@ class WSF_AUTOCOMPLETE_CONTROL extends WSF_INPUT_CONTROL
|
||||
filter: (parsedResponse) ->
|
||||
parsedResponse[self.control_name]['suggestions']
|
||||
})
|
||||
@$el.on 'typeahead:closed',()->
|
||||
self.change()
|
||||
@$el.on 'typeahead:blured',()->
|
||||
self.change()
|
||||
|
||||
class WSF_CHECKBOX_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
@@ -255,6 +259,47 @@ class WSF_PROGRESS_CONTROL extends WSF_CONTROL
|
||||
window.states[@control_name]['progress'] = state.progress
|
||||
$('#' + @control_name).children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
||||
|
||||
class WSF_PAGINATION_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
self = @
|
||||
@$el.on 'click', 'a', (e)->
|
||||
e.preventDefault()
|
||||
self.click(e)
|
||||
|
||||
click: (e)->
|
||||
nr = $(e.target).data('nr')
|
||||
if nr == "next"
|
||||
trigger_callback(@control_name, "next")
|
||||
else if nr == "prev"
|
||||
trigger_callback(@control_name, "prev")
|
||||
else
|
||||
trigger_callback(@control_name, "goto", nr)
|
||||
|
||||
update: (state) ->
|
||||
if state._html?
|
||||
@$el.html($(state._html).html())
|
||||
|
||||
class WSF_GRID_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
self = @
|
||||
|
||||
update: (state) ->
|
||||
if state.datasource?
|
||||
window.states[@control_name]['datasource'] = state.datasource
|
||||
if state._body?
|
||||
@$el.find('tbody').html(state._body)
|
||||
|
||||
class WSF_REPEATER_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
self = @
|
||||
|
||||
update: (state) ->
|
||||
if state.datasource?
|
||||
window.states[@control_name]['datasource'] = state.datasource
|
||||
if state._body?
|
||||
@$el.find('.repeater_content').html(state._body)
|
||||
console.log state._body
|
||||
|
||||
#map class name to effective class
|
||||
typemap =
|
||||
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL
|
||||
@@ -266,6 +311,9 @@ typemap =
|
||||
"WSF_HTML_CONTROL": WSF_HTML_CONTROL
|
||||
"WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL
|
||||
"WSF_PROGRESS_CONTROL": WSF_PROGRESS_CONTROL
|
||||
"WSF_PAGINATION_CONTROL": WSF_PAGINATION_CONTROL
|
||||
"WSF_GRID_CONTROL": WSF_GRID_CONTROL
|
||||
"WSF_REPEATER_CONTROL":WSF_REPEATER_CONTROL
|
||||
|
||||
#create a js class for each control
|
||||
for name,state of window.states
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated by CoffeeScript 1.6.1
|
||||
(function() {
|
||||
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_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, cache, controls, name, state, template, tmpl, 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_GRID_CONTROL, WSF_HTML_CONTROL, WSF_INPUT_CONTROL, WSF_MAX_VALIDATOR, WSF_MIN_VALIDATOR, WSF_PAGINATION_CONTROL, WSF_PROGRESS_CONTROL, WSF_REGEXP_VALIDATOR, WSF_REPEATER_CONTROL, WSF_TEXTAREA_CONTROL, WSF_VALIDATOR, cache, controls, name, state, template, tmpl, trigger_callback, type, typemap, validatormap, _ref, _ref1, _ref2,
|
||||
__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; };
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
trigger_callback = function(control_name, event) {
|
||||
trigger_callback = function(control_name, event, event_parameter) {
|
||||
return $.ajax({
|
||||
data: {
|
||||
control_name: control_name,
|
||||
event: event,
|
||||
event_parameter: event_parameter,
|
||||
states: JSON.stringify(window.states)
|
||||
},
|
||||
cache: false
|
||||
@@ -262,9 +263,8 @@
|
||||
|
||||
WSF_AUTOCOMPLETE_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
WSF_AUTOCOMPLETE_CONTROL.__super__.attach_events.apply(this, arguments);
|
||||
self = this;
|
||||
return this.$el.typeahead({
|
||||
this.$el.typeahead({
|
||||
name: this.control_name,
|
||||
template: window.states[this.control_name]['template'],
|
||||
engine: Mini,
|
||||
@@ -283,6 +283,12 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
this.$el.on('typeahead:closed', function() {
|
||||
return self.change();
|
||||
});
|
||||
return this.$el.on('typeahead:blured', function() {
|
||||
return self.change();
|
||||
});
|
||||
};
|
||||
|
||||
return WSF_AUTOCOMPLETE_CONTROL;
|
||||
@@ -482,6 +488,98 @@
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_PAGINATION_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_PAGINATION_CONTROL, _super);
|
||||
|
||||
function WSF_PAGINATION_CONTROL() {
|
||||
return WSF_PAGINATION_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_PAGINATION_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
self = this;
|
||||
return this.$el.on('click', 'a', function(e) {
|
||||
e.preventDefault();
|
||||
return self.click(e);
|
||||
});
|
||||
};
|
||||
|
||||
WSF_PAGINATION_CONTROL.prototype.click = function(e) {
|
||||
var nr;
|
||||
nr = $(e.target).data('nr');
|
||||
if (nr === "next") {
|
||||
return trigger_callback(this.control_name, "next");
|
||||
} else if (nr === "prev") {
|
||||
return trigger_callback(this.control_name, "prev");
|
||||
} else {
|
||||
return trigger_callback(this.control_name, "goto", nr);
|
||||
}
|
||||
};
|
||||
|
||||
WSF_PAGINATION_CONTROL.prototype.update = function(state) {
|
||||
if (state._html != null) {
|
||||
return this.$el.html($(state._html).html());
|
||||
}
|
||||
};
|
||||
|
||||
return WSF_PAGINATION_CONTROL;
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_GRID_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_GRID_CONTROL, _super);
|
||||
|
||||
function WSF_GRID_CONTROL() {
|
||||
return WSF_GRID_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_GRID_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
return self = this;
|
||||
};
|
||||
|
||||
WSF_GRID_CONTROL.prototype.update = function(state) {
|
||||
if (state.datasource != null) {
|
||||
window.states[this.control_name]['datasource'] = state.datasource;
|
||||
}
|
||||
if (state._body != null) {
|
||||
return this.$el.find('tbody').html(state._body);
|
||||
}
|
||||
};
|
||||
|
||||
return WSF_GRID_CONTROL;
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
WSF_REPEATER_CONTROL = (function(_super) {
|
||||
|
||||
__extends(WSF_REPEATER_CONTROL, _super);
|
||||
|
||||
function WSF_REPEATER_CONTROL() {
|
||||
return WSF_REPEATER_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_REPEATER_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
return self = this;
|
||||
};
|
||||
|
||||
WSF_REPEATER_CONTROL.prototype.update = function(state) {
|
||||
if (state.datasource != null) {
|
||||
window.states[this.control_name]['datasource'] = state.datasource;
|
||||
}
|
||||
if (state._body != null) {
|
||||
this.$el.find('.repeater_content').html(state._body);
|
||||
return console.log(state._body);
|
||||
}
|
||||
};
|
||||
|
||||
return WSF_REPEATER_CONTROL;
|
||||
|
||||
})(WSF_CONTROL);
|
||||
|
||||
typemap = {
|
||||
"WSF_BUTTON_CONTROL": WSF_BUTTON_CONTROL,
|
||||
"WSF_INPUT_CONTROL": WSF_INPUT_CONTROL,
|
||||
@@ -491,7 +589,10 @@
|
||||
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL,
|
||||
"WSF_HTML_CONTROL": WSF_HTML_CONTROL,
|
||||
"WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL,
|
||||
"WSF_PROGRESS_CONTROL": WSF_PROGRESS_CONTROL
|
||||
"WSF_PROGRESS_CONTROL": WSF_PROGRESS_CONTROL,
|
||||
"WSF_PAGINATION_CONTROL": WSF_PAGINATION_CONTROL,
|
||||
"WSF_GRID_CONTROL": WSF_GRID_CONTROL,
|
||||
"WSF_REPEATER_CONTROL": WSF_REPEATER_CONTROL
|
||||
};
|
||||
|
||||
_ref = window.states;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="curl" location="$ISE_LIBRARY\library\cURL\cURL-safe.ecf"/>
|
||||
<library name="http" location="..\..\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_html" location="..\..\library\server\wsf_html\wsf_html-safe.ecf"/>
|
||||
|
||||
Reference in New Issue
Block a user