]> source.dussan.org Git - jquery-ui.git/commitdiff
Progressbar updates
authorEduardo Lundgren <eduardolundgren@gmail.com>
Sat, 9 Aug 2008 23:51:46 +0000 (23:51 +0000)
committerEduardo Lundgren <eduardolundgren@gmail.com>
Sat, 9 Aug 2008 23:51:46 +0000 (23:51 +0000)
tests/visual/progressbar.html
ui/ui.progressbar.js

index 59ddbd403476b8b4ec1c35bd0eceb84139887491..9052855e197f528736d06e4864375ef11cad12c9 100644 (file)
@@ -114,7 +114,7 @@ body
 <button id="p1-destroy" onclick="$('#p1').progressbar('destroy');">destroy</button>\r
 <button id="p1-start" onclick="$('#p1').progressbar('start');">Start</button>\r
 <button id="p1-stop" onclick="$('#p1').progressbar('stop');">Stop</button>\r
-<button id="p1-pause" onclick="$('#p1').progressbar('reset');">reset</button>\r
+<button id="p1-stop" onclick="$('#p1').progressbar('pause');">pause</button>\r
 <button id="p1-enable" onclick="$('#p1').progressbar('enable');">enable</button>\r
 <button id="p1-disable" onclick="$('#p1').progressbar('disable');">disable</button>\r
 <button id="p1-progress" onclick="$('#p1').progressbar('progress', 50);">progress to 50</button>\r
@@ -128,7 +128,7 @@ body
 <button id="p2-destroy" onclick="$('#p2').progressbar('destroy');">destroy</button>\r
 <button id="p2-start" onclick="$('#p2').progressbar('start');">Start</button>\r
 <button id="p2-stop" onclick="$('#p2').progressbar('stop');">Stop</button>\r
-<button id="p2-pause" onclick="$('#p2').progressbar('reset');">reset</button>\r
+<button id="p2-stop" onclick="$('#p2').progressbar('pause');">pause</button>\r
 <button id="p2-enable" onclick="$('#p2').progressbar('enable');">enable</button>\r
 <button id="p2-disable" onclick="$('#p2').progressbar('disable');">disable</button>\r
 <button id="p2-progress" onclick="$('#p2').progressbar('progress', 40);">progress to 50</button>\r
@@ -141,7 +141,7 @@ body
 <button id="p3-destroy" onclick="$('#p3').progressbar('destroy');">destroy</button>\r
 <button id="p3-start" onclick="$('#p3').progressbar('start');">Start</button>\r
 <button id="p3-stop" onclick="$('#p3').progressbar('stop');">Stop</button>\r
-<button id="p3-pause" onclick="$('#p3').progressbar('reset');">reset</button>\r
+<button id="p3-stop" onclick="$('#p3').progressbar('pause');">pause</button>\r
 <button id="p3-enable" onclick="$('#p3').progressbar('enable');">enable</button>\r
 <button id="p3-disable" onclick="$('#p3').progressbar('disable');">disable</button>\r
 <button id="p3-progress" onclick="$('#p3').progressbar('progress', $('#p3-value').val());">progress to</button>\r
@@ -151,7 +151,7 @@ body
 \r
 <button id="p2-startall" onclick="$('#p2, #p1, #p3').progressbar('start');">Start All</button>\r
 <button id="p2-stopall" onclick="$('#p2, #p1, #p3').progressbar('stop');">Stop All</button>\r
-<button id="p2-stopall" onclick="$('#p2, #p1, #p3').progressbar('reset');">Reset All</button>\r
+<button id="p2-stopall" onclick="$('#p2, #p1, #p3').progressbar('pause');">Pause All</button>\r
 \r
 <script>\r
 \r
index c594ded12a0badda3ed74157b94a0414e910d14d..9e973094863cefc193ce3d6a8606f4d1056f1547 100644 (file)
@@ -47,6 +47,13 @@ $.widget("ui.progressbar", {
                        .append(this.bar.append(this.textElement.addClass(options.textClass)), this.textBg)\r
                        .appendTo(this.element);\r
 \r
+               jQuery.easing[this.identifier] = function (x, t, b, c, d) {\r
+                       var inc = options.increment,\r
+                               width = options.width,\r
+                               step = ((inc > width ? width : inc)/width),\r
+                               state = Math.round(x/step)*step;\r
+                       return state > 1 ? 1 : state;\r
+               };\r
        },\r
 \r
        plugins: {},\r
@@ -66,7 +73,7 @@ $.widget("ui.progressbar", {
                this.element.triggerHandler(n == "progressbar" ? n : ["progressbar", n].join(""), [e, this.ui()], this.options[n]);\r
        },\r
        destroy: function() {\r
-               this.reset();\r
+               this.stop();\r
 \r
                this.element\r
                        .removeClass("ui-progressbar ui-progressbar-disabled")\r
@@ -84,54 +91,68 @@ $.widget("ui.progressbar", {
                this.disabled = true;\r
        },\r
        start: function() {\r
-               if (this.disabled) return;\r
-\r
                var self = this, options = this.options;\r
 \r
-               jQuery.easing[this.identifier] = function (x, t, b, c, d) {\r
-                       var inc = options.increment,\r
-                               width = options.width,\r
-                               step = ((inc > width ? width : inc)/width),\r
-                               state = Math.round(x/step)*step;\r
-                       return state > 1 ? 1 : state;\r
+               if (this.disabled) {\r
+                       return;\r
                };\r
+               \r
+               self.active = true;\r
+               \r
+               setTimeout(\r
+                       function() {\r
+                               self.active = false;\r
+                       },\r
+                       options.duration\r
+               );\r
+\r
+               this.animate();\r
+\r
+               this.propagate('start', this.ui());\r
+               return false;\r
+       },\r
+       animate: function() {\r
+               var self = this,\r
+                       options = this.options,\r
+                       interval = options.interval;\r
 \r
                this.bar.animate(\r
                        {\r
                                width: options.width\r
                        },\r
                        {\r
-                               duration: options.interval,\r
+                               duration: interval,\r
                                easing: this.identifier,\r
                                step: function(step, b) {\r
-                                       var elapsedTime = ((new Date().getTime()) - b.startTime);\r
-                                       options.interval = options._interval - elapsedTime;\r
                                        self.progress((step/options.width)*100);\r
+                                       var elapsedTime = ((new Date().getTime()) - b.startTime);\r
+                                       options.interval = interval - elapsedTime;\r
                                },\r
                                complete: function() {\r
                                        delete jQuery.easing[self.identifier];\r
-                                       self.stop();\r
+                                       self.pause();\r
+\r
+                                       if (self.active) {\r
+                                               /*TODO*/\r
+                                               self.stop();\r
+                                               self.animate();\r
+                                       }\r
                                }\r
                        }\r
                );\r
-\r
-               this.propagate('start', this.ui());\r
-               return false;\r
        },\r
-       stop: function() {\r
+       pause: function() {\r
                if (this.disabled) return;\r
                this.bar.stop();\r
-               this.propagate('stop', this.ui());\r
-               return false;\r
-\r
+               this.propagate('pause', this.ui());\r
        },\r
-       reset: function() {\r
+       stop: function() {\r
                this.bar.stop();\r
                this.bar.width(0);\r
                this.textElement.width(0);\r
                this.bar.addClass('ui-hidden');\r
                this.options.interval = this.options._interval;\r
-               return false;\r
+               this.propagate('stop', this.ui());\r
        },\r
        progress: function(percentState) {\r
                if (this.bar.is('.ui-hidden')) {\r