Added progress callback
This commit is contained in:
@@ -25,7 +25,7 @@ feature
|
||||
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"))
|
||||
container.add_control (navbar)
|
||||
control:=container
|
||||
control := container
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
36
examples/widgetapp/progress/increasing_progresssource.e
Normal file
36
examples/widgetapp/progress/increasing_progresssource.e
Normal file
@@ -0,0 +1,36 @@
|
||||
note
|
||||
description: "Summary description for {INCREASING_PROGRESSSOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
INCREASING_PROGRESSSOURCE
|
||||
|
||||
inherit
|
||||
|
||||
WSF_PROGRESSSOURCE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
progress_value: INTEGER
|
||||
|
||||
make
|
||||
do
|
||||
progress_value := 0
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
progress: INTEGER
|
||||
do
|
||||
Result := progress_value
|
||||
if progress_value < 100 then
|
||||
progress_value := progress_value + 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -77,7 +77,7 @@ feature
|
||||
|
||||
--Progress bar
|
||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h4","","Number1/Number2"))
|
||||
create progress.make_progress ("progress1")
|
||||
create progress.make_progress_with_source ("progress1", create {INCREASING_PROGRESSSOURCE}.make)
|
||||
container.add_control (progress)
|
||||
end
|
||||
|
||||
|
||||
@@ -254,10 +254,18 @@ class WSF_CHECKBOX_LIST_CONTROL extends WSF_CONTROL
|
||||
|
||||
class WSF_PROGRESS_CONTROL extends WSF_CONTROL
|
||||
|
||||
attach_events:() ->
|
||||
self = @
|
||||
setInterval(@fetch, 1000)
|
||||
|
||||
fetch: ()->
|
||||
trigger_callback(@control_name, 'progress_fetch')
|
||||
|
||||
update: (state)->
|
||||
alert('update')
|
||||
if state.progress?
|
||||
window.states[@control_name]['progress'] = state.progress
|
||||
$('#' + @control_name).children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
||||
@$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
||||
|
||||
class WSF_PAGINATION_CONTROL extends WSF_CONTROL
|
||||
attach_events: ()->
|
||||
|
||||
@@ -477,10 +477,21 @@
|
||||
return WSF_PROGRESS_CONTROL.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
WSF_PROGRESS_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
self = this;
|
||||
return setInterval(this.fetch, 1000);
|
||||
};
|
||||
|
||||
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
||||
return trigger_callback(this.control_name, 'progress_fetch');
|
||||
};
|
||||
|
||||
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
||||
alert('update');
|
||||
if (state.progress != null) {
|
||||
window.states[this.control_name]['progress'] = state.progress;
|
||||
return $('#' + this.control_name).children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%');
|
||||
return this.$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -53,8 +53,11 @@ feature -- Event handling
|
||||
feature -- Rendering
|
||||
|
||||
render: STRING
|
||||
local
|
||||
p: STRING
|
||||
do
|
||||
Result := render_tag_with_tagname ("div", "", "role=%"progressbar%" aria-valuenow=%"" + progress_value.out + "%" aria-valuemin=%"0%" aria-valuemax=%"100%" style=%"width: " + progress_value.out + "%%;%"", "progress-bar")
|
||||
p := progress_value.out
|
||||
Result := render_tag_with_tagname ("div", "", "role=%"progressbar%" aria-valuenow=%"" + p + "%" aria-valuemin=%"0%" aria-valuemax=%"100%" style=%"width: " + p + "%%;%"", "progress-bar")
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user