Added progress callback

This commit is contained in:
Severin Münger
2013-09-15 22:13:51 +02:00
parent 647beea245
commit 2fbffb8c9e
6 changed files with 63 additions and 5 deletions

View File

@@ -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

View 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

View File

@@ -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

View File

@@ -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: ()->

View File

@@ -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 + '%');
}
};

View File

@@ -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