]> source.dussan.org Git - jquery-ui.git/commitdiff
Progressbar: Custom label demo cleanup
authorKris Borchers <kris.borchers@gmail.com>
Tue, 4 Dec 2012 03:25:55 +0000 (21:25 -0600)
committerKris Borchers <kris.borchers@gmail.com>
Tue, 4 Dec 2012 03:26:13 +0000 (21:26 -0600)
demos/progressbar/label.html

index c4334b65cf3b1df8f75dbcc730d2d36b76a0dab0..25394b205aac4978c56fc0cf1b9ffe5fd9194366 100644 (file)
@@ -2,7 +2,7 @@
 <html lang="en">
 <head>
        <meta charset="utf-8">
-       <title>jQuery UI Progressbar - Default functionality</title>
+       <title>jQuery UI Progressbar - Custom Label</title>
        <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
        <script src="../../jquery-1.8.3.js"></script>
        <script src="../../ui/jquery.ui.core.js"></script>
        <script src="../../ui/jquery.ui.progressbar.js"></script>
        <link rel="stylesheet" href="../demos.css">
        <style>
-               .progress-label {
-                       float: left;
-                       margin-left: 50%;
-                       margin-top: 5px;
-                       font-weight: bold;
-               }
+       .progress-label {
+               float: left;
+               margin-left: 50%;
+               margin-top: 5px;
+               font-weight: bold;
+               text-shadow: 1px 1px 0 #fff;
+       }
        </style>
        <script>
        $(function() {
-               $( "#progressbar" ).progressbar({
+               var progressbar = $( "#progressbar" ),
+                       progressLabel = $( ".progress-label" );
+
+               progressbar.progressbar({
                        value: false,
-                       change: function( event, ui ) {
-                               $( ".progress-label" ).text( $( "#progressbar" ).progressbar( "value" ) + "%" );
+                       change: function() {
+                               progressLabel.text( progressbar.progressbar( "value" ) + "%" );
+                       },
+                       complete: function() {
+                               progressLabel.text( "Complete!" );
                        }
                });
 
                function progress() {
-                       var val = $( "#progressbar" ).progressbar( "value" );
+                       var val = progressbar.progressbar( "value" ) || 0;
 
-                       if ( !val ) {
-                               val = 0;
-                       }
-                       if ( val < 100 ) {
-                               $( "#progressbar" ).progressbar( "value", val + 1 );
-                               setTimeout( function() {
-                                       progress();
-                               }, 100);
-                       } else {
-                               $( ".progress-label" ).text( "Complete!" );
+                       progressbar.progressbar( "value", val + 1 );
+
+                       if ( val < 99 ) {
+                               setTimeout( progress, 100 );
                        }
                }