diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-07-23 20:43:32 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-07-23 20:43:32 -0700 |
commit | 5c8a2a750ccc16b5e8b0dd97ff21dbfb9860d856 (patch) | |
tree | d0918611099cf1a8e3760c1efb49a25708ed7799 /modules/gallery/views/admin_maintenance_task.html.php | |
parent | 6246a917978e5d955c5e2fc49fc8c1a045aabedf (diff) |
Smooth out the animaation for the progress bar.
Diffstat (limited to 'modules/gallery/views/admin_maintenance_task.html.php')
-rw-r--r-- | modules/gallery/views/admin_maintenance_task.html.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/modules/gallery/views/admin_maintenance_task.html.php b/modules/gallery/views/admin_maintenance_task.html.php index 5c2c03a1..c81fe571 100644 --- a/modules/gallery/views/admin_maintenance_task.html.php +++ b/modules/gallery/views/admin_maintenance_task.html.php @@ -1,11 +1,32 @@ <?php defined("SYSPATH") or die("No direct script access.") ?> <script type="text/javascript"> + var target_value; + var animation = null; + var delta = 1; + animate_progress_bar = function() { + var current_value = Number($(".gProgressBar div").css("width").replace("%", "")); + if (current_value != target_value) { + var new_value = Math.min(current_value + delta, target_value); + if (target_value - current_value > delta) { + delta += .075; + } + $(".gProgressBar").progressbar("value", new_value); + animation = setTimeout(function() { animate_progress_bar(target_value); }, 100); + } else { + animation = null; + delta = 1; + } + } + update = function() { $.ajax({ url: "<?= url::site("admin/maintenance/run/$task->id?csrf=$csrf") ?>", dataType: "json", success: function(data) { - $(".gProgressBar").progressbar("value", data.task.percent_complete); + target_value = data.task.percent_complete; + if (!animation) { + animate_progress_bar(); + } $("#gStatus").html("" + data.task.status); if (data.task.done) { $("#gPauseButton").hide(); |