13
13
//>>docs: http://api.jqueryui.com/jQuery.widget/
14
14
//>>demos: http://jqueryui.com/widget/
15
15
16
- ( function ( factory ) {
16
+ ( function ( factory ) {
17
17
if ( typeof define === "function" && define . amd ) {
18
18
19
19
// AMD. Register as an anonymous module.
23
23
// Browser globals
24
24
factory ( jQuery ) ;
25
25
}
26
- } ( function ( $ ) {
26
+ } ( function ( $ ) {
27
27
28
28
var widget_uuid = 0 ,
29
29
widget_slice = Array . prototype . slice ;
30
30
31
- $ . cleanData = ( function ( orig ) {
31
+ $ . cleanData = ( function ( orig ) {
32
32
return function ( elems ) {
33
33
var events , elem , i ;
34
- for ( i = 0 ; ( elem = elems [ i ] ) != null ; i ++ ) {
34
+ for ( i = 0 ; ( elem = elems [ i ] ) != null ; i ++ ) {
35
35
try {
36
36
37
37
// Only trigger remove when necessary to save time
@@ -45,7 +45,7 @@ $.cleanData = (function( orig ) {
45
45
}
46
46
orig ( elems ) ;
47
47
} ;
48
- } ) ( $ . cleanData ) ;
48
+ } ) ( $ . cleanData ) ;
49
49
50
50
$ . widget = function ( name , base , prototype ) {
51
51
var fullName , existingConstructor , constructor , basePrototype ,
@@ -90,7 +90,7 @@ $.widget = function( name, base, prototype ) {
90
90
// track widgets that inherit from this widget in case this widget is
91
91
// redefined after a widget inherits from it
92
92
_childConstructors : [ ]
93
- } ) ;
93
+ } ) ;
94
94
95
95
basePrototype = new base ( ) ;
96
96
// we need to make the options hash a property directly on the new instance
@@ -102,7 +102,7 @@ $.widget = function( name, base, prototype ) {
102
102
proxiedPrototype [ prop ] = value ;
103
103
return ;
104
104
}
105
- proxiedPrototype [ prop ] = ( function ( ) {
105
+ proxiedPrototype [ prop ] = ( function ( ) {
106
106
var _super = function ( ) {
107
107
return base . prototype [ prop ] . apply ( this , arguments ) ;
108
108
} ,
@@ -124,19 +124,19 @@ $.widget = function( name, base, prototype ) {
124
124
125
125
return returnValue ;
126
126
} ;
127
- } ) ( ) ;
128
- } ) ;
127
+ } ) ( ) ;
128
+ } ) ;
129
129
constructor . prototype = $ . widget . extend ( basePrototype , {
130
130
// TODO: remove support for widgetEventPrefix
131
131
// always use the name + a colon as the prefix, e.g., draggable:start
132
132
// don't prefix for widgets that aren't DOM-based
133
- widgetEventPrefix : existingConstructor ? ( basePrototype . widgetEventPrefix || name ) : name
133
+ widgetEventPrefix : existingConstructor ? ( basePrototype . widgetEventPrefix || name ) : name
134
134
} , proxiedPrototype , {
135
135
constructor : constructor ,
136
136
namespace : namespace ,
137
137
widgetName : name ,
138
138
widgetFullName : fullName
139
- } ) ;
139
+ } ) ;
140
140
141
141
// If this widget is being redefined then we need to find all widgets that
142
142
// are inheriting from it and redefine all of them so that they inherit from
@@ -149,7 +149,7 @@ $.widget = function( name, base, prototype ) {
149
149
// redefine the child widget using the same prototype that was
150
150
// originally used, but inherit from the new version of the base
151
151
$ . widget ( childPrototype . namespace + "." + childPrototype . widgetName , constructor , child . _proto ) ;
152
- } ) ;
152
+ } ) ;
153
153
// remove the list of existing child constructors from the old constructor
154
154
// so the old child constructors can be garbage collected
155
155
delete existingConstructor . _childConstructors ;
@@ -196,7 +196,7 @@ $.widget.bridge = function( name, object ) {
196
196
returnValue = this ;
197
197
198
198
if ( isMethodCall ) {
199
- this . each ( function ( ) {
199
+ this . each ( function ( ) {
200
200
var methodValue ,
201
201
instance = $ . data ( this , fullName ) ;
202
202
if ( options === "instance" ) {
@@ -207,7 +207,7 @@ $.widget.bridge = function( name, object ) {
207
207
return $ . error ( "cannot call methods on " + name + " prior to initialization; " +
208
208
"attempted to call method '" + options + "'" ) ;
209
209
}
210
- if ( ! $ . isFunction ( instance [ options ] ) || options . charAt ( 0 ) === "_" ) {
210
+ if ( ! $ . isFunction ( instance [ options ] ) || options . charAt ( 0 ) === "_" ) {
211
211
return $ . error ( "no such method '" + options + "' for " + name + " widget instance" ) ;
212
212
}
213
213
methodValue = instance [ options ] . apply ( instance , args ) ;
@@ -217,15 +217,15 @@ $.widget.bridge = function( name, object ) {
217
217
methodValue ;
218
218
return false ;
219
219
}
220
- } ) ;
220
+ } ) ;
221
221
} else {
222
222
223
223
// Allow multiple hashes to be passed on init
224
224
if ( args . length ) {
225
- options = $ . widget . extend . apply ( null , [ options ] . concat ( args ) ) ;
225
+ options = $ . widget . extend . apply ( null , [ options ] . concat ( args ) ) ;
226
226
}
227
227
228
- this . each ( function ( ) {
228
+ this . each ( function ( ) {
229
229
var instance = $ . data ( this , fullName ) ;
230
230
if ( instance ) {
231
231
instance . option ( options || { } ) ;
@@ -235,7 +235,7 @@ $.widget.bridge = function( name, object ) {
235
235
} else {
236
236
$ . data ( this , fullName , new object ( options , this ) ) ;
237
237
}
238
- } ) ;
238
+ } ) ;
239
239
}
240
240
241
241
return returnValue ;
@@ -275,13 +275,13 @@ $.Widget.prototype = {
275
275
this . destroy ( ) ;
276
276
}
277
277
}
278
- } ) ;
278
+ } ) ;
279
279
this . document = $ ( element . style ?
280
280
// element within the document
281
281
element . ownerDocument :
282
282
// element is window or document
283
283
element . document || element ) ;
284
- this . window = $ ( this . document [ 0 ] . defaultView || this . document [ 0 ] . parentWindow ) ;
284
+ this . window = $ ( this . document [ 0 ] . defaultView || this . document [ 0 ] . parentWindow ) ;
285
285
}
286
286
287
287
this . options = $ . widget . extend ( { } ,
@@ -304,7 +304,7 @@ $.Widget.prototype = {
304
304
this . _destroy ( ) ;
305
305
$ . each ( this . classesElementLookup , function ( key , value ) {
306
306
that . _removeClass ( value , key ) ;
307
- } ) ;
307
+ } ) ;
308
308
309
309
// we can probably remove the unbind calls in 2.0
310
310
// all event bindings should go through this._on()
@@ -413,27 +413,27 @@ $.Widget.prototype = {
413
413
// for generating the string of classes. We want to use the value passed in from
414
414
// _setOption(), this is the new value of the classes option which was passed to
415
415
// _setOption(). We pass this value directly to _classes().
416
- elements . addClass ( this . _classes ( {
416
+ elements . addClass ( this . _classes ( {
417
417
element : elements ,
418
418
keys : classKey ,
419
419
classes : value ,
420
420
add : true
421
- } ) ) ;
421
+ } ) ) ;
422
422
}
423
423
} ,
424
424
425
425
enable : function ( ) {
426
- return this . _setOptions ( { disabled : false } ) ;
426
+ return this . _setOptions ( { disabled : false } ) ;
427
427
} ,
428
428
disable : function ( ) {
429
- return this . _setOptions ( { disabled : true } ) ;
429
+ return this . _setOptions ( { disabled : true } ) ;
430
430
} ,
431
431
432
432
_classes : function ( options ) {
433
433
var full = [ ] ,
434
434
that = this ;
435
435
436
- options = $ . extend ( {
436
+ options = $ . extend ( {
437
437
element : this . element ,
438
438
classes : this . options . classes || { }
439
439
} , options ) ;
@@ -514,7 +514,7 @@ $.Widget.prototype = {
514
514
// - disabled class as method for disabling individual parts
515
515
if ( ! suppressDisabledCheck &&
516
516
( instance . options . disabled === true ||
517
- $ ( this ) . hasClass ( "ui-state-disabled" ) ) ) {
517
+ $ ( this ) . hasClass ( "ui-state-disabled" ) ) ) {
518
518
return ;
519
519
}
520
520
return ( typeof handler === "string" ? instance [ handler ] : handler )
@@ -528,18 +528,18 @@ $.Widget.prototype = {
528
528
}
529
529
530
530
var match = event . match ( / ^ ( [ \w : - ] * ) \s * ( .* ) $ / ) ,
531
- eventName = match [ 1 ] + instance . eventNamespace ,
532
- selector = match [ 2 ] ;
531
+ eventName = match [ 1 ] + instance . eventNamespace ,
532
+ selector = match [ 2 ] ;
533
533
if ( selector ) {
534
534
delegateElement . delegate ( selector , eventName , handlerProxy ) ;
535
535
} else {
536
536
element . bind ( eventName , handlerProxy ) ;
537
537
}
538
- } ) ;
538
+ } ) ;
539
539
} ,
540
540
541
541
_off : function ( element , eventName ) {
542
- eventName = ( eventName || "" ) . split ( " " ) . join ( this . eventNamespace + " " ) +
542
+ eventName = ( eventName || "" ) . split ( " " ) . join ( this . eventNamespace + " " ) +
543
543
this . eventNamespace ;
544
544
element . unbind ( eventName ) . undelegate ( eventName ) ;
545
545
@@ -567,7 +567,7 @@ $.Widget.prototype = {
567
567
mouseleave : function ( event ) {
568
568
this . _removeClass ( $ ( event . currentTarget ) , null , "ui-state-hover" ) ;
569
569
}
570
- } ) ;
570
+ } ) ;
571
571
} ,
572
572
573
573
_focusable : function ( element ) {
@@ -579,7 +579,7 @@ $.Widget.prototype = {
579
579
focusout : function ( event ) {
580
580
this . _removeClass ( $ ( event . currentTarget ) , null , "ui-state-focus" ) ;
581
581
}
582
- } ) ;
582
+ } ) ;
583
583
} ,
584
584
585
585
_trigger : function ( type , event , data ) {
@@ -607,7 +607,7 @@ $.Widget.prototype = {
607
607
608
608
this . element . trigger ( event , data ) ;
609
609
return ! ( $ . isFunction ( callback ) &&
610
- callback . apply ( this . element [ 0 ] , [ event ] . concat ( data ) ) === false ||
610
+ callback . apply ( this . element [ 0 ] , [ event ] . concat ( data ) ) === false ||
611
611
event . isDefaultPrevented ( ) ) ;
612
612
}
613
613
} ;
@@ -637,17 +637,17 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
637
637
} else if ( effectName !== method && element [ effectName ] ) {
638
638
element [ effectName ] ( options . duration , options . easing , callback ) ;
639
639
} else {
640
- element . queue ( function ( next ) {
640
+ element . queue ( function ( next ) {
641
641
$ ( this ) [ method ] ( ) ;
642
642
if ( callback ) {
643
643
callback . call ( element [ 0 ] ) ;
644
644
}
645
645
next ( ) ;
646
- } ) ;
646
+ } ) ;
647
647
}
648
648
} ;
649
- } ) ;
649
+ } ) ;
650
650
651
651
return $ . widget ;
652
652
653
- } ) ) ;
653
+ } ) ) ;
0 commit comments