2 * jQuery JavaScript Library v3.2.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: 2017-03-20T18:59Z
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
);
76 function DOMEval( code
, doc
) {
77 doc
= doc
|| document
;
79 var script
= doc
.createElement( "script" );
82 doc
.head
.appendChild( script
).parentNode
.removeChild( script
);
85 // Defining this global in .eslintrc.json would create a danger of using the global
86 // unguarded in another place, it seems safer to define global only for this module
93 // Define a local copy of jQuery
94 jQuery = function( selector
, context
) {
96 // The jQuery object is actually just the init constructor 'enhanced'
97 // Need init if jQuery is called (just allow error to be thrown if not included)
98 return new jQuery
.fn
.init( selector
, context
);
101 // Support: Android <=4.0 only
102 // Make sure we trim BOM and NBSP
103 rtrim
= /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
105 // Matches dashed string for camelizing
107 rdashAlpha
= /-([a-z])/g,
109 // Used by jQuery.camelCase as callback to replace()
110 fcamelCase = function( all
, letter
) {
111 return letter
.toUpperCase();
114 jQuery
.fn
= jQuery
.prototype = {
116 // The current version of jQuery being used
121 // The default length of a jQuery object is 0
124 toArray: function() {
125 return slice
.call( this );
128 // Get the Nth element in the matched element set OR
129 // Get the whole matched element set as a clean array
130 get: function( num
) {
132 // Return all the elements in a clean array
134 return slice
.call( this );
137 // Return just the one element from the set
138 return num
< 0 ? this[ num
+ this.length
] : this[ num
];
141 // Take an array of elements and push it onto the stack
142 // (returning the new matched element set)
143 pushStack: function( elems
) {
145 // Build a new jQuery matched element set
146 var ret
= jQuery
.merge( this.constructor(), elems
);
148 // Add the old object onto the stack (as a reference)
149 ret
.prevObject
= this;
151 // Return the newly-formed element set
155 // Execute a callback for every element in the matched set.
156 each: function( callback
) {
157 return jQuery
.each( this, callback
);
160 map: function( callback
) {
161 return this.pushStack( jQuery
.map( this, function( elem
, i
) {
162 return callback
.call( elem
, i
, elem
);
167 return this.pushStack( slice
.apply( this, arguments
) );
175 return this.eq( -1 );
179 var len
= this.length
,
180 j
= +i
+ ( i
< 0 ? len
: 0 );
181 return this.pushStack( j
>= 0 && j
< len
? [ this[ j
] ] : [] );
185 return this.prevObject
|| this.constructor();
188 // For internal use only.
189 // Behaves like an Array's method, not like a jQuery method.
195 jQuery
.extend
= jQuery
.fn
.extend = function() {
196 var options
, name
, src
, copy
, copyIsArray
, clone
,
197 target
= arguments
[ 0 ] || {},
199 length
= arguments
.length
,
202 // Handle a deep copy situation
203 if ( typeof target
=== "boolean" ) {
206 // Skip the boolean and the target
207 target
= arguments
[ i
] || {};
211 // Handle case when target is a string or something (possible in deep copy)
212 if ( typeof target
!== "object" && !jQuery
.isFunction( target
) ) {
216 // Extend jQuery itself if only one argument is passed
217 if ( i
=== length
) {
222 for ( ; i
< length
; i
++ ) {
224 // Only deal with non-null/undefined values
225 if ( ( options
= arguments
[ i
] ) != null ) {
227 // Extend the base object
228 for ( name
in options
) {
229 src
= target
[ name
];
230 copy
= options
[ name
];
232 // Prevent Object.prototype pollution
233 // Prevent never-ending loop
234 if ( name
=== "__proto__" || target
=== copy
) {
238 // Recurse if we're merging plain objects or arrays
239 if ( deep
&& copy
&& ( jQuery
.isPlainObject( copy
) ||
240 ( copyIsArray
= Array
.isArray( copy
) ) ) ) {
244 clone
= src
&& Array
.isArray( src
) ? src
: [];
247 clone
= src
&& jQuery
.isPlainObject( src
) ? src
: {};
250 // Never move original objects, clone them
251 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
253 // Don't bring in undefined values
254 } else if ( copy
!== undefined ) {
255 target
[ name
] = copy
;
261 // Return the modified object
267 // Unique for each copy of jQuery on the page
268 expando
: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
270 // Assume jQuery is ready without the ready module
273 error: function( msg
) {
274 throw new Error( msg
);
279 isFunction: function( obj
) {
280 return jQuery
.type( obj
) === "function";
283 isWindow: function( obj
) {
284 return obj
!= null && obj
=== obj
.window
;
287 isNumeric: function( obj
) {
289 // As of jQuery 3.0, isNumeric is limited to
290 // strings and numbers (primitives or objects)
291 // that can be coerced to finite numbers (gh-2662)
292 var type
= jQuery
.type( obj
);
293 return ( type
=== "number" || type
=== "string" ) &&
295 // parseFloat NaNs numeric-cast false positives ("")
296 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
297 // subtraction forces infinities to NaN
298 !isNaN( obj
- parseFloat( obj
) );
301 isPlainObject: function( obj
) {
304 // Detect obvious negatives
305 // Use toString instead of jQuery.type to catch host objects
306 if ( !obj
|| toString
.call( obj
) !== "[object Object]" ) {
310 proto
= getProto( obj
);
312 // Objects with no prototype (e.g., `Object.create( null )`) are plain
317 // Objects with prototype are plain iff they were constructed by a global Object function
318 Ctor
= hasOwn
.call( proto
, "constructor" ) && proto
.constructor;
319 return typeof Ctor
=== "function" && fnToString
.call( Ctor
) === ObjectFunctionString
;
322 isEmptyObject: function( obj
) {
324 /* eslint-disable no-unused-vars */
325 // See https://github.com/eslint/eslint/issues/6125
328 for ( name
in obj
) {
334 type: function( obj
) {
339 // Support: Android <=2.3 only (functionish RegExp)
340 return typeof obj
=== "object" || typeof obj
=== "function" ?
341 class2type
[ toString
.call( obj
) ] || "object" :
345 // Evaluates a script in a global context
346 globalEval: function( code
) {
350 // Convert dashed to camelCase; used by the css and data modules
351 // Support: IE <=9 - 11, Edge 12 - 13
352 // Microsoft forgot to hump their vendor prefix (#9572)
353 camelCase: function( string
) {
354 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
357 each: function( obj
, callback
) {
360 if ( isArrayLike( obj
) ) {
362 for ( ; i
< length
; i
++ ) {
363 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
369 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
378 // Support: Android <=4.0 only
379 trim: function( text
) {
380 return text
== null ?
382 ( text
+ "" ).replace( rtrim
, "" );
385 // results is for internal usage only
386 makeArray: function( arr
, results
) {
387 var ret
= results
|| [];
390 if ( isArrayLike( Object( arr
) ) ) {
392 typeof arr
=== "string" ?
396 push
.call( ret
, arr
);
403 inArray: function( elem
, arr
, i
) {
404 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
407 // Support: Android <=4.0 only, PhantomJS 1 only
408 // push.apply(_, arraylike) throws on ancient WebKit
409 merge: function( first
, second
) {
410 var len
= +second
.length
,
414 for ( ; j
< len
; j
++ ) {
415 first
[ i
++ ] = second
[ j
];
423 grep: function( elems
, callback
, invert
) {
427 length
= elems
.length
,
428 callbackExpect
= !invert
;
430 // Go through the array, only saving the items
431 // that pass the validator function
432 for ( ; i
< length
; i
++ ) {
433 callbackInverse
= !callback( elems
[ i
], i
);
434 if ( callbackInverse
!== callbackExpect
) {
435 matches
.push( elems
[ i
] );
442 // arg is for internal usage only
443 map: function( elems
, callback
, arg
) {
448 // Go through the array, translating each of the items to their new values
449 if ( isArrayLike( elems
) ) {
450 length
= elems
.length
;
451 for ( ; i
< length
; i
++ ) {
452 value
= callback( elems
[ i
], i
, arg
);
454 if ( value
!= null ) {
459 // Go through every key on the object,
462 value
= callback( elems
[ i
], i
, arg
);
464 if ( value
!= null ) {
470 // Flatten any nested arrays
471 return concat
.apply( [], ret
);
474 // A global GUID counter for objects
477 // Bind a function to a context, optionally partially applying any
479 proxy: function( fn
, context
) {
480 var tmp
, args
, proxy
;
482 if ( typeof context
=== "string" ) {
488 // Quick check to determine if target is callable, in the spec
489 // this throws a TypeError, but we will just return undefined.
490 if ( !jQuery
.isFunction( fn
) ) {
495 args
= slice
.call( arguments
, 2 );
497 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
500 // Set the guid of unique handler to the same of original handler, so it can be removed
501 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
508 // jQuery.support is not used in Core but other projects attach their
509 // properties to it so it needs to exist.
513 if ( typeof Symbol
=== "function" ) {
514 jQuery
.fn
[ Symbol
.iterator
] = arr
[ Symbol
.iterator
];
517 // Populate the class2type map
518 jQuery
.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
519 function( i
, name
) {
520 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
523 function isArrayLike( obj
) {
525 // Support: real iOS 8.2 only (not reproducible in simulator)
526 // `in` check used to prevent JIT error (gh-2145)
527 // hasOwn isn't used here due to false negatives
528 // regarding Nodelist length in IE
529 var length
= !!obj
&& "length" in obj
&& obj
.length
,
530 type
= jQuery
.type( obj
);
532 if ( type
=== "function" || jQuery
.isWindow( obj
) ) {
536 return type
=== "array" || length
=== 0 ||
537 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
541 * Sizzle CSS Selector Engine v2.3.3
542 * https://sizzlejs.com/
544 * Copyright jQuery Foundation and other contributors
545 * Released under the MIT license
546 * http://jquery.org/license
550 (function( window
) {
564 // Local document vars
574 // Instance-specific data
575 expando
= "sizzle" + 1 * new Date(),
576 preferredDoc
= window
.document
,
579 classCache
= createCache(),
580 tokenCache
= createCache(),
581 compilerCache
= createCache(),
582 sortOrder = function( a
, b
) {
590 hasOwn
= ({}).hasOwnProperty
,
593 push_native
= arr
.push
,
596 // Use a stripped-down indexOf as it's faster than native
597 // https://jsperf.com/thor-indexof-vs-for/5
598 indexOf = function( list
, elem
) {
601 for ( ; i
< len
; i
++ ) {
602 if ( list
[i
] === elem
) {
609 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
611 // Regular expressions
613 // http://www.w3.org/TR/css3-selectors/#whitespace
614 whitespace
= "[\\x20\\t\\r\\n\\f]",
616 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
617 identifier
= "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
619 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
620 attributes
= "\\[" + whitespace
+ "*(" + identifier
+ ")(?:" + whitespace
+
621 // Operator (capture 2)
622 "*([*^$|!~]?=)" + whitespace
+
623 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
624 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier
+ "))|)" + whitespace
+
627 pseudos
= ":(" + identifier
+ ")(?:\\((" +
628 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
629 // 1. quoted (capture 3; capture 4 or capture 5)
630 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
631 // 2. simple (capture 6)
632 "((?:\\\\.|[^\\\\()[\\]]|" + attributes
+ ")*)|" +
633 // 3. anything else (capture 2)
637 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
638 rwhitespace
= new RegExp( whitespace
+ "+", "g" ),
639 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
641 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
642 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
644 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*?)" + whitespace
+ "*\\]", "g" ),
646 rpseudo
= new RegExp( pseudos
),
647 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
650 "ID": new RegExp( "^#(" + identifier
+ ")" ),
651 "CLASS": new RegExp( "^\\.(" + identifier
+ ")" ),
652 "TAG": new RegExp( "^(" + identifier
+ "|[*])" ),
653 "ATTR": new RegExp( "^" + attributes
),
654 "PSEUDO": new RegExp( "^" + pseudos
),
655 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
656 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
657 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
658 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
659 // For use in libraries implementing .is()
660 // We use this for POS matching in `select`
661 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
662 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
665 rinputs
= /^(?:input|select|textarea|button)$/i,
668 rnative
= /^[^{]+\{\s*\[native \w/,
670 // Easily-parseable/retrievable ID or TAG or CLASS selectors
671 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
676 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
677 runescape
= new RegExp( "\\\\([\\da-f]{1,6}" + whitespace
+ "?|(" + whitespace
+ ")|.)", "ig" ),
678 funescape = function( _
, escaped
, escapedWhitespace
) {
679 var high
= "0x" + escaped
- 0x10000;
680 // NaN means non-codepoint
681 // Support: Firefox<24
682 // Workaround erroneous numeric interpretation of +"0x"
683 return high
!== high
|| escapedWhitespace
?
687 String
.fromCharCode( high
+ 0x10000 ) :
688 // Supplemental Plane codepoint (surrogate pair)
689 String
.fromCharCode( high
>> 10 | 0xD800, high
& 0x3FF | 0xDC00 );
692 // CSS string/identifier serialization
693 // https://drafts.csswg.org/cssom/#common-serializing-idioms
694 rcssescape
= /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
695 fcssescape = function( ch
, asCodePoint
) {
698 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
703 // Control characters and (dependent upon position) numbers get escaped as code points
704 return ch
.slice( 0, -1 ) + "\\" + ch
.charCodeAt( ch
.length
- 1 ).toString( 16 ) + " ";
707 // Other potentially-special ASCII characters get backslash-escaped
713 // Removing the function wrapper causes a "Permission Denied"
715 unloadHandler = function() {
719 disabledAncestor
= addCombinator(
721 return elem
.disabled
=== true && ("form" in elem
|| "label" in elem
);
723 { dir
: "parentNode", next
: "legend" }
726 // Optimize for push.apply( _, NodeList )
729 (arr
= slice
.call( preferredDoc
.childNodes
)),
730 preferredDoc
.childNodes
732 // Support: Android<4.0
733 // Detect silently failing push.apply
734 arr
[ preferredDoc
.childNodes
.length
].nodeType
;
736 push
= { apply
: arr
.length
?
738 // Leverage slice if possible
739 function( target
, els
) {
740 push_native
.apply( target
, slice
.call(els
) );
744 // Otherwise append directly
745 function( target
, els
) {
746 var j
= target
.length
,
748 // Can't trust NodeList.length
749 while ( (target
[j
++] = els
[i
++]) ) {}
750 target
.length
= j
- 1;
755 function Sizzle( selector
, context
, results
, seed
) {
756 var m
, i
, elem
, nid
, match
, groups
, newSelector
,
757 newContext
= context
&& context
.ownerDocument
,
759 // nodeType defaults to 9, since context defaults to document
760 nodeType
= context
? context
.nodeType
: 9;
762 results
= results
|| [];
764 // Return early from calls with invalid selector or context
765 if ( typeof selector
!== "string" || !selector
||
766 nodeType
!== 1 && nodeType
!== 9 && nodeType
!== 11 ) {
771 // Try to shortcut find operations (as opposed to filters) in HTML documents
774 if ( ( context
? context
.ownerDocument
|| context
: preferredDoc
) !== document
) {
775 setDocument( context
);
777 context
= context
|| document
;
779 if ( documentIsHTML
) {
781 // If the selector is sufficiently simple, try using a "get*By*" DOM method
782 // (excepting DocumentFragment context, where the methods don't exist)
783 if ( nodeType
!== 11 && (match
= rquickExpr
.exec( selector
)) ) {
786 if ( (m
= match
[1]) ) {
789 if ( nodeType
=== 9 ) {
790 if ( (elem
= context
.getElementById( m
)) ) {
792 // Support: IE, Opera, Webkit
793 // TODO: identify versions
794 // getElementById can match elements by name instead of ID
795 if ( elem
.id
=== m
) {
796 results
.push( elem
);
806 // Support: IE, Opera, Webkit
807 // TODO: identify versions
808 // getElementById can match elements by name instead of ID
809 if ( newContext
&& (elem
= newContext
.getElementById( m
)) &&
810 contains( context
, elem
) &&
813 results
.push( elem
);
819 } else if ( match
[2] ) {
820 push
.apply( results
, context
.getElementsByTagName( selector
) );
824 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&&
825 context
.getElementsByClassName
) {
827 push
.apply( results
, context
.getElementsByClassName( m
) );
832 // Take advantage of querySelectorAll
834 !compilerCache
[ selector
+ " " ] &&
835 (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
837 if ( nodeType
!== 1 ) {
838 newContext
= context
;
839 newSelector
= selector
;
841 // qSA looks outside Element context, which is not what we want
842 // Thanks to Andrew Dupont for this workaround technique
844 // Exclude object elements
845 } else if ( context
.nodeName
.toLowerCase() !== "object" ) {
847 // Capture the context ID, setting it first if necessary
848 if ( (nid
= context
.getAttribute( "id" )) ) {
849 nid
= nid
.replace( rcssescape
, fcssescape
);
851 context
.setAttribute( "id", (nid
= expando
) );
854 // Prefix every selector in the list
855 groups
= tokenize( selector
);
858 groups
[i
] = "#" + nid
+ " " + toSelector( groups
[i
] );
860 newSelector
= groups
.join( "," );
862 // Expand context for sibling selectors
863 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) ||
870 newContext
.querySelectorAll( newSelector
)
873 } catch ( qsaError
) {
875 if ( nid
=== expando
) {
876 context
.removeAttribute( "id" );
885 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
889 * Create key-value caches of limited size
890 * @returns {function(string, object)} Returns the Object data after storing it on itself with
891 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
892 * deleting the oldest entry
894 function createCache() {
897 function cache( key
, value
) {
898 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
899 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
900 // Only keep the most recent entries
901 delete cache
[ keys
.shift() ];
903 return (cache
[ key
+ " " ] = value
);
909 * Mark a function for special use by Sizzle
910 * @param {Function} fn The function to mark
912 function markFunction( fn
) {
913 fn
[ expando
] = true;
918 * Support testing using an element
919 * @param {Function} fn Passed the created element and returns a boolean result
921 function assert( fn
) {
922 var el
= document
.createElement("fieldset");
929 // Remove from its parent by default
930 if ( el
.parentNode
) {
931 el
.parentNode
.removeChild( el
);
933 // release memory in IE
939 * Adds the same handler for all of the specified attrs
940 * @param {String} attrs Pipe-separated list of attributes
941 * @param {Function} handler The method that will be applied
943 function addHandle( attrs
, handler
) {
944 var arr
= attrs
.split("|"),
948 Expr
.attrHandle
[ arr
[i
] ] = handler
;
953 * Checks document order of two siblings
956 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
958 function siblingCheck( a
, b
) {
960 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
961 a
.sourceIndex
- b
.sourceIndex
;
963 // Use IE sourceIndex if available on both nodes
968 // Check if b follows a
970 while ( (cur
= cur
.nextSibling
) ) {
981 * Returns a function to use in pseudos for input types
982 * @param {String} type
984 function createInputPseudo( type
) {
985 return function( elem
) {
986 var name
= elem
.nodeName
.toLowerCase();
987 return name
=== "input" && elem
.type
=== type
;
992 * Returns a function to use in pseudos for buttons
993 * @param {String} type
995 function createButtonPseudo( type
) {
996 return function( elem
) {
997 var name
= elem
.nodeName
.toLowerCase();
998 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
1003 * Returns a function to use in pseudos for :enabled/:disabled
1004 * @param {Boolean} disabled true for :disabled; false for :enabled
1006 function createDisabledPseudo( disabled
) {
1008 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1009 return function( elem
) {
1011 // Only certain elements can match :enabled or :disabled
1012 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1013 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1014 if ( "form" in elem
) {
1016 // Check for inherited disabledness on relevant non-disabled elements:
1017 // * listed form-associated elements in a disabled fieldset
1018 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
1019 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1020 // * option elements in a disabled optgroup
1021 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1022 // All such elements have a "form" property.
1023 if ( elem
.parentNode
&& elem
.disabled
=== false ) {
1025 // Option elements defer to a parent optgroup if present
1026 if ( "label" in elem
) {
1027 if ( "label" in elem
.parentNode
) {
1028 return elem
.parentNode
.disabled
=== disabled
;
1030 return elem
.disabled
=== disabled
;
1034 // Support: IE 6 - 11
1035 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
1036 return elem
.isDisabled
=== disabled
||
1038 // Where there is no isDisabled, check manually
1040 elem
.isDisabled
!== !disabled
&&
1041 disabledAncestor( elem
) === disabled
;
1044 return elem
.disabled
=== disabled
;
1046 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1047 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1048 // even exist on them, let alone have a boolean value.
1049 } else if ( "label" in elem
) {
1050 return elem
.disabled
=== disabled
;
1053 // Remaining elements are neither :enabled nor :disabled
1059 * Returns a function to use in pseudos for positionals
1060 * @param {Function} fn
1062 function createPositionalPseudo( fn
) {
1063 return markFunction(function( argument
) {
1064 argument
= +argument
;
1065 return markFunction(function( seed
, matches
) {
1067 matchIndexes
= fn( [], seed
.length
, argument
),
1068 i
= matchIndexes
.length
;
1070 // Match elements found at the specified indexes
1072 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
1073 seed
[j
] = !(matches
[j
] = seed
[j
]);
1081 * Checks a node for validity as a Sizzle context
1082 * @param {Element|Object=} context
1083 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1085 function testContext( context
) {
1086 return context
&& typeof context
.getElementsByTagName
!== "undefined" && context
;
1089 // Expose support vars for convenience
1090 support
= Sizzle
.support
= {};
1094 * @param {Element|Object} elem An element or a document
1095 * @returns {Boolean} True iff elem is a non-HTML XML node
1097 isXML
= Sizzle
.isXML = function( elem
) {
1098 // documentElement is verified for cases where it doesn't yet exist
1099 // (such as loading iframes in IE - #4833)
1100 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
1101 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1105 * Sets document-related variables once based on the current document
1106 * @param {Element|Object} [doc] An element or document object to use to set the document
1107 * @returns {Object} Returns the current document
1109 setDocument
= Sizzle
.setDocument = function( node
) {
1110 var hasCompare
, subWindow
,
1111 doc
= node
? node
.ownerDocument
|| node
: preferredDoc
;
1113 // Return early if doc is invalid or already selected
1114 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1118 // Update global variables
1120 docElem
= document
.documentElement
;
1121 documentIsHTML
= !isXML( document
);
1123 // Support: IE 9-11, Edge
1124 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1125 if ( preferredDoc
!== document
&&
1126 (subWindow
= document
.defaultView
) && subWindow
.top
!== subWindow
) {
1128 // Support: IE 11, Edge
1129 if ( subWindow
.addEventListener
) {
1130 subWindow
.addEventListener( "unload", unloadHandler
, false );
1132 // Support: IE 9 - 10 only
1133 } else if ( subWindow
.attachEvent
) {
1134 subWindow
.attachEvent( "onunload", unloadHandler
);
1139 ---------------------------------------------------------------------- */
1142 // Verify that getAttribute really returns attributes and not properties
1143 // (excepting IE8 booleans)
1144 support
.attributes
= assert(function( el
) {
1146 return !el
.getAttribute("className");
1150 ---------------------------------------------------------------------- */
1152 // Check if getElementsByTagName("*") returns only elements
1153 support
.getElementsByTagName
= assert(function( el
) {
1154 el
.appendChild( document
.createComment("") );
1155 return !el
.getElementsByTagName("*").length
;
1159 support
.getElementsByClassName
= rnative
.test( document
.getElementsByClassName
);
1162 // Check if getElementById returns elements by name
1163 // The broken getElementById methods don't pick up programmatically-set names,
1164 // so use a roundabout getElementsByName test
1165 support
.getById
= assert(function( el
) {
1166 docElem
.appendChild( el
).id
= expando
;
1167 return !document
.getElementsByName
|| !document
.getElementsByName( expando
).length
;
1170 // ID filter and find
1171 if ( support
.getById
) {
1172 Expr
.filter
["ID"] = function( id
) {
1173 var attrId
= id
.replace( runescape
, funescape
);
1174 return function( elem
) {
1175 return elem
.getAttribute("id") === attrId
;
1178 Expr
.find
["ID"] = function( id
, context
) {
1179 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1180 var elem
= context
.getElementById( id
);
1181 return elem
? [ elem
] : [];
1185 Expr
.filter
["ID"] = function( id
) {
1186 var attrId
= id
.replace( runescape
, funescape
);
1187 return function( elem
) {
1188 var node
= typeof elem
.getAttributeNode
!== "undefined" &&
1189 elem
.getAttributeNode("id");
1190 return node
&& node
.value
=== attrId
;
1194 // Support: IE 6 - 7 only
1195 // getElementById is not reliable as a find shortcut
1196 Expr
.find
["ID"] = function( id
, context
) {
1197 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1199 elem
= context
.getElementById( id
);
1203 // Verify the id attribute
1204 node
= elem
.getAttributeNode("id");
1205 if ( node
&& node
.value
=== id
) {
1209 // Fall back on getElementsByName
1210 elems
= context
.getElementsByName( id
);
1212 while ( (elem
= elems
[i
++]) ) {
1213 node
= elem
.getAttributeNode("id");
1214 if ( node
&& node
.value
=== id
) {
1226 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1227 function( tag
, context
) {
1228 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
1229 return context
.getElementsByTagName( tag
);
1231 // DocumentFragment nodes don't have gEBTN
1232 } else if ( support
.qsa
) {
1233 return context
.querySelectorAll( tag
);
1237 function( tag
, context
) {
1241 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1242 results
= context
.getElementsByTagName( tag
);
1244 // Filter out possible comments
1245 if ( tag
=== "*" ) {
1246 while ( (elem
= results
[i
++]) ) {
1247 if ( elem
.nodeType
=== 1 ) {
1258 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1259 if ( typeof context
.getElementsByClassName
!== "undefined" && documentIsHTML
) {
1260 return context
.getElementsByClassName( className
);
1264 /* QSA/matchesSelector
1265 ---------------------------------------------------------------------- */
1267 // QSA and matchesSelector support
1269 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1272 // qSa(:focus) reports false when true (Chrome 21)
1273 // We allow this because of a bug in IE8/9 that throws an error
1274 // whenever `document.activeElement` is accessed on an iframe
1275 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1276 // See https://bugs.jquery.com/ticket/13378
1279 if ( (support
.qsa
= rnative
.test( document
.querySelectorAll
)) ) {
1281 // Regex strategy adopted from Diego Perini
1282 assert(function( el
) {
1283 // Select is set to empty string on purpose
1284 // This is to test IE's treatment of not explicitly
1285 // setting a boolean content attribute,
1286 // since its presence should be enough
1287 // https://bugs.jquery.com/ticket/12359
1288 docElem
.appendChild( el
).innerHTML
= "<a id='" + expando
+ "'></a>" +
1289 "<select id='" + expando
+ "-\r\\' msallowcapture=''>" +
1290 "<option selected=''></option></select>";
1292 // Support: IE8, Opera 11-12.16
1293 // Nothing should be selected when empty strings follow ^= or $= or *=
1294 // The test attribute must be unknown in Opera but "safe" for WinRT
1295 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1296 if ( el
.querySelectorAll("[msallowcapture^='']").length
) {
1297 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1301 // Boolean attributes and "value" are not treated correctly
1302 if ( !el
.querySelectorAll("[selected]").length
) {
1303 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1306 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1307 if ( !el
.querySelectorAll( "[id~=" + expando
+ "-]" ).length
) {
1308 rbuggyQSA
.push("~=");
1311 // Webkit/Opera - :checked should return selected option elements
1312 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1313 // IE8 throws error here and will not see later tests
1314 if ( !el
.querySelectorAll(":checked").length
) {
1315 rbuggyQSA
.push(":checked");
1318 // Support: Safari 8+, iOS 8+
1319 // https://bugs.webkit.org/show_bug.cgi?id=136851
1320 // In-page `selector#id sibling-combinator selector` fails
1321 if ( !el
.querySelectorAll( "a#" + expando
+ "+*" ).length
) {
1322 rbuggyQSA
.push(".#.+[+~]");
1326 assert(function( el
) {
1327 el
.innerHTML
= "<a href='' disabled='disabled'></a>" +
1328 "<select disabled='disabled'><option/></select>";
1330 // Support: Windows 8 Native Apps
1331 // The type and name attributes are restricted during .innerHTML assignment
1332 var input
= document
.createElement("input");
1333 input
.setAttribute( "type", "hidden" );
1334 el
.appendChild( input
).setAttribute( "name", "D" );
1337 // Enforce case-sensitivity of name attribute
1338 if ( el
.querySelectorAll("[name=d]").length
) {
1339 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1342 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1343 // IE8 throws error here and will not see later tests
1344 if ( el
.querySelectorAll(":enabled").length
!== 2 ) {
1345 rbuggyQSA
.push( ":enabled", ":disabled" );
1349 // IE's :disabled selector does not pick up the children of disabled fieldsets
1350 docElem
.appendChild( el
).disabled
= true;
1351 if ( el
.querySelectorAll(":disabled").length
!== 2 ) {
1352 rbuggyQSA
.push( ":enabled", ":disabled" );
1355 // Opera 10-11 does not throw on post-comma invalid pseudos
1356 el
.querySelectorAll("*,:x");
1357 rbuggyQSA
.push(",.*:");
1361 if ( (support
.matchesSelector
= rnative
.test( (matches
= docElem
.matches
||
1362 docElem
.webkitMatchesSelector
||
1363 docElem
.mozMatchesSelector
||
1364 docElem
.oMatchesSelector
||
1365 docElem
.msMatchesSelector
) )) ) {
1367 assert(function( el
) {
1368 // Check to see if it's possible to do matchesSelector
1369 // on a disconnected node (IE 9)
1370 support
.disconnectedMatch
= matches
.call( el
, "*" );
1372 // This should fail with an exception
1373 // Gecko does not error, returns false instead
1374 matches
.call( el
, "[s!='']:x" );
1375 rbuggyMatches
.push( "!=", pseudos
);
1379 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1380 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1383 ---------------------------------------------------------------------- */
1384 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1386 // Element contains another
1387 // Purposefully self-exclusive
1388 // As in, an element does not contain itself
1389 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1391 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
1392 bup
= b
&& b
.parentNode
;
1393 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1395 adown
.contains( bup
) :
1396 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1401 while ( (b
= b
.parentNode
) ) {
1411 ---------------------------------------------------------------------- */
1413 // Document order sorting
1414 sortOrder
= hasCompare
?
1417 // Flag for duplicate removal
1419 hasDuplicate
= true;
1423 // Sort on method existence if only one input has compareDocumentPosition
1424 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1429 // Calculate position if both inputs belong to the same document
1430 compare
= ( a
.ownerDocument
|| a
) === ( b
.ownerDocument
|| b
) ?
1431 a
.compareDocumentPosition( b
) :
1433 // Otherwise we know they are disconnected
1436 // Disconnected nodes
1438 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1440 // Choose the first element that is related to our preferred document
1441 if ( a
=== document
|| a
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, a
) ) {
1444 if ( b
=== document
|| b
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, b
) ) {
1448 // Maintain original order
1450 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1454 return compare
& 4 ? -1 : 1;
1457 // Exit early if the nodes are identical
1459 hasDuplicate
= true;
1470 // Parentless nodes are either documents or disconnected
1471 if ( !aup
|| !bup
) {
1472 return a
=== document
? -1 :
1473 b
=== document
? 1 :
1477 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1480 // If the nodes are siblings, we can do a quick check
1481 } else if ( aup
=== bup
) {
1482 return siblingCheck( a
, b
);
1485 // Otherwise we need full lists of their ancestors for comparison
1487 while ( (cur
= cur
.parentNode
) ) {
1491 while ( (cur
= cur
.parentNode
) ) {
1495 // Walk down the tree looking for a discrepancy
1496 while ( ap
[i
] === bp
[i
] ) {
1501 // Do a sibling check if the nodes have a common ancestor
1502 siblingCheck( ap
[i
], bp
[i
] ) :
1504 // Otherwise nodes in our document sort first
1505 ap
[i
] === preferredDoc
? -1 :
1506 bp
[i
] === preferredDoc
? 1 :
1513 Sizzle
.matches = function( expr
, elements
) {
1514 return Sizzle( expr
, null, null, elements
);
1517 Sizzle
.matchesSelector = function( elem
, expr
) {
1518 // Set document vars if needed
1519 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1520 setDocument( elem
);
1523 // Make sure that attribute selectors are quoted
1524 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1526 if ( support
.matchesSelector
&& documentIsHTML
&&
1527 !compilerCache
[ expr
+ " " ] &&
1528 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1529 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1532 var ret
= matches
.call( elem
, expr
);
1534 // IE 9's matchesSelector returns false on disconnected nodes
1535 if ( ret
|| support
.disconnectedMatch
||
1536 // As well, disconnected nodes are said to be in a document
1538 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1544 return Sizzle( expr
, document
, null, [ elem
] ).length
> 0;
1547 Sizzle
.contains = function( context
, elem
) {
1548 // Set document vars if needed
1549 if ( ( context
.ownerDocument
|| context
) !== document
) {
1550 setDocument( context
);
1552 return contains( context
, elem
);
1555 Sizzle
.attr = function( elem
, name
) {
1556 // Set document vars if needed
1557 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1558 setDocument( elem
);
1561 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1562 // Don't get fooled by Object.prototype properties (jQuery #13807)
1563 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1564 fn( elem
, name
, !documentIsHTML
) :
1567 return val
!== undefined ?
1569 support
.attributes
|| !documentIsHTML
?
1570 elem
.getAttribute( name
) :
1571 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1576 Sizzle
.escape = function( sel
) {
1577 return (sel
+ "").replace( rcssescape
, fcssescape
);
1580 Sizzle
.error = function( msg
) {
1581 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1585 * Document sorting and removing duplicates
1586 * @param {ArrayLike} results
1588 Sizzle
.uniqueSort = function( results
) {
1594 // Unless we *know* we can detect duplicates, assume their presence
1595 hasDuplicate
= !support
.detectDuplicates
;
1596 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1597 results
.sort( sortOrder
);
1599 if ( hasDuplicate
) {
1600 while ( (elem
= results
[i
++]) ) {
1601 if ( elem
=== results
[ i
] ) {
1602 j
= duplicates
.push( i
);
1606 results
.splice( duplicates
[ j
], 1 );
1610 // Clear input after sorting to release objects
1611 // See https://github.com/jquery/sizzle/pull/225
1618 * Utility function for retrieving the text value of an array of DOM nodes
1619 * @param {Array|Element} elem
1621 getText
= Sizzle
.getText = function( elem
) {
1625 nodeType
= elem
.nodeType
;
1628 // If no nodeType, this is expected to be an array
1629 while ( (node
= elem
[i
++]) ) {
1630 // Do not traverse comment nodes
1631 ret
+= getText( node
);
1633 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1634 // Use textContent for elements
1635 // innerText usage removed for consistency of new lines (jQuery #11153)
1636 if ( typeof elem
.textContent
=== "string" ) {
1637 return elem
.textContent
;
1639 // Traverse its children
1640 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1641 ret
+= getText( elem
);
1644 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1645 return elem
.nodeValue
;
1647 // Do not include comment or processing instruction nodes
1652 Expr
= Sizzle
.selectors
= {
1654 // Can be adjusted by the user
1657 createPseudo
: markFunction
,
1666 ">": { dir
: "parentNode", first
: true },
1667 " ": { dir
: "parentNode" },
1668 "+": { dir
: "previousSibling", first
: true },
1669 "~": { dir
: "previousSibling" }
1673 "ATTR": function( match
) {
1674 match
[1] = match
[1].replace( runescape
, funescape
);
1676 // Move the given value to match[3] whether quoted or unquoted
1677 match
[3] = ( match
[3] || match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1679 if ( match
[2] === "~=" ) {
1680 match
[3] = " " + match
[3] + " ";
1683 return match
.slice( 0, 4 );
1686 "CHILD": function( match
) {
1687 /* matches from matchExpr["CHILD"]
1688 1 type (only|nth|...)
1689 2 what (child|of-type)
1690 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1691 4 xn-component of xn+y argument ([+-]?\d*n|)
1692 5 sign of xn-component
1694 7 sign of y-component
1697 match
[1] = match
[1].toLowerCase();
1699 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1700 // nth-* requires argument
1702 Sizzle
.error( match
[0] );
1705 // numeric x and y parameters for Expr.filter.CHILD
1706 // remember that false/true cast respectively to 0/1
1707 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1708 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1710 // other types prohibit arguments
1711 } else if ( match
[3] ) {
1712 Sizzle
.error( match
[0] );
1718 "PSEUDO": function( match
) {
1720 unquoted
= !match
[6] && match
[2];
1722 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1726 // Accept quoted arguments as-is
1728 match
[2] = match
[4] || match
[5] || "";
1730 // Strip excess characters from unquoted arguments
1731 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1732 // Get excess from tokenize (recursively)
1733 (excess
= tokenize( unquoted
, true )) &&
1734 // advance to the next closing parenthesis
1735 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1737 // excess is a negative index
1738 match
[0] = match
[0].slice( 0, excess
);
1739 match
[2] = unquoted
.slice( 0, excess
);
1742 // Return only captures needed by the pseudo filter method (type and argument)
1743 return match
.slice( 0, 3 );
1749 "TAG": function( nodeNameSelector
) {
1750 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1751 return nodeNameSelector
=== "*" ?
1752 function() { return true; } :
1754 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1758 "CLASS": function( className
) {
1759 var pattern
= classCache
[ className
+ " " ];
1762 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1763 classCache( className
, function( elem
) {
1764 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== "undefined" && elem
.getAttribute("class") || "" );
1768 "ATTR": function( name
, operator
, check
) {
1769 return function( elem
) {
1770 var result
= Sizzle
.attr( elem
, name
);
1772 if ( result
== null ) {
1773 return operator
=== "!=";
1781 return operator
=== "=" ? result
=== check
:
1782 operator
=== "!=" ? result
!== check
:
1783 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1784 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1785 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check
:
1786 operator
=== "~=" ? ( " " + result
.replace( rwhitespace
, " " ) + " " ).indexOf( check
) > -1 :
1787 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1792 "CHILD": function( type
, what
, argument
, first
, last
) {
1793 var simple
= type
.slice( 0, 3 ) !== "nth",
1794 forward
= type
.slice( -4 ) !== "last",
1795 ofType
= what
=== "of-type";
1797 return first
=== 1 && last
=== 0 ?
1799 // Shortcut for :nth-*(n)
1801 return !!elem
.parentNode
;
1804 function( elem
, context
, xml
) {
1805 var cache
, uniqueCache
, outerCache
, node
, nodeIndex
, start
,
1806 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1807 parent
= elem
.parentNode
,
1808 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1809 useCache
= !xml
&& !ofType
,
1814 // :(first|last|only)-(child|of-type)
1818 while ( (node
= node
[ dir
]) ) {
1820 node
.nodeName
.toLowerCase() === name
:
1821 node
.nodeType
=== 1 ) {
1826 // Reverse direction for :only-* (if we haven't yet done so)
1827 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1832 start
= [ forward
? parent
.firstChild
: parent
.lastChild
];
1834 // non-xml :nth-child(...) stores cache data on `parent`
1835 if ( forward
&& useCache
) {
1837 // Seek `elem` from a previously-cached index
1839 // ...in a gzip-friendly way
1841 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1843 // Support: IE <9 only
1844 // Defend against cloned attroperties (jQuery gh-1709)
1845 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1846 (outerCache
[ node
.uniqueID
] = {});
1848 cache
= uniqueCache
[ type
] || [];
1849 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1850 diff
= nodeIndex
&& cache
[ 2 ];
1851 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1853 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1855 // Fallback to seeking `elem` from the start
1856 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1858 // When found, cache indexes on `parent` and break
1859 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1860 uniqueCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1866 // Use previously-cached element index if available
1868 // ...in a gzip-friendly way
1870 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1872 // Support: IE <9 only
1873 // Defend against cloned attroperties (jQuery gh-1709)
1874 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1875 (outerCache
[ node
.uniqueID
] = {});
1877 cache
= uniqueCache
[ type
] || [];
1878 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1882 // xml :nth-child(...)
1883 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1884 if ( diff
=== false ) {
1885 // Use the same loop as above to seek `elem` from the start
1886 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1887 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1890 node
.nodeName
.toLowerCase() === name
:
1891 node
.nodeType
=== 1 ) &&
1894 // Cache the index of each encountered element
1896 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1898 // Support: IE <9 only
1899 // Defend against cloned attroperties (jQuery gh-1709)
1900 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1901 (outerCache
[ node
.uniqueID
] = {});
1903 uniqueCache
[ type
] = [ dirruns
, diff
];
1906 if ( node
=== elem
) {
1914 // Incorporate the offset, then check against cycle size
1916 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
1921 "PSEUDO": function( pseudo
, argument
) {
1922 // pseudo-class names are case-insensitive
1923 // http://www.w3.org/TR/selectors/#pseudo-classes
1924 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1925 // Remember that setFilters inherits from pseudos
1927 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
1928 Sizzle
.error( "unsupported pseudo: " + pseudo
);
1930 // The user may use createPseudo to indicate that
1931 // arguments are needed to create the filter function
1932 // just as Sizzle does
1933 if ( fn
[ expando
] ) {
1934 return fn( argument
);
1937 // But maintain support for old signatures
1938 if ( fn
.length
> 1 ) {
1939 args
= [ pseudo
, pseudo
, "", argument
];
1940 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
1941 markFunction(function( seed
, matches
) {
1943 matched
= fn( seed
, argument
),
1946 idx
= indexOf( seed
, matched
[i
] );
1947 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
1951 return fn( elem
, 0, args
);
1960 // Potentially complex pseudos
1961 "not": markFunction(function( selector
) {
1962 // Trim the selector passed to compile
1963 // to avoid treating leading and trailing
1964 // spaces as combinators
1967 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
1969 return matcher
[ expando
] ?
1970 markFunction(function( seed
, matches
, context
, xml
) {
1972 unmatched
= matcher( seed
, null, xml
, [] ),
1975 // Match elements unmatched by `matcher`
1977 if ( (elem
= unmatched
[i
]) ) {
1978 seed
[i
] = !(matches
[i
] = elem
);
1982 function( elem
, context
, xml
) {
1984 matcher( input
, null, xml
, results
);
1985 // Don't keep the element (issue #299)
1987 return !results
.pop();
1991 "has": markFunction(function( selector
) {
1992 return function( elem
) {
1993 return Sizzle( selector
, elem
).length
> 0;
1997 "contains": markFunction(function( text
) {
1998 text
= text
.replace( runescape
, funescape
);
1999 return function( elem
) {
2000 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
2004 // "Whether an element is represented by a :lang() selector
2005 // is based solely on the element's language value
2006 // being equal to the identifier C,
2007 // or beginning with the identifier C immediately followed by "-".
2008 // The matching of C against the element's language value is performed case-insensitively.
2009 // The identifier C does not have to be a valid language name."
2010 // http://www.w3.org/TR/selectors/#lang-pseudo
2011 "lang": markFunction( function( lang
) {
2012 // lang value must be a valid identifier
2013 if ( !ridentifier
.test(lang
|| "") ) {
2014 Sizzle
.error( "unsupported lang: " + lang
);
2016 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
2017 return function( elem
) {
2020 if ( (elemLang
= documentIsHTML
?
2022 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
2024 elemLang
= elemLang
.toLowerCase();
2025 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
2027 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
2033 "target": function( elem
) {
2034 var hash
= window
.location
&& window
.location
.hash
;
2035 return hash
&& hash
.slice( 1 ) === elem
.id
;
2038 "root": function( elem
) {
2039 return elem
=== docElem
;
2042 "focus": function( elem
) {
2043 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
2046 // Boolean properties
2047 "enabled": createDisabledPseudo( false ),
2048 "disabled": createDisabledPseudo( true ),
2050 "checked": function( elem
) {
2051 // In CSS3, :checked should return both checked and selected elements
2052 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2053 var nodeName
= elem
.nodeName
.toLowerCase();
2054 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
2057 "selected": function( elem
) {
2058 // Accessing this property makes selected-by-default
2059 // options in Safari work properly
2060 if ( elem
.parentNode
) {
2061 elem
.parentNode
.selectedIndex
;
2064 return elem
.selected
=== true;
2068 "empty": function( elem
) {
2069 // http://www.w3.org/TR/selectors/#empty-pseudo
2070 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2071 // but not by others (comment: 8; processing instruction: 7; etc.)
2072 // nodeType < 6 works because attributes (2) do not appear as children
2073 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
2074 if ( elem
.nodeType
< 6 ) {
2081 "parent": function( elem
) {
2082 return !Expr
.pseudos
["empty"]( elem
);
2085 // Element/input types
2086 "header": function( elem
) {
2087 return rheader
.test( elem
.nodeName
);
2090 "input": function( elem
) {
2091 return rinputs
.test( elem
.nodeName
);
2094 "button": function( elem
) {
2095 var name
= elem
.nodeName
.toLowerCase();
2096 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
2099 "text": function( elem
) {
2101 return elem
.nodeName
.toLowerCase() === "input" &&
2102 elem
.type
=== "text" &&
2105 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2106 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === "text" );
2109 // Position-in-collection
2110 "first": createPositionalPseudo(function() {
2114 "last": createPositionalPseudo(function( matchIndexes
, length
) {
2115 return [ length
- 1 ];
2118 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2119 return [ argument
< 0 ? argument
+ length
: argument
];
2122 "even": createPositionalPseudo(function( matchIndexes
, length
) {
2124 for ( ; i
< length
; i
+= 2 ) {
2125 matchIndexes
.push( i
);
2127 return matchIndexes
;
2130 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
2132 for ( ; i
< length
; i
+= 2 ) {
2133 matchIndexes
.push( i
);
2135 return matchIndexes
;
2138 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2139 var i
= argument
< 0 ? argument
+ length
: argument
;
2140 for ( ; --i
>= 0; ) {
2141 matchIndexes
.push( i
);
2143 return matchIndexes
;
2146 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2147 var i
= argument
< 0 ? argument
+ length
: argument
;
2148 for ( ; ++i
< length
; ) {
2149 matchIndexes
.push( i
);
2151 return matchIndexes
;
2156 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
2158 // Add button/input type pseudos
2159 for ( i
in { radio
: true, checkbox
: true, file
: true, password
: true, image
: true } ) {
2160 Expr
.pseudos
[ i
] = createInputPseudo( i
);
2162 for ( i
in { submit
: true, reset
: true } ) {
2163 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
2166 // Easy API for creating new setFilters
2167 function setFilters() {}
2168 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
2169 Expr
.setFilters
= new setFilters();
2171 tokenize
= Sizzle
.tokenize = function( selector
, parseOnly
) {
2172 var matched
, match
, tokens
, type
,
2173 soFar
, groups
, preFilters
,
2174 cached
= tokenCache
[ selector
+ " " ];
2177 return parseOnly
? 0 : cached
.slice( 0 );
2182 preFilters
= Expr
.preFilter
;
2186 // Comma and first run
2187 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
2189 // Don't consume trailing commas as valid
2190 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2192 groups
.push( (tokens
= []) );
2198 if ( (match
= rcombinators
.exec( soFar
)) ) {
2199 matched
= match
.shift();
2202 // Cast descendant combinators to space
2203 type
: match
[0].replace( rtrim
, " " )
2205 soFar
= soFar
.slice( matched
.length
);
2209 for ( type
in Expr
.filter
) {
2210 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2211 (match
= preFilters
[ type
]( match
))) ) {
2212 matched
= match
.shift();
2218 soFar
= soFar
.slice( matched
.length
);
2227 // Return the length of the invalid excess
2228 // if we're just parsing
2229 // Otherwise, throw an error or return tokens
2233 Sizzle
.error( selector
) :
2235 tokenCache( selector
, groups
).slice( 0 );
2238 function toSelector( tokens
) {
2240 len
= tokens
.length
,
2242 for ( ; i
< len
; i
++ ) {
2243 selector
+= tokens
[i
].value
;
2248 function addCombinator( matcher
, combinator
, base
) {
2249 var dir
= combinator
.dir
,
2250 skip
= combinator
.next
,
2252 checkNonElements
= base
&& key
=== "parentNode",
2255 return combinator
.first
?
2256 // Check against closest ancestor/preceding element
2257 function( elem
, context
, xml
) {
2258 while ( (elem
= elem
[ dir
]) ) {
2259 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2260 return matcher( elem
, context
, xml
);
2266 // Check against all ancestor/preceding elements
2267 function( elem
, context
, xml
) {
2268 var oldCache
, uniqueCache
, outerCache
,
2269 newCache
= [ dirruns
, doneName
];
2271 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2273 while ( (elem
= elem
[ dir
]) ) {
2274 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2275 if ( matcher( elem
, context
, xml
) ) {
2281 while ( (elem
= elem
[ dir
]) ) {
2282 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2283 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2285 // Support: IE <9 only
2286 // Defend against cloned attroperties (jQuery gh-1709)
2287 uniqueCache
= outerCache
[ elem
.uniqueID
] || (outerCache
[ elem
.uniqueID
] = {});
2289 if ( skip
&& skip
=== elem
.nodeName
.toLowerCase() ) {
2290 elem
= elem
[ dir
] || elem
;
2291 } else if ( (oldCache
= uniqueCache
[ key
]) &&
2292 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2294 // Assign to newCache so results back-propagate to previous elements
2295 return (newCache
[ 2 ] = oldCache
[ 2 ]);
2297 // Reuse newcache so results back-propagate to previous elements
2298 uniqueCache
[ key
] = newCache
;
2300 // A match means we're done; a fail means we have to keep checking
2301 if ( (newCache
[ 2 ] = matcher( elem
, context
, xml
)) ) {
2312 function elementMatcher( matchers
) {
2313 return matchers
.length
> 1 ?
2314 function( elem
, context
, xml
) {
2315 var i
= matchers
.length
;
2317 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2326 function multipleContexts( selector
, contexts
, results
) {
2328 len
= contexts
.length
;
2329 for ( ; i
< len
; i
++ ) {
2330 Sizzle( selector
, contexts
[i
], results
);
2335 function condense( unmatched
, map
, filter
, context
, xml
) {
2339 len
= unmatched
.length
,
2340 mapped
= map
!= null;
2342 for ( ; i
< len
; i
++ ) {
2343 if ( (elem
= unmatched
[i
]) ) {
2344 if ( !filter
|| filter( elem
, context
, xml
) ) {
2345 newUnmatched
.push( elem
);
2353 return newUnmatched
;
2356 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2357 if ( postFilter
&& !postFilter
[ expando
] ) {
2358 postFilter
= setMatcher( postFilter
);
2360 if ( postFinder
&& !postFinder
[ expando
] ) {
2361 postFinder
= setMatcher( postFinder
, postSelector
);
2363 return markFunction(function( seed
, results
, context
, xml
) {
2367 preexisting
= results
.length
,
2369 // Get initial elements from seed or context
2370 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2372 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2373 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2374 condense( elems
, preMap
, preFilter
, context
, xml
) :
2377 matcherOut
= matcher
?
2378 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2379 postFinder
|| ( seed
? preFilter
: preexisting
|| postFilter
) ?
2381 // ...intermediate processing is necessary
2384 // ...otherwise use results directly
2388 // Find primary matches
2390 matcher( matcherIn
, matcherOut
, context
, xml
);
2395 temp
= condense( matcherOut
, postMap
);
2396 postFilter( temp
, [], context
, xml
);
2398 // Un-match failing elements by moving them back to matcherIn
2401 if ( (elem
= temp
[i
]) ) {
2402 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2408 if ( postFinder
|| preFilter
) {
2410 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2412 i
= matcherOut
.length
;
2414 if ( (elem
= matcherOut
[i
]) ) {
2415 // Restore matcherIn since elem is not yet a final match
2416 temp
.push( (matcherIn
[i
] = elem
) );
2419 postFinder( null, (matcherOut
= []), temp
, xml
);
2422 // Move matched elements from seed to results to keep them synchronized
2423 i
= matcherOut
.length
;
2425 if ( (elem
= matcherOut
[i
]) &&
2426 (temp
= postFinder
? indexOf( seed
, elem
) : preMap
[i
]) > -1 ) {
2428 seed
[temp
] = !(results
[temp
] = elem
);
2433 // Add elements to results, through postFinder if defined
2435 matcherOut
= condense(
2436 matcherOut
=== results
?
2437 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2441 postFinder( null, results
, matcherOut
, xml
);
2443 push
.apply( results
, matcherOut
);
2449 function matcherFromTokens( tokens
) {
2450 var checkContext
, matcher
, j
,
2451 len
= tokens
.length
,
2452 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2453 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2454 i
= leadingRelative
? 1 : 0,
2456 // The foundational matcher ensures that elements are reachable from top-level context(s)
2457 matchContext
= addCombinator( function( elem
) {
2458 return elem
=== checkContext
;
2459 }, implicitRelative
, true ),
2460 matchAnyContext
= addCombinator( function( elem
) {
2461 return indexOf( checkContext
, elem
) > -1;
2462 }, implicitRelative
, true ),
2463 matchers
= [ function( elem
, context
, xml
) {
2464 var ret
= ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2465 (checkContext
= context
).nodeType
?
2466 matchContext( elem
, context
, xml
) :
2467 matchAnyContext( elem
, context
, xml
) );
2468 // Avoid hanging onto element (issue #299)
2469 checkContext
= null;
2473 for ( ; i
< len
; i
++ ) {
2474 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2475 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2477 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2479 // Return special upon seeing a positional matcher
2480 if ( matcher
[ expando
] ) {
2481 // Find the next relative operator (if any) for proper handling
2483 for ( ; j
< len
; j
++ ) {
2484 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2489 i
> 1 && elementMatcher( matchers
),
2490 i
> 1 && toSelector(
2491 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2492 tokens
.slice( 0, i
- 1 ).concat({ value
: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2493 ).replace( rtrim
, "$1" ),
2495 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2496 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2497 j
< len
&& toSelector( tokens
)
2500 matchers
.push( matcher
);
2504 return elementMatcher( matchers
);
2507 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2508 var bySet
= setMatchers
.length
> 0,
2509 byElement
= elementMatchers
.length
> 0,
2510 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2511 var elem
, j
, matcher
,
2514 unmatched
= seed
&& [],
2516 contextBackup
= outermostContext
,
2517 // We must always have either seed elements or outermost context
2518 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", outermost
),
2519 // Use integer dirruns iff this is the outermost matcher
2520 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1),
2524 outermostContext
= context
=== document
|| context
|| outermost
;
2527 // Add elements passing elementMatchers directly to results
2528 // Support: IE<9, Safari
2529 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2530 for ( ; i
!== len
&& (elem
= elems
[i
]) != null; i
++ ) {
2531 if ( byElement
&& elem
) {
2533 if ( !context
&& elem
.ownerDocument
!== document
) {
2534 setDocument( elem
);
2535 xml
= !documentIsHTML
;
2537 while ( (matcher
= elementMatchers
[j
++]) ) {
2538 if ( matcher( elem
, context
|| document
, xml
) ) {
2539 results
.push( elem
);
2544 dirruns
= dirrunsUnique
;
2548 // Track unmatched elements for set filters
2550 // They will have gone through all possible matchers
2551 if ( (elem
= !matcher
&& elem
) ) {
2555 // Lengthen the array for every element, matched or not
2557 unmatched
.push( elem
);
2562 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2563 // makes the latter nonnegative.
2566 // Apply set filters to unmatched elements
2567 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2568 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2569 // no element matchers and no seed.
2570 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2571 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2572 // numerically zero.
2573 if ( bySet
&& i
!== matchedCount
) {
2575 while ( (matcher
= setMatchers
[j
++]) ) {
2576 matcher( unmatched
, setMatched
, context
, xml
);
2580 // Reintegrate element matches to eliminate the need for sorting
2581 if ( matchedCount
> 0 ) {
2583 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2584 setMatched
[i
] = pop
.call( results
);
2589 // Discard index placeholder values to get only actual matches
2590 setMatched
= condense( setMatched
);
2593 // Add matches to results
2594 push
.apply( results
, setMatched
);
2596 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2597 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2598 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2600 Sizzle
.uniqueSort( results
);
2604 // Override manipulation of globals by nested matchers
2606 dirruns
= dirrunsUnique
;
2607 outermostContext
= contextBackup
;
2614 markFunction( superMatcher
) :
2618 compile
= Sizzle
.compile = function( selector
, match
/* Internal Use Only */ ) {
2621 elementMatchers
= [],
2622 cached
= compilerCache
[ selector
+ " " ];
2625 // Generate a function of recursive functions that can be used to check each element
2627 match
= tokenize( selector
);
2631 cached
= matcherFromTokens( match
[i
] );
2632 if ( cached
[ expando
] ) {
2633 setMatchers
.push( cached
);
2635 elementMatchers
.push( cached
);
2639 // Cache the compiled function
2640 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2642 // Save selector and tokenization
2643 cached
.selector
= selector
;
2649 * A low-level selection function that works with Sizzle's compiled
2650 * selector functions
2651 * @param {String|Function} selector A selector or a pre-compiled
2652 * selector function built with Sizzle.compile
2653 * @param {Element} context
2654 * @param {Array} [results]
2655 * @param {Array} [seed] A set of elements to match against
2657 select
= Sizzle
.select = function( selector
, context
, results
, seed
) {
2658 var i
, tokens
, token
, type
, find
,
2659 compiled
= typeof selector
=== "function" && selector
,
2660 match
= !seed
&& tokenize( (selector
= compiled
.selector
|| selector
) );
2662 results
= results
|| [];
2664 // Try to minimize operations if there is only one selector in the list and no seed
2665 // (the latter of which guarantees us context)
2666 if ( match
.length
=== 1 ) {
2668 // Reduce context if the leading compound selector is an ID
2669 tokens
= match
[0] = match
[0].slice( 0 );
2670 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2671 context
.nodeType
=== 9 && documentIsHTML
&& Expr
.relative
[ tokens
[1].type
] ) {
2673 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2677 // Precompiled matchers will still verify ancestry, so step up a level
2678 } else if ( compiled
) {
2679 context
= context
.parentNode
;
2682 selector
= selector
.slice( tokens
.shift().value
.length
);
2685 // Fetch a seed set for right-to-left matching
2686 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2690 // Abort if we hit a combinator
2691 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2694 if ( (find
= Expr
.find
[ type
]) ) {
2695 // Search, expanding context for leading sibling combinators
2697 token
.matches
[0].replace( runescape
, funescape
),
2698 rsibling
.test( tokens
[0].type
) && testContext( context
.parentNode
) || context
2701 // If seed is empty or no tokens remain, we can return early
2702 tokens
.splice( i
, 1 );
2703 selector
= seed
.length
&& toSelector( tokens
);
2705 push
.apply( results
, seed
);
2715 // Compile and execute a filtering function if one is not provided
2716 // Provide `match` to avoid retokenization if we modified the selector above
2717 ( compiled
|| compile( selector
, match
) )(
2722 !context
|| rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2727 // One-time assignments
2730 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2732 // Support: Chrome 14-35+
2733 // Always assume duplicates if they aren't passed to the comparison function
2734 support
.detectDuplicates
= !!hasDuplicate
;
2736 // Initialize against the default document
2739 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2740 // Detached nodes confoundingly follow *each other*
2741 support
.sortDetached
= assert(function( el
) {
2742 // Should return 1, but returns 4 (following)
2743 return el
.compareDocumentPosition( document
.createElement("fieldset") ) & 1;
2747 // Prevent attribute/property "interpolation"
2748 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2749 if ( !assert(function( el
) {
2750 el
.innerHTML
= "<a href='#'></a>";
2751 return el
.firstChild
.getAttribute("href") === "#" ;
2753 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2755 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2761 // Use defaultValue in place of getAttribute("value")
2762 if ( !support
.attributes
|| !assert(function( el
) {
2763 el
.innerHTML
= "<input/>";
2764 el
.firstChild
.setAttribute( "value", "" );
2765 return el
.firstChild
.getAttribute( "value" ) === "";
2767 addHandle( "value", function( elem
, name
, isXML
) {
2768 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2769 return elem
.defaultValue
;
2775 // Use getAttributeNode to fetch booleans when getAttribute lies
2776 if ( !assert(function( el
) {
2777 return el
.getAttribute("disabled") == null;
2779 addHandle( booleans
, function( elem
, name
, isXML
) {
2782 return elem
[ name
] === true ? name
.toLowerCase() :
2783 (val
= elem
.getAttributeNode( name
)) && val
.specified
?
2796 jQuery
.find
= Sizzle
;
2797 jQuery
.expr
= Sizzle
.selectors
;
2800 jQuery
.expr
[ ":" ] = jQuery
.expr
.pseudos
;
2801 jQuery
.uniqueSort
= jQuery
.unique
= Sizzle
.uniqueSort
;
2802 jQuery
.text
= Sizzle
.getText
;
2803 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2804 jQuery
.contains
= Sizzle
.contains
;
2805 jQuery
.escapeSelector
= Sizzle
.escape
;
2810 var dir = function( elem
, dir
, until
) {
2812 truncate
= until
!== undefined;
2814 while ( ( elem
= elem
[ dir
] ) && elem
.nodeType
!== 9 ) {
2815 if ( elem
.nodeType
=== 1 ) {
2816 if ( truncate
&& jQuery( elem
).is( until
) ) {
2819 matched
.push( elem
);
2826 var siblings = function( n
, elem
) {
2829 for ( ; n
; n
= n
.nextSibling
) {
2830 if ( n
.nodeType
=== 1 && n
!== elem
) {
2839 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
2843 function nodeName( elem
, name
) {
2845 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
2848 var rsingleTag
= ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2852 var risSimple
= /^.[^:#\[\.,]*$/;
2854 // Implement the identical functionality for filter and not
2855 function winnow( elements
, qualifier
, not
) {
2856 if ( jQuery
.isFunction( qualifier
) ) {
2857 return jQuery
.grep( elements
, function( elem
, i
) {
2858 return !!qualifier
.call( elem
, i
, elem
) !== not
;
2863 if ( qualifier
.nodeType
) {
2864 return jQuery
.grep( elements
, function( elem
) {
2865 return ( elem
=== qualifier
) !== not
;
2869 // Arraylike of elements (jQuery, arguments, Array)
2870 if ( typeof qualifier
!== "string" ) {
2871 return jQuery
.grep( elements
, function( elem
) {
2872 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
;
2876 // Simple selector that can be filtered directly, removing non-Elements
2877 if ( risSimple
.test( qualifier
) ) {
2878 return jQuery
.filter( qualifier
, elements
, not
);
2881 // Complex selector, compare the two sets, removing non-Elements
2882 qualifier
= jQuery
.filter( qualifier
, elements
);
2883 return jQuery
.grep( elements
, function( elem
) {
2884 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
&& elem
.nodeType
=== 1;
2888 jQuery
.filter = function( expr
, elems
, not
) {
2889 var elem
= elems
[ 0 ];
2892 expr
= ":not(" + expr
+ ")";
2895 if ( elems
.length
=== 1 && elem
.nodeType
=== 1 ) {
2896 return jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [];
2899 return jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
2900 return elem
.nodeType
=== 1;
2905 find: function( selector
) {
2910 if ( typeof selector
!== "string" ) {
2911 return this.pushStack( jQuery( selector
).filter( function() {
2912 for ( i
= 0; i
< len
; i
++ ) {
2913 if ( jQuery
.contains( self
[ i
], this ) ) {
2920 ret
= this.pushStack( [] );
2922 for ( i
= 0; i
< len
; i
++ ) {
2923 jQuery
.find( selector
, self
[ i
], ret
);
2926 return len
> 1 ? jQuery
.uniqueSort( ret
) : ret
;
2928 filter: function( selector
) {
2929 return this.pushStack( winnow( this, selector
|| [], false ) );
2931 not: function( selector
) {
2932 return this.pushStack( winnow( this, selector
|| [], true ) );
2934 is: function( selector
) {
2938 // If this is a positional/relative selector, check membership in the returned set
2939 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2940 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
2941 jQuery( selector
) :
2949 // Initialize a jQuery object
2952 // A central reference to the root jQuery(document)
2955 // A simple way to check for HTML strings
2956 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2957 // Strict HTML recognition (#11290: must start with <)
2958 // Shortcut simple #id case for speed
2959 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2961 init
= jQuery
.fn
.init = function( selector
, context
, root
) {
2964 // HANDLE: $(""), $(null), $(undefined), $(false)
2969 // Method init() accepts an alternate rootjQuery
2970 // so migrate can support jQuery.sub (gh-2101)
2971 root
= root
|| rootjQuery
;
2973 // Handle HTML strings
2974 if ( typeof selector
=== "string" ) {
2975 if ( selector
[ 0 ] === "<" &&
2976 selector
[ selector
.length
- 1 ] === ">" &&
2977 selector
.length
>= 3 ) {
2979 // Assume that strings that start and end with <> are HTML and skip the regex check
2980 match
= [ null, selector
, null ];
2983 match
= rquickExpr
.exec( selector
);
2986 // Match html or make sure no context is specified for #id
2987 if ( match
&& ( match
[ 1 ] || !context
) ) {
2989 // HANDLE: $(html) -> $(array)
2991 context
= context
instanceof jQuery
? context
[ 0 ] : context
;
2993 // Option to run scripts is true for back-compat
2994 // Intentionally let the error be thrown if parseHTML is not present
2995 jQuery
.merge( this, jQuery
.parseHTML(
2997 context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
,
3001 // HANDLE: $(html, props)
3002 if ( rsingleTag
.test( match
[ 1 ] ) && jQuery
.isPlainObject( context
) ) {
3003 for ( match
in context
) {
3005 // Properties of context are called as methods if possible
3006 if ( jQuery
.isFunction( this[ match
] ) ) {
3007 this[ match
]( context
[ match
] );
3009 // ...and otherwise set as attributes
3011 this.attr( match
, context
[ match
] );
3020 elem
= document
.getElementById( match
[ 2 ] );
3024 // Inject the element directly into the jQuery object
3031 // HANDLE: $(expr, $(...))
3032 } else if ( !context
|| context
.jquery
) {
3033 return ( context
|| root
).find( selector
);
3035 // HANDLE: $(expr, context)
3036 // (which is just equivalent to: $(context).find(expr)
3038 return this.constructor( context
).find( selector
);
3041 // HANDLE: $(DOMElement)
3042 } else if ( selector
.nodeType
) {
3043 this[ 0 ] = selector
;
3047 // HANDLE: $(function)
3048 // Shortcut for document ready
3049 } else if ( jQuery
.isFunction( selector
) ) {
3050 return root
.ready
!== undefined ?
3051 root
.ready( selector
) :
3053 // Execute immediately if ready is not present
3057 return jQuery
.makeArray( selector
, this );
3060 // Give the init function the jQuery prototype for later instantiation
3061 init
.prototype = jQuery
.fn
;
3063 // Initialize central reference
3064 rootjQuery
= jQuery( document
);
3067 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
3069 // Methods guaranteed to produce a unique set when starting from a unique set
3070 guaranteedUnique
= {
3078 has: function( target
) {
3079 var targets
= jQuery( target
, this ),
3082 return this.filter( function() {
3084 for ( ; i
< l
; i
++ ) {
3085 if ( jQuery
.contains( this, targets
[ i
] ) ) {
3092 closest: function( selectors
, context
) {
3097 targets
= typeof selectors
!== "string" && jQuery( selectors
);
3099 // Positional selectors never match, since there's no _selection_ context
3100 if ( !rneedsContext
.test( selectors
) ) {
3101 for ( ; i
< l
; i
++ ) {
3102 for ( cur
= this[ i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
3104 // Always skip document fragments
3105 if ( cur
.nodeType
< 11 && ( targets
?
3106 targets
.index( cur
) > -1 :
3108 // Don't pass non-elements to Sizzle
3109 cur
.nodeType
=== 1 &&
3110 jQuery
.find
.matchesSelector( cur
, selectors
) ) ) {
3112 matched
.push( cur
);
3119 return this.pushStack( matched
.length
> 1 ? jQuery
.uniqueSort( matched
) : matched
);
3122 // Determine the position of an element within the set
3123 index: function( elem
) {
3125 // No argument, return index in parent
3127 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length
: -1;
3130 // Index in selector
3131 if ( typeof elem
=== "string" ) {
3132 return indexOf
.call( jQuery( elem
), this[ 0 ] );
3135 // Locate the position of the desired element
3136 return indexOf
.call( this,
3138 // If it receives a jQuery object, the first element is used
3139 elem
.jquery
? elem
[ 0 ] : elem
3143 add: function( selector
, context
) {
3144 return this.pushStack(
3146 jQuery
.merge( this.get(), jQuery( selector
, context
) )
3151 addBack: function( selector
) {
3152 return this.add( selector
== null ?
3153 this.prevObject
: this.prevObject
.filter( selector
)
3158 function sibling( cur
, dir
) {
3159 while ( ( cur
= cur
[ dir
] ) && cur
.nodeType
!== 1 ) {}
3164 parent: function( elem
) {
3165 var parent
= elem
.parentNode
;
3166 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
3168 parents: function( elem
) {
3169 return dir( elem
, "parentNode" );
3171 parentsUntil: function( elem
, i
, until
) {
3172 return dir( elem
, "parentNode", until
);
3174 next: function( elem
) {
3175 return sibling( elem
, "nextSibling" );
3177 prev: function( elem
) {
3178 return sibling( elem
, "previousSibling" );
3180 nextAll: function( elem
) {
3181 return dir( elem
, "nextSibling" );
3183 prevAll: function( elem
) {
3184 return dir( elem
, "previousSibling" );
3186 nextUntil: function( elem
, i
, until
) {
3187 return dir( elem
, "nextSibling", until
);
3189 prevUntil: function( elem
, i
, until
) {
3190 return dir( elem
, "previousSibling", until
);
3192 siblings: function( elem
) {
3193 return siblings( ( elem
.parentNode
|| {} ).firstChild
, elem
);
3195 children: function( elem
) {
3196 return siblings( elem
.firstChild
);
3198 contents: function( elem
) {
3199 if ( nodeName( elem
, "iframe" ) ) {
3200 return elem
.contentDocument
;
3203 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3204 // Treat the template element as a regular one in browsers that
3205 // don't support it.
3206 if ( nodeName( elem
, "template" ) ) {
3207 elem
= elem
.content
|| elem
;
3210 return jQuery
.merge( [], elem
.childNodes
);
3212 }, function( name
, fn
) {
3213 jQuery
.fn
[ name
] = function( until
, selector
) {
3214 var matched
= jQuery
.map( this, fn
, until
);
3216 if ( name
.slice( -5 ) !== "Until" ) {
3220 if ( selector
&& typeof selector
=== "string" ) {
3221 matched
= jQuery
.filter( selector
, matched
);
3224 if ( this.length
> 1 ) {
3226 // Remove duplicates
3227 if ( !guaranteedUnique
[ name
] ) {
3228 jQuery
.uniqueSort( matched
);
3231 // Reverse order for parents* and prev-derivatives
3232 if ( rparentsprev
.test( name
) ) {
3237 return this.pushStack( matched
);
3240 var rnothtmlwhite
= ( /[^\x20\t\r\n\f]+/g );
3244 // Convert String-formatted options into Object-formatted ones
3245 function createOptions( options
) {
3247 jQuery
.each( options
.match( rnothtmlwhite
) || [], function( _
, flag
) {
3248 object
[ flag
] = true;
3254 * Create a callback list using the following parameters:
3256 * options: an optional list of space-separated options that will change how
3257 * the callback list behaves or a more traditional option object
3259 * By default a callback list will act like an event callback list and can be
3260 * "fired" multiple times.
3264 * once: will ensure the callback list can only be fired once (like a Deferred)
3266 * memory: will keep track of previous values and will call any callback added
3267 * after the list has been fired right away with the latest "memorized"
3268 * values (like a Deferred)
3270 * unique: will ensure a callback can only be added once (no duplicate in the list)
3272 * stopOnFalse: interrupt callings when a callback returns false
3275 jQuery
.Callbacks = function( options
) {
3277 // Convert options from String-formatted to Object-formatted if needed
3278 // (we check in cache first)
3279 options
= typeof options
=== "string" ?
3280 createOptions( options
) :
3281 jQuery
.extend( {}, options
);
3283 var // Flag to know if list is currently firing
3286 // Last fire value for non-forgettable lists
3289 // Flag to know if list was already fired
3292 // Flag to prevent firing
3295 // Actual callback list
3298 // Queue of execution data for repeatable lists
3301 // Index of currently firing callback (modified by add/remove as needed)
3307 // Enforce single-firing
3308 locked
= locked
|| options
.once
;
3310 // Execute callbacks for all pending executions,
3311 // respecting firingIndex overrides and runtime changes
3312 fired
= firing
= true;
3313 for ( ; queue
.length
; firingIndex
= -1 ) {
3314 memory
= queue
.shift();
3315 while ( ++firingIndex
< list
.length
) {
3317 // Run callback and check for early termination
3318 if ( list
[ firingIndex
].apply( memory
[ 0 ], memory
[ 1 ] ) === false &&
3319 options
.stopOnFalse
) {
3321 // Jump to end and forget the data so .add doesn't re-fire
3322 firingIndex
= list
.length
;
3328 // Forget the data if we're done with it
3329 if ( !options
.memory
) {
3335 // Clean up if we're done firing for good
3338 // Keep an empty list if we have data for future add calls
3342 // Otherwise, this object is spent
3349 // Actual Callbacks object
3352 // Add a callback or a collection of callbacks to the list
3356 // If we have memory from a past run, we should fire after adding
3357 if ( memory
&& !firing
) {
3358 firingIndex
= list
.length
- 1;
3359 queue
.push( memory
);
3362 ( function add( args
) {
3363 jQuery
.each( args
, function( _
, arg
) {
3364 if ( jQuery
.isFunction( arg
) ) {
3365 if ( !options
.unique
|| !self
.has( arg
) ) {
3368 } else if ( arg
&& arg
.length
&& jQuery
.type( arg
) !== "string" ) {
3370 // Inspect recursively
3376 if ( memory
&& !firing
) {
3383 // Remove a callback from the list
3384 remove: function() {
3385 jQuery
.each( arguments
, function( _
, arg
) {
3387 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3388 list
.splice( index
, 1 );
3390 // Handle firing indexes
3391 if ( index
<= firingIndex
) {
3399 // Check if a given callback is in the list.
3400 // If no argument is given, return whether or not list has callbacks attached.
3401 has: function( fn
) {
3403 jQuery
.inArray( fn
, list
) > -1 :
3407 // Remove all callbacks from the list
3415 // Disable .fire and .add
3416 // Abort any current/pending executions
3417 // Clear all callbacks and values
3418 disable: function() {
3419 locked
= queue
= [];
3423 disabled: function() {
3428 // Also disable .add unless we have memory (since it would have no effect)
3429 // Abort any pending executions
3431 locked
= queue
= [];
3432 if ( !memory
&& !firing
) {
3437 locked: function() {
3441 // Call all callbacks with the given context and arguments
3442 fireWith: function( context
, args
) {
3445 args
= [ context
, args
.slice
? args
.slice() : args
];
3454 // Call all the callbacks with the given arguments
3456 self
.fireWith( this, arguments
);
3460 // To know if the callbacks have already been called at least once
3470 function Identity( v
) {
3473 function Thrower( ex
) {
3477 function adoptValue( value
, resolve
, reject
, noValue
) {
3482 // Check for promise aspect first to privilege synchronous behavior
3483 if ( value
&& jQuery
.isFunction( ( method
= value
.promise
) ) ) {
3484 method
.call( value
).done( resolve
).fail( reject
);
3487 } else if ( value
&& jQuery
.isFunction( ( method
= value
.then
) ) ) {
3488 method
.call( value
, resolve
, reject
);
3490 // Other non-thenables
3493 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3494 // * false: [ value ].slice( 0 ) => resolve( value )
3495 // * true: [ value ].slice( 1 ) => resolve()
3496 resolve
.apply( undefined, [ value
].slice( noValue
) );
3499 // For Promises/A+, convert exceptions into rejections
3500 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3501 // Deferred#then to conditionally suppress rejection.
3504 // Support: Android 4.0 only
3505 // Strict mode functions invoked without .call/.apply get global-object context
3506 reject
.apply( undefined, [ value
] );
3512 Deferred: function( func
) {
3515 // action, add listener, callbacks,
3516 // ... .then handlers, argument index, [final state]
3517 [ "notify", "progress", jQuery
.Callbacks( "memory" ),
3518 jQuery
.Callbacks( "memory" ), 2 ],
3519 [ "resolve", "done", jQuery
.Callbacks( "once memory" ),
3520 jQuery
.Callbacks( "once memory" ), 0, "resolved" ],
3521 [ "reject", "fail", jQuery
.Callbacks( "once memory" ),
3522 jQuery
.Callbacks( "once memory" ), 1, "rejected" ]
3529 always: function() {
3530 deferred
.done( arguments
).fail( arguments
);
3533 "catch": function( fn
) {
3534 return promise
.then( null, fn
);
3537 // Keep pipe for back-compat
3538 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3539 var fns
= arguments
;
3541 return jQuery
.Deferred( function( newDefer
) {
3542 jQuery
.each( tuples
, function( i
, tuple
) {
3544 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3545 var fn
= jQuery
.isFunction( fns
[ tuple
[ 4 ] ] ) && fns
[ tuple
[ 4 ] ];
3547 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3548 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3549 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3550 deferred
[ tuple
[ 1 ] ]( function() {
3551 var returned
= fn
&& fn
.apply( this, arguments
);
3552 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
3554 .progress( newDefer
.notify
)
3555 .done( newDefer
.resolve
)
3556 .fail( newDefer
.reject
);
3558 newDefer
[ tuple
[ 0 ] + "With" ](
3560 fn
? [ returned
] : arguments
3568 then: function( onFulfilled
, onRejected
, onProgress
) {
3570 function resolve( depth
, deferred
, handler
, special
) {
3574 mightThrow = function() {
3577 // Support: Promises/A+ section 2.3.3.3.3
3578 // https://promisesaplus.com/#point-59
3579 // Ignore double-resolution attempts
3580 if ( depth
< maxDepth
) {
3584 returned
= handler
.apply( that
, args
);
3586 // Support: Promises/A+ section 2.3.1
3587 // https://promisesaplus.com/#point-48
3588 if ( returned
=== deferred
.promise() ) {
3589 throw new TypeError( "Thenable self-resolution" );
3592 // Support: Promises/A+ sections 2.3.3.1, 3.5
3593 // https://promisesaplus.com/#point-54
3594 // https://promisesaplus.com/#point-75
3595 // Retrieve `then` only once
3598 // Support: Promises/A+ section 2.3.4
3599 // https://promisesaplus.com/#point-64
3600 // Only check objects and functions for thenability
3601 ( typeof returned
=== "object" ||
3602 typeof returned
=== "function" ) &&
3605 // Handle a returned thenable
3606 if ( jQuery
.isFunction( then
) ) {
3608 // Special processors (notify) just wait for resolution
3612 resolve( maxDepth
, deferred
, Identity
, special
),
3613 resolve( maxDepth
, deferred
, Thrower
, special
)
3616 // Normal processors (resolve) also hook into progress
3619 // ...and disregard older resolution values
3624 resolve( maxDepth
, deferred
, Identity
, special
),
3625 resolve( maxDepth
, deferred
, Thrower
, special
),
3626 resolve( maxDepth
, deferred
, Identity
,
3627 deferred
.notifyWith
)
3631 // Handle all other returned values
3634 // Only substitute handlers pass on context
3635 // and multiple values (non-spec behavior)
3636 if ( handler
!== Identity
) {
3638 args
= [ returned
];
3641 // Process the value(s)
3642 // Default process is resolve
3643 ( special
|| deferred
.resolveWith
)( that
, args
);
3647 // Only normal processors (resolve) catch and reject exceptions
3655 if ( jQuery
.Deferred
.exceptionHook
) {
3656 jQuery
.Deferred
.exceptionHook( e
,
3657 process
.stackTrace
);
3660 // Support: Promises/A+ section 2.3.3.3.4.1
3661 // https://promisesaplus.com/#point-61
3662 // Ignore post-resolution exceptions
3663 if ( depth
+ 1 >= maxDepth
) {
3665 // Only substitute handlers pass on context
3666 // and multiple values (non-spec behavior)
3667 if ( handler
!== Thrower
) {
3672 deferred
.rejectWith( that
, args
);
3677 // Support: Promises/A+ section 2.3.3.3.1
3678 // https://promisesaplus.com/#point-57
3679 // Re-resolve promises immediately to dodge false rejection from
3680 // subsequent errors
3685 // Call an optional hook to record the stack, in case of exception
3686 // since it's otherwise lost when execution goes async
3687 if ( jQuery
.Deferred
.getStackHook
) {
3688 process
.stackTrace
= jQuery
.Deferred
.getStackHook();
3690 window
.setTimeout( process
);
3695 return jQuery
.Deferred( function( newDefer
) {
3697 // progress_handlers.add( ... )
3698 tuples
[ 0 ][ 3 ].add(
3702 jQuery
.isFunction( onProgress
) ?
3709 // fulfilled_handlers.add( ... )
3710 tuples
[ 1 ][ 3 ].add(
3714 jQuery
.isFunction( onFulfilled
) ?
3720 // rejected_handlers.add( ... )
3721 tuples
[ 2 ][ 3 ].add(
3725 jQuery
.isFunction( onRejected
) ?
3733 // Get a promise for this deferred
3734 // If obj is provided, the promise aspect is added to the object
3735 promise: function( obj
) {
3736 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3741 // Add list-specific methods
3742 jQuery
.each( tuples
, function( i
, tuple
) {
3743 var list
= tuple
[ 2 ],
3744 stateString
= tuple
[ 5 ];
3746 // promise.progress = list.add
3747 // promise.done = list.add
3748 // promise.fail = list.add
3749 promise
[ tuple
[ 1 ] ] = list
.add
;
3752 if ( stateString
) {
3756 // state = "resolved" (i.e., fulfilled)
3757 // state = "rejected"
3758 state
= stateString
;
3761 // rejected_callbacks.disable
3762 // fulfilled_callbacks.disable
3763 tuples
[ 3 - i
][ 2 ].disable
,
3765 // progress_callbacks.lock
3766 tuples
[ 0 ][ 2 ].lock
3770 // progress_handlers.fire
3771 // fulfilled_handlers.fire
3772 // rejected_handlers.fire
3773 list
.add( tuple
[ 3 ].fire
);
3775 // deferred.notify = function() { deferred.notifyWith(...) }
3776 // deferred.resolve = function() { deferred.resolveWith(...) }
3777 // deferred.reject = function() { deferred.rejectWith(...) }
3778 deferred
[ tuple
[ 0 ] ] = function() {
3779 deferred
[ tuple
[ 0 ] + "With" ]( this === deferred
? undefined : this, arguments
);
3783 // deferred.notifyWith = list.fireWith
3784 // deferred.resolveWith = list.fireWith
3785 // deferred.rejectWith = list.fireWith
3786 deferred
[ tuple
[ 0 ] + "With" ] = list
.fireWith
;
3789 // Make the deferred a promise
3790 promise
.promise( deferred
);
3792 // Call given func if any
3794 func
.call( deferred
, deferred
);
3802 when: function( singleValue
) {
3805 // count of uncompleted subordinates
3806 remaining
= arguments
.length
,
3808 // count of unprocessed arguments
3811 // subordinate fulfillment data
3812 resolveContexts
= Array( i
),
3813 resolveValues
= slice
.call( arguments
),
3815 // the master Deferred
3816 master
= jQuery
.Deferred(),
3818 // subordinate callback factory
3819 updateFunc = function( i
) {
3820 return function( value
) {
3821 resolveContexts
[ i
] = this;
3822 resolveValues
[ i
] = arguments
.length
> 1 ? slice
.call( arguments
) : value
;
3823 if ( !( --remaining
) ) {
3824 master
.resolveWith( resolveContexts
, resolveValues
);
3829 // Single- and empty arguments are adopted like Promise.resolve
3830 if ( remaining
<= 1 ) {
3831 adoptValue( singleValue
, master
.done( updateFunc( i
) ).resolve
, master
.reject
,
3834 // Use .then() to unwrap secondary thenables (cf. gh-3000)
3835 if ( master
.state() === "pending" ||
3836 jQuery
.isFunction( resolveValues
[ i
] && resolveValues
[ i
].then
) ) {
3838 return master
.then();
3842 // Multiple arguments are aggregated like Promise.all array elements
3844 adoptValue( resolveValues
[ i
], updateFunc( i
), master
.reject
);
3847 return master
.promise();
3852 // These usually indicate a programmer mistake during development,
3853 // warn about them ASAP rather than swallowing them by default.
3854 var rerrorNames
= /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3856 jQuery
.Deferred
.exceptionHook = function( error
, stack
) {
3858 // Support: IE 8 - 9 only
3859 // Console exists when dev tools are open, which can happen at any time
3860 if ( window
.console
&& window
.console
.warn
&& error
&& rerrorNames
.test( error
.name
) ) {
3861 window
.console
.warn( "jQuery.Deferred exception: " + error
.message
, error
.stack
, stack
);
3868 jQuery
.readyException = function( error
) {
3869 window
.setTimeout( function() {
3877 // The deferred used on DOM ready
3878 var readyList
= jQuery
.Deferred();
3880 jQuery
.fn
.ready = function( fn
) {
3885 // Wrap jQuery.readyException in a function so that the lookup
3886 // happens at the time of error handling instead of callback
3888 .catch( function( error
) {
3889 jQuery
.readyException( error
);
3897 // Is the DOM ready to be used? Set to true once it occurs.
3900 // A counter to track how many items to wait for before
3901 // the ready event fires. See #6781
3904 // Handle when the DOM is ready
3905 ready: function( wait
) {
3907 // Abort if there are pending holds or we're already ready
3908 if ( wait
=== true ? --jQuery
.readyWait
: jQuery
.isReady
) {
3912 // Remember that the DOM is ready
3913 jQuery
.isReady
= true;
3915 // If a normal DOM Ready event fired, decrement, and wait if need be
3916 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
3920 // If there are functions bound, to execute
3921 readyList
.resolveWith( document
, [ jQuery
] );
3925 jQuery
.ready
.then
= readyList
.then
;
3927 // The ready event handler and self cleanup method
3928 function completed() {
3929 document
.removeEventListener( "DOMContentLoaded", completed
);
3930 window
.removeEventListener( "load", completed
);
3934 // Catch cases where $(document).ready() is called
3935 // after the browser event has already occurred.
3936 // Support: IE <=9 - 10 only
3937 // Older IE sometimes signals "interactive" too soon
3938 if ( document
.readyState
=== "complete" ||
3939 ( document
.readyState
!== "loading" && !document
.documentElement
.doScroll
) ) {
3941 // Handle it asynchronously to allow scripts the opportunity to delay ready
3942 window
.setTimeout( jQuery
.ready
);
3946 // Use the handy event callback
3947 document
.addEventListener( "DOMContentLoaded", completed
);
3949 // A fallback to window.onload, that will always work
3950 window
.addEventListener( "load", completed
);
3956 // Multifunctional method to get and set values of a collection
3957 // The value/s can optionally be executed if it's a function
3958 var access = function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
3964 if ( jQuery
.type( key
) === "object" ) {
3967 access( elems
, fn
, i
, key
[ i
], true, emptyGet
, raw
);
3971 } else if ( value
!== undefined ) {
3974 if ( !jQuery
.isFunction( value
) ) {
3980 // Bulk operations run against the entire set
3982 fn
.call( elems
, value
);
3985 // ...except when executing function values
3988 fn = function( elem
, key
, value
) {
3989 return bulk
.call( jQuery( elem
), value
);
3995 for ( ; i
< len
; i
++ ) {
3997 elems
[ i
], key
, raw
?
3999 value
.call( elems
[ i
], i
, fn( elems
[ i
], key
) )
4011 return fn
.call( elems
);
4014 return len
? fn( elems
[ 0 ], key
) : emptyGet
;
4016 var acceptData = function( owner
) {
4020 // - Node.ELEMENT_NODE
4021 // - Node.DOCUMENT_NODE
4024 return owner
.nodeType
=== 1 || owner
.nodeType
=== 9 || !( +owner
.nodeType
);
4031 this.expando
= jQuery
.expando
+ Data
.uid
++;
4038 cache: function( owner
) {
4040 // Check if the owner object already has a cache
4041 var value
= owner
[ this.expando
];
4043 // If not, create one
4047 // We can accept data for non-element nodes in modern browsers,
4048 // but we should not, see #8335.
4049 // Always return an empty object.
4050 if ( acceptData( owner
) ) {
4052 // If it is a node unlikely to be stringify-ed or looped over
4053 // use plain assignment
4054 if ( owner
.nodeType
) {
4055 owner
[ this.expando
] = value
;
4057 // Otherwise secure it in a non-enumerable property
4058 // configurable must be true to allow the property to be
4059 // deleted when data is removed
4061 Object
.defineProperty( owner
, this.expando
, {
4071 set: function( owner
, data
, value
) {
4073 cache
= this.cache( owner
);
4075 // Handle: [ owner, key, value ] args
4076 // Always use camelCase key (gh-2257)
4077 if ( typeof data
=== "string" ) {
4078 cache
[ jQuery
.camelCase( data
) ] = value
;
4080 // Handle: [ owner, { properties } ] args
4083 // Copy the properties one-by-one to the cache object
4084 for ( prop
in data
) {
4085 cache
[ jQuery
.camelCase( prop
) ] = data
[ prop
];
4090 get: function( owner
, key
) {
4091 return key
=== undefined ?
4092 this.cache( owner
) :
4094 // Always use camelCase key (gh-2257)
4095 owner
[ this.expando
] && owner
[ this.expando
][ jQuery
.camelCase( key
) ];
4097 access: function( owner
, key
, value
) {
4099 // In cases where either:
4101 // 1. No key was specified
4102 // 2. A string key was specified, but no value provided
4104 // Take the "read" path and allow the get method to determine
4105 // which value to return, respectively either:
4107 // 1. The entire cache object
4108 // 2. The data stored at the key
4110 if ( key
=== undefined ||
4111 ( ( key
&& typeof key
=== "string" ) && value
=== undefined ) ) {
4113 return this.get( owner
, key
);
4116 // When the key is not a string, or both a key and value
4117 // are specified, set or extend (existing objects) with either:
4119 // 1. An object of properties
4120 // 2. A key and value
4122 this.set( owner
, key
, value
);
4124 // Since the "set" path can have two possible entry points
4125 // return the expected data based on which path was taken[*]
4126 return value
!== undefined ? value
: key
;
4128 remove: function( owner
, key
) {
4130 cache
= owner
[ this.expando
];
4132 if ( cache
=== undefined ) {
4136 if ( key
!== undefined ) {
4138 // Support array or space separated string of keys
4139 if ( Array
.isArray( key
) ) {
4141 // If key is an array of keys...
4142 // We always set camelCase keys, so remove that.
4143 key
= key
.map( jQuery
.camelCase
);
4145 key
= jQuery
.camelCase( key
);
4147 // If a key with the spaces exists, use it.
4148 // Otherwise, create an array by matching non-whitespace
4149 key
= key
in cache
?
4151 ( key
.match( rnothtmlwhite
) || [] );
4157 delete cache
[ key
[ i
] ];
4161 // Remove the expando if there's no more data
4162 if ( key
=== undefined || jQuery
.isEmptyObject( cache
) ) {
4164 // Support: Chrome <=35 - 45
4165 // Webkit & Blink performance suffers when deleting properties
4166 // from DOM nodes, so set to undefined instead
4167 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4168 if ( owner
.nodeType
) {
4169 owner
[ this.expando
] = undefined;
4171 delete owner
[ this.expando
];
4175 hasData: function( owner
) {
4176 var cache
= owner
[ this.expando
];
4177 return cache
!== undefined && !jQuery
.isEmptyObject( cache
);
4180 var dataPriv
= new Data();
4182 var dataUser
= new Data();
4186 // Implementation Summary
4188 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4189 // 2. Improve the module's maintainability by reducing the storage
4190 // paths to a single mechanism.
4191 // 3. Use the same single mechanism to support "private" and "user" data.
4192 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4193 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4194 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4196 var rbrace
= /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4197 rmultiDash
= /[A-Z]/g;
4199 function getData( data
) {
4200 if ( data
=== "true" ) {
4204 if ( data
=== "false" ) {
4208 if ( data
=== "null" ) {
4212 // Only convert to a number if it doesn't change the string
4213 if ( data
=== +data
+ "" ) {
4217 if ( rbrace
.test( data
) ) {
4218 return JSON
.parse( data
);
4224 function dataAttr( elem
, key
, data
) {
4227 // If nothing was found internally, try to fetch any
4228 // data from the HTML5 data-* attribute
4229 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
4230 name
= "data-" + key
.replace( rmultiDash
, "-$&" ).toLowerCase();
4231 data
= elem
.getAttribute( name
);
4233 if ( typeof data
=== "string" ) {
4235 data
= getData( data
);
4238 // Make sure we set the data so it isn't changed later
4239 dataUser
.set( elem
, key
, data
);
4248 hasData: function( elem
) {
4249 return dataUser
.hasData( elem
) || dataPriv
.hasData( elem
);
4252 data: function( elem
, name
, data
) {
4253 return dataUser
.access( elem
, name
, data
);
4256 removeData: function( elem
, name
) {
4257 dataUser
.remove( elem
, name
);
4260 // TODO: Now that all calls to _data and _removeData have been replaced
4261 // with direct calls to dataPriv methods, these can be deprecated.
4262 _data: function( elem
, name
, data
) {
4263 return dataPriv
.access( elem
, name
, data
);
4266 _removeData: function( elem
, name
) {
4267 dataPriv
.remove( elem
, name
);
4272 data: function( key
, value
) {
4275 attrs
= elem
&& elem
.attributes
;
4278 if ( key
=== undefined ) {
4279 if ( this.length
) {
4280 data
= dataUser
.get( elem
);
4282 if ( elem
.nodeType
=== 1 && !dataPriv
.get( elem
, "hasDataAttrs" ) ) {
4286 // Support: IE 11 only
4287 // The attrs elements can be null (#14894)
4289 name
= attrs
[ i
].name
;
4290 if ( name
.indexOf( "data-" ) === 0 ) {
4291 name
= jQuery
.camelCase( name
.slice( 5 ) );
4292 dataAttr( elem
, name
, data
[ name
] );
4296 dataPriv
.set( elem
, "hasDataAttrs", true );
4303 // Sets multiple values
4304 if ( typeof key
=== "object" ) {
4305 return this.each( function() {
4306 dataUser
.set( this, key
);
4310 return access( this, function( value
) {
4313 // The calling jQuery object (element matches) is not empty
4314 // (and therefore has an element appears at this[ 0 ]) and the
4315 // `value` parameter was not undefined. An empty jQuery object
4316 // will result in `undefined` for elem = this[ 0 ] which will
4317 // throw an exception if an attempt to read a data cache is made.
4318 if ( elem
&& value
=== undefined ) {
4320 // Attempt to get data from the cache
4321 // The key will always be camelCased in Data
4322 data
= dataUser
.get( elem
, key
);
4323 if ( data
!== undefined ) {
4327 // Attempt to "discover" the data in
4328 // HTML5 custom data-* attrs
4329 data
= dataAttr( elem
, key
);
4330 if ( data
!== undefined ) {
4334 // We tried really hard, but the data doesn't exist.
4339 this.each( function() {
4341 // We always store the camelCased key
4342 dataUser
.set( this, key
, value
);
4344 }, null, value
, arguments
.length
> 1, null, true );
4347 removeData: function( key
) {
4348 return this.each( function() {
4349 dataUser
.remove( this, key
);
4356 queue: function( elem
, type
, data
) {
4360 type
= ( type
|| "fx" ) + "queue";
4361 queue
= dataPriv
.get( elem
, type
);
4363 // Speed up dequeue by getting out quickly if this is just a lookup
4365 if ( !queue
|| Array
.isArray( data
) ) {
4366 queue
= dataPriv
.access( elem
, type
, jQuery
.makeArray( data
) );
4375 dequeue: function( elem
, type
) {
4376 type
= type
|| "fx";
4378 var queue
= jQuery
.queue( elem
, type
),
4379 startLength
= queue
.length
,
4381 hooks
= jQuery
._queueHooks( elem
, type
),
4383 jQuery
.dequeue( elem
, type
);
4386 // If the fx queue is dequeued, always remove the progress sentinel
4387 if ( fn
=== "inprogress" ) {
4394 // Add a progress sentinel to prevent the fx queue from being
4395 // automatically dequeued
4396 if ( type
=== "fx" ) {
4397 queue
.unshift( "inprogress" );
4400 // Clear up the last queue stop function
4402 fn
.call( elem
, next
, hooks
);
4405 if ( !startLength
&& hooks
) {
4410 // Not public - generate a queueHooks object, or return the current one
4411 _queueHooks: function( elem
, type
) {
4412 var key
= type
+ "queueHooks";
4413 return dataPriv
.get( elem
, key
) || dataPriv
.access( elem
, key
, {
4414 empty
: jQuery
.Callbacks( "once memory" ).add( function() {
4415 dataPriv
.remove( elem
, [ type
+ "queue", key
] );
4422 queue: function( type
, data
) {
4425 if ( typeof type
!== "string" ) {
4431 if ( arguments
.length
< setter
) {
4432 return jQuery
.queue( this[ 0 ], type
);
4435 return data
=== undefined ?
4437 this.each( function() {
4438 var queue
= jQuery
.queue( this, type
, data
);
4440 // Ensure a hooks for this queue
4441 jQuery
._queueHooks( this, type
);
4443 if ( type
=== "fx" && queue
[ 0 ] !== "inprogress" ) {
4444 jQuery
.dequeue( this, type
);
4448 dequeue: function( type
) {
4449 return this.each( function() {
4450 jQuery
.dequeue( this, type
);
4453 clearQueue: function( type
) {
4454 return this.queue( type
|| "fx", [] );
4457 // Get a promise resolved when queues of a certain type
4458 // are emptied (fx is the type by default)
4459 promise: function( type
, obj
) {
4462 defer
= jQuery
.Deferred(),
4465 resolve = function() {
4466 if ( !( --count
) ) {
4467 defer
.resolveWith( elements
, [ elements
] );
4471 if ( typeof type
!== "string" ) {
4475 type
= type
|| "fx";
4478 tmp
= dataPriv
.get( elements
[ i
], type
+ "queueHooks" );
4479 if ( tmp
&& tmp
.empty
) {
4481 tmp
.empty
.add( resolve
);
4485 return defer
.promise( obj
);
4488 var pnum
= ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source
;
4490 var rcssNum
= new RegExp( "^(?:([+-])=|)(" + pnum
+ ")([a-z%]*)$", "i" );
4493 var cssExpand
= [ "Top", "Right", "Bottom", "Left" ];
4495 var isHiddenWithinTree = function( elem
, el
) {
4497 // isHiddenWithinTree might be called from jQuery#filter function;
4498 // in that case, element will be second argument
4501 // Inline style trumps all
4502 return elem
.style
.display
=== "none" ||
4503 elem
.style
.display
=== "" &&
4505 // Otherwise, check computed style
4506 // Support: Firefox <=43 - 45
4507 // Disconnected elements can have computed display: none, so first confirm that elem is
4509 jQuery
.contains( elem
.ownerDocument
, elem
) &&
4511 jQuery
.css( elem
, "display" ) === "none";
4514 var swap = function( elem
, options
, callback
, args
) {
4518 // Remember the old values, and insert the new ones
4519 for ( name
in options
) {
4520 old
[ name
] = elem
.style
[ name
];
4521 elem
.style
[ name
] = options
[ name
];
4524 ret
= callback
.apply( elem
, args
|| [] );
4526 // Revert the old values
4527 for ( name
in options
) {
4528 elem
.style
[ name
] = old
[ name
];
4537 function adjustCSS( elem
, prop
, valueParts
, tween
) {
4541 currentValue
= tween
?
4546 return jQuery
.css( elem
, prop
, "" );
4548 initial
= currentValue(),
4549 unit
= valueParts
&& valueParts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
4551 // Starting value computation is required for potential unit mismatches
4552 initialInUnit
= ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +initial
) &&
4553 rcssNum
.exec( jQuery
.css( elem
, prop
) );
4555 if ( initialInUnit
&& initialInUnit
[ 3 ] !== unit
) {
4557 // Trust units reported by jQuery.css
4558 unit
= unit
|| initialInUnit
[ 3 ];
4560 // Make sure we update the tween properties later on
4561 valueParts
= valueParts
|| [];
4563 // Iteratively approximate from a nonzero starting point
4564 initialInUnit
= +initial
|| 1;
4568 // If previous iteration zeroed out, double until we get *something*.
4569 // Use string for doubling so we don't accidentally see scale as unchanged below
4570 scale
= scale
|| ".5";
4573 initialInUnit
= initialInUnit
/ scale
;
4574 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4576 // Update scale, tolerating zero or NaN from tween.cur()
4577 // Break the loop if scale is unchanged or perfect, or if we've just had enough.
4579 scale
!== ( scale
= currentValue() / initial
) && scale
!== 1 && --maxIterations
4584 initialInUnit
= +initialInUnit
|| +initial
|| 0;
4586 // Apply relative offset (+=/-=) if specified
4587 adjusted
= valueParts
[ 1 ] ?
4588 initialInUnit
+ ( valueParts
[ 1 ] + 1 ) * valueParts
[ 2 ] :
4592 tween
.start
= initialInUnit
;
4593 tween
.end
= adjusted
;
4600 var defaultDisplayMap
= {};
4602 function getDefaultDisplay( elem
) {
4604 doc
= elem
.ownerDocument
,
4605 nodeName
= elem
.nodeName
,
4606 display
= defaultDisplayMap
[ nodeName
];
4612 temp
= doc
.body
.appendChild( doc
.createElement( nodeName
) );
4613 display
= jQuery
.css( temp
, "display" );
4615 temp
.parentNode
.removeChild( temp
);
4617 if ( display
=== "none" ) {
4620 defaultDisplayMap
[ nodeName
] = display
;
4625 function showHide( elements
, show
) {
4629 length
= elements
.length
;
4631 // Determine new display value for elements that need to change
4632 for ( ; index
< length
; index
++ ) {
4633 elem
= elements
[ index
];
4634 if ( !elem
.style
) {
4638 display
= elem
.style
.display
;
4641 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4642 // check is required in this first loop unless we have a nonempty display value (either
4643 // inline or about-to-be-restored)
4644 if ( display
=== "none" ) {
4645 values
[ index
] = dataPriv
.get( elem
, "display" ) || null;
4646 if ( !values
[ index
] ) {
4647 elem
.style
.display
= "";
4650 if ( elem
.style
.display
=== "" && isHiddenWithinTree( elem
) ) {
4651 values
[ index
] = getDefaultDisplay( elem
);
4654 if ( display
!== "none" ) {
4655 values
[ index
] = "none";
4657 // Remember what we're overwriting
4658 dataPriv
.set( elem
, "display", display
);
4663 // Set the display of the elements in a second loop to avoid constant reflow
4664 for ( index
= 0; index
< length
; index
++ ) {
4665 if ( values
[ index
] != null ) {
4666 elements
[ index
].style
.display
= values
[ index
];
4675 return showHide( this, true );
4678 return showHide( this );
4680 toggle: function( state
) {
4681 if ( typeof state
=== "boolean" ) {
4682 return state
? this.show() : this.hide();
4685 return this.each( function() {
4686 if ( isHiddenWithinTree( this ) ) {
4687 jQuery( this ).show();
4689 jQuery( this ).hide();
4694 var rcheckableType
= ( /^(?:checkbox|radio)$/i );
4696 var rtagName
= ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
4698 var rscriptType
= ( /^$|\/(?:java|ecma)script/i );
4702 // We have to close these tags to support XHTML (#13200)
4705 // Support: IE <=9 only
4706 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
4708 // XHTML parsers do not magically insert elements in the
4709 // same way that tag soup parsers do. So we cannot shorten
4710 // this by omitting <tbody> or other required elements.
4711 thead
: [ 1, "<table>", "</table>" ],
4712 col
: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4713 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
4714 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4716 _default
: [ 0, "", "" ]
4719 // Support: IE <=9 only
4720 wrapMap
.optgroup
= wrapMap
.option
;
4722 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
4723 wrapMap
.th
= wrapMap
.td
;
4726 function getAll( context
, tag
) {
4728 // Support: IE <=9 - 11 only
4729 // Use typeof to avoid zero-argument method invocation on host objects (#15151)
4732 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
4733 ret
= context
.getElementsByTagName( tag
|| "*" );
4735 } else if ( typeof context
.querySelectorAll
!== "undefined" ) {
4736 ret
= context
.querySelectorAll( tag
|| "*" );
4742 if ( tag
=== undefined || tag
&& nodeName( context
, tag
) ) {
4743 return jQuery
.merge( [ context
], ret
);
4750 // Mark scripts as having already been evaluated
4751 function setGlobalEval( elems
, refElements
) {
4755 for ( ; i
< l
; i
++ ) {
4759 !refElements
|| dataPriv
.get( refElements
[ i
], "globalEval" )
4765 var rhtml
= /<|&#?\w+;/;
4767 function buildFragment( elems
, context
, scripts
, selection
, ignored
) {
4768 var elem
, tmp
, tag
, wrap
, contains
, j
,
4769 fragment
= context
.createDocumentFragment(),
4774 for ( ; i
< l
; i
++ ) {
4777 if ( elem
|| elem
=== 0 ) {
4779 // Add nodes directly
4780 if ( jQuery
.type( elem
) === "object" ) {
4782 // Support: Android <=4.0 only, PhantomJS 1 only
4783 // push.apply(_, arraylike) throws on ancient WebKit
4784 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
4786 // Convert non-html into a text node
4787 } else if ( !rhtml
.test( elem
) ) {
4788 nodes
.push( context
.createTextNode( elem
) );
4790 // Convert html into DOM nodes
4792 tmp
= tmp
|| fragment
.appendChild( context
.createElement( "div" ) );
4794 // Deserialize a standard representation
4795 tag
= ( rtagName
.exec( elem
) || [ "", "" ] )[ 1 ].toLowerCase();
4796 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
4797 tmp
.innerHTML
= wrap
[ 1 ] + jQuery
.htmlPrefilter( elem
) + wrap
[ 2 ];
4799 // Descend through wrappers to the right content
4802 tmp
= tmp
.lastChild
;
4805 // Support: Android <=4.0 only, PhantomJS 1 only
4806 // push.apply(_, arraylike) throws on ancient WebKit
4807 jQuery
.merge( nodes
, tmp
.childNodes
);
4809 // Remember the top-level container
4810 tmp
= fragment
.firstChild
;
4812 // Ensure the created nodes are orphaned (#12392)
4813 tmp
.textContent
= "";
4818 // Remove wrapper from fragment
4819 fragment
.textContent
= "";
4822 while ( ( elem
= nodes
[ i
++ ] ) ) {
4824 // Skip elements already in the context collection (trac-4087)
4825 if ( selection
&& jQuery
.inArray( elem
, selection
) > -1 ) {
4827 ignored
.push( elem
);
4832 contains
= jQuery
.contains( elem
.ownerDocument
, elem
);
4834 // Append to fragment
4835 tmp
= getAll( fragment
.appendChild( elem
), "script" );
4837 // Preserve script evaluation history
4839 setGlobalEval( tmp
);
4842 // Capture executables
4845 while ( ( elem
= tmp
[ j
++ ] ) ) {
4846 if ( rscriptType
.test( elem
.type
|| "" ) ) {
4847 scripts
.push( elem
);
4858 var fragment
= document
.createDocumentFragment(),
4859 div
= fragment
.appendChild( document
.createElement( "div" ) ),
4860 input
= document
.createElement( "input" );
4862 // Support: Android 4.0 - 4.3 only
4863 // Check state lost if the name is set (#11217)
4864 // Support: Windows Web Apps (WWA)
4865 // `name` and `type` must use .setAttribute for WWA (#14901)
4866 input
.setAttribute( "type", "radio" );
4867 input
.setAttribute( "checked", "checked" );
4868 input
.setAttribute( "name", "t" );
4870 div
.appendChild( input
);
4872 // Support: Android <=4.1 only
4873 // Older WebKit doesn't clone checked state correctly in fragments
4874 support
.checkClone
= div
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
4876 // Support: IE <=11 only
4877 // Make sure textarea (and checkbox) defaultValue is properly cloned
4878 div
.innerHTML
= "<textarea>x</textarea>";
4879 support
.noCloneChecked
= !!div
.cloneNode( true ).lastChild
.defaultValue
;
4881 var documentElement
= document
.documentElement
;
4887 rmouseEvent
= /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4888 rtypenamespace
= /^([^.]*)(?:\.(.+)|)/;
4890 function returnTrue() {
4894 function returnFalse() {
4898 // Support: IE <=9 only
4899 // See #13393 for more info
4900 function safeActiveElement() {
4902 return document
.activeElement
;
4906 function on( elem
, types
, selector
, data
, fn
, one
) {
4909 // Types can be a map of types/handlers
4910 if ( typeof types
=== "object" ) {
4912 // ( types-Object, selector, data )
4913 if ( typeof selector
!== "string" ) {
4915 // ( types-Object, data )
4916 data
= data
|| selector
;
4917 selector
= undefined;
4919 for ( type
in types
) {
4920 on( elem
, type
, selector
, data
, types
[ type
], one
);
4925 if ( data
== null && fn
== null ) {
4929 data
= selector
= undefined;
4930 } else if ( fn
== null ) {
4931 if ( typeof selector
=== "string" ) {
4933 // ( types, selector, fn )
4938 // ( types, data, fn )
4941 selector
= undefined;
4944 if ( fn
=== false ) {
4952 fn = function( event
) {
4954 // Can use an empty set, since event contains the info
4955 jQuery().off( event
);
4956 return origFn
.apply( this, arguments
);
4959 // Use same guid so caller can remove using origFn
4960 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
4962 return elem
.each( function() {
4963 jQuery
.event
.add( this, types
, fn
, data
, selector
);
4968 * Helper functions for managing events -- not part of the public interface.
4969 * Props to Dean Edwards' addEvent library for many of the ideas.
4975 add: function( elem
, types
, handler
, data
, selector
) {
4977 var handleObjIn
, eventHandle
, tmp
,
4978 events
, t
, handleObj
,
4979 special
, handlers
, type
, namespaces
, origType
,
4980 elemData
= dataPriv
.get( elem
);
4982 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4987 // Caller can pass in an object of custom data in lieu of the handler
4988 if ( handler
.handler
) {
4989 handleObjIn
= handler
;
4990 handler
= handleObjIn
.handler
;
4991 selector
= handleObjIn
.selector
;
4994 // Ensure that invalid selectors throw exceptions at attach time
4995 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
4997 jQuery
.find
.matchesSelector( documentElement
, selector
);
5000 // Make sure that the handler has a unique ID, used to find/remove it later
5001 if ( !handler
.guid
) {
5002 handler
.guid
= jQuery
.guid
++;
5005 // Init the element's event structure and main handler, if this is the first
5006 if ( !( events
= elemData
.events
) ) {
5007 events
= elemData
.events
= {};
5009 if ( !( eventHandle
= elemData
.handle
) ) {
5010 eventHandle
= elemData
.handle = function( e
) {
5012 // Discard the second event of a jQuery.event.trigger() and
5013 // when an event is called after a page has unloaded
5014 return typeof jQuery
!== "undefined" && jQuery
.event
.triggered
!== e
.type
?
5015 jQuery
.event
.dispatch
.apply( elem
, arguments
) : undefined;
5019 // Handle multiple events separated by a space
5020 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5023 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5024 type
= origType
= tmp
[ 1 ];
5025 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5027 // There *must* be a type, no attaching namespace-only handlers
5032 // If event changes its type, use the special event handlers for the changed type
5033 special
= jQuery
.event
.special
[ type
] || {};
5035 // If selector defined, determine special event api type, otherwise given type
5036 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
5038 // Update special based on newly reset type
5039 special
= jQuery
.event
.special
[ type
] || {};
5041 // handleObj is passed to all event handlers
5042 handleObj
= jQuery
.extend( {
5049 needsContext
: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
5050 namespace: namespaces
.join( "." )
5053 // Init the event handler queue if we're the first
5054 if ( !( handlers
= events
[ type
] ) ) {
5055 handlers
= events
[ type
] = [];
5056 handlers
.delegateCount
= 0;
5058 // Only use addEventListener if the special events handler returns false
5059 if ( !special
.setup
||
5060 special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
5062 if ( elem
.addEventListener
) {
5063 elem
.addEventListener( type
, eventHandle
);
5068 if ( special
.add
) {
5069 special
.add
.call( elem
, handleObj
);
5071 if ( !handleObj
.handler
.guid
) {
5072 handleObj
.handler
.guid
= handler
.guid
;
5076 // Add to the element's handler list, delegates in front
5078 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
5080 handlers
.push( handleObj
);
5083 // Keep track of which events have ever been used, for event optimization
5084 jQuery
.event
.global
[ type
] = true;
5089 // Detach an event or set of events from an element
5090 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
5092 var j
, origCount
, tmp
,
5093 events
, t
, handleObj
,
5094 special
, handlers
, type
, namespaces
, origType
,
5095 elemData
= dataPriv
.hasData( elem
) && dataPriv
.get( elem
);
5097 if ( !elemData
|| !( events
= elemData
.events
) ) {
5101 // Once for each type.namespace in types; type may be omitted
5102 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5105 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5106 type
= origType
= tmp
[ 1 ];
5107 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5109 // Unbind all events (on this namespace, if provided) for the element
5111 for ( type
in events
) {
5112 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
5117 special
= jQuery
.event
.special
[ type
] || {};
5118 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
5119 handlers
= events
[ type
] || [];
5121 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5123 // Remove matching events
5124 origCount
= j
= handlers
.length
;
5126 handleObj
= handlers
[ j
];
5128 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
5129 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
5130 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
5131 ( !selector
|| selector
=== handleObj
.selector
||
5132 selector
=== "**" && handleObj
.selector
) ) {
5133 handlers
.splice( j
, 1 );
5135 if ( handleObj
.selector
) {
5136 handlers
.delegateCount
--;
5138 if ( special
.remove
) {
5139 special
.remove
.call( elem
, handleObj
);
5144 // Remove generic event handler if we removed something and no more handlers exist
5145 // (avoids potential for endless recursion during removal of special event handlers)
5146 if ( origCount
&& !handlers
.length
) {
5147 if ( !special
.teardown
||
5148 special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
5150 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
5153 delete events
[ type
];
5157 // Remove data and the expando if it's no longer used
5158 if ( jQuery
.isEmptyObject( events
) ) {
5159 dataPriv
.remove( elem
, "handle events" );
5163 dispatch: function( nativeEvent
) {
5165 // Make a writable jQuery.Event from the native event object
5166 var event
= jQuery
.event
.fix( nativeEvent
);
5168 var i
, j
, ret
, matched
, handleObj
, handlerQueue
,
5169 args
= new Array( arguments
.length
),
5170 handlers
= ( dataPriv
.get( this, "events" ) || {} )[ event
.type
] || [],
5171 special
= jQuery
.event
.special
[ event
.type
] || {};
5173 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5176 for ( i
= 1; i
< arguments
.length
; i
++ ) {
5177 args
[ i
] = arguments
[ i
];
5180 event
.delegateTarget
= this;
5182 // Call the preDispatch hook for the mapped type, and let it bail if desired
5183 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
5187 // Determine handlers
5188 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
5190 // Run delegates first; they may want to stop propagation beneath us
5192 while ( ( matched
= handlerQueue
[ i
++ ] ) && !event
.isPropagationStopped() ) {
5193 event
.currentTarget
= matched
.elem
;
5196 while ( ( handleObj
= matched
.handlers
[ j
++ ] ) &&
5197 !event
.isImmediatePropagationStopped() ) {
5199 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5200 // a subset or equal to those in the bound event (both can have no namespace).
5201 if ( !event
.rnamespace
|| event
.rnamespace
.test( handleObj
.namespace ) ) {
5203 event
.handleObj
= handleObj
;
5204 event
.data
= handleObj
.data
;
5206 ret
= ( ( jQuery
.event
.special
[ handleObj
.origType
] || {} ).handle
||
5207 handleObj
.handler
).apply( matched
.elem
, args
);
5209 if ( ret
!== undefined ) {
5210 if ( ( event
.result
= ret
) === false ) {
5211 event
.preventDefault();
5212 event
.stopPropagation();
5219 // Call the postDispatch hook for the mapped type
5220 if ( special
.postDispatch
) {
5221 special
.postDispatch
.call( this, event
);
5224 return event
.result
;
5227 handlers: function( event
, handlers
) {
5228 var i
, handleObj
, sel
, matchedHandlers
, matchedSelectors
,
5230 delegateCount
= handlers
.delegateCount
,
5233 // Find delegate handlers
5234 if ( delegateCount
&&
5237 // Black-hole SVG <use> instance trees (trac-13180)
5240 // Support: Firefox <=42
5241 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5242 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5243 // Support: IE 11 only
5244 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5245 !( event
.type
=== "click" && event
.button
>= 1 ) ) {
5247 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
5249 // Don't check non-elements (#13208)
5250 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5251 if ( cur
.nodeType
=== 1 && !( event
.type
=== "click" && cur
.disabled
=== true ) ) {
5252 matchedHandlers
= [];
5253 matchedSelectors
= {};
5254 for ( i
= 0; i
< delegateCount
; i
++ ) {
5255 handleObj
= handlers
[ i
];
5257 // Don't conflict with Object.prototype properties (#13203)
5258 sel
= handleObj
.selector
+ " ";
5260 if ( matchedSelectors
[ sel
] === undefined ) {
5261 matchedSelectors
[ sel
] = handleObj
.needsContext
?
5262 jQuery( sel
, this ).index( cur
) > -1 :
5263 jQuery
.find( sel
, this, null, [ cur
] ).length
;
5265 if ( matchedSelectors
[ sel
] ) {
5266 matchedHandlers
.push( handleObj
);
5269 if ( matchedHandlers
.length
) {
5270 handlerQueue
.push( { elem
: cur
, handlers
: matchedHandlers
} );
5276 // Add the remaining (directly-bound) handlers
5278 if ( delegateCount
< handlers
.length
) {
5279 handlerQueue
.push( { elem
: cur
, handlers
: handlers
.slice( delegateCount
) } );
5282 return handlerQueue
;
5285 addProp: function( name
, hook
) {
5286 Object
.defineProperty( jQuery
.Event
.prototype, name
, {
5290 get: jQuery
.isFunction( hook
) ?
5292 if ( this.originalEvent
) {
5293 return hook( this.originalEvent
);
5297 if ( this.originalEvent
) {
5298 return this.originalEvent
[ name
];
5302 set: function( value
) {
5303 Object
.defineProperty( this, name
, {
5313 fix: function( originalEvent
) {
5314 return originalEvent
[ jQuery
.expando
] ?
5316 new jQuery
.Event( originalEvent
);
5322 // Prevent triggered image.load events from bubbling to window.load
5327 // Fire native event if possible so blur/focus sequence is correct
5328 trigger: function() {
5329 if ( this !== safeActiveElement() && this.focus
) {
5334 delegateType
: "focusin"
5337 trigger: function() {
5338 if ( this === safeActiveElement() && this.blur
) {
5343 delegateType
: "focusout"
5347 // For checkbox, fire native event so checked state will be right
5348 trigger: function() {
5349 if ( this.type
=== "checkbox" && this.click
&& nodeName( this, "input" ) ) {
5355 // For cross-browser consistency, don't fire native .click() on links
5356 _default: function( event
) {
5357 return nodeName( event
.target
, "a" );
5362 postDispatch: function( event
) {
5364 // Support: Firefox 20+
5365 // Firefox doesn't alert if the returnValue field is not set.
5366 if ( event
.result
!== undefined && event
.originalEvent
) {
5367 event
.originalEvent
.returnValue
= event
.result
;
5374 jQuery
.removeEvent = function( elem
, type
, handle
) {
5376 // This "if" is needed for plain objects
5377 if ( elem
.removeEventListener
) {
5378 elem
.removeEventListener( type
, handle
);
5382 jQuery
.Event = function( src
, props
) {
5384 // Allow instantiation without the 'new' keyword
5385 if ( !( this instanceof jQuery
.Event
) ) {
5386 return new jQuery
.Event( src
, props
);
5390 if ( src
&& src
.type
) {
5391 this.originalEvent
= src
;
5392 this.type
= src
.type
;
5394 // Events bubbling up the document may have been marked as prevented
5395 // by a handler lower down the tree; reflect the correct value.
5396 this.isDefaultPrevented
= src
.defaultPrevented
||
5397 src
.defaultPrevented
=== undefined &&
5399 // Support: Android <=2.3 only
5400 src
.returnValue
=== false ?
5404 // Create target properties
5405 // Support: Safari <=6 - 7 only
5406 // Target should not be a text node (#504, #13143)
5407 this.target
= ( src
.target
&& src
.target
.nodeType
=== 3 ) ?
5408 src
.target
.parentNode
:
5411 this.currentTarget
= src
.currentTarget
;
5412 this.relatedTarget
= src
.relatedTarget
;
5419 // Put explicitly provided properties onto the event object
5421 jQuery
.extend( this, props
);
5424 // Create a timestamp if incoming event doesn't have one
5425 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
5428 this[ jQuery
.expando
] = true;
5431 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5432 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5433 jQuery
.Event
.prototype = {
5434 constructor: jQuery
.Event
,
5435 isDefaultPrevented
: returnFalse
,
5436 isPropagationStopped
: returnFalse
,
5437 isImmediatePropagationStopped
: returnFalse
,
5440 preventDefault: function() {
5441 var e
= this.originalEvent
;
5443 this.isDefaultPrevented
= returnTrue
;
5445 if ( e
&& !this.isSimulated
) {
5449 stopPropagation: function() {
5450 var e
= this.originalEvent
;
5452 this.isPropagationStopped
= returnTrue
;
5454 if ( e
&& !this.isSimulated
) {
5455 e
.stopPropagation();
5458 stopImmediatePropagation: function() {
5459 var e
= this.originalEvent
;
5461 this.isImmediatePropagationStopped
= returnTrue
;
5463 if ( e
&& !this.isSimulated
) {
5464 e
.stopImmediatePropagation();
5467 this.stopPropagation();
5471 // Includes all common event props including KeyEvent and MouseEvent specific props
5476 changedTouches
: true,
5499 targetTouches
: true,
5503 which: function( event
) {
5504 var button
= event
.button
;
5506 // Add which for key events
5507 if ( event
.which
== null && rkeyEvent
.test( event
.type
) ) {
5508 return event
.charCode
!= null ? event
.charCode
: event
.keyCode
;
5511 // Add which for click: 1 === left; 2 === middle; 3 === right
5512 if ( !event
.which
&& button
!== undefined && rmouseEvent
.test( event
.type
) ) {
5530 }, jQuery
.event
.addProp
);
5532 // Create mouseenter/leave events using mouseover/out and event-time checks
5533 // so that event delegation works in jQuery.
5534 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5536 // Support: Safari 7 only
5537 // Safari sends mouseenter too often; see:
5538 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5539 // for the description of the bug (it existed in older Chrome versions as well).
5541 mouseenter
: "mouseover",
5542 mouseleave
: "mouseout",
5543 pointerenter
: "pointerover",
5544 pointerleave
: "pointerout"
5545 }, function( orig
, fix
) {
5546 jQuery
.event
.special
[ orig
] = {
5550 handle: function( event
) {
5553 related
= event
.relatedTarget
,
5554 handleObj
= event
.handleObj
;
5556 // For mouseenter/leave call the handler if related is outside the target.
5557 // NB: No relatedTarget if the mouse left/entered the browser window
5558 if ( !related
|| ( related
!== target
&& !jQuery
.contains( target
, related
) ) ) {
5559 event
.type
= handleObj
.origType
;
5560 ret
= handleObj
.handler
.apply( this, arguments
);
5570 on: function( types
, selector
, data
, fn
) {
5571 return on( this, types
, selector
, data
, fn
);
5573 one: function( types
, selector
, data
, fn
) {
5574 return on( this, types
, selector
, data
, fn
, 1 );
5576 off: function( types
, selector
, fn
) {
5577 var handleObj
, type
;
5578 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
5580 // ( event ) dispatched jQuery.Event
5581 handleObj
= types
.handleObj
;
5582 jQuery( types
.delegateTarget
).off(
5583 handleObj
.namespace ?
5584 handleObj
.origType
+ "." + handleObj
.namespace :
5591 if ( typeof types
=== "object" ) {
5593 // ( types-object [, selector] )
5594 for ( type
in types
) {
5595 this.off( type
, selector
, types
[ type
] );
5599 if ( selector
=== false || typeof selector
=== "function" ) {
5603 selector
= undefined;
5605 if ( fn
=== false ) {
5608 return this.each( function() {
5609 jQuery
.event
.remove( this, types
, fn
, selector
);
5617 /* eslint-disable max-len */
5619 // See https://github.com/eslint/eslint/issues/3229
5620 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
5624 // Support: IE <=10 - 11, Edge 12 - 13
5625 // In IE/Edge using regex groups here causes severe slowdowns.
5626 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5627 rnoInnerhtml
= /<script|<style|<link/i,
5629 // checked="checked" or checked
5630 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5631 rscriptTypeMasked
= /^true\/(.*)/,
5632 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5634 // Prefer a tbody over its parent table for containing new rows
5635 function manipulationTarget( elem
, content
) {
5636 if ( nodeName( elem
, "table" ) &&
5637 nodeName( content
.nodeType
!== 11 ? content
: content
.firstChild
, "tr" ) ) {
5639 return jQuery( ">tbody", elem
)[ 0 ] || elem
;
5645 // Replace/restore the type attribute of script elements for safe DOM manipulation
5646 function disableScript( elem
) {
5647 elem
.type
= ( elem
.getAttribute( "type" ) !== null ) + "/" + elem
.type
;
5650 function restoreScript( elem
) {
5651 var match
= rscriptTypeMasked
.exec( elem
.type
);
5654 elem
.type
= match
[ 1 ];
5656 elem
.removeAttribute( "type" );
5662 function cloneCopyEvent( src
, dest
) {
5663 var i
, l
, type
, pdataOld
, pdataCur
, udataOld
, udataCur
, events
;
5665 if ( dest
.nodeType
!== 1 ) {
5669 // 1. Copy private data: events, handlers, etc.
5670 if ( dataPriv
.hasData( src
) ) {
5671 pdataOld
= dataPriv
.access( src
);
5672 pdataCur
= dataPriv
.set( dest
, pdataOld
);
5673 events
= pdataOld
.events
;
5676 delete pdataCur
.handle
;
5677 pdataCur
.events
= {};
5679 for ( type
in events
) {
5680 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
5681 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
5687 // 2. Copy user data
5688 if ( dataUser
.hasData( src
) ) {
5689 udataOld
= dataUser
.access( src
);
5690 udataCur
= jQuery
.extend( {}, udataOld
);
5692 dataUser
.set( dest
, udataCur
);
5696 // Fix IE bugs, see support tests
5697 function fixInput( src
, dest
) {
5698 var nodeName
= dest
.nodeName
.toLowerCase();
5700 // Fails to persist the checked state of a cloned checkbox or radio button.
5701 if ( nodeName
=== "input" && rcheckableType
.test( src
.type
) ) {
5702 dest
.checked
= src
.checked
;
5704 // Fails to return the selected option to the default selected state when cloning options
5705 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
5706 dest
.defaultValue
= src
.defaultValue
;
5710 function domManip( collection
, args
, callback
, ignored
) {
5712 // Flatten any nested arrays
5713 args
= concat
.apply( [], args
);
5715 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
5717 l
= collection
.length
,
5720 isFunction
= jQuery
.isFunction( value
);
5722 // We can't cloneNode fragments that contain checked, in WebKit
5724 ( l
> 1 && typeof value
=== "string" &&
5725 !support
.checkClone
&& rchecked
.test( value
) ) ) {
5726 return collection
.each( function( index
) {
5727 var self
= collection
.eq( index
);
5729 args
[ 0 ] = value
.call( this, index
, self
.html() );
5731 domManip( self
, args
, callback
, ignored
);
5736 fragment
= buildFragment( args
, collection
[ 0 ].ownerDocument
, false, collection
, ignored
);
5737 first
= fragment
.firstChild
;
5739 if ( fragment
.childNodes
.length
=== 1 ) {
5743 // Require either new content or an interest in ignored elements to invoke the callback
5744 if ( first
|| ignored
) {
5745 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
5746 hasScripts
= scripts
.length
;
5748 // Use the original fragment for the last item
5749 // instead of the first because it can end up
5750 // being emptied incorrectly in certain situations (#8070).
5751 for ( ; i
< l
; i
++ ) {
5754 if ( i
!== iNoClone
) {
5755 node
= jQuery
.clone( node
, true, true );
5757 // Keep references to cloned scripts for later restoration
5760 // Support: Android <=4.0 only, PhantomJS 1 only
5761 // push.apply(_, arraylike) throws on ancient WebKit
5762 jQuery
.merge( scripts
, getAll( node
, "script" ) );
5766 callback
.call( collection
[ i
], node
, i
);
5770 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
5773 jQuery
.map( scripts
, restoreScript
);
5775 // Evaluate executable scripts on first document insertion
5776 for ( i
= 0; i
< hasScripts
; i
++ ) {
5777 node
= scripts
[ i
];
5778 if ( rscriptType
.test( node
.type
|| "" ) &&
5779 !dataPriv
.access( node
, "globalEval" ) &&
5780 jQuery
.contains( doc
, node
) ) {
5784 // Optional AJAX dependency, but won't run scripts if not present
5785 if ( jQuery
._evalUrl
) {
5786 jQuery
._evalUrl( node
.src
);
5789 DOMEval( node
.textContent
.replace( rcleanScript
, "" ), doc
);
5800 function remove( elem
, selector
, keepData
) {
5802 nodes
= selector
? jQuery
.filter( selector
, elem
) : elem
,
5805 for ( ; ( node
= nodes
[ i
] ) != null; i
++ ) {
5806 if ( !keepData
&& node
.nodeType
=== 1 ) {
5807 jQuery
.cleanData( getAll( node
) );
5810 if ( node
.parentNode
) {
5811 if ( keepData
&& jQuery
.contains( node
.ownerDocument
, node
) ) {
5812 setGlobalEval( getAll( node
, "script" ) );
5814 node
.parentNode
.removeChild( node
);
5822 htmlPrefilter: function( html
) {
5823 return html
.replace( rxhtmlTag
, "<$1></$2>" );
5826 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
5827 var i
, l
, srcElements
, destElements
,
5828 clone
= elem
.cloneNode( true ),
5829 inPage
= jQuery
.contains( elem
.ownerDocument
, elem
);
5831 // Fix IE cloning issues
5832 if ( !support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) &&
5833 !jQuery
.isXMLDoc( elem
) ) {
5835 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
5836 destElements
= getAll( clone
);
5837 srcElements
= getAll( elem
);
5839 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5840 fixInput( srcElements
[ i
], destElements
[ i
] );
5844 // Copy the events from the original to the clone
5845 if ( dataAndEvents
) {
5846 if ( deepDataAndEvents
) {
5847 srcElements
= srcElements
|| getAll( elem
);
5848 destElements
= destElements
|| getAll( clone
);
5850 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5851 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
5854 cloneCopyEvent( elem
, clone
);
5858 // Preserve script evaluation history
5859 destElements
= getAll( clone
, "script" );
5860 if ( destElements
.length
> 0 ) {
5861 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
5864 // Return the cloned set
5868 cleanData: function( elems
) {
5869 var data
, elem
, type
,
5870 special
= jQuery
.event
.special
,
5873 for ( ; ( elem
= elems
[ i
] ) !== undefined; i
++ ) {
5874 if ( acceptData( elem
) ) {
5875 if ( ( data
= elem
[ dataPriv
.expando
] ) ) {
5876 if ( data
.events
) {
5877 for ( type
in data
.events
) {
5878 if ( special
[ type
] ) {
5879 jQuery
.event
.remove( elem
, type
);
5881 // This is a shortcut to avoid jQuery.event.remove's overhead
5883 jQuery
.removeEvent( elem
, type
, data
.handle
);
5888 // Support: Chrome <=35 - 45+
5889 // Assign undefined instead of using delete, see Data#remove
5890 elem
[ dataPriv
.expando
] = undefined;
5892 if ( elem
[ dataUser
.expando
] ) {
5894 // Support: Chrome <=35 - 45+
5895 // Assign undefined instead of using delete, see Data#remove
5896 elem
[ dataUser
.expando
] = undefined;
5904 detach: function( selector
) {
5905 return remove( this, selector
, true );
5908 remove: function( selector
) {
5909 return remove( this, selector
);
5912 text: function( value
) {
5913 return access( this, function( value
) {
5914 return value
=== undefined ?
5915 jQuery
.text( this ) :
5916 this.empty().each( function() {
5917 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5918 this.textContent
= value
;
5921 }, null, value
, arguments
.length
);
5924 append: function() {
5925 return domManip( this, arguments
, function( elem
) {
5926 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5927 var target
= manipulationTarget( this, elem
);
5928 target
.appendChild( elem
);
5933 prepend: function() {
5934 return domManip( this, arguments
, function( elem
) {
5935 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5936 var target
= manipulationTarget( this, elem
);
5937 target
.insertBefore( elem
, target
.firstChild
);
5942 before: function() {
5943 return domManip( this, arguments
, function( elem
) {
5944 if ( this.parentNode
) {
5945 this.parentNode
.insertBefore( elem
, this );
5951 return domManip( this, arguments
, function( elem
) {
5952 if ( this.parentNode
) {
5953 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5962 for ( ; ( elem
= this[ i
] ) != null; i
++ ) {
5963 if ( elem
.nodeType
=== 1 ) {
5965 // Prevent memory leaks
5966 jQuery
.cleanData( getAll( elem
, false ) );
5968 // Remove any remaining nodes
5969 elem
.textContent
= "";
5976 clone: function( dataAndEvents
, deepDataAndEvents
) {
5977 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5978 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents
: deepDataAndEvents
;
5980 return this.map( function() {
5981 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5985 html: function( value
) {
5986 return access( this, function( value
) {
5987 var elem
= this[ 0 ] || {},
5991 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
5992 return elem
.innerHTML
;
5995 // See if we can take a shortcut and just use innerHTML
5996 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5997 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5999 value
= jQuery
.htmlPrefilter( value
);
6002 for ( ; i
< l
; i
++ ) {
6003 elem
= this[ i
] || {};
6005 // Remove element nodes and prevent memory leaks
6006 if ( elem
.nodeType
=== 1 ) {
6007 jQuery
.cleanData( getAll( elem
, false ) );
6008 elem
.innerHTML
= value
;
6014 // If using innerHTML throws an exception, use the fallback method
6019 this.empty().append( value
);
6021 }, null, value
, arguments
.length
);
6024 replaceWith: function() {
6027 // Make the changes, replacing each non-ignored context element with the new content
6028 return domManip( this, arguments
, function( elem
) {
6029 var parent
= this.parentNode
;
6031 if ( jQuery
.inArray( this, ignored
) < 0 ) {
6032 jQuery
.cleanData( getAll( this ) );
6034 parent
.replaceChild( elem
, this );
6038 // Force callback invocation
6045 prependTo
: "prepend",
6046 insertBefore
: "before",
6047 insertAfter
: "after",
6048 replaceAll
: "replaceWith"
6049 }, function( name
, original
) {
6050 jQuery
.fn
[ name
] = function( selector
) {
6053 insert
= jQuery( selector
),
6054 last
= insert
.length
- 1,
6057 for ( ; i
<= last
; i
++ ) {
6058 elems
= i
=== last
? this : this.clone( true );
6059 jQuery( insert
[ i
] )[ original
]( elems
);
6061 // Support: Android <=4.0 only, PhantomJS 1 only
6062 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6063 push
.apply( ret
, elems
.get() );
6066 return this.pushStack( ret
);
6069 var rmargin
= ( /^margin/ );
6071 var rnumnonpx
= new RegExp( "^(" + pnum
+ ")(?!px)[a-z%]+$", "i" );
6073 var getStyles = function( elem
) {
6075 // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
6076 // IE throws on elements created in popups
6077 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6078 var view
= elem
.ownerDocument
.defaultView
;
6080 if ( !view
|| !view
.opener
) {
6084 return view
.getComputedStyle( elem
);
6091 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6092 // so they're executed at the same time to save the second computation.
6093 function computeStyleTests() {
6095 // This is a singleton, we need to execute it only once
6101 "box-sizing:border-box;" +
6102 "position:relative;display:block;" +
6103 "margin:auto;border:1px;padding:1px;" +
6106 documentElement
.appendChild( container
);
6108 var divStyle
= window
.getComputedStyle( div
);
6109 pixelPositionVal
= divStyle
.top
!== "1%";
6111 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6112 reliableMarginLeftVal
= divStyle
.marginLeft
=== "2px";
6113 boxSizingReliableVal
= divStyle
.width
=== "4px";
6115 // Support: Android 4.0 - 4.3 only
6116 // Some styles come back with percentage values, even though they shouldn't
6117 div
.style
.marginRight
= "50%";
6118 pixelMarginRightVal
= divStyle
.marginRight
=== "4px";
6120 documentElement
.removeChild( container
);
6122 // Nullify the div so it wouldn't be stored in the memory and
6123 // it will also be a sign that checks already performed
6127 var pixelPositionVal
, boxSizingReliableVal
, pixelMarginRightVal
, reliableMarginLeftVal
,
6128 container
= document
.createElement( "div" ),
6129 div
= document
.createElement( "div" );
6131 // Finish early in limited (non-browser) environments
6136 // Support: IE <=9 - 11 only
6137 // Style of cloned element affects source element cloned (#8908)
6138 div
.style
.backgroundClip
= "content-box";
6139 div
.cloneNode( true ).style
.backgroundClip
= "";
6140 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
6142 container
.style
.cssText
= "border:0;width:8px;height:0;top:0;left:-9999px;" +
6143 "padding:0;margin-top:1px;position:absolute";
6144 container
.appendChild( div
);
6146 jQuery
.extend( support
, {
6147 pixelPosition: function() {
6148 computeStyleTests();
6149 return pixelPositionVal
;
6151 boxSizingReliable: function() {
6152 computeStyleTests();
6153 return boxSizingReliableVal
;
6155 pixelMarginRight: function() {
6156 computeStyleTests();
6157 return pixelMarginRightVal
;
6159 reliableMarginLeft: function() {
6160 computeStyleTests();
6161 return reliableMarginLeftVal
;
6167 function curCSS( elem
, name
, computed
) {
6168 var width
, minWidth
, maxWidth
, ret
,
6170 // Support: Firefox 51+
6171 // Retrieving style before computed somehow
6172 // fixes an issue with getting wrong values
6173 // on detached elements
6176 computed
= computed
|| getStyles( elem
);
6178 // getPropertyValue is needed for:
6179 // .css('filter') (IE 9 only, #12537)
6180 // .css('--customProperty) (#3144)
6182 ret
= computed
.getPropertyValue( name
) || computed
[ name
];
6184 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
, elem
) ) {
6185 ret
= jQuery
.style( elem
, name
);
6188 // A tribute to the "awesome hack by Dean Edwards"
6189 // Android Browser returns percentage for some values,
6190 // but width seems to be reliably pixels.
6191 // This is against the CSSOM draft spec:
6192 // https://drafts.csswg.org/cssom/#resolved-values
6193 if ( !support
.pixelMarginRight() && rnumnonpx
.test( ret
) && rmargin
.test( name
) ) {
6195 // Remember the original values
6196 width
= style
.width
;
6197 minWidth
= style
.minWidth
;
6198 maxWidth
= style
.maxWidth
;
6200 // Put in the new values to get a computed value out
6201 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
6202 ret
= computed
.width
;
6204 // Revert the changed values
6205 style
.width
= width
;
6206 style
.minWidth
= minWidth
;
6207 style
.maxWidth
= maxWidth
;
6211 return ret
!== undefined ?
6213 // Support: IE <=9 - 11 only
6214 // IE returns zIndex value as an integer.
6220 function addGetHookIf( conditionFn
, hookFn
) {
6222 // Define the hook, we'll check on the first run if it's really needed.
6225 if ( conditionFn() ) {
6227 // Hook not needed (or it's not possible to use it due
6228 // to missing dependency), remove it.
6233 // Hook needed; redefine it so that the support test is not executed again.
6234 return ( this.get = hookFn
).apply( this, arguments
);
6242 // Swappable if display is none or starts with table
6243 // except "table", "table-cell", or "table-caption"
6244 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6245 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
6246 rcustomProp
= /^--/,
6247 cssShow
= { position
: "absolute", visibility
: "hidden", display
: "block" },
6248 cssNormalTransform
= {
6253 cssPrefixes
= [ "Webkit", "Moz", "ms" ],
6254 emptyStyle
= document
.createElement( "div" ).style
;
6256 // Return a css property mapped to a potentially vendor prefixed property
6257 function vendorPropName( name
) {
6259 // Shortcut for names that are not vendor prefixed
6260 if ( name
in emptyStyle
) {
6264 // Check for vendor prefixed names
6265 var capName
= name
[ 0 ].toUpperCase() + name
.slice( 1 ),
6266 i
= cssPrefixes
.length
;
6269 name
= cssPrefixes
[ i
] + capName
;
6270 if ( name
in emptyStyle
) {
6276 // Return a property mapped along what jQuery.cssProps suggests or to
6277 // a vendor prefixed property.
6278 function finalPropName( name
) {
6279 var ret
= jQuery
.cssProps
[ name
];
6281 ret
= jQuery
.cssProps
[ name
] = vendorPropName( name
) || name
;
6286 function setPositiveNumber( elem
, value
, subtract
) {
6288 // Any relative (+/-) values have already been
6289 // normalized at this point
6290 var matches
= rcssNum
.exec( value
);
6293 // Guard against undefined "subtract", e.g., when used as in cssHooks
6294 Math
.max( 0, matches
[ 2 ] - ( subtract
|| 0 ) ) + ( matches
[ 3 ] || "px" ) :
6298 function augmentWidthOrHeight( elem
, name
, extra
, isBorderBox
, styles
) {
6302 // If we already have the right measurement, avoid augmentation
6303 if ( extra
=== ( isBorderBox
? "border" : "content" ) ) {
6306 // Otherwise initialize for horizontal or vertical properties
6308 i
= name
=== "width" ? 1 : 0;
6311 for ( ; i
< 4; i
+= 2 ) {
6313 // Both box models exclude margin, so add it if we want it
6314 if ( extra
=== "margin" ) {
6315 val
+= jQuery
.css( elem
, extra
+ cssExpand
[ i
], true, styles
);
6318 if ( isBorderBox
) {
6320 // border-box includes padding, so remove it if we want content
6321 if ( extra
=== "content" ) {
6322 val
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6325 // At this point, extra isn't border nor margin, so remove border
6326 if ( extra
!== "margin" ) {
6327 val
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6331 // At this point, extra isn't content, so add padding
6332 val
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6334 // At this point, extra isn't content nor padding, so add border
6335 if ( extra
!== "padding" ) {
6336 val
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6344 function getWidthOrHeight( elem
, name
, extra
) {
6346 // Start with computed style
6347 var valueIsBorderBox
,
6348 styles
= getStyles( elem
),
6349 val
= curCSS( elem
, name
, styles
),
6350 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box";
6352 // Computed unit is not pixels. Stop here and return.
6353 if ( rnumnonpx
.test( val
) ) {
6357 // Check for style in case a browser which returns unreliable values
6358 // for getComputedStyle silently falls back to the reliable elem.style
6359 valueIsBorderBox
= isBorderBox
&&
6360 ( support
.boxSizingReliable() || val
=== elem
.style
[ name
] );
6362 // Fall back to offsetWidth/Height when value is "auto"
6363 // This happens for inline elements with no explicit setting (gh-3571)
6364 if ( val
=== "auto" ) {
6365 val
= elem
[ "offset" + name
[ 0 ].toUpperCase() + name
.slice( 1 ) ];
6368 // Normalize "", auto, and prepare for extra
6369 val
= parseFloat( val
) || 0;
6371 // Use the active box-sizing model to add/subtract irrelevant styles
6373 augmentWidthOrHeight(
6376 extra
|| ( isBorderBox
? "border" : "content" ),
6385 // Add in style property hooks for overriding the default
6386 // behavior of getting and setting a style property
6389 get: function( elem
, computed
) {
6392 // We should always get a number back from opacity
6393 var ret
= curCSS( elem
, "opacity" );
6394 return ret
=== "" ? "1" : ret
;
6400 // Don't automatically add "px" to these possibly-unitless properties
6402 "animationIterationCount": true,
6403 "columnCount": true,
6404 "fillOpacity": true,
6417 // Add in properties whose names you wish to fix before
6418 // setting or getting the value
6423 // Get and set the style property on a DOM Node
6424 style: function( elem
, name
, value
, extra
) {
6426 // Don't set styles on text and comment nodes
6427 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6431 // Make sure that we're working with the right name
6432 var ret
, type
, hooks
,
6433 origName
= jQuery
.camelCase( name
),
6434 isCustomProp
= rcustomProp
.test( name
),
6437 // Make sure that we're working with the right name. We don't
6438 // want to query the value if it is a CSS custom property
6439 // since they are user-defined.
6440 if ( !isCustomProp
) {
6441 name
= finalPropName( origName
);
6444 // Gets hook for the prefixed version, then unprefixed version
6445 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6447 // Check if we're setting a value
6448 if ( value
!== undefined ) {
6449 type
= typeof value
;
6451 // Convert "+=" or "-=" to relative numbers (#7345)
6452 if ( type
=== "string" && ( ret
= rcssNum
.exec( value
) ) && ret
[ 1 ] ) {
6453 value
= adjustCSS( elem
, name
, ret
);
6459 // Make sure that null and NaN values aren't set (#7116)
6460 if ( value
== null || value
!== value
) {
6464 // If a number was passed in, add the unit (except for certain CSS properties)
6465 if ( type
=== "number" ) {
6466 value
+= ret
&& ret
[ 3 ] || ( jQuery
.cssNumber
[ origName
] ? "" : "px" );
6469 // background-* props affect original clone's values
6470 if ( !support
.clearCloneStyle
&& value
=== "" && name
.indexOf( "background" ) === 0 ) {
6471 style
[ name
] = "inherit";
6474 // If a hook was provided, use that value, otherwise just set the specified value
6475 if ( !hooks
|| !( "set" in hooks
) ||
6476 ( value
= hooks
.set( elem
, value
, extra
) ) !== undefined ) {
6478 if ( isCustomProp
) {
6479 style
.setProperty( name
, value
);
6481 style
[ name
] = value
;
6487 // If a hook was provided get the non-computed value from there
6488 if ( hooks
&& "get" in hooks
&&
6489 ( ret
= hooks
.get( elem
, false, extra
) ) !== undefined ) {
6494 // Otherwise just get the value from the style object
6495 return style
[ name
];
6499 css: function( elem
, name
, extra
, styles
) {
6500 var val
, num
, hooks
,
6501 origName
= jQuery
.camelCase( name
),
6502 isCustomProp
= rcustomProp
.test( name
);
6504 // Make sure that we're working with the right name. We don't
6505 // want to modify the value if it is a CSS custom property
6506 // since they are user-defined.
6507 if ( !isCustomProp
) {
6508 name
= finalPropName( origName
);
6511 // Try prefixed name followed by the unprefixed name
6512 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6514 // If a hook was provided get the computed value from there
6515 if ( hooks
&& "get" in hooks
) {
6516 val
= hooks
.get( elem
, true, extra
);
6519 // Otherwise, if a way to get the computed value exists, use that
6520 if ( val
=== undefined ) {
6521 val
= curCSS( elem
, name
, styles
);
6524 // Convert "normal" to computed value
6525 if ( val
=== "normal" && name
in cssNormalTransform
) {
6526 val
= cssNormalTransform
[ name
];
6529 // Make numeric if forced or a qualifier was provided and val looks numeric
6530 if ( extra
=== "" || extra
) {
6531 num
= parseFloat( val
);
6532 return extra
=== true || isFinite( num
) ? num
|| 0 : val
;
6539 jQuery
.each( [ "height", "width" ], function( i
, name
) {
6540 jQuery
.cssHooks
[ name
] = {
6541 get: function( elem
, computed
, extra
) {
6544 // Certain elements can have dimension info if we invisibly show them
6545 // but it must have a current display style that would benefit
6546 return rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) &&
6548 // Support: Safari 8+
6549 // Table columns in Safari have non-zero offsetWidth & zero
6550 // getBoundingClientRect().width unless display is changed.
6551 // Support: IE <=11 only
6552 // Running getBoundingClientRect on a disconnected node
6553 // in IE throws an error.
6554 ( !elem
.getClientRects().length
|| !elem
.getBoundingClientRect().width
) ?
6555 swap( elem
, cssShow
, function() {
6556 return getWidthOrHeight( elem
, name
, extra
);
6558 getWidthOrHeight( elem
, name
, extra
);
6562 set: function( elem
, value
, extra
) {
6564 styles
= extra
&& getStyles( elem
),
6565 subtract
= extra
&& augmentWidthOrHeight(
6569 jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6573 // Convert to pixels if value adjustment is needed
6574 if ( subtract
&& ( matches
= rcssNum
.exec( value
) ) &&
6575 ( matches
[ 3 ] || "px" ) !== "px" ) {
6577 elem
.style
[ name
] = value
;
6578 value
= jQuery
.css( elem
, name
);
6581 return setPositiveNumber( elem
, value
, subtract
);
6586 jQuery
.cssHooks
.marginLeft
= addGetHookIf( support
.reliableMarginLeft
,
6587 function( elem
, computed
) {
6589 return ( parseFloat( curCSS( elem
, "marginLeft" ) ) ||
6590 elem
.getBoundingClientRect().left
-
6591 swap( elem
, { marginLeft
: 0 }, function() {
6592 return elem
.getBoundingClientRect().left
;
6599 // These hooks are used by animate to expand properties
6604 }, function( prefix
, suffix
) {
6605 jQuery
.cssHooks
[ prefix
+ suffix
] = {
6606 expand: function( value
) {
6610 // Assumes a single number if not a string
6611 parts
= typeof value
=== "string" ? value
.split( " " ) : [ value
];
6613 for ( ; i
< 4; i
++ ) {
6614 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
6615 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
6622 if ( !rmargin
.test( prefix
) ) {
6623 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
6628 css: function( name
, value
) {
6629 return access( this, function( elem
, name
, value
) {
6634 if ( Array
.isArray( name
) ) {
6635 styles
= getStyles( elem
);
6638 for ( ; i
< len
; i
++ ) {
6639 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
6645 return value
!== undefined ?
6646 jQuery
.style( elem
, name
, value
) :
6647 jQuery
.css( elem
, name
);
6648 }, name
, value
, arguments
.length
> 1 );
6653 function Tween( elem
, options
, prop
, end
, easing
) {
6654 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
6656 jQuery
.Tween
= Tween
;
6660 init: function( elem
, options
, prop
, end
, easing
, unit
) {
6663 this.easing
= easing
|| jQuery
.easing
._default
;
6664 this.options
= options
;
6665 this.start
= this.now
= this.cur();
6667 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
6670 var hooks
= Tween
.propHooks
[ this.prop
];
6672 return hooks
&& hooks
.get ?
6674 Tween
.propHooks
._default
.get( this );
6676 run: function( percent
) {
6678 hooks
= Tween
.propHooks
[ this.prop
];
6680 if ( this.options
.duration
) {
6681 this.pos
= eased
= jQuery
.easing
[ this.easing
](
6682 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
6685 this.pos
= eased
= percent
;
6687 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
6689 if ( this.options
.step
) {
6690 this.options
.step
.call( this.elem
, this.now
, this );
6693 if ( hooks
&& hooks
.set ) {
6696 Tween
.propHooks
._default
.set( this );
6702 Tween
.prototype.init
.prototype = Tween
.prototype;
6706 get: function( tween
) {
6709 // Use a property on the element directly when it is not a DOM element,
6710 // or when there is no matching style property that exists.
6711 if ( tween
.elem
.nodeType
!== 1 ||
6712 tween
.elem
[ tween
.prop
] != null && tween
.elem
.style
[ tween
.prop
] == null ) {
6713 return tween
.elem
[ tween
.prop
];
6716 // Passing an empty string as a 3rd parameter to .css will automatically
6717 // attempt a parseFloat and fallback to a string if the parse fails.
6718 // Simple values such as "10px" are parsed to Float;
6719 // complex values such as "rotate(1rad)" are returned as-is.
6720 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
6722 // Empty strings, null, undefined and "auto" are converted to 0.
6723 return !result
|| result
=== "auto" ? 0 : result
;
6725 set: function( tween
) {
6727 // Use step hook for back compat.
6728 // Use cssHook if its there.
6729 // Use .style if available and use plain properties where available.
6730 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
6731 jQuery
.fx
.step
[ tween
.prop
]( tween
);
6732 } else if ( tween
.elem
.nodeType
=== 1 &&
6733 ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null ||
6734 jQuery
.cssHooks
[ tween
.prop
] ) ) {
6735 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
6737 tween
.elem
[ tween
.prop
] = tween
.now
;
6743 // Support: IE <=9 only
6744 // Panic based approach to setting things on disconnected nodes
6745 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
6746 set: function( tween
) {
6747 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
6748 tween
.elem
[ tween
.prop
] = tween
.now
;
6754 linear: function( p
) {
6757 swing: function( p
) {
6758 return 0.5 - Math
.cos( p
* Math
.PI
) / 2;
6763 jQuery
.fx
= Tween
.prototype.init
;
6765 // Back compat <1.8 extension point
6766 jQuery
.fx
.step
= {};
6773 rfxtypes
= /^(?:toggle|show|hide)$/,
6774 rrun
= /queueHooks$/;
6776 function schedule() {
6778 if ( document
.hidden
=== false && window
.requestAnimationFrame
) {
6779 window
.requestAnimationFrame( schedule
);
6781 window
.setTimeout( schedule
, jQuery
.fx
.interval
);
6788 // Animations created synchronously will run synchronously
6789 function createFxNow() {
6790 window
.setTimeout( function() {
6793 return ( fxNow
= jQuery
.now() );
6796 // Generate parameters to create a standard animation
6797 function genFx( type
, includeWidth
) {
6800 attrs
= { height
: type
};
6802 // If we include width, step value is 1 to do all cssExpand values,
6803 // otherwise step value is 2 to skip over Left and Right
6804 includeWidth
= includeWidth
? 1 : 0;
6805 for ( ; i
< 4; i
+= 2 - includeWidth
) {
6806 which
= cssExpand
[ i
];
6807 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
6810 if ( includeWidth
) {
6811 attrs
.opacity
= attrs
.width
= type
;
6817 function createTween( value
, prop
, animation
) {
6819 collection
= ( Animation
.tweeners
[ prop
] || [] ).concat( Animation
.tweeners
[ "*" ] ),
6821 length
= collection
.length
;
6822 for ( ; index
< length
; index
++ ) {
6823 if ( ( tween
= collection
[ index
].call( animation
, prop
, value
) ) ) {
6825 // We're done with this property
6831 function defaultPrefilter( elem
, props
, opts
) {
6832 var prop
, value
, toggle
, hooks
, oldfire
, propTween
, restoreDisplay
, display
,
6833 isBox
= "width" in props
|| "height" in props
,
6837 hidden
= elem
.nodeType
&& isHiddenWithinTree( elem
),
6838 dataShow
= dataPriv
.get( elem
, "fxshow" );
6840 // Queue-skipping animations hijack the fx hooks
6841 if ( !opts
.queue
) {
6842 hooks
= jQuery
._queueHooks( elem
, "fx" );
6843 if ( hooks
.unqueued
== null ) {
6845 oldfire
= hooks
.empty
.fire
;
6846 hooks
.empty
.fire = function() {
6847 if ( !hooks
.unqueued
) {
6854 anim
.always( function() {
6856 // Ensure the complete handler is called before this completes
6857 anim
.always( function() {
6859 if ( !jQuery
.queue( elem
, "fx" ).length
) {
6866 // Detect show/hide animations
6867 for ( prop
in props
) {
6868 value
= props
[ prop
];
6869 if ( rfxtypes
.test( value
) ) {
6870 delete props
[ prop
];
6871 toggle
= toggle
|| value
=== "toggle";
6872 if ( value
=== ( hidden
? "hide" : "show" ) ) {
6874 // Pretend to be hidden if this is a "show" and
6875 // there is still data from a stopped show/hide
6876 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
6879 // Ignore all other no-op show/hide data
6884 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
6888 // Bail out if this is a no-op like .hide().hide()
6889 propTween
= !jQuery
.isEmptyObject( props
);
6890 if ( !propTween
&& jQuery
.isEmptyObject( orig
) ) {
6894 // Restrict "overflow" and "display" styles during box animations
6895 if ( isBox
&& elem
.nodeType
=== 1 ) {
6897 // Support: IE <=9 - 11, Edge 12 - 13
6898 // Record all 3 overflow attributes because IE does not infer the shorthand
6899 // from identically-valued overflowX and overflowY
6900 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
6902 // Identify a display type, preferring old show/hide data over the CSS cascade
6903 restoreDisplay
= dataShow
&& dataShow
.display
;
6904 if ( restoreDisplay
== null ) {
6905 restoreDisplay
= dataPriv
.get( elem
, "display" );
6907 display
= jQuery
.css( elem
, "display" );
6908 if ( display
=== "none" ) {
6909 if ( restoreDisplay
) {
6910 display
= restoreDisplay
;
6913 // Get nonempty value(s) by temporarily forcing visibility
6914 showHide( [ elem
], true );
6915 restoreDisplay
= elem
.style
.display
|| restoreDisplay
;
6916 display
= jQuery
.css( elem
, "display" );
6917 showHide( [ elem
] );
6921 // Animate inline elements as inline-block
6922 if ( display
=== "inline" || display
=== "inline-block" && restoreDisplay
!= null ) {
6923 if ( jQuery
.css( elem
, "float" ) === "none" ) {
6925 // Restore the original display value at the end of pure show/hide animations
6927 anim
.done( function() {
6928 style
.display
= restoreDisplay
;
6930 if ( restoreDisplay
== null ) {
6931 display
= style
.display
;
6932 restoreDisplay
= display
=== "none" ? "" : display
;
6935 style
.display
= "inline-block";
6940 if ( opts
.overflow
) {
6941 style
.overflow
= "hidden";
6942 anim
.always( function() {
6943 style
.overflow
= opts
.overflow
[ 0 ];
6944 style
.overflowX
= opts
.overflow
[ 1 ];
6945 style
.overflowY
= opts
.overflow
[ 2 ];
6949 // Implement show/hide animations
6951 for ( prop
in orig
) {
6953 // General show/hide setup for this element animation
6956 if ( "hidden" in dataShow
) {
6957 hidden
= dataShow
.hidden
;
6960 dataShow
= dataPriv
.access( elem
, "fxshow", { display
: restoreDisplay
} );
6963 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
6965 dataShow
.hidden
= !hidden
;
6968 // Show elements before animating them
6970 showHide( [ elem
], true );
6973 /* eslint-disable no-loop-func */
6975 anim
.done( function() {
6977 /* eslint-enable no-loop-func */
6979 // The final step of a "hide" animation is actually hiding the element
6981 showHide( [ elem
] );
6983 dataPriv
.remove( elem
, "fxshow" );
6984 for ( prop
in orig
) {
6985 jQuery
.style( elem
, prop
, orig
[ prop
] );
6990 // Per-property setup
6991 propTween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
6992 if ( !( prop
in dataShow
) ) {
6993 dataShow
[ prop
] = propTween
.start
;
6995 propTween
.end
= propTween
.start
;
6996 propTween
.start
= 0;
7002 function propFilter( props
, specialEasing
) {
7003 var index
, name
, easing
, value
, hooks
;
7005 // camelCase, specialEasing and expand cssHook pass
7006 for ( index
in props
) {
7007 name
= jQuery
.camelCase( index
);
7008 easing
= specialEasing
[ name
];
7009 value
= props
[ index
];
7010 if ( Array
.isArray( value
) ) {
7011 easing
= value
[ 1 ];
7012 value
= props
[ index
] = value
[ 0 ];
7015 if ( index
!== name
) {
7016 props
[ name
] = value
;
7017 delete props
[ index
];
7020 hooks
= jQuery
.cssHooks
[ name
];
7021 if ( hooks
&& "expand" in hooks
) {
7022 value
= hooks
.expand( value
);
7023 delete props
[ name
];
7025 // Not quite $.extend, this won't overwrite existing keys.
7026 // Reusing 'index' because we have the correct "name"
7027 for ( index
in value
) {
7028 if ( !( index
in props
) ) {
7029 props
[ index
] = value
[ index
];
7030 specialEasing
[ index
] = easing
;
7034 specialEasing
[ name
] = easing
;
7039 function Animation( elem
, properties
, options
) {
7043 length
= Animation
.prefilters
.length
,
7044 deferred
= jQuery
.Deferred().always( function() {
7046 // Don't match elem in the :animated selector
7053 var currentTime
= fxNow
|| createFxNow(),
7054 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
7056 // Support: Android 2.3 only
7057 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
7058 temp
= remaining
/ animation
.duration
|| 0,
7061 length
= animation
.tweens
.length
;
7063 for ( ; index
< length
; index
++ ) {
7064 animation
.tweens
[ index
].run( percent
);
7067 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
] );
7069 // If there's more to do, yield
7070 if ( percent
< 1 && length
) {
7074 // If this was an empty animation, synthesize a final progress notification
7076 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7079 // Resolve the animation and report its conclusion
7080 deferred
.resolveWith( elem
, [ animation
] );
7083 animation
= deferred
.promise( {
7085 props
: jQuery
.extend( {}, properties
),
7086 opts
: jQuery
.extend( true, {
7088 easing
: jQuery
.easing
._default
7090 originalProperties
: properties
,
7091 originalOptions
: options
,
7092 startTime
: fxNow
|| createFxNow(),
7093 duration
: options
.duration
,
7095 createTween: function( prop
, end
) {
7096 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
7097 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
7098 animation
.tweens
.push( tween
);
7101 stop: function( gotoEnd
) {
7104 // If we are going to the end, we want to run all the tweens
7105 // otherwise we skip this part
7106 length
= gotoEnd
? animation
.tweens
.length
: 0;
7111 for ( ; index
< length
; index
++ ) {
7112 animation
.tweens
[ index
].run( 1 );
7115 // Resolve when we played the last frame; otherwise, reject
7117 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7118 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
7120 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
7125 props
= animation
.props
;
7127 propFilter( props
, animation
.opts
.specialEasing
);
7129 for ( ; index
< length
; index
++ ) {
7130 result
= Animation
.prefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
7132 if ( jQuery
.isFunction( result
.stop
) ) {
7133 jQuery
._queueHooks( animation
.elem
, animation
.opts
.queue
).stop
=
7134 jQuery
.proxy( result
.stop
, result
);
7140 jQuery
.map( props
, createTween
, animation
);
7142 if ( jQuery
.isFunction( animation
.opts
.start
) ) {
7143 animation
.opts
.start
.call( elem
, animation
);
7146 // Attach callbacks from options
7148 .progress( animation
.opts
.progress
)
7149 .done( animation
.opts
.done
, animation
.opts
.complete
)
7150 .fail( animation
.opts
.fail
)
7151 .always( animation
.opts
.always
);
7154 jQuery
.extend( tick
, {
7157 queue
: animation
.opts
.queue
7164 jQuery
.Animation
= jQuery
.extend( Animation
, {
7167 "*": [ function( prop
, value
) {
7168 var tween
= this.createTween( prop
, value
);
7169 adjustCSS( tween
.elem
, prop
, rcssNum
.exec( value
), tween
);
7174 tweener: function( props
, callback
) {
7175 if ( jQuery
.isFunction( props
) ) {
7179 props
= props
.match( rnothtmlwhite
);
7184 length
= props
.length
;
7186 for ( ; index
< length
; index
++ ) {
7187 prop
= props
[ index
];
7188 Animation
.tweeners
[ prop
] = Animation
.tweeners
[ prop
] || [];
7189 Animation
.tweeners
[ prop
].unshift( callback
);
7193 prefilters
: [ defaultPrefilter
],
7195 prefilter: function( callback
, prepend
) {
7197 Animation
.prefilters
.unshift( callback
);
7199 Animation
.prefilters
.push( callback
);
7204 jQuery
.speed = function( speed
, easing
, fn
) {
7205 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
7206 complete
: fn
|| !fn
&& easing
||
7207 jQuery
.isFunction( speed
) && speed
,
7209 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
7212 // Go to the end state if fx are off
7213 if ( jQuery
.fx
.off
) {
7217 if ( typeof opt
.duration
!== "number" ) {
7218 if ( opt
.duration
in jQuery
.fx
.speeds
) {
7219 opt
.duration
= jQuery
.fx
.speeds
[ opt
.duration
];
7222 opt
.duration
= jQuery
.fx
.speeds
._default
;
7227 // Normalize opt.queue - true/undefined/null -> "fx"
7228 if ( opt
.queue
== null || opt
.queue
=== true ) {
7233 opt
.old
= opt
.complete
;
7235 opt
.complete = function() {
7236 if ( jQuery
.isFunction( opt
.old
) ) {
7237 opt
.old
.call( this );
7241 jQuery
.dequeue( this, opt
.queue
);
7249 fadeTo: function( speed
, to
, easing
, callback
) {
7251 // Show any hidden elements after setting opacity to 0
7252 return this.filter( isHiddenWithinTree
).css( "opacity", 0 ).show()
7254 // Animate to the value specified
7255 .end().animate( { opacity
: to
}, speed
, easing
, callback
);
7257 animate: function( prop
, speed
, easing
, callback
) {
7258 var empty
= jQuery
.isEmptyObject( prop
),
7259 optall
= jQuery
.speed( speed
, easing
, callback
),
7260 doAnimation = function() {
7262 // Operate on a copy of prop so per-property easing won't be lost
7263 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
7265 // Empty animations, or finishing resolves immediately
7266 if ( empty
|| dataPriv
.get( this, "finish" ) ) {
7270 doAnimation
.finish
= doAnimation
;
7272 return empty
|| optall
.queue
=== false ?
7273 this.each( doAnimation
) :
7274 this.queue( optall
.queue
, doAnimation
);
7276 stop: function( type
, clearQueue
, gotoEnd
) {
7277 var stopQueue = function( hooks
) {
7278 var stop
= hooks
.stop
;
7283 if ( typeof type
!== "string" ) {
7284 gotoEnd
= clearQueue
;
7288 if ( clearQueue
&& type
!== false ) {
7289 this.queue( type
|| "fx", [] );
7292 return this.each( function() {
7294 index
= type
!= null && type
+ "queueHooks",
7295 timers
= jQuery
.timers
,
7296 data
= dataPriv
.get( this );
7299 if ( data
[ index
] && data
[ index
].stop
) {
7300 stopQueue( data
[ index
] );
7303 for ( index
in data
) {
7304 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
7305 stopQueue( data
[ index
] );
7310 for ( index
= timers
.length
; index
--; ) {
7311 if ( timers
[ index
].elem
=== this &&
7312 ( type
== null || timers
[ index
].queue
=== type
) ) {
7314 timers
[ index
].anim
.stop( gotoEnd
);
7316 timers
.splice( index
, 1 );
7320 // Start the next in the queue if the last step wasn't forced.
7321 // Timers currently will call their complete callbacks, which
7322 // will dequeue but only if they were gotoEnd.
7323 if ( dequeue
|| !gotoEnd
) {
7324 jQuery
.dequeue( this, type
);
7328 finish: function( type
) {
7329 if ( type
!== false ) {
7330 type
= type
|| "fx";
7332 return this.each( function() {
7334 data
= dataPriv
.get( this ),
7335 queue
= data
[ type
+ "queue" ],
7336 hooks
= data
[ type
+ "queueHooks" ],
7337 timers
= jQuery
.timers
,
7338 length
= queue
? queue
.length
: 0;
7340 // Enable finishing flag on private data
7343 // Empty the queue first
7344 jQuery
.queue( this, type
, [] );
7346 if ( hooks
&& hooks
.stop
) {
7347 hooks
.stop
.call( this, true );
7350 // Look for any active animations, and finish them
7351 for ( index
= timers
.length
; index
--; ) {
7352 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
7353 timers
[ index
].anim
.stop( true );
7354 timers
.splice( index
, 1 );
7358 // Look for any animations in the old queue and finish them
7359 for ( index
= 0; index
< length
; index
++ ) {
7360 if ( queue
[ index
] && queue
[ index
].finish
) {
7361 queue
[ index
].finish
.call( this );
7365 // Turn off finishing flag
7371 jQuery
.each( [ "toggle", "show", "hide" ], function( i
, name
) {
7372 var cssFn
= jQuery
.fn
[ name
];
7373 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7374 return speed
== null || typeof speed
=== "boolean" ?
7375 cssFn
.apply( this, arguments
) :
7376 this.animate( genFx( name
, true ), speed
, easing
, callback
);
7380 // Generate shortcuts for custom animations
7382 slideDown
: genFx( "show" ),
7383 slideUp
: genFx( "hide" ),
7384 slideToggle
: genFx( "toggle" ),
7385 fadeIn
: { opacity
: "show" },
7386 fadeOut
: { opacity
: "hide" },
7387 fadeToggle
: { opacity
: "toggle" }
7388 }, function( name
, props
) {
7389 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7390 return this.animate( props
, speed
, easing
, callback
);
7395 jQuery
.fx
.tick = function() {
7398 timers
= jQuery
.timers
;
7400 fxNow
= jQuery
.now();
7402 for ( ; i
< timers
.length
; i
++ ) {
7403 timer
= timers
[ i
];
7405 // Run the timer and safely remove it when done (allowing for external removal)
7406 if ( !timer() && timers
[ i
] === timer
) {
7407 timers
.splice( i
--, 1 );
7411 if ( !timers
.length
) {
7417 jQuery
.fx
.timer = function( timer
) {
7418 jQuery
.timers
.push( timer
);
7422 jQuery
.fx
.interval
= 13;
7423 jQuery
.fx
.start = function() {
7432 jQuery
.fx
.stop = function() {
7436 jQuery
.fx
.speeds
= {
7445 // Based off of the plugin by Clint Helfers, with permission.
7446 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
7447 jQuery
.fn
.delay = function( time
, type
) {
7448 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
7449 type
= type
|| "fx";
7451 return this.queue( type
, function( next
, hooks
) {
7452 var timeout
= window
.setTimeout( next
, time
);
7453 hooks
.stop = function() {
7454 window
.clearTimeout( timeout
);
7461 var input
= document
.createElement( "input" ),
7462 select
= document
.createElement( "select" ),
7463 opt
= select
.appendChild( document
.createElement( "option" ) );
7465 input
.type
= "checkbox";
7467 // Support: Android <=4.3 only
7468 // Default value for a checkbox should be "on"
7469 support
.checkOn
= input
.value
!== "";
7471 // Support: IE <=11 only
7472 // Must access selectedIndex to make default options select
7473 support
.optSelected
= opt
.selected
;
7475 // Support: IE <=11 only
7476 // An input loses its value after becoming a radio
7477 input
= document
.createElement( "input" );
7479 input
.type
= "radio";
7480 support
.radioValue
= input
.value
=== "t";
7485 attrHandle
= jQuery
.expr
.attrHandle
;
7488 attr: function( name
, value
) {
7489 return access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
7492 removeAttr: function( name
) {
7493 return this.each( function() {
7494 jQuery
.removeAttr( this, name
);
7500 attr: function( elem
, name
, value
) {
7502 nType
= elem
.nodeType
;
7504 // Don't get/set attributes on text, comment and attribute nodes
7505 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7509 // Fallback to prop when attributes are not supported
7510 if ( typeof elem
.getAttribute
=== "undefined" ) {
7511 return jQuery
.prop( elem
, name
, value
);
7514 // Attribute hooks are determined by the lowercase version
7515 // Grab necessary hook if one is defined
7516 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
7517 hooks
= jQuery
.attrHooks
[ name
.toLowerCase() ] ||
7518 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook
: undefined );
7521 if ( value
!== undefined ) {
7522 if ( value
=== null ) {
7523 jQuery
.removeAttr( elem
, name
);
7527 if ( hooks
&& "set" in hooks
&&
7528 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
7532 elem
.setAttribute( name
, value
+ "" );
7536 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
7540 ret
= jQuery
.find
.attr( elem
, name
);
7542 // Non-existent attributes return null, we normalize to undefined
7543 return ret
== null ? undefined : ret
;
7548 set: function( elem
, value
) {
7549 if ( !support
.radioValue
&& value
=== "radio" &&
7550 nodeName( elem
, "input" ) ) {
7551 var val
= elem
.value
;
7552 elem
.setAttribute( "type", value
);
7562 removeAttr: function( elem
, value
) {
7566 // Attribute names can contain non-HTML whitespace characters
7567 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
7568 attrNames
= value
&& value
.match( rnothtmlwhite
);
7570 if ( attrNames
&& elem
.nodeType
=== 1 ) {
7571 while ( ( name
= attrNames
[ i
++ ] ) ) {
7572 elem
.removeAttribute( name
);
7578 // Hooks for boolean attributes
7580 set: function( elem
, value
, name
) {
7581 if ( value
=== false ) {
7583 // Remove boolean attributes when set to false
7584 jQuery
.removeAttr( elem
, name
);
7586 elem
.setAttribute( name
, name
);
7592 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( i
, name
) {
7593 var getter
= attrHandle
[ name
] || jQuery
.find
.attr
;
7595 attrHandle
[ name
] = function( elem
, name
, isXML
) {
7597 lowercaseName
= name
.toLowerCase();
7601 // Avoid an infinite loop by temporarily removing this function from the getter
7602 handle
= attrHandle
[ lowercaseName
];
7603 attrHandle
[ lowercaseName
] = ret
;
7604 ret
= getter( elem
, name
, isXML
) != null ?
7607 attrHandle
[ lowercaseName
] = handle
;
7616 var rfocusable
= /^(?:input|select|textarea|button)$/i,
7617 rclickable
= /^(?:a|area)$/i;
7620 prop: function( name
, value
) {
7621 return access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
7624 removeProp: function( name
) {
7625 return this.each( function() {
7626 delete this[ jQuery
.propFix
[ name
] || name
];
7632 prop: function( elem
, name
, value
) {
7634 nType
= elem
.nodeType
;
7636 // Don't get/set properties on text, comment and attribute nodes
7637 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7641 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
7643 // Fix name and attach hooks
7644 name
= jQuery
.propFix
[ name
] || name
;
7645 hooks
= jQuery
.propHooks
[ name
];
7648 if ( value
!== undefined ) {
7649 if ( hooks
&& "set" in hooks
&&
7650 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
7654 return ( elem
[ name
] = value
);
7657 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
7661 return elem
[ name
];
7666 get: function( elem
) {
7668 // Support: IE <=9 - 11 only
7669 // elem.tabIndex doesn't always return the
7670 // correct value when it hasn't been explicitly set
7671 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
7672 // Use proper attribute retrieval(#12072)
7673 var tabindex
= jQuery
.find
.attr( elem
, "tabindex" );
7676 return parseInt( tabindex
, 10 );
7680 rfocusable
.test( elem
.nodeName
) ||
7681 rclickable
.test( elem
.nodeName
) &&
7694 "class": "className"
7698 // Support: IE <=11 only
7699 // Accessing the selectedIndex property
7700 // forces the browser to respect setting selected
7702 // The getter ensures a default option is selected
7703 // when in an optgroup
7704 // eslint rule "no-unused-expressions" is disabled for this code
7705 // since it considers such accessions noop
7706 if ( !support
.optSelected
) {
7707 jQuery
.propHooks
.selected
= {
7708 get: function( elem
) {
7710 /* eslint no-unused-expressions: "off" */
7712 var parent
= elem
.parentNode
;
7713 if ( parent
&& parent
.parentNode
) {
7714 parent
.parentNode
.selectedIndex
;
7718 set: function( elem
) {
7720 /* eslint no-unused-expressions: "off" */
7722 var parent
= elem
.parentNode
;
7724 parent
.selectedIndex
;
7726 if ( parent
.parentNode
) {
7727 parent
.parentNode
.selectedIndex
;
7746 jQuery
.propFix
[ this.toLowerCase() ] = this;
7752 // Strip and collapse whitespace according to HTML spec
7753 // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
7754 function stripAndCollapse( value
) {
7755 var tokens
= value
.match( rnothtmlwhite
) || [];
7756 return tokens
.join( " " );
7760 function getClass( elem
) {
7761 return elem
.getAttribute
&& elem
.getAttribute( "class" ) || "";
7765 addClass: function( value
) {
7766 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
7769 if ( jQuery
.isFunction( value
) ) {
7770 return this.each( function( j
) {
7771 jQuery( this ).addClass( value
.call( this, j
, getClass( this ) ) );
7775 if ( typeof value
=== "string" && value
) {
7776 classes
= value
.match( rnothtmlwhite
) || [];
7778 while ( ( elem
= this[ i
++ ] ) ) {
7779 curValue
= getClass( elem
);
7780 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
7784 while ( ( clazz
= classes
[ j
++ ] ) ) {
7785 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
7790 // Only assign if different to avoid unneeded rendering.
7791 finalValue
= stripAndCollapse( cur
);
7792 if ( curValue
!== finalValue
) {
7793 elem
.setAttribute( "class", finalValue
);
7802 removeClass: function( value
) {
7803 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
7806 if ( jQuery
.isFunction( value
) ) {
7807 return this.each( function( j
) {
7808 jQuery( this ).removeClass( value
.call( this, j
, getClass( this ) ) );
7812 if ( !arguments
.length
) {
7813 return this.attr( "class", "" );
7816 if ( typeof value
=== "string" && value
) {
7817 classes
= value
.match( rnothtmlwhite
) || [];
7819 while ( ( elem
= this[ i
++ ] ) ) {
7820 curValue
= getClass( elem
);
7822 // This expression is here for better compressibility (see addClass)
7823 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
7827 while ( ( clazz
= classes
[ j
++ ] ) ) {
7829 // Remove *all* instances
7830 while ( cur
.indexOf( " " + clazz
+ " " ) > -1 ) {
7831 cur
= cur
.replace( " " + clazz
+ " ", " " );
7835 // Only assign if different to avoid unneeded rendering.
7836 finalValue
= stripAndCollapse( cur
);
7837 if ( curValue
!== finalValue
) {
7838 elem
.setAttribute( "class", finalValue
);
7847 toggleClass: function( value
, stateVal
) {
7848 var type
= typeof value
;
7850 if ( typeof stateVal
=== "boolean" && type
=== "string" ) {
7851 return stateVal
? this.addClass( value
) : this.removeClass( value
);
7854 if ( jQuery
.isFunction( value
) ) {
7855 return this.each( function( i
) {
7856 jQuery( this ).toggleClass(
7857 value
.call( this, i
, getClass( this ), stateVal
),
7863 return this.each( function() {
7864 var className
, i
, self
, classNames
;
7866 if ( type
=== "string" ) {
7868 // Toggle individual class names
7870 self
= jQuery( this );
7871 classNames
= value
.match( rnothtmlwhite
) || [];
7873 while ( ( className
= classNames
[ i
++ ] ) ) {
7875 // Check each className given, space separated list
7876 if ( self
.hasClass( className
) ) {
7877 self
.removeClass( className
);
7879 self
.addClass( className
);
7883 // Toggle whole class name
7884 } else if ( value
=== undefined || type
=== "boolean" ) {
7885 className
= getClass( this );
7888 // Store className if set
7889 dataPriv
.set( this, "__className__", className
);
7892 // If the element has a class name or if we're passed `false`,
7893 // then remove the whole classname (if there was one, the above saved it).
7894 // Otherwise bring back whatever was previously saved (if anything),
7895 // falling back to the empty string if nothing was stored.
7896 if ( this.setAttribute
) {
7897 this.setAttribute( "class",
7898 className
|| value
=== false ?
7900 dataPriv
.get( this, "__className__" ) || ""
7907 hasClass: function( selector
) {
7908 var className
, elem
,
7911 className
= " " + selector
+ " ";
7912 while ( ( elem
= this[ i
++ ] ) ) {
7913 if ( elem
.nodeType
=== 1 &&
7914 ( " " + stripAndCollapse( getClass( elem
) ) + " " ).indexOf( className
) > -1 ) {
7926 var rreturn
= /\r/g;
7929 val: function( value
) {
7930 var hooks
, ret
, isFunction
,
7933 if ( !arguments
.length
) {
7935 hooks
= jQuery
.valHooks
[ elem
.type
] ||
7936 jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
7940 ( ret
= hooks
.get( elem
, "value" ) ) !== undefined
7947 // Handle most common string cases
7948 if ( typeof ret
=== "string" ) {
7949 return ret
.replace( rreturn
, "" );
7952 // Handle cases where value is null/undef or number
7953 return ret
== null ? "" : ret
;
7959 isFunction
= jQuery
.isFunction( value
);
7961 return this.each( function( i
) {
7964 if ( this.nodeType
!== 1 ) {
7969 val
= value
.call( this, i
, jQuery( this ).val() );
7974 // Treat null/undefined as ""; convert numbers to string
7975 if ( val
== null ) {
7978 } else if ( typeof val
=== "number" ) {
7981 } else if ( Array
.isArray( val
) ) {
7982 val
= jQuery
.map( val
, function( value
) {
7983 return value
== null ? "" : value
+ "";
7987 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
7989 // If set returns undefined, fall back to normal setting
7990 if ( !hooks
|| !( "set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
8000 get: function( elem
) {
8002 var val
= jQuery
.find
.attr( elem
, "value" );
8003 return val
!= null ?
8006 // Support: IE <=10 - 11 only
8007 // option.text throws exceptions (#14686, #14858)
8008 // Strip and collapse whitespace
8009 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8010 stripAndCollapse( jQuery
.text( elem
) );
8014 get: function( elem
) {
8015 var value
, option
, i
,
8016 options
= elem
.options
,
8017 index
= elem
.selectedIndex
,
8018 one
= elem
.type
=== "select-one",
8019 values
= one
? null : [],
8020 max
= one
? index
+ 1 : options
.length
;
8026 i
= one
? index
: 0;
8029 // Loop through all the selected options
8030 for ( ; i
< max
; i
++ ) {
8031 option
= options
[ i
];
8033 // Support: IE <=9 only
8034 // IE8-9 doesn't update selected after form reset (#2551)
8035 if ( ( option
.selected
|| i
=== index
) &&
8037 // Don't return options that are disabled or in a disabled optgroup
8039 ( !option
.parentNode
.disabled
||
8040 !nodeName( option
.parentNode
, "optgroup" ) ) ) {
8042 // Get the specific value for the option
8043 value
= jQuery( option
).val();
8045 // We don't need an array for one selects
8050 // Multi-Selects return an array
8051 values
.push( value
);
8058 set: function( elem
, value
) {
8059 var optionSet
, option
,
8060 options
= elem
.options
,
8061 values
= jQuery
.makeArray( value
),
8065 option
= options
[ i
];
8067 /* eslint-disable no-cond-assign */
8069 if ( option
.selected
=
8070 jQuery
.inArray( jQuery
.valHooks
.option
.get( option
), values
) > -1
8075 /* eslint-enable no-cond-assign */
8078 // Force browsers to behave consistently when non-matching value is set
8080 elem
.selectedIndex
= -1;
8088 // Radios and checkboxes getter/setter
8089 jQuery
.each( [ "radio", "checkbox" ], function() {
8090 jQuery
.valHooks
[ this ] = {
8091 set: function( elem
, value
) {
8092 if ( Array
.isArray( value
) ) {
8093 return ( elem
.checked
= jQuery
.inArray( jQuery( elem
).val(), value
) > -1 );
8097 if ( !support
.checkOn
) {
8098 jQuery
.valHooks
[ this ].get = function( elem
) {
8099 return elem
.getAttribute( "value" ) === null ? "on" : elem
.value
;
8107 // Return jQuery for attributes-only inclusion
8110 var rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/;
8112 jQuery
.extend( jQuery
.event
, {
8114 trigger: function( event
, data
, elem
, onlyHandlers
) {
8116 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
,
8117 eventPath
= [ elem
|| document
],
8118 type
= hasOwn
.call( event
, "type" ) ? event
.type
: event
,
8119 namespaces
= hasOwn
.call( event
, "namespace" ) ? event
.namespace.split( "." ) : [];
8121 cur
= tmp
= elem
= elem
|| document
;
8123 // Don't do events on text and comment nodes
8124 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
8128 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8129 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
8133 if ( type
.indexOf( "." ) > -1 ) {
8135 // Namespaced trigger; create a regexp to match event type in handle()
8136 namespaces
= type
.split( "." );
8137 type
= namespaces
.shift();
8140 ontype
= type
.indexOf( ":" ) < 0 && "on" + type
;
8142 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8143 event
= event
[ jQuery
.expando
] ?
8145 new jQuery
.Event( type
, typeof event
=== "object" && event
);
8147 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8148 event
.isTrigger
= onlyHandlers
? 2 : 3;
8149 event
.namespace = namespaces
.join( "." );
8150 event
.rnamespace
= event
.namespace ?
8151 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8154 // Clean up the event in case it is being reused
8155 event
.result
= undefined;
8156 if ( !event
.target
) {
8157 event
.target
= elem
;
8160 // Clone any incoming data and prepend the event, creating the handler arg list
8161 data
= data
== null ?
8163 jQuery
.makeArray( data
, [ event
] );
8165 // Allow special events to draw outside the lines
8166 special
= jQuery
.event
.special
[ type
] || {};
8167 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
8171 // Determine event propagation path in advance, per W3C events spec (#9951)
8172 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
8173 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
8175 bubbleType
= special
.delegateType
|| type
;
8176 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
8177 cur
= cur
.parentNode
;
8179 for ( ; cur
; cur
= cur
.parentNode
) {
8180 eventPath
.push( cur
);
8184 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8185 if ( tmp
=== ( elem
.ownerDocument
|| document
) ) {
8186 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
8190 // Fire handlers on the event path
8192 while ( ( cur
= eventPath
[ i
++ ] ) && !event
.isPropagationStopped() ) {
8194 event
.type
= i
> 1 ?
8196 special
.bindType
|| type
;
8199 handle
= ( dataPriv
.get( cur
, "events" ) || {} )[ event
.type
] &&
8200 dataPriv
.get( cur
, "handle" );
8202 handle
.apply( cur
, data
);
8206 handle
= ontype
&& cur
[ ontype
];
8207 if ( handle
&& handle
.apply
&& acceptData( cur
) ) {
8208 event
.result
= handle
.apply( cur
, data
);
8209 if ( event
.result
=== false ) {
8210 event
.preventDefault();
8216 // If nobody prevented the default action, do it now
8217 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
8219 if ( ( !special
._default
||
8220 special
._default
.apply( eventPath
.pop(), data
) === false ) &&
8221 acceptData( elem
) ) {
8223 // Call a native DOM method on the target with the same name as the event.
8224 // Don't do default actions on window, that's where global variables be (#6170)
8225 if ( ontype
&& jQuery
.isFunction( elem
[ type
] ) && !jQuery
.isWindow( elem
) ) {
8227 // Don't re-trigger an onFOO event when we call its FOO() method
8228 tmp
= elem
[ ontype
];
8231 elem
[ ontype
] = null;
8234 // Prevent re-triggering of the same event, since we already bubbled it above
8235 jQuery
.event
.triggered
= type
;
8237 jQuery
.event
.triggered
= undefined;
8240 elem
[ ontype
] = tmp
;
8246 return event
.result
;
8249 // Piggyback on a donor event to simulate a different one
8250 // Used only for `focus(in | out)` events
8251 simulate: function( type
, elem
, event
) {
8252 var e
= jQuery
.extend(
8261 jQuery
.event
.trigger( e
, null, elem
);
8268 trigger: function( type
, data
) {
8269 return this.each( function() {
8270 jQuery
.event
.trigger( type
, data
, this );
8273 triggerHandler: function( type
, data
) {
8274 var elem
= this[ 0 ];
8276 return jQuery
.event
.trigger( type
, data
, elem
, true );
8282 jQuery
.each( ( "blur focus focusin focusout resize scroll click dblclick " +
8283 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
8284 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
8285 function( i
, name
) {
8287 // Handle event binding
8288 jQuery
.fn
[ name
] = function( data
, fn
) {
8289 return arguments
.length
> 0 ?
8290 this.on( name
, null, data
, fn
) :
8291 this.trigger( name
);
8296 hover: function( fnOver
, fnOut
) {
8297 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
8304 support
.focusin
= "onfocusin" in window
;
8307 // Support: Firefox <=44
8308 // Firefox doesn't have focus(in | out) events
8309 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
8311 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
8312 // focus(in | out) events fire after focus & blur events,
8313 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
8314 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
8315 if ( !support
.focusin
) {
8316 jQuery
.each( { focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
8318 // Attach a single capturing handler on the document while someone wants focusin/focusout
8319 var handler = function( event
) {
8320 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
) );
8323 jQuery
.event
.special
[ fix
] = {
8325 var doc
= this.ownerDocument
|| this,
8326 attaches
= dataPriv
.access( doc
, fix
);
8329 doc
.addEventListener( orig
, handler
, true );
8331 dataPriv
.access( doc
, fix
, ( attaches
|| 0 ) + 1 );
8333 teardown: function() {
8334 var doc
= this.ownerDocument
|| this,
8335 attaches
= dataPriv
.access( doc
, fix
) - 1;
8338 doc
.removeEventListener( orig
, handler
, true );
8339 dataPriv
.remove( doc
, fix
);
8342 dataPriv
.access( doc
, fix
, attaches
);
8348 var location
= window
.location
;
8350 var nonce
= jQuery
.now();
8352 var rquery
= ( /\?/ );
8356 // Cross-browser xml parsing
8357 jQuery
.parseXML = function( data
) {
8359 if ( !data
|| typeof data
!== "string" ) {
8363 // Support: IE 9 - 11 only
8364 // IE throws on parseFromString with invalid input.
8366 xml
= ( new window
.DOMParser() ).parseFromString( data
, "text/xml" );
8371 if ( !xml
|| xml
.getElementsByTagName( "parsererror" ).length
) {
8372 jQuery
.error( "Invalid XML: " + data
);
8381 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
8382 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
8384 function buildParams( prefix
, obj
, traditional
, add
) {
8387 if ( Array
.isArray( obj
) ) {
8389 // Serialize array item.
8390 jQuery
.each( obj
, function( i
, v
) {
8391 if ( traditional
|| rbracket
.test( prefix
) ) {
8393 // Treat each array item as a scalar.
8398 // Item is non-scalar (array or object), encode its numeric index.
8400 prefix
+ "[" + ( typeof v
=== "object" && v
!= null ? i
: "" ) + "]",
8408 } else if ( !traditional
&& jQuery
.type( obj
) === "object" ) {
8410 // Serialize object item.
8411 for ( name
in obj
) {
8412 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
8417 // Serialize scalar item.
8422 // Serialize an array of form elements or a set of
8423 // key/values into a query string
8424 jQuery
.param = function( a
, traditional
) {
8427 add = function( key
, valueOrFunction
) {
8429 // If value is a function, invoke it and use its return value
8430 var value
= jQuery
.isFunction( valueOrFunction
) ?
8434 s
[ s
.length
] = encodeURIComponent( key
) + "=" +
8435 encodeURIComponent( value
== null ? "" : value
);
8438 // If an array was passed in, assume that it is an array of form elements.
8439 if ( Array
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
8441 // Serialize the form elements
8442 jQuery
.each( a
, function() {
8443 add( this.name
, this.value
);
8448 // If traditional, encode the "old" way (the way 1.3.2 or older
8449 // did it), otherwise encode params recursively.
8450 for ( prefix
in a
) {
8451 buildParams( prefix
, a
[ prefix
], traditional
, add
);
8455 // Return the resulting serialization
8456 return s
.join( "&" );
8460 serialize: function() {
8461 return jQuery
.param( this.serializeArray() );
8463 serializeArray: function() {
8464 return this.map( function() {
8466 // Can add propHook for "elements" to filter or add form elements
8467 var elements
= jQuery
.prop( this, "elements" );
8468 return elements
? jQuery
.makeArray( elements
) : this;
8470 .filter( function() {
8471 var type
= this.type
;
8473 // Use .is( ":disabled" ) so that fieldset[disabled] works
8474 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
8475 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
8476 ( this.checked
|| !rcheckableType
.test( type
) );
8478 .map( function( i
, elem
) {
8479 var val
= jQuery( this ).val();
8481 if ( val
== null ) {
8485 if ( Array
.isArray( val
) ) {
8486 return jQuery
.map( val
, function( val
) {
8487 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8491 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8500 rantiCache
= /([?&])_=[^&]*/,
8501 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg,
8503 // #7653, #8125, #8152: local protocol detection
8504 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8505 rnoContent
= /^(?:GET|HEAD)$/,
8506 rprotocol
= /^\/\//,
8509 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8510 * 2) These are called:
8511 * - BEFORE asking for a transport
8512 * - AFTER param serialization (s.data is a string if s.processData is true)
8513 * 3) key is the dataType
8514 * 4) the catchall symbol "*" can be used
8515 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8519 /* Transports bindings
8520 * 1) key is the dataType
8521 * 2) the catchall symbol "*" can be used
8522 * 3) selection will start with transport dataType and THEN go to "*" if needed
8526 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8527 allTypes
= "*/".concat( "*" ),
8529 // Anchor tag for parsing the document origin
8530 originAnchor
= document
.createElement( "a" );
8531 originAnchor
.href
= location
.href
;
8533 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8534 function addToPrefiltersOrTransports( structure
) {
8536 // dataTypeExpression is optional and defaults to "*"
8537 return function( dataTypeExpression
, func
) {
8539 if ( typeof dataTypeExpression
!== "string" ) {
8540 func
= dataTypeExpression
;
8541 dataTypeExpression
= "*";
8546 dataTypes
= dataTypeExpression
.toLowerCase().match( rnothtmlwhite
) || [];
8548 if ( jQuery
.isFunction( func
) ) {
8550 // For each dataType in the dataTypeExpression
8551 while ( ( dataType
= dataTypes
[ i
++ ] ) ) {
8553 // Prepend if requested
8554 if ( dataType
[ 0 ] === "+" ) {
8555 dataType
= dataType
.slice( 1 ) || "*";
8556 ( structure
[ dataType
] = structure
[ dataType
] || [] ).unshift( func
);
8560 ( structure
[ dataType
] = structure
[ dataType
] || [] ).push( func
);
8567 // Base inspection function for prefilters and transports
8568 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
8571 seekingTransport
= ( structure
=== transports
);
8573 function inspect( dataType
) {
8575 inspected
[ dataType
] = true;
8576 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
8577 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
8578 if ( typeof dataTypeOrTransport
=== "string" &&
8579 !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
8581 options
.dataTypes
.unshift( dataTypeOrTransport
);
8582 inspect( dataTypeOrTransport
);
8584 } else if ( seekingTransport
) {
8585 return !( selected
= dataTypeOrTransport
);
8591 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
8594 // A special extend for ajax options
8595 // that takes "flat" options (not to be deep extended)
8597 function ajaxExtend( target
, src
) {
8599 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
8601 for ( key
in src
) {
8602 if ( src
[ key
] !== undefined ) {
8603 ( flatOptions
[ key
] ? target
: ( deep
|| ( deep
= {} ) ) )[ key
] = src
[ key
];
8607 jQuery
.extend( true, target
, deep
);
8613 /* Handles responses to an ajax request:
8614 * - finds the right dataType (mediates between content-type and expected dataType)
8615 * - returns the corresponding response
8617 function ajaxHandleResponses( s
, jqXHR
, responses
) {
8619 var ct
, type
, finalDataType
, firstDataType
,
8620 contents
= s
.contents
,
8621 dataTypes
= s
.dataTypes
;
8623 // Remove auto dataType and get content-type in the process
8624 while ( dataTypes
[ 0 ] === "*" ) {
8626 if ( ct
=== undefined ) {
8627 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "Content-Type" );
8631 // Check if we're dealing with a known content-type
8633 for ( type
in contents
) {
8634 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
8635 dataTypes
.unshift( type
);
8641 // Check to see if we have a response for the expected dataType
8642 if ( dataTypes
[ 0 ] in responses
) {
8643 finalDataType
= dataTypes
[ 0 ];
8646 // Try convertible dataTypes
8647 for ( type
in responses
) {
8648 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[ 0 ] ] ) {
8649 finalDataType
= type
;
8652 if ( !firstDataType
) {
8653 firstDataType
= type
;
8657 // Or just use first one
8658 finalDataType
= finalDataType
|| firstDataType
;
8661 // If we found a dataType
8662 // We add the dataType to the list if needed
8663 // and return the corresponding response
8664 if ( finalDataType
) {
8665 if ( finalDataType
!== dataTypes
[ 0 ] ) {
8666 dataTypes
.unshift( finalDataType
);
8668 return responses
[ finalDataType
];
8672 /* Chain conversions given the request and the original response
8673 * Also sets the responseXXX fields on the jqXHR instance
8675 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
8676 var conv2
, current
, conv
, tmp
, prev
,
8679 // Work with a copy of dataTypes in case we need to modify it for conversion
8680 dataTypes
= s
.dataTypes
.slice();
8682 // Create converters map with lowercased keys
8683 if ( dataTypes
[ 1 ] ) {
8684 for ( conv
in s
.converters
) {
8685 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
8689 current
= dataTypes
.shift();
8691 // Convert to each sequential dataType
8694 if ( s
.responseFields
[ current
] ) {
8695 jqXHR
[ s
.responseFields
[ current
] ] = response
;
8698 // Apply the dataFilter if provided
8699 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
8700 response
= s
.dataFilter( response
, s
.dataType
);
8704 current
= dataTypes
.shift();
8708 // There's only work to do if current dataType is non-auto
8709 if ( current
=== "*" ) {
8713 // Convert response if prev dataType is non-auto and differs from current
8714 } else if ( prev
!== "*" && prev
!== current
) {
8716 // Seek a direct converter
8717 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
8719 // If none found, seek a pair
8721 for ( conv2
in converters
) {
8723 // If conv2 outputs current
8724 tmp
= conv2
.split( " " );
8725 if ( tmp
[ 1 ] === current
) {
8727 // If prev can be converted to accepted input
8728 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
8729 converters
[ "* " + tmp
[ 0 ] ];
8732 // Condense equivalence converters
8733 if ( conv
=== true ) {
8734 conv
= converters
[ conv2
];
8736 // Otherwise, insert the intermediate dataType
8737 } else if ( converters
[ conv2
] !== true ) {
8739 dataTypes
.unshift( tmp
[ 1 ] );
8747 // Apply converter (if not an equivalence)
8748 if ( conv
!== true ) {
8750 // Unless errors are allowed to bubble, catch and return them
8751 if ( conv
&& s
.throws ) {
8752 response
= conv( response
);
8755 response
= conv( response
);
8758 state
: "parsererror",
8759 error
: conv
? e
: "No conversion from " + prev
+ " to " + current
8768 return { state
: "success", data
: response
};
8773 // Counter for holding the number of active queries
8776 // Last-Modified header cache for next request
8783 isLocal
: rlocalProtocol
.test( location
.protocol
),
8787 contentType
: "application/x-www-form-urlencoded; charset=UTF-8",
8805 xml
: "application/xml, text/xml",
8806 json
: "application/json, text/javascript"
8817 text
: "responseText",
8818 json
: "responseJSON"
8822 // Keys separate source (or catchall "*") and destination types with a single space
8825 // Convert anything to text
8828 // Text to html (true = no transformation)
8831 // Evaluate text as a json expression
8832 "text json": JSON
.parse
,
8834 // Parse text as xml
8835 "text xml": jQuery
.parseXML
8838 // For options that shouldn't be deep extended:
8839 // you can add your own custom options here if
8840 // and when you create one that shouldn't be
8841 // deep extended (see ajaxExtend)
8848 // Creates a full fledged settings object into target
8849 // with both ajaxSettings and settings fields.
8850 // If target is omitted, writes into ajaxSettings.
8851 ajaxSetup: function( target
, settings
) {
8854 // Building a settings object
8855 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
8857 // Extending ajaxSettings
8858 ajaxExtend( jQuery
.ajaxSettings
, target
);
8861 ajaxPrefilter
: addToPrefiltersOrTransports( prefilters
),
8862 ajaxTransport
: addToPrefiltersOrTransports( transports
),
8865 ajax: function( url
, options
) {
8867 // If url is an object, simulate pre-1.5 signature
8868 if ( typeof url
=== "object" ) {
8873 // Force options to be an object
8874 options
= options
|| {};
8878 // URL without anti-cache param
8882 responseHeadersString
,
8891 // Request state (becomes false upon send and true upon completion)
8894 // To know if global events are to be dispatched
8900 // uncached part of the url
8903 // Create the final options object
8904 s
= jQuery
.ajaxSetup( {}, options
),
8906 // Callbacks context
8907 callbackContext
= s
.context
|| s
,
8909 // Context for global events is callbackContext if it is a DOM node or jQuery collection
8910 globalEventContext
= s
.context
&&
8911 ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
8912 jQuery( callbackContext
) :
8916 deferred
= jQuery
.Deferred(),
8917 completeDeferred
= jQuery
.Callbacks( "once memory" ),
8919 // Status-dependent callbacks
8920 statusCode
= s
.statusCode
|| {},
8922 // Headers (they are sent all at once)
8923 requestHeaders
= {},
8924 requestHeadersNames
= {},
8926 // Default abort message
8927 strAbort
= "canceled",
8933 // Builds headers hashtable if needed
8934 getResponseHeader: function( key
) {
8937 if ( !responseHeaders
) {
8938 responseHeaders
= {};
8939 while ( ( match
= rheaders
.exec( responseHeadersString
) ) ) {
8940 responseHeaders
[ match
[ 1 ].toLowerCase() ] = match
[ 2 ];
8943 match
= responseHeaders
[ key
.toLowerCase() ];
8945 return match
== null ? null : match
;
8949 getAllResponseHeaders: function() {
8950 return completed
? responseHeadersString
: null;
8953 // Caches the header
8954 setRequestHeader: function( name
, value
) {
8955 if ( completed
== null ) {
8956 name
= requestHeadersNames
[ name
.toLowerCase() ] =
8957 requestHeadersNames
[ name
.toLowerCase() ] || name
;
8958 requestHeaders
[ name
] = value
;
8963 // Overrides response content-type header
8964 overrideMimeType: function( type
) {
8965 if ( completed
== null ) {
8971 // Status-dependent callbacks
8972 statusCode: function( map
) {
8977 // Execute the appropriate callbacks
8978 jqXHR
.always( map
[ jqXHR
.status
] );
8981 // Lazy-add the new callbacks in a way that preserves old ones
8982 for ( code
in map
) {
8983 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
8990 // Cancel the request
8991 abort: function( statusText
) {
8992 var finalText
= statusText
|| strAbort
;
8994 transport
.abort( finalText
);
8996 done( 0, finalText
);
9002 deferred
.promise( jqXHR
);
9004 // Add protocol if not provided (prefilters might expect it)
9005 // Handle falsy url in the settings object (#10093: consistency with old signature)
9006 // We also use the url parameter if available
9007 s
.url
= ( ( url
|| s
.url
|| location
.href
) + "" )
9008 .replace( rprotocol
, location
.protocol
+ "//" );
9010 // Alias method option to type as per ticket #12004
9011 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
9013 // Extract dataTypes list
9014 s
.dataTypes
= ( s
.dataType
|| "*" ).toLowerCase().match( rnothtmlwhite
) || [ "" ];
9016 // A cross-domain request is in order when the origin doesn't match the current origin.
9017 if ( s
.crossDomain
== null ) {
9018 urlAnchor
= document
.createElement( "a" );
9020 // Support: IE <=8 - 11, Edge 12 - 13
9021 // IE throws exception on accessing the href property if url is malformed,
9022 // e.g. http://example.com:80x/
9024 urlAnchor
.href
= s
.url
;
9026 // Support: IE <=8 - 11 only
9027 // Anchor's host property isn't correctly set when s.url is relative
9028 urlAnchor
.href
= urlAnchor
.href
;
9029 s
.crossDomain
= originAnchor
.protocol
+ "//" + originAnchor
.host
!==
9030 urlAnchor
.protocol
+ "//" + urlAnchor
.host
;
9033 // If there is an error parsing the URL, assume it is crossDomain,
9034 // it can be rejected by the transport if it is invalid
9035 s
.crossDomain
= true;
9039 // Convert data if not already a string
9040 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
9041 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
9045 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
9047 // If request was aborted inside a prefilter, stop there
9052 // We can fire global events as of now if asked to
9053 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9054 fireGlobals
= jQuery
.event
&& s
.global
;
9056 // Watch for a new set of requests
9057 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
9058 jQuery
.event
.trigger( "ajaxStart" );
9061 // Uppercase the type
9062 s
.type
= s
.type
.toUpperCase();
9064 // Determine if request has content
9065 s
.hasContent
= !rnoContent
.test( s
.type
);
9067 // Save the URL in case we're toying with the If-Modified-Since
9068 // and/or If-None-Match header later on
9069 // Remove hash to simplify url manipulation
9070 cacheURL
= s
.url
.replace( rhash
, "" );
9072 // More options handling for requests with no content
9073 if ( !s
.hasContent
) {
9075 // Remember the hash so we can put it back
9076 uncached
= s
.url
.slice( cacheURL
.length
);
9078 // If data is available, append data to url
9080 cacheURL
+= ( rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
;
9082 // #9682: remove data so that it's not used in an eventual retry
9086 // Add or update anti-cache param if needed
9087 if ( s
.cache
=== false ) {
9088 cacheURL
= cacheURL
.replace( rantiCache
, "$1" );
9089 uncached
= ( rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + ( nonce
++ ) + uncached
;
9092 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9093 s
.url
= cacheURL
+ uncached
;
9095 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9096 } else if ( s
.data
&& s
.processData
&&
9097 ( s
.contentType
|| "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9098 s
.data
= s
.data
.replace( r20
, "+" );
9101 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9102 if ( s
.ifModified
) {
9103 if ( jQuery
.lastModified
[ cacheURL
] ) {
9104 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
9106 if ( jQuery
.etag
[ cacheURL
] ) {
9107 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
9111 // Set the correct header, if data is being sent
9112 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
9113 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
9116 // Set the Accepts header for the server, depending on the dataType
9117 jqXHR
.setRequestHeader(
9119 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[ 0 ] ] ?
9120 s
.accepts
[ s
.dataTypes
[ 0 ] ] +
9121 ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
9125 // Check for headers option
9126 for ( i
in s
.headers
) {
9127 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
9130 // Allow custom headers/mimetypes and early abort
9131 if ( s
.beforeSend
&&
9132 ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || completed
) ) {
9134 // Abort if not done already and return
9135 return jqXHR
.abort();
9138 // Aborting is no longer a cancellation
9141 // Install callbacks on deferreds
9142 completeDeferred
.add( s
.complete
);
9143 jqXHR
.done( s
.success
);
9144 jqXHR
.fail( s
.error
);
9147 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
9149 // If no transport, we auto-abort
9151 done( -1, "No Transport" );
9153 jqXHR
.readyState
= 1;
9155 // Send global event
9156 if ( fireGlobals
) {
9157 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
9160 // If request was aborted inside ajaxSend, stop there
9166 if ( s
.async
&& s
.timeout
> 0 ) {
9167 timeoutTimer
= window
.setTimeout( function() {
9168 jqXHR
.abort( "timeout" );
9174 transport
.send( requestHeaders
, done
);
9177 // Rethrow post-completion exceptions
9182 // Propagate others as results
9187 // Callback for when everything is done
9188 function done( status
, nativeStatusText
, responses
, headers
) {
9189 var isSuccess
, success
, error
, response
, modified
,
9190 statusText
= nativeStatusText
;
9192 // Ignore repeat invocations
9199 // Clear timeout if it exists
9200 if ( timeoutTimer
) {
9201 window
.clearTimeout( timeoutTimer
);
9204 // Dereference transport for early garbage collection
9205 // (no matter how long the jqXHR object will be used)
9206 transport
= undefined;
9208 // Cache response headers
9209 responseHeadersString
= headers
|| "";
9212 jqXHR
.readyState
= status
> 0 ? 4 : 0;
9214 // Determine if successful
9215 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
9217 // Get response data
9219 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
9222 // Convert no matter what (that way responseXXX fields are always set)
9223 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
9225 // If successful, handle type chaining
9228 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9229 if ( s
.ifModified
) {
9230 modified
= jqXHR
.getResponseHeader( "Last-Modified" );
9232 jQuery
.lastModified
[ cacheURL
] = modified
;
9234 modified
= jqXHR
.getResponseHeader( "etag" );
9236 jQuery
.etag
[ cacheURL
] = modified
;
9241 if ( status
=== 204 || s
.type
=== "HEAD" ) {
9242 statusText
= "nocontent";
9245 } else if ( status
=== 304 ) {
9246 statusText
= "notmodified";
9248 // If we have data, let's convert it
9250 statusText
= response
.state
;
9251 success
= response
.data
;
9252 error
= response
.error
;
9257 // Extract error from statusText and normalize for non-aborts
9259 if ( status
|| !statusText
) {
9260 statusText
= "error";
9267 // Set data for the fake xhr object
9268 jqXHR
.status
= status
;
9269 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
9273 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
9275 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
9278 // Status-dependent callbacks
9279 jqXHR
.statusCode( statusCode
);
9280 statusCode
= undefined;
9282 if ( fireGlobals
) {
9283 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
9284 [ jqXHR
, s
, isSuccess
? success
: error
] );
9288 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
9290 if ( fireGlobals
) {
9291 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
9293 // Handle the global AJAX counter
9294 if ( !( --jQuery
.active
) ) {
9295 jQuery
.event
.trigger( "ajaxStop" );
9303 getJSON: function( url
, data
, callback
) {
9304 return jQuery
.get( url
, data
, callback
, "json" );
9307 getScript: function( url
, callback
) {
9308 return jQuery
.get( url
, undefined, callback
, "script" );
9312 jQuery
.each( [ "get", "post" ], function( i
, method
) {
9313 jQuery
[ method
] = function( url
, data
, callback
, type
) {
9315 // Shift arguments if data argument was omitted
9316 if ( jQuery
.isFunction( data
) ) {
9317 type
= type
|| callback
;
9322 // The url can be an options object (which then must have .url)
9323 return jQuery
.ajax( jQuery
.extend( {
9329 }, jQuery
.isPlainObject( url
) && url
) );
9334 jQuery
._evalUrl = function( url
) {
9335 return jQuery
.ajax( {
9338 // Make this explicit, since user can override this through ajaxSetup (#11264)
9350 wrapAll: function( html
) {
9354 if ( jQuery
.isFunction( html
) ) {
9355 html
= html
.call( this[ 0 ] );
9358 // The elements to wrap the target around
9359 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
9361 if ( this[ 0 ].parentNode
) {
9362 wrap
.insertBefore( this[ 0 ] );
9365 wrap
.map( function() {
9368 while ( elem
.firstElementChild
) {
9369 elem
= elem
.firstElementChild
;
9379 wrapInner: function( html
) {
9380 if ( jQuery
.isFunction( html
) ) {
9381 return this.each( function( i
) {
9382 jQuery( this ).wrapInner( html
.call( this, i
) );
9386 return this.each( function() {
9387 var self
= jQuery( this ),
9388 contents
= self
.contents();
9390 if ( contents
.length
) {
9391 contents
.wrapAll( html
);
9394 self
.append( html
);
9399 wrap: function( html
) {
9400 var isFunction
= jQuery
.isFunction( html
);
9402 return this.each( function( i
) {
9403 jQuery( this ).wrapAll( isFunction
? html
.call( this, i
) : html
);
9407 unwrap: function( selector
) {
9408 this.parent( selector
).not( "body" ).each( function() {
9409 jQuery( this ).replaceWith( this.childNodes
);
9416 jQuery
.expr
.pseudos
.hidden = function( elem
) {
9417 return !jQuery
.expr
.pseudos
.visible( elem
);
9419 jQuery
.expr
.pseudos
.visible = function( elem
) {
9420 return !!( elem
.offsetWidth
|| elem
.offsetHeight
|| elem
.getClientRects().length
);
9426 jQuery
.ajaxSettings
.xhr = function() {
9428 return new window
.XMLHttpRequest();
9432 var xhrSuccessStatus
= {
9434 // File protocol always yields status code 0, assume 200
9437 // Support: IE <=9 only
9438 // #1450: sometimes IE returns 1223 when it should be 204
9441 xhrSupported
= jQuery
.ajaxSettings
.xhr();
9443 support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
9444 support
.ajax
= xhrSupported
= !!xhrSupported
;
9446 jQuery
.ajaxTransport( function( options
) {
9447 var callback
, errorCallback
;
9449 // Cross domain only allowed if supported through XMLHttpRequest
9450 if ( support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
9452 send: function( headers
, complete
) {
9454 xhr
= options
.xhr();
9464 // Apply custom fields if provided
9465 if ( options
.xhrFields
) {
9466 for ( i
in options
.xhrFields
) {
9467 xhr
[ i
] = options
.xhrFields
[ i
];
9471 // Override mime type if needed
9472 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
9473 xhr
.overrideMimeType( options
.mimeType
);
9476 // X-Requested-With header
9477 // For cross-domain requests, seeing as conditions for a preflight are
9478 // akin to a jigsaw puzzle, we simply never set it to be sure.
9479 // (it can always be set on a per-request basis or even using ajaxSetup)
9480 // For same-domain requests, won't change header if already provided.
9481 if ( !options
.crossDomain
&& !headers
[ "X-Requested-With" ] ) {
9482 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
9486 for ( i
in headers
) {
9487 xhr
.setRequestHeader( i
, headers
[ i
] );
9491 callback = function( type
) {
9494 callback
= errorCallback
= xhr
.onload
=
9495 xhr
.onerror
= xhr
.onabort
= xhr
.onreadystatechange
= null;
9497 if ( type
=== "abort" ) {
9499 } else if ( type
=== "error" ) {
9501 // Support: IE <=9 only
9502 // On a manual native abort, IE9 throws
9503 // errors on any property access that is not readyState
9504 if ( typeof xhr
.status
!== "number" ) {
9505 complete( 0, "error" );
9509 // File: protocol always yields status 0; see #8605, #14207
9516 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
9519 // Support: IE <=9 only
9520 // IE9 has no XHR2 but throws on binary (trac-11426)
9521 // For XHR2 non-text, let the caller handle it (gh-2498)
9522 ( xhr
.responseType
|| "text" ) !== "text" ||
9523 typeof xhr
.responseText
!== "string" ?
9524 { binary
: xhr
.response
} :
9525 { text
: xhr
.responseText
},
9526 xhr
.getAllResponseHeaders()
9534 xhr
.onload
= callback();
9535 errorCallback
= xhr
.onerror
= callback( "error" );
9537 // Support: IE 9 only
9538 // Use onreadystatechange to replace onabort
9539 // to handle uncaught aborts
9540 if ( xhr
.onabort
!== undefined ) {
9541 xhr
.onabort
= errorCallback
;
9543 xhr
.onreadystatechange = function() {
9545 // Check readyState before timeout as it changes
9546 if ( xhr
.readyState
=== 4 ) {
9548 // Allow onerror to be called first,
9549 // but that will not handle a native abort
9550 // Also, save errorCallback to a variable
9551 // as xhr.onerror cannot be accessed
9552 window
.setTimeout( function() {
9561 // Create the abort callback
9562 callback
= callback( "abort" );
9566 // Do send the request (this may raise an exception)
9567 xhr
.send( options
.hasContent
&& options
.data
|| null );
9570 // #14683: Only rethrow if this hasn't been notified as an error yet
9589 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
9590 jQuery
.ajaxPrefilter( function( s
) {
9591 if ( s
.crossDomain
) {
9592 s
.contents
.script
= false;
9596 // Install script dataType
9599 script
: "text/javascript, application/javascript, " +
9600 "application/ecmascript, application/x-ecmascript"
9603 script
: /\b(?:java|ecma)script\b/
9606 "text script": function( text
) {
9607 jQuery
.globalEval( text
);
9613 // Handle cache's special case and crossDomain
9614 jQuery
.ajaxPrefilter( "script", function( s
) {
9615 if ( s
.cache
=== undefined ) {
9618 if ( s
.crossDomain
) {
9623 // Bind script tag hack transport
9624 jQuery
.ajaxTransport( "script", function( s
) {
9626 // This transport only deals with cross domain requests
9627 if ( s
.crossDomain
) {
9628 var script
, callback
;
9630 send: function( _
, complete
) {
9631 script
= jQuery( "<script>" ).prop( {
9632 charset
: s
.scriptCharset
,
9636 callback = function( evt
) {
9640 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
9645 // Use native DOM manipulation to avoid our domManip AJAX trickery
9646 document
.head
.appendChild( script
[ 0 ] );
9660 var oldCallbacks
= [],
9661 rjsonp
= /(=)\?(?=&|$)|\?\?/;
9663 // Default jsonp settings
9666 jsonpCallback: function() {
9667 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
++ ) );
9668 this[ callback
] = true;
9673 // Detect, normalize options and install callbacks for jsonp requests
9674 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
9676 var callbackName
, overwritten
, responseContainer
,
9677 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
9679 typeof s
.data
=== "string" &&
9680 ( s
.contentType
|| "" )
9681 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
9682 rjsonp
.test( s
.data
) && "data"
9685 // Handle iff the expected data type is "jsonp" or we have a parameter to set
9686 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
9688 // Get callback name, remembering preexisting value associated with it
9689 callbackName
= s
.jsonpCallback
= jQuery
.isFunction( s
.jsonpCallback
) ?
9693 // Insert callback into url or form data
9695 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
9696 } else if ( s
.jsonp
!== false ) {
9697 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
9700 // Use data converter to retrieve json after script execution
9701 s
.converters
[ "script json" ] = function() {
9702 if ( !responseContainer
) {
9703 jQuery
.error( callbackName
+ " was not called" );
9705 return responseContainer
[ 0 ];
9708 // Force json dataType
9709 s
.dataTypes
[ 0 ] = "json";
9712 overwritten
= window
[ callbackName
];
9713 window
[ callbackName
] = function() {
9714 responseContainer
= arguments
;
9717 // Clean-up function (fires after converters)
9718 jqXHR
.always( function() {
9720 // If previous value didn't exist - remove it
9721 if ( overwritten
=== undefined ) {
9722 jQuery( window
).removeProp( callbackName
);
9724 // Otherwise restore preexisting value
9726 window
[ callbackName
] = overwritten
;
9729 // Save back as free
9730 if ( s
[ callbackName
] ) {
9732 // Make sure that re-using the options doesn't screw things around
9733 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
9735 // Save the callback name for future use
9736 oldCallbacks
.push( callbackName
);
9739 // Call if it was a function and we have a response
9740 if ( responseContainer
&& jQuery
.isFunction( overwritten
) ) {
9741 overwritten( responseContainer
[ 0 ] );
9744 responseContainer
= overwritten
= undefined;
9747 // Delegate to script
9755 // Support: Safari 8 only
9756 // In Safari 8 documents created via document.implementation.createHTMLDocument
9757 // collapse sibling forms: the second one becomes a child of the first one.
9758 // Because of that, this security measure has to be disabled in Safari 8.
9759 // https://bugs.webkit.org/show_bug.cgi?id=137337
9760 support
.createHTMLDocument
= ( function() {
9761 var body
= document
.implementation
.createHTMLDocument( "" ).body
;
9762 body
.innerHTML
= "<form></form><form></form>";
9763 return body
.childNodes
.length
=== 2;
9767 // Argument "data" should be string of html
9768 // context (optional): If specified, the fragment will be created in this context,
9769 // defaults to document
9770 // keepScripts (optional): If true, will include scripts passed in the html string
9771 jQuery
.parseHTML = function( data
, context
, keepScripts
) {
9772 if ( typeof data
!== "string" ) {
9775 if ( typeof context
=== "boolean" ) {
9776 keepScripts
= context
;
9780 var base
, parsed
, scripts
;
9784 // Stop scripts or inline event handlers from being executed immediately
9785 // by using document.implementation
9786 if ( support
.createHTMLDocument
) {
9787 context
= document
.implementation
.createHTMLDocument( "" );
9789 // Set the base href for the created document
9790 // so any parsed elements with URLs
9791 // are based on the document's URL (gh-2965)
9792 base
= context
.createElement( "base" );
9793 base
.href
= document
.location
.href
;
9794 context
.head
.appendChild( base
);
9800 parsed
= rsingleTag
.exec( data
);
9801 scripts
= !keepScripts
&& [];
9805 return [ context
.createElement( parsed
[ 1 ] ) ];
9808 parsed
= buildFragment( [ data
], context
, scripts
);
9810 if ( scripts
&& scripts
.length
) {
9811 jQuery( scripts
).remove();
9814 return jQuery
.merge( [], parsed
.childNodes
);
9819 * Load a url into a page
9821 jQuery
.fn
.load = function( url
, params
, callback
) {
9822 var selector
, type
, response
,
9824 off
= url
.indexOf( " " );
9827 selector
= stripAndCollapse( url
.slice( off
) );
9828 url
= url
.slice( 0, off
);
9831 // If it's a function
9832 if ( jQuery
.isFunction( params
) ) {
9834 // We assume that it's the callback
9838 // Otherwise, build a param string
9839 } else if ( params
&& typeof params
=== "object" ) {
9843 // If we have elements to modify, make the request
9844 if ( self
.length
> 0 ) {
9848 // If "type" variable is undefined, then "GET" method will be used.
9849 // Make value of this field explicit since
9850 // user can override it through ajaxSetup method
9851 type
: type
|| "GET",
9854 } ).done( function( responseText
) {
9856 // Save response for use in complete callback
9857 response
= arguments
;
9859 self
.html( selector
?
9861 // If a selector was specified, locate the right elements in a dummy div
9862 // Exclude scripts to avoid IE 'Permission Denied' errors
9863 jQuery( "<div>" ).append( jQuery
.parseHTML( responseText
) ).find( selector
) :
9865 // Otherwise use the full result
9868 // If the request succeeds, this function gets "data", "status", "jqXHR"
9869 // but they are ignored because response was set above.
9870 // If it fails, this function gets "jqXHR", "status", "error"
9871 } ).always( callback
&& function( jqXHR
, status
) {
9872 self
.each( function() {
9873 callback
.apply( this, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
9884 // Attach a bunch of functions for handling common AJAX events
9892 ], function( i
, type
) {
9893 jQuery
.fn
[ type
] = function( fn
) {
9894 return this.on( type
, fn
);
9901 jQuery
.expr
.pseudos
.animated = function( elem
) {
9902 return jQuery
.grep( jQuery
.timers
, function( fn
) {
9903 return elem
=== fn
.elem
;
9911 setOffset: function( elem
, options
, i
) {
9912 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
9913 position
= jQuery
.css( elem
, "position" ),
9914 curElem
= jQuery( elem
),
9917 // Set position first, in-case top/left are set even on static elem
9918 if ( position
=== "static" ) {
9919 elem
.style
.position
= "relative";
9922 curOffset
= curElem
.offset();
9923 curCSSTop
= jQuery
.css( elem
, "top" );
9924 curCSSLeft
= jQuery
.css( elem
, "left" );
9925 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) &&
9926 ( curCSSTop
+ curCSSLeft
).indexOf( "auto" ) > -1;
9928 // Need to be able to calculate position if either
9929 // top or left is auto and position is either absolute or fixed
9930 if ( calculatePosition
) {
9931 curPosition
= curElem
.position();
9932 curTop
= curPosition
.top
;
9933 curLeft
= curPosition
.left
;
9936 curTop
= parseFloat( curCSSTop
) || 0;
9937 curLeft
= parseFloat( curCSSLeft
) || 0;
9940 if ( jQuery
.isFunction( options
) ) {
9942 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
9943 options
= options
.call( elem
, i
, jQuery
.extend( {}, curOffset
) );
9946 if ( options
.top
!= null ) {
9947 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
9949 if ( options
.left
!= null ) {
9950 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
9953 if ( "using" in options
) {
9954 options
.using
.call( elem
, props
);
9957 curElem
.css( props
);
9963 offset: function( options
) {
9965 // Preserve chaining for setter
9966 if ( arguments
.length
) {
9967 return options
=== undefined ?
9969 this.each( function( i
) {
9970 jQuery
.offset
.setOffset( this, options
, i
);
9974 var doc
, docElem
, rect
, win
,
9981 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
9982 // Support: IE <=11 only
9983 // Running getBoundingClientRect on a
9984 // disconnected node in IE throws an error
9985 if ( !elem
.getClientRects().length
) {
9986 return { top
: 0, left
: 0 };
9989 rect
= elem
.getBoundingClientRect();
9991 doc
= elem
.ownerDocument
;
9992 docElem
= doc
.documentElement
;
9993 win
= doc
.defaultView
;
9996 top
: rect
.top
+ win
.pageYOffset
- docElem
.clientTop
,
9997 left
: rect
.left
+ win
.pageXOffset
- docElem
.clientLeft
10001 position: function() {
10002 if ( !this[ 0 ] ) {
10006 var offsetParent
, offset
,
10008 parentOffset
= { top
: 0, left
: 0 };
10010 // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
10011 // because it is its only offset parent
10012 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
10014 // Assume getBoundingClientRect is there when computed position is fixed
10015 offset
= elem
.getBoundingClientRect();
10019 // Get *real* offsetParent
10020 offsetParent
= this.offsetParent();
10022 // Get correct offsets
10023 offset
= this.offset();
10024 if ( !nodeName( offsetParent
[ 0 ], "html" ) ) {
10025 parentOffset
= offsetParent
.offset();
10028 // Add offsetParent borders
10030 top
: parentOffset
.top
+ jQuery
.css( offsetParent
[ 0 ], "borderTopWidth", true ),
10031 left
: parentOffset
.left
+ jQuery
.css( offsetParent
[ 0 ], "borderLeftWidth", true )
10035 // Subtract parent offsets and element margins
10037 top
: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
10038 left
: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
10042 // This method will return documentElement in the following cases:
10043 // 1) For the element inside the iframe without offsetParent, this method will return
10044 // documentElement of the parent window
10045 // 2) For the hidden or detached element
10046 // 3) For body or html element, i.e. in case of the html node - it will return itself
10048 // but those exceptions were never presented as a real life use-cases
10049 // and might be considered as more preferable results.
10051 // This logic, however, is not guaranteed and can change at any point in the future
10052 offsetParent: function() {
10053 return this.map( function() {
10054 var offsetParent
= this.offsetParent
;
10056 while ( offsetParent
&& jQuery
.css( offsetParent
, "position" ) === "static" ) {
10057 offsetParent
= offsetParent
.offsetParent
;
10060 return offsetParent
|| documentElement
;
10065 // Create scrollLeft and scrollTop methods
10066 jQuery
.each( { scrollLeft
: "pageXOffset", scrollTop
: "pageYOffset" }, function( method
, prop
) {
10067 var top
= "pageYOffset" === prop
;
10069 jQuery
.fn
[ method
] = function( val
) {
10070 return access( this, function( elem
, method
, val
) {
10072 // Coalesce documents and windows
10074 if ( jQuery
.isWindow( elem
) ) {
10076 } else if ( elem
.nodeType
=== 9 ) {
10077 win
= elem
.defaultView
;
10080 if ( val
=== undefined ) {
10081 return win
? win
[ prop
] : elem
[ method
];
10086 !top
? val
: win
.pageXOffset
,
10087 top
? val
: win
.pageYOffset
10091 elem
[ method
] = val
;
10093 }, method
, val
, arguments
.length
);
10097 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10098 // Add the top/left cssHooks using jQuery.fn.position
10099 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10100 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10101 // getComputedStyle returns percent when specified for top/left/bottom/right;
10102 // rather than make the css module depend on the offset module, just check for it here
10103 jQuery
.each( [ "top", "left" ], function( i
, prop
) {
10104 jQuery
.cssHooks
[ prop
] = addGetHookIf( support
.pixelPosition
,
10105 function( elem
, computed
) {
10107 computed
= curCSS( elem
, prop
);
10109 // If curCSS returns percentage, fallback to offset
10110 return rnumnonpx
.test( computed
) ?
10111 jQuery( elem
).position()[ prop
] + "px" :
10119 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10120 jQuery
.each( { Height
: "height", Width
: "width" }, function( name
, type
) {
10121 jQuery
.each( { padding
: "inner" + name
, content
: type
, "": "outer" + name
},
10122 function( defaultExtra
, funcName
) {
10124 // Margin is only for outerHeight, outerWidth
10125 jQuery
.fn
[ funcName
] = function( margin
, value
) {
10126 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
10127 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
10129 return access( this, function( elem
, type
, value
) {
10132 if ( jQuery
.isWindow( elem
) ) {
10134 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10135 return funcName
.indexOf( "outer" ) === 0 ?
10136 elem
[ "inner" + name
] :
10137 elem
.document
.documentElement
[ "client" + name
];
10140 // Get document width or height
10141 if ( elem
.nodeType
=== 9 ) {
10142 doc
= elem
.documentElement
;
10144 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10145 // whichever is greatest
10147 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
10148 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
10149 doc
[ "client" + name
]
10153 return value
=== undefined ?
10155 // Get width or height on the element, requesting but not forcing parseFloat
10156 jQuery
.css( elem
, type
, extra
) :
10158 // Set width or height on the element
10159 jQuery
.style( elem
, type
, value
, extra
);
10160 }, type
, chainable
? margin
: undefined, chainable
);
10166 jQuery
.fn
.extend( {
10168 bind: function( types
, data
, fn
) {
10169 return this.on( types
, null, data
, fn
);
10171 unbind: function( types
, fn
) {
10172 return this.off( types
, null, fn
);
10175 delegate: function( selector
, types
, data
, fn
) {
10176 return this.on( types
, selector
, data
, fn
);
10178 undelegate: function( selector
, types
, fn
) {
10180 // ( namespace ) or ( selector, types [, fn] )
10181 return arguments
.length
=== 1 ?
10182 this.off( selector
, "**" ) :
10183 this.off( types
, selector
|| "**", fn
);
10187 jQuery
.holdReady = function( hold
) {
10189 jQuery
.readyWait
++;
10191 jQuery
.ready( true );
10194 jQuery
.isArray
= Array
.isArray
;
10195 jQuery
.parseJSON
= JSON
.parse
;
10196 jQuery
.nodeName
= nodeName
;
10201 // Register as a named AMD module, since jQuery can be concatenated with other
10202 // files that may use define, but not via a proper concatenation script that
10203 // understands anonymous AMD modules. A named AMD is safest and most robust
10204 // way to register. Lowercase jquery is used because AMD module names are
10205 // derived from file names, and jQuery is normally delivered in a lowercase
10206 // file name. Do this after creating the global so that if an AMD module wants
10207 // to call noConflict to hide this version of jQuery, it will work.
10209 // Note that for maximum portability, libraries that are not jQuery should
10210 // declare themselves as anonymous modules, and avoid setting a global if an
10211 // AMD loader is present. jQuery is a special case. For more information, see
10212 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10214 if ( typeof define
=== "function" && define
.amd
) {
10215 define( "jquery", [], function() {
10225 // Map over jQuery in case of overwrite
10226 _jQuery
= window
.jQuery
,
10228 // Map over the $ in case of overwrite
10231 jQuery
.noConflict = function( deep
) {
10232 if ( window
.$ === jQuery
) {
10236 if ( deep
&& window
.jQuery
=== jQuery
) {
10237 window
.jQuery
= _jQuery
;
10243 // Expose jQuery and $ identifiers, even in AMD
10244 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10245 // and CommonJS for browser emulators (#13566)
10247 window
.jQuery
= window
.$ = jQuery
;