]> source.dussan.org Git - jquery-ui.git/commitdiff
Progressbar: Move progressbar into widgets folder
authorAlexander Schmitz <arschmitz@gmail.com>
Wed, 15 Jul 2015 02:04:22 +0000 (22:04 -0400)
committerAlexander Schmitz <arschmitz@gmail.com>
Sat, 8 Aug 2015 04:29:38 +0000 (00:29 -0400)
Ref #13885

demos/bootstrap.js
tests/unit/progressbar/common.js
tests/unit/progressbar/core.js
tests/unit/progressbar/events.js
tests/unit/progressbar/methods.js
tests/unit/progressbar/options.js
ui/progressbar.js [deleted file]
ui/widgets/progressbar.js [new file with mode: 0644]

index 15f220c214b0796f4af11f42f898fd40198ce488..5a5d888894245dda982b2f57e6741ae12781011c 100644 (file)
@@ -32,7 +32,8 @@ var widgets = [
        "dialog",
        "draggable",
        "droppable",
-       "menu"
+       "menu",
+       "progressbar"
 ];
 
 function getPath( module ) {
index c949f136f9c8a5ef65b9a0b4c4f01f24772452f9..baadb6d5319cb9cb35c6242fac973da8c23bc110 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "lib/common",
-       "ui/progressbar"
+       "ui/widgets/progressbar"
 ], function( common ) {
 
 common.testWidget( "progressbar", {
index 05eea9ef7b191abcf68eac09ae6589b39e5020b3..8c09f67ae2a6af31388e147cdbb915010e900a2a 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/progressbar"
+       "ui/widgets/progressbar"
 ], function( $ ) {
 
 module( "progressbar: core" );
index a40b2c43218b0ee83809645e2b81b33611a70589..7f4926466f4cc70084dd343f5a1998909433ad9e 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/progressbar"
+       "ui/widgets/progressbar"
 ], function( $ ) {
 
 module( "progressbar: events" );
index eaf0a5c76655024e883eb1454575fbc20c8ba8c3..00de2f46e844c4734be8ccff80b651ff07cc039f 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/progressbar"
+       "ui/widgets/progressbar"
 ], function( $ ) {
 
 module( "progressbar: methods" );
index 7b6ac9db260a5f35c824f69d015b7e227cdff6b4..533c1535136d0155943484111cfc166543676dd7 100644 (file)
@@ -1,6 +1,6 @@
 define( [
        "jquery",
-       "ui/progressbar"
+       "ui/widgets/progressbar"
 ], function( $ ) {
 
 module( "progressbar: options" );
diff --git a/ui/progressbar.js b/ui/progressbar.js
deleted file mode 100644 (file)
index 7b1cc93..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*!
- * jQuery UI Progressbar @VERSION
- * http://jqueryui.com
- *
- * Copyright jQuery Foundation and other contributors
- * Released under the MIT license.
- * http://jquery.org/license
- */
-
-//>>label: Progressbar
-//>>group: Widgets
-//>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
-//>>docs: http://api.jqueryui.com/progressbar/
-//>>demos: http://jqueryui.com/progressbar/
-//>>css.structure: ../themes/base/core.css
-//>>css.structure: ../themes/base/progressbar.css
-//>>css.theme: ../themes/base/theme.css
-
-( function( factory ) {
-       if ( typeof define === "function" && define.amd ) {
-
-               // AMD. Register as an anonymous module.
-               define( [
-                       "jquery",
-                       "./version",
-                       "./widget"
-               ], factory );
-       } else {
-
-               // Browser globals
-               factory( jQuery );
-       }
-}( function( $ ) {
-
-return $.widget( "ui.progressbar", {
-       version: "@VERSION",
-       options: {
-               classes: {
-                       "ui-progressbar": "ui-corner-all",
-                       "ui-progressbar-value": "ui-corner-left",
-                       "ui-progressbar-complete": "ui-corner-right"
-               },
-               max: 100,
-               value: 0,
-
-               change: null,
-               complete: null
-       },
-
-       min: 0,
-
-       _create: function() {
-
-               // Constrain initial value
-               this.oldValue = this.options.value = this._constrainedValue();
-
-               this.element.attr( {
-
-                       // Only set static values; aria-valuenow and aria-valuemax are
-                       // set inside _refreshValue()
-                       role: "progressbar",
-                       "aria-valuemin": this.min
-               } );
-               this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
-
-               this.valueDiv = $( "<div>" ).appendTo( this.element );
-               this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
-               this._refreshValue();
-       },
-
-       _destroy: function() {
-               this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
-
-               this.valueDiv.remove();
-       },
-
-       value: function( newValue ) {
-               if ( newValue === undefined ) {
-                       return this.options.value;
-               }
-
-               this.options.value = this._constrainedValue( newValue );
-               this._refreshValue();
-       },
-
-       _constrainedValue: function( newValue ) {
-               if ( newValue === undefined ) {
-                       newValue = this.options.value;
-               }
-
-               this.indeterminate = newValue === false;
-
-               // sanitize value
-               if ( typeof newValue !== "number" ) {
-                       newValue = 0;
-               }
-
-               return this.indeterminate ? false :
-                       Math.min( this.options.max, Math.max( this.min, newValue ) );
-       },
-
-       _setOptions: function( options ) {
-               // Ensure "value" option is set after other values (like max)
-               var value = options.value;
-               delete options.value;
-
-               this._super( options );
-
-               this.options.value = this._constrainedValue( value );
-               this._refreshValue();
-       },
-
-       _setOption: function( key, value ) {
-               if ( key === "max" ) {
-                       // Don't allow a max less than min
-                       value = Math.max( this.min, value );
-               }
-               if ( key === "disabled" ) {
-                       this.element.attr( "aria-disabled", value );
-                       this._toggleClass( null, "ui-state-disabled", !!value );
-               }
-               this._super( key, value );
-       },
-
-       _percentage: function() {
-               return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
-       },
-
-       _refreshValue: function() {
-               var value = this.options.value,
-                       percentage = this._percentage();
-
-               this.valueDiv
-                       .toggle( this.indeterminate || value > this.min )
-                       .width( percentage.toFixed( 0 ) + "%" );
-
-               this
-                       ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
-                               value === this.options.max )
-                       ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
-
-               if ( this.indeterminate ) {
-                       this.element.removeAttr( "aria-valuenow" );
-                       if ( !this.overlayDiv ) {
-                               this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
-                               this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
-                       }
-               } else {
-                       this.element.attr( {
-                               "aria-valuemax": this.options.max,
-                               "aria-valuenow": value
-                       } );
-                       if ( this.overlayDiv ) {
-                               this.overlayDiv.remove();
-                               this.overlayDiv = null;
-                       }
-               }
-
-               if ( this.oldValue !== value ) {
-                       this.oldValue = value;
-                       this._trigger( "change" );
-               }
-               if ( value === this.options.max ) {
-                       this._trigger( "complete" );
-               }
-       }
-} );
-
-} ) );
diff --git a/ui/widgets/progressbar.js b/ui/widgets/progressbar.js
new file mode 100644 (file)
index 0000000..a52cbb7
--- /dev/null
@@ -0,0 +1,169 @@
+/*!
+ * jQuery UI Progressbar @VERSION
+ * http://jqueryui.com
+ *
+ * Copyright jQuery Foundation and other contributors
+ * Released under the MIT license.
+ * http://jquery.org/license
+ */
+
+//>>label: Progressbar
+//>>group: Widgets
+//>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
+//>>docs: http://api.jqueryui.com/progressbar/
+//>>demos: http://jqueryui.com/progressbar/
+//>>css.structure: ../themes/base/core.css
+//>>css.structure: ../themes/base/progressbar.css
+//>>css.theme: ../themes/base/theme.css
+
+( function( factory ) {
+       if ( typeof define === "function" && define.amd ) {
+
+               // AMD. Register as an anonymous module.
+               define( [
+                       "jquery",
+                       "../version",
+                       "../widget"
+               ], factory );
+       } else {
+
+               // Browser globals
+               factory( jQuery );
+       }
+}( function( $ ) {
+
+return $.widget( "ui.progressbar", {
+       version: "@VERSION",
+       options: {
+               classes: {
+                       "ui-progressbar": "ui-corner-all",
+                       "ui-progressbar-value": "ui-corner-left",
+                       "ui-progressbar-complete": "ui-corner-right"
+               },
+               max: 100,
+               value: 0,
+
+               change: null,
+               complete: null
+       },
+
+       min: 0,
+
+       _create: function() {
+
+               // Constrain initial value
+               this.oldValue = this.options.value = this._constrainedValue();
+
+               this.element.attr( {
+
+                       // Only set static values; aria-valuenow and aria-valuemax are
+                       // set inside _refreshValue()
+                       role: "progressbar",
+                       "aria-valuemin": this.min
+               } );
+               this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
+
+               this.valueDiv = $( "<div>" ).appendTo( this.element );
+               this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
+               this._refreshValue();
+       },
+
+       _destroy: function() {
+               this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
+
+               this.valueDiv.remove();
+       },
+
+       value: function( newValue ) {
+               if ( newValue === undefined ) {
+                       return this.options.value;
+               }
+
+               this.options.value = this._constrainedValue( newValue );
+               this._refreshValue();
+       },
+
+       _constrainedValue: function( newValue ) {
+               if ( newValue === undefined ) {
+                       newValue = this.options.value;
+               }
+
+               this.indeterminate = newValue === false;
+
+               // sanitize value
+               if ( typeof newValue !== "number" ) {
+                       newValue = 0;
+               }
+
+               return this.indeterminate ? false :
+                       Math.min( this.options.max, Math.max( this.min, newValue ) );
+       },
+
+       _setOptions: function( options ) {
+               // Ensure "value" option is set after other values (like max)
+               var value = options.value;
+               delete options.value;
+
+               this._super( options );
+
+               this.options.value = this._constrainedValue( value );
+               this._refreshValue();
+       },
+
+       _setOption: function( key, value ) {
+               if ( key === "max" ) {
+                       // Don't allow a max less than min
+                       value = Math.max( this.min, value );
+               }
+               if ( key === "disabled" ) {
+                       this.element.attr( "aria-disabled", value );
+                       this._toggleClass( null, "ui-state-disabled", !!value );
+               }
+               this._super( key, value );
+       },
+
+       _percentage: function() {
+               return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
+       },
+
+       _refreshValue: function() {
+               var value = this.options.value,
+                       percentage = this._percentage();
+
+               this.valueDiv
+                       .toggle( this.indeterminate || value > this.min )
+                       .width( percentage.toFixed( 0 ) + "%" );
+
+               this
+                       ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
+                               value === this.options.max )
+                       ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
+
+               if ( this.indeterminate ) {
+                       this.element.removeAttr( "aria-valuenow" );
+                       if ( !this.overlayDiv ) {
+                               this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
+                               this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
+                       }
+               } else {
+                       this.element.attr( {
+                               "aria-valuemax": this.options.max,
+                               "aria-valuenow": value
+                       } );
+                       if ( this.overlayDiv ) {
+                               this.overlayDiv.remove();
+                               this.overlayDiv = null;
+                       }
+               }
+
+               if ( this.oldValue !== value ) {
+                       this.oldValue = value;
+                       this._trigger( "change" );
+               }
+               if ( value === this.options.max ) {
+                       this._trigger( "complete" );
+               }
+       }
+} );
+
+} ) );