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