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