2 * jQuery JavaScript Library v3.7.1
5 * Copyright OpenJS Foundation and other contributors
6 * Released under the MIT license
7 * https://jquery.org/license
9 * Date: 2023-08-28T13:37Z
11 ( function( global, factory ) {
15 if ( typeof module === "object" && typeof module.exports === "object" ) {
17 // For CommonJS and CommonJS-like environments where a proper `window`
18 // is present, execute the factory and get jQuery.
19 // For environments that do not have a `window` with a `document`
20 // (such as Node.js), expose a factory as module.exports.
21 // This accentuates the need for the creation of a real `window`.
22 // e.g. var jQuery = require("jquery")(window);
23 // See ticket trac-14549 for more info.
24 module.exports = global.document ?
25 factory( global, true ) :
28 throw new Error( "jQuery requires a window with a document" );
36 // Pass this if window is not defined yet
37 } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
39 // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
40 // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
41 // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
42 // enough that all such attempts are guarded in a try block.
47 var getProto = Object.getPrototypeOf;
49 var slice = arr.slice;
51 var flat = arr.flat ? function( array ) {
52 return arr.flat.call( array );
53 } : function( array ) {
54 return arr.concat.apply( [], array );
60 var indexOf = arr.indexOf;
64 var toString = class2type.toString;
66 var hasOwn = class2type.hasOwnProperty;
68 var fnToString = hasOwn.toString;
70 var ObjectFunctionString = fnToString.call( Object );
74 var isFunction = function isFunction( obj ) {
76 // Support: Chrome <=57, Firefox <=52
77 // In some browsers, typeof returns "function" for HTML <object> elements
78 // (i.e., `typeof document.createElement( "object" ) === "function"`).
79 // We don't want to classify *any* DOM node as a function.
80 // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5
81 // Plus for old WebKit, typeof returns "function" for HTML collections
82 // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)
83 return typeof obj === "function" && typeof obj.nodeType !== "number" &&
84 typeof obj.item !== "function";
88 var isWindow = function isWindow( obj ) {
89 return obj != null && obj === obj.window;
93 var document = window.document;
97 var preservedScriptAttributes = {
104 function DOMEval( code, node, doc ) {
105 doc = doc || document;
108 script = doc.createElement( "script" );
112 for ( i in preservedScriptAttributes ) {
114 // Support: Firefox 64+, Edge 18+
115 // Some browsers don't support the "nonce" property on scripts.
116 // On the other hand, just using `getAttribute` is not enough as
117 // the `nonce` attribute is reset to an empty string whenever it
118 // becomes browsing-context connected.
119 // See https://github.com/whatwg/html/issues/2369
120 // See https://html.spec.whatwg.org/#nonce-attributes
121 // The `node.getAttribute` check was added for the sake of
122 // `jQuery.globalEval` so that it can fake a nonce-containing node
124 val = node[ i ] || node.getAttribute && node.getAttribute( i );
126 script.setAttribute( i, val );
130 doc.head.appendChild( script ).parentNode.removeChild( script );
134 function toType( obj ) {
139 // Support: Android <=2.3 only (functionish RegExp)
140 return typeof obj === "object" || typeof obj === "function" ?
141 class2type[ toString.call( obj ) ] || "object" :
145 // Defining this global in .eslintrc.json would create a danger of using the global
146 // unguarded in another place, it seems safer to define global only for this module
150 var version = "3.7.1",
152 rhtmlSuffix = /HTML$/i,
154 // Define a local copy of jQuery
155 jQuery = function( selector, context ) {
157 // The jQuery object is actually just the init constructor 'enhanced'
158 // Need init if jQuery is called (just allow error to be thrown if not included)
159 return new jQuery.fn.init( selector, context );
162 jQuery.fn = jQuery.prototype = {
164 // The current version of jQuery being used
169 // The default length of a jQuery object is 0
172 toArray: function() {
173 return slice.call( this );
176 // Get the Nth element in the matched element set OR
177 // Get the whole matched element set as a clean array
178 get: function( num ) {
180 // Return all the elements in a clean array
182 return slice.call( this );
185 // Return just the one element from the set
186 return num < 0 ? this[ num + this.length ] : this[ num ];
189 // Take an array of elements and push it onto the stack
190 // (returning the new matched element set)
191 pushStack: function( elems ) {
193 // Build a new jQuery matched element set
194 var ret = jQuery.merge( this.constructor(), elems );
196 // Add the old object onto the stack (as a reference)
197 ret.prevObject = this;
199 // Return the newly-formed element set
203 // Execute a callback for every element in the matched set.
204 each: function( callback ) {
205 return jQuery.each( this, callback );
208 map: function( callback ) {
209 return this.pushStack( jQuery.map( this, function( elem, i ) {
210 return callback.call( elem, i, elem );
215 return this.pushStack( slice.apply( this, arguments ) );
223 return this.eq( -1 );
227 return this.pushStack( jQuery.grep( this, function( _elem, i ) {
228 return ( i + 1 ) % 2;
233 return this.pushStack( jQuery.grep( this, function( _elem, i ) {
239 var len = this.length,
240 j = +i + ( i < 0 ? len : 0 );
241 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
245 return this.prevObject || this.constructor();
248 // For internal use only.
249 // Behaves like an Array's method, not like a jQuery method.
255 jQuery.extend = jQuery.fn.extend = function() {
256 var options, name, src, copy, copyIsArray, clone,
257 target = arguments[ 0 ] || {},
259 length = arguments.length,
262 // Handle a deep copy situation
263 if ( typeof target === "boolean" ) {
266 // Skip the boolean and the target
267 target = arguments[ i ] || {};
271 // Handle case when target is a string or something (possible in deep copy)
272 if ( typeof target !== "object" && !isFunction( target ) ) {
276 // Extend jQuery itself if only one argument is passed
277 if ( i === length ) {
282 for ( ; i < length; i++ ) {
284 // Only deal with non-null/undefined values
285 if ( ( options = arguments[ i ] ) != null ) {
287 // Extend the base object
288 for ( name in options ) {
289 copy = options[ name ];
291 // Prevent Object.prototype pollution
292 // Prevent never-ending loop
293 if ( name === "__proto__" || target === copy ) {
297 // Recurse if we're merging plain objects or arrays
298 if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
299 ( copyIsArray = Array.isArray( copy ) ) ) ) {
300 src = target[ name ];
302 // Ensure proper type for the source value
303 if ( copyIsArray && !Array.isArray( src ) ) {
305 } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
312 // Never move original objects, clone them
313 target[ name ] = jQuery.extend( deep, clone, copy );
315 // Don't bring in undefined values
316 } else if ( copy !== undefined ) {
317 target[ name ] = copy;
323 // Return the modified object
329 // Unique for each copy of jQuery on the page
330 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
332 // Assume jQuery is ready without the ready module
335 error: function( msg ) {
336 throw new Error( msg );
341 isPlainObject: function( obj ) {
344 // Detect obvious negatives
345 // Use toString instead of jQuery.type to catch host objects
346 if ( !obj || toString.call( obj ) !== "[object Object]" ) {
350 proto = getProto( obj );
352 // Objects with no prototype (e.g., `Object.create( null )`) are plain
357 // Objects with prototype are plain iff they were constructed by a global Object function
358 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
359 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
362 isEmptyObject: function( obj ) {
365 for ( name in obj ) {
371 // Evaluates a script in a provided context; falls back to the global one
373 globalEval: function( code, options, doc ) {
374 DOMEval( code, { nonce: options && options.nonce }, doc );
377 each: function( obj, callback ) {
380 if ( isArrayLike( obj ) ) {
382 for ( ; i < length; i++ ) {
383 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
389 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
399 // Retrieve the text value of an array of DOM nodes
400 text: function( elem ) {
404 nodeType = elem.nodeType;
408 // If no nodeType, this is expected to be an array
409 while ( ( node = elem[ i++ ] ) ) {
411 // Do not traverse comment nodes
412 ret += jQuery.text( node );
415 if ( nodeType === 1 || nodeType === 11 ) {
416 return elem.textContent;
418 if ( nodeType === 9 ) {
419 return elem.documentElement.textContent;
421 if ( nodeType === 3 || nodeType === 4 ) {
422 return elem.nodeValue;
425 // Do not include comment or processing instruction nodes
430 // results is for internal usage only
431 makeArray: function( arr, results ) {
432 var ret = results || [];
435 if ( isArrayLike( Object( arr ) ) ) {
437 typeof arr === "string" ?
441 push.call( ret, arr );
448 inArray: function( elem, arr, i ) {
449 return arr == null ? -1 : indexOf.call( arr, elem, i );
452 isXMLDoc: function( elem ) {
453 var namespace = elem && elem.namespaceURI,
454 docElem = elem && ( elem.ownerDocument || elem ).documentElement;
456 // Assume HTML when documentElement doesn't yet exist, such as inside
457 // document fragments.
458 return !rhtmlSuffix.test( namespace || docElem && docElem.nodeName || "HTML" );
461 // Support: Android <=4.0 only, PhantomJS 1 only
462 // push.apply(_, arraylike) throws on ancient WebKit
463 merge: function( first, second ) {
464 var len = +second.length,
468 for ( ; j < len; j++ ) {
469 first[ i++ ] = second[ j ];
477 grep: function( elems, callback, invert ) {
481 length = elems.length,
482 callbackExpect = !invert;
484 // Go through the array, only saving the items
485 // that pass the validator function
486 for ( ; i < length; i++ ) {
487 callbackInverse = !callback( elems[ i ], i );
488 if ( callbackInverse !== callbackExpect ) {
489 matches.push( elems[ i ] );
496 // arg is for internal usage only
497 map: function( elems, callback, arg ) {
502 // Go through the array, translating each of the items to their new values
503 if ( isArrayLike( elems ) ) {
504 length = elems.length;
505 for ( ; i < length; i++ ) {
506 value = callback( elems[ i ], i, arg );
508 if ( value != null ) {
513 // Go through every key on the object,
516 value = callback( elems[ i ], i, arg );
518 if ( value != null ) {
524 // Flatten any nested arrays
528 // A global GUID counter for objects
531 // jQuery.support is not used in Core but other projects attach their
532 // properties to it so it needs to exist.
536 if ( typeof Symbol === "function" ) {
537 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
540 // Populate the class2type map
541 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
542 function( _i, name ) {
543 class2type[ "[object " + name + "]" ] = name.toLowerCase();
546 function isArrayLike( obj ) {
548 // Support: real iOS 8.2 only (not reproducible in simulator)
549 // `in` check used to prevent JIT error (gh-2145)
550 // hasOwn isn't used here due to false negatives
551 // regarding Nodelist length in IE
552 var length = !!obj && "length" in obj && obj.length,
553 type = toType( obj );
555 if ( isFunction( obj ) || isWindow( obj ) ) {
559 return type === "array" || length === 0 ||
560 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
564 function nodeName( elem, name ) {
566 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
575 var splice = arr.splice;
578 var whitespace = "[\\x20\\t\\r\\n\\f]";
581 var rtrimCSS = new RegExp(
582 "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
589 // Note: an element does not contain itself
590 jQuery.contains = function( a, b ) {
591 var bup = b && b.parentNode;
593 return a === bup || !!( bup && bup.nodeType === 1 && (
595 // Support: IE 9 - 11+
596 // IE doesn't have `contains` on SVG.
599 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
606 // CSS string/identifier serialization
607 // https://drafts.csswg.org/cssom/#common-serializing-idioms
608 var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
610 function fcssescape( ch, asCodePoint ) {
613 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
618 // Control characters and (dependent upon position) numbers get escaped as code points
619 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
622 // Other potentially-special ASCII characters get backslash-escaped
626 jQuery.escapeSelector = function( sel ) {
627 return ( sel + "" ).replace( rcssescape, fcssescape );
633 var preferredDoc = document,
645 // Local document vars
652 // Instance-specific data
653 expando = jQuery.expando,
656 classCache = createCache(),
657 tokenCache = createCache(),
658 compilerCache = createCache(),
659 nonnativeSelectorCache = createCache(),
660 sortOrder = function( a, b ) {
667 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|" +
668 "loop|multiple|open|readonly|required|scoped",
670 // Regular expressions
672 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
673 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
674 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
676 // Attribute selectors: https://www.w3.org/TR/selectors/#attribute-selectors
677 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
679 // Operator (capture 2)
680 "*([*^$|!~]?=)" + whitespace +
682 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
683 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
686 pseudos = ":(" + identifier + ")(?:\\((" +
688 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
689 // 1. quoted (capture 3; capture 4 or capture 5)
690 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
692 // 2. simple (capture 6)
693 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
695 // 3. anything else (capture 2)
699 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
700 rwhitespace = new RegExp( whitespace + "+", "g" ),
702 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
703 rleadingCombinator = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" +
705 rdescend = new RegExp( whitespace + "|>" ),
707 rpseudo = new RegExp( pseudos ),
708 ridentifier = new RegExp( "^" + identifier + "$" ),
711 ID: new RegExp( "^#(" + identifier + ")" ),
712 CLASS: new RegExp( "^\\.(" + identifier + ")" ),
713 TAG: new RegExp( "^(" + identifier + "|[*])" ),
714 ATTR: new RegExp( "^" + attributes ),
715 PSEUDO: new RegExp( "^" + pseudos ),
717 "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
718 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
719 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
720 bool: new RegExp( "^(?:" + booleans + ")$", "i" ),
722 // For use in libraries implementing .is()
723 // We use this for POS matching in `select`
724 needsContext: new RegExp( "^" + whitespace +
725 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
726 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
729 rinputs = /^(?:input|select|textarea|button)$/i,
732 // Easily-parseable/retrievable ID or TAG or CLASS selectors
733 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
738 // https://www.w3.org/TR/CSS21/syndata.html#escaped-characters
739 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace +
740 "?|\\\\([^\\r\\n\\f])", "g" ),
741 funescape = function( escape, nonHex ) {
742 var high = "0x" + escape.slice( 1 ) - 0x10000;
746 // Strip the backslash prefix from a non-hex escape sequence
750 // Replace a hexadecimal escape sequence with the encoded Unicode code point
752 // For values outside the Basic Multilingual Plane (BMP), manually construct a
755 String.fromCharCode( high + 0x10000 ) :
756 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
759 // Used for iframes; see `setDocument`.
760 // Support: IE 9 - 11+, Edge 12 - 18+
761 // Removing the function wrapper causes a "Permission Denied"
763 unloadHandler = function() {
767 inDisabledFieldset = addCombinator(
769 return elem.disabled === true && nodeName( elem, "fieldset" );
771 { dir: "parentNode", next: "legend" }
774 // Support: IE <=9 only
775 // Accessing document.activeElement can throw unexpectedly
776 // https://bugs.jquery.com/ticket/13393
777 function safeActiveElement() {
779 return document.activeElement;
783 // Optimize for push.apply( _, NodeList )
786 ( arr = slice.call( preferredDoc.childNodes ) ),
787 preferredDoc.childNodes
790 // Support: Android <=4.0
791 // Detect silently failing push.apply
792 // eslint-disable-next-line no-unused-expressions
793 arr[ preferredDoc.childNodes.length ].nodeType;
796 apply: function( target, els ) {
797 pushNative.apply( target, slice.call( els ) );
799 call: function( target ) {
800 pushNative.apply( target, slice.call( arguments, 1 ) );
805 function find( selector, context, results, seed ) {
806 var m, i, elem, nid, match, groups, newSelector,
807 newContext = context && context.ownerDocument,
809 // nodeType defaults to 9, since context defaults to document
810 nodeType = context ? context.nodeType : 9;
812 results = results || [];
814 // Return early from calls with invalid selector or context
815 if ( typeof selector !== "string" || !selector ||
816 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
821 // Try to shortcut find operations (as opposed to filters) in HTML documents
823 setDocument( context );
824 context = context || document;
826 if ( documentIsHTML ) {
828 // If the selector is sufficiently simple, try using a "get*By*" DOM method
829 // (excepting DocumentFragment context, where the methods don't exist)
830 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
833 if ( ( m = match[ 1 ] ) ) {
836 if ( nodeType === 9 ) {
837 if ( ( elem = context.getElementById( m ) ) ) {
839 // Support: IE 9 only
840 // getElementById can match elements by name instead of ID
841 if ( elem.id === m ) {
842 push.call( results, elem );
852 // Support: IE 9 only
853 // getElementById can match elements by name instead of ID
854 if ( newContext && ( elem = newContext.getElementById( m ) ) &&
855 find.contains( context, elem ) &&
858 push.call( results, elem );
864 } else if ( match[ 2 ] ) {
865 push.apply( results, context.getElementsByTagName( selector ) );
869 } else if ( ( m = match[ 3 ] ) && context.getElementsByClassName ) {
870 push.apply( results, context.getElementsByClassName( m ) );
875 // Take advantage of querySelectorAll
876 if ( !nonnativeSelectorCache[ selector + " " ] &&
877 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) ) {
879 newSelector = selector;
880 newContext = context;
882 // qSA considers elements outside a scoping root when evaluating child or
883 // descendant combinators, which is not what we want.
884 // In such cases, we work around the behavior by prefixing every selector in the
885 // list with an ID selector referencing the scope context.
886 // The technique has to be used as well when a leading combinator is used
887 // as such selectors are not recognized by querySelectorAll.
888 // Thanks to Andrew Dupont for this technique.
889 if ( nodeType === 1 &&
890 ( rdescend.test( selector ) || rleadingCombinator.test( selector ) ) ) {
892 // Expand context for sibling selectors
893 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
896 // We can use :scope instead of the ID hack if the browser
897 // supports it & if we're not changing the context.
898 // Support: IE 11+, Edge 17 - 18+
899 // IE/Edge sometimes throw a "Permission denied" error when
900 // strict-comparing two documents; shallow comparisons work.
901 // eslint-disable-next-line eqeqeq
902 if ( newContext != context || !support.scope ) {
904 // Capture the context ID, setting it first if necessary
905 if ( ( nid = context.getAttribute( "id" ) ) ) {
906 nid = jQuery.escapeSelector( nid );
908 context.setAttribute( "id", ( nid = expando ) );
912 // Prefix every selector in the list
913 groups = tokenize( selector );
916 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
917 toSelector( groups[ i ] );
919 newSelector = groups.join( "," );
924 newContext.querySelectorAll( newSelector )
927 } catch ( qsaError ) {
928 nonnativeSelectorCache( selector, true );
930 if ( nid === expando ) {
931 context.removeAttribute( "id" );
939 return select( selector.replace( rtrimCSS, "$1" ), context, results, seed );
943 * Create key-value caches of limited size
944 * @returns {function(string, object)} Returns the Object data after storing it on itself with
945 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
946 * deleting the oldest entry
948 function createCache() {
951 function cache( key, value ) {
953 // Use (key + " ") to avoid collision with native prototype properties
954 // (see https://github.com/jquery/sizzle/issues/157)
955 if ( keys.push( key + " " ) > Expr.cacheLength ) {
957 // Only keep the most recent entries
958 delete cache[ keys.shift() ];
960 return ( cache[ key + " " ] = value );
966 * Mark a function for special use by jQuery selector module
967 * @param {Function} fn The function to mark
969 function markFunction( fn ) {
970 fn[ expando ] = true;
975 * Support testing using an element
976 * @param {Function} fn Passed the created element and returns a boolean result
978 function assert( fn ) {
979 var el = document.createElement( "fieldset" );
987 // Remove from its parent by default
988 if ( el.parentNode ) {
989 el.parentNode.removeChild( el );
992 // release memory in IE
998 * Returns a function to use in pseudos for input types
999 * @param {String} type
1001 function createInputPseudo( type ) {
1002 return function( elem ) {
1003 return nodeName( elem, "input" ) && elem.type === type;
1008 * Returns a function to use in pseudos for buttons
1009 * @param {String} type
1011 function createButtonPseudo( type ) {
1012 return function( elem ) {
1013 return ( nodeName( elem, "input" ) || nodeName( elem, "button" ) ) &&
1019 * Returns a function to use in pseudos for :enabled/:disabled
1020 * @param {Boolean} disabled true for :disabled; false for :enabled
1022 function createDisabledPseudo( disabled ) {
1024 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1025 return function( elem ) {
1027 // Only certain elements can match :enabled or :disabled
1028 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1029 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1030 if ( "form" in elem ) {
1032 // Check for inherited disabledness on relevant non-disabled elements:
1033 // * listed form-associated elements in a disabled fieldset
1034 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
1035 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1036 // * option elements in a disabled optgroup
1037 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1038 // All such elements have a "form" property.
1039 if ( elem.parentNode && elem.disabled === false ) {
1041 // Option elements defer to a parent optgroup if present
1042 if ( "label" in elem ) {
1043 if ( "label" in elem.parentNode ) {
1044 return elem.parentNode.disabled === disabled;
1046 return elem.disabled === disabled;
1050 // Support: IE 6 - 11+
1051 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
1052 return elem.isDisabled === disabled ||
1054 // Where there is no isDisabled, check manually
1055 elem.isDisabled !== !disabled &&
1056 inDisabledFieldset( elem ) === disabled;
1059 return elem.disabled === disabled;
1061 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1062 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1063 // even exist on them, let alone have a boolean value.
1064 } else if ( "label" in elem ) {
1065 return elem.disabled === disabled;
1068 // Remaining elements are neither :enabled nor :disabled
1074 * Returns a function to use in pseudos for positionals
1075 * @param {Function} fn
1077 function createPositionalPseudo( fn ) {
1078 return markFunction( function( argument ) {
1079 argument = +argument;
1080 return markFunction( function( seed, matches ) {
1082 matchIndexes = fn( [], seed.length, argument ),
1083 i = matchIndexes.length;
1085 // Match elements found at the specified indexes
1087 if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
1088 seed[ j ] = !( matches[ j ] = seed[ j ] );
1096 * Checks a node for validity as a jQuery selector context
1097 * @param {Element|Object=} context
1098 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1100 function testContext( context ) {
1101 return context && typeof context.getElementsByTagName !== "undefined" && context;
1105 * Sets document-related variables once based on the current document
1106 * @param {Element|Object} [node] An element or document object to use to set the document
1107 * @returns {Object} Returns the current document
1109 function setDocument( node ) {
1111 doc = node ? node.ownerDocument || node : preferredDoc;
1113 // Return early if doc is invalid or already selected
1114 // Support: IE 11+, Edge 17 - 18+
1115 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1116 // two documents; shallow comparisons work.
1117 // eslint-disable-next-line eqeqeq
1118 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
1122 // Update global variables
1124 documentElement = document.documentElement;
1125 documentIsHTML = !jQuery.isXMLDoc( document );
1127 // Support: iOS 7 only, IE 9 - 11+
1128 // Older browsers didn't support unprefixed `matches`.
1129 matches = documentElement.matches ||
1130 documentElement.webkitMatchesSelector ||
1131 documentElement.msMatchesSelector;
1133 // Support: IE 9 - 11+, Edge 12 - 18+
1134 // Accessing iframe documents after unload throws "permission denied" errors
1135 // (see trac-13936).
1136 // Limit the fix to IE & Edge Legacy; despite Edge 15+ implementing `matches`,
1137 // all IE 9+ and Edge Legacy versions implement `msMatchesSelector` as well.
1138 if ( documentElement.msMatchesSelector &&
1140 // Support: IE 11+, Edge 17 - 18+
1141 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1142 // two documents; shallow comparisons work.
1143 // eslint-disable-next-line eqeqeq
1144 preferredDoc != document &&
1145 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
1147 // Support: IE 9 - 11+, Edge 12 - 18+
1148 subWindow.addEventListener( "unload", unloadHandler );
1152 // Check if getElementById returns elements by name
1153 // The broken getElementById methods don't pick up programmatically-set names,
1154 // so use a roundabout getElementsByName test
1155 support.getById = assert( function( el ) {
1156 documentElement.appendChild( el ).id = jQuery.expando;
1157 return !document.getElementsByName ||
1158 !document.getElementsByName( jQuery.expando ).length;
1161 // Support: IE 9 only
1162 // Check to see if it's possible to do matchesSelector
1163 // on a disconnected node.
1164 support.disconnectedMatch = assert( function( el ) {
1165 return matches.call( el, "*" );
1168 // Support: IE 9 - 11+, Edge 12 - 18+
1169 // IE/Edge don't support the :scope pseudo-class.
1170 support.scope = assert( function() {
1171 return document.querySelectorAll( ":scope" );
1174 // Support: Chrome 105 - 111 only, Safari 15.4 - 16.3 only
1175 // Make sure the `:has()` argument is parsed unforgivingly.
1176 // We include `*` in the test to detect buggy implementations that are
1177 // _selectively_ forgiving (specifically when the list includes at least
1178 // one valid selector).
1179 // Note that we treat complete lack of support for `:has()` as if it were
1180 // spec-compliant support, which is fine because use of `:has()` in such
1181 // environments will fail in the qSA path and fall back to jQuery traversal
1183 support.cssHas = assert( function() {
1185 document.querySelector( ":has(*,:jqfake)" );
1192 // ID filter and find
1193 if ( support.getById ) {
1194 Expr.filter.ID = function( id ) {
1195 var attrId = id.replace( runescape, funescape );
1196 return function( elem ) {
1197 return elem.getAttribute( "id" ) === attrId;
1200 Expr.find.ID = function( id, context ) {
1201 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1202 var elem = context.getElementById( id );
1203 return elem ? [ elem ] : [];
1207 Expr.filter.ID = function( id ) {
1208 var attrId = id.replace( runescape, funescape );
1209 return function( elem ) {
1210 var node = typeof elem.getAttributeNode !== "undefined" &&
1211 elem.getAttributeNode( "id" );
1212 return node && node.value === attrId;
1216 // Support: IE 6 - 7 only
1217 // getElementById is not reliable as a find shortcut
1218 Expr.find.ID = function( id, context ) {
1219 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1221 elem = context.getElementById( id );
1225 // Verify the id attribute
1226 node = elem.getAttributeNode( "id" );
1227 if ( node && node.value === id ) {
1231 // Fall back on getElementsByName
1232 elems = context.getElementsByName( id );
1234 while ( ( elem = elems[ i++ ] ) ) {
1235 node = elem.getAttributeNode( "id" );
1236 if ( node && node.value === id ) {
1248 Expr.find.TAG = function( tag, context ) {
1249 if ( typeof context.getElementsByTagName !== "undefined" ) {
1250 return context.getElementsByTagName( tag );
1252 // DocumentFragment nodes don't have gEBTN
1254 return context.querySelectorAll( tag );
1259 Expr.find.CLASS = function( className, context ) {
1260 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1261 return context.getElementsByClassName( className );
1265 /* QSA/matchesSelector
1266 ---------------------------------------------------------------------- */
1268 // QSA and matchesSelector support
1273 // Regex strategy adopted from Diego Perini
1274 assert( function( el ) {
1278 documentElement.appendChild( el ).innerHTML =
1279 "<a id='" + expando + "' href='' disabled='disabled'></a>" +
1280 "<select id='" + expando + "-\r\\' disabled='disabled'>" +
1281 "<option selected=''></option></select>";
1283 // Support: iOS <=7 - 8 only
1284 // Boolean attributes and "value" are not treated correctly in some XML documents
1285 if ( !el.querySelectorAll( "[selected]" ).length ) {
1286 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1289 // Support: iOS <=7 - 8 only
1290 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1291 rbuggyQSA.push( "~=" );
1294 // Support: iOS 8 only
1295 // https://bugs.webkit.org/show_bug.cgi?id=136851
1296 // In-page `selector#id sibling-combinator selector` fails
1297 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
1298 rbuggyQSA.push( ".#.+[+~]" );
1301 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+
1302 // In some of the document kinds, these selectors wouldn't work natively.
1303 // This is probably OK but for backwards compatibility we want to maintain
1304 // handling them through jQuery traversal in jQuery 3.x.
1305 if ( !el.querySelectorAll( ":checked" ).length ) {
1306 rbuggyQSA.push( ":checked" );
1309 // Support: Windows 8 Native Apps
1310 // The type and name attributes are restricted during .innerHTML assignment
1311 input = document.createElement( "input" );
1312 input.setAttribute( "type", "hidden" );
1313 el.appendChild( input ).setAttribute( "name", "D" );
1315 // Support: IE 9 - 11+
1316 // IE's :disabled selector does not pick up the children of disabled fieldsets
1317 // Support: Chrome <=105+, Firefox <=104+, Safari <=15.4+
1318 // In some of the document kinds, these selectors wouldn't work natively.
1319 // This is probably OK but for backwards compatibility we want to maintain
1320 // handling them through jQuery traversal in jQuery 3.x.
1321 documentElement.appendChild( el ).disabled = true;
1322 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
1323 rbuggyQSA.push( ":enabled", ":disabled" );
1326 // Support: IE 11+, Edge 15 - 18+
1327 // IE 11/Edge don't find elements on a `[name='']` query in some cases.
1328 // Adding a temporary attribute to the document before the selection works
1329 // around the issue.
1330 // Interestingly, IE 10 & older don't seem to have the issue.
1331 input = document.createElement( "input" );
1332 input.setAttribute( "name", "" );
1333 el.appendChild( input );
1334 if ( !el.querySelectorAll( "[name='']" ).length ) {
1335 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
1336 whitespace + "*(?:''|\"\")" );
1340 if ( !support.cssHas ) {
1342 // Support: Chrome 105 - 110+, Safari 15.4 - 16.3+
1343 // Our regular `try-catch` mechanism fails to detect natively-unsupported
1344 // pseudo-classes inside `:has()` (such as `:has(:contains("Foo"))`)
1345 // in browsers that parse the `:has()` argument as a forgiving selector list.
1346 // https://drafts.csswg.org/selectors/#relational now requires the argument
1347 // to be parsed unforgivingly, but browsers have not yet fully adjusted.
1348 rbuggyQSA.push( ":has" );
1351 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
1354 ---------------------------------------------------------------------- */
1356 // Document order sorting
1357 sortOrder = function( a, b ) {
1359 // Flag for duplicate removal
1361 hasDuplicate = true;
1365 // Sort on method existence if only one input has compareDocumentPosition
1366 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1371 // Calculate position if both inputs belong to the same document
1372 // Support: IE 11+, Edge 17 - 18+
1373 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1374 // two documents; shallow comparisons work.
1375 // eslint-disable-next-line eqeqeq
1376 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
1377 a.compareDocumentPosition( b ) :
1379 // Otherwise we know they are disconnected
1382 // Disconnected nodes
1384 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
1386 // Choose the first element that is related to our preferred document
1387 // Support: IE 11+, Edge 17 - 18+
1388 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1389 // two documents; shallow comparisons work.
1390 // eslint-disable-next-line eqeqeq
1391 if ( a === document || a.ownerDocument == preferredDoc &&
1392 find.contains( preferredDoc, a ) ) {
1396 // Support: IE 11+, Edge 17 - 18+
1397 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1398 // two documents; shallow comparisons work.
1399 // eslint-disable-next-line eqeqeq
1400 if ( b === document || b.ownerDocument == preferredDoc &&
1401 find.contains( preferredDoc, b ) ) {
1405 // Maintain original order
1407 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1411 return compare & 4 ? -1 : 1;
1417 find.matches = function( expr, elements ) {
1418 return find( expr, null, null, elements );
1421 find.matchesSelector = function( elem, expr ) {
1422 setDocument( elem );
1424 if ( documentIsHTML &&
1425 !nonnativeSelectorCache[ expr + " " ] &&
1426 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1429 var ret = matches.call( elem, expr );
1431 // IE 9's matchesSelector returns false on disconnected nodes
1432 if ( ret || support.disconnectedMatch ||
1434 // As well, disconnected nodes are said to be in a document
1436 elem.document && elem.document.nodeType !== 11 ) {
1440 nonnativeSelectorCache( expr, true );
1444 return find( expr, document, null, [ elem ] ).length > 0;
1447 find.contains = function( context, elem ) {
1449 // Set document vars if needed
1450 // Support: IE 11+, Edge 17 - 18+
1451 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1452 // two documents; shallow comparisons work.
1453 // eslint-disable-next-line eqeqeq
1454 if ( ( context.ownerDocument || context ) != document ) {
1455 setDocument( context );
1457 return jQuery.contains( context, elem );
1461 find.attr = function( elem, name ) {
1463 // Set document vars if needed
1464 // Support: IE 11+, Edge 17 - 18+
1465 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1466 // two documents; shallow comparisons work.
1467 // eslint-disable-next-line eqeqeq
1468 if ( ( elem.ownerDocument || elem ) != document ) {
1469 setDocument( elem );
1472 var fn = Expr.attrHandle[ name.toLowerCase() ],
1474 // Don't get fooled by Object.prototype properties (see trac-13807)
1475 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1476 fn( elem, name, !documentIsHTML ) :
1479 if ( val !== undefined ) {
1483 return elem.getAttribute( name );
1486 find.error = function( msg ) {
1487 throw new Error( "Syntax error, unrecognized expression: " + msg );
1491 * Document sorting and removing duplicates
1492 * @param {ArrayLike} results
1494 jQuery.uniqueSort = function( results ) {
1500 // Unless we *know* we can detect duplicates, assume their presence
1502 // Support: Android <=4.0+
1503 // Testing for detecting duplicates is unpredictable so instead assume we can't
1504 // depend on duplicate detection in all browsers without a stable sort.
1505 hasDuplicate = !support.sortStable;
1506 sortInput = !support.sortStable && slice.call( results, 0 );
1507 sort.call( results, sortOrder );
1509 if ( hasDuplicate ) {
1510 while ( ( elem = results[ i++ ] ) ) {
1511 if ( elem === results[ i ] ) {
1512 j = duplicates.push( i );
1516 splice.call( results, duplicates[ j ], 1 );
1520 // Clear input after sorting to release objects
1521 // See https://github.com/jquery/sizzle/pull/225
1527 jQuery.fn.uniqueSort = function() {
1528 return this.pushStack( jQuery.uniqueSort( slice.apply( this ) ) );
1531 Expr = jQuery.expr = {
1533 // Can be adjusted by the user
1536 createPseudo: markFunction,
1545 ">": { dir: "parentNode", first: true },
1546 " ": { dir: "parentNode" },
1547 "+": { dir: "previousSibling", first: true },
1548 "~": { dir: "previousSibling" }
1552 ATTR: function( match ) {
1553 match[ 1 ] = match[ 1 ].replace( runescape, funescape );
1555 // Move the given value to match[3] whether quoted or unquoted
1556 match[ 3 ] = ( match[ 3 ] || match[ 4 ] || match[ 5 ] || "" )
1557 .replace( runescape, funescape );
1559 if ( match[ 2 ] === "~=" ) {
1560 match[ 3 ] = " " + match[ 3 ] + " ";
1563 return match.slice( 0, 4 );
1566 CHILD: function( match ) {
1568 /* matches from matchExpr["CHILD"]
1569 1 type (only|nth|...)
1570 2 what (child|of-type)
1571 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1572 4 xn-component of xn+y argument ([+-]?\d*n|)
1573 5 sign of xn-component
1575 7 sign of y-component
1578 match[ 1 ] = match[ 1 ].toLowerCase();
1580 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
1582 // nth-* requires argument
1583 if ( !match[ 3 ] ) {
1584 find.error( match[ 0 ] );
1587 // numeric x and y parameters for Expr.filter.CHILD
1588 // remember that false/true cast respectively to 0/1
1589 match[ 4 ] = +( match[ 4 ] ?
1590 match[ 5 ] + ( match[ 6 ] || 1 ) :
1591 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" )
1593 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
1595 // other types prohibit arguments
1596 } else if ( match[ 3 ] ) {
1597 find.error( match[ 0 ] );
1603 PSEUDO: function( match ) {
1605 unquoted = !match[ 6 ] && match[ 2 ];
1607 if ( matchExpr.CHILD.test( match[ 0 ] ) ) {
1611 // Accept quoted arguments as-is
1613 match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
1615 // Strip excess characters from unquoted arguments
1616 } else if ( unquoted && rpseudo.test( unquoted ) &&
1618 // Get excess from tokenize (recursively)
1619 ( excess = tokenize( unquoted, true ) ) &&
1621 // advance to the next closing parenthesis
1622 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
1624 // excess is a negative index
1625 match[ 0 ] = match[ 0 ].slice( 0, excess );
1626 match[ 2 ] = unquoted.slice( 0, excess );
1629 // Return only captures needed by the pseudo filter method (type and argument)
1630 return match.slice( 0, 3 );
1636 TAG: function( nodeNameSelector ) {
1637 var expectedNodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1638 return nodeNameSelector === "*" ?
1643 return nodeName( elem, expectedNodeName );
1647 CLASS: function( className ) {
1648 var pattern = classCache[ className + " " ];
1651 ( pattern = new RegExp( "(^|" + whitespace + ")" + className +
1652 "(" + whitespace + "|$)" ) ) &&
1653 classCache( className, function( elem ) {
1654 return pattern.test(
1655 typeof elem.className === "string" && elem.className ||
1656 typeof elem.getAttribute !== "undefined" &&
1657 elem.getAttribute( "class" ) ||
1663 ATTR: function( name, operator, check ) {
1664 return function( elem ) {
1665 var result = find.attr( elem, name );
1667 if ( result == null ) {
1668 return operator === "!=";
1676 if ( operator === "=" ) {
1677 return result === check;
1679 if ( operator === "!=" ) {
1680 return result !== check;
1682 if ( operator === "^=" ) {
1683 return check && result.indexOf( check ) === 0;
1685 if ( operator === "*=" ) {
1686 return check && result.indexOf( check ) > -1;
1688 if ( operator === "$=" ) {
1689 return check && result.slice( -check.length ) === check;
1691 if ( operator === "~=" ) {
1692 return ( " " + result.replace( rwhitespace, " " ) + " " )
1693 .indexOf( check ) > -1;
1695 if ( operator === "|=" ) {
1696 return result === check || result.slice( 0, check.length + 1 ) === check + "-";
1703 CHILD: function( type, what, _argument, first, last ) {
1704 var simple = type.slice( 0, 3 ) !== "nth",
1705 forward = type.slice( -4 ) !== "last",
1706 ofType = what === "of-type";
1708 return first === 1 && last === 0 ?
1710 // Shortcut for :nth-*(n)
1712 return !!elem.parentNode;
1715 function( elem, _context, xml ) {
1716 var cache, outerCache, node, nodeIndex, start,
1717 dir = simple !== forward ? "nextSibling" : "previousSibling",
1718 parent = elem.parentNode,
1719 name = ofType && elem.nodeName.toLowerCase(),
1720 useCache = !xml && !ofType,
1725 // :(first|last|only)-(child|of-type)
1729 while ( ( node = node[ dir ] ) ) {
1731 nodeName( node, name ) :
1732 node.nodeType === 1 ) {
1738 // Reverse direction for :only-* (if we haven't yet done so)
1739 start = dir = type === "only" && !start && "nextSibling";
1744 start = [ forward ? parent.firstChild : parent.lastChild ];
1746 // non-xml :nth-child(...) stores cache data on `parent`
1747 if ( forward && useCache ) {
1749 // Seek `elem` from a previously-cached index
1750 outerCache = parent[ expando ] || ( parent[ expando ] = {} );
1751 cache = outerCache[ type ] || [];
1752 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1753 diff = nodeIndex && cache[ 2 ];
1754 node = nodeIndex && parent.childNodes[ nodeIndex ];
1756 while ( ( node = ++nodeIndex && node && node[ dir ] ||
1758 // Fallback to seeking `elem` from the start
1759 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
1761 // When found, cache indexes on `parent` and break
1762 if ( node.nodeType === 1 && ++diff && node === elem ) {
1763 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1770 // Use previously-cached element index if available
1772 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
1773 cache = outerCache[ type ] || [];
1774 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1778 // xml :nth-child(...)
1779 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1780 if ( diff === false ) {
1782 // Use the same loop as above to seek `elem` from the start
1783 while ( ( node = ++nodeIndex && node && node[ dir ] ||
1784 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
1787 nodeName( node, name ) :
1788 node.nodeType === 1 ) &&
1791 // Cache the index of each encountered element
1793 outerCache = node[ expando ] ||
1794 ( node[ expando ] = {} );
1795 outerCache[ type ] = [ dirruns, diff ];
1798 if ( node === elem ) {
1806 // Incorporate the offset, then check against cycle size
1808 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1813 PSEUDO: function( pseudo, argument ) {
1815 // pseudo-class names are case-insensitive
1816 // https://www.w3.org/TR/selectors/#pseudo-classes
1817 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1818 // Remember that setFilters inherits from pseudos
1820 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1821 find.error( "unsupported pseudo: " + pseudo );
1823 // The user may use createPseudo to indicate that
1824 // arguments are needed to create the filter function
1825 // just as jQuery does
1826 if ( fn[ expando ] ) {
1827 return fn( argument );
1830 // But maintain support for old signatures
1831 if ( fn.length > 1 ) {
1832 args = [ pseudo, pseudo, "", argument ];
1833 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1834 markFunction( function( seed, matches ) {
1836 matched = fn( seed, argument ),
1839 idx = indexOf.call( seed, matched[ i ] );
1840 seed[ idx ] = !( matches[ idx ] = matched[ i ] );
1844 return fn( elem, 0, args );
1854 // Potentially complex pseudos
1855 not: markFunction( function( selector ) {
1857 // Trim the selector passed to compile
1858 // to avoid treating leading and trailing
1859 // spaces as combinators
1862 matcher = compile( selector.replace( rtrimCSS, "$1" ) );
1864 return matcher[ expando ] ?
1865 markFunction( function( seed, matches, _context, xml ) {
1867 unmatched = matcher( seed, null, xml, [] ),
1870 // Match elements unmatched by `matcher`
1872 if ( ( elem = unmatched[ i ] ) ) {
1873 seed[ i ] = !( matches[ i ] = elem );
1877 function( elem, _context, xml ) {
1879 matcher( input, null, xml, results );
1881 // Don't keep the element
1882 // (see https://github.com/jquery/sizzle/issues/299)
1884 return !results.pop();
1888 has: markFunction( function( selector ) {
1889 return function( elem ) {
1890 return find( selector, elem ).length > 0;
1894 contains: markFunction( function( text ) {
1895 text = text.replace( runescape, funescape );
1896 return function( elem ) {
1897 return ( elem.textContent || jQuery.text( elem ) ).indexOf( text ) > -1;
1901 // "Whether an element is represented by a :lang() selector
1902 // is based solely on the element's language value
1903 // being equal to the identifier C,
1904 // or beginning with the identifier C immediately followed by "-".
1905 // The matching of C against the element's language value is performed case-insensitively.
1906 // The identifier C does not have to be a valid language name."
1907 // https://www.w3.org/TR/selectors/#lang-pseudo
1908 lang: markFunction( function( lang ) {
1910 // lang value must be a valid identifier
1911 if ( !ridentifier.test( lang || "" ) ) {
1912 find.error( "unsupported lang: " + lang );
1914 lang = lang.replace( runescape, funescape ).toLowerCase();
1915 return function( elem ) {
1918 if ( ( elemLang = documentIsHTML ?
1920 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
1922 elemLang = elemLang.toLowerCase();
1923 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1925 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
1931 target: function( elem ) {
1932 var hash = window.location && window.location.hash;
1933 return hash && hash.slice( 1 ) === elem.id;
1936 root: function( elem ) {
1937 return elem === documentElement;
1940 focus: function( elem ) {
1941 return elem === safeActiveElement() &&
1942 document.hasFocus() &&
1943 !!( elem.type || elem.href || ~elem.tabIndex );
1946 // Boolean properties
1947 enabled: createDisabledPseudo( false ),
1948 disabled: createDisabledPseudo( true ),
1950 checked: function( elem ) {
1952 // In CSS3, :checked should return both checked and selected elements
1953 // https://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1954 return ( nodeName( elem, "input" ) && !!elem.checked ) ||
1955 ( nodeName( elem, "option" ) && !!elem.selected );
1958 selected: function( elem ) {
1960 // Support: IE <=11+
1961 // Accessing the selectedIndex property
1962 // forces the browser to treat the default option as
1963 // selected when in an optgroup.
1964 if ( elem.parentNode ) {
1965 // eslint-disable-next-line no-unused-expressions
1966 elem.parentNode.selectedIndex;
1969 return elem.selected === true;
1973 empty: function( elem ) {
1975 // https://www.w3.org/TR/selectors/#empty-pseudo
1976 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1977 // but not by others (comment: 8; processing instruction: 7; etc.)
1978 // nodeType < 6 works because attributes (2) do not appear as children
1979 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1980 if ( elem.nodeType < 6 ) {
1987 parent: function( elem ) {
1988 return !Expr.pseudos.empty( elem );
1991 // Element/input types
1992 header: function( elem ) {
1993 return rheader.test( elem.nodeName );
1996 input: function( elem ) {
1997 return rinputs.test( elem.nodeName );
2000 button: function( elem ) {
2001 return nodeName( elem, "input" ) && elem.type === "button" ||
2002 nodeName( elem, "button" );
2005 text: function( elem ) {
2007 return nodeName( elem, "input" ) && elem.type === "text" &&
2009 // Support: IE <10 only
2010 // New HTML5 attribute values (e.g., "search") appear
2011 // with elem.type === "text"
2012 ( ( attr = elem.getAttribute( "type" ) ) == null ||
2013 attr.toLowerCase() === "text" );
2016 // Position-in-collection
2017 first: createPositionalPseudo( function() {
2021 last: createPositionalPseudo( function( _matchIndexes, length ) {
2022 return [ length - 1 ];
2025 eq: createPositionalPseudo( function( _matchIndexes, length, argument ) {
2026 return [ argument < 0 ? argument + length : argument ];
2029 even: createPositionalPseudo( function( matchIndexes, length ) {
2031 for ( ; i < length; i += 2 ) {
2032 matchIndexes.push( i );
2034 return matchIndexes;
2037 odd: createPositionalPseudo( function( matchIndexes, length ) {
2039 for ( ; i < length; i += 2 ) {
2040 matchIndexes.push( i );
2042 return matchIndexes;
2045 lt: createPositionalPseudo( function( matchIndexes, length, argument ) {
2048 if ( argument < 0 ) {
2049 i = argument + length;
2050 } else if ( argument > length ) {
2056 for ( ; --i >= 0; ) {
2057 matchIndexes.push( i );
2059 return matchIndexes;
2062 gt: createPositionalPseudo( function( matchIndexes, length, argument ) {
2063 var i = argument < 0 ? argument + length : argument;
2064 for ( ; ++i < length; ) {
2065 matchIndexes.push( i );
2067 return matchIndexes;
2072 Expr.pseudos.nth = Expr.pseudos.eq;
2074 // Add button/input type pseudos
2075 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2076 Expr.pseudos[ i ] = createInputPseudo( i );
2078 for ( i in { submit: true, reset: true } ) {
2079 Expr.pseudos[ i ] = createButtonPseudo( i );
2082 // Easy API for creating new setFilters
2083 function setFilters() {}
2084 setFilters.prototype = Expr.filters = Expr.pseudos;
2085 Expr.setFilters = new setFilters();
2087 function tokenize( selector, parseOnly ) {
2088 var matched, match, tokens, type,
2089 soFar, groups, preFilters,
2090 cached = tokenCache[ selector + " " ];
2093 return parseOnly ? 0 : cached.slice( 0 );
2098 preFilters = Expr.preFilter;
2102 // Comma and first run
2103 if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
2106 // Don't consume trailing commas as valid
2107 soFar = soFar.slice( match[ 0 ].length ) || soFar;
2109 groups.push( ( tokens = [] ) );
2115 if ( ( match = rleadingCombinator.exec( soFar ) ) ) {
2116 matched = match.shift();
2120 // Cast descendant combinators to space
2121 type: match[ 0 ].replace( rtrimCSS, " " )
2123 soFar = soFar.slice( matched.length );
2127 for ( type in Expr.filter ) {
2128 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
2129 ( match = preFilters[ type ]( match ) ) ) ) {
2130 matched = match.shift();
2136 soFar = soFar.slice( matched.length );
2145 // Return the length of the invalid excess
2146 // if we're just parsing
2147 // Otherwise, throw an error or return tokens
2149 return soFar.length;
2153 find.error( selector ) :
2156 tokenCache( selector, groups ).slice( 0 );
2159 function toSelector( tokens ) {
2161 len = tokens.length,
2163 for ( ; i < len; i++ ) {
2164 selector += tokens[ i ].value;
2169 function addCombinator( matcher, combinator, base ) {
2170 var dir = combinator.dir,
2171 skip = combinator.next,
2173 checkNonElements = base && key === "parentNode",
2176 return combinator.first ?
2178 // Check against closest ancestor/preceding element
2179 function( elem, context, xml ) {
2180 while ( ( elem = elem[ dir ] ) ) {
2181 if ( elem.nodeType === 1 || checkNonElements ) {
2182 return matcher( elem, context, xml );
2188 // Check against all ancestor/preceding elements
2189 function( elem, context, xml ) {
2190 var oldCache, outerCache,
2191 newCache = [ dirruns, doneName ];
2193 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2195 while ( ( elem = elem[ dir ] ) ) {
2196 if ( elem.nodeType === 1 || checkNonElements ) {
2197 if ( matcher( elem, context, xml ) ) {
2203 while ( ( elem = elem[ dir ] ) ) {
2204 if ( elem.nodeType === 1 || checkNonElements ) {
2205 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
2207 if ( skip && nodeName( elem, skip ) ) {
2208 elem = elem[ dir ] || elem;
2209 } else if ( ( oldCache = outerCache[ key ] ) &&
2210 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2212 // Assign to newCache so results back-propagate to previous elements
2213 return ( newCache[ 2 ] = oldCache[ 2 ] );
2216 // Reuse newcache so results back-propagate to previous elements
2217 outerCache[ key ] = newCache;
2219 // A match means we're done; a fail means we have to keep checking
2220 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
2231 function elementMatcher( matchers ) {
2232 return matchers.length > 1 ?
2233 function( elem, context, xml ) {
2234 var i = matchers.length;
2236 if ( !matchers[ i ]( elem, context, xml ) ) {
2245 function multipleContexts( selector, contexts, results ) {
2247 len = contexts.length;
2248 for ( ; i < len; i++ ) {
2249 find( selector, contexts[ i ], results );
2254 function condense( unmatched, map, filter, context, xml ) {
2258 len = unmatched.length,
2259 mapped = map != null;
2261 for ( ; i < len; i++ ) {
2262 if ( ( elem = unmatched[ i ] ) ) {
2263 if ( !filter || filter( elem, context, xml ) ) {
2264 newUnmatched.push( elem );
2272 return newUnmatched;
2275 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2276 if ( postFilter && !postFilter[ expando ] ) {
2277 postFilter = setMatcher( postFilter );
2279 if ( postFinder && !postFinder[ expando ] ) {
2280 postFinder = setMatcher( postFinder, postSelector );
2282 return markFunction( function( seed, results, context, xml ) {
2283 var temp, i, elem, matcherOut,
2286 preexisting = results.length,
2288 // Get initial elements from seed or context
2290 multipleContexts( selector || "*",
2291 context.nodeType ? [ context ] : context, [] ),
2293 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2294 matcherIn = preFilter && ( seed || !selector ) ?
2295 condense( elems, preMap, preFilter, context, xml ) :
2300 // If we have a postFinder, or filtered seed, or non-seed postFilter
2301 // or preexisting results,
2302 matcherOut = postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2304 // ...intermediate processing is necessary
2307 // ...otherwise use results directly
2310 // Find primary matches
2311 matcher( matcherIn, matcherOut, context, xml );
2313 matcherOut = matcherIn;
2318 temp = condense( matcherOut, postMap );
2319 postFilter( temp, [], context, xml );
2321 // Un-match failing elements by moving them back to matcherIn
2324 if ( ( elem = temp[ i ] ) ) {
2325 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
2331 if ( postFinder || preFilter ) {
2334 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2336 i = matcherOut.length;
2338 if ( ( elem = matcherOut[ i ] ) ) {
2340 // Restore matcherIn since elem is not yet a final match
2341 temp.push( ( matcherIn[ i ] = elem ) );
2344 postFinder( null, ( matcherOut = [] ), temp, xml );
2347 // Move matched elements from seed to results to keep them synchronized
2348 i = matcherOut.length;
2350 if ( ( elem = matcherOut[ i ] ) &&
2351 ( temp = postFinder ? indexOf.call( seed, elem ) : preMap[ i ] ) > -1 ) {
2353 seed[ temp ] = !( results[ temp ] = elem );
2358 // Add elements to results, through postFinder if defined
2360 matcherOut = condense(
2361 matcherOut === results ?
2362 matcherOut.splice( preexisting, matcherOut.length ) :
2366 postFinder( null, results, matcherOut, xml );
2368 push.apply( results, matcherOut );
2374 function matcherFromTokens( tokens ) {
2375 var checkContext, matcher, j,
2376 len = tokens.length,
2377 leadingRelative = Expr.relative[ tokens[ 0 ].type ],
2378 implicitRelative = leadingRelative || Expr.relative[ " " ],
2379 i = leadingRelative ? 1 : 0,
2381 // The foundational matcher ensures that elements are reachable from top-level context(s)
2382 matchContext = addCombinator( function( elem ) {
2383 return elem === checkContext;
2384 }, implicitRelative, true ),
2385 matchAnyContext = addCombinator( function( elem ) {
2386 return indexOf.call( checkContext, elem ) > -1;
2387 }, implicitRelative, true ),
2388 matchers = [ function( elem, context, xml ) {
2390 // Support: IE 11+, Edge 17 - 18+
2391 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2392 // two documents; shallow comparisons work.
2393 // eslint-disable-next-line eqeqeq
2394 var ret = ( !leadingRelative && ( xml || context != outermostContext ) ) || (
2395 ( checkContext = context ).nodeType ?
2396 matchContext( elem, context, xml ) :
2397 matchAnyContext( elem, context, xml ) );
2399 // Avoid hanging onto element
2400 // (see https://github.com/jquery/sizzle/issues/299)
2401 checkContext = null;
2405 for ( ; i < len; i++ ) {
2406 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
2407 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
2409 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
2411 // Return special upon seeing a positional matcher
2412 if ( matcher[ expando ] ) {
2414 // Find the next relative operator (if any) for proper handling
2416 for ( ; j < len; j++ ) {
2417 if ( Expr.relative[ tokens[ j ].type ] ) {
2422 i > 1 && elementMatcher( matchers ),
2423 i > 1 && toSelector(
2425 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2426 tokens.slice( 0, i - 1 )
2427 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
2428 ).replace( rtrimCSS, "$1" ),
2430 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2431 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
2432 j < len && toSelector( tokens )
2435 matchers.push( matcher );
2439 return elementMatcher( matchers );
2442 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2443 var bySet = setMatchers.length > 0,
2444 byElement = elementMatchers.length > 0,
2445 superMatcher = function( seed, context, xml, results, outermost ) {
2446 var elem, j, matcher,
2449 unmatched = seed && [],
2451 contextBackup = outermostContext,
2453 // We must always have either seed elements or outermost context
2454 elems = seed || byElement && Expr.find.TAG( "*", outermost ),
2456 // Use integer dirruns iff this is the outermost matcher
2457 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
2462 // Support: IE 11+, Edge 17 - 18+
2463 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2464 // two documents; shallow comparisons work.
2465 // eslint-disable-next-line eqeqeq
2466 outermostContext = context == document || context || outermost;
2469 // Add elements passing elementMatchers directly to results
2470 // Support: iOS <=7 - 9 only
2471 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching
2472 // elements by id. (see trac-14142)
2473 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
2474 if ( byElement && elem ) {
2477 // Support: IE 11+, Edge 17 - 18+
2478 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2479 // two documents; shallow comparisons work.
2480 // eslint-disable-next-line eqeqeq
2481 if ( !context && elem.ownerDocument != document ) {
2482 setDocument( elem );
2483 xml = !documentIsHTML;
2485 while ( ( matcher = elementMatchers[ j++ ] ) ) {
2486 if ( matcher( elem, context || document, xml ) ) {
2487 push.call( results, elem );
2492 dirruns = dirrunsUnique;
2496 // Track unmatched elements for set filters
2499 // They will have gone through all possible matchers
2500 if ( ( elem = !matcher && elem ) ) {
2504 // Lengthen the array for every element, matched or not
2506 unmatched.push( elem );
2511 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2512 // makes the latter nonnegative.
2515 // Apply set filters to unmatched elements
2516 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2517 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2518 // no element matchers and no seed.
2519 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2520 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2521 // numerically zero.
2522 if ( bySet && i !== matchedCount ) {
2524 while ( ( matcher = setMatchers[ j++ ] ) ) {
2525 matcher( unmatched, setMatched, context, xml );
2530 // Reintegrate element matches to eliminate the need for sorting
2531 if ( matchedCount > 0 ) {
2533 if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
2534 setMatched[ i ] = pop.call( results );
2539 // Discard index placeholder values to get only actual matches
2540 setMatched = condense( setMatched );
2543 // Add matches to results
2544 push.apply( results, setMatched );
2546 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2547 if ( outermost && !seed && setMatched.length > 0 &&
2548 ( matchedCount + setMatchers.length ) > 1 ) {
2550 jQuery.uniqueSort( results );
2554 // Override manipulation of globals by nested matchers
2556 dirruns = dirrunsUnique;
2557 outermostContext = contextBackup;
2564 markFunction( superMatcher ) :
2568 function compile( selector, match /* Internal Use Only */ ) {
2571 elementMatchers = [],
2572 cached = compilerCache[ selector + " " ];
2576 // Generate a function of recursive functions that can be used to check each element
2578 match = tokenize( selector );
2582 cached = matcherFromTokens( match[ i ] );
2583 if ( cached[ expando ] ) {
2584 setMatchers.push( cached );
2586 elementMatchers.push( cached );
2590 // Cache the compiled function
2591 cached = compilerCache( selector,
2592 matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2594 // Save selector and tokenization
2595 cached.selector = selector;
2601 * A low-level selection function that works with jQuery's compiled
2602 * selector functions
2603 * @param {String|Function} selector A selector or a pre-compiled
2604 * selector function built with jQuery selector compile
2605 * @param {Element} context
2606 * @param {Array} [results]
2607 * @param {Array} [seed] A set of elements to match against
2609 function select( selector, context, results, seed ) {
2610 var i, tokens, token, type, find,
2611 compiled = typeof selector === "function" && selector,
2612 match = !seed && tokenize( ( selector = compiled.selector || selector ) );
2614 results = results || [];
2616 // Try to minimize operations if there is only one selector in the list and no seed
2617 // (the latter of which guarantees us context)
2618 if ( match.length === 1 ) {
2620 // Reduce context if the leading compound selector is an ID
2621 tokens = match[ 0 ] = match[ 0 ].slice( 0 );
2622 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
2623 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
2625 context = ( Expr.find.ID(
2626 token.matches[ 0 ].replace( runescape, funescape ),
2632 // Precompiled matchers will still verify ancestry, so step up a level
2633 } else if ( compiled ) {
2634 context = context.parentNode;
2637 selector = selector.slice( tokens.shift().value.length );
2640 // Fetch a seed set for right-to-left matching
2641 i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length;
2643 token = tokens[ i ];
2645 // Abort if we hit a combinator
2646 if ( Expr.relative[ ( type = token.type ) ] ) {
2649 if ( ( find = Expr.find[ type ] ) ) {
2651 // Search, expanding context for leading sibling combinators
2653 token.matches[ 0 ].replace( runescape, funescape ),
2654 rsibling.test( tokens[ 0 ].type ) &&
2655 testContext( context.parentNode ) || context
2658 // If seed is empty or no tokens remain, we can return early
2659 tokens.splice( i, 1 );
2660 selector = seed.length && toSelector( tokens );
2662 push.apply( results, seed );
2672 // Compile and execute a filtering function if one is not provided
2673 // Provide `match` to avoid retokenization if we modified the selector above
2674 ( compiled || compile( selector, match ) )(
2679 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2684 // One-time assignments
2686 // Support: Android <=4.0 - 4.1+
2688 support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
2690 // Initialize against the default document
2693 // Support: Android <=4.0 - 4.1+
2694 // Detached nodes confoundingly follow *each other*
2695 support.sortDetached = assert( function( el ) {
2697 // Should return 1, but returns 4 (following)
2698 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
2704 jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2705 jQuery.unique = jQuery.uniqueSort;
2707 // These have always been private, but they used to be documented as part of
2708 // Sizzle so let's maintain them for now for backwards compatibility purposes.
2709 find.compile = compile;
2710 find.select = select;
2711 find.setDocument = setDocument;
2712 find.tokenize = tokenize;
2714 find.escape = jQuery.escapeSelector;
2715 find.getText = jQuery.text;
2716 find.isXML = jQuery.isXMLDoc;
2717 find.selectors = jQuery.expr;
2718 find.support = jQuery.support;
2719 find.uniqueSort = jQuery.uniqueSort;
2726 var dir = function( elem, dir, until ) {
2728 truncate = until !== undefined;
2730 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2731 if ( elem.nodeType === 1 ) {
2732 if ( truncate && jQuery( elem ).is( until ) ) {
2735 matched.push( elem );
2742 var siblings = function( n, elem ) {
2745 for ( ; n; n = n.nextSibling ) {
2746 if ( n.nodeType === 1 && n !== elem ) {
2755 var rneedsContext = jQuery.expr.match.needsContext;
2757 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2761 // Implement the identical functionality for filter and not
2762 function winnow( elements, qualifier, not ) {
2763 if ( isFunction( qualifier ) ) {
2764 return jQuery.grep( elements, function( elem, i ) {
2765 return !!qualifier.call( elem, i, elem ) !== not;
2770 if ( qualifier.nodeType ) {
2771 return jQuery.grep( elements, function( elem ) {
2772 return ( elem === qualifier ) !== not;
2776 // Arraylike of elements (jQuery, arguments, Array)
2777 if ( typeof qualifier !== "string" ) {
2778 return jQuery.grep( elements, function( elem ) {
2779 return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
2783 // Filtered directly for both simple and complex selectors
2784 return jQuery.filter( qualifier, elements, not );
2787 jQuery.filter = function( expr, elems, not ) {
2788 var elem = elems[ 0 ];
2791 expr = ":not(" + expr + ")";
2794 if ( elems.length === 1 && elem.nodeType === 1 ) {
2795 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
2798 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2799 return elem.nodeType === 1;
2804 find: function( selector ) {
2809 if ( typeof selector !== "string" ) {
2810 return this.pushStack( jQuery( selector ).filter( function() {
2811 for ( i = 0; i < len; i++ ) {
2812 if ( jQuery.contains( self[ i ], this ) ) {
2819 ret = this.pushStack( [] );
2821 for ( i = 0; i < len; i++ ) {
2822 jQuery.find( selector, self[ i ], ret );
2825 return len > 1 ? jQuery.uniqueSort( ret ) : ret;
2827 filter: function( selector ) {
2828 return this.pushStack( winnow( this, selector || [], false ) );
2830 not: function( selector ) {
2831 return this.pushStack( winnow( this, selector || [], true ) );
2833 is: function( selector ) {
2837 // If this is a positional/relative selector, check membership in the returned set
2838 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2839 typeof selector === "string" && rneedsContext.test( selector ) ?
2840 jQuery( selector ) :
2848 // Initialize a jQuery object
2851 // A central reference to the root jQuery(document)
2854 // A simple way to check for HTML strings
2855 // Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)
2856 // Strict HTML recognition (trac-11290: must start with <)
2857 // Shortcut simple #id case for speed
2858 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2860 init = jQuery.fn.init = function( selector, context, root ) {
2863 // HANDLE: $(""), $(null), $(undefined), $(false)
2868 // Method init() accepts an alternate rootjQuery
2869 // so migrate can support jQuery.sub (gh-2101)
2870 root = root || rootjQuery;
2872 // Handle HTML strings
2873 if ( typeof selector === "string" ) {
2874 if ( selector[ 0 ] === "<" &&
2875 selector[ selector.length - 1 ] === ">" &&
2876 selector.length >= 3 ) {
2878 // Assume that strings that start and end with <> are HTML and skip the regex check
2879 match = [ null, selector, null ];
2882 match = rquickExpr.exec( selector );
2885 // Match html or make sure no context is specified for #id
2886 if ( match && ( match[ 1 ] || !context ) ) {
2888 // HANDLE: $(html) -> $(array)
2890 context = context instanceof jQuery ? context[ 0 ] : context;
2892 // Option to run scripts is true for back-compat
2893 // Intentionally let the error be thrown if parseHTML is not present
2894 jQuery.merge( this, jQuery.parseHTML(
2896 context && context.nodeType ? context.ownerDocument || context : document,
2900 // HANDLE: $(html, props)
2901 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2902 for ( match in context ) {
2904 // Properties of context are called as methods if possible
2905 if ( isFunction( this[ match ] ) ) {
2906 this[ match ]( context[ match ] );
2908 // ...and otherwise set as attributes
2910 this.attr( match, context[ match ] );
2919 elem = document.getElementById( match[ 2 ] );
2923 // Inject the element directly into the jQuery object
2930 // HANDLE: $(expr, $(...))
2931 } else if ( !context || context.jquery ) {
2932 return ( context || root ).find( selector );
2934 // HANDLE: $(expr, context)
2935 // (which is just equivalent to: $(context).find(expr)
2937 return this.constructor( context ).find( selector );
2940 // HANDLE: $(DOMElement)
2941 } else if ( selector.nodeType ) {
2942 this[ 0 ] = selector;
2946 // HANDLE: $(function)
2947 // Shortcut for document ready
2948 } else if ( isFunction( selector ) ) {
2949 return root.ready !== undefined ?
2950 root.ready( selector ) :
2952 // Execute immediately if ready is not present
2956 return jQuery.makeArray( selector, this );
2959 // Give the init function the jQuery prototype for later instantiation
2960 init.prototype = jQuery.fn;
2962 // Initialize central reference
2963 rootjQuery = jQuery( document );
2966 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2968 // Methods guaranteed to produce a unique set when starting from a unique set
2969 guaranteedUnique = {
2977 has: function( target ) {
2978 var targets = jQuery( target, this ),
2981 return this.filter( function() {
2983 for ( ; i < l; i++ ) {
2984 if ( jQuery.contains( this, targets[ i ] ) ) {
2991 closest: function( selectors, context ) {
2996 targets = typeof selectors !== "string" && jQuery( selectors );
2998 // Positional selectors never match, since there's no _selection_ context
2999 if ( !rneedsContext.test( selectors ) ) {
3000 for ( ; i < l; i++ ) {
3001 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3003 // Always skip document fragments
3004 if ( cur.nodeType < 11 && ( targets ?
3005 targets.index( cur ) > -1 :
3007 // Don't pass non-elements to jQuery#find
3008 cur.nodeType === 1 &&
3009 jQuery.find.matchesSelector( cur, selectors ) ) ) {
3011 matched.push( cur );
3018 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3021 // Determine the position of an element within the set
3022 index: function( elem ) {
3024 // No argument, return index in parent
3026 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3029 // Index in selector
3030 if ( typeof elem === "string" ) {
3031 return indexOf.call( jQuery( elem ), this[ 0 ] );
3034 // Locate the position of the desired element
3035 return indexOf.call( this,
3037 // If it receives a jQuery object, the first element is used
3038 elem.jquery ? elem[ 0 ] : elem
3042 add: function( selector, context ) {
3043 return this.pushStack(
3045 jQuery.merge( this.get(), jQuery( selector, context ) )
3050 addBack: function( selector ) {
3051 return this.add( selector == null ?
3052 this.prevObject : this.prevObject.filter( selector )
3057 function sibling( cur, dir ) {
3058 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
3063 parent: function( elem ) {
3064 var parent = elem.parentNode;
3065 return parent && parent.nodeType !== 11 ? parent : null;
3067 parents: function( elem ) {
3068 return dir( elem, "parentNode" );
3070 parentsUntil: function( elem, _i, until ) {
3071 return dir( elem, "parentNode", until );
3073 next: function( elem ) {
3074 return sibling( elem, "nextSibling" );
3076 prev: function( elem ) {
3077 return sibling( elem, "previousSibling" );
3079 nextAll: function( elem ) {
3080 return dir( elem, "nextSibling" );
3082 prevAll: function( elem ) {
3083 return dir( elem, "previousSibling" );
3085 nextUntil: function( elem, _i, until ) {
3086 return dir( elem, "nextSibling", until );
3088 prevUntil: function( elem, _i, until ) {
3089 return dir( elem, "previousSibling", until );
3091 siblings: function( elem ) {
3092 return siblings( ( elem.parentNode || {} ).firstChild, elem );
3094 children: function( elem ) {
3095 return siblings( elem.firstChild );
3097 contents: function( elem ) {
3098 if ( elem.contentDocument != null &&
3101 // <object> elements with no `data` attribute has an object
3102 // `contentDocument` with a `null` prototype.
3103 getProto( elem.contentDocument ) ) {
3105 return elem.contentDocument;
3108 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3109 // Treat the template element as a regular one in browsers that
3110 // don't support it.
3111 if ( nodeName( elem, "template" ) ) {
3112 elem = elem.content || elem;
3115 return jQuery.merge( [], elem.childNodes );
3117 }, function( name, fn ) {
3118 jQuery.fn[ name ] = function( until, selector ) {
3119 var matched = jQuery.map( this, fn, until );
3121 if ( name.slice( -5 ) !== "Until" ) {
3125 if ( selector && typeof selector === "string" ) {
3126 matched = jQuery.filter( selector, matched );
3129 if ( this.length > 1 ) {
3131 // Remove duplicates
3132 if ( !guaranteedUnique[ name ] ) {
3133 jQuery.uniqueSort( matched );
3136 // Reverse order for parents* and prev-derivatives
3137 if ( rparentsprev.test( name ) ) {
3142 return this.pushStack( matched );
3145 var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
3149 // Convert String-formatted options into Object-formatted ones
3150 function createOptions( options ) {
3152 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
3153 object[ flag ] = true;
3159 * Create a callback list using the following parameters:
3161 * options: an optional list of space-separated options that will change how
3162 * the callback list behaves or a more traditional option object
3164 * By default a callback list will act like an event callback list and can be
3165 * "fired" multiple times.
3169 * once: will ensure the callback list can only be fired once (like a Deferred)
3171 * memory: will keep track of previous values and will call any callback added
3172 * after the list has been fired right away with the latest "memorized"
3173 * values (like a Deferred)
3175 * unique: will ensure a callback can only be added once (no duplicate in the list)
3177 * stopOnFalse: interrupt callings when a callback returns false
3180 jQuery.Callbacks = function( options ) {
3182 // Convert options from String-formatted to Object-formatted if needed
3183 // (we check in cache first)
3184 options = typeof options === "string" ?
3185 createOptions( options ) :
3186 jQuery.extend( {}, options );
3188 var // Flag to know if list is currently firing
3191 // Last fire value for non-forgettable lists
3194 // Flag to know if list was already fired
3197 // Flag to prevent firing
3200 // Actual callback list
3203 // Queue of execution data for repeatable lists
3206 // Index of currently firing callback (modified by add/remove as needed)
3212 // Enforce single-firing
3213 locked = locked || options.once;
3215 // Execute callbacks for all pending executions,
3216 // respecting firingIndex overrides and runtime changes
3217 fired = firing = true;
3218 for ( ; queue.length; firingIndex = -1 ) {
3219 memory = queue.shift();
3220 while ( ++firingIndex < list.length ) {
3222 // Run callback and check for early termination
3223 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3224 options.stopOnFalse ) {
3226 // Jump to end and forget the data so .add doesn't re-fire
3227 firingIndex = list.length;
3233 // Forget the data if we're done with it
3234 if ( !options.memory ) {
3240 // Clean up if we're done firing for good
3243 // Keep an empty list if we have data for future add calls
3247 // Otherwise, this object is spent
3254 // Actual Callbacks object
3257 // Add a callback or a collection of callbacks to the list
3261 // If we have memory from a past run, we should fire after adding
3262 if ( memory && !firing ) {
3263 firingIndex = list.length - 1;
3264 queue.push( memory );
3267 ( function add( args ) {
3268 jQuery.each( args, function( _, arg ) {
3269 if ( isFunction( arg ) ) {
3270 if ( !options.unique || !self.has( arg ) ) {
3273 } else if ( arg && arg.length && toType( arg ) !== "string" ) {
3275 // Inspect recursively
3281 if ( memory && !firing ) {
3288 // Remove a callback from the list
3289 remove: function() {
3290 jQuery.each( arguments, function( _, arg ) {
3292 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3293 list.splice( index, 1 );
3295 // Handle firing indexes
3296 if ( index <= firingIndex ) {
3304 // Check if a given callback is in the list.
3305 // If no argument is given, return whether or not list has callbacks attached.
3306 has: function( fn ) {
3308 jQuery.inArray( fn, list ) > -1 :
3312 // Remove all callbacks from the list
3320 // Disable .fire and .add
3321 // Abort any current/pending executions
3322 // Clear all callbacks and values
3323 disable: function() {
3324 locked = queue = [];
3328 disabled: function() {
3333 // Also disable .add unless we have memory (since it would have no effect)
3334 // Abort any pending executions
3336 locked = queue = [];
3337 if ( !memory && !firing ) {
3342 locked: function() {
3346 // Call all callbacks with the given context and arguments
3347 fireWith: function( context, args ) {
3350 args = [ context, args.slice ? args.slice() : args ];
3359 // Call all the callbacks with the given arguments
3361 self.fireWith( this, arguments );
3365 // To know if the callbacks have already been called at least once
3375 function Identity( v ) {
3378 function Thrower( ex ) {
3382 function adoptValue( value, resolve, reject, noValue ) {
3387 // Check for promise aspect first to privilege synchronous behavior
3388 if ( value && isFunction( ( method = value.promise ) ) ) {
3389 method.call( value ).done( resolve ).fail( reject );
3392 } else if ( value && isFunction( ( method = value.then ) ) ) {
3393 method.call( value, resolve, reject );
3395 // Other non-thenables
3398 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3399 // * false: [ value ].slice( 0 ) => resolve( value )
3400 // * true: [ value ].slice( 1 ) => resolve()
3401 resolve.apply( undefined, [ value ].slice( noValue ) );
3404 // For Promises/A+, convert exceptions into rejections
3405 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3406 // Deferred#then to conditionally suppress rejection.
3409 // Support: Android 4.0 only
3410 // Strict mode functions invoked without .call/.apply get global-object context
3411 reject.apply( undefined, [ value ] );
3417 Deferred: function( func ) {
3420 // action, add listener, callbacks,
3421 // ... .then handlers, argument index, [final state]
3422 [ "notify", "progress", jQuery.Callbacks( "memory" ),
3423 jQuery.Callbacks( "memory" ), 2 ],
3424 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
3425 jQuery.Callbacks( "once memory" ), 0, "resolved" ],
3426 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
3427 jQuery.Callbacks( "once memory" ), 1, "rejected" ]
3434 always: function() {
3435 deferred.done( arguments ).fail( arguments );
3438 "catch": function( fn ) {
3439 return promise.then( null, fn );
3442 // Keep pipe for back-compat
3443 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3444 var fns = arguments;
3446 return jQuery.Deferred( function( newDefer ) {
3447 jQuery.each( tuples, function( _i, tuple ) {
3449 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3450 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
3452 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3453 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3454 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3455 deferred[ tuple[ 1 ] ]( function() {
3456 var returned = fn && fn.apply( this, arguments );
3457 if ( returned && isFunction( returned.promise ) ) {
3459 .progress( newDefer.notify )
3460 .done( newDefer.resolve )
3461 .fail( newDefer.reject );
3463 newDefer[ tuple[ 0 ] + "With" ](
3465 fn ? [ returned ] : arguments
3473 then: function( onFulfilled, onRejected, onProgress ) {
3475 function resolve( depth, deferred, handler, special ) {
3479 mightThrow = function() {
3482 // Support: Promises/A+ section 2.3.3.3.3
3483 // https://promisesaplus.com/#point-59
3484 // Ignore double-resolution attempts
3485 if ( depth < maxDepth ) {
3489 returned = handler.apply( that, args );
3491 // Support: Promises/A+ section 2.3.1
3492 // https://promisesaplus.com/#point-48
3493 if ( returned === deferred.promise() ) {
3494 throw new TypeError( "Thenable self-resolution" );
3497 // Support: Promises/A+ sections 2.3.3.1, 3.5
3498 // https://promisesaplus.com/#point-54
3499 // https://promisesaplus.com/#point-75
3500 // Retrieve `then` only once
3503 // Support: Promises/A+ section 2.3.4
3504 // https://promisesaplus.com/#point-64
3505 // Only check objects and functions for thenability
3506 ( typeof returned === "object" ||
3507 typeof returned === "function" ) &&
3510 // Handle a returned thenable
3511 if ( isFunction( then ) ) {
3513 // Special processors (notify) just wait for resolution
3517 resolve( maxDepth, deferred, Identity, special ),
3518 resolve( maxDepth, deferred, Thrower, special )
3521 // Normal processors (resolve) also hook into progress
3524 // ...and disregard older resolution values
3529 resolve( maxDepth, deferred, Identity, special ),
3530 resolve( maxDepth, deferred, Thrower, special ),
3531 resolve( maxDepth, deferred, Identity,
3532 deferred.notifyWith )
3536 // Handle all other returned values
3539 // Only substitute handlers pass on context
3540 // and multiple values (non-spec behavior)
3541 if ( handler !== Identity ) {
3543 args = [ returned ];
3546 // Process the value(s)
3547 // Default process is resolve
3548 ( special || deferred.resolveWith )( that, args );
3552 // Only normal processors (resolve) catch and reject exceptions
3560 if ( jQuery.Deferred.exceptionHook ) {
3561 jQuery.Deferred.exceptionHook( e,
3565 // Support: Promises/A+ section 2.3.3.3.4.1
3566 // https://promisesaplus.com/#point-61
3567 // Ignore post-resolution exceptions
3568 if ( depth + 1 >= maxDepth ) {
3570 // Only substitute handlers pass on context
3571 // and multiple values (non-spec behavior)
3572 if ( handler !== Thrower ) {
3577 deferred.rejectWith( that, args );
3582 // Support: Promises/A+ section 2.3.3.3.1
3583 // https://promisesaplus.com/#point-57
3584 // Re-resolve promises immediately to dodge false rejection from
3585 // subsequent errors
3590 // Call an optional hook to record the error, in case of exception
3591 // since it's otherwise lost when execution goes async
3592 if ( jQuery.Deferred.getErrorHook ) {
3593 process.error = jQuery.Deferred.getErrorHook();
3595 // The deprecated alias of the above. While the name suggests
3596 // returning the stack, not an error instance, jQuery just passes
3597 // it directly to `console.warn` so both will work; an instance
3598 // just better cooperates with source maps.
3599 } else if ( jQuery.Deferred.getStackHook ) {
3600 process.error = jQuery.Deferred.getStackHook();
3602 window.setTimeout( process );
3607 return jQuery.Deferred( function( newDefer ) {
3609 // progress_handlers.add( ... )
3610 tuples[ 0 ][ 3 ].add(
3614 isFunction( onProgress ) ?
3621 // fulfilled_handlers.add( ... )
3622 tuples[ 1 ][ 3 ].add(
3626 isFunction( onFulfilled ) ?
3632 // rejected_handlers.add( ... )
3633 tuples[ 2 ][ 3 ].add(
3637 isFunction( onRejected ) ?
3645 // Get a promise for this deferred
3646 // If obj is provided, the promise aspect is added to the object
3647 promise: function( obj ) {
3648 return obj != null ? jQuery.extend( obj, promise ) : promise;
3653 // Add list-specific methods
3654 jQuery.each( tuples, function( i, tuple ) {
3655 var list = tuple[ 2 ],
3656 stateString = tuple[ 5 ];
3658 // promise.progress = list.add
3659 // promise.done = list.add
3660 // promise.fail = list.add
3661 promise[ tuple[ 1 ] ] = list.add;
3664 if ( stateString ) {
3668 // state = "resolved" (i.e., fulfilled)
3669 // state = "rejected"
3670 state = stateString;
3673 // rejected_callbacks.disable
3674 // fulfilled_callbacks.disable
3675 tuples[ 3 - i ][ 2 ].disable,
3677 // rejected_handlers.disable
3678 // fulfilled_handlers.disable
3679 tuples[ 3 - i ][ 3 ].disable,
3681 // progress_callbacks.lock
3682 tuples[ 0 ][ 2 ].lock,
3684 // progress_handlers.lock
3685 tuples[ 0 ][ 3 ].lock
3689 // progress_handlers.fire
3690 // fulfilled_handlers.fire
3691 // rejected_handlers.fire
3692 list.add( tuple[ 3 ].fire );
3694 // deferred.notify = function() { deferred.notifyWith(...) }
3695 // deferred.resolve = function() { deferred.resolveWith(...) }
3696 // deferred.reject = function() { deferred.rejectWith(...) }
3697 deferred[ tuple[ 0 ] ] = function() {
3698 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
3702 // deferred.notifyWith = list.fireWith
3703 // deferred.resolveWith = list.fireWith
3704 // deferred.rejectWith = list.fireWith
3705 deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3708 // Make the deferred a promise
3709 promise.promise( deferred );
3711 // Call given func if any
3713 func.call( deferred, deferred );
3721 when: function( singleValue ) {
3724 // count of uncompleted subordinates
3725 remaining = arguments.length,
3727 // count of unprocessed arguments
3730 // subordinate fulfillment data
3731 resolveContexts = Array( i ),
3732 resolveValues = slice.call( arguments ),
3734 // the primary Deferred
3735 primary = jQuery.Deferred(),
3737 // subordinate callback factory
3738 updateFunc = function( i ) {
3739 return function( value ) {
3740 resolveContexts[ i ] = this;
3741 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3742 if ( !( --remaining ) ) {
3743 primary.resolveWith( resolveContexts, resolveValues );
3748 // Single- and empty arguments are adopted like Promise.resolve
3749 if ( remaining <= 1 ) {
3750 adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
3753 // Use .then() to unwrap secondary thenables (cf. gh-3000)
3754 if ( primary.state() === "pending" ||
3755 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
3757 return primary.then();
3761 // Multiple arguments are aggregated like Promise.all array elements
3763 adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
3766 return primary.promise();
3771 // These usually indicate a programmer mistake during development,
3772 // warn about them ASAP rather than swallowing them by default.
3773 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3775 // If `jQuery.Deferred.getErrorHook` is defined, `asyncError` is an error
3776 // captured before the async barrier to get the original error cause
3777 // which may otherwise be hidden.
3778 jQuery.Deferred.exceptionHook = function( error, asyncError ) {
3780 // Support: IE 8 - 9 only
3781 // Console exists when dev tools are open, which can happen at any time
3782 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
3783 window.console.warn( "jQuery.Deferred exception: " + error.message,
3784 error.stack, asyncError );
3791 jQuery.readyException = function( error ) {
3792 window.setTimeout( function() {
3800 // The deferred used on DOM ready
3801 var readyList = jQuery.Deferred();
3803 jQuery.fn.ready = function( fn ) {
3808 // Wrap jQuery.readyException in a function so that the lookup
3809 // happens at the time of error handling instead of callback
3811 .catch( function( error ) {
3812 jQuery.readyException( error );
3820 // Is the DOM ready to be used? Set to true once it occurs.
3823 // A counter to track how many items to wait for before
3824 // the ready event fires. See trac-6781
3827 // Handle when the DOM is ready
3828 ready: function( wait ) {
3830 // Abort if there are pending holds or we're already ready
3831 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3835 // Remember that the DOM is ready
3836 jQuery.isReady = true;
3838 // If a normal DOM Ready event fired, decrement, and wait if need be
3839 if ( wait !== true && --jQuery.readyWait > 0 ) {
3843 // If there are functions bound, to execute
3844 readyList.resolveWith( document, [ jQuery ] );
3848 jQuery.ready.then = readyList.then;
3850 // The ready event handler and self cleanup method
3851 function completed() {
3852 document.removeEventListener( "DOMContentLoaded", completed );
3853 window.removeEventListener( "load", completed );
3857 // Catch cases where $(document).ready() is called
3858 // after the browser event has already occurred.
3859 // Support: IE <=9 - 10 only
3860 // Older IE sometimes signals "interactive" too soon
3861 if ( document.readyState === "complete" ||
3862 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3864 // Handle it asynchronously to allow scripts the opportunity to delay ready
3865 window.setTimeout( jQuery.ready );
3869 // Use the handy event callback
3870 document.addEventListener( "DOMContentLoaded", completed );
3872 // A fallback to window.onload, that will always work
3873 window.addEventListener( "load", completed );
3879 // Multifunctional method to get and set values of a collection
3880 // The value/s can optionally be executed if it's a function
3881 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3887 if ( toType( key ) === "object" ) {
3890 access( elems, fn, i, key[ i ], true, emptyGet, raw );
3894 } else if ( value !== undefined ) {
3897 if ( !isFunction( value ) ) {
3903 // Bulk operations run against the entire set
3905 fn.call( elems, value );
3908 // ...except when executing function values
3911 fn = function( elem, _key, value ) {
3912 return bulk.call( jQuery( elem ), value );
3918 for ( ; i < len; i++ ) {
3920 elems[ i ], key, raw ?
3922 value.call( elems[ i ], i, fn( elems[ i ], key ) )
3934 return fn.call( elems );
3937 return len ? fn( elems[ 0 ], key ) : emptyGet;
3941 // Matches dashed string for camelizing
3942 var rmsPrefix = /^-ms-/,
3943 rdashAlpha = /-([a-z])/g;
3945 // Used by camelCase as callback to replace()
3946 function fcamelCase( _all, letter ) {
3947 return letter.toUpperCase();
3950 // Convert dashed to camelCase; used by the css and data modules
3951 // Support: IE <=9 - 11, Edge 12 - 15
3952 // Microsoft forgot to hump their vendor prefix (trac-9572)
3953 function camelCase( string ) {
3954 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
3956 var acceptData = function( owner ) {
3960 // - Node.ELEMENT_NODE
3961 // - Node.DOCUMENT_NODE
3964 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
3971 this.expando = jQuery.expando + Data.uid++;
3978 cache: function( owner ) {
3980 // Check if the owner object already has a cache
3981 var value = owner[ this.expando ];
3983 // If not, create one
3987 // We can accept data for non-element nodes in modern browsers,
3988 // but we should not, see trac-8335.
3989 // Always return an empty object.
3990 if ( acceptData( owner ) ) {
3992 // If it is a node unlikely to be stringify-ed or looped over
3993 // use plain assignment
3994 if ( owner.nodeType ) {
3995 owner[ this.expando ] = value;
3997 // Otherwise secure it in a non-enumerable property
3998 // configurable must be true to allow the property to be
3999 // deleted when data is removed
4001 Object.defineProperty( owner, this.expando, {
4011 set: function( owner, data, value ) {
4013 cache = this.cache( owner );
4015 // Handle: [ owner, key, value ] args
4016 // Always use camelCase key (gh-2257)
4017 if ( typeof data === "string" ) {
4018 cache[ camelCase( data ) ] = value;
4020 // Handle: [ owner, { properties } ] args
4023 // Copy the properties one-by-one to the cache object
4024 for ( prop in data ) {
4025 cache[ camelCase( prop ) ] = data[ prop ];
4030 get: function( owner, key ) {
4031 return key === undefined ?
4032 this.cache( owner ) :
4034 // Always use camelCase key (gh-2257)
4035 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
4037 access: function( owner, key, value ) {
4039 // In cases where either:
4041 // 1. No key was specified
4042 // 2. A string key was specified, but no value provided
4044 // Take the "read" path and allow the get method to determine
4045 // which value to return, respectively either:
4047 // 1. The entire cache object
4048 // 2. The data stored at the key
4050 if ( key === undefined ||
4051 ( ( key && typeof key === "string" ) && value === undefined ) ) {
4053 return this.get( owner, key );
4056 // When the key is not a string, or both a key and value
4057 // are specified, set or extend (existing objects) with either:
4059 // 1. An object of properties
4060 // 2. A key and value
4062 this.set( owner, key, value );
4064 // Since the "set" path can have two possible entry points
4065 // return the expected data based on which path was taken[*]
4066 return value !== undefined ? value : key;
4068 remove: function( owner, key ) {
4070 cache = owner[ this.expando ];
4072 if ( cache === undefined ) {
4076 if ( key !== undefined ) {
4078 // Support array or space separated string of keys
4079 if ( Array.isArray( key ) ) {
4081 // If key is an array of keys...
4082 // We always set camelCase keys, so remove that.
4083 key = key.map( camelCase );
4085 key = camelCase( key );
4087 // If a key with the spaces exists, use it.
4088 // Otherwise, create an array by matching non-whitespace
4089 key = key in cache ?
4091 ( key.match( rnothtmlwhite ) || [] );
4097 delete cache[ key[ i ] ];
4101 // Remove the expando if there's no more data
4102 if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
4104 // Support: Chrome <=35 - 45
4105 // Webkit & Blink performance suffers when deleting properties
4106 // from DOM nodes, so set to undefined instead
4107 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4108 if ( owner.nodeType ) {
4109 owner[ this.expando ] = undefined;
4111 delete owner[ this.expando ];
4115 hasData: function( owner ) {
4116 var cache = owner[ this.expando ];
4117 return cache !== undefined && !jQuery.isEmptyObject( cache );
4120 var dataPriv = new Data();
4122 var dataUser = new Data();
4126 // Implementation Summary
4128 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4129 // 2. Improve the module's maintainability by reducing the storage
4130 // paths to a single mechanism.
4131 // 3. Use the same single mechanism to support "private" and "user" data.
4132 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4133 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4134 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4136 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4137 rmultiDash = /[A-Z]/g;
4139 function getData( data ) {
4140 if ( data === "true" ) {
4144 if ( data === "false" ) {
4148 if ( data === "null" ) {
4152 // Only convert to a number if it doesn't change the string
4153 if ( data === +data + "" ) {
4157 if ( rbrace.test( data ) ) {
4158 return JSON.parse( data );
4164 function dataAttr( elem, key, data ) {
4167 // If nothing was found internally, try to fetch any
4168 // data from the HTML5 data-* attribute
4169 if ( data === undefined && elem.nodeType === 1 ) {
4170 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
4171 data = elem.getAttribute( name );
4173 if ( typeof data === "string" ) {
4175 data = getData( data );
4178 // Make sure we set the data so it isn't changed later
4179 dataUser.set( elem, key, data );
4188 hasData: function( elem ) {
4189 return dataUser.hasData( elem ) || dataPriv.hasData( elem );
4192 data: function( elem, name, data ) {
4193 return dataUser.access( elem, name, data );
4196 removeData: function( elem, name ) {
4197 dataUser.remove( elem, name );
4200 // TODO: Now that all calls to _data and _removeData have been replaced
4201 // with direct calls to dataPriv methods, these can be deprecated.
4202 _data: function( elem, name, data ) {
4203 return dataPriv.access( elem, name, data );
4206 _removeData: function( elem, name ) {
4207 dataPriv.remove( elem, name );
4212 data: function( key, value ) {
4215 attrs = elem && elem.attributes;
4218 if ( key === undefined ) {
4219 if ( this.length ) {
4220 data = dataUser.get( elem );
4222 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
4226 // Support: IE 11 only
4227 // The attrs elements can be null (trac-14894)
4229 name = attrs[ i ].name;
4230 if ( name.indexOf( "data-" ) === 0 ) {
4231 name = camelCase( name.slice( 5 ) );
4232 dataAttr( elem, name, data[ name ] );
4236 dataPriv.set( elem, "hasDataAttrs", true );
4243 // Sets multiple values
4244 if ( typeof key === "object" ) {
4245 return this.each( function() {
4246 dataUser.set( this, key );
4250 return access( this, function( value ) {
4253 // The calling jQuery object (element matches) is not empty
4254 // (and therefore has an element appears at this[ 0 ]) and the
4255 // `value` parameter was not undefined. An empty jQuery object
4256 // will result in `undefined` for elem = this[ 0 ] which will
4257 // throw an exception if an attempt to read a data cache is made.
4258 if ( elem && value === undefined ) {
4260 // Attempt to get data from the cache
4261 // The key will always be camelCased in Data
4262 data = dataUser.get( elem, key );
4263 if ( data !== undefined ) {
4267 // Attempt to "discover" the data in
4268 // HTML5 custom data-* attrs
4269 data = dataAttr( elem, key );
4270 if ( data !== undefined ) {
4274 // We tried really hard, but the data doesn't exist.
4279 this.each( function() {
4281 // We always store the camelCased key
4282 dataUser.set( this, key, value );
4284 }, null, value, arguments.length > 1, null, true );
4287 removeData: function( key ) {
4288 return this.each( function() {
4289 dataUser.remove( this, key );
4296 queue: function( elem, type, data ) {
4300 type = ( type || "fx" ) + "queue";
4301 queue = dataPriv.get( elem, type );
4303 // Speed up dequeue by getting out quickly if this is just a lookup
4305 if ( !queue || Array.isArray( data ) ) {
4306 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
4315 dequeue: function( elem, type ) {
4316 type = type || "fx";
4318 var queue = jQuery.queue( elem, type ),
4319 startLength = queue.length,
4321 hooks = jQuery._queueHooks( elem, type ),
4323 jQuery.dequeue( elem, type );
4326 // If the fx queue is dequeued, always remove the progress sentinel
4327 if ( fn === "inprogress" ) {
4334 // Add a progress sentinel to prevent the fx queue from being
4335 // automatically dequeued
4336 if ( type === "fx" ) {
4337 queue.unshift( "inprogress" );
4340 // Clear up the last queue stop function
4342 fn.call( elem, next, hooks );
4345 if ( !startLength && hooks ) {
4350 // Not public - generate a queueHooks object, or return the current one
4351 _queueHooks: function( elem, type ) {
4352 var key = type + "queueHooks";
4353 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
4354 empty: jQuery.Callbacks( "once memory" ).add( function() {
4355 dataPriv.remove( elem, [ type + "queue", key ] );
4362 queue: function( type, data ) {
4365 if ( typeof type !== "string" ) {
4371 if ( arguments.length < setter ) {
4372 return jQuery.queue( this[ 0 ], type );
4375 return data === undefined ?
4377 this.each( function() {
4378 var queue = jQuery.queue( this, type, data );
4380 // Ensure a hooks for this queue
4381 jQuery._queueHooks( this, type );
4383 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4384 jQuery.dequeue( this, type );
4388 dequeue: function( type ) {
4389 return this.each( function() {
4390 jQuery.dequeue( this, type );
4393 clearQueue: function( type ) {
4394 return this.queue( type || "fx", [] );
4397 // Get a promise resolved when queues of a certain type
4398 // are emptied (fx is the type by default)
4399 promise: function( type, obj ) {
4402 defer = jQuery.Deferred(),
4405 resolve = function() {
4406 if ( !( --count ) ) {
4407 defer.resolveWith( elements, [ elements ] );
4411 if ( typeof type !== "string" ) {
4415 type = type || "fx";
4418 tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
4419 if ( tmp && tmp.empty ) {
4421 tmp.empty.add( resolve );
4425 return defer.promise( obj );
4428 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4430 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4433 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4435 var documentElement = document.documentElement;
4439 var isAttached = function( elem ) {
4440 return jQuery.contains( elem.ownerDocument, elem );
4442 composed = { composed: true };
4444 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
4445 // Check attachment across shadow DOM boundaries when possible (gh-3504)
4446 // Support: iOS 10.0-10.2 only
4447 // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
4448 // leading to errors. We need to check for `getRootNode`.
4449 if ( documentElement.getRootNode ) {
4450 isAttached = function( elem ) {
4451 return jQuery.contains( elem.ownerDocument, elem ) ||
4452 elem.getRootNode( composed ) === elem.ownerDocument;
4455 var isHiddenWithinTree = function( elem, el ) {
4457 // isHiddenWithinTree might be called from jQuery#filter function;
4458 // in that case, element will be second argument
4461 // Inline style trumps all
4462 return elem.style.display === "none" ||
4463 elem.style.display === "" &&
4465 // Otherwise, check computed style
4466 // Support: Firefox <=43 - 45
4467 // Disconnected elements can have computed display: none, so first confirm that elem is
4469 isAttached( elem ) &&
4471 jQuery.css( elem, "display" ) === "none";
4476 function adjustCSS( elem, prop, valueParts, tween ) {
4477 var adjusted, scale,
4479 currentValue = tween ?
4484 return jQuery.css( elem, prop, "" );
4486 initial = currentValue(),
4487 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4489 // Starting value computation is required for potential unit mismatches
4490 initialInUnit = elem.nodeType &&
4491 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4492 rcssNum.exec( jQuery.css( elem, prop ) );
4494 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4496 // Support: Firefox <=54
4497 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
4498 initial = initial / 2;
4500 // Trust units reported by jQuery.css
4501 unit = unit || initialInUnit[ 3 ];
4503 // Iteratively approximate from a nonzero starting point
4504 initialInUnit = +initial || 1;
4506 while ( maxIterations-- ) {
4508 // Evaluate and update our best guess (doubling guesses that zero out).
4509 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
4510 jQuery.style( elem, prop, initialInUnit + unit );
4511 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
4514 initialInUnit = initialInUnit / scale;
4518 initialInUnit = initialInUnit * 2;
4519 jQuery.style( elem, prop, initialInUnit + unit );
4521 // Make sure we update the tween properties later on
4522 valueParts = valueParts || [];
4526 initialInUnit = +initialInUnit || +initial || 0;
4528 // Apply relative offset (+=/-=) if specified
4529 adjusted = valueParts[ 1 ] ?
4530 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4534 tween.start = initialInUnit;
4535 tween.end = adjusted;
4542 var defaultDisplayMap = {};
4544 function getDefaultDisplay( elem ) {
4546 doc = elem.ownerDocument,
4547 nodeName = elem.nodeName,
4548 display = defaultDisplayMap[ nodeName ];
4554 temp = doc.body.appendChild( doc.createElement( nodeName ) );
4555 display = jQuery.css( temp, "display" );
4557 temp.parentNode.removeChild( temp );
4559 if ( display === "none" ) {
4562 defaultDisplayMap[ nodeName ] = display;
4567 function showHide( elements, show ) {
4571 length = elements.length;
4573 // Determine new display value for elements that need to change
4574 for ( ; index < length; index++ ) {
4575 elem = elements[ index ];
4576 if ( !elem.style ) {
4580 display = elem.style.display;
4583 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4584 // check is required in this first loop unless we have a nonempty display value (either
4585 // inline or about-to-be-restored)
4586 if ( display === "none" ) {
4587 values[ index ] = dataPriv.get( elem, "display" ) || null;
4588 if ( !values[ index ] ) {
4589 elem.style.display = "";
4592 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
4593 values[ index ] = getDefaultDisplay( elem );
4596 if ( display !== "none" ) {
4597 values[ index ] = "none";
4599 // Remember what we're overwriting
4600 dataPriv.set( elem, "display", display );
4605 // Set the display of the elements in a second loop to avoid constant reflow
4606 for ( index = 0; index < length; index++ ) {
4607 if ( values[ index ] != null ) {
4608 elements[ index ].style.display = values[ index ];
4617 return showHide( this, true );
4620 return showHide( this );
4622 toggle: function( state ) {
4623 if ( typeof state === "boolean" ) {
4624 return state ? this.show() : this.hide();
4627 return this.each( function() {
4628 if ( isHiddenWithinTree( this ) ) {
4629 jQuery( this ).show();
4631 jQuery( this ).hide();
4636 var rcheckableType = ( /^(?:checkbox|radio)$/i );
4638 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
4640 var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
4645 var fragment = document.createDocumentFragment(),
4646 div = fragment.appendChild( document.createElement( "div" ) ),
4647 input = document.createElement( "input" );
4649 // Support: Android 4.0 - 4.3 only
4650 // Check state lost if the name is set (trac-11217)
4651 // Support: Windows Web Apps (WWA)
4652 // `name` and `type` must use .setAttribute for WWA (trac-14901)
4653 input.setAttribute( "type", "radio" );
4654 input.setAttribute( "checked", "checked" );
4655 input.setAttribute( "name", "t" );
4657 div.appendChild( input );
4659 // Support: Android <=4.1 only
4660 // Older WebKit doesn't clone checked state correctly in fragments
4661 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4663 // Support: IE <=11 only
4664 // Make sure textarea (and checkbox) defaultValue is properly cloned
4665 div.innerHTML = "<textarea>x</textarea>";
4666 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4668 // Support: IE <=9 only
4669 // IE <=9 replaces <option> tags with their contents when inserted outside of
4670 // the select element.
4671 div.innerHTML = "<option></option>";
4672 support.option = !!div.lastChild;
4676 // We have to close these tags to support XHTML (trac-13200)
4679 // XHTML parsers do not magically insert elements in the
4680 // same way that tag soup parsers do. So we cannot shorten
4681 // this by omitting <tbody> or other required elements.
4682 thead: [ 1, "<table>", "</table>" ],
4683 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4684 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4685 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4687 _default: [ 0, "", "" ]
4690 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4691 wrapMap.th = wrapMap.td;
4693 // Support: IE <=9 only
4694 if ( !support.option ) {
4695 wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
4699 function getAll( context, tag ) {
4701 // Support: IE <=9 - 11 only
4702 // Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
4705 if ( typeof context.getElementsByTagName !== "undefined" ) {
4706 ret = context.getElementsByTagName( tag || "*" );
4708 } else if ( typeof context.querySelectorAll !== "undefined" ) {
4709 ret = context.querySelectorAll( tag || "*" );
4715 if ( tag === undefined || tag && nodeName( context, tag ) ) {
4716 return jQuery.merge( [ context ], ret );
4723 // Mark scripts as having already been evaluated
4724 function setGlobalEval( elems, refElements ) {
4728 for ( ; i < l; i++ ) {
4732 !refElements || dataPriv.get( refElements[ i ], "globalEval" )
4738 var rhtml = /<|&#?\w+;/;
4740 function buildFragment( elems, context, scripts, selection, ignored ) {
4741 var elem, tmp, tag, wrap, attached, j,
4742 fragment = context.createDocumentFragment(),
4747 for ( ; i < l; i++ ) {
4750 if ( elem || elem === 0 ) {
4752 // Add nodes directly
4753 if ( toType( elem ) === "object" ) {
4755 // Support: Android <=4.0 only, PhantomJS 1 only
4756 // push.apply(_, arraylike) throws on ancient WebKit
4757 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4759 // Convert non-html into a text node
4760 } else if ( !rhtml.test( elem ) ) {
4761 nodes.push( context.createTextNode( elem ) );
4763 // Convert html into DOM nodes
4765 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4767 // Deserialize a standard representation
4768 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4769 wrap = wrapMap[ tag ] || wrapMap._default;
4770 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4772 // Descend through wrappers to the right content
4775 tmp = tmp.lastChild;
4778 // Support: Android <=4.0 only, PhantomJS 1 only
4779 // push.apply(_, arraylike) throws on ancient WebKit
4780 jQuery.merge( nodes, tmp.childNodes );
4782 // Remember the top-level container
4783 tmp = fragment.firstChild;
4785 // Ensure the created nodes are orphaned (trac-12392)
4786 tmp.textContent = "";
4791 // Remove wrapper from fragment
4792 fragment.textContent = "";
4795 while ( ( elem = nodes[ i++ ] ) ) {
4797 // Skip elements already in the context collection (trac-4087)
4798 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4800 ignored.push( elem );
4805 attached = isAttached( elem );
4807 // Append to fragment
4808 tmp = getAll( fragment.appendChild( elem ), "script" );
4810 // Preserve script evaluation history
4812 setGlobalEval( tmp );
4815 // Capture executables
4818 while ( ( elem = tmp[ j++ ] ) ) {
4819 if ( rscriptType.test( elem.type || "" ) ) {
4820 scripts.push( elem );
4830 var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4832 function returnTrue() {
4836 function returnFalse() {
4840 function on( elem, types, selector, data, fn, one ) {
4843 // Types can be a map of types/handlers
4844 if ( typeof types === "object" ) {
4846 // ( types-Object, selector, data )
4847 if ( typeof selector !== "string" ) {
4849 // ( types-Object, data )
4850 data = data || selector;
4851 selector = undefined;
4853 for ( type in types ) {
4854 on( elem, type, selector, data, types[ type ], one );
4859 if ( data == null && fn == null ) {
4863 data = selector = undefined;
4864 } else if ( fn == null ) {
4865 if ( typeof selector === "string" ) {
4867 // ( types, selector, fn )
4872 // ( types, data, fn )
4875 selector = undefined;
4878 if ( fn === false ) {
4886 fn = function( event ) {
4888 // Can use an empty set, since event contains the info
4889 jQuery().off( event );
4890 return origFn.apply( this, arguments );
4893 // Use same guid so caller can remove using origFn
4894 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4896 return elem.each( function() {
4897 jQuery.event.add( this, types, fn, data, selector );
4902 * Helper functions for managing events -- not part of the public interface.
4903 * Props to Dean Edwards' addEvent library for many of the ideas.
4909 add: function( elem, types, handler, data, selector ) {
4911 var handleObjIn, eventHandle, tmp,
4912 events, t, handleObj,
4913 special, handlers, type, namespaces, origType,
4914 elemData = dataPriv.get( elem );
4916 // Only attach events to objects that accept data
4917 if ( !acceptData( elem ) ) {
4921 // Caller can pass in an object of custom data in lieu of the handler
4922 if ( handler.handler ) {
4923 handleObjIn = handler;
4924 handler = handleObjIn.handler;
4925 selector = handleObjIn.selector;
4928 // Ensure that invalid selectors throw exceptions at attach time
4929 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
4931 jQuery.find.matchesSelector( documentElement, selector );
4934 // Make sure that the handler has a unique ID, used to find/remove it later
4935 if ( !handler.guid ) {
4936 handler.guid = jQuery.guid++;
4939 // Init the element's event structure and main handler, if this is the first
4940 if ( !( events = elemData.events ) ) {
4941 events = elemData.events = Object.create( null );
4943 if ( !( eventHandle = elemData.handle ) ) {
4944 eventHandle = elemData.handle = function( e ) {
4946 // Discard the second event of a jQuery.event.trigger() and
4947 // when an event is called after a page has unloaded
4948 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
4949 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
4953 // Handle multiple events separated by a space
4954 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
4957 tmp = rtypenamespace.exec( types[ t ] ) || [];
4958 type = origType = tmp[ 1 ];
4959 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4961 // There *must* be a type, no attaching namespace-only handlers
4966 // If event changes its type, use the special event handlers for the changed type
4967 special = jQuery.event.special[ type ] || {};
4969 // If selector defined, determine special event api type, otherwise given type
4970 type = ( selector ? special.delegateType : special.bindType ) || type;
4972 // Update special based on newly reset type
4973 special = jQuery.event.special[ type ] || {};
4975 // handleObj is passed to all event handlers
4976 handleObj = jQuery.extend( {
4983 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4984 namespace: namespaces.join( "." )
4987 // Init the event handler queue if we're the first
4988 if ( !( handlers = events[ type ] ) ) {
4989 handlers = events[ type ] = [];
4990 handlers.delegateCount = 0;
4992 // Only use addEventListener if the special events handler returns false
4993 if ( !special.setup ||
4994 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4996 if ( elem.addEventListener ) {
4997 elem.addEventListener( type, eventHandle );
5002 if ( special.add ) {
5003 special.add.call( elem, handleObj );
5005 if ( !handleObj.handler.guid ) {
5006 handleObj.handler.guid = handler.guid;
5010 // Add to the element's handler list, delegates in front
5012 handlers.splice( handlers.delegateCount++, 0, handleObj );
5014 handlers.push( handleObj );
5017 // Keep track of which events have ever been used, for event optimization
5018 jQuery.event.global[ type ] = true;
5023 // Detach an event or set of events from an element
5024 remove: function( elem, types, handler, selector, mappedTypes ) {
5026 var j, origCount, tmp,
5027 events, t, handleObj,
5028 special, handlers, type, namespaces, origType,
5029 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
5031 if ( !elemData || !( events = elemData.events ) ) {
5035 // Once for each type.namespace in types; type may be omitted
5036 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
5039 tmp = rtypenamespace.exec( types[ t ] ) || [];
5040 type = origType = tmp[ 1 ];
5041 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5043 // Unbind all events (on this namespace, if provided) for the element
5045 for ( type in events ) {
5046 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5051 special = jQuery.event.special[ type ] || {};
5052 type = ( selector ? special.delegateType : special.bindType ) || type;
5053 handlers = events[ type ] || [];
5055 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5057 // Remove matching events
5058 origCount = j = handlers.length;
5060 handleObj = handlers[ j ];
5062 if ( ( mappedTypes || origType === handleObj.origType ) &&
5063 ( !handler || handler.guid === handleObj.guid ) &&
5064 ( !tmp || tmp.test( handleObj.namespace ) ) &&
5065 ( !selector || selector === handleObj.selector ||
5066 selector === "**" && handleObj.selector ) ) {
5067 handlers.splice( j, 1 );
5069 if ( handleObj.selector ) {
5070 handlers.delegateCount--;
5072 if ( special.remove ) {
5073 special.remove.call( elem, handleObj );
5078 // Remove generic event handler if we removed something and no more handlers exist
5079 // (avoids potential for endless recursion during removal of special event handlers)
5080 if ( origCount && !handlers.length ) {
5081 if ( !special.teardown ||
5082 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5084 jQuery.removeEvent( elem, type, elemData.handle );
5087 delete events[ type ];
5091 // Remove data and the expando if it's no longer used
5092 if ( jQuery.isEmptyObject( events ) ) {
5093 dataPriv.remove( elem, "handle events" );
5097 dispatch: function( nativeEvent ) {
5099 var i, j, ret, matched, handleObj, handlerQueue,
5100 args = new Array( arguments.length ),
5102 // Make a writable jQuery.Event from the native event object
5103 event = jQuery.event.fix( nativeEvent ),
5106 dataPriv.get( this, "events" ) || Object.create( null )
5107 )[ event.type ] || [],
5108 special = jQuery.event.special[ event.type ] || {};
5110 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5113 for ( i = 1; i < arguments.length; i++ ) {
5114 args[ i ] = arguments[ i ];
5117 event.delegateTarget = this;
5119 // Call the preDispatch hook for the mapped type, and let it bail if desired
5120 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5124 // Determine handlers
5125 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5127 // Run delegates first; they may want to stop propagation beneath us
5129 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5130 event.currentTarget = matched.elem;
5133 while ( ( handleObj = matched.handlers[ j++ ] ) &&
5134 !event.isImmediatePropagationStopped() ) {
5136 // If the event is namespaced, then each handler is only invoked if it is
5137 // specially universal or its namespaces are a superset of the event's.
5138 if ( !event.rnamespace || handleObj.namespace === false ||
5139 event.rnamespace.test( handleObj.namespace ) ) {
5141 event.handleObj = handleObj;
5142 event.data = handleObj.data;
5144 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5145 handleObj.handler ).apply( matched.elem, args );
5147 if ( ret !== undefined ) {
5148 if ( ( event.result = ret ) === false ) {
5149 event.preventDefault();
5150 event.stopPropagation();
5157 // Call the postDispatch hook for the mapped type
5158 if ( special.postDispatch ) {
5159 special.postDispatch.call( this, event );
5162 return event.result;
5165 handlers: function( event, handlers ) {
5166 var i, handleObj, sel, matchedHandlers, matchedSelectors,
5168 delegateCount = handlers.delegateCount,
5171 // Find delegate handlers
5172 if ( delegateCount &&
5175 // Black-hole SVG <use> instance trees (trac-13180)
5178 // Support: Firefox <=42
5179 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5180 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5181 // Support: IE 11 only
5182 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5183 !( event.type === "click" && event.button >= 1 ) ) {
5185 for ( ; cur !== this; cur = cur.parentNode || this ) {
5187 // Don't check non-elements (trac-13208)
5188 // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)
5189 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
5190 matchedHandlers = [];
5191 matchedSelectors = {};
5192 for ( i = 0; i < delegateCount; i++ ) {
5193 handleObj = handlers[ i ];
5195 // Don't conflict with Object.prototype properties (trac-13203)
5196 sel = handleObj.selector + " ";
5198 if ( matchedSelectors[ sel ] === undefined ) {
5199 matchedSelectors[ sel ] = handleObj.needsContext ?
5200 jQuery( sel, this ).index( cur ) > -1 :
5201 jQuery.find( sel, this, null, [ cur ] ).length;
5203 if ( matchedSelectors[ sel ] ) {
5204 matchedHandlers.push( handleObj );
5207 if ( matchedHandlers.length ) {
5208 handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
5214 // Add the remaining (directly-bound) handlers
5216 if ( delegateCount < handlers.length ) {
5217 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
5220 return handlerQueue;
5223 addProp: function( name, hook ) {
5224 Object.defineProperty( jQuery.Event.prototype, name, {
5228 get: isFunction( hook ) ?
5230 if ( this.originalEvent ) {
5231 return hook( this.originalEvent );
5235 if ( this.originalEvent ) {
5236 return this.originalEvent[ name ];
5240 set: function( value ) {
5241 Object.defineProperty( this, name, {
5251 fix: function( originalEvent ) {
5252 return originalEvent[ jQuery.expando ] ?
5254 new jQuery.Event( originalEvent );
5260 // Prevent triggered image.load events from bubbling to window.load
5265 // Utilize native event to ensure correct state for checkable inputs
5266 setup: function( data ) {
5268 // For mutual compressibility with _default, replace `this` access with a local var.
5269 // `|| data` is dead code meant only to preserve the variable through minification.
5270 var el = this || data;
5272 // Claim the first handler
5273 if ( rcheckableType.test( el.type ) &&
5274 el.click && nodeName( el, "input" ) ) {
5276 // dataPriv.set( el, "click", ... )
5277 leverageNative( el, "click", true );
5280 // Return false to allow normal processing in the caller
5283 trigger: function( data ) {
5285 // For mutual compressibility with _default, replace `this` access with a local var.
5286 // `|| data` is dead code meant only to preserve the variable through minification.
5287 var el = this || data;
5289 // Force setup before triggering a click
5290 if ( rcheckableType.test( el.type ) &&
5291 el.click && nodeName( el, "input" ) ) {
5293 leverageNative( el, "click" );
5296 // Return non-false to allow normal event-path propagation
5300 // For cross-browser consistency, suppress native .click() on links
5301 // Also prevent it if we're currently inside a leveraged native-event stack
5302 _default: function( event ) {
5303 var target = event.target;
5304 return rcheckableType.test( target.type ) &&
5305 target.click && nodeName( target, "input" ) &&
5306 dataPriv.get( target, "click" ) ||
5307 nodeName( target, "a" );
5312 postDispatch: function( event ) {
5314 // Support: Firefox 20+
5315 // Firefox doesn't alert if the returnValue field is not set.
5316 if ( event.result !== undefined && event.originalEvent ) {
5317 event.originalEvent.returnValue = event.result;
5324 // Ensure the presence of an event listener that handles manually-triggered
5325 // synthetic events by interrupting progress until reinvoked in response to
5326 // *native* events that it fires directly, ensuring that state changes have
5327 // already occurred before other listeners are invoked.
5328 function leverageNative( el, type, isSetup ) {
5330 // Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add
5332 if ( dataPriv.get( el, type ) === undefined ) {
5333 jQuery.event.add( el, type, returnTrue );
5338 // Register the controller as a special universal handler for all event namespaces
5339 dataPriv.set( el, type, false );
5340 jQuery.event.add( el, type, {
5342 handler: function( event ) {
5344 saved = dataPriv.get( this, type );
5346 if ( ( event.isTrigger & 1 ) && this[ type ] ) {
5348 // Interrupt processing of the outer synthetic .trigger()ed event
5351 // Store arguments for use when handling the inner native event
5352 // There will always be at least one argument (an event object), so this array
5353 // will not be confused with a leftover capture object.
5354 saved = slice.call( arguments );
5355 dataPriv.set( this, type, saved );
5357 // Trigger the native event and capture its result
5359 result = dataPriv.get( this, type );
5360 dataPriv.set( this, type, false );
5362 if ( saved !== result ) {
5364 // Cancel the outer synthetic event
5365 event.stopImmediatePropagation();
5366 event.preventDefault();
5371 // If this is an inner synthetic event for an event with a bubbling surrogate
5372 // (focus or blur), assume that the surrogate already propagated from triggering
5373 // the native event and prevent that from happening again here.
5374 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
5375 // bubbling surrogate propagates *after* the non-bubbling base), but that seems
5376 // less bad than duplication.
5377 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
5378 event.stopPropagation();
5381 // If this is a native event triggered above, everything is now in order
5382 // Fire an inner synthetic event with the original arguments
5383 } else if ( saved ) {
5385 // ...and capture the result
5386 dataPriv.set( this, type, jQuery.event.trigger(
5392 // Abort handling of the native event by all jQuery handlers while allowing
5393 // native handlers on the same element to run. On target, this is achieved
5394 // by stopping immediate propagation just on the jQuery event. However,
5395 // the native event is re-wrapped by a jQuery one on each level of the
5396 // propagation so the only way to stop it for jQuery is to stop it for
5397 // everyone via native `stopPropagation()`. This is not a problem for
5398 // focus/blur which don't bubble, but it does also stop click on checkboxes
5399 // and radios. We accept this limitation.
5400 event.stopPropagation();
5401 event.isImmediatePropagationStopped = returnTrue;
5407 jQuery.removeEvent = function( elem, type, handle ) {
5409 // This "if" is needed for plain objects
5410 if ( elem.removeEventListener ) {
5411 elem.removeEventListener( type, handle );
5415 jQuery.Event = function( src, props ) {
5417 // Allow instantiation without the 'new' keyword
5418 if ( !( this instanceof jQuery.Event ) ) {
5419 return new jQuery.Event( src, props );
5423 if ( src && src.type ) {
5424 this.originalEvent = src;
5425 this.type = src.type;
5427 // Events bubbling up the document may have been marked as prevented
5428 // by a handler lower down the tree; reflect the correct value.
5429 this.isDefaultPrevented = src.defaultPrevented ||
5430 src.defaultPrevented === undefined &&
5432 // Support: Android <=2.3 only
5433 src.returnValue === false ?
5437 // Create target properties
5438 // Support: Safari <=6 - 7 only
5439 // Target should not be a text node (trac-504, trac-13143)
5440 this.target = ( src.target && src.target.nodeType === 3 ) ?
5441 src.target.parentNode :
5444 this.currentTarget = src.currentTarget;
5445 this.relatedTarget = src.relatedTarget;
5452 // Put explicitly provided properties onto the event object
5454 jQuery.extend( this, props );
5457 // Create a timestamp if incoming event doesn't have one
5458 this.timeStamp = src && src.timeStamp || Date.now();
5461 this[ jQuery.expando ] = true;
5464 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5465 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5466 jQuery.Event.prototype = {
5467 constructor: jQuery.Event,
5468 isDefaultPrevented: returnFalse,
5469 isPropagationStopped: returnFalse,
5470 isImmediatePropagationStopped: returnFalse,
5473 preventDefault: function() {
5474 var e = this.originalEvent;
5476 this.isDefaultPrevented = returnTrue;
5478 if ( e && !this.isSimulated ) {
5482 stopPropagation: function() {
5483 var e = this.originalEvent;
5485 this.isPropagationStopped = returnTrue;
5487 if ( e && !this.isSimulated ) {
5488 e.stopPropagation();
5491 stopImmediatePropagation: function() {
5492 var e = this.originalEvent;
5494 this.isImmediatePropagationStopped = returnTrue;
5496 if ( e && !this.isSimulated ) {
5497 e.stopImmediatePropagation();
5500 this.stopPropagation();
5504 // Includes all common event props including KeyEvent and MouseEvent specific props
5509 changedTouches: true,
5533 targetTouches: true,
5537 }, jQuery.event.addProp );
5539 jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
5541 function focusMappedHandler( nativeEvent ) {
5542 if ( document.documentMode ) {
5545 // Attach a single focusin/focusout handler on the document while someone wants
5546 // focus/blur. This is because the former are synchronous in IE while the latter
5547 // are async. In other browsers, all those handlers are invoked synchronously.
5549 // `handle` from private data would already wrap the event, but we need
5550 // to change the `type` here.
5551 var handle = dataPriv.get( this, "handle" ),
5552 event = jQuery.event.fix( nativeEvent );
5553 event.type = nativeEvent.type === "focusin" ? "focus" : "blur";
5554 event.isSimulated = true;
5556 // First, handle focusin/focusout
5557 handle( nativeEvent );
5559 // ...then, handle focus/blur
5561 // focus/blur don't bubble while focusin/focusout do; simulate the former by only
5562 // invoking the handler at the lower level.
5563 if ( event.target === event.currentTarget ) {
5565 // The setup part calls `leverageNative`, which, in turn, calls
5566 // `jQuery.event.add`, so event handle will already have been set
5572 // For non-IE browsers, attach a single capturing handler on the document
5573 // while someone wants focusin/focusout.
5574 jQuery.event.simulate( delegateType, nativeEvent.target,
5575 jQuery.event.fix( nativeEvent ) );
5579 jQuery.event.special[ type ] = {
5581 // Utilize native event if possible so blur/focus sequence is correct
5586 // Claim the first handler
5587 // dataPriv.set( this, "focus", ... )
5588 // dataPriv.set( this, "blur", ... )
5589 leverageNative( this, type, true );
5591 if ( document.documentMode ) {
5593 // Support: IE 9 - 11+
5594 // We use the same native handler for focusin & focus (and focusout & blur)
5595 // so we need to coordinate setup & teardown parts between those events.
5596 // Use `delegateType` as the key as `type` is already used by `leverageNative`.
5597 attaches = dataPriv.get( this, delegateType );
5599 this.addEventListener( delegateType, focusMappedHandler );
5601 dataPriv.set( this, delegateType, ( attaches || 0 ) + 1 );
5604 // Return false to allow normal processing in the caller
5608 trigger: function() {
5610 // Force setup before trigger
5611 leverageNative( this, type );
5613 // Return non-false to allow normal event-path propagation
5617 teardown: function() {
5620 if ( document.documentMode ) {
5621 attaches = dataPriv.get( this, delegateType ) - 1;
5623 this.removeEventListener( delegateType, focusMappedHandler );
5624 dataPriv.remove( this, delegateType );
5626 dataPriv.set( this, delegateType, attaches );
5630 // Return false to indicate standard teardown should be applied
5635 // Suppress native focus or blur if we're currently inside
5636 // a leveraged native-event stack
5637 _default: function( event ) {
5638 return dataPriv.get( event.target, type );
5641 delegateType: delegateType
5644 // Support: Firefox <=44
5645 // Firefox doesn't have focus(in | out) events
5646 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
5648 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
5649 // focus(in | out) events fire after focus & blur events,
5650 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
5651 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
5653 // Support: IE 9 - 11+
5654 // To preserve relative focusin/focus & focusout/blur event order guaranteed on the 3.x branch,
5655 // attach a single handler for both events in IE.
5656 jQuery.event.special[ delegateType ] = {
5659 // Handle: regular nodes (via `this.ownerDocument`), window
5660 // (via `this.document`) & document (via `this`).
5661 var doc = this.ownerDocument || this.document || this,
5662 dataHolder = document.documentMode ? this : doc,
5663 attaches = dataPriv.get( dataHolder, delegateType );
5665 // Support: IE 9 - 11+
5666 // We use the same native handler for focusin & focus (and focusout & blur)
5667 // so we need to coordinate setup & teardown parts between those events.
5668 // Use `delegateType` as the key as `type` is already used by `leverageNative`.
5670 if ( document.documentMode ) {
5671 this.addEventListener( delegateType, focusMappedHandler );
5673 doc.addEventListener( type, focusMappedHandler, true );
5676 dataPriv.set( dataHolder, delegateType, ( attaches || 0 ) + 1 );
5678 teardown: function() {
5679 var doc = this.ownerDocument || this.document || this,
5680 dataHolder = document.documentMode ? this : doc,
5681 attaches = dataPriv.get( dataHolder, delegateType ) - 1;
5684 if ( document.documentMode ) {
5685 this.removeEventListener( delegateType, focusMappedHandler );
5687 doc.removeEventListener( type, focusMappedHandler, true );
5689 dataPriv.remove( dataHolder, delegateType );
5691 dataPriv.set( dataHolder, delegateType, attaches );
5697 // Create mouseenter/leave events using mouseover/out and event-time checks
5698 // so that event delegation works in jQuery.
5699 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5701 // Support: Safari 7 only
5702 // Safari sends mouseenter too often; see:
5703 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5704 // for the description of the bug (it existed in older Chrome versions as well).
5706 mouseenter: "mouseover",
5707 mouseleave: "mouseout",
5708 pointerenter: "pointerover",
5709 pointerleave: "pointerout"
5710 }, function( orig, fix ) {
5711 jQuery.event.special[ orig ] = {
5715 handle: function( event ) {
5718 related = event.relatedTarget,
5719 handleObj = event.handleObj;
5721 // For mouseenter/leave call the handler if related is outside the target.
5722 // NB: No relatedTarget if the mouse left/entered the browser window
5723 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5724 event.type = handleObj.origType;
5725 ret = handleObj.handler.apply( this, arguments );
5735 on: function( types, selector, data, fn ) {
5736 return on( this, types, selector, data, fn );
5738 one: function( types, selector, data, fn ) {
5739 return on( this, types, selector, data, fn, 1 );
5741 off: function( types, selector, fn ) {
5742 var handleObj, type;
5743 if ( types && types.preventDefault && types.handleObj ) {
5745 // ( event ) dispatched jQuery.Event
5746 handleObj = types.handleObj;
5747 jQuery( types.delegateTarget ).off(
5748 handleObj.namespace ?
5749 handleObj.origType + "." + handleObj.namespace :
5756 if ( typeof types === "object" ) {
5758 // ( types-object [, selector] )
5759 for ( type in types ) {
5760 this.off( type, selector, types[ type ] );
5764 if ( selector === false || typeof selector === "function" ) {
5768 selector = undefined;
5770 if ( fn === false ) {
5773 return this.each( function() {
5774 jQuery.event.remove( this, types, fn, selector );
5782 // Support: IE <=10 - 11, Edge 12 - 13 only
5783 // In IE/Edge using regex groups here causes severe slowdowns.
5784 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5785 rnoInnerhtml = /<script|<style|<link/i,
5787 // checked="checked" or checked
5788 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5790 rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g;
5792 // Prefer a tbody over its parent table for containing new rows
5793 function manipulationTarget( elem, content ) {
5794 if ( nodeName( elem, "table" ) &&
5795 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
5797 return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
5803 // Replace/restore the type attribute of script elements for safe DOM manipulation
5804 function disableScript( elem ) {
5805 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
5808 function restoreScript( elem ) {
5809 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
5810 elem.type = elem.type.slice( 5 );
5812 elem.removeAttribute( "type" );
5818 function cloneCopyEvent( src, dest ) {
5819 var i, l, type, pdataOld, udataOld, udataCur, events;
5821 if ( dest.nodeType !== 1 ) {
5825 // 1. Copy private data: events, handlers, etc.
5826 if ( dataPriv.hasData( src ) ) {
5827 pdataOld = dataPriv.get( src );
5828 events = pdataOld.events;
5831 dataPriv.remove( dest, "handle events" );
5833 for ( type in events ) {
5834 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5835 jQuery.event.add( dest, type, events[ type ][ i ] );
5841 // 2. Copy user data
5842 if ( dataUser.hasData( src ) ) {
5843 udataOld = dataUser.access( src );
5844 udataCur = jQuery.extend( {}, udataOld );
5846 dataUser.set( dest, udataCur );
5850 // Fix IE bugs, see support tests
5851 function fixInput( src, dest ) {
5852 var nodeName = dest.nodeName.toLowerCase();
5854 // Fails to persist the checked state of a cloned checkbox or radio button.
5855 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5856 dest.checked = src.checked;
5858 // Fails to return the selected option to the default selected state when cloning options
5859 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5860 dest.defaultValue = src.defaultValue;
5864 function domManip( collection, args, callback, ignored ) {
5866 // Flatten any nested arrays
5867 args = flat( args );
5869 var fragment, first, scripts, hasScripts, node, doc,
5871 l = collection.length,
5874 valueIsFunction = isFunction( value );
5876 // We can't cloneNode fragments that contain checked, in WebKit
5877 if ( valueIsFunction ||
5878 ( l > 1 && typeof value === "string" &&
5879 !support.checkClone && rchecked.test( value ) ) ) {
5880 return collection.each( function( index ) {
5881 var self = collection.eq( index );
5882 if ( valueIsFunction ) {
5883 args[ 0 ] = value.call( this, index, self.html() );
5885 domManip( self, args, callback, ignored );
5890 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5891 first = fragment.firstChild;
5893 if ( fragment.childNodes.length === 1 ) {
5897 // Require either new content or an interest in ignored elements to invoke the callback
5898 if ( first || ignored ) {
5899 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5900 hasScripts = scripts.length;
5902 // Use the original fragment for the last item
5903 // instead of the first because it can end up
5904 // being emptied incorrectly in certain situations (trac-8070).
5905 for ( ; i < l; i++ ) {
5908 if ( i !== iNoClone ) {
5909 node = jQuery.clone( node, true, true );
5911 // Keep references to cloned scripts for later restoration
5914 // Support: Android <=4.0 only, PhantomJS 1 only
5915 // push.apply(_, arraylike) throws on ancient WebKit
5916 jQuery.merge( scripts, getAll( node, "script" ) );
5920 callback.call( collection[ i ], node, i );
5924 doc = scripts[ scripts.length - 1 ].ownerDocument;
5926 // Re-enable scripts
5927 jQuery.map( scripts, restoreScript );
5929 // Evaluate executable scripts on first document insertion
5930 for ( i = 0; i < hasScripts; i++ ) {
5931 node = scripts[ i ];
5932 if ( rscriptType.test( node.type || "" ) &&
5933 !dataPriv.access( node, "globalEval" ) &&
5934 jQuery.contains( doc, node ) ) {
5936 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
5938 // Optional AJAX dependency, but won't run scripts if not present
5939 if ( jQuery._evalUrl && !node.noModule ) {
5940 jQuery._evalUrl( node.src, {
5941 nonce: node.nonce || node.getAttribute( "nonce" )
5946 // Unwrap a CDATA section containing script contents. This shouldn't be
5947 // needed as in XML documents they're already not visible when
5948 // inspecting element contents and in HTML documents they have no
5949 // meaning but we're preserving that logic for backwards compatibility.
5950 // This will be removed completely in 4.0. See gh-4904.
5951 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
5962 function remove( elem, selector, keepData ) {
5964 nodes = selector ? jQuery.filter( selector, elem ) : elem,
5967 for ( ; ( node = nodes[ i ] ) != null; i++ ) {
5968 if ( !keepData && node.nodeType === 1 ) {
5969 jQuery.cleanData( getAll( node ) );
5972 if ( node.parentNode ) {
5973 if ( keepData && isAttached( node ) ) {
5974 setGlobalEval( getAll( node, "script" ) );
5976 node.parentNode.removeChild( node );
5984 htmlPrefilter: function( html ) {
5988 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5989 var i, l, srcElements, destElements,
5990 clone = elem.cloneNode( true ),
5991 inPage = isAttached( elem );
5993 // Fix IE cloning issues
5994 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5995 !jQuery.isXMLDoc( elem ) ) {
5997 // We eschew jQuery#find here for performance reasons:
5998 // https://jsperf.com/getall-vs-sizzle/2
5999 destElements = getAll( clone );
6000 srcElements = getAll( elem );
6002 for ( i = 0, l = srcElements.length; i < l; i++ ) {
6003 fixInput( srcElements[ i ], destElements[ i ] );
6007 // Copy the events from the original to the clone
6008 if ( dataAndEvents ) {
6009 if ( deepDataAndEvents ) {
6010 srcElements = srcElements || getAll( elem );
6011 destElements = destElements || getAll( clone );
6013 for ( i = 0, l = srcElements.length; i < l; i++ ) {
6014 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
6017 cloneCopyEvent( elem, clone );
6021 // Preserve script evaluation history
6022 destElements = getAll( clone, "script" );
6023 if ( destElements.length > 0 ) {
6024 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6027 // Return the cloned set
6031 cleanData: function( elems ) {
6032 var data, elem, type,
6033 special = jQuery.event.special,
6036 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
6037 if ( acceptData( elem ) ) {
6038 if ( ( data = elem[ dataPriv.expando ] ) ) {
6039 if ( data.events ) {
6040 for ( type in data.events ) {
6041 if ( special[ type ] ) {
6042 jQuery.event.remove( elem, type );
6044 // This is a shortcut to avoid jQuery.event.remove's overhead
6046 jQuery.removeEvent( elem, type, data.handle );
6051 // Support: Chrome <=35 - 45+
6052 // Assign undefined instead of using delete, see Data#remove
6053 elem[ dataPriv.expando ] = undefined;
6055 if ( elem[ dataUser.expando ] ) {
6057 // Support: Chrome <=35 - 45+
6058 // Assign undefined instead of using delete, see Data#remove
6059 elem[ dataUser.expando ] = undefined;
6067 detach: function( selector ) {
6068 return remove( this, selector, true );
6071 remove: function( selector ) {
6072 return remove( this, selector );
6075 text: function( value ) {
6076 return access( this, function( value ) {
6077 return value === undefined ?
6078 jQuery.text( this ) :
6079 this.empty().each( function() {
6080 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6081 this.textContent = value;
6084 }, null, value, arguments.length );
6087 append: function() {
6088 return domManip( this, arguments, function( elem ) {
6089 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6090 var target = manipulationTarget( this, elem );
6091 target.appendChild( elem );
6096 prepend: function() {
6097 return domManip( this, arguments, function( elem ) {
6098 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6099 var target = manipulationTarget( this, elem );
6100 target.insertBefore( elem, target.firstChild );
6105 before: function() {
6106 return domManip( this, arguments, function( elem ) {
6107 if ( this.parentNode ) {
6108 this.parentNode.insertBefore( elem, this );
6114 return domManip( this, arguments, function( elem ) {
6115 if ( this.parentNode ) {
6116 this.parentNode.insertBefore( elem, this.nextSibling );
6125 for ( ; ( elem = this[ i ] ) != null; i++ ) {
6126 if ( elem.nodeType === 1 ) {
6128 // Prevent memory leaks
6129 jQuery.cleanData( getAll( elem, false ) );
6131 // Remove any remaining nodes
6132 elem.textContent = "";
6139 clone: function( dataAndEvents, deepDataAndEvents ) {
6140 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6141 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6143 return this.map( function() {
6144 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6148 html: function( value ) {
6149 return access( this, function( value ) {
6150 var elem = this[ 0 ] || {},
6154 if ( value === undefined && elem.nodeType === 1 ) {
6155 return elem.innerHTML;
6158 // See if we can take a shortcut and just use innerHTML
6159 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6160 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
6162 value = jQuery.htmlPrefilter( value );
6165 for ( ; i < l; i++ ) {
6166 elem = this[ i ] || {};
6168 // Remove element nodes and prevent memory leaks
6169 if ( elem.nodeType === 1 ) {
6170 jQuery.cleanData( getAll( elem, false ) );
6171 elem.innerHTML = value;
6177 // If using innerHTML throws an exception, use the fallback method
6182 this.empty().append( value );
6184 }, null, value, arguments.length );
6187 replaceWith: function() {
6190 // Make the changes, replacing each non-ignored context element with the new content
6191 return domManip( this, arguments, function( elem ) {
6192 var parent = this.parentNode;
6194 if ( jQuery.inArray( this, ignored ) < 0 ) {
6195 jQuery.cleanData( getAll( this ) );
6197 parent.replaceChild( elem, this );
6201 // Force callback invocation
6208 prependTo: "prepend",
6209 insertBefore: "before",
6210 insertAfter: "after",
6211 replaceAll: "replaceWith"
6212 }, function( name, original ) {
6213 jQuery.fn[ name ] = function( selector ) {
6216 insert = jQuery( selector ),
6217 last = insert.length - 1,
6220 for ( ; i <= last; i++ ) {
6221 elems = i === last ? this : this.clone( true );
6222 jQuery( insert[ i ] )[ original ]( elems );
6224 // Support: Android <=4.0 only, PhantomJS 1 only
6225 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6226 push.apply( ret, elems.get() );
6229 return this.pushStack( ret );
6232 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6234 var rcustomProp = /^--/;
6237 var getStyles = function( elem ) {
6239 // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150)
6240 // IE throws on elements created in popups
6241 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6242 var view = elem.ownerDocument.defaultView;
6244 if ( !view || !view.opener ) {
6248 return view.getComputedStyle( elem );
6251 var swap = function( elem, options, callback ) {
6255 // Remember the old values, and insert the new ones
6256 for ( name in options ) {
6257 old[ name ] = elem.style[ name ];
6258 elem.style[ name ] = options[ name ];
6261 ret = callback.call( elem );
6263 // Revert the old values
6264 for ( name in options ) {
6265 elem.style[ name ] = old[ name ];
6272 var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
6278 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6279 // so they're executed at the same time to save the second computation.
6280 function computeStyleTests() {
6282 // This is a singleton, we need to execute it only once
6287 container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
6288 "margin-top:1px;padding:0;border:0";
6290 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
6291 "margin:auto;border:1px;padding:1px;" +
6293 documentElement.appendChild( container ).appendChild( div );
6295 var divStyle = window.getComputedStyle( div );
6296 pixelPositionVal = divStyle.top !== "1%";
6298 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6299 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
6301 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
6302 // Some styles come back with percentage values, even though they shouldn't
6303 div.style.right = "60%";
6304 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
6306 // Support: IE 9 - 11 only
6307 // Detect misreporting of content dimensions for box-sizing:border-box elements
6308 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
6310 // Support: IE 9 only
6311 // Detect overflow:scroll screwiness (gh-3699)
6312 // Support: Chrome <=64
6313 // Don't get tricked when zoom affects offsetWidth (gh-4029)
6314 div.style.position = "absolute";
6315 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
6317 documentElement.removeChild( container );
6319 // Nullify the div so it wouldn't be stored in the memory and
6320 // it will also be a sign that checks already performed
6324 function roundPixelMeasures( measure ) {
6325 return Math.round( parseFloat( measure ) );
6328 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
6329 reliableTrDimensionsVal, reliableMarginLeftVal,
6330 container = document.createElement( "div" ),
6331 div = document.createElement( "div" );
6333 // Finish early in limited (non-browser) environments
6338 // Support: IE <=9 - 11 only
6339 // Style of cloned element affects source element cloned (trac-8908)
6340 div.style.backgroundClip = "content-box";
6341 div.cloneNode( true ).style.backgroundClip = "";
6342 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6344 jQuery.extend( support, {
6345 boxSizingReliable: function() {
6346 computeStyleTests();
6347 return boxSizingReliableVal;
6349 pixelBoxStyles: function() {
6350 computeStyleTests();
6351 return pixelBoxStylesVal;
6353 pixelPosition: function() {
6354 computeStyleTests();
6355 return pixelPositionVal;
6357 reliableMarginLeft: function() {
6358 computeStyleTests();
6359 return reliableMarginLeftVal;
6361 scrollboxSize: function() {
6362 computeStyleTests();
6363 return scrollboxSizeVal;
6366 // Support: IE 9 - 11+, Edge 15 - 18+
6367 // IE/Edge misreport `getComputedStyle` of table rows with width/height
6368 // set in CSS while `offset*` properties report correct values.
6369 // Behavior in IE 9 is more subtle than in newer versions & it passes
6370 // some versions of this test; make sure not to make it pass there!
6372 // Support: Firefox 70+
6373 // Only Firefox includes border widths
6374 // in computed dimensions. (gh-4529)
6375 reliableTrDimensions: function() {
6376 var table, tr, trChild, trStyle;
6377 if ( reliableTrDimensionsVal == null ) {
6378 table = document.createElement( "table" );
6379 tr = document.createElement( "tr" );
6380 trChild = document.createElement( "div" );
6382 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
6383 tr.style.cssText = "box-sizing:content-box;border:1px solid";
6385 // Support: Chrome 86+
6386 // Height set through cssText does not get applied.
6387 // Computed height then comes back as 0.
6388 tr.style.height = "1px";
6389 trChild.style.height = "9px";
6391 // Support: Android 8 Chrome 86+
6392 // In our bodyBackground.html iframe,
6393 // display for all div elements is set to "inline",
6394 // which causes a problem only in Android 8 Chrome 86.
6395 // Ensuring the div is `display: block`
6396 // gets around this issue.
6397 trChild.style.display = "block";
6400 .appendChild( table )
6402 .appendChild( trChild );
6404 trStyle = window.getComputedStyle( tr );
6405 reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
6406 parseInt( trStyle.borderTopWidth, 10 ) +
6407 parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
6409 documentElement.removeChild( table );
6411 return reliableTrDimensionsVal;
6417 function curCSS( elem, name, computed ) {
6418 var width, minWidth, maxWidth, ret,
6419 isCustomProp = rcustomProp.test( name ),
6421 // Support: Firefox 51+
6422 // Retrieving style before computed somehow
6423 // fixes an issue with getting wrong values
6424 // on detached elements
6427 computed = computed || getStyles( elem );
6429 // getPropertyValue is needed for:
6430 // .css('filter') (IE 9 only, trac-12537)
6431 // .css('--customProperty) (gh-3144)
6434 // Support: IE <=9 - 11+
6435 // IE only supports `"float"` in `getPropertyValue`; in computed styles
6436 // it's only available as `"cssFloat"`. We no longer modify properties
6437 // sent to `.css()` apart from camelCasing, so we need to check both.
6438 // Normally, this would create difference in behavior: if
6439 // `getPropertyValue` returns an empty string, the value returned
6440 // by `.css()` would be `undefined`. This is usually the case for
6441 // disconnected elements. However, in IE even disconnected elements
6442 // with no styles return `"none"` for `getPropertyValue( "float" )`
6443 ret = computed.getPropertyValue( name ) || computed[ name ];
6445 if ( isCustomProp && ret ) {
6447 // Support: Firefox 105+, Chrome <=105+
6448 // Spec requires trimming whitespace for custom properties (gh-4926).
6449 // Firefox only trims leading whitespace. Chrome just collapses
6450 // both leading & trailing whitespace to a single space.
6452 // Fall back to `undefined` if empty string returned.
6453 // This collapses a missing definition with property defined
6454 // and set to an empty string but there's no standard API
6455 // allowing us to differentiate them without a performance penalty
6456 // and returning `undefined` aligns with older jQuery.
6458 // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
6459 // as whitespace while CSS does not, but this is not a problem
6460 // because CSS preprocessing replaces them with U+000A LINE FEED
6461 // (which *is* CSS whitespace)
6462 // https://www.w3.org/TR/css-syntax-3/#input-preprocessing
6463 ret = ret.replace( rtrimCSS, "$1" ) || undefined;
6466 if ( ret === "" && !isAttached( elem ) ) {
6467 ret = jQuery.style( elem, name );
6470 // A tribute to the "awesome hack by Dean Edwards"
6471 // Android Browser returns percentage for some values,
6472 // but width seems to be reliably pixels.
6473 // This is against the CSSOM draft spec:
6474 // https://drafts.csswg.org/cssom/#resolved-values
6475 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
6477 // Remember the original values
6478 width = style.width;
6479 minWidth = style.minWidth;
6480 maxWidth = style.maxWidth;
6482 // Put in the new values to get a computed value out
6483 style.minWidth = style.maxWidth = style.width = ret;
6484 ret = computed.width;
6486 // Revert the changed values
6487 style.width = width;
6488 style.minWidth = minWidth;
6489 style.maxWidth = maxWidth;
6493 return ret !== undefined ?
6495 // Support: IE <=9 - 11 only
6496 // IE returns zIndex value as an integer.
6502 function addGetHookIf( conditionFn, hookFn ) {
6504 // Define the hook, we'll check on the first run if it's really needed.
6507 if ( conditionFn() ) {
6509 // Hook not needed (or it's not possible to use it due
6510 // to missing dependency), remove it.
6515 // Hook needed; redefine it so that the support test is not executed again.
6516 return ( this.get = hookFn ).apply( this, arguments );
6522 var cssPrefixes = [ "Webkit", "Moz", "ms" ],
6523 emptyStyle = document.createElement( "div" ).style,
6526 // Return a vendor-prefixed property or undefined
6527 function vendorPropName( name ) {
6529 // Check for vendor prefixed names
6530 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
6531 i = cssPrefixes.length;
6534 name = cssPrefixes[ i ] + capName;
6535 if ( name in emptyStyle ) {
6541 // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
6542 function finalPropName( name ) {
6543 var final = jQuery.cssProps[ name ] || vendorProps[ name ];
6548 if ( name in emptyStyle ) {
6551 return vendorProps[ name ] = vendorPropName( name ) || name;
6557 // Swappable if display is none or starts with table
6558 // except "table", "table-cell", or "table-caption"
6559 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6560 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6561 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6562 cssNormalTransform = {
6567 function setPositiveNumber( _elem, value, subtract ) {
6569 // Any relative (+/-) values have already been
6570 // normalized at this point
6571 var matches = rcssNum.exec( value );
6574 // Guard against undefined "subtract", e.g., when used as in cssHooks
6575 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
6579 function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
6580 var i = dimension === "width" ? 1 : 0,
6585 // Adjustment may not be necessary
6586 if ( box === ( isBorderBox ? "border" : "content" ) ) {
6590 for ( ; i < 4; i += 2 ) {
6592 // Both box models exclude margin
6593 // Count margin delta separately to only add it after scroll gutter adjustment.
6594 // This is needed to make negative margins work with `outerHeight( true )` (gh-3982).
6595 if ( box === "margin" ) {
6596 marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
6599 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6600 if ( !isBorderBox ) {
6603 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6605 // For "border" or "margin", add border
6606 if ( box !== "padding" ) {
6607 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6609 // But still keep track of it otherwise
6611 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6614 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6615 // "padding" or "margin"
6618 // For "content", subtract padding
6619 if ( box === "content" ) {
6620 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6623 // For "content" or "padding", subtract border
6624 if ( box !== "margin" ) {
6625 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6630 // Account for positive content-box scroll gutter when requested by providing computedVal
6631 if ( !isBorderBox && computedVal >= 0 ) {
6633 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6634 // Assuming integer scroll gutter, subtract the rest and round down
6635 delta += Math.max( 0, Math.ceil(
6636 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
6642 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
6643 // Use an explicit zero to avoid NaN (gh-3964)
6647 return delta + marginDelta;
6650 function getWidthOrHeight( elem, dimension, extra ) {
6652 // Start with computed style
6653 var styles = getStyles( elem ),
6655 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
6656 // Fake content-box until we know it's needed to know the true value.
6657 boxSizingNeeded = !support.boxSizingReliable() || extra,
6658 isBorderBox = boxSizingNeeded &&
6659 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6660 valueIsBorderBox = isBorderBox,
6662 val = curCSS( elem, dimension, styles ),
6663 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
6665 // Support: Firefox <=54
6666 // Return a confounding non-pixel value or feign ignorance, as appropriate.
6667 if ( rnumnonpx.test( val ) ) {
6675 // Support: IE 9 - 11 only
6676 // Use offsetWidth/offsetHeight for when box sizing is unreliable.
6677 // In those cases, the computed value can be trusted to be border-box.
6678 if ( ( !support.boxSizingReliable() && isBorderBox ||
6680 // Support: IE 10 - 11+, Edge 15 - 18+
6681 // IE/Edge misreport `getComputedStyle` of table rows with width/height
6682 // set in CSS while `offset*` properties report correct values.
6683 // Interestingly, in some cases IE 9 doesn't suffer from this issue.
6684 !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
6686 // Fall back to offsetWidth/offsetHeight when value is "auto"
6687 // This happens for inline elements with no explicit setting (gh-3571)
6690 // Support: Android <=4.1 - 4.3 only
6691 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
6692 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
6694 // Make sure the element is visible & connected
6695 elem.getClientRects().length ) {
6697 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6699 // Where available, offsetWidth/offsetHeight approximate border box dimensions.
6700 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
6701 // retrieved value as a content box dimension.
6702 valueIsBorderBox = offsetProp in elem;
6703 if ( valueIsBorderBox ) {
6704 val = elem[ offsetProp ];
6708 // Normalize "" and auto
6709 val = parseFloat( val ) || 0;
6711 // Adjust for the element's box model
6716 extra || ( isBorderBox ? "border" : "content" ),
6720 // Provide the current computed size to request scroll gutter calculation (gh-3589)
6728 // Add in style property hooks for overriding the default
6729 // behavior of getting and setting a style property
6732 get: function( elem, computed ) {
6735 // We should always get a number back from opacity
6736 var ret = curCSS( elem, "opacity" );
6737 return ret === "" ? "1" : ret;
6743 // Don't automatically add "px" to these possibly-unitless properties
6745 animationIterationCount: true,
6747 borderImageSlice: true,
6754 gridColumnEnd: true,
6755 gridColumnStart: true,
6772 strokeMiterlimit: true,
6776 // Add in properties whose names you wish to fix before
6777 // setting or getting the value
6780 // Get and set the style property on a DOM Node
6781 style: function( elem, name, value, extra ) {
6783 // Don't set styles on text and comment nodes
6784 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6788 // Make sure that we're working with the right name
6789 var ret, type, hooks,
6790 origName = camelCase( name ),
6791 isCustomProp = rcustomProp.test( name ),
6794 // Make sure that we're working with the right name. We don't
6795 // want to query the value if it is a CSS custom property
6796 // since they are user-defined.
6797 if ( !isCustomProp ) {
6798 name = finalPropName( origName );
6801 // Gets hook for the prefixed version, then unprefixed version
6802 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6804 // Check if we're setting a value
6805 if ( value !== undefined ) {
6806 type = typeof value;
6808 // Convert "+=" or "-=" to relative numbers (trac-7345)
6809 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
6810 value = adjustCSS( elem, name, ret );
6812 // Fixes bug trac-9237
6816 // Make sure that null and NaN values aren't set (trac-7116)
6817 if ( value == null || value !== value ) {
6821 // If a number was passed in, add the unit (except for certain CSS properties)
6822 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
6823 // "px" to a few hardcoded values.
6824 if ( type === "number" && !isCustomProp ) {
6825 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
6828 // background-* props affect original clone's values
6829 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
6830 style[ name ] = "inherit";
6833 // If a hook was provided, use that value, otherwise just set the specified value
6834 if ( !hooks || !( "set" in hooks ) ||
6835 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
6837 if ( isCustomProp ) {
6838 style.setProperty( name, value );
6840 style[ name ] = value;
6846 // If a hook was provided get the non-computed value from there
6847 if ( hooks && "get" in hooks &&
6848 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
6853 // Otherwise just get the value from the style object
6854 return style[ name ];
6858 css: function( elem, name, extra, styles ) {
6859 var val, num, hooks,
6860 origName = camelCase( name ),
6861 isCustomProp = rcustomProp.test( name );
6863 // Make sure that we're working with the right name. We don't
6864 // want to modify the value if it is a CSS custom property
6865 // since they are user-defined.
6866 if ( !isCustomProp ) {
6867 name = finalPropName( origName );
6870 // Try prefixed name followed by the unprefixed name
6871 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6873 // If a hook was provided get the computed value from there
6874 if ( hooks && "get" in hooks ) {
6875 val = hooks.get( elem, true, extra );
6878 // Otherwise, if a way to get the computed value exists, use that
6879 if ( val === undefined ) {
6880 val = curCSS( elem, name, styles );
6883 // Convert "normal" to computed value
6884 if ( val === "normal" && name in cssNormalTransform ) {
6885 val = cssNormalTransform[ name ];
6888 // Make numeric if forced or a qualifier was provided and val looks numeric
6889 if ( extra === "" || extra ) {
6890 num = parseFloat( val );
6891 return extra === true || isFinite( num ) ? num || 0 : val;
6898 jQuery.each( [ "height", "width" ], function( _i, dimension ) {
6899 jQuery.cssHooks[ dimension ] = {
6900 get: function( elem, computed, extra ) {
6903 // Certain elements can have dimension info if we invisibly show them
6904 // but it must have a current display style that would benefit
6905 return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
6907 // Support: Safari 8+
6908 // Table columns in Safari have non-zero offsetWidth & zero
6909 // getBoundingClientRect().width unless display is changed.
6910 // Support: IE <=11 only
6911 // Running getBoundingClientRect on a disconnected node
6912 // in IE throws an error.
6913 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
6914 swap( elem, cssShow, function() {
6915 return getWidthOrHeight( elem, dimension, extra );
6917 getWidthOrHeight( elem, dimension, extra );
6921 set: function( elem, value, extra ) {
6923 styles = getStyles( elem ),
6925 // Only read styles.position if the test has a chance to fail
6926 // to avoid forcing a reflow.
6927 scrollboxSizeBuggy = !support.scrollboxSize() &&
6928 styles.position === "absolute",
6930 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
6931 boxSizingNeeded = scrollboxSizeBuggy || extra,
6932 isBorderBox = boxSizingNeeded &&
6933 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6944 // Account for unreliable border-box dimensions by comparing offset* to computed and
6945 // faking a content-box to get border and padding (gh-3699)
6946 if ( isBorderBox && scrollboxSizeBuggy ) {
6947 subtract -= Math.ceil(
6948 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
6949 parseFloat( styles[ dimension ] ) -
6950 boxModelAdjustment( elem, dimension, "border", false, styles ) -
6955 // Convert to pixels if value adjustment is needed
6956 if ( subtract && ( matches = rcssNum.exec( value ) ) &&
6957 ( matches[ 3 ] || "px" ) !== "px" ) {
6959 elem.style[ dimension ] = value;
6960 value = jQuery.css( elem, dimension );
6963 return setPositiveNumber( elem, value, subtract );
6968 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
6969 function( elem, computed ) {
6971 return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
6972 elem.getBoundingClientRect().left -
6973 swap( elem, { marginLeft: 0 }, function() {
6974 return elem.getBoundingClientRect().left;
6981 // These hooks are used by animate to expand properties
6986 }, function( prefix, suffix ) {
6987 jQuery.cssHooks[ prefix + suffix ] = {
6988 expand: function( value ) {
6992 // Assumes a single number if not a string
6993 parts = typeof value === "string" ? value.split( " " ) : [ value ];
6995 for ( ; i < 4; i++ ) {
6996 expanded[ prefix + cssExpand[ i ] + suffix ] =
6997 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7004 if ( prefix !== "margin" ) {
7005 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7010 css: function( name, value ) {
7011 return access( this, function( elem, name, value ) {
7016 if ( Array.isArray( name ) ) {
7017 styles = getStyles( elem );
7020 for ( ; i < len; i++ ) {
7021 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
7027 return value !== undefined ?
7028 jQuery.style( elem, name, value ) :
7029 jQuery.css( elem, name );
7030 }, name, value, arguments.length > 1 );
7035 function Tween( elem, options, prop, end, easing ) {
7036 return new Tween.prototype.init( elem, options, prop, end, easing );
7038 jQuery.Tween = Tween;
7042 init: function( elem, options, prop, end, easing, unit ) {
7045 this.easing = easing || jQuery.easing._default;
7046 this.options = options;
7047 this.start = this.now = this.cur();
7049 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
7052 var hooks = Tween.propHooks[ this.prop ];
7054 return hooks && hooks.get ?
7056 Tween.propHooks._default.get( this );
7058 run: function( percent ) {
7060 hooks = Tween.propHooks[ this.prop ];
7062 if ( this.options.duration ) {
7063 this.pos = eased = jQuery.easing[ this.easing ](
7064 percent, this.options.duration * percent, 0, 1, this.options.duration
7067 this.pos = eased = percent;
7069 this.now = ( this.end - this.start ) * eased + this.start;
7071 if ( this.options.step ) {
7072 this.options.step.call( this.elem, this.now, this );
7075 if ( hooks && hooks.set ) {
7078 Tween.propHooks._default.set( this );
7084 Tween.prototype.init.prototype = Tween.prototype;
7088 get: function( tween ) {
7091 // Use a property on the element directly when it is not a DOM element,
7092 // or when there is no matching style property that exists.
7093 if ( tween.elem.nodeType !== 1 ||
7094 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
7095 return tween.elem[ tween.prop ];
7098 // Passing an empty string as a 3rd parameter to .css will automatically
7099 // attempt a parseFloat and fallback to a string if the parse fails.
7100 // Simple values such as "10px" are parsed to Float;
7101 // complex values such as "rotate(1rad)" are returned as-is.
7102 result = jQuery.css( tween.elem, tween.prop, "" );
7104 // Empty strings, null, undefined and "auto" are converted to 0.
7105 return !result || result === "auto" ? 0 : result;
7107 set: function( tween ) {
7109 // Use step hook for back compat.
7110 // Use cssHook if its there.
7111 // Use .style if available and use plain properties where available.
7112 if ( jQuery.fx.step[ tween.prop ] ) {
7113 jQuery.fx.step[ tween.prop ]( tween );
7114 } else if ( tween.elem.nodeType === 1 && (
7115 jQuery.cssHooks[ tween.prop ] ||
7116 tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
7117 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
7119 tween.elem[ tween.prop ] = tween.now;
7125 // Support: IE <=9 only
7126 // Panic based approach to setting things on disconnected nodes
7127 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
7128 set: function( tween ) {
7129 if ( tween.elem.nodeType && tween.elem.parentNode ) {
7130 tween.elem[ tween.prop ] = tween.now;
7136 linear: function( p ) {
7139 swing: function( p ) {
7140 return 0.5 - Math.cos( p * Math.PI ) / 2;
7145 jQuery.fx = Tween.prototype.init;
7147 // Back compat <1.8 extension point
7148 jQuery.fx.step = {};
7155 rfxtypes = /^(?:toggle|show|hide)$/,
7156 rrun = /queueHooks$/;
7158 function schedule() {
7160 if ( document.hidden === false && window.requestAnimationFrame ) {
7161 window.requestAnimationFrame( schedule );
7163 window.setTimeout( schedule, jQuery.fx.interval );
7170 // Animations created synchronously will run synchronously
7171 function createFxNow() {
7172 window.setTimeout( function() {
7175 return ( fxNow = Date.now() );
7178 // Generate parameters to create a standard animation
7179 function genFx( type, includeWidth ) {
7182 attrs = { height: type };
7184 // If we include width, step value is 1 to do all cssExpand values,
7185 // otherwise step value is 2 to skip over Left and Right
7186 includeWidth = includeWidth ? 1 : 0;
7187 for ( ; i < 4; i += 2 - includeWidth ) {
7188 which = cssExpand[ i ];
7189 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
7192 if ( includeWidth ) {
7193 attrs.opacity = attrs.width = type;
7199 function createTween( value, prop, animation ) {
7201 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
7203 length = collection.length;
7204 for ( ; index < length; index++ ) {
7205 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
7207 // We're done with this property
7213 function defaultPrefilter( elem, props, opts ) {
7214 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
7215 isBox = "width" in props || "height" in props,
7219 hidden = elem.nodeType && isHiddenWithinTree( elem ),
7220 dataShow = dataPriv.get( elem, "fxshow" );
7222 // Queue-skipping animations hijack the fx hooks
7223 if ( !opts.queue ) {
7224 hooks = jQuery._queueHooks( elem, "fx" );
7225 if ( hooks.unqueued == null ) {
7227 oldfire = hooks.empty.fire;
7228 hooks.empty.fire = function() {
7229 if ( !hooks.unqueued ) {
7236 anim.always( function() {
7238 // Ensure the complete handler is called before this completes
7239 anim.always( function() {
7241 if ( !jQuery.queue( elem, "fx" ).length ) {
7248 // Detect show/hide animations
7249 for ( prop in props ) {
7250 value = props[ prop ];
7251 if ( rfxtypes.test( value ) ) {
7252 delete props[ prop ];
7253 toggle = toggle || value === "toggle";
7254 if ( value === ( hidden ? "hide" : "show" ) ) {
7256 // Pretend to be hidden if this is a "show" and
7257 // there is still data from a stopped show/hide
7258 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
7261 // Ignore all other no-op show/hide data
7266 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
7270 // Bail out if this is a no-op like .hide().hide()
7271 propTween = !jQuery.isEmptyObject( props );
7272 if ( !propTween && jQuery.isEmptyObject( orig ) ) {
7276 // Restrict "overflow" and "display" styles during box animations
7277 if ( isBox && elem.nodeType === 1 ) {
7279 // Support: IE <=9 - 11, Edge 12 - 15
7280 // Record all 3 overflow attributes because IE does not infer the shorthand
7281 // from identically-valued overflowX and overflowY and Edge just mirrors
7282 // the overflowX value there.
7283 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
7285 // Identify a display type, preferring old show/hide data over the CSS cascade
7286 restoreDisplay = dataShow && dataShow.display;
7287 if ( restoreDisplay == null ) {
7288 restoreDisplay = dataPriv.get( elem, "display" );
7290 display = jQuery.css( elem, "display" );
7291 if ( display === "none" ) {
7292 if ( restoreDisplay ) {
7293 display = restoreDisplay;
7296 // Get nonempty value(s) by temporarily forcing visibility
7297 showHide( [ elem ], true );
7298 restoreDisplay = elem.style.display || restoreDisplay;
7299 display = jQuery.css( elem, "display" );
7300 showHide( [ elem ] );
7304 // Animate inline elements as inline-block
7305 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
7306 if ( jQuery.css( elem, "float" ) === "none" ) {
7308 // Restore the original display value at the end of pure show/hide animations
7310 anim.done( function() {
7311 style.display = restoreDisplay;
7313 if ( restoreDisplay == null ) {
7314 display = style.display;
7315 restoreDisplay = display === "none" ? "" : display;
7318 style.display = "inline-block";
7323 if ( opts.overflow ) {
7324 style.overflow = "hidden";
7325 anim.always( function() {
7326 style.overflow = opts.overflow[ 0 ];
7327 style.overflowX = opts.overflow[ 1 ];
7328 style.overflowY = opts.overflow[ 2 ];
7332 // Implement show/hide animations
7334 for ( prop in orig ) {
7336 // General show/hide setup for this element animation
7339 if ( "hidden" in dataShow ) {
7340 hidden = dataShow.hidden;
7343 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
7346 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
7348 dataShow.hidden = !hidden;
7351 // Show elements before animating them
7353 showHide( [ elem ], true );
7356 /* eslint-disable no-loop-func */
7358 anim.done( function() {
7360 /* eslint-enable no-loop-func */
7362 // The final step of a "hide" animation is actually hiding the element
7364 showHide( [ elem ] );
7366 dataPriv.remove( elem, "fxshow" );
7367 for ( prop in orig ) {
7368 jQuery.style( elem, prop, orig[ prop ] );
7373 // Per-property setup
7374 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
7375 if ( !( prop in dataShow ) ) {
7376 dataShow[ prop ] = propTween.start;
7378 propTween.end = propTween.start;
7379 propTween.start = 0;
7385 function propFilter( props, specialEasing ) {
7386 var index, name, easing, value, hooks;
7388 // camelCase, specialEasing and expand cssHook pass
7389 for ( index in props ) {
7390 name = camelCase( index );
7391 easing = specialEasing[ name ];
7392 value = props[ index ];
7393 if ( Array.isArray( value ) ) {
7394 easing = value[ 1 ];
7395 value = props[ index ] = value[ 0 ];
7398 if ( index !== name ) {
7399 props[ name ] = value;
7400 delete props[ index ];
7403 hooks = jQuery.cssHooks[ name ];
7404 if ( hooks && "expand" in hooks ) {
7405 value = hooks.expand( value );
7406 delete props[ name ];
7408 // Not quite $.extend, this won't overwrite existing keys.
7409 // Reusing 'index' because we have the correct "name"
7410 for ( index in value ) {
7411 if ( !( index in props ) ) {
7412 props[ index ] = value[ index ];
7413 specialEasing[ index ] = easing;
7417 specialEasing[ name ] = easing;
7422 function Animation( elem, properties, options ) {
7426 length = Animation.prefilters.length,
7427 deferred = jQuery.Deferred().always( function() {
7429 // Don't match elem in the :animated selector
7436 var currentTime = fxNow || createFxNow(),
7437 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7439 // Support: Android 2.3 only
7440 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497)
7441 temp = remaining / animation.duration || 0,
7444 length = animation.tweens.length;
7446 for ( ; index < length; index++ ) {
7447 animation.tweens[ index ].run( percent );
7450 deferred.notifyWith( elem, [ animation, percent, remaining ] );
7452 // If there's more to do, yield
7453 if ( percent < 1 && length ) {
7457 // If this was an empty animation, synthesize a final progress notification
7459 deferred.notifyWith( elem, [ animation, 1, 0 ] );
7462 // Resolve the animation and report its conclusion
7463 deferred.resolveWith( elem, [ animation ] );
7466 animation = deferred.promise( {
7468 props: jQuery.extend( {}, properties ),
7469 opts: jQuery.extend( true, {
7471 easing: jQuery.easing._default
7473 originalProperties: properties,
7474 originalOptions: options,
7475 startTime: fxNow || createFxNow(),
7476 duration: options.duration,
7478 createTween: function( prop, end ) {
7479 var tween = jQuery.Tween( elem, animation.opts, prop, end,
7480 animation.opts.specialEasing[ prop ] || animation.opts.easing );
7481 animation.tweens.push( tween );
7484 stop: function( gotoEnd ) {
7487 // If we are going to the end, we want to run all the tweens
7488 // otherwise we skip this part
7489 length = gotoEnd ? animation.tweens.length : 0;
7494 for ( ; index < length; index++ ) {
7495 animation.tweens[ index ].run( 1 );
7498 // Resolve when we played the last frame; otherwise, reject
7500 deferred.notifyWith( elem, [ animation, 1, 0 ] );
7501 deferred.resolveWith( elem, [ animation, gotoEnd ] );
7503 deferred.rejectWith( elem, [ animation, gotoEnd ] );
7508 props = animation.props;
7510 propFilter( props, animation.opts.specialEasing );
7512 for ( ; index < length; index++ ) {
7513 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
7515 if ( isFunction( result.stop ) ) {
7516 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
7517 result.stop.bind( result );
7523 jQuery.map( props, createTween, animation );
7525 if ( isFunction( animation.opts.start ) ) {
7526 animation.opts.start.call( elem, animation );
7529 // Attach callbacks from options
7531 .progress( animation.opts.progress )
7532 .done( animation.opts.done, animation.opts.complete )
7533 .fail( animation.opts.fail )
7534 .always( animation.opts.always );
7537 jQuery.extend( tick, {
7540 queue: animation.opts.queue
7547 jQuery.Animation = jQuery.extend( Animation, {
7550 "*": [ function( prop, value ) {
7551 var tween = this.createTween( prop, value );
7552 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
7557 tweener: function( props, callback ) {
7558 if ( isFunction( props ) ) {
7562 props = props.match( rnothtmlwhite );
7567 length = props.length;
7569 for ( ; index < length; index++ ) {
7570 prop = props[ index ];
7571 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
7572 Animation.tweeners[ prop ].unshift( callback );
7576 prefilters: [ defaultPrefilter ],
7578 prefilter: function( callback, prepend ) {
7580 Animation.prefilters.unshift( callback );
7582 Animation.prefilters.push( callback );
7587 jQuery.speed = function( speed, easing, fn ) {
7588 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7589 complete: fn || !fn && easing ||
7590 isFunction( speed ) && speed,
7592 easing: fn && easing || easing && !isFunction( easing ) && easing
7595 // Go to the end state if fx are off
7596 if ( jQuery.fx.off ) {
7600 if ( typeof opt.duration !== "number" ) {
7601 if ( opt.duration in jQuery.fx.speeds ) {
7602 opt.duration = jQuery.fx.speeds[ opt.duration ];
7605 opt.duration = jQuery.fx.speeds._default;
7610 // Normalize opt.queue - true/undefined/null -> "fx"
7611 if ( opt.queue == null || opt.queue === true ) {
7616 opt.old = opt.complete;
7618 opt.complete = function() {
7619 if ( isFunction( opt.old ) ) {
7620 opt.old.call( this );
7624 jQuery.dequeue( this, opt.queue );
7632 fadeTo: function( speed, to, easing, callback ) {
7634 // Show any hidden elements after setting opacity to 0
7635 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
7637 // Animate to the value specified
7638 .end().animate( { opacity: to }, speed, easing, callback );
7640 animate: function( prop, speed, easing, callback ) {
7641 var empty = jQuery.isEmptyObject( prop ),
7642 optall = jQuery.speed( speed, easing, callback ),
7643 doAnimation = function() {
7645 // Operate on a copy of prop so per-property easing won't be lost
7646 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7648 // Empty animations, or finishing resolves immediately
7649 if ( empty || dataPriv.get( this, "finish" ) ) {
7654 doAnimation.finish = doAnimation;
7656 return empty || optall.queue === false ?
7657 this.each( doAnimation ) :
7658 this.queue( optall.queue, doAnimation );
7660 stop: function( type, clearQueue, gotoEnd ) {
7661 var stopQueue = function( hooks ) {
7662 var stop = hooks.stop;
7667 if ( typeof type !== "string" ) {
7668 gotoEnd = clearQueue;
7673 this.queue( type || "fx", [] );
7676 return this.each( function() {
7678 index = type != null && type + "queueHooks",
7679 timers = jQuery.timers,
7680 data = dataPriv.get( this );
7683 if ( data[ index ] && data[ index ].stop ) {
7684 stopQueue( data[ index ] );
7687 for ( index in data ) {
7688 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7689 stopQueue( data[ index ] );
7694 for ( index = timers.length; index--; ) {
7695 if ( timers[ index ].elem === this &&
7696 ( type == null || timers[ index ].queue === type ) ) {
7698 timers[ index ].anim.stop( gotoEnd );
7700 timers.splice( index, 1 );
7704 // Start the next in the queue if the last step wasn't forced.
7705 // Timers currently will call their complete callbacks, which
7706 // will dequeue but only if they were gotoEnd.
7707 if ( dequeue || !gotoEnd ) {
7708 jQuery.dequeue( this, type );
7712 finish: function( type ) {
7713 if ( type !== false ) {
7714 type = type || "fx";
7716 return this.each( function() {
7718 data = dataPriv.get( this ),
7719 queue = data[ type + "queue" ],
7720 hooks = data[ type + "queueHooks" ],
7721 timers = jQuery.timers,
7722 length = queue ? queue.length : 0;
7724 // Enable finishing flag on private data
7727 // Empty the queue first
7728 jQuery.queue( this, type, [] );
7730 if ( hooks && hooks.stop ) {
7731 hooks.stop.call( this, true );
7734 // Look for any active animations, and finish them
7735 for ( index = timers.length; index--; ) {
7736 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
7737 timers[ index ].anim.stop( true );
7738 timers.splice( index, 1 );
7742 // Look for any animations in the old queue and finish them
7743 for ( index = 0; index < length; index++ ) {
7744 if ( queue[ index ] && queue[ index ].finish ) {
7745 queue[ index ].finish.call( this );
7749 // Turn off finishing flag
7755 jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
7756 var cssFn = jQuery.fn[ name ];
7757 jQuery.fn[ name ] = function( speed, easing, callback ) {
7758 return speed == null || typeof speed === "boolean" ?
7759 cssFn.apply( this, arguments ) :
7760 this.animate( genFx( name, true ), speed, easing, callback );
7764 // Generate shortcuts for custom animations
7766 slideDown: genFx( "show" ),
7767 slideUp: genFx( "hide" ),
7768 slideToggle: genFx( "toggle" ),
7769 fadeIn: { opacity: "show" },
7770 fadeOut: { opacity: "hide" },
7771 fadeToggle: { opacity: "toggle" }
7772 }, function( name, props ) {
7773 jQuery.fn[ name ] = function( speed, easing, callback ) {
7774 return this.animate( props, speed, easing, callback );
7779 jQuery.fx.tick = function() {
7782 timers = jQuery.timers;
7786 for ( ; i < timers.length; i++ ) {
7787 timer = timers[ i ];
7789 // Run the timer and safely remove it when done (allowing for external removal)
7790 if ( !timer() && timers[ i ] === timer ) {
7791 timers.splice( i--, 1 );
7795 if ( !timers.length ) {
7801 jQuery.fx.timer = function( timer ) {
7802 jQuery.timers.push( timer );
7806 jQuery.fx.interval = 13;
7807 jQuery.fx.start = function() {
7816 jQuery.fx.stop = function() {
7820 jQuery.fx.speeds = {
7829 // Based off of the plugin by Clint Helfers, with permission.
7830 jQuery.fn.delay = function( time, type ) {
7831 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
7832 type = type || "fx";
7834 return this.queue( type, function( next, hooks ) {
7835 var timeout = window.setTimeout( next, time );
7836 hooks.stop = function() {
7837 window.clearTimeout( timeout );
7844 var input = document.createElement( "input" ),
7845 select = document.createElement( "select" ),
7846 opt = select.appendChild( document.createElement( "option" ) );
7848 input.type = "checkbox";
7850 // Support: Android <=4.3 only
7851 // Default value for a checkbox should be "on"
7852 support.checkOn = input.value !== "";
7854 // Support: IE <=11 only
7855 // Must access selectedIndex to make default options select
7856 support.optSelected = opt.selected;
7858 // Support: IE <=11 only
7859 // An input loses its value after becoming a radio
7860 input = document.createElement( "input" );
7862 input.type = "radio";
7863 support.radioValue = input.value === "t";
7868 attrHandle = jQuery.expr.attrHandle;
7871 attr: function( name, value ) {
7872 return access( this, jQuery.attr, name, value, arguments.length > 1 );
7875 removeAttr: function( name ) {
7876 return this.each( function() {
7877 jQuery.removeAttr( this, name );
7883 attr: function( elem, name, value ) {
7885 nType = elem.nodeType;
7887 // Don't get/set attributes on text, comment and attribute nodes
7888 if ( nType === 3 || nType === 8 || nType === 2 ) {
7892 // Fallback to prop when attributes are not supported
7893 if ( typeof elem.getAttribute === "undefined" ) {
7894 return jQuery.prop( elem, name, value );
7897 // Attribute hooks are determined by the lowercase version
7898 // Grab necessary hook if one is defined
7899 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7900 hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
7901 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
7904 if ( value !== undefined ) {
7905 if ( value === null ) {
7906 jQuery.removeAttr( elem, name );
7910 if ( hooks && "set" in hooks &&
7911 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
7915 elem.setAttribute( name, value + "" );
7919 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
7923 ret = jQuery.find.attr( elem, name );
7925 // Non-existent attributes return null, we normalize to undefined
7926 return ret == null ? undefined : ret;
7931 set: function( elem, value ) {
7932 if ( !support.radioValue && value === "radio" &&
7933 nodeName( elem, "input" ) ) {
7934 var val = elem.value;
7935 elem.setAttribute( "type", value );
7945 removeAttr: function( elem, value ) {
7949 // Attribute names can contain non-HTML whitespace characters
7950 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
7951 attrNames = value && value.match( rnothtmlwhite );
7953 if ( attrNames && elem.nodeType === 1 ) {
7954 while ( ( name = attrNames[ i++ ] ) ) {
7955 elem.removeAttribute( name );
7961 // Hooks for boolean attributes
7963 set: function( elem, value, name ) {
7964 if ( value === false ) {
7966 // Remove boolean attributes when set to false
7967 jQuery.removeAttr( elem, name );
7969 elem.setAttribute( name, name );
7975 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
7976 var getter = attrHandle[ name ] || jQuery.find.attr;
7978 attrHandle[ name ] = function( elem, name, isXML ) {
7980 lowercaseName = name.toLowerCase();
7984 // Avoid an infinite loop by temporarily removing this function from the getter
7985 handle = attrHandle[ lowercaseName ];
7986 attrHandle[ lowercaseName ] = ret;
7987 ret = getter( elem, name, isXML ) != null ?
7990 attrHandle[ lowercaseName ] = handle;
7999 var rfocusable = /^(?:input|select|textarea|button)$/i,
8000 rclickable = /^(?:a|area)$/i;
8003 prop: function( name, value ) {
8004 return access( this, jQuery.prop, name, value, arguments.length > 1 );
8007 removeProp: function( name ) {
8008 return this.each( function() {
8009 delete this[ jQuery.propFix[ name ] || name ];
8015 prop: function( elem, name, value ) {
8017 nType = elem.nodeType;
8019 // Don't get/set properties on text, comment and attribute nodes
8020 if ( nType === 3 || nType === 8 || nType === 2 ) {
8024 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
8026 // Fix name and attach hooks
8027 name = jQuery.propFix[ name ] || name;
8028 hooks = jQuery.propHooks[ name ];
8031 if ( value !== undefined ) {
8032 if ( hooks && "set" in hooks &&
8033 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
8037 return ( elem[ name ] = value );
8040 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
8044 return elem[ name ];
8049 get: function( elem ) {
8051 // Support: IE <=9 - 11 only
8052 // elem.tabIndex doesn't always return the
8053 // correct value when it hasn't been explicitly set
8054 // Use proper attribute retrieval (trac-12072)
8055 var tabindex = jQuery.find.attr( elem, "tabindex" );
8058 return parseInt( tabindex, 10 );
8062 rfocusable.test( elem.nodeName ) ||
8063 rclickable.test( elem.nodeName ) &&
8076 "class": "className"
8080 // Support: IE <=11 only
8081 // Accessing the selectedIndex property
8082 // forces the browser to respect setting selected
8084 // The getter ensures a default option is selected
8085 // when in an optgroup
8086 // eslint rule "no-unused-expressions" is disabled for this code
8087 // since it considers such accessions noop
8088 if ( !support.optSelected ) {
8089 jQuery.propHooks.selected = {
8090 get: function( elem ) {
8092 /* eslint no-unused-expressions: "off" */
8094 var parent = elem.parentNode;
8095 if ( parent && parent.parentNode ) {
8096 parent.parentNode.selectedIndex;
8100 set: function( elem ) {
8102 /* eslint no-unused-expressions: "off" */
8104 var parent = elem.parentNode;
8106 parent.selectedIndex;
8108 if ( parent.parentNode ) {
8109 parent.parentNode.selectedIndex;
8128 jQuery.propFix[ this.toLowerCase() ] = this;
8134 // Strip and collapse whitespace according to HTML spec
8135 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
8136 function stripAndCollapse( value ) {
8137 var tokens = value.match( rnothtmlwhite ) || [];
8138 return tokens.join( " " );
8142 function getClass( elem ) {
8143 return elem.getAttribute && elem.getAttribute( "class" ) || "";
8146 function classesToArray( value ) {
8147 if ( Array.isArray( value ) ) {
8150 if ( typeof value === "string" ) {
8151 return value.match( rnothtmlwhite ) || [];
8157 addClass: function( value ) {
8158 var classNames, cur, curValue, className, i, finalValue;
8160 if ( isFunction( value ) ) {
8161 return this.each( function( j ) {
8162 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
8166 classNames = classesToArray( value );
8168 if ( classNames.length ) {
8169 return this.each( function() {
8170 curValue = getClass( this );
8171 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
8174 for ( i = 0; i < classNames.length; i++ ) {
8175 className = classNames[ i ];
8176 if ( cur.indexOf( " " + className + " " ) < 0 ) {
8177 cur += className + " ";
8181 // Only assign if different to avoid unneeded rendering.
8182 finalValue = stripAndCollapse( cur );
8183 if ( curValue !== finalValue ) {
8184 this.setAttribute( "class", finalValue );
8193 removeClass: function( value ) {
8194 var classNames, cur, curValue, className, i, finalValue;
8196 if ( isFunction( value ) ) {
8197 return this.each( function( j ) {
8198 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
8202 if ( !arguments.length ) {
8203 return this.attr( "class", "" );
8206 classNames = classesToArray( value );
8208 if ( classNames.length ) {
8209 return this.each( function() {
8210 curValue = getClass( this );
8212 // This expression is here for better compressibility (see addClass)
8213 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
8216 for ( i = 0; i < classNames.length; i++ ) {
8217 className = classNames[ i ];
8219 // Remove *all* instances
8220 while ( cur.indexOf( " " + className + " " ) > -1 ) {
8221 cur = cur.replace( " " + className + " ", " " );
8225 // Only assign if different to avoid unneeded rendering.
8226 finalValue = stripAndCollapse( cur );
8227 if ( curValue !== finalValue ) {
8228 this.setAttribute( "class", finalValue );
8237 toggleClass: function( value, stateVal ) {
8238 var classNames, className, i, self,
8239 type = typeof value,
8240 isValidValue = type === "string" || Array.isArray( value );
8242 if ( isFunction( value ) ) {
8243 return this.each( function( i ) {
8244 jQuery( this ).toggleClass(
8245 value.call( this, i, getClass( this ), stateVal ),
8251 if ( typeof stateVal === "boolean" && isValidValue ) {
8252 return stateVal ? this.addClass( value ) : this.removeClass( value );
8255 classNames = classesToArray( value );
8257 return this.each( function() {
8258 if ( isValidValue ) {
8260 // Toggle individual class names
8261 self = jQuery( this );
8263 for ( i = 0; i < classNames.length; i++ ) {
8264 className = classNames[ i ];
8266 // Check each className given, space separated list
8267 if ( self.hasClass( className ) ) {
8268 self.removeClass( className );
8270 self.addClass( className );
8274 // Toggle whole class name
8275 } else if ( value === undefined || type === "boolean" ) {
8276 className = getClass( this );
8279 // Store className if set
8280 dataPriv.set( this, "__className__", className );
8283 // If the element has a class name or if we're passed `false`,
8284 // then remove the whole classname (if there was one, the above saved it).
8285 // Otherwise bring back whatever was previously saved (if anything),
8286 // falling back to the empty string if nothing was stored.
8287 if ( this.setAttribute ) {
8288 this.setAttribute( "class",
8289 className || value === false ?
8291 dataPriv.get( this, "__className__" ) || ""
8298 hasClass: function( selector ) {
8299 var className, elem,
8302 className = " " + selector + " ";
8303 while ( ( elem = this[ i++ ] ) ) {
8304 if ( elem.nodeType === 1 &&
8305 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
8317 var rreturn = /\r/g;
8320 val: function( value ) {
8321 var hooks, ret, valueIsFunction,
8324 if ( !arguments.length ) {
8326 hooks = jQuery.valHooks[ elem.type ] ||
8327 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
8331 ( ret = hooks.get( elem, "value" ) ) !== undefined
8338 // Handle most common string cases
8339 if ( typeof ret === "string" ) {
8340 return ret.replace( rreturn, "" );
8343 // Handle cases where value is null/undef or number
8344 return ret == null ? "" : ret;
8350 valueIsFunction = isFunction( value );
8352 return this.each( function( i ) {
8355 if ( this.nodeType !== 1 ) {
8359 if ( valueIsFunction ) {
8360 val = value.call( this, i, jQuery( this ).val() );
8365 // Treat null/undefined as ""; convert numbers to string
8366 if ( val == null ) {
8369 } else if ( typeof val === "number" ) {
8372 } else if ( Array.isArray( val ) ) {
8373 val = jQuery.map( val, function( value ) {
8374 return value == null ? "" : value + "";
8378 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
8380 // If set returns undefined, fall back to normal setting
8381 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
8391 get: function( elem ) {
8393 var val = jQuery.find.attr( elem, "value" );
8394 return val != null ?
8397 // Support: IE <=10 - 11 only
8398 // option.text throws exceptions (trac-14686, trac-14858)
8399 // Strip and collapse whitespace
8400 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8401 stripAndCollapse( jQuery.text( elem ) );
8405 get: function( elem ) {
8406 var value, option, i,
8407 options = elem.options,
8408 index = elem.selectedIndex,
8409 one = elem.type === "select-one",
8410 values = one ? null : [],
8411 max = one ? index + 1 : options.length;
8417 i = one ? index : 0;
8420 // Loop through all the selected options
8421 for ( ; i < max; i++ ) {
8422 option = options[ i ];
8424 // Support: IE <=9 only
8425 // IE8-9 doesn't update selected after form reset (trac-2551)
8426 if ( ( option.selected || i === index ) &&
8428 // Don't return options that are disabled or in a disabled optgroup
8430 ( !option.parentNode.disabled ||
8431 !nodeName( option.parentNode, "optgroup" ) ) ) {
8433 // Get the specific value for the option
8434 value = jQuery( option ).val();
8436 // We don't need an array for one selects
8441 // Multi-Selects return an array
8442 values.push( value );
8449 set: function( elem, value ) {
8450 var optionSet, option,
8451 options = elem.options,
8452 values = jQuery.makeArray( value ),
8456 option = options[ i ];
8458 /* eslint-disable no-cond-assign */
8460 if ( option.selected =
8461 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
8466 /* eslint-enable no-cond-assign */
8469 // Force browsers to behave consistently when non-matching value is set
8471 elem.selectedIndex = -1;
8479 // Radios and checkboxes getter/setter
8480 jQuery.each( [ "radio", "checkbox" ], function() {
8481 jQuery.valHooks[ this ] = {
8482 set: function( elem, value ) {
8483 if ( Array.isArray( value ) ) {
8484 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
8488 if ( !support.checkOn ) {
8489 jQuery.valHooks[ this ].get = function( elem ) {
8490 return elem.getAttribute( "value" ) === null ? "on" : elem.value;
8498 // Return jQuery for attributes-only inclusion
8499 var location = window.location;
8501 var nonce = { guid: Date.now() };
8503 var rquery = ( /\?/ );
8507 // Cross-browser xml parsing
8508 jQuery.parseXML = function( data ) {
8509 var xml, parserErrorElem;
8510 if ( !data || typeof data !== "string" ) {
8514 // Support: IE 9 - 11 only
8515 // IE throws on parseFromString with invalid input.
8517 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
8520 parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
8521 if ( !xml || parserErrorElem ) {
8522 jQuery.error( "Invalid XML: " + (
8524 jQuery.map( parserErrorElem.childNodes, function( el ) {
8525 return el.textContent;
8534 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
8535 stopPropagationCallback = function( e ) {
8536 e.stopPropagation();
8539 jQuery.extend( jQuery.event, {
8541 trigger: function( event, data, elem, onlyHandlers ) {
8543 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
8544 eventPath = [ elem || document ],
8545 type = hasOwn.call( event, "type" ) ? event.type : event,
8546 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
8548 cur = lastElement = tmp = elem = elem || document;
8550 // Don't do events on text and comment nodes
8551 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
8555 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8556 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
8560 if ( type.indexOf( "." ) > -1 ) {
8562 // Namespaced trigger; create a regexp to match event type in handle()
8563 namespaces = type.split( "." );
8564 type = namespaces.shift();
8567 ontype = type.indexOf( ":" ) < 0 && "on" + type;
8569 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8570 event = event[ jQuery.expando ] ?
8572 new jQuery.Event( type, typeof event === "object" && event );
8574 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8575 event.isTrigger = onlyHandlers ? 2 : 3;
8576 event.namespace = namespaces.join( "." );
8577 event.rnamespace = event.namespace ?
8578 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8581 // Clean up the event in case it is being reused
8582 event.result = undefined;
8583 if ( !event.target ) {
8584 event.target = elem;
8587 // Clone any incoming data and prepend the event, creating the handler arg list
8588 data = data == null ?
8590 jQuery.makeArray( data, [ event ] );
8592 // Allow special events to draw outside the lines
8593 special = jQuery.event.special[ type ] || {};
8594 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
8598 // Determine event propagation path in advance, per W3C events spec (trac-9951)
8599 // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)
8600 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
8602 bubbleType = special.delegateType || type;
8603 if ( !rfocusMorph.test( bubbleType + type ) ) {
8604 cur = cur.parentNode;
8606 for ( ; cur; cur = cur.parentNode ) {
8607 eventPath.push( cur );
8611 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8612 if ( tmp === ( elem.ownerDocument || document ) ) {
8613 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
8617 // Fire handlers on the event path
8619 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
8621 event.type = i > 1 ?
8623 special.bindType || type;
8626 handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
8627 dataPriv.get( cur, "handle" );
8629 handle.apply( cur, data );
8633 handle = ontype && cur[ ontype ];
8634 if ( handle && handle.apply && acceptData( cur ) ) {
8635 event.result = handle.apply( cur, data );
8636 if ( event.result === false ) {
8637 event.preventDefault();
8643 // If nobody prevented the default action, do it now
8644 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
8646 if ( ( !special._default ||
8647 special._default.apply( eventPath.pop(), data ) === false ) &&
8648 acceptData( elem ) ) {
8650 // Call a native DOM method on the target with the same name as the event.
8651 // Don't do default actions on window, that's where global variables be (trac-6170)
8652 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
8654 // Don't re-trigger an onFOO event when we call its FOO() method
8655 tmp = elem[ ontype ];
8658 elem[ ontype ] = null;
8661 // Prevent re-triggering of the same event, since we already bubbled it above
8662 jQuery.event.triggered = type;
8664 if ( event.isPropagationStopped() ) {
8665 lastElement.addEventListener( type, stopPropagationCallback );
8670 if ( event.isPropagationStopped() ) {
8671 lastElement.removeEventListener( type, stopPropagationCallback );
8674 jQuery.event.triggered = undefined;
8677 elem[ ontype ] = tmp;
8683 return event.result;
8686 // Piggyback on a donor event to simulate a different one
8687 // Used only for `focus(in | out)` events
8688 simulate: function( type, elem, event ) {
8689 var e = jQuery.extend(
8698 jQuery.event.trigger( e, null, elem );
8705 trigger: function( type, data ) {
8706 return this.each( function() {
8707 jQuery.event.trigger( type, data, this );
8710 triggerHandler: function( type, data ) {
8711 var elem = this[ 0 ];
8713 return jQuery.event.trigger( type, data, elem, true );
8722 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
8723 rsubmittable = /^(?:input|select|textarea|keygen)/i;
8725 function buildParams( prefix, obj, traditional, add ) {
8728 if ( Array.isArray( obj ) ) {
8730 // Serialize array item.
8731 jQuery.each( obj, function( i, v ) {
8732 if ( traditional || rbracket.test( prefix ) ) {
8734 // Treat each array item as a scalar.
8739 // Item is non-scalar (array or object), encode its numeric index.
8741 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
8749 } else if ( !traditional && toType( obj ) === "object" ) {
8751 // Serialize object item.
8752 for ( name in obj ) {
8753 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
8758 // Serialize scalar item.
8763 // Serialize an array of form elements or a set of
8764 // key/values into a query string
8765 jQuery.param = function( a, traditional ) {
8768 add = function( key, valueOrFunction ) {
8770 // If value is a function, invoke it and use its return value
8771 var value = isFunction( valueOrFunction ) ?
8775 s[ s.length ] = encodeURIComponent( key ) + "=" +
8776 encodeURIComponent( value == null ? "" : value );
8783 // If an array was passed in, assume that it is an array of form elements.
8784 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
8786 // Serialize the form elements
8787 jQuery.each( a, function() {
8788 add( this.name, this.value );
8793 // If traditional, encode the "old" way (the way 1.3.2 or older
8794 // did it), otherwise encode params recursively.
8795 for ( prefix in a ) {
8796 buildParams( prefix, a[ prefix ], traditional, add );
8800 // Return the resulting serialization
8801 return s.join( "&" );
8805 serialize: function() {
8806 return jQuery.param( this.serializeArray() );
8808 serializeArray: function() {
8809 return this.map( function() {
8811 // Can add propHook for "elements" to filter or add form elements
8812 var elements = jQuery.prop( this, "elements" );
8813 return elements ? jQuery.makeArray( elements ) : this;
8814 } ).filter( function() {
8815 var type = this.type;
8817 // Use .is( ":disabled" ) so that fieldset[disabled] works
8818 return this.name && !jQuery( this ).is( ":disabled" ) &&
8819 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
8820 ( this.checked || !rcheckableType.test( type ) );
8821 } ).map( function( _i, elem ) {
8822 var val = jQuery( this ).val();
8824 if ( val == null ) {
8828 if ( Array.isArray( val ) ) {
8829 return jQuery.map( val, function( val ) {
8830 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8834 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8843 rantiCache = /([?&])_=[^&]*/,
8844 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
8846 // trac-7653, trac-8125, trac-8152: local protocol detection
8847 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8848 rnoContent = /^(?:GET|HEAD)$/,
8849 rprotocol = /^\/\//,
8852 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8853 * 2) These are called:
8854 * - BEFORE asking for a transport
8855 * - AFTER param serialization (s.data is a string if s.processData is true)
8856 * 3) key is the dataType
8857 * 4) the catchall symbol "*" can be used
8858 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8862 /* Transports bindings
8863 * 1) key is the dataType
8864 * 2) the catchall symbol "*" can be used
8865 * 3) selection will start with transport dataType and THEN go to "*" if needed
8869 // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression
8870 allTypes = "*/".concat( "*" ),
8872 // Anchor tag for parsing the document origin
8873 originAnchor = document.createElement( "a" );
8875 originAnchor.href = location.href;
8877 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8878 function addToPrefiltersOrTransports( structure ) {
8880 // dataTypeExpression is optional and defaults to "*"
8881 return function( dataTypeExpression, func ) {
8883 if ( typeof dataTypeExpression !== "string" ) {
8884 func = dataTypeExpression;
8885 dataTypeExpression = "*";
8890 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
8892 if ( isFunction( func ) ) {
8894 // For each dataType in the dataTypeExpression
8895 while ( ( dataType = dataTypes[ i++ ] ) ) {
8897 // Prepend if requested
8898 if ( dataType[ 0 ] === "+" ) {
8899 dataType = dataType.slice( 1 ) || "*";
8900 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
8904 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
8911 // Base inspection function for prefilters and transports
8912 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
8915 seekingTransport = ( structure === transports );
8917 function inspect( dataType ) {
8919 inspected[ dataType ] = true;
8920 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
8921 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
8922 if ( typeof dataTypeOrTransport === "string" &&
8923 !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
8925 options.dataTypes.unshift( dataTypeOrTransport );
8926 inspect( dataTypeOrTransport );
8928 } else if ( seekingTransport ) {
8929 return !( selected = dataTypeOrTransport );
8935 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
8938 // A special extend for ajax options
8939 // that takes "flat" options (not to be deep extended)
8941 function ajaxExtend( target, src ) {
8943 flatOptions = jQuery.ajaxSettings.flatOptions || {};
8945 for ( key in src ) {
8946 if ( src[ key ] !== undefined ) {
8947 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
8951 jQuery.extend( true, target, deep );
8957 /* Handles responses to an ajax request:
8958 * - finds the right dataType (mediates between content-type and expected dataType)
8959 * - returns the corresponding response
8961 function ajaxHandleResponses( s, jqXHR, responses ) {
8963 var ct, type, finalDataType, firstDataType,
8964 contents = s.contents,
8965 dataTypes = s.dataTypes;
8967 // Remove auto dataType and get content-type in the process
8968 while ( dataTypes[ 0 ] === "*" ) {
8970 if ( ct === undefined ) {
8971 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
8975 // Check if we're dealing with a known content-type
8977 for ( type in contents ) {
8978 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8979 dataTypes.unshift( type );
8985 // Check to see if we have a response for the expected dataType
8986 if ( dataTypes[ 0 ] in responses ) {
8987 finalDataType = dataTypes[ 0 ];
8990 // Try convertible dataTypes
8991 for ( type in responses ) {
8992 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
8993 finalDataType = type;
8996 if ( !firstDataType ) {
8997 firstDataType = type;
9001 // Or just use first one
9002 finalDataType = finalDataType || firstDataType;
9005 // If we found a dataType
9006 // We add the dataType to the list if needed
9007 // and return the corresponding response
9008 if ( finalDataType ) {
9009 if ( finalDataType !== dataTypes[ 0 ] ) {
9010 dataTypes.unshift( finalDataType );
9012 return responses[ finalDataType ];
9016 /* Chain conversions given the request and the original response
9017 * Also sets the responseXXX fields on the jqXHR instance
9019 function ajaxConvert( s, response, jqXHR, isSuccess ) {
9020 var conv2, current, conv, tmp, prev,
9023 // Work with a copy of dataTypes in case we need to modify it for conversion
9024 dataTypes = s.dataTypes.slice();
9026 // Create converters map with lowercased keys
9027 if ( dataTypes[ 1 ] ) {
9028 for ( conv in s.converters ) {
9029 converters[ conv.toLowerCase() ] = s.converters[ conv ];
9033 current = dataTypes.shift();
9035 // Convert to each sequential dataType
9038 if ( s.responseFields[ current ] ) {
9039 jqXHR[ s.responseFields[ current ] ] = response;
9042 // Apply the dataFilter if provided
9043 if ( !prev && isSuccess && s.dataFilter ) {
9044 response = s.dataFilter( response, s.dataType );
9048 current = dataTypes.shift();
9052 // There's only work to do if current dataType is non-auto
9053 if ( current === "*" ) {
9057 // Convert response if prev dataType is non-auto and differs from current
9058 } else if ( prev !== "*" && prev !== current ) {
9060 // Seek a direct converter
9061 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
9063 // If none found, seek a pair
9065 for ( conv2 in converters ) {
9067 // If conv2 outputs current
9068 tmp = conv2.split( " " );
9069 if ( tmp[ 1 ] === current ) {
9071 // If prev can be converted to accepted input
9072 conv = converters[ prev + " " + tmp[ 0 ] ] ||
9073 converters[ "* " + tmp[ 0 ] ];
9076 // Condense equivalence converters
9077 if ( conv === true ) {
9078 conv = converters[ conv2 ];
9080 // Otherwise, insert the intermediate dataType
9081 } else if ( converters[ conv2 ] !== true ) {
9083 dataTypes.unshift( tmp[ 1 ] );
9091 // Apply converter (if not an equivalence)
9092 if ( conv !== true ) {
9094 // Unless errors are allowed to bubble, catch and return them
9095 if ( conv && s.throws ) {
9096 response = conv( response );
9099 response = conv( response );
9102 state: "parsererror",
9103 error: conv ? e : "No conversion from " + prev + " to " + current
9112 return { state: "success", data: response };
9117 // Counter for holding the number of active queries
9120 // Last-Modified header cache for next request
9127 isLocal: rlocalProtocol.test( location.protocol ),
9131 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
9149 xml: "application/xml, text/xml",
9150 json: "application/json, text/javascript"
9161 text: "responseText",
9162 json: "responseJSON"
9166 // Keys separate source (or catchall "*") and destination types with a single space
9169 // Convert anything to text
9172 // Text to html (true = no transformation)
9175 // Evaluate text as a json expression
9176 "text json": JSON.parse,
9178 // Parse text as xml
9179 "text xml": jQuery.parseXML
9182 // For options that shouldn't be deep extended:
9183 // you can add your own custom options here if
9184 // and when you create one that shouldn't be
9185 // deep extended (see ajaxExtend)
9192 // Creates a full fledged settings object into target
9193 // with both ajaxSettings and settings fields.
9194 // If target is omitted, writes into ajaxSettings.
9195 ajaxSetup: function( target, settings ) {
9198 // Building a settings object
9199 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
9201 // Extending ajaxSettings
9202 ajaxExtend( jQuery.ajaxSettings, target );
9205 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
9206 ajaxTransport: addToPrefiltersOrTransports( transports ),
9209 ajax: function( url, options ) {
9211 // If url is an object, simulate pre-1.5 signature
9212 if ( typeof url === "object" ) {
9217 // Force options to be an object
9218 options = options || {};
9222 // URL without anti-cache param
9226 responseHeadersString,
9235 // Request state (becomes false upon send and true upon completion)
9238 // To know if global events are to be dispatched
9244 // uncached part of the url
9247 // Create the final options object
9248 s = jQuery.ajaxSetup( {}, options ),
9250 // Callbacks context
9251 callbackContext = s.context || s,
9253 // Context for global events is callbackContext if it is a DOM node or jQuery collection
9254 globalEventContext = s.context &&
9255 ( callbackContext.nodeType || callbackContext.jquery ) ?
9256 jQuery( callbackContext ) :
9260 deferred = jQuery.Deferred(),
9261 completeDeferred = jQuery.Callbacks( "once memory" ),
9263 // Status-dependent callbacks
9264 statusCode = s.statusCode || {},
9266 // Headers (they are sent all at once)
9267 requestHeaders = {},
9268 requestHeadersNames = {},
9270 // Default abort message
9271 strAbort = "canceled",
9277 // Builds headers hashtable if needed
9278 getResponseHeader: function( key ) {
9281 if ( !responseHeaders ) {
9282 responseHeaders = {};
9283 while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
9284 responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
9285 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
9286 .concat( match[ 2 ] );
9289 match = responseHeaders[ key.toLowerCase() + " " ];
9291 return match == null ? null : match.join( ", " );
9295 getAllResponseHeaders: function() {
9296 return completed ? responseHeadersString : null;
9299 // Caches the header
9300 setRequestHeader: function( name, value ) {
9301 if ( completed == null ) {
9302 name = requestHeadersNames[ name.toLowerCase() ] =
9303 requestHeadersNames[ name.toLowerCase() ] || name;
9304 requestHeaders[ name ] = value;
9309 // Overrides response content-type header
9310 overrideMimeType: function( type ) {
9311 if ( completed == null ) {
9317 // Status-dependent callbacks
9318 statusCode: function( map ) {
9323 // Execute the appropriate callbacks
9324 jqXHR.always( map[ jqXHR.status ] );
9327 // Lazy-add the new callbacks in a way that preserves old ones
9328 for ( code in map ) {
9329 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
9336 // Cancel the request
9337 abort: function( statusText ) {
9338 var finalText = statusText || strAbort;
9340 transport.abort( finalText );
9342 done( 0, finalText );
9348 deferred.promise( jqXHR );
9350 // Add protocol if not provided (prefilters might expect it)
9351 // Handle falsy url in the settings object (trac-10093: consistency with old signature)
9352 // We also use the url parameter if available
9353 s.url = ( ( url || s.url || location.href ) + "" )
9354 .replace( rprotocol, location.protocol + "//" );
9356 // Alias method option to type as per ticket trac-12004
9357 s.type = options.method || options.type || s.method || s.type;
9359 // Extract dataTypes list
9360 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
9362 // A cross-domain request is in order when the origin doesn't match the current origin.
9363 if ( s.crossDomain == null ) {
9364 urlAnchor = document.createElement( "a" );
9366 // Support: IE <=8 - 11, Edge 12 - 15
9367 // IE throws exception on accessing the href property if url is malformed,
9368 // e.g. http://example.com:80x/
9370 urlAnchor.href = s.url;
9372 // Support: IE <=8 - 11 only
9373 // Anchor's host property isn't correctly set when s.url is relative
9374 urlAnchor.href = urlAnchor.href;
9375 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
9376 urlAnchor.protocol + "//" + urlAnchor.host;
9379 // If there is an error parsing the URL, assume it is crossDomain,
9380 // it can be rejected by the transport if it is invalid
9381 s.crossDomain = true;
9385 // Convert data if not already a string
9386 if ( s.data && s.processData && typeof s.data !== "string" ) {
9387 s.data = jQuery.param( s.data, s.traditional );
9391 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9393 // If request was aborted inside a prefilter, stop there
9398 // We can fire global events as of now if asked to
9399 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118)
9400 fireGlobals = jQuery.event && s.global;
9402 // Watch for a new set of requests
9403 if ( fireGlobals && jQuery.active++ === 0 ) {
9404 jQuery.event.trigger( "ajaxStart" );
9407 // Uppercase the type
9408 s.type = s.type.toUpperCase();
9410 // Determine if request has content
9411 s.hasContent = !rnoContent.test( s.type );
9413 // Save the URL in case we're toying with the If-Modified-Since
9414 // and/or If-None-Match header later on
9415 // Remove hash to simplify url manipulation
9416 cacheURL = s.url.replace( rhash, "" );
9418 // More options handling for requests with no content
9419 if ( !s.hasContent ) {
9421 // Remember the hash so we can put it back
9422 uncached = s.url.slice( cacheURL.length );
9424 // If data is available and should be processed, append data to url
9425 if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
9426 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
9428 // trac-9682: remove data so that it's not used in an eventual retry
9432 // Add or update anti-cache param if needed
9433 if ( s.cache === false ) {
9434 cacheURL = cacheURL.replace( rantiCache, "$1" );
9435 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
9439 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9440 s.url = cacheURL + uncached;
9442 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9443 } else if ( s.data && s.processData &&
9444 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9445 s.data = s.data.replace( r20, "+" );
9448 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9449 if ( s.ifModified ) {
9450 if ( jQuery.lastModified[ cacheURL ] ) {
9451 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9453 if ( jQuery.etag[ cacheURL ] ) {
9454 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9458 // Set the correct header, if data is being sent
9459 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9460 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9463 // Set the Accepts header for the server, depending on the dataType
9464 jqXHR.setRequestHeader(
9466 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
9467 s.accepts[ s.dataTypes[ 0 ] ] +
9468 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9472 // Check for headers option
9473 for ( i in s.headers ) {
9474 jqXHR.setRequestHeader( i, s.headers[ i ] );
9477 // Allow custom headers/mimetypes and early abort
9478 if ( s.beforeSend &&
9479 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
9481 // Abort if not done already and return
9482 return jqXHR.abort();
9485 // Aborting is no longer a cancellation
9488 // Install callbacks on deferreds
9489 completeDeferred.add( s.complete );
9490 jqXHR.done( s.success );
9491 jqXHR.fail( s.error );
9494 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9496 // If no transport, we auto-abort
9498 done( -1, "No Transport" );
9500 jqXHR.readyState = 1;
9502 // Send global event
9503 if ( fireGlobals ) {
9504 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9507 // If request was aborted inside ajaxSend, stop there
9513 if ( s.async && s.timeout > 0 ) {
9514 timeoutTimer = window.setTimeout( function() {
9515 jqXHR.abort( "timeout" );
9521 transport.send( requestHeaders, done );
9524 // Rethrow post-completion exceptions
9529 // Propagate others as results
9534 // Callback for when everything is done
9535 function done( status, nativeStatusText, responses, headers ) {
9536 var isSuccess, success, error, response, modified,
9537 statusText = nativeStatusText;
9539 // Ignore repeat invocations
9546 // Clear timeout if it exists
9547 if ( timeoutTimer ) {
9548 window.clearTimeout( timeoutTimer );
9551 // Dereference transport for early garbage collection
9552 // (no matter how long the jqXHR object will be used)
9553 transport = undefined;
9555 // Cache response headers
9556 responseHeadersString = headers || "";
9559 jqXHR.readyState = status > 0 ? 4 : 0;
9561 // Determine if successful
9562 isSuccess = status >= 200 && status < 300 || status === 304;
9564 // Get response data
9566 response = ajaxHandleResponses( s, jqXHR, responses );
9569 // Use a noop converter for missing script but not if jsonp
9571 jQuery.inArray( "script", s.dataTypes ) > -1 &&
9572 jQuery.inArray( "json", s.dataTypes ) < 0 ) {
9573 s.converters[ "text script" ] = function() {};
9576 // Convert no matter what (that way responseXXX fields are always set)
9577 response = ajaxConvert( s, response, jqXHR, isSuccess );
9579 // If successful, handle type chaining
9582 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9583 if ( s.ifModified ) {
9584 modified = jqXHR.getResponseHeader( "Last-Modified" );
9586 jQuery.lastModified[ cacheURL ] = modified;
9588 modified = jqXHR.getResponseHeader( "etag" );
9590 jQuery.etag[ cacheURL ] = modified;
9595 if ( status === 204 || s.type === "HEAD" ) {
9596 statusText = "nocontent";
9599 } else if ( status === 304 ) {
9600 statusText = "notmodified";
9602 // If we have data, let's convert it
9604 statusText = response.state;
9605 success = response.data;
9606 error = response.error;
9611 // Extract error from statusText and normalize for non-aborts
9613 if ( status || !statusText ) {
9614 statusText = "error";
9621 // Set data for the fake xhr object
9622 jqXHR.status = status;
9623 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9627 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9629 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9632 // Status-dependent callbacks
9633 jqXHR.statusCode( statusCode );
9634 statusCode = undefined;
9636 if ( fireGlobals ) {
9637 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9638 [ jqXHR, s, isSuccess ? success : error ] );
9642 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9644 if ( fireGlobals ) {
9645 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9647 // Handle the global AJAX counter
9648 if ( !( --jQuery.active ) ) {
9649 jQuery.event.trigger( "ajaxStop" );
9657 getJSON: function( url, data, callback ) {
9658 return jQuery.get( url, data, callback, "json" );
9661 getScript: function( url, callback ) {
9662 return jQuery.get( url, undefined, callback, "script" );
9666 jQuery.each( [ "get", "post" ], function( _i, method ) {
9667 jQuery[ method ] = function( url, data, callback, type ) {
9669 // Shift arguments if data argument was omitted
9670 if ( isFunction( data ) ) {
9671 type = type || callback;
9676 // The url can be an options object (which then must have .url)
9677 return jQuery.ajax( jQuery.extend( {
9683 }, jQuery.isPlainObject( url ) && url ) );
9687 jQuery.ajaxPrefilter( function( s ) {
9689 for ( i in s.headers ) {
9690 if ( i.toLowerCase() === "content-type" ) {
9691 s.contentType = s.headers[ i ] || "";
9697 jQuery._evalUrl = function( url, options, doc ) {
9698 return jQuery.ajax( {
9701 // Make this explicit, since user can override this through ajaxSetup (trac-11264)
9708 // Only evaluate the response if it is successful (gh-4126)
9709 // dataFilter is not invoked for failure responses, so using it instead
9710 // of the default converter is kludgy but it works.
9712 "text script": function() {}
9714 dataFilter: function( response ) {
9715 jQuery.globalEval( response, options, doc );
9722 wrapAll: function( html ) {
9726 if ( isFunction( html ) ) {
9727 html = html.call( this[ 0 ] );
9730 // The elements to wrap the target around
9731 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
9733 if ( this[ 0 ].parentNode ) {
9734 wrap.insertBefore( this[ 0 ] );
9737 wrap.map( function() {
9740 while ( elem.firstElementChild ) {
9741 elem = elem.firstElementChild;
9751 wrapInner: function( html ) {
9752 if ( isFunction( html ) ) {
9753 return this.each( function( i ) {
9754 jQuery( this ).wrapInner( html.call( this, i ) );
9758 return this.each( function() {
9759 var self = jQuery( this ),
9760 contents = self.contents();
9762 if ( contents.length ) {
9763 contents.wrapAll( html );
9766 self.append( html );
9771 wrap: function( html ) {
9772 var htmlIsFunction = isFunction( html );
9774 return this.each( function( i ) {
9775 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
9779 unwrap: function( selector ) {
9780 this.parent( selector ).not( "body" ).each( function() {
9781 jQuery( this ).replaceWith( this.childNodes );
9788 jQuery.expr.pseudos.hidden = function( elem ) {
9789 return !jQuery.expr.pseudos.visible( elem );
9791 jQuery.expr.pseudos.visible = function( elem ) {
9792 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
9798 jQuery.ajaxSettings.xhr = function() {
9800 return new window.XMLHttpRequest();
9804 var xhrSuccessStatus = {
9806 // File protocol always yields status code 0, assume 200
9809 // Support: IE <=9 only
9810 // trac-1450: sometimes IE returns 1223 when it should be 204
9813 xhrSupported = jQuery.ajaxSettings.xhr();
9815 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
9816 support.ajax = xhrSupported = !!xhrSupported;
9818 jQuery.ajaxTransport( function( options ) {
9819 var callback, errorCallback;
9821 // Cross domain only allowed if supported through XMLHttpRequest
9822 if ( support.cors || xhrSupported && !options.crossDomain ) {
9824 send: function( headers, complete ) {
9826 xhr = options.xhr();
9836 // Apply custom fields if provided
9837 if ( options.xhrFields ) {
9838 for ( i in options.xhrFields ) {
9839 xhr[ i ] = options.xhrFields[ i ];
9843 // Override mime type if needed
9844 if ( options.mimeType && xhr.overrideMimeType ) {
9845 xhr.overrideMimeType( options.mimeType );
9848 // X-Requested-With header
9849 // For cross-domain requests, seeing as conditions for a preflight are
9850 // akin to a jigsaw puzzle, we simply never set it to be sure.
9851 // (it can always be set on a per-request basis or even using ajaxSetup)
9852 // For same-domain requests, won't change header if already provided.
9853 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
9854 headers[ "X-Requested-With" ] = "XMLHttpRequest";
9858 for ( i in headers ) {
9859 xhr.setRequestHeader( i, headers[ i ] );
9863 callback = function( type ) {
9866 callback = errorCallback = xhr.onload =
9867 xhr.onerror = xhr.onabort = xhr.ontimeout =
9868 xhr.onreadystatechange = null;
9870 if ( type === "abort" ) {
9872 } else if ( type === "error" ) {
9874 // Support: IE <=9 only
9875 // On a manual native abort, IE9 throws
9876 // errors on any property access that is not readyState
9877 if ( typeof xhr.status !== "number" ) {
9878 complete( 0, "error" );
9882 // File: protocol always yields status 0; see trac-8605, trac-14207
9889 xhrSuccessStatus[ xhr.status ] || xhr.status,
9892 // Support: IE <=9 only
9893 // IE9 has no XHR2 but throws on binary (trac-11426)
9894 // For XHR2 non-text, let the caller handle it (gh-2498)
9895 ( xhr.responseType || "text" ) !== "text" ||
9896 typeof xhr.responseText !== "string" ?
9897 { binary: xhr.response } :
9898 { text: xhr.responseText },
9899 xhr.getAllResponseHeaders()
9907 xhr.onload = callback();
9908 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
9910 // Support: IE 9 only
9911 // Use onreadystatechange to replace onabort
9912 // to handle uncaught aborts
9913 if ( xhr.onabort !== undefined ) {
9914 xhr.onabort = errorCallback;
9916 xhr.onreadystatechange = function() {
9918 // Check readyState before timeout as it changes
9919 if ( xhr.readyState === 4 ) {
9921 // Allow onerror to be called first,
9922 // but that will not handle a native abort
9923 // Also, save errorCallback to a variable
9924 // as xhr.onerror cannot be accessed
9925 window.setTimeout( function() {
9934 // Create the abort callback
9935 callback = callback( "abort" );
9939 // Do send the request (this may raise an exception)
9940 xhr.send( options.hasContent && options.data || null );
9943 // trac-14683: Only rethrow if this hasn't been notified as an error yet
9962 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
9963 jQuery.ajaxPrefilter( function( s ) {
9964 if ( s.crossDomain ) {
9965 s.contents.script = false;
9969 // Install script dataType
9972 script: "text/javascript, application/javascript, " +
9973 "application/ecmascript, application/x-ecmascript"
9976 script: /\b(?:java|ecma)script\b/
9979 "text script": function( text ) {
9980 jQuery.globalEval( text );
9986 // Handle cache's special case and crossDomain
9987 jQuery.ajaxPrefilter( "script", function( s ) {
9988 if ( s.cache === undefined ) {
9991 if ( s.crossDomain ) {
9996 // Bind script tag hack transport
9997 jQuery.ajaxTransport( "script", function( s ) {
9999 // This transport only deals with cross domain or forced-by-attrs requests
10000 if ( s.crossDomain || s.scriptAttrs ) {
10001 var script, callback;
10003 send: function( _, complete ) {
10004 script = jQuery( "<script>" )
10005 .attr( s.scriptAttrs || {} )
10006 .prop( { charset: s.scriptCharset, src: s.url } )
10007 .on( "load error", callback = function( evt ) {
10011 complete( evt.type === "error" ? 404 : 200, evt.type );
10015 // Use native DOM manipulation to avoid our domManip AJAX trickery
10016 document.head.appendChild( script[ 0 ] );
10018 abort: function() {
10030 var oldCallbacks = [],
10031 rjsonp = /(=)\?(?=&|$)|\?\?/;
10033 // Default jsonp settings
10034 jQuery.ajaxSetup( {
10036 jsonpCallback: function() {
10037 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
10038 this[ callback ] = true;
10043 // Detect, normalize options and install callbacks for jsonp requests
10044 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
10046 var callbackName, overwritten, responseContainer,
10047 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
10049 typeof s.data === "string" &&
10050 ( s.contentType || "" )
10051 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
10052 rjsonp.test( s.data ) && "data"
10055 // Handle iff the expected data type is "jsonp" or we have a parameter to set
10056 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
10058 // Get callback name, remembering preexisting value associated with it
10059 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
10060 s.jsonpCallback() :
10063 // Insert callback into url or form data
10065 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
10066 } else if ( s.jsonp !== false ) {
10067 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
10070 // Use data converter to retrieve json after script execution
10071 s.converters[ "script json" ] = function() {
10072 if ( !responseContainer ) {
10073 jQuery.error( callbackName + " was not called" );
10075 return responseContainer[ 0 ];
10078 // Force json dataType
10079 s.dataTypes[ 0 ] = "json";
10081 // Install callback
10082 overwritten = window[ callbackName ];
10083 window[ callbackName ] = function() {
10084 responseContainer = arguments;
10087 // Clean-up function (fires after converters)
10088 jqXHR.always( function() {
10090 // If previous value didn't exist - remove it
10091 if ( overwritten === undefined ) {
10092 jQuery( window ).removeProp( callbackName );
10094 // Otherwise restore preexisting value
10096 window[ callbackName ] = overwritten;
10099 // Save back as free
10100 if ( s[ callbackName ] ) {
10102 // Make sure that re-using the options doesn't screw things around
10103 s.jsonpCallback = originalSettings.jsonpCallback;
10105 // Save the callback name for future use
10106 oldCallbacks.push( callbackName );
10109 // Call if it was a function and we have a response
10110 if ( responseContainer && isFunction( overwritten ) ) {
10111 overwritten( responseContainer[ 0 ] );
10114 responseContainer = overwritten = undefined;
10117 // Delegate to script
10125 // Support: Safari 8 only
10126 // In Safari 8 documents created via document.implementation.createHTMLDocument
10127 // collapse sibling forms: the second one becomes a child of the first one.
10128 // Because of that, this security measure has to be disabled in Safari 8.
10129 // https://bugs.webkit.org/show_bug.cgi?id=137337
10130 support.createHTMLDocument = ( function() {
10131 var body = document.implementation.createHTMLDocument( "" ).body;
10132 body.innerHTML = "<form></form><form></form>";
10133 return body.childNodes.length === 2;
10137 // Argument "data" should be string of html
10138 // context (optional): If specified, the fragment will be created in this context,
10139 // defaults to document
10140 // keepScripts (optional): If true, will include scripts passed in the html string
10141 jQuery.parseHTML = function( data, context, keepScripts ) {
10142 if ( typeof data !== "string" ) {
10145 if ( typeof context === "boolean" ) {
10146 keepScripts = context;
10150 var base, parsed, scripts;
10154 // Stop scripts or inline event handlers from being executed immediately
10155 // by using document.implementation
10156 if ( support.createHTMLDocument ) {
10157 context = document.implementation.createHTMLDocument( "" );
10159 // Set the base href for the created document
10160 // so any parsed elements with URLs
10161 // are based on the document's URL (gh-2965)
10162 base = context.createElement( "base" );
10163 base.href = document.location.href;
10164 context.head.appendChild( base );
10166 context = document;
10170 parsed = rsingleTag.exec( data );
10171 scripts = !keepScripts && [];
10175 return [ context.createElement( parsed[ 1 ] ) ];
10178 parsed = buildFragment( [ data ], context, scripts );
10180 if ( scripts && scripts.length ) {
10181 jQuery( scripts ).remove();
10184 return jQuery.merge( [], parsed.childNodes );
10189 * Load a url into a page
10191 jQuery.fn.load = function( url, params, callback ) {
10192 var selector, type, response,
10194 off = url.indexOf( " " );
10197 selector = stripAndCollapse( url.slice( off ) );
10198 url = url.slice( 0, off );
10201 // If it's a function
10202 if ( isFunction( params ) ) {
10204 // We assume that it's the callback
10206 params = undefined;
10208 // Otherwise, build a param string
10209 } else if ( params && typeof params === "object" ) {
10213 // If we have elements to modify, make the request
10214 if ( self.length > 0 ) {
10218 // If "type" variable is undefined, then "GET" method will be used.
10219 // Make value of this field explicit since
10220 // user can override it through ajaxSetup method
10221 type: type || "GET",
10224 } ).done( function( responseText ) {
10226 // Save response for use in complete callback
10227 response = arguments;
10229 self.html( selector ?
10231 // If a selector was specified, locate the right elements in a dummy div
10232 // Exclude scripts to avoid IE 'Permission Denied' errors
10233 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
10235 // Otherwise use the full result
10238 // If the request succeeds, this function gets "data", "status", "jqXHR"
10239 // but they are ignored because response was set above.
10240 // If it fails, this function gets "jqXHR", "status", "error"
10241 } ).always( callback && function( jqXHR, status ) {
10242 self.each( function() {
10243 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
10254 jQuery.expr.pseudos.animated = function( elem ) {
10255 return jQuery.grep( jQuery.timers, function( fn ) {
10256 return elem === fn.elem;
10264 setOffset: function( elem, options, i ) {
10265 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
10266 position = jQuery.css( elem, "position" ),
10267 curElem = jQuery( elem ),
10270 // Set position first, in-case top/left are set even on static elem
10271 if ( position === "static" ) {
10272 elem.style.position = "relative";
10275 curOffset = curElem.offset();
10276 curCSSTop = jQuery.css( elem, "top" );
10277 curCSSLeft = jQuery.css( elem, "left" );
10278 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
10279 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
10281 // Need to be able to calculate position if either
10282 // top or left is auto and position is either absolute or fixed
10283 if ( calculatePosition ) {
10284 curPosition = curElem.position();
10285 curTop = curPosition.top;
10286 curLeft = curPosition.left;
10289 curTop = parseFloat( curCSSTop ) || 0;
10290 curLeft = parseFloat( curCSSLeft ) || 0;
10293 if ( isFunction( options ) ) {
10295 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
10296 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
10299 if ( options.top != null ) {
10300 props.top = ( options.top - curOffset.top ) + curTop;
10302 if ( options.left != null ) {
10303 props.left = ( options.left - curOffset.left ) + curLeft;
10306 if ( "using" in options ) {
10307 options.using.call( elem, props );
10310 curElem.css( props );
10315 jQuery.fn.extend( {
10317 // offset() relates an element's border box to the document origin
10318 offset: function( options ) {
10320 // Preserve chaining for setter
10321 if ( arguments.length ) {
10322 return options === undefined ?
10324 this.each( function( i ) {
10325 jQuery.offset.setOffset( this, options, i );
10336 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
10337 // Support: IE <=11 only
10338 // Running getBoundingClientRect on a
10339 // disconnected node in IE throws an error
10340 if ( !elem.getClientRects().length ) {
10341 return { top: 0, left: 0 };
10344 // Get document-relative position by adding viewport scroll to viewport-relative gBCR
10345 rect = elem.getBoundingClientRect();
10346 win = elem.ownerDocument.defaultView;
10348 top: rect.top + win.pageYOffset,
10349 left: rect.left + win.pageXOffset
10353 // position() relates an element's margin box to its offset parent's padding box
10354 // This corresponds to the behavior of CSS absolute positioning
10355 position: function() {
10356 if ( !this[ 0 ] ) {
10360 var offsetParent, offset, doc,
10362 parentOffset = { top: 0, left: 0 };
10364 // position:fixed elements are offset from the viewport, which itself always has zero offset
10365 if ( jQuery.css( elem, "position" ) === "fixed" ) {
10367 // Assume position:fixed implies availability of getBoundingClientRect
10368 offset = elem.getBoundingClientRect();
10371 offset = this.offset();
10373 // Account for the *real* offset parent, which can be the document or its root element
10374 // when a statically positioned element is identified
10375 doc = elem.ownerDocument;
10376 offsetParent = elem.offsetParent || doc.documentElement;
10377 while ( offsetParent &&
10378 ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
10379 jQuery.css( offsetParent, "position" ) === "static" ) {
10381 offsetParent = offsetParent.parentNode;
10383 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
10385 // Incorporate borders into its offset, since they are outside its content origin
10386 parentOffset = jQuery( offsetParent ).offset();
10387 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
10388 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
10392 // Subtract parent offsets and element margins
10394 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10395 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
10399 // This method will return documentElement in the following cases:
10400 // 1) For the element inside the iframe without offsetParent, this method will return
10401 // documentElement of the parent window
10402 // 2) For the hidden or detached element
10403 // 3) For body or html element, i.e. in case of the html node - it will return itself
10405 // but those exceptions were never presented as a real life use-cases
10406 // and might be considered as more preferable results.
10408 // This logic, however, is not guaranteed and can change at any point in the future
10409 offsetParent: function() {
10410 return this.map( function() {
10411 var offsetParent = this.offsetParent;
10413 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
10414 offsetParent = offsetParent.offsetParent;
10417 return offsetParent || documentElement;
10422 // Create scrollLeft and scrollTop methods
10423 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10424 var top = "pageYOffset" === prop;
10426 jQuery.fn[ method ] = function( val ) {
10427 return access( this, function( elem, method, val ) {
10429 // Coalesce documents and windows
10431 if ( isWindow( elem ) ) {
10433 } else if ( elem.nodeType === 9 ) {
10434 win = elem.defaultView;
10437 if ( val === undefined ) {
10438 return win ? win[ prop ] : elem[ method ];
10443 !top ? val : win.pageXOffset,
10444 top ? val : win.pageYOffset
10448 elem[ method ] = val;
10450 }, method, val, arguments.length );
10454 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10455 // Add the top/left cssHooks using jQuery.fn.position
10456 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10457 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10458 // getComputedStyle returns percent when specified for top/left/bottom/right;
10459 // rather than make the css module depend on the offset module, just check for it here
10460 jQuery.each( [ "top", "left" ], function( _i, prop ) {
10461 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10462 function( elem, computed ) {
10464 computed = curCSS( elem, prop );
10466 // If curCSS returns percentage, fallback to offset
10467 return rnumnonpx.test( computed ) ?
10468 jQuery( elem ).position()[ prop ] + "px" :
10476 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10477 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10479 padding: "inner" + name,
10482 }, function( defaultExtra, funcName ) {
10484 // Margin is only for outerHeight, outerWidth
10485 jQuery.fn[ funcName ] = function( margin, value ) {
10486 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10487 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10489 return access( this, function( elem, type, value ) {
10492 if ( isWindow( elem ) ) {
10494 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10495 return funcName.indexOf( "outer" ) === 0 ?
10496 elem[ "inner" + name ] :
10497 elem.document.documentElement[ "client" + name ];
10500 // Get document width or height
10501 if ( elem.nodeType === 9 ) {
10502 doc = elem.documentElement;
10504 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10505 // whichever is greatest
10507 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10508 elem.body[ "offset" + name ], doc[ "offset" + name ],
10509 doc[ "client" + name ]
10513 return value === undefined ?
10515 // Get width or height on the element, requesting but not forcing parseFloat
10516 jQuery.css( elem, type, extra ) :
10518 // Set width or height on the element
10519 jQuery.style( elem, type, value, extra );
10520 }, type, chainable ? margin : undefined, chainable );
10533 ], function( _i, type ) {
10534 jQuery.fn[ type ] = function( fn ) {
10535 return this.on( type, fn );
10542 jQuery.fn.extend( {
10544 bind: function( types, data, fn ) {
10545 return this.on( types, null, data, fn );
10547 unbind: function( types, fn ) {
10548 return this.off( types, null, fn );
10551 delegate: function( selector, types, data, fn ) {
10552 return this.on( types, selector, data, fn );
10554 undelegate: function( selector, types, fn ) {
10556 // ( namespace ) or ( selector, types [, fn] )
10557 return arguments.length === 1 ?
10558 this.off( selector, "**" ) :
10559 this.off( types, selector || "**", fn );
10562 hover: function( fnOver, fnOut ) {
10564 .on( "mouseenter", fnOver )
10565 .on( "mouseleave", fnOut || fnOver );
10570 ( "blur focus focusin focusout resize scroll click dblclick " +
10571 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10572 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
10573 function( _i, name ) {
10575 // Handle event binding
10576 jQuery.fn[ name ] = function( data, fn ) {
10577 return arguments.length > 0 ?
10578 this.on( name, null, data, fn ) :
10579 this.trigger( name );
10587 // Support: Android <=4.0 only
10588 // Make sure we trim BOM and NBSP
10589 // Require that the "whitespace run" starts from a non-whitespace
10590 // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
10591 var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
10593 // Bind a function to a context, optionally partially applying any
10595 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10596 // However, it is not slated for removal any time soon
10597 jQuery.proxy = function( fn, context ) {
10598 var tmp, args, proxy;
10600 if ( typeof context === "string" ) {
10601 tmp = fn[ context ];
10606 // Quick check to determine if target is callable, in the spec
10607 // this throws a TypeError, but we will just return undefined.
10608 if ( !isFunction( fn ) ) {
10613 args = slice.call( arguments, 2 );
10614 proxy = function() {
10615 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
10618 // Set the guid of unique handler to the same of original handler, so it can be removed
10619 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
10624 jQuery.holdReady = function( hold ) {
10626 jQuery.readyWait++;
10628 jQuery.ready( true );
10631 jQuery.isArray = Array.isArray;
10632 jQuery.parseJSON = JSON.parse;
10633 jQuery.nodeName = nodeName;
10634 jQuery.isFunction = isFunction;
10635 jQuery.isWindow = isWindow;
10636 jQuery.camelCase = camelCase;
10637 jQuery.type = toType;
10639 jQuery.now = Date.now;
10641 jQuery.isNumeric = function( obj ) {
10643 // As of jQuery 3.0, isNumeric is limited to
10644 // strings and numbers (primitives or objects)
10645 // that can be coerced to finite numbers (gh-2662)
10646 var type = jQuery.type( obj );
10647 return ( type === "number" || type === "string" ) &&
10649 // parseFloat NaNs numeric-cast false positives ("")
10650 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
10651 // subtraction forces infinities to NaN
10652 !isNaN( obj - parseFloat( obj ) );
10655 jQuery.trim = function( text ) {
10656 return text == null ?
10658 ( text + "" ).replace( rtrim, "$1" );
10663 // Register as a named AMD module, since jQuery can be concatenated with other
10664 // files that may use define, but not via a proper concatenation script that
10665 // understands anonymous AMD modules. A named AMD is safest and most robust
10666 // way to register. Lowercase jquery is used because AMD module names are
10667 // derived from file names, and jQuery is normally delivered in a lowercase
10668 // file name. Do this after creating the global so that if an AMD module wants
10669 // to call noConflict to hide this version of jQuery, it will work.
10671 // Note that for maximum portability, libraries that are not jQuery should
10672 // declare themselves as anonymous modules, and avoid setting a global if an
10673 // AMD loader is present. jQuery is a special case. For more information, see
10674 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10676 if ( typeof define === "function" && define.amd ) {
10677 define( "jquery", [], function() {
10687 // Map over jQuery in case of overwrite
10688 _jQuery = window.jQuery,
10690 // Map over the $ in case of overwrite
10693 jQuery.noConflict = function( deep ) {
10694 if ( window.$ === jQuery ) {
10698 if ( deep && window.jQuery === jQuery ) {
10699 window.jQuery = _jQuery;
10705 // Expose jQuery and $ identifiers, even in AMD
10706 // (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557)
10707 // and CommonJS for browser emulators (trac-13566)
10708 if ( typeof noGlobal === "undefined" ) {
10709 window.jQuery = window.$ = jQuery;