From: Alexander Schmitz Date: Wed, 15 Jul 2015 02:04:22 +0000 (-0400) Subject: Progressbar: Move progressbar into widgets folder X-Git-Tag: 1.12.0-beta.1~204 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=92e267903ebc4c1c0fc26468055296dd906ef76b;p=jquery-ui.git Progressbar: Move progressbar into widgets folder Ref #13885 --- diff --git a/demos/bootstrap.js b/demos/bootstrap.js index 15f220c21..5a5d88889 100644 --- a/demos/bootstrap.js +++ b/demos/bootstrap.js @@ -32,7 +32,8 @@ var widgets = [ "dialog", "draggable", "droppable", - "menu" + "menu", + "progressbar" ]; function getPath( module ) { diff --git a/tests/unit/progressbar/common.js b/tests/unit/progressbar/common.js index c949f136f..baadb6d53 100644 --- a/tests/unit/progressbar/common.js +++ b/tests/unit/progressbar/common.js @@ -1,6 +1,6 @@ define( [ "lib/common", - "ui/progressbar" + "ui/widgets/progressbar" ], function( common ) { common.testWidget( "progressbar", { diff --git a/tests/unit/progressbar/core.js b/tests/unit/progressbar/core.js index 05eea9ef7..8c09f67ae 100644 --- a/tests/unit/progressbar/core.js +++ b/tests/unit/progressbar/core.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/progressbar" + "ui/widgets/progressbar" ], function( $ ) { module( "progressbar: core" ); diff --git a/tests/unit/progressbar/events.js b/tests/unit/progressbar/events.js index a40b2c432..7f4926466 100644 --- a/tests/unit/progressbar/events.js +++ b/tests/unit/progressbar/events.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/progressbar" + "ui/widgets/progressbar" ], function( $ ) { module( "progressbar: events" ); diff --git a/tests/unit/progressbar/methods.js b/tests/unit/progressbar/methods.js index eaf0a5c76..00de2f46e 100644 --- a/tests/unit/progressbar/methods.js +++ b/tests/unit/progressbar/methods.js @@ -1,6 +1,6 @@ define( [ "jquery", - "ui/progressbar" + "ui/widgets/progressbar" ], function( $ ) { module( "progressbar: methods" ); diff --git a/tests/unit/progressbar/options.js b/tests/unit/progressbar/options.js index 7b6ac9db2..533c15351 100644 --- a/tests/unit/progressbar/options.js +++ b/tests/unit/progressbar/options.js @@ -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 index 7b1cc9351..000000000 --- a/ui/progressbar.js +++ /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 = $( "
" ).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 = $( "
" ).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 index 000000000..a52cbb713 --- /dev/null +++ b/ui/widgets/progressbar.js @@ -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 = $( "
" ).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 = $( "
" ).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" ); + } + } +} ); + +} ) );