FossilRepo

fossilrepo / assets / admin / js / vendor / jquery / jquery.12e87d2f3a4c.js
Blame History Raw 10717 lines
1
/*!
2
* jQuery JavaScript Library v3.7.1
3
* https://jquery.com/
4
*
5
* Copyright OpenJS Foundation and other contributors
6
* Released under the MIT license
7
* https://jquery.org/license
8
*
9
* Date: 2023-08-28T13:37Z
10
*/
11
( function( global, factory ) {
12
13
"use strict";
14
15
if ( typeof module === "object" && typeof module.exports === "object" ) {
16
17
// For CommonJS and CommonJS-like environments where a proper `window`
18
// is present, execute the factory and get jQuery.
19
// For environments that do not have a `window` with a `document`
20
// (such as Node.js), expose a factory as module.exports.
21
// This accentuates the need for the creation of a real `window`.
22
// e.g. var jQuery = require("jquery")(window);
23
// See ticket trac-14549 for more info.
24
module.exports = global.document ?
25
factory( global, true ) :
26
function( w ) {
27
if ( !w.document ) {
28
throw new Error( "jQuery requires a window with a document" );
29
}
30
return factory( w );
31
};
32
} else {
33
factory( global );
34
}
35
36
// Pass this if window is not defined yet
37
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
38
39
// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
40
// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
41
// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
42
// enough that all such attempts are guarded in a try block.
43
"use strict";
44
45
var arr = [];
46
47
var getProto = Object.getPrototypeOf;
48
49
var slice = arr.slice;
50
51
var flat = arr.flat ? function( array ) {
52
return arr.flat.call( array );
53
} : function( array ) {
54
return arr.concat.apply( [], array );
55
};
56
57
58
var push = arr.push;
59
60
var indexOf = arr.indexOf;
61
62
var class2type = {};
63
64
var toString = class2type.toString;
65
66
var hasOwn = class2type.hasOwnProperty;
67
68
var fnToString = hasOwn.toString;
69
70
var ObjectFunctionString = fnToString.call( Object );
71
72
var support = {};
73
74
var isFunction = function isFunction( obj ) {
75
76
// Support: Chrome <=57, Firefox <=52
77
// In some browsers, typeof returns "function" for HTML <object> elements
78
// (i.e., `typeof document.createElement( "object" ) === "function"`).
79
// We don't want to classify *any* DOM node as a function.
80
// Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5
81
// Plus for old WebKit, typeof returns "function" for HTML collections
82
// (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)
83
return typeof obj === "function" && typeof obj.nodeType !== "number" &&
84
typeof obj.item !== "function";
85
};
86
87
88
var isWindow = function isWindow( obj ) {
89
return obj != null && obj === obj.window;
90
};
91
92
93
var document = window.document;
94
95
96
97
var preservedScriptAttributes = {
98
type: true,
99
src: true,
100
nonce: true,
101
noModule: true
102
};
103
104
function DOMEval( code, node, doc ) {
105
doc = doc || document;
106
107
var i, val,
108
script = doc.createElement( "script" );
109
110
script.text = code;
111
if ( node ) {
112
for ( i in preservedScriptAttributes ) {
113
114
// Support: Firefox 64+, Edge 18+
115
// Some browsers don't support the "nonce" property on scripts.
116
// On the other hand, just using `getAttribute` is not enough as
117
// the `nonce` attribute is reset to an empty string whenever it
118
// becomes browsing-context connected.
119
// See https://github.com/whatwg/html/issues/2369
120
// See https://html.spec.whatwg.org/#nonce-attributes
121
// The `node.getAttribute` check was added for the sake of
122
// `jQuery.globalEval` so that it can fake a nonce-containing node
123
// via an object.
124
val = node[ i ] || node.getAttribute && node.getAttribute( i );
125
if ( val ) {
126
script.setAttribute( i, val );
127
}
128
}
129
}
130
doc.head.appendChild( script ).parentNode.removeChild( script );
131
}
132
133
134
function toType( obj ) {
135
if ( obj == null ) {
136
return obj + "";
137
}
138
139
// Support: Android <=2.3 only (functionish RegExp)
140
return typeof obj === "object" || typeof obj === "function" ?
141
class2type[ toString.call( obj ) ] || "object" :
142
typeof obj;
143
}
144
/* global Symbol */
145
// Defining this global in .eslintrc.json would create a danger of using the global
146
// unguarded in another place, it seems safer to define global only for this module
147
148
149
150
var version = "3.7.1",
151
152
rhtmlSuffix = /HTML$/i,
153
154
// Define a local copy of jQuery
155
jQuery = function( selector, context ) {
156
157
// The jQuery object is actually just the init constructor 'enhanced'
158
// Need init if jQuery is called (just allow error to be thrown if not included)
159
return new jQuery.fn.init( selector, context );
160
};
161
162
jQuery.fn = jQuery.prototype = {
163
164
// The current version of jQuery being used
165
jquery: version,
166
167
constructor: jQuery,
168
169
// The default length of a jQuery object is 0
170
length: 0,
171
172
toArray: function() {
173
return slice.call( this );
174
},
175
176
// Get the Nth element in the matched element set OR
177
// Get the whole matched element set as a clean array
178
get: function( num ) {
179
180
// Return all the elements in a clean array
181
if ( num == null ) {
182
return slice.call( this );
183
}
184
185
// Return just the one element from the set
186
return num < 0 ? this[ num + this.length ] : this[ num ];
187
},
188
189
// Take an array of elements and push it onto the stack
190
// (returning the new matched element set)
191
pushStack: function( elems ) {
192
193
// Build a new jQuery matched element set
194
var ret = jQuery.merge( this.constructor(), elems );
195
196
// Add the old object onto the stack (as a reference)
197
ret.prevObject = this;
198
199
// Return the newly-formed element set
200
return ret;
201
},
202
203
// Execute a callback for every element in the matched set.
204
each: function( callback ) {
205
return jQuery.each( this, callback );
206
},
207
208
map: function( callback ) {
209
return this.pushStack( jQuery.map( this, function( elem, i ) {
210
return callback.call( elem, i, elem );
211
} ) );
212
},
213
214
slice: function() {
215
return this.pushStack( slice.apply( this, arguments ) );
216
},
217
218
first: function() {
219
return this.eq( 0 );
220
},
221
222
last: function() {
223
return this.eq( -1 );
224
},
225
226
even: function() {
227
return this.pushStack( jQuery.grep( this, function( _elem, i ) {
228
return ( i + 1 ) % 2;
229
} ) );
230
},
231
232
odd: function() {
233
return this.pushStack( jQuery.grep( this, function( _elem, i ) {
234
return i % 2;
235
} ) );
236
},
237
238
eq: function( i ) {
239
var len = this.length,
240
j = +i + ( i < 0 ? len : 0 );
241
return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
242
},
243
244
end: function() {
245
return this.prevObject || this.constructor();
246
},
247
248
// For internal use only.
249
// Behaves like an Array's method, not like a jQuery method.
250
push: push,
251
sort: arr.sort,
252
splice: arr.splice
253
};
254
255
jQuery.extend = jQuery.fn.extend = function() {
256
var options, name, src, copy, copyIsArray, clone,
257
target = arguments[ 0 ] || {},
258
i = 1,
259
length = arguments.length,
260
deep = false;
261
262
// Handle a deep copy situation
263
if ( typeof target === "boolean" ) {
264
deep = target;
265
266
// Skip the boolean and the target
267
target = arguments[ i ] || {};
268
i++;
269
}
270
271
// Handle case when target is a string or something (possible in deep copy)
272
if ( typeof target !== "object" && !isFunction( target ) ) {
273
target = {};
274
}
275
276
// Extend jQuery itself if only one argument is passed
277
if ( i === length ) {
278
target = this;
279
i--;
280
}
281
282
for ( ; i < length; i++ ) {
283
284
// Only deal with non-null/undefined values
285
if ( ( options = arguments[ i ] ) != null ) {
286
287
// Extend the base object
288
for ( name in options ) {
289
copy = options[ name ];
290
291
// Prevent Object.prototype pollution
292
// Prevent never-ending loop
293
if ( name === "__proto__" || target === copy ) {
294
continue;
295
}
296
297
// Recurse if we're merging plain objects or arrays
298
if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
299
( copyIsArray = Array.isArray( copy ) ) ) ) {
300
src = target[ name ];
301
302
// Ensure proper type for the source value
303
if ( copyIsArray && !Array.isArray( src ) ) {
304
clone = [];
305
} else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
306
clone = {};
307
} else {
308
clone = src;
309
}
310
copyIsArray = false;
311
312
// Never move original objects, clone them
313
target[ name ] = jQuery.extend( deep, clone, copy );
314
315
// Don't bring in undefined values
316
} else if ( copy !== undefined ) {
317
target[ name ] = copy;
318
}
319
}
320
}
321
}
322
323
// Return the modified object
324
return target;
325
};
326
327
jQuery.extend( {
328
329
// Unique for each copy of jQuery on the page
330
expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
331
332
// Assume jQuery is ready without the ready module
333
isReady: true,
334
335
error: function( msg ) {
336
throw new Error( msg );
337
},
338
339
noop: function() {},
340
341
isPlainObject: function( obj ) {
342
var proto, Ctor;
343
344
// Detect obvious negatives
345
// Use toString instead of jQuery.type to catch host objects
346
if ( !obj || toString.call( obj ) !== "[object Object]" ) {
347
return false;
348
}
349
350
proto = getProto( obj );
351
352
// Objects with no prototype (e.g., `Object.create( null )`) are plain
353
if ( !proto ) {
354
return true;
355
}
356
357
// Objects with prototype are plain iff they were constructed by a global Object function
358
Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
359
return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
360
},
361
362
isEmptyObject: function( obj ) {
363
var name;
364
365
for ( name in obj ) {
366
return false;
367
}
368
return true;
369
},
370
371
// Evaluates a script in a provided context; falls back to the global one
372
// if not specified.
373
globalEval: function( code, options, doc ) {
374
DOMEval( code, { nonce: options && options.nonce }, doc );
375
},
376
377
each: function( obj, callback ) {
378
var length, i = 0;
379
380
if ( isArrayLike( obj ) ) {
381
length = obj.length;
382
for ( ; i < length; i++ ) {
383
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
384
break;
385
}
386
}
387
} else {
388
for ( i in obj ) {
389
if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
390
break;
391
}
392
}
393
}
394
395
return obj;
396
},
397
398
399
// Retrieve the text value of an array of DOM nodes
400
text: function( elem ) {
401
var node,
402
ret = "",
403
i = 0,
404
nodeType = elem.nodeType;
405
406
if ( !nodeType ) {
407
408
// If no nodeType, this is expected to be an array
409
while ( ( node = elem[ i++ ] ) ) {
410
411
// Do not traverse comment nodes
412
ret += jQuery.text( node );
413
}
414
}
415
if ( nodeType === 1 || nodeType === 11 ) {
416
return elem.textContent;
417
}
418
if ( nodeType === 9 ) {
419
return elem.documentElement.textContent;
420
}
421
if ( nodeType === 3 || nodeType === 4 ) {
422
return elem.nodeValue;
423
}
424
425
// Do not include comment or processing instruction nodes
426
427
return ret;
428
},
429
430
// results is for internal usage only
431
makeArray: function( arr, results ) {
432
var ret = results || [];
433
434
if ( arr != null ) {
435
if ( isArrayLike( Object( arr ) ) ) {
436
jQuery.merge( ret,
437
typeof arr === "string" ?
438
[ arr ] : arr
439
);
440
} else {
441
push.call( ret, arr );
442
}
443
}
444
445
return ret;
446
},
447
448
inArray: function( elem, arr, i ) {
449
return arr == null ? -1 : indexOf.call( arr, elem, i );
450
},
451
452
isXMLDoc: function( elem ) {
453
var namespace = elem && elem.namespaceURI,
454
docElem = elem && ( elem.ownerDocument || elem ).documentElement;
455
456
// Assume HTML when documentElement doesn't yet exist, such as inside
457
// document fragments.
458
return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" );
459
},
460
461
// Support: Android <=4.0 only, PhantomJS 1 only
462
// push.apply(_, arraylike) throws on ancient WebKit
463
merge: function( first, second ) {
464
var len = +second.length,
465
j = 0,
466
i = first.length;
467
468
for ( ; j < len; j++ ) {
469
first[ i++ ] = second[ j ];
470
}
471
472
first.length = i;
473
474
return first;
475
},
476
477
grep: function( elems, callback, invert ) {
478
var callbackInverse,
479
matches = [],
480
i = 0,
481
length = elems.length,
482
callbackExpect = !invert;
483
484
// Go through the array, only saving the items
485
// that pass the validator function
486
for ( ; i < length; i++ ) {
487
callbackInverse = !callback( elems[ i ], i );
488
if ( callbackInverse !== callbackExpect ) {
489
matches.push( elems[ i ] );
490
}
491
}
492
493
return matches;
494
},
495
496
// arg is for internal usage only
497
map: function( elems, callback, arg ) {
498
var length, value,
499
i = 0,
500
ret = [];
501
502
// Go through the array, translating each of the items to their new values
503
if ( isArrayLike( elems ) ) {
504
length = elems.length;
505
for ( ; i < length; i++ ) {
506
value = callback( elems[ i ], i, arg );
507
508
if ( value != null ) {
509
ret.push( value );
510
}
511
}
512
513
// Go through every key on the object,
514
} else {
515
for ( i in elems ) {
516
value = callback( elems[ i ], i, arg );
517
518
if ( value != null ) {
519
ret.push( value );
520
}
521
}
522
}
523
524
// Flatten any nested arrays
525
return flat( ret );
526
},
527
528
// A global GUID counter for objects
529
guid: 1,
530
531
// jQuery.support is not used in Core but other projects attach their
532
// properties to it so it needs to exist.
533
support: support
534
} );
535
536
if ( typeof Symbol === "function" ) {
537
jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
538
}
539
540
// Populate the class2type map
541
jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
542
function( _i, name ) {
543
class2type[ "[object " + name + "]" ] = name.toLowerCase();
544
} );
545
546
function isArrayLike( obj ) {
547
548
// Support: real iOS 8.2 only (not reproducible in simulator)
549
// `in` check used to prevent JIT error (gh-2145)
550
// hasOwn isn't used here due to false negatives
551
// regarding Nodelist length in IE
552
var length = !!obj && "length" in obj && obj.length,
553
type = toType( obj );
554
555
if ( isFunction( obj ) || isWindow( obj ) ) {
556
return false;
557
}
558
559
return type === "array" || length === 0 ||
560
typeof length === "number" && length > 0 && ( length - 1 ) in obj;
561
}
562
563
564
function nodeName( elem, name ) {
565
566
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
567
568
}
569
var pop = arr.pop;
570
571
572
var sort = arr.sort;
573
574
575
var splice = arr.splice;
576
577
578
var whitespace = "[\\x20\\t\\r\\n\\f]";
579
580
581
var rtrimCSS = new RegExp(
582
"^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
583
"g"
584
);
585
586
587
588
589
// Note: an element does not contain itself
590
jQuery.contains = function( a, b ) {
591
var bup = b && b.parentNode;
592
593
return a === bup || !!( bup && bup.nodeType === 1 && (
594
595
// Support: IE 9 - 11+
596
// IE doesn't have `contains` on SVG.
597
a.contains ?
598
a.contains( bup ) :
599
a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
600
) );
601
};
602
603
604
605
606
// CSS string/identifier serialization
607
// https://drafts.csswg.org/cssom/#common-serializing-idioms
608
var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
609
610
function fcssescape( ch, asCodePoint ) {
611
if ( asCodePoint ) {
612
613
// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
614
if ( ch === "\0" ) {
615
return "\uFFFD";
616
}
617
618
// Control characters and (dependent upon position) numbers get escaped as code points
619
return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
620
}
621
622
// Other potentially-special ASCII characters get backslash-escaped
623
return "\\" + ch;
624
}
625
626
jQuery.escapeSelector = function( sel ) {
627
return ( sel + "" ).replace( rcssescape, fcssescape );
628
};
629
630
631
632
633
var preferredDoc = document,
634
pushNative = push;
635
636
( function() {
637
638
var i,
639
Expr,
640
outermostContext,
641
sortInput,
642
hasDuplicate,
643
push = pushNative,
644
645
// Local document vars
646
document,
647
documentElement,
648
documentIsHTML,
649
rbuggyQSA,
650
matches,
651
652
// Instance-specific data
653
expando = jQuery.expando,
654
dirruns = 0,
655
done = 0,
656
classCache = createCache(),
657
tokenCache = createCache(),
658
compilerCache = createCache(),
659
nonnativeSelectorCache = createCache(),
660
sortOrder = function( a, b ) {
661
if ( a === b ) {
662
hasDuplicate = true;
663
}
664
return 0;
665
},
666
667
booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" +
668
"loop|multiple|open|readonly|required|scoped",
669
670
// Regular expressions
671
672
// https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
673
identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
674
"?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
675
676
// Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors
677
attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
678
679
// Operator (capture 2)
680
"*([*^$|!~]?=)" + whitespace +
681
682
// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
683
"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
684
whitespace + "*\\]",
685
686
pseudos = ":(" + identifier + ")(?:\\((" +
687
688
// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
689
// 1. quoted (capture 3; capture 4 or capture 5)
690
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
691
692
// 2. simple (capture 6)
693
"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
694
695
// 3. anything else (capture 2)
696
".*" +
697
")\\)|)",
698
699
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
700
rwhitespace = new RegExp( whitespace + "+", "g" ),
701
702
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
703
rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" +
704
whitespace + "*" ),
705
rdescend = new RegExp( whitespace + "|>" ),
706
707
rpseudo = new RegExp( pseudos ),
708
ridentifier = new RegExp( "^" + identifier + "$" ),
709
710
matchExpr = {
711
ID: new RegExp( "^#(" + identifier + ")" ),
712
CLASS: new RegExp( "^\\.(" + identifier + ")" ),
713
TAG: new RegExp( "^(" + identifier + "|[*])" ),
714
ATTR: new RegExp( "^" + attributes ),
715
PSEUDO: new RegExp( "^" + pseudos ),
716
CHILD: new RegExp(
717
"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
718
whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
719
whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
720
bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
721
722
// For use in libraries implementing .is()
723
// We use this for POS matching in `select`
724
needsContext: new RegExp( "^" + whitespace +
725
"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
726
"*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
727
},
728
729
rinputs = /^(?:input|select|textarea|button)$/i,
730
rheader = /^h\d$/i,
731
732
// Easily-parseable/retrievable ID or TAG or CLASS selectors
733
rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
734
735
rsibling = /[+~]/,
736
737
// CSS escapes
738
// https://www.w3.org/TR/CSS21/syndata.html#escaped-characters
739
runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace +
740
"?|\\\\([^\\r\\n\\f])", "g" ),
741
funescape = function( escape, nonHex ) {
742
var high = "0x" + escape.slice( 1 ) - 0x10000;
743
744
if ( nonHex ) {
745
746
// Strip the backslash prefix from a non-hex escape sequence
747
return nonHex;
748
}
749
750
// Replace a hexadecimal escape sequence with the encoded Unicode code point
751
// Support: IE <=11+
752
// For values outside the Basic Multilingual Plane (BMP), manually construct a
753
// surrogate pair
754
return high < 0 ?
755
String.fromCharCode( high + 0x10000 ) :
756
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
757
},
758
759
// Used for iframes; see `setDocument`.
760
// Support: IE 9 - 11+, Edge 12 - 18+
761
// Removing the function wrapper causes a "Permission Denied"
762
// error in IE/Edge.
763
unloadHandler = function() {
764
setDocument();
765
},
766
767
inDisabledFieldset = addCombinator(
768
function( elem ) {
769
return elem.disabled === true && nodeName( elem, "fieldset" );
770
},
771
{ dir: "parentNode", next: "legend" }
772
);
773
774
// Support: IE <=9 only
775
// Accessing document.activeElement can throw unexpectedly
776
// https://bugs.jquery.com/ticket/13393
777
function safeActiveElement() {
778
try {
779
return document.activeElement;
780
} catch ( err ) { }
781
}
782
783
// Optimize for push.apply( _, NodeList )
784
try {
785
push.apply(
786
( arr = slice.call( preferredDoc.childNodes ) ),
787
preferredDoc.childNodes
788
);
789
790
// Support: Android <=4.0
791
// Detect silently failing push.apply
792
// eslint-disable-next-line no-unused-expressions
793
arr[ preferredDoc.childNodes.length ].nodeType;
794
} catch ( e ) {
795
push = {
796
apply: function( target, els ) {
797
pushNative.apply( target, slice.call( els ) );
798
},
799
call: function( target ) {
800
pushNative.apply( target, slice.call( arguments, 1 ) );
801
}
802
};
803
}
804
805
function find( selector, context, results, seed ) {
806
var m, i, elem, nid, match, groups, newSelector,
807
newContext = context && context.ownerDocument,
808
809
// nodeType defaults to 9, since context defaults to document
810
nodeType = context ? context.nodeType : 9;
811
812
results = results || [];
813
814
// Return early from calls with invalid selector or context
815
if ( typeof selector !== "string" || !selector ||
816
nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
817
818
return results;
819
}
820
821
// Try to shortcut find operations (as opposed to filters) in HTML documents
822
if ( !seed ) {
823
setDocument( context );
824
context = context || document;
825
826
if ( documentIsHTML ) {
827
828
// If the selector is sufficiently simple, try using a "get*By*" DOM method
829
// (excepting DocumentFragment context, where the methods don't exist)
830
if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
831
832
// ID selector
833
if ( ( m = match[ 1 ] ) ) {
834
835
// Document context
836
if ( nodeType === 9 ) {
837
if ( ( elem = context.getElementById( m ) ) ) {
838
839
// Support: IE 9 only
840
// getElementById can match elements by name instead of ID
841
if ( elem.id === m ) {
842
push.call( results, elem );
843
return results;
844
}
845
} else {
846
return results;
847
}
848
849
// Element context
850
} else {
851
852
// Support: IE 9 only
853
// getElementById can match elements by name instead of ID
854
if ( newContext && ( elem = newContext.getElementById( m ) ) &&
855
find.contains( context, elem ) &&
856
elem.id === m ) {
857
858
push.call( results, elem );
859
return results;
860
}
861
}
862
863
// Type selector
864
} else if ( match[ 2 ] ) {
865
push.apply( results, context.getElementsByTagName( selector ) );
866
return results;
867
868
// Class selector
869
} else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) {
870
push.apply( results, context.getElementsByClassName( m ) );
871
return results;
872
}
873
}
874
875
// Take advantage of querySelectorAll
876
if ( !nonnativeSelectorCache[ selector + " " ] &&
877
( !rbuggyQSA || !rbuggyQSA.test( selector ) ) ) {
878
879
newSelector = selector;
880
newContext = context;
881
882
// qSA considers elements outside a scoping root when evaluating child or
883
// descendant combinators, which is not what we want.
884
// In such cases, we work around the behavior by prefixing every selector in the
885
// list with an ID selector referencing the scope context.
886
// The technique has to be used as well when a leading combinator is used
887
// as such selectors are not recognized by querySelectorAll.
888
// Thanks to Andrew Dupont for this technique.
889
if ( nodeType === 1 &&
890
( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) {
891
892
// Expand context for sibling selectors
893
newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
894
context;
895
896
// We can use :scope instead of the ID hack if the browser
897
// supports it & if we're not changing the context.
898
// Support: IE 11+, Edge 17 - 18+
899
// IE/Edge sometimes throw a "Permission denied" error when
900
// strict-comparing two documents; shallow comparisons work.
901
// eslint-disable-next-line eqeqeq
902
if ( newContext != context || !support.scope ) {
903
904
// Capture the context ID, setting it first if necessary
905
if ( ( nid = context.getAttribute( "id" ) ) ) {
906
nid = jQuery.escapeSelector( nid );
907
} else {
908
context.setAttribute( "id", ( nid = expando ) );
909
}
910
}
911
912
// Prefix every selector in the list
913
groups = tokenize( selector );
914
i = groups.length;
915
while ( i-- ) {
916
groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
917
toSelector( groups[ i ] );
918
}
919
newSelector = groups.join( "," );
920
}
921
922
try {
923
push.apply( results,
924
newContext.querySelectorAll( newSelector )
925
);
926
return results;
927
} catch ( qsaError ) {
928
nonnativeSelectorCache( selector, true );
929
} finally {
930
if ( nid === expando ) {
931
context.removeAttribute( "id" );
932
}
933
}
934
}
935
}
936
}
937
938
// All others
939
return select( selector.replace( rtrimCSS, "$1" ), context, results, seed );
940
}
941
942
/**
943
* Create key-value caches of limited size
944
* @returns {function(string, object)} Returns the Object data after storing it on itself with
945
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
946
* deleting the oldest entry
947
*/
948
function createCache() {
949
var keys = [];
950
951
function cache( key, value ) {
952
953
// Use (key + " ") to avoid collision with native prototype properties
954
// (see https://github.com/jquery/sizzle/issues/157)
955
if ( keys.push( key + " " ) > Expr.cacheLength ) {
956
957
// Only keep the most recent entries
958
delete cache[ keys.shift() ];
959
}
960
return ( cache[ key + " " ] = value );
961
}
962
return cache;
963
}
964
965
/**
966
* Mark a function for special use by jQuery selector module
967
* @param {Function} fn The function to mark
968
*/
969
function markFunction( fn ) {
970
fn[ expando ] = true;
971
return fn;
972
}
973
974
/**
975
* Support testing using an element
976
* @param {Function} fn Passed the created element and returns a boolean result
977
*/
978
function assert( fn ) {
979
var el = document.createElement( "fieldset" );
980
981
try {
982
return !!fn( el );
983
} catch ( e ) {
984
return false;
985
} finally {
986
987
// Remove from its parent by default
988
if ( el.parentNode ) {
989
el.parentNode.removeChild( el );
990
}
991
992
// release memory in IE
993
el = null;
994
}
995
}
996
997
/**
998
* Returns a function to use in pseudos for input types
999
* @param {String} type
1000
*/
1001
function createInputPseudo( type ) {
1002
return function( elem ) {
1003
return nodeName( elem, "input" ) && elem.type === type;
1004
};
1005
}
1006
1007
/**
1008
* Returns a function to use in pseudos for buttons
1009
* @param {String} type
1010
*/
1011
function createButtonPseudo( type ) {
1012
return function( elem ) {
1013
return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) &&
1014
elem.type === type;
1015
};
1016
}
1017
1018
/**
1019
* Returns a function to use in pseudos for :enabled/:disabled
1020
* @param {Boolean} disabled true for :disabled; false for :enabled
1021
*/
1022
function createDisabledPseudo( disabled ) {
1023
1024
// Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1025
return function( elem ) {
1026
1027
// Only certain elements can match :enabled or :disabled
1028
// https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1029
// https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1030
if ( "form" in elem ) {
1031
1032
// Check for inherited disabledness on relevant non-disabled elements:
1033
// * listed form-associated elements in a disabled fieldset
1034
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
1035
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1036
// * option elements in a disabled optgroup
1037
// https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1038
// All such elements have a "form" property.
1039
if ( elem.parentNode && elem.disabled === false ) {
1040
1041
// Option elements defer to a parent optgroup if present
1042
if ( "label" in elem ) {
1043
if ( "label" in elem.parentNode ) {
1044
return elem.parentNode.disabled === disabled;
1045
} else {
1046
return elem.disabled === disabled;
1047
}
1048
}
1049
1050
// Support: IE 6 - 11+
1051
// Use the isDisabled shortcut property to check for disabled fieldset ancestors
1052
return elem.isDisabled === disabled ||
1053
1054
// Where there is no isDisabled, check manually
1055
elem.isDisabled !== !disabled &&
1056
inDisabledFieldset( elem ) === disabled;
1057
}
1058
1059
return elem.disabled === disabled;
1060
1061
// Try to winnow out elements that can't be disabled before trusting the disabled property.
1062
// Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1063
// even exist on them, let alone have a boolean value.
1064
} else if ( "label" in elem ) {
1065
return elem.disabled === disabled;
1066
}
1067
1068
// Remaining elements are neither :enabled nor :disabled
1069
return false;
1070
};
1071
}
1072
1073
/**
1074
* Returns a function to use in pseudos for positionals
1075
* @param {Function} fn
1076
*/
1077
function createPositionalPseudo( fn ) {
1078
return markFunction( function( argument ) {
1079
argument = +argument;
1080
return markFunction( function( seed, matches ) {
1081
var j,
1082
matchIndexes = fn( [], seed.length, argument ),
1083
i = matchIndexes.length;
1084
1085
// Match elements found at the specified indexes
1086
while ( i-- ) {
1087
if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
1088
seed[ j ] = !( matches[ j ] = seed[ j ] );
1089
}
1090
}
1091
} );
1092
} );
1093
}
1094
1095
/**
1096
* Checks a node for validity as a jQuery selector context
1097
* @param {Element|Object=} context
1098
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1099
*/
1100
function testContext( context ) {
1101
return context && typeof context.getElementsByTagName !== "undefined" && context;
1102
}
1103
1104
/**
1105
* Sets document-related variables once based on the current document
1106
* @param {Element|Object} [node] An element or document object to use to set the document
1107
* @returns {Object} Returns the current document
1108
*/
1109
function setDocument( node ) {
1110
var subWindow,
1111
doc = node ? node.ownerDocument || node : preferredDoc;
1112
1113
// Return early if doc is invalid or already selected
1114
// Support: IE 11+, Edge 17 - 18+
1115
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1116
// two documents; shallow comparisons work.
1117
// eslint-disable-next-line eqeqeq
1118
if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
1119
return document;
1120
}
1121
1122
// Update global variables
1123
document = doc;
1124
documentElement = document.documentElement;
1125
documentIsHTML = !jQuery.isXMLDoc( document );
1126
1127
// Support: iOS 7 only, IE 9 - 11+
1128
// Older browsers didn't support unprefixed `matches`.
1129
matches = documentElement.matches ||
1130
documentElement.webkitMatchesSelector ||
1131
documentElement.msMatchesSelector;
1132
1133
// Support: IE 9 - 11+, Edge 12 - 18+
1134
// Accessing iframe documents after unload throws "permission denied" errors
1135
// (see trac-13936).
1136
// Limit the fix to IE & Edge Legacy; despite Edge 15+ implementing `matches`,
1137
// all IE 9+ and Edge Legacy versions implement `msMatchesSelector` as well.
1138
if ( documentElement.msMatchesSelector &&
1139
1140
// Support: IE 11+, Edge 17 - 18+
1141
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1142
// two documents; shallow comparisons work.
1143
// eslint-disable-next-line eqeqeq
1144
preferredDoc != document &&
1145
( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
1146
1147
// Support: IE 9 - 11+, Edge 12 - 18+
1148
subWindow.addEventListener( "unload", unloadHandler );
1149
}
1150
1151
// Support: IE <10
1152
// Check if getElementById returns elements by name
1153
// The broken getElementById methods don't pick up programmatically-set names,
1154
// so use a roundabout getElementsByName test
1155
support.getById = assert( function( el ) {
1156
documentElement.appendChild( el ).id = jQuery.expando;
1157
return !document.getElementsByName ||
1158
!document.getElementsByName( jQuery.expando ).length;
1159
} );
1160
1161
// Support: IE 9 only
1162
// Check to see if it's possible to do matchesSelector
1163
// on a disconnected node.
1164
support.disconnectedMatch = assert( function( el ) {
1165
return matches.call( el, "*" );
1166
} );
1167
1168
// Support: IE 9 - 11+, Edge 12 - 18+
1169
// IE/Edge don't support the :scope pseudo-class.
1170
support.scope = assert( function() {
1171
return document.querySelectorAll( ":scope" );
1172
} );
1173
1174
// Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only
1175
// Make sure the `:has()` argument is parsed unforgivingly.
1176
// We include `*` in the test to detect buggy implementations that are
1177
// _selectively_ forgiving (specifically when the list includes at least
1178
// one valid selector).
1179
// Note that we treat complete lack of support for `:has()` as if it were
1180
// spec-compliant support, which is fine because use of `:has()` in such
1181
// environments will fail in the qSA path and fall back to jQuery traversal
1182
// anyway.
1183
support.cssHas = assert( function() {
1184
try {
1185
document.querySelector( ":has(*,:jqfake)" );
1186
return false;
1187
} catch ( e ) {
1188
return true;
1189
}
1190
} );
1191
1192
// ID filter and find
1193
if ( support.getById ) {
1194
Expr.filter.ID = function( id ) {
1195
var attrId = id.replace( runescape, funescape );
1196
return function( elem ) {
1197
return elem.getAttribute( "id" ) === attrId;
1198
};
1199
};
1200
Expr.find.ID = function( id, context ) {
1201
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1202
var elem = context.getElementById( id );
1203
return elem ? [ elem ] : [];
1204
}
1205
};
1206
} else {
1207
Expr.filter.ID = function( id ) {
1208
var attrId = id.replace( runescape, funescape );
1209
return function( elem ) {
1210
var node = typeof elem.getAttributeNode !== "undefined" &&
1211
elem.getAttributeNode( "id" );
1212
return node && node.value === attrId;
1213
};
1214
};
1215
1216
// Support: IE 6 - 7 only
1217
// getElementById is not reliable as a find shortcut
1218
Expr.find.ID = function( id, context ) {
1219
if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1220
var node, i, elems,
1221
elem = context.getElementById( id );
1222
1223
if ( elem ) {
1224
1225
// Verify the id attribute
1226
node = elem.getAttributeNode( "id" );
1227
if ( node && node.value === id ) {
1228
return [ elem ];
1229
}
1230
1231
// Fall back on getElementsByName
1232
elems = context.getElementsByName( id );
1233
i = 0;
1234
while ( ( elem = elems[ i++ ] ) ) {
1235
node = elem.getAttributeNode( "id" );
1236
if ( node && node.value === id ) {
1237
return [ elem ];
1238
}
1239
}
1240
}
1241
1242
return [];
1243
}
1244
};
1245
}
1246
1247
// Tag
1248
Expr.find.TAG = function( tag, context ) {
1249
if ( typeof context.getElementsByTagName !== "undefined" ) {
1250
return context.getElementsByTagName( tag );
1251
1252
// DocumentFragment nodes don't have gEBTN
1253
} else {
1254
return context.querySelectorAll( tag );
1255
}
1256
};
1257
1258
// Class
1259
Expr.find.CLASS = function( className, context ) {
1260
if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1261
return context.getElementsByClassName( className );
1262
}
1263
};
1264
1265
/* QSA/matchesSelector
1266
---------------------------------------------------------------------- */
1267
1268
// QSA and matchesSelector support
1269
1270
rbuggyQSA = [];
1271
1272
// Build QSA regex
1273
// Regex strategy adopted from Diego Perini
1274
assert( function( el ) {
1275
1276
var input;
1277
1278
documentElement.appendChild( el ).innerHTML =
1279
"<a id='" + expando + "' href='' disabled='disabled'></a>" +
1280
"<select id='" + expando + "-\r\\' disabled='disabled'>" +
1281
"<option selected=''></option></select>";
1282
1283
// Support: iOS <=7 - 8 only
1284
// Boolean attributes and "value" are not treated correctly in some XML documents
1285
if ( !el.querySelectorAll( "[selected]" ).length ) {
1286
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1287
}
1288
1289
// Support: iOS <=7 - 8 only
1290
if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1291
rbuggyQSA.push( "~=" );
1292
}
1293
1294
// Support: iOS 8 only
1295
// https://bugs.webkit.org/show_bug.cgi?id=136851
1296
// In-page `selector#id sibling-combinator selector` fails
1297
if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
1298
rbuggyQSA.push( ".#.+[+~]" );
1299
}
1300
1301
// Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+
1302
// In some of the document kinds, these selectors wouldn't work natively.
1303
// This is probably OK but for backwards compatibility we want to maintain
1304
// handling them through jQuery traversal in jQuery 3.x.
1305
if ( !el.querySelectorAll( ":checked" ).length ) {
1306
rbuggyQSA.push( ":checked" );
1307
}
1308
1309
// Support: Windows 8 Native Apps
1310
// The type and name attributes are restricted during .innerHTML assignment
1311
input = document.createElement( "input" );
1312
input.setAttribute( "type", "hidden" );
1313
el.appendChild( input ).setAttribute( "name", "D" );
1314
1315
// Support: IE 9 - 11+
1316
// IE's :disabled selector does not pick up the children of disabled fieldsets
1317
// Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+
1318
// In some of the document kinds, these selectors wouldn't work natively.
1319
// This is probably OK but for backwards compatibility we want to maintain
1320
// handling them through jQuery traversal in jQuery 3.x.
1321
documentElement.appendChild( el ).disabled = true;
1322
if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
1323
rbuggyQSA.push( ":enabled", ":disabled" );
1324
}
1325
1326
// Support: IE 11+, Edge 15 - 18+
1327
// IE 11/Edge don't find elements on a `[name='']` query in some cases.
1328
// Adding a temporary attribute to the document before the selection works
1329
// around the issue.
1330
// Interestingly, IE 10 & older don't seem to have the issue.
1331
input = document.createElement( "input" );
1332
input.setAttribute( "name", "" );
1333
el.appendChild( input );
1334
if ( !el.querySelectorAll( "[name='']" ).length ) {
1335
rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
1336
whitespace + "*(?:''|\"\")" );
1337
}
1338
} );
1339
1340
if ( !support.cssHas ) {
1341
1342
// Support: Chrome 105 - 110+, Safari 15.4 - 16.3+
1343
// Our regular `try-catch` mechanism fails to detect natively-unsupported
1344
// pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`)
1345
// in browsers that parse the `:has()` argument as a forgiving selector list.
1346
// https://drafts.csswg.org/selectors/#relational now requires the argument
1347
// to be parsed unforgivingly, but browsers have not yet fully adjusted.
1348
rbuggyQSA.push( ":has" );
1349
}
1350
1351
rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
1352
1353
/* Sorting
1354
---------------------------------------------------------------------- */
1355
1356
// Document order sorting
1357
sortOrder = function( a, b ) {
1358
1359
// Flag for duplicate removal
1360
if ( a === b ) {
1361
hasDuplicate = true;
1362
return 0;
1363
}
1364
1365
// Sort on method existence if only one input has compareDocumentPosition
1366
var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1367
if ( compare ) {
1368
return compare;
1369
}
1370
1371
// Calculate position if both inputs belong to the same document
1372
// Support: IE 11+, Edge 17 - 18+
1373
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1374
// two documents; shallow comparisons work.
1375
// eslint-disable-next-line eqeqeq
1376
compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
1377
a.compareDocumentPosition( b ) :
1378
1379
// Otherwise we know they are disconnected
1380
1;
1381
1382
// Disconnected nodes
1383
if ( compare & 1 ||
1384
( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
1385
1386
// Choose the first element that is related to our preferred document
1387
// Support: IE 11+, Edge 17 - 18+
1388
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1389
// two documents; shallow comparisons work.
1390
// eslint-disable-next-line eqeqeq
1391
if ( a === document || a.ownerDocument == preferredDoc &&
1392
find.contains( preferredDoc, a ) ) {
1393
return -1;
1394
}
1395
1396
// Support: IE 11+, Edge 17 - 18+
1397
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1398
// two documents; shallow comparisons work.
1399
// eslint-disable-next-line eqeqeq
1400
if ( b === document || b.ownerDocument == preferredDoc &&
1401
find.contains( preferredDoc, b ) ) {
1402
return 1;
1403
}
1404
1405
// Maintain original order
1406
return sortInput ?
1407
( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1408
0;
1409
}
1410
1411
return compare & 4 ? -1 : 1;
1412
};
1413
1414
return document;
1415
}
1416
1417
find.matches = function( expr, elements ) {
1418
return find( expr, null, null, elements );
1419
};
1420
1421
find.matchesSelector = function( elem, expr ) {
1422
setDocument( elem );
1423
1424
if ( documentIsHTML &&
1425
!nonnativeSelectorCache[ expr + " " ] &&
1426
( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1427
1428
try {
1429
var ret = matches.call( elem, expr );
1430
1431
// IE 9's matchesSelector returns false on disconnected nodes
1432
if ( ret || support.disconnectedMatch ||
1433
1434
// As well, disconnected nodes are said to be in a document
1435
// fragment in IE 9
1436
elem.document && elem.document.nodeType !== 11 ) {
1437
return ret;
1438
}
1439
} catch ( e ) {
1440
nonnativeSelectorCache( expr, true );
1441
}
1442
}
1443
1444
return find( expr, document, null, [ elem ] ).length > 0;
1445
};
1446
1447
find.contains = function( context, elem ) {
1448
1449
// Set document vars if needed
1450
// Support: IE 11+, Edge 17 - 18+
1451
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1452
// two documents; shallow comparisons work.
1453
// eslint-disable-next-line eqeqeq
1454
if ( ( context.ownerDocument || context ) != document ) {
1455
setDocument( context );
1456
}
1457
return jQuery.contains( context, elem );
1458
};
1459
1460
1461
find.attr = function( elem, name ) {
1462
1463
// Set document vars if needed
1464
// Support: IE 11+, Edge 17 - 18+
1465
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1466
// two documents; shallow comparisons work.
1467
// eslint-disable-next-line eqeqeq
1468
if ( ( elem.ownerDocument || elem ) != document ) {
1469
setDocument( elem );
1470
}
1471
1472
var fn = Expr.attrHandle[ name.toLowerCase() ],
1473
1474
// Don't get fooled by Object.prototype properties (see trac-13807)
1475
val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1476
fn( elem, name, !documentIsHTML ) :
1477
undefined;
1478
1479
if ( val !== undefined ) {
1480
return val;
1481
}
1482
1483
return elem.getAttribute( name );
1484
};
1485
1486
find.error = function( msg ) {
1487
throw new Error( "Syntax error, unrecognized expression: " + msg );
1488
};
1489
1490
/**
1491
* Document sorting and removing duplicates
1492
* @param {ArrayLike} results
1493
*/
1494
jQuery.uniqueSort = function( results ) {
1495
var elem,
1496
duplicates = [],
1497
j = 0,
1498
i = 0;
1499
1500
// Unless we *know* we can detect duplicates, assume their presence
1501
//
1502
// Support: Android <=4.0+
1503
// Testing for detecting duplicates is unpredictable so instead assume we can't
1504
// depend on duplicate detection in all browsers without a stable sort.
1505
hasDuplicate = !support.sortStable;
1506
sortInput = !support.sortStable && slice.call( results, 0 );
1507
sort.call( results, sortOrder );
1508
1509
if ( hasDuplicate ) {
1510
while ( ( elem = results[ i++ ] ) ) {
1511
if ( elem === results[ i ] ) {
1512
j = duplicates.push( i );
1513
}
1514
}
1515
while ( j-- ) {
1516
splice.call( results, duplicates[ j ], 1 );
1517
}
1518
}
1519
1520
// Clear input after sorting to release objects
1521
// See https://github.com/jquery/sizzle/pull/225
1522
sortInput = null;
1523
1524
return results;
1525
};
1526
1527
jQuery.fn.uniqueSort = function() {
1528
return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) );
1529
};
1530
1531
Expr = jQuery.expr = {
1532
1533
// Can be adjusted by the user
1534
cacheLength: 50,
1535
1536
createPseudo: markFunction,
1537
1538
match: matchExpr,
1539
1540
attrHandle: {},
1541
1542
find: {},
1543
1544
relative: {
1545
">": { dir: "parentNode", first: true },
1546
" ": { dir: "parentNode" },
1547
"+": { dir: "previousSibling", first: true },
1548
"~": { dir: "previousSibling" }
1549
},
1550
1551
preFilter: {
1552
ATTR: function( match ) {
1553
match[ 1 ] = match[ 1 ].replace( runescape, funescape );
1554
1555
// Move the given value to match[3] whether quoted or unquoted
1556
match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" )
1557
.replace( runescape, funescape );
1558
1559
if ( match[ 2 ] === "~=" ) {
1560
match[ 3 ] = " " + match[ 3 ] + " ";
1561
}
1562
1563
return match.slice( 0, 4 );
1564
},
1565
1566
CHILD: function( match ) {
1567
1568
/* matches from matchExpr["CHILD"]
1569
1 type (only|nth|...)
1570
2 what (child|of-type)
1571
3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1572
4 xn-component of xn+y argument ([+-]?\d*n|)
1573
5 sign of xn-component
1574
6 x of xn-component
1575
7 sign of y-component
1576
8 y of y-component
1577
*/
1578
match[ 1 ] = match[ 1 ].toLowerCase();
1579
1580
if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
1581
1582
// nth-* requires argument
1583
if ( !match[ 3 ] ) {
1584
find.error( match[ 0 ] );
1585
}
1586
1587
// numeric x and y parameters for Expr.filter.CHILD
1588
// remember that false/true cast respectively to 0/1
1589
match[ 4 ] = +( match[ 4 ] ?
1590
match[ 5 ] + ( match[ 6 ] || 1 ) :
1591
2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" )
1592
);
1593
match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
1594
1595
// other types prohibit arguments
1596
} else if ( match[ 3 ] ) {
1597
find.error( match[ 0 ] );
1598
}
1599
1600
return match;
1601
},
1602
1603
PSEUDO: function( match ) {
1604
var excess,
1605
unquoted = !match[ 6 ] && match[ 2 ];
1606
1607
if ( matchExpr.CHILD.test( match[ 0 ] ) ) {
1608
return null;
1609
}
1610
1611
// Accept quoted arguments as-is
1612
if ( match[ 3 ] ) {
1613
match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
1614
1615
// Strip excess characters from unquoted arguments
1616
} else if ( unquoted && rpseudo.test( unquoted ) &&
1617
1618
// Get excess from tokenize (recursively)
1619
( excess = tokenize( unquoted, true ) ) &&
1620
1621
// advance to the next closing parenthesis
1622
( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
1623
1624
// excess is a negative index
1625
match[ 0 ] = match[ 0 ].slice( 0, excess );
1626
match[ 2 ] = unquoted.slice( 0, excess );
1627
}
1628
1629
// Return only captures needed by the pseudo filter method (type and argument)
1630
return match.slice( 0, 3 );
1631
}
1632
},
1633
1634
filter: {
1635
1636
TAG: function( nodeNameSelector ) {
1637
var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1638
return nodeNameSelector === "*" ?
1639
function() {
1640
return true;
1641
} :
1642
function( elem ) {
1643
return nodeName( elem, expectedNodeName );
1644
};
1645
},
1646
1647
CLASS: function( className ) {
1648
var pattern = classCache[ className + " " ];
1649
1650
return pattern ||
1651
( pattern = new RegExp( "(^|" + whitespace + ")" + className +
1652
"(" + whitespace + "|$)" ) ) &&
1653
classCache( className, function( elem ) {
1654
return pattern.test(
1655
typeof elem.className === "string" && elem.className ||
1656
typeof elem.getAttribute !== "undefined" &&
1657
elem.getAttribute( "class" ) ||
1658
""
1659
);
1660
} );
1661
},
1662
1663
ATTR: function( name, operator, check ) {
1664
return function( elem ) {
1665
var result = find.attr( elem, name );
1666
1667
if ( result == null ) {
1668
return operator === "!=";
1669
}
1670
if ( !operator ) {
1671
return true;
1672
}
1673
1674
result += "";
1675
1676
if ( operator === "=" ) {
1677
return result === check;
1678
}
1679
if ( operator === "!=" ) {
1680
return result !== check;
1681
}
1682
if ( operator === "^=" ) {
1683
return check && result.indexOf( check ) === 0;
1684
}
1685
if ( operator === "*=" ) {
1686
return check && result.indexOf( check ) > -1;
1687
}
1688
if ( operator === "$=" ) {
1689
return check && result.slice( -check.length ) === check;
1690
}
1691
if ( operator === "~=" ) {
1692
return ( " " + result.replace( rwhitespace, " " ) + " " )
1693
.indexOf( check ) > -1;
1694
}
1695
if ( operator === "|=" ) {
1696
return result === check || result.slice( 0, check.length + 1 ) === check + "-";
1697
}
1698
1699
return false;
1700
};
1701
},
1702
1703
CHILD: function( type, what, _argument, first, last ) {
1704
var simple = type.slice( 0, 3 ) !== "nth",
1705
forward = type.slice( -4 ) !== "last",
1706
ofType = what === "of-type";
1707
1708
return first === 1 && last === 0 ?
1709
1710
// Shortcut for :nth-*(n)
1711
function( elem ) {
1712
return !!elem.parentNode;
1713
} :
1714
1715
function( elem, _context, xml ) {
1716
var cache, outerCache, node, nodeIndex, start,
1717
dir = simple !== forward ? "nextSibling" : "previousSibling",
1718
parent = elem.parentNode,
1719
name = ofType && elem.nodeName.toLowerCase(),
1720
useCache = !xml && !ofType,
1721
diff = false;
1722
1723
if ( parent ) {
1724
1725
// :(first|last|only)-(child|of-type)
1726
if ( simple ) {
1727
while ( dir ) {
1728
node = elem;
1729
while ( ( node = node[ dir ] ) ) {
1730
if ( ofType ?
1731
nodeName( node, name ) :
1732
node.nodeType === 1 ) {
1733
1734
return false;
1735
}
1736
}
1737
1738
// Reverse direction for :only-* (if we haven't yet done so)
1739
start = dir = type === "only" && !start && "nextSibling";
1740
}
1741
return true;
1742
}
1743
1744
start = [ forward ? parent.firstChild : parent.lastChild ];
1745
1746
// non-xml :nth-child(...) stores cache data on `parent`
1747
if ( forward && useCache ) {
1748
1749
// Seek `elem` from a previously-cached index
1750
outerCache = parent[ expando ] || ( parent[ expando ] = {} );
1751
cache = outerCache[ type ] || [];
1752
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1753
diff = nodeIndex && cache[ 2 ];
1754
node = nodeIndex && parent.childNodes[ nodeIndex ];
1755
1756
while ( ( node = ++nodeIndex && node && node[ dir ] ||
1757
1758
// Fallback to seeking `elem` from the start
1759
( diff = nodeIndex = 0 ) || start.pop() ) ) {
1760
1761
// When found, cache indexes on `parent` and break
1762
if ( node.nodeType === 1 && ++diff && node === elem ) {
1763
outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1764
break;
1765
}
1766
}
1767
1768
} else {
1769
1770
// Use previously-cached element index if available
1771
if ( useCache ) {
1772
outerCache = elem[ expando ] || ( elem[ expando ] = {} );
1773
cache = outerCache[ type ] || [];
1774
nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1775
diff = nodeIndex;
1776
}
1777
1778
// xml :nth-child(...)
1779
// or :nth-last-child(...) or :nth(-last)?-of-type(...)
1780
if ( diff === false ) {
1781
1782
// Use the same loop as above to seek `elem` from the start
1783
while ( ( node = ++nodeIndex && node && node[ dir ] ||
1784
( diff = nodeIndex = 0 ) || start.pop() ) ) {
1785
1786
if ( ( ofType ?
1787
nodeName( node, name ) :
1788
node.nodeType === 1 ) &&
1789
++diff ) {
1790
1791
// Cache the index of each encountered element
1792
if ( useCache ) {
1793
outerCache = node[ expando ] ||
1794
( node[ expando ] = {} );
1795
outerCache[ type ] = [ dirruns, diff ];
1796
}
1797
1798
if ( node === elem ) {
1799
break;
1800
}
1801
}
1802
}
1803
}
1804
}
1805
1806
// Incorporate the offset, then check against cycle size
1807
diff -= last;
1808
return diff === first || ( diff % first === 0 && diff / first >= 0 );
1809
}
1810
};
1811
},
1812
1813
PSEUDO: function( pseudo, argument ) {
1814
1815
// pseudo-class names are case-insensitive
1816
// https://www.w3.org/TR/selectors/#pseudo-classes
1817
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1818
// Remember that setFilters inherits from pseudos
1819
var args,
1820
fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1821
find.error( "unsupported pseudo: " + pseudo );
1822
1823
// The user may use createPseudo to indicate that
1824
// arguments are needed to create the filter function
1825
// just as jQuery does
1826
if ( fn[ expando ] ) {
1827
return fn( argument );
1828
}
1829
1830
// But maintain support for old signatures
1831
if ( fn.length > 1 ) {
1832
args = [ pseudo, pseudo, "", argument ];
1833
return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1834
markFunction( function( seed, matches ) {
1835
var idx,
1836
matched = fn( seed, argument ),
1837
i = matched.length;
1838
while ( i-- ) {
1839
idx = indexOf.call( seed, matched[ i ] );
1840
seed[ idx ] = !( matches[ idx ] = matched[ i ] );
1841
}
1842
} ) :
1843
function( elem ) {
1844
return fn( elem, 0, args );
1845
};
1846
}
1847
1848
return fn;
1849
}
1850
},
1851
1852
pseudos: {
1853
1854
// Potentially complex pseudos
1855
not: markFunction( function( selector ) {
1856
1857
// Trim the selector passed to compile
1858
// to avoid treating leading and trailing
1859
// spaces as combinators
1860
var input = [],
1861
results = [],
1862
matcher = compile( selector.replace( rtrimCSS, "$1" ) );
1863
1864
return matcher[ expando ] ?
1865
markFunction( function( seed, matches, _context, xml ) {
1866
var elem,
1867
unmatched = matcher( seed, null, xml, [] ),
1868
i = seed.length;
1869
1870
// Match elements unmatched by `matcher`
1871
while ( i-- ) {
1872
if ( ( elem = unmatched[ i ] ) ) {
1873
seed[ i ] = !( matches[ i ] = elem );
1874
}
1875
}
1876
} ) :
1877
function( elem, _context, xml ) {
1878
input[ 0 ] = elem;
1879
matcher( input, null, xml, results );
1880
1881
// Don't keep the element
1882
// (see https://github.com/jquery/sizzle/issues/299)
1883
input[ 0 ] = null;
1884
return !results.pop();
1885
};
1886
} ),
1887
1888
has: markFunction( function( selector ) {
1889
return function( elem ) {
1890
return find( selector, elem ).length > 0;
1891
};
1892
} ),
1893
1894
contains: markFunction( function( text ) {
1895
text = text.replace( runescape, funescape );
1896
return function( elem ) {
1897
return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1;
1898
};
1899
} ),
1900
1901
// "Whether an element is represented by a :lang() selector
1902
// is based solely on the element's language value
1903
// being equal to the identifier C,
1904
// or beginning with the identifier C immediately followed by "-".
1905
// The matching of C against the element's language value is performed case-insensitively.
1906
// The identifier C does not have to be a valid language name."
1907
// https://www.w3.org/TR/selectors/#lang-pseudo
1908
lang: markFunction( function( lang ) {
1909
1910
// lang value must be a valid identifier
1911
if ( !ridentifier.test( lang || "" ) ) {
1912
find.error( "unsupported lang: " + lang );
1913
}
1914
lang = lang.replace( runescape, funescape ).toLowerCase();
1915
return function( elem ) {
1916
var elemLang;
1917
do {
1918
if ( ( elemLang = documentIsHTML ?
1919
elem.lang :
1920
elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
1921
1922
elemLang = elemLang.toLowerCase();
1923
return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1924
}
1925
} while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
1926
return false;
1927
};
1928
} ),
1929
1930
// Miscellaneous
1931
target: function( elem ) {
1932
var hash = window.location && window.location.hash;
1933
return hash && hash.slice( 1 ) === elem.id;
1934
},
1935
1936
root: function( elem ) {
1937
return elem === documentElement;
1938
},
1939
1940
focus: function( elem ) {
1941
return elem === safeActiveElement() &&
1942
document.hasFocus() &&
1943
!!( elem.type || elem.href || ~elem.tabIndex );
1944
},
1945
1946
// Boolean properties
1947
enabled: createDisabledPseudo( false ),
1948
disabled: createDisabledPseudo( true ),
1949
1950
checked: function( elem ) {
1951
1952
// In CSS3, :checked should return both checked and selected elements
1953
// https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1954
return ( nodeName( elem, "input" ) && !!elem.checked ) ||
1955
( nodeName( elem, "option" ) && !!elem.selected );
1956
},
1957
1958
selected: function( elem ) {
1959
1960
// Support: IE <=11+
1961
// Accessing the selectedIndex property
1962
// forces the browser to treat the default option as
1963
// selected when in an optgroup.
1964
if ( elem.parentNode ) {
1965
// eslint-disable-next-line no-unused-expressions
1966
elem.parentNode.selectedIndex;
1967
}
1968
1969
return elem.selected === true;
1970
},
1971
1972
// Contents
1973
empty: function( elem ) {
1974
1975
// https://www.w3.org/TR/selectors/#empty-pseudo
1976
// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1977
// but not by others (comment: 8; processing instruction: 7; etc.)
1978
// nodeType < 6 works because attributes (2) do not appear as children
1979
for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1980
if ( elem.nodeType < 6 ) {
1981
return false;
1982
}
1983
}
1984
return true;
1985
},
1986
1987
parent: function( elem ) {
1988
return !Expr.pseudos.empty( elem );
1989
},
1990
1991
// Element/input types
1992
header: function( elem ) {
1993
return rheader.test( elem.nodeName );
1994
},
1995
1996
input: function( elem ) {
1997
return rinputs.test( elem.nodeName );
1998
},
1999
2000
button: function( elem ) {
2001
return nodeName( elem, "input" ) && elem.type === "button" ||
2002
nodeName( elem, "button" );
2003
},
2004
2005
text: function( elem ) {
2006
var attr;
2007
return nodeName( elem, "input" ) && elem.type === "text" &&
2008
2009
// Support: IE <10 only
2010
// New HTML5 attribute values (e.g., "search") appear
2011
// with elem.type === "text"
2012
( ( attr = elem.getAttribute( "type" ) ) == null ||
2013
attr.toLowerCase() === "text" );
2014
},
2015
2016
// Position-in-collection
2017
first: createPositionalPseudo( function() {
2018
return [ 0 ];
2019
} ),
2020
2021
last: createPositionalPseudo( function( _matchIndexes, length ) {
2022
return [ length - 1 ];
2023
} ),
2024
2025
eq: createPositionalPseudo( function( _matchIndexes, length, argument ) {
2026
return [ argument < 0 ? argument + length : argument ];
2027
} ),
2028
2029
even: createPositionalPseudo( function( matchIndexes, length ) {
2030
var i = 0;
2031
for ( ; i < length; i += 2 ) {
2032
matchIndexes.push( i );
2033
}
2034
return matchIndexes;
2035
} ),
2036
2037
odd: createPositionalPseudo( function( matchIndexes, length ) {
2038
var i = 1;
2039
for ( ; i < length; i += 2 ) {
2040
matchIndexes.push( i );
2041
}
2042
return matchIndexes;
2043
} ),
2044
2045
lt: createPositionalPseudo( function( matchIndexes, length, argument ) {
2046
var i;
2047
2048
if ( argument < 0 ) {
2049
i = argument + length;
2050
} else if ( argument > length ) {
2051
i = length;
2052
} else {
2053
i = argument;
2054
}
2055
2056
for ( ; --i >= 0; ) {
2057
matchIndexes.push( i );
2058
}
2059
return matchIndexes;
2060
} ),
2061
2062
gt: createPositionalPseudo( function( matchIndexes, length, argument ) {
2063
var i = argument < 0 ? argument + length : argument;
2064
for ( ; ++i < length; ) {
2065
matchIndexes.push( i );
2066
}
2067
return matchIndexes;
2068
} )
2069
}
2070
};
2071
2072
Expr.pseudos.nth = Expr.pseudos.eq;
2073
2074
// Add button/input type pseudos
2075
for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2076
Expr.pseudos[ i ] = createInputPseudo( i );
2077
}
2078
for ( i in { submit: true, reset: true } ) {
2079
Expr.pseudos[ i ] = createButtonPseudo( i );
2080
}
2081
2082
// Easy API for creating new setFilters
2083
function setFilters() {}
2084
setFilters.prototype = Expr.filters = Expr.pseudos;
2085
Expr.setFilters = new setFilters();
2086
2087
function tokenize( selector, parseOnly ) {
2088
var matched, match, tokens, type,
2089
soFar, groups, preFilters,
2090
cached = tokenCache[ selector + " " ];
2091
2092
if ( cached ) {
2093
return parseOnly ? 0 : cached.slice( 0 );
2094
}
2095
2096
soFar = selector;
2097
groups = [];
2098
preFilters = Expr.preFilter;
2099
2100
while ( soFar ) {
2101
2102
// Comma and first run
2103
if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
2104
if ( match ) {
2105
2106
// Don't consume trailing commas as valid
2107
soFar = soFar.slice( match[ 0 ].length ) || soFar;
2108
}
2109
groups.push( ( tokens = [] ) );
2110
}
2111
2112
matched = false;
2113
2114
// Combinators
2115
if ( ( match = rleadingCombinator.exec( soFar ) ) ) {
2116
matched = match.shift();
2117
tokens.push( {
2118
value: matched,
2119
2120
// Cast descendant combinators to space
2121
type: match[ 0 ].replace( rtrimCSS, " " )
2122
} );
2123
soFar = soFar.slice( matched.length );
2124
}
2125
2126
// Filters
2127
for ( type in Expr.filter ) {
2128
if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
2129
( match = preFilters[ type ]( match ) ) ) ) {
2130
matched = match.shift();
2131
tokens.push( {
2132
value: matched,
2133
type: type,
2134
matches: match
2135
} );
2136
soFar = soFar.slice( matched.length );
2137
}
2138
}
2139
2140
if ( !matched ) {
2141
break;
2142
}
2143
}
2144
2145
// Return the length of the invalid excess
2146
// if we're just parsing
2147
// Otherwise, throw an error or return tokens
2148
if ( parseOnly ) {
2149
return soFar.length;
2150
}
2151
2152
return soFar ?
2153
find.error( selector ) :
2154
2155
// Cache the tokens
2156
tokenCache( selector, groups ).slice( 0 );
2157
}
2158
2159
function toSelector( tokens ) {
2160
var i = 0,
2161
len = tokens.length,
2162
selector = "";
2163
for ( ; i < len; i++ ) {
2164
selector += tokens[ i ].value;
2165
}
2166
return selector;
2167
}
2168
2169
function addCombinator( matcher, combinator, base ) {
2170
var dir = combinator.dir,
2171
skip = combinator.next,
2172
key = skip || dir,
2173
checkNonElements = base && key === "parentNode",
2174
doneName = done++;
2175
2176
return combinator.first ?
2177
2178
// Check against closest ancestor/preceding element
2179
function( elem, context, xml ) {
2180
while ( ( elem = elem[ dir ] ) ) {
2181
if ( elem.nodeType === 1 || checkNonElements ) {
2182
return matcher( elem, context, xml );
2183
}
2184
}
2185
return false;
2186
} :
2187
2188
// Check against all ancestor/preceding elements
2189
function( elem, context, xml ) {
2190
var oldCache, outerCache,
2191
newCache = [ dirruns, doneName ];
2192
2193
// We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2194
if ( xml ) {
2195
while ( ( elem = elem[ dir ] ) ) {
2196
if ( elem.nodeType === 1 || checkNonElements ) {
2197
if ( matcher( elem, context, xml ) ) {
2198
return true;
2199
}
2200
}
2201
}
2202
} else {
2203
while ( ( elem = elem[ dir ] ) ) {
2204
if ( elem.nodeType === 1 || checkNonElements ) {
2205
outerCache = elem[ expando ] || ( elem[ expando ] = {} );
2206
2207
if ( skip && nodeName( elem, skip ) ) {
2208
elem = elem[ dir ] || elem;
2209
} else if ( ( oldCache = outerCache[ key ] ) &&
2210
oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2211
2212
// Assign to newCache so results back-propagate to previous elements
2213
return ( newCache[ 2 ] = oldCache[ 2 ] );
2214
} else {
2215
2216
// Reuse newcache so results back-propagate to previous elements
2217
outerCache[ key ] = newCache;
2218
2219
// A match means we're done; a fail means we have to keep checking
2220
if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
2221
return true;
2222
}
2223
}
2224
}
2225
}
2226
}
2227
return false;
2228
};
2229
}
2230
2231
function elementMatcher( matchers ) {
2232
return matchers.length > 1 ?
2233
function( elem, context, xml ) {
2234
var i = matchers.length;
2235
while ( i-- ) {
2236
if ( !matchers[ i ]( elem, context, xml ) ) {
2237
return false;
2238
}
2239
}
2240
return true;
2241
} :
2242
matchers[ 0 ];
2243
}
2244
2245
function multipleContexts( selector, contexts, results ) {
2246
var i = 0,
2247
len = contexts.length;
2248
for ( ; i < len; i++ ) {
2249
find( selector, contexts[ i ], results );
2250
}
2251
return results;
2252
}
2253
2254
function condense( unmatched, map, filter, context, xml ) {
2255
var elem,
2256
newUnmatched = [],
2257
i = 0,
2258
len = unmatched.length,
2259
mapped = map != null;
2260
2261
for ( ; i < len; i++ ) {
2262
if ( ( elem = unmatched[ i ] ) ) {
2263
if ( !filter || filter( elem, context, xml ) ) {
2264
newUnmatched.push( elem );
2265
if ( mapped ) {
2266
map.push( i );
2267
}
2268
}
2269
}
2270
}
2271
2272
return newUnmatched;
2273
}
2274
2275
function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2276
if ( postFilter && !postFilter[ expando ] ) {
2277
postFilter = setMatcher( postFilter );
2278
}
2279
if ( postFinder && !postFinder[ expando ] ) {
2280
postFinder = setMatcher( postFinder, postSelector );
2281
}
2282
return markFunction( function( seed, results, context, xml ) {
2283
var temp, i, elem, matcherOut,
2284
preMap = [],
2285
postMap = [],
2286
preexisting = results.length,
2287
2288
// Get initial elements from seed or context
2289
elems = seed ||
2290
multipleContexts( selector || "*",
2291
context.nodeType ? [ context ] : context, [] ),
2292
2293
// Prefilter to get matcher input, preserving a map for seed-results synchronization
2294
matcherIn = preFilter && ( seed || !selector ) ?
2295
condense( elems, preMap, preFilter, context, xml ) :
2296
elems;
2297
2298
if ( matcher ) {
2299
2300
// If we have a postFinder, or filtered seed, or non-seed postFilter
2301
// or preexisting results,
2302
matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2303
2304
// ...intermediate processing is necessary
2305
[] :
2306
2307
// ...otherwise use results directly
2308
results;
2309
2310
// Find primary matches
2311
matcher( matcherIn, matcherOut, context, xml );
2312
} else {
2313
matcherOut = matcherIn;
2314
}
2315
2316
// Apply postFilter
2317
if ( postFilter ) {
2318
temp = condense( matcherOut, postMap );
2319
postFilter( temp, [], context, xml );
2320
2321
// Un-match failing elements by moving them back to matcherIn
2322
i = temp.length;
2323
while ( i-- ) {
2324
if ( ( elem = temp[ i ] ) ) {
2325
matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
2326
}
2327
}
2328
}
2329
2330
if ( seed ) {
2331
if ( postFinder || preFilter ) {
2332
if ( postFinder ) {
2333
2334
// Get the final matcherOut by condensing this intermediate into postFinder contexts
2335
temp = [];
2336
i = matcherOut.length;
2337
while ( i-- ) {
2338
if ( ( elem = matcherOut[ i ] ) ) {
2339
2340
// Restore matcherIn since elem is not yet a final match
2341
temp.push( ( matcherIn[ i ] = elem ) );
2342
}
2343
}
2344
postFinder( null, ( matcherOut = [] ), temp, xml );
2345
}
2346
2347
// Move matched elements from seed to results to keep them synchronized
2348
i = matcherOut.length;
2349
while ( i-- ) {
2350
if ( ( elem = matcherOut[ i ] ) &&
2351
( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) {
2352
2353
seed[ temp ] = !( results[ temp ] = elem );
2354
}
2355
}
2356
}
2357
2358
// Add elements to results, through postFinder if defined
2359
} else {
2360
matcherOut = condense(
2361
matcherOut === results ?
2362
matcherOut.splice( preexisting, matcherOut.length ) :
2363
matcherOut
2364
);
2365
if ( postFinder ) {
2366
postFinder( null, results, matcherOut, xml );
2367
} else {
2368
push.apply( results, matcherOut );
2369
}
2370
}
2371
} );
2372
}
2373
2374
function matcherFromTokens( tokens ) {
2375
var checkContext, matcher, j,
2376
len = tokens.length,
2377
leadingRelative = Expr.relative[ tokens[ 0 ].type ],
2378
implicitRelative = leadingRelative || Expr.relative[ " " ],
2379
i = leadingRelative ? 1 : 0,
2380
2381
// The foundational matcher ensures that elements are reachable from top-level context(s)
2382
matchContext = addCombinator( function( elem ) {
2383
return elem === checkContext;
2384
}, implicitRelative, true ),
2385
matchAnyContext = addCombinator( function( elem ) {
2386
return indexOf.call( checkContext, elem ) > -1;
2387
}, implicitRelative, true ),
2388
matchers = [ function( elem, context, xml ) {
2389
2390
// Support: IE 11+, Edge 17 - 18+
2391
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2392
// two documents; shallow comparisons work.
2393
// eslint-disable-next-line eqeqeq
2394
var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || (
2395
( checkContext = context ).nodeType ?
2396
matchContext( elem, context, xml ) :
2397
matchAnyContext( elem, context, xml ) );
2398
2399
// Avoid hanging onto element
2400
// (see https://github.com/jquery/sizzle/issues/299)
2401
checkContext = null;
2402
return ret;
2403
} ];
2404
2405
for ( ; i < len; i++ ) {
2406
if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
2407
matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
2408
} else {
2409
matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
2410
2411
// Return special upon seeing a positional matcher
2412
if ( matcher[ expando ] ) {
2413
2414
// Find the next relative operator (if any) for proper handling
2415
j = ++i;
2416
for ( ; j < len; j++ ) {
2417
if ( Expr.relative[ tokens[ j ].type ] ) {
2418
break;
2419
}
2420
}
2421
return setMatcher(
2422
i > 1 && elementMatcher( matchers ),
2423
i > 1 && toSelector(
2424
2425
// If the preceding token was a descendant combinator, insert an implicit any-element `*`
2426
tokens.slice( 0, i - 1 )
2427
.concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
2428
).replace( rtrimCSS, "$1" ),
2429
matcher,
2430
i < j && matcherFromTokens( tokens.slice( i, j ) ),
2431
j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
2432
j < len && toSelector( tokens )
2433
);
2434
}
2435
matchers.push( matcher );
2436
}
2437
}
2438
2439
return elementMatcher( matchers );
2440
}
2441
2442
function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2443
var bySet = setMatchers.length > 0,
2444
byElement = elementMatchers.length > 0,
2445
superMatcher = function( seed, context, xml, results, outermost ) {
2446
var elem, j, matcher,
2447
matchedCount = 0,
2448
i = "0",
2449
unmatched = seed && [],
2450
setMatched = [],
2451
contextBackup = outermostContext,
2452
2453
// We must always have either seed elements or outermost context
2454
elems = seed || byElement && Expr.find.TAG( "*", outermost ),
2455
2456
// Use integer dirruns iff this is the outermost matcher
2457
dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
2458
len = elems.length;
2459
2460
if ( outermost ) {
2461
2462
// Support: IE 11+, Edge 17 - 18+
2463
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2464
// two documents; shallow comparisons work.
2465
// eslint-disable-next-line eqeqeq
2466
outermostContext = context == document || context || outermost;
2467
}
2468
2469
// Add elements passing elementMatchers directly to results
2470
// Support: iOS <=7 - 9 only
2471
// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching
2472
// elements by id. (see trac-14142)
2473
for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
2474
if ( byElement && elem ) {
2475
j = 0;
2476
2477
// Support: IE 11+, Edge 17 - 18+
2478
// IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2479
// two documents; shallow comparisons work.
2480
// eslint-disable-next-line eqeqeq
2481
if ( !context && elem.ownerDocument != document ) {
2482
setDocument( elem );
2483
xml = !documentIsHTML;
2484
}
2485
while ( ( matcher = elementMatchers[ j++ ] ) ) {
2486
if ( matcher( elem, context || document, xml ) ) {
2487
push.call( results, elem );
2488
break;
2489
}
2490
}
2491
if ( outermost ) {
2492
dirruns = dirrunsUnique;
2493
}
2494
}
2495
2496
// Track unmatched elements for set filters
2497
if ( bySet ) {
2498
2499
// They will have gone through all possible matchers
2500
if ( ( elem = !matcher && elem ) ) {
2501
matchedCount--;
2502
}
2503
2504
// Lengthen the array for every element, matched or not
2505
if ( seed ) {
2506
unmatched.push( elem );
2507
}
2508
}
2509
}
2510
2511
// `i` is now the count of elements visited above, and adding it to `matchedCount`
2512
// makes the latter nonnegative.
2513
matchedCount += i;
2514
2515
// Apply set filters to unmatched elements
2516
// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2517
// equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2518
// no element matchers and no seed.
2519
// Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2520
// case, which will result in a "00" `matchedCount` that differs from `i` but is also
2521
// numerically zero.
2522
if ( bySet && i !== matchedCount ) {
2523
j = 0;
2524
while ( ( matcher = setMatchers[ j++ ] ) ) {
2525
matcher( unmatched, setMatched, context, xml );
2526
}
2527
2528
if ( seed ) {
2529
2530
// Reintegrate element matches to eliminate the need for sorting
2531
if ( matchedCount > 0 ) {
2532
while ( i-- ) {
2533
if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
2534
setMatched[ i ] = pop.call( results );
2535
}
2536
}
2537
}
2538
2539
// Discard index placeholder values to get only actual matches
2540
setMatched = condense( setMatched );
2541
}
2542
2543
// Add matches to results
2544
push.apply( results, setMatched );
2545
2546
// Seedless set matches succeeding multiple successful matchers stipulate sorting
2547
if ( outermost && !seed && setMatched.length > 0 &&
2548
( matchedCount + setMatchers.length ) > 1 ) {
2549
2550
jQuery.uniqueSort( results );
2551
}
2552
}
2553
2554
// Override manipulation of globals by nested matchers
2555
if ( outermost ) {
2556
dirruns = dirrunsUnique;
2557
outermostContext = contextBackup;
2558
}
2559
2560
return unmatched;
2561
};
2562
2563
return bySet ?
2564
markFunction( superMatcher ) :
2565
superMatcher;
2566
}
2567
2568
function compile( selector, match /* Internal Use Only */ ) {
2569
var i,
2570
setMatchers = [],
2571
elementMatchers = [],
2572
cached = compilerCache[ selector + " " ];
2573
2574
if ( !cached ) {
2575
2576
// Generate a function of recursive functions that can be used to check each element
2577
if ( !match ) {
2578
match = tokenize( selector );
2579
}
2580
i = match.length;
2581
while ( i-- ) {
2582
cached = matcherFromTokens( match[ i ] );
2583
if ( cached[ expando ] ) {
2584
setMatchers.push( cached );
2585
} else {
2586
elementMatchers.push( cached );
2587
}
2588
}
2589
2590
// Cache the compiled function
2591
cached = compilerCache( selector,
2592
matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2593
2594
// Save selector and tokenization
2595
cached.selector = selector;
2596
}
2597
return cached;
2598
}
2599
2600
/**
2601
* A low-level selection function that works with jQuery's compiled
2602
* selector functions
2603
* @param {String|Function} selector A selector or a pre-compiled
2604
* selector function built with jQuery selector compile
2605
* @param {Element} context
2606
* @param {Array} [results]
2607
* @param {Array} [seed] A set of elements to match against
2608
*/
2609
function select( selector, context, results, seed ) {
2610
var i, tokens, token, type, find,
2611
compiled = typeof selector === "function" && selector,
2612
match = !seed && tokenize( ( selector = compiled.selector || selector ) );
2613
2614
results = results || [];
2615
2616
// Try to minimize operations if there is only one selector in the list and no seed
2617
// (the latter of which guarantees us context)
2618
if ( match.length === 1 ) {
2619
2620
// Reduce context if the leading compound selector is an ID
2621
tokens = match[ 0 ] = match[ 0 ].slice( 0 );
2622
if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
2623
context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
2624
2625
context = ( Expr.find.ID(
2626
token.matches[ 0 ].replace( runescape, funescape ),
2627
context
2628
) || [] )[ 0 ];
2629
if ( !context ) {
2630
return results;
2631
2632
// Precompiled matchers will still verify ancestry, so step up a level
2633
} else if ( compiled ) {
2634
context = context.parentNode;
2635
}
2636
2637
selector = selector.slice( tokens.shift().value.length );
2638
}
2639
2640
// Fetch a seed set for right-to-left matching
2641
i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length;
2642
while ( i-- ) {
2643
token = tokens[ i ];
2644
2645
// Abort if we hit a combinator
2646
if ( Expr.relative[ ( type = token.type ) ] ) {
2647
break;
2648
}
2649
if ( ( find = Expr.find[ type ] ) ) {
2650
2651
// Search, expanding context for leading sibling combinators
2652
if ( ( seed = find(
2653
token.matches[ 0 ].replace( runescape, funescape ),
2654
rsibling.test( tokens[ 0 ].type ) &&
2655
testContext( context.parentNode ) || context
2656
) ) ) {
2657
2658
// If seed is empty or no tokens remain, we can return early
2659
tokens.splice( i, 1 );
2660
selector = seed.length && toSelector( tokens );
2661
if ( !selector ) {
2662
push.apply( results, seed );
2663
return results;
2664
}
2665
2666
break;
2667
}
2668
}
2669
}
2670
}
2671
2672
// Compile and execute a filtering function if one is not provided
2673
// Provide `match` to avoid retokenization if we modified the selector above
2674
( compiled || compile( selector, match ) )(
2675
seed,
2676
context,
2677
!documentIsHTML,
2678
results,
2679
!context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2680
);
2681
return results;
2682
}
2683
2684
// One-time assignments
2685
2686
// Support: Android <=4.0 - 4.1+
2687
// Sort stability
2688
support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
2689
2690
// Initialize against the default document
2691
setDocument();
2692
2693
// Support: Android <=4.0 - 4.1+
2694
// Detached nodes confoundingly follow *each other*
2695
support.sortDetached = assert( function( el ) {
2696
2697
// Should return 1, but returns 4 (following)
2698
return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
2699
} );
2700
2701
jQuery.find = find;
2702
2703
// Deprecated
2704
jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2705
jQuery.unique = jQuery.uniqueSort;
2706
2707
// These have always been private, but they used to be documented as part of
2708
// Sizzle so let's maintain them for now for backwards compatibility purposes.
2709
find.compile = compile;
2710
find.select = select;
2711
find.setDocument = setDocument;
2712
find.tokenize = tokenize;
2713
2714
find.escape = jQuery.escapeSelector;
2715
find.getText = jQuery.text;
2716
find.isXML = jQuery.isXMLDoc;
2717
find.selectors = jQuery.expr;
2718
find.support = jQuery.support;
2719
find.uniqueSort = jQuery.uniqueSort;
2720
2721
/* eslint-enable */
2722
2723
} )();
2724
2725
2726
var dir = function( elem, dir, until ) {
2727
var matched = [],
2728
truncate = until !== undefined;
2729
2730
while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2731
if ( elem.nodeType === 1 ) {
2732
if ( truncate && jQuery( elem ).is( until ) ) {
2733
break;
2734
}
2735
matched.push( elem );
2736
}
2737
}
2738
return matched;
2739
};
2740
2741
2742
var siblings = function( n, elem ) {
2743
var matched = [];
2744
2745
for ( ; n; n = n.nextSibling ) {
2746
if ( n.nodeType === 1 && n !== elem ) {
2747
matched.push( n );
2748
}
2749
}
2750
2751
return matched;
2752
};
2753
2754
2755
var rneedsContext = jQuery.expr.match.needsContext;
2756
2757
var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2758
2759
2760
2761
// Implement the identical functionality for filter and not
2762
function winnow( elements, qualifier, not ) {
2763
if ( isFunction( qualifier ) ) {
2764
return jQuery.grep( elements, function( elem, i ) {
2765
return !!qualifier.call( elem, i, elem ) !== not;
2766
} );
2767
}
2768
2769
// Single element
2770
if ( qualifier.nodeType ) {
2771
return jQuery.grep( elements, function( elem ) {
2772
return ( elem === qualifier ) !== not;
2773
} );
2774
}
2775
2776
// Arraylike of elements (jQuery, arguments, Array)
2777
if ( typeof qualifier !== "string" ) {
2778
return jQuery.grep( elements, function( elem ) {
2779
return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
2780
} );
2781
}
2782
2783
// Filtered directly for both simple and complex selectors
2784
return jQuery.filter( qualifier, elements, not );
2785
}
2786
2787
jQuery.filter = function( expr, elems, not ) {
2788
var elem = elems[ 0 ];
2789
2790
if ( not ) {
2791
expr = ":not(" + expr + ")";
2792
}
2793
2794
if ( elems.length === 1 && elem.nodeType === 1 ) {
2795
return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
2796
}
2797
2798
return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2799
return elem.nodeType === 1;
2800
} ) );
2801
};
2802
2803
jQuery.fn.extend( {
2804
find: function( selector ) {
2805
var i, ret,
2806
len = this.length,
2807
self = this;
2808
2809
if ( typeof selector !== "string" ) {
2810
return this.pushStack( jQuery( selector ).filter( function() {
2811
for ( i = 0; i < len; i++ ) {
2812
if ( jQuery.contains( self[ i ], this ) ) {
2813
return true;
2814
}
2815
}
2816
} ) );
2817
}
2818
2819
ret = this.pushStack( [] );
2820
2821
for ( i = 0; i < len; i++ ) {
2822
jQuery.find( selector, self[ i ], ret );
2823
}
2824
2825
return len > 1 ? jQuery.uniqueSort( ret ) : ret;
2826
},
2827
filter: function( selector ) {
2828
return this.pushStack( winnow( this, selector || [], false ) );
2829
},
2830
not: function( selector ) {
2831
return this.pushStack( winnow( this, selector || [], true ) );
2832
},
2833
is: function( selector ) {
2834
return !!winnow(
2835
this,
2836
2837
// If this is a positional/relative selector, check membership in the returned set
2838
// so $("p:first").is("p:last") won't return true for a doc with two "p".
2839
typeof selector === "string" && rneedsContext.test( selector ) ?
2840
jQuery( selector ) :
2841
selector || [],
2842
false
2843
).length;
2844
}
2845
} );
2846
2847
2848
// Initialize a jQuery object
2849
2850
2851
// A central reference to the root jQuery(document)
2852
var rootjQuery,
2853
2854
// A simple way to check for HTML strings
2855
// Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)
2856
// Strict HTML recognition (trac-11290: must start with <)
2857
// Shortcut simple #id case for speed
2858
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2859
2860
init = jQuery.fn.init = function( selector, context, root ) {
2861
var match, elem;
2862
2863
// HANDLE: $(""), $(null), $(undefined), $(false)
2864
if ( !selector ) {
2865
return this;
2866
}
2867
2868
// Method init() accepts an alternate rootjQuery
2869
// so migrate can support jQuery.sub (gh-2101)
2870
root = root || rootjQuery;
2871
2872
// Handle HTML strings
2873
if ( typeof selector === "string" ) {
2874
if ( selector[ 0 ] === "<" &&
2875
selector[ selector.length - 1 ] === ">" &&
2876
selector.length >= 3 ) {
2877
2878
// Assume that strings that start and end with <> are HTML and skip the regex check
2879
match = [ null, selector, null ];
2880
2881
} else {
2882
match = rquickExpr.exec( selector );
2883
}
2884
2885
// Match html or make sure no context is specified for #id
2886
if ( match && ( match[ 1 ] || !context ) ) {
2887
2888
// HANDLE: $(html) -> $(array)
2889
if ( match[ 1 ] ) {
2890
context = context instanceof jQuery ? context[ 0 ] : context;
2891
2892
// Option to run scripts is true for back-compat
2893
// Intentionally let the error be thrown if parseHTML is not present
2894
jQuery.merge( this, jQuery.parseHTML(
2895
match[ 1 ],
2896
context && context.nodeType ? context.ownerDocument || context : document,
2897
true
2898
) );
2899
2900
// HANDLE: $(html, props)
2901
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2902
for ( match in context ) {
2903
2904
// Properties of context are called as methods if possible
2905
if ( isFunction( this[ match ] ) ) {
2906
this[ match ]( context[ match ] );
2907
2908
// ...and otherwise set as attributes
2909
} else {
2910
this.attr( match, context[ match ] );
2911
}
2912
}
2913
}
2914
2915
return this;
2916
2917
// HANDLE: $(#id)
2918
} else {
2919
elem = document.getElementById( match[ 2 ] );
2920
2921
if ( elem ) {
2922
2923
// Inject the element directly into the jQuery object
2924
this[ 0 ] = elem;
2925
this.length = 1;
2926
}
2927
return this;
2928
}
2929
2930
// HANDLE: $(expr, $(...))
2931
} else if ( !context || context.jquery ) {
2932
return ( context || root ).find( selector );
2933
2934
// HANDLE: $(expr, context)
2935
// (which is just equivalent to: $(context).find(expr)
2936
} else {
2937
return this.constructor( context ).find( selector );
2938
}
2939
2940
// HANDLE: $(DOMElement)
2941
} else if ( selector.nodeType ) {
2942
this[ 0 ] = selector;
2943
this.length = 1;
2944
return this;
2945
2946
// HANDLE: $(function)
2947
// Shortcut for document ready
2948
} else if ( isFunction( selector ) ) {
2949
return root.ready !== undefined ?
2950
root.ready( selector ) :
2951
2952
// Execute immediately if ready is not present
2953
selector( jQuery );
2954
}
2955
2956
return jQuery.makeArray( selector, this );
2957
};
2958
2959
// Give the init function the jQuery prototype for later instantiation
2960
init.prototype = jQuery.fn;
2961
2962
// Initialize central reference
2963
rootjQuery = jQuery( document );
2964
2965
2966
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2967
2968
// Methods guaranteed to produce a unique set when starting from a unique set
2969
guaranteedUnique = {
2970
children: true,
2971
contents: true,
2972
next: true,
2973
prev: true
2974
};
2975
2976
jQuery.fn.extend( {
2977
has: function( target ) {
2978
var targets = jQuery( target, this ),
2979
l = targets.length;
2980
2981
return this.filter( function() {
2982
var i = 0;
2983
for ( ; i < l; i++ ) {
2984
if ( jQuery.contains( this, targets[ i ] ) ) {
2985
return true;
2986
}
2987
}
2988
} );
2989
},
2990
2991
closest: function( selectors, context ) {
2992
var cur,
2993
i = 0,
2994
l = this.length,
2995
matched = [],
2996
targets = typeof selectors !== "string" && jQuery( selectors );
2997
2998
// Positional selectors never match, since there's no _selection_ context
2999
if ( !rneedsContext.test( selectors ) ) {
3000
for ( ; i < l; i++ ) {
3001
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3002
3003
// Always skip document fragments
3004
if ( cur.nodeType < 11 && ( targets ?
3005
targets.index( cur ) > -1 :
3006
3007
// Don't pass non-elements to jQuery#find
3008
cur.nodeType === 1 &&
3009
jQuery.find.matchesSelector( cur, selectors ) ) ) {
3010
3011
matched.push( cur );
3012
break;
3013
}
3014
}
3015
}
3016
}
3017
3018
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3019
},
3020
3021
// Determine the position of an element within the set
3022
index: function( elem ) {
3023
3024
// No argument, return index in parent
3025
if ( !elem ) {
3026
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3027
}
3028
3029
// Index in selector
3030
if ( typeof elem === "string" ) {
3031
return indexOf.call( jQuery( elem ), this[ 0 ] );
3032
}
3033
3034
// Locate the position of the desired element
3035
return indexOf.call( this,
3036
3037
// If it receives a jQuery object, the first element is used
3038
elem.jquery ? elem[ 0 ] : elem
3039
);
3040
},
3041
3042
add: function( selector, context ) {
3043
return this.pushStack(
3044
jQuery.uniqueSort(
3045
jQuery.merge( this.get(), jQuery( selector, context ) )
3046
)
3047
);
3048
},
3049
3050
addBack: function( selector ) {
3051
return this.add( selector == null ?
3052
this.prevObject : this.prevObject.filter( selector )
3053
);
3054
}
3055
} );
3056
3057
function sibling( cur, dir ) {
3058
while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
3059
return cur;
3060
}
3061
3062
jQuery.each( {
3063
parent: function( elem ) {
3064
var parent = elem.parentNode;
3065
return parent && parent.nodeType !== 11 ? parent : null;
3066
},
3067
parents: function( elem ) {
3068
return dir( elem, "parentNode" );
3069
},
3070
parentsUntil: function( elem, _i, until ) {
3071
return dir( elem, "parentNode", until );
3072
},
3073
next: function( elem ) {
3074
return sibling( elem, "nextSibling" );
3075
},
3076
prev: function( elem ) {
3077
return sibling( elem, "previousSibling" );
3078
},
3079
nextAll: function( elem ) {
3080
return dir( elem, "nextSibling" );
3081
},
3082
prevAll: function( elem ) {
3083
return dir( elem, "previousSibling" );
3084
},
3085
nextUntil: function( elem, _i, until ) {
3086
return dir( elem, "nextSibling", until );
3087
},
3088
prevUntil: function( elem, _i, until ) {
3089
return dir( elem, "previousSibling", until );
3090
},
3091
siblings: function( elem ) {
3092
return siblings( ( elem.parentNode || {} ).firstChild, elem );
3093
},
3094
children: function( elem ) {
3095
return siblings( elem.firstChild );
3096
},
3097
contents: function( elem ) {
3098
if ( elem.contentDocument != null &&
3099
3100
// Support: IE 11+
3101
// <object> elements with no `data` attribute has an object
3102
// `contentDocument` with a `null` prototype.
3103
getProto( elem.contentDocument ) ) {
3104
3105
return elem.contentDocument;
3106
}
3107
3108
// Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3109
// Treat the template element as a regular one in browsers that
3110
// don't support it.
3111
if ( nodeName( elem, "template" ) ) {
3112
elem = elem.content || elem;
3113
}
3114
3115
return jQuery.merge( [], elem.childNodes );
3116
}
3117
}, function( name, fn ) {
3118
jQuery.fn[ name ] = function( until, selector ) {
3119
var matched = jQuery.map( this, fn, until );
3120
3121
if ( name.slice( -5 ) !== "Until" ) {
3122
selector = until;
3123
}
3124
3125
if ( selector && typeof selector === "string" ) {
3126
matched = jQuery.filter( selector, matched );
3127
}
3128
3129
if ( this.length > 1 ) {
3130
3131
// Remove duplicates
3132
if ( !guaranteedUnique[ name ] ) {
3133
jQuery.uniqueSort( matched );
3134
}
3135
3136
// Reverse order for parents* and prev-derivatives
3137
if ( rparentsprev.test( name ) ) {
3138
matched.reverse();
3139
}
3140
}
3141
3142
return this.pushStack( matched );
3143
};
3144
} );
3145
var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
3146
3147
3148
3149
// Convert String-formatted options into Object-formatted ones
3150
function createOptions( options ) {
3151
var object = {};
3152
jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
3153
object[ flag ] = true;
3154
} );
3155
return object;
3156
}
3157
3158
/*
3159
* Create a callback list using the following parameters:
3160
*
3161
* options: an optional list of space-separated options that will change how
3162
* the callback list behaves or a more traditional option object
3163
*
3164
* By default a callback list will act like an event callback list and can be
3165
* "fired" multiple times.
3166
*
3167
* Possible options:
3168
*
3169
* once: will ensure the callback list can only be fired once (like a Deferred)
3170
*
3171
* memory: will keep track of previous values and will call any callback added
3172
* after the list has been fired right away with the latest "memorized"
3173
* values (like a Deferred)
3174
*
3175
* unique: will ensure a callback can only be added once (no duplicate in the list)
3176
*
3177
* stopOnFalse: interrupt callings when a callback returns false
3178
*
3179
*/
3180
jQuery.Callbacks = function( options ) {
3181
3182
// Convert options from String-formatted to Object-formatted if needed
3183
// (we check in cache first)
3184
options = typeof options === "string" ?
3185
createOptions( options ) :
3186
jQuery.extend( {}, options );
3187
3188
var // Flag to know if list is currently firing
3189
firing,
3190
3191
// Last fire value for non-forgettable lists
3192
memory,
3193
3194
// Flag to know if list was already fired
3195
fired,
3196
3197
// Flag to prevent firing
3198
locked,
3199
3200
// Actual callback list
3201
list = [],
3202
3203
// Queue of execution data for repeatable lists
3204
queue = [],
3205
3206
// Index of currently firing callback (modified by add/remove as needed)
3207
firingIndex = -1,
3208
3209
// Fire callbacks
3210
fire = function() {
3211
3212
// Enforce single-firing
3213
locked = locked || options.once;
3214
3215
// Execute callbacks for all pending executions,
3216
// respecting firingIndex overrides and runtime changes
3217
fired = firing = true;
3218
for ( ; queue.length; firingIndex = -1 ) {
3219
memory = queue.shift();
3220
while ( ++firingIndex < list.length ) {
3221
3222
// Run callback and check for early termination
3223
if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3224
options.stopOnFalse ) {
3225
3226
// Jump to end and forget the data so .add doesn't re-fire
3227
firingIndex = list.length;
3228
memory = false;
3229
}
3230
}
3231
}
3232
3233
// Forget the data if we're done with it
3234
if ( !options.memory ) {
3235
memory = false;
3236
}
3237
3238
firing = false;
3239
3240
// Clean up if we're done firing for good
3241
if ( locked ) {
3242
3243
// Keep an empty list if we have data for future add calls
3244
if ( memory ) {
3245
list = [];
3246
3247
// Otherwise, this object is spent
3248
} else {
3249
list = "";
3250
}
3251
}
3252
},
3253
3254
// Actual Callbacks object
3255
self = {
3256
3257
// Add a callback or a collection of callbacks to the list
3258
add: function() {
3259
if ( list ) {
3260
3261
// If we have memory from a past run, we should fire after adding
3262
if ( memory && !firing ) {
3263
firingIndex = list.length - 1;
3264
queue.push( memory );
3265
}
3266
3267
( function add( args ) {
3268
jQuery.each( args, function( _, arg ) {
3269
if ( isFunction( arg ) ) {
3270
if ( !options.unique || !self.has( arg ) ) {
3271
list.push( arg );
3272
}
3273
} else if ( arg && arg.length && toType( arg ) !== "string" ) {
3274
3275
// Inspect recursively
3276
add( arg );
3277
}
3278
} );
3279
} )( arguments );
3280
3281
if ( memory && !firing ) {
3282
fire();
3283
}
3284
}
3285
return this;
3286
},
3287
3288
// Remove a callback from the list
3289
remove: function() {
3290
jQuery.each( arguments, function( _, arg ) {
3291
var index;
3292
while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3293
list.splice( index, 1 );
3294
3295
// Handle firing indexes
3296
if ( index <= firingIndex ) {
3297
firingIndex--;
3298
}
3299
}
3300
} );
3301
return this;
3302
},
3303
3304
// Check if a given callback is in the list.
3305
// If no argument is given, return whether or not list has callbacks attached.
3306
has: function( fn ) {
3307
return fn ?
3308
jQuery.inArray( fn, list ) > -1 :
3309
list.length > 0;
3310
},
3311
3312
// Remove all callbacks from the list
3313
empty: function() {
3314
if ( list ) {
3315
list = [];
3316
}
3317
return this;
3318
},
3319
3320
// Disable .fire and .add
3321
// Abort any current/pending executions
3322
// Clear all callbacks and values
3323
disable: function() {
3324
locked = queue = [];
3325
list = memory = "";
3326
return this;
3327
},
3328
disabled: function() {
3329
return !list;
3330
},
3331
3332
// Disable .fire
3333
// Also disable .add unless we have memory (since it would have no effect)
3334
// Abort any pending executions
3335
lock: function() {
3336
locked = queue = [];
3337
if ( !memory && !firing ) {
3338
list = memory = "";
3339
}
3340
return this;
3341
},
3342
locked: function() {
3343
return !!locked;
3344
},
3345
3346
// Call all callbacks with the given context and arguments
3347
fireWith: function( context, args ) {
3348
if ( !locked ) {
3349
args = args || [];
3350
args = [ context, args.slice ? args.slice() : args ];
3351
queue.push( args );
3352
if ( !firing ) {
3353
fire();
3354
}
3355
}
3356
return this;
3357
},
3358
3359
// Call all the callbacks with the given arguments
3360
fire: function() {
3361
self.fireWith( this, arguments );
3362
return this;
3363
},
3364
3365
// To know if the callbacks have already been called at least once
3366
fired: function() {
3367
return !!fired;
3368
}
3369
};
3370
3371
return self;
3372
};
3373
3374
3375
function Identity( v ) {
3376
return v;
3377
}
3378
function Thrower( ex ) {
3379
throw ex;
3380
}
3381
3382
function adoptValue( value, resolve, reject, noValue ) {
3383
var method;
3384
3385
try {
3386
3387
// Check for promise aspect first to privilege synchronous behavior
3388
if ( value && isFunction( ( method = value.promise ) ) ) {
3389
method.call( value ).done( resolve ).fail( reject );
3390
3391
// Other thenables
3392
} else if ( value && isFunction( ( method = value.then ) ) ) {
3393
method.call( value, resolve, reject );
3394
3395
// Other non-thenables
3396
} else {
3397
3398
// Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3399
// * false: [ value ].slice( 0 ) => resolve( value )
3400
// * true: [ value ].slice( 1 ) => resolve()
3401
resolve.apply( undefined, [ value ].slice( noValue ) );
3402
}
3403
3404
// For Promises/A+, convert exceptions into rejections
3405
// Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3406
// Deferred#then to conditionally suppress rejection.
3407
} catch ( value ) {
3408
3409
// Support: Android 4.0 only
3410
// Strict mode functions invoked without .call/.apply get global-object context
3411
reject.apply( undefined, [ value ] );
3412
}
3413
}
3414
3415
jQuery.extend( {
3416
3417
Deferred: function( func ) {
3418
var tuples = [
3419
3420
// action, add listener, callbacks,
3421
// ... .then handlers, argument index, [final state]
3422
[ "notify", "progress", jQuery.Callbacks( "memory" ),
3423
jQuery.Callbacks( "memory" ), 2 ],
3424
[ "resolve", "done", jQuery.Callbacks( "once memory" ),
3425
jQuery.Callbacks( "once memory" ), 0, "resolved" ],
3426
[ "reject", "fail", jQuery.Callbacks( "once memory" ),
3427
jQuery.Callbacks( "once memory" ), 1, "rejected" ]
3428
],
3429
state = "pending",
3430
promise = {
3431
state: function() {
3432
return state;
3433
},
3434
always: function() {
3435
deferred.done( arguments ).fail( arguments );
3436
return this;
3437
},
3438
"catch": function( fn ) {
3439
return promise.then( null, fn );
3440
},
3441
3442
// Keep pipe for back-compat
3443
pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3444
var fns = arguments;
3445
3446
return jQuery.Deferred( function( newDefer ) {
3447
jQuery.each( tuples, function( _i, tuple ) {
3448
3449
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
3450
var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
3451
3452
// deferred.progress(function() { bind to newDefer or newDefer.notify })
3453
// deferred.done(function() { bind to newDefer or newDefer.resolve })
3454
// deferred.fail(function() { bind to newDefer or newDefer.reject })
3455
deferred[ tuple[ 1 ] ]( function() {
3456
var returned = fn && fn.apply( this, arguments );
3457
if ( returned && isFunction( returned.promise ) ) {
3458
returned.promise()
3459
.progress( newDefer.notify )
3460
.done( newDefer.resolve )
3461
.fail( newDefer.reject );
3462
} else {
3463
newDefer[ tuple[ 0 ] + "With" ](
3464
this,
3465
fn ? [ returned ] : arguments
3466
);
3467
}
3468
} );
3469
} );
3470
fns = null;
3471
} ).promise();
3472
},
3473
then: function( onFulfilled, onRejected, onProgress ) {
3474
var maxDepth = 0;
3475
function resolve( depth, deferred, handler, special ) {
3476
return function() {
3477
var that = this,
3478
args = arguments,
3479
mightThrow = function() {
3480
var returned, then;
3481
3482
// Support: Promises/A+ section 2.3.3.3.3
3483
// https://promisesaplus.com/#point-59
3484
// Ignore double-resolution attempts
3485
if ( depth < maxDepth ) {
3486
return;
3487
}
3488
3489
returned = handler.apply( that, args );
3490
3491
// Support: Promises/A+ section 2.3.1
3492
// https://promisesaplus.com/#point-48
3493
if ( returned === deferred.promise() ) {
3494
throw new TypeError( "Thenable self-resolution" );
3495
}
3496
3497
// Support: Promises/A+ sections 2.3.3.1, 3.5
3498
// https://promisesaplus.com/#point-54
3499
// https://promisesaplus.com/#point-75
3500
// Retrieve `then` only once
3501
then = returned &&
3502
3503
// Support: Promises/A+ section 2.3.4
3504
// https://promisesaplus.com/#point-64
3505
// Only check objects and functions for thenability
3506
( typeof returned === "object" ||
3507
typeof returned === "function" ) &&
3508
returned.then;
3509
3510
// Handle a returned thenable
3511
if ( isFunction( then ) ) {
3512
3513
// Special processors (notify) just wait for resolution
3514
if ( special ) {
3515
then.call(
3516
returned,
3517
resolve( maxDepth, deferred, Identity, special ),
3518
resolve( maxDepth, deferred, Thrower, special )
3519
);
3520
3521
// Normal processors (resolve) also hook into progress
3522
} else {
3523
3524
// ...and disregard older resolution values
3525
maxDepth++;
3526
3527
then.call(
3528
returned,
3529
resolve( maxDepth, deferred, Identity, special ),
3530
resolve( maxDepth, deferred, Thrower, special ),
3531
resolve( maxDepth, deferred, Identity,
3532
deferred.notifyWith )
3533
);
3534
}
3535
3536
// Handle all other returned values
3537
} else {
3538
3539
// Only substitute handlers pass on context
3540
// and multiple values (non-spec behavior)
3541
if ( handler !== Identity ) {
3542
that = undefined;
3543
args = [ returned ];
3544
}
3545
3546
// Process the value(s)
3547
// Default process is resolve
3548
( special || deferred.resolveWith )( that, args );
3549
}
3550
},
3551
3552
// Only normal processors (resolve) catch and reject exceptions
3553
process = special ?
3554
mightThrow :
3555
function() {
3556
try {
3557
mightThrow();
3558
} catch ( e ) {
3559
3560
if ( jQuery.Deferred.exceptionHook ) {
3561
jQuery.Deferred.exceptionHook( e,
3562
process.error );
3563
}
3564
3565
// Support: Promises/A+ section 2.3.3.3.4.1
3566
// https://promisesaplus.com/#point-61
3567
// Ignore post-resolution exceptions
3568
if ( depth + 1 >= maxDepth ) {
3569
3570
// Only substitute handlers pass on context
3571
// and multiple values (non-spec behavior)
3572
if ( handler !== Thrower ) {
3573
that = undefined;
3574
args = [ e ];
3575
}
3576
3577
deferred.rejectWith( that, args );
3578
}
3579
}
3580
};
3581
3582
// Support: Promises/A+ section 2.3.3.3.1
3583
// https://promisesaplus.com/#point-57
3584
// Re-resolve promises immediately to dodge false rejection from
3585
// subsequent errors
3586
if ( depth ) {
3587
process();
3588
} else {
3589
3590
// Call an optional hook to record the error, in case of exception
3591
// since it's otherwise lost when execution goes async
3592
if ( jQuery.Deferred.getErrorHook ) {
3593
process.error = jQuery.Deferred.getErrorHook();
3594
3595
// The deprecated alias of the above. While the name suggests
3596
// returning the stack, not an error instance, jQuery just passes
3597
// it directly to `console.warn` so both will work; an instance
3598
// just better cooperates with source maps.
3599
} else if ( jQuery.Deferred.getStackHook ) {
3600
process.error = jQuery.Deferred.getStackHook();
3601
}
3602
window.setTimeout( process );
3603
}
3604
};
3605
}
3606
3607
return jQuery.Deferred( function( newDefer ) {
3608
3609
// progress_handlers.add( ... )
3610
tuples[ 0 ][ 3 ].add(
3611
resolve(
3612
0,
3613
newDefer,
3614
isFunction( onProgress ) ?
3615
onProgress :
3616
Identity,
3617
newDefer.notifyWith
3618
)
3619
);
3620
3621
// fulfilled_handlers.add( ... )
3622
tuples[ 1 ][ 3 ].add(
3623
resolve(
3624
0,
3625
newDefer,
3626
isFunction( onFulfilled ) ?
3627
onFulfilled :
3628
Identity
3629
)
3630
);
3631
3632
// rejected_handlers.add( ... )
3633
tuples[ 2 ][ 3 ].add(
3634
resolve(
3635
0,
3636
newDefer,
3637
isFunction( onRejected ) ?
3638
onRejected :
3639
Thrower
3640
)
3641
);
3642
} ).promise();
3643
},
3644
3645
// Get a promise for this deferred
3646
// If obj is provided, the promise aspect is added to the object
3647
promise: function( obj ) {
3648
return obj != null ? jQuery.extend( obj, promise ) : promise;
3649
}
3650
},
3651
deferred = {};
3652
3653
// Add list-specific methods
3654
jQuery.each( tuples, function( i, tuple ) {
3655
var list = tuple[ 2 ],
3656
stateString = tuple[ 5 ];
3657
3658
// promise.progress = list.add
3659
// promise.done = list.add
3660
// promise.fail = list.add
3661
promise[ tuple[ 1 ] ] = list.add;
3662
3663
// Handle state
3664
if ( stateString ) {
3665
list.add(
3666
function() {
3667
3668
// state = "resolved" (i.e., fulfilled)
3669
// state = "rejected"
3670
state = stateString;
3671
},
3672
3673
// rejected_callbacks.disable
3674
// fulfilled_callbacks.disable
3675
tuples[ 3 - i ][ 2 ].disable,
3676
3677
// rejected_handlers.disable
3678
// fulfilled_handlers.disable
3679
tuples[ 3 - i ][ 3 ].disable,
3680
3681
// progress_callbacks.lock
3682
tuples[ 0 ][ 2 ].lock,
3683
3684
// progress_handlers.lock
3685
tuples[ 0 ][ 3 ].lock
3686
);
3687
}
3688
3689
// progress_handlers.fire
3690
// fulfilled_handlers.fire
3691
// rejected_handlers.fire
3692
list.add( tuple[ 3 ].fire );
3693
3694
// deferred.notify = function() { deferred.notifyWith(...) }
3695
// deferred.resolve = function() { deferred.resolveWith(...) }
3696
// deferred.reject = function() { deferred.rejectWith(...) }
3697
deferred[ tuple[ 0 ] ] = function() {
3698
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
3699
return this;
3700
};
3701
3702
// deferred.notifyWith = list.fireWith
3703
// deferred.resolveWith = list.fireWith
3704
// deferred.rejectWith = list.fireWith
3705
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3706
} );
3707
3708
// Make the deferred a promise
3709
promise.promise( deferred );
3710
3711
// Call given func if any
3712
if ( func ) {
3713
func.call( deferred, deferred );
3714
}
3715
3716
// All done!
3717
return deferred;
3718
},
3719
3720
// Deferred helper
3721
when: function( singleValue ) {
3722
var
3723
3724
// count of uncompleted subordinates
3725
remaining = arguments.length,
3726
3727
// count of unprocessed arguments
3728
i = remaining,
3729
3730
// subordinate fulfillment data
3731
resolveContexts = Array( i ),
3732
resolveValues = slice.call( arguments ),
3733
3734
// the primary Deferred
3735
primary = jQuery.Deferred(),
3736
3737
// subordinate callback factory
3738
updateFunc = function( i ) {
3739
return function( value ) {
3740
resolveContexts[ i ] = this;
3741
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3742
if ( !( --remaining ) ) {
3743
primary.resolveWith( resolveContexts, resolveValues );
3744
}
3745
};
3746
};
3747
3748
// Single- and empty arguments are adopted like Promise.resolve
3749
if ( remaining <= 1 ) {
3750
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
3751
!remaining );
3752
3753
// Use .then() to unwrap secondary thenables (cf. gh-3000)
3754
if ( primary.state() === "pending" ||
3755
isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
3756
3757
return primary.then();
3758
}
3759
}
3760
3761
// Multiple arguments are aggregated like Promise.all array elements
3762
while ( i-- ) {
3763
adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
3764
}
3765
3766
return primary.promise();
3767
}
3768
} );
3769
3770
3771
// These usually indicate a programmer mistake during development,
3772
// warn about them ASAP rather than swallowing them by default.
3773
var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3774
3775
// If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error
3776
// captured before the async barrier to get the original error cause
3777
// which may otherwise be hidden.
3778
jQuery.Deferred.exceptionHook = function( error, asyncError ) {
3779
3780
// Support: IE 8 - 9 only
3781
// Console exists when dev tools are open, which can happen at any time
3782
if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
3783
window.console.warn( "jQuery.Deferred exception: " + error.message,
3784
error.stack, asyncError );
3785
}
3786
};
3787
3788
3789
3790
3791
jQuery.readyException = function( error ) {
3792
window.setTimeout( function() {
3793
throw error;
3794
} );
3795
};
3796
3797
3798
3799
3800
// The deferred used on DOM ready
3801
var readyList = jQuery.Deferred();
3802
3803
jQuery.fn.ready = function( fn ) {
3804
3805
readyList
3806
.then( fn )
3807
3808
// Wrap jQuery.readyException in a function so that the lookup
3809
// happens at the time of error handling instead of callback
3810
// registration.
3811
.catch( function( error ) {
3812
jQuery.readyException( error );
3813
} );
3814
3815
return this;
3816
};
3817
3818
jQuery.extend( {
3819
3820
// Is the DOM ready to be used? Set to true once it occurs.
3821
isReady: false,
3822
3823
// A counter to track how many items to wait for before
3824
// the ready event fires. See trac-6781
3825
readyWait: 1,
3826
3827
// Handle when the DOM is ready
3828
ready: function( wait ) {
3829
3830
// Abort if there are pending holds or we're already ready
3831
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3832
return;
3833
}
3834
3835
// Remember that the DOM is ready
3836
jQuery.isReady = true;
3837
3838
// If a normal DOM Ready event fired, decrement, and wait if need be
3839
if ( wait !== true && --jQuery.readyWait > 0 ) {
3840
return;
3841
}
3842
3843
// If there are functions bound, to execute
3844
readyList.resolveWith( document, [ jQuery ] );
3845
}
3846
} );
3847
3848
jQuery.ready.then = readyList.then;
3849
3850
// The ready event handler and self cleanup method
3851
function completed() {
3852
document.removeEventListener( "DOMContentLoaded", completed );
3853
window.removeEventListener( "load", completed );
3854
jQuery.ready();
3855
}
3856
3857
// Catch cases where $(document).ready() is called
3858
// after the browser event has already occurred.
3859
// Support: IE <=9 - 10 only
3860
// Older IE sometimes signals "interactive" too soon
3861
if ( document.readyState === "complete" ||
3862
( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3863
3864
// Handle it asynchronously to allow scripts the opportunity to delay ready
3865
window.setTimeout( jQuery.ready );
3866
3867
} else {
3868
3869
// Use the handy event callback
3870
document.addEventListener( "DOMContentLoaded", completed );
3871
3872
// A fallback to window.onload, that will always work
3873
window.addEventListener( "load", completed );
3874
}
3875
3876
3877
3878
3879
// Multifunctional method to get and set values of a collection
3880
// The value/s can optionally be executed if it's a function
3881
var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3882
var i = 0,
3883
len = elems.length,
3884
bulk = key == null;
3885
3886
// Sets many values
3887
if ( toType( key ) === "object" ) {
3888
chainable = true;
3889
for ( i in key ) {
3890
access( elems, fn, i, key[ i ], true, emptyGet, raw );
3891
}
3892
3893
// Sets one value
3894
} else if ( value !== undefined ) {
3895
chainable = true;
3896
3897
if ( !isFunction( value ) ) {
3898
raw = true;
3899
}
3900
3901
if ( bulk ) {
3902
3903
// Bulk operations run against the entire set
3904
if ( raw ) {
3905
fn.call( elems, value );
3906
fn = null;
3907
3908
// ...except when executing function values
3909
} else {
3910
bulk = fn;
3911
fn = function( elem, _key, value ) {
3912
return bulk.call( jQuery( elem ), value );
3913
};
3914
}
3915
}
3916
3917
if ( fn ) {
3918
for ( ; i < len; i++ ) {
3919
fn(
3920
elems[ i ], key, raw ?
3921
value :
3922
value.call( elems[ i ], i, fn( elems[ i ], key ) )
3923
);
3924
}
3925
}
3926
}
3927
3928
if ( chainable ) {
3929
return elems;
3930
}
3931
3932
// Gets
3933
if ( bulk ) {
3934
return fn.call( elems );
3935
}
3936
3937
return len ? fn( elems[ 0 ], key ) : emptyGet;
3938
};
3939
3940
3941
// Matches dashed string for camelizing
3942
var rmsPrefix = /^-ms-/,
3943
rdashAlpha = /-([a-z])/g;
3944
3945
// Used by camelCase as callback to replace()
3946
function fcamelCase( _all, letter ) {
3947
return letter.toUpperCase();
3948
}
3949
3950
// Convert dashed to camelCase; used by the css and data modules
3951
// Support: IE <=9 - 11, Edge 12 - 15
3952
// Microsoft forgot to hump their vendor prefix (trac-9572)
3953
function camelCase( string ) {
3954
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
3955
}
3956
var acceptData = function( owner ) {
3957
3958
// Accepts only:
3959
// - Node
3960
// - Node.ELEMENT_NODE
3961
// - Node.DOCUMENT_NODE
3962
// - Object
3963
// - Any
3964
return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
3965
};
3966
3967
3968
3969
3970
function Data() {
3971
this.expando = jQuery.expando + Data.uid++;
3972
}
3973
3974
Data.uid = 1;
3975
3976
Data.prototype = {
3977
3978
cache: function( owner ) {
3979
3980
// Check if the owner object already has a cache
3981
var value = owner[ this.expando ];
3982
3983
// If not, create one
3984
if ( !value ) {
3985
value = {};
3986
3987
// We can accept data for non-element nodes in modern browsers,
3988
// but we should not, see trac-8335.
3989
// Always return an empty object.
3990
if ( acceptData( owner ) ) {
3991
3992
// If it is a node unlikely to be stringify-ed or looped over
3993
// use plain assignment
3994
if ( owner.nodeType ) {
3995
owner[ this.expando ] = value;
3996
3997
// Otherwise secure it in a non-enumerable property
3998
// configurable must be true to allow the property to be
3999
// deleted when data is removed
4000
} else {
4001
Object.defineProperty( owner, this.expando, {
4002
value: value,
4003
configurable: true
4004
} );
4005
}
4006
}
4007
}
4008
4009
return value;
4010
},
4011
set: function( owner, data, value ) {
4012
var prop,
4013
cache = this.cache( owner );
4014
4015
// Handle: [ owner, key, value ] args
4016
// Always use camelCase key (gh-2257)
4017
if ( typeof data === "string" ) {
4018
cache[ camelCase( data ) ] = value;
4019
4020
// Handle: [ owner, { properties } ] args
4021
} else {
4022
4023
// Copy the properties one-by-one to the cache object
4024
for ( prop in data ) {
4025
cache[ camelCase( prop ) ] = data[ prop ];
4026
}
4027
}
4028
return cache;
4029
},
4030
get: function( owner, key ) {
4031
return key === undefined ?
4032
this.cache( owner ) :
4033
4034
// Always use camelCase key (gh-2257)
4035
owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
4036
},
4037
access: function( owner, key, value ) {
4038
4039
// In cases where either:
4040
//
4041
// 1. No key was specified
4042
// 2. A string key was specified, but no value provided
4043
//
4044
// Take the "read" path and allow the get method to determine
4045
// which value to return, respectively either:
4046
//
4047
// 1. The entire cache object
4048
// 2. The data stored at the key
4049
//
4050
if ( key === undefined ||
4051
( ( key && typeof key === "string" ) && value === undefined ) ) {
4052
4053
return this.get( owner, key );
4054
}
4055
4056
// When the key is not a string, or both a key and value
4057
// are specified, set or extend (existing objects) with either:
4058
//
4059
// 1. An object of properties
4060
// 2. A key and value
4061
//
4062
this.set( owner, key, value );
4063
4064
// Since the "set" path can have two possible entry points
4065
// return the expected data based on which path was taken[*]
4066
return value !== undefined ? value : key;
4067
},
4068
remove: function( owner, key ) {
4069
var i,
4070
cache = owner[ this.expando ];
4071
4072
if ( cache === undefined ) {
4073
return;
4074
}
4075
4076
if ( key !== undefined ) {
4077
4078
// Support array or space separated string of keys
4079
if ( Array.isArray( key ) ) {
4080
4081
// If key is an array of keys...
4082
// We always set camelCase keys, so remove that.
4083
key = key.map( camelCase );
4084
} else {
4085
key = camelCase( key );
4086
4087
// If a key with the spaces exists, use it.
4088
// Otherwise, create an array by matching non-whitespace
4089
key = key in cache ?
4090
[ key ] :
4091
( key.match( rnothtmlwhite ) || [] );
4092
}
4093
4094
i = key.length;
4095
4096
while ( i-- ) {
4097
delete cache[ key[ i ] ];
4098
}
4099
}
4100
4101
// Remove the expando if there's no more data
4102
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
4103
4104
// Support: Chrome <=35 - 45
4105
// Webkit & Blink performance suffers when deleting properties
4106
// from DOM nodes, so set to undefined instead
4107
// https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4108
if ( owner.nodeType ) {
4109
owner[ this.expando ] = undefined;
4110
} else {
4111
delete owner[ this.expando ];
4112
}
4113
}
4114
},
4115
hasData: function( owner ) {
4116
var cache = owner[ this.expando ];
4117
return cache !== undefined && !jQuery.isEmptyObject( cache );
4118
}
4119
};
4120
var dataPriv = new Data();
4121
4122
var dataUser = new Data();
4123
4124
4125
4126
// Implementation Summary
4127
//
4128
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
4129
// 2. Improve the module's maintainability by reducing the storage
4130
// paths to a single mechanism.
4131
// 3. Use the same single mechanism to support "private" and "user" data.
4132
// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4133
// 5. Avoid exposing implementation details on user objects (eg. expando properties)
4134
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4135
4136
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4137
rmultiDash = /[A-Z]/g;
4138
4139
function getData( data ) {
4140
if ( data === "true" ) {
4141
return true;
4142
}
4143
4144
if ( data === "false" ) {
4145
return false;
4146
}
4147
4148
if ( data === "null" ) {
4149
return null;
4150
}
4151
4152
// Only convert to a number if it doesn't change the string
4153
if ( data === +data + "" ) {
4154
return +data;
4155
}
4156
4157
if ( rbrace.test( data ) ) {
4158
return JSON.parse( data );
4159
}
4160
4161
return data;
4162
}
4163
4164
function dataAttr( elem, key, data ) {
4165
var name;
4166
4167
// If nothing was found internally, try to fetch any
4168
// data from the HTML5 data-* attribute
4169
if ( data === undefined && elem.nodeType === 1 ) {
4170
name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
4171
data = elem.getAttribute( name );
4172
4173
if ( typeof data === "string" ) {
4174
try {
4175
data = getData( data );
4176
} catch ( e ) {}
4177
4178
// Make sure we set the data so it isn't changed later
4179
dataUser.set( elem, key, data );
4180
} else {
4181
data = undefined;
4182
}
4183
}
4184
return data;
4185
}
4186
4187
jQuery.extend( {
4188
hasData: function( elem ) {
4189
return dataUser.hasData( elem ) || dataPriv.hasData( elem );
4190
},
4191
4192
data: function( elem, name, data ) {
4193
return dataUser.access( elem, name, data );
4194
},
4195
4196
removeData: function( elem, name ) {
4197
dataUser.remove( elem, name );
4198
},
4199
4200
// TODO: Now that all calls to _data and _removeData have been replaced
4201
// with direct calls to dataPriv methods, these can be deprecated.
4202
_data: function( elem, name, data ) {
4203
return dataPriv.access( elem, name, data );
4204
},
4205
4206
_removeData: function( elem, name ) {
4207
dataPriv.remove( elem, name );
4208
}
4209
} );
4210
4211
jQuery.fn.extend( {
4212
data: function( key, value ) {
4213
var i, name, data,
4214
elem = this[ 0 ],
4215
attrs = elem && elem.attributes;
4216
4217
// Gets all values
4218
if ( key === undefined ) {
4219
if ( this.length ) {
4220
data = dataUser.get( elem );
4221
4222
if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
4223
i = attrs.length;
4224
while ( i-- ) {
4225
4226
// Support: IE 11 only
4227
// The attrs elements can be null (trac-14894)
4228
if ( attrs[ i ] ) {
4229
name = attrs[ i ].name;
4230
if ( name.indexOf( "data-" ) === 0 ) {
4231
name = camelCase( name.slice( 5 ) );
4232
dataAttr( elem, name, data[ name ] );
4233
}
4234
}
4235
}
4236
dataPriv.set( elem, "hasDataAttrs", true );
4237
}
4238
}
4239
4240
return data;
4241
}
4242
4243
// Sets multiple values
4244
if ( typeof key === "object" ) {
4245
return this.each( function() {
4246
dataUser.set( this, key );
4247
} );
4248
}
4249
4250
return access( this, function( value ) {
4251
var data;
4252
4253
// The calling jQuery object (element matches) is not empty
4254
// (and therefore has an element appears at this[ 0 ]) and the
4255
// `value` parameter was not undefined. An empty jQuery object
4256
// will result in `undefined` for elem = this[ 0 ] which will
4257
// throw an exception if an attempt to read a data cache is made.
4258
if ( elem && value === undefined ) {
4259
4260
// Attempt to get data from the cache
4261
// The key will always be camelCased in Data
4262
data = dataUser.get( elem, key );
4263
if ( data !== undefined ) {
4264
return data;
4265
}
4266
4267
// Attempt to "discover" the data in
4268
// HTML5 custom data-* attrs
4269
data = dataAttr( elem, key );
4270
if ( data !== undefined ) {
4271
return data;
4272
}
4273
4274
// We tried really hard, but the data doesn't exist.
4275
return;
4276
}
4277
4278
// Set the data...
4279
this.each( function() {
4280
4281
// We always store the camelCased key
4282
dataUser.set( this, key, value );
4283
} );
4284
}, null, value, arguments.length > 1, null, true );
4285
},
4286
4287
removeData: function( key ) {
4288
return this.each( function() {
4289
dataUser.remove( this, key );
4290
} );
4291
}
4292
} );
4293
4294
4295
jQuery.extend( {
4296
queue: function( elem, type, data ) {
4297
var queue;
4298
4299
if ( elem ) {
4300
type = ( type || "fx" ) + "queue";
4301
queue = dataPriv.get( elem, type );
4302
4303
// Speed up dequeue by getting out quickly if this is just a lookup
4304
if ( data ) {
4305
if ( !queue || Array.isArray( data ) ) {
4306
queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
4307
} else {
4308
queue.push( data );
4309
}
4310
}
4311
return queue || [];
4312
}
4313
},
4314
4315
dequeue: function( elem, type ) {
4316
type = type || "fx";
4317
4318
var queue = jQuery.queue( elem, type ),
4319
startLength = queue.length,
4320
fn = queue.shift(),
4321
hooks = jQuery._queueHooks( elem, type ),
4322
next = function() {
4323
jQuery.dequeue( elem, type );
4324
};
4325
4326
// If the fx queue is dequeued, always remove the progress sentinel
4327
if ( fn === "inprogress" ) {
4328
fn = queue.shift();
4329
startLength--;
4330
}
4331
4332
if ( fn ) {
4333
4334
// Add a progress sentinel to prevent the fx queue from being
4335
// automatically dequeued
4336
if ( type === "fx" ) {
4337
queue.unshift( "inprogress" );
4338
}
4339
4340
// Clear up the last queue stop function
4341
delete hooks.stop;
4342
fn.call( elem, next, hooks );
4343
}
4344
4345
if ( !startLength && hooks ) {
4346
hooks.empty.fire();
4347
}
4348
},
4349
4350
// Not public - generate a queueHooks object, or return the current one
4351
_queueHooks: function( elem, type ) {
4352
var key = type + "queueHooks";
4353
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
4354
empty: jQuery.Callbacks( "once memory" ).add( function() {
4355
dataPriv.remove( elem, [ type + "queue", key ] );
4356
} )
4357
} );
4358
}
4359
} );
4360
4361
jQuery.fn.extend( {
4362
queue: function( type, data ) {
4363
var setter = 2;
4364
4365
if ( typeof type !== "string" ) {
4366
data = type;
4367
type = "fx";
4368
setter--;
4369
}
4370
4371
if ( arguments.length < setter ) {
4372
return jQuery.queue( this[ 0 ], type );
4373
}
4374
4375
return data === undefined ?
4376
this :
4377
this.each( function() {
4378
var queue = jQuery.queue( this, type, data );
4379
4380
// Ensure a hooks for this queue
4381
jQuery._queueHooks( this, type );
4382
4383
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4384
jQuery.dequeue( this, type );
4385
}
4386
} );
4387
},
4388
dequeue: function( type ) {
4389
return this.each( function() {
4390
jQuery.dequeue( this, type );
4391
} );
4392
},
4393
clearQueue: function( type ) {
4394
return this.queue( type || "fx", [] );
4395
},
4396
4397
// Get a promise resolved when queues of a certain type
4398
// are emptied (fx is the type by default)
4399
promise: function( type, obj ) {
4400
var tmp,
4401
count = 1,
4402
defer = jQuery.Deferred(),
4403
elements = this,
4404
i = this.length,
4405
resolve = function() {
4406
if ( !( --count ) ) {
4407
defer.resolveWith( elements, [ elements ] );
4408
}
4409
};
4410
4411
if ( typeof type !== "string" ) {
4412
obj = type;
4413
type = undefined;
4414
}
4415
type = type || "fx";
4416
4417
while ( i-- ) {
4418
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
4419
if ( tmp && tmp.empty ) {
4420
count++;
4421
tmp.empty.add( resolve );
4422
}
4423
}
4424
resolve();
4425
return defer.promise( obj );
4426
}
4427
} );
4428
var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4429
4430
var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4431
4432
4433
var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4434
4435
var documentElement = document.documentElement;
4436
4437
4438
4439
var isAttached = function( elem ) {
4440
return jQuery.contains( elem.ownerDocument, elem );
4441
},
4442
composed = { composed: true };
4443
4444
// Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
4445
// Check attachment across shadow DOM boundaries when possible (gh-3504)
4446
// Support: iOS 10.0-10.2 only
4447
// Early iOS 10 versions support `attachShadow` but not `getRootNode`,
4448
// leading to errors. We need to check for `getRootNode`.
4449
if ( documentElement.getRootNode ) {
4450
isAttached = function( elem ) {
4451
return jQuery.contains( elem.ownerDocument, elem ) ||
4452
elem.getRootNode( composed ) === elem.ownerDocument;
4453
};
4454
}
4455
var isHiddenWithinTree = function( elem, el ) {
4456
4457
// isHiddenWithinTree might be called from jQuery#filter function;
4458
// in that case, element will be second argument
4459
elem = el || elem;
4460
4461
// Inline style trumps all
4462
return elem.style.display === "none" ||
4463
elem.style.display === "" &&
4464
4465
// Otherwise, check computed style
4466
// Support: Firefox <=43 - 45
4467
// Disconnected elements can have computed display: none, so first confirm that elem is
4468
// in the document.
4469
isAttached( elem ) &&
4470
4471
jQuery.css( elem, "display" ) === "none";
4472
};
4473
4474
4475
4476
function adjustCSS( elem, prop, valueParts, tween ) {
4477
var adjusted, scale,
4478
maxIterations = 20,
4479
currentValue = tween ?
4480
function() {
4481
return tween.cur();
4482
} :
4483
function() {
4484
return jQuery.css( elem, prop, "" );
4485
},
4486
initial = currentValue(),
4487
unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4488
4489
// Starting value computation is required for potential unit mismatches
4490
initialInUnit = elem.nodeType &&
4491
( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4492
rcssNum.exec( jQuery.css( elem, prop ) );
4493
4494
if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4495
4496
// Support: Firefox <=54
4497
// Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
4498
initial = initial / 2;
4499
4500
// Trust units reported by jQuery.css
4501
unit = unit || initialInUnit[ 3 ];
4502
4503
// Iteratively approximate from a nonzero starting point
4504
initialInUnit = +initial || 1;
4505
4506
while ( maxIterations-- ) {
4507
4508
// Evaluate and update our best guess (doubling guesses that zero out).
4509
// Finish if the scale equals or crosses 1 (making the old*new product non-positive).
4510
jQuery.style( elem, prop, initialInUnit + unit );
4511
if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
4512
maxIterations = 0;
4513
}
4514
initialInUnit = initialInUnit / scale;
4515
4516
}
4517
4518
initialInUnit = initialInUnit * 2;
4519
jQuery.style( elem, prop, initialInUnit + unit );
4520
4521
// Make sure we update the tween properties later on
4522
valueParts = valueParts || [];
4523
}
4524
4525
if ( valueParts ) {
4526
initialInUnit = +initialInUnit || +initial || 0;
4527
4528
// Apply relative offset (+=/-=) if specified
4529
adjusted = valueParts[ 1 ] ?
4530
initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4531
+valueParts[ 2 ];
4532
if ( tween ) {
4533
tween.unit = unit;
4534
tween.start = initialInUnit;
4535
tween.end = adjusted;
4536
}
4537
}
4538
return adjusted;
4539
}
4540
4541
4542
var defaultDisplayMap = {};
4543
4544
function getDefaultDisplay( elem ) {
4545
var temp,
4546
doc = elem.ownerDocument,
4547
nodeName = elem.nodeName,
4548
display = defaultDisplayMap[ nodeName ];
4549
4550
if ( display ) {
4551
return display;
4552
}
4553
4554
temp = doc.body.appendChild( doc.createElement( nodeName ) );
4555
display = jQuery.css( temp, "display" );
4556
4557
temp.parentNode.removeChild( temp );
4558
4559
if ( display === "none" ) {
4560
display = "block";
4561
}
4562
defaultDisplayMap[ nodeName ] = display;
4563
4564
return display;
4565
}
4566
4567
function showHide( elements, show ) {
4568
var display, elem,
4569
values = [],
4570
index = 0,
4571
length = elements.length;
4572
4573
// Determine new display value for elements that need to change
4574
for ( ; index < length; index++ ) {
4575
elem = elements[ index ];
4576
if ( !elem.style ) {
4577
continue;
4578
}
4579
4580
display = elem.style.display;
4581
if ( show ) {
4582
4583
// Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4584
// check is required in this first loop unless we have a nonempty display value (either
4585
// inline or about-to-be-restored)
4586
if ( display === "none" ) {
4587
values[ index ] = dataPriv.get( elem, "display" ) || null;
4588
if ( !values[ index ] ) {
4589
elem.style.display = "";
4590
}
4591
}
4592
if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
4593
values[ index ] = getDefaultDisplay( elem );
4594
}
4595
} else {
4596
if ( display !== "none" ) {
4597
values[ index ] = "none";
4598
4599
// Remember what we're overwriting
4600
dataPriv.set( elem, "display", display );
4601
}
4602
}
4603
}
4604
4605
// Set the display of the elements in a second loop to avoid constant reflow
4606
for ( index = 0; index < length; index++ ) {
4607
if ( values[ index ] != null ) {
4608
elements[ index ].style.display = values[ index ];
4609
}
4610
}
4611
4612
return elements;
4613
}
4614
4615
jQuery.fn.extend( {
4616
show: function() {
4617
return showHide( this, true );
4618
},
4619
hide: function() {
4620
return showHide( this );
4621
},
4622
toggle: function( state ) {
4623
if ( typeof state === "boolean" ) {
4624
return state ? this.show() : this.hide();
4625
}
4626
4627
return this.each( function() {
4628
if ( isHiddenWithinTree( this ) ) {
4629
jQuery( this ).show();
4630
} else {
4631
jQuery( this ).hide();
4632
}
4633
} );
4634
}
4635
} );
4636
var rcheckableType = ( /^(?:checkbox|radio)$/i );
4637
4638
var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
4639
4640
var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
4641
4642
4643
4644
( function() {
4645
var fragment = document.createDocumentFragment(),
4646
div = fragment.appendChild( document.createElement( "div" ) ),
4647
input = document.createElement( "input" );
4648
4649
// Support: Android 4.0 - 4.3 only
4650
// Check state lost if the name is set (trac-11217)
4651
// Support: Windows Web Apps (WWA)
4652
// `name` and `type` must use .setAttribute for WWA (trac-14901)
4653
input.setAttribute( "type", "radio" );
4654
input.setAttribute( "checked", "checked" );
4655
input.setAttribute( "name", "t" );
4656
4657
div.appendChild( input );
4658
4659
// Support: Android <=4.1 only
4660
// Older WebKit doesn't clone checked state correctly in fragments
4661
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4662
4663
// Support: IE <=11 only
4664
// Make sure textarea (and checkbox) defaultValue is properly cloned
4665
div.innerHTML = "<textarea>x</textarea>";
4666
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4667
4668
// Support: IE <=9 only
4669
// IE <=9 replaces <option> tags with their contents when inserted outside of
4670
// the select element.
4671
div.innerHTML = "<option></option>";
4672
support.option = !!div.lastChild;
4673
} )();
4674
4675
4676
// We have to close these tags to support XHTML (trac-13200)
4677
var wrapMap = {
4678
4679
// XHTML parsers do not magically insert elements in the
4680
// same way that tag soup parsers do. So we cannot shorten
4681
// this by omitting <tbody> or other required elements.
4682
thead: [ 1, "<table>", "</table>" ],
4683
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4684
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4685
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4686
4687
_default: [ 0, "", "" ]
4688
};
4689
4690
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4691
wrapMap.th = wrapMap.td;
4692
4693
// Support: IE <=9 only
4694
if ( !support.option ) {
4695
wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
4696
}
4697
4698
4699
function getAll( context, tag ) {
4700
4701
// Support: IE <=9 - 11 only
4702
// Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
4703
var ret;
4704
4705
if ( typeof context.getElementsByTagName !== "undefined" ) {
4706
ret = context.getElementsByTagName( tag || "*" );
4707
4708
} else if ( typeof context.querySelectorAll !== "undefined" ) {
4709
ret = context.querySelectorAll( tag || "*" );
4710
4711
} else {
4712
ret = [];
4713
}
4714
4715
if ( tag === undefined || tag && nodeName( context, tag ) ) {
4716
return jQuery.merge( [ context ], ret );
4717
}
4718
4719
return ret;
4720
}
4721
4722
4723
// Mark scripts as having already been evaluated
4724
function setGlobalEval( elems, refElements ) {
4725
var i = 0,
4726
l = elems.length;
4727
4728
for ( ; i < l; i++ ) {
4729
dataPriv.set(
4730
elems[ i ],
4731
"globalEval",
4732
!refElements || dataPriv.get( refElements[ i ], "globalEval" )
4733
);
4734
}
4735
}
4736
4737
4738
var rhtml = /<|&#?\w+;/;
4739
4740
function buildFragment( elems, context, scripts, selection, ignored ) {
4741
var elem, tmp, tag, wrap, attached, j,
4742
fragment = context.createDocumentFragment(),
4743
nodes = [],
4744
i = 0,
4745
l = elems.length;
4746
4747
for ( ; i < l; i++ ) {
4748
elem = elems[ i ];
4749
4750
if ( elem || elem === 0 ) {
4751
4752
// Add nodes directly
4753
if ( toType( elem ) === "object" ) {
4754
4755
// Support: Android <=4.0 only, PhantomJS 1 only
4756
// push.apply(_, arraylike) throws on ancient WebKit
4757
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4758
4759
// Convert non-html into a text node
4760
} else if ( !rhtml.test( elem ) ) {
4761
nodes.push( context.createTextNode( elem ) );
4762
4763
// Convert html into DOM nodes
4764
} else {
4765
tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4766
4767
// Deserialize a standard representation
4768
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4769
wrap = wrapMap[ tag ] || wrapMap._default;
4770
tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4771
4772
// Descend through wrappers to the right content
4773
j = wrap[ 0 ];
4774
while ( j-- ) {
4775
tmp = tmp.lastChild;
4776
}
4777
4778
// Support: Android <=4.0 only, PhantomJS 1 only
4779
// push.apply(_, arraylike) throws on ancient WebKit
4780
jQuery.merge( nodes, tmp.childNodes );
4781
4782
// Remember the top-level container
4783
tmp = fragment.firstChild;
4784
4785
// Ensure the created nodes are orphaned (trac-12392)
4786
tmp.textContent = "";
4787
}
4788
}
4789
}
4790
4791
// Remove wrapper from fragment
4792
fragment.textContent = "";
4793
4794
i = 0;
4795
while ( ( elem = nodes[ i++ ] ) ) {
4796
4797
// Skip elements already in the context collection (trac-4087)
4798
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4799
if ( ignored ) {
4800
ignored.push( elem );
4801
}
4802
continue;
4803
}
4804
4805
attached = isAttached( elem );
4806
4807
// Append to fragment
4808
tmp = getAll( fragment.appendChild( elem ), "script" );
4809
4810
// Preserve script evaluation history
4811
if ( attached ) {
4812
setGlobalEval( tmp );
4813
}
4814
4815
// Capture executables
4816
if ( scripts ) {
4817
j = 0;
4818
while ( ( elem = tmp[ j++ ] ) ) {
4819
if ( rscriptType.test( elem.type || "" ) ) {
4820
scripts.push( elem );
4821
}
4822
}
4823
}
4824
}
4825
4826
return fragment;
4827
}
4828
4829
4830
var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4831
4832
function returnTrue() {
4833
return true;
4834
}
4835
4836
function returnFalse() {
4837
return false;
4838
}
4839
4840
function on( elem, types, selector, data, fn, one ) {
4841
var origFn, type;
4842
4843
// Types can be a map of types/handlers
4844
if ( typeof types === "object" ) {
4845
4846
// ( types-Object, selector, data )
4847
if ( typeof selector !== "string" ) {
4848
4849
// ( types-Object, data )
4850
data = data || selector;
4851
selector = undefined;
4852
}
4853
for ( type in types ) {
4854
on( elem, type, selector, data, types[ type ], one );
4855
}
4856
return elem;
4857
}
4858
4859
if ( data == null && fn == null ) {
4860
4861
// ( types, fn )
4862
fn = selector;
4863
data = selector = undefined;
4864
} else if ( fn == null ) {
4865
if ( typeof selector === "string" ) {
4866
4867
// ( types, selector, fn )
4868
fn = data;
4869
data = undefined;
4870
} else {
4871
4872
// ( types, data, fn )
4873
fn = data;
4874
data = selector;
4875
selector = undefined;
4876
}
4877
}
4878
if ( fn === false ) {
4879
fn = returnFalse;
4880
} else if ( !fn ) {
4881
return elem;
4882
}
4883
4884
if ( one === 1 ) {
4885
origFn = fn;
4886
fn = function( event ) {
4887
4888
// Can use an empty set, since event contains the info
4889
jQuery().off( event );
4890
return origFn.apply( this, arguments );
4891
};
4892
4893
// Use same guid so caller can remove using origFn
4894
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4895
}
4896
return elem.each( function() {
4897
jQuery.event.add( this, types, fn, data, selector );
4898
} );
4899
}
4900
4901
/*
4902
* Helper functions for managing events -- not part of the public interface.
4903
* Props to Dean Edwards' addEvent library for many of the ideas.
4904
*/
4905
jQuery.event = {
4906
4907
global: {},
4908
4909
add: function( elem, types, handler, data, selector ) {
4910
4911
var handleObjIn, eventHandle, tmp,
4912
events, t, handleObj,
4913
special, handlers, type, namespaces, origType,
4914
elemData = dataPriv.get( elem );
4915
4916
// Only attach events to objects that accept data
4917
if ( !acceptData( elem ) ) {
4918
return;
4919
}
4920
4921
// Caller can pass in an object of custom data in lieu of the handler
4922
if ( handler.handler ) {
4923
handleObjIn = handler;
4924
handler = handleObjIn.handler;
4925
selector = handleObjIn.selector;
4926
}
4927
4928
// Ensure that invalid selectors throw exceptions at attach time
4929
// Evaluate against documentElement in case elem is a non-element node (e.g., document)
4930
if ( selector ) {
4931
jQuery.find.matchesSelector( documentElement, selector );
4932
}
4933
4934
// Make sure that the handler has a unique ID, used to find/remove it later
4935
if ( !handler.guid ) {
4936
handler.guid = jQuery.guid++;
4937
}
4938
4939
// Init the element's event structure and main handler, if this is the first
4940
if ( !( events = elemData.events ) ) {
4941
events = elemData.events = Object.create( null );
4942
}
4943
if ( !( eventHandle = elemData.handle ) ) {
4944
eventHandle = elemData.handle = function( e ) {
4945
4946
// Discard the second event of a jQuery.event.trigger() and
4947
// when an event is called after a page has unloaded
4948
return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
4949
jQuery.event.dispatch.apply( elem, arguments ) : undefined;
4950
};
4951
}
4952
4953
// Handle multiple events separated by a space
4954
types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
4955
t = types.length;
4956
while ( t-- ) {
4957
tmp = rtypenamespace.exec( types[ t ] ) || [];
4958
type = origType = tmp[ 1 ];
4959
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4960
4961
// There *must* be a type, no attaching namespace-only handlers
4962
if ( !type ) {
4963
continue;
4964
}
4965
4966
// If event changes its type, use the special event handlers for the changed type
4967
special = jQuery.event.special[ type ] || {};
4968
4969
// If selector defined, determine special event api type, otherwise given type
4970
type = ( selector ? special.delegateType : special.bindType ) || type;
4971
4972
// Update special based on newly reset type
4973
special = jQuery.event.special[ type ] || {};
4974
4975
// handleObj is passed to all event handlers
4976
handleObj = jQuery.extend( {
4977
type: type,
4978
origType: origType,
4979
data: data,
4980
handler: handler,
4981
guid: handler.guid,
4982
selector: selector,
4983
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4984
namespace: namespaces.join( "." )
4985
}, handleObjIn );
4986
4987
// Init the event handler queue if we're the first
4988
if ( !( handlers = events[ type ] ) ) {
4989
handlers = events[ type ] = [];
4990
handlers.delegateCount = 0;
4991
4992
// Only use addEventListener if the special events handler returns false
4993
if ( !special.setup ||
4994
special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4995
4996
if ( elem.addEventListener ) {
4997
elem.addEventListener( type, eventHandle );
4998
}
4999
}
5000
}
5001
5002
if ( special.add ) {
5003
special.add.call( elem, handleObj );
5004
5005
if ( !handleObj.handler.guid ) {
5006
handleObj.handler.guid = handler.guid;
5007
}
5008
}
5009
5010
// Add to the element's handler list, delegates in front
5011
if ( selector ) {
5012
handlers.splice( handlers.delegateCount++, 0, handleObj );
5013
} else {
5014
handlers.push( handleObj );
5015
}
5016
5017
// Keep track of which events have ever been used, for event optimization
5018
jQuery.event.global[ type ] = true;
5019
}
5020
5021
},
5022
5023
// Detach an event or set of events from an element
5024
remove: function( elem, types, handler, selector, mappedTypes ) {
5025
5026
var j, origCount, tmp,
5027
events, t, handleObj,
5028
special, handlers, type, namespaces, origType,
5029
elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
5030
5031
if ( !elemData || !( events = elemData.events ) ) {
5032
return;
5033
}
5034
5035
// Once for each type.namespace in types; type may be omitted
5036
types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
5037
t = types.length;
5038
while ( t-- ) {
5039
tmp = rtypenamespace.exec( types[ t ] ) || [];
5040
type = origType = tmp[ 1 ];
5041
namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5042
5043
// Unbind all events (on this namespace, if provided) for the element
5044
if ( !type ) {
5045
for ( type in events ) {
5046
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5047
}
5048
continue;
5049
}
5050
5051
special = jQuery.event.special[ type ] || {};
5052
type = ( selector ? special.delegateType : special.bindType ) || type;
5053
handlers = events[ type ] || [];
5054
tmp = tmp[ 2 ] &&
5055
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5056
5057
// Remove matching events
5058
origCount = j = handlers.length;
5059
while ( j-- ) {
5060
handleObj = handlers[ j ];
5061
5062
if ( ( mappedTypes || origType === handleObj.origType ) &&
5063
( !handler || handler.guid === handleObj.guid ) &&
5064
( !tmp || tmp.test( handleObj.namespace ) ) &&
5065
( !selector || selector === handleObj.selector ||
5066
selector === "**" && handleObj.selector ) ) {
5067
handlers.splice( j, 1 );
5068
5069
if ( handleObj.selector ) {
5070
handlers.delegateCount--;
5071
}
5072
if ( special.remove ) {
5073
special.remove.call( elem, handleObj );
5074
}
5075
}
5076
}
5077
5078
// Remove generic event handler if we removed something and no more handlers exist
5079
// (avoids potential for endless recursion during removal of special event handlers)
5080
if ( origCount && !handlers.length ) {
5081
if ( !special.teardown ||
5082
special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5083
5084
jQuery.removeEvent( elem, type, elemData.handle );
5085
}
5086
5087
delete events[ type ];
5088
}
5089
}
5090
5091
// Remove data and the expando if it's no longer used
5092
if ( jQuery.isEmptyObject( events ) ) {
5093
dataPriv.remove( elem, "handle events" );
5094
}
5095
},
5096
5097
dispatch: function( nativeEvent ) {
5098
5099
var i, j, ret, matched, handleObj, handlerQueue,
5100
args = new Array( arguments.length ),
5101
5102
// Make a writable jQuery.Event from the native event object
5103
event = jQuery.event.fix( nativeEvent ),
5104
5105
handlers = (
5106
dataPriv.get( this, "events" ) || Object.create( null )
5107
)[ event.type ] || [],
5108
special = jQuery.event.special[ event.type ] || {};
5109
5110
// Use the fix-ed jQuery.Event rather than the (read-only) native event
5111
args[ 0 ] = event;
5112
5113
for ( i = 1; i < arguments.length; i++ ) {
5114
args[ i ] = arguments[ i ];
5115
}
5116
5117
event.delegateTarget = this;
5118
5119
// Call the preDispatch hook for the mapped type, and let it bail if desired
5120
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5121
return;
5122
}
5123
5124
// Determine handlers
5125
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5126
5127
// Run delegates first; they may want to stop propagation beneath us
5128
i = 0;
5129
while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5130
event.currentTarget = matched.elem;
5131
5132
j = 0;
5133
while ( ( handleObj = matched.handlers[ j++ ] ) &&
5134
!event.isImmediatePropagationStopped() ) {
5135
5136
// If the event is namespaced, then each handler is only invoked if it is
5137
// specially universal or its namespaces are a superset of the event's.
5138
if ( !event.rnamespace || handleObj.namespace === false ||
5139
event.rnamespace.test( handleObj.namespace ) ) {
5140
5141
event.handleObj = handleObj;
5142
event.data = handleObj.data;
5143
5144
ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5145
handleObj.handler ).apply( matched.elem, args );
5146
5147
if ( ret !== undefined ) {
5148
if ( ( event.result = ret ) === false ) {
5149
event.preventDefault();
5150
event.stopPropagation();
5151
}
5152
}
5153
}
5154
}
5155
}
5156
5157
// Call the postDispatch hook for the mapped type
5158
if ( special.postDispatch ) {
5159
special.postDispatch.call( this, event );
5160
}
5161
5162
return event.result;
5163
},
5164
5165
handlers: function( event, handlers ) {
5166
var i, handleObj, sel, matchedHandlers, matchedSelectors,
5167
handlerQueue = [],
5168
delegateCount = handlers.delegateCount,
5169
cur = event.target;
5170
5171
// Find delegate handlers
5172
if ( delegateCount &&
5173
5174
// Support: IE <=9
5175
// Black-hole SVG <use> instance trees (trac-13180)
5176
cur.nodeType &&
5177
5178
// Support: Firefox <=42
5179
// Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5180
// https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5181
// Support: IE 11 only
5182
// ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5183
!( event.type === "click" && event.button >= 1 ) ) {
5184
5185
for ( ; cur !== this; cur = cur.parentNode || this ) {
5186
5187
// Don't check non-elements (trac-13208)
5188
// Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)
5189
if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
5190
matchedHandlers = [];
5191
matchedSelectors = {};
5192
for ( i = 0; i < delegateCount; i++ ) {
5193
handleObj = handlers[ i ];
5194
5195
// Don't conflict with Object.prototype properties (trac-13203)
5196
sel = handleObj.selector + " ";
5197
5198
if ( matchedSelectors[ sel ] === undefined ) {
5199
matchedSelectors[ sel ] = handleObj.needsContext ?
5200
jQuery( sel, this ).index( cur ) > -1 :
5201
jQuery.find( sel, this, null, [ cur ] ).length;
5202
}
5203
if ( matchedSelectors[ sel ] ) {
5204
matchedHandlers.push( handleObj );
5205
}
5206
}
5207
if ( matchedHandlers.length ) {
5208
handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
5209
}
5210
}
5211
}
5212
}
5213
5214
// Add the remaining (directly-bound) handlers
5215
cur = this;
5216
if ( delegateCount < handlers.length ) {
5217
handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
5218
}
5219
5220
return handlerQueue;
5221
},
5222
5223
addProp: function( name, hook ) {
5224
Object.defineProperty( jQuery.Event.prototype, name, {
5225
enumerable: true,
5226
configurable: true,
5227
5228
get: isFunction( hook ) ?
5229
function() {
5230
if ( this.originalEvent ) {
5231
return hook( this.originalEvent );
5232
}
5233
} :
5234
function() {
5235
if ( this.originalEvent ) {
5236
return this.originalEvent[ name ];
5237
}
5238
},
5239
5240
set: function( value ) {
5241
Object.defineProperty( this, name, {
5242
enumerable: true,
5243
configurable: true,
5244
writable: true,
5245
value: value
5246
} );
5247
}
5248
} );
5249
},
5250
5251
fix: function( originalEvent ) {
5252
return originalEvent[ jQuery.expando ] ?
5253
originalEvent :
5254
new jQuery.Event( originalEvent );
5255
},
5256
5257
special: {
5258
load: {
5259
5260
// Prevent triggered image.load events from bubbling to window.load
5261
noBubble: true
5262
},
5263
click: {
5264
5265
// Utilize native event to ensure correct state for checkable inputs
5266
setup: function( data ) {
5267
5268
// For mutual compressibility with _default, replace `this` access with a local var.
5269
// `|| data` is dead code meant only to preserve the variable through minification.
5270
var el = this || data;
5271
5272
// Claim the first handler
5273
if ( rcheckableType.test( el.type ) &&
5274
el.click && nodeName( el, "input" ) ) {
5275
5276
// dataPriv.set( el, "click", ... )
5277
leverageNative( el, "click", true );
5278
}
5279
5280
// Return false to allow normal processing in the caller
5281
return false;
5282
},
5283
trigger: function( data ) {
5284
5285
// For mutual compressibility with _default, replace `this` access with a local var.
5286
// `|| data` is dead code meant only to preserve the variable through minification.
5287
var el = this || data;
5288
5289
// Force setup before triggering a click
5290
if ( rcheckableType.test( el.type ) &&
5291
el.click && nodeName( el, "input" ) ) {
5292
5293
leverageNative( el, "click" );
5294
}
5295
5296
// Return non-false to allow normal event-path propagation
5297
return true;
5298
},
5299
5300
// For cross-browser consistency, suppress native .click() on links
5301
// Also prevent it if we're currently inside a leveraged native-event stack
5302
_default: function( event ) {
5303
var target = event.target;
5304
return rcheckableType.test( target.type ) &&
5305
target.click && nodeName( target, "input" ) &&
5306
dataPriv.get( target, "click" ) ||
5307
nodeName( target, "a" );
5308
}
5309
},
5310
5311
beforeunload: {
5312
postDispatch: function( event ) {
5313
5314
// Support: Firefox 20+
5315
// Firefox doesn't alert if the returnValue field is not set.
5316
if ( event.result !== undefined && event.originalEvent ) {
5317
event.originalEvent.returnValue = event.result;
5318
}
5319
}
5320
}
5321
}
5322
};
5323
5324
// Ensure the presence of an event listener that handles manually-triggered
5325
// synthetic events by interrupting progress until reinvoked in response to
5326
// *native* events that it fires directly, ensuring that state changes have
5327
// already occurred before other listeners are invoked.
5328
function leverageNative( el, type, isSetup ) {
5329
5330
// Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add
5331
if ( !isSetup ) {
5332
if ( dataPriv.get( el, type ) === undefined ) {
5333
jQuery.event.add( el, type, returnTrue );
5334
}
5335
return;
5336
}
5337
5338
// Register the controller as a special universal handler for all event namespaces
5339
dataPriv.set( el, type, false );
5340
jQuery.event.add( el, type, {
5341
namespace: false,
5342
handler: function( event ) {
5343
var result,
5344
saved = dataPriv.get( this, type );
5345
5346
if ( ( event.isTrigger & 1 ) && this[ type ] ) {
5347
5348
// Interrupt processing of the outer synthetic .trigger()ed event
5349
if ( !saved ) {
5350
5351
// Store arguments for use when handling the inner native event
5352
// There will always be at least one argument (an event object), so this array
5353
// will not be confused with a leftover capture object.
5354
saved = slice.call( arguments );
5355
dataPriv.set( this, type, saved );
5356
5357
// Trigger the native event and capture its result
5358
this[ type ]();
5359
result = dataPriv.get( this, type );
5360
dataPriv.set( this, type, false );
5361
5362
if ( saved !== result ) {
5363
5364
// Cancel the outer synthetic event
5365
event.stopImmediatePropagation();
5366
event.preventDefault();
5367
5368
return result;
5369
}
5370
5371
// If this is an inner synthetic event for an event with a bubbling surrogate
5372
// (focus or blur), assume that the surrogate already propagated from triggering
5373
// the native event and prevent that from happening again here.
5374
// This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
5375
// bubbling surrogate propagates *after* the non-bubbling base), but that seems
5376
// less bad than duplication.
5377
} else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
5378
event.stopPropagation();
5379
}
5380
5381
// If this is a native event triggered above, everything is now in order
5382
// Fire an inner synthetic event with the original arguments
5383
} else if ( saved ) {
5384
5385
// ...and capture the result
5386
dataPriv.set( this, type, jQuery.event.trigger(
5387
saved[ 0 ],
5388
saved.slice( 1 ),
5389
this
5390
) );
5391
5392
// Abort handling of the native event by all jQuery handlers while allowing
5393
// native handlers on the same element to run. On target, this is achieved
5394
// by stopping immediate propagation just on the jQuery event. However,
5395
// the native event is re-wrapped by a jQuery one on each level of the
5396
// propagation so the only way to stop it for jQuery is to stop it for
5397
// everyone via native `stopPropagation()`. This is not a problem for
5398
// focus/blur which don't bubble, but it does also stop click on checkboxes
5399
// and radios. We accept this limitation.
5400
event.stopPropagation();
5401
event.isImmediatePropagationStopped = returnTrue;
5402
}
5403
}
5404
} );
5405
}
5406
5407
jQuery.removeEvent = function( elem, type, handle ) {
5408
5409
// This "if" is needed for plain objects
5410
if ( elem.removeEventListener ) {
5411
elem.removeEventListener( type, handle );
5412
}
5413
};
5414
5415
jQuery.Event = function( src, props ) {
5416
5417
// Allow instantiation without the 'new' keyword
5418
if ( !( this instanceof jQuery.Event ) ) {
5419
return new jQuery.Event( src, props );
5420
}
5421
5422
// Event object
5423
if ( src && src.type ) {
5424
this.originalEvent = src;
5425
this.type = src.type;
5426
5427
// Events bubbling up the document may have been marked as prevented
5428
// by a handler lower down the tree; reflect the correct value.
5429
this.isDefaultPrevented = src.defaultPrevented ||
5430
src.defaultPrevented === undefined &&
5431
5432
// Support: Android <=2.3 only
5433
src.returnValue === false ?
5434
returnTrue :
5435
returnFalse;
5436
5437
// Create target properties
5438
// Support: Safari <=6 - 7 only
5439
// Target should not be a text node (trac-504, trac-13143)
5440
this.target = ( src.target && src.target.nodeType === 3 ) ?
5441
src.target.parentNode :
5442
src.target;
5443
5444
this.currentTarget = src.currentTarget;
5445
this.relatedTarget = src.relatedTarget;
5446
5447
// Event type
5448
} else {
5449
this.type = src;
5450
}
5451
5452
// Put explicitly provided properties onto the event object
5453
if ( props ) {
5454
jQuery.extend( this, props );
5455
}
5456
5457
// Create a timestamp if incoming event doesn't have one
5458
this.timeStamp = src && src.timeStamp || Date.now();
5459
5460
// Mark it as fixed
5461
this[ jQuery.expando ] = true;
5462
};
5463
5464
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5465
// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5466
jQuery.Event.prototype = {
5467
constructor: jQuery.Event,
5468
isDefaultPrevented: returnFalse,
5469
isPropagationStopped: returnFalse,
5470
isImmediatePropagationStopped: returnFalse,
5471
isSimulated: false,
5472
5473
preventDefault: function() {
5474
var e = this.originalEvent;
5475
5476
this.isDefaultPrevented = returnTrue;
5477
5478
if ( e && !this.isSimulated ) {
5479
e.preventDefault();
5480
}
5481
},
5482
stopPropagation: function() {
5483
var e = this.originalEvent;
5484
5485
this.isPropagationStopped = returnTrue;
5486
5487
if ( e && !this.isSimulated ) {
5488
e.stopPropagation();
5489
}
5490
},
5491
stopImmediatePropagation: function() {
5492
var e = this.originalEvent;
5493
5494
this.isImmediatePropagationStopped = returnTrue;
5495
5496
if ( e && !this.isSimulated ) {
5497
e.stopImmediatePropagation();
5498
}
5499
5500
this.stopPropagation();
5501
}
5502
};
5503
5504
// Includes all common event props including KeyEvent and MouseEvent specific props
5505
jQuery.each( {
5506
altKey: true,
5507
bubbles: true,
5508
cancelable: true,
5509
changedTouches: true,
5510
ctrlKey: true,
5511
detail: true,
5512
eventPhase: true,
5513
metaKey: true,
5514
pageX: true,
5515
pageY: true,
5516
shiftKey: true,
5517
view: true,
5518
"char": true,
5519
code: true,
5520
charCode: true,
5521
key: true,
5522
keyCode: true,
5523
button: true,
5524
buttons: true,
5525
clientX: true,
5526
clientY: true,
5527
offsetX: true,
5528
offsetY: true,
5529
pointerId: true,
5530
pointerType: true,
5531
screenX: true,
5532
screenY: true,
5533
targetTouches: true,
5534
toElement: true,
5535
touches: true,
5536
which: true
5537
}, jQuery.event.addProp );
5538
5539
jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
5540
5541
function focusMappedHandler( nativeEvent ) {
5542
if ( document.documentMode ) {
5543
5544
// Support: IE 11+
5545
// Attach a single focusin/focusout handler on the document while someone wants
5546
// focus/blur. This is because the former are synchronous in IE while the latter
5547
// are async. In other browsers, all those handlers are invoked synchronously.
5548
5549
// `handle` from private data would already wrap the event, but we need
5550
// to change the `type` here.
5551
var handle = dataPriv.get( this, "handle" ),
5552
event = jQuery.event.fix( nativeEvent );
5553
event.type = nativeEvent.type === "focusin" ? "focus" : "blur";
5554
event.isSimulated = true;
5555
5556
// First, handle focusin/focusout
5557
handle( nativeEvent );
5558
5559
// ...then, handle focus/blur
5560
//
5561
// focus/blur don't bubble while focusin/focusout do; simulate the former by only
5562
// invoking the handler at the lower level.
5563
if ( event.target === event.currentTarget ) {
5564
5565
// The setup part calls `leverageNative`, which, in turn, calls
5566
// `jQuery.event.add`, so event handle will already have been set
5567
// by this point.
5568
handle( event );
5569
}
5570
} else {
5571
5572
// For non-IE browsers, attach a single capturing handler on the document
5573
// while someone wants focusin/focusout.
5574
jQuery.event.simulate( delegateType, nativeEvent.target,
5575
jQuery.event.fix( nativeEvent ) );
5576
}
5577
}
5578
5579
jQuery.event.special[ type ] = {
5580
5581
// Utilize native event if possible so blur/focus sequence is correct
5582
setup: function() {
5583
5584
var attaches;
5585
5586
// Claim the first handler
5587
// dataPriv.set( this, "focus", ... )
5588
// dataPriv.set( this, "blur", ... )
5589
leverageNative( this, type, true );
5590
5591
if ( document.documentMode ) {
5592
5593
// Support: IE 9 - 11+
5594
// We use the same native handler for focusin & focus (and focusout & blur)
5595
// so we need to coordinate setup & teardown parts between those events.
5596
// Use `delegateType` as the key as `type` is already used by `leverageNative`.
5597
attaches = dataPriv.get( this, delegateType );
5598
if ( !attaches ) {
5599
this.addEventListener( delegateType, focusMappedHandler );
5600
}
5601
dataPriv.set( this, delegateType, ( attaches || 0 ) + 1 );
5602
} else {
5603
5604
// Return false to allow normal processing in the caller
5605
return false;
5606
}
5607
},
5608
trigger: function() {
5609
5610
// Force setup before trigger
5611
leverageNative( this, type );
5612
5613
// Return non-false to allow normal event-path propagation
5614
return true;
5615
},
5616
5617
teardown: function() {
5618
var attaches;
5619
5620
if ( document.documentMode ) {
5621
attaches = dataPriv.get( this, delegateType ) - 1;
5622
if ( !attaches ) {
5623
this.removeEventListener( delegateType, focusMappedHandler );
5624
dataPriv.remove( this, delegateType );
5625
} else {
5626
dataPriv.set( this, delegateType, attaches );
5627
}
5628
} else {
5629
5630
// Return false to indicate standard teardown should be applied
5631
return false;
5632
}
5633
},
5634
5635
// Suppress native focus or blur if we're currently inside
5636
// a leveraged native-event stack
5637
_default: function( event ) {
5638
return dataPriv.get( event.target, type );
5639
},
5640
5641
delegateType: delegateType
5642
};
5643
5644
// Support: Firefox <=44
5645
// Firefox doesn't have focus(in | out) events
5646
// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
5647
//
5648
// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
5649
// focus(in | out) events fire after focus & blur events,
5650
// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
5651
// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
5652
//
5653
// Support: IE 9 - 11+
5654
// To preserve relative focusin/focus & focusout/blur event order guaranteed on the 3.x branch,
5655
// attach a single handler for both events in IE.
5656
jQuery.event.special[ delegateType ] = {
5657
setup: function() {
5658
5659
// Handle: regular nodes (via `this.ownerDocument`), window
5660
// (via `this.document`) & document (via `this`).
5661
var doc = this.ownerDocument || this.document || this,
5662
dataHolder = document.documentMode ? this : doc,
5663
attaches = dataPriv.get( dataHolder, delegateType );
5664
5665
// Support: IE 9 - 11+
5666
// We use the same native handler for focusin & focus (and focusout & blur)
5667
// so we need to coordinate setup & teardown parts between those events.
5668
// Use `delegateType` as the key as `type` is already used by `leverageNative`.
5669
if ( !attaches ) {
5670
if ( document.documentMode ) {
5671
this.addEventListener( delegateType, focusMappedHandler );
5672
} else {
5673
doc.addEventListener( type, focusMappedHandler, true );
5674
}
5675
}
5676
dataPriv.set( dataHolder, delegateType, ( attaches || 0 ) + 1 );
5677
},
5678
teardown: function() {
5679
var doc = this.ownerDocument || this.document || this,
5680
dataHolder = document.documentMode ? this : doc,
5681
attaches = dataPriv.get( dataHolder, delegateType ) - 1;
5682
5683
if ( !attaches ) {
5684
if ( document.documentMode ) {
5685
this.removeEventListener( delegateType, focusMappedHandler );
5686
} else {
5687
doc.removeEventListener( type, focusMappedHandler, true );
5688
}
5689
dataPriv.remove( dataHolder, delegateType );
5690
} else {
5691
dataPriv.set( dataHolder, delegateType, attaches );
5692
}
5693
}
5694
};
5695
} );
5696
5697
// Create mouseenter/leave events using mouseover/out and event-time checks
5698
// so that event delegation works in jQuery.
5699
// Do the same for pointerenter/pointerleave and pointerover/pointerout
5700
//
5701
// Support: Safari 7 only
5702
// Safari sends mouseenter too often; see:
5703
// https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5704
// for the description of the bug (it existed in older Chrome versions as well).
5705
jQuery.each( {
5706
mouseenter: "mouseover",
5707
mouseleave: "mouseout",
5708
pointerenter: "pointerover",
5709
pointerleave: "pointerout"
5710
}, function( orig, fix ) {
5711
jQuery.event.special[ orig ] = {
5712
delegateType: fix,
5713
bindType: fix,
5714
5715
handle: function( event ) {
5716
var ret,
5717
target = this,
5718
related = event.relatedTarget,
5719
handleObj = event.handleObj;
5720
5721
// For mouseenter/leave call the handler if related is outside the target.
5722
// NB: No relatedTarget if the mouse left/entered the browser window
5723
if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5724
event.type = handleObj.origType;
5725
ret = handleObj.handler.apply( this, arguments );
5726
event.type = fix;
5727
}
5728
return ret;
5729
}
5730
};
5731
} );
5732
5733
jQuery.fn.extend( {
5734
5735
on: function( types, selector, data, fn ) {
5736
return on( this, types, selector, data, fn );
5737
},
5738
one: function( types, selector, data, fn ) {
5739
return on( this, types, selector, data, fn, 1 );
5740
},
5741
off: function( types, selector, fn ) {
5742
var handleObj, type;
5743
if ( types && types.preventDefault && types.handleObj ) {
5744
5745
// ( event ) dispatched jQuery.Event
5746
handleObj = types.handleObj;
5747
jQuery( types.delegateTarget ).off(
5748
handleObj.namespace ?
5749
handleObj.origType + "." + handleObj.namespace :
5750
handleObj.origType,
5751
handleObj.selector,
5752
handleObj.handler
5753
);
5754
return this;
5755
}
5756
if ( typeof types === "object" ) {
5757
5758
// ( types-object [, selector] )
5759
for ( type in types ) {
5760
this.off( type, selector, types[ type ] );
5761
}
5762
return this;
5763
}
5764
if ( selector === false || typeof selector === "function" ) {
5765
5766
// ( types [, fn] )
5767
fn = selector;
5768
selector = undefined;
5769
}
5770
if ( fn === false ) {
5771
fn = returnFalse;
5772
}
5773
return this.each( function() {
5774
jQuery.event.remove( this, types, fn, selector );
5775
} );
5776
}
5777
} );
5778
5779
5780
var
5781
5782
// Support: IE <=10 - 11, Edge 12 - 13 only
5783
// In IE/Edge using regex groups here causes severe slowdowns.
5784
// See https://connect.microsoft.com/IE/feedback/details/1736512/
5785
rnoInnerhtml = /<script|<style|<link/i,
5786
5787
// checked="checked" or checked
5788
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5789
5790
rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g;
5791
5792
// Prefer a tbody over its parent table for containing new rows
5793
function manipulationTarget( elem, content ) {
5794
if ( nodeName( elem, "table" ) &&
5795
nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
5796
5797
return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
5798
}
5799
5800
return elem;
5801
}
5802
5803
// Replace/restore the type attribute of script elements for safe DOM manipulation
5804
function disableScript( elem ) {
5805
elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
5806
return elem;
5807
}
5808
function restoreScript( elem ) {
5809
if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
5810
elem.type = elem.type.slice( 5 );
5811
} else {
5812
elem.removeAttribute( "type" );
5813
}
5814
5815
return elem;
5816
}
5817
5818
function cloneCopyEvent( src, dest ) {
5819
var i, l, type, pdataOld, udataOld, udataCur, events;
5820
5821
if ( dest.nodeType !== 1 ) {
5822
return;
5823
}
5824
5825
// 1. Copy private data: events, handlers, etc.
5826
if ( dataPriv.hasData( src ) ) {
5827
pdataOld = dataPriv.get( src );
5828
events = pdataOld.events;
5829
5830
if ( events ) {
5831
dataPriv.remove( dest, "handle events" );
5832
5833
for ( type in events ) {
5834
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5835
jQuery.event.add( dest, type, events[ type ][ i ] );
5836
}
5837
}
5838
}
5839
}
5840
5841
// 2. Copy user data
5842
if ( dataUser.hasData( src ) ) {
5843
udataOld = dataUser.access( src );
5844
udataCur = jQuery.extend( {}, udataOld );
5845
5846
dataUser.set( dest, udataCur );
5847
}
5848
}
5849
5850
// Fix IE bugs, see support tests
5851
function fixInput( src, dest ) {
5852
var nodeName = dest.nodeName.toLowerCase();
5853
5854
// Fails to persist the checked state of a cloned checkbox or radio button.
5855
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5856
dest.checked = src.checked;
5857
5858
// Fails to return the selected option to the default selected state when cloning options
5859
} else if ( nodeName === "input" || nodeName === "textarea" ) {
5860
dest.defaultValue = src.defaultValue;
5861
}
5862
}
5863
5864
function domManip( collection, args, callback, ignored ) {
5865
5866
// Flatten any nested arrays
5867
args = flat( args );
5868
5869
var fragment, first, scripts, hasScripts, node, doc,
5870
i = 0,
5871
l = collection.length,
5872
iNoClone = l - 1,
5873
value = args[ 0 ],
5874
valueIsFunction = isFunction( value );
5875
5876
// We can't cloneNode fragments that contain checked, in WebKit
5877
if ( valueIsFunction ||
5878
( l > 1 && typeof value === "string" &&
5879
!support.checkClone && rchecked.test( value ) ) ) {
5880
return collection.each( function( index ) {
5881
var self = collection.eq( index );
5882
if ( valueIsFunction ) {
5883
args[ 0 ] = value.call( this, index, self.html() );
5884
}
5885
domManip( self, args, callback, ignored );
5886
} );
5887
}
5888
5889
if ( l ) {
5890
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5891
first = fragment.firstChild;
5892
5893
if ( fragment.childNodes.length === 1 ) {
5894
fragment = first;
5895
}
5896
5897
// Require either new content or an interest in ignored elements to invoke the callback
5898
if ( first || ignored ) {
5899
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5900
hasScripts = scripts.length;
5901
5902
// Use the original fragment for the last item
5903
// instead of the first because it can end up
5904
// being emptied incorrectly in certain situations (trac-8070).
5905
for ( ; i < l; i++ ) {
5906
node = fragment;
5907
5908
if ( i !== iNoClone ) {
5909
node = jQuery.clone( node, true, true );
5910
5911
// Keep references to cloned scripts for later restoration
5912
if ( hasScripts ) {
5913
5914
// Support: Android <=4.0 only, PhantomJS 1 only
5915
// push.apply(_, arraylike) throws on ancient WebKit
5916
jQuery.merge( scripts, getAll( node, "script" ) );
5917
}
5918
}
5919
5920
callback.call( collection[ i ], node, i );
5921
}
5922
5923
if ( hasScripts ) {
5924
doc = scripts[ scripts.length - 1 ].ownerDocument;
5925
5926
// Re-enable scripts
5927
jQuery.map( scripts, restoreScript );
5928
5929
// Evaluate executable scripts on first document insertion
5930
for ( i = 0; i < hasScripts; i++ ) {
5931
node = scripts[ i ];
5932
if ( rscriptType.test( node.type || "" ) &&
5933
!dataPriv.access( node, "globalEval" ) &&
5934
jQuery.contains( doc, node ) ) {
5935
5936
if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
5937
5938
// Optional AJAX dependency, but won't run scripts if not present
5939
if ( jQuery._evalUrl && !node.noModule ) {
5940
jQuery._evalUrl( node.src, {
5941
nonce: node.nonce || node.getAttribute( "nonce" )
5942
}, doc );
5943
}
5944
} else {
5945
5946
// Unwrap a CDATA section containing script contents. This shouldn't be
5947
// needed as in XML documents they're already not visible when
5948
// inspecting element contents and in HTML documents they have no
5949
// meaning but we're preserving that logic for backwards compatibility.
5950
// This will be removed completely in 4.0. See gh-4904.
5951
DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
5952
}
5953
}
5954
}
5955
}
5956
}
5957
}
5958
5959
return collection;
5960
}
5961
5962
function remove( elem, selector, keepData ) {
5963
var node,
5964
nodes = selector ? jQuery.filter( selector, elem ) : elem,
5965
i = 0;
5966
5967
for ( ; ( node = nodes[ i ] ) != null; i++ ) {
5968
if ( !keepData && node.nodeType === 1 ) {
5969
jQuery.cleanData( getAll( node ) );
5970
}
5971
5972
if ( node.parentNode ) {
5973
if ( keepData && isAttached( node ) ) {
5974
setGlobalEval( getAll( node, "script" ) );
5975
}
5976
node.parentNode.removeChild( node );
5977
}
5978
}
5979
5980
return elem;
5981
}
5982
5983
jQuery.extend( {
5984
htmlPrefilter: function( html ) {
5985
return html;
5986
},
5987
5988
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5989
var i, l, srcElements, destElements,
5990
clone = elem.cloneNode( true ),
5991
inPage = isAttached( elem );
5992
5993
// Fix IE cloning issues
5994
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5995
!jQuery.isXMLDoc( elem ) ) {
5996
5997
// We eschew jQuery#find here for performance reasons:
5998
// https://jsperf.com/getall-vs-sizzle/2
5999
destElements = getAll( clone );
6000
srcElements = getAll( elem );
6001
6002
for ( i = 0, l = srcElements.length; i < l; i++ ) {
6003
fixInput( srcElements[ i ], destElements[ i ] );
6004
}
6005
}
6006
6007
// Copy the events from the original to the clone
6008
if ( dataAndEvents ) {
6009
if ( deepDataAndEvents ) {
6010
srcElements = srcElements || getAll( elem );
6011
destElements = destElements || getAll( clone );
6012
6013
for ( i = 0, l = srcElements.length; i < l; i++ ) {
6014
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
6015
}
6016
} else {
6017
cloneCopyEvent( elem, clone );
6018
}
6019
}
6020
6021
// Preserve script evaluation history
6022
destElements = getAll( clone, "script" );
6023
if ( destElements.length > 0 ) {
6024
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6025
}
6026
6027
// Return the cloned set
6028
return clone;
6029
},
6030
6031
cleanData: function( elems ) {
6032
var data, elem, type,
6033
special = jQuery.event.special,
6034
i = 0;
6035
6036
for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
6037
if ( acceptData( elem ) ) {
6038
if ( ( data = elem[ dataPriv.expando ] ) ) {
6039
if ( data.events ) {
6040
for ( type in data.events ) {
6041
if ( special[ type ] ) {
6042
jQuery.event.remove( elem, type );
6043
6044
// This is a shortcut to avoid jQuery.event.remove's overhead
6045
} else {
6046
jQuery.removeEvent( elem, type, data.handle );
6047
}
6048
}
6049
}
6050
6051
// Support: Chrome <=35 - 45+
6052
// Assign undefined instead of using delete, see Data#remove
6053
elem[ dataPriv.expando ] = undefined;
6054
}
6055
if ( elem[ dataUser.expando ] ) {
6056
6057
// Support: Chrome <=35 - 45+
6058
// Assign undefined instead of using delete, see Data#remove
6059
elem[ dataUser.expando ] = undefined;
6060
}
6061
}
6062
}
6063
}
6064
} );
6065
6066
jQuery.fn.extend( {
6067
detach: function( selector ) {
6068
return remove( this, selector, true );
6069
},
6070
6071
remove: function( selector ) {
6072
return remove( this, selector );
6073
},
6074
6075
text: function( value ) {
6076
return access( this, function( value ) {
6077
return value === undefined ?
6078
jQuery.text( this ) :
6079
this.empty().each( function() {
6080
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6081
this.textContent = value;
6082
}
6083
} );
6084
}, null, value, arguments.length );
6085
},
6086
6087
append: function() {
6088
return domManip( this, arguments, function( elem ) {
6089
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6090
var target = manipulationTarget( this, elem );
6091
target.appendChild( elem );
6092
}
6093
} );
6094
},
6095
6096
prepend: function() {
6097
return domManip( this, arguments, function( elem ) {
6098
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6099
var target = manipulationTarget( this, elem );
6100
target.insertBefore( elem, target.firstChild );
6101
}
6102
} );
6103
},
6104
6105
before: function() {
6106
return domManip( this, arguments, function( elem ) {
6107
if ( this.parentNode ) {
6108
this.parentNode.insertBefore( elem, this );
6109
}
6110
} );
6111
},
6112
6113
after: function() {
6114
return domManip( this, arguments, function( elem ) {
6115
if ( this.parentNode ) {
6116
this.parentNode.insertBefore( elem, this.nextSibling );
6117
}
6118
} );
6119
},
6120
6121
empty: function() {
6122
var elem,
6123
i = 0;
6124
6125
for ( ; ( elem = this[ i ] ) != null; i++ ) {
6126
if ( elem.nodeType === 1 ) {
6127
6128
// Prevent memory leaks
6129
jQuery.cleanData( getAll( elem, false ) );
6130
6131
// Remove any remaining nodes
6132
elem.textContent = "";
6133
}
6134
}
6135
6136
return this;
6137
},
6138
6139
clone: function( dataAndEvents, deepDataAndEvents ) {
6140
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6141
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6142
6143
return this.map( function() {
6144
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6145
} );
6146
},
6147
6148
html: function( value ) {
6149
return access( this, function( value ) {
6150
var elem = this[ 0 ] || {},
6151
i = 0,
6152
l = this.length;
6153
6154
if ( value === undefined && elem.nodeType === 1 ) {
6155
return elem.innerHTML;
6156
}
6157
6158
// See if we can take a shortcut and just use innerHTML
6159
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6160
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
6161
6162
value = jQuery.htmlPrefilter( value );
6163
6164
try {
6165
for ( ; i < l; i++ ) {
6166
elem = this[ i ] || {};
6167
6168
// Remove element nodes and prevent memory leaks
6169
if ( elem.nodeType === 1 ) {
6170
jQuery.cleanData( getAll( elem, false ) );
6171
elem.innerHTML = value;
6172
}
6173
}
6174
6175
elem = 0;
6176
6177
// If using innerHTML throws an exception, use the fallback method
6178
} catch ( e ) {}
6179
}
6180
6181
if ( elem ) {
6182
this.empty().append( value );
6183
}
6184
}, null, value, arguments.length );
6185
},
6186
6187
replaceWith: function() {
6188
var ignored = [];
6189
6190
// Make the changes, replacing each non-ignored context element with the new content
6191
return domManip( this, arguments, function( elem ) {
6192
var parent = this.parentNode;
6193
6194
if ( jQuery.inArray( this, ignored ) < 0 ) {
6195
jQuery.cleanData( getAll( this ) );
6196
if ( parent ) {
6197
parent.replaceChild( elem, this );
6198
}
6199
}
6200
6201
// Force callback invocation
6202
}, ignored );
6203
}
6204
} );
6205
6206
jQuery.each( {
6207
appendTo: "append",
6208
prependTo: "prepend",
6209
insertBefore: "before",
6210
insertAfter: "after",
6211
replaceAll: "replaceWith"
6212
}, function( name, original ) {
6213
jQuery.fn[ name ] = function( selector ) {
6214
var elems,
6215
ret = [],
6216
insert = jQuery( selector ),
6217
last = insert.length - 1,
6218
i = 0;
6219
6220
for ( ; i <= last; i++ ) {
6221
elems = i === last ? this : this.clone( true );
6222
jQuery( insert[ i ] )[ original ]( elems );
6223
6224
// Support: Android <=4.0 only, PhantomJS 1 only
6225
// .get() because push.apply(_, arraylike) throws on ancient WebKit
6226
push.apply( ret, elems.get() );
6227
}
6228
6229
return this.pushStack( ret );
6230
};
6231
} );
6232
var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6233
6234
var rcustomProp = /^--/;
6235
6236
6237
var getStyles = function( elem ) {
6238
6239
// Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150)
6240
// IE throws on elements created in popups
6241
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6242
var view = elem.ownerDocument.defaultView;
6243
6244
if ( !view || !view.opener ) {
6245
view = window;
6246
}
6247
6248
return view.getComputedStyle( elem );
6249
};
6250
6251
var swap = function( elem, options, callback ) {
6252
var ret, name,
6253
old = {};
6254
6255
// Remember the old values, and insert the new ones
6256
for ( name in options ) {
6257
old[ name ] = elem.style[ name ];
6258
elem.style[ name ] = options[ name ];
6259
}
6260
6261
ret = callback.call( elem );
6262
6263
// Revert the old values
6264
for ( name in options ) {
6265
elem.style[ name ] = old[ name ];
6266
}
6267
6268
return ret;
6269
};
6270
6271
6272
var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
6273
6274
6275
6276
( function() {
6277
6278
// Executing both pixelPosition & boxSizingReliable tests require only one layout
6279
// so they're executed at the same time to save the second computation.
6280
function computeStyleTests() {
6281
6282
// This is a singleton, we need to execute it only once
6283
if ( !div ) {
6284
return;
6285
}
6286
6287
container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
6288
"margin-top:1px;padding:0;border:0";
6289
div.style.cssText =
6290
"position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
6291
"margin:auto;border:1px;padding:1px;" +
6292
"width:60%;top:1%";
6293
documentElement.appendChild( container ).appendChild( div );
6294
6295
var divStyle = window.getComputedStyle( div );
6296
pixelPositionVal = divStyle.top !== "1%";
6297
6298
// Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6299
reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
6300
6301
// Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
6302
// Some styles come back with percentage values, even though they shouldn't
6303
div.style.right = "60%";
6304
pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
6305
6306
// Support: IE 9 - 11 only
6307
// Detect misreporting of content dimensions for box-sizing:border-box elements
6308
boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
6309
6310
// Support: IE 9 only
6311
// Detect overflow:scroll screwiness (gh-3699)
6312
// Support: Chrome <=64
6313
// Don't get tricked when zoom affects offsetWidth (gh-4029)
6314
div.style.position = "absolute";
6315
scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
6316
6317
documentElement.removeChild( container );
6318
6319
// Nullify the div so it wouldn't be stored in the memory and
6320
// it will also be a sign that checks already performed
6321
div = null;
6322
}
6323
6324
function roundPixelMeasures( measure ) {
6325
return Math.round( parseFloat( measure ) );
6326
}
6327
6328
var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
6329
reliableTrDimensionsVal, reliableMarginLeftVal,
6330
container = document.createElement( "div" ),
6331
div = document.createElement( "div" );
6332
6333
// Finish early in limited (non-browser) environments
6334
if ( !div.style ) {
6335
return;
6336
}
6337
6338
// Support: IE <=9 - 11 only
6339
// Style of cloned element affects source element cloned (trac-8908)
6340
div.style.backgroundClip = "content-box";
6341
div.cloneNode( true ).style.backgroundClip = "";
6342
support.clearCloneStyle = div.style.backgroundClip === "content-box";
6343
6344
jQuery.extend( support, {
6345
boxSizingReliable: function() {
6346
computeStyleTests();
6347
return boxSizingReliableVal;
6348
},
6349
pixelBoxStyles: function() {
6350
computeStyleTests();
6351
return pixelBoxStylesVal;
6352
},
6353
pixelPosition: function() {
6354
computeStyleTests();
6355
return pixelPositionVal;
6356
},
6357
reliableMarginLeft: function() {
6358
computeStyleTests();
6359
return reliableMarginLeftVal;
6360
},
6361
scrollboxSize: function() {
6362
computeStyleTests();
6363
return scrollboxSizeVal;
6364
},
6365
6366
// Support: IE 9 - 11+, Edge 15 - 18+
6367
// IE/Edge misreport `getComputedStyle` of table rows with width/height
6368
// set in CSS while `offset*` properties report correct values.
6369
// Behavior in IE 9 is more subtle than in newer versions & it passes
6370
// some versions of this test; make sure not to make it pass there!
6371
//
6372
// Support: Firefox 70+
6373
// Only Firefox includes border widths
6374
// in computed dimensions. (gh-4529)
6375
reliableTrDimensions: function() {
6376
var table, tr, trChild, trStyle;
6377
if ( reliableTrDimensionsVal == null ) {
6378
table = document.createElement( "table" );
6379
tr = document.createElement( "tr" );
6380
trChild = document.createElement( "div" );
6381
6382
table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
6383
tr.style.cssText = "box-sizing:content-box;border:1px solid";
6384
6385
// Support: Chrome 86+
6386
// Height set through cssText does not get applied.
6387
// Computed height then comes back as 0.
6388
tr.style.height = "1px";
6389
trChild.style.height = "9px";
6390
6391
// Support: Android 8 Chrome 86+
6392
// In our bodyBackground.html iframe,
6393
// display for all div elements is set to "inline",
6394
// which causes a problem only in Android 8 Chrome 86.
6395
// Ensuring the div is `display: block`
6396
// gets around this issue.
6397
trChild.style.display = "block";
6398
6399
documentElement
6400
.appendChild( table )
6401
.appendChild( tr )
6402
.appendChild( trChild );
6403
6404
trStyle = window.getComputedStyle( tr );
6405
reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
6406
parseInt( trStyle.borderTopWidth, 10 ) +
6407
parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
6408
6409
documentElement.removeChild( table );
6410
}
6411
return reliableTrDimensionsVal;
6412
}
6413
} );
6414
} )();
6415
6416
6417
function curCSS( elem, name, computed ) {
6418
var width, minWidth, maxWidth, ret,
6419
isCustomProp = rcustomProp.test( name ),
6420
6421
// Support: Firefox 51+
6422
// Retrieving style before computed somehow
6423
// fixes an issue with getting wrong values
6424
// on detached elements
6425
style = elem.style;
6426
6427
computed = computed || getStyles( elem );
6428
6429
// getPropertyValue is needed for:
6430
// .css('filter') (IE 9 only, trac-12537)
6431
// .css('--customProperty) (gh-3144)
6432
if ( computed ) {
6433
6434
// Support: IE <=9 - 11+
6435
// IE only supports `"float"` in `getPropertyValue`; in computed styles
6436
// it's only available as `"cssFloat"`. We no longer modify properties
6437
// sent to `.css()` apart from camelCasing, so we need to check both.
6438
// Normally, this would create difference in behavior: if
6439
// `getPropertyValue` returns an empty string, the value returned
6440
// by `.css()` would be `undefined`. This is usually the case for
6441
// disconnected elements. However, in IE even disconnected elements
6442
// with no styles return `"none"` for `getPropertyValue( "float" )`
6443
ret = computed.getPropertyValue( name ) || computed[ name ];
6444
6445
if ( isCustomProp && ret ) {
6446
6447
// Support: Firefox 105+, Chrome <=105+
6448
// Spec requires trimming whitespace for custom properties (gh-4926).
6449
// Firefox only trims leading whitespace. Chrome just collapses
6450
// both leading & trailing whitespace to a single space.
6451
//
6452
// Fall back to `undefined` if empty string returned.
6453
// This collapses a missing definition with property defined
6454
// and set to an empty string but there's no standard API
6455
// allowing us to differentiate them without a performance penalty
6456
// and returning `undefined` aligns with older jQuery.
6457
//
6458
// rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
6459
// as whitespace while CSS does not, but this is not a problem
6460
// because CSS preprocessing replaces them with U+000A LINE FEED
6461
// (which *is* CSS whitespace)
6462
// https://www.w3.org/TR/css-syntax-3/#input-preprocessing
6463
ret = ret.replace( rtrimCSS, "$1" ) || undefined;
6464
}
6465
6466
if ( ret === "" && !isAttached( elem ) ) {
6467
ret = jQuery.style( elem, name );
6468
}
6469
6470
// A tribute to the "awesome hack by Dean Edwards"
6471
// Android Browser returns percentage for some values,
6472
// but width seems to be reliably pixels.
6473
// This is against the CSSOM draft spec:
6474
// https://drafts.csswg.org/cssom/#resolved-values
6475
if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
6476
6477
// Remember the original values
6478
width = style.width;
6479
minWidth = style.minWidth;
6480
maxWidth = style.maxWidth;
6481
6482
// Put in the new values to get a computed value out
6483
style.minWidth = style.maxWidth = style.width = ret;
6484
ret = computed.width;
6485
6486
// Revert the changed values
6487
style.width = width;
6488
style.minWidth = minWidth;
6489
style.maxWidth = maxWidth;
6490
}
6491
}
6492
6493
return ret !== undefined ?
6494
6495
// Support: IE <=9 - 11 only
6496
// IE returns zIndex value as an integer.
6497
ret + "" :
6498
ret;
6499
}
6500
6501
6502
function addGetHookIf( conditionFn, hookFn ) {
6503
6504
// Define the hook, we'll check on the first run if it's really needed.
6505
return {
6506
get: function() {
6507
if ( conditionFn() ) {
6508
6509
// Hook not needed (or it's not possible to use it due
6510
// to missing dependency), remove it.
6511
delete this.get;
6512
return;
6513
}
6514
6515
// Hook needed; redefine it so that the support test is not executed again.
6516
return ( this.get = hookFn ).apply( this, arguments );
6517
}
6518
};
6519
}
6520
6521
6522
var cssPrefixes = [ "Webkit", "Moz", "ms" ],
6523
emptyStyle = document.createElement( "div" ).style,
6524
vendorProps = {};
6525
6526
// Return a vendor-prefixed property or undefined
6527
function vendorPropName( name ) {
6528
6529
// Check for vendor prefixed names
6530
var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
6531
i = cssPrefixes.length;
6532
6533
while ( i-- ) {
6534
name = cssPrefixes[ i ] + capName;
6535
if ( name in emptyStyle ) {
6536
return name;
6537
}
6538
}
6539
}
6540
6541
// Return a potentially-mapped jQuery.cssProps or vendor prefixed property
6542
function finalPropName( name ) {
6543
var final = jQuery.cssProps[ name ] || vendorProps[ name ];
6544
6545
if ( final ) {
6546
return final;
6547
}
6548
if ( name in emptyStyle ) {
6549
return name;
6550
}
6551
return vendorProps[ name ] = vendorPropName( name ) || name;
6552
}
6553
6554
6555
var
6556
6557
// Swappable if display is none or starts with table
6558
// except "table", "table-cell", or "table-caption"
6559
// See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6560
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6561
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6562
cssNormalTransform = {
6563
letterSpacing: "0",
6564
fontWeight: "400"
6565
};
6566
6567
function setPositiveNumber( _elem, value, subtract ) {
6568
6569
// Any relative (+/-) values have already been
6570
// normalized at this point
6571
var matches = rcssNum.exec( value );
6572
return matches ?
6573
6574
// Guard against undefined "subtract", e.g., when used as in cssHooks
6575
Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
6576
value;
6577
}
6578
6579
function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
6580
var i = dimension === "width" ? 1 : 0,
6581
extra = 0,
6582
delta = 0,
6583
marginDelta = 0;
6584
6585
// Adjustment may not be necessary
6586
if ( box === ( isBorderBox ? "border" : "content" ) ) {
6587
return 0;
6588
}
6589
6590
for ( ; i < 4; i += 2 ) {
6591
6592
// Both box models exclude margin
6593
// Count margin delta separately to only add it after scroll gutter adjustment.
6594
// This is needed to make negative margins work with `outerHeight( true )` (gh-3982).
6595
if ( box === "margin" ) {
6596
marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
6597
}
6598
6599
// If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6600
if ( !isBorderBox ) {
6601
6602
// Add padding
6603
delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6604
6605
// For "border" or "margin", add border
6606
if ( box !== "padding" ) {
6607
delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6608
6609
// But still keep track of it otherwise
6610
} else {
6611
extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6612
}
6613
6614
// If we get here with a border-box (content + padding + border), we're seeking "content" or
6615
// "padding" or "margin"
6616
} else {
6617
6618
// For "content", subtract padding
6619
if ( box === "content" ) {
6620
delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6621
}
6622
6623
// For "content" or "padding", subtract border
6624
if ( box !== "margin" ) {
6625
delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6626
}
6627
}
6628
}
6629
6630
// Account for positive content-box scroll gutter when requested by providing computedVal
6631
if ( !isBorderBox && computedVal >= 0 ) {
6632
6633
// offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6634
// Assuming integer scroll gutter, subtract the rest and round down
6635
delta += Math.max( 0, Math.ceil(
6636
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
6637
computedVal -
6638
delta -
6639
extra -
6640
0.5
6641
6642
// If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
6643
// Use an explicit zero to avoid NaN (gh-3964)
6644
) ) || 0;
6645
}
6646
6647
return delta + marginDelta;
6648
}
6649
6650
function getWidthOrHeight( elem, dimension, extra ) {
6651
6652
// Start with computed style
6653
var styles = getStyles( elem ),
6654
6655
// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
6656
// Fake content-box until we know it's needed to know the true value.
6657
boxSizingNeeded = !support.boxSizingReliable() || extra,
6658
isBorderBox = boxSizingNeeded &&
6659
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6660
valueIsBorderBox = isBorderBox,
6661
6662
val = curCSS( elem, dimension, styles ),
6663
offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
6664
6665
// Support: Firefox <=54
6666
// Return a confounding non-pixel value or feign ignorance, as appropriate.
6667
if ( rnumnonpx.test( val ) ) {
6668
if ( !extra ) {
6669
return val;
6670
}
6671
val = "auto";
6672
}
6673
6674
6675
// Support: IE 9 - 11 only
6676
// Use offsetWidth/offsetHeight for when box sizing is unreliable.
6677
// In those cases, the computed value can be trusted to be border-box.
6678
if ( ( !support.boxSizingReliable() && isBorderBox ||
6679
6680
// Support: IE 10 - 11+, Edge 15 - 18+
6681
// IE/Edge misreport `getComputedStyle` of table rows with width/height
6682
// set in CSS while `offset*` properties report correct values.
6683
// Interestingly, in some cases IE 9 doesn't suffer from this issue.
6684
!support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
6685
6686
// Fall back to offsetWidth/offsetHeight when value is "auto"
6687
// This happens for inline elements with no explicit setting (gh-3571)
6688
val === "auto" ||
6689
6690
// Support: Android <=4.1 - 4.3 only
6691
// Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
6692
!parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
6693
6694
// Make sure the element is visible & connected
6695
elem.getClientRects().length ) {
6696
6697
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6698
6699
// Where available, offsetWidth/offsetHeight approximate border box dimensions.
6700
// Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
6701
// retrieved value as a content box dimension.
6702
valueIsBorderBox = offsetProp in elem;
6703
if ( valueIsBorderBox ) {
6704
val = elem[ offsetProp ];
6705
}
6706
}
6707
6708
// Normalize "" and auto
6709
val = parseFloat( val ) || 0;
6710
6711
// Adjust for the element's box model
6712
return ( val +
6713
boxModelAdjustment(
6714
elem,
6715
dimension,
6716
extra || ( isBorderBox ? "border" : "content" ),
6717
valueIsBorderBox,
6718
styles,
6719
6720
// Provide the current computed size to request scroll gutter calculation (gh-3589)
6721
val
6722
)
6723
) + "px";
6724
}
6725
6726
jQuery.extend( {
6727
6728
// Add in style property hooks for overriding the default
6729
// behavior of getting and setting a style property
6730
cssHooks: {
6731
opacity: {
6732
get: function( elem, computed ) {
6733
if ( computed ) {
6734
6735
// We should always get a number back from opacity
6736
var ret = curCSS( elem, "opacity" );
6737
return ret === "" ? "1" : ret;
6738
}
6739
}
6740
}
6741
},
6742
6743
// Don't automatically add "px" to these possibly-unitless properties
6744
cssNumber: {
6745
animationIterationCount: true,
6746
aspectRatio: true,
6747
borderImageSlice: true,
6748
columnCount: true,
6749
flexGrow: true,
6750
flexShrink: true,
6751
fontWeight: true,
6752
gridArea: true,
6753
gridColumn: true,
6754
gridColumnEnd: true,
6755
gridColumnStart: true,
6756
gridRow: true,
6757
gridRowEnd: true,
6758
gridRowStart: true,
6759
lineHeight: true,
6760
opacity: true,
6761
order: true,
6762
orphans: true,
6763
scale: true,
6764
widows: true,
6765
zIndex: true,
6766
zoom: true,
6767
6768
// SVG-related
6769
fillOpacity: true,
6770
floodOpacity: true,
6771
stopOpacity: true,
6772
strokeMiterlimit: true,
6773
strokeOpacity: true
6774
},
6775
6776
// Add in properties whose names you wish to fix before
6777
// setting or getting the value
6778
cssProps: {},
6779
6780
// Get and set the style property on a DOM Node
6781
style: function( elem, name, value, extra ) {
6782
6783
// Don't set styles on text and comment nodes
6784
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6785
return;
6786
}
6787
6788
// Make sure that we're working with the right name
6789
var ret, type, hooks,
6790
origName = camelCase( name ),
6791
isCustomProp = rcustomProp.test( name ),
6792
style = elem.style;
6793
6794
// Make sure that we're working with the right name. We don't
6795
// want to query the value if it is a CSS custom property
6796
// since they are user-defined.
6797
if ( !isCustomProp ) {
6798
name = finalPropName( origName );
6799
}
6800
6801
// Gets hook for the prefixed version, then unprefixed version
6802
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6803
6804
// Check if we're setting a value
6805
if ( value !== undefined ) {
6806
type = typeof value;
6807
6808
// Convert "+=" or "-=" to relative numbers (trac-7345)
6809
if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
6810
value = adjustCSS( elem, name, ret );
6811
6812
// Fixes bug trac-9237
6813
type = "number";
6814
}
6815
6816
// Make sure that null and NaN values aren't set (trac-7116)
6817
if ( value == null || value !== value ) {
6818
return;
6819
}
6820
6821
// If a number was passed in, add the unit (except for certain CSS properties)
6822
// The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
6823
// "px" to a few hardcoded values.
6824
if ( type === "number" && !isCustomProp ) {
6825
value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
6826
}
6827
6828
// background-* props affect original clone's values
6829
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
6830
style[ name ] = "inherit";
6831
}
6832
6833
// If a hook was provided, use that value, otherwise just set the specified value
6834
if ( !hooks || !( "set" in hooks ) ||
6835
( value = hooks.set( elem, value, extra ) ) !== undefined ) {
6836
6837
if ( isCustomProp ) {
6838
style.setProperty( name, value );
6839
} else {
6840
style[ name ] = value;
6841
}
6842
}
6843
6844
} else {
6845
6846
// If a hook was provided get the non-computed value from there
6847
if ( hooks && "get" in hooks &&
6848
( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
6849
6850
return ret;
6851
}
6852
6853
// Otherwise just get the value from the style object
6854
return style[ name ];
6855
}
6856
},
6857
6858
css: function( elem, name, extra, styles ) {
6859
var val, num, hooks,
6860
origName = camelCase( name ),
6861
isCustomProp = rcustomProp.test( name );
6862
6863
// Make sure that we're working with the right name. We don't
6864
// want to modify the value if it is a CSS custom property
6865
// since they are user-defined.
6866
if ( !isCustomProp ) {
6867
name = finalPropName( origName );
6868
}
6869
6870
// Try prefixed name followed by the unprefixed name
6871
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6872
6873
// If a hook was provided get the computed value from there
6874
if ( hooks && "get" in hooks ) {
6875
val = hooks.get( elem, true, extra );
6876
}
6877
6878
// Otherwise, if a way to get the computed value exists, use that
6879
if ( val === undefined ) {
6880
val = curCSS( elem, name, styles );
6881
}
6882
6883
// Convert "normal" to computed value
6884
if ( val === "normal" && name in cssNormalTransform ) {
6885
val = cssNormalTransform[ name ];
6886
}
6887
6888
// Make numeric if forced or a qualifier was provided and val looks numeric
6889
if ( extra === "" || extra ) {
6890
num = parseFloat( val );
6891
return extra === true || isFinite( num ) ? num || 0 : val;
6892
}
6893
6894
return val;
6895
}
6896
} );
6897
6898
jQuery.each( [ "height", "width" ], function( _i, dimension ) {
6899
jQuery.cssHooks[ dimension ] = {
6900
get: function( elem, computed, extra ) {
6901
if ( computed ) {
6902
6903
// Certain elements can have dimension info if we invisibly show them
6904
// but it must have a current display style that would benefit
6905
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
6906
6907
// Support: Safari 8+
6908
// Table columns in Safari have non-zero offsetWidth & zero
6909
// getBoundingClientRect().width unless display is changed.
6910
// Support: IE <=11 only
6911
// Running getBoundingClientRect on a disconnected node
6912
// in IE throws an error.
6913
( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
6914
swap( elem, cssShow, function() {
6915
return getWidthOrHeight( elem, dimension, extra );
6916
} ) :
6917
getWidthOrHeight( elem, dimension, extra );
6918
}
6919
},
6920
6921
set: function( elem, value, extra ) {
6922
var matches,
6923
styles = getStyles( elem ),
6924
6925
// Only read styles.position if the test has a chance to fail
6926
// to avoid forcing a reflow.
6927
scrollboxSizeBuggy = !support.scrollboxSize() &&
6928
styles.position === "absolute",
6929
6930
// To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
6931
boxSizingNeeded = scrollboxSizeBuggy || extra,
6932
isBorderBox = boxSizingNeeded &&
6933
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6934
subtract = extra ?
6935
boxModelAdjustment(
6936
elem,
6937
dimension,
6938
extra,
6939
isBorderBox,
6940
styles
6941
) :
6942
0;
6943
6944
// Account for unreliable border-box dimensions by comparing offset* to computed and
6945
// faking a content-box to get border and padding (gh-3699)
6946
if ( isBorderBox && scrollboxSizeBuggy ) {
6947
subtract -= Math.ceil(
6948
elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
6949
parseFloat( styles[ dimension ] ) -
6950
boxModelAdjustment( elem, dimension, "border", false, styles ) -
6951
0.5
6952
);
6953
}
6954
6955
// Convert to pixels if value adjustment is needed
6956
if ( subtract && ( matches = rcssNum.exec( value ) ) &&
6957
( matches[ 3 ] || "px" ) !== "px" ) {
6958
6959
elem.style[ dimension ] = value;
6960
value = jQuery.css( elem, dimension );
6961
}
6962
6963
return setPositiveNumber( elem, value, subtract );
6964
}
6965
};
6966
} );
6967
6968
jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
6969
function( elem, computed ) {
6970
if ( computed ) {
6971
return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
6972
elem.getBoundingClientRect().left -
6973
swap( elem, { marginLeft: 0 }, function() {
6974
return elem.getBoundingClientRect().left;
6975
} )
6976
) + "px";
6977
}
6978
}
6979
);
6980
6981
// These hooks are used by animate to expand properties
6982
jQuery.each( {
6983
margin: "",
6984
padding: "",
6985
border: "Width"
6986
}, function( prefix, suffix ) {
6987
jQuery.cssHooks[ prefix + suffix ] = {
6988
expand: function( value ) {
6989
var i = 0,
6990
expanded = {},
6991
6992
// Assumes a single number if not a string
6993
parts = typeof value === "string" ? value.split( " " ) : [ value ];
6994
6995
for ( ; i < 4; i++ ) {
6996
expanded[ prefix + cssExpand[ i ] + suffix ] =
6997
parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6998
}
6999
7000
return expanded;
7001
}
7002
};
7003
7004
if ( prefix !== "margin" ) {
7005
jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7006
}
7007
} );
7008
7009
jQuery.fn.extend( {
7010
css: function( name, value ) {
7011
return access( this, function( elem, name, value ) {
7012
var styles, len,
7013
map = {},
7014
i = 0;
7015
7016
if ( Array.isArray( name ) ) {
7017
styles = getStyles( elem );
7018
len = name.length;
7019
7020
for ( ; i < len; i++ ) {
7021
map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
7022
}
7023
7024
return map;
7025
}
7026
7027
return value !== undefined ?
7028
jQuery.style( elem, name, value ) :
7029
jQuery.css( elem, name );
7030
}, name, value, arguments.length > 1 );
7031
}
7032
} );
7033
7034
7035
function Tween( elem, options, prop, end, easing ) {
7036
return new Tween.prototype.init( elem, options, prop, end, easing );
7037
}
7038
jQuery.Tween = Tween;
7039
7040
Tween.prototype = {
7041
constructor: Tween,
7042
init: function( elem, options, prop, end, easing, unit ) {
7043
this.elem = elem;
7044
this.prop = prop;
7045
this.easing = easing || jQuery.easing._default;
7046
this.options = options;
7047
this.start = this.now = this.cur();
7048
this.end = end;
7049
this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
7050
},
7051
cur: function() {
7052
var hooks = Tween.propHooks[ this.prop ];
7053
7054
return hooks && hooks.get ?
7055
hooks.get( this ) :
7056
Tween.propHooks._default.get( this );
7057
},
7058
run: function( percent ) {
7059
var eased,
7060
hooks = Tween.propHooks[ this.prop ];
7061
7062
if ( this.options.duration ) {
7063
this.pos = eased = jQuery.easing[ this.easing ](
7064
percent, this.options.duration * percent, 0, 1, this.options.duration
7065
);
7066
} else {
7067
this.pos = eased = percent;
7068
}
7069
this.now = ( this.end - this.start ) * eased + this.start;
7070
7071
if ( this.options.step ) {
7072
this.options.step.call( this.elem, this.now, this );
7073
}
7074
7075
if ( hooks && hooks.set ) {
7076
hooks.set( this );
7077
} else {
7078
Tween.propHooks._default.set( this );
7079
}
7080
return this;
7081
}
7082
};
7083
7084
Tween.prototype.init.prototype = Tween.prototype;
7085
7086
Tween.propHooks = {
7087
_default: {
7088
get: function( tween ) {
7089
var result;
7090
7091
// Use a property on the element directly when it is not a DOM element,
7092
// or when there is no matching style property that exists.
7093
if ( tween.elem.nodeType !== 1 ||
7094
tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
7095
return tween.elem[ tween.prop ];
7096
}
7097
7098
// Passing an empty string as a 3rd parameter to .css will automatically
7099
// attempt a parseFloat and fallback to a string if the parse fails.
7100
// Simple values such as "10px" are parsed to Float;
7101
// complex values such as "rotate(1rad)" are returned as-is.
7102
result = jQuery.css( tween.elem, tween.prop, "" );
7103
7104
// Empty strings, null, undefined and "auto" are converted to 0.
7105
return !result || result === "auto" ? 0 : result;
7106
},
7107
set: function( tween ) {
7108
7109
// Use step hook for back compat.
7110
// Use cssHook if its there.
7111
// Use .style if available and use plain properties where available.
7112
if ( jQuery.fx.step[ tween.prop ] ) {
7113
jQuery.fx.step[ tween.prop ]( tween );
7114
} else if ( tween.elem.nodeType === 1 && (
7115
jQuery.cssHooks[ tween.prop ] ||
7116
tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
7117
jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
7118
} else {
7119
tween.elem[ tween.prop ] = tween.now;
7120
}
7121
}
7122
}
7123
};
7124
7125
// Support: IE <=9 only
7126
// Panic based approach to setting things on disconnected nodes
7127
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
7128
set: function( tween ) {
7129
if ( tween.elem.nodeType && tween.elem.parentNode ) {
7130
tween.elem[ tween.prop ] = tween.now;
7131
}
7132
}
7133
};
7134
7135
jQuery.easing = {
7136
linear: function( p ) {
7137
return p;
7138
},
7139
swing: function( p ) {
7140
return 0.5 - Math.cos( p * Math.PI ) / 2;
7141
},
7142
_default: "swing"
7143
};
7144
7145
jQuery.fx = Tween.prototype.init;
7146
7147
// Back compat <1.8 extension point
7148
jQuery.fx.step = {};
7149
7150
7151
7152
7153
var
7154
fxNow, inProgress,
7155
rfxtypes = /^(?:toggle|show|hide)$/,
7156
rrun = /queueHooks$/;
7157
7158
function schedule() {
7159
if ( inProgress ) {
7160
if ( document.hidden === false && window.requestAnimationFrame ) {
7161
window.requestAnimationFrame( schedule );
7162
} else {
7163
window.setTimeout( schedule, jQuery.fx.interval );
7164
}
7165
7166
jQuery.fx.tick();
7167
}
7168
}
7169
7170
// Animations created synchronously will run synchronously
7171
function createFxNow() {
7172
window.setTimeout( function() {
7173
fxNow = undefined;
7174
} );
7175
return ( fxNow = Date.now() );
7176
}
7177
7178
// Generate parameters to create a standard animation
7179
function genFx( type, includeWidth ) {
7180
var which,
7181
i = 0,
7182
attrs = { height: type };
7183
7184
// If we include width, step value is 1 to do all cssExpand values,
7185
// otherwise step value is 2 to skip over Left and Right
7186
includeWidth = includeWidth ? 1 : 0;
7187
for ( ; i < 4; i += 2 - includeWidth ) {
7188
which = cssExpand[ i ];
7189
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
7190
}
7191
7192
if ( includeWidth ) {
7193
attrs.opacity = attrs.width = type;
7194
}
7195
7196
return attrs;
7197
}
7198
7199
function createTween( value, prop, animation ) {
7200
var tween,
7201
collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
7202
index = 0,
7203
length = collection.length;
7204
for ( ; index < length; index++ ) {
7205
if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
7206
7207
// We're done with this property
7208
return tween;
7209
}
7210
}
7211
}
7212
7213
function defaultPrefilter( elem, props, opts ) {
7214
var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
7215
isBox = "width" in props || "height" in props,
7216
anim = this,
7217
orig = {},
7218
style = elem.style,
7219
hidden = elem.nodeType && isHiddenWithinTree( elem ),
7220
dataShow = dataPriv.get( elem, "fxshow" );
7221
7222
// Queue-skipping animations hijack the fx hooks
7223
if ( !opts.queue ) {
7224
hooks = jQuery._queueHooks( elem, "fx" );
7225
if ( hooks.unqueued == null ) {
7226
hooks.unqueued = 0;
7227
oldfire = hooks.empty.fire;
7228
hooks.empty.fire = function() {
7229
if ( !hooks.unqueued ) {
7230
oldfire();
7231
}
7232
};
7233
}
7234
hooks.unqueued++;
7235
7236
anim.always( function() {
7237
7238
// Ensure the complete handler is called before this completes
7239
anim.always( function() {
7240
hooks.unqueued--;
7241
if ( !jQuery.queue( elem, "fx" ).length ) {
7242
hooks.empty.fire();
7243
}
7244
} );
7245
} );
7246
}
7247
7248
// Detect show/hide animations
7249
for ( prop in props ) {
7250
value = props[ prop ];
7251
if ( rfxtypes.test( value ) ) {
7252
delete props[ prop ];
7253
toggle = toggle || value === "toggle";
7254
if ( value === ( hidden ? "hide" : "show" ) ) {
7255
7256
// Pretend to be hidden if this is a "show" and
7257
// there is still data from a stopped show/hide
7258
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
7259
hidden = true;
7260
7261
// Ignore all other no-op show/hide data
7262
} else {
7263
continue;
7264
}
7265
}
7266
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
7267
}
7268
}
7269
7270
// Bail out if this is a no-op like .hide().hide()
7271
propTween = !jQuery.isEmptyObject( props );
7272
if ( !propTween && jQuery.isEmptyObject( orig ) ) {
7273
return;
7274
}
7275
7276
// Restrict "overflow" and "display" styles during box animations
7277
if ( isBox && elem.nodeType === 1 ) {
7278
7279
// Support: IE <=9 - 11, Edge 12 - 15
7280
// Record all 3 overflow attributes because IE does not infer the shorthand
7281
// from identically-valued overflowX and overflowY and Edge just mirrors
7282
// the overflowX value there.
7283
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
7284
7285
// Identify a display type, preferring old show/hide data over the CSS cascade
7286
restoreDisplay = dataShow && dataShow.display;
7287
if ( restoreDisplay == null ) {
7288
restoreDisplay = dataPriv.get( elem, "display" );
7289
}
7290
display = jQuery.css( elem, "display" );
7291
if ( display === "none" ) {
7292
if ( restoreDisplay ) {
7293
display = restoreDisplay;
7294
} else {
7295
7296
// Get nonempty value(s) by temporarily forcing visibility
7297
showHide( [ elem ], true );
7298
restoreDisplay = elem.style.display || restoreDisplay;
7299
display = jQuery.css( elem, "display" );
7300
showHide( [ elem ] );
7301
}
7302
}
7303
7304
// Animate inline elements as inline-block
7305
if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
7306
if ( jQuery.css( elem, "float" ) === "none" ) {
7307
7308
// Restore the original display value at the end of pure show/hide animations
7309
if ( !propTween ) {
7310
anim.done( function() {
7311
style.display = restoreDisplay;
7312
} );
7313
if ( restoreDisplay == null ) {
7314
display = style.display;
7315
restoreDisplay = display === "none" ? "" : display;
7316
}
7317
}
7318
style.display = "inline-block";
7319
}
7320
}
7321
}
7322
7323
if ( opts.overflow ) {
7324
style.overflow = "hidden";
7325
anim.always( function() {
7326
style.overflow = opts.overflow[ 0 ];
7327
style.overflowX = opts.overflow[ 1 ];
7328
style.overflowY = opts.overflow[ 2 ];
7329
} );
7330
}
7331
7332
// Implement show/hide animations
7333
propTween = false;
7334
for ( prop in orig ) {
7335
7336
// General show/hide setup for this element animation
7337
if ( !propTween ) {
7338
if ( dataShow ) {
7339
if ( "hidden" in dataShow ) {
7340
hidden = dataShow.hidden;
7341
}
7342
} else {
7343
dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
7344
}
7345
7346
// Store hidden/visible for toggle so `.stop().toggle()` "reverses"
7347
if ( toggle ) {
7348
dataShow.hidden = !hidden;
7349
}
7350
7351
// Show elements before animating them
7352
if ( hidden ) {
7353
showHide( [ elem ], true );
7354
}
7355
7356
/* eslint-disable no-loop-func */
7357
7358
anim.done( function() {
7359
7360
/* eslint-enable no-loop-func */
7361
7362
// The final step of a "hide" animation is actually hiding the element
7363
if ( !hidden ) {
7364
showHide( [ elem ] );
7365
}
7366
dataPriv.remove( elem, "fxshow" );
7367
for ( prop in orig ) {
7368
jQuery.style( elem, prop, orig[ prop ] );
7369
}
7370
} );
7371
}
7372
7373
// Per-property setup
7374
propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
7375
if ( !( prop in dataShow ) ) {
7376
dataShow[ prop ] = propTween.start;
7377
if ( hidden ) {
7378
propTween.end = propTween.start;
7379
propTween.start = 0;
7380
}
7381
}
7382
}
7383
}
7384
7385
function propFilter( props, specialEasing ) {
7386
var index, name, easing, value, hooks;
7387
7388
// camelCase, specialEasing and expand cssHook pass
7389
for ( index in props ) {
7390
name = camelCase( index );
7391
easing = specialEasing[ name ];
7392
value = props[ index ];
7393
if ( Array.isArray( value ) ) {
7394
easing = value[ 1 ];
7395
value = props[ index ] = value[ 0 ];
7396
}
7397
7398
if ( index !== name ) {
7399
props[ name ] = value;
7400
delete props[ index ];
7401
}
7402
7403
hooks = jQuery.cssHooks[ name ];
7404
if ( hooks && "expand" in hooks ) {
7405
value = hooks.expand( value );
7406
delete props[ name ];
7407
7408
// Not quite $.extend, this won't overwrite existing keys.
7409
// Reusing 'index' because we have the correct "name"
7410
for ( index in value ) {
7411
if ( !( index in props ) ) {
7412
props[ index ] = value[ index ];
7413
specialEasing[ index ] = easing;
7414
}
7415
}
7416
} else {
7417
specialEasing[ name ] = easing;
7418
}
7419
}
7420
}
7421
7422
function Animation( elem, properties, options ) {
7423
var result,
7424
stopped,
7425
index = 0,
7426
length = Animation.prefilters.length,
7427
deferred = jQuery.Deferred().always( function() {
7428
7429
// Don't match elem in the :animated selector
7430
delete tick.elem;
7431
} ),
7432
tick = function() {
7433
if ( stopped ) {
7434
return false;
7435
}
7436
var currentTime = fxNow || createFxNow(),
7437
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7438
7439
// Support: Android 2.3 only
7440
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497)
7441
temp = remaining / animation.duration || 0,
7442
percent = 1 - temp,
7443
index = 0,
7444
length = animation.tweens.length;
7445
7446
for ( ; index < length; index++ ) {
7447
animation.tweens[ index ].run( percent );
7448
}
7449
7450
deferred.notifyWith( elem, [ animation, percent, remaining ] );
7451
7452
// If there's more to do, yield
7453
if ( percent < 1 && length ) {
7454
return remaining;
7455
}
7456
7457
// If this was an empty animation, synthesize a final progress notification
7458
if ( !length ) {
7459
deferred.notifyWith( elem, [ animation, 1, 0 ] );
7460
}
7461
7462
// Resolve the animation and report its conclusion
7463
deferred.resolveWith( elem, [ animation ] );
7464
return false;
7465
},
7466
animation = deferred.promise( {
7467
elem: elem,
7468
props: jQuery.extend( {}, properties ),
7469
opts: jQuery.extend( true, {
7470
specialEasing: {},
7471
easing: jQuery.easing._default
7472
}, options ),
7473
originalProperties: properties,
7474
originalOptions: options,
7475
startTime: fxNow || createFxNow(),
7476
duration: options.duration,
7477
tweens: [],
7478
createTween: function( prop, end ) {
7479
var tween = jQuery.Tween( elem, animation.opts, prop, end,
7480
animation.opts.specialEasing[ prop ] || animation.opts.easing );
7481
animation.tweens.push( tween );
7482
return tween;
7483
},
7484
stop: function( gotoEnd ) {
7485
var index = 0,
7486
7487
// If we are going to the end, we want to run all the tweens
7488
// otherwise we skip this part
7489
length = gotoEnd ? animation.tweens.length : 0;
7490
if ( stopped ) {
7491
return this;
7492
}
7493
stopped = true;
7494
for ( ; index < length; index++ ) {
7495
animation.tweens[ index ].run( 1 );
7496
}
7497
7498
// Resolve when we played the last frame; otherwise, reject
7499
if ( gotoEnd ) {
7500
deferred.notifyWith( elem, [ animation, 1, 0 ] );
7501
deferred.resolveWith( elem, [ animation, gotoEnd ] );
7502
} else {
7503
deferred.rejectWith( elem, [ animation, gotoEnd ] );
7504
}
7505
return this;
7506
}
7507
} ),
7508
props = animation.props;
7509
7510
propFilter( props, animation.opts.specialEasing );
7511
7512
for ( ; index < length; index++ ) {
7513
result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
7514
if ( result ) {
7515
if ( isFunction( result.stop ) ) {
7516
jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
7517
result.stop.bind( result );
7518
}
7519
return result;
7520
}
7521
}
7522
7523
jQuery.map( props, createTween, animation );
7524
7525
if ( isFunction( animation.opts.start ) ) {
7526
animation.opts.start.call( elem, animation );
7527
}
7528
7529
// Attach callbacks from options
7530
animation
7531
.progress( animation.opts.progress )
7532
.done( animation.opts.done, animation.opts.complete )
7533
.fail( animation.opts.fail )
7534
.always( animation.opts.always );
7535
7536
jQuery.fx.timer(
7537
jQuery.extend( tick, {
7538
elem: elem,
7539
anim: animation,
7540
queue: animation.opts.queue
7541
} )
7542
);
7543
7544
return animation;
7545
}
7546
7547
jQuery.Animation = jQuery.extend( Animation, {
7548
7549
tweeners: {
7550
"*": [ function( prop, value ) {
7551
var tween = this.createTween( prop, value );
7552
adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
7553
return tween;
7554
} ]
7555
},
7556
7557
tweener: function( props, callback ) {
7558
if ( isFunction( props ) ) {
7559
callback = props;
7560
props = [ "*" ];
7561
} else {
7562
props = props.match( rnothtmlwhite );
7563
}
7564
7565
var prop,
7566
index = 0,
7567
length = props.length;
7568
7569
for ( ; index < length; index++ ) {
7570
prop = props[ index ];
7571
Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
7572
Animation.tweeners[ prop ].unshift( callback );
7573
}
7574
},
7575
7576
prefilters: [ defaultPrefilter ],
7577
7578
prefilter: function( callback, prepend ) {
7579
if ( prepend ) {
7580
Animation.prefilters.unshift( callback );
7581
} else {
7582
Animation.prefilters.push( callback );
7583
}
7584
}
7585
} );
7586
7587
jQuery.speed = function( speed, easing, fn ) {
7588
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7589
complete: fn || !fn && easing ||
7590
isFunction( speed ) && speed,
7591
duration: speed,
7592
easing: fn && easing || easing && !isFunction( easing ) && easing
7593
};
7594
7595
// Go to the end state if fx are off
7596
if ( jQuery.fx.off ) {
7597
opt.duration = 0;
7598
7599
} else {
7600
if ( typeof opt.duration !== "number" ) {
7601
if ( opt.duration in jQuery.fx.speeds ) {
7602
opt.duration = jQuery.fx.speeds[ opt.duration ];
7603
7604
} else {
7605
opt.duration = jQuery.fx.speeds._default;
7606
}
7607
}
7608
}
7609
7610
// Normalize opt.queue - true/undefined/null -> "fx"
7611
if ( opt.queue == null || opt.queue === true ) {
7612
opt.queue = "fx";
7613
}
7614
7615
// Queueing
7616
opt.old = opt.complete;
7617
7618
opt.complete = function() {
7619
if ( isFunction( opt.old ) ) {
7620
opt.old.call( this );
7621
}
7622
7623
if ( opt.queue ) {
7624
jQuery.dequeue( this, opt.queue );
7625
}
7626
};
7627
7628
return opt;
7629
};
7630
7631
jQuery.fn.extend( {
7632
fadeTo: function( speed, to, easing, callback ) {
7633
7634
// Show any hidden elements after setting opacity to 0
7635
return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
7636
7637
// Animate to the value specified
7638
.end().animate( { opacity: to }, speed, easing, callback );
7639
},
7640
animate: function( prop, speed, easing, callback ) {
7641
var empty = jQuery.isEmptyObject( prop ),
7642
optall = jQuery.speed( speed, easing, callback ),
7643
doAnimation = function() {
7644
7645
// Operate on a copy of prop so per-property easing won't be lost
7646
var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7647
7648
// Empty animations, or finishing resolves immediately
7649
if ( empty || dataPriv.get( this, "finish" ) ) {
7650
anim.stop( true );
7651
}
7652
};
7653
7654
doAnimation.finish = doAnimation;
7655
7656
return empty || optall.queue === false ?
7657
this.each( doAnimation ) :
7658
this.queue( optall.queue, doAnimation );
7659
},
7660
stop: function( type, clearQueue, gotoEnd ) {
7661
var stopQueue = function( hooks ) {
7662
var stop = hooks.stop;
7663
delete hooks.stop;
7664
stop( gotoEnd );
7665
};
7666
7667
if ( typeof type !== "string" ) {
7668
gotoEnd = clearQueue;
7669
clearQueue = type;
7670
type = undefined;
7671
}
7672
if ( clearQueue ) {
7673
this.queue( type || "fx", [] );
7674
}
7675
7676
return this.each( function() {
7677
var dequeue = true,
7678
index = type != null && type + "queueHooks",
7679
timers = jQuery.timers,
7680
data = dataPriv.get( this );
7681
7682
if ( index ) {
7683
if ( data[ index ] && data[ index ].stop ) {
7684
stopQueue( data[ index ] );
7685
}
7686
} else {
7687
for ( index in data ) {
7688
if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7689
stopQueue( data[ index ] );
7690
}
7691
}
7692
}
7693
7694
for ( index = timers.length; index--; ) {
7695
if ( timers[ index ].elem === this &&
7696
( type == null || timers[ index ].queue === type ) ) {
7697
7698
timers[ index ].anim.stop( gotoEnd );
7699
dequeue = false;
7700
timers.splice( index, 1 );
7701
}
7702
}
7703
7704
// Start the next in the queue if the last step wasn't forced.
7705
// Timers currently will call their complete callbacks, which
7706
// will dequeue but only if they were gotoEnd.
7707
if ( dequeue || !gotoEnd ) {
7708
jQuery.dequeue( this, type );
7709
}
7710
} );
7711
},
7712
finish: function( type ) {
7713
if ( type !== false ) {
7714
type = type || "fx";
7715
}
7716
return this.each( function() {
7717
var index,
7718
data = dataPriv.get( this ),
7719
queue = data[ type + "queue" ],
7720
hooks = data[ type + "queueHooks" ],
7721
timers = jQuery.timers,
7722
length = queue ? queue.length : 0;
7723
7724
// Enable finishing flag on private data
7725
data.finish = true;
7726
7727
// Empty the queue first
7728
jQuery.queue( this, type, [] );
7729
7730
if ( hooks && hooks.stop ) {
7731
hooks.stop.call( this, true );
7732
}
7733
7734
// Look for any active animations, and finish them
7735
for ( index = timers.length; index--; ) {
7736
if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
7737
timers[ index ].anim.stop( true );
7738
timers.splice( index, 1 );
7739
}
7740
}
7741
7742
// Look for any animations in the old queue and finish them
7743
for ( index = 0; index < length; index++ ) {
7744
if ( queue[ index ] && queue[ index ].finish ) {
7745
queue[ index ].finish.call( this );
7746
}
7747
}
7748
7749
// Turn off finishing flag
7750
delete data.finish;
7751
} );
7752
}
7753
} );
7754
7755
jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
7756
var cssFn = jQuery.fn[ name ];
7757
jQuery.fn[ name ] = function( speed, easing, callback ) {
7758
return speed == null || typeof speed === "boolean" ?
7759
cssFn.apply( this, arguments ) :
7760
this.animate( genFx( name, true ), speed, easing, callback );
7761
};
7762
} );
7763
7764
// Generate shortcuts for custom animations
7765
jQuery.each( {
7766
slideDown: genFx( "show" ),
7767
slideUp: genFx( "hide" ),
7768
slideToggle: genFx( "toggle" ),
7769
fadeIn: { opacity: "show" },
7770
fadeOut: { opacity: "hide" },
7771
fadeToggle: { opacity: "toggle" }
7772
}, function( name, props ) {
7773
jQuery.fn[ name ] = function( speed, easing, callback ) {
7774
return this.animate( props, speed, easing, callback );
7775
};
7776
} );
7777
7778
jQuery.timers = [];
7779
jQuery.fx.tick = function() {
7780
var timer,
7781
i = 0,
7782
timers = jQuery.timers;
7783
7784
fxNow = Date.now();
7785
7786
for ( ; i < timers.length; i++ ) {
7787
timer = timers[ i ];
7788
7789
// Run the timer and safely remove it when done (allowing for external removal)
7790
if ( !timer() && timers[ i ] === timer ) {
7791
timers.splice( i--, 1 );
7792
}
7793
}
7794
7795
if ( !timers.length ) {
7796
jQuery.fx.stop();
7797
}
7798
fxNow = undefined;
7799
};
7800
7801
jQuery.fx.timer = function( timer ) {
7802
jQuery.timers.push( timer );
7803
jQuery.fx.start();
7804
};
7805
7806
jQuery.fx.interval = 13;
7807
jQuery.fx.start = function() {
7808
if ( inProgress ) {
7809
return;
7810
}
7811
7812
inProgress = true;
7813
schedule();
7814
};
7815
7816
jQuery.fx.stop = function() {
7817
inProgress = null;
7818
};
7819
7820
jQuery.fx.speeds = {
7821
slow: 600,
7822
fast: 200,
7823
7824
// Default speed
7825
_default: 400
7826
};
7827
7828
7829
// Based off of the plugin by Clint Helfers, with permission.
7830
jQuery.fn.delay = function( time, type ) {
7831
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
7832
type = type || "fx";
7833
7834
return this.queue( type, function( next, hooks ) {
7835
var timeout = window.setTimeout( next, time );
7836
hooks.stop = function() {
7837
window.clearTimeout( timeout );
7838
};
7839
} );
7840
};
7841
7842
7843
( function() {
7844
var input = document.createElement( "input" ),
7845
select = document.createElement( "select" ),
7846
opt = select.appendChild( document.createElement( "option" ) );
7847
7848
input.type = "checkbox";
7849
7850
// Support: Android <=4.3 only
7851
// Default value for a checkbox should be "on"
7852
support.checkOn = input.value !== "";
7853
7854
// Support: IE <=11 only
7855
// Must access selectedIndex to make default options select
7856
support.optSelected = opt.selected;
7857
7858
// Support: IE <=11 only
7859
// An input loses its value after becoming a radio
7860
input = document.createElement( "input" );
7861
input.value = "t";
7862
input.type = "radio";
7863
support.radioValue = input.value === "t";
7864
} )();
7865
7866
7867
var boolHook,
7868
attrHandle = jQuery.expr.attrHandle;
7869
7870
jQuery.fn.extend( {
7871
attr: function( name, value ) {
7872
return access( this, jQuery.attr, name, value, arguments.length > 1 );
7873
},
7874
7875
removeAttr: function( name ) {
7876
return this.each( function() {
7877
jQuery.removeAttr( this, name );
7878
} );
7879
}
7880
} );
7881
7882
jQuery.extend( {
7883
attr: function( elem, name, value ) {
7884
var ret, hooks,
7885
nType = elem.nodeType;
7886
7887
// Don't get/set attributes on text, comment and attribute nodes
7888
if ( nType === 3 || nType === 8 || nType === 2 ) {
7889
return;
7890
}
7891
7892
// Fallback to prop when attributes are not supported
7893
if ( typeof elem.getAttribute === "undefined" ) {
7894
return jQuery.prop( elem, name, value );
7895
}
7896
7897
// Attribute hooks are determined by the lowercase version
7898
// Grab necessary hook if one is defined
7899
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7900
hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
7901
( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
7902
}
7903
7904
if ( value !== undefined ) {
7905
if ( value === null ) {
7906
jQuery.removeAttr( elem, name );
7907
return;
7908
}
7909
7910
if ( hooks && "set" in hooks &&
7911
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
7912
return ret;
7913
}
7914
7915
elem.setAttribute( name, value + "" );
7916
return value;
7917
}
7918
7919
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
7920
return ret;
7921
}
7922
7923
ret = jQuery.find.attr( elem, name );
7924
7925
// Non-existent attributes return null, we normalize to undefined
7926
return ret == null ? undefined : ret;
7927
},
7928
7929
attrHooks: {
7930
type: {
7931
set: function( elem, value ) {
7932
if ( !support.radioValue && value === "radio" &&
7933
nodeName( elem, "input" ) ) {
7934
var val = elem.value;
7935
elem.setAttribute( "type", value );
7936
if ( val ) {
7937
elem.value = val;
7938
}
7939
return value;
7940
}
7941
}
7942
}
7943
},
7944
7945
removeAttr: function( elem, value ) {
7946
var name,
7947
i = 0,
7948
7949
// Attribute names can contain non-HTML whitespace characters
7950
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
7951
attrNames = value && value.match( rnothtmlwhite );
7952
7953
if ( attrNames && elem.nodeType === 1 ) {
7954
while ( ( name = attrNames[ i++ ] ) ) {
7955
elem.removeAttribute( name );
7956
}
7957
}
7958
}
7959
} );
7960
7961
// Hooks for boolean attributes
7962
boolHook = {
7963
set: function( elem, value, name ) {
7964
if ( value === false ) {
7965
7966
// Remove boolean attributes when set to false
7967
jQuery.removeAttr( elem, name );
7968
} else {
7969
elem.setAttribute( name, name );
7970
}
7971
return name;
7972
}
7973
};
7974
7975
jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
7976
var getter = attrHandle[ name ] || jQuery.find.attr;
7977
7978
attrHandle[ name ] = function( elem, name, isXML ) {
7979
var ret, handle,
7980
lowercaseName = name.toLowerCase();
7981
7982
if ( !isXML ) {
7983
7984
// Avoid an infinite loop by temporarily removing this function from the getter
7985
handle = attrHandle[ lowercaseName ];
7986
attrHandle[ lowercaseName ] = ret;
7987
ret = getter( elem, name, isXML ) != null ?
7988
lowercaseName :
7989
null;
7990
attrHandle[ lowercaseName ] = handle;
7991
}
7992
return ret;
7993
};
7994
} );
7995
7996
7997
7998
7999
var rfocusable = /^(?:input|select|textarea|button)$/i,
8000
rclickable = /^(?:a|area)$/i;
8001
8002
jQuery.fn.extend( {
8003
prop: function( name, value ) {
8004
return access( this, jQuery.prop, name, value, arguments.length > 1 );
8005
},
8006
8007
removeProp: function( name ) {
8008
return this.each( function() {
8009
delete this[ jQuery.propFix[ name ] || name ];
8010
} );
8011
}
8012
} );
8013
8014
jQuery.extend( {
8015
prop: function( elem, name, value ) {
8016
var ret, hooks,
8017
nType = elem.nodeType;
8018
8019
// Don't get/set properties on text, comment and attribute nodes
8020
if ( nType === 3 || nType === 8 || nType === 2 ) {
8021
return;
8022
}
8023
8024
if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
8025
8026
// Fix name and attach hooks
8027
name = jQuery.propFix[ name ] || name;
8028
hooks = jQuery.propHooks[ name ];
8029
}
8030
8031
if ( value !== undefined ) {
8032
if ( hooks && "set" in hooks &&
8033
( ret = hooks.set( elem, value, name ) ) !== undefined ) {
8034
return ret;
8035
}
8036
8037
return ( elem[ name ] = value );
8038
}
8039
8040
if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
8041
return ret;
8042
}
8043
8044
return elem[ name ];
8045
},
8046
8047
propHooks: {
8048
tabIndex: {
8049
get: function( elem ) {
8050
8051
// Support: IE <=9 - 11 only
8052
// elem.tabIndex doesn't always return the
8053
// correct value when it hasn't been explicitly set
8054
// Use proper attribute retrieval (trac-12072)
8055
var tabindex = jQuery.find.attr( elem, "tabindex" );
8056
8057
if ( tabindex ) {
8058
return parseInt( tabindex, 10 );
8059
}
8060
8061
if (
8062
rfocusable.test( elem.nodeName ) ||
8063
rclickable.test( elem.nodeName ) &&
8064
elem.href
8065
) {
8066
return 0;
8067
}
8068
8069
return -1;
8070
}
8071
}
8072
},
8073
8074
propFix: {
8075
"for": "htmlFor",
8076
"class": "className"
8077
}
8078
} );
8079
8080
// Support: IE <=11 only
8081
// Accessing the selectedIndex property
8082
// forces the browser to respect setting selected
8083
// on the option
8084
// The getter ensures a default option is selected
8085
// when in an optgroup
8086
// eslint rule "no-unused-expressions" is disabled for this code
8087
// since it considers such accessions noop
8088
if ( !support.optSelected ) {
8089
jQuery.propHooks.selected = {
8090
get: function( elem ) {
8091
8092
/* eslint no-unused-expressions: "off" */
8093
8094
var parent = elem.parentNode;
8095
if ( parent && parent.parentNode ) {
8096
parent.parentNode.selectedIndex;
8097
}
8098
return null;
8099
},
8100
set: function( elem ) {
8101
8102
/* eslint no-unused-expressions: "off" */
8103
8104
var parent = elem.parentNode;
8105
if ( parent ) {
8106
parent.selectedIndex;
8107
8108
if ( parent.parentNode ) {
8109
parent.parentNode.selectedIndex;
8110
}
8111
}
8112
}
8113
};
8114
}
8115
8116
jQuery.each( [
8117
"tabIndex",
8118
"readOnly",
8119
"maxLength",
8120
"cellSpacing",
8121
"cellPadding",
8122
"rowSpan",
8123
"colSpan",
8124
"useMap",
8125
"frameBorder",
8126
"contentEditable"
8127
], function() {
8128
jQuery.propFix[ this.toLowerCase() ] = this;
8129
} );
8130
8131
8132
8133
8134
// Strip and collapse whitespace according to HTML spec
8135
// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
8136
function stripAndCollapse( value ) {
8137
var tokens = value.match( rnothtmlwhite ) || [];
8138
return tokens.join( " " );
8139
}
8140
8141
8142
function getClass( elem ) {
8143
return elem.getAttribute && elem.getAttribute( "class" ) || "";
8144
}
8145
8146
function classesToArray( value ) {
8147
if ( Array.isArray( value ) ) {
8148
return value;
8149
}
8150
if ( typeof value === "string" ) {
8151
return value.match( rnothtmlwhite ) || [];
8152
}
8153
return [];
8154
}
8155
8156
jQuery.fn.extend( {
8157
addClass: function( value ) {
8158
var classNames, cur, curValue, className, i, finalValue;
8159
8160
if ( isFunction( value ) ) {
8161
return this.each( function( j ) {
8162
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
8163
} );
8164
}
8165
8166
classNames = classesToArray( value );
8167
8168
if ( classNames.length ) {
8169
return this.each( function() {
8170
curValue = getClass( this );
8171
cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
8172
8173
if ( cur ) {
8174
for ( i = 0; i < classNames.length; i++ ) {
8175
className = classNames[ i ];
8176
if ( cur.indexOf( " " + className + " " ) < 0 ) {
8177
cur += className + " ";
8178
}
8179
}
8180
8181
// Only assign if different to avoid unneeded rendering.
8182
finalValue = stripAndCollapse( cur );
8183
if ( curValue !== finalValue ) {
8184
this.setAttribute( "class", finalValue );
8185
}
8186
}
8187
} );
8188
}
8189
8190
return this;
8191
},
8192
8193
removeClass: function( value ) {
8194
var classNames, cur, curValue, className, i, finalValue;
8195
8196
if ( isFunction( value ) ) {
8197
return this.each( function( j ) {
8198
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
8199
} );
8200
}
8201
8202
if ( !arguments.length ) {
8203
return this.attr( "class", "" );
8204
}
8205
8206
classNames = classesToArray( value );
8207
8208
if ( classNames.length ) {
8209
return this.each( function() {
8210
curValue = getClass( this );
8211
8212
// This expression is here for better compressibility (see addClass)
8213
cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
8214
8215
if ( cur ) {
8216
for ( i = 0; i < classNames.length; i++ ) {
8217
className = classNames[ i ];
8218
8219
// Remove *all* instances
8220
while ( cur.indexOf( " " + className + " " ) > -1 ) {
8221
cur = cur.replace( " " + className + " ", " " );
8222
}
8223
}
8224
8225
// Only assign if different to avoid unneeded rendering.
8226
finalValue = stripAndCollapse( cur );
8227
if ( curValue !== finalValue ) {
8228
this.setAttribute( "class", finalValue );
8229
}
8230
}
8231
} );
8232
}
8233
8234
return this;
8235
},
8236
8237
toggleClass: function( value, stateVal ) {
8238
var classNames, className, i, self,
8239
type = typeof value,
8240
isValidValue = type === "string" || Array.isArray( value );
8241
8242
if ( isFunction( value ) ) {
8243
return this.each( function( i ) {
8244
jQuery( this ).toggleClass(
8245
value.call( this, i, getClass( this ), stateVal ),
8246
stateVal
8247
);
8248
} );
8249
}
8250
8251
if ( typeof stateVal === "boolean" && isValidValue ) {
8252
return stateVal ? this.addClass( value ) : this.removeClass( value );
8253
}
8254
8255
classNames = classesToArray( value );
8256
8257
return this.each( function() {
8258
if ( isValidValue ) {
8259
8260
// Toggle individual class names
8261
self = jQuery( this );
8262
8263
for ( i = 0; i < classNames.length; i++ ) {
8264
className = classNames[ i ];
8265
8266
// Check each className given, space separated list
8267
if ( self.hasClass( className ) ) {
8268
self.removeClass( className );
8269
} else {
8270
self.addClass( className );
8271
}
8272
}
8273
8274
// Toggle whole class name
8275
} else if ( value === undefined || type === "boolean" ) {
8276
className = getClass( this );
8277
if ( className ) {
8278
8279
// Store className if set
8280
dataPriv.set( this, "__className__", className );
8281
}
8282
8283
// If the element has a class name or if we're passed `false`,
8284
// then remove the whole classname (if there was one, the above saved it).
8285
// Otherwise bring back whatever was previously saved (if anything),
8286
// falling back to the empty string if nothing was stored.
8287
if ( this.setAttribute ) {
8288
this.setAttribute( "class",
8289
className || value === false ?
8290
"" :
8291
dataPriv.get( this, "__className__" ) || ""
8292
);
8293
}
8294
}
8295
} );
8296
},
8297
8298
hasClass: function( selector ) {
8299
var className, elem,
8300
i = 0;
8301
8302
className = " " + selector + " ";
8303
while ( ( elem = this[ i++ ] ) ) {
8304
if ( elem.nodeType === 1 &&
8305
( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
8306
return true;
8307
}
8308
}
8309
8310
return false;
8311
}
8312
} );
8313
8314
8315
8316
8317
var rreturn = /\r/g;
8318
8319
jQuery.fn.extend( {
8320
val: function( value ) {
8321
var hooks, ret, valueIsFunction,
8322
elem = this[ 0 ];
8323
8324
if ( !arguments.length ) {
8325
if ( elem ) {
8326
hooks = jQuery.valHooks[ elem.type ] ||
8327
jQuery.valHooks[ elem.nodeName.toLowerCase() ];
8328
8329
if ( hooks &&
8330
"get" in hooks &&
8331
( ret = hooks.get( elem, "value" ) ) !== undefined
8332
) {
8333
return ret;
8334
}
8335
8336
ret = elem.value;
8337
8338
// Handle most common string cases
8339
if ( typeof ret === "string" ) {
8340
return ret.replace( rreturn, "" );
8341
}
8342
8343
// Handle cases where value is null/undef or number
8344
return ret == null ? "" : ret;
8345
}
8346
8347
return;
8348
}
8349
8350
valueIsFunction = isFunction( value );
8351
8352
return this.each( function( i ) {
8353
var val;
8354
8355
if ( this.nodeType !== 1 ) {
8356
return;
8357
}
8358
8359
if ( valueIsFunction ) {
8360
val = value.call( this, i, jQuery( this ).val() );
8361
} else {
8362
val = value;
8363
}
8364
8365
// Treat null/undefined as ""; convert numbers to string
8366
if ( val == null ) {
8367
val = "";
8368
8369
} else if ( typeof val === "number" ) {
8370
val += "";
8371
8372
} else if ( Array.isArray( val ) ) {
8373
val = jQuery.map( val, function( value ) {
8374
return value == null ? "" : value + "";
8375
} );
8376
}
8377
8378
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
8379
8380
// If set returns undefined, fall back to normal setting
8381
if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
8382
this.value = val;
8383
}
8384
} );
8385
}
8386
} );
8387
8388
jQuery.extend( {
8389
valHooks: {
8390
option: {
8391
get: function( elem ) {
8392
8393
var val = jQuery.find.attr( elem, "value" );
8394
return val != null ?
8395
val :
8396
8397
// Support: IE <=10 - 11 only
8398
// option.text throws exceptions (trac-14686, trac-14858)
8399
// Strip and collapse whitespace
8400
// https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8401
stripAndCollapse( jQuery.text( elem ) );
8402
}
8403
},
8404
select: {
8405
get: function( elem ) {
8406
var value, option, i,
8407
options = elem.options,
8408
index = elem.selectedIndex,
8409
one = elem.type === "select-one",
8410
values = one ? null : [],
8411
max = one ? index + 1 : options.length;
8412
8413
if ( index < 0 ) {
8414
i = max;
8415
8416
} else {
8417
i = one ? index : 0;
8418
}
8419
8420
// Loop through all the selected options
8421
for ( ; i < max; i++ ) {
8422
option = options[ i ];
8423
8424
// Support: IE <=9 only
8425
// IE8-9 doesn't update selected after form reset (trac-2551)
8426
if ( ( option.selected || i === index ) &&
8427
8428
// Don't return options that are disabled or in a disabled optgroup
8429
!option.disabled &&
8430
( !option.parentNode.disabled ||
8431
!nodeName( option.parentNode, "optgroup" ) ) ) {
8432
8433
// Get the specific value for the option
8434
value = jQuery( option ).val();
8435
8436
// We don't need an array for one selects
8437
if ( one ) {
8438
return value;
8439
}
8440
8441
// Multi-Selects return an array
8442
values.push( value );
8443
}
8444
}
8445
8446
return values;
8447
},
8448
8449
set: function( elem, value ) {
8450
var optionSet, option,
8451
options = elem.options,
8452
values = jQuery.makeArray( value ),
8453
i = options.length;
8454
8455
while ( i-- ) {
8456
option = options[ i ];
8457
8458
/* eslint-disable no-cond-assign */
8459
8460
if ( option.selected =
8461
jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
8462
) {
8463
optionSet = true;
8464
}
8465
8466
/* eslint-enable no-cond-assign */
8467
}
8468
8469
// Force browsers to behave consistently when non-matching value is set
8470
if ( !optionSet ) {
8471
elem.selectedIndex = -1;
8472
}
8473
return values;
8474
}
8475
}
8476
}
8477
} );
8478
8479
// Radios and checkboxes getter/setter
8480
jQuery.each( [ "radio", "checkbox" ], function() {
8481
jQuery.valHooks[ this ] = {
8482
set: function( elem, value ) {
8483
if ( Array.isArray( value ) ) {
8484
return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
8485
}
8486
}
8487
};
8488
if ( !support.checkOn ) {
8489
jQuery.valHooks[ this ].get = function( elem ) {
8490
return elem.getAttribute( "value" ) === null ? "on" : elem.value;
8491
};
8492
}
8493
} );
8494
8495
8496
8497
8498
// Return jQuery for attributes-only inclusion
8499
var location = window.location;
8500
8501
var nonce = { guid: Date.now() };
8502
8503
var rquery = ( /\?/ );
8504
8505
8506
8507
// Cross-browser xml parsing
8508
jQuery.parseXML = function( data ) {
8509
var xml, parserErrorElem;
8510
if ( !data || typeof data !== "string" ) {
8511
return null;
8512
}
8513
8514
// Support: IE 9 - 11 only
8515
// IE throws on parseFromString with invalid input.
8516
try {
8517
xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
8518
} catch ( e ) {}
8519
8520
parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
8521
if ( !xml || parserErrorElem ) {
8522
jQuery.error( "Invalid XML: " + (
8523
parserErrorElem ?
8524
jQuery.map( parserErrorElem.childNodes, function( el ) {
8525
return el.textContent;
8526
} ).join( "\n" ) :
8527
data
8528
) );
8529
}
8530
return xml;
8531
};
8532
8533
8534
var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
8535
stopPropagationCallback = function( e ) {
8536
e.stopPropagation();
8537
};
8538
8539
jQuery.extend( jQuery.event, {
8540
8541
trigger: function( event, data, elem, onlyHandlers ) {
8542
8543
var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
8544
eventPath = [ elem || document ],
8545
type = hasOwn.call( event, "type" ) ? event.type : event,
8546
namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
8547
8548
cur = lastElement = tmp = elem = elem || document;
8549
8550
// Don't do events on text and comment nodes
8551
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
8552
return;
8553
}
8554
8555
// focus/blur morphs to focusin/out; ensure we're not firing them right now
8556
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
8557
return;
8558
}
8559
8560
if ( type.indexOf( "." ) > -1 ) {
8561
8562
// Namespaced trigger; create a regexp to match event type in handle()
8563
namespaces = type.split( "." );
8564
type = namespaces.shift();
8565
namespaces.sort();
8566
}
8567
ontype = type.indexOf( ":" ) < 0 && "on" + type;
8568
8569
// Caller can pass in a jQuery.Event object, Object, or just an event type string
8570
event = event[ jQuery.expando ] ?
8571
event :
8572
new jQuery.Event( type, typeof event === "object" && event );
8573
8574
// Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8575
event.isTrigger = onlyHandlers ? 2 : 3;
8576
event.namespace = namespaces.join( "." );
8577
event.rnamespace = event.namespace ?
8578
new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8579
null;
8580
8581
// Clean up the event in case it is being reused
8582
event.result = undefined;
8583
if ( !event.target ) {
8584
event.target = elem;
8585
}
8586
8587
// Clone any incoming data and prepend the event, creating the handler arg list
8588
data = data == null ?
8589
[ event ] :
8590
jQuery.makeArray( data, [ event ] );
8591
8592
// Allow special events to draw outside the lines
8593
special = jQuery.event.special[ type ] || {};
8594
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
8595
return;
8596
}
8597
8598
// Determine event propagation path in advance, per W3C events spec (trac-9951)
8599
// Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)
8600
if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
8601
8602
bubbleType = special.delegateType || type;
8603
if ( !rfocusMorph.test( bubbleType + type ) ) {
8604
cur = cur.parentNode;
8605
}
8606
for ( ; cur; cur = cur.parentNode ) {
8607
eventPath.push( cur );
8608
tmp = cur;
8609
}
8610
8611
// Only add window if we got to document (e.g., not plain obj or detached DOM)
8612
if ( tmp === ( elem.ownerDocument || document ) ) {
8613
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
8614
}
8615
}
8616
8617
// Fire handlers on the event path
8618
i = 0;
8619
while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
8620
lastElement = cur;
8621
event.type = i > 1 ?
8622
bubbleType :
8623
special.bindType || type;
8624
8625
// jQuery handler
8626
handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
8627
dataPriv.get( cur, "handle" );
8628
if ( handle ) {
8629
handle.apply( cur, data );
8630
}
8631
8632
// Native handler
8633
handle = ontype && cur[ ontype ];
8634
if ( handle && handle.apply && acceptData( cur ) ) {
8635
event.result = handle.apply( cur, data );
8636
if ( event.result === false ) {
8637
event.preventDefault();
8638
}
8639
}
8640
}
8641
event.type = type;
8642
8643
// If nobody prevented the default action, do it now
8644
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
8645
8646
if ( ( !special._default ||
8647
special._default.apply( eventPath.pop(), data ) === false ) &&
8648
acceptData( elem ) ) {
8649
8650
// Call a native DOM method on the target with the same name as the event.
8651
// Don't do default actions on window, that's where global variables be (trac-6170)
8652
if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
8653
8654
// Don't re-trigger an onFOO event when we call its FOO() method
8655
tmp = elem[ ontype ];
8656
8657
if ( tmp ) {
8658
elem[ ontype ] = null;
8659
}
8660
8661
// Prevent re-triggering of the same event, since we already bubbled it above
8662
jQuery.event.triggered = type;
8663
8664
if ( event.isPropagationStopped() ) {
8665
lastElement.addEventListener( type, stopPropagationCallback );
8666
}
8667
8668
elem[ type ]();
8669
8670
if ( event.isPropagationStopped() ) {
8671
lastElement.removeEventListener( type, stopPropagationCallback );
8672
}
8673
8674
jQuery.event.triggered = undefined;
8675
8676
if ( tmp ) {
8677
elem[ ontype ] = tmp;
8678
}
8679
}
8680
}
8681
}
8682
8683
return event.result;
8684
},
8685
8686
// Piggyback on a donor event to simulate a different one
8687
// Used only for `focus(in | out)` events
8688
simulate: function( type, elem, event ) {
8689
var e = jQuery.extend(
8690
new jQuery.Event(),
8691
event,
8692
{
8693
type: type,
8694
isSimulated: true
8695
}
8696
);
8697
8698
jQuery.event.trigger( e, null, elem );
8699
}
8700
8701
} );
8702
8703
jQuery.fn.extend( {
8704
8705
trigger: function( type, data ) {
8706
return this.each( function() {
8707
jQuery.event.trigger( type, data, this );
8708
} );
8709
},
8710
triggerHandler: function( type, data ) {
8711
var elem = this[ 0 ];
8712
if ( elem ) {
8713
return jQuery.event.trigger( type, data, elem, true );
8714
}
8715
}
8716
} );
8717
8718
8719
var
8720
rbracket = /\[\]$/,
8721
rCRLF = /\r?\n/g,
8722
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
8723
rsubmittable = /^(?:input|select|textarea|keygen)/i;
8724
8725
function buildParams( prefix, obj, traditional, add ) {
8726
var name;
8727
8728
if ( Array.isArray( obj ) ) {
8729
8730
// Serialize array item.
8731
jQuery.each( obj, function( i, v ) {
8732
if ( traditional || rbracket.test( prefix ) ) {
8733
8734
// Treat each array item as a scalar.
8735
add( prefix, v );
8736
8737
} else {
8738
8739
// Item is non-scalar (array or object), encode its numeric index.
8740
buildParams(
8741
prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
8742
v,
8743
traditional,
8744
add
8745
);
8746
}
8747
} );
8748
8749
} else if ( !traditional && toType( obj ) === "object" ) {
8750
8751
// Serialize object item.
8752
for ( name in obj ) {
8753
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
8754
}
8755
8756
} else {
8757
8758
// Serialize scalar item.
8759
add( prefix, obj );
8760
}
8761
}
8762
8763
// Serialize an array of form elements or a set of
8764
// key/values into a query string
8765
jQuery.param = function( a, traditional ) {
8766
var prefix,
8767
s = [],
8768
add = function( key, valueOrFunction ) {
8769
8770
// If value is a function, invoke it and use its return value
8771
var value = isFunction( valueOrFunction ) ?
8772
valueOrFunction() :
8773
valueOrFunction;
8774
8775
s[ s.length ] = encodeURIComponent( key ) + "=" +
8776
encodeURIComponent( value == null ? "" : value );
8777
};
8778
8779
if ( a == null ) {
8780
return "";
8781
}
8782
8783
// If an array was passed in, assume that it is an array of form elements.
8784
if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
8785
8786
// Serialize the form elements
8787
jQuery.each( a, function() {
8788
add( this.name, this.value );
8789
} );
8790
8791
} else {
8792
8793
// If traditional, encode the "old" way (the way 1.3.2 or older
8794
// did it), otherwise encode params recursively.
8795
for ( prefix in a ) {
8796
buildParams( prefix, a[ prefix ], traditional, add );
8797
}
8798
}
8799
8800
// Return the resulting serialization
8801
return s.join( "&" );
8802
};
8803
8804
jQuery.fn.extend( {
8805
serialize: function() {
8806
return jQuery.param( this.serializeArray() );
8807
},
8808
serializeArray: function() {
8809
return this.map( function() {
8810
8811
// Can add propHook for "elements" to filter or add form elements
8812
var elements = jQuery.prop( this, "elements" );
8813
return elements ? jQuery.makeArray( elements ) : this;
8814
} ).filter( function() {
8815
var type = this.type;
8816
8817
// Use .is( ":disabled" ) so that fieldset[disabled] works
8818
return this.name && !jQuery( this ).is( ":disabled" ) &&
8819
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
8820
( this.checked || !rcheckableType.test( type ) );
8821
} ).map( function( _i, elem ) {
8822
var val = jQuery( this ).val();
8823
8824
if ( val == null ) {
8825
return null;
8826
}
8827
8828
if ( Array.isArray( val ) ) {
8829
return jQuery.map( val, function( val ) {
8830
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8831
} );
8832
}
8833
8834
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8835
} ).get();
8836
}
8837
} );
8838
8839
8840
var
8841
r20 = /%20/g,
8842
rhash = /#.*$/,
8843
rantiCache = /([?&])_=[^&]*/,
8844
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
8845
8846
// trac-7653, trac-8125, trac-8152: local protocol detection
8847
rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8848
rnoContent = /^(?:GET|HEAD)$/,
8849
rprotocol = /^\/\//,
8850
8851
/* Prefilters
8852
* 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8853
* 2) These are called:
8854
* - BEFORE asking for a transport
8855
* - AFTER param serialization (s.data is a string if s.processData is true)
8856
* 3) key is the dataType
8857
* 4) the catchall symbol "*" can be used
8858
* 5) execution will start with transport dataType and THEN continue down to "*" if needed
8859
*/
8860
prefilters = {},
8861
8862
/* Transports bindings
8863
* 1) key is the dataType
8864
* 2) the catchall symbol "*" can be used
8865
* 3) selection will start with transport dataType and THEN go to "*" if needed
8866
*/
8867
transports = {},
8868
8869
// Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression
8870
allTypes = "*/".concat( "*" ),
8871
8872
// Anchor tag for parsing the document origin
8873
originAnchor = document.createElement( "a" );
8874
8875
originAnchor.href = location.href;
8876
8877
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8878
function addToPrefiltersOrTransports( structure ) {
8879
8880
// dataTypeExpression is optional and defaults to "*"
8881
return function( dataTypeExpression, func ) {
8882
8883
if ( typeof dataTypeExpression !== "string" ) {
8884
func = dataTypeExpression;
8885
dataTypeExpression = "*";
8886
}
8887
8888
var dataType,
8889
i = 0,
8890
dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
8891
8892
if ( isFunction( func ) ) {
8893
8894
// For each dataType in the dataTypeExpression
8895
while ( ( dataType = dataTypes[ i++ ] ) ) {
8896
8897
// Prepend if requested
8898
if ( dataType[ 0 ] === "+" ) {
8899
dataType = dataType.slice( 1 ) || "*";
8900
( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
8901
8902
// Otherwise append
8903
} else {
8904
( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
8905
}
8906
}
8907
}
8908
};
8909
}
8910
8911
// Base inspection function for prefilters and transports
8912
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
8913
8914
var inspected = {},
8915
seekingTransport = ( structure === transports );
8916
8917
function inspect( dataType ) {
8918
var selected;
8919
inspected[ dataType ] = true;
8920
jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
8921
var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
8922
if ( typeof dataTypeOrTransport === "string" &&
8923
!seekingTransport && !inspected[ dataTypeOrTransport ] ) {
8924
8925
options.dataTypes.unshift( dataTypeOrTransport );
8926
inspect( dataTypeOrTransport );
8927
return false;
8928
} else if ( seekingTransport ) {
8929
return !( selected = dataTypeOrTransport );
8930
}
8931
} );
8932
return selected;
8933
}
8934
8935
return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
8936
}
8937
8938
// A special extend for ajax options
8939
// that takes "flat" options (not to be deep extended)
8940
// Fixes trac-9887
8941
function ajaxExtend( target, src ) {
8942
var key, deep,
8943
flatOptions = jQuery.ajaxSettings.flatOptions || {};
8944
8945
for ( key in src ) {
8946
if ( src[ key ] !== undefined ) {
8947
( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
8948
}
8949
}
8950
if ( deep ) {
8951
jQuery.extend( true, target, deep );
8952
}
8953
8954
return target;
8955
}
8956
8957
/* Handles responses to an ajax request:
8958
* - finds the right dataType (mediates between content-type and expected dataType)
8959
* - returns the corresponding response
8960
*/
8961
function ajaxHandleResponses( s, jqXHR, responses ) {
8962
8963
var ct, type, finalDataType, firstDataType,
8964
contents = s.contents,
8965
dataTypes = s.dataTypes;
8966
8967
// Remove auto dataType and get content-type in the process
8968
while ( dataTypes[ 0 ] === "*" ) {
8969
dataTypes.shift();
8970
if ( ct === undefined ) {
8971
ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
8972
}
8973
}
8974
8975
// Check if we're dealing with a known content-type
8976
if ( ct ) {
8977
for ( type in contents ) {
8978
if ( contents[ type ] && contents[ type ].test( ct ) ) {
8979
dataTypes.unshift( type );
8980
break;
8981
}
8982
}
8983
}
8984
8985
// Check to see if we have a response for the expected dataType
8986
if ( dataTypes[ 0 ] in responses ) {
8987
finalDataType = dataTypes[ 0 ];
8988
} else {
8989
8990
// Try convertible dataTypes
8991
for ( type in responses ) {
8992
if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
8993
finalDataType = type;
8994
break;
8995
}
8996
if ( !firstDataType ) {
8997
firstDataType = type;
8998
}
8999
}
9000
9001
// Or just use first one
9002
finalDataType = finalDataType || firstDataType;
9003
}
9004
9005
// If we found a dataType
9006
// We add the dataType to the list if needed
9007
// and return the corresponding response
9008
if ( finalDataType ) {
9009
if ( finalDataType !== dataTypes[ 0 ] ) {
9010
dataTypes.unshift( finalDataType );
9011
}
9012
return responses[ finalDataType ];
9013
}
9014
}
9015
9016
/* Chain conversions given the request and the original response
9017
* Also sets the responseXXX fields on the jqXHR instance
9018
*/
9019
function ajaxConvert( s, response, jqXHR, isSuccess ) {
9020
var conv2, current, conv, tmp, prev,
9021
converters = {},
9022
9023
// Work with a copy of dataTypes in case we need to modify it for conversion
9024
dataTypes = s.dataTypes.slice();
9025
9026
// Create converters map with lowercased keys
9027
if ( dataTypes[ 1 ] ) {
9028
for ( conv in s.converters ) {
9029
converters[ conv.toLowerCase() ] = s.converters[ conv ];
9030
}
9031
}
9032
9033
current = dataTypes.shift();
9034
9035
// Convert to each sequential dataType
9036
while ( current ) {
9037
9038
if ( s.responseFields[ current ] ) {
9039
jqXHR[ s.responseFields[ current ] ] = response;
9040
}
9041
9042
// Apply the dataFilter if provided
9043
if ( !prev && isSuccess && s.dataFilter ) {
9044
response = s.dataFilter( response, s.dataType );
9045
}
9046
9047
prev = current;
9048
current = dataTypes.shift();
9049
9050
if ( current ) {
9051
9052
// There's only work to do if current dataType is non-auto
9053
if ( current === "*" ) {
9054
9055
current = prev;
9056
9057
// Convert response if prev dataType is non-auto and differs from current
9058
} else if ( prev !== "*" && prev !== current ) {
9059
9060
// Seek a direct converter
9061
conv = converters[ prev + " " + current ] || converters[ "* " + current ];
9062
9063
// If none found, seek a pair
9064
if ( !conv ) {
9065
for ( conv2 in converters ) {
9066
9067
// If conv2 outputs current
9068
tmp = conv2.split( " " );
9069
if ( tmp[ 1 ] === current ) {
9070
9071
// If prev can be converted to accepted input
9072
conv = converters[ prev + " " + tmp[ 0 ] ] ||
9073
converters[ "* " + tmp[ 0 ] ];
9074
if ( conv ) {
9075
9076
// Condense equivalence converters
9077
if ( conv === true ) {
9078
conv = converters[ conv2 ];
9079
9080
// Otherwise, insert the intermediate dataType
9081
} else if ( converters[ conv2 ] !== true ) {
9082
current = tmp[ 0 ];
9083
dataTypes.unshift( tmp[ 1 ] );
9084
}
9085
break;
9086
}
9087
}
9088
}
9089
}
9090
9091
// Apply converter (if not an equivalence)
9092
if ( conv !== true ) {
9093
9094
// Unless errors are allowed to bubble, catch and return them
9095
if ( conv && s.throws ) {
9096
response = conv( response );
9097
} else {
9098
try {
9099
response = conv( response );
9100
} catch ( e ) {
9101
return {
9102
state: "parsererror",
9103
error: conv ? e : "No conversion from " + prev + " to " + current
9104
};
9105
}
9106
}
9107
}
9108
}
9109
}
9110
}
9111
9112
return { state: "success", data: response };
9113
}
9114
9115
jQuery.extend( {
9116
9117
// Counter for holding the number of active queries
9118
active: 0,
9119
9120
// Last-Modified header cache for next request
9121
lastModified: {},
9122
etag: {},
9123
9124
ajaxSettings: {
9125
url: location.href,
9126
type: "GET",
9127
isLocal: rlocalProtocol.test( location.protocol ),
9128
global: true,
9129
processData: true,
9130
async: true,
9131
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
9132
9133
/*
9134
timeout: 0,
9135
data: null,
9136
dataType: null,
9137
username: null,
9138
password: null,
9139
cache: null,
9140
throws: false,
9141
traditional: false,
9142
headers: {},
9143
*/
9144
9145
accepts: {
9146
"*": allTypes,
9147
text: "text/plain",
9148
html: "text/html",
9149
xml: "application/xml, text/xml",
9150
json: "application/json, text/javascript"
9151
},
9152
9153
contents: {
9154
xml: /\bxml\b/,
9155
html: /\bhtml/,
9156
json: /\bjson\b/
9157
},
9158
9159
responseFields: {
9160
xml: "responseXML",
9161
text: "responseText",
9162
json: "responseJSON"
9163
},
9164
9165
// Data converters
9166
// Keys separate source (or catchall "*") and destination types with a single space
9167
converters: {
9168
9169
// Convert anything to text
9170
"* text": String,
9171
9172
// Text to html (true = no transformation)
9173
"text html": true,
9174
9175
// Evaluate text as a json expression
9176
"text json": JSON.parse,
9177
9178
// Parse text as xml
9179
"text xml": jQuery.parseXML
9180
},
9181
9182
// For options that shouldn't be deep extended:
9183
// you can add your own custom options here if
9184
// and when you create one that shouldn't be
9185
// deep extended (see ajaxExtend)
9186
flatOptions: {
9187
url: true,
9188
context: true
9189
}
9190
},
9191
9192
// Creates a full fledged settings object into target
9193
// with both ajaxSettings and settings fields.
9194
// If target is omitted, writes into ajaxSettings.
9195
ajaxSetup: function( target, settings ) {
9196
return settings ?
9197
9198
// Building a settings object
9199
ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
9200
9201
// Extending ajaxSettings
9202
ajaxExtend( jQuery.ajaxSettings, target );
9203
},
9204
9205
ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
9206
ajaxTransport: addToPrefiltersOrTransports( transports ),
9207
9208
// Main method
9209
ajax: function( url, options ) {
9210
9211
// If url is an object, simulate pre-1.5 signature
9212
if ( typeof url === "object" ) {
9213
options = url;
9214
url = undefined;
9215
}
9216
9217
// Force options to be an object
9218
options = options || {};
9219
9220
var transport,
9221
9222
// URL without anti-cache param
9223
cacheURL,
9224
9225
// Response headers
9226
responseHeadersString,
9227
responseHeaders,
9228
9229
// timeout handle
9230
timeoutTimer,
9231
9232
// Url cleanup var
9233
urlAnchor,
9234
9235
// Request state (becomes false upon send and true upon completion)
9236
completed,
9237
9238
// To know if global events are to be dispatched
9239
fireGlobals,
9240
9241
// Loop variable
9242
i,
9243
9244
// uncached part of the url
9245
uncached,
9246
9247
// Create the final options object
9248
s = jQuery.ajaxSetup( {}, options ),
9249
9250
// Callbacks context
9251
callbackContext = s.context || s,
9252
9253
// Context for global events is callbackContext if it is a DOM node or jQuery collection
9254
globalEventContext = s.context &&
9255
( callbackContext.nodeType || callbackContext.jquery ) ?
9256
jQuery( callbackContext ) :
9257
jQuery.event,
9258
9259
// Deferreds
9260
deferred = jQuery.Deferred(),
9261
completeDeferred = jQuery.Callbacks( "once memory" ),
9262
9263
// Status-dependent callbacks
9264
statusCode = s.statusCode || {},
9265
9266
// Headers (they are sent all at once)
9267
requestHeaders = {},
9268
requestHeadersNames = {},
9269
9270
// Default abort message
9271
strAbort = "canceled",
9272
9273
// Fake xhr
9274
jqXHR = {
9275
readyState: 0,
9276
9277
// Builds headers hashtable if needed
9278
getResponseHeader: function( key ) {
9279
var match;
9280
if ( completed ) {
9281
if ( !responseHeaders ) {
9282
responseHeaders = {};
9283
while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
9284
responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
9285
( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
9286
.concat( match[ 2 ] );
9287
}
9288
}
9289
match = responseHeaders[ key.toLowerCase() + " " ];
9290
}
9291
return match == null ? null : match.join( ", " );
9292
},
9293
9294
// Raw string
9295
getAllResponseHeaders: function() {
9296
return completed ? responseHeadersString : null;
9297
},
9298
9299
// Caches the header
9300
setRequestHeader: function( name, value ) {
9301
if ( completed == null ) {
9302
name = requestHeadersNames[ name.toLowerCase() ] =
9303
requestHeadersNames[ name.toLowerCase() ] || name;
9304
requestHeaders[ name ] = value;
9305
}
9306
return this;
9307
},
9308
9309
// Overrides response content-type header
9310
overrideMimeType: function( type ) {
9311
if ( completed == null ) {
9312
s.mimeType = type;
9313
}
9314
return this;
9315
},
9316
9317
// Status-dependent callbacks
9318
statusCode: function( map ) {
9319
var code;
9320
if ( map ) {
9321
if ( completed ) {
9322
9323
// Execute the appropriate callbacks
9324
jqXHR.always( map[ jqXHR.status ] );
9325
} else {
9326
9327
// Lazy-add the new callbacks in a way that preserves old ones
9328
for ( code in map ) {
9329
statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
9330
}
9331
}
9332
}
9333
return this;
9334
},
9335
9336
// Cancel the request
9337
abort: function( statusText ) {
9338
var finalText = statusText || strAbort;
9339
if ( transport ) {
9340
transport.abort( finalText );
9341
}
9342
done( 0, finalText );
9343
return this;
9344
}
9345
};
9346
9347
// Attach deferreds
9348
deferred.promise( jqXHR );
9349
9350
// Add protocol if not provided (prefilters might expect it)
9351
// Handle falsy url in the settings object (trac-10093: consistency with old signature)
9352
// We also use the url parameter if available
9353
s.url = ( ( url || s.url || location.href ) + "" )
9354
.replace( rprotocol, location.protocol + "//" );
9355
9356
// Alias method option to type as per ticket trac-12004
9357
s.type = options.method || options.type || s.method || s.type;
9358
9359
// Extract dataTypes list
9360
s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
9361
9362
// A cross-domain request is in order when the origin doesn't match the current origin.
9363
if ( s.crossDomain == null ) {
9364
urlAnchor = document.createElement( "a" );
9365
9366
// Support: IE <=8 - 11, Edge 12 - 15
9367
// IE throws exception on accessing the href property if url is malformed,
9368
// e.g. http://example.com:80x/
9369
try {
9370
urlAnchor.href = s.url;
9371
9372
// Support: IE <=8 - 11 only
9373
// Anchor's host property isn't correctly set when s.url is relative
9374
urlAnchor.href = urlAnchor.href;
9375
s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
9376
urlAnchor.protocol + "//" + urlAnchor.host;
9377
} catch ( e ) {
9378
9379
// If there is an error parsing the URL, assume it is crossDomain,
9380
// it can be rejected by the transport if it is invalid
9381
s.crossDomain = true;
9382
}
9383
}
9384
9385
// Convert data if not already a string
9386
if ( s.data && s.processData && typeof s.data !== "string" ) {
9387
s.data = jQuery.param( s.data, s.traditional );
9388
}
9389
9390
// Apply prefilters
9391
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9392
9393
// If request was aborted inside a prefilter, stop there
9394
if ( completed ) {
9395
return jqXHR;
9396
}
9397
9398
// We can fire global events as of now if asked to
9399
// Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118)
9400
fireGlobals = jQuery.event && s.global;
9401
9402
// Watch for a new set of requests
9403
if ( fireGlobals && jQuery.active++ === 0 ) {
9404
jQuery.event.trigger( "ajaxStart" );
9405
}
9406
9407
// Uppercase the type
9408
s.type = s.type.toUpperCase();
9409
9410
// Determine if request has content
9411
s.hasContent = !rnoContent.test( s.type );
9412
9413
// Save the URL in case we're toying with the If-Modified-Since
9414
// and/or If-None-Match header later on
9415
// Remove hash to simplify url manipulation
9416
cacheURL = s.url.replace( rhash, "" );
9417
9418
// More options handling for requests with no content
9419
if ( !s.hasContent ) {
9420
9421
// Remember the hash so we can put it back
9422
uncached = s.url.slice( cacheURL.length );
9423
9424
// If data is available and should be processed, append data to url
9425
if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
9426
cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
9427
9428
// trac-9682: remove data so that it's not used in an eventual retry
9429
delete s.data;
9430
}
9431
9432
// Add or update anti-cache param if needed
9433
if ( s.cache === false ) {
9434
cacheURL = cacheURL.replace( rantiCache, "$1" );
9435
uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
9436
uncached;
9437
}
9438
9439
// Put hash and anti-cache on the URL that will be requested (gh-1732)
9440
s.url = cacheURL + uncached;
9441
9442
// Change '%20' to '+' if this is encoded form body content (gh-2658)
9443
} else if ( s.data && s.processData &&
9444
( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9445
s.data = s.data.replace( r20, "+" );
9446
}
9447
9448
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9449
if ( s.ifModified ) {
9450
if ( jQuery.lastModified[ cacheURL ] ) {
9451
jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9452
}
9453
if ( jQuery.etag[ cacheURL ] ) {
9454
jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9455
}
9456
}
9457
9458
// Set the correct header, if data is being sent
9459
if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9460
jqXHR.setRequestHeader( "Content-Type", s.contentType );
9461
}
9462
9463
// Set the Accepts header for the server, depending on the dataType
9464
jqXHR.setRequestHeader(
9465
"Accept",
9466
s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
9467
s.accepts[ s.dataTypes[ 0 ] ] +
9468
( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9469
s.accepts[ "*" ]
9470
);
9471
9472
// Check for headers option
9473
for ( i in s.headers ) {
9474
jqXHR.setRequestHeader( i, s.headers[ i ] );
9475
}
9476
9477
// Allow custom headers/mimetypes and early abort
9478
if ( s.beforeSend &&
9479
( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
9480
9481
// Abort if not done already and return
9482
return jqXHR.abort();
9483
}
9484
9485
// Aborting is no longer a cancellation
9486
strAbort = "abort";
9487
9488
// Install callbacks on deferreds
9489
completeDeferred.add( s.complete );
9490
jqXHR.done( s.success );
9491
jqXHR.fail( s.error );
9492
9493
// Get transport
9494
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9495
9496
// If no transport, we auto-abort
9497
if ( !transport ) {
9498
done( -1, "No Transport" );
9499
} else {
9500
jqXHR.readyState = 1;
9501
9502
// Send global event
9503
if ( fireGlobals ) {
9504
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9505
}
9506
9507
// If request was aborted inside ajaxSend, stop there
9508
if ( completed ) {
9509
return jqXHR;
9510
}
9511
9512
// Timeout
9513
if ( s.async && s.timeout > 0 ) {
9514
timeoutTimer = window.setTimeout( function() {
9515
jqXHR.abort( "timeout" );
9516
}, s.timeout );
9517
}
9518
9519
try {
9520
completed = false;
9521
transport.send( requestHeaders, done );
9522
} catch ( e ) {
9523
9524
// Rethrow post-completion exceptions
9525
if ( completed ) {
9526
throw e;
9527
}
9528
9529
// Propagate others as results
9530
done( -1, e );
9531
}
9532
}
9533
9534
// Callback for when everything is done
9535
function done( status, nativeStatusText, responses, headers ) {
9536
var isSuccess, success, error, response, modified,
9537
statusText = nativeStatusText;
9538
9539
// Ignore repeat invocations
9540
if ( completed ) {
9541
return;
9542
}
9543
9544
completed = true;
9545
9546
// Clear timeout if it exists
9547
if ( timeoutTimer ) {
9548
window.clearTimeout( timeoutTimer );
9549
}
9550
9551
// Dereference transport for early garbage collection
9552
// (no matter how long the jqXHR object will be used)
9553
transport = undefined;
9554
9555
// Cache response headers
9556
responseHeadersString = headers || "";
9557
9558
// Set readyState
9559
jqXHR.readyState = status > 0 ? 4 : 0;
9560
9561
// Determine if successful
9562
isSuccess = status >= 200 && status < 300 || status === 304;
9563
9564
// Get response data
9565
if ( responses ) {
9566
response = ajaxHandleResponses( s, jqXHR, responses );
9567
}
9568
9569
// Use a noop converter for missing script but not if jsonp
9570
if ( !isSuccess &&
9571
jQuery.inArray( "script", s.dataTypes ) > -1 &&
9572
jQuery.inArray( "json", s.dataTypes ) < 0 ) {
9573
s.converters[ "text script" ] = function() {};
9574
}
9575
9576
// Convert no matter what (that way responseXXX fields are always set)
9577
response = ajaxConvert( s, response, jqXHR, isSuccess );
9578
9579
// If successful, handle type chaining
9580
if ( isSuccess ) {
9581
9582
// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9583
if ( s.ifModified ) {
9584
modified = jqXHR.getResponseHeader( "Last-Modified" );
9585
if ( modified ) {
9586
jQuery.lastModified[ cacheURL ] = modified;
9587
}
9588
modified = jqXHR.getResponseHeader( "etag" );
9589
if ( modified ) {
9590
jQuery.etag[ cacheURL ] = modified;
9591
}
9592
}
9593
9594
// if no content
9595
if ( status === 204 || s.type === "HEAD" ) {
9596
statusText = "nocontent";
9597
9598
// if not modified
9599
} else if ( status === 304 ) {
9600
statusText = "notmodified";
9601
9602
// If we have data, let's convert it
9603
} else {
9604
statusText = response.state;
9605
success = response.data;
9606
error = response.error;
9607
isSuccess = !error;
9608
}
9609
} else {
9610
9611
// Extract error from statusText and normalize for non-aborts
9612
error = statusText;
9613
if ( status || !statusText ) {
9614
statusText = "error";
9615
if ( status < 0 ) {
9616
status = 0;
9617
}
9618
}
9619
}
9620
9621
// Set data for the fake xhr object
9622
jqXHR.status = status;
9623
jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9624
9625
// Success/Error
9626
if ( isSuccess ) {
9627
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9628
} else {
9629
deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9630
}
9631
9632
// Status-dependent callbacks
9633
jqXHR.statusCode( statusCode );
9634
statusCode = undefined;
9635
9636
if ( fireGlobals ) {
9637
globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9638
[ jqXHR, s, isSuccess ? success : error ] );
9639
}
9640
9641
// Complete
9642
completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9643
9644
if ( fireGlobals ) {
9645
globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9646
9647
// Handle the global AJAX counter
9648
if ( !( --jQuery.active ) ) {
9649
jQuery.event.trigger( "ajaxStop" );
9650
}
9651
}
9652
}
9653
9654
return jqXHR;
9655
},
9656
9657
getJSON: function( url, data, callback ) {
9658
return jQuery.get( url, data, callback, "json" );
9659
},
9660
9661
getScript: function( url, callback ) {
9662
return jQuery.get( url, undefined, callback, "script" );
9663
}
9664
} );
9665
9666
jQuery.each( [ "get", "post" ], function( _i, method ) {
9667
jQuery[ method ] = function( url, data, callback, type ) {
9668
9669
// Shift arguments if data argument was omitted
9670
if ( isFunction( data ) ) {
9671
type = type || callback;
9672
callback = data;
9673
data = undefined;
9674
}
9675
9676
// The url can be an options object (which then must have .url)
9677
return jQuery.ajax( jQuery.extend( {
9678
url: url,
9679
type: method,
9680
dataType: type,
9681
data: data,
9682
success: callback
9683
}, jQuery.isPlainObject( url ) && url ) );
9684
};
9685
} );
9686
9687
jQuery.ajaxPrefilter( function( s ) {
9688
var i;
9689
for ( i in s.headers ) {
9690
if ( i.toLowerCase() === "content-type" ) {
9691
s.contentType = s.headers[ i ] || "";
9692
}
9693
}
9694
} );
9695
9696
9697
jQuery._evalUrl = function( url, options, doc ) {
9698
return jQuery.ajax( {
9699
url: url,
9700
9701
// Make this explicit, since user can override this through ajaxSetup (trac-11264)
9702
type: "GET",
9703
dataType: "script",
9704
cache: true,
9705
async: false,
9706
global: false,
9707
9708
// Only evaluate the response if it is successful (gh-4126)
9709
// dataFilter is not invoked for failure responses, so using it instead
9710
// of the default converter is kludgy but it works.
9711
converters: {
9712
"text script": function() {}
9713
},
9714
dataFilter: function( response ) {
9715
jQuery.globalEval( response, options, doc );
9716
}
9717
} );
9718
};
9719
9720
9721
jQuery.fn.extend( {
9722
wrapAll: function( html ) {
9723
var wrap;
9724
9725
if ( this[ 0 ] ) {
9726
if ( isFunction( html ) ) {
9727
html = html.call( this[ 0 ] );
9728
}
9729
9730
// The elements to wrap the target around
9731
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
9732
9733
if ( this[ 0 ].parentNode ) {
9734
wrap.insertBefore( this[ 0 ] );
9735
}
9736
9737
wrap.map( function() {
9738
var elem = this;
9739
9740
while ( elem.firstElementChild ) {
9741
elem = elem.firstElementChild;
9742
}
9743
9744
return elem;
9745
} ).append( this );
9746
}
9747
9748
return this;
9749
},
9750
9751
wrapInner: function( html ) {
9752
if ( isFunction( html ) ) {
9753
return this.each( function( i ) {
9754
jQuery( this ).wrapInner( html.call( this, i ) );
9755
} );
9756
}
9757
9758
return this.each( function() {
9759
var self = jQuery( this ),
9760
contents = self.contents();
9761
9762
if ( contents.length ) {
9763
contents.wrapAll( html );
9764
9765
} else {
9766
self.append( html );
9767
}
9768
} );
9769
},
9770
9771
wrap: function( html ) {
9772
var htmlIsFunction = isFunction( html );
9773
9774
return this.each( function( i ) {
9775
jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
9776
} );
9777
},
9778
9779
unwrap: function( selector ) {
9780
this.parent( selector ).not( "body" ).each( function() {
9781
jQuery( this ).replaceWith( this.childNodes );
9782
} );
9783
return this;
9784
}
9785
} );
9786
9787
9788
jQuery.expr.pseudos.hidden = function( elem ) {
9789
return !jQuery.expr.pseudos.visible( elem );
9790
};
9791
jQuery.expr.pseudos.visible = function( elem ) {
9792
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
9793
};
9794
9795
9796
9797
9798
jQuery.ajaxSettings.xhr = function() {
9799
try {
9800
return new window.XMLHttpRequest();
9801
} catch ( e ) {}
9802
};
9803
9804
var xhrSuccessStatus = {
9805
9806
// File protocol always yields status code 0, assume 200
9807
0: 200,
9808
9809
// Support: IE <=9 only
9810
// trac-1450: sometimes IE returns 1223 when it should be 204
9811
1223: 204
9812
},
9813
xhrSupported = jQuery.ajaxSettings.xhr();
9814
9815
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
9816
support.ajax = xhrSupported = !!xhrSupported;
9817
9818
jQuery.ajaxTransport( function( options ) {
9819
var callback, errorCallback;
9820
9821
// Cross domain only allowed if supported through XMLHttpRequest
9822
if ( support.cors || xhrSupported && !options.crossDomain ) {
9823
return {
9824
send: function( headers, complete ) {
9825
var i,
9826
xhr = options.xhr();
9827
9828
xhr.open(
9829
options.type,
9830
options.url,
9831
options.async,
9832
options.username,
9833
options.password
9834
);
9835
9836
// Apply custom fields if provided
9837
if ( options.xhrFields ) {
9838
for ( i in options.xhrFields ) {
9839
xhr[ i ] = options.xhrFields[ i ];
9840
}
9841
}
9842
9843
// Override mime type if needed
9844
if ( options.mimeType && xhr.overrideMimeType ) {
9845
xhr.overrideMimeType( options.mimeType );
9846
}
9847
9848
// X-Requested-With header
9849
// For cross-domain requests, seeing as conditions for a preflight are
9850
// akin to a jigsaw puzzle, we simply never set it to be sure.
9851
// (it can always be set on a per-request basis or even using ajaxSetup)
9852
// For same-domain requests, won't change header if already provided.
9853
if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
9854
headers[ "X-Requested-With" ] = "XMLHttpRequest";
9855
}
9856
9857
// Set headers
9858
for ( i in headers ) {
9859
xhr.setRequestHeader( i, headers[ i ] );
9860
}
9861
9862
// Callback
9863
callback = function( type ) {
9864
return function() {
9865
if ( callback ) {
9866
callback = errorCallback = xhr.onload =
9867
xhr.onerror = xhr.onabort = xhr.ontimeout =
9868
xhr.onreadystatechange = null;
9869
9870
if ( type === "abort" ) {
9871
xhr.abort();
9872
} else if ( type === "error" ) {
9873
9874
// Support: IE <=9 only
9875
// On a manual native abort, IE9 throws
9876
// errors on any property access that is not readyState
9877
if ( typeof xhr.status !== "number" ) {
9878
complete( 0, "error" );
9879
} else {
9880
complete(
9881
9882
// File: protocol always yields status 0; see trac-8605, trac-14207
9883
xhr.status,
9884
xhr.statusText
9885
);
9886
}
9887
} else {
9888
complete(
9889
xhrSuccessStatus[ xhr.status ] || xhr.status,
9890
xhr.statusText,
9891
9892
// Support: IE <=9 only
9893
// IE9 has no XHR2 but throws on binary (trac-11426)
9894
// For XHR2 non-text, let the caller handle it (gh-2498)
9895
( xhr.responseType || "text" ) !== "text" ||
9896
typeof xhr.responseText !== "string" ?
9897
{ binary: xhr.response } :
9898
{ text: xhr.responseText },
9899
xhr.getAllResponseHeaders()
9900
);
9901
}
9902
}
9903
};
9904
};
9905
9906
// Listen to events
9907
xhr.onload = callback();
9908
errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
9909
9910
// Support: IE 9 only
9911
// Use onreadystatechange to replace onabort
9912
// to handle uncaught aborts
9913
if ( xhr.onabort !== undefined ) {
9914
xhr.onabort = errorCallback;
9915
} else {
9916
xhr.onreadystatechange = function() {
9917
9918
// Check readyState before timeout as it changes
9919
if ( xhr.readyState === 4 ) {
9920
9921
// Allow onerror to be called first,
9922
// but that will not handle a native abort
9923
// Also, save errorCallback to a variable
9924
// as xhr.onerror cannot be accessed
9925
window.setTimeout( function() {
9926
if ( callback ) {
9927
errorCallback();
9928
}
9929
} );
9930
}
9931
};
9932
}
9933
9934
// Create the abort callback
9935
callback = callback( "abort" );
9936
9937
try {
9938
9939
// Do send the request (this may raise an exception)
9940
xhr.send( options.hasContent && options.data || null );
9941
} catch ( e ) {
9942
9943
// trac-14683: Only rethrow if this hasn't been notified as an error yet
9944
if ( callback ) {
9945
throw e;
9946
}
9947
}
9948
},
9949
9950
abort: function() {
9951
if ( callback ) {
9952
callback();
9953
}
9954
}
9955
};
9956
}
9957
} );
9958
9959
9960
9961
9962
// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
9963
jQuery.ajaxPrefilter( function( s ) {
9964
if ( s.crossDomain ) {
9965
s.contents.script = false;
9966
}
9967
} );
9968
9969
// Install script dataType
9970
jQuery.ajaxSetup( {
9971
accepts: {
9972
script: "text/javascript, application/javascript, " +
9973
"application/ecmascript, application/x-ecmascript"
9974
},
9975
contents: {
9976
script: /\b(?:java|ecma)script\b/
9977
},
9978
converters: {
9979
"text script": function( text ) {
9980
jQuery.globalEval( text );
9981
return text;
9982
}
9983
}
9984
} );
9985
9986
// Handle cache's special case and crossDomain
9987
jQuery.ajaxPrefilter( "script", function( s ) {
9988
if ( s.cache === undefined ) {
9989
s.cache = false;
9990
}
9991
if ( s.crossDomain ) {
9992
s.type = "GET";
9993
}
9994
} );
9995
9996
// Bind script tag hack transport
9997
jQuery.ajaxTransport( "script", function( s ) {
9998
9999
// This transport only deals with cross domain or forced-by-attrs requests
10000
if ( s.crossDomain || s.scriptAttrs ) {
10001
var script, callback;
10002
return {
10003
send: function( _, complete ) {
10004
script = jQuery( "<script>" )
10005
.attr( s.scriptAttrs || {} )
10006
.prop( { charset: s.scriptCharset, src: s.url } )
10007
.on( "load error", callback = function( evt ) {
10008
script.remove();
10009
callback = null;
10010
if ( evt ) {
10011
complete( evt.type === "error" ? 404 : 200, evt.type );
10012
}
10013
} );
10014
10015
// Use native DOM manipulation to avoid our domManip AJAX trickery
10016
document.head.appendChild( script[ 0 ] );
10017
},
10018
abort: function() {
10019
if ( callback ) {
10020
callback();
10021
}
10022
}
10023
};
10024
}
10025
} );
10026
10027
10028
10029
10030
var oldCallbacks = [],
10031
rjsonp = /(=)\?(?=&|$)|\?\?/;
10032
10033
// Default jsonp settings
10034
jQuery.ajaxSetup( {
10035
jsonp: "callback",
10036
jsonpCallback: function() {
10037
var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
10038
this[ callback ] = true;
10039
return callback;
10040
}
10041
} );
10042
10043
// Detect, normalize options and install callbacks for jsonp requests
10044
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
10045
10046
var callbackName, overwritten, responseContainer,
10047
jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
10048
"url" :
10049
typeof s.data === "string" &&
10050
( s.contentType || "" )
10051
.indexOf( "application/x-www-form-urlencoded" ) === 0 &&
10052
rjsonp.test( s.data ) && "data"
10053
);
10054
10055
// Handle iff the expected data type is "jsonp" or we have a parameter to set
10056
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
10057
10058
// Get callback name, remembering preexisting value associated with it
10059
callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
10060
s.jsonpCallback() :
10061
s.jsonpCallback;
10062
10063
// Insert callback into url or form data
10064
if ( jsonProp ) {
10065
s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
10066
} else if ( s.jsonp !== false ) {
10067
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
10068
}
10069
10070
// Use data converter to retrieve json after script execution
10071
s.converters[ "script json" ] = function() {
10072
if ( !responseContainer ) {
10073
jQuery.error( callbackName + " was not called" );
10074
}
10075
return responseContainer[ 0 ];
10076
};
10077
10078
// Force json dataType
10079
s.dataTypes[ 0 ] = "json";
10080
10081
// Install callback
10082
overwritten = window[ callbackName ];
10083
window[ callbackName ] = function() {
10084
responseContainer = arguments;
10085
};
10086
10087
// Clean-up function (fires after converters)
10088
jqXHR.always( function() {
10089
10090
// If previous value didn't exist - remove it
10091
if ( overwritten === undefined ) {
10092
jQuery( window ).removeProp( callbackName );
10093
10094
// Otherwise restore preexisting value
10095
} else {
10096
window[ callbackName ] = overwritten;
10097
}
10098
10099
// Save back as free
10100
if ( s[ callbackName ] ) {
10101
10102
// Make sure that re-using the options doesn't screw things around
10103
s.jsonpCallback = originalSettings.jsonpCallback;
10104
10105
// Save the callback name for future use
10106
oldCallbacks.push( callbackName );
10107
}
10108
10109
// Call if it was a function and we have a response
10110
if ( responseContainer && isFunction( overwritten ) ) {
10111
overwritten( responseContainer[ 0 ] );
10112
}
10113
10114
responseContainer = overwritten = undefined;
10115
} );
10116
10117
// Delegate to script
10118
return "script";
10119
}
10120
} );
10121
10122
10123
10124
10125
// Support: Safari 8 only
10126
// In Safari 8 documents created via document.implementation.createHTMLDocument
10127
// collapse sibling forms: the second one becomes a child of the first one.
10128
// Because of that, this security measure has to be disabled in Safari 8.
10129
// https://bugs.webkit.org/show_bug.cgi?id=137337
10130
support.createHTMLDocument = ( function() {
10131
var body = document.implementation.createHTMLDocument( "" ).body;
10132
body.innerHTML = "<form></form><form></form>";
10133
return body.childNodes.length === 2;
10134
} )();
10135
10136
10137
// Argument "data" should be string of html
10138
// context (optional): If specified, the fragment will be created in this context,
10139
// defaults to document
10140
// keepScripts (optional): If true, will include scripts passed in the html string
10141
jQuery.parseHTML = function( data, context, keepScripts ) {
10142
if ( typeof data !== "string" ) {
10143
return [];
10144
}
10145
if ( typeof context === "boolean" ) {
10146
keepScripts = context;
10147
context = false;
10148
}
10149
10150
var base, parsed, scripts;
10151
10152
if ( !context ) {
10153
10154
// Stop scripts or inline event handlers from being executed immediately
10155
// by using document.implementation
10156
if ( support.createHTMLDocument ) {
10157
context = document.implementation.createHTMLDocument( "" );
10158
10159
// Set the base href for the created document
10160
// so any parsed elements with URLs
10161
// are based on the document's URL (gh-2965)
10162
base = context.createElement( "base" );
10163
base.href = document.location.href;
10164
context.head.appendChild( base );
10165
} else {
10166
context = document;
10167
}
10168
}
10169
10170
parsed = rsingleTag.exec( data );
10171
scripts = !keepScripts && [];
10172
10173
// Single tag
10174
if ( parsed ) {
10175
return [ context.createElement( parsed[ 1 ] ) ];
10176
}
10177
10178
parsed = buildFragment( [ data ], context, scripts );
10179
10180
if ( scripts && scripts.length ) {
10181
jQuery( scripts ).remove();
10182
}
10183
10184
return jQuery.merge( [], parsed.childNodes );
10185
};
10186
10187
10188
/**
10189
* Load a url into a page
10190
*/
10191
jQuery.fn.load = function( url, params, callback ) {
10192
var selector, type, response,
10193
self = this,
10194
off = url.indexOf( " " );
10195
10196
if ( off > -1 ) {
10197
selector = stripAndCollapse( url.slice( off ) );
10198
url = url.slice( 0, off );
10199
}
10200
10201
// If it's a function
10202
if ( isFunction( params ) ) {
10203
10204
// We assume that it's the callback
10205
callback = params;
10206
params = undefined;
10207
10208
// Otherwise, build a param string
10209
} else if ( params && typeof params === "object" ) {
10210
type = "POST";
10211
}
10212
10213
// If we have elements to modify, make the request
10214
if ( self.length > 0 ) {
10215
jQuery.ajax( {
10216
url: url,
10217
10218
// If "type" variable is undefined, then "GET" method will be used.
10219
// Make value of this field explicit since
10220
// user can override it through ajaxSetup method
10221
type: type || "GET",
10222
dataType: "html",
10223
data: params
10224
} ).done( function( responseText ) {
10225
10226
// Save response for use in complete callback
10227
response = arguments;
10228
10229
self.html( selector ?
10230
10231
// If a selector was specified, locate the right elements in a dummy div
10232
// Exclude scripts to avoid IE 'Permission Denied' errors
10233
jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
10234
10235
// Otherwise use the full result
10236
responseText );
10237
10238
// If the request succeeds, this function gets "data", "status", "jqXHR"
10239
// but they are ignored because response was set above.
10240
// If it fails, this function gets "jqXHR", "status", "error"
10241
} ).always( callback && function( jqXHR, status ) {
10242
self.each( function() {
10243
callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
10244
} );
10245
} );
10246
}
10247
10248
return this;
10249
};
10250
10251
10252
10253
10254
jQuery.expr.pseudos.animated = function( elem ) {
10255
return jQuery.grep( jQuery.timers, function( fn ) {
10256
return elem === fn.elem;
10257
} ).length;
10258
};
10259
10260
10261
10262
10263
jQuery.offset = {
10264
setOffset: function( elem, options, i ) {
10265
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
10266
position = jQuery.css( elem, "position" ),
10267
curElem = jQuery( elem ),
10268
props = {};
10269
10270
// Set position first, in-case top/left are set even on static elem
10271
if ( position === "static" ) {
10272
elem.style.position = "relative";
10273
}
10274
10275
curOffset = curElem.offset();
10276
curCSSTop = jQuery.css( elem, "top" );
10277
curCSSLeft = jQuery.css( elem, "left" );
10278
calculatePosition = ( position === "absolute" || position === "fixed" ) &&
10279
( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
10280
10281
// Need to be able to calculate position if either
10282
// top or left is auto and position is either absolute or fixed
10283
if ( calculatePosition ) {
10284
curPosition = curElem.position();
10285
curTop = curPosition.top;
10286
curLeft = curPosition.left;
10287
10288
} else {
10289
curTop = parseFloat( curCSSTop ) || 0;
10290
curLeft = parseFloat( curCSSLeft ) || 0;
10291
}
10292
10293
if ( isFunction( options ) ) {
10294
10295
// Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
10296
options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
10297
}
10298
10299
if ( options.top != null ) {
10300
props.top = ( options.top - curOffset.top ) + curTop;
10301
}
10302
if ( options.left != null ) {
10303
props.left = ( options.left - curOffset.left ) + curLeft;
10304
}
10305
10306
if ( "using" in options ) {
10307
options.using.call( elem, props );
10308
10309
} else {
10310
curElem.css( props );
10311
}
10312
}
10313
};
10314
10315
jQuery.fn.extend( {
10316
10317
// offset() relates an element's border box to the document origin
10318
offset: function( options ) {
10319
10320
// Preserve chaining for setter
10321
if ( arguments.length ) {
10322
return options === undefined ?
10323
this :
10324
this.each( function( i ) {
10325
jQuery.offset.setOffset( this, options, i );
10326
} );
10327
}
10328
10329
var rect, win,
10330
elem = this[ 0 ];
10331
10332
if ( !elem ) {
10333
return;
10334
}
10335
10336
// Return zeros for disconnected and hidden (display: none) elements (gh-2310)
10337
// Support: IE <=11 only
10338
// Running getBoundingClientRect on a
10339
// disconnected node in IE throws an error
10340
if ( !elem.getClientRects().length ) {
10341
return { top: 0, left: 0 };
10342
}
10343
10344
// Get document-relative position by adding viewport scroll to viewport-relative gBCR
10345
rect = elem.getBoundingClientRect();
10346
win = elem.ownerDocument.defaultView;
10347
return {
10348
top: rect.top + win.pageYOffset,
10349
left: rect.left + win.pageXOffset
10350
};
10351
},
10352
10353
// position() relates an element's margin box to its offset parent's padding box
10354
// This corresponds to the behavior of CSS absolute positioning
10355
position: function() {
10356
if ( !this[ 0 ] ) {
10357
return;
10358
}
10359
10360
var offsetParent, offset, doc,
10361
elem = this[ 0 ],
10362
parentOffset = { top: 0, left: 0 };
10363
10364
// position:fixed elements are offset from the viewport, which itself always has zero offset
10365
if ( jQuery.css( elem, "position" ) === "fixed" ) {
10366
10367
// Assume position:fixed implies availability of getBoundingClientRect
10368
offset = elem.getBoundingClientRect();
10369
10370
} else {
10371
offset = this.offset();
10372
10373
// Account for the *real* offset parent, which can be the document or its root element
10374
// when a statically positioned element is identified
10375
doc = elem.ownerDocument;
10376
offsetParent = elem.offsetParent || doc.documentElement;
10377
while ( offsetParent &&
10378
( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
10379
jQuery.css( offsetParent, "position" ) === "static" ) {
10380
10381
offsetParent = offsetParent.parentNode;
10382
}
10383
if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
10384
10385
// Incorporate borders into its offset, since they are outside its content origin
10386
parentOffset = jQuery( offsetParent ).offset();
10387
parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
10388
parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
10389
}
10390
}
10391
10392
// Subtract parent offsets and element margins
10393
return {
10394
top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10395
left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
10396
};
10397
},
10398
10399
// This method will return documentElement in the following cases:
10400
// 1) For the element inside the iframe without offsetParent, this method will return
10401
// documentElement of the parent window
10402
// 2) For the hidden or detached element
10403
// 3) For body or html element, i.e. in case of the html node - it will return itself
10404
//
10405
// but those exceptions were never presented as a real life use-cases
10406
// and might be considered as more preferable results.
10407
//
10408
// This logic, however, is not guaranteed and can change at any point in the future
10409
offsetParent: function() {
10410
return this.map( function() {
10411
var offsetParent = this.offsetParent;
10412
10413
while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
10414
offsetParent = offsetParent.offsetParent;
10415
}
10416
10417
return offsetParent || documentElement;
10418
} );
10419
}
10420
} );
10421
10422
// Create scrollLeft and scrollTop methods
10423
jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10424
var top = "pageYOffset" === prop;
10425
10426
jQuery.fn[ method ] = function( val ) {
10427
return access( this, function( elem, method, val ) {
10428
10429
// Coalesce documents and windows
10430
var win;
10431
if ( isWindow( elem ) ) {
10432
win = elem;
10433
} else if ( elem.nodeType === 9 ) {
10434
win = elem.defaultView;
10435
}
10436
10437
if ( val === undefined ) {
10438
return win ? win[ prop ] : elem[ method ];
10439
}
10440
10441
if ( win ) {
10442
win.scrollTo(
10443
!top ? val : win.pageXOffset,
10444
top ? val : win.pageYOffset
10445
);
10446
10447
} else {
10448
elem[ method ] = val;
10449
}
10450
}, method, val, arguments.length );
10451
};
10452
} );
10453
10454
// Support: Safari <=7 - 9.1, Chrome <=37 - 49
10455
// Add the top/left cssHooks using jQuery.fn.position
10456
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10457
// Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10458
// getComputedStyle returns percent when specified for top/left/bottom/right;
10459
// rather than make the css module depend on the offset module, just check for it here
10460
jQuery.each( [ "top", "left" ], function( _i, prop ) {
10461
jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10462
function( elem, computed ) {
10463
if ( computed ) {
10464
computed = curCSS( elem, prop );
10465
10466
// If curCSS returns percentage, fallback to offset
10467
return rnumnonpx.test( computed ) ?
10468
jQuery( elem ).position()[ prop ] + "px" :
10469
computed;
10470
}
10471
}
10472
);
10473
} );
10474
10475
10476
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10477
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10478
jQuery.each( {
10479
padding: "inner" + name,
10480
content: type,
10481
"": "outer" + name
10482
}, function( defaultExtra, funcName ) {
10483
10484
// Margin is only for outerHeight, outerWidth
10485
jQuery.fn[ funcName ] = function( margin, value ) {
10486
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10487
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10488
10489
return access( this, function( elem, type, value ) {
10490
var doc;
10491
10492
if ( isWindow( elem ) ) {
10493
10494
// $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10495
return funcName.indexOf( "outer" ) === 0 ?
10496
elem[ "inner" + name ] :
10497
elem.document.documentElement[ "client" + name ];
10498
}
10499
10500
// Get document width or height
10501
if ( elem.nodeType === 9 ) {
10502
doc = elem.documentElement;
10503
10504
// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10505
// whichever is greatest
10506
return Math.max(
10507
elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10508
elem.body[ "offset" + name ], doc[ "offset" + name ],
10509
doc[ "client" + name ]
10510
);
10511
}
10512
10513
return value === undefined ?
10514
10515
// Get width or height on the element, requesting but not forcing parseFloat
10516
jQuery.css( elem, type, extra ) :
10517
10518
// Set width or height on the element
10519
jQuery.style( elem, type, value, extra );
10520
}, type, chainable ? margin : undefined, chainable );
10521
};
10522
} );
10523
} );
10524
10525
10526
jQuery.each( [
10527
"ajaxStart",
10528
"ajaxStop",
10529
"ajaxComplete",
10530
"ajaxError",
10531
"ajaxSuccess",
10532
"ajaxSend"
10533
], function( _i, type ) {
10534
jQuery.fn[ type ] = function( fn ) {
10535
return this.on( type, fn );
10536
};
10537
} );
10538
10539
10540
10541
10542
jQuery.fn.extend( {
10543
10544
bind: function( types, data, fn ) {
10545
return this.on( types, null, data, fn );
10546
},
10547
unbind: function( types, fn ) {
10548
return this.off( types, null, fn );
10549
},
10550
10551
delegate: function( selector, types, data, fn ) {
10552
return this.on( types, selector, data, fn );
10553
},
10554
undelegate: function( selector, types, fn ) {
10555
10556
// ( namespace ) or ( selector, types [, fn] )
10557
return arguments.length === 1 ?
10558
this.off( selector, "**" ) :
10559
this.off( types, selector || "**", fn );
10560
},
10561
10562
hover: function( fnOver, fnOut ) {
10563
return this
10564
.on( "mouseenter", fnOver )
10565
.on( "mouseleave", fnOut || fnOver );
10566
}
10567
} );
10568
10569
jQuery.each(
10570
( "blur focus focusin focusout resize scroll click dblclick " +
10571
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10572
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
10573
function( _i, name ) {
10574
10575
// Handle event binding
10576
jQuery.fn[ name ] = function( data, fn ) {
10577
return arguments.length > 0 ?
10578
this.on( name, null, data, fn ) :
10579
this.trigger( name );
10580
};
10581
}
10582
);
10583
10584
10585
10586
10587
// Support: Android <=4.0 only
10588
// Make sure we trim BOM and NBSP
10589
// Require that the "whitespace run" starts from a non-whitespace
10590
// to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
10591
var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
10592
10593
// Bind a function to a context, optionally partially applying any
10594
// arguments.
10595
// jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10596
// However, it is not slated for removal any time soon
10597
jQuery.proxy = function( fn, context ) {
10598
var tmp, args, proxy;
10599
10600
if ( typeof context === "string" ) {
10601
tmp = fn[ context ];
10602
context = fn;
10603
fn = tmp;
10604
}
10605
10606
// Quick check to determine if target is callable, in the spec
10607
// this throws a TypeError, but we will just return undefined.
10608
if ( !isFunction( fn ) ) {
10609
return undefined;
10610
}
10611
10612
// Simulated bind
10613
args = slice.call( arguments, 2 );
10614
proxy = function() {
10615
return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
10616
};
10617
10618
// Set the guid of unique handler to the same of original handler, so it can be removed
10619
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
10620
10621
return proxy;
10622
};
10623
10624
jQuery.holdReady = function( hold ) {
10625
if ( hold ) {
10626
jQuery.readyWait++;
10627
} else {
10628
jQuery.ready( true );
10629
}
10630
};
10631
jQuery.isArray = Array.isArray;
10632
jQuery.parseJSON = JSON.parse;
10633
jQuery.nodeName = nodeName;
10634
jQuery.isFunction = isFunction;
10635
jQuery.isWindow = isWindow;
10636
jQuery.camelCase = camelCase;
10637
jQuery.type = toType;
10638
10639
jQuery.now = Date.now;
10640
10641
jQuery.isNumeric = function( obj ) {
10642
10643
// As of jQuery 3.0, isNumeric is limited to
10644
// strings and numbers (primitives or objects)
10645
// that can be coerced to finite numbers (gh-2662)
10646
var type = jQuery.type( obj );
10647
return ( type === "number" || type === "string" ) &&
10648
10649
// parseFloat NaNs numeric-cast false positives ("")
10650
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
10651
// subtraction forces infinities to NaN
10652
!isNaN( obj - parseFloat( obj ) );
10653
};
10654
10655
jQuery.trim = function( text ) {
10656
return text == null ?
10657
"" :
10658
( text + "" ).replace( rtrim, "$1" );
10659
};
10660
10661
10662
10663
// Register as a named AMD module, since jQuery can be concatenated with other
10664
// files that may use define, but not via a proper concatenation script that
10665
// understands anonymous AMD modules. A named AMD is safest and most robust
10666
// way to register. Lowercase jquery is used because AMD module names are
10667
// derived from file names, and jQuery is normally delivered in a lowercase
10668
// file name. Do this after creating the global so that if an AMD module wants
10669
// to call noConflict to hide this version of jQuery, it will work.
10670
10671
// Note that for maximum portability, libraries that are not jQuery should
10672
// declare themselves as anonymous modules, and avoid setting a global if an
10673
// AMD loader is present. jQuery is a special case. For more information, see
10674
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10675
10676
if ( typeof define === "function" && define.amd ) {
10677
define( "jquery", [], function() {
10678
return jQuery;
10679
} );
10680
}
10681
10682
10683
10684
10685
var
10686
10687
// Map over jQuery in case of overwrite
10688
_jQuery = window.jQuery,
10689
10690
// Map over the $ in case of overwrite
10691
_$ = window.$;
10692
10693
jQuery.noConflict = function( deep ) {
10694
if ( window.$ === jQuery ) {
10695
window.$ = _$;
10696
}
10697
10698
if ( deep && window.jQuery === jQuery ) {
10699
window.jQuery = _jQuery;
10700
}
10701
10702
return jQuery;
10703
};
10704
10705
// Expose jQuery and $ identifiers, even in AMD
10706
// (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557)
10707
// and CommonJS for browser emulators (trac-13566)
10708
if ( typeof noGlobal === "undefined" ) {
10709
window.jQuery = window.$ = jQuery;
10710
}
10711
10712
10713
10714
10715
return jQuery;
10716
} );
10717

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button