[Bps-public-commit] r15199 - in Pushmi/trunk: . Pushmi-Admin/lib/Pushmi/Admin Pushmi-Admin/share/web/static/js

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Aug 15 16:27:44 EDT 2008


Author: alexmv
Date: Fri Aug 15 16:27:34 2008
New Revision: 15199

Added:
   Pushmi/trunk/Pushmi-Admin/share/web/static/js/pushmi_progress.js
Modified:
   Pushmi/trunk/   (props changed)
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
   Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm

Log:
 r36014 at kohr-ah:  chmrr | 2008-08-15 16:27:22 -0400
  * Make the progressbar always start at 0 when it appears on the page, so it is still useful for big repos


Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm	Fri Aug 15 16:27:34 2008
@@ -9,6 +9,7 @@
     my $class = shift;
     Jifty->web->add_javascript(qw(
         jquery.progressbar.js
+        pushmi_progress.js
     ));
 }
 

Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	(original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm	Fri Aug 15 16:27:34 2008
@@ -145,8 +145,7 @@
     };
 
     if ($replica->remote_revision ne "???") {
-        my $progress = int(($replica->local_revision / $replica->remote_revision) * 100);
-        outs_raw( qq{<script>if (jQuery("#progress-$id")) jQuery("#progress-$id").progressBar($progress)</script>} );
+        outs_raw( qq{<script>jQuery(document).ready(function() {updateprogress(@{[$replica->id]},@{[$replica->local_revision]},@{[$replica->remote_revision]})})</script>} );
     }
 
     Jifty->subs->update_on(
@@ -269,9 +268,8 @@
     return unless $replica->remote_revision;
     return unless $replica->status eq "loading";
 
-    my $progress = int(($replica->local_revision / $replica->remote_revision) * 100);
-    outs_raw( qq{<script>jQuery(document).ready(function() {jQuery("#progress-$id").progressBar();})</script>} );
-    span {{ class is "progressbar", id is "progress-$id"}; $progress . "%" };
+    outs_raw( qq{<script>jQuery(document).ready(function() {jQuery("#progress-$id").progressBar(0);})</script>} );
+    span {{ class is "progressbar minvalue-".$replica->local_revision, id is "progress-$id"}; "0%" };
 };
 
 template 'fragments/logs' => sub {

Added: Pushmi/trunk/Pushmi-Admin/share/web/static/js/pushmi_progress.js
==============================================================================
--- (empty file)
+++ Pushmi/trunk/Pushmi-Admin/share/web/static/js/pushmi_progress.js	Fri Aug 15 16:27:34 2008
@@ -0,0 +1,18 @@
+function updateprogress(id, local, remote) {
+    var elem = jQuery("#progress-" + id);
+    if (elem.length == 0)
+        return;
+   
+    var class = elem.attr("class");
+    if (class == null)
+        return;
+    var matches = class.match(/minvalue-(\d+)/);
+    if (matches == null)
+        return;
+    var min = parseInt(matches[1]);
+
+    if (local == min && remote == min)
+        elem.progressBar(0);
+    else
+        elem.progressBar((local - min)/(remote - min) * 100);
+}



More information about the Bps-public-commit mailing list