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