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