2 * jQuery JavaScript Library v3.3.1-dfsg
6 * https://sizzlejs.com/
8 * Copyright JS Foundation and other contributors
9 * Released under the MIT license
10 * https://jquery.org/license
12 * Date: 2019-04-19T06:52Z
14 ( function( global
, factory
) {
18 if ( typeof module
=== "object" && typeof module
.exports
=== "object" ) {
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 ) :
31 throw new Error( "jQuery requires a window with a document" );
39 // Pass this if window is not defined yet
40 } )( typeof window
!== "undefined" ? window
: this, function( window
, noGlobal
) {
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.
50 var document
= window
.document
;
52 var getProto
= Object
.getPrototypeOf
;
54 var slice
= arr
.slice
;
56 var concat
= arr
.concat
;
60 var indexOf
= arr
.indexOf
;
64 var toString
= class2type
.toString
;
66 var hasOwn
= class2type
.hasOwnProperty
;
68 var fnToString
= hasOwn
.toString
;
70 var ObjectFunctionString
= fnToString
.call( Object
);
74 var isFunction
= function isFunction( obj
) {
76 // Support: Chrome <=57, Firefox <=52
77 // In some browsers, typeof returns "function" for HTML <object> elements
78 // (i.e., `typeof document.createElement( "object" ) === "function"`).
79 // We don't want to classify *any* DOM node as a function.
80 return typeof obj
=== "function" && typeof obj
.nodeType
!== "number";
84 var isWindow
= function isWindow( obj
) {
85 return obj
!= null && obj
=== obj
.window
;
91 var preservedScriptAttributes
= {
97 function DOMEval( code
, doc
, node
) {
98 doc
= doc
|| document
;
101 script
= doc
.createElement( "script" );
105 for ( i
in preservedScriptAttributes
) {
107 script
[ i
] = node
[ i
];
111 doc
.head
.appendChild( script
).parentNode
.removeChild( script
);
115 function toType( obj
) {
120 // Support: Android <=2.3 only (functionish RegExp)
121 return typeof obj
=== "object" || typeof obj
=== "function" ?
122 class2type
[ toString
.call( obj
) ] || "object" :
126 // Defining this global in .eslintrc.json would create a danger of using the global
127 // unguarded in another place, it seems safer to define global only for this module
134 // Define a local copy of jQuery
135 jQuery = function( selector
, context
) {
137 // The jQuery object is actually just the init constructor 'enhanced'
138 // Need init if jQuery is called (just allow error to be thrown if not included)
139 return new jQuery
.fn
.init( selector
, context
);
142 // Support: Android <=4.0 only
143 // Make sure we trim BOM and NBSP
144 rtrim
= /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
146 jQuery
.fn
= jQuery
.prototype = {
148 // The current version of jQuery being used
153 // The default length of a jQuery object is 0
156 toArray: function() {
157 return slice
.call( this );
160 // Get the Nth element in the matched element set OR
161 // Get the whole matched element set as a clean array
162 get: function( num
) {
164 // Return all the elements in a clean array
166 return slice
.call( this );
169 // Return just the one element from the set
170 return num
< 0 ? this[ num
+ this.length
] : this[ num
];
173 // Take an array of elements and push it onto the stack
174 // (returning the new matched element set)
175 pushStack: function( elems
) {
177 // Build a new jQuery matched element set
178 var ret
= jQuery
.merge( this.constructor(), elems
);
180 // Add the old object onto the stack (as a reference)
181 ret
.prevObject
= this;
183 // Return the newly-formed element set
187 // Execute a callback for every element in the matched set.
188 each: function( callback
) {
189 return jQuery
.each( this, callback
);
192 map: function( callback
) {
193 return this.pushStack( jQuery
.map( this, function( elem
, i
) {
194 return callback
.call( elem
, i
, elem
);
199 return this.pushStack( slice
.apply( this, arguments
) );
207 return this.eq( -1 );
211 var len
= this.length
,
212 j
= +i
+ ( i
< 0 ? len
: 0 );
213 return this.pushStack( j
>= 0 && j
< len
? [ this[ j
] ] : [] );
217 return this.prevObject
|| this.constructor();
220 // For internal use only.
221 // Behaves like an Array's method, not like a jQuery method.
227 jQuery
.extend
= jQuery
.fn
.extend = function() {
228 var options
, name
, src
, copy
, copyIsArray
, clone
,
229 target
= arguments
[ 0 ] || {},
231 length
= arguments
.length
,
234 // Handle a deep copy situation
235 if ( typeof target
=== "boolean" ) {
238 // Skip the boolean and the target
239 target
= arguments
[ i
] || {};
243 // Handle case when target is a string or something (possible in deep copy)
244 if ( typeof target
!== "object" && !isFunction( target
) ) {
248 // Extend jQuery itself if only one argument is passed
249 if ( i
=== length
) {
254 for ( ; i
< length
; i
++ ) {
256 // Only deal with non-null/undefined values
257 if ( ( options
= arguments
[ i
] ) != null ) {
259 // Extend the base object
260 for ( name
in options
) {
261 src
= target
[ name
];
262 copy
= options
[ name
];
264 // Prevent Object.prototype pollution
265 // Prevent never-ending loop
266 if ( name
=== "__proto__" || target
=== copy
) {
270 // Recurse if we're merging plain objects or arrays
271 if ( deep
&& copy
&& ( jQuery
.isPlainObject( copy
) ||
272 ( copyIsArray
= Array
.isArray( copy
) ) ) ) {
276 clone
= src
&& Array
.isArray( src
) ? src
: [];
279 clone
= src
&& jQuery
.isPlainObject( src
) ? src
: {};
282 // Never move original objects, clone them
283 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
285 // Don't bring in undefined values
286 } else if ( copy
!== undefined ) {
287 target
[ name
] = copy
;
293 // Return the modified object
299 // Unique for each copy of jQuery on the page
300 expando
: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
302 // Assume jQuery is ready without the ready module
305 error: function( msg
) {
306 throw new Error( msg
);
311 isPlainObject: function( obj
) {
314 // Detect obvious negatives
315 // Use toString instead of jQuery.type to catch host objects
316 if ( !obj
|| toString
.call( obj
) !== "[object Object]" ) {
320 proto
= getProto( obj
);
322 // Objects with no prototype (e.g., `Object.create( null )`) are plain
327 // Objects with prototype are plain iff they were constructed by a global Object function
328 Ctor
= hasOwn
.call( proto
, "constructor" ) && proto
.constructor;
329 return typeof Ctor
=== "function" && fnToString
.call( Ctor
) === ObjectFunctionString
;
332 isEmptyObject: function( obj
) {
334 /* eslint-disable no-unused-vars */
335 // See https://github.com/eslint/eslint/issues/6125
338 for ( name
in obj
) {
344 // Evaluates a script in a global context
345 globalEval: function( code
) {
349 each: function( obj
, callback
) {
352 if ( isArrayLike( obj
) ) {
354 for ( ; i
< length
; i
++ ) {
355 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
361 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
370 // Support: Android <=4.0 only
371 trim: function( text
) {
372 return text
== null ?
374 ( text
+ "" ).replace( rtrim
, "" );
377 // results is for internal usage only
378 makeArray: function( arr
, results
) {
379 var ret
= results
|| [];
382 if ( isArrayLike( Object( arr
) ) ) {
384 typeof arr
=== "string" ?
388 push
.call( ret
, arr
);
395 inArray: function( elem
, arr
, i
) {
396 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
399 // Support: Android <=4.0 only, PhantomJS 1 only
400 // push.apply(_, arraylike) throws on ancient WebKit
401 merge: function( first
, second
) {
402 var len
= +second
.length
,
406 for ( ; j
< len
; j
++ ) {
407 first
[ i
++ ] = second
[ j
];
415 grep: function( elems
, callback
, invert
) {
419 length
= elems
.length
,
420 callbackExpect
= !invert
;
422 // Go through the array, only saving the items
423 // that pass the validator function
424 for ( ; i
< length
; i
++ ) {
425 callbackInverse
= !callback( elems
[ i
], i
);
426 if ( callbackInverse
!== callbackExpect
) {
427 matches
.push( elems
[ i
] );
434 // arg is for internal usage only
435 map: function( elems
, callback
, arg
) {
440 // Go through the array, translating each of the items to their new values
441 if ( isArrayLike( elems
) ) {
442 length
= elems
.length
;
443 for ( ; i
< length
; i
++ ) {
444 value
= callback( elems
[ i
], i
, arg
);
446 if ( value
!= null ) {
451 // Go through every key on the object,
454 value
= callback( elems
[ i
], i
, arg
);
456 if ( value
!= null ) {
462 // Flatten any nested arrays
463 return concat
.apply( [], ret
);
466 // A global GUID counter for objects
469 // jQuery.support is not used in Core but other projects attach their
470 // properties to it so it needs to exist.
474 if ( typeof Symbol
=== "function" ) {
475 jQuery
.fn
[ Symbol
.iterator
] = arr
[ Symbol
.iterator
];
478 // Populate the class2type map
479 jQuery
.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
480 function( i
, name
) {
481 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
484 function isArrayLike( obj
) {
486 // Support: real iOS 8.2 only (not reproducible in simulator)
487 // `in` check used to prevent JIT error (gh-2145)
488 // hasOwn isn't used here due to false negatives
489 // regarding Nodelist length in IE
490 var length
= !!obj
&& "length" in obj
&& obj
.length
,
491 type
= toType( obj
);
493 if ( isFunction( obj
) || isWindow( obj
) ) {
497 return type
=== "array" || length
=== 0 ||
498 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
502 * Sizzle CSS Selector Engine v2.3.3
503 * https://sizzlejs.com/
505 * Copyright jQuery Foundation and other contributors
506 * Released under the MIT license
507 * http://jquery.org/license
511 (function( window
) {
525 // Local document vars
535 // Instance-specific data
536 expando
= "sizzle" + 1 * new Date(),
537 preferredDoc
= window
.document
,
540 classCache
= createCache(),
541 tokenCache
= createCache(),
542 compilerCache
= createCache(),
543 sortOrder = function( a
, b
) {
551 hasOwn
= ({}).hasOwnProperty
,
554 push_native
= arr
.push
,
557 // Use a stripped-down indexOf as it's faster than native
558 // https://jsperf.com/thor-indexof-vs-for/5
559 indexOf = function( list
, elem
) {
562 for ( ; i
< len
; i
++ ) {
563 if ( list
[i
] === elem
) {
570 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
572 // Regular expressions
574 // http://www.w3.org/TR/css3-selectors/#whitespace
575 whitespace
= "[\\x20\\t\\r\\n\\f]",
577 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
578 identifier
= "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
580 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
581 attributes
= "\\[" + whitespace
+ "*(" + identifier
+ ")(?:" + whitespace
+
582 // Operator (capture 2)
583 "*([*^$|!~]?=)" + whitespace
+
584 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
585 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier
+ "))|)" + whitespace
+
588 pseudos
= ":(" + identifier
+ ")(?:\\((" +
589 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
590 // 1. quoted (capture 3; capture 4 or capture 5)
591 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
592 // 2. simple (capture 6)
593 "((?:\\\\.|[^\\\\()[\\]]|" + attributes
+ ")*)|" +
594 // 3. anything else (capture 2)
598 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
599 rwhitespace
= new RegExp( whitespace
+ "+", "g" ),
600 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
602 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
603 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
605 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*?)" + whitespace
+ "*\\]", "g" ),
607 rpseudo
= new RegExp( pseudos
),
608 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
611 "ID": new RegExp( "^#(" + identifier
+ ")" ),
612 "CLASS": new RegExp( "^\\.(" + identifier
+ ")" ),
613 "TAG": new RegExp( "^(" + identifier
+ "|[*])" ),
614 "ATTR": new RegExp( "^" + attributes
),
615 "PSEUDO": new RegExp( "^" + pseudos
),
616 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
617 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
618 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
619 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
620 // For use in libraries implementing .is()
621 // We use this for POS matching in `select`
622 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
623 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
626 rinputs
= /^(?:input|select|textarea|button)$/i,
629 rnative
= /^[^{]+\{\s*\[native \w/,
631 // Easily-parseable/retrievable ID or TAG or CLASS selectors
632 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
637 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
638 runescape
= new RegExp( "\\\\([\\da-f]{1,6}" + whitespace
+ "?|(" + whitespace
+ ")|.)", "ig" ),
639 funescape = function( _
, escaped
, escapedWhitespace
) {
640 var high
= "0x" + escaped
- 0x10000;
641 // NaN means non-codepoint
642 // Support: Firefox<24
643 // Workaround erroneous numeric interpretation of +"0x"
644 return high
!== high
|| escapedWhitespace
?
648 String
.fromCharCode( high
+ 0x10000 ) :
649 // Supplemental Plane codepoint (surrogate pair)
650 String
.fromCharCode( high
>> 10 | 0xD800, high
& 0x3FF | 0xDC00 );
653 // CSS string/identifier serialization
654 // https://drafts.csswg.org/cssom/#common-serializing-idioms
655 rcssescape
= /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
656 fcssescape = function( ch
, asCodePoint
) {
659 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
664 // Control characters and (dependent upon position) numbers get escaped as code points
665 return ch
.slice( 0, -1 ) + "\\" + ch
.charCodeAt( ch
.length
- 1 ).toString( 16 ) + " ";
668 // Other potentially-special ASCII characters get backslash-escaped
674 // Removing the function wrapper causes a "Permission Denied"
676 unloadHandler = function() {
680 disabledAncestor
= addCombinator(
682 return elem
.disabled
=== true && ("form" in elem
|| "label" in elem
);
684 { dir
: "parentNode", next
: "legend" }
687 // Optimize for push.apply( _, NodeList )
690 (arr
= slice
.call( preferredDoc
.childNodes
)),
691 preferredDoc
.childNodes
693 // Support: Android<4.0
694 // Detect silently failing push.apply
695 arr
[ preferredDoc
.childNodes
.length
].nodeType
;
697 push
= { apply
: arr
.length
?
699 // Leverage slice if possible
700 function( target
, els
) {
701 push_native
.apply( target
, slice
.call(els
) );
705 // Otherwise append directly
706 function( target
, els
) {
707 var j
= target
.length
,
709 // Can't trust NodeList.length
710 while ( (target
[j
++] = els
[i
++]) ) {}
711 target
.length
= j
- 1;
716 function Sizzle( selector
, context
, results
, seed
) {
717 var m
, i
, elem
, nid
, match
, groups
, newSelector
,
718 newContext
= context
&& context
.ownerDocument
,
720 // nodeType defaults to 9, since context defaults to document
721 nodeType
= context
? context
.nodeType
: 9;
723 results
= results
|| [];
725 // Return early from calls with invalid selector or context
726 if ( typeof selector
!== "string" || !selector
||
727 nodeType
!== 1 && nodeType
!== 9 && nodeType
!== 11 ) {
732 // Try to shortcut find operations (as opposed to filters) in HTML documents
735 if ( ( context
? context
.ownerDocument
|| context
: preferredDoc
) !== document
) {
736 setDocument( context
);
738 context
= context
|| document
;
740 if ( documentIsHTML
) {
742 // If the selector is sufficiently simple, try using a "get*By*" DOM method
743 // (excepting DocumentFragment context, where the methods don't exist)
744 if ( nodeType
!== 11 && (match
= rquickExpr
.exec( selector
)) ) {
747 if ( (m
= match
[1]) ) {
750 if ( nodeType
=== 9 ) {
751 if ( (elem
= context
.getElementById( m
)) ) {
753 // Support: IE, Opera, Webkit
754 // TODO: identify versions
755 // getElementById can match elements by name instead of ID
756 if ( elem
.id
=== m
) {
757 results
.push( elem
);
767 // Support: IE, Opera, Webkit
768 // TODO: identify versions
769 // getElementById can match elements by name instead of ID
770 if ( newContext
&& (elem
= newContext
.getElementById( m
)) &&
771 contains( context
, elem
) &&
774 results
.push( elem
);
780 } else if ( match
[2] ) {
781 push
.apply( results
, context
.getElementsByTagName( selector
) );
785 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&&
786 context
.getElementsByClassName
) {
788 push
.apply( results
, context
.getElementsByClassName( m
) );
793 // Take advantage of querySelectorAll
795 !compilerCache
[ selector
+ " " ] &&
796 (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
798 if ( nodeType
!== 1 ) {
799 newContext
= context
;
800 newSelector
= selector
;
802 // qSA looks outside Element context, which is not what we want
803 // Thanks to Andrew Dupont for this workaround technique
805 // Exclude object elements
806 } else if ( context
.nodeName
.toLowerCase() !== "object" ) {
808 // Capture the context ID, setting it first if necessary
809 if ( (nid
= context
.getAttribute( "id" )) ) {
810 nid
= nid
.replace( rcssescape
, fcssescape
);
812 context
.setAttribute( "id", (nid
= expando
) );
815 // Prefix every selector in the list
816 groups
= tokenize( selector
);
819 groups
[i
] = "#" + nid
+ " " + toSelector( groups
[i
] );
821 newSelector
= groups
.join( "," );
823 // Expand context for sibling selectors
824 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) ||
831 newContext
.querySelectorAll( newSelector
)
834 } catch ( qsaError
) {
836 if ( nid
=== expando
) {
837 context
.removeAttribute( "id" );
846 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
850 * Create key-value caches of limited size
851 * @returns {function(string, object)} Returns the Object data after storing it on itself with
852 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
853 * deleting the oldest entry
855 function createCache() {
858 function cache( key
, value
) {
859 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
860 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
861 // Only keep the most recent entries
862 delete cache
[ keys
.shift() ];
864 return (cache
[ key
+ " " ] = value
);
870 * Mark a function for special use by Sizzle
871 * @param {Function} fn The function to mark
873 function markFunction( fn
) {
874 fn
[ expando
] = true;
879 * Support testing using an element
880 * @param {Function} fn Passed the created element and returns a boolean result
882 function assert( fn
) {
883 var el
= document
.createElement("fieldset");
890 // Remove from its parent by default
891 if ( el
.parentNode
) {
892 el
.parentNode
.removeChild( el
);
894 // release memory in IE
900 * Adds the same handler for all of the specified attrs
901 * @param {String} attrs Pipe-separated list of attributes
902 * @param {Function} handler The method that will be applied
904 function addHandle( attrs
, handler
) {
905 var arr
= attrs
.split("|"),
909 Expr
.attrHandle
[ arr
[i
] ] = handler
;
914 * Checks document order of two siblings
917 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
919 function siblingCheck( a
, b
) {
921 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
922 a
.sourceIndex
- b
.sourceIndex
;
924 // Use IE sourceIndex if available on both nodes
929 // Check if b follows a
931 while ( (cur
= cur
.nextSibling
) ) {
942 * Returns a function to use in pseudos for input types
943 * @param {String} type
945 function createInputPseudo( type
) {
946 return function( elem
) {
947 var name
= elem
.nodeName
.toLowerCase();
948 return name
=== "input" && elem
.type
=== type
;
953 * Returns a function to use in pseudos for buttons
954 * @param {String} type
956 function createButtonPseudo( type
) {
957 return function( elem
) {
958 var name
= elem
.nodeName
.toLowerCase();
959 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
964 * Returns a function to use in pseudos for :enabled/:disabled
965 * @param {Boolean} disabled true for :disabled; false for :enabled
967 function createDisabledPseudo( disabled
) {
969 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
970 return function( elem
) {
972 // Only certain elements can match :enabled or :disabled
973 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
974 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
975 if ( "form" in elem
) {
977 // Check for inherited disabledness on relevant non-disabled elements:
978 // * listed form-associated elements in a disabled fieldset
979 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
980 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
981 // * option elements in a disabled optgroup
982 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
983 // All such elements have a "form" property.
984 if ( elem
.parentNode
&& elem
.disabled
=== false ) {
986 // Option elements defer to a parent optgroup if present
987 if ( "label" in elem
) {
988 if ( "label" in elem
.parentNode
) {
989 return elem
.parentNode
.disabled
=== disabled
;
991 return elem
.disabled
=== disabled
;
995 // Support: IE 6 - 11
996 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
997 return elem
.isDisabled
=== disabled
||
999 // Where there is no isDisabled, check manually
1001 elem
.isDisabled
!== !disabled
&&
1002 disabledAncestor( elem
) === disabled
;
1005 return elem
.disabled
=== disabled
;
1007 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1008 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1009 // even exist on them, let alone have a boolean value.
1010 } else if ( "label" in elem
) {
1011 return elem
.disabled
=== disabled
;
1014 // Remaining elements are neither :enabled nor :disabled
1020 * Returns a function to use in pseudos for positionals
1021 * @param {Function} fn
1023 function createPositionalPseudo( fn
) {
1024 return markFunction(function( argument
) {
1025 argument
= +argument
;
1026 return markFunction(function( seed
, matches
) {
1028 matchIndexes
= fn( [], seed
.length
, argument
),
1029 i
= matchIndexes
.length
;
1031 // Match elements found at the specified indexes
1033 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
1034 seed
[j
] = !(matches
[j
] = seed
[j
]);
1042 * Checks a node for validity as a Sizzle context
1043 * @param {Element|Object=} context
1044 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1046 function testContext( context
) {
1047 return context
&& typeof context
.getElementsByTagName
!== "undefined" && context
;
1050 // Expose support vars for convenience
1051 support
= Sizzle
.support
= {};
1055 * @param {Element|Object} elem An element or a document
1056 * @returns {Boolean} True iff elem is a non-HTML XML node
1058 isXML
= Sizzle
.isXML = function( elem
) {
1059 // documentElement is verified for cases where it doesn't yet exist
1060 // (such as loading iframes in IE - #4833)
1061 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
1062 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1066 * Sets document-related variables once based on the current document
1067 * @param {Element|Object} [doc] An element or document object to use to set the document
1068 * @returns {Object} Returns the current document
1070 setDocument
= Sizzle
.setDocument = function( node
) {
1071 var hasCompare
, subWindow
,
1072 doc
= node
? node
.ownerDocument
|| node
: preferredDoc
;
1074 // Return early if doc is invalid or already selected
1075 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1079 // Update global variables
1081 docElem
= document
.documentElement
;
1082 documentIsHTML
= !isXML( document
);
1084 // Support: IE 9-11, Edge
1085 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1086 if ( preferredDoc
!== document
&&
1087 (subWindow
= document
.defaultView
) && subWindow
.top
!== subWindow
) {
1089 // Support: IE 11, Edge
1090 if ( subWindow
.addEventListener
) {
1091 subWindow
.addEventListener( "unload", unloadHandler
, false );
1093 // Support: IE 9 - 10 only
1094 } else if ( subWindow
.attachEvent
) {
1095 subWindow
.attachEvent( "onunload", unloadHandler
);
1100 ---------------------------------------------------------------------- */
1103 // Verify that getAttribute really returns attributes and not properties
1104 // (excepting IE8 booleans)
1105 support
.attributes
= assert(function( el
) {
1107 return !el
.getAttribute("className");
1111 ---------------------------------------------------------------------- */
1113 // Check if getElementsByTagName("*") returns only elements
1114 support
.getElementsByTagName
= assert(function( el
) {
1115 el
.appendChild( document
.createComment("") );
1116 return !el
.getElementsByTagName("*").length
;
1120 support
.getElementsByClassName
= rnative
.test( document
.getElementsByClassName
);
1123 // Check if getElementById returns elements by name
1124 // The broken getElementById methods don't pick up programmatically-set names,
1125 // so use a roundabout getElementsByName test
1126 support
.getById
= assert(function( el
) {
1127 docElem
.appendChild( el
).id
= expando
;
1128 return !document
.getElementsByName
|| !document
.getElementsByName( expando
).length
;
1131 // ID filter and find
1132 if ( support
.getById
) {
1133 Expr
.filter
["ID"] = function( id
) {
1134 var attrId
= id
.replace( runescape
, funescape
);
1135 return function( elem
) {
1136 return elem
.getAttribute("id") === attrId
;
1139 Expr
.find
["ID"] = function( id
, context
) {
1140 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1141 var elem
= context
.getElementById( id
);
1142 return elem
? [ elem
] : [];
1146 Expr
.filter
["ID"] = function( id
) {
1147 var attrId
= id
.replace( runescape
, funescape
);
1148 return function( elem
) {
1149 var node
= typeof elem
.getAttributeNode
!== "undefined" &&
1150 elem
.getAttributeNode("id");
1151 return node
&& node
.value
=== attrId
;
1155 // Support: IE 6 - 7 only
1156 // getElementById is not reliable as a find shortcut
1157 Expr
.find
["ID"] = function( id
, context
) {
1158 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1160 elem
= context
.getElementById( id
);
1164 // Verify the id attribute
1165 node
= elem
.getAttributeNode("id");
1166 if ( node
&& node
.value
=== id
) {
1170 // Fall back on getElementsByName
1171 elems
= context
.getElementsByName( id
);
1173 while ( (elem
= elems
[i
++]) ) {
1174 node
= elem
.getAttributeNode("id");
1175 if ( node
&& node
.value
=== id
) {
1187 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1188 function( tag
, context
) {
1189 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
1190 return context
.getElementsByTagName( tag
);
1192 // DocumentFragment nodes don't have gEBTN
1193 } else if ( support
.qsa
) {
1194 return context
.querySelectorAll( tag
);
1198 function( tag
, context
) {
1202 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1203 results
= context
.getElementsByTagName( tag
);
1205 // Filter out possible comments
1206 if ( tag
=== "*" ) {
1207 while ( (elem
= results
[i
++]) ) {
1208 if ( elem
.nodeType
=== 1 ) {
1219 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1220 if ( typeof context
.getElementsByClassName
!== "undefined" && documentIsHTML
) {
1221 return context
.getElementsByClassName( className
);
1225 /* QSA/matchesSelector
1226 ---------------------------------------------------------------------- */
1228 // QSA and matchesSelector support
1230 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1233 // qSa(:focus) reports false when true (Chrome 21)
1234 // We allow this because of a bug in IE8/9 that throws an error
1235 // whenever `document.activeElement` is accessed on an iframe
1236 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1237 // See https://bugs.jquery.com/ticket/13378
1240 if ( (support
.qsa
= rnative
.test( document
.querySelectorAll
)) ) {
1242 // Regex strategy adopted from Diego Perini
1243 assert(function( el
) {
1244 // Select is set to empty string on purpose
1245 // This is to test IE's treatment of not explicitly
1246 // setting a boolean content attribute,
1247 // since its presence should be enough
1248 // https://bugs.jquery.com/ticket/12359
1249 docElem
.appendChild( el
).innerHTML
= "<a id='" + expando
+ "'></a>" +
1250 "<select id='" + expando
+ "-\r\\' msallowcapture=''>" +
1251 "<option selected=''></option></select>";
1253 // Support: IE8, Opera 11-12.16
1254 // Nothing should be selected when empty strings follow ^= or $= or *=
1255 // The test attribute must be unknown in Opera but "safe" for WinRT
1256 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1257 if ( el
.querySelectorAll("[msallowcapture^='']").length
) {
1258 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1262 // Boolean attributes and "value" are not treated correctly
1263 if ( !el
.querySelectorAll("[selected]").length
) {
1264 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1267 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1268 if ( !el
.querySelectorAll( "[id~=" + expando
+ "-]" ).length
) {
1269 rbuggyQSA
.push("~=");
1272 // Webkit/Opera - :checked should return selected option elements
1273 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1274 // IE8 throws error here and will not see later tests
1275 if ( !el
.querySelectorAll(":checked").length
) {
1276 rbuggyQSA
.push(":checked");
1279 // Support: Safari 8+, iOS 8+
1280 // https://bugs.webkit.org/show_bug.cgi?id=136851
1281 // In-page `selector#id sibling-combinator selector` fails
1282 if ( !el
.querySelectorAll( "a#" + expando
+ "+*" ).length
) {
1283 rbuggyQSA
.push(".#.+[+~]");
1287 assert(function( el
) {
1288 el
.innerHTML
= "<a href='' disabled='disabled'></a>" +
1289 "<select disabled='disabled'><option/></select>";
1291 // Support: Windows 8 Native Apps
1292 // The type and name attributes are restricted during .innerHTML assignment
1293 var input
= document
.createElement("input");
1294 input
.setAttribute( "type", "hidden" );
1295 el
.appendChild( input
).setAttribute( "name", "D" );
1298 // Enforce case-sensitivity of name attribute
1299 if ( el
.querySelectorAll("[name=d]").length
) {
1300 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1303 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1304 // IE8 throws error here and will not see later tests
1305 if ( el
.querySelectorAll(":enabled").length
!== 2 ) {
1306 rbuggyQSA
.push( ":enabled", ":disabled" );
1310 // IE's :disabled selector does not pick up the children of disabled fieldsets
1311 docElem
.appendChild( el
).disabled
= true;
1312 if ( el
.querySelectorAll(":disabled").length
!== 2 ) {
1313 rbuggyQSA
.push( ":enabled", ":disabled" );
1316 // Opera 10-11 does not throw on post-comma invalid pseudos
1317 el
.querySelectorAll("*,:x");
1318 rbuggyQSA
.push(",.*:");
1322 if ( (support
.matchesSelector
= rnative
.test( (matches
= docElem
.matches
||
1323 docElem
.webkitMatchesSelector
||
1324 docElem
.mozMatchesSelector
||
1325 docElem
.oMatchesSelector
||
1326 docElem
.msMatchesSelector
) )) ) {
1328 assert(function( el
) {
1329 // Check to see if it's possible to do matchesSelector
1330 // on a disconnected node (IE 9)
1331 support
.disconnectedMatch
= matches
.call( el
, "*" );
1333 // This should fail with an exception
1334 // Gecko does not error, returns false instead
1335 matches
.call( el
, "[s!='']:x" );
1336 rbuggyMatches
.push( "!=", pseudos
);
1340 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1341 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1344 ---------------------------------------------------------------------- */
1345 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1347 // Element contains another
1348 // Purposefully self-exclusive
1349 // As in, an element does not contain itself
1350 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1352 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
1353 bup
= b
&& b
.parentNode
;
1354 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1356 adown
.contains( bup
) :
1357 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1362 while ( (b
= b
.parentNode
) ) {
1372 ---------------------------------------------------------------------- */
1374 // Document order sorting
1375 sortOrder
= hasCompare
?
1378 // Flag for duplicate removal
1380 hasDuplicate
= true;
1384 // Sort on method existence if only one input has compareDocumentPosition
1385 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1390 // Calculate position if both inputs belong to the same document
1391 compare
= ( a
.ownerDocument
|| a
) === ( b
.ownerDocument
|| b
) ?
1392 a
.compareDocumentPosition( b
) :
1394 // Otherwise we know they are disconnected
1397 // Disconnected nodes
1399 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1401 // Choose the first element that is related to our preferred document
1402 if ( a
=== document
|| a
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, a
) ) {
1405 if ( b
=== document
|| b
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, b
) ) {
1409 // Maintain original order
1411 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1415 return compare
& 4 ? -1 : 1;
1418 // Exit early if the nodes are identical
1420 hasDuplicate
= true;
1431 // Parentless nodes are either documents or disconnected
1432 if ( !aup
|| !bup
) {
1433 return a
=== document
? -1 :
1434 b
=== document
? 1 :
1438 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1441 // If the nodes are siblings, we can do a quick check
1442 } else if ( aup
=== bup
) {
1443 return siblingCheck( a
, b
);
1446 // Otherwise we need full lists of their ancestors for comparison
1448 while ( (cur
= cur
.parentNode
) ) {
1452 while ( (cur
= cur
.parentNode
) ) {
1456 // Walk down the tree looking for a discrepancy
1457 while ( ap
[i
] === bp
[i
] ) {
1462 // Do a sibling check if the nodes have a common ancestor
1463 siblingCheck( ap
[i
], bp
[i
] ) :
1465 // Otherwise nodes in our document sort first
1466 ap
[i
] === preferredDoc
? -1 :
1467 bp
[i
] === preferredDoc
? 1 :
1474 Sizzle
.matches = function( expr
, elements
) {
1475 return Sizzle( expr
, null, null, elements
);
1478 Sizzle
.matchesSelector = function( elem
, expr
) {
1479 // Set document vars if needed
1480 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1481 setDocument( elem
);
1484 // Make sure that attribute selectors are quoted
1485 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1487 if ( support
.matchesSelector
&& documentIsHTML
&&
1488 !compilerCache
[ expr
+ " " ] &&
1489 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1490 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1493 var ret
= matches
.call( elem
, expr
);
1495 // IE 9's matchesSelector returns false on disconnected nodes
1496 if ( ret
|| support
.disconnectedMatch
||
1497 // As well, disconnected nodes are said to be in a document
1499 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1505 return Sizzle( expr
, document
, null, [ elem
] ).length
> 0;
1508 Sizzle
.contains = function( context
, elem
) {
1509 // Set document vars if needed
1510 if ( ( context
.ownerDocument
|| context
) !== document
) {
1511 setDocument( context
);
1513 return contains( context
, elem
);
1516 Sizzle
.attr = function( elem
, name
) {
1517 // Set document vars if needed
1518 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1519 setDocument( elem
);
1522 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1523 // Don't get fooled by Object.prototype properties (jQuery #13807)
1524 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1525 fn( elem
, name
, !documentIsHTML
) :
1528 return val
!== undefined ?
1530 support
.attributes
|| !documentIsHTML
?
1531 elem
.getAttribute( name
) :
1532 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1537 Sizzle
.escape = function( sel
) {
1538 return (sel
+ "").replace( rcssescape
, fcssescape
);
1541 Sizzle
.error = function( msg
) {
1542 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1546 * Document sorting and removing duplicates
1547 * @param {ArrayLike} results
1549 Sizzle
.uniqueSort = function( results
) {
1555 // Unless we *know* we can detect duplicates, assume their presence
1556 hasDuplicate
= !support
.detectDuplicates
;
1557 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1558 results
.sort( sortOrder
);
1560 if ( hasDuplicate
) {
1561 while ( (elem
= results
[i
++]) ) {
1562 if ( elem
=== results
[ i
] ) {
1563 j
= duplicates
.push( i
);
1567 results
.splice( duplicates
[ j
], 1 );
1571 // Clear input after sorting to release objects
1572 // See https://github.com/jquery/sizzle/pull/225
1579 * Utility function for retrieving the text value of an array of DOM nodes
1580 * @param {Array|Element} elem
1582 getText
= Sizzle
.getText = function( elem
) {
1586 nodeType
= elem
.nodeType
;
1589 // If no nodeType, this is expected to be an array
1590 while ( (node
= elem
[i
++]) ) {
1591 // Do not traverse comment nodes
1592 ret
+= getText( node
);
1594 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1595 // Use textContent for elements
1596 // innerText usage removed for consistency of new lines (jQuery #11153)
1597 if ( typeof elem
.textContent
=== "string" ) {
1598 return elem
.textContent
;
1600 // Traverse its children
1601 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1602 ret
+= getText( elem
);
1605 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1606 return elem
.nodeValue
;
1608 // Do not include comment or processing instruction nodes
1613 Expr
= Sizzle
.selectors
= {
1615 // Can be adjusted by the user
1618 createPseudo
: markFunction
,
1627 ">": { dir
: "parentNode", first
: true },
1628 " ": { dir
: "parentNode" },
1629 "+": { dir
: "previousSibling", first
: true },
1630 "~": { dir
: "previousSibling" }
1634 "ATTR": function( match
) {
1635 match
[1] = match
[1].replace( runescape
, funescape
);
1637 // Move the given value to match[3] whether quoted or unquoted
1638 match
[3] = ( match
[3] || match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1640 if ( match
[2] === "~=" ) {
1641 match
[3] = " " + match
[3] + " ";
1644 return match
.slice( 0, 4 );
1647 "CHILD": function( match
) {
1648 /* matches from matchExpr["CHILD"]
1649 1 type (only|nth|...)
1650 2 what (child|of-type)
1651 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1652 4 xn-component of xn+y argument ([+-]?\d*n|)
1653 5 sign of xn-component
1655 7 sign of y-component
1658 match
[1] = match
[1].toLowerCase();
1660 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1661 // nth-* requires argument
1663 Sizzle
.error( match
[0] );
1666 // numeric x and y parameters for Expr.filter.CHILD
1667 // remember that false/true cast respectively to 0/1
1668 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1669 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1671 // other types prohibit arguments
1672 } else if ( match
[3] ) {
1673 Sizzle
.error( match
[0] );
1679 "PSEUDO": function( match
) {
1681 unquoted
= !match
[6] && match
[2];
1683 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1687 // Accept quoted arguments as-is
1689 match
[2] = match
[4] || match
[5] || "";
1691 // Strip excess characters from unquoted arguments
1692 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1693 // Get excess from tokenize (recursively)
1694 (excess
= tokenize( unquoted
, true )) &&
1695 // advance to the next closing parenthesis
1696 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1698 // excess is a negative index
1699 match
[0] = match
[0].slice( 0, excess
);
1700 match
[2] = unquoted
.slice( 0, excess
);
1703 // Return only captures needed by the pseudo filter method (type and argument)
1704 return match
.slice( 0, 3 );
1710 "TAG": function( nodeNameSelector
) {
1711 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1712 return nodeNameSelector
=== "*" ?
1713 function() { return true; } :
1715 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1719 "CLASS": function( className
) {
1720 var pattern
= classCache
[ className
+ " " ];
1723 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1724 classCache( className
, function( elem
) {
1725 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== "undefined" && elem
.getAttribute("class") || "" );
1729 "ATTR": function( name
, operator
, check
) {
1730 return function( elem
) {
1731 var result
= Sizzle
.attr( elem
, name
);
1733 if ( result
== null ) {
1734 return operator
=== "!=";
1742 return operator
=== "=" ? result
=== check
:
1743 operator
=== "!=" ? result
!== check
:
1744 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1745 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1746 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check
:
1747 operator
=== "~=" ? ( " " + result
.replace( rwhitespace
, " " ) + " " ).indexOf( check
) > -1 :
1748 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1753 "CHILD": function( type
, what
, argument
, first
, last
) {
1754 var simple
= type
.slice( 0, 3 ) !== "nth",
1755 forward
= type
.slice( -4 ) !== "last",
1756 ofType
= what
=== "of-type";
1758 return first
=== 1 && last
=== 0 ?
1760 // Shortcut for :nth-*(n)
1762 return !!elem
.parentNode
;
1765 function( elem
, context
, xml
) {
1766 var cache
, uniqueCache
, outerCache
, node
, nodeIndex
, start
,
1767 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1768 parent
= elem
.parentNode
,
1769 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1770 useCache
= !xml
&& !ofType
,
1775 // :(first|last|only)-(child|of-type)
1779 while ( (node
= node
[ dir
]) ) {
1781 node
.nodeName
.toLowerCase() === name
:
1782 node
.nodeType
=== 1 ) {
1787 // Reverse direction for :only-* (if we haven't yet done so)
1788 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1793 start
= [ forward
? parent
.firstChild
: parent
.lastChild
];
1795 // non-xml :nth-child(...) stores cache data on `parent`
1796 if ( forward
&& useCache
) {
1798 // Seek `elem` from a previously-cached index
1800 // ...in a gzip-friendly way
1802 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1804 // Support: IE <9 only
1805 // Defend against cloned attroperties (jQuery gh-1709)
1806 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1807 (outerCache
[ node
.uniqueID
] = {});
1809 cache
= uniqueCache
[ type
] || [];
1810 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1811 diff
= nodeIndex
&& cache
[ 2 ];
1812 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1814 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1816 // Fallback to seeking `elem` from the start
1817 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1819 // When found, cache indexes on `parent` and break
1820 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1821 uniqueCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1827 // Use previously-cached element index if available
1829 // ...in a gzip-friendly way
1831 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1833 // Support: IE <9 only
1834 // Defend against cloned attroperties (jQuery gh-1709)
1835 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1836 (outerCache
[ node
.uniqueID
] = {});
1838 cache
= uniqueCache
[ type
] || [];
1839 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1843 // xml :nth-child(...)
1844 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1845 if ( diff
=== false ) {
1846 // Use the same loop as above to seek `elem` from the start
1847 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1848 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1851 node
.nodeName
.toLowerCase() === name
:
1852 node
.nodeType
=== 1 ) &&
1855 // Cache the index of each encountered element
1857 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1859 // Support: IE <9 only
1860 // Defend against cloned attroperties (jQuery gh-1709)
1861 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1862 (outerCache
[ node
.uniqueID
] = {});
1864 uniqueCache
[ type
] = [ dirruns
, diff
];
1867 if ( node
=== elem
) {
1875 // Incorporate the offset, then check against cycle size
1877 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
1882 "PSEUDO": function( pseudo
, argument
) {
1883 // pseudo-class names are case-insensitive
1884 // http://www.w3.org/TR/selectors/#pseudo-classes
1885 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1886 // Remember that setFilters inherits from pseudos
1888 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
1889 Sizzle
.error( "unsupported pseudo: " + pseudo
);
1891 // The user may use createPseudo to indicate that
1892 // arguments are needed to create the filter function
1893 // just as Sizzle does
1894 if ( fn
[ expando
] ) {
1895 return fn( argument
);
1898 // But maintain support for old signatures
1899 if ( fn
.length
> 1 ) {
1900 args
= [ pseudo
, pseudo
, "", argument
];
1901 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
1902 markFunction(function( seed
, matches
) {
1904 matched
= fn( seed
, argument
),
1907 idx
= indexOf( seed
, matched
[i
] );
1908 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
1912 return fn( elem
, 0, args
);
1921 // Potentially complex pseudos
1922 "not": markFunction(function( selector
) {
1923 // Trim the selector passed to compile
1924 // to avoid treating leading and trailing
1925 // spaces as combinators
1928 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
1930 return matcher
[ expando
] ?
1931 markFunction(function( seed
, matches
, context
, xml
) {
1933 unmatched
= matcher( seed
, null, xml
, [] ),
1936 // Match elements unmatched by `matcher`
1938 if ( (elem
= unmatched
[i
]) ) {
1939 seed
[i
] = !(matches
[i
] = elem
);
1943 function( elem
, context
, xml
) {
1945 matcher( input
, null, xml
, results
);
1946 // Don't keep the element (issue #299)
1948 return !results
.pop();
1952 "has": markFunction(function( selector
) {
1953 return function( elem
) {
1954 return Sizzle( selector
, elem
).length
> 0;
1958 "contains": markFunction(function( text
) {
1959 text
= text
.replace( runescape
, funescape
);
1960 return function( elem
) {
1961 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
1965 // "Whether an element is represented by a :lang() selector
1966 // is based solely on the element's language value
1967 // being equal to the identifier C,
1968 // or beginning with the identifier C immediately followed by "-".
1969 // The matching of C against the element's language value is performed case-insensitively.
1970 // The identifier C does not have to be a valid language name."
1971 // http://www.w3.org/TR/selectors/#lang-pseudo
1972 "lang": markFunction( function( lang
) {
1973 // lang value must be a valid identifier
1974 if ( !ridentifier
.test(lang
|| "") ) {
1975 Sizzle
.error( "unsupported lang: " + lang
);
1977 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
1978 return function( elem
) {
1981 if ( (elemLang
= documentIsHTML
?
1983 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
1985 elemLang
= elemLang
.toLowerCase();
1986 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
1988 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
1994 "target": function( elem
) {
1995 var hash
= window
.location
&& window
.location
.hash
;
1996 return hash
&& hash
.slice( 1 ) === elem
.id
;
1999 "root": function( elem
) {
2000 return elem
=== docElem
;
2003 "focus": function( elem
) {
2004 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
2007 // Boolean properties
2008 "enabled": createDisabledPseudo( false ),
2009 "disabled": createDisabledPseudo( true ),
2011 "checked": function( elem
) {
2012 // In CSS3, :checked should return both checked and selected elements
2013 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2014 var nodeName
= elem
.nodeName
.toLowerCase();
2015 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
2018 "selected": function( elem
) {
2019 // Accessing this property makes selected-by-default
2020 // options in Safari work properly
2021 if ( elem
.parentNode
) {
2022 elem
.parentNode
.selectedIndex
;
2025 return elem
.selected
=== true;
2029 "empty": function( elem
) {
2030 // http://www.w3.org/TR/selectors/#empty-pseudo
2031 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2032 // but not by others (comment: 8; processing instruction: 7; etc.)
2033 // nodeType < 6 works because attributes (2) do not appear as children
2034 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
2035 if ( elem
.nodeType
< 6 ) {
2042 "parent": function( elem
) {
2043 return !Expr
.pseudos
["empty"]( elem
);
2046 // Element/input types
2047 "header": function( elem
) {
2048 return rheader
.test( elem
.nodeName
);
2051 "input": function( elem
) {
2052 return rinputs
.test( elem
.nodeName
);
2055 "button": function( elem
) {
2056 var name
= elem
.nodeName
.toLowerCase();
2057 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
2060 "text": function( elem
) {
2062 return elem
.nodeName
.toLowerCase() === "input" &&
2063 elem
.type
=== "text" &&
2066 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2067 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === "text" );
2070 // Position-in-collection
2071 "first": createPositionalPseudo(function() {
2075 "last": createPositionalPseudo(function( matchIndexes
, length
) {
2076 return [ length
- 1 ];
2079 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2080 return [ argument
< 0 ? argument
+ length
: argument
];
2083 "even": createPositionalPseudo(function( matchIndexes
, length
) {
2085 for ( ; i
< length
; i
+= 2 ) {
2086 matchIndexes
.push( i
);
2088 return matchIndexes
;
2091 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
2093 for ( ; i
< length
; i
+= 2 ) {
2094 matchIndexes
.push( i
);
2096 return matchIndexes
;
2099 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2100 var i
= argument
< 0 ? argument
+ length
: argument
;
2101 for ( ; --i
>= 0; ) {
2102 matchIndexes
.push( i
);
2104 return matchIndexes
;
2107 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2108 var i
= argument
< 0 ? argument
+ length
: argument
;
2109 for ( ; ++i
< length
; ) {
2110 matchIndexes
.push( i
);
2112 return matchIndexes
;
2117 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
2119 // Add button/input type pseudos
2120 for ( i
in { radio
: true, checkbox
: true, file
: true, password
: true, image
: true } ) {
2121 Expr
.pseudos
[ i
] = createInputPseudo( i
);
2123 for ( i
in { submit
: true, reset
: true } ) {
2124 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
2127 // Easy API for creating new setFilters
2128 function setFilters() {}
2129 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
2130 Expr
.setFilters
= new setFilters();
2132 tokenize
= Sizzle
.tokenize = function( selector
, parseOnly
) {
2133 var matched
, match
, tokens
, type
,
2134 soFar
, groups
, preFilters
,
2135 cached
= tokenCache
[ selector
+ " " ];
2138 return parseOnly
? 0 : cached
.slice( 0 );
2143 preFilters
= Expr
.preFilter
;
2147 // Comma and first run
2148 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
2150 // Don't consume trailing commas as valid
2151 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2153 groups
.push( (tokens
= []) );
2159 if ( (match
= rcombinators
.exec( soFar
)) ) {
2160 matched
= match
.shift();
2163 // Cast descendant combinators to space
2164 type
: match
[0].replace( rtrim
, " " )
2166 soFar
= soFar
.slice( matched
.length
);
2170 for ( type
in Expr
.filter
) {
2171 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2172 (match
= preFilters
[ type
]( match
))) ) {
2173 matched
= match
.shift();
2179 soFar
= soFar
.slice( matched
.length
);
2188 // Return the length of the invalid excess
2189 // if we're just parsing
2190 // Otherwise, throw an error or return tokens
2194 Sizzle
.error( selector
) :
2196 tokenCache( selector
, groups
).slice( 0 );
2199 function toSelector( tokens
) {
2201 len
= tokens
.length
,
2203 for ( ; i
< len
; i
++ ) {
2204 selector
+= tokens
[i
].value
;
2209 function addCombinator( matcher
, combinator
, base
) {
2210 var dir
= combinator
.dir
,
2211 skip
= combinator
.next
,
2213 checkNonElements
= base
&& key
=== "parentNode",
2216 return combinator
.first
?
2217 // Check against closest ancestor/preceding element
2218 function( elem
, context
, xml
) {
2219 while ( (elem
= elem
[ dir
]) ) {
2220 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2221 return matcher( elem
, context
, xml
);
2227 // Check against all ancestor/preceding elements
2228 function( elem
, context
, xml
) {
2229 var oldCache
, uniqueCache
, outerCache
,
2230 newCache
= [ dirruns
, doneName
];
2232 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2234 while ( (elem
= elem
[ dir
]) ) {
2235 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2236 if ( matcher( elem
, context
, xml
) ) {
2242 while ( (elem
= elem
[ dir
]) ) {
2243 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2244 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2246 // Support: IE <9 only
2247 // Defend against cloned attroperties (jQuery gh-1709)
2248 uniqueCache
= outerCache
[ elem
.uniqueID
] || (outerCache
[ elem
.uniqueID
] = {});
2250 if ( skip
&& skip
=== elem
.nodeName
.toLowerCase() ) {
2251 elem
= elem
[ dir
] || elem
;
2252 } else if ( (oldCache
= uniqueCache
[ key
]) &&
2253 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2255 // Assign to newCache so results back-propagate to previous elements
2256 return (newCache
[ 2 ] = oldCache
[ 2 ]);
2258 // Reuse newcache so results back-propagate to previous elements
2259 uniqueCache
[ key
] = newCache
;
2261 // A match means we're done; a fail means we have to keep checking
2262 if ( (newCache
[ 2 ] = matcher( elem
, context
, xml
)) ) {
2273 function elementMatcher( matchers
) {
2274 return matchers
.length
> 1 ?
2275 function( elem
, context
, xml
) {
2276 var i
= matchers
.length
;
2278 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2287 function multipleContexts( selector
, contexts
, results
) {
2289 len
= contexts
.length
;
2290 for ( ; i
< len
; i
++ ) {
2291 Sizzle( selector
, contexts
[i
], results
);
2296 function condense( unmatched
, map
, filter
, context
, xml
) {
2300 len
= unmatched
.length
,
2301 mapped
= map
!= null;
2303 for ( ; i
< len
; i
++ ) {
2304 if ( (elem
= unmatched
[i
]) ) {
2305 if ( !filter
|| filter( elem
, context
, xml
) ) {
2306 newUnmatched
.push( elem
);
2314 return newUnmatched
;
2317 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2318 if ( postFilter
&& !postFilter
[ expando
] ) {
2319 postFilter
= setMatcher( postFilter
);
2321 if ( postFinder
&& !postFinder
[ expando
] ) {
2322 postFinder
= setMatcher( postFinder
, postSelector
);
2324 return markFunction(function( seed
, results
, context
, xml
) {
2328 preexisting
= results
.length
,
2330 // Get initial elements from seed or context
2331 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2333 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2334 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2335 condense( elems
, preMap
, preFilter
, context
, xml
) :
2338 matcherOut
= matcher
?
2339 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2340 postFinder
|| ( seed
? preFilter
: preexisting
|| postFilter
) ?
2342 // ...intermediate processing is necessary
2345 // ...otherwise use results directly
2349 // Find primary matches
2351 matcher( matcherIn
, matcherOut
, context
, xml
);
2356 temp
= condense( matcherOut
, postMap
);
2357 postFilter( temp
, [], context
, xml
);
2359 // Un-match failing elements by moving them back to matcherIn
2362 if ( (elem
= temp
[i
]) ) {
2363 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2369 if ( postFinder
|| preFilter
) {
2371 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2373 i
= matcherOut
.length
;
2375 if ( (elem
= matcherOut
[i
]) ) {
2376 // Restore matcherIn since elem is not yet a final match
2377 temp
.push( (matcherIn
[i
] = elem
) );
2380 postFinder( null, (matcherOut
= []), temp
, xml
);
2383 // Move matched elements from seed to results to keep them synchronized
2384 i
= matcherOut
.length
;
2386 if ( (elem
= matcherOut
[i
]) &&
2387 (temp
= postFinder
? indexOf( seed
, elem
) : preMap
[i
]) > -1 ) {
2389 seed
[temp
] = !(results
[temp
] = elem
);
2394 // Add elements to results, through postFinder if defined
2396 matcherOut
= condense(
2397 matcherOut
=== results
?
2398 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2402 postFinder( null, results
, matcherOut
, xml
);
2404 push
.apply( results
, matcherOut
);
2410 function matcherFromTokens( tokens
) {
2411 var checkContext
, matcher
, j
,
2412 len
= tokens
.length
,
2413 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2414 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2415 i
= leadingRelative
? 1 : 0,
2417 // The foundational matcher ensures that elements are reachable from top-level context(s)
2418 matchContext
= addCombinator( function( elem
) {
2419 return elem
=== checkContext
;
2420 }, implicitRelative
, true ),
2421 matchAnyContext
= addCombinator( function( elem
) {
2422 return indexOf( checkContext
, elem
) > -1;
2423 }, implicitRelative
, true ),
2424 matchers
= [ function( elem
, context
, xml
) {
2425 var ret
= ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2426 (checkContext
= context
).nodeType
?
2427 matchContext( elem
, context
, xml
) :
2428 matchAnyContext( elem
, context
, xml
) );
2429 // Avoid hanging onto element (issue #299)
2430 checkContext
= null;
2434 for ( ; i
< len
; i
++ ) {
2435 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2436 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2438 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2440 // Return special upon seeing a positional matcher
2441 if ( matcher
[ expando
] ) {
2442 // Find the next relative operator (if any) for proper handling
2444 for ( ; j
< len
; j
++ ) {
2445 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2450 i
> 1 && elementMatcher( matchers
),
2451 i
> 1 && toSelector(
2452 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2453 tokens
.slice( 0, i
- 1 ).concat({ value
: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2454 ).replace( rtrim
, "$1" ),
2456 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2457 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2458 j
< len
&& toSelector( tokens
)
2461 matchers
.push( matcher
);
2465 return elementMatcher( matchers
);
2468 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2469 var bySet
= setMatchers
.length
> 0,
2470 byElement
= elementMatchers
.length
> 0,
2471 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2472 var elem
, j
, matcher
,
2475 unmatched
= seed
&& [],
2477 contextBackup
= outermostContext
,
2478 // We must always have either seed elements or outermost context
2479 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", outermost
),
2480 // Use integer dirruns iff this is the outermost matcher
2481 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1),
2485 outermostContext
= context
=== document
|| context
|| outermost
;
2488 // Add elements passing elementMatchers directly to results
2489 // Support: IE<9, Safari
2490 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2491 for ( ; i
!== len
&& (elem
= elems
[i
]) != null; i
++ ) {
2492 if ( byElement
&& elem
) {
2494 if ( !context
&& elem
.ownerDocument
!== document
) {
2495 setDocument( elem
);
2496 xml
= !documentIsHTML
;
2498 while ( (matcher
= elementMatchers
[j
++]) ) {
2499 if ( matcher( elem
, context
|| document
, xml
) ) {
2500 results
.push( elem
);
2505 dirruns
= dirrunsUnique
;
2509 // Track unmatched elements for set filters
2511 // They will have gone through all possible matchers
2512 if ( (elem
= !matcher
&& elem
) ) {
2516 // Lengthen the array for every element, matched or not
2518 unmatched
.push( elem
);
2523 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2524 // makes the latter nonnegative.
2527 // Apply set filters to unmatched elements
2528 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2529 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2530 // no element matchers and no seed.
2531 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2532 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2533 // numerically zero.
2534 if ( bySet
&& i
!== matchedCount
) {
2536 while ( (matcher
= setMatchers
[j
++]) ) {
2537 matcher( unmatched
, setMatched
, context
, xml
);
2541 // Reintegrate element matches to eliminate the need for sorting
2542 if ( matchedCount
> 0 ) {
2544 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2545 setMatched
[i
] = pop
.call( results
);
2550 // Discard index placeholder values to get only actual matches
2551 setMatched
= condense( setMatched
);
2554 // Add matches to results
2555 push
.apply( results
, setMatched
);
2557 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2558 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2559 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2561 Sizzle
.uniqueSort( results
);
2565 // Override manipulation of globals by nested matchers
2567 dirruns
= dirrunsUnique
;
2568 outermostContext
= contextBackup
;
2575 markFunction( superMatcher
) :
2579 compile
= Sizzle
.compile = function( selector
, match
/* Internal Use Only */ ) {
2582 elementMatchers
= [],
2583 cached
= compilerCache
[ selector
+ " " ];
2586 // Generate a function of recursive functions that can be used to check each element
2588 match
= tokenize( selector
);
2592 cached
= matcherFromTokens( match
[i
] );
2593 if ( cached
[ expando
] ) {
2594 setMatchers
.push( cached
);
2596 elementMatchers
.push( cached
);
2600 // Cache the compiled function
2601 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2603 // Save selector and tokenization
2604 cached
.selector
= selector
;
2610 * A low-level selection function that works with Sizzle's compiled
2611 * selector functions
2612 * @param {String|Function} selector A selector or a pre-compiled
2613 * selector function built with Sizzle.compile
2614 * @param {Element} context
2615 * @param {Array} [results]
2616 * @param {Array} [seed] A set of elements to match against
2618 select
= Sizzle
.select = function( selector
, context
, results
, seed
) {
2619 var i
, tokens
, token
, type
, find
,
2620 compiled
= typeof selector
=== "function" && selector
,
2621 match
= !seed
&& tokenize( (selector
= compiled
.selector
|| selector
) );
2623 results
= results
|| [];
2625 // Try to minimize operations if there is only one selector in the list and no seed
2626 // (the latter of which guarantees us context)
2627 if ( match
.length
=== 1 ) {
2629 // Reduce context if the leading compound selector is an ID
2630 tokens
= match
[0] = match
[0].slice( 0 );
2631 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2632 context
.nodeType
=== 9 && documentIsHTML
&& Expr
.relative
[ tokens
[1].type
] ) {
2634 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2638 // Precompiled matchers will still verify ancestry, so step up a level
2639 } else if ( compiled
) {
2640 context
= context
.parentNode
;
2643 selector
= selector
.slice( tokens
.shift().value
.length
);
2646 // Fetch a seed set for right-to-left matching
2647 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2651 // Abort if we hit a combinator
2652 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2655 if ( (find
= Expr
.find
[ type
]) ) {
2656 // Search, expanding context for leading sibling combinators
2658 token
.matches
[0].replace( runescape
, funescape
),
2659 rsibling
.test( tokens
[0].type
) && testContext( context
.parentNode
) || context
2662 // If seed is empty or no tokens remain, we can return early
2663 tokens
.splice( i
, 1 );
2664 selector
= seed
.length
&& toSelector( tokens
);
2666 push
.apply( results
, seed
);
2676 // Compile and execute a filtering function if one is not provided
2677 // Provide `match` to avoid retokenization if we modified the selector above
2678 ( compiled
|| compile( selector
, match
) )(
2683 !context
|| rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2688 // One-time assignments
2691 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2693 // Support: Chrome 14-35+
2694 // Always assume duplicates if they aren't passed to the comparison function
2695 support
.detectDuplicates
= !!hasDuplicate
;
2697 // Initialize against the default document
2700 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2701 // Detached nodes confoundingly follow *each other*
2702 support
.sortDetached
= assert(function( el
) {
2703 // Should return 1, but returns 4 (following)
2704 return el
.compareDocumentPosition( document
.createElement("fieldset") ) & 1;
2708 // Prevent attribute/property "interpolation"
2709 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2710 if ( !assert(function( el
) {
2711 el
.innerHTML
= "<a href='#'></a>";
2712 return el
.firstChild
.getAttribute("href") === "#" ;
2714 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2716 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2722 // Use defaultValue in place of getAttribute("value")
2723 if ( !support
.attributes
|| !assert(function( el
) {
2724 el
.innerHTML
= "<input/>";
2725 el
.firstChild
.setAttribute( "value", "" );
2726 return el
.firstChild
.getAttribute( "value" ) === "";
2728 addHandle( "value", function( elem
, name
, isXML
) {
2729 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2730 return elem
.defaultValue
;
2736 // Use getAttributeNode to fetch booleans when getAttribute lies
2737 if ( !assert(function( el
) {
2738 return el
.getAttribute("disabled") == null;
2740 addHandle( booleans
, function( elem
, name
, isXML
) {
2743 return elem
[ name
] === true ? name
.toLowerCase() :
2744 (val
= elem
.getAttributeNode( name
)) && val
.specified
?
2757 jQuery
.find
= Sizzle
;
2758 jQuery
.expr
= Sizzle
.selectors
;
2761 jQuery
.expr
[ ":" ] = jQuery
.expr
.pseudos
;
2762 jQuery
.uniqueSort
= jQuery
.unique
= Sizzle
.uniqueSort
;
2763 jQuery
.text
= Sizzle
.getText
;
2764 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2765 jQuery
.contains
= Sizzle
.contains
;
2766 jQuery
.escapeSelector
= Sizzle
.escape
;
2771 var dir = function( elem
, dir
, until
) {
2773 truncate
= until
!== undefined;
2775 while ( ( elem
= elem
[ dir
] ) && elem
.nodeType
!== 9 ) {
2776 if ( elem
.nodeType
=== 1 ) {
2777 if ( truncate
&& jQuery( elem
).is( until
) ) {
2780 matched
.push( elem
);
2787 var siblings = function( n
, elem
) {
2790 for ( ; n
; n
= n
.nextSibling
) {
2791 if ( n
.nodeType
=== 1 && n
!== elem
) {
2800 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
2804 function nodeName( elem
, name
) {
2806 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
2809 var rsingleTag
= ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2813 // Implement the identical functionality for filter and not
2814 function winnow( elements
, qualifier
, not
) {
2815 if ( isFunction( qualifier
) ) {
2816 return jQuery
.grep( elements
, function( elem
, i
) {
2817 return !!qualifier
.call( elem
, i
, elem
) !== not
;
2822 if ( qualifier
.nodeType
) {
2823 return jQuery
.grep( elements
, function( elem
) {
2824 return ( elem
=== qualifier
) !== not
;
2828 // Arraylike of elements (jQuery, arguments, Array)
2829 if ( typeof qualifier
!== "string" ) {
2830 return jQuery
.grep( elements
, function( elem
) {
2831 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
;
2835 // Filtered directly for both simple and complex selectors
2836 return jQuery
.filter( qualifier
, elements
, not
);
2839 jQuery
.filter = function( expr
, elems
, not
) {
2840 var elem
= elems
[ 0 ];
2843 expr
= ":not(" + expr
+ ")";
2846 if ( elems
.length
=== 1 && elem
.nodeType
=== 1 ) {
2847 return jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [];
2850 return jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
2851 return elem
.nodeType
=== 1;
2856 find: function( selector
) {
2861 if ( typeof selector
!== "string" ) {
2862 return this.pushStack( jQuery( selector
).filter( function() {
2863 for ( i
= 0; i
< len
; i
++ ) {
2864 if ( jQuery
.contains( self
[ i
], this ) ) {
2871 ret
= this.pushStack( [] );
2873 for ( i
= 0; i
< len
; i
++ ) {
2874 jQuery
.find( selector
, self
[ i
], ret
);
2877 return len
> 1 ? jQuery
.uniqueSort( ret
) : ret
;
2879 filter: function( selector
) {
2880 return this.pushStack( winnow( this, selector
|| [], false ) );
2882 not: function( selector
) {
2883 return this.pushStack( winnow( this, selector
|| [], true ) );
2885 is: function( selector
) {
2889 // If this is a positional/relative selector, check membership in the returned set
2890 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2891 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
2892 jQuery( selector
) :
2900 // Initialize a jQuery object
2903 // A central reference to the root jQuery(document)
2906 // A simple way to check for HTML strings
2907 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2908 // Strict HTML recognition (#11290: must start with <)
2909 // Shortcut simple #id case for speed
2910 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2912 init
= jQuery
.fn
.init = function( selector
, context
, root
) {
2915 // HANDLE: $(""), $(null), $(undefined), $(false)
2920 // Method init() accepts an alternate rootjQuery
2921 // so migrate can support jQuery.sub (gh-2101)
2922 root
= root
|| rootjQuery
;
2924 // Handle HTML strings
2925 if ( typeof selector
=== "string" ) {
2926 if ( selector
[ 0 ] === "<" &&
2927 selector
[ selector
.length
- 1 ] === ">" &&
2928 selector
.length
>= 3 ) {
2930 // Assume that strings that start and end with <> are HTML and skip the regex check
2931 match
= [ null, selector
, null ];
2934 match
= rquickExpr
.exec( selector
);
2937 // Match html or make sure no context is specified for #id
2938 if ( match
&& ( match
[ 1 ] || !context
) ) {
2940 // HANDLE: $(html) -> $(array)
2942 context
= context
instanceof jQuery
? context
[ 0 ] : context
;
2944 // Option to run scripts is true for back-compat
2945 // Intentionally let the error be thrown if parseHTML is not present
2946 jQuery
.merge( this, jQuery
.parseHTML(
2948 context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
,
2952 // HANDLE: $(html, props)
2953 if ( rsingleTag
.test( match
[ 1 ] ) && jQuery
.isPlainObject( context
) ) {
2954 for ( match
in context
) {
2956 // Properties of context are called as methods if possible
2957 if ( isFunction( this[ match
] ) ) {
2958 this[ match
]( context
[ match
] );
2960 // ...and otherwise set as attributes
2962 this.attr( match
, context
[ match
] );
2971 elem
= document
.getElementById( match
[ 2 ] );
2975 // Inject the element directly into the jQuery object
2982 // HANDLE: $(expr, $(...))
2983 } else if ( !context
|| context
.jquery
) {
2984 return ( context
|| root
).find( selector
);
2986 // HANDLE: $(expr, context)
2987 // (which is just equivalent to: $(context).find(expr)
2989 return this.constructor( context
).find( selector
);
2992 // HANDLE: $(DOMElement)
2993 } else if ( selector
.nodeType
) {
2994 this[ 0 ] = selector
;
2998 // HANDLE: $(function)
2999 // Shortcut for document ready
3000 } else if ( isFunction( selector
) ) {
3001 return root
.ready
!== undefined ?
3002 root
.ready( selector
) :
3004 // Execute immediately if ready is not present
3008 return jQuery
.makeArray( selector
, this );
3011 // Give the init function the jQuery prototype for later instantiation
3012 init
.prototype = jQuery
.fn
;
3014 // Initialize central reference
3015 rootjQuery
= jQuery( document
);
3018 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
3020 // Methods guaranteed to produce a unique set when starting from a unique set
3021 guaranteedUnique
= {
3029 has: function( target
) {
3030 var targets
= jQuery( target
, this ),
3033 return this.filter( function() {
3035 for ( ; i
< l
; i
++ ) {
3036 if ( jQuery
.contains( this, targets
[ i
] ) ) {
3043 closest: function( selectors
, context
) {
3048 targets
= typeof selectors
!== "string" && jQuery( selectors
);
3050 // Positional selectors never match, since there's no _selection_ context
3051 if ( !rneedsContext
.test( selectors
) ) {
3052 for ( ; i
< l
; i
++ ) {
3053 for ( cur
= this[ i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
3055 // Always skip document fragments
3056 if ( cur
.nodeType
< 11 && ( targets
?
3057 targets
.index( cur
) > -1 :
3059 // Don't pass non-elements to Sizzle
3060 cur
.nodeType
=== 1 &&
3061 jQuery
.find
.matchesSelector( cur
, selectors
) ) ) {
3063 matched
.push( cur
);
3070 return this.pushStack( matched
.length
> 1 ? jQuery
.uniqueSort( matched
) : matched
);
3073 // Determine the position of an element within the set
3074 index: function( elem
) {
3076 // No argument, return index in parent
3078 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length
: -1;
3081 // Index in selector
3082 if ( typeof elem
=== "string" ) {
3083 return indexOf
.call( jQuery( elem
), this[ 0 ] );
3086 // Locate the position of the desired element
3087 return indexOf
.call( this,
3089 // If it receives a jQuery object, the first element is used
3090 elem
.jquery
? elem
[ 0 ] : elem
3094 add: function( selector
, context
) {
3095 return this.pushStack(
3097 jQuery
.merge( this.get(), jQuery( selector
, context
) )
3102 addBack: function( selector
) {
3103 return this.add( selector
== null ?
3104 this.prevObject
: this.prevObject
.filter( selector
)
3109 function sibling( cur
, dir
) {
3110 while ( ( cur
= cur
[ dir
] ) && cur
.nodeType
!== 1 ) {}
3115 parent: function( elem
) {
3116 var parent
= elem
.parentNode
;
3117 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
3119 parents: function( elem
) {
3120 return dir( elem
, "parentNode" );
3122 parentsUntil: function( elem
, i
, until
) {
3123 return dir( elem
, "parentNode", until
);
3125 next: function( elem
) {
3126 return sibling( elem
, "nextSibling" );
3128 prev: function( elem
) {
3129 return sibling( elem
, "previousSibling" );
3131 nextAll: function( elem
) {
3132 return dir( elem
, "nextSibling" );
3134 prevAll: function( elem
) {
3135 return dir( elem
, "previousSibling" );
3137 nextUntil: function( elem
, i
, until
) {
3138 return dir( elem
, "nextSibling", until
);
3140 prevUntil: function( elem
, i
, until
) {
3141 return dir( elem
, "previousSibling", until
);
3143 siblings: function( elem
) {
3144 return siblings( ( elem
.parentNode
|| {} ).firstChild
, elem
);
3146 children: function( elem
) {
3147 return siblings( elem
.firstChild
);
3149 contents: function( elem
) {
3150 if ( nodeName( elem
, "iframe" ) ) {
3151 return elem
.contentDocument
;
3154 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3155 // Treat the template element as a regular one in browsers that
3156 // don't support it.
3157 if ( nodeName( elem
, "template" ) ) {
3158 elem
= elem
.content
|| elem
;
3161 return jQuery
.merge( [], elem
.childNodes
);
3163 }, function( name
, fn
) {
3164 jQuery
.fn
[ name
] = function( until
, selector
) {
3165 var matched
= jQuery
.map( this, fn
, until
);
3167 if ( name
.slice( -5 ) !== "Until" ) {
3171 if ( selector
&& typeof selector
=== "string" ) {
3172 matched
= jQuery
.filter( selector
, matched
);
3175 if ( this.length
> 1 ) {
3177 // Remove duplicates
3178 if ( !guaranteedUnique
[ name
] ) {
3179 jQuery
.uniqueSort( matched
);
3182 // Reverse order for parents* and prev-derivatives
3183 if ( rparentsprev
.test( name
) ) {
3188 return this.pushStack( matched
);
3191 var rnothtmlwhite
= ( /[^\x20\t\r\n\f]+/g );
3195 // Convert String-formatted options into Object-formatted ones
3196 function createOptions( options
) {
3198 jQuery
.each( options
.match( rnothtmlwhite
) || [], function( _
, flag
) {
3199 object
[ flag
] = true;
3205 * Create a callback list using the following parameters:
3207 * options: an optional list of space-separated options that will change how
3208 * the callback list behaves or a more traditional option object
3210 * By default a callback list will act like an event callback list and can be
3211 * "fired" multiple times.
3215 * once: will ensure the callback list can only be fired once (like a Deferred)
3217 * memory: will keep track of previous values and will call any callback added
3218 * after the list has been fired right away with the latest "memorized"
3219 * values (like a Deferred)
3221 * unique: will ensure a callback can only be added once (no duplicate in the list)
3223 * stopOnFalse: interrupt callings when a callback returns false
3226 jQuery
.Callbacks = function( options
) {
3228 // Convert options from String-formatted to Object-formatted if needed
3229 // (we check in cache first)
3230 options
= typeof options
=== "string" ?
3231 createOptions( options
) :
3232 jQuery
.extend( {}, options
);
3234 var // Flag to know if list is currently firing
3237 // Last fire value for non-forgettable lists
3240 // Flag to know if list was already fired
3243 // Flag to prevent firing
3246 // Actual callback list
3249 // Queue of execution data for repeatable lists
3252 // Index of currently firing callback (modified by add/remove as needed)
3258 // Enforce single-firing
3259 locked
= locked
|| options
.once
;
3261 // Execute callbacks for all pending executions,
3262 // respecting firingIndex overrides and runtime changes
3263 fired
= firing
= true;
3264 for ( ; queue
.length
; firingIndex
= -1 ) {
3265 memory
= queue
.shift();
3266 while ( ++firingIndex
< list
.length
) {
3268 // Run callback and check for early termination
3269 if ( list
[ firingIndex
].apply( memory
[ 0 ], memory
[ 1 ] ) === false &&
3270 options
.stopOnFalse
) {
3272 // Jump to end and forget the data so .add doesn't re-fire
3273 firingIndex
= list
.length
;
3279 // Forget the data if we're done with it
3280 if ( !options
.memory
) {
3286 // Clean up if we're done firing for good
3289 // Keep an empty list if we have data for future add calls
3293 // Otherwise, this object is spent
3300 // Actual Callbacks object
3303 // Add a callback or a collection of callbacks to the list
3307 // If we have memory from a past run, we should fire after adding
3308 if ( memory
&& !firing
) {
3309 firingIndex
= list
.length
- 1;
3310 queue
.push( memory
);
3313 ( function add( args
) {
3314 jQuery
.each( args
, function( _
, arg
) {
3315 if ( isFunction( arg
) ) {
3316 if ( !options
.unique
|| !self
.has( arg
) ) {
3319 } else if ( arg
&& arg
.length
&& toType( arg
) !== "string" ) {
3321 // Inspect recursively
3327 if ( memory
&& !firing
) {
3334 // Remove a callback from the list
3335 remove: function() {
3336 jQuery
.each( arguments
, function( _
, arg
) {
3338 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3339 list
.splice( index
, 1 );
3341 // Handle firing indexes
3342 if ( index
<= firingIndex
) {
3350 // Check if a given callback is in the list.
3351 // If no argument is given, return whether or not list has callbacks attached.
3352 has: function( fn
) {
3354 jQuery
.inArray( fn
, list
) > -1 :
3358 // Remove all callbacks from the list
3366 // Disable .fire and .add
3367 // Abort any current/pending executions
3368 // Clear all callbacks and values
3369 disable: function() {
3370 locked
= queue
= [];
3374 disabled: function() {
3379 // Also disable .add unless we have memory (since it would have no effect)
3380 // Abort any pending executions
3382 locked
= queue
= [];
3383 if ( !memory
&& !firing
) {
3388 locked: function() {
3392 // Call all callbacks with the given context and arguments
3393 fireWith: function( context
, args
) {
3396 args
= [ context
, args
.slice
? args
.slice() : args
];
3405 // Call all the callbacks with the given arguments
3407 self
.fireWith( this, arguments
);
3411 // To know if the callbacks have already been called at least once
3421 function Identity( v
) {
3424 function Thrower( ex
) {
3428 function adoptValue( value
, resolve
, reject
, noValue
) {
3433 // Check for promise aspect first to privilege synchronous behavior
3434 if ( value
&& isFunction( ( method
= value
.promise
) ) ) {
3435 method
.call( value
).done( resolve
).fail( reject
);
3438 } else if ( value
&& isFunction( ( method
= value
.then
) ) ) {
3439 method
.call( value
, resolve
, reject
);
3441 // Other non-thenables
3444 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3445 // * false: [ value ].slice( 0 ) => resolve( value )
3446 // * true: [ value ].slice( 1 ) => resolve()
3447 resolve
.apply( undefined, [ value
].slice( noValue
) );
3450 // For Promises/A+, convert exceptions into rejections
3451 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3452 // Deferred#then to conditionally suppress rejection.
3455 // Support: Android 4.0 only
3456 // Strict mode functions invoked without .call/.apply get global-object context
3457 reject
.apply( undefined, [ value
] );
3463 Deferred: function( func
) {
3466 // action, add listener, callbacks,
3467 // ... .then handlers, argument index, [final state]
3468 [ "notify", "progress", jQuery
.Callbacks( "memory" ),
3469 jQuery
.Callbacks( "memory" ), 2 ],
3470 [ "resolve", "done", jQuery
.Callbacks( "once memory" ),
3471 jQuery
.Callbacks( "once memory" ), 0, "resolved" ],
3472 [ "reject", "fail", jQuery
.Callbacks( "once memory" ),
3473 jQuery
.Callbacks( "once memory" ), 1, "rejected" ]
3480 always: function() {
3481 deferred
.done( arguments
).fail( arguments
);
3484 "catch": function( fn
) {
3485 return promise
.then( null, fn
);
3488 // Keep pipe for back-compat
3489 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3490 var fns
= arguments
;
3492 return jQuery
.Deferred( function( newDefer
) {
3493 jQuery
.each( tuples
, function( i
, tuple
) {
3495 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3496 var fn
= isFunction( fns
[ tuple
[ 4 ] ] ) && fns
[ tuple
[ 4 ] ];
3498 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3499 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3500 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3501 deferred
[ tuple
[ 1 ] ]( function() {
3502 var returned
= fn
&& fn
.apply( this, arguments
);
3503 if ( returned
&& isFunction( returned
.promise
) ) {
3505 .progress( newDefer
.notify
)
3506 .done( newDefer
.resolve
)
3507 .fail( newDefer
.reject
);
3509 newDefer
[ tuple
[ 0 ] + "With" ](
3511 fn
? [ returned
] : arguments
3519 then: function( onFulfilled
, onRejected
, onProgress
) {
3521 function resolve( depth
, deferred
, handler
, special
) {
3525 mightThrow = function() {
3528 // Support: Promises/A+ section 2.3.3.3.3
3529 // https://promisesaplus.com/#point-59
3530 // Ignore double-resolution attempts
3531 if ( depth
< maxDepth
) {
3535 returned
= handler
.apply( that
, args
);
3537 // Support: Promises/A+ section 2.3.1
3538 // https://promisesaplus.com/#point-48
3539 if ( returned
=== deferred
.promise() ) {
3540 throw new TypeError( "Thenable self-resolution" );
3543 // Support: Promises/A+ sections 2.3.3.1, 3.5
3544 // https://promisesaplus.com/#point-54
3545 // https://promisesaplus.com/#point-75
3546 // Retrieve `then` only once
3549 // Support: Promises/A+ section 2.3.4
3550 // https://promisesaplus.com/#point-64
3551 // Only check objects and functions for thenability
3552 ( typeof returned
=== "object" ||
3553 typeof returned
=== "function" ) &&
3556 // Handle a returned thenable
3557 if ( isFunction( then
) ) {
3559 // Special processors (notify) just wait for resolution
3563 resolve( maxDepth
, deferred
, Identity
, special
),
3564 resolve( maxDepth
, deferred
, Thrower
, special
)
3567 // Normal processors (resolve) also hook into progress
3570 // ...and disregard older resolution values
3575 resolve( maxDepth
, deferred
, Identity
, special
),
3576 resolve( maxDepth
, deferred
, Thrower
, special
),
3577 resolve( maxDepth
, deferred
, Identity
,
3578 deferred
.notifyWith
)
3582 // Handle all other returned values
3585 // Only substitute handlers pass on context
3586 // and multiple values (non-spec behavior)
3587 if ( handler
!== Identity
) {
3589 args
= [ returned
];
3592 // Process the value(s)
3593 // Default process is resolve
3594 ( special
|| deferred
.resolveWith
)( that
, args
);
3598 // Only normal processors (resolve) catch and reject exceptions
3606 if ( jQuery
.Deferred
.exceptionHook
) {
3607 jQuery
.Deferred
.exceptionHook( e
,
3608 process
.stackTrace
);
3611 // Support: Promises/A+ section 2.3.3.3.4.1
3612 // https://promisesaplus.com/#point-61
3613 // Ignore post-resolution exceptions
3614 if ( depth
+ 1 >= maxDepth
) {
3616 // Only substitute handlers pass on context
3617 // and multiple values (non-spec behavior)
3618 if ( handler
!== Thrower
) {
3623 deferred
.rejectWith( that
, args
);
3628 // Support: Promises/A+ section 2.3.3.3.1
3629 // https://promisesaplus.com/#point-57
3630 // Re-resolve promises immediately to dodge false rejection from
3631 // subsequent errors
3636 // Call an optional hook to record the stack, in case of exception
3637 // since it's otherwise lost when execution goes async
3638 if ( jQuery
.Deferred
.getStackHook
) {
3639 process
.stackTrace
= jQuery
.Deferred
.getStackHook();
3641 window
.setTimeout( process
);
3646 return jQuery
.Deferred( function( newDefer
) {
3648 // progress_handlers.add( ... )
3649 tuples
[ 0 ][ 3 ].add(
3653 isFunction( onProgress
) ?
3660 // fulfilled_handlers.add( ... )
3661 tuples
[ 1 ][ 3 ].add(
3665 isFunction( onFulfilled
) ?
3671 // rejected_handlers.add( ... )
3672 tuples
[ 2 ][ 3 ].add(
3676 isFunction( onRejected
) ?
3684 // Get a promise for this deferred
3685 // If obj is provided, the promise aspect is added to the object
3686 promise: function( obj
) {
3687 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3692 // Add list-specific methods
3693 jQuery
.each( tuples
, function( i
, tuple
) {
3694 var list
= tuple
[ 2 ],
3695 stateString
= tuple
[ 5 ];
3697 // promise.progress = list.add
3698 // promise.done = list.add
3699 // promise.fail = list.add
3700 promise
[ tuple
[ 1 ] ] = list
.add
;
3703 if ( stateString
) {
3707 // state = "resolved" (i.e., fulfilled)
3708 // state = "rejected"
3709 state
= stateString
;
3712 // rejected_callbacks.disable
3713 // fulfilled_callbacks.disable
3714 tuples
[ 3 - i
][ 2 ].disable
,
3716 // rejected_handlers.disable
3717 // fulfilled_handlers.disable
3718 tuples
[ 3 - i
][ 3 ].disable
,
3720 // progress_callbacks.lock
3721 tuples
[ 0 ][ 2 ].lock
,
3723 // progress_handlers.lock
3724 tuples
[ 0 ][ 3 ].lock
3728 // progress_handlers.fire
3729 // fulfilled_handlers.fire
3730 // rejected_handlers.fire
3731 list
.add( tuple
[ 3 ].fire
);
3733 // deferred.notify = function() { deferred.notifyWith(...) }
3734 // deferred.resolve = function() { deferred.resolveWith(...) }
3735 // deferred.reject = function() { deferred.rejectWith(...) }
3736 deferred
[ tuple
[ 0 ] ] = function() {
3737 deferred
[ tuple
[ 0 ] + "With" ]( this === deferred
? undefined : this, arguments
);
3741 // deferred.notifyWith = list.fireWith
3742 // deferred.resolveWith = list.fireWith
3743 // deferred.rejectWith = list.fireWith
3744 deferred
[ tuple
[ 0 ] + "With" ] = list
.fireWith
;
3747 // Make the deferred a promise
3748 promise
.promise( deferred
);
3750 // Call given func if any
3752 func
.call( deferred
, deferred
);
3760 when: function( singleValue
) {
3763 // count of uncompleted subordinates
3764 remaining
= arguments
.length
,
3766 // count of unprocessed arguments
3769 // subordinate fulfillment data
3770 resolveContexts
= Array( i
),
3771 resolveValues
= slice
.call( arguments
),
3773 // the master Deferred
3774 master
= jQuery
.Deferred(),
3776 // subordinate callback factory
3777 updateFunc = function( i
) {
3778 return function( value
) {
3779 resolveContexts
[ i
] = this;
3780 resolveValues
[ i
] = arguments
.length
> 1 ? slice
.call( arguments
) : value
;
3781 if ( !( --remaining
) ) {
3782 master
.resolveWith( resolveContexts
, resolveValues
);
3787 // Single- and empty arguments are adopted like Promise.resolve
3788 if ( remaining
<= 1 ) {
3789 adoptValue( singleValue
, master
.done( updateFunc( i
) ).resolve
, master
.reject
,
3792 // Use .then() to unwrap secondary thenables (cf. gh-3000)
3793 if ( master
.state() === "pending" ||
3794 isFunction( resolveValues
[ i
] && resolveValues
[ i
].then
) ) {
3796 return master
.then();
3800 // Multiple arguments are aggregated like Promise.all array elements
3802 adoptValue( resolveValues
[ i
], updateFunc( i
), master
.reject
);
3805 return master
.promise();
3810 // These usually indicate a programmer mistake during development,
3811 // warn about them ASAP rather than swallowing them by default.
3812 var rerrorNames
= /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3814 jQuery
.Deferred
.exceptionHook = function( error
, stack
) {
3816 // Support: IE 8 - 9 only
3817 // Console exists when dev tools are open, which can happen at any time
3818 if ( window
.console
&& window
.console
.warn
&& error
&& rerrorNames
.test( error
.name
) ) {
3819 window
.console
.warn( "jQuery.Deferred exception: " + error
.message
, error
.stack
, stack
);
3826 jQuery
.readyException = function( error
) {
3827 window
.setTimeout( function() {
3835 // The deferred used on DOM ready
3836 var readyList
= jQuery
.Deferred();
3838 jQuery
.fn
.ready = function( fn
) {
3843 // Wrap jQuery.readyException in a function so that the lookup
3844 // happens at the time of error handling instead of callback
3846 .catch( function( error
) {
3847 jQuery
.readyException( error
);
3855 // Is the DOM ready to be used? Set to true once it occurs.
3858 // A counter to track how many items to wait for before
3859 // the ready event fires. See #6781
3862 // Handle when the DOM is ready
3863 ready: function( wait
) {
3865 // Abort if there are pending holds or we're already ready
3866 if ( wait
=== true ? --jQuery
.readyWait
: jQuery
.isReady
) {
3870 // Remember that the DOM is ready
3871 jQuery
.isReady
= true;
3873 // If a normal DOM Ready event fired, decrement, and wait if need be
3874 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
3878 // If there are functions bound, to execute
3879 readyList
.resolveWith( document
, [ jQuery
] );
3883 jQuery
.ready
.then
= readyList
.then
;
3885 // The ready event handler and self cleanup method
3886 function completed() {
3887 document
.removeEventListener( "DOMContentLoaded", completed
);
3888 window
.removeEventListener( "load", completed
);
3892 // Catch cases where $(document).ready() is called
3893 // after the browser event has already occurred.
3894 // Support: IE <=9 - 10 only
3895 // Older IE sometimes signals "interactive" too soon
3896 if ( document
.readyState
=== "complete" ||
3897 ( document
.readyState
!== "loading" && !document
.documentElement
.doScroll
) ) {
3899 // Handle it asynchronously to allow scripts the opportunity to delay ready
3900 window
.setTimeout( jQuery
.ready
);
3904 // Use the handy event callback
3905 document
.addEventListener( "DOMContentLoaded", completed
);
3907 // A fallback to window.onload, that will always work
3908 window
.addEventListener( "load", completed
);
3914 // Multifunctional method to get and set values of a collection
3915 // The value/s can optionally be executed if it's a function
3916 var access = function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
3922 if ( toType( key
) === "object" ) {
3925 access( elems
, fn
, i
, key
[ i
], true, emptyGet
, raw
);
3929 } else if ( value
!== undefined ) {
3932 if ( !isFunction( value
) ) {
3938 // Bulk operations run against the entire set
3940 fn
.call( elems
, value
);
3943 // ...except when executing function values
3946 fn = function( elem
, key
, value
) {
3947 return bulk
.call( jQuery( elem
), value
);
3953 for ( ; i
< len
; i
++ ) {
3955 elems
[ i
], key
, raw
?
3957 value
.call( elems
[ i
], i
, fn( elems
[ i
], key
) )
3969 return fn
.call( elems
);
3972 return len
? fn( elems
[ 0 ], key
) : emptyGet
;
3976 // Matches dashed string for camelizing
3977 var rmsPrefix
= /^-ms-/,
3978 rdashAlpha
= /-([a-z])/g;
3980 // Used by camelCase as callback to replace()
3981 function fcamelCase( all
, letter
) {
3982 return letter
.toUpperCase();
3985 // Convert dashed to camelCase; used by the css and data modules
3986 // Support: IE <=9 - 11, Edge 12 - 15
3987 // Microsoft forgot to hump their vendor prefix (#9572)
3988 function camelCase( string
) {
3989 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
3991 var acceptData = function( owner
) {
3995 // - Node.ELEMENT_NODE
3996 // - Node.DOCUMENT_NODE
3999 return owner
.nodeType
=== 1 || owner
.nodeType
=== 9 || !( +owner
.nodeType
);
4006 this.expando
= jQuery
.expando
+ Data
.uid
++;
4013 cache: function( owner
) {
4015 // Check if the owner object already has a cache
4016 var value
= owner
[ this.expando
];
4018 // If not, create one
4022 // We can accept data for non-element nodes in modern browsers,
4023 // but we should not, see #8335.
4024 // Always return an empty object.
4025 if ( acceptData( owner
) ) {
4027 // If it is a node unlikely to be stringify-ed or looped over
4028 // use plain assignment
4029 if ( owner
.nodeType
) {
4030 owner
[ this.expando
] = value
;
4032 // Otherwise secure it in a non-enumerable property
4033 // configurable must be true to allow the property to be
4034 // deleted when data is removed
4036 Object
.defineProperty( owner
, this.expando
, {
4046 set: function( owner
, data
, value
) {
4048 cache
= this.cache( owner
);
4050 // Handle: [ owner, key, value ] args
4051 // Always use camelCase key (gh-2257)
4052 if ( typeof data
=== "string" ) {
4053 cache
[ camelCase( data
) ] = value
;
4055 // Handle: [ owner, { properties } ] args
4058 // Copy the properties one-by-one to the cache object
4059 for ( prop
in data
) {
4060 cache
[ camelCase( prop
) ] = data
[ prop
];
4065 get: function( owner
, key
) {
4066 return key
=== undefined ?
4067 this.cache( owner
) :
4069 // Always use camelCase key (gh-2257)
4070 owner
[ this.expando
] && owner
[ this.expando
][ camelCase( key
) ];
4072 access: function( owner
, key
, value
) {
4074 // In cases where either:
4076 // 1. No key was specified
4077 // 2. A string key was specified, but no value provided
4079 // Take the "read" path and allow the get method to determine
4080 // which value to return, respectively either:
4082 // 1. The entire cache object
4083 // 2. The data stored at the key
4085 if ( key
=== undefined ||
4086 ( ( key
&& typeof key
=== "string" ) && value
=== undefined ) ) {
4088 return this.get( owner
, key
);
4091 // When the key is not a string, or both a key and value
4092 // are specified, set or extend (existing objects) with either:
4094 // 1. An object of properties
4095 // 2. A key and value
4097 this.set( owner
, key
, value
);
4099 // Since the "set" path can have two possible entry points
4100 // return the expected data based on which path was taken[*]
4101 return value
!== undefined ? value
: key
;
4103 remove: function( owner
, key
) {
4105 cache
= owner
[ this.expando
];
4107 if ( cache
=== undefined ) {
4111 if ( key
!== undefined ) {
4113 // Support array or space separated string of keys
4114 if ( Array
.isArray( key
) ) {
4116 // If key is an array of keys...
4117 // We always set camelCase keys, so remove that.
4118 key
= key
.map( camelCase
);
4120 key
= camelCase( key
);
4122 // If a key with the spaces exists, use it.
4123 // Otherwise, create an array by matching non-whitespace
4124 key
= key
in cache
?
4126 ( key
.match( rnothtmlwhite
) || [] );
4132 delete cache
[ key
[ i
] ];
4136 // Remove the expando if there's no more data
4137 if ( key
=== undefined || jQuery
.isEmptyObject( cache
) ) {
4139 // Support: Chrome <=35 - 45
4140 // Webkit & Blink performance suffers when deleting properties
4141 // from DOM nodes, so set to undefined instead
4142 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4143 if ( owner
.nodeType
) {
4144 owner
[ this.expando
] = undefined;
4146 delete owner
[ this.expando
];
4150 hasData: function( owner
) {
4151 var cache
= owner
[ this.expando
];
4152 return cache
!== undefined && !jQuery
.isEmptyObject( cache
);
4155 var dataPriv
= new Data();
4157 var dataUser
= new Data();
4161 // Implementation Summary
4163 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4164 // 2. Improve the module's maintainability by reducing the storage
4165 // paths to a single mechanism.
4166 // 3. Use the same single mechanism to support "private" and "user" data.
4167 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4168 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4169 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4171 var rbrace
= /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4172 rmultiDash
= /[A-Z]/g;
4174 function getData( data
) {
4175 if ( data
=== "true" ) {
4179 if ( data
=== "false" ) {
4183 if ( data
=== "null" ) {
4187 // Only convert to a number if it doesn't change the string
4188 if ( data
=== +data
+ "" ) {
4192 if ( rbrace
.test( data
) ) {
4193 return JSON
.parse( data
);
4199 function dataAttr( elem
, key
, data
) {
4202 // If nothing was found internally, try to fetch any
4203 // data from the HTML5 data-* attribute
4204 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
4205 name
= "data-" + key
.replace( rmultiDash
, "-$&" ).toLowerCase();
4206 data
= elem
.getAttribute( name
);
4208 if ( typeof data
=== "string" ) {
4210 data
= getData( data
);
4213 // Make sure we set the data so it isn't changed later
4214 dataUser
.set( elem
, key
, data
);
4223 hasData: function( elem
) {
4224 return dataUser
.hasData( elem
) || dataPriv
.hasData( elem
);
4227 data: function( elem
, name
, data
) {
4228 return dataUser
.access( elem
, name
, data
);
4231 removeData: function( elem
, name
) {
4232 dataUser
.remove( elem
, name
);
4235 // TODO: Now that all calls to _data and _removeData have been replaced
4236 // with direct calls to dataPriv methods, these can be deprecated.
4237 _data: function( elem
, name
, data
) {
4238 return dataPriv
.access( elem
, name
, data
);
4241 _removeData: function( elem
, name
) {
4242 dataPriv
.remove( elem
, name
);
4247 data: function( key
, value
) {
4250 attrs
= elem
&& elem
.attributes
;
4253 if ( key
=== undefined ) {
4254 if ( this.length
) {
4255 data
= dataUser
.get( elem
);
4257 if ( elem
.nodeType
=== 1 && !dataPriv
.get( elem
, "hasDataAttrs" ) ) {
4261 // Support: IE 11 only
4262 // The attrs elements can be null (#14894)
4264 name
= attrs
[ i
].name
;
4265 if ( name
.indexOf( "data-" ) === 0 ) {
4266 name
= camelCase( name
.slice( 5 ) );
4267 dataAttr( elem
, name
, data
[ name
] );
4271 dataPriv
.set( elem
, "hasDataAttrs", true );
4278 // Sets multiple values
4279 if ( typeof key
=== "object" ) {
4280 return this.each( function() {
4281 dataUser
.set( this, key
);
4285 return access( this, function( value
) {
4288 // The calling jQuery object (element matches) is not empty
4289 // (and therefore has an element appears at this[ 0 ]) and the
4290 // `value` parameter was not undefined. An empty jQuery object
4291 // will result in `undefined` for elem = this[ 0 ] which will
4292 // throw an exception if an attempt to read a data cache is made.
4293 if ( elem
&& value
=== undefined ) {
4295 // Attempt to get data from the cache
4296 // The key will always be camelCased in Data
4297 data
= dataUser
.get( elem
, key
);
4298 if ( data
!== undefined ) {
4302 // Attempt to "discover" the data in
4303 // HTML5 custom data-* attrs
4304 data
= dataAttr( elem
, key
);
4305 if ( data
!== undefined ) {
4309 // We tried really hard, but the data doesn't exist.
4314 this.each( function() {
4316 // We always store the camelCased key
4317 dataUser
.set( this, key
, value
);
4319 }, null, value
, arguments
.length
> 1, null, true );
4322 removeData: function( key
) {
4323 return this.each( function() {
4324 dataUser
.remove( this, key
);
4331 queue: function( elem
, type
, data
) {
4335 type
= ( type
|| "fx" ) + "queue";
4336 queue
= dataPriv
.get( elem
, type
);
4338 // Speed up dequeue by getting out quickly if this is just a lookup
4340 if ( !queue
|| Array
.isArray( data
) ) {
4341 queue
= dataPriv
.access( elem
, type
, jQuery
.makeArray( data
) );
4350 dequeue: function( elem
, type
) {
4351 type
= type
|| "fx";
4353 var queue
= jQuery
.queue( elem
, type
),
4354 startLength
= queue
.length
,
4356 hooks
= jQuery
._queueHooks( elem
, type
),
4358 jQuery
.dequeue( elem
, type
);
4361 // If the fx queue is dequeued, always remove the progress sentinel
4362 if ( fn
=== "inprogress" ) {
4369 // Add a progress sentinel to prevent the fx queue from being
4370 // automatically dequeued
4371 if ( type
=== "fx" ) {
4372 queue
.unshift( "inprogress" );
4375 // Clear up the last queue stop function
4377 fn
.call( elem
, next
, hooks
);
4380 if ( !startLength
&& hooks
) {
4385 // Not public - generate a queueHooks object, or return the current one
4386 _queueHooks: function( elem
, type
) {
4387 var key
= type
+ "queueHooks";
4388 return dataPriv
.get( elem
, key
) || dataPriv
.access( elem
, key
, {
4389 empty
: jQuery
.Callbacks( "once memory" ).add( function() {
4390 dataPriv
.remove( elem
, [ type
+ "queue", key
] );
4397 queue: function( type
, data
) {
4400 if ( typeof type
!== "string" ) {
4406 if ( arguments
.length
< setter
) {
4407 return jQuery
.queue( this[ 0 ], type
);
4410 return data
=== undefined ?
4412 this.each( function() {
4413 var queue
= jQuery
.queue( this, type
, data
);
4415 // Ensure a hooks for this queue
4416 jQuery
._queueHooks( this, type
);
4418 if ( type
=== "fx" && queue
[ 0 ] !== "inprogress" ) {
4419 jQuery
.dequeue( this, type
);
4423 dequeue: function( type
) {
4424 return this.each( function() {
4425 jQuery
.dequeue( this, type
);
4428 clearQueue: function( type
) {
4429 return this.queue( type
|| "fx", [] );
4432 // Get a promise resolved when queues of a certain type
4433 // are emptied (fx is the type by default)
4434 promise: function( type
, obj
) {
4437 defer
= jQuery
.Deferred(),
4440 resolve = function() {
4441 if ( !( --count
) ) {
4442 defer
.resolveWith( elements
, [ elements
] );
4446 if ( typeof type
!== "string" ) {
4450 type
= type
|| "fx";
4453 tmp
= dataPriv
.get( elements
[ i
], type
+ "queueHooks" );
4454 if ( tmp
&& tmp
.empty
) {
4456 tmp
.empty
.add( resolve
);
4460 return defer
.promise( obj
);
4463 var pnum
= ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source
;
4465 var rcssNum
= new RegExp( "^(?:([+-])=|)(" + pnum
+ ")([a-z%]*)$", "i" );
4468 var cssExpand
= [ "Top", "Right", "Bottom", "Left" ];
4470 var isHiddenWithinTree = function( elem
, el
) {
4472 // isHiddenWithinTree might be called from jQuery#filter function;
4473 // in that case, element will be second argument
4476 // Inline style trumps all
4477 return elem
.style
.display
=== "none" ||
4478 elem
.style
.display
=== "" &&
4480 // Otherwise, check computed style
4481 // Support: Firefox <=43 - 45
4482 // Disconnected elements can have computed display: none, so first confirm that elem is
4484 jQuery
.contains( elem
.ownerDocument
, elem
) &&
4486 jQuery
.css( elem
, "display" ) === "none";
4489 var swap = function( elem
, options
, callback
, args
) {
4493 // Remember the old values, and insert the new ones
4494 for ( name
in options
) {
4495 old
[ name
] = elem
.style
[ name
];
4496 elem
.style
[ name
] = options
[ name
];
4499 ret
= callback
.apply( elem
, args
|| [] );
4501 // Revert the old values
4502 for ( name
in options
) {
4503 elem
.style
[ name
] = old
[ name
];
4512 function adjustCSS( elem
, prop
, valueParts
, tween
) {
4513 var adjusted
, scale
,
4515 currentValue
= tween
?
4520 return jQuery
.css( elem
, prop
, "" );
4522 initial
= currentValue(),
4523 unit
= valueParts
&& valueParts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
4525 // Starting value computation is required for potential unit mismatches
4526 initialInUnit
= ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +initial
) &&
4527 rcssNum
.exec( jQuery
.css( elem
, prop
) );
4529 if ( initialInUnit
&& initialInUnit
[ 3 ] !== unit
) {
4531 // Support: Firefox <=54
4532 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
4533 initial
= initial
/ 2;
4535 // Trust units reported by jQuery.css
4536 unit
= unit
|| initialInUnit
[ 3 ];
4538 // Iteratively approximate from a nonzero starting point
4539 initialInUnit
= +initial
|| 1;
4541 while ( maxIterations
-- ) {
4543 // Evaluate and update our best guess (doubling guesses that zero out).
4544 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
4545 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4546 if ( ( 1 - scale
) * ( 1 - ( scale
= currentValue() / initial
|| 0.5 ) ) <= 0 ) {
4549 initialInUnit
= initialInUnit
/ scale
;
4553 initialInUnit
= initialInUnit
* 2;
4554 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4556 // Make sure we update the tween properties later on
4557 valueParts
= valueParts
|| [];
4561 initialInUnit
= +initialInUnit
|| +initial
|| 0;
4563 // Apply relative offset (+=/-=) if specified
4564 adjusted
= valueParts
[ 1 ] ?
4565 initialInUnit
+ ( valueParts
[ 1 ] + 1 ) * valueParts
[ 2 ] :
4569 tween
.start
= initialInUnit
;
4570 tween
.end
= adjusted
;
4577 var defaultDisplayMap
= {};
4579 function getDefaultDisplay( elem
) {
4581 doc
= elem
.ownerDocument
,
4582 nodeName
= elem
.nodeName
,
4583 display
= defaultDisplayMap
[ nodeName
];
4589 temp
= doc
.body
.appendChild( doc
.createElement( nodeName
) );
4590 display
= jQuery
.css( temp
, "display" );
4592 temp
.parentNode
.removeChild( temp
);
4594 if ( display
=== "none" ) {
4597 defaultDisplayMap
[ nodeName
] = display
;
4602 function showHide( elements
, show
) {
4606 length
= elements
.length
;
4608 // Determine new display value for elements that need to change
4609 for ( ; index
< length
; index
++ ) {
4610 elem
= elements
[ index
];
4611 if ( !elem
.style
) {
4615 display
= elem
.style
.display
;
4618 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4619 // check is required in this first loop unless we have a nonempty display value (either
4620 // inline or about-to-be-restored)
4621 if ( display
=== "none" ) {
4622 values
[ index
] = dataPriv
.get( elem
, "display" ) || null;
4623 if ( !values
[ index
] ) {
4624 elem
.style
.display
= "";
4627 if ( elem
.style
.display
=== "" && isHiddenWithinTree( elem
) ) {
4628 values
[ index
] = getDefaultDisplay( elem
);
4631 if ( display
!== "none" ) {
4632 values
[ index
] = "none";
4634 // Remember what we're overwriting
4635 dataPriv
.set( elem
, "display", display
);
4640 // Set the display of the elements in a second loop to avoid constant reflow
4641 for ( index
= 0; index
< length
; index
++ ) {
4642 if ( values
[ index
] != null ) {
4643 elements
[ index
].style
.display
= values
[ index
];
4652 return showHide( this, true );
4655 return showHide( this );
4657 toggle: function( state
) {
4658 if ( typeof state
=== "boolean" ) {
4659 return state
? this.show() : this.hide();
4662 return this.each( function() {
4663 if ( isHiddenWithinTree( this ) ) {
4664 jQuery( this ).show();
4666 jQuery( this ).hide();
4671 var rcheckableType
= ( /^(?:checkbox|radio)$/i );
4673 var rtagName
= ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
4675 var rscriptType
= ( /^$|^module$|\/(?:java|ecma)script/i );
4679 // We have to close these tags to support XHTML (#13200)
4682 // Support: IE <=9 only
4683 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
4685 // XHTML parsers do not magically insert elements in the
4686 // same way that tag soup parsers do. So we cannot shorten
4687 // this by omitting <tbody> or other required elements.
4688 thead
: [ 1, "<table>", "</table>" ],
4689 col
: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4690 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
4691 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4693 _default
: [ 0, "", "" ]
4696 // Support: IE <=9 only
4697 wrapMap
.optgroup
= wrapMap
.option
;
4699 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
4700 wrapMap
.th
= wrapMap
.td
;
4703 function getAll( context
, tag
) {
4705 // Support: IE <=9 - 11 only
4706 // Use typeof to avoid zero-argument method invocation on host objects (#15151)
4709 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
4710 ret
= context
.getElementsByTagName( tag
|| "*" );
4712 } else if ( typeof context
.querySelectorAll
!== "undefined" ) {
4713 ret
= context
.querySelectorAll( tag
|| "*" );
4719 if ( tag
=== undefined || tag
&& nodeName( context
, tag
) ) {
4720 return jQuery
.merge( [ context
], ret
);
4727 // Mark scripts as having already been evaluated
4728 function setGlobalEval( elems
, refElements
) {
4732 for ( ; i
< l
; i
++ ) {
4736 !refElements
|| dataPriv
.get( refElements
[ i
], "globalEval" )
4742 var rhtml
= /<|&#?\w+;/;
4744 function buildFragment( elems
, context
, scripts
, selection
, ignored
) {
4745 var elem
, tmp
, tag
, wrap
, contains
, j
,
4746 fragment
= context
.createDocumentFragment(),
4751 for ( ; i
< l
; i
++ ) {
4754 if ( elem
|| elem
=== 0 ) {
4756 // Add nodes directly
4757 if ( toType( elem
) === "object" ) {
4759 // Support: Android <=4.0 only, PhantomJS 1 only
4760 // push.apply(_, arraylike) throws on ancient WebKit
4761 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
4763 // Convert non-html into a text node
4764 } else if ( !rhtml
.test( elem
) ) {
4765 nodes
.push( context
.createTextNode( elem
) );
4767 // Convert html into DOM nodes
4769 tmp
= tmp
|| fragment
.appendChild( context
.createElement( "div" ) );
4771 // Deserialize a standard representation
4772 tag
= ( rtagName
.exec( elem
) || [ "", "" ] )[ 1 ].toLowerCase();
4773 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
4774 tmp
.innerHTML
= wrap
[ 1 ] + jQuery
.htmlPrefilter( elem
) + wrap
[ 2 ];
4776 // Descend through wrappers to the right content
4779 tmp
= tmp
.lastChild
;
4782 // Support: Android <=4.0 only, PhantomJS 1 only
4783 // push.apply(_, arraylike) throws on ancient WebKit
4784 jQuery
.merge( nodes
, tmp
.childNodes
);
4786 // Remember the top-level container
4787 tmp
= fragment
.firstChild
;
4789 // Ensure the created nodes are orphaned (#12392)
4790 tmp
.textContent
= "";
4795 // Remove wrapper from fragment
4796 fragment
.textContent
= "";
4799 while ( ( elem
= nodes
[ i
++ ] ) ) {
4801 // Skip elements already in the context collection (trac-4087)
4802 if ( selection
&& jQuery
.inArray( elem
, selection
) > -1 ) {
4804 ignored
.push( elem
);
4809 contains
= jQuery
.contains( elem
.ownerDocument
, elem
);
4811 // Append to fragment
4812 tmp
= getAll( fragment
.appendChild( elem
), "script" );
4814 // Preserve script evaluation history
4816 setGlobalEval( tmp
);
4819 // Capture executables
4822 while ( ( elem
= tmp
[ j
++ ] ) ) {
4823 if ( rscriptType
.test( elem
.type
|| "" ) ) {
4824 scripts
.push( elem
);
4835 var fragment
= document
.createDocumentFragment(),
4836 div
= fragment
.appendChild( document
.createElement( "div" ) ),
4837 input
= document
.createElement( "input" );
4839 // Support: Android 4.0 - 4.3 only
4840 // Check state lost if the name is set (#11217)
4841 // Support: Windows Web Apps (WWA)
4842 // `name` and `type` must use .setAttribute for WWA (#14901)
4843 input
.setAttribute( "type", "radio" );
4844 input
.setAttribute( "checked", "checked" );
4845 input
.setAttribute( "name", "t" );
4847 div
.appendChild( input
);
4849 // Support: Android <=4.1 only
4850 // Older WebKit doesn't clone checked state correctly in fragments
4851 support
.checkClone
= div
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
4853 // Support: IE <=11 only
4854 // Make sure textarea (and checkbox) defaultValue is properly cloned
4855 div
.innerHTML
= "<textarea>x</textarea>";
4856 support
.noCloneChecked
= !!div
.cloneNode( true ).lastChild
.defaultValue
;
4858 var documentElement
= document
.documentElement
;
4864 rmouseEvent
= /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4865 rtypenamespace
= /^([^.]*)(?:\.(.+)|)/;
4867 function returnTrue() {
4871 function returnFalse() {
4875 // Support: IE <=9 only
4876 // See #13393 for more info
4877 function safeActiveElement() {
4879 return document
.activeElement
;
4883 function on( elem
, types
, selector
, data
, fn
, one
) {
4886 // Types can be a map of types/handlers
4887 if ( typeof types
=== "object" ) {
4889 // ( types-Object, selector, data )
4890 if ( typeof selector
!== "string" ) {
4892 // ( types-Object, data )
4893 data
= data
|| selector
;
4894 selector
= undefined;
4896 for ( type
in types
) {
4897 on( elem
, type
, selector
, data
, types
[ type
], one
);
4902 if ( data
== null && fn
== null ) {
4906 data
= selector
= undefined;
4907 } else if ( fn
== null ) {
4908 if ( typeof selector
=== "string" ) {
4910 // ( types, selector, fn )
4915 // ( types, data, fn )
4918 selector
= undefined;
4921 if ( fn
=== false ) {
4929 fn = function( event
) {
4931 // Can use an empty set, since event contains the info
4932 jQuery().off( event
);
4933 return origFn
.apply( this, arguments
);
4936 // Use same guid so caller can remove using origFn
4937 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
4939 return elem
.each( function() {
4940 jQuery
.event
.add( this, types
, fn
, data
, selector
);
4945 * Helper functions for managing events -- not part of the public interface.
4946 * Props to Dean Edwards' addEvent library for many of the ideas.
4952 add: function( elem
, types
, handler
, data
, selector
) {
4954 var handleObjIn
, eventHandle
, tmp
,
4955 events
, t
, handleObj
,
4956 special
, handlers
, type
, namespaces
, origType
,
4957 elemData
= dataPriv
.get( elem
);
4959 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4964 // Caller can pass in an object of custom data in lieu of the handler
4965 if ( handler
.handler
) {
4966 handleObjIn
= handler
;
4967 handler
= handleObjIn
.handler
;
4968 selector
= handleObjIn
.selector
;
4971 // Ensure that invalid selectors throw exceptions at attach time
4972 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
4974 jQuery
.find
.matchesSelector( documentElement
, selector
);
4977 // Make sure that the handler has a unique ID, used to find/remove it later
4978 if ( !handler
.guid
) {
4979 handler
.guid
= jQuery
.guid
++;
4982 // Init the element's event structure and main handler, if this is the first
4983 if ( !( events
= elemData
.events
) ) {
4984 events
= elemData
.events
= {};
4986 if ( !( eventHandle
= elemData
.handle
) ) {
4987 eventHandle
= elemData
.handle = function( e
) {
4989 // Discard the second event of a jQuery.event.trigger() and
4990 // when an event is called after a page has unloaded
4991 return typeof jQuery
!== "undefined" && jQuery
.event
.triggered
!== e
.type
?
4992 jQuery
.event
.dispatch
.apply( elem
, arguments
) : undefined;
4996 // Handle multiple events separated by a space
4997 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5000 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5001 type
= origType
= tmp
[ 1 ];
5002 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5004 // There *must* be a type, no attaching namespace-only handlers
5009 // If event changes its type, use the special event handlers for the changed type
5010 special
= jQuery
.event
.special
[ type
] || {};
5012 // If selector defined, determine special event api type, otherwise given type
5013 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
5015 // Update special based on newly reset type
5016 special
= jQuery
.event
.special
[ type
] || {};
5018 // handleObj is passed to all event handlers
5019 handleObj
= jQuery
.extend( {
5026 needsContext
: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
5027 namespace: namespaces
.join( "." )
5030 // Init the event handler queue if we're the first
5031 if ( !( handlers
= events
[ type
] ) ) {
5032 handlers
= events
[ type
] = [];
5033 handlers
.delegateCount
= 0;
5035 // Only use addEventListener if the special events handler returns false
5036 if ( !special
.setup
||
5037 special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
5039 if ( elem
.addEventListener
) {
5040 elem
.addEventListener( type
, eventHandle
);
5045 if ( special
.add
) {
5046 special
.add
.call( elem
, handleObj
);
5048 if ( !handleObj
.handler
.guid
) {
5049 handleObj
.handler
.guid
= handler
.guid
;
5053 // Add to the element's handler list, delegates in front
5055 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
5057 handlers
.push( handleObj
);
5060 // Keep track of which events have ever been used, for event optimization
5061 jQuery
.event
.global
[ type
] = true;
5066 // Detach an event or set of events from an element
5067 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
5069 var j
, origCount
, tmp
,
5070 events
, t
, handleObj
,
5071 special
, handlers
, type
, namespaces
, origType
,
5072 elemData
= dataPriv
.hasData( elem
) && dataPriv
.get( elem
);
5074 if ( !elemData
|| !( events
= elemData
.events
) ) {
5078 // Once for each type.namespace in types; type may be omitted
5079 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5082 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5083 type
= origType
= tmp
[ 1 ];
5084 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5086 // Unbind all events (on this namespace, if provided) for the element
5088 for ( type
in events
) {
5089 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
5094 special
= jQuery
.event
.special
[ type
] || {};
5095 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
5096 handlers
= events
[ type
] || [];
5098 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5100 // Remove matching events
5101 origCount
= j
= handlers
.length
;
5103 handleObj
= handlers
[ j
];
5105 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
5106 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
5107 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
5108 ( !selector
|| selector
=== handleObj
.selector
||
5109 selector
=== "**" && handleObj
.selector
) ) {
5110 handlers
.splice( j
, 1 );
5112 if ( handleObj
.selector
) {
5113 handlers
.delegateCount
--;
5115 if ( special
.remove
) {
5116 special
.remove
.call( elem
, handleObj
);
5121 // Remove generic event handler if we removed something and no more handlers exist
5122 // (avoids potential for endless recursion during removal of special event handlers)
5123 if ( origCount
&& !handlers
.length
) {
5124 if ( !special
.teardown
||
5125 special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
5127 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
5130 delete events
[ type
];
5134 // Remove data and the expando if it's no longer used
5135 if ( jQuery
.isEmptyObject( events
) ) {
5136 dataPriv
.remove( elem
, "handle events" );
5140 dispatch: function( nativeEvent
) {
5142 // Make a writable jQuery.Event from the native event object
5143 var event
= jQuery
.event
.fix( nativeEvent
);
5145 var i
, j
, ret
, matched
, handleObj
, handlerQueue
,
5146 args
= new Array( arguments
.length
),
5147 handlers
= ( dataPriv
.get( this, "events" ) || {} )[ event
.type
] || [],
5148 special
= jQuery
.event
.special
[ event
.type
] || {};
5150 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5153 for ( i
= 1; i
< arguments
.length
; i
++ ) {
5154 args
[ i
] = arguments
[ i
];
5157 event
.delegateTarget
= this;
5159 // Call the preDispatch hook for the mapped type, and let it bail if desired
5160 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
5164 // Determine handlers
5165 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
5167 // Run delegates first; they may want to stop propagation beneath us
5169 while ( ( matched
= handlerQueue
[ i
++ ] ) && !event
.isPropagationStopped() ) {
5170 event
.currentTarget
= matched
.elem
;
5173 while ( ( handleObj
= matched
.handlers
[ j
++ ] ) &&
5174 !event
.isImmediatePropagationStopped() ) {
5176 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5177 // a subset or equal to those in the bound event (both can have no namespace).
5178 if ( !event
.rnamespace
|| event
.rnamespace
.test( handleObj
.namespace ) ) {
5180 event
.handleObj
= handleObj
;
5181 event
.data
= handleObj
.data
;
5183 ret
= ( ( jQuery
.event
.special
[ handleObj
.origType
] || {} ).handle
||
5184 handleObj
.handler
).apply( matched
.elem
, args
);
5186 if ( ret
!== undefined ) {
5187 if ( ( event
.result
= ret
) === false ) {
5188 event
.preventDefault();
5189 event
.stopPropagation();
5196 // Call the postDispatch hook for the mapped type
5197 if ( special
.postDispatch
) {
5198 special
.postDispatch
.call( this, event
);
5201 return event
.result
;
5204 handlers: function( event
, handlers
) {
5205 var i
, handleObj
, sel
, matchedHandlers
, matchedSelectors
,
5207 delegateCount
= handlers
.delegateCount
,
5210 // Find delegate handlers
5211 if ( delegateCount
&&
5214 // Black-hole SVG <use> instance trees (trac-13180)
5217 // Support: Firefox <=42
5218 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5219 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5220 // Support: IE 11 only
5221 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5222 !( event
.type
=== "click" && event
.button
>= 1 ) ) {
5224 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
5226 // Don't check non-elements (#13208)
5227 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5228 if ( cur
.nodeType
=== 1 && !( event
.type
=== "click" && cur
.disabled
=== true ) ) {
5229 matchedHandlers
= [];
5230 matchedSelectors
= {};
5231 for ( i
= 0; i
< delegateCount
; i
++ ) {
5232 handleObj
= handlers
[ i
];
5234 // Don't conflict with Object.prototype properties (#13203)
5235 sel
= handleObj
.selector
+ " ";
5237 if ( matchedSelectors
[ sel
] === undefined ) {
5238 matchedSelectors
[ sel
] = handleObj
.needsContext
?
5239 jQuery( sel
, this ).index( cur
) > -1 :
5240 jQuery
.find( sel
, this, null, [ cur
] ).length
;
5242 if ( matchedSelectors
[ sel
] ) {
5243 matchedHandlers
.push( handleObj
);
5246 if ( matchedHandlers
.length
) {
5247 handlerQueue
.push( { elem
: cur
, handlers
: matchedHandlers
} );
5253 // Add the remaining (directly-bound) handlers
5255 if ( delegateCount
< handlers
.length
) {
5256 handlerQueue
.push( { elem
: cur
, handlers
: handlers
.slice( delegateCount
) } );
5259 return handlerQueue
;
5262 addProp: function( name
, hook
) {
5263 Object
.defineProperty( jQuery
.Event
.prototype, name
, {
5267 get: isFunction( hook
) ?
5269 if ( this.originalEvent
) {
5270 return hook( this.originalEvent
);
5274 if ( this.originalEvent
) {
5275 return this.originalEvent
[ name
];
5279 set: function( value
) {
5280 Object
.defineProperty( this, name
, {
5290 fix: function( originalEvent
) {
5291 return originalEvent
[ jQuery
.expando
] ?
5293 new jQuery
.Event( originalEvent
);
5299 // Prevent triggered image.load events from bubbling to window.load
5304 // Fire native event if possible so blur/focus sequence is correct
5305 trigger: function() {
5306 if ( this !== safeActiveElement() && this.focus
) {
5311 delegateType
: "focusin"
5314 trigger: function() {
5315 if ( this === safeActiveElement() && this.blur
) {
5320 delegateType
: "focusout"
5324 // For checkbox, fire native event so checked state will be right
5325 trigger: function() {
5326 if ( this.type
=== "checkbox" && this.click
&& nodeName( this, "input" ) ) {
5332 // For cross-browser consistency, don't fire native .click() on links
5333 _default: function( event
) {
5334 return nodeName( event
.target
, "a" );
5339 postDispatch: function( event
) {
5341 // Support: Firefox 20+
5342 // Firefox doesn't alert if the returnValue field is not set.
5343 if ( event
.result
!== undefined && event
.originalEvent
) {
5344 event
.originalEvent
.returnValue
= event
.result
;
5351 jQuery
.removeEvent = function( elem
, type
, handle
) {
5353 // This "if" is needed for plain objects
5354 if ( elem
.removeEventListener
) {
5355 elem
.removeEventListener( type
, handle
);
5359 jQuery
.Event = function( src
, props
) {
5361 // Allow instantiation without the 'new' keyword
5362 if ( !( this instanceof jQuery
.Event
) ) {
5363 return new jQuery
.Event( src
, props
);
5367 if ( src
&& src
.type
) {
5368 this.originalEvent
= src
;
5369 this.type
= src
.type
;
5371 // Events bubbling up the document may have been marked as prevented
5372 // by a handler lower down the tree; reflect the correct value.
5373 this.isDefaultPrevented
= src
.defaultPrevented
||
5374 src
.defaultPrevented
=== undefined &&
5376 // Support: Android <=2.3 only
5377 src
.returnValue
=== false ?
5381 // Create target properties
5382 // Support: Safari <=6 - 7 only
5383 // Target should not be a text node (#504, #13143)
5384 this.target
= ( src
.target
&& src
.target
.nodeType
=== 3 ) ?
5385 src
.target
.parentNode
:
5388 this.currentTarget
= src
.currentTarget
;
5389 this.relatedTarget
= src
.relatedTarget
;
5396 // Put explicitly provided properties onto the event object
5398 jQuery
.extend( this, props
);
5401 // Create a timestamp if incoming event doesn't have one
5402 this.timeStamp
= src
&& src
.timeStamp
|| Date
.now();
5405 this[ jQuery
.expando
] = true;
5408 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5409 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5410 jQuery
.Event
.prototype = {
5411 constructor: jQuery
.Event
,
5412 isDefaultPrevented
: returnFalse
,
5413 isPropagationStopped
: returnFalse
,
5414 isImmediatePropagationStopped
: returnFalse
,
5417 preventDefault: function() {
5418 var e
= this.originalEvent
;
5420 this.isDefaultPrevented
= returnTrue
;
5422 if ( e
&& !this.isSimulated
) {
5426 stopPropagation: function() {
5427 var e
= this.originalEvent
;
5429 this.isPropagationStopped
= returnTrue
;
5431 if ( e
&& !this.isSimulated
) {
5432 e
.stopPropagation();
5435 stopImmediatePropagation: function() {
5436 var e
= this.originalEvent
;
5438 this.isImmediatePropagationStopped
= returnTrue
;
5440 if ( e
&& !this.isSimulated
) {
5441 e
.stopImmediatePropagation();
5444 this.stopPropagation();
5448 // Includes all common event props including KeyEvent and MouseEvent specific props
5453 changedTouches
: true,
5476 targetTouches
: true,
5480 which: function( event
) {
5481 var button
= event
.button
;
5483 // Add which for key events
5484 if ( event
.which
== null && rkeyEvent
.test( event
.type
) ) {
5485 return event
.charCode
!= null ? event
.charCode
: event
.keyCode
;
5488 // Add which for click: 1 === left; 2 === middle; 3 === right
5489 if ( !event
.which
&& button
!== undefined && rmouseEvent
.test( event
.type
) ) {
5507 }, jQuery
.event
.addProp
);
5509 // Create mouseenter/leave events using mouseover/out and event-time checks
5510 // so that event delegation works in jQuery.
5511 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5513 // Support: Safari 7 only
5514 // Safari sends mouseenter too often; see:
5515 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5516 // for the description of the bug (it existed in older Chrome versions as well).
5518 mouseenter
: "mouseover",
5519 mouseleave
: "mouseout",
5520 pointerenter
: "pointerover",
5521 pointerleave
: "pointerout"
5522 }, function( orig
, fix
) {
5523 jQuery
.event
.special
[ orig
] = {
5527 handle: function( event
) {
5530 related
= event
.relatedTarget
,
5531 handleObj
= event
.handleObj
;
5533 // For mouseenter/leave call the handler if related is outside the target.
5534 // NB: No relatedTarget if the mouse left/entered the browser window
5535 if ( !related
|| ( related
!== target
&& !jQuery
.contains( target
, related
) ) ) {
5536 event
.type
= handleObj
.origType
;
5537 ret
= handleObj
.handler
.apply( this, arguments
);
5547 on: function( types
, selector
, data
, fn
) {
5548 return on( this, types
, selector
, data
, fn
);
5550 one: function( types
, selector
, data
, fn
) {
5551 return on( this, types
, selector
, data
, fn
, 1 );
5553 off: function( types
, selector
, fn
) {
5554 var handleObj
, type
;
5555 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
5557 // ( event ) dispatched jQuery.Event
5558 handleObj
= types
.handleObj
;
5559 jQuery( types
.delegateTarget
).off(
5560 handleObj
.namespace ?
5561 handleObj
.origType
+ "." + handleObj
.namespace :
5568 if ( typeof types
=== "object" ) {
5570 // ( types-object [, selector] )
5571 for ( type
in types
) {
5572 this.off( type
, selector
, types
[ type
] );
5576 if ( selector
=== false || typeof selector
=== "function" ) {
5580 selector
= undefined;
5582 if ( fn
=== false ) {
5585 return this.each( function() {
5586 jQuery
.event
.remove( this, types
, fn
, selector
);
5594 /* eslint-disable max-len */
5596 // See https://github.com/eslint/eslint/issues/3229
5597 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
5601 // Support: IE <=10 - 11, Edge 12 - 13 only
5602 // In IE/Edge using regex groups here causes severe slowdowns.
5603 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5604 rnoInnerhtml
= /<script|<style|<link/i,
5606 // checked="checked" or checked
5607 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5608 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5610 // Prefer a tbody over its parent table for containing new rows
5611 function manipulationTarget( elem
, content
) {
5612 if ( nodeName( elem
, "table" ) &&
5613 nodeName( content
.nodeType
!== 11 ? content
: content
.firstChild
, "tr" ) ) {
5615 return jQuery( elem
).children( "tbody" )[ 0 ] || elem
;
5621 // Replace/restore the type attribute of script elements for safe DOM manipulation
5622 function disableScript( elem
) {
5623 elem
.type
= ( elem
.getAttribute( "type" ) !== null ) + "/" + elem
.type
;
5626 function restoreScript( elem
) {
5627 if ( ( elem
.type
|| "" ).slice( 0, 5 ) === "true/" ) {
5628 elem
.type
= elem
.type
.slice( 5 );
5630 elem
.removeAttribute( "type" );
5636 function cloneCopyEvent( src
, dest
) {
5637 var i
, l
, type
, pdataOld
, pdataCur
, udataOld
, udataCur
, events
;
5639 if ( dest
.nodeType
!== 1 ) {
5643 // 1. Copy private data: events, handlers, etc.
5644 if ( dataPriv
.hasData( src
) ) {
5645 pdataOld
= dataPriv
.access( src
);
5646 pdataCur
= dataPriv
.set( dest
, pdataOld
);
5647 events
= pdataOld
.events
;
5650 delete pdataCur
.handle
;
5651 pdataCur
.events
= {};
5653 for ( type
in events
) {
5654 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
5655 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
5661 // 2. Copy user data
5662 if ( dataUser
.hasData( src
) ) {
5663 udataOld
= dataUser
.access( src
);
5664 udataCur
= jQuery
.extend( {}, udataOld
);
5666 dataUser
.set( dest
, udataCur
);
5670 // Fix IE bugs, see support tests
5671 function fixInput( src
, dest
) {
5672 var nodeName
= dest
.nodeName
.toLowerCase();
5674 // Fails to persist the checked state of a cloned checkbox or radio button.
5675 if ( nodeName
=== "input" && rcheckableType
.test( src
.type
) ) {
5676 dest
.checked
= src
.checked
;
5678 // Fails to return the selected option to the default selected state when cloning options
5679 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
5680 dest
.defaultValue
= src
.defaultValue
;
5684 function domManip( collection
, args
, callback
, ignored
) {
5686 // Flatten any nested arrays
5687 args
= concat
.apply( [], args
);
5689 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
5691 l
= collection
.length
,
5694 valueIsFunction
= isFunction( value
);
5696 // We can't cloneNode fragments that contain checked, in WebKit
5697 if ( valueIsFunction
||
5698 ( l
> 1 && typeof value
=== "string" &&
5699 !support
.checkClone
&& rchecked
.test( value
) ) ) {
5700 return collection
.each( function( index
) {
5701 var self
= collection
.eq( index
);
5702 if ( valueIsFunction
) {
5703 args
[ 0 ] = value
.call( this, index
, self
.html() );
5705 domManip( self
, args
, callback
, ignored
);
5710 fragment
= buildFragment( args
, collection
[ 0 ].ownerDocument
, false, collection
, ignored
);
5711 first
= fragment
.firstChild
;
5713 if ( fragment
.childNodes
.length
=== 1 ) {
5717 // Require either new content or an interest in ignored elements to invoke the callback
5718 if ( first
|| ignored
) {
5719 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
5720 hasScripts
= scripts
.length
;
5722 // Use the original fragment for the last item
5723 // instead of the first because it can end up
5724 // being emptied incorrectly in certain situations (#8070).
5725 for ( ; i
< l
; i
++ ) {
5728 if ( i
!== iNoClone
) {
5729 node
= jQuery
.clone( node
, true, true );
5731 // Keep references to cloned scripts for later restoration
5734 // Support: Android <=4.0 only, PhantomJS 1 only
5735 // push.apply(_, arraylike) throws on ancient WebKit
5736 jQuery
.merge( scripts
, getAll( node
, "script" ) );
5740 callback
.call( collection
[ i
], node
, i
);
5744 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
5747 jQuery
.map( scripts
, restoreScript
);
5749 // Evaluate executable scripts on first document insertion
5750 for ( i
= 0; i
< hasScripts
; i
++ ) {
5751 node
= scripts
[ i
];
5752 if ( rscriptType
.test( node
.type
|| "" ) &&
5753 !dataPriv
.access( node
, "globalEval" ) &&
5754 jQuery
.contains( doc
, node
) ) {
5756 if ( node
.src
&& ( node
.type
|| "" ).toLowerCase() !== "module" ) {
5758 // Optional AJAX dependency, but won't run scripts if not present
5759 if ( jQuery
._evalUrl
) {
5760 jQuery
._evalUrl( node
.src
);
5763 DOMEval( node
.textContent
.replace( rcleanScript
, "" ), doc
, node
);
5774 function remove( elem
, selector
, keepData
) {
5776 nodes
= selector
? jQuery
.filter( selector
, elem
) : elem
,
5779 for ( ; ( node
= nodes
[ i
] ) != null; i
++ ) {
5780 if ( !keepData
&& node
.nodeType
=== 1 ) {
5781 jQuery
.cleanData( getAll( node
) );
5784 if ( node
.parentNode
) {
5785 if ( keepData
&& jQuery
.contains( node
.ownerDocument
, node
) ) {
5786 setGlobalEval( getAll( node
, "script" ) );
5788 node
.parentNode
.removeChild( node
);
5796 htmlPrefilter: function( html
) {
5797 return html
.replace( rxhtmlTag
, "<$1></$2>" );
5800 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
5801 var i
, l
, srcElements
, destElements
,
5802 clone
= elem
.cloneNode( true ),
5803 inPage
= jQuery
.contains( elem
.ownerDocument
, elem
);
5805 // Fix IE cloning issues
5806 if ( !support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) &&
5807 !jQuery
.isXMLDoc( elem
) ) {
5809 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
5810 destElements
= getAll( clone
);
5811 srcElements
= getAll( elem
);
5813 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5814 fixInput( srcElements
[ i
], destElements
[ i
] );
5818 // Copy the events from the original to the clone
5819 if ( dataAndEvents
) {
5820 if ( deepDataAndEvents
) {
5821 srcElements
= srcElements
|| getAll( elem
);
5822 destElements
= destElements
|| getAll( clone
);
5824 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5825 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
5828 cloneCopyEvent( elem
, clone
);
5832 // Preserve script evaluation history
5833 destElements
= getAll( clone
, "script" );
5834 if ( destElements
.length
> 0 ) {
5835 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
5838 // Return the cloned set
5842 cleanData: function( elems
) {
5843 var data
, elem
, type
,
5844 special
= jQuery
.event
.special
,
5847 for ( ; ( elem
= elems
[ i
] ) !== undefined; i
++ ) {
5848 if ( acceptData( elem
) ) {
5849 if ( ( data
= elem
[ dataPriv
.expando
] ) ) {
5850 if ( data
.events
) {
5851 for ( type
in data
.events
) {
5852 if ( special
[ type
] ) {
5853 jQuery
.event
.remove( elem
, type
);
5855 // This is a shortcut to avoid jQuery.event.remove's overhead
5857 jQuery
.removeEvent( elem
, type
, data
.handle
);
5862 // Support: Chrome <=35 - 45+
5863 // Assign undefined instead of using delete, see Data#remove
5864 elem
[ dataPriv
.expando
] = undefined;
5866 if ( elem
[ dataUser
.expando
] ) {
5868 // Support: Chrome <=35 - 45+
5869 // Assign undefined instead of using delete, see Data#remove
5870 elem
[ dataUser
.expando
] = undefined;
5878 detach: function( selector
) {
5879 return remove( this, selector
, true );
5882 remove: function( selector
) {
5883 return remove( this, selector
);
5886 text: function( value
) {
5887 return access( this, function( value
) {
5888 return value
=== undefined ?
5889 jQuery
.text( this ) :
5890 this.empty().each( function() {
5891 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5892 this.textContent
= value
;
5895 }, null, value
, arguments
.length
);
5898 append: function() {
5899 return domManip( this, arguments
, function( elem
) {
5900 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5901 var target
= manipulationTarget( this, elem
);
5902 target
.appendChild( elem
);
5907 prepend: function() {
5908 return domManip( this, arguments
, function( elem
) {
5909 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5910 var target
= manipulationTarget( this, elem
);
5911 target
.insertBefore( elem
, target
.firstChild
);
5916 before: function() {
5917 return domManip( this, arguments
, function( elem
) {
5918 if ( this.parentNode
) {
5919 this.parentNode
.insertBefore( elem
, this );
5925 return domManip( this, arguments
, function( elem
) {
5926 if ( this.parentNode
) {
5927 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5936 for ( ; ( elem
= this[ i
] ) != null; i
++ ) {
5937 if ( elem
.nodeType
=== 1 ) {
5939 // Prevent memory leaks
5940 jQuery
.cleanData( getAll( elem
, false ) );
5942 // Remove any remaining nodes
5943 elem
.textContent
= "";
5950 clone: function( dataAndEvents
, deepDataAndEvents
) {
5951 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5952 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents
: deepDataAndEvents
;
5954 return this.map( function() {
5955 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5959 html: function( value
) {
5960 return access( this, function( value
) {
5961 var elem
= this[ 0 ] || {},
5965 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
5966 return elem
.innerHTML
;
5969 // See if we can take a shortcut and just use innerHTML
5970 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5971 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5973 value
= jQuery
.htmlPrefilter( value
);
5976 for ( ; i
< l
; i
++ ) {
5977 elem
= this[ i
] || {};
5979 // Remove element nodes and prevent memory leaks
5980 if ( elem
.nodeType
=== 1 ) {
5981 jQuery
.cleanData( getAll( elem
, false ) );
5982 elem
.innerHTML
= value
;
5988 // If using innerHTML throws an exception, use the fallback method
5993 this.empty().append( value
);
5995 }, null, value
, arguments
.length
);
5998 replaceWith: function() {
6001 // Make the changes, replacing each non-ignored context element with the new content
6002 return domManip( this, arguments
, function( elem
) {
6003 var parent
= this.parentNode
;
6005 if ( jQuery
.inArray( this, ignored
) < 0 ) {
6006 jQuery
.cleanData( getAll( this ) );
6008 parent
.replaceChild( elem
, this );
6012 // Force callback invocation
6019 prependTo
: "prepend",
6020 insertBefore
: "before",
6021 insertAfter
: "after",
6022 replaceAll
: "replaceWith"
6023 }, function( name
, original
) {
6024 jQuery
.fn
[ name
] = function( selector
) {
6027 insert
= jQuery( selector
),
6028 last
= insert
.length
- 1,
6031 for ( ; i
<= last
; i
++ ) {
6032 elems
= i
=== last
? this : this.clone( true );
6033 jQuery( insert
[ i
] )[ original
]( elems
);
6035 // Support: Android <=4.0 only, PhantomJS 1 only
6036 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6037 push
.apply( ret
, elems
.get() );
6040 return this.pushStack( ret
);
6043 var rnumnonpx
= new RegExp( "^(" + pnum
+ ")(?!px)[a-z%]+$", "i" );
6045 var getStyles = function( elem
) {
6047 // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
6048 // IE throws on elements created in popups
6049 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6050 var view
= elem
.ownerDocument
.defaultView
;
6052 if ( !view
|| !view
.opener
) {
6056 return view
.getComputedStyle( elem
);
6059 var rboxStyle
= new RegExp( cssExpand
.join( "|" ), "i" );
6065 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6066 // so they're executed at the same time to save the second computation.
6067 function computeStyleTests() {
6069 // This is a singleton, we need to execute it only once
6074 container
.style
.cssText
= "position:absolute;left:-11111px;width:60px;" +
6075 "margin-top:1px;padding:0;border:0";
6077 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
6078 "margin:auto;border:1px;padding:1px;" +
6080 documentElement
.appendChild( container
).appendChild( div
);
6082 var divStyle
= window
.getComputedStyle( div
);
6083 pixelPositionVal
= divStyle
.top
!== "1%";
6085 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6086 reliableMarginLeftVal
= roundPixelMeasures( divStyle
.marginLeft
) === 12;
6088 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
6089 // Some styles come back with percentage values, even though they shouldn't
6090 div
.style
.right
= "60%";
6091 pixelBoxStylesVal
= roundPixelMeasures( divStyle
.right
) === 36;
6093 // Support: IE 9 - 11 only
6094 // Detect misreporting of content dimensions for box-sizing:border-box elements
6095 boxSizingReliableVal
= roundPixelMeasures( divStyle
.width
) === 36;
6097 // Support: IE 9 only
6098 // Detect overflow:scroll screwiness (gh-3699)
6099 div
.style
.position
= "absolute";
6100 scrollboxSizeVal
= div
.offsetWidth
=== 36 || "absolute";
6102 documentElement
.removeChild( container
);
6104 // Nullify the div so it wouldn't be stored in the memory and
6105 // it will also be a sign that checks already performed
6109 function roundPixelMeasures( measure
) {
6110 return Math
.round( parseFloat( measure
) );
6113 var pixelPositionVal
, boxSizingReliableVal
, scrollboxSizeVal
, pixelBoxStylesVal
,
6114 reliableMarginLeftVal
,
6115 container
= document
.createElement( "div" ),
6116 div
= document
.createElement( "div" );
6118 // Finish early in limited (non-browser) environments
6123 // Support: IE <=9 - 11 only
6124 // Style of cloned element affects source element cloned (#8908)
6125 div
.style
.backgroundClip
= "content-box";
6126 div
.cloneNode( true ).style
.backgroundClip
= "";
6127 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
6129 jQuery
.extend( support
, {
6130 boxSizingReliable: function() {
6131 computeStyleTests();
6132 return boxSizingReliableVal
;
6134 pixelBoxStyles: function() {
6135 computeStyleTests();
6136 return pixelBoxStylesVal
;
6138 pixelPosition: function() {
6139 computeStyleTests();
6140 return pixelPositionVal
;
6142 reliableMarginLeft: function() {
6143 computeStyleTests();
6144 return reliableMarginLeftVal
;
6146 scrollboxSize: function() {
6147 computeStyleTests();
6148 return scrollboxSizeVal
;
6154 function curCSS( elem
, name
, computed
) {
6155 var width
, minWidth
, maxWidth
, ret
,
6157 // Support: Firefox 51+
6158 // Retrieving style before computed somehow
6159 // fixes an issue with getting wrong values
6160 // on detached elements
6163 computed
= computed
|| getStyles( elem
);
6165 // getPropertyValue is needed for:
6166 // .css('filter') (IE 9 only, #12537)
6167 // .css('--customProperty) (#3144)
6169 ret
= computed
.getPropertyValue( name
) || computed
[ name
];
6171 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
, elem
) ) {
6172 ret
= jQuery
.style( elem
, name
);
6175 // A tribute to the "awesome hack by Dean Edwards"
6176 // Android Browser returns percentage for some values,
6177 // but width seems to be reliably pixels.
6178 // This is against the CSSOM draft spec:
6179 // https://drafts.csswg.org/cssom/#resolved-values
6180 if ( !support
.pixelBoxStyles() && rnumnonpx
.test( ret
) && rboxStyle
.test( name
) ) {
6182 // Remember the original values
6183 width
= style
.width
;
6184 minWidth
= style
.minWidth
;
6185 maxWidth
= style
.maxWidth
;
6187 // Put in the new values to get a computed value out
6188 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
6189 ret
= computed
.width
;
6191 // Revert the changed values
6192 style
.width
= width
;
6193 style
.minWidth
= minWidth
;
6194 style
.maxWidth
= maxWidth
;
6198 return ret
!== undefined ?
6200 // Support: IE <=9 - 11 only
6201 // IE returns zIndex value as an integer.
6207 function addGetHookIf( conditionFn
, hookFn
) {
6209 // Define the hook, we'll check on the first run if it's really needed.
6212 if ( conditionFn() ) {
6214 // Hook not needed (or it's not possible to use it due
6215 // to missing dependency), remove it.
6220 // Hook needed; redefine it so that the support test is not executed again.
6221 return ( this.get = hookFn
).apply( this, arguments
);
6229 // Swappable if display is none or starts with table
6230 // except "table", "table-cell", or "table-caption"
6231 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6232 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
6233 rcustomProp
= /^--/,
6234 cssShow
= { position
: "absolute", visibility
: "hidden", display
: "block" },
6235 cssNormalTransform
= {
6240 cssPrefixes
= [ "Webkit", "Moz", "ms" ],
6241 emptyStyle
= document
.createElement( "div" ).style
;
6243 // Return a css property mapped to a potentially vendor prefixed property
6244 function vendorPropName( name
) {
6246 // Shortcut for names that are not vendor prefixed
6247 if ( name
in emptyStyle
) {
6251 // Check for vendor prefixed names
6252 var capName
= name
[ 0 ].toUpperCase() + name
.slice( 1 ),
6253 i
= cssPrefixes
.length
;
6256 name
= cssPrefixes
[ i
] + capName
;
6257 if ( name
in emptyStyle
) {
6263 // Return a property mapped along what jQuery.cssProps suggests or to
6264 // a vendor prefixed property.
6265 function finalPropName( name
) {
6266 var ret
= jQuery
.cssProps
[ name
];
6268 ret
= jQuery
.cssProps
[ name
] = vendorPropName( name
) || name
;
6273 function setPositiveNumber( elem
, value
, subtract
) {
6275 // Any relative (+/-) values have already been
6276 // normalized at this point
6277 var matches
= rcssNum
.exec( value
);
6280 // Guard against undefined "subtract", e.g., when used as in cssHooks
6281 Math
.max( 0, matches
[ 2 ] - ( subtract
|| 0 ) ) + ( matches
[ 3 ] || "px" ) :
6285 function boxModelAdjustment( elem
, dimension
, box
, isBorderBox
, styles
, computedVal
) {
6286 var i
= dimension
=== "width" ? 1 : 0,
6290 // Adjustment may not be necessary
6291 if ( box
=== ( isBorderBox
? "border" : "content" ) ) {
6295 for ( ; i
< 4; i
+= 2 ) {
6297 // Both box models exclude margin
6298 if ( box
=== "margin" ) {
6299 delta
+= jQuery
.css( elem
, box
+ cssExpand
[ i
], true, styles
);
6302 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6303 if ( !isBorderBox
) {
6306 delta
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6308 // For "border" or "margin", add border
6309 if ( box
!== "padding" ) {
6310 delta
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6312 // But still keep track of it otherwise
6314 extra
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6317 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6318 // "padding" or "margin"
6321 // For "content", subtract padding
6322 if ( box
=== "content" ) {
6323 delta
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6326 // For "content" or "padding", subtract border
6327 if ( box
!== "margin" ) {
6328 delta
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6333 // Account for positive content-box scroll gutter when requested by providing computedVal
6334 if ( !isBorderBox
&& computedVal
>= 0 ) {
6336 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6337 // Assuming integer scroll gutter, subtract the rest and round down
6338 delta
+= Math
.max( 0, Math
.ceil(
6339 elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ] -
6350 function getWidthOrHeight( elem
, dimension
, extra
) {
6352 // Start with computed style
6353 var styles
= getStyles( elem
),
6354 val
= curCSS( elem
, dimension
, styles
),
6355 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6356 valueIsBorderBox
= isBorderBox
;
6358 // Support: Firefox <=54
6359 // Return a confounding non-pixel value or feign ignorance, as appropriate.
6360 if ( rnumnonpx
.test( val
) ) {
6367 // Check for style in case a browser which returns unreliable values
6368 // for getComputedStyle silently falls back to the reliable elem.style
6369 valueIsBorderBox
= valueIsBorderBox
&&
6370 ( support
.boxSizingReliable() || val
=== elem
.style
[ dimension
] );
6372 // Fall back to offsetWidth/offsetHeight when value is "auto"
6373 // This happens for inline elements with no explicit setting (gh-3571)
6374 // Support: Android <=4.1 - 4.3 only
6375 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
6376 if ( val
=== "auto" ||
6377 !parseFloat( val
) && jQuery
.css( elem
, "display", false, styles
) === "inline" ) {
6379 val
= elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ];
6381 // offsetWidth/offsetHeight provide border-box values
6382 valueIsBorderBox
= true;
6385 // Normalize "" and auto
6386 val
= parseFloat( val
) || 0;
6388 // Adjust for the element's box model
6393 extra
|| ( isBorderBox
? "border" : "content" ),
6397 // Provide the current computed size to request scroll gutter calculation (gh-3589)
6405 // Add in style property hooks for overriding the default
6406 // behavior of getting and setting a style property
6409 get: function( elem
, computed
) {
6412 // We should always get a number back from opacity
6413 var ret
= curCSS( elem
, "opacity" );
6414 return ret
=== "" ? "1" : ret
;
6420 // Don't automatically add "px" to these possibly-unitless properties
6422 "animationIterationCount": true,
6423 "columnCount": true,
6424 "fillOpacity": true,
6437 // Add in properties whose names you wish to fix before
6438 // setting or getting the value
6441 // Get and set the style property on a DOM Node
6442 style: function( elem
, name
, value
, extra
) {
6444 // Don't set styles on text and comment nodes
6445 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6449 // Make sure that we're working with the right name
6450 var ret
, type
, hooks
,
6451 origName
= camelCase( name
),
6452 isCustomProp
= rcustomProp
.test( name
),
6455 // Make sure that we're working with the right name. We don't
6456 // want to query the value if it is a CSS custom property
6457 // since they are user-defined.
6458 if ( !isCustomProp
) {
6459 name
= finalPropName( origName
);
6462 // Gets hook for the prefixed version, then unprefixed version
6463 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6465 // Check if we're setting a value
6466 if ( value
!== undefined ) {
6467 type
= typeof value
;
6469 // Convert "+=" or "-=" to relative numbers (#7345)
6470 if ( type
=== "string" && ( ret
= rcssNum
.exec( value
) ) && ret
[ 1 ] ) {
6471 value
= adjustCSS( elem
, name
, ret
);
6477 // Make sure that null and NaN values aren't set (#7116)
6478 if ( value
== null || value
!== value
) {
6482 // If a number was passed in, add the unit (except for certain CSS properties)
6483 if ( type
=== "number" ) {
6484 value
+= ret
&& ret
[ 3 ] || ( jQuery
.cssNumber
[ origName
] ? "" : "px" );
6487 // background-* props affect original clone's values
6488 if ( !support
.clearCloneStyle
&& value
=== "" && name
.indexOf( "background" ) === 0 ) {
6489 style
[ name
] = "inherit";
6492 // If a hook was provided, use that value, otherwise just set the specified value
6493 if ( !hooks
|| !( "set" in hooks
) ||
6494 ( value
= hooks
.set( elem
, value
, extra
) ) !== undefined ) {
6496 if ( isCustomProp
) {
6497 style
.setProperty( name
, value
);
6499 style
[ name
] = value
;
6505 // If a hook was provided get the non-computed value from there
6506 if ( hooks
&& "get" in hooks
&&
6507 ( ret
= hooks
.get( elem
, false, extra
) ) !== undefined ) {
6512 // Otherwise just get the value from the style object
6513 return style
[ name
];
6517 css: function( elem
, name
, extra
, styles
) {
6518 var val
, num
, hooks
,
6519 origName
= camelCase( name
),
6520 isCustomProp
= rcustomProp
.test( name
);
6522 // Make sure that we're working with the right name. We don't
6523 // want to modify the value if it is a CSS custom property
6524 // since they are user-defined.
6525 if ( !isCustomProp
) {
6526 name
= finalPropName( origName
);
6529 // Try prefixed name followed by the unprefixed name
6530 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6532 // If a hook was provided get the computed value from there
6533 if ( hooks
&& "get" in hooks
) {
6534 val
= hooks
.get( elem
, true, extra
);
6537 // Otherwise, if a way to get the computed value exists, use that
6538 if ( val
=== undefined ) {
6539 val
= curCSS( elem
, name
, styles
);
6542 // Convert "normal" to computed value
6543 if ( val
=== "normal" && name
in cssNormalTransform
) {
6544 val
= cssNormalTransform
[ name
];
6547 // Make numeric if forced or a qualifier was provided and val looks numeric
6548 if ( extra
=== "" || extra
) {
6549 num
= parseFloat( val
);
6550 return extra
=== true || isFinite( num
) ? num
|| 0 : val
;
6557 jQuery
.each( [ "height", "width" ], function( i
, dimension
) {
6558 jQuery
.cssHooks
[ dimension
] = {
6559 get: function( elem
, computed
, extra
) {
6562 // Certain elements can have dimension info if we invisibly show them
6563 // but it must have a current display style that would benefit
6564 return rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) &&
6566 // Support: Safari 8+
6567 // Table columns in Safari have non-zero offsetWidth & zero
6568 // getBoundingClientRect().width unless display is changed.
6569 // Support: IE <=11 only
6570 // Running getBoundingClientRect on a disconnected node
6571 // in IE throws an error.
6572 ( !elem
.getClientRects().length
|| !elem
.getBoundingClientRect().width
) ?
6573 swap( elem
, cssShow
, function() {
6574 return getWidthOrHeight( elem
, dimension
, extra
);
6576 getWidthOrHeight( elem
, dimension
, extra
);
6580 set: function( elem
, value
, extra
) {
6582 styles
= getStyles( elem
),
6583 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6584 subtract
= extra
&& boxModelAdjustment(
6592 // Account for unreliable border-box dimensions by comparing offset* to computed and
6593 // faking a content-box to get border and padding (gh-3699)
6594 if ( isBorderBox
&& support
.scrollboxSize() === styles
.position
) {
6595 subtract
-= Math
.ceil(
6596 elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ] -
6597 parseFloat( styles
[ dimension
] ) -
6598 boxModelAdjustment( elem
, dimension
, "border", false, styles
) -
6603 // Convert to pixels if value adjustment is needed
6604 if ( subtract
&& ( matches
= rcssNum
.exec( value
) ) &&
6605 ( matches
[ 3 ] || "px" ) !== "px" ) {
6607 elem
.style
[ dimension
] = value
;
6608 value
= jQuery
.css( elem
, dimension
);
6611 return setPositiveNumber( elem
, value
, subtract
);
6616 jQuery
.cssHooks
.marginLeft
= addGetHookIf( support
.reliableMarginLeft
,
6617 function( elem
, computed
) {
6619 return ( parseFloat( curCSS( elem
, "marginLeft" ) ) ||
6620 elem
.getBoundingClientRect().left
-
6621 swap( elem
, { marginLeft
: 0 }, function() {
6622 return elem
.getBoundingClientRect().left
;
6629 // These hooks are used by animate to expand properties
6634 }, function( prefix
, suffix
) {
6635 jQuery
.cssHooks
[ prefix
+ suffix
] = {
6636 expand: function( value
) {
6640 // Assumes a single number if not a string
6641 parts
= typeof value
=== "string" ? value
.split( " " ) : [ value
];
6643 for ( ; i
< 4; i
++ ) {
6644 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
6645 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
6652 if ( prefix
!== "margin" ) {
6653 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
6658 css: function( name
, value
) {
6659 return access( this, function( elem
, name
, value
) {
6664 if ( Array
.isArray( name
) ) {
6665 styles
= getStyles( elem
);
6668 for ( ; i
< len
; i
++ ) {
6669 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
6675 return value
!== undefined ?
6676 jQuery
.style( elem
, name
, value
) :
6677 jQuery
.css( elem
, name
);
6678 }, name
, value
, arguments
.length
> 1 );
6683 function Tween( elem
, options
, prop
, end
, easing
) {
6684 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
6686 jQuery
.Tween
= Tween
;
6690 init: function( elem
, options
, prop
, end
, easing
, unit
) {
6693 this.easing
= easing
|| jQuery
.easing
._default
;
6694 this.options
= options
;
6695 this.start
= this.now
= this.cur();
6697 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
6700 var hooks
= Tween
.propHooks
[ this.prop
];
6702 return hooks
&& hooks
.get ?
6704 Tween
.propHooks
._default
.get( this );
6706 run: function( percent
) {
6708 hooks
= Tween
.propHooks
[ this.prop
];
6710 if ( this.options
.duration
) {
6711 this.pos
= eased
= jQuery
.easing
[ this.easing
](
6712 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
6715 this.pos
= eased
= percent
;
6717 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
6719 if ( this.options
.step
) {
6720 this.options
.step
.call( this.elem
, this.now
, this );
6723 if ( hooks
&& hooks
.set ) {
6726 Tween
.propHooks
._default
.set( this );
6732 Tween
.prototype.init
.prototype = Tween
.prototype;
6736 get: function( tween
) {
6739 // Use a property on the element directly when it is not a DOM element,
6740 // or when there is no matching style property that exists.
6741 if ( tween
.elem
.nodeType
!== 1 ||
6742 tween
.elem
[ tween
.prop
] != null && tween
.elem
.style
[ tween
.prop
] == null ) {
6743 return tween
.elem
[ tween
.prop
];
6746 // Passing an empty string as a 3rd parameter to .css will automatically
6747 // attempt a parseFloat and fallback to a string if the parse fails.
6748 // Simple values such as "10px" are parsed to Float;
6749 // complex values such as "rotate(1rad)" are returned as-is.
6750 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
6752 // Empty strings, null, undefined and "auto" are converted to 0.
6753 return !result
|| result
=== "auto" ? 0 : result
;
6755 set: function( tween
) {
6757 // Use step hook for back compat.
6758 // Use cssHook if its there.
6759 // Use .style if available and use plain properties where available.
6760 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
6761 jQuery
.fx
.step
[ tween
.prop
]( tween
);
6762 } else if ( tween
.elem
.nodeType
=== 1 &&
6763 ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null ||
6764 jQuery
.cssHooks
[ tween
.prop
] ) ) {
6765 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
6767 tween
.elem
[ tween
.prop
] = tween
.now
;
6773 // Support: IE <=9 only
6774 // Panic based approach to setting things on disconnected nodes
6775 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
6776 set: function( tween
) {
6777 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
6778 tween
.elem
[ tween
.prop
] = tween
.now
;
6784 linear: function( p
) {
6787 swing: function( p
) {
6788 return 0.5 - Math
.cos( p
* Math
.PI
) / 2;
6793 jQuery
.fx
= Tween
.prototype.init
;
6795 // Back compat <1.8 extension point
6796 jQuery
.fx
.step
= {};
6803 rfxtypes
= /^(?:toggle|show|hide)$/,
6804 rrun
= /queueHooks$/;
6806 function schedule() {
6808 if ( document
.hidden
=== false && window
.requestAnimationFrame
) {
6809 window
.requestAnimationFrame( schedule
);
6811 window
.setTimeout( schedule
, jQuery
.fx
.interval
);
6818 // Animations created synchronously will run synchronously
6819 function createFxNow() {
6820 window
.setTimeout( function() {
6823 return ( fxNow
= Date
.now() );
6826 // Generate parameters to create a standard animation
6827 function genFx( type
, includeWidth
) {
6830 attrs
= { height
: type
};
6832 // If we include width, step value is 1 to do all cssExpand values,
6833 // otherwise step value is 2 to skip over Left and Right
6834 includeWidth
= includeWidth
? 1 : 0;
6835 for ( ; i
< 4; i
+= 2 - includeWidth
) {
6836 which
= cssExpand
[ i
];
6837 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
6840 if ( includeWidth
) {
6841 attrs
.opacity
= attrs
.width
= type
;
6847 function createTween( value
, prop
, animation
) {
6849 collection
= ( Animation
.tweeners
[ prop
] || [] ).concat( Animation
.tweeners
[ "*" ] ),
6851 length
= collection
.length
;
6852 for ( ; index
< length
; index
++ ) {
6853 if ( ( tween
= collection
[ index
].call( animation
, prop
, value
) ) ) {
6855 // We're done with this property
6861 function defaultPrefilter( elem
, props
, opts
) {
6862 var prop
, value
, toggle
, hooks
, oldfire
, propTween
, restoreDisplay
, display
,
6863 isBox
= "width" in props
|| "height" in props
,
6867 hidden
= elem
.nodeType
&& isHiddenWithinTree( elem
),
6868 dataShow
= dataPriv
.get( elem
, "fxshow" );
6870 // Queue-skipping animations hijack the fx hooks
6871 if ( !opts
.queue
) {
6872 hooks
= jQuery
._queueHooks( elem
, "fx" );
6873 if ( hooks
.unqueued
== null ) {
6875 oldfire
= hooks
.empty
.fire
;
6876 hooks
.empty
.fire = function() {
6877 if ( !hooks
.unqueued
) {
6884 anim
.always( function() {
6886 // Ensure the complete handler is called before this completes
6887 anim
.always( function() {
6889 if ( !jQuery
.queue( elem
, "fx" ).length
) {
6896 // Detect show/hide animations
6897 for ( prop
in props
) {
6898 value
= props
[ prop
];
6899 if ( rfxtypes
.test( value
) ) {
6900 delete props
[ prop
];
6901 toggle
= toggle
|| value
=== "toggle";
6902 if ( value
=== ( hidden
? "hide" : "show" ) ) {
6904 // Pretend to be hidden if this is a "show" and
6905 // there is still data from a stopped show/hide
6906 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
6909 // Ignore all other no-op show/hide data
6914 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
6918 // Bail out if this is a no-op like .hide().hide()
6919 propTween
= !jQuery
.isEmptyObject( props
);
6920 if ( !propTween
&& jQuery
.isEmptyObject( orig
) ) {
6924 // Restrict "overflow" and "display" styles during box animations
6925 if ( isBox
&& elem
.nodeType
=== 1 ) {
6927 // Support: IE <=9 - 11, Edge 12 - 15
6928 // Record all 3 overflow attributes because IE does not infer the shorthand
6929 // from identically-valued overflowX and overflowY and Edge just mirrors
6930 // the overflowX value there.
6931 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
6933 // Identify a display type, preferring old show/hide data over the CSS cascade
6934 restoreDisplay
= dataShow
&& dataShow
.display
;
6935 if ( restoreDisplay
== null ) {
6936 restoreDisplay
= dataPriv
.get( elem
, "display" );
6938 display
= jQuery
.css( elem
, "display" );
6939 if ( display
=== "none" ) {
6940 if ( restoreDisplay
) {
6941 display
= restoreDisplay
;
6944 // Get nonempty value(s) by temporarily forcing visibility
6945 showHide( [ elem
], true );
6946 restoreDisplay
= elem
.style
.display
|| restoreDisplay
;
6947 display
= jQuery
.css( elem
, "display" );
6948 showHide( [ elem
] );
6952 // Animate inline elements as inline-block
6953 if ( display
=== "inline" || display
=== "inline-block" && restoreDisplay
!= null ) {
6954 if ( jQuery
.css( elem
, "float" ) === "none" ) {
6956 // Restore the original display value at the end of pure show/hide animations
6958 anim
.done( function() {
6959 style
.display
= restoreDisplay
;
6961 if ( restoreDisplay
== null ) {
6962 display
= style
.display
;
6963 restoreDisplay
= display
=== "none" ? "" : display
;
6966 style
.display
= "inline-block";
6971 if ( opts
.overflow
) {
6972 style
.overflow
= "hidden";
6973 anim
.always( function() {
6974 style
.overflow
= opts
.overflow
[ 0 ];
6975 style
.overflowX
= opts
.overflow
[ 1 ];
6976 style
.overflowY
= opts
.overflow
[ 2 ];
6980 // Implement show/hide animations
6982 for ( prop
in orig
) {
6984 // General show/hide setup for this element animation
6987 if ( "hidden" in dataShow
) {
6988 hidden
= dataShow
.hidden
;
6991 dataShow
= dataPriv
.access( elem
, "fxshow", { display
: restoreDisplay
} );
6994 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
6996 dataShow
.hidden
= !hidden
;
6999 // Show elements before animating them
7001 showHide( [ elem
], true );
7004 /* eslint-disable no-loop-func */
7006 anim
.done( function() {
7008 /* eslint-enable no-loop-func */
7010 // The final step of a "hide" animation is actually hiding the element
7012 showHide( [ elem
] );
7014 dataPriv
.remove( elem
, "fxshow" );
7015 for ( prop
in orig
) {
7016 jQuery
.style( elem
, prop
, orig
[ prop
] );
7021 // Per-property setup
7022 propTween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
7023 if ( !( prop
in dataShow
) ) {
7024 dataShow
[ prop
] = propTween
.start
;
7026 propTween
.end
= propTween
.start
;
7027 propTween
.start
= 0;
7033 function propFilter( props
, specialEasing
) {
7034 var index
, name
, easing
, value
, hooks
;
7036 // camelCase, specialEasing and expand cssHook pass
7037 for ( index
in props
) {
7038 name
= camelCase( index
);
7039 easing
= specialEasing
[ name
];
7040 value
= props
[ index
];
7041 if ( Array
.isArray( value
) ) {
7042 easing
= value
[ 1 ];
7043 value
= props
[ index
] = value
[ 0 ];
7046 if ( index
!== name
) {
7047 props
[ name
] = value
;
7048 delete props
[ index
];
7051 hooks
= jQuery
.cssHooks
[ name
];
7052 if ( hooks
&& "expand" in hooks
) {
7053 value
= hooks
.expand( value
);
7054 delete props
[ name
];
7056 // Not quite $.extend, this won't overwrite existing keys.
7057 // Reusing 'index' because we have the correct "name"
7058 for ( index
in value
) {
7059 if ( !( index
in props
) ) {
7060 props
[ index
] = value
[ index
];
7061 specialEasing
[ index
] = easing
;
7065 specialEasing
[ name
] = easing
;
7070 function Animation( elem
, properties
, options
) {
7074 length
= Animation
.prefilters
.length
,
7075 deferred
= jQuery
.Deferred().always( function() {
7077 // Don't match elem in the :animated selector
7084 var currentTime
= fxNow
|| createFxNow(),
7085 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
7087 // Support: Android 2.3 only
7088 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
7089 temp
= remaining
/ animation
.duration
|| 0,
7092 length
= animation
.tweens
.length
;
7094 for ( ; index
< length
; index
++ ) {
7095 animation
.tweens
[ index
].run( percent
);
7098 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
] );
7100 // If there's more to do, yield
7101 if ( percent
< 1 && length
) {
7105 // If this was an empty animation, synthesize a final progress notification
7107 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7110 // Resolve the animation and report its conclusion
7111 deferred
.resolveWith( elem
, [ animation
] );
7114 animation
= deferred
.promise( {
7116 props
: jQuery
.extend( {}, properties
),
7117 opts
: jQuery
.extend( true, {
7119 easing
: jQuery
.easing
._default
7121 originalProperties
: properties
,
7122 originalOptions
: options
,
7123 startTime
: fxNow
|| createFxNow(),
7124 duration
: options
.duration
,
7126 createTween: function( prop
, end
) {
7127 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
7128 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
7129 animation
.tweens
.push( tween
);
7132 stop: function( gotoEnd
) {
7135 // If we are going to the end, we want to run all the tweens
7136 // otherwise we skip this part
7137 length
= gotoEnd
? animation
.tweens
.length
: 0;
7142 for ( ; index
< length
; index
++ ) {
7143 animation
.tweens
[ index
].run( 1 );
7146 // Resolve when we played the last frame; otherwise, reject
7148 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7149 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
7151 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
7156 props
= animation
.props
;
7158 propFilter( props
, animation
.opts
.specialEasing
);
7160 for ( ; index
< length
; index
++ ) {
7161 result
= Animation
.prefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
7163 if ( isFunction( result
.stop
) ) {
7164 jQuery
._queueHooks( animation
.elem
, animation
.opts
.queue
).stop
=
7165 result
.stop
.bind( result
);
7171 jQuery
.map( props
, createTween
, animation
);
7173 if ( isFunction( animation
.opts
.start
) ) {
7174 animation
.opts
.start
.call( elem
, animation
);
7177 // Attach callbacks from options
7179 .progress( animation
.opts
.progress
)
7180 .done( animation
.opts
.done
, animation
.opts
.complete
)
7181 .fail( animation
.opts
.fail
)
7182 .always( animation
.opts
.always
);
7185 jQuery
.extend( tick
, {
7188 queue
: animation
.opts
.queue
7195 jQuery
.Animation
= jQuery
.extend( Animation
, {
7198 "*": [ function( prop
, value
) {
7199 var tween
= this.createTween( prop
, value
);
7200 adjustCSS( tween
.elem
, prop
, rcssNum
.exec( value
), tween
);
7205 tweener: function( props
, callback
) {
7206 if ( isFunction( props
) ) {
7210 props
= props
.match( rnothtmlwhite
);
7215 length
= props
.length
;
7217 for ( ; index
< length
; index
++ ) {
7218 prop
= props
[ index
];
7219 Animation
.tweeners
[ prop
] = Animation
.tweeners
[ prop
] || [];
7220 Animation
.tweeners
[ prop
].unshift( callback
);
7224 prefilters
: [ defaultPrefilter
],
7226 prefilter: function( callback
, prepend
) {
7228 Animation
.prefilters
.unshift( callback
);
7230 Animation
.prefilters
.push( callback
);
7235 jQuery
.speed = function( speed
, easing
, fn
) {
7236 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
7237 complete
: fn
|| !fn
&& easing
||
7238 isFunction( speed
) && speed
,
7240 easing
: fn
&& easing
|| easing
&& !isFunction( easing
) && easing
7243 // Go to the end state if fx are off
7244 if ( jQuery
.fx
.off
) {
7248 if ( typeof opt
.duration
!== "number" ) {
7249 if ( opt
.duration
in jQuery
.fx
.speeds
) {
7250 opt
.duration
= jQuery
.fx
.speeds
[ opt
.duration
];
7253 opt
.duration
= jQuery
.fx
.speeds
._default
;
7258 // Normalize opt.queue - true/undefined/null -> "fx"
7259 if ( opt
.queue
== null || opt
.queue
=== true ) {
7264 opt
.old
= opt
.complete
;
7266 opt
.complete = function() {
7267 if ( isFunction( opt
.old
) ) {
7268 opt
.old
.call( this );
7272 jQuery
.dequeue( this, opt
.queue
);
7280 fadeTo: function( speed
, to
, easing
, callback
) {
7282 // Show any hidden elements after setting opacity to 0
7283 return this.filter( isHiddenWithinTree
).css( "opacity", 0 ).show()
7285 // Animate to the value specified
7286 .end().animate( { opacity
: to
}, speed
, easing
, callback
);
7288 animate: function( prop
, speed
, easing
, callback
) {
7289 var empty
= jQuery
.isEmptyObject( prop
),
7290 optall
= jQuery
.speed( speed
, easing
, callback
),
7291 doAnimation = function() {
7293 // Operate on a copy of prop so per-property easing won't be lost
7294 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
7296 // Empty animations, or finishing resolves immediately
7297 if ( empty
|| dataPriv
.get( this, "finish" ) ) {
7301 doAnimation
.finish
= doAnimation
;
7303 return empty
|| optall
.queue
=== false ?
7304 this.each( doAnimation
) :
7305 this.queue( optall
.queue
, doAnimation
);
7307 stop: function( type
, clearQueue
, gotoEnd
) {
7308 var stopQueue = function( hooks
) {
7309 var stop
= hooks
.stop
;
7314 if ( typeof type
!== "string" ) {
7315 gotoEnd
= clearQueue
;
7319 if ( clearQueue
&& type
!== false ) {
7320 this.queue( type
|| "fx", [] );
7323 return this.each( function() {
7325 index
= type
!= null && type
+ "queueHooks",
7326 timers
= jQuery
.timers
,
7327 data
= dataPriv
.get( this );
7330 if ( data
[ index
] && data
[ index
].stop
) {
7331 stopQueue( data
[ index
] );
7334 for ( index
in data
) {
7335 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
7336 stopQueue( data
[ index
] );
7341 for ( index
= timers
.length
; index
--; ) {
7342 if ( timers
[ index
].elem
=== this &&
7343 ( type
== null || timers
[ index
].queue
=== type
) ) {
7345 timers
[ index
].anim
.stop( gotoEnd
);
7347 timers
.splice( index
, 1 );
7351 // Start the next in the queue if the last step wasn't forced.
7352 // Timers currently will call their complete callbacks, which
7353 // will dequeue but only if they were gotoEnd.
7354 if ( dequeue
|| !gotoEnd
) {
7355 jQuery
.dequeue( this, type
);
7359 finish: function( type
) {
7360 if ( type
!== false ) {
7361 type
= type
|| "fx";
7363 return this.each( function() {
7365 data
= dataPriv
.get( this ),
7366 queue
= data
[ type
+ "queue" ],
7367 hooks
= data
[ type
+ "queueHooks" ],
7368 timers
= jQuery
.timers
,
7369 length
= queue
? queue
.length
: 0;
7371 // Enable finishing flag on private data
7374 // Empty the queue first
7375 jQuery
.queue( this, type
, [] );
7377 if ( hooks
&& hooks
.stop
) {
7378 hooks
.stop
.call( this, true );
7381 // Look for any active animations, and finish them
7382 for ( index
= timers
.length
; index
--; ) {
7383 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
7384 timers
[ index
].anim
.stop( true );
7385 timers
.splice( index
, 1 );
7389 // Look for any animations in the old queue and finish them
7390 for ( index
= 0; index
< length
; index
++ ) {
7391 if ( queue
[ index
] && queue
[ index
].finish
) {
7392 queue
[ index
].finish
.call( this );
7396 // Turn off finishing flag
7402 jQuery
.each( [ "toggle", "show", "hide" ], function( i
, name
) {
7403 var cssFn
= jQuery
.fn
[ name
];
7404 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7405 return speed
== null || typeof speed
=== "boolean" ?
7406 cssFn
.apply( this, arguments
) :
7407 this.animate( genFx( name
, true ), speed
, easing
, callback
);
7411 // Generate shortcuts for custom animations
7413 slideDown
: genFx( "show" ),
7414 slideUp
: genFx( "hide" ),
7415 slideToggle
: genFx( "toggle" ),
7416 fadeIn
: { opacity
: "show" },
7417 fadeOut
: { opacity
: "hide" },
7418 fadeToggle
: { opacity
: "toggle" }
7419 }, function( name
, props
) {
7420 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7421 return this.animate( props
, speed
, easing
, callback
);
7426 jQuery
.fx
.tick = function() {
7429 timers
= jQuery
.timers
;
7433 for ( ; i
< timers
.length
; i
++ ) {
7434 timer
= timers
[ i
];
7436 // Run the timer and safely remove it when done (allowing for external removal)
7437 if ( !timer() && timers
[ i
] === timer
) {
7438 timers
.splice( i
--, 1 );
7442 if ( !timers
.length
) {
7448 jQuery
.fx
.timer = function( timer
) {
7449 jQuery
.timers
.push( timer
);
7453 jQuery
.fx
.interval
= 13;
7454 jQuery
.fx
.start = function() {
7463 jQuery
.fx
.stop = function() {
7467 jQuery
.fx
.speeds
= {
7476 // Based off of the plugin by Clint Helfers, with permission.
7477 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
7478 jQuery
.fn
.delay = function( time
, type
) {
7479 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
7480 type
= type
|| "fx";
7482 return this.queue( type
, function( next
, hooks
) {
7483 var timeout
= window
.setTimeout( next
, time
);
7484 hooks
.stop = function() {
7485 window
.clearTimeout( timeout
);
7492 var input
= document
.createElement( "input" ),
7493 select
= document
.createElement( "select" ),
7494 opt
= select
.appendChild( document
.createElement( "option" ) );
7496 input
.type
= "checkbox";
7498 // Support: Android <=4.3 only
7499 // Default value for a checkbox should be "on"
7500 support
.checkOn
= input
.value
!== "";
7502 // Support: IE <=11 only
7503 // Must access selectedIndex to make default options select
7504 support
.optSelected
= opt
.selected
;
7506 // Support: IE <=11 only
7507 // An input loses its value after becoming a radio
7508 input
= document
.createElement( "input" );
7510 input
.type
= "radio";
7511 support
.radioValue
= input
.value
=== "t";
7516 attrHandle
= jQuery
.expr
.attrHandle
;
7519 attr: function( name
, value
) {
7520 return access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
7523 removeAttr: function( name
) {
7524 return this.each( function() {
7525 jQuery
.removeAttr( this, name
);
7531 attr: function( elem
, name
, value
) {
7533 nType
= elem
.nodeType
;
7535 // Don't get/set attributes on text, comment and attribute nodes
7536 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7540 // Fallback to prop when attributes are not supported
7541 if ( typeof elem
.getAttribute
=== "undefined" ) {
7542 return jQuery
.prop( elem
, name
, value
);
7545 // Attribute hooks are determined by the lowercase version
7546 // Grab necessary hook if one is defined
7547 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
7548 hooks
= jQuery
.attrHooks
[ name
.toLowerCase() ] ||
7549 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook
: undefined );
7552 if ( value
!== undefined ) {
7553 if ( value
=== null ) {
7554 jQuery
.removeAttr( elem
, name
);
7558 if ( hooks
&& "set" in hooks
&&
7559 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
7563 elem
.setAttribute( name
, value
+ "" );
7567 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
7571 ret
= jQuery
.find
.attr( elem
, name
);
7573 // Non-existent attributes return null, we normalize to undefined
7574 return ret
== null ? undefined : ret
;
7579 set: function( elem
, value
) {
7580 if ( !support
.radioValue
&& value
=== "radio" &&
7581 nodeName( elem
, "input" ) ) {
7582 var val
= elem
.value
;
7583 elem
.setAttribute( "type", value
);
7593 removeAttr: function( elem
, value
) {
7597 // Attribute names can contain non-HTML whitespace characters
7598 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
7599 attrNames
= value
&& value
.match( rnothtmlwhite
);
7601 if ( attrNames
&& elem
.nodeType
=== 1 ) {
7602 while ( ( name
= attrNames
[ i
++ ] ) ) {
7603 elem
.removeAttribute( name
);
7609 // Hooks for boolean attributes
7611 set: function( elem
, value
, name
) {
7612 if ( value
=== false ) {
7614 // Remove boolean attributes when set to false
7615 jQuery
.removeAttr( elem
, name
);
7617 elem
.setAttribute( name
, name
);
7623 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( i
, name
) {
7624 var getter
= attrHandle
[ name
] || jQuery
.find
.attr
;
7626 attrHandle
[ name
] = function( elem
, name
, isXML
) {
7628 lowercaseName
= name
.toLowerCase();
7632 // Avoid an infinite loop by temporarily removing this function from the getter
7633 handle
= attrHandle
[ lowercaseName
];
7634 attrHandle
[ lowercaseName
] = ret
;
7635 ret
= getter( elem
, name
, isXML
) != null ?
7638 attrHandle
[ lowercaseName
] = handle
;
7647 var rfocusable
= /^(?:input|select|textarea|button)$/i,
7648 rclickable
= /^(?:a|area)$/i;
7651 prop: function( name
, value
) {
7652 return access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
7655 removeProp: function( name
) {
7656 return this.each( function() {
7657 delete this[ jQuery
.propFix
[ name
] || name
];
7663 prop: function( elem
, name
, value
) {
7665 nType
= elem
.nodeType
;
7667 // Don't get/set properties on text, comment and attribute nodes
7668 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7672 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
7674 // Fix name and attach hooks
7675 name
= jQuery
.propFix
[ name
] || name
;
7676 hooks
= jQuery
.propHooks
[ name
];
7679 if ( value
!== undefined ) {
7680 if ( hooks
&& "set" in hooks
&&
7681 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
7685 return ( elem
[ name
] = value
);
7688 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
7692 return elem
[ name
];
7697 get: function( elem
) {
7699 // Support: IE <=9 - 11 only
7700 // elem.tabIndex doesn't always return the
7701 // correct value when it hasn't been explicitly set
7702 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
7703 // Use proper attribute retrieval(#12072)
7704 var tabindex
= jQuery
.find
.attr( elem
, "tabindex" );
7707 return parseInt( tabindex
, 10 );
7711 rfocusable
.test( elem
.nodeName
) ||
7712 rclickable
.test( elem
.nodeName
) &&
7725 "class": "className"
7729 // Support: IE <=11 only
7730 // Accessing the selectedIndex property
7731 // forces the browser to respect setting selected
7733 // The getter ensures a default option is selected
7734 // when in an optgroup
7735 // eslint rule "no-unused-expressions" is disabled for this code
7736 // since it considers such accessions noop
7737 if ( !support
.optSelected
) {
7738 jQuery
.propHooks
.selected
= {
7739 get: function( elem
) {
7741 /* eslint no-unused-expressions: "off" */
7743 var parent
= elem
.parentNode
;
7744 if ( parent
&& parent
.parentNode
) {
7745 parent
.parentNode
.selectedIndex
;
7749 set: function( elem
) {
7751 /* eslint no-unused-expressions: "off" */
7753 var parent
= elem
.parentNode
;
7755 parent
.selectedIndex
;
7757 if ( parent
.parentNode
) {
7758 parent
.parentNode
.selectedIndex
;
7777 jQuery
.propFix
[ this.toLowerCase() ] = this;
7783 // Strip and collapse whitespace according to HTML spec
7784 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
7785 function stripAndCollapse( value
) {
7786 var tokens
= value
.match( rnothtmlwhite
) || [];
7787 return tokens
.join( " " );
7791 function getClass( elem
) {
7792 return elem
.getAttribute
&& elem
.getAttribute( "class" ) || "";
7795 function classesToArray( value
) {
7796 if ( Array
.isArray( value
) ) {
7799 if ( typeof value
=== "string" ) {
7800 return value
.match( rnothtmlwhite
) || [];
7806 addClass: function( value
) {
7807 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
7810 if ( isFunction( value
) ) {
7811 return this.each( function( j
) {
7812 jQuery( this ).addClass( value
.call( this, j
, getClass( this ) ) );
7816 classes
= classesToArray( value
);
7818 if ( classes
.length
) {
7819 while ( ( elem
= this[ i
++ ] ) ) {
7820 curValue
= getClass( elem
);
7821 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
7825 while ( ( clazz
= classes
[ j
++ ] ) ) {
7826 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
7831 // Only assign if different to avoid unneeded rendering.
7832 finalValue
= stripAndCollapse( cur
);
7833 if ( curValue
!== finalValue
) {
7834 elem
.setAttribute( "class", finalValue
);
7843 removeClass: function( value
) {
7844 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
7847 if ( isFunction( value
) ) {
7848 return this.each( function( j
) {
7849 jQuery( this ).removeClass( value
.call( this, j
, getClass( this ) ) );
7853 if ( !arguments
.length
) {
7854 return this.attr( "class", "" );
7857 classes
= classesToArray( value
);
7859 if ( classes
.length
) {
7860 while ( ( elem
= this[ i
++ ] ) ) {
7861 curValue
= getClass( elem
);
7863 // This expression is here for better compressibility (see addClass)
7864 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
7868 while ( ( clazz
= classes
[ j
++ ] ) ) {
7870 // Remove *all* instances
7871 while ( cur
.indexOf( " " + clazz
+ " " ) > -1 ) {
7872 cur
= cur
.replace( " " + clazz
+ " ", " " );
7876 // Only assign if different to avoid unneeded rendering.
7877 finalValue
= stripAndCollapse( cur
);
7878 if ( curValue
!== finalValue
) {
7879 elem
.setAttribute( "class", finalValue
);
7888 toggleClass: function( value
, stateVal
) {
7889 var type
= typeof value
,
7890 isValidValue
= type
=== "string" || Array
.isArray( value
);
7892 if ( typeof stateVal
=== "boolean" && isValidValue
) {
7893 return stateVal
? this.addClass( value
) : this.removeClass( value
);
7896 if ( isFunction( value
) ) {
7897 return this.each( function( i
) {
7898 jQuery( this ).toggleClass(
7899 value
.call( this, i
, getClass( this ), stateVal
),
7905 return this.each( function() {
7906 var className
, i
, self
, classNames
;
7908 if ( isValidValue
) {
7910 // Toggle individual class names
7912 self
= jQuery( this );
7913 classNames
= classesToArray( value
);
7915 while ( ( className
= classNames
[ i
++ ] ) ) {
7917 // Check each className given, space separated list
7918 if ( self
.hasClass( className
) ) {
7919 self
.removeClass( className
);
7921 self
.addClass( className
);
7925 // Toggle whole class name
7926 } else if ( value
=== undefined || type
=== "boolean" ) {
7927 className
= getClass( this );
7930 // Store className if set
7931 dataPriv
.set( this, "__className__", className
);
7934 // If the element has a class name or if we're passed `false`,
7935 // then remove the whole classname (if there was one, the above saved it).
7936 // Otherwise bring back whatever was previously saved (if anything),
7937 // falling back to the empty string if nothing was stored.
7938 if ( this.setAttribute
) {
7939 this.setAttribute( "class",
7940 className
|| value
=== false ?
7942 dataPriv
.get( this, "__className__" ) || ""
7949 hasClass: function( selector
) {
7950 var className
, elem
,
7953 className
= " " + selector
+ " ";
7954 while ( ( elem
= this[ i
++ ] ) ) {
7955 if ( elem
.nodeType
=== 1 &&
7956 ( " " + stripAndCollapse( getClass( elem
) ) + " " ).indexOf( className
) > -1 ) {
7968 var rreturn
= /\r/g;
7971 val: function( value
) {
7972 var hooks
, ret
, valueIsFunction
,
7975 if ( !arguments
.length
) {
7977 hooks
= jQuery
.valHooks
[ elem
.type
] ||
7978 jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
7982 ( ret
= hooks
.get( elem
, "value" ) ) !== undefined
7989 // Handle most common string cases
7990 if ( typeof ret
=== "string" ) {
7991 return ret
.replace( rreturn
, "" );
7994 // Handle cases where value is null/undef or number
7995 return ret
== null ? "" : ret
;
8001 valueIsFunction
= isFunction( value
);
8003 return this.each( function( i
) {
8006 if ( this.nodeType
!== 1 ) {
8010 if ( valueIsFunction
) {
8011 val
= value
.call( this, i
, jQuery( this ).val() );
8016 // Treat null/undefined as ""; convert numbers to string
8017 if ( val
== null ) {
8020 } else if ( typeof val
=== "number" ) {
8023 } else if ( Array
.isArray( val
) ) {
8024 val
= jQuery
.map( val
, function( value
) {
8025 return value
== null ? "" : value
+ "";
8029 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
8031 // If set returns undefined, fall back to normal setting
8032 if ( !hooks
|| !( "set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
8042 get: function( elem
) {
8044 var val
= jQuery
.find
.attr( elem
, "value" );
8045 return val
!= null ?
8048 // Support: IE <=10 - 11 only
8049 // option.text throws exceptions (#14686, #14858)
8050 // Strip and collapse whitespace
8051 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8052 stripAndCollapse( jQuery
.text( elem
) );
8056 get: function( elem
) {
8057 var value
, option
, i
,
8058 options
= elem
.options
,
8059 index
= elem
.selectedIndex
,
8060 one
= elem
.type
=== "select-one",
8061 values
= one
? null : [],
8062 max
= one
? index
+ 1 : options
.length
;
8068 i
= one
? index
: 0;
8071 // Loop through all the selected options
8072 for ( ; i
< max
; i
++ ) {
8073 option
= options
[ i
];
8075 // Support: IE <=9 only
8076 // IE8-9 doesn't update selected after form reset (#2551)
8077 if ( ( option
.selected
|| i
=== index
) &&
8079 // Don't return options that are disabled or in a disabled optgroup
8081 ( !option
.parentNode
.disabled
||
8082 !nodeName( option
.parentNode
, "optgroup" ) ) ) {
8084 // Get the specific value for the option
8085 value
= jQuery( option
).val();
8087 // We don't need an array for one selects
8092 // Multi-Selects return an array
8093 values
.push( value
);
8100 set: function( elem
, value
) {
8101 var optionSet
, option
,
8102 options
= elem
.options
,
8103 values
= jQuery
.makeArray( value
),
8107 option
= options
[ i
];
8109 /* eslint-disable no-cond-assign */
8111 if ( option
.selected
=
8112 jQuery
.inArray( jQuery
.valHooks
.option
.get( option
), values
) > -1
8117 /* eslint-enable no-cond-assign */
8120 // Force browsers to behave consistently when non-matching value is set
8122 elem
.selectedIndex
= -1;
8130 // Radios and checkboxes getter/setter
8131 jQuery
.each( [ "radio", "checkbox" ], function() {
8132 jQuery
.valHooks
[ this ] = {
8133 set: function( elem
, value
) {
8134 if ( Array
.isArray( value
) ) {
8135 return ( elem
.checked
= jQuery
.inArray( jQuery( elem
).val(), value
) > -1 );
8139 if ( !support
.checkOn
) {
8140 jQuery
.valHooks
[ this ].get = function( elem
) {
8141 return elem
.getAttribute( "value" ) === null ? "on" : elem
.value
;
8149 // Return jQuery for attributes-only inclusion
8152 support
.focusin
= "onfocusin" in window
;
8155 var rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
8156 stopPropagationCallback = function( e
) {
8157 e
.stopPropagation();
8160 jQuery
.extend( jQuery
.event
, {
8162 trigger: function( event
, data
, elem
, onlyHandlers
) {
8164 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
, lastElement
,
8165 eventPath
= [ elem
|| document
],
8166 type
= hasOwn
.call( event
, "type" ) ? event
.type
: event
,
8167 namespaces
= hasOwn
.call( event
, "namespace" ) ? event
.namespace.split( "." ) : [];
8169 cur
= lastElement
= tmp
= elem
= elem
|| document
;
8171 // Don't do events on text and comment nodes
8172 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
8176 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8177 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
8181 if ( type
.indexOf( "." ) > -1 ) {
8183 // Namespaced trigger; create a regexp to match event type in handle()
8184 namespaces
= type
.split( "." );
8185 type
= namespaces
.shift();
8188 ontype
= type
.indexOf( ":" ) < 0 && "on" + type
;
8190 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8191 event
= event
[ jQuery
.expando
] ?
8193 new jQuery
.Event( type
, typeof event
=== "object" && event
);
8195 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8196 event
.isTrigger
= onlyHandlers
? 2 : 3;
8197 event
.namespace = namespaces
.join( "." );
8198 event
.rnamespace
= event
.namespace ?
8199 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8202 // Clean up the event in case it is being reused
8203 event
.result
= undefined;
8204 if ( !event
.target
) {
8205 event
.target
= elem
;
8208 // Clone any incoming data and prepend the event, creating the handler arg list
8209 data
= data
== null ?
8211 jQuery
.makeArray( data
, [ event
] );
8213 // Allow special events to draw outside the lines
8214 special
= jQuery
.event
.special
[ type
] || {};
8215 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
8219 // Determine event propagation path in advance, per W3C events spec (#9951)
8220 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
8221 if ( !onlyHandlers
&& !special
.noBubble
&& !isWindow( elem
) ) {
8223 bubbleType
= special
.delegateType
|| type
;
8224 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
8225 cur
= cur
.parentNode
;
8227 for ( ; cur
; cur
= cur
.parentNode
) {
8228 eventPath
.push( cur
);
8232 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8233 if ( tmp
=== ( elem
.ownerDocument
|| document
) ) {
8234 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
8238 // Fire handlers on the event path
8240 while ( ( cur
= eventPath
[ i
++ ] ) && !event
.isPropagationStopped() ) {
8242 event
.type
= i
> 1 ?
8244 special
.bindType
|| type
;
8247 handle
= ( dataPriv
.get( cur
, "events" ) || {} )[ event
.type
] &&
8248 dataPriv
.get( cur
, "handle" );
8250 handle
.apply( cur
, data
);
8254 handle
= ontype
&& cur
[ ontype
];
8255 if ( handle
&& handle
.apply
&& acceptData( cur
) ) {
8256 event
.result
= handle
.apply( cur
, data
);
8257 if ( event
.result
=== false ) {
8258 event
.preventDefault();
8264 // If nobody prevented the default action, do it now
8265 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
8267 if ( ( !special
._default
||
8268 special
._default
.apply( eventPath
.pop(), data
) === false ) &&
8269 acceptData( elem
) ) {
8271 // Call a native DOM method on the target with the same name as the event.
8272 // Don't do default actions on window, that's where global variables be (#6170)
8273 if ( ontype
&& isFunction( elem
[ type
] ) && !isWindow( elem
) ) {
8275 // Don't re-trigger an onFOO event when we call its FOO() method
8276 tmp
= elem
[ ontype
];
8279 elem
[ ontype
] = null;
8282 // Prevent re-triggering of the same event, since we already bubbled it above
8283 jQuery
.event
.triggered
= type
;
8285 if ( event
.isPropagationStopped() ) {
8286 lastElement
.addEventListener( type
, stopPropagationCallback
);
8291 if ( event
.isPropagationStopped() ) {
8292 lastElement
.removeEventListener( type
, stopPropagationCallback
);
8295 jQuery
.event
.triggered
= undefined;
8298 elem
[ ontype
] = tmp
;
8304 return event
.result
;
8307 // Piggyback on a donor event to simulate a different one
8308 // Used only for `focus(in | out)` events
8309 simulate: function( type
, elem
, event
) {
8310 var e
= jQuery
.extend(
8319 jQuery
.event
.trigger( e
, null, elem
);
8326 trigger: function( type
, data
) {
8327 return this.each( function() {
8328 jQuery
.event
.trigger( type
, data
, this );
8331 triggerHandler: function( type
, data
) {
8332 var elem
= this[ 0 ];
8334 return jQuery
.event
.trigger( type
, data
, elem
, true );
8340 // Support: Firefox <=44
8341 // Firefox doesn't have focus(in | out) events
8342 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
8344 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
8345 // focus(in | out) events fire after focus & blur events,
8346 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
8347 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
8348 if ( !support
.focusin
) {
8349 jQuery
.each( { focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
8351 // Attach a single capturing handler on the document while someone wants focusin/focusout
8352 var handler = function( event
) {
8353 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
) );
8356 jQuery
.event
.special
[ fix
] = {
8358 var doc
= this.ownerDocument
|| this,
8359 attaches
= dataPriv
.access( doc
, fix
);
8362 doc
.addEventListener( orig
, handler
, true );
8364 dataPriv
.access( doc
, fix
, ( attaches
|| 0 ) + 1 );
8366 teardown: function() {
8367 var doc
= this.ownerDocument
|| this,
8368 attaches
= dataPriv
.access( doc
, fix
) - 1;
8371 doc
.removeEventListener( orig
, handler
, true );
8372 dataPriv
.remove( doc
, fix
);
8375 dataPriv
.access( doc
, fix
, attaches
);
8381 var location
= window
.location
;
8383 var nonce
= Date
.now();
8385 var rquery
= ( /\?/ );
8389 // Cross-browser xml parsing
8390 jQuery
.parseXML = function( data
) {
8392 if ( !data
|| typeof data
!== "string" ) {
8396 // Support: IE 9 - 11 only
8397 // IE throws on parseFromString with invalid input.
8399 xml
= ( new window
.DOMParser() ).parseFromString( data
, "text/xml" );
8404 if ( !xml
|| xml
.getElementsByTagName( "parsererror" ).length
) {
8405 jQuery
.error( "Invalid XML: " + data
);
8414 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
8415 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
8417 function buildParams( prefix
, obj
, traditional
, add
) {
8420 if ( Array
.isArray( obj
) ) {
8422 // Serialize array item.
8423 jQuery
.each( obj
, function( i
, v
) {
8424 if ( traditional
|| rbracket
.test( prefix
) ) {
8426 // Treat each array item as a scalar.
8431 // Item is non-scalar (array or object), encode its numeric index.
8433 prefix
+ "[" + ( typeof v
=== "object" && v
!= null ? i
: "" ) + "]",
8441 } else if ( !traditional
&& toType( obj
) === "object" ) {
8443 // Serialize object item.
8444 for ( name
in obj
) {
8445 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
8450 // Serialize scalar item.
8455 // Serialize an array of form elements or a set of
8456 // key/values into a query string
8457 jQuery
.param = function( a
, traditional
) {
8460 add = function( key
, valueOrFunction
) {
8462 // If value is a function, invoke it and use its return value
8463 var value
= isFunction( valueOrFunction
) ?
8467 s
[ s
.length
] = encodeURIComponent( key
) + "=" +
8468 encodeURIComponent( value
== null ? "" : value
);
8471 // If an array was passed in, assume that it is an array of form elements.
8472 if ( Array
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
8474 // Serialize the form elements
8475 jQuery
.each( a
, function() {
8476 add( this.name
, this.value
);
8481 // If traditional, encode the "old" way (the way 1.3.2 or older
8482 // did it), otherwise encode params recursively.
8483 for ( prefix
in a
) {
8484 buildParams( prefix
, a
[ prefix
], traditional
, add
);
8488 // Return the resulting serialization
8489 return s
.join( "&" );
8493 serialize: function() {
8494 return jQuery
.param( this.serializeArray() );
8496 serializeArray: function() {
8497 return this.map( function() {
8499 // Can add propHook for "elements" to filter or add form elements
8500 var elements
= jQuery
.prop( this, "elements" );
8501 return elements
? jQuery
.makeArray( elements
) : this;
8503 .filter( function() {
8504 var type
= this.type
;
8506 // Use .is( ":disabled" ) so that fieldset[disabled] works
8507 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
8508 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
8509 ( this.checked
|| !rcheckableType
.test( type
) );
8511 .map( function( i
, elem
) {
8512 var val
= jQuery( this ).val();
8514 if ( val
== null ) {
8518 if ( Array
.isArray( val
) ) {
8519 return jQuery
.map( val
, function( val
) {
8520 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8524 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8533 rantiCache
= /([?&])_=[^&]*/,
8534 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg,
8536 // #7653, #8125, #8152: local protocol detection
8537 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8538 rnoContent
= /^(?:GET|HEAD)$/,
8539 rprotocol
= /^\/\//,
8542 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8543 * 2) These are called:
8544 * - BEFORE asking for a transport
8545 * - AFTER param serialization (s.data is a string if s.processData is true)
8546 * 3) key is the dataType
8547 * 4) the catchall symbol "*" can be used
8548 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8552 /* Transports bindings
8553 * 1) key is the dataType
8554 * 2) the catchall symbol "*" can be used
8555 * 3) selection will start with transport dataType and THEN go to "*" if needed
8559 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8560 allTypes
= "*/".concat( "*" ),
8562 // Anchor tag for parsing the document origin
8563 originAnchor
= document
.createElement( "a" );
8564 originAnchor
.href
= location
.href
;
8566 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8567 function addToPrefiltersOrTransports( structure
) {
8569 // dataTypeExpression is optional and defaults to "*"
8570 return function( dataTypeExpression
, func
) {
8572 if ( typeof dataTypeExpression
!== "string" ) {
8573 func
= dataTypeExpression
;
8574 dataTypeExpression
= "*";
8579 dataTypes
= dataTypeExpression
.toLowerCase().match( rnothtmlwhite
) || [];
8581 if ( isFunction( func
) ) {
8583 // For each dataType in the dataTypeExpression
8584 while ( ( dataType
= dataTypes
[ i
++ ] ) ) {
8586 // Prepend if requested
8587 if ( dataType
[ 0 ] === "+" ) {
8588 dataType
= dataType
.slice( 1 ) || "*";
8589 ( structure
[ dataType
] = structure
[ dataType
] || [] ).unshift( func
);
8593 ( structure
[ dataType
] = structure
[ dataType
] || [] ).push( func
);
8600 // Base inspection function for prefilters and transports
8601 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
8604 seekingTransport
= ( structure
=== transports
);
8606 function inspect( dataType
) {
8608 inspected
[ dataType
] = true;
8609 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
8610 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
8611 if ( typeof dataTypeOrTransport
=== "string" &&
8612 !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
8614 options
.dataTypes
.unshift( dataTypeOrTransport
);
8615 inspect( dataTypeOrTransport
);
8617 } else if ( seekingTransport
) {
8618 return !( selected
= dataTypeOrTransport
);
8624 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
8627 // A special extend for ajax options
8628 // that takes "flat" options (not to be deep extended)
8630 function ajaxExtend( target
, src
) {
8632 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
8634 for ( key
in src
) {
8635 if ( src
[ key
] !== undefined ) {
8636 ( flatOptions
[ key
] ? target
: ( deep
|| ( deep
= {} ) ) )[ key
] = src
[ key
];
8640 jQuery
.extend( true, target
, deep
);
8646 /* Handles responses to an ajax request:
8647 * - finds the right dataType (mediates between content-type and expected dataType)
8648 * - returns the corresponding response
8650 function ajaxHandleResponses( s
, jqXHR
, responses
) {
8652 var ct
, type
, finalDataType
, firstDataType
,
8653 contents
= s
.contents
,
8654 dataTypes
= s
.dataTypes
;
8656 // Remove auto dataType and get content-type in the process
8657 while ( dataTypes
[ 0 ] === "*" ) {
8659 if ( ct
=== undefined ) {
8660 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "Content-Type" );
8664 // Check if we're dealing with a known content-type
8666 for ( type
in contents
) {
8667 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
8668 dataTypes
.unshift( type
);
8674 // Check to see if we have a response for the expected dataType
8675 if ( dataTypes
[ 0 ] in responses
) {
8676 finalDataType
= dataTypes
[ 0 ];
8679 // Try convertible dataTypes
8680 for ( type
in responses
) {
8681 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[ 0 ] ] ) {
8682 finalDataType
= type
;
8685 if ( !firstDataType
) {
8686 firstDataType
= type
;
8690 // Or just use first one
8691 finalDataType
= finalDataType
|| firstDataType
;
8694 // If we found a dataType
8695 // We add the dataType to the list if needed
8696 // and return the corresponding response
8697 if ( finalDataType
) {
8698 if ( finalDataType
!== dataTypes
[ 0 ] ) {
8699 dataTypes
.unshift( finalDataType
);
8701 return responses
[ finalDataType
];
8705 /* Chain conversions given the request and the original response
8706 * Also sets the responseXXX fields on the jqXHR instance
8708 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
8709 var conv2
, current
, conv
, tmp
, prev
,
8712 // Work with a copy of dataTypes in case we need to modify it for conversion
8713 dataTypes
= s
.dataTypes
.slice();
8715 // Create converters map with lowercased keys
8716 if ( dataTypes
[ 1 ] ) {
8717 for ( conv
in s
.converters
) {
8718 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
8722 current
= dataTypes
.shift();
8724 // Convert to each sequential dataType
8727 if ( s
.responseFields
[ current
] ) {
8728 jqXHR
[ s
.responseFields
[ current
] ] = response
;
8731 // Apply the dataFilter if provided
8732 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
8733 response
= s
.dataFilter( response
, s
.dataType
);
8737 current
= dataTypes
.shift();
8741 // There's only work to do if current dataType is non-auto
8742 if ( current
=== "*" ) {
8746 // Convert response if prev dataType is non-auto and differs from current
8747 } else if ( prev
!== "*" && prev
!== current
) {
8749 // Seek a direct converter
8750 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
8752 // If none found, seek a pair
8754 for ( conv2
in converters
) {
8756 // If conv2 outputs current
8757 tmp
= conv2
.split( " " );
8758 if ( tmp
[ 1 ] === current
) {
8760 // If prev can be converted to accepted input
8761 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
8762 converters
[ "* " + tmp
[ 0 ] ];
8765 // Condense equivalence converters
8766 if ( conv
=== true ) {
8767 conv
= converters
[ conv2
];
8769 // Otherwise, insert the intermediate dataType
8770 } else if ( converters
[ conv2
] !== true ) {
8772 dataTypes
.unshift( tmp
[ 1 ] );
8780 // Apply converter (if not an equivalence)
8781 if ( conv
!== true ) {
8783 // Unless errors are allowed to bubble, catch and return them
8784 if ( conv
&& s
.throws ) {
8785 response
= conv( response
);
8788 response
= conv( response
);
8791 state
: "parsererror",
8792 error
: conv
? e
: "No conversion from " + prev
+ " to " + current
8801 return { state
: "success", data
: response
};
8806 // Counter for holding the number of active queries
8809 // Last-Modified header cache for next request
8816 isLocal
: rlocalProtocol
.test( location
.protocol
),
8820 contentType
: "application/x-www-form-urlencoded; charset=UTF-8",
8838 xml
: "application/xml, text/xml",
8839 json
: "application/json, text/javascript"
8850 text
: "responseText",
8851 json
: "responseJSON"
8855 // Keys separate source (or catchall "*") and destination types with a single space
8858 // Convert anything to text
8861 // Text to html (true = no transformation)
8864 // Evaluate text as a json expression
8865 "text json": JSON
.parse
,
8867 // Parse text as xml
8868 "text xml": jQuery
.parseXML
8871 // For options that shouldn't be deep extended:
8872 // you can add your own custom options here if
8873 // and when you create one that shouldn't be
8874 // deep extended (see ajaxExtend)
8881 // Creates a full fledged settings object into target
8882 // with both ajaxSettings and settings fields.
8883 // If target is omitted, writes into ajaxSettings.
8884 ajaxSetup: function( target
, settings
) {
8887 // Building a settings object
8888 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
8890 // Extending ajaxSettings
8891 ajaxExtend( jQuery
.ajaxSettings
, target
);
8894 ajaxPrefilter
: addToPrefiltersOrTransports( prefilters
),
8895 ajaxTransport
: addToPrefiltersOrTransports( transports
),
8898 ajax: function( url
, options
) {
8900 // If url is an object, simulate pre-1.5 signature
8901 if ( typeof url
=== "object" ) {
8906 // Force options to be an object
8907 options
= options
|| {};
8911 // URL without anti-cache param
8915 responseHeadersString
,
8924 // Request state (becomes false upon send and true upon completion)
8927 // To know if global events are to be dispatched
8933 // uncached part of the url
8936 // Create the final options object
8937 s
= jQuery
.ajaxSetup( {}, options
),
8939 // Callbacks context
8940 callbackContext
= s
.context
|| s
,
8942 // Context for global events is callbackContext if it is a DOM node or jQuery collection
8943 globalEventContext
= s
.context
&&
8944 ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
8945 jQuery( callbackContext
) :
8949 deferred
= jQuery
.Deferred(),
8950 completeDeferred
= jQuery
.Callbacks( "once memory" ),
8952 // Status-dependent callbacks
8953 statusCode
= s
.statusCode
|| {},
8955 // Headers (they are sent all at once)
8956 requestHeaders
= {},
8957 requestHeadersNames
= {},
8959 // Default abort message
8960 strAbort
= "canceled",
8966 // Builds headers hashtable if needed
8967 getResponseHeader: function( key
) {
8970 if ( !responseHeaders
) {
8971 responseHeaders
= {};
8972 while ( ( match
= rheaders
.exec( responseHeadersString
) ) ) {
8973 responseHeaders
[ match
[ 1 ].toLowerCase() ] = match
[ 2 ];
8976 match
= responseHeaders
[ key
.toLowerCase() ];
8978 return match
== null ? null : match
;
8982 getAllResponseHeaders: function() {
8983 return completed
? responseHeadersString
: null;
8986 // Caches the header
8987 setRequestHeader: function( name
, value
) {
8988 if ( completed
== null ) {
8989 name
= requestHeadersNames
[ name
.toLowerCase() ] =
8990 requestHeadersNames
[ name
.toLowerCase() ] || name
;
8991 requestHeaders
[ name
] = value
;
8996 // Overrides response content-type header
8997 overrideMimeType: function( type
) {
8998 if ( completed
== null ) {
9004 // Status-dependent callbacks
9005 statusCode: function( map
) {
9010 // Execute the appropriate callbacks
9011 jqXHR
.always( map
[ jqXHR
.status
] );
9014 // Lazy-add the new callbacks in a way that preserves old ones
9015 for ( code
in map
) {
9016 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
9023 // Cancel the request
9024 abort: function( statusText
) {
9025 var finalText
= statusText
|| strAbort
;
9027 transport
.abort( finalText
);
9029 done( 0, finalText
);
9035 deferred
.promise( jqXHR
);
9037 // Add protocol if not provided (prefilters might expect it)
9038 // Handle falsy url in the settings object (#10093: consistency with old signature)
9039 // We also use the url parameter if available
9040 s
.url
= ( ( url
|| s
.url
|| location
.href
) + "" )
9041 .replace( rprotocol
, location
.protocol
+ "//" );
9043 // Alias method option to type as per ticket #12004
9044 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
9046 // Extract dataTypes list
9047 s
.dataTypes
= ( s
.dataType
|| "*" ).toLowerCase().match( rnothtmlwhite
) || [ "" ];
9049 // A cross-domain request is in order when the origin doesn't match the current origin.
9050 if ( s
.crossDomain
== null ) {
9051 urlAnchor
= document
.createElement( "a" );
9053 // Support: IE <=8 - 11, Edge 12 - 15
9054 // IE throws exception on accessing the href property if url is malformed,
9055 // e.g. http://example.com:80x/
9057 urlAnchor
.href
= s
.url
;
9059 // Support: IE <=8 - 11 only
9060 // Anchor's host property isn't correctly set when s.url is relative
9061 urlAnchor
.href
= urlAnchor
.href
;
9062 s
.crossDomain
= originAnchor
.protocol
+ "//" + originAnchor
.host
!==
9063 urlAnchor
.protocol
+ "//" + urlAnchor
.host
;
9066 // If there is an error parsing the URL, assume it is crossDomain,
9067 // it can be rejected by the transport if it is invalid
9068 s
.crossDomain
= true;
9072 // Convert data if not already a string
9073 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
9074 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
9078 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
9080 // If request was aborted inside a prefilter, stop there
9085 // We can fire global events as of now if asked to
9086 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9087 fireGlobals
= jQuery
.event
&& s
.global
;
9089 // Watch for a new set of requests
9090 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
9091 jQuery
.event
.trigger( "ajaxStart" );
9094 // Uppercase the type
9095 s
.type
= s
.type
.toUpperCase();
9097 // Determine if request has content
9098 s
.hasContent
= !rnoContent
.test( s
.type
);
9100 // Save the URL in case we're toying with the If-Modified-Since
9101 // and/or If-None-Match header later on
9102 // Remove hash to simplify url manipulation
9103 cacheURL
= s
.url
.replace( rhash
, "" );
9105 // More options handling for requests with no content
9106 if ( !s
.hasContent
) {
9108 // Remember the hash so we can put it back
9109 uncached
= s
.url
.slice( cacheURL
.length
);
9111 // If data is available and should be processed, append data to url
9112 if ( s
.data
&& ( s
.processData
|| typeof s
.data
=== "string" ) ) {
9113 cacheURL
+= ( rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
;
9115 // #9682: remove data so that it's not used in an eventual retry
9119 // Add or update anti-cache param if needed
9120 if ( s
.cache
=== false ) {
9121 cacheURL
= cacheURL
.replace( rantiCache
, "$1" );
9122 uncached
= ( rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + ( nonce
++ ) + uncached
;
9125 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9126 s
.url
= cacheURL
+ uncached
;
9128 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9129 } else if ( s
.data
&& s
.processData
&&
9130 ( s
.contentType
|| "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9131 s
.data
= s
.data
.replace( r20
, "+" );
9134 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9135 if ( s
.ifModified
) {
9136 if ( jQuery
.lastModified
[ cacheURL
] ) {
9137 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
9139 if ( jQuery
.etag
[ cacheURL
] ) {
9140 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
9144 // Set the correct header, if data is being sent
9145 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
9146 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
9149 // Set the Accepts header for the server, depending on the dataType
9150 jqXHR
.setRequestHeader(
9152 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[ 0 ] ] ?
9153 s
.accepts
[ s
.dataTypes
[ 0 ] ] +
9154 ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
9158 // Check for headers option
9159 for ( i
in s
.headers
) {
9160 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
9163 // Allow custom headers/mimetypes and early abort
9164 if ( s
.beforeSend
&&
9165 ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || completed
) ) {
9167 // Abort if not done already and return
9168 return jqXHR
.abort();
9171 // Aborting is no longer a cancellation
9174 // Install callbacks on deferreds
9175 completeDeferred
.add( s
.complete
);
9176 jqXHR
.done( s
.success
);
9177 jqXHR
.fail( s
.error
);
9180 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
9182 // If no transport, we auto-abort
9184 done( -1, "No Transport" );
9186 jqXHR
.readyState
= 1;
9188 // Send global event
9189 if ( fireGlobals
) {
9190 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
9193 // If request was aborted inside ajaxSend, stop there
9199 if ( s
.async
&& s
.timeout
> 0 ) {
9200 timeoutTimer
= window
.setTimeout( function() {
9201 jqXHR
.abort( "timeout" );
9207 transport
.send( requestHeaders
, done
);
9210 // Rethrow post-completion exceptions
9215 // Propagate others as results
9220 // Callback for when everything is done
9221 function done( status
, nativeStatusText
, responses
, headers
) {
9222 var isSuccess
, success
, error
, response
, modified
,
9223 statusText
= nativeStatusText
;
9225 // Ignore repeat invocations
9232 // Clear timeout if it exists
9233 if ( timeoutTimer
) {
9234 window
.clearTimeout( timeoutTimer
);
9237 // Dereference transport for early garbage collection
9238 // (no matter how long the jqXHR object will be used)
9239 transport
= undefined;
9241 // Cache response headers
9242 responseHeadersString
= headers
|| "";
9245 jqXHR
.readyState
= status
> 0 ? 4 : 0;
9247 // Determine if successful
9248 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
9250 // Get response data
9252 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
9255 // Convert no matter what (that way responseXXX fields are always set)
9256 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
9258 // If successful, handle type chaining
9261 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9262 if ( s
.ifModified
) {
9263 modified
= jqXHR
.getResponseHeader( "Last-Modified" );
9265 jQuery
.lastModified
[ cacheURL
] = modified
;
9267 modified
= jqXHR
.getResponseHeader( "etag" );
9269 jQuery
.etag
[ cacheURL
] = modified
;
9274 if ( status
=== 204 || s
.type
=== "HEAD" ) {
9275 statusText
= "nocontent";
9278 } else if ( status
=== 304 ) {
9279 statusText
= "notmodified";
9281 // If we have data, let's convert it
9283 statusText
= response
.state
;
9284 success
= response
.data
;
9285 error
= response
.error
;
9290 // Extract error from statusText and normalize for non-aborts
9292 if ( status
|| !statusText
) {
9293 statusText
= "error";
9300 // Set data for the fake xhr object
9301 jqXHR
.status
= status
;
9302 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
9306 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
9308 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
9311 // Status-dependent callbacks
9312 jqXHR
.statusCode( statusCode
);
9313 statusCode
= undefined;
9315 if ( fireGlobals
) {
9316 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
9317 [ jqXHR
, s
, isSuccess
? success
: error
] );
9321 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
9323 if ( fireGlobals
) {
9324 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
9326 // Handle the global AJAX counter
9327 if ( !( --jQuery
.active
) ) {
9328 jQuery
.event
.trigger( "ajaxStop" );
9336 getJSON: function( url
, data
, callback
) {
9337 return jQuery
.get( url
, data
, callback
, "json" );
9340 getScript: function( url
, callback
) {
9341 return jQuery
.get( url
, undefined, callback
, "script" );
9345 jQuery
.each( [ "get", "post" ], function( i
, method
) {
9346 jQuery
[ method
] = function( url
, data
, callback
, type
) {
9348 // Shift arguments if data argument was omitted
9349 if ( isFunction( data
) ) {
9350 type
= type
|| callback
;
9355 // The url can be an options object (which then must have .url)
9356 return jQuery
.ajax( jQuery
.extend( {
9362 }, jQuery
.isPlainObject( url
) && url
) );
9367 jQuery
._evalUrl = function( url
) {
9368 return jQuery
.ajax( {
9371 // Make this explicit, since user can override this through ajaxSetup (#11264)
9383 wrapAll: function( html
) {
9387 if ( isFunction( html
) ) {
9388 html
= html
.call( this[ 0 ] );
9391 // The elements to wrap the target around
9392 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
9394 if ( this[ 0 ].parentNode
) {
9395 wrap
.insertBefore( this[ 0 ] );
9398 wrap
.map( function() {
9401 while ( elem
.firstElementChild
) {
9402 elem
= elem
.firstElementChild
;
9412 wrapInner: function( html
) {
9413 if ( isFunction( html
) ) {
9414 return this.each( function( i
) {
9415 jQuery( this ).wrapInner( html
.call( this, i
) );
9419 return this.each( function() {
9420 var self
= jQuery( this ),
9421 contents
= self
.contents();
9423 if ( contents
.length
) {
9424 contents
.wrapAll( html
);
9427 self
.append( html
);
9432 wrap: function( html
) {
9433 var htmlIsFunction
= isFunction( html
);
9435 return this.each( function( i
) {
9436 jQuery( this ).wrapAll( htmlIsFunction
? html
.call( this, i
) : html
);
9440 unwrap: function( selector
) {
9441 this.parent( selector
).not( "body" ).each( function() {
9442 jQuery( this ).replaceWith( this.childNodes
);
9449 jQuery
.expr
.pseudos
.hidden = function( elem
) {
9450 return !jQuery
.expr
.pseudos
.visible( elem
);
9452 jQuery
.expr
.pseudos
.visible = function( elem
) {
9453 return !!( elem
.offsetWidth
|| elem
.offsetHeight
|| elem
.getClientRects().length
);
9459 jQuery
.ajaxSettings
.xhr = function() {
9461 return new window
.XMLHttpRequest();
9465 var xhrSuccessStatus
= {
9467 // File protocol always yields status code 0, assume 200
9470 // Support: IE <=9 only
9471 // #1450: sometimes IE returns 1223 when it should be 204
9474 xhrSupported
= jQuery
.ajaxSettings
.xhr();
9476 support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
9477 support
.ajax
= xhrSupported
= !!xhrSupported
;
9479 jQuery
.ajaxTransport( function( options
) {
9480 var callback
, errorCallback
;
9482 // Cross domain only allowed if supported through XMLHttpRequest
9483 if ( support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
9485 send: function( headers
, complete
) {
9487 xhr
= options
.xhr();
9497 // Apply custom fields if provided
9498 if ( options
.xhrFields
) {
9499 for ( i
in options
.xhrFields
) {
9500 xhr
[ i
] = options
.xhrFields
[ i
];
9504 // Override mime type if needed
9505 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
9506 xhr
.overrideMimeType( options
.mimeType
);
9509 // X-Requested-With header
9510 // For cross-domain requests, seeing as conditions for a preflight are
9511 // akin to a jigsaw puzzle, we simply never set it to be sure.
9512 // (it can always be set on a per-request basis or even using ajaxSetup)
9513 // For same-domain requests, won't change header if already provided.
9514 if ( !options
.crossDomain
&& !headers
[ "X-Requested-With" ] ) {
9515 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
9519 for ( i
in headers
) {
9520 xhr
.setRequestHeader( i
, headers
[ i
] );
9524 callback = function( type
) {
9527 callback
= errorCallback
= xhr
.onload
=
9528 xhr
.onerror
= xhr
.onabort
= xhr
.ontimeout
=
9529 xhr
.onreadystatechange
= null;
9531 if ( type
=== "abort" ) {
9533 } else if ( type
=== "error" ) {
9535 // Support: IE <=9 only
9536 // On a manual native abort, IE9 throws
9537 // errors on any property access that is not readyState
9538 if ( typeof xhr
.status
!== "number" ) {
9539 complete( 0, "error" );
9543 // File: protocol always yields status 0; see #8605, #14207
9550 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
9553 // Support: IE <=9 only
9554 // IE9 has no XHR2 but throws on binary (trac-11426)
9555 // For XHR2 non-text, let the caller handle it (gh-2498)
9556 ( xhr
.responseType
|| "text" ) !== "text" ||
9557 typeof xhr
.responseText
!== "string" ?
9558 { binary
: xhr
.response
} :
9559 { text
: xhr
.responseText
},
9560 xhr
.getAllResponseHeaders()
9568 xhr
.onload
= callback();
9569 errorCallback
= xhr
.onerror
= xhr
.ontimeout
= callback( "error" );
9571 // Support: IE 9 only
9572 // Use onreadystatechange to replace onabort
9573 // to handle uncaught aborts
9574 if ( xhr
.onabort
!== undefined ) {
9575 xhr
.onabort
= errorCallback
;
9577 xhr
.onreadystatechange = function() {
9579 // Check readyState before timeout as it changes
9580 if ( xhr
.readyState
=== 4 ) {
9582 // Allow onerror to be called first,
9583 // but that will not handle a native abort
9584 // Also, save errorCallback to a variable
9585 // as xhr.onerror cannot be accessed
9586 window
.setTimeout( function() {
9595 // Create the abort callback
9596 callback
= callback( "abort" );
9600 // Do send the request (this may raise an exception)
9601 xhr
.send( options
.hasContent
&& options
.data
|| null );
9604 // #14683: Only rethrow if this hasn't been notified as an error yet
9623 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
9624 jQuery
.ajaxPrefilter( function( s
) {
9625 if ( s
.crossDomain
) {
9626 s
.contents
.script
= false;
9630 // Install script dataType
9633 script
: "text/javascript, application/javascript, " +
9634 "application/ecmascript, application/x-ecmascript"
9637 script
: /\b(?:java|ecma)script\b/
9640 "text script": function( text
) {
9641 jQuery
.globalEval( text
);
9647 // Handle cache's special case and crossDomain
9648 jQuery
.ajaxPrefilter( "script", function( s
) {
9649 if ( s
.cache
=== undefined ) {
9652 if ( s
.crossDomain
) {
9657 // Bind script tag hack transport
9658 jQuery
.ajaxTransport( "script", function( s
) {
9660 // This transport only deals with cross domain requests
9661 if ( s
.crossDomain
) {
9662 var script
, callback
;
9664 send: function( _
, complete
) {
9665 script
= jQuery( "<script>" ).prop( {
9666 charset
: s
.scriptCharset
,
9670 callback = function( evt
) {
9674 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
9679 // Use native DOM manipulation to avoid our domManip AJAX trickery
9680 document
.head
.appendChild( script
[ 0 ] );
9694 var oldCallbacks
= [],
9695 rjsonp
= /(=)\?(?=&|$)|\?\?/;
9697 // Default jsonp settings
9700 jsonpCallback: function() {
9701 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
++ ) );
9702 this[ callback
] = true;
9707 // Detect, normalize options and install callbacks for jsonp requests
9708 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
9710 var callbackName
, overwritten
, responseContainer
,
9711 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
9713 typeof s
.data
=== "string" &&
9714 ( s
.contentType
|| "" )
9715 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
9716 rjsonp
.test( s
.data
) && "data"
9719 // Handle iff the expected data type is "jsonp" or we have a parameter to set
9720 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
9722 // Get callback name, remembering preexisting value associated with it
9723 callbackName
= s
.jsonpCallback
= isFunction( s
.jsonpCallback
) ?
9727 // Insert callback into url or form data
9729 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
9730 } else if ( s
.jsonp
!== false ) {
9731 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
9734 // Use data converter to retrieve json after script execution
9735 s
.converters
[ "script json" ] = function() {
9736 if ( !responseContainer
) {
9737 jQuery
.error( callbackName
+ " was not called" );
9739 return responseContainer
[ 0 ];
9742 // Force json dataType
9743 s
.dataTypes
[ 0 ] = "json";
9746 overwritten
= window
[ callbackName
];
9747 window
[ callbackName
] = function() {
9748 responseContainer
= arguments
;
9751 // Clean-up function (fires after converters)
9752 jqXHR
.always( function() {
9754 // If previous value didn't exist - remove it
9755 if ( overwritten
=== undefined ) {
9756 jQuery( window
).removeProp( callbackName
);
9758 // Otherwise restore preexisting value
9760 window
[ callbackName
] = overwritten
;
9763 // Save back as free
9764 if ( s
[ callbackName
] ) {
9766 // Make sure that re-using the options doesn't screw things around
9767 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
9769 // Save the callback name for future use
9770 oldCallbacks
.push( callbackName
);
9773 // Call if it was a function and we have a response
9774 if ( responseContainer
&& isFunction( overwritten
) ) {
9775 overwritten( responseContainer
[ 0 ] );
9778 responseContainer
= overwritten
= undefined;
9781 // Delegate to script
9789 // Support: Safari 8 only
9790 // In Safari 8 documents created via document.implementation.createHTMLDocument
9791 // collapse sibling forms: the second one becomes a child of the first one.
9792 // Because of that, this security measure has to be disabled in Safari 8.
9793 // https://bugs.webkit.org/show_bug.cgi?id=137337
9794 support
.createHTMLDocument
= ( function() {
9795 var body
= document
.implementation
.createHTMLDocument( "" ).body
;
9796 body
.innerHTML
= "<form></form><form></form>";
9797 return body
.childNodes
.length
=== 2;
9801 // Argument "data" should be string of html
9802 // context (optional): If specified, the fragment will be created in this context,
9803 // defaults to document
9804 // keepScripts (optional): If true, will include scripts passed in the html string
9805 jQuery
.parseHTML = function( data
, context
, keepScripts
) {
9806 if ( typeof data
!== "string" ) {
9809 if ( typeof context
=== "boolean" ) {
9810 keepScripts
= context
;
9814 var base
, parsed
, scripts
;
9818 // Stop scripts or inline event handlers from being executed immediately
9819 // by using document.implementation
9820 if ( support
.createHTMLDocument
) {
9821 context
= document
.implementation
.createHTMLDocument( "" );
9823 // Set the base href for the created document
9824 // so any parsed elements with URLs
9825 // are based on the document's URL (gh-2965)
9826 base
= context
.createElement( "base" );
9827 base
.href
= document
.location
.href
;
9828 context
.head
.appendChild( base
);
9834 parsed
= rsingleTag
.exec( data
);
9835 scripts
= !keepScripts
&& [];
9839 return [ context
.createElement( parsed
[ 1 ] ) ];
9842 parsed
= buildFragment( [ data
], context
, scripts
);
9844 if ( scripts
&& scripts
.length
) {
9845 jQuery( scripts
).remove();
9848 return jQuery
.merge( [], parsed
.childNodes
);
9853 * Load a url into a page
9855 jQuery
.fn
.load = function( url
, params
, callback
) {
9856 var selector
, type
, response
,
9858 off
= url
.indexOf( " " );
9861 selector
= stripAndCollapse( url
.slice( off
) );
9862 url
= url
.slice( 0, off
);
9865 // If it's a function
9866 if ( isFunction( params
) ) {
9868 // We assume that it's the callback
9872 // Otherwise, build a param string
9873 } else if ( params
&& typeof params
=== "object" ) {
9877 // If we have elements to modify, make the request
9878 if ( self
.length
> 0 ) {
9882 // If "type" variable is undefined, then "GET" method will be used.
9883 // Make value of this field explicit since
9884 // user can override it through ajaxSetup method
9885 type
: type
|| "GET",
9888 } ).done( function( responseText
) {
9890 // Save response for use in complete callback
9891 response
= arguments
;
9893 self
.html( selector
?
9895 // If a selector was specified, locate the right elements in a dummy div
9896 // Exclude scripts to avoid IE 'Permission Denied' errors
9897 jQuery( "<div>" ).append( jQuery
.parseHTML( responseText
) ).find( selector
) :
9899 // Otherwise use the full result
9902 // If the request succeeds, this function gets "data", "status", "jqXHR"
9903 // but they are ignored because response was set above.
9904 // If it fails, this function gets "jqXHR", "status", "error"
9905 } ).always( callback
&& function( jqXHR
, status
) {
9906 self
.each( function() {
9907 callback
.apply( this, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
9918 // Attach a bunch of functions for handling common AJAX events
9926 ], function( i
, type
) {
9927 jQuery
.fn
[ type
] = function( fn
) {
9928 return this.on( type
, fn
);
9935 jQuery
.expr
.pseudos
.animated = function( elem
) {
9936 return jQuery
.grep( jQuery
.timers
, function( fn
) {
9937 return elem
=== fn
.elem
;
9945 setOffset: function( elem
, options
, i
) {
9946 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
9947 position
= jQuery
.css( elem
, "position" ),
9948 curElem
= jQuery( elem
),
9951 // Set position first, in-case top/left are set even on static elem
9952 if ( position
=== "static" ) {
9953 elem
.style
.position
= "relative";
9956 curOffset
= curElem
.offset();
9957 curCSSTop
= jQuery
.css( elem
, "top" );
9958 curCSSLeft
= jQuery
.css( elem
, "left" );
9959 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) &&
9960 ( curCSSTop
+ curCSSLeft
).indexOf( "auto" ) > -1;
9962 // Need to be able to calculate position if either
9963 // top or left is auto and position is either absolute or fixed
9964 if ( calculatePosition
) {
9965 curPosition
= curElem
.position();
9966 curTop
= curPosition
.top
;
9967 curLeft
= curPosition
.left
;
9970 curTop
= parseFloat( curCSSTop
) || 0;
9971 curLeft
= parseFloat( curCSSLeft
) || 0;
9974 if ( isFunction( options
) ) {
9976 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
9977 options
= options
.call( elem
, i
, jQuery
.extend( {}, curOffset
) );
9980 if ( options
.top
!= null ) {
9981 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
9983 if ( options
.left
!= null ) {
9984 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
9987 if ( "using" in options
) {
9988 options
.using
.call( elem
, props
);
9991 curElem
.css( props
);
9998 // offset() relates an element's border box to the document origin
9999 offset: function( options
) {
10001 // Preserve chaining for setter
10002 if ( arguments
.length
) {
10003 return options
=== undefined ?
10005 this.each( function( i
) {
10006 jQuery
.offset
.setOffset( this, options
, i
);
10017 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
10018 // Support: IE <=11 only
10019 // Running getBoundingClientRect on a
10020 // disconnected node in IE throws an error
10021 if ( !elem
.getClientRects().length
) {
10022 return { top
: 0, left
: 0 };
10025 // Get document-relative position by adding viewport scroll to viewport-relative gBCR
10026 rect
= elem
.getBoundingClientRect();
10027 win
= elem
.ownerDocument
.defaultView
;
10029 top
: rect
.top
+ win
.pageYOffset
,
10030 left
: rect
.left
+ win
.pageXOffset
10034 // position() relates an element's margin box to its offset parent's padding box
10035 // This corresponds to the behavior of CSS absolute positioning
10036 position: function() {
10037 if ( !this[ 0 ] ) {
10041 var offsetParent
, offset
, doc
,
10043 parentOffset
= { top
: 0, left
: 0 };
10045 // position:fixed elements are offset from the viewport, which itself always has zero offset
10046 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
10048 // Assume position:fixed implies availability of getBoundingClientRect
10049 offset
= elem
.getBoundingClientRect();
10052 offset
= this.offset();
10054 // Account for the *real* offset parent, which can be the document or its root element
10055 // when a statically positioned element is identified
10056 doc
= elem
.ownerDocument
;
10057 offsetParent
= elem
.offsetParent
|| doc
.documentElement
;
10058 while ( offsetParent
&&
10059 ( offsetParent
=== doc
.body
|| offsetParent
=== doc
.documentElement
) &&
10060 jQuery
.css( offsetParent
, "position" ) === "static" ) {
10062 offsetParent
= offsetParent
.parentNode
;
10064 if ( offsetParent
&& offsetParent
!== elem
&& offsetParent
.nodeType
=== 1 ) {
10066 // Incorporate borders into its offset, since they are outside its content origin
10067 parentOffset
= jQuery( offsetParent
).offset();
10068 parentOffset
.top
+= jQuery
.css( offsetParent
, "borderTopWidth", true );
10069 parentOffset
.left
+= jQuery
.css( offsetParent
, "borderLeftWidth", true );
10073 // Subtract parent offsets and element margins
10075 top
: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
10076 left
: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
10080 // This method will return documentElement in the following cases:
10081 // 1) For the element inside the iframe without offsetParent, this method will return
10082 // documentElement of the parent window
10083 // 2) For the hidden or detached element
10084 // 3) For body or html element, i.e. in case of the html node - it will return itself
10086 // but those exceptions were never presented as a real life use-cases
10087 // and might be considered as more preferable results.
10089 // This logic, however, is not guaranteed and can change at any point in the future
10090 offsetParent: function() {
10091 return this.map( function() {
10092 var offsetParent
= this.offsetParent
;
10094 while ( offsetParent
&& jQuery
.css( offsetParent
, "position" ) === "static" ) {
10095 offsetParent
= offsetParent
.offsetParent
;
10098 return offsetParent
|| documentElement
;
10103 // Create scrollLeft and scrollTop methods
10104 jQuery
.each( { scrollLeft
: "pageXOffset", scrollTop
: "pageYOffset" }, function( method
, prop
) {
10105 var top
= "pageYOffset" === prop
;
10107 jQuery
.fn
[ method
] = function( val
) {
10108 return access( this, function( elem
, method
, val
) {
10110 // Coalesce documents and windows
10112 if ( isWindow( elem
) ) {
10114 } else if ( elem
.nodeType
=== 9 ) {
10115 win
= elem
.defaultView
;
10118 if ( val
=== undefined ) {
10119 return win
? win
[ prop
] : elem
[ method
];
10124 !top
? val
: win
.pageXOffset
,
10125 top
? val
: win
.pageYOffset
10129 elem
[ method
] = val
;
10131 }, method
, val
, arguments
.length
);
10135 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10136 // Add the top/left cssHooks using jQuery.fn.position
10137 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10138 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10139 // getComputedStyle returns percent when specified for top/left/bottom/right;
10140 // rather than make the css module depend on the offset module, just check for it here
10141 jQuery
.each( [ "top", "left" ], function( i
, prop
) {
10142 jQuery
.cssHooks
[ prop
] = addGetHookIf( support
.pixelPosition
,
10143 function( elem
, computed
) {
10145 computed
= curCSS( elem
, prop
);
10147 // If curCSS returns percentage, fallback to offset
10148 return rnumnonpx
.test( computed
) ?
10149 jQuery( elem
).position()[ prop
] + "px" :
10157 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10158 jQuery
.each( { Height
: "height", Width
: "width" }, function( name
, type
) {
10159 jQuery
.each( { padding
: "inner" + name
, content
: type
, "": "outer" + name
},
10160 function( defaultExtra
, funcName
) {
10162 // Margin is only for outerHeight, outerWidth
10163 jQuery
.fn
[ funcName
] = function( margin
, value
) {
10164 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
10165 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
10167 return access( this, function( elem
, type
, value
) {
10170 if ( isWindow( elem
) ) {
10172 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10173 return funcName
.indexOf( "outer" ) === 0 ?
10174 elem
[ "inner" + name
] :
10175 elem
.document
.documentElement
[ "client" + name
];
10178 // Get document width or height
10179 if ( elem
.nodeType
=== 9 ) {
10180 doc
= elem
.documentElement
;
10182 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10183 // whichever is greatest
10185 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
10186 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
10187 doc
[ "client" + name
]
10191 return value
=== undefined ?
10193 // Get width or height on the element, requesting but not forcing parseFloat
10194 jQuery
.css( elem
, type
, extra
) :
10196 // Set width or height on the element
10197 jQuery
.style( elem
, type
, value
, extra
);
10198 }, type
, chainable
? margin
: undefined, chainable
);
10204 jQuery
.each( ( "blur focus focusin focusout resize scroll click dblclick " +
10205 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10206 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
10207 function( i
, name
) {
10209 // Handle event binding
10210 jQuery
.fn
[ name
] = function( data
, fn
) {
10211 return arguments
.length
> 0 ?
10212 this.on( name
, null, data
, fn
) :
10213 this.trigger( name
);
10217 jQuery
.fn
.extend( {
10218 hover: function( fnOver
, fnOut
) {
10219 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
10226 jQuery
.fn
.extend( {
10228 bind: function( types
, data
, fn
) {
10229 return this.on( types
, null, data
, fn
);
10231 unbind: function( types
, fn
) {
10232 return this.off( types
, null, fn
);
10235 delegate: function( selector
, types
, data
, fn
) {
10236 return this.on( types
, selector
, data
, fn
);
10238 undelegate: function( selector
, types
, fn
) {
10240 // ( namespace ) or ( selector, types [, fn] )
10241 return arguments
.length
=== 1 ?
10242 this.off( selector
, "**" ) :
10243 this.off( types
, selector
|| "**", fn
);
10247 // Bind a function to a context, optionally partially applying any
10249 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10250 // However, it is not slated for removal any time soon
10251 jQuery
.proxy = function( fn
, context
) {
10252 var tmp
, args
, proxy
;
10254 if ( typeof context
=== "string" ) {
10255 tmp
= fn
[ context
];
10260 // Quick check to determine if target is callable, in the spec
10261 // this throws a TypeError, but we will just return undefined.
10262 if ( !isFunction( fn
) ) {
10267 args
= slice
.call( arguments
, 2 );
10268 proxy = function() {
10269 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
10272 // Set the guid of unique handler to the same of original handler, so it can be removed
10273 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
10278 jQuery
.holdReady = function( hold
) {
10280 jQuery
.readyWait
++;
10282 jQuery
.ready( true );
10285 jQuery
.isArray
= Array
.isArray
;
10286 jQuery
.parseJSON
= JSON
.parse
;
10287 jQuery
.nodeName
= nodeName
;
10288 jQuery
.isFunction
= isFunction
;
10289 jQuery
.isWindow
= isWindow
;
10290 jQuery
.camelCase
= camelCase
;
10291 jQuery
.type
= toType
;
10293 jQuery
.now
= Date
.now
;
10295 jQuery
.isNumeric = function( obj
) {
10297 // As of jQuery 3.0, isNumeric is limited to
10298 // strings and numbers (primitives or objects)
10299 // that can be coerced to finite numbers (gh-2662)
10300 var type
= jQuery
.type( obj
);
10301 return ( type
=== "number" || type
=== "string" ) &&
10303 // parseFloat NaNs numeric-cast false positives ("")
10304 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
10305 // subtraction forces infinities to NaN
10306 !isNaN( obj
- parseFloat( obj
) );
10312 // Register as a named AMD module, since jQuery can be concatenated with other
10313 // files that may use define, but not via a proper concatenation script that
10314 // understands anonymous AMD modules. A named AMD is safest and most robust
10315 // way to register. Lowercase jquery is used because AMD module names are
10316 // derived from file names, and jQuery is normally delivered in a lowercase
10317 // file name. Do this after creating the global so that if an AMD module wants
10318 // to call noConflict to hide this version of jQuery, it will work.
10320 // Note that for maximum portability, libraries that are not jQuery should
10321 // declare themselves as anonymous modules, and avoid setting a global if an
10322 // AMD loader is present. jQuery is a special case. For more information, see
10323 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10325 if ( typeof define
=== "function" && define
.amd
) {
10326 define( "jquery", [], function() {
10336 // Map over jQuery in case of overwrite
10337 _jQuery
= window
.jQuery
,
10339 // Map over the $ in case of overwrite
10342 jQuery
.noConflict = function( deep
) {
10343 if ( window
.$ === jQuery
) {
10347 if ( deep
&& window
.jQuery
=== jQuery
) {
10348 window
.jQuery
= _jQuery
;
10354 // Expose jQuery and $ identifiers, even in AMD
10355 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10356 // and CommonJS for browser emulators (#13566)
10358 window
.jQuery
= window
.$ = jQuery
;