|
11 | 11 | * jquery.ui.core.js
|
12 | 12 | * jquery.ui.widget.js
|
13 | 13 | */
|
14 |
| -(function($) { |
| 14 | +(function( $ ) { |
15 | 15 |
|
16 |
| -$.widget("ui.progressbar", { |
| 16 | +$.widget( "ui.progressbar", { |
17 | 17 | options: {
|
18 | 18 | value: 0
|
19 | 19 | },
|
20 | 20 | _create: function() {
|
21 |
| - |
22 | 21 | this.element
|
23 |
| - .addClass("ui-progressbar" |
24 |
| - + " ui-widget" |
25 |
| - + " ui-widget-content" |
26 |
| - + " ui-corner-all") |
| 22 | + .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) |
27 | 23 | .attr({
|
28 | 24 | role: "progressbar",
|
29 | 25 | "aria-valuemin": this._valueMin(),
|
30 | 26 | "aria-valuemax": this._valueMax(),
|
31 | 27 | "aria-valuenow": this._value()
|
32 | 28 | });
|
33 | 29 |
|
34 |
| - this.valueDiv = $('<div class="ui-progressbar-value ui-widget-header ui-corner-left"></div>').appendTo(this.element); |
| 30 | + this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" ) |
| 31 | + .appendTo( this.element ); |
35 | 32 |
|
36 | 33 | this._refreshValue();
|
37 |
| - |
38 | 34 | },
|
39 | 35 |
|
40 | 36 | destroy: function() {
|
41 |
| - |
42 | 37 | this.element
|
43 |
| - .removeClass("ui-progressbar" |
44 |
| - + " ui-widget" |
45 |
| - + " ui-widget-content" |
46 |
| - + " ui-corner-all") |
47 |
| - .removeAttr("role") |
48 |
| - .removeAttr("aria-valuemin") |
49 |
| - .removeAttr("aria-valuemax") |
50 |
| - .removeAttr("aria-valuenow") |
51 |
| - .removeData("progressbar") |
52 |
| - .unbind(".progressbar"); |
| 38 | + .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) |
| 39 | + .removeAttr( "role" ) |
| 40 | + .removeAttr( "aria-valuemin" ) |
| 41 | + .removeAttr( "aria-valuemax" ) |
| 42 | + .removeAttr( "aria-valuenow" ); |
53 | 43 |
|
54 | 44 | this.valueDiv.remove();
|
55 | 45 |
|
56 |
| - $.Widget.prototype.destroy.apply(this, arguments); |
57 |
| - |
58 |
| - return this; |
| 46 | + $.Widget.prototype.destroy.apply( this, arguments ); |
59 | 47 | },
|
60 | 48 |
|
61 |
| - value: function(newValue) { |
62 |
| - if (newValue === undefined) { |
| 49 | + value: function( newValue ) { |
| 50 | + if ( newValue === undefined ) { |
63 | 51 | return this._value();
|
64 | 52 | }
|
65 |
| - |
66 |
| - this._setOption('value', newValue); |
| 53 | + |
| 54 | + this._setOption( "value", newValue ); |
67 | 55 | return this;
|
68 | 56 | },
|
69 | 57 |
|
70 |
| - _setOption: function(key, value) { |
71 |
| - |
72 |
| - switch (key) { |
73 |
| - case 'value': |
| 58 | + _setOption: function( key, value ) { |
| 59 | + switch ( key ) { |
| 60 | + case "value": |
74 | 61 | this.options.value = value;
|
75 | 62 | this._refreshValue();
|
76 |
| - this._trigger('change', null, {}); |
| 63 | + this._trigger( "change" ); |
77 | 64 | break;
|
78 | 65 | }
|
79 | 66 |
|
80 |
| - $.Widget.prototype._setOption.apply(this, arguments); |
81 |
| - |
| 67 | + $.Widget.prototype._setOption.apply( this, arguments ); |
82 | 68 | },
|
83 | 69 |
|
84 | 70 | _value: function() {
|
85 | 71 | var val = this.options.value;
|
86 | 72 | // normalize invalid value
|
87 |
| - if (typeof val != "number") |
| 73 | + if ( typeof val !== "number" ) { |
88 | 74 | val = 0;
|
89 |
| - if (val < this._valueMin()) val = this._valueMin(); |
90 |
| - if (val > this._valueMax()) val = this._valueMax(); |
| 75 | + } |
| 76 | + if ( val < this._valueMin() ) { |
| 77 | + val = this._valueMin(); |
| 78 | + } |
| 79 | + if ( val > this._valueMax() ) { |
| 80 | + val = this._valueMax(); |
| 81 | + } |
91 | 82 |
|
92 | 83 | return val;
|
93 |
| - |
94 | 84 | },
|
95 | 85 |
|
96 | 86 | _valueMin: function() {
|
97 |
| - var valueMin = 0; |
98 |
| - return valueMin; |
| 87 | + return 0; |
99 | 88 | },
|
100 | 89 |
|
101 | 90 | _valueMax: function() {
|
102 |
| - var valueMax = 100; |
103 |
| - return valueMax; |
| 91 | + return 100; |
104 | 92 | },
|
105 | 93 |
|
106 | 94 | _refreshValue: function() {
|
107 | 95 | var value = this.value();
|
108 |
| - this.valueDiv[value == this._valueMax() ? 'addClass' : 'removeClass']("ui-corner-right"); |
109 |
| - this.valueDiv.width(value + '%'); |
110 |
| - this.element.attr("aria-valuenow", value); |
| 96 | + this.valueDiv |
| 97 | + [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" ) |
| 98 | + .width( value + "%" ); |
| 99 | + this.element.attr( "aria-valuenow", value ); |
111 | 100 | }
|
112 |
| - |
113 | 101 | });
|
114 | 102 |
|
115 |
| -$.extend($.ui.progressbar, { |
| 103 | +$.extend( $.ui.progressbar, { |
116 | 104 | version: "@VERSION"
|
117 | 105 | });
|
118 | 106 |
|
119 |
| -})(jQuery); |
| 107 | +})( jQuery ); |
0 commit comments