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