From 2bbac274c17a4c68b443ae001fd8d37393512b95 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 30 Oct 2016 04:32:19 +0300 Subject: [PATCH] tweaking progress... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/ui-widgets.js | 18 +++++++++--------- ui (gen4)/ui.js | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index ba407781..244d5564 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1181,28 +1181,27 @@ var WidgetTestActions = actions.Actions({ var timeout = widget.attr('close-timeout') timeout && clearTimeout(JSON.parse(timeout)) - + // get the widget parts we are updating... var bar = widget.find('progress') var state = widget.find('.progress-details') // XXX stub??? - max = max ? + // normalize max and value... + max = max != null ? (typeof(max) == typeof('str') && /[+-][0-9]+/.test(max) ? parseInt(bar.attr('max') || 0) + parseInt(max) : parseInt(max)) : bar.attr('max') - - value = value ? + value = value != null ? (typeof(value) == typeof('str') && /[+-][0-9]+/.test(value) ? parseInt(bar.attr('value') || 0) + parseInt(value) : parseInt(value)) : bar.attr('value') - // ignore value if not max is present + handle overflow... - value = max ? Math.min(value, max) : null + // format the message... msg = msg ? ': '+msg : '' msg = ' '+ msg - + (value && value >= max ? ' ('+max+' done)' + + (value && value >= (max || 0) ? ' ('+value+' done)' : value && max && value != max ? ' ('+ value +' of '+ max +')' : ' (ready)') @@ -1215,14 +1214,15 @@ var WidgetTestActions = actions.Actions({ // auto-close... // XXX make this optional... - if(value && value >= max){ + if(value && value >= (max || 0)){ widget.attr('close-timeout', JSON.stringify(setTimeout(function(){ widget.trigger('progressClose') }, 1000))) } - }], + // XXX what should we return??? (state, self, controller?) + }], testProgress: ['Test/Demo progress bar...', function(text){ var done = 0 diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js index caf134e8..7fd1219b 100755 --- a/ui (gen4)/ui.js +++ b/ui (gen4)/ui.js @@ -150,7 +150,7 @@ $(function(){ if(e == 'queued'){ ig.showProgress('Progress', '+0', '+1') - } else if(e == 'loaded' || e == 'done'){ + } else if(e == 'loaded' || e == 'done' || e == 'written'){ ig.showProgress('Progress', '+1') } }}