Added Progress Control

This commit is contained in:
Severin Münger
2013-09-15 01:55:17 +02:00
parent 9db93cf4c9
commit 6761d22fa8
4 changed files with 90 additions and 5 deletions

View File

@@ -96,6 +96,7 @@ class WSF_BUTTON_CONTROL extends WSF_CONTROL
@$el.click (e)-> @$el.click (e)->
e.preventDefault() e.preventDefault()
self.click() self.click()
click: ()-> click: ()->
if window.states[@control_name]['callback_click'] if window.states[@control_name]['callback_click']
trigger_callback(@control_name, 'click') trigger_callback(@control_name, 'click')
@@ -247,16 +248,24 @@ class WSF_CHECKBOX_LIST_CONTROL extends WSF_CONTROL
result.push(subc.checked_value) result.push(subc.checked_value)
return result return result
class WSF_PROGRESS_CONTROL extends WSF_CONTROL
update: (state)->
if state.progress?
window.states[@control_name]['progress'] = state.progress
$('#' + @control_name).children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
#map class name to effective class #map class name to effective class
typemap = 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_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
"WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL "WSF_CHECKBOX_LIST_CONTROL": WSF_CHECKBOX_LIST_CONTROL
"WSF_PROGRESS_CONTROL": WSF_PROGRESS_CONTROL
#create a js class for each control #create a js class for each control
for name,state of window.states for name,state of window.states

View File

@@ -0,0 +1,59 @@
note
description: "Summary description for {WSF_PROGRESS_CONTROL}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_PROGRESS_CONTROL
inherit
WSF_CONTROL
create
make_progress
feature {NONE} -- Initialization
make_progress (n: STRING; p: WSF_PROGRESSSOURCE)
do
make_control (n, "div")
add_class ("progress")
progress_source := p
end
feature -- State handling
set_state (new_state: JSON_OBJECT)
do
end
state: JSON_OBJECT
do
create Result.make
Result.put (create {JSON_NUMBER}.make_integer (progress_source.progress), "progress")
end
feature -- Event handling
handle_callback (cname: STRING; event: STRING)
do
if cname.is_equal (control_name) and event.is_equal ("progress_fetch") then
state_changes.put (create {JSON_NUMBER}.make_integer (progress_source.progress), create {JSON_STRING}.make_json ("progress"))
end
end
feature -- Rendering
render: STRING
do
Result := render_tag_with_tagname ("div", "", "role=%"progressbar%" aria-valuenow=%"" + progress_source.progress.out + "%" aria-valuemin=%"0%" aria-valuemax=%"100%" style=%"width: " + progress_source.progress.out + "%%;%"", "progress-bar")
Result := render_tag (Result, "")
end
feature
progress_source: WSF_PROGRESSSOURCE
end

View File

@@ -0,0 +1,16 @@
note
description: "Summary description for {WSF_PROGRESSSOURCE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_PROGRESSSOURCE
feature
progress: INTEGER
deferred
end
end

View File

@@ -25,6 +25,7 @@
<cluster name="grid" location=".\webcontrol\grid\"/> <cluster name="grid" location=".\webcontrol\grid\"/>
<cluster name="autocompletions" location=".\webcontrol\autocompletions\"/> <cluster name="autocompletions" location=".\webcontrol\autocompletions\"/>
<cluster name="navbar" location=".\webcontrol\navbar\"/> <cluster name="navbar" location=".\webcontrol\navbar\"/>
<cluster name="progressbar" location="\home\severin\Documents\EWF\EWF\library\server\wsf_html\webcontrol\progressbar\"/>
</cluster> </cluster>
<cluster name="widget" location=".\widget\" recursive="true"/> <cluster name="widget" location=".\widget\" recursive="true"/>
</target> </target>