wiki.techinc.nl/resources/lib/jquery.ui/jquery.ui.progressbar.js
Timo Tijhof 3cb2ccd878 Upgrade jQuery UI from 1.8.24 to 1.9.2
jQuery UI 1.10 has already been released, and 1.11 is on the
horizon (1.9 is marked "legacy" as of writing). 1.10 drops the
compatibility layer for 1.8 API. So, users should definitely be
encouraged to upgrade their code to move away from the deprecated
1.8 APIs. However, to take it one step at a time, this commit
upgrades us to 1.9 first. That way we're at least not using an
unsupported code base anymore, while at the same time not rolling
out breaking changes.

jQuery UI has redesigned many of its APIs[1], but compatibility
with the jQuery UI 1.8 API is maintained throughout 1.9.x.

* Base theme is now called "Smoothness".

* Sorting the entries in Resources.php alphabetically to make it
  easier to ensure all files are listed when comparing them
  side-by-side.

* Update dependencies to match the "Depends:" header inside
  the javascript files.

* In jQuery UI 1.9, effect files were renamed to match the
  jquery.ui.*.js naming pattern.

* New modules:
  - jquery.ui.menu
  - jquery.ui.spinner
  - jquery.ui.tooltip

* Release notes:
  - http://blog.jqueryui.com/2012/10/jquery-ui-1-9-0/
    - http://jqueryui.com/upgrade-guide/1.9/
    - http://jqueryui.com/changelog/1.9.0/
  - http://blog.jqueryui.com/2012/10/jquery-ui-1-9-1/
    - http://jqueryui.com/changelog/1.9.1/
  - http://blog.jqueryui.com/2012/11/jquery-ui-1-9-2/

[1] http://blog.jqueryui.com/2011/03/api-redesigns-the-past-present-and-future/

Bug: 47076
Change-Id: I0e10b42fb7c25b9d4704719f21c44c08f36ddfa7
2014-06-05 00:29:23 +02:00

105 lines
2.2 KiB
JavaScript

/*!
* jQuery UI Progressbar 1.9.2
* http://jqueryui.com
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
* http://api.jqueryui.com/progressbar/
*
* Depends:
* jquery.ui.core.js
* jquery.ui.widget.js
*/
(function( $, undefined ) {
$.widget( "ui.progressbar", {
version: "1.9.2",
options: {
value: 0,
max: 100
},
min: 0,
_create: function() {
this.element
.addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
.attr({
role: "progressbar",
"aria-valuemin": this.min,
"aria-valuemax": this.options.max,
"aria-valuenow": this._value()
});
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
.appendTo( this.element );
this.oldValue = this._value();
this._refreshValue();
},
_destroy: function() {
this.element
.removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
.removeAttr( "role" )
.removeAttr( "aria-valuemin" )
.removeAttr( "aria-valuemax" )
.removeAttr( "aria-valuenow" );
this.valueDiv.remove();
},
value: function( newValue ) {
if ( newValue === undefined ) {
return this._value();
}
this._setOption( "value", newValue );
return this;
},
_setOption: function( key, value ) {
if ( key === "value" ) {
this.options.value = value;
this._refreshValue();
if ( this._value() === this.options.max ) {
this._trigger( "complete" );
}
}
this._super( key, value );
},
_value: function() {
var val = this.options.value;
// normalize invalid value
if ( typeof val !== "number" ) {
val = 0;
}
return Math.min( this.options.max, Math.max( this.min, val ) );
},
_percentage: function() {
return 100 * this._value() / this.options.max;
},
_refreshValue: function() {
var value = this.value(),
percentage = this._percentage();
if ( this.oldValue !== value ) {
this.oldValue = value;
this._trigger( "change" );
}
this.valueDiv
.toggle( value > this.min )
.toggleClass( "ui-corner-right", value === this.options.max )
.width( percentage.toFixed(0) + "%" );
this.element.attr( "aria-valuenow", value );
}
});
})( jQuery );