2 * jQuery JavaScript Library v3.3.1
6 * https://sizzlejs.com/
8 * Copyright JS Foundation and other contributors
9 * Released under the MIT license
10 * https://jquery.org/license
12 * Date: 2018-01-20T17:24Z
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 never-ending loop
265 if ( target
=== copy
) {
269 // Recurse if we're merging plain objects or arrays
270 if ( deep
&& copy
&& ( jQuery
.isPlainObject( copy
) ||
271 ( copyIsArray
= Array
.isArray( copy
) ) ) ) {
275 clone
= src
&& Array
.isArray( src
) ? src
: [];
278 clone
= src
&& jQuery
.isPlainObject( src
) ? src
: {};
281 // Never move original objects, clone them
282 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
284 // Don't bring in undefined values
285 } else if ( copy
!== undefined ) {
286 target
[ name
] = copy
;
292 // Return the modified object
298 // Unique for each copy of jQuery on the page
299 expando
: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
301 // Assume jQuery is ready without the ready module
304 error: function( msg
) {
305 throw new Error( msg
);
310 isPlainObject: function( obj
) {
313 // Detect obvious negatives
314 // Use toString instead of jQuery.type to catch host objects
315 if ( !obj
|| toString
.call( obj
) !== "[object Object]" ) {
319 proto
= getProto( obj
);
321 // Objects with no prototype (e.g., `Object.create( null )`) are plain
326 // Objects with prototype are plain iff they were constructed by a global Object function
327 Ctor
= hasOwn
.call( proto
, "constructor" ) && proto
.constructor;
328 return typeof Ctor
=== "function" && fnToString
.call( Ctor
) === ObjectFunctionString
;
331 isEmptyObject: function( obj
) {
333 /* eslint-disable no-unused-vars */
334 // See https://github.com/eslint/eslint/issues/6125
337 for ( name
in obj
) {
343 // Evaluates a script in a global context
344 globalEval: function( code
) {
348 each: function( obj
, callback
) {
351 if ( isArrayLike( obj
) ) {
353 for ( ; i
< length
; i
++ ) {
354 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
360 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
369 // Support: Android <=4.0 only
370 trim: function( text
) {
371 return text
== null ?
373 ( text
+ "" ).replace( rtrim
, "" );
376 // results is for internal usage only
377 makeArray: function( arr
, results
) {
378 var ret
= results
|| [];
381 if ( isArrayLike( Object( arr
) ) ) {
383 typeof arr
=== "string" ?
387 push
.call( ret
, arr
);
394 inArray: function( elem
, arr
, i
) {
395 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
398 // Support: Android <=4.0 only, PhantomJS 1 only
399 // push.apply(_, arraylike) throws on ancient WebKit
400 merge: function( first
, second
) {
401 var len
= +second
.length
,
405 for ( ; j
< len
; j
++ ) {
406 first
[ i
++ ] = second
[ j
];
414 grep: function( elems
, callback
, invert
) {
418 length
= elems
.length
,
419 callbackExpect
= !invert
;
421 // Go through the array, only saving the items
422 // that pass the validator function
423 for ( ; i
< length
; i
++ ) {
424 callbackInverse
= !callback( elems
[ i
], i
);
425 if ( callbackInverse
!== callbackExpect
) {
426 matches
.push( elems
[ i
] );
433 // arg is for internal usage only
434 map: function( elems
, callback
, arg
) {
439 // Go through the array, translating each of the items to their new values
440 if ( isArrayLike( elems
) ) {
441 length
= elems
.length
;
442 for ( ; i
< length
; i
++ ) {
443 value
= callback( elems
[ i
], i
, arg
);
445 if ( value
!= null ) {
450 // Go through every key on the object,
453 value
= callback( elems
[ i
], i
, arg
);
455 if ( value
!= null ) {
461 // Flatten any nested arrays
462 return concat
.apply( [], ret
);
465 // A global GUID counter for objects
468 // jQuery.support is not used in Core but other projects attach their
469 // properties to it so it needs to exist.
473 if ( typeof Symbol
=== "function" ) {
474 jQuery
.fn
[ Symbol
.iterator
] = arr
[ Symbol
.iterator
];
477 // Populate the class2type map
478 jQuery
.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
479 function( i
, name
) {
480 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
483 function isArrayLike( obj
) {
485 // Support: real iOS 8.2 only (not reproducible in simulator)
486 // `in` check used to prevent JIT error (gh-2145)
487 // hasOwn isn't used here due to false negatives
488 // regarding Nodelist length in IE
489 var length
= !!obj
&& "length" in obj
&& obj
.length
,
490 type
= toType( obj
);
492 if ( isFunction( obj
) || isWindow( obj
) ) {
496 return type
=== "array" || length
=== 0 ||
497 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
501 * Sizzle CSS Selector Engine v2.3.3
502 * https://sizzlejs.com/
504 * Copyright jQuery Foundation and other contributors
505 * Released under the MIT license
506 * http://jquery.org/license
510 (function( window
) {
524 // Local document vars
534 // Instance-specific data
535 expando
= "sizzle" + 1 * new Date(),
536 preferredDoc
= window
.document
,
539 classCache
= createCache(),
540 tokenCache
= createCache(),
541 compilerCache
= createCache(),
542 sortOrder = function( a
, b
) {
550 hasOwn
= ({}).hasOwnProperty
,
553 push_native
= arr
.push
,
556 // Use a stripped-down indexOf as it's faster than native
557 // https://jsperf.com/thor-indexof-vs-for/5
558 indexOf = function( list
, elem
) {
561 for ( ; i
< len
; i
++ ) {
562 if ( list
[i
] === elem
) {
569 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
571 // Regular expressions
573 // http://www.w3.org/TR/css3-selectors/#whitespace
574 whitespace
= "[\\x20\\t\\r\\n\\f]",
576 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
577 identifier
= "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
579 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
580 attributes
= "\\[" + whitespace
+ "*(" + identifier
+ ")(?:" + whitespace
+
581 // Operator (capture 2)
582 "*([*^$|!~]?=)" + whitespace
+
583 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
584 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier
+ "))|)" + whitespace
+
587 pseudos
= ":(" + identifier
+ ")(?:\\((" +
588 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
589 // 1. quoted (capture 3; capture 4 or capture 5)
590 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
591 // 2. simple (capture 6)
592 "((?:\\\\.|[^\\\\()[\\]]|" + attributes
+ ")*)|" +
593 // 3. anything else (capture 2)
597 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
598 rwhitespace
= new RegExp( whitespace
+ "+", "g" ),
599 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
601 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
602 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
604 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*?)" + whitespace
+ "*\\]", "g" ),
606 rpseudo
= new RegExp( pseudos
),
607 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
610 "ID": new RegExp( "^#(" + identifier
+ ")" ),
611 "CLASS": new RegExp( "^\\.(" + identifier
+ ")" ),
612 "TAG": new RegExp( "^(" + identifier
+ "|[*])" ),
613 "ATTR": new RegExp( "^" + attributes
),
614 "PSEUDO": new RegExp( "^" + pseudos
),
615 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
616 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
617 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
618 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
619 // For use in libraries implementing .is()
620 // We use this for POS matching in `select`
621 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
622 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
625 rinputs
= /^(?:input|select|textarea|button)$/i,
628 rnative
= /^[^{]+\{\s*\[native \w/,
630 // Easily-parseable/retrievable ID or TAG or CLASS selectors
631 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
636 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
637 runescape
= new RegExp( "\\\\([\\da-f]{1,6}" + whitespace
+ "?|(" + whitespace
+ ")|.)", "ig" ),
638 funescape = function( _
, escaped
, escapedWhitespace
) {
639 var high
= "0x" + escaped
- 0x10000;
640 // NaN means non-codepoint
641 // Support: Firefox<24
642 // Workaround erroneous numeric interpretation of +"0x"
643 return high
!== high
|| escapedWhitespace
?
647 String
.fromCharCode( high
+ 0x10000 ) :
648 // Supplemental Plane codepoint (surrogate pair)
649 String
.fromCharCode( high
>> 10 | 0xD800, high
& 0x3FF | 0xDC00 );
652 // CSS string/identifier serialization
653 // https://drafts.csswg.org/cssom/#common-serializing-idioms
654 rcssescape
= /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
655 fcssescape = function( ch
, asCodePoint
) {
658 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
663 // Control characters and (dependent upon position) numbers get escaped as code points
664 return ch
.slice( 0, -1 ) + "\\" + ch
.charCodeAt( ch
.length
- 1 ).toString( 16 ) + " ";
667 // Other potentially-special ASCII characters get backslash-escaped
673 // Removing the function wrapper causes a "Permission Denied"
675 unloadHandler = function() {
679 disabledAncestor
= addCombinator(
681 return elem
.disabled
=== true && ("form" in elem
|| "label" in elem
);
683 { dir
: "parentNode", next
: "legend" }
686 // Optimize for push.apply( _, NodeList )
689 (arr
= slice
.call( preferredDoc
.childNodes
)),
690 preferredDoc
.childNodes
692 // Support: Android<4.0
693 // Detect silently failing push.apply
694 arr
[ preferredDoc
.childNodes
.length
].nodeType
;
696 push
= { apply
: arr
.length
?
698 // Leverage slice if possible
699 function( target
, els
) {
700 push_native
.apply( target
, slice
.call(els
) );
704 // Otherwise append directly
705 function( target
, els
) {
706 var j
= target
.length
,
708 // Can't trust NodeList.length
709 while ( (target
[j
++] = els
[i
++]) ) {}
710 target
.length
= j
- 1;
715 function Sizzle( selector
, context
, results
, seed
) {
716 var m
, i
, elem
, nid
, match
, groups
, newSelector
,
717 newContext
= context
&& context
.ownerDocument
,
719 // nodeType defaults to 9, since context defaults to document
720 nodeType
= context
? context
.nodeType
: 9;
722 results
= results
|| [];
724 // Return early from calls with invalid selector or context
725 if ( typeof selector
!== "string" || !selector
||
726 nodeType
!== 1 && nodeType
!== 9 && nodeType
!== 11 ) {
731 // Try to shortcut find operations (as opposed to filters) in HTML documents
734 if ( ( context
? context
.ownerDocument
|| context
: preferredDoc
) !== document
) {
735 setDocument( context
);
737 context
= context
|| document
;
739 if ( documentIsHTML
) {
741 // If the selector is sufficiently simple, try using a "get*By*" DOM method
742 // (excepting DocumentFragment context, where the methods don't exist)
743 if ( nodeType
!== 11 && (match
= rquickExpr
.exec( selector
)) ) {
746 if ( (m
= match
[1]) ) {
749 if ( nodeType
=== 9 ) {
750 if ( (elem
= context
.getElementById( m
)) ) {
752 // Support: IE, Opera, Webkit
753 // TODO: identify versions
754 // getElementById can match elements by name instead of ID
755 if ( elem
.id
=== m
) {
756 results
.push( elem
);
766 // Support: IE, Opera, Webkit
767 // TODO: identify versions
768 // getElementById can match elements by name instead of ID
769 if ( newContext
&& (elem
= newContext
.getElementById( m
)) &&
770 contains( context
, elem
) &&
773 results
.push( elem
);
779 } else if ( match
[2] ) {
780 push
.apply( results
, context
.getElementsByTagName( selector
) );
784 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&&
785 context
.getElementsByClassName
) {
787 push
.apply( results
, context
.getElementsByClassName( m
) );
792 // Take advantage of querySelectorAll
794 !compilerCache
[ selector
+ " " ] &&
795 (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
797 if ( nodeType
!== 1 ) {
798 newContext
= context
;
799 newSelector
= selector
;
801 // qSA looks outside Element context, which is not what we want
802 // Thanks to Andrew Dupont for this workaround technique
804 // Exclude object elements
805 } else if ( context
.nodeName
.toLowerCase() !== "object" ) {
807 // Capture the context ID, setting it first if necessary
808 if ( (nid
= context
.getAttribute( "id" )) ) {
809 nid
= nid
.replace( rcssescape
, fcssescape
);
811 context
.setAttribute( "id", (nid
= expando
) );
814 // Prefix every selector in the list
815 groups
= tokenize( selector
);
818 groups
[i
] = "#" + nid
+ " " + toSelector( groups
[i
] );
820 newSelector
= groups
.join( "," );
822 // Expand context for sibling selectors
823 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) ||
830 newContext
.querySelectorAll( newSelector
)
833 } catch ( qsaError
) {
835 if ( nid
=== expando
) {
836 context
.removeAttribute( "id" );
845 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
849 * Create key-value caches of limited size
850 * @returns {function(string, object)} Returns the Object data after storing it on itself with
851 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
852 * deleting the oldest entry
854 function createCache() {
857 function cache( key
, value
) {
858 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
859 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
860 // Only keep the most recent entries
861 delete cache
[ keys
.shift() ];
863 return (cache
[ key
+ " " ] = value
);
869 * Mark a function for special use by Sizzle
870 * @param {Function} fn The function to mark
872 function markFunction( fn
) {
873 fn
[ expando
] = true;
878 * Support testing using an element
879 * @param {Function} fn Passed the created element and returns a boolean result
881 function assert( fn
) {
882 var el
= document
.createElement("fieldset");
889 // Remove from its parent by default
890 if ( el
.parentNode
) {
891 el
.parentNode
.removeChild( el
);
893 // release memory in IE
899 * Adds the same handler for all of the specified attrs
900 * @param {String} attrs Pipe-separated list of attributes
901 * @param {Function} handler The method that will be applied
903 function addHandle( attrs
, handler
) {
904 var arr
= attrs
.split("|"),
908 Expr
.attrHandle
[ arr
[i
] ] = handler
;
913 * Checks document order of two siblings
916 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
918 function siblingCheck( a
, b
) {
920 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
921 a
.sourceIndex
- b
.sourceIndex
;
923 // Use IE sourceIndex if available on both nodes
928 // Check if b follows a
930 while ( (cur
= cur
.nextSibling
) ) {
941 * Returns a function to use in pseudos for input types
942 * @param {String} type
944 function createInputPseudo( type
) {
945 return function( elem
) {
946 var name
= elem
.nodeName
.toLowerCase();
947 return name
=== "input" && elem
.type
=== type
;
952 * Returns a function to use in pseudos for buttons
953 * @param {String} type
955 function createButtonPseudo( type
) {
956 return function( elem
) {
957 var name
= elem
.nodeName
.toLowerCase();
958 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
963 * Returns a function to use in pseudos for :enabled/:disabled
964 * @param {Boolean} disabled true for :disabled; false for :enabled
966 function createDisabledPseudo( disabled
) {
968 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
969 return function( elem
) {
971 // Only certain elements can match :enabled or :disabled
972 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
973 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
974 if ( "form" in elem
) {
976 // Check for inherited disabledness on relevant non-disabled elements:
977 // * listed form-associated elements in a disabled fieldset
978 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
979 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
980 // * option elements in a disabled optgroup
981 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
982 // All such elements have a "form" property.
983 if ( elem
.parentNode
&& elem
.disabled
=== false ) {
985 // Option elements defer to a parent optgroup if present
986 if ( "label" in elem
) {
987 if ( "label" in elem
.parentNode
) {
988 return elem
.parentNode
.disabled
=== disabled
;
990 return elem
.disabled
=== disabled
;
994 // Support: IE 6 - 11
995 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
996 return elem
.isDisabled
=== disabled
||
998 // Where there is no isDisabled, check manually
1000 elem
.isDisabled
!== !disabled
&&
1001 disabledAncestor( elem
) === disabled
;
1004 return elem
.disabled
=== disabled
;
1006 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1007 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1008 // even exist on them, let alone have a boolean value.
1009 } else if ( "label" in elem
) {
1010 return elem
.disabled
=== disabled
;
1013 // Remaining elements are neither :enabled nor :disabled
1019 * Returns a function to use in pseudos for positionals
1020 * @param {Function} fn
1022 function createPositionalPseudo( fn
) {
1023 return markFunction(function( argument
) {
1024 argument
= +argument
;
1025 return markFunction(function( seed
, matches
) {
1027 matchIndexes
= fn( [], seed
.length
, argument
),
1028 i
= matchIndexes
.length
;
1030 // Match elements found at the specified indexes
1032 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
1033 seed
[j
] = !(matches
[j
] = seed
[j
]);
1041 * Checks a node for validity as a Sizzle context
1042 * @param {Element|Object=} context
1043 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1045 function testContext( context
) {
1046 return context
&& typeof context
.getElementsByTagName
!== "undefined" && context
;
1049 // Expose support vars for convenience
1050 support
= Sizzle
.support
= {};
1054 * @param {Element|Object} elem An element or a document
1055 * @returns {Boolean} True iff elem is a non-HTML XML node
1057 isXML
= Sizzle
.isXML = function( elem
) {
1058 // documentElement is verified for cases where it doesn't yet exist
1059 // (such as loading iframes in IE - #4833)
1060 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
1061 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1065 * Sets document-related variables once based on the current document
1066 * @param {Element|Object} [doc] An element or document object to use to set the document
1067 * @returns {Object} Returns the current document
1069 setDocument
= Sizzle
.setDocument = function( node
) {
1070 var hasCompare
, subWindow
,
1071 doc
= node
? node
.ownerDocument
|| node
: preferredDoc
;
1073 // Return early if doc is invalid or already selected
1074 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1078 // Update global variables
1080 docElem
= document
.documentElement
;
1081 documentIsHTML
= !isXML( document
);
1083 // Support: IE 9-11, Edge
1084 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1085 if ( preferredDoc
!== document
&&
1086 (subWindow
= document
.defaultView
) && subWindow
.top
!== subWindow
) {
1088 // Support: IE 11, Edge
1089 if ( subWindow
.addEventListener
) {
1090 subWindow
.addEventListener( "unload", unloadHandler
, false );
1092 // Support: IE 9 - 10 only
1093 } else if ( subWindow
.attachEvent
) {
1094 subWindow
.attachEvent( "onunload", unloadHandler
);
1099 ---------------------------------------------------------------------- */
1102 // Verify that getAttribute really returns attributes and not properties
1103 // (excepting IE8 booleans)
1104 support
.attributes
= assert(function( el
) {
1106 return !el
.getAttribute("className");
1110 ---------------------------------------------------------------------- */
1112 // Check if getElementsByTagName("*") returns only elements
1113 support
.getElementsByTagName
= assert(function( el
) {
1114 el
.appendChild( document
.createComment("") );
1115 return !el
.getElementsByTagName("*").length
;
1119 support
.getElementsByClassName
= rnative
.test( document
.getElementsByClassName
);
1122 // Check if getElementById returns elements by name
1123 // The broken getElementById methods don't pick up programmatically-set names,
1124 // so use a roundabout getElementsByName test
1125 support
.getById
= assert(function( el
) {
1126 docElem
.appendChild( el
).id
= expando
;
1127 return !document
.getElementsByName
|| !document
.getElementsByName( expando
).length
;
1130 // ID filter and find
1131 if ( support
.getById
) {
1132 Expr
.filter
["ID"] = function( id
) {
1133 var attrId
= id
.replace( runescape
, funescape
);
1134 return function( elem
) {
1135 return elem
.getAttribute("id") === attrId
;
1138 Expr
.find
["ID"] = function( id
, context
) {
1139 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1140 var elem
= context
.getElementById( id
);
1141 return elem
? [ elem
] : [];
1145 Expr
.filter
["ID"] = function( id
) {
1146 var attrId
= id
.replace( runescape
, funescape
);
1147 return function( elem
) {
1148 var node
= typeof elem
.getAttributeNode
!== "undefined" &&
1149 elem
.getAttributeNode("id");
1150 return node
&& node
.value
=== attrId
;
1154 // Support: IE 6 - 7 only
1155 // getElementById is not reliable as a find shortcut
1156 Expr
.find
["ID"] = function( id
, context
) {
1157 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1159 elem
= context
.getElementById( id
);
1163 // Verify the id attribute
1164 node
= elem
.getAttributeNode("id");
1165 if ( node
&& node
.value
=== id
) {
1169 // Fall back on getElementsByName
1170 elems
= context
.getElementsByName( id
);
1172 while ( (elem
= elems
[i
++]) ) {
1173 node
= elem
.getAttributeNode("id");
1174 if ( node
&& node
.value
=== id
) {
1186 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1187 function( tag
, context
) {
1188 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
1189 return context
.getElementsByTagName( tag
);
1191 // DocumentFragment nodes don't have gEBTN
1192 } else if ( support
.qsa
) {
1193 return context
.querySelectorAll( tag
);
1197 function( tag
, context
) {
1201 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1202 results
= context
.getElementsByTagName( tag
);
1204 // Filter out possible comments
1205 if ( tag
=== "*" ) {
1206 while ( (elem
= results
[i
++]) ) {
1207 if ( elem
.nodeType
=== 1 ) {
1218 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1219 if ( typeof context
.getElementsByClassName
!== "undefined" && documentIsHTML
) {
1220 return context
.getElementsByClassName( className
);
1224 /* QSA/matchesSelector
1225 ---------------------------------------------------------------------- */
1227 // QSA and matchesSelector support
1229 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1232 // qSa(:focus) reports false when true (Chrome 21)
1233 // We allow this because of a bug in IE8/9 that throws an error
1234 // whenever `document.activeElement` is accessed on an iframe
1235 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1236 // See https://bugs.jquery.com/ticket/13378
1239 if ( (support
.qsa
= rnative
.test( document
.querySelectorAll
)) ) {
1241 // Regex strategy adopted from Diego Perini
1242 assert(function( el
) {
1243 // Select is set to empty string on purpose
1244 // This is to test IE's treatment of not explicitly
1245 // setting a boolean content attribute,
1246 // since its presence should be enough
1247 // https://bugs.jquery.com/ticket/12359
1248 docElem
.appendChild( el
).innerHTML
= "<a id='" + expando
+ "'></a>" +
1249 "<select id='" + expando
+ "-\r\\' msallowcapture=''>" +
1250 "<option selected=''></option></select>";
1252 // Support: IE8, Opera 11-12.16
1253 // Nothing should be selected when empty strings follow ^= or $= or *=
1254 // The test attribute must be unknown in Opera but "safe" for WinRT
1255 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1256 if ( el
.querySelectorAll("[msallowcapture^='']").length
) {
1257 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1261 // Boolean attributes and "value" are not treated correctly
1262 if ( !el
.querySelectorAll("[selected]").length
) {
1263 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1266 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1267 if ( !el
.querySelectorAll( "[id~=" + expando
+ "-]" ).length
) {
1268 rbuggyQSA
.push("~=");
1271 // Webkit/Opera - :checked should return selected option elements
1272 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1273 // IE8 throws error here and will not see later tests
1274 if ( !el
.querySelectorAll(":checked").length
) {
1275 rbuggyQSA
.push(":checked");
1278 // Support: Safari 8+, iOS 8+
1279 // https://bugs.webkit.org/show_bug.cgi?id=136851
1280 // In-page `selector#id sibling-combinator selector` fails
1281 if ( !el
.querySelectorAll( "a#" + expando
+ "+*" ).length
) {
1282 rbuggyQSA
.push(".#.+[+~]");
1286 assert(function( el
) {
1287 el
.innerHTML
= "<a href='' disabled='disabled'></a>" +
1288 "<select disabled='disabled'><option/></select>";
1290 // Support: Windows 8 Native Apps
1291 // The type and name attributes are restricted during .innerHTML assignment
1292 var input
= document
.createElement("input");
1293 input
.setAttribute( "type", "hidden" );
1294 el
.appendChild( input
).setAttribute( "name", "D" );
1297 // Enforce case-sensitivity of name attribute
1298 if ( el
.querySelectorAll("[name=d]").length
) {
1299 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1302 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1303 // IE8 throws error here and will not see later tests
1304 if ( el
.querySelectorAll(":enabled").length
!== 2 ) {
1305 rbuggyQSA
.push( ":enabled", ":disabled" );
1309 // IE's :disabled selector does not pick up the children of disabled fieldsets
1310 docElem
.appendChild( el
).disabled
= true;
1311 if ( el
.querySelectorAll(":disabled").length
!== 2 ) {
1312 rbuggyQSA
.push( ":enabled", ":disabled" );
1315 // Opera 10-11 does not throw on post-comma invalid pseudos
1316 el
.querySelectorAll("*,:x");
1317 rbuggyQSA
.push(",.*:");
1321 if ( (support
.matchesSelector
= rnative
.test( (matches
= docElem
.matches
||
1322 docElem
.webkitMatchesSelector
||
1323 docElem
.mozMatchesSelector
||
1324 docElem
.oMatchesSelector
||
1325 docElem
.msMatchesSelector
) )) ) {
1327 assert(function( el
) {
1328 // Check to see if it's possible to do matchesSelector
1329 // on a disconnected node (IE 9)
1330 support
.disconnectedMatch
= matches
.call( el
, "*" );
1332 // This should fail with an exception
1333 // Gecko does not error, returns false instead
1334 matches
.call( el
, "[s!='']:x" );
1335 rbuggyMatches
.push( "!=", pseudos
);
1339 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1340 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1343 ---------------------------------------------------------------------- */
1344 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1346 // Element contains another
1347 // Purposefully self-exclusive
1348 // As in, an element does not contain itself
1349 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1351 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
1352 bup
= b
&& b
.parentNode
;
1353 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1355 adown
.contains( bup
) :
1356 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1361 while ( (b
= b
.parentNode
) ) {
1371 ---------------------------------------------------------------------- */
1373 // Document order sorting
1374 sortOrder
= hasCompare
?
1377 // Flag for duplicate removal
1379 hasDuplicate
= true;
1383 // Sort on method existence if only one input has compareDocumentPosition
1384 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1389 // Calculate position if both inputs belong to the same document
1390 compare
= ( a
.ownerDocument
|| a
) === ( b
.ownerDocument
|| b
) ?
1391 a
.compareDocumentPosition( b
) :
1393 // Otherwise we know they are disconnected
1396 // Disconnected nodes
1398 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1400 // Choose the first element that is related to our preferred document
1401 if ( a
=== document
|| a
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, a
) ) {
1404 if ( b
=== document
|| b
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, b
) ) {
1408 // Maintain original order
1410 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1414 return compare
& 4 ? -1 : 1;
1417 // Exit early if the nodes are identical
1419 hasDuplicate
= true;
1430 // Parentless nodes are either documents or disconnected
1431 if ( !aup
|| !bup
) {
1432 return a
=== document
? -1 :
1433 b
=== document
? 1 :
1437 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1440 // If the nodes are siblings, we can do a quick check
1441 } else if ( aup
=== bup
) {
1442 return siblingCheck( a
, b
);
1445 // Otherwise we need full lists of their ancestors for comparison
1447 while ( (cur
= cur
.parentNode
) ) {
1451 while ( (cur
= cur
.parentNode
) ) {
1455 // Walk down the tree looking for a discrepancy
1456 while ( ap
[i
] === bp
[i
] ) {
1461 // Do a sibling check if the nodes have a common ancestor
1462 siblingCheck( ap
[i
], bp
[i
] ) :
1464 // Otherwise nodes in our document sort first
1465 ap
[i
] === preferredDoc
? -1 :
1466 bp
[i
] === preferredDoc
? 1 :
1473 Sizzle
.matches = function( expr
, elements
) {
1474 return Sizzle( expr
, null, null, elements
);
1477 Sizzle
.matchesSelector = function( elem
, expr
) {
1478 // Set document vars if needed
1479 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1480 setDocument( elem
);
1483 // Make sure that attribute selectors are quoted
1484 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1486 if ( support
.matchesSelector
&& documentIsHTML
&&
1487 !compilerCache
[ expr
+ " " ] &&
1488 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1489 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1492 var ret
= matches
.call( elem
, expr
);
1494 // IE 9's matchesSelector returns false on disconnected nodes
1495 if ( ret
|| support
.disconnectedMatch
||
1496 // As well, disconnected nodes are said to be in a document
1498 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1504 return Sizzle( expr
, document
, null, [ elem
] ).length
> 0;
1507 Sizzle
.contains = function( context
, elem
) {
1508 // Set document vars if needed
1509 if ( ( context
.ownerDocument
|| context
) !== document
) {
1510 setDocument( context
);
1512 return contains( context
, elem
);
1515 Sizzle
.attr = function( elem
, name
) {
1516 // Set document vars if needed
1517 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1518 setDocument( elem
);
1521 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1522 // Don't get fooled by Object.prototype properties (jQuery #13807)
1523 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1524 fn( elem
, name
, !documentIsHTML
) :
1527 return val
!== undefined ?
1529 support
.attributes
|| !documentIsHTML
?
1530 elem
.getAttribute( name
) :
1531 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1536 Sizzle
.escape = function( sel
) {
1537 return (sel
+ "").replace( rcssescape
, fcssescape
);
1540 Sizzle
.error = function( msg
) {
1541 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1545 * Document sorting and removing duplicates
1546 * @param {ArrayLike} results
1548 Sizzle
.uniqueSort = function( results
) {
1554 // Unless we *know* we can detect duplicates, assume their presence
1555 hasDuplicate
= !support
.detectDuplicates
;
1556 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1557 results
.sort( sortOrder
);
1559 if ( hasDuplicate
) {
1560 while ( (elem
= results
[i
++]) ) {
1561 if ( elem
=== results
[ i
] ) {
1562 j
= duplicates
.push( i
);
1566 results
.splice( duplicates
[ j
], 1 );
1570 // Clear input after sorting to release objects
1571 // See https://github.com/jquery/sizzle/pull/225
1578 * Utility function for retrieving the text value of an array of DOM nodes
1579 * @param {Array|Element} elem
1581 getText
= Sizzle
.getText = function( elem
) {
1585 nodeType
= elem
.nodeType
;
1588 // If no nodeType, this is expected to be an array
1589 while ( (node
= elem
[i
++]) ) {
1590 // Do not traverse comment nodes
1591 ret
+= getText( node
);
1593 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1594 // Use textContent for elements
1595 // innerText usage removed for consistency of new lines (jQuery #11153)
1596 if ( typeof elem
.textContent
=== "string" ) {
1597 return elem
.textContent
;
1599 // Traverse its children
1600 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1601 ret
+= getText( elem
);
1604 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1605 return elem
.nodeValue
;
1607 // Do not include comment or processing instruction nodes
1612 Expr
= Sizzle
.selectors
= {
1614 // Can be adjusted by the user
1617 createPseudo
: markFunction
,
1626 ">": { dir
: "parentNode", first
: true },
1627 " ": { dir
: "parentNode" },
1628 "+": { dir
: "previousSibling", first
: true },
1629 "~": { dir
: "previousSibling" }
1633 "ATTR": function( match
) {
1634 match
[1] = match
[1].replace( runescape
, funescape
);
1636 // Move the given value to match[3] whether quoted or unquoted
1637 match
[3] = ( match
[3] || match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1639 if ( match
[2] === "~=" ) {
1640 match
[3] = " " + match
[3] + " ";
1643 return match
.slice( 0, 4 );
1646 "CHILD": function( match
) {
1647 /* matches from matchExpr["CHILD"]
1648 1 type (only|nth|...)
1649 2 what (child|of-type)
1650 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1651 4 xn-component of xn+y argument ([+-]?\d*n|)
1652 5 sign of xn-component
1654 7 sign of y-component
1657 match
[1] = match
[1].toLowerCase();
1659 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1660 // nth-* requires argument
1662 Sizzle
.error( match
[0] );
1665 // numeric x and y parameters for Expr.filter.CHILD
1666 // remember that false/true cast respectively to 0/1
1667 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1668 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1670 // other types prohibit arguments
1671 } else if ( match
[3] ) {
1672 Sizzle
.error( match
[0] );
1678 "PSEUDO": function( match
) {
1680 unquoted
= !match
[6] && match
[2];
1682 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1686 // Accept quoted arguments as-is
1688 match
[2] = match
[4] || match
[5] || "";
1690 // Strip excess characters from unquoted arguments
1691 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1692 // Get excess from tokenize (recursively)
1693 (excess
= tokenize( unquoted
, true )) &&
1694 // advance to the next closing parenthesis
1695 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1697 // excess is a negative index
1698 match
[0] = match
[0].slice( 0, excess
);
1699 match
[2] = unquoted
.slice( 0, excess
);
1702 // Return only captures needed by the pseudo filter method (type and argument)
1703 return match
.slice( 0, 3 );
1709 "TAG": function( nodeNameSelector
) {
1710 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1711 return nodeNameSelector
=== "*" ?
1712 function() { return true; } :
1714 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1718 "CLASS": function( className
) {
1719 var pattern
= classCache
[ className
+ " " ];
1722 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1723 classCache( className
, function( elem
) {
1724 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== "undefined" && elem
.getAttribute("class") || "" );
1728 "ATTR": function( name
, operator
, check
) {
1729 return function( elem
) {
1730 var result
= Sizzle
.attr( elem
, name
);
1732 if ( result
== null ) {
1733 return operator
=== "!=";
1741 return operator
=== "=" ? result
=== check
:
1742 operator
=== "!=" ? result
!== check
:
1743 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1744 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1745 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check
:
1746 operator
=== "~=" ? ( " " + result
.replace( rwhitespace
, " " ) + " " ).indexOf( check
) > -1 :
1747 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1752 "CHILD": function( type
, what
, argument
, first
, last
) {
1753 var simple
= type
.slice( 0, 3 ) !== "nth",
1754 forward
= type
.slice( -4 ) !== "last",
1755 ofType
= what
=== "of-type";
1757 return first
=== 1 && last
=== 0 ?
1759 // Shortcut for :nth-*(n)
1761 return !!elem
.parentNode
;
1764 function( elem
, context
, xml
) {
1765 var cache
, uniqueCache
, outerCache
, node
, nodeIndex
, start
,
1766 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1767 parent
= elem
.parentNode
,
1768 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1769 useCache
= !xml
&& !ofType
,
1774 // :(first|last|only)-(child|of-type)
1778 while ( (node
= node
[ dir
]) ) {
1780 node
.nodeName
.toLowerCase() === name
:
1781 node
.nodeType
=== 1 ) {
1786 // Reverse direction for :only-* (if we haven't yet done so)
1787 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1792 start
= [ forward
? parent
.firstChild
: parent
.lastChild
];
1794 // non-xml :nth-child(...) stores cache data on `parent`
1795 if ( forward
&& useCache
) {
1797 // Seek `elem` from a previously-cached index
1799 // ...in a gzip-friendly way
1801 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1803 // Support: IE <9 only
1804 // Defend against cloned attroperties (jQuery gh-1709)
1805 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1806 (outerCache
[ node
.uniqueID
] = {});
1808 cache
= uniqueCache
[ type
] || [];
1809 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1810 diff
= nodeIndex
&& cache
[ 2 ];
1811 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1813 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1815 // Fallback to seeking `elem` from the start
1816 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1818 // When found, cache indexes on `parent` and break
1819 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1820 uniqueCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1826 // Use previously-cached element index if available
1828 // ...in a gzip-friendly way
1830 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1832 // Support: IE <9 only
1833 // Defend against cloned attroperties (jQuery gh-1709)
1834 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1835 (outerCache
[ node
.uniqueID
] = {});
1837 cache
= uniqueCache
[ type
] || [];
1838 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1842 // xml :nth-child(...)
1843 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1844 if ( diff
=== false ) {
1845 // Use the same loop as above to seek `elem` from the start
1846 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1847 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1850 node
.nodeName
.toLowerCase() === name
:
1851 node
.nodeType
=== 1 ) &&
1854 // Cache the index of each encountered element
1856 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1858 // Support: IE <9 only
1859 // Defend against cloned attroperties (jQuery gh-1709)
1860 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1861 (outerCache
[ node
.uniqueID
] = {});
1863 uniqueCache
[ type
] = [ dirruns
, diff
];
1866 if ( node
=== elem
) {
1874 // Incorporate the offset, then check against cycle size
1876 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
1881 "PSEUDO": function( pseudo
, argument
) {
1882 // pseudo-class names are case-insensitive
1883 // http://www.w3.org/TR/selectors/#pseudo-classes
1884 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1885 // Remember that setFilters inherits from pseudos
1887 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
1888 Sizzle
.error( "unsupported pseudo: " + pseudo
);
1890 // The user may use createPseudo to indicate that
1891 // arguments are needed to create the filter function
1892 // just as Sizzle does
1893 if ( fn
[ expando
] ) {
1894 return fn( argument
);
1897 // But maintain support for old signatures
1898 if ( fn
.length
> 1 ) {
1899 args
= [ pseudo
, pseudo
, "", argument
];
1900 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
1901 markFunction(function( seed
, matches
) {
1903 matched
= fn( seed
, argument
),
1906 idx
= indexOf( seed
, matched
[i
] );
1907 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
1911 return fn( elem
, 0, args
);
1920 // Potentially complex pseudos
1921 "not": markFunction(function( selector
) {
1922 // Trim the selector passed to compile
1923 // to avoid treating leading and trailing
1924 // spaces as combinators
1927 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
1929 return matcher
[ expando
] ?
1930 markFunction(function( seed
, matches
, context
, xml
) {
1932 unmatched
= matcher( seed
, null, xml
, [] ),
1935 // Match elements unmatched by `matcher`
1937 if ( (elem
= unmatched
[i
]) ) {
1938 seed
[i
] = !(matches
[i
] = elem
);
1942 function( elem
, context
, xml
) {
1944 matcher( input
, null, xml
, results
);
1945 // Don't keep the element (issue #299)
1947 return !results
.pop();
1951 "has": markFunction(function( selector
) {
1952 return function( elem
) {
1953 return Sizzle( selector
, elem
).length
> 0;
1957 "contains": markFunction(function( text
) {
1958 text
= text
.replace( runescape
, funescape
);
1959 return function( elem
) {
1960 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
1964 // "Whether an element is represented by a :lang() selector
1965 // is based solely on the element's language value
1966 // being equal to the identifier C,
1967 // or beginning with the identifier C immediately followed by "-".
1968 // The matching of C against the element's language value is performed case-insensitively.
1969 // The identifier C does not have to be a valid language name."
1970 // http://www.w3.org/TR/selectors/#lang-pseudo
1971 "lang": markFunction( function( lang
) {
1972 // lang value must be a valid identifier
1973 if ( !ridentifier
.test(lang
|| "") ) {
1974 Sizzle
.error( "unsupported lang: " + lang
);
1976 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
1977 return function( elem
) {
1980 if ( (elemLang
= documentIsHTML
?
1982 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
1984 elemLang
= elemLang
.toLowerCase();
1985 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
1987 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
1993 "target": function( elem
) {
1994 var hash
= window
.location
&& window
.location
.hash
;
1995 return hash
&& hash
.slice( 1 ) === elem
.id
;
1998 "root": function( elem
) {
1999 return elem
=== docElem
;
2002 "focus": function( elem
) {
2003 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
2006 // Boolean properties
2007 "enabled": createDisabledPseudo( false ),
2008 "disabled": createDisabledPseudo( true ),
2010 "checked": function( elem
) {
2011 // In CSS3, :checked should return both checked and selected elements
2012 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2013 var nodeName
= elem
.nodeName
.toLowerCase();
2014 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
2017 "selected": function( elem
) {
2018 // Accessing this property makes selected-by-default
2019 // options in Safari work properly
2020 if ( elem
.parentNode
) {
2021 elem
.parentNode
.selectedIndex
;
2024 return elem
.selected
=== true;
2028 "empty": function( elem
) {
2029 // http://www.w3.org/TR/selectors/#empty-pseudo
2030 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2031 // but not by others (comment: 8; processing instruction: 7; etc.)
2032 // nodeType < 6 works because attributes (2) do not appear as children
2033 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
2034 if ( elem
.nodeType
< 6 ) {
2041 "parent": function( elem
) {
2042 return !Expr
.pseudos
["empty"]( elem
);
2045 // Element/input types
2046 "header": function( elem
) {
2047 return rheader
.test( elem
.nodeName
);
2050 "input": function( elem
) {
2051 return rinputs
.test( elem
.nodeName
);
2054 "button": function( elem
) {
2055 var name
= elem
.nodeName
.toLowerCase();
2056 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
2059 "text": function( elem
) {
2061 return elem
.nodeName
.toLowerCase() === "input" &&
2062 elem
.type
=== "text" &&
2065 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2066 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === "text" );
2069 // Position-in-collection
2070 "first": createPositionalPseudo(function() {
2074 "last": createPositionalPseudo(function( matchIndexes
, length
) {
2075 return [ length
- 1 ];
2078 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2079 return [ argument
< 0 ? argument
+ length
: argument
];
2082 "even": createPositionalPseudo(function( matchIndexes
, length
) {
2084 for ( ; i
< length
; i
+= 2 ) {
2085 matchIndexes
.push( i
);
2087 return matchIndexes
;
2090 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
2092 for ( ; i
< length
; i
+= 2 ) {
2093 matchIndexes
.push( i
);
2095 return matchIndexes
;
2098 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2099 var i
= argument
< 0 ? argument
+ length
: argument
;
2100 for ( ; --i
>= 0; ) {
2101 matchIndexes
.push( i
);
2103 return matchIndexes
;
2106 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2107 var i
= argument
< 0 ? argument
+ length
: argument
;
2108 for ( ; ++i
< length
; ) {
2109 matchIndexes
.push( i
);
2111 return matchIndexes
;
2116 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
2118 // Add button/input type pseudos
2119 for ( i
in { radio
: true, checkbox
: true, file
: true, password
: true, image
: true } ) {
2120 Expr
.pseudos
[ i
] = createInputPseudo( i
);
2122 for ( i
in { submit
: true, reset
: true } ) {
2123 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
2126 // Easy API for creating new setFilters
2127 function setFilters() {}
2128 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
2129 Expr
.setFilters
= new setFilters();
2131 tokenize
= Sizzle
.tokenize = function( selector
, parseOnly
) {
2132 var matched
, match
, tokens
, type
,
2133 soFar
, groups
, preFilters
,
2134 cached
= tokenCache
[ selector
+ " " ];
2137 return parseOnly
? 0 : cached
.slice( 0 );
2142 preFilters
= Expr
.preFilter
;
2146 // Comma and first run
2147 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
2149 // Don't consume trailing commas as valid
2150 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2152 groups
.push( (tokens
= []) );
2158 if ( (match
= rcombinators
.exec( soFar
)) ) {
2159 matched
= match
.shift();
2162 // Cast descendant combinators to space
2163 type
: match
[0].replace( rtrim
, " " )
2165 soFar
= soFar
.slice( matched
.length
);
2169 for ( type
in Expr
.filter
) {
2170 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2171 (match
= preFilters
[ type
]( match
))) ) {
2172 matched
= match
.shift();
2178 soFar
= soFar
.slice( matched
.length
);
2187 // Return the length of the invalid excess
2188 // if we're just parsing
2189 // Otherwise, throw an error or return tokens
2193 Sizzle
.error( selector
) :
2195 tokenCache( selector
, groups
).slice( 0 );
2198 function toSelector( tokens
) {
2200 len
= tokens
.length
,
2202 for ( ; i
< len
; i
++ ) {
2203 selector
+= tokens
[i
].value
;
2208 function addCombinator( matcher
, combinator
, base
) {
2209 var dir
= combinator
.dir
,
2210 skip
= combinator
.next
,
2212 checkNonElements
= base
&& key
=== "parentNode",
2215 return combinator
.first
?
2216 // Check against closest ancestor/preceding element
2217 function( elem
, context
, xml
) {
2218 while ( (elem
= elem
[ dir
]) ) {
2219 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2220 return matcher( elem
, context
, xml
);
2226 // Check against all ancestor/preceding elements
2227 function( elem
, context
, xml
) {
2228 var oldCache
, uniqueCache
, outerCache
,
2229 newCache
= [ dirruns
, doneName
];
2231 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2233 while ( (elem
= elem
[ dir
]) ) {
2234 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2235 if ( matcher( elem
, context
, xml
) ) {
2241 while ( (elem
= elem
[ dir
]) ) {
2242 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2243 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2245 // Support: IE <9 only
2246 // Defend against cloned attroperties (jQuery gh-1709)
2247 uniqueCache
= outerCache
[ elem
.uniqueID
] || (outerCache
[ elem
.uniqueID
] = {});
2249 if ( skip
&& skip
=== elem
.nodeName
.toLowerCase() ) {
2250 elem
= elem
[ dir
] || elem
;
2251 } else if ( (oldCache
= uniqueCache
[ key
]) &&
2252 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2254 // Assign to newCache so results back-propagate to previous elements
2255 return (newCache
[ 2 ] = oldCache
[ 2 ]);
2257 // Reuse newcache so results back-propagate to previous elements
2258 uniqueCache
[ key
] = newCache
;
2260 // A match means we're done; a fail means we have to keep checking
2261 if ( (newCache
[ 2 ] = matcher( elem
, context
, xml
)) ) {
2272 function elementMatcher( matchers
) {
2273 return matchers
.length
> 1 ?
2274 function( elem
, context
, xml
) {
2275 var i
= matchers
.length
;
2277 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2286 function multipleContexts( selector
, contexts
, results
) {
2288 len
= contexts
.length
;
2289 for ( ; i
< len
; i
++ ) {
2290 Sizzle( selector
, contexts
[i
], results
);
2295 function condense( unmatched
, map
, filter
, context
, xml
) {
2299 len
= unmatched
.length
,
2300 mapped
= map
!= null;
2302 for ( ; i
< len
; i
++ ) {
2303 if ( (elem
= unmatched
[i
]) ) {
2304 if ( !filter
|| filter( elem
, context
, xml
) ) {
2305 newUnmatched
.push( elem
);
2313 return newUnmatched
;
2316 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2317 if ( postFilter
&& !postFilter
[ expando
] ) {
2318 postFilter
= setMatcher( postFilter
);
2320 if ( postFinder
&& !postFinder
[ expando
] ) {
2321 postFinder
= setMatcher( postFinder
, postSelector
);
2323 return markFunction(function( seed
, results
, context
, xml
) {
2327 preexisting
= results
.length
,
2329 // Get initial elements from seed or context
2330 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2332 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2333 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2334 condense( elems
, preMap
, preFilter
, context
, xml
) :
2337 matcherOut
= matcher
?
2338 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2339 postFinder
|| ( seed
? preFilter
: preexisting
|| postFilter
) ?
2341 // ...intermediate processing is necessary
2344 // ...otherwise use results directly
2348 // Find primary matches
2350 matcher( matcherIn
, matcherOut
, context
, xml
);
2355 temp
= condense( matcherOut
, postMap
);
2356 postFilter( temp
, [], context
, xml
);
2358 // Un-match failing elements by moving them back to matcherIn
2361 if ( (elem
= temp
[i
]) ) {
2362 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2368 if ( postFinder
|| preFilter
) {
2370 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2372 i
= matcherOut
.length
;
2374 if ( (elem
= matcherOut
[i
]) ) {
2375 // Restore matcherIn since elem is not yet a final match
2376 temp
.push( (matcherIn
[i
] = elem
) );
2379 postFinder( null, (matcherOut
= []), temp
, xml
);
2382 // Move matched elements from seed to results to keep them synchronized
2383 i
= matcherOut
.length
;
2385 if ( (elem
= matcherOut
[i
]) &&
2386 (temp
= postFinder
? indexOf( seed
, elem
) : preMap
[i
]) > -1 ) {
2388 seed
[temp
] = !(results
[temp
] = elem
);
2393 // Add elements to results, through postFinder if defined
2395 matcherOut
= condense(
2396 matcherOut
=== results
?
2397 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2401 postFinder( null, results
, matcherOut
, xml
);
2403 push
.apply( results
, matcherOut
);
2409 function matcherFromTokens( tokens
) {
2410 var checkContext
, matcher
, j
,
2411 len
= tokens
.length
,
2412 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2413 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2414 i
= leadingRelative
? 1 : 0,
2416 // The foundational matcher ensures that elements are reachable from top-level context(s)
2417 matchContext
= addCombinator( function( elem
) {
2418 return elem
=== checkContext
;
2419 }, implicitRelative
, true ),
2420 matchAnyContext
= addCombinator( function( elem
) {
2421 return indexOf( checkContext
, elem
) > -1;
2422 }, implicitRelative
, true ),
2423 matchers
= [ function( elem
, context
, xml
) {
2424 var ret
= ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2425 (checkContext
= context
).nodeType
?
2426 matchContext( elem
, context
, xml
) :
2427 matchAnyContext( elem
, context
, xml
) );
2428 // Avoid hanging onto element (issue #299)
2429 checkContext
= null;
2433 for ( ; i
< len
; i
++ ) {
2434 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2435 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2437 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2439 // Return special upon seeing a positional matcher
2440 if ( matcher
[ expando
] ) {
2441 // Find the next relative operator (if any) for proper handling
2443 for ( ; j
< len
; j
++ ) {
2444 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2449 i
> 1 && elementMatcher( matchers
),
2450 i
> 1 && toSelector(
2451 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2452 tokens
.slice( 0, i
- 1 ).concat({ value
: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2453 ).replace( rtrim
, "$1" ),
2455 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2456 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2457 j
< len
&& toSelector( tokens
)
2460 matchers
.push( matcher
);
2464 return elementMatcher( matchers
);
2467 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2468 var bySet
= setMatchers
.length
> 0,
2469 byElement
= elementMatchers
.length
> 0,
2470 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2471 var elem
, j
, matcher
,
2474 unmatched
= seed
&& [],
2476 contextBackup
= outermostContext
,
2477 // We must always have either seed elements or outermost context
2478 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", outermost
),
2479 // Use integer dirruns iff this is the outermost matcher
2480 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1),
2484 outermostContext
= context
=== document
|| context
|| outermost
;
2487 // Add elements passing elementMatchers directly to results
2488 // Support: IE<9, Safari
2489 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2490 for ( ; i
!== len
&& (elem
= elems
[i
]) != null; i
++ ) {
2491 if ( byElement
&& elem
) {
2493 if ( !context
&& elem
.ownerDocument
!== document
) {
2494 setDocument( elem
);
2495 xml
= !documentIsHTML
;
2497 while ( (matcher
= elementMatchers
[j
++]) ) {
2498 if ( matcher( elem
, context
|| document
, xml
) ) {
2499 results
.push( elem
);
2504 dirruns
= dirrunsUnique
;
2508 // Track unmatched elements for set filters
2510 // They will have gone through all possible matchers
2511 if ( (elem
= !matcher
&& elem
) ) {
2515 // Lengthen the array for every element, matched or not
2517 unmatched
.push( elem
);
2522 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2523 // makes the latter nonnegative.
2526 // Apply set filters to unmatched elements
2527 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2528 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2529 // no element matchers and no seed.
2530 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2531 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2532 // numerically zero.
2533 if ( bySet
&& i
!== matchedCount
) {
2535 while ( (matcher
= setMatchers
[j
++]) ) {
2536 matcher( unmatched
, setMatched
, context
, xml
);
2540 // Reintegrate element matches to eliminate the need for sorting
2541 if ( matchedCount
> 0 ) {
2543 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2544 setMatched
[i
] = pop
.call( results
);
2549 // Discard index placeholder values to get only actual matches
2550 setMatched
= condense( setMatched
);
2553 // Add matches to results
2554 push
.apply( results
, setMatched
);
2556 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2557 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2558 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2560 Sizzle
.uniqueSort( results
);
2564 // Override manipulation of globals by nested matchers
2566 dirruns
= dirrunsUnique
;
2567 outermostContext
= contextBackup
;
2574 markFunction( superMatcher
) :
2578 compile
= Sizzle
.compile = function( selector
, match
/* Internal Use Only */ ) {
2581 elementMatchers
= [],
2582 cached
= compilerCache
[ selector
+ " " ];
2585 // Generate a function of recursive functions that can be used to check each element
2587 match
= tokenize( selector
);
2591 cached
= matcherFromTokens( match
[i
] );
2592 if ( cached
[ expando
] ) {
2593 setMatchers
.push( cached
);
2595 elementMatchers
.push( cached
);
2599 // Cache the compiled function
2600 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2602 // Save selector and tokenization
2603 cached
.selector
= selector
;
2609 * A low-level selection function that works with Sizzle's compiled
2610 * selector functions
2611 * @param {String|Function} selector A selector or a pre-compiled
2612 * selector function built with Sizzle.compile
2613 * @param {Element} context
2614 * @param {Array} [results]
2615 * @param {Array} [seed] A set of elements to match against
2617 select
= Sizzle
.select = function( selector
, context
, results
, seed
) {
2618 var i
, tokens
, token
, type
, find
,
2619 compiled
= typeof selector
=== "function" && selector
,
2620 match
= !seed
&& tokenize( (selector
= compiled
.selector
|| selector
) );
2622 results
= results
|| [];
2624 // Try to minimize operations if there is only one selector in the list and no seed
2625 // (the latter of which guarantees us context)
2626 if ( match
.length
=== 1 ) {
2628 // Reduce context if the leading compound selector is an ID
2629 tokens
= match
[0] = match
[0].slice( 0 );
2630 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2631 context
.nodeType
=== 9 && documentIsHTML
&& Expr
.relative
[ tokens
[1].type
] ) {
2633 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2637 // Precompiled matchers will still verify ancestry, so step up a level
2638 } else if ( compiled
) {
2639 context
= context
.parentNode
;
2642 selector
= selector
.slice( tokens
.shift().value
.length
);
2645 // Fetch a seed set for right-to-left matching
2646 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2650 // Abort if we hit a combinator
2651 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2654 if ( (find
= Expr
.find
[ type
]) ) {
2655 // Search, expanding context for leading sibling combinators
2657 token
.matches
[0].replace( runescape
, funescape
),
2658 rsibling
.test( tokens
[0].type
) && testContext( context
.parentNode
) || context
2661 // If seed is empty or no tokens remain, we can return early
2662 tokens
.splice( i
, 1 );
2663 selector
= seed
.length
&& toSelector( tokens
);
2665 push
.apply( results
, seed
);
2675 // Compile and execute a filtering function if one is not provided
2676 // Provide `match` to avoid retokenization if we modified the selector above
2677 ( compiled
|| compile( selector
, match
) )(
2682 !context
|| rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2687 // One-time assignments
2690 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2692 // Support: Chrome 14-35+
2693 // Always assume duplicates if they aren't passed to the comparison function
2694 support
.detectDuplicates
= !!hasDuplicate
;
2696 // Initialize against the default document
2699 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2700 // Detached nodes confoundingly follow *each other*
2701 support
.sortDetached
= assert(function( el
) {
2702 // Should return 1, but returns 4 (following)
2703 return el
.compareDocumentPosition( document
.createElement("fieldset") ) & 1;
2707 // Prevent attribute/property "interpolation"
2708 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2709 if ( !assert(function( el
) {
2710 el
.innerHTML
= "<a href='#'></a>";
2711 return el
.firstChild
.getAttribute("href") === "#" ;
2713 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2715 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2721 // Use defaultValue in place of getAttribute("value")
2722 if ( !support
.attributes
|| !assert(function( el
) {
2723 el
.innerHTML
= "<input/>";
2724 el
.firstChild
.setAttribute( "value", "" );
2725 return el
.firstChild
.getAttribute( "value" ) === "";
2727 addHandle( "value", function( elem
, name
, isXML
) {
2728 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2729 return elem
.defaultValue
;
2735 // Use getAttributeNode to fetch booleans when getAttribute lies
2736 if ( !assert(function( el
) {
2737 return el
.getAttribute("disabled") == null;
2739 addHandle( booleans
, function( elem
, name
, isXML
) {
2742 return elem
[ name
] === true ? name
.toLowerCase() :
2743 (val
= elem
.getAttributeNode( name
)) && val
.specified
?
2756 jQuery
.find
= Sizzle
;
2757 jQuery
.expr
= Sizzle
.selectors
;
2760 jQuery
.expr
[ ":" ] = jQuery
.expr
.pseudos
;
2761 jQuery
.uniqueSort
= jQuery
.unique
= Sizzle
.uniqueSort
;
2762 jQuery
.text
= Sizzle
.getText
;
2763 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2764 jQuery
.contains
= Sizzle
.contains
;
2765 jQuery
.escapeSelector
= Sizzle
.escape
;
2770 var dir = function( elem
, dir
, until
) {
2772 truncate
= until
!== undefined;
2774 while ( ( elem
= elem
[ dir
] ) && elem
.nodeType
!== 9 ) {
2775 if ( elem
.nodeType
=== 1 ) {
2776 if ( truncate
&& jQuery( elem
).is( until
) ) {
2779 matched
.push( elem
);
2786 var siblings = function( n
, elem
) {
2789 for ( ; n
; n
= n
.nextSibling
) {
2790 if ( n
.nodeType
=== 1 && n
!== elem
) {
2799 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
2803 function nodeName( elem
, name
) {
2805 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
2808 var rsingleTag
= ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2812 // Implement the identical functionality for filter and not
2813 function winnow( elements
, qualifier
, not
) {
2814 if ( isFunction( qualifier
) ) {
2815 return jQuery
.grep( elements
, function( elem
, i
) {
2816 return !!qualifier
.call( elem
, i
, elem
) !== not
;
2821 if ( qualifier
.nodeType
) {
2822 return jQuery
.grep( elements
, function( elem
) {
2823 return ( elem
=== qualifier
) !== not
;
2827 // Arraylike of elements (jQuery, arguments, Array)
2828 if ( typeof qualifier
!== "string" ) {
2829 return jQuery
.grep( elements
, function( elem
) {
2830 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
;
2834 // Filtered directly for both simple and complex selectors
2835 return jQuery
.filter( qualifier
, elements
, not
);
2838 jQuery
.filter = function( expr
, elems
, not
) {
2839 var elem
= elems
[ 0 ];
2842 expr
= ":not(" + expr
+ ")";
2845 if ( elems
.length
=== 1 && elem
.nodeType
=== 1 ) {
2846 return jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [];
2849 return jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
2850 return elem
.nodeType
=== 1;
2855 find: function( selector
) {
2860 if ( typeof selector
!== "string" ) {
2861 return this.pushStack( jQuery( selector
).filter( function() {
2862 for ( i
= 0; i
< len
; i
++ ) {
2863 if ( jQuery
.contains( self
[ i
], this ) ) {
2870 ret
= this.pushStack( [] );
2872 for ( i
= 0; i
< len
; i
++ ) {
2873 jQuery
.find( selector
, self
[ i
], ret
);
2876 return len
> 1 ? jQuery
.uniqueSort( ret
) : ret
;
2878 filter: function( selector
) {
2879 return this.pushStack( winnow( this, selector
|| [], false ) );
2881 not: function( selector
) {
2882 return this.pushStack( winnow( this, selector
|| [], true ) );
2884 is: function( selector
) {
2888 // If this is a positional/relative selector, check membership in the returned set
2889 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2890 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
2891 jQuery( selector
) :
2899 // Initialize a jQuery object
2902 // A central reference to the root jQuery(document)
2905 // A simple way to check for HTML strings
2906 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2907 // Strict HTML recognition (#11290: must start with <)
2908 // Shortcut simple #id case for speed
2909 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2911 init
= jQuery
.fn
.init = function( selector
, context
, root
) {
2914 // HANDLE: $(""), $(null), $(undefined), $(false)
2919 // Method init() accepts an alternate rootjQuery
2920 // so migrate can support jQuery.sub (gh-2101)
2921 root
= root
|| rootjQuery
;
2923 // Handle HTML strings
2924 if ( typeof selector
=== "string" ) {
2925 if ( selector
[ 0 ] === "<" &&
2926 selector
[ selector
.length
- 1 ] === ">" &&
2927 selector
.length
>= 3 ) {
2929 // Assume that strings that start and end with <> are HTML and skip the regex check
2930 match
= [ null, selector
, null ];
2933 match
= rquickExpr
.exec( selector
);
2936 // Match html or make sure no context is specified for #id
2937 if ( match
&& ( match
[ 1 ] || !context
) ) {
2939 // HANDLE: $(html) -> $(array)
2941 context
= context
instanceof jQuery
? context
[ 0 ] : context
;
2943 // Option to run scripts is true for back-compat
2944 // Intentionally let the error be thrown if parseHTML is not present
2945 jQuery
.merge( this, jQuery
.parseHTML(
2947 context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
,
2951 // HANDLE: $(html, props)
2952 if ( rsingleTag
.test( match
[ 1 ] ) && jQuery
.isPlainObject( context
) ) {
2953 for ( match
in context
) {
2955 // Properties of context are called as methods if possible
2956 if ( isFunction( this[ match
] ) ) {
2957 this[ match
]( context
[ match
] );
2959 // ...and otherwise set as attributes
2961 this.attr( match
, context
[ match
] );
2970 elem
= document
.getElementById( match
[ 2 ] );
2974 // Inject the element directly into the jQuery object
2981 // HANDLE: $(expr, $(...))
2982 } else if ( !context
|| context
.jquery
) {
2983 return ( context
|| root
).find( selector
);
2985 // HANDLE: $(expr, context)
2986 // (which is just equivalent to: $(context).find(expr)
2988 return this.constructor( context
).find( selector
);
2991 // HANDLE: $(DOMElement)
2992 } else if ( selector
.nodeType
) {
2993 this[ 0 ] = selector
;
2997 // HANDLE: $(function)
2998 // Shortcut for document ready
2999 } else if ( isFunction( selector
) ) {
3000 return root
.ready
!== undefined ?
3001 root
.ready( selector
) :
3003 // Execute immediately if ready is not present
3007 return jQuery
.makeArray( selector
, this );
3010 // Give the init function the jQuery prototype for later instantiation
3011 init
.prototype = jQuery
.fn
;
3013 // Initialize central reference
3014 rootjQuery
= jQuery( document
);
3017 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
3019 // Methods guaranteed to produce a unique set when starting from a unique set
3020 guaranteedUnique
= {
3028 has: function( target
) {
3029 var targets
= jQuery( target
, this ),
3032 return this.filter( function() {
3034 for ( ; i
< l
; i
++ ) {
3035 if ( jQuery
.contains( this, targets
[ i
] ) ) {
3042 closest: function( selectors
, context
) {
3047 targets
= typeof selectors
!== "string" && jQuery( selectors
);
3049 // Positional selectors never match, since there's no _selection_ context
3050 if ( !rneedsContext
.test( selectors
) ) {
3051 for ( ; i
< l
; i
++ ) {
3052 for ( cur
= this[ i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
3054 // Always skip document fragments
3055 if ( cur
.nodeType
< 11 && ( targets
?
3056 targets
.index( cur
) > -1 :
3058 // Don't pass non-elements to Sizzle
3059 cur
.nodeType
=== 1 &&
3060 jQuery
.find
.matchesSelector( cur
, selectors
) ) ) {
3062 matched
.push( cur
);
3069 return this.pushStack( matched
.length
> 1 ? jQuery
.uniqueSort( matched
) : matched
);
3072 // Determine the position of an element within the set
3073 index: function( elem
) {
3075 // No argument, return index in parent
3077 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length
: -1;
3080 // Index in selector
3081 if ( typeof elem
=== "string" ) {
3082 return indexOf
.call( jQuery( elem
), this[ 0 ] );
3085 // Locate the position of the desired element
3086 return indexOf
.call( this,
3088 // If it receives a jQuery object, the first element is used
3089 elem
.jquery
? elem
[ 0 ] : elem
3093 add: function( selector
, context
) {
3094 return this.pushStack(
3096 jQuery
.merge( this.get(), jQuery( selector
, context
) )
3101 addBack: function( selector
) {
3102 return this.add( selector
== null ?
3103 this.prevObject
: this.prevObject
.filter( selector
)
3108 function sibling( cur
, dir
) {
3109 while ( ( cur
= cur
[ dir
] ) && cur
.nodeType
!== 1 ) {}
3114 parent: function( elem
) {
3115 var parent
= elem
.parentNode
;
3116 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
3118 parents: function( elem
) {
3119 return dir( elem
, "parentNode" );
3121 parentsUntil: function( elem
, i
, until
) {
3122 return dir( elem
, "parentNode", until
);
3124 next: function( elem
) {
3125 return sibling( elem
, "nextSibling" );
3127 prev: function( elem
) {
3128 return sibling( elem
, "previousSibling" );
3130 nextAll: function( elem
) {
3131 return dir( elem
, "nextSibling" );
3133 prevAll: function( elem
) {
3134 return dir( elem
, "previousSibling" );
3136 nextUntil: function( elem
, i
, until
) {
3137 return dir( elem
, "nextSibling", until
);
3139 prevUntil: function( elem
, i
, until
) {
3140 return dir( elem
, "previousSibling", until
);
3142 siblings: function( elem
) {
3143 return siblings( ( elem
.parentNode
|| {} ).firstChild
, elem
);
3145 children: function( elem
) {
3146 return siblings( elem
.firstChild
);
3148 contents: function( elem
) {
3149 if ( nodeName( elem
, "iframe" ) ) {
3150 return elem
.contentDocument
;
3153 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3154 // Treat the template element as a regular one in browsers that
3155 // don't support it.
3156 if ( nodeName( elem
, "template" ) ) {
3157 elem
= elem
.content
|| elem
;
3160 return jQuery
.merge( [], elem
.childNodes
);
3162 }, function( name
, fn
) {
3163 jQuery
.fn
[ name
] = function( until
, selector
) {
3164 var matched
= jQuery
.map( this, fn
, until
);
3166 if ( name
.slice( -5 ) !== "Until" ) {
3170 if ( selector
&& typeof selector
=== "string" ) {
3171 matched
= jQuery
.filter( selector
, matched
);
3174 if ( this.length
> 1 ) {
3176 // Remove duplicates
3177 if ( !guaranteedUnique
[ name
] ) {
3178 jQuery
.uniqueSort( matched
);
3181 // Reverse order for parents* and prev-derivatives
3182 if ( rparentsprev
.test( name
) ) {
3187 return this.pushStack( matched
);
3190 var rnothtmlwhite
= ( /[^\x20\t\r\n\f]+/g );
3194 // Convert String-formatted options into Object-formatted ones
3195 function createOptions( options
) {
3197 jQuery
.each( options
.match( rnothtmlwhite
) || [], function( _
, flag
) {
3198 object
[ flag
] = true;
3204 * Create a callback list using the following parameters:
3206 * options: an optional list of space-separated options that will change how
3207 * the callback list behaves or a more traditional option object
3209 * By default a callback list will act like an event callback list and can be
3210 * "fired" multiple times.
3214 * once: will ensure the callback list can only be fired once (like a Deferred)
3216 * memory: will keep track of previous values and will call any callback added
3217 * after the list has been fired right away with the latest "memorized"
3218 * values (like a Deferred)
3220 * unique: will ensure a callback can only be added once (no duplicate in the list)
3222 * stopOnFalse: interrupt callings when a callback returns false
3225 jQuery
.Callbacks = function( options
) {
3227 // Convert options from String-formatted to Object-formatted if needed
3228 // (we check in cache first)
3229 options
= typeof options
=== "string" ?
3230 createOptions( options
) :
3231 jQuery
.extend( {}, options
);
3233 var // Flag to know if list is currently firing
3236 // Last fire value for non-forgettable lists
3239 // Flag to know if list was already fired
3242 // Flag to prevent firing
3245 // Actual callback list
3248 // Queue of execution data for repeatable lists
3251 // Index of currently firing callback (modified by add/remove as needed)
3257 // Enforce single-firing
3258 locked
= locked
|| options
.once
;
3260 // Execute callbacks for all pending executions,
3261 // respecting firingIndex overrides and runtime changes
3262 fired
= firing
= true;
3263 for ( ; queue
.length
; firingIndex
= -1 ) {
3264 memory
= queue
.shift();
3265 while ( ++firingIndex
< list
.length
) {
3267 // Run callback and check for early termination
3268 if ( list
[ firingIndex
].apply( memory
[ 0 ], memory
[ 1 ] ) === false &&
3269 options
.stopOnFalse
) {
3271 // Jump to end and forget the data so .add doesn't re-fire
3272 firingIndex
= list
.length
;
3278 // Forget the data if we're done with it
3279 if ( !options
.memory
) {
3285 // Clean up if we're done firing for good
3288 // Keep an empty list if we have data for future add calls
3292 // Otherwise, this object is spent
3299 // Actual Callbacks object
3302 // Add a callback or a collection of callbacks to the list
3306 // If we have memory from a past run, we should fire after adding
3307 if ( memory
&& !firing
) {
3308 firingIndex
= list
.length
- 1;
3309 queue
.push( memory
);
3312 ( function add( args
) {
3313 jQuery
.each( args
, function( _
, arg
) {
3314 if ( isFunction( arg
) ) {
3315 if ( !options
.unique
|| !self
.has( arg
) ) {
3318 } else if ( arg
&& arg
.length
&& toType( arg
) !== "string" ) {
3320 // Inspect recursively
3326 if ( memory
&& !firing
) {
3333 // Remove a callback from the list
3334 remove: function() {
3335 jQuery
.each( arguments
, function( _
, arg
) {
3337 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3338 list
.splice( index
, 1 );
3340 // Handle firing indexes
3341 if ( index
<= firingIndex
) {
3349 // Check if a given callback is in the list.
3350 // If no argument is given, return whether or not list has callbacks attached.
3351 has: function( fn
) {
3353 jQuery
.inArray( fn
, list
) > -1 :
3357 // Remove all callbacks from the list
3365 // Disable .fire and .add
3366 // Abort any current/pending executions
3367 // Clear all callbacks and values
3368 disable: function() {
3369 locked
= queue
= [];
3373 disabled: function() {
3378 // Also disable .add unless we have memory (since it would have no effect)
3379 // Abort any pending executions
3381 locked
= queue
= [];
3382 if ( !memory
&& !firing
) {
3387 locked: function() {
3391 // Call all callbacks with the given context and arguments
3392 fireWith: function( context
, args
) {
3395 args
= [ context
, args
.slice
? args
.slice() : args
];
3404 // Call all the callbacks with the given arguments
3406 self
.fireWith( this, arguments
);
3410 // To know if the callbacks have already been called at least once
3420 function Identity( v
) {
3423 function Thrower( ex
) {
3427 function adoptValue( value
, resolve
, reject
, noValue
) {
3432 // Check for promise aspect first to privilege synchronous behavior
3433 if ( value
&& isFunction( ( method
= value
.promise
) ) ) {
3434 method
.call( value
).done( resolve
).fail( reject
);
3437 } else if ( value
&& isFunction( ( method
= value
.then
) ) ) {
3438 method
.call( value
, resolve
, reject
);
3440 // Other non-thenables
3443 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3444 // * false: [ value ].slice( 0 ) => resolve( value )
3445 // * true: [ value ].slice( 1 ) => resolve()
3446 resolve
.apply( undefined, [ value
].slice( noValue
) );
3449 // For Promises/A+, convert exceptions into rejections
3450 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3451 // Deferred#then to conditionally suppress rejection.
3454 // Support: Android 4.0 only
3455 // Strict mode functions invoked without .call/.apply get global-object context
3456 reject
.apply( undefined, [ value
] );
3462 Deferred: function( func
) {
3465 // action, add listener, callbacks,
3466 // ... .then handlers, argument index, [final state]
3467 [ "notify", "progress", jQuery
.Callbacks( "memory" ),
3468 jQuery
.Callbacks( "memory" ), 2 ],
3469 [ "resolve", "done", jQuery
.Callbacks( "once memory" ),
3470 jQuery
.Callbacks( "once memory" ), 0, "resolved" ],
3471 [ "reject", "fail", jQuery
.Callbacks( "once memory" ),
3472 jQuery
.Callbacks( "once memory" ), 1, "rejected" ]
3479 always: function() {
3480 deferred
.done( arguments
).fail( arguments
);
3483 "catch": function( fn
) {
3484 return promise
.then( null, fn
);
3487 // Keep pipe for back-compat
3488 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3489 var fns
= arguments
;
3491 return jQuery
.Deferred( function( newDefer
) {
3492 jQuery
.each( tuples
, function( i
, tuple
) {
3494 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3495 var fn
= isFunction( fns
[ tuple
[ 4 ] ] ) && fns
[ tuple
[ 4 ] ];
3497 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3498 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3499 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3500 deferred
[ tuple
[ 1 ] ]( function() {
3501 var returned
= fn
&& fn
.apply( this, arguments
);
3502 if ( returned
&& isFunction( returned
.promise
) ) {
3504 .progress( newDefer
.notify
)
3505 .done( newDefer
.resolve
)
3506 .fail( newDefer
.reject
);
3508 newDefer
[ tuple
[ 0 ] + "With" ](
3510 fn
? [ returned
] : arguments
3518 then: function( onFulfilled
, onRejected
, onProgress
) {
3520 function resolve( depth
, deferred
, handler
, special
) {
3524 mightThrow = function() {
3527 // Support: Promises/A+ section 2.3.3.3.3
3528 // https://promisesaplus.com/#point-59
3529 // Ignore double-resolution attempts
3530 if ( depth
< maxDepth
) {
3534 returned
= handler
.apply( that
, args
);
3536 // Support: Promises/A+ section 2.3.1
3537 // https://promisesaplus.com/#point-48
3538 if ( returned
=== deferred
.promise() ) {
3539 throw new TypeError( "Thenable self-resolution" );
3542 // Support: Promises/A+ sections 2.3.3.1, 3.5
3543 // https://promisesaplus.com/#point-54
3544 // https://promisesaplus.com/#point-75
3545 // Retrieve `then` only once
3548 // Support: Promises/A+ section 2.3.4
3549 // https://promisesaplus.com/#point-64
3550 // Only check objects and functions for thenability
3551 ( typeof returned
=== "object" ||
3552 typeof returned
=== "function" ) &&
3555 // Handle a returned thenable
3556 if ( isFunction( then
) ) {
3558 // Special processors (notify) just wait for resolution
3562 resolve( maxDepth
, deferred
, Identity
, special
),
3563 resolve( maxDepth
, deferred
, Thrower
, special
)
3566 // Normal processors (resolve) also hook into progress
3569 // ...and disregard older resolution values
3574 resolve( maxDepth
, deferred
, Identity
, special
),
3575 resolve( maxDepth
, deferred
, Thrower
, special
),
3576 resolve( maxDepth
, deferred
, Identity
,
3577 deferred
.notifyWith
)
3581 // Handle all other returned values
3584 // Only substitute handlers pass on context
3585 // and multiple values (non-spec behavior)
3586 if ( handler
!== Identity
) {
3588 args
= [ returned
];
3591 // Process the value(s)
3592 // Default process is resolve
3593 ( special
|| deferred
.resolveWith
)( that
, args
);
3597 // Only normal processors (resolve) catch and reject exceptions
3605 if ( jQuery
.Deferred
.exceptionHook
) {
3606 jQuery
.Deferred
.exceptionHook( e
,
3607 process
.stackTrace
);
3610 // Support: Promises/A+ section 2.3.3.3.4.1
3611 // https://promisesaplus.com/#point-61
3612 // Ignore post-resolution exceptions
3613 if ( depth
+ 1 >= maxDepth
) {
3615 // Only substitute handlers pass on context
3616 // and multiple values (non-spec behavior)
3617 if ( handler
!== Thrower
) {
3622 deferred
.rejectWith( that
, args
);
3627 // Support: Promises/A+ section 2.3.3.3.1
3628 // https://promisesaplus.com/#point-57
3629 // Re-resolve promises immediately to dodge false rejection from
3630 // subsequent errors
3635 // Call an optional hook to record the stack, in case of exception
3636 // since it's otherwise lost when execution goes async
3637 if ( jQuery
.Deferred
.getStackHook
) {
3638 process
.stackTrace
= jQuery
.Deferred
.getStackHook();
3640 window
.setTimeout( process
);
3645 return jQuery
.Deferred( function( newDefer
) {
3647 // progress_handlers.add( ... )
3648 tuples
[ 0 ][ 3 ].add(
3652 isFunction( onProgress
) ?
3659 // fulfilled_handlers.add( ... )
3660 tuples
[ 1 ][ 3 ].add(
3664 isFunction( onFulfilled
) ?
3670 // rejected_handlers.add( ... )
3671 tuples
[ 2 ][ 3 ].add(
3675 isFunction( onRejected
) ?
3683 // Get a promise for this deferred
3684 // If obj is provided, the promise aspect is added to the object
3685 promise: function( obj
) {
3686 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3691 // Add list-specific methods
3692 jQuery
.each( tuples
, function( i
, tuple
) {
3693 var list
= tuple
[ 2 ],
3694 stateString
= tuple
[ 5 ];
3696 // promise.progress = list.add
3697 // promise.done = list.add
3698 // promise.fail = list.add
3699 promise
[ tuple
[ 1 ] ] = list
.add
;
3702 if ( stateString
) {
3706 // state = "resolved" (i.e., fulfilled)
3707 // state = "rejected"
3708 state
= stateString
;
3711 // rejected_callbacks.disable
3712 // fulfilled_callbacks.disable
3713 tuples
[ 3 - i
][ 2 ].disable
,
3715 // rejected_handlers.disable
3716 // fulfilled_handlers.disable
3717 tuples
[ 3 - i
][ 3 ].disable
,
3719 // progress_callbacks.lock
3720 tuples
[ 0 ][ 2 ].lock
,
3722 // progress_handlers.lock
3723 tuples
[ 0 ][ 3 ].lock
3727 // progress_handlers.fire
3728 // fulfilled_handlers.fire
3729 // rejected_handlers.fire
3730 list
.add( tuple
[ 3 ].fire
);
3732 // deferred.notify = function() { deferred.notifyWith(...) }
3733 // deferred.resolve = function() { deferred.resolveWith(...) }
3734 // deferred.reject = function() { deferred.rejectWith(...) }
3735 deferred
[ tuple
[ 0 ] ] = function() {
3736 deferred
[ tuple
[ 0 ] + "With" ]( this === deferred
? undefined : this, arguments
);
3740 // deferred.notifyWith = list.fireWith
3741 // deferred.resolveWith = list.fireWith
3742 // deferred.rejectWith = list.fireWith
3743 deferred
[ tuple
[ 0 ] + "With" ] = list
.fireWith
;
3746 // Make the deferred a promise
3747 promise
.promise( deferred
);
3749 // Call given func if any
3751 func
.call( deferred
, deferred
);
3759 when: function( singleValue
) {
3762 // count of uncompleted subordinates
3763 remaining
= arguments
.length
,
3765 // count of unprocessed arguments
3768 // subordinate fulfillment data
3769 resolveContexts
= Array( i
),
3770 resolveValues
= slice
.call( arguments
),
3772 // the master Deferred
3773 master
= jQuery
.Deferred(),
3775 // subordinate callback factory
3776 updateFunc = function( i
) {
3777 return function( value
) {
3778 resolveContexts
[ i
] = this;
3779 resolveValues
[ i
] = arguments
.length
> 1 ? slice
.call( arguments
) : value
;
3780 if ( !( --remaining
) ) {
3781 master
.resolveWith( resolveContexts
, resolveValues
);
3786 // Single- and empty arguments are adopted like Promise.resolve
3787 if ( remaining
<= 1 ) {
3788 adoptValue( singleValue
, master
.done( updateFunc( i
) ).resolve
, master
.reject
,
3791 // Use .then() to unwrap secondary thenables (cf. gh-3000)
3792 if ( master
.state() === "pending" ||
3793 isFunction( resolveValues
[ i
] && resolveValues
[ i
].then
) ) {
3795 return master
.then();
3799 // Multiple arguments are aggregated like Promise.all array elements
3801 adoptValue( resolveValues
[ i
], updateFunc( i
), master
.reject
);
3804 return master
.promise();
3809 // These usually indicate a programmer mistake during development,
3810 // warn about them ASAP rather than swallowing them by default.
3811 var rerrorNames
= /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3813 jQuery
.Deferred
.exceptionHook = function( error
, stack
) {
3815 // Support: IE 8 - 9 only
3816 // Console exists when dev tools are open, which can happen at any time
3817 if ( window
.console
&& window
.console
.warn
&& error
&& rerrorNames
.test( error
.name
) ) {
3818 window
.console
.warn( "jQuery.Deferred exception: " + error
.message
, error
.stack
, stack
);
3825 jQuery
.readyException = function( error
) {
3826 window
.setTimeout( function() {
3834 // The deferred used on DOM ready
3835 var readyList
= jQuery
.Deferred();
3837 jQuery
.fn
.ready = function( fn
) {
3842 // Wrap jQuery.readyException in a function so that the lookup
3843 // happens at the time of error handling instead of callback
3845 .catch( function( error
) {
3846 jQuery
.readyException( error
);
3854 // Is the DOM ready to be used? Set to true once it occurs.
3857 // A counter to track how many items to wait for before
3858 // the ready event fires. See #6781
3861 // Handle when the DOM is ready
3862 ready: function( wait
) {
3864 // Abort if there are pending holds or we're already ready
3865 if ( wait
=== true ? --jQuery
.readyWait
: jQuery
.isReady
) {
3869 // Remember that the DOM is ready
3870 jQuery
.isReady
= true;
3872 // If a normal DOM Ready event fired, decrement, and wait if need be
3873 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
3877 // If there are functions bound, to execute
3878 readyList
.resolveWith( document
, [ jQuery
] );
3882 jQuery
.ready
.then
= readyList
.then
;
3884 // The ready event handler and self cleanup method
3885 function completed() {
3886 document
.removeEventListener( "DOMContentLoaded", completed
);
3887 window
.removeEventListener( "load", completed
);
3891 // Catch cases where $(document).ready() is called
3892 // after the browser event has already occurred.
3893 // Support: IE <=9 - 10 only
3894 // Older IE sometimes signals "interactive" too soon
3895 if ( document
.readyState
=== "complete" ||
3896 ( document
.readyState
!== "loading" && !document
.documentElement
.doScroll
) ) {
3898 // Handle it asynchronously to allow scripts the opportunity to delay ready
3899 window
.setTimeout( jQuery
.ready
);
3903 // Use the handy event callback
3904 document
.addEventListener( "DOMContentLoaded", completed
);
3906 // A fallback to window.onload, that will always work
3907 window
.addEventListener( "load", completed
);
3913 // Multifunctional method to get and set values of a collection
3914 // The value/s can optionally be executed if it's a function
3915 var access = function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
3921 if ( toType( key
) === "object" ) {
3924 access( elems
, fn
, i
, key
[ i
], true, emptyGet
, raw
);
3928 } else if ( value
!== undefined ) {
3931 if ( !isFunction( value
) ) {
3937 // Bulk operations run against the entire set
3939 fn
.call( elems
, value
);
3942 // ...except when executing function values
3945 fn = function( elem
, key
, value
) {
3946 return bulk
.call( jQuery( elem
), value
);
3952 for ( ; i
< len
; i
++ ) {
3954 elems
[ i
], key
, raw
?
3956 value
.call( elems
[ i
], i
, fn( elems
[ i
], key
) )
3968 return fn
.call( elems
);
3971 return len
? fn( elems
[ 0 ], key
) : emptyGet
;
3975 // Matches dashed string for camelizing
3976 var rmsPrefix
= /^-ms-/,
3977 rdashAlpha
= /-([a-z])/g;
3979 // Used by camelCase as callback to replace()
3980 function fcamelCase( all
, letter
) {
3981 return letter
.toUpperCase();
3984 // Convert dashed to camelCase; used by the css and data modules
3985 // Support: IE <=9 - 11, Edge 12 - 15
3986 // Microsoft forgot to hump their vendor prefix (#9572)
3987 function camelCase( string
) {
3988 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
3990 var acceptData = function( owner
) {
3994 // - Node.ELEMENT_NODE
3995 // - Node.DOCUMENT_NODE
3998 return owner
.nodeType
=== 1 || owner
.nodeType
=== 9 || !( +owner
.nodeType
);
4005 this.expando
= jQuery
.expando
+ Data
.uid
++;
4012 cache: function( owner
) {
4014 // Check if the owner object already has a cache
4015 var value
= owner
[ this.expando
];
4017 // If not, create one
4021 // We can accept data for non-element nodes in modern browsers,
4022 // but we should not, see #8335.
4023 // Always return an empty object.
4024 if ( acceptData( owner
) ) {
4026 // If it is a node unlikely to be stringify-ed or looped over
4027 // use plain assignment
4028 if ( owner
.nodeType
) {
4029 owner
[ this.expando
] = value
;
4031 // Otherwise secure it in a non-enumerable property
4032 // configurable must be true to allow the property to be
4033 // deleted when data is removed
4035 Object
.defineProperty( owner
, this.expando
, {
4045 set: function( owner
, data
, value
) {
4047 cache
= this.cache( owner
);
4049 // Handle: [ owner, key, value ] args
4050 // Always use camelCase key (gh-2257)
4051 if ( typeof data
=== "string" ) {
4052 cache
[ camelCase( data
) ] = value
;
4054 // Handle: [ owner, { properties } ] args
4057 // Copy the properties one-by-one to the cache object
4058 for ( prop
in data
) {
4059 cache
[ camelCase( prop
) ] = data
[ prop
];
4064 get: function( owner
, key
) {
4065 return key
=== undefined ?
4066 this.cache( owner
) :
4068 // Always use camelCase key (gh-2257)
4069 owner
[ this.expando
] && owner
[ this.expando
][ camelCase( key
) ];
4071 access: function( owner
, key
, value
) {
4073 // In cases where either:
4075 // 1. No key was specified
4076 // 2. A string key was specified, but no value provided
4078 // Take the "read" path and allow the get method to determine
4079 // which value to return, respectively either:
4081 // 1. The entire cache object
4082 // 2. The data stored at the key
4084 if ( key
=== undefined ||
4085 ( ( key
&& typeof key
=== "string" ) && value
=== undefined ) ) {
4087 return this.get( owner
, key
);
4090 // When the key is not a string, or both a key and value
4091 // are specified, set or extend (existing objects) with either:
4093 // 1. An object of properties
4094 // 2. A key and value
4096 this.set( owner
, key
, value
);
4098 // Since the "set" path can have two possible entry points
4099 // return the expected data based on which path was taken[*]
4100 return value
!== undefined ? value
: key
;
4102 remove: function( owner
, key
) {
4104 cache
= owner
[ this.expando
];
4106 if ( cache
=== undefined ) {
4110 if ( key
!== undefined ) {
4112 // Support array or space separated string of keys
4113 if ( Array
.isArray( key
) ) {
4115 // If key is an array of keys...
4116 // We always set camelCase keys, so remove that.
4117 key
= key
.map( camelCase
);
4119 key
= camelCase( key
);
4121 // If a key with the spaces exists, use it.
4122 // Otherwise, create an array by matching non-whitespace
4123 key
= key
in cache
?
4125 ( key
.match( rnothtmlwhite
) || [] );
4131 delete cache
[ key
[ i
] ];
4135 // Remove the expando if there's no more data
4136 if ( key
=== undefined || jQuery
.isEmptyObject( cache
) ) {
4138 // Support: Chrome <=35 - 45
4139 // Webkit & Blink performance suffers when deleting properties
4140 // from DOM nodes, so set to undefined instead
4141 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4142 if ( owner
.nodeType
) {
4143 owner
[ this.expando
] = undefined;
4145 delete owner
[ this.expando
];
4149 hasData: function( owner
) {
4150 var cache
= owner
[ this.expando
];
4151 return cache
!== undefined && !jQuery
.isEmptyObject( cache
);
4154 var dataPriv
= new Data();
4156 var dataUser
= new Data();
4160 // Implementation Summary
4162 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4163 // 2. Improve the module's maintainability by reducing the storage
4164 // paths to a single mechanism.
4165 // 3. Use the same single mechanism to support "private" and "user" data.
4166 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4167 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4168 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4170 var rbrace
= /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4171 rmultiDash
= /[A-Z]/g;
4173 function getData( data
) {
4174 if ( data
=== "true" ) {
4178 if ( data
=== "false" ) {
4182 if ( data
=== "null" ) {
4186 // Only convert to a number if it doesn't change the string
4187 if ( data
=== +data
+ "" ) {
4191 if ( rbrace
.test( data
) ) {
4192 return JSON
.parse( data
);
4198 function dataAttr( elem
, key
, data
) {
4201 // If nothing was found internally, try to fetch any
4202 // data from the HTML5 data-* attribute
4203 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
4204 name
= "data-" + key
.replace( rmultiDash
, "-$&" ).toLowerCase();
4205 data
= elem
.getAttribute( name
);
4207 if ( typeof data
=== "string" ) {
4209 data
= getData( data
);
4212 // Make sure we set the data so it isn't changed later
4213 dataUser
.set( elem
, key
, data
);
4222 hasData: function( elem
) {
4223 return dataUser
.hasData( elem
) || dataPriv
.hasData( elem
);
4226 data: function( elem
, name
, data
) {
4227 return dataUser
.access( elem
, name
, data
);
4230 removeData: function( elem
, name
) {
4231 dataUser
.remove( elem
, name
);
4234 // TODO: Now that all calls to _data and _removeData have been replaced
4235 // with direct calls to dataPriv methods, these can be deprecated.
4236 _data: function( elem
, name
, data
) {
4237 return dataPriv
.access( elem
, name
, data
);
4240 _removeData: function( elem
, name
) {
4241 dataPriv
.remove( elem
, name
);
4246 data: function( key
, value
) {
4249 attrs
= elem
&& elem
.attributes
;
4252 if ( key
=== undefined ) {
4253 if ( this.length
) {
4254 data
= dataUser
.get( elem
);
4256 if ( elem
.nodeType
=== 1 && !dataPriv
.get( elem
, "hasDataAttrs" ) ) {
4260 // Support: IE 11 only
4261 // The attrs elements can be null (#14894)
4263 name
= attrs
[ i
].name
;
4264 if ( name
.indexOf( "data-" ) === 0 ) {
4265 name
= camelCase( name
.slice( 5 ) );
4266 dataAttr( elem
, name
, data
[ name
] );
4270 dataPriv
.set( elem
, "hasDataAttrs", true );
4277 // Sets multiple values
4278 if ( typeof key
=== "object" ) {
4279 return this.each( function() {
4280 dataUser
.set( this, key
);
4284 return access( this, function( value
) {
4287 // The calling jQuery object (element matches) is not empty
4288 // (and therefore has an element appears at this[ 0 ]) and the
4289 // `value` parameter was not undefined. An empty jQuery object
4290 // will result in `undefined` for elem = this[ 0 ] which will
4291 // throw an exception if an attempt to read a data cache is made.
4292 if ( elem
&& value
=== undefined ) {
4294 // Attempt to get data from the cache
4295 // The key will always be camelCased in Data
4296 data
= dataUser
.get( elem
, key
);
4297 if ( data
!== undefined ) {
4301 // Attempt to "discover" the data in
4302 // HTML5 custom data-* attrs
4303 data
= dataAttr( elem
, key
);
4304 if ( data
!== undefined ) {
4308 // We tried really hard, but the data doesn't exist.
4313 this.each( function() {
4315 // We always store the camelCased key
4316 dataUser
.set( this, key
, value
);
4318 }, null, value
, arguments
.length
> 1, null, true );
4321 removeData: function( key
) {
4322 return this.each( function() {
4323 dataUser
.remove( this, key
);
4330 queue: function( elem
, type
, data
) {
4334 type
= ( type
|| "fx" ) + "queue";
4335 queue
= dataPriv
.get( elem
, type
);
4337 // Speed up dequeue by getting out quickly if this is just a lookup
4339 if ( !queue
|| Array
.isArray( data
) ) {
4340 queue
= dataPriv
.access( elem
, type
, jQuery
.makeArray( data
) );
4349 dequeue: function( elem
, type
) {
4350 type
= type
|| "fx";
4352 var queue
= jQuery
.queue( elem
, type
),
4353 startLength
= queue
.length
,
4355 hooks
= jQuery
._queueHooks( elem
, type
),
4357 jQuery
.dequeue( elem
, type
);
4360 // If the fx queue is dequeued, always remove the progress sentinel
4361 if ( fn
=== "inprogress" ) {
4368 // Add a progress sentinel to prevent the fx queue from being
4369 // automatically dequeued
4370 if ( type
=== "fx" ) {
4371 queue
.unshift( "inprogress" );
4374 // Clear up the last queue stop function
4376 fn
.call( elem
, next
, hooks
);
4379 if ( !startLength
&& hooks
) {
4384 // Not public - generate a queueHooks object, or return the current one
4385 _queueHooks: function( elem
, type
) {
4386 var key
= type
+ "queueHooks";
4387 return dataPriv
.get( elem
, key
) || dataPriv
.access( elem
, key
, {
4388 empty
: jQuery
.Callbacks( "once memory" ).add( function() {
4389 dataPriv
.remove( elem
, [ type
+ "queue", key
] );
4396 queue: function( type
, data
) {
4399 if ( typeof type
!== "string" ) {
4405 if ( arguments
.length
< setter
) {
4406 return jQuery
.queue( this[ 0 ], type
);
4409 return data
=== undefined ?
4411 this.each( function() {
4412 var queue
= jQuery
.queue( this, type
, data
);
4414 // Ensure a hooks for this queue
4415 jQuery
._queueHooks( this, type
);
4417 if ( type
=== "fx" && queue
[ 0 ] !== "inprogress" ) {
4418 jQuery
.dequeue( this, type
);
4422 dequeue: function( type
) {
4423 return this.each( function() {
4424 jQuery
.dequeue( this, type
);
4427 clearQueue: function( type
) {
4428 return this.queue( type
|| "fx", [] );
4431 // Get a promise resolved when queues of a certain type
4432 // are emptied (fx is the type by default)
4433 promise: function( type
, obj
) {
4436 defer
= jQuery
.Deferred(),
4439 resolve = function() {
4440 if ( !( --count
) ) {
4441 defer
.resolveWith( elements
, [ elements
] );
4445 if ( typeof type
!== "string" ) {
4449 type
= type
|| "fx";
4452 tmp
= dataPriv
.get( elements
[ i
], type
+ "queueHooks" );
4453 if ( tmp
&& tmp
.empty
) {
4455 tmp
.empty
.add( resolve
);
4459 return defer
.promise( obj
);
4462 var pnum
= ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source
;
4464 var rcssNum
= new RegExp( "^(?:([+-])=|)(" + pnum
+ ")([a-z%]*)$", "i" );
4467 var cssExpand
= [ "Top", "Right", "Bottom", "Left" ];
4469 var isHiddenWithinTree = function( elem
, el
) {
4471 // isHiddenWithinTree might be called from jQuery#filter function;
4472 // in that case, element will be second argument
4475 // Inline style trumps all
4476 return elem
.style
.display
=== "none" ||
4477 elem
.style
.display
=== "" &&
4479 // Otherwise, check computed style
4480 // Support: Firefox <=43 - 45
4481 // Disconnected elements can have computed display: none, so first confirm that elem is
4483 jQuery
.contains( elem
.ownerDocument
, elem
) &&
4485 jQuery
.css( elem
, "display" ) === "none";
4488 var swap = function( elem
, options
, callback
, args
) {
4492 // Remember the old values, and insert the new ones
4493 for ( name
in options
) {
4494 old
[ name
] = elem
.style
[ name
];
4495 elem
.style
[ name
] = options
[ name
];
4498 ret
= callback
.apply( elem
, args
|| [] );
4500 // Revert the old values
4501 for ( name
in options
) {
4502 elem
.style
[ name
] = old
[ name
];
4511 function adjustCSS( elem
, prop
, valueParts
, tween
) {
4512 var adjusted
, scale
,
4514 currentValue
= tween
?
4519 return jQuery
.css( elem
, prop
, "" );
4521 initial
= currentValue(),
4522 unit
= valueParts
&& valueParts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
4524 // Starting value computation is required for potential unit mismatches
4525 initialInUnit
= ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +initial
) &&
4526 rcssNum
.exec( jQuery
.css( elem
, prop
) );
4528 if ( initialInUnit
&& initialInUnit
[ 3 ] !== unit
) {
4530 // Support: Firefox <=54
4531 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
4532 initial
= initial
/ 2;
4534 // Trust units reported by jQuery.css
4535 unit
= unit
|| initialInUnit
[ 3 ];
4537 // Iteratively approximate from a nonzero starting point
4538 initialInUnit
= +initial
|| 1;
4540 while ( maxIterations
-- ) {
4542 // Evaluate and update our best guess (doubling guesses that zero out).
4543 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
4544 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4545 if ( ( 1 - scale
) * ( 1 - ( scale
= currentValue() / initial
|| 0.5 ) ) <= 0 ) {
4548 initialInUnit
= initialInUnit
/ scale
;
4552 initialInUnit
= initialInUnit
* 2;
4553 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4555 // Make sure we update the tween properties later on
4556 valueParts
= valueParts
|| [];
4560 initialInUnit
= +initialInUnit
|| +initial
|| 0;
4562 // Apply relative offset (+=/-=) if specified
4563 adjusted
= valueParts
[ 1 ] ?
4564 initialInUnit
+ ( valueParts
[ 1 ] + 1 ) * valueParts
[ 2 ] :
4568 tween
.start
= initialInUnit
;
4569 tween
.end
= adjusted
;
4576 var defaultDisplayMap
= {};
4578 function getDefaultDisplay( elem
) {
4580 doc
= elem
.ownerDocument
,
4581 nodeName
= elem
.nodeName
,
4582 display
= defaultDisplayMap
[ nodeName
];
4588 temp
= doc
.body
.appendChild( doc
.createElement( nodeName
) );
4589 display
= jQuery
.css( temp
, "display" );
4591 temp
.parentNode
.removeChild( temp
);
4593 if ( display
=== "none" ) {
4596 defaultDisplayMap
[ nodeName
] = display
;
4601 function showHide( elements
, show
) {
4605 length
= elements
.length
;
4607 // Determine new display value for elements that need to change
4608 for ( ; index
< length
; index
++ ) {
4609 elem
= elements
[ index
];
4610 if ( !elem
.style
) {
4614 display
= elem
.style
.display
;
4617 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4618 // check is required in this first loop unless we have a nonempty display value (either
4619 // inline or about-to-be-restored)
4620 if ( display
=== "none" ) {
4621 values
[ index
] = dataPriv
.get( elem
, "display" ) || null;
4622 if ( !values
[ index
] ) {
4623 elem
.style
.display
= "";
4626 if ( elem
.style
.display
=== "" && isHiddenWithinTree( elem
) ) {
4627 values
[ index
] = getDefaultDisplay( elem
);
4630 if ( display
!== "none" ) {
4631 values
[ index
] = "none";
4633 // Remember what we're overwriting
4634 dataPriv
.set( elem
, "display", display
);
4639 // Set the display of the elements in a second loop to avoid constant reflow
4640 for ( index
= 0; index
< length
; index
++ ) {
4641 if ( values
[ index
] != null ) {
4642 elements
[ index
].style
.display
= values
[ index
];
4651 return showHide( this, true );
4654 return showHide( this );
4656 toggle: function( state
) {
4657 if ( typeof state
=== "boolean" ) {
4658 return state
? this.show() : this.hide();
4661 return this.each( function() {
4662 if ( isHiddenWithinTree( this ) ) {
4663 jQuery( this ).show();
4665 jQuery( this ).hide();
4670 var rcheckableType
= ( /^(?:checkbox|radio)$/i );
4672 var rtagName
= ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
4674 var rscriptType
= ( /^$|^module$|\/(?:java|ecma)script/i );
4678 // We have to close these tags to support XHTML (#13200)
4681 // Support: IE <=9 only
4682 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
4684 // XHTML parsers do not magically insert elements in the
4685 // same way that tag soup parsers do. So we cannot shorten
4686 // this by omitting <tbody> or other required elements.
4687 thead
: [ 1, "<table>", "</table>" ],
4688 col
: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4689 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
4690 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4692 _default
: [ 0, "", "" ]
4695 // Support: IE <=9 only
4696 wrapMap
.optgroup
= wrapMap
.option
;
4698 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
4699 wrapMap
.th
= wrapMap
.td
;
4702 function getAll( context
, tag
) {
4704 // Support: IE <=9 - 11 only
4705 // Use typeof to avoid zero-argument method invocation on host objects (#15151)
4708 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
4709 ret
= context
.getElementsByTagName( tag
|| "*" );
4711 } else if ( typeof context
.querySelectorAll
!== "undefined" ) {
4712 ret
= context
.querySelectorAll( tag
|| "*" );
4718 if ( tag
=== undefined || tag
&& nodeName( context
, tag
) ) {
4719 return jQuery
.merge( [ context
], ret
);
4726 // Mark scripts as having already been evaluated
4727 function setGlobalEval( elems
, refElements
) {
4731 for ( ; i
< l
; i
++ ) {
4735 !refElements
|| dataPriv
.get( refElements
[ i
], "globalEval" )
4741 var rhtml
= /<|&#?\w+;/;
4743 function buildFragment( elems
, context
, scripts
, selection
, ignored
) {
4744 var elem
, tmp
, tag
, wrap
, contains
, j
,
4745 fragment
= context
.createDocumentFragment(),
4750 for ( ; i
< l
; i
++ ) {
4753 if ( elem
|| elem
=== 0 ) {
4755 // Add nodes directly
4756 if ( toType( elem
) === "object" ) {
4758 // Support: Android <=4.0 only, PhantomJS 1 only
4759 // push.apply(_, arraylike) throws on ancient WebKit
4760 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
4762 // Convert non-html into a text node
4763 } else if ( !rhtml
.test( elem
) ) {
4764 nodes
.push( context
.createTextNode( elem
) );
4766 // Convert html into DOM nodes
4768 tmp
= tmp
|| fragment
.appendChild( context
.createElement( "div" ) );
4770 // Deserialize a standard representation
4771 tag
= ( rtagName
.exec( elem
) || [ "", "" ] )[ 1 ].toLowerCase();
4772 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
4773 tmp
.innerHTML
= wrap
[ 1 ] + jQuery
.htmlPrefilter( elem
) + wrap
[ 2 ];
4775 // Descend through wrappers to the right content
4778 tmp
= tmp
.lastChild
;
4781 // Support: Android <=4.0 only, PhantomJS 1 only
4782 // push.apply(_, arraylike) throws on ancient WebKit
4783 jQuery
.merge( nodes
, tmp
.childNodes
);
4785 // Remember the top-level container
4786 tmp
= fragment
.firstChild
;
4788 // Ensure the created nodes are orphaned (#12392)
4789 tmp
.textContent
= "";
4794 // Remove wrapper from fragment
4795 fragment
.textContent
= "";
4798 while ( ( elem
= nodes
[ i
++ ] ) ) {
4800 // Skip elements already in the context collection (trac-4087)
4801 if ( selection
&& jQuery
.inArray( elem
, selection
) > -1 ) {
4803 ignored
.push( elem
);
4808 contains
= jQuery
.contains( elem
.ownerDocument
, elem
);
4810 // Append to fragment
4811 tmp
= getAll( fragment
.appendChild( elem
), "script" );
4813 // Preserve script evaluation history
4815 setGlobalEval( tmp
);
4818 // Capture executables
4821 while ( ( elem
= tmp
[ j
++ ] ) ) {
4822 if ( rscriptType
.test( elem
.type
|| "" ) ) {
4823 scripts
.push( elem
);
4834 var fragment
= document
.createDocumentFragment(),
4835 div
= fragment
.appendChild( document
.createElement( "div" ) ),
4836 input
= document
.createElement( "input" );
4838 // Support: Android 4.0 - 4.3 only
4839 // Check state lost if the name is set (#11217)
4840 // Support: Windows Web Apps (WWA)
4841 // `name` and `type` must use .setAttribute for WWA (#14901)
4842 input
.setAttribute( "type", "radio" );
4843 input
.setAttribute( "checked", "checked" );
4844 input
.setAttribute( "name", "t" );
4846 div
.appendChild( input
);
4848 // Support: Android <=4.1 only
4849 // Older WebKit doesn't clone checked state correctly in fragments
4850 support
.checkClone
= div
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
4852 // Support: IE <=11 only
4853 // Make sure textarea (and checkbox) defaultValue is properly cloned
4854 div
.innerHTML
= "<textarea>x</textarea>";
4855 support
.noCloneChecked
= !!div
.cloneNode( true ).lastChild
.defaultValue
;
4857 var documentElement
= document
.documentElement
;
4863 rmouseEvent
= /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4864 rtypenamespace
= /^([^.]*)(?:\.(.+)|)/;
4866 function returnTrue() {
4870 function returnFalse() {
4874 // Support: IE <=9 only
4875 // See #13393 for more info
4876 function safeActiveElement() {
4878 return document
.activeElement
;
4882 function on( elem
, types
, selector
, data
, fn
, one
) {
4885 // Types can be a map of types/handlers
4886 if ( typeof types
=== "object" ) {
4888 // ( types-Object, selector, data )
4889 if ( typeof selector
!== "string" ) {
4891 // ( types-Object, data )
4892 data
= data
|| selector
;
4893 selector
= undefined;
4895 for ( type
in types
) {
4896 on( elem
, type
, selector
, data
, types
[ type
], one
);
4901 if ( data
== null && fn
== null ) {
4905 data
= selector
= undefined;
4906 } else if ( fn
== null ) {
4907 if ( typeof selector
=== "string" ) {
4909 // ( types, selector, fn )
4914 // ( types, data, fn )
4917 selector
= undefined;
4920 if ( fn
=== false ) {
4928 fn = function( event
) {
4930 // Can use an empty set, since event contains the info
4931 jQuery().off( event
);
4932 return origFn
.apply( this, arguments
);
4935 // Use same guid so caller can remove using origFn
4936 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
4938 return elem
.each( function() {
4939 jQuery
.event
.add( this, types
, fn
, data
, selector
);
4944 * Helper functions for managing events -- not part of the public interface.
4945 * Props to Dean Edwards' addEvent library for many of the ideas.
4951 add: function( elem
, types
, handler
, data
, selector
) {
4953 var handleObjIn
, eventHandle
, tmp
,
4954 events
, t
, handleObj
,
4955 special
, handlers
, type
, namespaces
, origType
,
4956 elemData
= dataPriv
.get( elem
);
4958 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4963 // Caller can pass in an object of custom data in lieu of the handler
4964 if ( handler
.handler
) {
4965 handleObjIn
= handler
;
4966 handler
= handleObjIn
.handler
;
4967 selector
= handleObjIn
.selector
;
4970 // Ensure that invalid selectors throw exceptions at attach time
4971 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
4973 jQuery
.find
.matchesSelector( documentElement
, selector
);
4976 // Make sure that the handler has a unique ID, used to find/remove it later
4977 if ( !handler
.guid
) {
4978 handler
.guid
= jQuery
.guid
++;
4981 // Init the element's event structure and main handler, if this is the first
4982 if ( !( events
= elemData
.events
) ) {
4983 events
= elemData
.events
= {};
4985 if ( !( eventHandle
= elemData
.handle
) ) {
4986 eventHandle
= elemData
.handle = function( e
) {
4988 // Discard the second event of a jQuery.event.trigger() and
4989 // when an event is called after a page has unloaded
4990 return typeof jQuery
!== "undefined" && jQuery
.event
.triggered
!== e
.type
?
4991 jQuery
.event
.dispatch
.apply( elem
, arguments
) : undefined;
4995 // Handle multiple events separated by a space
4996 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
4999 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5000 type
= origType
= tmp
[ 1 ];
5001 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5003 // There *must* be a type, no attaching namespace-only handlers
5008 // If event changes its type, use the special event handlers for the changed type
5009 special
= jQuery
.event
.special
[ type
] || {};
5011 // If selector defined, determine special event api type, otherwise given type
5012 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
5014 // Update special based on newly reset type
5015 special
= jQuery
.event
.special
[ type
] || {};
5017 // handleObj is passed to all event handlers
5018 handleObj
= jQuery
.extend( {
5025 needsContext
: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
5026 namespace: namespaces
.join( "." )
5029 // Init the event handler queue if we're the first
5030 if ( !( handlers
= events
[ type
] ) ) {
5031 handlers
= events
[ type
] = [];
5032 handlers
.delegateCount
= 0;
5034 // Only use addEventListener if the special events handler returns false
5035 if ( !special
.setup
||
5036 special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
5038 if ( elem
.addEventListener
) {
5039 elem
.addEventListener( type
, eventHandle
);
5044 if ( special
.add
) {
5045 special
.add
.call( elem
, handleObj
);
5047 if ( !handleObj
.handler
.guid
) {
5048 handleObj
.handler
.guid
= handler
.guid
;
5052 // Add to the element's handler list, delegates in front
5054 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
5056 handlers
.push( handleObj
);
5059 // Keep track of which events have ever been used, for event optimization
5060 jQuery
.event
.global
[ type
] = true;
5065 // Detach an event or set of events from an element
5066 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
5068 var j
, origCount
, tmp
,
5069 events
, t
, handleObj
,
5070 special
, handlers
, type
, namespaces
, origType
,
5071 elemData
= dataPriv
.hasData( elem
) && dataPriv
.get( elem
);
5073 if ( !elemData
|| !( events
= elemData
.events
) ) {
5077 // Once for each type.namespace in types; type may be omitted
5078 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5081 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5082 type
= origType
= tmp
[ 1 ];
5083 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5085 // Unbind all events (on this namespace, if provided) for the element
5087 for ( type
in events
) {
5088 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
5093 special
= jQuery
.event
.special
[ type
] || {};
5094 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
5095 handlers
= events
[ type
] || [];
5097 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5099 // Remove matching events
5100 origCount
= j
= handlers
.length
;
5102 handleObj
= handlers
[ j
];
5104 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
5105 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
5106 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
5107 ( !selector
|| selector
=== handleObj
.selector
||
5108 selector
=== "**" && handleObj
.selector
) ) {
5109 handlers
.splice( j
, 1 );
5111 if ( handleObj
.selector
) {
5112 handlers
.delegateCount
--;
5114 if ( special
.remove
) {
5115 special
.remove
.call( elem
, handleObj
);
5120 // Remove generic event handler if we removed something and no more handlers exist
5121 // (avoids potential for endless recursion during removal of special event handlers)
5122 if ( origCount
&& !handlers
.length
) {
5123 if ( !special
.teardown
||
5124 special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
5126 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
5129 delete events
[ type
];
5133 // Remove data and the expando if it's no longer used
5134 if ( jQuery
.isEmptyObject( events
) ) {
5135 dataPriv
.remove( elem
, "handle events" );
5139 dispatch: function( nativeEvent
) {
5141 // Make a writable jQuery.Event from the native event object
5142 var event
= jQuery
.event
.fix( nativeEvent
);
5144 var i
, j
, ret
, matched
, handleObj
, handlerQueue
,
5145 args
= new Array( arguments
.length
),
5146 handlers
= ( dataPriv
.get( this, "events" ) || {} )[ event
.type
] || [],
5147 special
= jQuery
.event
.special
[ event
.type
] || {};
5149 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5152 for ( i
= 1; i
< arguments
.length
; i
++ ) {
5153 args
[ i
] = arguments
[ i
];
5156 event
.delegateTarget
= this;
5158 // Call the preDispatch hook for the mapped type, and let it bail if desired
5159 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
5163 // Determine handlers
5164 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
5166 // Run delegates first; they may want to stop propagation beneath us
5168 while ( ( matched
= handlerQueue
[ i
++ ] ) && !event
.isPropagationStopped() ) {
5169 event
.currentTarget
= matched
.elem
;
5172 while ( ( handleObj
= matched
.handlers
[ j
++ ] ) &&
5173 !event
.isImmediatePropagationStopped() ) {
5175 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5176 // a subset or equal to those in the bound event (both can have no namespace).
5177 if ( !event
.rnamespace
|| event
.rnamespace
.test( handleObj
.namespace ) ) {
5179 event
.handleObj
= handleObj
;
5180 event
.data
= handleObj
.data
;
5182 ret
= ( ( jQuery
.event
.special
[ handleObj
.origType
] || {} ).handle
||
5183 handleObj
.handler
).apply( matched
.elem
, args
);
5185 if ( ret
!== undefined ) {
5186 if ( ( event
.result
= ret
) === false ) {
5187 event
.preventDefault();
5188 event
.stopPropagation();
5195 // Call the postDispatch hook for the mapped type
5196 if ( special
.postDispatch
) {
5197 special
.postDispatch
.call( this, event
);
5200 return event
.result
;
5203 handlers: function( event
, handlers
) {
5204 var i
, handleObj
, sel
, matchedHandlers
, matchedSelectors
,
5206 delegateCount
= handlers
.delegateCount
,
5209 // Find delegate handlers
5210 if ( delegateCount
&&
5213 // Black-hole SVG <use> instance trees (trac-13180)
5216 // Support: Firefox <=42
5217 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5218 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5219 // Support: IE 11 only
5220 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5221 !( event
.type
=== "click" && event
.button
>= 1 ) ) {
5223 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
5225 // Don't check non-elements (#13208)
5226 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5227 if ( cur
.nodeType
=== 1 && !( event
.type
=== "click" && cur
.disabled
=== true ) ) {
5228 matchedHandlers
= [];
5229 matchedSelectors
= {};
5230 for ( i
= 0; i
< delegateCount
; i
++ ) {
5231 handleObj
= handlers
[ i
];
5233 // Don't conflict with Object.prototype properties (#13203)
5234 sel
= handleObj
.selector
+ " ";
5236 if ( matchedSelectors
[ sel
] === undefined ) {
5237 matchedSelectors
[ sel
] = handleObj
.needsContext
?
5238 jQuery( sel
, this ).index( cur
) > -1 :
5239 jQuery
.find( sel
, this, null, [ cur
] ).length
;
5241 if ( matchedSelectors
[ sel
] ) {
5242 matchedHandlers
.push( handleObj
);
5245 if ( matchedHandlers
.length
) {
5246 handlerQueue
.push( { elem
: cur
, handlers
: matchedHandlers
} );
5252 // Add the remaining (directly-bound) handlers
5254 if ( delegateCount
< handlers
.length
) {
5255 handlerQueue
.push( { elem
: cur
, handlers
: handlers
.slice( delegateCount
) } );
5258 return handlerQueue
;
5261 addProp: function( name
, hook
) {
5262 Object
.defineProperty( jQuery
.Event
.prototype, name
, {
5266 get: isFunction( hook
) ?
5268 if ( this.originalEvent
) {
5269 return hook( this.originalEvent
);
5273 if ( this.originalEvent
) {
5274 return this.originalEvent
[ name
];
5278 set: function( value
) {
5279 Object
.defineProperty( this, name
, {
5289 fix: function( originalEvent
) {
5290 return originalEvent
[ jQuery
.expando
] ?
5292 new jQuery
.Event( originalEvent
);
5298 // Prevent triggered image.load events from bubbling to window.load
5303 // Fire native event if possible so blur/focus sequence is correct
5304 trigger: function() {
5305 if ( this !== safeActiveElement() && this.focus
) {
5310 delegateType
: "focusin"
5313 trigger: function() {
5314 if ( this === safeActiveElement() && this.blur
) {
5319 delegateType
: "focusout"
5323 // For checkbox, fire native event so checked state will be right
5324 trigger: function() {
5325 if ( this.type
=== "checkbox" && this.click
&& nodeName( this, "input" ) ) {
5331 // For cross-browser consistency, don't fire native .click() on links
5332 _default: function( event
) {
5333 return nodeName( event
.target
, "a" );
5338 postDispatch: function( event
) {
5340 // Support: Firefox 20+
5341 // Firefox doesn't alert if the returnValue field is not set.
5342 if ( event
.result
!== undefined && event
.originalEvent
) {
5343 event
.originalEvent
.returnValue
= event
.result
;
5350 jQuery
.removeEvent = function( elem
, type
, handle
) {
5352 // This "if" is needed for plain objects
5353 if ( elem
.removeEventListener
) {
5354 elem
.removeEventListener( type
, handle
);
5358 jQuery
.Event = function( src
, props
) {
5360 // Allow instantiation without the 'new' keyword
5361 if ( !( this instanceof jQuery
.Event
) ) {
5362 return new jQuery
.Event( src
, props
);
5366 if ( src
&& src
.type
) {
5367 this.originalEvent
= src
;
5368 this.type
= src
.type
;
5370 // Events bubbling up the document may have been marked as prevented
5371 // by a handler lower down the tree; reflect the correct value.
5372 this.isDefaultPrevented
= src
.defaultPrevented
||
5373 src
.defaultPrevented
=== undefined &&
5375 // Support: Android <=2.3 only
5376 src
.returnValue
=== false ?
5380 // Create target properties
5381 // Support: Safari <=6 - 7 only
5382 // Target should not be a text node (#504, #13143)
5383 this.target
= ( src
.target
&& src
.target
.nodeType
=== 3 ) ?
5384 src
.target
.parentNode
:
5387 this.currentTarget
= src
.currentTarget
;
5388 this.relatedTarget
= src
.relatedTarget
;
5395 // Put explicitly provided properties onto the event object
5397 jQuery
.extend( this, props
);
5400 // Create a timestamp if incoming event doesn't have one
5401 this.timeStamp
= src
&& src
.timeStamp
|| Date
.now();
5404 this[ jQuery
.expando
] = true;
5407 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5408 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5409 jQuery
.Event
.prototype = {
5410 constructor: jQuery
.Event
,
5411 isDefaultPrevented
: returnFalse
,
5412 isPropagationStopped
: returnFalse
,
5413 isImmediatePropagationStopped
: returnFalse
,
5416 preventDefault: function() {
5417 var e
= this.originalEvent
;
5419 this.isDefaultPrevented
= returnTrue
;
5421 if ( e
&& !this.isSimulated
) {
5425 stopPropagation: function() {
5426 var e
= this.originalEvent
;
5428 this.isPropagationStopped
= returnTrue
;
5430 if ( e
&& !this.isSimulated
) {
5431 e
.stopPropagation();
5434 stopImmediatePropagation: function() {
5435 var e
= this.originalEvent
;
5437 this.isImmediatePropagationStopped
= returnTrue
;
5439 if ( e
&& !this.isSimulated
) {
5440 e
.stopImmediatePropagation();
5443 this.stopPropagation();
5447 // Includes all common event props including KeyEvent and MouseEvent specific props
5452 changedTouches
: true,
5475 targetTouches
: true,
5479 which: function( event
) {
5480 var button
= event
.button
;
5482 // Add which for key events
5483 if ( event
.which
== null && rkeyEvent
.test( event
.type
) ) {
5484 return event
.charCode
!= null ? event
.charCode
: event
.keyCode
;
5487 // Add which for click: 1 === left; 2 === middle; 3 === right
5488 if ( !event
.which
&& button
!== undefined && rmouseEvent
.test( event
.type
) ) {
5506 }, jQuery
.event
.addProp
);
5508 // Create mouseenter/leave events using mouseover/out and event-time checks
5509 // so that event delegation works in jQuery.
5510 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5512 // Support: Safari 7 only
5513 // Safari sends mouseenter too often; see:
5514 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5515 // for the description of the bug (it existed in older Chrome versions as well).
5517 mouseenter
: "mouseover",
5518 mouseleave
: "mouseout",
5519 pointerenter
: "pointerover",
5520 pointerleave
: "pointerout"
5521 }, function( orig
, fix
) {
5522 jQuery
.event
.special
[ orig
] = {
5526 handle: function( event
) {
5529 related
= event
.relatedTarget
,
5530 handleObj
= event
.handleObj
;
5532 // For mouseenter/leave call the handler if related is outside the target.
5533 // NB: No relatedTarget if the mouse left/entered the browser window
5534 if ( !related
|| ( related
!== target
&& !jQuery
.contains( target
, related
) ) ) {
5535 event
.type
= handleObj
.origType
;
5536 ret
= handleObj
.handler
.apply( this, arguments
);
5546 on: function( types
, selector
, data
, fn
) {
5547 return on( this, types
, selector
, data
, fn
);
5549 one: function( types
, selector
, data
, fn
) {
5550 return on( this, types
, selector
, data
, fn
, 1 );
5552 off: function( types
, selector
, fn
) {
5553 var handleObj
, type
;
5554 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
5556 // ( event ) dispatched jQuery.Event
5557 handleObj
= types
.handleObj
;
5558 jQuery( types
.delegateTarget
).off(
5559 handleObj
.namespace ?
5560 handleObj
.origType
+ "." + handleObj
.namespace :
5567 if ( typeof types
=== "object" ) {
5569 // ( types-object [, selector] )
5570 for ( type
in types
) {
5571 this.off( type
, selector
, types
[ type
] );
5575 if ( selector
=== false || typeof selector
=== "function" ) {
5579 selector
= undefined;
5581 if ( fn
=== false ) {
5584 return this.each( function() {
5585 jQuery
.event
.remove( this, types
, fn
, selector
);
5593 /* eslint-disable max-len */
5595 // See https://github.com/eslint/eslint/issues/3229
5596 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
5600 // Support: IE <=10 - 11, Edge 12 - 13 only
5601 // In IE/Edge using regex groups here causes severe slowdowns.
5602 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5603 rnoInnerhtml
= /<script|<style|<link/i,
5605 // checked="checked" or checked
5606 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5607 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5609 // Prefer a tbody over its parent table for containing new rows
5610 function manipulationTarget( elem
, content
) {
5611 if ( nodeName( elem
, "table" ) &&
5612 nodeName( content
.nodeType
!== 11 ? content
: content
.firstChild
, "tr" ) ) {
5614 return jQuery( elem
).children( "tbody" )[ 0 ] || elem
;
5620 // Replace/restore the type attribute of script elements for safe DOM manipulation
5621 function disableScript( elem
) {
5622 elem
.type
= ( elem
.getAttribute( "type" ) !== null ) + "/" + elem
.type
;
5625 function restoreScript( elem
) {
5626 if ( ( elem
.type
|| "" ).slice( 0, 5 ) === "true/" ) {
5627 elem
.type
= elem
.type
.slice( 5 );
5629 elem
.removeAttribute( "type" );
5635 function cloneCopyEvent( src
, dest
) {
5636 var i
, l
, type
, pdataOld
, pdataCur
, udataOld
, udataCur
, events
;
5638 if ( dest
.nodeType
!== 1 ) {
5642 // 1. Copy private data: events, handlers, etc.
5643 if ( dataPriv
.hasData( src
) ) {
5644 pdataOld
= dataPriv
.access( src
);
5645 pdataCur
= dataPriv
.set( dest
, pdataOld
);
5646 events
= pdataOld
.events
;
5649 delete pdataCur
.handle
;
5650 pdataCur
.events
= {};
5652 for ( type
in events
) {
5653 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
5654 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
5660 // 2. Copy user data
5661 if ( dataUser
.hasData( src
) ) {
5662 udataOld
= dataUser
.access( src
);
5663 udataCur
= jQuery
.extend( {}, udataOld
);
5665 dataUser
.set( dest
, udataCur
);
5669 // Fix IE bugs, see support tests
5670 function fixInput( src
, dest
) {
5671 var nodeName
= dest
.nodeName
.toLowerCase();
5673 // Fails to persist the checked state of a cloned checkbox or radio button.
5674 if ( nodeName
=== "input" && rcheckableType
.test( src
.type
) ) {
5675 dest
.checked
= src
.checked
;
5677 // Fails to return the selected option to the default selected state when cloning options
5678 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
5679 dest
.defaultValue
= src
.defaultValue
;
5683 function domManip( collection
, args
, callback
, ignored
) {
5685 // Flatten any nested arrays
5686 args
= concat
.apply( [], args
);
5688 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
5690 l
= collection
.length
,
5693 valueIsFunction
= isFunction( value
);
5695 // We can't cloneNode fragments that contain checked, in WebKit
5696 if ( valueIsFunction
||
5697 ( l
> 1 && typeof value
=== "string" &&
5698 !support
.checkClone
&& rchecked
.test( value
) ) ) {
5699 return collection
.each( function( index
) {
5700 var self
= collection
.eq( index
);
5701 if ( valueIsFunction
) {
5702 args
[ 0 ] = value
.call( this, index
, self
.html() );
5704 domManip( self
, args
, callback
, ignored
);
5709 fragment
= buildFragment( args
, collection
[ 0 ].ownerDocument
, false, collection
, ignored
);
5710 first
= fragment
.firstChild
;
5712 if ( fragment
.childNodes
.length
=== 1 ) {
5716 // Require either new content or an interest in ignored elements to invoke the callback
5717 if ( first
|| ignored
) {
5718 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
5719 hasScripts
= scripts
.length
;
5721 // Use the original fragment for the last item
5722 // instead of the first because it can end up
5723 // being emptied incorrectly in certain situations (#8070).
5724 for ( ; i
< l
; i
++ ) {
5727 if ( i
!== iNoClone
) {
5728 node
= jQuery
.clone( node
, true, true );
5730 // Keep references to cloned scripts for later restoration
5733 // Support: Android <=4.0 only, PhantomJS 1 only
5734 // push.apply(_, arraylike) throws on ancient WebKit
5735 jQuery
.merge( scripts
, getAll( node
, "script" ) );
5739 callback
.call( collection
[ i
], node
, i
);
5743 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
5746 jQuery
.map( scripts
, restoreScript
);
5748 // Evaluate executable scripts on first document insertion
5749 for ( i
= 0; i
< hasScripts
; i
++ ) {
5750 node
= scripts
[ i
];
5751 if ( rscriptType
.test( node
.type
|| "" ) &&
5752 !dataPriv
.access( node
, "globalEval" ) &&
5753 jQuery
.contains( doc
, node
) ) {
5755 if ( node
.src
&& ( node
.type
|| "" ).toLowerCase() !== "module" ) {
5757 // Optional AJAX dependency, but won't run scripts if not present
5758 if ( jQuery
._evalUrl
) {
5759 jQuery
._evalUrl( node
.src
);
5762 DOMEval( node
.textContent
.replace( rcleanScript
, "" ), doc
, node
);
5773 function remove( elem
, selector
, keepData
) {
5775 nodes
= selector
? jQuery
.filter( selector
, elem
) : elem
,
5778 for ( ; ( node
= nodes
[ i
] ) != null; i
++ ) {
5779 if ( !keepData
&& node
.nodeType
=== 1 ) {
5780 jQuery
.cleanData( getAll( node
) );
5783 if ( node
.parentNode
) {
5784 if ( keepData
&& jQuery
.contains( node
.ownerDocument
, node
) ) {
5785 setGlobalEval( getAll( node
, "script" ) );
5787 node
.parentNode
.removeChild( node
);
5795 htmlPrefilter: function( html
) {
5796 return html
.replace( rxhtmlTag
, "<$1></$2>" );
5799 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
5800 var i
, l
, srcElements
, destElements
,
5801 clone
= elem
.cloneNode( true ),
5802 inPage
= jQuery
.contains( elem
.ownerDocument
, elem
);
5804 // Fix IE cloning issues
5805 if ( !support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) &&
5806 !jQuery
.isXMLDoc( elem
) ) {
5808 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
5809 destElements
= getAll( clone
);
5810 srcElements
= getAll( elem
);
5812 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5813 fixInput( srcElements
[ i
], destElements
[ i
] );
5817 // Copy the events from the original to the clone
5818 if ( dataAndEvents
) {
5819 if ( deepDataAndEvents
) {
5820 srcElements
= srcElements
|| getAll( elem
);
5821 destElements
= destElements
|| getAll( clone
);
5823 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5824 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
5827 cloneCopyEvent( elem
, clone
);
5831 // Preserve script evaluation history
5832 destElements
= getAll( clone
, "script" );
5833 if ( destElements
.length
> 0 ) {
5834 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
5837 // Return the cloned set
5841 cleanData: function( elems
) {
5842 var data
, elem
, type
,
5843 special
= jQuery
.event
.special
,
5846 for ( ; ( elem
= elems
[ i
] ) !== undefined; i
++ ) {
5847 if ( acceptData( elem
) ) {
5848 if ( ( data
= elem
[ dataPriv
.expando
] ) ) {
5849 if ( data
.events
) {
5850 for ( type
in data
.events
) {
5851 if ( special
[ type
] ) {
5852 jQuery
.event
.remove( elem
, type
);
5854 // This is a shortcut to avoid jQuery.event.remove's overhead
5856 jQuery
.removeEvent( elem
, type
, data
.handle
);
5861 // Support: Chrome <=35 - 45+
5862 // Assign undefined instead of using delete, see Data#remove
5863 elem
[ dataPriv
.expando
] = undefined;
5865 if ( elem
[ dataUser
.expando
] ) {
5867 // Support: Chrome <=35 - 45+
5868 // Assign undefined instead of using delete, see Data#remove
5869 elem
[ dataUser
.expando
] = undefined;
5877 detach: function( selector
) {
5878 return remove( this, selector
, true );
5881 remove: function( selector
) {
5882 return remove( this, selector
);
5885 text: function( value
) {
5886 return access( this, function( value
) {
5887 return value
=== undefined ?
5888 jQuery
.text( this ) :
5889 this.empty().each( function() {
5890 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5891 this.textContent
= value
;
5894 }, null, value
, arguments
.length
);
5897 append: function() {
5898 return domManip( this, arguments
, function( elem
) {
5899 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5900 var target
= manipulationTarget( this, elem
);
5901 target
.appendChild( elem
);
5906 prepend: function() {
5907 return domManip( this, arguments
, function( elem
) {
5908 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5909 var target
= manipulationTarget( this, elem
);
5910 target
.insertBefore( elem
, target
.firstChild
);
5915 before: function() {
5916 return domManip( this, arguments
, function( elem
) {
5917 if ( this.parentNode
) {
5918 this.parentNode
.insertBefore( elem
, this );
5924 return domManip( this, arguments
, function( elem
) {
5925 if ( this.parentNode
) {
5926 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5935 for ( ; ( elem
= this[ i
] ) != null; i
++ ) {
5936 if ( elem
.nodeType
=== 1 ) {
5938 // Prevent memory leaks
5939 jQuery
.cleanData( getAll( elem
, false ) );
5941 // Remove any remaining nodes
5942 elem
.textContent
= "";
5949 clone: function( dataAndEvents
, deepDataAndEvents
) {
5950 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5951 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents
: deepDataAndEvents
;
5953 return this.map( function() {
5954 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5958 html: function( value
) {
5959 return access( this, function( value
) {
5960 var elem
= this[ 0 ] || {},
5964 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
5965 return elem
.innerHTML
;
5968 // See if we can take a shortcut and just use innerHTML
5969 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5970 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5972 value
= jQuery
.htmlPrefilter( value
);
5975 for ( ; i
< l
; i
++ ) {
5976 elem
= this[ i
] || {};
5978 // Remove element nodes and prevent memory leaks
5979 if ( elem
.nodeType
=== 1 ) {
5980 jQuery
.cleanData( getAll( elem
, false ) );
5981 elem
.innerHTML
= value
;
5987 // If using innerHTML throws an exception, use the fallback method
5992 this.empty().append( value
);
5994 }, null, value
, arguments
.length
);
5997 replaceWith: function() {
6000 // Make the changes, replacing each non-ignored context element with the new content
6001 return domManip( this, arguments
, function( elem
) {
6002 var parent
= this.parentNode
;
6004 if ( jQuery
.inArray( this, ignored
) < 0 ) {
6005 jQuery
.cleanData( getAll( this ) );
6007 parent
.replaceChild( elem
, this );
6011 // Force callback invocation
6018 prependTo
: "prepend",
6019 insertBefore
: "before",
6020 insertAfter
: "after",
6021 replaceAll
: "replaceWith"
6022 }, function( name
, original
) {
6023 jQuery
.fn
[ name
] = function( selector
) {
6026 insert
= jQuery( selector
),
6027 last
= insert
.length
- 1,
6030 for ( ; i
<= last
; i
++ ) {
6031 elems
= i
=== last
? this : this.clone( true );
6032 jQuery( insert
[ i
] )[ original
]( elems
);
6034 // Support: Android <=4.0 only, PhantomJS 1 only
6035 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6036 push
.apply( ret
, elems
.get() );
6039 return this.pushStack( ret
);
6042 var rnumnonpx
= new RegExp( "^(" + pnum
+ ")(?!px)[a-z%]+$", "i" );
6044 var getStyles = function( elem
) {
6046 // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
6047 // IE throws on elements created in popups
6048 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6049 var view
= elem
.ownerDocument
.defaultView
;
6051 if ( !view
|| !view
.opener
) {
6055 return view
.getComputedStyle( elem
);
6058 var rboxStyle
= new RegExp( cssExpand
.join( "|" ), "i" );
6064 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6065 // so they're executed at the same time to save the second computation.
6066 function computeStyleTests() {
6068 // This is a singleton, we need to execute it only once
6073 container
.style
.cssText
= "position:absolute;left:-11111px;width:60px;" +
6074 "margin-top:1px;padding:0;border:0";
6076 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
6077 "margin:auto;border:1px;padding:1px;" +
6079 documentElement
.appendChild( container
).appendChild( div
);
6081 var divStyle
= window
.getComputedStyle( div
);
6082 pixelPositionVal
= divStyle
.top
!== "1%";
6084 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6085 reliableMarginLeftVal
= roundPixelMeasures( divStyle
.marginLeft
) === 12;
6087 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
6088 // Some styles come back with percentage values, even though they shouldn't
6089 div
.style
.right
= "60%";
6090 pixelBoxStylesVal
= roundPixelMeasures( divStyle
.right
) === 36;
6092 // Support: IE 9 - 11 only
6093 // Detect misreporting of content dimensions for box-sizing:border-box elements
6094 boxSizingReliableVal
= roundPixelMeasures( divStyle
.width
) === 36;
6096 // Support: IE 9 only
6097 // Detect overflow:scroll screwiness (gh-3699)
6098 div
.style
.position
= "absolute";
6099 scrollboxSizeVal
= div
.offsetWidth
=== 36 || "absolute";
6101 documentElement
.removeChild( container
);
6103 // Nullify the div so it wouldn't be stored in the memory and
6104 // it will also be a sign that checks already performed
6108 function roundPixelMeasures( measure
) {
6109 return Math
.round( parseFloat( measure
) );
6112 var pixelPositionVal
, boxSizingReliableVal
, scrollboxSizeVal
, pixelBoxStylesVal
,
6113 reliableMarginLeftVal
,
6114 container
= document
.createElement( "div" ),
6115 div
= document
.createElement( "div" );
6117 // Finish early in limited (non-browser) environments
6122 // Support: IE <=9 - 11 only
6123 // Style of cloned element affects source element cloned (#8908)
6124 div
.style
.backgroundClip
= "content-box";
6125 div
.cloneNode( true ).style
.backgroundClip
= "";
6126 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
6128 jQuery
.extend( support
, {
6129 boxSizingReliable: function() {
6130 computeStyleTests();
6131 return boxSizingReliableVal
;
6133 pixelBoxStyles: function() {
6134 computeStyleTests();
6135 return pixelBoxStylesVal
;
6137 pixelPosition: function() {
6138 computeStyleTests();
6139 return pixelPositionVal
;
6141 reliableMarginLeft: function() {
6142 computeStyleTests();
6143 return reliableMarginLeftVal
;
6145 scrollboxSize: function() {
6146 computeStyleTests();
6147 return scrollboxSizeVal
;
6153 function curCSS( elem
, name
, computed
) {
6154 var width
, minWidth
, maxWidth
, ret
,
6156 // Support: Firefox 51+
6157 // Retrieving style before computed somehow
6158 // fixes an issue with getting wrong values
6159 // on detached elements
6162 computed
= computed
|| getStyles( elem
);
6164 // getPropertyValue is needed for:
6165 // .css('filter') (IE 9 only, #12537)
6166 // .css('--customProperty) (#3144)
6168 ret
= computed
.getPropertyValue( name
) || computed
[ name
];
6170 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
, elem
) ) {
6171 ret
= jQuery
.style( elem
, name
);
6174 // A tribute to the "awesome hack by Dean Edwards"
6175 // Android Browser returns percentage for some values,
6176 // but width seems to be reliably pixels.
6177 // This is against the CSSOM draft spec:
6178 // https://drafts.csswg.org/cssom/#resolved-values
6179 if ( !support
.pixelBoxStyles() && rnumnonpx
.test( ret
) && rboxStyle
.test( name
) ) {
6181 // Remember the original values
6182 width
= style
.width
;
6183 minWidth
= style
.minWidth
;
6184 maxWidth
= style
.maxWidth
;
6186 // Put in the new values to get a computed value out
6187 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
6188 ret
= computed
.width
;
6190 // Revert the changed values
6191 style
.width
= width
;
6192 style
.minWidth
= minWidth
;
6193 style
.maxWidth
= maxWidth
;
6197 return ret
!== undefined ?
6199 // Support: IE <=9 - 11 only
6200 // IE returns zIndex value as an integer.
6206 function addGetHookIf( conditionFn
, hookFn
) {
6208 // Define the hook, we'll check on the first run if it's really needed.
6211 if ( conditionFn() ) {
6213 // Hook not needed (or it's not possible to use it due
6214 // to missing dependency), remove it.
6219 // Hook needed; redefine it so that the support test is not executed again.
6220 return ( this.get = hookFn
).apply( this, arguments
);
6228 // Swappable if display is none or starts with table
6229 // except "table", "table-cell", or "table-caption"
6230 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6231 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
6232 rcustomProp
= /^--/,
6233 cssShow
= { position
: "absolute", visibility
: "hidden", display
: "block" },
6234 cssNormalTransform
= {
6239 cssPrefixes
= [ "Webkit", "Moz", "ms" ],
6240 emptyStyle
= document
.createElement( "div" ).style
;
6242 // Return a css property mapped to a potentially vendor prefixed property
6243 function vendorPropName( name
) {
6245 // Shortcut for names that are not vendor prefixed
6246 if ( name
in emptyStyle
) {
6250 // Check for vendor prefixed names
6251 var capName
= name
[ 0 ].toUpperCase() + name
.slice( 1 ),
6252 i
= cssPrefixes
.length
;
6255 name
= cssPrefixes
[ i
] + capName
;
6256 if ( name
in emptyStyle
) {
6262 // Return a property mapped along what jQuery.cssProps suggests or to
6263 // a vendor prefixed property.
6264 function finalPropName( name
) {
6265 var ret
= jQuery
.cssProps
[ name
];
6267 ret
= jQuery
.cssProps
[ name
] = vendorPropName( name
) || name
;
6272 function setPositiveNumber( elem
, value
, subtract
) {
6274 // Any relative (+/-) values have already been
6275 // normalized at this point
6276 var matches
= rcssNum
.exec( value
);
6279 // Guard against undefined "subtract", e.g., when used as in cssHooks
6280 Math
.max( 0, matches
[ 2 ] - ( subtract
|| 0 ) ) + ( matches
[ 3 ] || "px" ) :
6284 function boxModelAdjustment( elem
, dimension
, box
, isBorderBox
, styles
, computedVal
) {
6285 var i
= dimension
=== "width" ? 1 : 0,
6289 // Adjustment may not be necessary
6290 if ( box
=== ( isBorderBox
? "border" : "content" ) ) {
6294 for ( ; i
< 4; i
+= 2 ) {
6296 // Both box models exclude margin
6297 if ( box
=== "margin" ) {
6298 delta
+= jQuery
.css( elem
, box
+ cssExpand
[ i
], true, styles
);
6301 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6302 if ( !isBorderBox
) {
6305 delta
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6307 // For "border" or "margin", add border
6308 if ( box
!== "padding" ) {
6309 delta
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6311 // But still keep track of it otherwise
6313 extra
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6316 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6317 // "padding" or "margin"
6320 // For "content", subtract padding
6321 if ( box
=== "content" ) {
6322 delta
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6325 // For "content" or "padding", subtract border
6326 if ( box
!== "margin" ) {
6327 delta
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6332 // Account for positive content-box scroll gutter when requested by providing computedVal
6333 if ( !isBorderBox
&& computedVal
>= 0 ) {
6335 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6336 // Assuming integer scroll gutter, subtract the rest and round down
6337 delta
+= Math
.max( 0, Math
.ceil(
6338 elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ] -
6349 function getWidthOrHeight( elem
, dimension
, extra
) {
6351 // Start with computed style
6352 var styles
= getStyles( elem
),
6353 val
= curCSS( elem
, dimension
, styles
),
6354 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6355 valueIsBorderBox
= isBorderBox
;
6357 // Support: Firefox <=54
6358 // Return a confounding non-pixel value or feign ignorance, as appropriate.
6359 if ( rnumnonpx
.test( val
) ) {
6366 // Check for style in case a browser which returns unreliable values
6367 // for getComputedStyle silently falls back to the reliable elem.style
6368 valueIsBorderBox
= valueIsBorderBox
&&
6369 ( support
.boxSizingReliable() || val
=== elem
.style
[ dimension
] );
6371 // Fall back to offsetWidth/offsetHeight when value is "auto"
6372 // This happens for inline elements with no explicit setting (gh-3571)
6373 // Support: Android <=4.1 - 4.3 only
6374 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
6375 if ( val
=== "auto" ||
6376 !parseFloat( val
) && jQuery
.css( elem
, "display", false, styles
) === "inline" ) {
6378 val
= elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ];
6380 // offsetWidth/offsetHeight provide border-box values
6381 valueIsBorderBox
= true;
6384 // Normalize "" and auto
6385 val
= parseFloat( val
) || 0;
6387 // Adjust for the element's box model
6392 extra
|| ( isBorderBox
? "border" : "content" ),
6396 // Provide the current computed size to request scroll gutter calculation (gh-3589)
6404 // Add in style property hooks for overriding the default
6405 // behavior of getting and setting a style property
6408 get: function( elem
, computed
) {
6411 // We should always get a number back from opacity
6412 var ret
= curCSS( elem
, "opacity" );
6413 return ret
=== "" ? "1" : ret
;
6419 // Don't automatically add "px" to these possibly-unitless properties
6421 "animationIterationCount": true,
6422 "columnCount": true,
6423 "fillOpacity": true,
6436 // Add in properties whose names you wish to fix before
6437 // setting or getting the value
6440 // Get and set the style property on a DOM Node
6441 style: function( elem
, name
, value
, extra
) {
6443 // Don't set styles on text and comment nodes
6444 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6448 // Make sure that we're working with the right name
6449 var ret
, type
, hooks
,
6450 origName
= camelCase( name
),
6451 isCustomProp
= rcustomProp
.test( name
),
6454 // Make sure that we're working with the right name. We don't
6455 // want to query the value if it is a CSS custom property
6456 // since they are user-defined.
6457 if ( !isCustomProp
) {
6458 name
= finalPropName( origName
);
6461 // Gets hook for the prefixed version, then unprefixed version
6462 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6464 // Check if we're setting a value
6465 if ( value
!== undefined ) {
6466 type
= typeof value
;
6468 // Convert "+=" or "-=" to relative numbers (#7345)
6469 if ( type
=== "string" && ( ret
= rcssNum
.exec( value
) ) && ret
[ 1 ] ) {
6470 value
= adjustCSS( elem
, name
, ret
);
6476 // Make sure that null and NaN values aren't set (#7116)
6477 if ( value
== null || value
!== value
) {
6481 // If a number was passed in, add the unit (except for certain CSS properties)
6482 if ( type
=== "number" ) {
6483 value
+= ret
&& ret
[ 3 ] || ( jQuery
.cssNumber
[ origName
] ? "" : "px" );
6486 // background-* props affect original clone's values
6487 if ( !support
.clearCloneStyle
&& value
=== "" && name
.indexOf( "background" ) === 0 ) {
6488 style
[ name
] = "inherit";
6491 // If a hook was provided, use that value, otherwise just set the specified value
6492 if ( !hooks
|| !( "set" in hooks
) ||
6493 ( value
= hooks
.set( elem
, value
, extra
) ) !== undefined ) {
6495 if ( isCustomProp
) {
6496 style
.setProperty( name
, value
);
6498 style
[ name
] = value
;
6504 // If a hook was provided get the non-computed value from there
6505 if ( hooks
&& "get" in hooks
&&
6506 ( ret
= hooks
.get( elem
, false, extra
) ) !== undefined ) {
6511 // Otherwise just get the value from the style object
6512 return style
[ name
];
6516 css: function( elem
, name
, extra
, styles
) {
6517 var val
, num
, hooks
,
6518 origName
= camelCase( name
),
6519 isCustomProp
= rcustomProp
.test( name
);
6521 // Make sure that we're working with the right name. We don't
6522 // want to modify the value if it is a CSS custom property
6523 // since they are user-defined.
6524 if ( !isCustomProp
) {
6525 name
= finalPropName( origName
);
6528 // Try prefixed name followed by the unprefixed name
6529 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6531 // If a hook was provided get the computed value from there
6532 if ( hooks
&& "get" in hooks
) {
6533 val
= hooks
.get( elem
, true, extra
);
6536 // Otherwise, if a way to get the computed value exists, use that
6537 if ( val
=== undefined ) {
6538 val
= curCSS( elem
, name
, styles
);
6541 // Convert "normal" to computed value
6542 if ( val
=== "normal" && name
in cssNormalTransform
) {
6543 val
= cssNormalTransform
[ name
];
6546 // Make numeric if forced or a qualifier was provided and val looks numeric
6547 if ( extra
=== "" || extra
) {
6548 num
= parseFloat( val
);
6549 return extra
=== true || isFinite( num
) ? num
|| 0 : val
;
6556 jQuery
.each( [ "height", "width" ], function( i
, dimension
) {
6557 jQuery
.cssHooks
[ dimension
] = {
6558 get: function( elem
, computed
, extra
) {
6561 // Certain elements can have dimension info if we invisibly show them
6562 // but it must have a current display style that would benefit
6563 return rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) &&
6565 // Support: Safari 8+
6566 // Table columns in Safari have non-zero offsetWidth & zero
6567 // getBoundingClientRect().width unless display is changed.
6568 // Support: IE <=11 only
6569 // Running getBoundingClientRect on a disconnected node
6570 // in IE throws an error.
6571 ( !elem
.getClientRects().length
|| !elem
.getBoundingClientRect().width
) ?
6572 swap( elem
, cssShow
, function() {
6573 return getWidthOrHeight( elem
, dimension
, extra
);
6575 getWidthOrHeight( elem
, dimension
, extra
);
6579 set: function( elem
, value
, extra
) {
6581 styles
= getStyles( elem
),
6582 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6583 subtract
= extra
&& boxModelAdjustment(
6591 // Account for unreliable border-box dimensions by comparing offset* to computed and
6592 // faking a content-box to get border and padding (gh-3699)
6593 if ( isBorderBox
&& support
.scrollboxSize() === styles
.position
) {
6594 subtract
-= Math
.ceil(
6595 elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ] -
6596 parseFloat( styles
[ dimension
] ) -
6597 boxModelAdjustment( elem
, dimension
, "border", false, styles
) -
6602 // Convert to pixels if value adjustment is needed
6603 if ( subtract
&& ( matches
= rcssNum
.exec( value
) ) &&
6604 ( matches
[ 3 ] || "px" ) !== "px" ) {
6606 elem
.style
[ dimension
] = value
;
6607 value
= jQuery
.css( elem
, dimension
);
6610 return setPositiveNumber( elem
, value
, subtract
);
6615 jQuery
.cssHooks
.marginLeft
= addGetHookIf( support
.reliableMarginLeft
,
6616 function( elem
, computed
) {
6618 return ( parseFloat( curCSS( elem
, "marginLeft" ) ) ||
6619 elem
.getBoundingClientRect().left
-
6620 swap( elem
, { marginLeft
: 0 }, function() {
6621 return elem
.getBoundingClientRect().left
;
6628 // These hooks are used by animate to expand properties
6633 }, function( prefix
, suffix
) {
6634 jQuery
.cssHooks
[ prefix
+ suffix
] = {
6635 expand: function( value
) {
6639 // Assumes a single number if not a string
6640 parts
= typeof value
=== "string" ? value
.split( " " ) : [ value
];
6642 for ( ; i
< 4; i
++ ) {
6643 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
6644 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
6651 if ( prefix
!== "margin" ) {
6652 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
6657 css: function( name
, value
) {
6658 return access( this, function( elem
, name
, value
) {
6663 if ( Array
.isArray( name
) ) {
6664 styles
= getStyles( elem
);
6667 for ( ; i
< len
; i
++ ) {
6668 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
6674 return value
!== undefined ?
6675 jQuery
.style( elem
, name
, value
) :
6676 jQuery
.css( elem
, name
);
6677 }, name
, value
, arguments
.length
> 1 );
6682 function Tween( elem
, options
, prop
, end
, easing
) {
6683 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
6685 jQuery
.Tween
= Tween
;
6689 init: function( elem
, options
, prop
, end
, easing
, unit
) {
6692 this.easing
= easing
|| jQuery
.easing
._default
;
6693 this.options
= options
;
6694 this.start
= this.now
= this.cur();
6696 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
6699 var hooks
= Tween
.propHooks
[ this.prop
];
6701 return hooks
&& hooks
.get ?
6703 Tween
.propHooks
._default
.get( this );
6705 run: function( percent
) {
6707 hooks
= Tween
.propHooks
[ this.prop
];
6709 if ( this.options
.duration
) {
6710 this.pos
= eased
= jQuery
.easing
[ this.easing
](
6711 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
6714 this.pos
= eased
= percent
;
6716 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
6718 if ( this.options
.step
) {
6719 this.options
.step
.call( this.elem
, this.now
, this );
6722 if ( hooks
&& hooks
.set ) {
6725 Tween
.propHooks
._default
.set( this );
6731 Tween
.prototype.init
.prototype = Tween
.prototype;
6735 get: function( tween
) {
6738 // Use a property on the element directly when it is not a DOM element,
6739 // or when there is no matching style property that exists.
6740 if ( tween
.elem
.nodeType
!== 1 ||
6741 tween
.elem
[ tween
.prop
] != null && tween
.elem
.style
[ tween
.prop
] == null ) {
6742 return tween
.elem
[ tween
.prop
];
6745 // Passing an empty string as a 3rd parameter to .css will automatically
6746 // attempt a parseFloat and fallback to a string if the parse fails.
6747 // Simple values such as "10px" are parsed to Float;
6748 // complex values such as "rotate(1rad)" are returned as-is.
6749 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
6751 // Empty strings, null, undefined and "auto" are converted to 0.
6752 return !result
|| result
=== "auto" ? 0 : result
;
6754 set: function( tween
) {
6756 // Use step hook for back compat.
6757 // Use cssHook if its there.
6758 // Use .style if available and use plain properties where available.
6759 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
6760 jQuery
.fx
.step
[ tween
.prop
]( tween
);
6761 } else if ( tween
.elem
.nodeType
=== 1 &&
6762 ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null ||
6763 jQuery
.cssHooks
[ tween
.prop
] ) ) {
6764 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
6766 tween
.elem
[ tween
.prop
] = tween
.now
;
6772 // Support: IE <=9 only
6773 // Panic based approach to setting things on disconnected nodes
6774 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
6775 set: function( tween
) {
6776 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
6777 tween
.elem
[ tween
.prop
] = tween
.now
;
6783 linear: function( p
) {
6786 swing: function( p
) {
6787 return 0.5 - Math
.cos( p
* Math
.PI
) / 2;
6792 jQuery
.fx
= Tween
.prototype.init
;
6794 // Back compat <1.8 extension point
6795 jQuery
.fx
.step
= {};
6802 rfxtypes
= /^(?:toggle|show|hide)$/,
6803 rrun
= /queueHooks$/;
6805 function schedule() {
6807 if ( document
.hidden
=== false && window
.requestAnimationFrame
) {
6808 window
.requestAnimationFrame( schedule
);
6810 window
.setTimeout( schedule
, jQuery
.fx
.interval
);
6817 // Animations created synchronously will run synchronously
6818 function createFxNow() {
6819 window
.setTimeout( function() {
6822 return ( fxNow
= Date
.now() );
6825 // Generate parameters to create a standard animation
6826 function genFx( type
, includeWidth
) {
6829 attrs
= { height
: type
};
6831 // If we include width, step value is 1 to do all cssExpand values,
6832 // otherwise step value is 2 to skip over Left and Right
6833 includeWidth
= includeWidth
? 1 : 0;
6834 for ( ; i
< 4; i
+= 2 - includeWidth
) {
6835 which
= cssExpand
[ i
];
6836 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
6839 if ( includeWidth
) {
6840 attrs
.opacity
= attrs
.width
= type
;
6846 function createTween( value
, prop
, animation
) {
6848 collection
= ( Animation
.tweeners
[ prop
] || [] ).concat( Animation
.tweeners
[ "*" ] ),
6850 length
= collection
.length
;
6851 for ( ; index
< length
; index
++ ) {
6852 if ( ( tween
= collection
[ index
].call( animation
, prop
, value
) ) ) {
6854 // We're done with this property
6860 function defaultPrefilter( elem
, props
, opts
) {
6861 var prop
, value
, toggle
, hooks
, oldfire
, propTween
, restoreDisplay
, display
,
6862 isBox
= "width" in props
|| "height" in props
,
6866 hidden
= elem
.nodeType
&& isHiddenWithinTree( elem
),
6867 dataShow
= dataPriv
.get( elem
, "fxshow" );
6869 // Queue-skipping animations hijack the fx hooks
6870 if ( !opts
.queue
) {
6871 hooks
= jQuery
._queueHooks( elem
, "fx" );
6872 if ( hooks
.unqueued
== null ) {
6874 oldfire
= hooks
.empty
.fire
;
6875 hooks
.empty
.fire = function() {
6876 if ( !hooks
.unqueued
) {
6883 anim
.always( function() {
6885 // Ensure the complete handler is called before this completes
6886 anim
.always( function() {
6888 if ( !jQuery
.queue( elem
, "fx" ).length
) {
6895 // Detect show/hide animations
6896 for ( prop
in props
) {
6897 value
= props
[ prop
];
6898 if ( rfxtypes
.test( value
) ) {
6899 delete props
[ prop
];
6900 toggle
= toggle
|| value
=== "toggle";
6901 if ( value
=== ( hidden
? "hide" : "show" ) ) {
6903 // Pretend to be hidden if this is a "show" and
6904 // there is still data from a stopped show/hide
6905 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
6908 // Ignore all other no-op show/hide data
6913 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
6917 // Bail out if this is a no-op like .hide().hide()
6918 propTween
= !jQuery
.isEmptyObject( props
);
6919 if ( !propTween
&& jQuery
.isEmptyObject( orig
) ) {
6923 // Restrict "overflow" and "display" styles during box animations
6924 if ( isBox
&& elem
.nodeType
=== 1 ) {
6926 // Support: IE <=9 - 11, Edge 12 - 15
6927 // Record all 3 overflow attributes because IE does not infer the shorthand
6928 // from identically-valued overflowX and overflowY and Edge just mirrors
6929 // the overflowX value there.
6930 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
6932 // Identify a display type, preferring old show/hide data over the CSS cascade
6933 restoreDisplay
= dataShow
&& dataShow
.display
;
6934 if ( restoreDisplay
== null ) {
6935 restoreDisplay
= dataPriv
.get( elem
, "display" );
6937 display
= jQuery
.css( elem
, "display" );
6938 if ( display
=== "none" ) {
6939 if ( restoreDisplay
) {
6940 display
= restoreDisplay
;
6943 // Get nonempty value(s) by temporarily forcing visibility
6944 showHide( [ elem
], true );
6945 restoreDisplay
= elem
.style
.display
|| restoreDisplay
;
6946 display
= jQuery
.css( elem
, "display" );
6947 showHide( [ elem
] );
6951 // Animate inline elements as inline-block
6952 if ( display
=== "inline" || display
=== "inline-block" && restoreDisplay
!= null ) {
6953 if ( jQuery
.css( elem
, "float" ) === "none" ) {
6955 // Restore the original display value at the end of pure show/hide animations
6957 anim
.done( function() {
6958 style
.display
= restoreDisplay
;
6960 if ( restoreDisplay
== null ) {
6961 display
= style
.display
;
6962 restoreDisplay
= display
=== "none" ? "" : display
;
6965 style
.display
= "inline-block";
6970 if ( opts
.overflow
) {
6971 style
.overflow
= "hidden";
6972 anim
.always( function() {
6973 style
.overflow
= opts
.overflow
[ 0 ];
6974 style
.overflowX
= opts
.overflow
[ 1 ];
6975 style
.overflowY
= opts
.overflow
[ 2 ];
6979 // Implement show/hide animations
6981 for ( prop
in orig
) {
6983 // General show/hide setup for this element animation
6986 if ( "hidden" in dataShow
) {
6987 hidden
= dataShow
.hidden
;
6990 dataShow
= dataPriv
.access( elem
, "fxshow", { display
: restoreDisplay
} );
6993 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
6995 dataShow
.hidden
= !hidden
;
6998 // Show elements before animating them
7000 showHide( [ elem
], true );
7003 /* eslint-disable no-loop-func */
7005 anim
.done( function() {
7007 /* eslint-enable no-loop-func */
7009 // The final step of a "hide" animation is actually hiding the element
7011 showHide( [ elem
] );
7013 dataPriv
.remove( elem
, "fxshow" );
7014 for ( prop
in orig
) {
7015 jQuery
.style( elem
, prop
, orig
[ prop
] );
7020 // Per-property setup
7021 propTween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
7022 if ( !( prop
in dataShow
) ) {
7023 dataShow
[ prop
] = propTween
.start
;
7025 propTween
.end
= propTween
.start
;
7026 propTween
.start
= 0;
7032 function propFilter( props
, specialEasing
) {
7033 var index
, name
, easing
, value
, hooks
;
7035 // camelCase, specialEasing and expand cssHook pass
7036 for ( index
in props
) {
7037 name
= camelCase( index
);
7038 easing
= specialEasing
[ name
];
7039 value
= props
[ index
];
7040 if ( Array
.isArray( value
) ) {
7041 easing
= value
[ 1 ];
7042 value
= props
[ index
] = value
[ 0 ];
7045 if ( index
!== name
) {
7046 props
[ name
] = value
;
7047 delete props
[ index
];
7050 hooks
= jQuery
.cssHooks
[ name
];
7051 if ( hooks
&& "expand" in hooks
) {
7052 value
= hooks
.expand( value
);
7053 delete props
[ name
];
7055 // Not quite $.extend, this won't overwrite existing keys.
7056 // Reusing 'index' because we have the correct "name"
7057 for ( index
in value
) {
7058 if ( !( index
in props
) ) {
7059 props
[ index
] = value
[ index
];
7060 specialEasing
[ index
] = easing
;
7064 specialEasing
[ name
] = easing
;
7069 function Animation( elem
, properties
, options
) {
7073 length
= Animation
.prefilters
.length
,
7074 deferred
= jQuery
.Deferred().always( function() {
7076 // Don't match elem in the :animated selector
7083 var currentTime
= fxNow
|| createFxNow(),
7084 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
7086 // Support: Android 2.3 only
7087 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
7088 temp
= remaining
/ animation
.duration
|| 0,
7091 length
= animation
.tweens
.length
;
7093 for ( ; index
< length
; index
++ ) {
7094 animation
.tweens
[ index
].run( percent
);
7097 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
] );
7099 // If there's more to do, yield
7100 if ( percent
< 1 && length
) {
7104 // If this was an empty animation, synthesize a final progress notification
7106 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7109 // Resolve the animation and report its conclusion
7110 deferred
.resolveWith( elem
, [ animation
] );
7113 animation
= deferred
.promise( {
7115 props
: jQuery
.extend( {}, properties
),
7116 opts
: jQuery
.extend( true, {
7118 easing
: jQuery
.easing
._default
7120 originalProperties
: properties
,
7121 originalOptions
: options
,
7122 startTime
: fxNow
|| createFxNow(),
7123 duration
: options
.duration
,
7125 createTween: function( prop
, end
) {
7126 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
7127 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
7128 animation
.tweens
.push( tween
);
7131 stop: function( gotoEnd
) {
7134 // If we are going to the end, we want to run all the tweens
7135 // otherwise we skip this part
7136 length
= gotoEnd
? animation
.tweens
.length
: 0;
7141 for ( ; index
< length
; index
++ ) {
7142 animation
.tweens
[ index
].run( 1 );
7145 // Resolve when we played the last frame; otherwise, reject
7147 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7148 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
7150 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
7155 props
= animation
.props
;
7157 propFilter( props
, animation
.opts
.specialEasing
);
7159 for ( ; index
< length
; index
++ ) {
7160 result
= Animation
.prefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
7162 if ( isFunction( result
.stop
) ) {
7163 jQuery
._queueHooks( animation
.elem
, animation
.opts
.queue
).stop
=
7164 result
.stop
.bind( result
);
7170 jQuery
.map( props
, createTween
, animation
);
7172 if ( isFunction( animation
.opts
.start
) ) {
7173 animation
.opts
.start
.call( elem
, animation
);
7176 // Attach callbacks from options
7178 .progress( animation
.opts
.progress
)
7179 .done( animation
.opts
.done
, animation
.opts
.complete
)
7180 .fail( animation
.opts
.fail
)
7181 .always( animation
.opts
.always
);
7184 jQuery
.extend( tick
, {
7187 queue
: animation
.opts
.queue
7194 jQuery
.Animation
= jQuery
.extend( Animation
, {
7197 "*": [ function( prop
, value
) {
7198 var tween
= this.createTween( prop
, value
);
7199 adjustCSS( tween
.elem
, prop
, rcssNum
.exec( value
), tween
);
7204 tweener: function( props
, callback
) {
7205 if ( isFunction( props
) ) {
7209 props
= props
.match( rnothtmlwhite
);
7214 length
= props
.length
;
7216 for ( ; index
< length
; index
++ ) {
7217 prop
= props
[ index
];
7218 Animation
.tweeners
[ prop
] = Animation
.tweeners
[ prop
] || [];
7219 Animation
.tweeners
[ prop
].unshift( callback
);
7223 prefilters
: [ defaultPrefilter
],
7225 prefilter: function( callback
, prepend
) {
7227 Animation
.prefilters
.unshift( callback
);
7229 Animation
.prefilters
.push( callback
);
7234 jQuery
.speed = function( speed
, easing
, fn
) {
7235 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
7236 complete
: fn
|| !fn
&& easing
||
7237 isFunction( speed
) && speed
,
7239 easing
: fn
&& easing
|| easing
&& !isFunction( easing
) && easing
7242 // Go to the end state if fx are off
7243 if ( jQuery
.fx
.off
) {
7247 if ( typeof opt
.duration
!== "number" ) {
7248 if ( opt
.duration
in jQuery
.fx
.speeds
) {
7249 opt
.duration
= jQuery
.fx
.speeds
[ opt
.duration
];
7252 opt
.duration
= jQuery
.fx
.speeds
._default
;
7257 // Normalize opt.queue - true/undefined/null -> "fx"
7258 if ( opt
.queue
== null || opt
.queue
=== true ) {
7263 opt
.old
= opt
.complete
;
7265 opt
.complete = function() {
7266 if ( isFunction( opt
.old
) ) {
7267 opt
.old
.call( this );
7271 jQuery
.dequeue( this, opt
.queue
);
7279 fadeTo: function( speed
, to
, easing
, callback
) {
7281 // Show any hidden elements after setting opacity to 0
7282 return this.filter( isHiddenWithinTree
).css( "opacity", 0 ).show()
7284 // Animate to the value specified
7285 .end().animate( { opacity
: to
}, speed
, easing
, callback
);
7287 animate: function( prop
, speed
, easing
, callback
) {
7288 var empty
= jQuery
.isEmptyObject( prop
),
7289 optall
= jQuery
.speed( speed
, easing
, callback
),
7290 doAnimation = function() {
7292 // Operate on a copy of prop so per-property easing won't be lost
7293 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
7295 // Empty animations, or finishing resolves immediately
7296 if ( empty
|| dataPriv
.get( this, "finish" ) ) {
7300 doAnimation
.finish
= doAnimation
;
7302 return empty
|| optall
.queue
=== false ?
7303 this.each( doAnimation
) :
7304 this.queue( optall
.queue
, doAnimation
);
7306 stop: function( type
, clearQueue
, gotoEnd
) {
7307 var stopQueue = function( hooks
) {
7308 var stop
= hooks
.stop
;
7313 if ( typeof type
!== "string" ) {
7314 gotoEnd
= clearQueue
;
7318 if ( clearQueue
&& type
!== false ) {
7319 this.queue( type
|| "fx", [] );
7322 return this.each( function() {
7324 index
= type
!= null && type
+ "queueHooks",
7325 timers
= jQuery
.timers
,
7326 data
= dataPriv
.get( this );
7329 if ( data
[ index
] && data
[ index
].stop
) {
7330 stopQueue( data
[ index
] );
7333 for ( index
in data
) {
7334 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
7335 stopQueue( data
[ index
] );
7340 for ( index
= timers
.length
; index
--; ) {
7341 if ( timers
[ index
].elem
=== this &&
7342 ( type
== null || timers
[ index
].queue
=== type
) ) {
7344 timers
[ index
].anim
.stop( gotoEnd
);
7346 timers
.splice( index
, 1 );
7350 // Start the next in the queue if the last step wasn't forced.
7351 // Timers currently will call their complete callbacks, which
7352 // will dequeue but only if they were gotoEnd.
7353 if ( dequeue
|| !gotoEnd
) {
7354 jQuery
.dequeue( this, type
);
7358 finish: function( type
) {
7359 if ( type
!== false ) {
7360 type
= type
|| "fx";
7362 return this.each( function() {
7364 data
= dataPriv
.get( this ),
7365 queue
= data
[ type
+ "queue" ],
7366 hooks
= data
[ type
+ "queueHooks" ],
7367 timers
= jQuery
.timers
,
7368 length
= queue
? queue
.length
: 0;
7370 // Enable finishing flag on private data
7373 // Empty the queue first
7374 jQuery
.queue( this, type
, [] );
7376 if ( hooks
&& hooks
.stop
) {
7377 hooks
.stop
.call( this, true );
7380 // Look for any active animations, and finish them
7381 for ( index
= timers
.length
; index
--; ) {
7382 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
7383 timers
[ index
].anim
.stop( true );
7384 timers
.splice( index
, 1 );
7388 // Look for any animations in the old queue and finish them
7389 for ( index
= 0; index
< length
; index
++ ) {
7390 if ( queue
[ index
] && queue
[ index
].finish
) {
7391 queue
[ index
].finish
.call( this );
7395 // Turn off finishing flag
7401 jQuery
.each( [ "toggle", "show", "hide" ], function( i
, name
) {
7402 var cssFn
= jQuery
.fn
[ name
];
7403 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7404 return speed
== null || typeof speed
=== "boolean" ?
7405 cssFn
.apply( this, arguments
) :
7406 this.animate( genFx( name
, true ), speed
, easing
, callback
);
7410 // Generate shortcuts for custom animations
7412 slideDown
: genFx( "show" ),
7413 slideUp
: genFx( "hide" ),
7414 slideToggle
: genFx( "toggle" ),
7415 fadeIn
: { opacity
: "show" },
7416 fadeOut
: { opacity
: "hide" },
7417 fadeToggle
: { opacity
: "toggle" }
7418 }, function( name
, props
) {
7419 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7420 return this.animate( props
, speed
, easing
, callback
);
7425 jQuery
.fx
.tick = function() {
7428 timers
= jQuery
.timers
;
7432 for ( ; i
< timers
.length
; i
++ ) {
7433 timer
= timers
[ i
];
7435 // Run the timer and safely remove it when done (allowing for external removal)
7436 if ( !timer() && timers
[ i
] === timer
) {
7437 timers
.splice( i
--, 1 );
7441 if ( !timers
.length
) {
7447 jQuery
.fx
.timer = function( timer
) {
7448 jQuery
.timers
.push( timer
);
7452 jQuery
.fx
.interval
= 13;
7453 jQuery
.fx
.start = function() {
7462 jQuery
.fx
.stop = function() {
7466 jQuery
.fx
.speeds
= {
7475 // Based off of the plugin by Clint Helfers, with permission.
7476 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
7477 jQuery
.fn
.delay = function( time
, type
) {
7478 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
7479 type
= type
|| "fx";
7481 return this.queue( type
, function( next
, hooks
) {
7482 var timeout
= window
.setTimeout( next
, time
);
7483 hooks
.stop = function() {
7484 window
.clearTimeout( timeout
);
7491 var input
= document
.createElement( "input" ),
7492 select
= document
.createElement( "select" ),
7493 opt
= select
.appendChild( document
.createElement( "option" ) );
7495 input
.type
= "checkbox";
7497 // Support: Android <=4.3 only
7498 // Default value for a checkbox should be "on"
7499 support
.checkOn
= input
.value
!== "";
7501 // Support: IE <=11 only
7502 // Must access selectedIndex to make default options select
7503 support
.optSelected
= opt
.selected
;
7505 // Support: IE <=11 only
7506 // An input loses its value after becoming a radio
7507 input
= document
.createElement( "input" );
7509 input
.type
= "radio";
7510 support
.radioValue
= input
.value
=== "t";
7515 attrHandle
= jQuery
.expr
.attrHandle
;
7518 attr: function( name
, value
) {
7519 return access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
7522 removeAttr: function( name
) {
7523 return this.each( function() {
7524 jQuery
.removeAttr( this, name
);
7530 attr: function( elem
, name
, value
) {
7532 nType
= elem
.nodeType
;
7534 // Don't get/set attributes on text, comment and attribute nodes
7535 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7539 // Fallback to prop when attributes are not supported
7540 if ( typeof elem
.getAttribute
=== "undefined" ) {
7541 return jQuery
.prop( elem
, name
, value
);
7544 // Attribute hooks are determined by the lowercase version
7545 // Grab necessary hook if one is defined
7546 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
7547 hooks
= jQuery
.attrHooks
[ name
.toLowerCase() ] ||
7548 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook
: undefined );
7551 if ( value
!== undefined ) {
7552 if ( value
=== null ) {
7553 jQuery
.removeAttr( elem
, name
);
7557 if ( hooks
&& "set" in hooks
&&
7558 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
7562 elem
.setAttribute( name
, value
+ "" );
7566 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
7570 ret
= jQuery
.find
.attr( elem
, name
);
7572 // Non-existent attributes return null, we normalize to undefined
7573 return ret
== null ? undefined : ret
;
7578 set: function( elem
, value
) {
7579 if ( !support
.radioValue
&& value
=== "radio" &&
7580 nodeName( elem
, "input" ) ) {
7581 var val
= elem
.value
;
7582 elem
.setAttribute( "type", value
);
7592 removeAttr: function( elem
, value
) {
7596 // Attribute names can contain non-HTML whitespace characters
7597 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
7598 attrNames
= value
&& value
.match( rnothtmlwhite
);
7600 if ( attrNames
&& elem
.nodeType
=== 1 ) {
7601 while ( ( name
= attrNames
[ i
++ ] ) ) {
7602 elem
.removeAttribute( name
);
7608 // Hooks for boolean attributes
7610 set: function( elem
, value
, name
) {
7611 if ( value
=== false ) {
7613 // Remove boolean attributes when set to false
7614 jQuery
.removeAttr( elem
, name
);
7616 elem
.setAttribute( name
, name
);
7622 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( i
, name
) {
7623 var getter
= attrHandle
[ name
] || jQuery
.find
.attr
;
7625 attrHandle
[ name
] = function( elem
, name
, isXML
) {
7627 lowercaseName
= name
.toLowerCase();
7631 // Avoid an infinite loop by temporarily removing this function from the getter
7632 handle
= attrHandle
[ lowercaseName
];
7633 attrHandle
[ lowercaseName
] = ret
;
7634 ret
= getter( elem
, name
, isXML
) != null ?
7637 attrHandle
[ lowercaseName
] = handle
;
7646 var rfocusable
= /^(?:input|select|textarea|button)$/i,
7647 rclickable
= /^(?:a|area)$/i;
7650 prop: function( name
, value
) {
7651 return access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
7654 removeProp: function( name
) {
7655 return this.each( function() {
7656 delete this[ jQuery
.propFix
[ name
] || name
];
7662 prop: function( elem
, name
, value
) {
7664 nType
= elem
.nodeType
;
7666 // Don't get/set properties on text, comment and attribute nodes
7667 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7671 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
7673 // Fix name and attach hooks
7674 name
= jQuery
.propFix
[ name
] || name
;
7675 hooks
= jQuery
.propHooks
[ name
];
7678 if ( value
!== undefined ) {
7679 if ( hooks
&& "set" in hooks
&&
7680 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
7684 return ( elem
[ name
] = value
);
7687 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
7691 return elem
[ name
];
7696 get: function( elem
) {
7698 // Support: IE <=9 - 11 only
7699 // elem.tabIndex doesn't always return the
7700 // correct value when it hasn't been explicitly set
7701 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
7702 // Use proper attribute retrieval(#12072)
7703 var tabindex
= jQuery
.find
.attr( elem
, "tabindex" );
7706 return parseInt( tabindex
, 10 );
7710 rfocusable
.test( elem
.nodeName
) ||
7711 rclickable
.test( elem
.nodeName
) &&
7724 "class": "className"
7728 // Support: IE <=11 only
7729 // Accessing the selectedIndex property
7730 // forces the browser to respect setting selected
7732 // The getter ensures a default option is selected
7733 // when in an optgroup
7734 // eslint rule "no-unused-expressions" is disabled for this code
7735 // since it considers such accessions noop
7736 if ( !support
.optSelected
) {
7737 jQuery
.propHooks
.selected
= {
7738 get: function( elem
) {
7740 /* eslint no-unused-expressions: "off" */
7742 var parent
= elem
.parentNode
;
7743 if ( parent
&& parent
.parentNode
) {
7744 parent
.parentNode
.selectedIndex
;
7748 set: function( elem
) {
7750 /* eslint no-unused-expressions: "off" */
7752 var parent
= elem
.parentNode
;
7754 parent
.selectedIndex
;
7756 if ( parent
.parentNode
) {
7757 parent
.parentNode
.selectedIndex
;
7776 jQuery
.propFix
[ this.toLowerCase() ] = this;
7782 // Strip and collapse whitespace according to HTML spec
7783 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
7784 function stripAndCollapse( value
) {
7785 var tokens
= value
.match( rnothtmlwhite
) || [];
7786 return tokens
.join( " " );
7790 function getClass( elem
) {
7791 return elem
.getAttribute
&& elem
.getAttribute( "class" ) || "";
7794 function classesToArray( value
) {
7795 if ( Array
.isArray( value
) ) {
7798 if ( typeof value
=== "string" ) {
7799 return value
.match( rnothtmlwhite
) || [];
7805 addClass: function( value
) {
7806 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
7809 if ( isFunction( value
) ) {
7810 return this.each( function( j
) {
7811 jQuery( this ).addClass( value
.call( this, j
, getClass( this ) ) );
7815 classes
= classesToArray( value
);
7817 if ( classes
.length
) {
7818 while ( ( elem
= this[ i
++ ] ) ) {
7819 curValue
= getClass( elem
);
7820 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
7824 while ( ( clazz
= classes
[ j
++ ] ) ) {
7825 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
7830 // Only assign if different to avoid unneeded rendering.
7831 finalValue
= stripAndCollapse( cur
);
7832 if ( curValue
!== finalValue
) {
7833 elem
.setAttribute( "class", finalValue
);
7842 removeClass: function( value
) {
7843 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
7846 if ( isFunction( value
) ) {
7847 return this.each( function( j
) {
7848 jQuery( this ).removeClass( value
.call( this, j
, getClass( this ) ) );
7852 if ( !arguments
.length
) {
7853 return this.attr( "class", "" );
7856 classes
= classesToArray( value
);
7858 if ( classes
.length
) {
7859 while ( ( elem
= this[ i
++ ] ) ) {
7860 curValue
= getClass( elem
);
7862 // This expression is here for better compressibility (see addClass)
7863 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
7867 while ( ( clazz
= classes
[ j
++ ] ) ) {
7869 // Remove *all* instances
7870 while ( cur
.indexOf( " " + clazz
+ " " ) > -1 ) {
7871 cur
= cur
.replace( " " + clazz
+ " ", " " );
7875 // Only assign if different to avoid unneeded rendering.
7876 finalValue
= stripAndCollapse( cur
);
7877 if ( curValue
!== finalValue
) {
7878 elem
.setAttribute( "class", finalValue
);
7887 toggleClass: function( value
, stateVal
) {
7888 var type
= typeof value
,
7889 isValidValue
= type
=== "string" || Array
.isArray( value
);
7891 if ( typeof stateVal
=== "boolean" && isValidValue
) {
7892 return stateVal
? this.addClass( value
) : this.removeClass( value
);
7895 if ( isFunction( value
) ) {
7896 return this.each( function( i
) {
7897 jQuery( this ).toggleClass(
7898 value
.call( this, i
, getClass( this ), stateVal
),
7904 return this.each( function() {
7905 var className
, i
, self
, classNames
;
7907 if ( isValidValue
) {
7909 // Toggle individual class names
7911 self
= jQuery( this );
7912 classNames
= classesToArray( value
);
7914 while ( ( className
= classNames
[ i
++ ] ) ) {
7916 // Check each className given, space separated list
7917 if ( self
.hasClass( className
) ) {
7918 self
.removeClass( className
);
7920 self
.addClass( className
);
7924 // Toggle whole class name
7925 } else if ( value
=== undefined || type
=== "boolean" ) {
7926 className
= getClass( this );
7929 // Store className if set
7930 dataPriv
.set( this, "__className__", className
);
7933 // If the element has a class name or if we're passed `false`,
7934 // then remove the whole classname (if there was one, the above saved it).
7935 // Otherwise bring back whatever was previously saved (if anything),
7936 // falling back to the empty string if nothing was stored.
7937 if ( this.setAttribute
) {
7938 this.setAttribute( "class",
7939 className
|| value
=== false ?
7941 dataPriv
.get( this, "__className__" ) || ""
7948 hasClass: function( selector
) {
7949 var className
, elem
,
7952 className
= " " + selector
+ " ";
7953 while ( ( elem
= this[ i
++ ] ) ) {
7954 if ( elem
.nodeType
=== 1 &&
7955 ( " " + stripAndCollapse( getClass( elem
) ) + " " ).indexOf( className
) > -1 ) {
7967 var rreturn
= /\r/g;
7970 val: function( value
) {
7971 var hooks
, ret
, valueIsFunction
,
7974 if ( !arguments
.length
) {
7976 hooks
= jQuery
.valHooks
[ elem
.type
] ||
7977 jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
7981 ( ret
= hooks
.get( elem
, "value" ) ) !== undefined
7988 // Handle most common string cases
7989 if ( typeof ret
=== "string" ) {
7990 return ret
.replace( rreturn
, "" );
7993 // Handle cases where value is null/undef or number
7994 return ret
== null ? "" : ret
;
8000 valueIsFunction
= isFunction( value
);
8002 return this.each( function( i
) {
8005 if ( this.nodeType
!== 1 ) {
8009 if ( valueIsFunction
) {
8010 val
= value
.call( this, i
, jQuery( this ).val() );
8015 // Treat null/undefined as ""; convert numbers to string
8016 if ( val
== null ) {
8019 } else if ( typeof val
=== "number" ) {
8022 } else if ( Array
.isArray( val
) ) {
8023 val
= jQuery
.map( val
, function( value
) {
8024 return value
== null ? "" : value
+ "";
8028 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
8030 // If set returns undefined, fall back to normal setting
8031 if ( !hooks
|| !( "set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
8041 get: function( elem
) {
8043 var val
= jQuery
.find
.attr( elem
, "value" );
8044 return val
!= null ?
8047 // Support: IE <=10 - 11 only
8048 // option.text throws exceptions (#14686, #14858)
8049 // Strip and collapse whitespace
8050 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8051 stripAndCollapse( jQuery
.text( elem
) );
8055 get: function( elem
) {
8056 var value
, option
, i
,
8057 options
= elem
.options
,
8058 index
= elem
.selectedIndex
,
8059 one
= elem
.type
=== "select-one",
8060 values
= one
? null : [],
8061 max
= one
? index
+ 1 : options
.length
;
8067 i
= one
? index
: 0;
8070 // Loop through all the selected options
8071 for ( ; i
< max
; i
++ ) {
8072 option
= options
[ i
];
8074 // Support: IE <=9 only
8075 // IE8-9 doesn't update selected after form reset (#2551)
8076 if ( ( option
.selected
|| i
=== index
) &&
8078 // Don't return options that are disabled or in a disabled optgroup
8080 ( !option
.parentNode
.disabled
||
8081 !nodeName( option
.parentNode
, "optgroup" ) ) ) {
8083 // Get the specific value for the option
8084 value
= jQuery( option
).val();
8086 // We don't need an array for one selects
8091 // Multi-Selects return an array
8092 values
.push( value
);
8099 set: function( elem
, value
) {
8100 var optionSet
, option
,
8101 options
= elem
.options
,
8102 values
= jQuery
.makeArray( value
),
8106 option
= options
[ i
];
8108 /* eslint-disable no-cond-assign */
8110 if ( option
.selected
=
8111 jQuery
.inArray( jQuery
.valHooks
.option
.get( option
), values
) > -1
8116 /* eslint-enable no-cond-assign */
8119 // Force browsers to behave consistently when non-matching value is set
8121 elem
.selectedIndex
= -1;
8129 // Radios and checkboxes getter/setter
8130 jQuery
.each( [ "radio", "checkbox" ], function() {
8131 jQuery
.valHooks
[ this ] = {
8132 set: function( elem
, value
) {
8133 if ( Array
.isArray( value
) ) {
8134 return ( elem
.checked
= jQuery
.inArray( jQuery( elem
).val(), value
) > -1 );
8138 if ( !support
.checkOn
) {
8139 jQuery
.valHooks
[ this ].get = function( elem
) {
8140 return elem
.getAttribute( "value" ) === null ? "on" : elem
.value
;
8148 // Return jQuery for attributes-only inclusion
8151 support
.focusin
= "onfocusin" in window
;
8154 var rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
8155 stopPropagationCallback = function( e
) {
8156 e
.stopPropagation();
8159 jQuery
.extend( jQuery
.event
, {
8161 trigger: function( event
, data
, elem
, onlyHandlers
) {
8163 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
, lastElement
,
8164 eventPath
= [ elem
|| document
],
8165 type
= hasOwn
.call( event
, "type" ) ? event
.type
: event
,
8166 namespaces
= hasOwn
.call( event
, "namespace" ) ? event
.namespace.split( "." ) : [];
8168 cur
= lastElement
= tmp
= elem
= elem
|| document
;
8170 // Don't do events on text and comment nodes
8171 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
8175 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8176 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
8180 if ( type
.indexOf( "." ) > -1 ) {
8182 // Namespaced trigger; create a regexp to match event type in handle()
8183 namespaces
= type
.split( "." );
8184 type
= namespaces
.shift();
8187 ontype
= type
.indexOf( ":" ) < 0 && "on" + type
;
8189 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8190 event
= event
[ jQuery
.expando
] ?
8192 new jQuery
.Event( type
, typeof event
=== "object" && event
);
8194 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8195 event
.isTrigger
= onlyHandlers
? 2 : 3;
8196 event
.namespace = namespaces
.join( "." );
8197 event
.rnamespace
= event
.namespace ?
8198 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8201 // Clean up the event in case it is being reused
8202 event
.result
= undefined;
8203 if ( !event
.target
) {
8204 event
.target
= elem
;
8207 // Clone any incoming data and prepend the event, creating the handler arg list
8208 data
= data
== null ?
8210 jQuery
.makeArray( data
, [ event
] );
8212 // Allow special events to draw outside the lines
8213 special
= jQuery
.event
.special
[ type
] || {};
8214 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
8218 // Determine event propagation path in advance, per W3C events spec (#9951)
8219 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
8220 if ( !onlyHandlers
&& !special
.noBubble
&& !isWindow( elem
) ) {
8222 bubbleType
= special
.delegateType
|| type
;
8223 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
8224 cur
= cur
.parentNode
;
8226 for ( ; cur
; cur
= cur
.parentNode
) {
8227 eventPath
.push( cur
);
8231 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8232 if ( tmp
=== ( elem
.ownerDocument
|| document
) ) {
8233 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
8237 // Fire handlers on the event path
8239 while ( ( cur
= eventPath
[ i
++ ] ) && !event
.isPropagationStopped() ) {
8241 event
.type
= i
> 1 ?
8243 special
.bindType
|| type
;
8246 handle
= ( dataPriv
.get( cur
, "events" ) || {} )[ event
.type
] &&
8247 dataPriv
.get( cur
, "handle" );
8249 handle
.apply( cur
, data
);
8253 handle
= ontype
&& cur
[ ontype
];
8254 if ( handle
&& handle
.apply
&& acceptData( cur
) ) {
8255 event
.result
= handle
.apply( cur
, data
);
8256 if ( event
.result
=== false ) {
8257 event
.preventDefault();
8263 // If nobody prevented the default action, do it now
8264 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
8266 if ( ( !special
._default
||
8267 special
._default
.apply( eventPath
.pop(), data
) === false ) &&
8268 acceptData( elem
) ) {
8270 // Call a native DOM method on the target with the same name as the event.
8271 // Don't do default actions on window, that's where global variables be (#6170)
8272 if ( ontype
&& isFunction( elem
[ type
] ) && !isWindow( elem
) ) {
8274 // Don't re-trigger an onFOO event when we call its FOO() method
8275 tmp
= elem
[ ontype
];
8278 elem
[ ontype
] = null;
8281 // Prevent re-triggering of the same event, since we already bubbled it above
8282 jQuery
.event
.triggered
= type
;
8284 if ( event
.isPropagationStopped() ) {
8285 lastElement
.addEventListener( type
, stopPropagationCallback
);
8290 if ( event
.isPropagationStopped() ) {
8291 lastElement
.removeEventListener( type
, stopPropagationCallback
);
8294 jQuery
.event
.triggered
= undefined;
8297 elem
[ ontype
] = tmp
;
8303 return event
.result
;
8306 // Piggyback on a donor event to simulate a different one
8307 // Used only for `focus(in | out)` events
8308 simulate: function( type
, elem
, event
) {
8309 var e
= jQuery
.extend(
8318 jQuery
.event
.trigger( e
, null, elem
);
8325 trigger: function( type
, data
) {
8326 return this.each( function() {
8327 jQuery
.event
.trigger( type
, data
, this );
8330 triggerHandler: function( type
, data
) {
8331 var elem
= this[ 0 ];
8333 return jQuery
.event
.trigger( type
, data
, elem
, true );
8339 // Support: Firefox <=44
8340 // Firefox doesn't have focus(in | out) events
8341 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
8343 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
8344 // focus(in | out) events fire after focus & blur events,
8345 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
8346 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
8347 if ( !support
.focusin
) {
8348 jQuery
.each( { focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
8350 // Attach a single capturing handler on the document while someone wants focusin/focusout
8351 var handler = function( event
) {
8352 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
) );
8355 jQuery
.event
.special
[ fix
] = {
8357 var doc
= this.ownerDocument
|| this,
8358 attaches
= dataPriv
.access( doc
, fix
);
8361 doc
.addEventListener( orig
, handler
, true );
8363 dataPriv
.access( doc
, fix
, ( attaches
|| 0 ) + 1 );
8365 teardown: function() {
8366 var doc
= this.ownerDocument
|| this,
8367 attaches
= dataPriv
.access( doc
, fix
) - 1;
8370 doc
.removeEventListener( orig
, handler
, true );
8371 dataPriv
.remove( doc
, fix
);
8374 dataPriv
.access( doc
, fix
, attaches
);
8380 var location
= window
.location
;
8382 var nonce
= Date
.now();
8384 var rquery
= ( /\?/ );
8388 // Cross-browser xml parsing
8389 jQuery
.parseXML = function( data
) {
8391 if ( !data
|| typeof data
!== "string" ) {
8395 // Support: IE 9 - 11 only
8396 // IE throws on parseFromString with invalid input.
8398 xml
= ( new window
.DOMParser() ).parseFromString( data
, "text/xml" );
8403 if ( !xml
|| xml
.getElementsByTagName( "parsererror" ).length
) {
8404 jQuery
.error( "Invalid XML: " + data
);
8413 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
8414 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
8416 function buildParams( prefix
, obj
, traditional
, add
) {
8419 if ( Array
.isArray( obj
) ) {
8421 // Serialize array item.
8422 jQuery
.each( obj
, function( i
, v
) {
8423 if ( traditional
|| rbracket
.test( prefix
) ) {
8425 // Treat each array item as a scalar.
8430 // Item is non-scalar (array or object), encode its numeric index.
8432 prefix
+ "[" + ( typeof v
=== "object" && v
!= null ? i
: "" ) + "]",
8440 } else if ( !traditional
&& toType( obj
) === "object" ) {
8442 // Serialize object item.
8443 for ( name
in obj
) {
8444 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
8449 // Serialize scalar item.
8454 // Serialize an array of form elements or a set of
8455 // key/values into a query string
8456 jQuery
.param = function( a
, traditional
) {
8459 add = function( key
, valueOrFunction
) {
8461 // If value is a function, invoke it and use its return value
8462 var value
= isFunction( valueOrFunction
) ?
8466 s
[ s
.length
] = encodeURIComponent( key
) + "=" +
8467 encodeURIComponent( value
== null ? "" : value
);
8470 // If an array was passed in, assume that it is an array of form elements.
8471 if ( Array
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
8473 // Serialize the form elements
8474 jQuery
.each( a
, function() {
8475 add( this.name
, this.value
);
8480 // If traditional, encode the "old" way (the way 1.3.2 or older
8481 // did it), otherwise encode params recursively.
8482 for ( prefix
in a
) {
8483 buildParams( prefix
, a
[ prefix
], traditional
, add
);
8487 // Return the resulting serialization
8488 return s
.join( "&" );
8492 serialize: function() {
8493 return jQuery
.param( this.serializeArray() );
8495 serializeArray: function() {
8496 return this.map( function() {
8498 // Can add propHook for "elements" to filter or add form elements
8499 var elements
= jQuery
.prop( this, "elements" );
8500 return elements
? jQuery
.makeArray( elements
) : this;
8502 .filter( function() {
8503 var type
= this.type
;
8505 // Use .is( ":disabled" ) so that fieldset[disabled] works
8506 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
8507 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
8508 ( this.checked
|| !rcheckableType
.test( type
) );
8510 .map( function( i
, elem
) {
8511 var val
= jQuery( this ).val();
8513 if ( val
== null ) {
8517 if ( Array
.isArray( val
) ) {
8518 return jQuery
.map( val
, function( val
) {
8519 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8523 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8532 rantiCache
= /([?&])_=[^&]*/,
8533 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg,
8535 // #7653, #8125, #8152: local protocol detection
8536 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8537 rnoContent
= /^(?:GET|HEAD)$/,
8538 rprotocol
= /^\/\//,
8541 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8542 * 2) These are called:
8543 * - BEFORE asking for a transport
8544 * - AFTER param serialization (s.data is a string if s.processData is true)
8545 * 3) key is the dataType
8546 * 4) the catchall symbol "*" can be used
8547 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8551 /* Transports bindings
8552 * 1) key is the dataType
8553 * 2) the catchall symbol "*" can be used
8554 * 3) selection will start with transport dataType and THEN go to "*" if needed
8558 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8559 allTypes
= "*/".concat( "*" ),
8561 // Anchor tag for parsing the document origin
8562 originAnchor
= document
.createElement( "a" );
8563 originAnchor
.href
= location
.href
;
8565 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8566 function addToPrefiltersOrTransports( structure
) {
8568 // dataTypeExpression is optional and defaults to "*"
8569 return function( dataTypeExpression
, func
) {
8571 if ( typeof dataTypeExpression
!== "string" ) {
8572 func
= dataTypeExpression
;
8573 dataTypeExpression
= "*";
8578 dataTypes
= dataTypeExpression
.toLowerCase().match( rnothtmlwhite
) || [];
8580 if ( isFunction( func
) ) {
8582 // For each dataType in the dataTypeExpression
8583 while ( ( dataType
= dataTypes
[ i
++ ] ) ) {
8585 // Prepend if requested
8586 if ( dataType
[ 0 ] === "+" ) {
8587 dataType
= dataType
.slice( 1 ) || "*";
8588 ( structure
[ dataType
] = structure
[ dataType
] || [] ).unshift( func
);
8592 ( structure
[ dataType
] = structure
[ dataType
] || [] ).push( func
);
8599 // Base inspection function for prefilters and transports
8600 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
8603 seekingTransport
= ( structure
=== transports
);
8605 function inspect( dataType
) {
8607 inspected
[ dataType
] = true;
8608 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
8609 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
8610 if ( typeof dataTypeOrTransport
=== "string" &&
8611 !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
8613 options
.dataTypes
.unshift( dataTypeOrTransport
);
8614 inspect( dataTypeOrTransport
);
8616 } else if ( seekingTransport
) {
8617 return !( selected
= dataTypeOrTransport
);
8623 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
8626 // A special extend for ajax options
8627 // that takes "flat" options (not to be deep extended)
8629 function ajaxExtend( target
, src
) {
8631 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
8633 for ( key
in src
) {
8634 if ( src
[ key
] !== undefined ) {
8635 ( flatOptions
[ key
] ? target
: ( deep
|| ( deep
= {} ) ) )[ key
] = src
[ key
];
8639 jQuery
.extend( true, target
, deep
);
8645 /* Handles responses to an ajax request:
8646 * - finds the right dataType (mediates between content-type and expected dataType)
8647 * - returns the corresponding response
8649 function ajaxHandleResponses( s
, jqXHR
, responses
) {
8651 var ct
, type
, finalDataType
, firstDataType
,
8652 contents
= s
.contents
,
8653 dataTypes
= s
.dataTypes
;
8655 // Remove auto dataType and get content-type in the process
8656 while ( dataTypes
[ 0 ] === "*" ) {
8658 if ( ct
=== undefined ) {
8659 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "Content-Type" );
8663 // Check if we're dealing with a known content-type
8665 for ( type
in contents
) {
8666 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
8667 dataTypes
.unshift( type
);
8673 // Check to see if we have a response for the expected dataType
8674 if ( dataTypes
[ 0 ] in responses
) {
8675 finalDataType
= dataTypes
[ 0 ];
8678 // Try convertible dataTypes
8679 for ( type
in responses
) {
8680 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[ 0 ] ] ) {
8681 finalDataType
= type
;
8684 if ( !firstDataType
) {
8685 firstDataType
= type
;
8689 // Or just use first one
8690 finalDataType
= finalDataType
|| firstDataType
;
8693 // If we found a dataType
8694 // We add the dataType to the list if needed
8695 // and return the corresponding response
8696 if ( finalDataType
) {
8697 if ( finalDataType
!== dataTypes
[ 0 ] ) {
8698 dataTypes
.unshift( finalDataType
);
8700 return responses
[ finalDataType
];
8704 /* Chain conversions given the request and the original response
8705 * Also sets the responseXXX fields on the jqXHR instance
8707 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
8708 var conv2
, current
, conv
, tmp
, prev
,
8711 // Work with a copy of dataTypes in case we need to modify it for conversion
8712 dataTypes
= s
.dataTypes
.slice();
8714 // Create converters map with lowercased keys
8715 if ( dataTypes
[ 1 ] ) {
8716 for ( conv
in s
.converters
) {
8717 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
8721 current
= dataTypes
.shift();
8723 // Convert to each sequential dataType
8726 if ( s
.responseFields
[ current
] ) {
8727 jqXHR
[ s
.responseFields
[ current
] ] = response
;
8730 // Apply the dataFilter if provided
8731 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
8732 response
= s
.dataFilter( response
, s
.dataType
);
8736 current
= dataTypes
.shift();
8740 // There's only work to do if current dataType is non-auto
8741 if ( current
=== "*" ) {
8745 // Convert response if prev dataType is non-auto and differs from current
8746 } else if ( prev
!== "*" && prev
!== current
) {
8748 // Seek a direct converter
8749 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
8751 // If none found, seek a pair
8753 for ( conv2
in converters
) {
8755 // If conv2 outputs current
8756 tmp
= conv2
.split( " " );
8757 if ( tmp
[ 1 ] === current
) {
8759 // If prev can be converted to accepted input
8760 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
8761 converters
[ "* " + tmp
[ 0 ] ];
8764 // Condense equivalence converters
8765 if ( conv
=== true ) {
8766 conv
= converters
[ conv2
];
8768 // Otherwise, insert the intermediate dataType
8769 } else if ( converters
[ conv2
] !== true ) {
8771 dataTypes
.unshift( tmp
[ 1 ] );
8779 // Apply converter (if not an equivalence)
8780 if ( conv
!== true ) {
8782 // Unless errors are allowed to bubble, catch and return them
8783 if ( conv
&& s
.throws ) {
8784 response
= conv( response
);
8787 response
= conv( response
);
8790 state
: "parsererror",
8791 error
: conv
? e
: "No conversion from " + prev
+ " to " + current
8800 return { state
: "success", data
: response
};
8805 // Counter for holding the number of active queries
8808 // Last-Modified header cache for next request
8815 isLocal
: rlocalProtocol
.test( location
.protocol
),
8819 contentType
: "application/x-www-form-urlencoded; charset=UTF-8",
8837 xml
: "application/xml, text/xml",
8838 json
: "application/json, text/javascript"
8849 text
: "responseText",
8850 json
: "responseJSON"
8854 // Keys separate source (or catchall "*") and destination types with a single space
8857 // Convert anything to text
8860 // Text to html (true = no transformation)
8863 // Evaluate text as a json expression
8864 "text json": JSON
.parse
,
8866 // Parse text as xml
8867 "text xml": jQuery
.parseXML
8870 // For options that shouldn't be deep extended:
8871 // you can add your own custom options here if
8872 // and when you create one that shouldn't be
8873 // deep extended (see ajaxExtend)
8880 // Creates a full fledged settings object into target
8881 // with both ajaxSettings and settings fields.
8882 // If target is omitted, writes into ajaxSettings.
8883 ajaxSetup: function( target
, settings
) {
8886 // Building a settings object
8887 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
8889 // Extending ajaxSettings
8890 ajaxExtend( jQuery
.ajaxSettings
, target
);
8893 ajaxPrefilter
: addToPrefiltersOrTransports( prefilters
),
8894 ajaxTransport
: addToPrefiltersOrTransports( transports
),
8897 ajax: function( url
, options
) {
8899 // If url is an object, simulate pre-1.5 signature
8900 if ( typeof url
=== "object" ) {
8905 // Force options to be an object
8906 options
= options
|| {};
8910 // URL without anti-cache param
8914 responseHeadersString
,
8923 // Request state (becomes false upon send and true upon completion)
8926 // To know if global events are to be dispatched
8932 // uncached part of the url
8935 // Create the final options object
8936 s
= jQuery
.ajaxSetup( {}, options
),
8938 // Callbacks context
8939 callbackContext
= s
.context
|| s
,
8941 // Context for global events is callbackContext if it is a DOM node or jQuery collection
8942 globalEventContext
= s
.context
&&
8943 ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
8944 jQuery( callbackContext
) :
8948 deferred
= jQuery
.Deferred(),
8949 completeDeferred
= jQuery
.Callbacks( "once memory" ),
8951 // Status-dependent callbacks
8952 statusCode
= s
.statusCode
|| {},
8954 // Headers (they are sent all at once)
8955 requestHeaders
= {},
8956 requestHeadersNames
= {},
8958 // Default abort message
8959 strAbort
= "canceled",
8965 // Builds headers hashtable if needed
8966 getResponseHeader: function( key
) {
8969 if ( !responseHeaders
) {
8970 responseHeaders
= {};
8971 while ( ( match
= rheaders
.exec( responseHeadersString
) ) ) {
8972 responseHeaders
[ match
[ 1 ].toLowerCase() ] = match
[ 2 ];
8975 match
= responseHeaders
[ key
.toLowerCase() ];
8977 return match
== null ? null : match
;
8981 getAllResponseHeaders: function() {
8982 return completed
? responseHeadersString
: null;
8985 // Caches the header
8986 setRequestHeader: function( name
, value
) {
8987 if ( completed
== null ) {
8988 name
= requestHeadersNames
[ name
.toLowerCase() ] =
8989 requestHeadersNames
[ name
.toLowerCase() ] || name
;
8990 requestHeaders
[ name
] = value
;
8995 // Overrides response content-type header
8996 overrideMimeType: function( type
) {
8997 if ( completed
== null ) {
9003 // Status-dependent callbacks
9004 statusCode: function( map
) {
9009 // Execute the appropriate callbacks
9010 jqXHR
.always( map
[ jqXHR
.status
] );
9013 // Lazy-add the new callbacks in a way that preserves old ones
9014 for ( code
in map
) {
9015 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
9022 // Cancel the request
9023 abort: function( statusText
) {
9024 var finalText
= statusText
|| strAbort
;
9026 transport
.abort( finalText
);
9028 done( 0, finalText
);
9034 deferred
.promise( jqXHR
);
9036 // Add protocol if not provided (prefilters might expect it)
9037 // Handle falsy url in the settings object (#10093: consistency with old signature)
9038 // We also use the url parameter if available
9039 s
.url
= ( ( url
|| s
.url
|| location
.href
) + "" )
9040 .replace( rprotocol
, location
.protocol
+ "//" );
9042 // Alias method option to type as per ticket #12004
9043 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
9045 // Extract dataTypes list
9046 s
.dataTypes
= ( s
.dataType
|| "*" ).toLowerCase().match( rnothtmlwhite
) || [ "" ];
9048 // A cross-domain request is in order when the origin doesn't match the current origin.
9049 if ( s
.crossDomain
== null ) {
9050 urlAnchor
= document
.createElement( "a" );
9052 // Support: IE <=8 - 11, Edge 12 - 15
9053 // IE throws exception on accessing the href property if url is malformed,
9054 // e.g. http://example.com:80x/
9056 urlAnchor
.href
= s
.url
;
9058 // Support: IE <=8 - 11 only
9059 // Anchor's host property isn't correctly set when s.url is relative
9060 urlAnchor
.href
= urlAnchor
.href
;
9061 s
.crossDomain
= originAnchor
.protocol
+ "//" + originAnchor
.host
!==
9062 urlAnchor
.protocol
+ "//" + urlAnchor
.host
;
9065 // If there is an error parsing the URL, assume it is crossDomain,
9066 // it can be rejected by the transport if it is invalid
9067 s
.crossDomain
= true;
9071 // Convert data if not already a string
9072 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
9073 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
9077 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
9079 // If request was aborted inside a prefilter, stop there
9084 // We can fire global events as of now if asked to
9085 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9086 fireGlobals
= jQuery
.event
&& s
.global
;
9088 // Watch for a new set of requests
9089 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
9090 jQuery
.event
.trigger( "ajaxStart" );
9093 // Uppercase the type
9094 s
.type
= s
.type
.toUpperCase();
9096 // Determine if request has content
9097 s
.hasContent
= !rnoContent
.test( s
.type
);
9099 // Save the URL in case we're toying with the If-Modified-Since
9100 // and/or If-None-Match header later on
9101 // Remove hash to simplify url manipulation
9102 cacheURL
= s
.url
.replace( rhash
, "" );
9104 // More options handling for requests with no content
9105 if ( !s
.hasContent
) {
9107 // Remember the hash so we can put it back
9108 uncached
= s
.url
.slice( cacheURL
.length
);
9110 // If data is available and should be processed, append data to url
9111 if ( s
.data
&& ( s
.processData
|| typeof s
.data
=== "string" ) ) {
9112 cacheURL
+= ( rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
;
9114 // #9682: remove data so that it's not used in an eventual retry
9118 // Add or update anti-cache param if needed
9119 if ( s
.cache
=== false ) {
9120 cacheURL
= cacheURL
.replace( rantiCache
, "$1" );
9121 uncached
= ( rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + ( nonce
++ ) + uncached
;
9124 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9125 s
.url
= cacheURL
+ uncached
;
9127 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9128 } else if ( s
.data
&& s
.processData
&&
9129 ( s
.contentType
|| "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9130 s
.data
= s
.data
.replace( r20
, "+" );
9133 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9134 if ( s
.ifModified
) {
9135 if ( jQuery
.lastModified
[ cacheURL
] ) {
9136 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
9138 if ( jQuery
.etag
[ cacheURL
] ) {
9139 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
9143 // Set the correct header, if data is being sent
9144 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
9145 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
9148 // Set the Accepts header for the server, depending on the dataType
9149 jqXHR
.setRequestHeader(
9151 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[ 0 ] ] ?
9152 s
.accepts
[ s
.dataTypes
[ 0 ] ] +
9153 ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
9157 // Check for headers option
9158 for ( i
in s
.headers
) {
9159 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
9162 // Allow custom headers/mimetypes and early abort
9163 if ( s
.beforeSend
&&
9164 ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || completed
) ) {
9166 // Abort if not done already and return
9167 return jqXHR
.abort();
9170 // Aborting is no longer a cancellation
9173 // Install callbacks on deferreds
9174 completeDeferred
.add( s
.complete
);
9175 jqXHR
.done( s
.success
);
9176 jqXHR
.fail( s
.error
);
9179 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
9181 // If no transport, we auto-abort
9183 done( -1, "No Transport" );
9185 jqXHR
.readyState
= 1;
9187 // Send global event
9188 if ( fireGlobals
) {
9189 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
9192 // If request was aborted inside ajaxSend, stop there
9198 if ( s
.async
&& s
.timeout
> 0 ) {
9199 timeoutTimer
= window
.setTimeout( function() {
9200 jqXHR
.abort( "timeout" );
9206 transport
.send( requestHeaders
, done
);
9209 // Rethrow post-completion exceptions
9214 // Propagate others as results
9219 // Callback for when everything is done
9220 function done( status
, nativeStatusText
, responses
, headers
) {
9221 var isSuccess
, success
, error
, response
, modified
,
9222 statusText
= nativeStatusText
;
9224 // Ignore repeat invocations
9231 // Clear timeout if it exists
9232 if ( timeoutTimer
) {
9233 window
.clearTimeout( timeoutTimer
);
9236 // Dereference transport for early garbage collection
9237 // (no matter how long the jqXHR object will be used)
9238 transport
= undefined;
9240 // Cache response headers
9241 responseHeadersString
= headers
|| "";
9244 jqXHR
.readyState
= status
> 0 ? 4 : 0;
9246 // Determine if successful
9247 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
9249 // Get response data
9251 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
9254 // Convert no matter what (that way responseXXX fields are always set)
9255 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
9257 // If successful, handle type chaining
9260 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9261 if ( s
.ifModified
) {
9262 modified
= jqXHR
.getResponseHeader( "Last-Modified" );
9264 jQuery
.lastModified
[ cacheURL
] = modified
;
9266 modified
= jqXHR
.getResponseHeader( "etag" );
9268 jQuery
.etag
[ cacheURL
] = modified
;
9273 if ( status
=== 204 || s
.type
=== "HEAD" ) {
9274 statusText
= "nocontent";
9277 } else if ( status
=== 304 ) {
9278 statusText
= "notmodified";
9280 // If we have data, let's convert it
9282 statusText
= response
.state
;
9283 success
= response
.data
;
9284 error
= response
.error
;
9289 // Extract error from statusText and normalize for non-aborts
9291 if ( status
|| !statusText
) {
9292 statusText
= "error";
9299 // Set data for the fake xhr object
9300 jqXHR
.status
= status
;
9301 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
9305 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
9307 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
9310 // Status-dependent callbacks
9311 jqXHR
.statusCode( statusCode
);
9312 statusCode
= undefined;
9314 if ( fireGlobals
) {
9315 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
9316 [ jqXHR
, s
, isSuccess
? success
: error
] );
9320 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
9322 if ( fireGlobals
) {
9323 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
9325 // Handle the global AJAX counter
9326 if ( !( --jQuery
.active
) ) {
9327 jQuery
.event
.trigger( "ajaxStop" );
9335 getJSON: function( url
, data
, callback
) {
9336 return jQuery
.get( url
, data
, callback
, "json" );
9339 getScript: function( url
, callback
) {
9340 return jQuery
.get( url
, undefined, callback
, "script" );
9344 jQuery
.each( [ "get", "post" ], function( i
, method
) {
9345 jQuery
[ method
] = function( url
, data
, callback
, type
) {
9347 // Shift arguments if data argument was omitted
9348 if ( isFunction( data
) ) {
9349 type
= type
|| callback
;
9354 // The url can be an options object (which then must have .url)
9355 return jQuery
.ajax( jQuery
.extend( {
9361 }, jQuery
.isPlainObject( url
) && url
) );
9366 jQuery
._evalUrl = function( url
) {
9367 return jQuery
.ajax( {
9370 // Make this explicit, since user can override this through ajaxSetup (#11264)
9382 wrapAll: function( html
) {
9386 if ( isFunction( html
) ) {
9387 html
= html
.call( this[ 0 ] );
9390 // The elements to wrap the target around
9391 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
9393 if ( this[ 0 ].parentNode
) {
9394 wrap
.insertBefore( this[ 0 ] );
9397 wrap
.map( function() {
9400 while ( elem
.firstElementChild
) {
9401 elem
= elem
.firstElementChild
;
9411 wrapInner: function( html
) {
9412 if ( isFunction( html
) ) {
9413 return this.each( function( i
) {
9414 jQuery( this ).wrapInner( html
.call( this, i
) );
9418 return this.each( function() {
9419 var self
= jQuery( this ),
9420 contents
= self
.contents();
9422 if ( contents
.length
) {
9423 contents
.wrapAll( html
);
9426 self
.append( html
);
9431 wrap: function( html
) {
9432 var htmlIsFunction
= isFunction( html
);
9434 return this.each( function( i
) {
9435 jQuery( this ).wrapAll( htmlIsFunction
? html
.call( this, i
) : html
);
9439 unwrap: function( selector
) {
9440 this.parent( selector
).not( "body" ).each( function() {
9441 jQuery( this ).replaceWith( this.childNodes
);
9448 jQuery
.expr
.pseudos
.hidden = function( elem
) {
9449 return !jQuery
.expr
.pseudos
.visible( elem
);
9451 jQuery
.expr
.pseudos
.visible = function( elem
) {
9452 return !!( elem
.offsetWidth
|| elem
.offsetHeight
|| elem
.getClientRects().length
);
9458 jQuery
.ajaxSettings
.xhr = function() {
9460 return new window
.XMLHttpRequest();
9464 var xhrSuccessStatus
= {
9466 // File protocol always yields status code 0, assume 200
9469 // Support: IE <=9 only
9470 // #1450: sometimes IE returns 1223 when it should be 204
9473 xhrSupported
= jQuery
.ajaxSettings
.xhr();
9475 support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
9476 support
.ajax
= xhrSupported
= !!xhrSupported
;
9478 jQuery
.ajaxTransport( function( options
) {
9479 var callback
, errorCallback
;
9481 // Cross domain only allowed if supported through XMLHttpRequest
9482 if ( support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
9484 send: function( headers
, complete
) {
9486 xhr
= options
.xhr();
9496 // Apply custom fields if provided
9497 if ( options
.xhrFields
) {
9498 for ( i
in options
.xhrFields
) {
9499 xhr
[ i
] = options
.xhrFields
[ i
];
9503 // Override mime type if needed
9504 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
9505 xhr
.overrideMimeType( options
.mimeType
);
9508 // X-Requested-With header
9509 // For cross-domain requests, seeing as conditions for a preflight are
9510 // akin to a jigsaw puzzle, we simply never set it to be sure.
9511 // (it can always be set on a per-request basis or even using ajaxSetup)
9512 // For same-domain requests, won't change header if already provided.
9513 if ( !options
.crossDomain
&& !headers
[ "X-Requested-With" ] ) {
9514 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
9518 for ( i
in headers
) {
9519 xhr
.setRequestHeader( i
, headers
[ i
] );
9523 callback = function( type
) {
9526 callback
= errorCallback
= xhr
.onload
=
9527 xhr
.onerror
= xhr
.onabort
= xhr
.ontimeout
=
9528 xhr
.onreadystatechange
= null;
9530 if ( type
=== "abort" ) {
9532 } else if ( type
=== "error" ) {
9534 // Support: IE <=9 only
9535 // On a manual native abort, IE9 throws
9536 // errors on any property access that is not readyState
9537 if ( typeof xhr
.status
!== "number" ) {
9538 complete( 0, "error" );
9542 // File: protocol always yields status 0; see #8605, #14207
9549 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
9552 // Support: IE <=9 only
9553 // IE9 has no XHR2 but throws on binary (trac-11426)
9554 // For XHR2 non-text, let the caller handle it (gh-2498)
9555 ( xhr
.responseType
|| "text" ) !== "text" ||
9556 typeof xhr
.responseText
!== "string" ?
9557 { binary
: xhr
.response
} :
9558 { text
: xhr
.responseText
},
9559 xhr
.getAllResponseHeaders()
9567 xhr
.onload
= callback();
9568 errorCallback
= xhr
.onerror
= xhr
.ontimeout
= callback( "error" );
9570 // Support: IE 9 only
9571 // Use onreadystatechange to replace onabort
9572 // to handle uncaught aborts
9573 if ( xhr
.onabort
!== undefined ) {
9574 xhr
.onabort
= errorCallback
;
9576 xhr
.onreadystatechange = function() {
9578 // Check readyState before timeout as it changes
9579 if ( xhr
.readyState
=== 4 ) {
9581 // Allow onerror to be called first,
9582 // but that will not handle a native abort
9583 // Also, save errorCallback to a variable
9584 // as xhr.onerror cannot be accessed
9585 window
.setTimeout( function() {
9594 // Create the abort callback
9595 callback
= callback( "abort" );
9599 // Do send the request (this may raise an exception)
9600 xhr
.send( options
.hasContent
&& options
.data
|| null );
9603 // #14683: Only rethrow if this hasn't been notified as an error yet
9622 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
9623 jQuery
.ajaxPrefilter( function( s
) {
9624 if ( s
.crossDomain
) {
9625 s
.contents
.script
= false;
9629 // Install script dataType
9632 script
: "text/javascript, application/javascript, " +
9633 "application/ecmascript, application/x-ecmascript"
9636 script
: /\b(?:java|ecma)script\b/
9639 "text script": function( text
) {
9640 jQuery
.globalEval( text
);
9646 // Handle cache's special case and crossDomain
9647 jQuery
.ajaxPrefilter( "script", function( s
) {
9648 if ( s
.cache
=== undefined ) {
9651 if ( s
.crossDomain
) {
9656 // Bind script tag hack transport
9657 jQuery
.ajaxTransport( "script", function( s
) {
9659 // This transport only deals with cross domain requests
9660 if ( s
.crossDomain
) {
9661 var script
, callback
;
9663 send: function( _
, complete
) {
9664 script
= jQuery( "<script>" ).prop( {
9665 charset
: s
.scriptCharset
,
9669 callback = function( evt
) {
9673 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
9678 // Use native DOM manipulation to avoid our domManip AJAX trickery
9679 document
.head
.appendChild( script
[ 0 ] );
9693 var oldCallbacks
= [],
9694 rjsonp
= /(=)\?(?=&|$)|\?\?/;
9696 // Default jsonp settings
9699 jsonpCallback: function() {
9700 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
++ ) );
9701 this[ callback
] = true;
9706 // Detect, normalize options and install callbacks for jsonp requests
9707 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
9709 var callbackName
, overwritten
, responseContainer
,
9710 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
9712 typeof s
.data
=== "string" &&
9713 ( s
.contentType
|| "" )
9714 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
9715 rjsonp
.test( s
.data
) && "data"
9718 // Handle iff the expected data type is "jsonp" or we have a parameter to set
9719 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
9721 // Get callback name, remembering preexisting value associated with it
9722 callbackName
= s
.jsonpCallback
= isFunction( s
.jsonpCallback
) ?
9726 // Insert callback into url or form data
9728 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
9729 } else if ( s
.jsonp
!== false ) {
9730 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
9733 // Use data converter to retrieve json after script execution
9734 s
.converters
[ "script json" ] = function() {
9735 if ( !responseContainer
) {
9736 jQuery
.error( callbackName
+ " was not called" );
9738 return responseContainer
[ 0 ];
9741 // Force json dataType
9742 s
.dataTypes
[ 0 ] = "json";
9745 overwritten
= window
[ callbackName
];
9746 window
[ callbackName
] = function() {
9747 responseContainer
= arguments
;
9750 // Clean-up function (fires after converters)
9751 jqXHR
.always( function() {
9753 // If previous value didn't exist - remove it
9754 if ( overwritten
=== undefined ) {
9755 jQuery( window
).removeProp( callbackName
);
9757 // Otherwise restore preexisting value
9759 window
[ callbackName
] = overwritten
;
9762 // Save back as free
9763 if ( s
[ callbackName
] ) {
9765 // Make sure that re-using the options doesn't screw things around
9766 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
9768 // Save the callback name for future use
9769 oldCallbacks
.push( callbackName
);
9772 // Call if it was a function and we have a response
9773 if ( responseContainer
&& isFunction( overwritten
) ) {
9774 overwritten( responseContainer
[ 0 ] );
9777 responseContainer
= overwritten
= undefined;
9780 // Delegate to script
9788 // Support: Safari 8 only
9789 // In Safari 8 documents created via document.implementation.createHTMLDocument
9790 // collapse sibling forms: the second one becomes a child of the first one.
9791 // Because of that, this security measure has to be disabled in Safari 8.
9792 // https://bugs.webkit.org/show_bug.cgi?id=137337
9793 support
.createHTMLDocument
= ( function() {
9794 var body
= document
.implementation
.createHTMLDocument( "" ).body
;
9795 body
.innerHTML
= "<form></form><form></form>";
9796 return body
.childNodes
.length
=== 2;
9800 // Argument "data" should be string of html
9801 // context (optional): If specified, the fragment will be created in this context,
9802 // defaults to document
9803 // keepScripts (optional): If true, will include scripts passed in the html string
9804 jQuery
.parseHTML = function( data
, context
, keepScripts
) {
9805 if ( typeof data
!== "string" ) {
9808 if ( typeof context
=== "boolean" ) {
9809 keepScripts
= context
;
9813 var base
, parsed
, scripts
;
9817 // Stop scripts or inline event handlers from being executed immediately
9818 // by using document.implementation
9819 if ( support
.createHTMLDocument
) {
9820 context
= document
.implementation
.createHTMLDocument( "" );
9822 // Set the base href for the created document
9823 // so any parsed elements with URLs
9824 // are based on the document's URL (gh-2965)
9825 base
= context
.createElement( "base" );
9826 base
.href
= document
.location
.href
;
9827 context
.head
.appendChild( base
);
9833 parsed
= rsingleTag
.exec( data
);
9834 scripts
= !keepScripts
&& [];
9838 return [ context
.createElement( parsed
[ 1 ] ) ];
9841 parsed
= buildFragment( [ data
], context
, scripts
);
9843 if ( scripts
&& scripts
.length
) {
9844 jQuery( scripts
).remove();
9847 return jQuery
.merge( [], parsed
.childNodes
);
9852 * Load a url into a page
9854 jQuery
.fn
.load = function( url
, params
, callback
) {
9855 var selector
, type
, response
,
9857 off
= url
.indexOf( " " );
9860 selector
= stripAndCollapse( url
.slice( off
) );
9861 url
= url
.slice( 0, off
);
9864 // If it's a function
9865 if ( isFunction( params
) ) {
9867 // We assume that it's the callback
9871 // Otherwise, build a param string
9872 } else if ( params
&& typeof params
=== "object" ) {
9876 // If we have elements to modify, make the request
9877 if ( self
.length
> 0 ) {
9881 // If "type" variable is undefined, then "GET" method will be used.
9882 // Make value of this field explicit since
9883 // user can override it through ajaxSetup method
9884 type
: type
|| "GET",
9887 } ).done( function( responseText
) {
9889 // Save response for use in complete callback
9890 response
= arguments
;
9892 self
.html( selector
?
9894 // If a selector was specified, locate the right elements in a dummy div
9895 // Exclude scripts to avoid IE 'Permission Denied' errors
9896 jQuery( "<div>" ).append( jQuery
.parseHTML( responseText
) ).find( selector
) :
9898 // Otherwise use the full result
9901 // If the request succeeds, this function gets "data", "status", "jqXHR"
9902 // but they are ignored because response was set above.
9903 // If it fails, this function gets "jqXHR", "status", "error"
9904 } ).always( callback
&& function( jqXHR
, status
) {
9905 self
.each( function() {
9906 callback
.apply( this, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
9917 // Attach a bunch of functions for handling common AJAX events
9925 ], function( i
, type
) {
9926 jQuery
.fn
[ type
] = function( fn
) {
9927 return this.on( type
, fn
);
9934 jQuery
.expr
.pseudos
.animated = function( elem
) {
9935 return jQuery
.grep( jQuery
.timers
, function( fn
) {
9936 return elem
=== fn
.elem
;
9944 setOffset: function( elem
, options
, i
) {
9945 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
9946 position
= jQuery
.css( elem
, "position" ),
9947 curElem
= jQuery( elem
),
9950 // Set position first, in-case top/left are set even on static elem
9951 if ( position
=== "static" ) {
9952 elem
.style
.position
= "relative";
9955 curOffset
= curElem
.offset();
9956 curCSSTop
= jQuery
.css( elem
, "top" );
9957 curCSSLeft
= jQuery
.css( elem
, "left" );
9958 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) &&
9959 ( curCSSTop
+ curCSSLeft
).indexOf( "auto" ) > -1;
9961 // Need to be able to calculate position if either
9962 // top or left is auto and position is either absolute or fixed
9963 if ( calculatePosition
) {
9964 curPosition
= curElem
.position();
9965 curTop
= curPosition
.top
;
9966 curLeft
= curPosition
.left
;
9969 curTop
= parseFloat( curCSSTop
) || 0;
9970 curLeft
= parseFloat( curCSSLeft
) || 0;
9973 if ( isFunction( options
) ) {
9975 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
9976 options
= options
.call( elem
, i
, jQuery
.extend( {}, curOffset
) );
9979 if ( options
.top
!= null ) {
9980 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
9982 if ( options
.left
!= null ) {
9983 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
9986 if ( "using" in options
) {
9987 options
.using
.call( elem
, props
);
9990 curElem
.css( props
);
9997 // offset() relates an element's border box to the document origin
9998 offset: function( options
) {
10000 // Preserve chaining for setter
10001 if ( arguments
.length
) {
10002 return options
=== undefined ?
10004 this.each( function( i
) {
10005 jQuery
.offset
.setOffset( this, options
, i
);
10016 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
10017 // Support: IE <=11 only
10018 // Running getBoundingClientRect on a
10019 // disconnected node in IE throws an error
10020 if ( !elem
.getClientRects().length
) {
10021 return { top
: 0, left
: 0 };
10024 // Get document-relative position by adding viewport scroll to viewport-relative gBCR
10025 rect
= elem
.getBoundingClientRect();
10026 win
= elem
.ownerDocument
.defaultView
;
10028 top
: rect
.top
+ win
.pageYOffset
,
10029 left
: rect
.left
+ win
.pageXOffset
10033 // position() relates an element's margin box to its offset parent's padding box
10034 // This corresponds to the behavior of CSS absolute positioning
10035 position: function() {
10036 if ( !this[ 0 ] ) {
10040 var offsetParent
, offset
, doc
,
10042 parentOffset
= { top
: 0, left
: 0 };
10044 // position:fixed elements are offset from the viewport, which itself always has zero offset
10045 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
10047 // Assume position:fixed implies availability of getBoundingClientRect
10048 offset
= elem
.getBoundingClientRect();
10051 offset
= this.offset();
10053 // Account for the *real* offset parent, which can be the document or its root element
10054 // when a statically positioned element is identified
10055 doc
= elem
.ownerDocument
;
10056 offsetParent
= elem
.offsetParent
|| doc
.documentElement
;
10057 while ( offsetParent
&&
10058 ( offsetParent
=== doc
.body
|| offsetParent
=== doc
.documentElement
) &&
10059 jQuery
.css( offsetParent
, "position" ) === "static" ) {
10061 offsetParent
= offsetParent
.parentNode
;
10063 if ( offsetParent
&& offsetParent
!== elem
&& offsetParent
.nodeType
=== 1 ) {
10065 // Incorporate borders into its offset, since they are outside its content origin
10066 parentOffset
= jQuery( offsetParent
).offset();
10067 parentOffset
.top
+= jQuery
.css( offsetParent
, "borderTopWidth", true );
10068 parentOffset
.left
+= jQuery
.css( offsetParent
, "borderLeftWidth", true );
10072 // Subtract parent offsets and element margins
10074 top
: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
10075 left
: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
10079 // This method will return documentElement in the following cases:
10080 // 1) For the element inside the iframe without offsetParent, this method will return
10081 // documentElement of the parent window
10082 // 2) For the hidden or detached element
10083 // 3) For body or html element, i.e. in case of the html node - it will return itself
10085 // but those exceptions were never presented as a real life use-cases
10086 // and might be considered as more preferable results.
10088 // This logic, however, is not guaranteed and can change at any point in the future
10089 offsetParent: function() {
10090 return this.map( function() {
10091 var offsetParent
= this.offsetParent
;
10093 while ( offsetParent
&& jQuery
.css( offsetParent
, "position" ) === "static" ) {
10094 offsetParent
= offsetParent
.offsetParent
;
10097 return offsetParent
|| documentElement
;
10102 // Create scrollLeft and scrollTop methods
10103 jQuery
.each( { scrollLeft
: "pageXOffset", scrollTop
: "pageYOffset" }, function( method
, prop
) {
10104 var top
= "pageYOffset" === prop
;
10106 jQuery
.fn
[ method
] = function( val
) {
10107 return access( this, function( elem
, method
, val
) {
10109 // Coalesce documents and windows
10111 if ( isWindow( elem
) ) {
10113 } else if ( elem
.nodeType
=== 9 ) {
10114 win
= elem
.defaultView
;
10117 if ( val
=== undefined ) {
10118 return win
? win
[ prop
] : elem
[ method
];
10123 !top
? val
: win
.pageXOffset
,
10124 top
? val
: win
.pageYOffset
10128 elem
[ method
] = val
;
10130 }, method
, val
, arguments
.length
);
10134 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10135 // Add the top/left cssHooks using jQuery.fn.position
10136 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10137 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10138 // getComputedStyle returns percent when specified for top/left/bottom/right;
10139 // rather than make the css module depend on the offset module, just check for it here
10140 jQuery
.each( [ "top", "left" ], function( i
, prop
) {
10141 jQuery
.cssHooks
[ prop
] = addGetHookIf( support
.pixelPosition
,
10142 function( elem
, computed
) {
10144 computed
= curCSS( elem
, prop
);
10146 // If curCSS returns percentage, fallback to offset
10147 return rnumnonpx
.test( computed
) ?
10148 jQuery( elem
).position()[ prop
] + "px" :
10156 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10157 jQuery
.each( { Height
: "height", Width
: "width" }, function( name
, type
) {
10158 jQuery
.each( { padding
: "inner" + name
, content
: type
, "": "outer" + name
},
10159 function( defaultExtra
, funcName
) {
10161 // Margin is only for outerHeight, outerWidth
10162 jQuery
.fn
[ funcName
] = function( margin
, value
) {
10163 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
10164 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
10166 return access( this, function( elem
, type
, value
) {
10169 if ( isWindow( elem
) ) {
10171 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10172 return funcName
.indexOf( "outer" ) === 0 ?
10173 elem
[ "inner" + name
] :
10174 elem
.document
.documentElement
[ "client" + name
];
10177 // Get document width or height
10178 if ( elem
.nodeType
=== 9 ) {
10179 doc
= elem
.documentElement
;
10181 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10182 // whichever is greatest
10184 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
10185 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
10186 doc
[ "client" + name
]
10190 return value
=== undefined ?
10192 // Get width or height on the element, requesting but not forcing parseFloat
10193 jQuery
.css( elem
, type
, extra
) :
10195 // Set width or height on the element
10196 jQuery
.style( elem
, type
, value
, extra
);
10197 }, type
, chainable
? margin
: undefined, chainable
);
10203 jQuery
.each( ( "blur focus focusin focusout resize scroll click dblclick " +
10204 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10205 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
10206 function( i
, name
) {
10208 // Handle event binding
10209 jQuery
.fn
[ name
] = function( data
, fn
) {
10210 return arguments
.length
> 0 ?
10211 this.on( name
, null, data
, fn
) :
10212 this.trigger( name
);
10216 jQuery
.fn
.extend( {
10217 hover: function( fnOver
, fnOut
) {
10218 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
10225 jQuery
.fn
.extend( {
10227 bind: function( types
, data
, fn
) {
10228 return this.on( types
, null, data
, fn
);
10230 unbind: function( types
, fn
) {
10231 return this.off( types
, null, fn
);
10234 delegate: function( selector
, types
, data
, fn
) {
10235 return this.on( types
, selector
, data
, fn
);
10237 undelegate: function( selector
, types
, fn
) {
10239 // ( namespace ) or ( selector, types [, fn] )
10240 return arguments
.length
=== 1 ?
10241 this.off( selector
, "**" ) :
10242 this.off( types
, selector
|| "**", fn
);
10246 // Bind a function to a context, optionally partially applying any
10248 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10249 // However, it is not slated for removal any time soon
10250 jQuery
.proxy = function( fn
, context
) {
10251 var tmp
, args
, proxy
;
10253 if ( typeof context
=== "string" ) {
10254 tmp
= fn
[ context
];
10259 // Quick check to determine if target is callable, in the spec
10260 // this throws a TypeError, but we will just return undefined.
10261 if ( !isFunction( fn
) ) {
10266 args
= slice
.call( arguments
, 2 );
10267 proxy = function() {
10268 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
10271 // Set the guid of unique handler to the same of original handler, so it can be removed
10272 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
10277 jQuery
.holdReady = function( hold
) {
10279 jQuery
.readyWait
++;
10281 jQuery
.ready( true );
10284 jQuery
.isArray
= Array
.isArray
;
10285 jQuery
.parseJSON
= JSON
.parse
;
10286 jQuery
.nodeName
= nodeName
;
10287 jQuery
.isFunction
= isFunction
;
10288 jQuery
.isWindow
= isWindow
;
10289 jQuery
.camelCase
= camelCase
;
10290 jQuery
.type
= toType
;
10292 jQuery
.now
= Date
.now
;
10294 jQuery
.isNumeric = function( obj
) {
10296 // As of jQuery 3.0, isNumeric is limited to
10297 // strings and numbers (primitives or objects)
10298 // that can be coerced to finite numbers (gh-2662)
10299 var type
= jQuery
.type( obj
);
10300 return ( type
=== "number" || type
=== "string" ) &&
10302 // parseFloat NaNs numeric-cast false positives ("")
10303 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
10304 // subtraction forces infinities to NaN
10305 !isNaN( obj
- parseFloat( obj
) );
10311 // Register as a named AMD module, since jQuery can be concatenated with other
10312 // files that may use define, but not via a proper concatenation script that
10313 // understands anonymous AMD modules. A named AMD is safest and most robust
10314 // way to register. Lowercase jquery is used because AMD module names are
10315 // derived from file names, and jQuery is normally delivered in a lowercase
10316 // file name. Do this after creating the global so that if an AMD module wants
10317 // to call noConflict to hide this version of jQuery, it will work.
10319 // Note that for maximum portability, libraries that are not jQuery should
10320 // declare themselves as anonymous modules, and avoid setting a global if an
10321 // AMD loader is present. jQuery is a special case. For more information, see
10322 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10324 if ( typeof define
=== "function" && define
.amd
) {
10325 define( "jquery", [], function() {
10335 // Map over jQuery in case of overwrite
10336 _jQuery
= window
.jQuery
,
10338 // Map over the $ in case of overwrite
10341 jQuery
.noConflict = function( deep
) {
10342 if ( window
.$ === jQuery
) {
10346 if ( deep
&& window
.jQuery
=== jQuery
) {
10347 window
.jQuery
= _jQuery
;
10353 // Expose jQuery and $ identifiers, even in AMD
10354 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10355 // and CommonJS for browser emulators (#13566)
10357 window
.jQuery
= window
.$ = jQuery
;