@@ -40,7 +40,7 @@ $.cleanData = ( function( orig ) {
40
40
$ ( elem ) . triggerHandler ( "remove" ) ;
41
41
}
42
42
43
- // http ://bugs.jquery.com/ticket/8235
43
+ // Http ://bugs.jquery.com/ticket/8235
44
44
} catch ( e ) { }
45
45
}
46
46
orig ( elems ) ;
@@ -49,7 +49,8 @@ $.cleanData = ( function( orig ) {
49
49
50
50
$ . widget = function ( name , base , prototype ) {
51
51
var fullName , existingConstructor , constructor , basePrototype ,
52
- // proxiedPrototype allows the provided prototype to remain unmodified
52
+
53
+ // ProxiedPrototype allows the provided prototype to remain unmodified
53
54
// so that it can be used as a mixin for multiple widgets (#8876)
54
55
proxiedPrototype = { } ,
55
56
namespace = name . split ( "." ) [ 0 ] ;
@@ -66,38 +67,43 @@ $.widget = function( name, base, prototype ) {
66
67
prototype = $ . extend . apply ( null , [ { } ] . concat ( prototype ) ) ;
67
68
}
68
69
69
- // create selector for plugin
70
+ // Create selector for plugin
70
71
$ . expr [ ":" ] [ fullName . toLowerCase ( ) ] = function ( elem ) {
71
72
return ! ! $ . data ( elem , fullName ) ;
72
73
} ;
73
74
74
75
$ [ namespace ] = $ [ namespace ] || { } ;
75
76
existingConstructor = $ [ namespace ] [ name ] ;
76
77
constructor = $ [ namespace ] [ name ] = function ( options , element ) {
77
- // allow instantiation without "new" keyword
78
+
79
+ // Allow instantiation without "new" keyword
78
80
if ( ! this . _createWidget ) {
79
81
return new constructor ( options , element ) ;
80
82
}
81
83
82
- // allow instantiation without initializing for simple inheritance
84
+ // Allow instantiation without initializing for simple inheritance
83
85
// must use "new" keyword (the code above always passes args)
84
86
if ( arguments . length ) {
85
87
this . _createWidget ( options , element ) ;
86
88
}
87
89
} ;
88
- // extend with the existing constructor to carry over any static properties
90
+
91
+ // Extend with the existing constructor to carry over any static properties
89
92
$ . extend ( constructor , existingConstructor , {
90
93
version : prototype . version ,
91
- // copy the object used to create the prototype in case we need to
94
+
95
+ // Copy the object used to create the prototype in case we need to
92
96
// redefine the widget later
93
97
_proto : $ . extend ( { } , prototype ) ,
94
- // track widgets that inherit from this widget in case this widget is
98
+
99
+ // Track widgets that inherit from this widget in case this widget is
95
100
// redefined after a widget inherits from it
96
101
_childConstructors : [ ]
97
102
} ) ;
98
103
99
104
basePrototype = new base ( ) ;
100
- // we need to make the options hash a property directly on the new instance
105
+
106
+ // We need to make the options hash a property directly on the new instance
101
107
// otherwise we'll modify the options hash on the prototype that we're
102
108
// inheriting from
103
109
basePrototype . options = $ . widget . extend ( { } , basePrototype . options ) ;
@@ -131,6 +137,7 @@ $.widget = function( name, base, prototype ) {
131
137
} ) ( ) ;
132
138
} ) ;
133
139
constructor . prototype = $ . widget . extend ( basePrototype , {
140
+
134
141
// TODO: remove support for widgetEventPrefix
135
142
// always use the name + a colon as the prefix, e.g., draggable:start
136
143
// don't prefix for widgets that aren't DOM-based
@@ -150,11 +157,12 @@ $.widget = function( name, base, prototype ) {
150
157
$ . each ( existingConstructor . _childConstructors , function ( i , child ) {
151
158
var childPrototype = child . prototype ;
152
159
153
- // redefine the child widget using the same prototype that was
160
+ // Redefine the child widget using the same prototype that was
154
161
// originally used, but inherit from the new version of the base
155
162
$ . widget ( childPrototype . namespace + "." + childPrototype . widgetName , constructor , child . _proto ) ;
156
163
} ) ;
157
- // remove the list of existing child constructors from the old constructor
164
+
165
+ // Remove the list of existing child constructors from the old constructor
158
166
// so the old child constructors can be garbage collected
159
167
delete existingConstructor . _childConstructors ;
160
168
} else {
@@ -176,12 +184,15 @@ $.widget.extend = function( target ) {
176
184
for ( key in input [ inputIndex ] ) {
177
185
value = input [ inputIndex ] [ key ] ;
178
186
if ( input [ inputIndex ] . hasOwnProperty ( key ) && value !== undefined ) {
187
+
179
188
// Clone objects
180
189
if ( $ . isPlainObject ( value ) ) {
181
190
target [ key ] = $ . isPlainObject ( target [ key ] ) ?
182
191
$ . widget . extend ( { } , target [ key ] , value ) :
192
+
183
193
// Don't extend strings, arrays, etc. with objects
184
194
$ . widget . extend ( { } , value ) ;
195
+
185
196
// Copy everything else by reference
186
197
} else {
187
198
target [ key ] = value ;
@@ -257,7 +268,7 @@ $.Widget.prototype = {
257
268
classes : { } ,
258
269
disabled : false ,
259
270
260
- // callbacks
271
+ // Callbacks
261
272
create : null
262
273
} ,
263
274
_createWidget : function ( options , element ) {
@@ -281,9 +292,11 @@ $.Widget.prototype = {
281
292
}
282
293
} ) ;
283
294
this . document = $ ( element . style ?
284
- // element within the document
295
+
296
+ // Element within the document
285
297
element . ownerDocument :
286
- // element is window or document
298
+
299
+ // Element is window or document
287
300
element . document || element ) ;
288
301
this . window = $ ( this . document [ 0 ] . defaultView || this . document [ 0 ] . parentWindow ) ;
289
302
}
@@ -310,7 +323,7 @@ $.Widget.prototype = {
310
323
that . _removeClass ( value , key ) ;
311
324
} ) ;
312
325
313
- // we can probably remove the unbind calls in 2.0
326
+ // We can probably remove the unbind calls in 2.0
314
327
// all event bindings should go through this._on()
315
328
this . element
316
329
. off ( this . eventNamespace )
@@ -319,7 +332,7 @@ $.Widget.prototype = {
319
332
. off ( this . eventNamespace )
320
333
. removeAttr ( "aria-disabled" ) ;
321
334
322
- // clean up events and states
335
+ // Clean up events and states
323
336
this . bindings . off ( this . eventNamespace ) ;
324
337
} ,
325
338
_destroy : $ . noop ,
@@ -335,12 +348,14 @@ $.Widget.prototype = {
335
348
i ;
336
349
337
350
if ( arguments . length === 0 ) {
338
- // don't return a reference to the internal hash
351
+
352
+ // Don't return a reference to the internal hash
339
353
return $ . widget . extend ( { } , this . options ) ;
340
354
}
341
355
342
356
if ( typeof key === "string" ) {
343
- // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
357
+
358
+ // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
344
359
options = { } ;
345
360
parts = key . split ( "." ) ;
346
361
key = parts . shift ( ) ;
@@ -494,14 +509,14 @@ $.Widget.prototype = {
494
509
var delegateElement ,
495
510
instance = this ;
496
511
497
- // no suppressDisabledCheck flag, shuffle arguments
512
+ // No suppressDisabledCheck flag, shuffle arguments
498
513
if ( typeof suppressDisabledCheck !== "boolean" ) {
499
514
handlers = element ;
500
515
element = suppressDisabledCheck ;
501
516
suppressDisabledCheck = false ;
502
517
}
503
518
504
- // no element argument, shuffle and use this.element
519
+ // No element argument, shuffle and use this.element
505
520
if ( ! handlers ) {
506
521
handlers = element ;
507
522
element = this . element ;
@@ -513,7 +528,8 @@ $.Widget.prototype = {
513
528
514
529
$ . each ( handlers , function ( event , handler ) {
515
530
function handlerProxy ( ) {
516
- // allow widgets to customize the disabled handling
531
+
532
+ // Allow widgets to customize the disabled handling
517
533
// - disabled as an array instead of boolean
518
534
// - disabled class as method for disabling individual parts
519
535
if ( ! suppressDisabledCheck &&
@@ -525,7 +541,7 @@ $.Widget.prototype = {
525
541
. apply ( instance , arguments ) ;
526
542
}
527
543
528
- // copy the guid so direct unbinding works
544
+ // Copy the guid so direct unbinding works
529
545
if ( typeof handler !== "string" ) {
530
546
handlerProxy . guid = handler . guid =
531
547
handler . guid || handlerProxy . guid || $ . guid ++ ;
@@ -595,11 +611,12 @@ $.Widget.prototype = {
595
611
event . type = ( type === this . widgetEventPrefix ?
596
612
type :
597
613
this . widgetEventPrefix + type ) . toLowerCase ( ) ;
598
- // the original event may come from any element
614
+
615
+ // The original event may come from any element
599
616
// so we need to reset the target on the new event
600
617
event . target = this . element [ 0 ] ;
601
618
602
- // copy original event properties over to the new event
619
+ // Copy original event properties over to the new event
603
620
orig = event . originalEvent ;
604
621
if ( orig ) {
605
622
for ( prop in orig ) {
0 commit comments