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