2 * jQuery JavaScript Library v3.1.1
6 * https://sizzlejs.com/
8 * Copyright jQuery Foundation and other contributors
9 * Released under the MIT license
10 * https://jquery.org/license
12 * Date: 2016-09-22T22:30Z
14 ( function( global, factory ) {
18 if ( typeof module === "object" && typeof module.exports === "object" ) {
20 // For CommonJS and CommonJS-like environments where a proper `window`
21 // is present, execute the factory and get jQuery.
22 // For environments that do not have a `window` with a `document`
23 // (such as Node.js), expose a factory as module.exports.
24 // This accentuates the need for the creation of a real `window`.
25 // e.g. var jQuery = require("jquery")(window);
26 // See ticket #14549 for more info.
27 module.exports = global.document ?
28 factory( global, true ) :
31 throw new Error( "jQuery requires a window with a document" );
39 // Pass this if window is not defined yet
40 } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
42 // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
43 // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
44 // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
45 // enough that all such attempts are guarded in a try block.
50 var document = window.document;
52 var getProto = Object.getPrototypeOf;
54 var slice = arr.slice;
56 var concat = arr.concat;
60 var indexOf = arr.indexOf;
64 var toString = class2type.toString;
66 var hasOwn = class2type.hasOwnProperty;
68 var fnToString = hasOwn.toString;
70 var ObjectFunctionString = fnToString.call( Object );
76 function DOMEval( code, doc ) {
77 doc = doc || document;
79 var script = doc.createElement( "script" );
82 doc.head.appendChild( script ).parentNode.removeChild( script );
85 // Defining this global in .eslintrc.json would create a danger of using the global
86 // unguarded in another place, it seems safer to define global only for this module
93 // Define a local copy of jQuery
94 jQuery = function( selector, context ) {
96 // The jQuery object is actually just the init constructor 'enhanced'
97 // Need init if jQuery is called (just allow error to be thrown if not included)
98 return new jQuery.fn.init( selector, context );
101 // Support: Android <=4.0 only
102 // Make sure we trim BOM and NBSP
103 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
105 // Matches dashed string for camelizing
107 rdashAlpha = /-([a-z])/g,
109 // Used by jQuery.camelCase as callback to replace()
110 fcamelCase = function( all, letter ) {
111 return letter.toUpperCase();
114 jQuery.fn = jQuery.prototype = {
116 // The current version of jQuery being used
121 // The default length of a jQuery object is 0
124 toArray: function() {
125 return slice.call( this );
128 // Get the Nth element in the matched element set OR
129 // Get the whole matched element set as a clean array
130 get: function( num ) {
132 // Return all the elements in a clean array
134 return slice.call( this );
137 // Return just the one element from the set
138 return num < 0 ? this[ num + this.length ] : this[ num ];
141 // Take an array of elements and push it onto the stack
142 // (returning the new matched element set)
143 pushStack: function( elems ) {
145 // Build a new jQuery matched element set
146 var ret = jQuery.merge( this.constructor(), elems );
148 // Add the old object onto the stack (as a reference)
149 ret.prevObject = this;
151 // Return the newly-formed element set
155 // Execute a callback for every element in the matched set.
156 each: function( callback ) {
157 return jQuery.each( this, callback );
160 map: function( callback ) {
161 return this.pushStack( jQuery.map( this, function( elem, i ) {
162 return callback.call( elem, i, elem );
167 return this.pushStack( slice.apply( this, arguments ) );
175 return this.eq( -1 );
179 var len = this.length,
180 j = +i + ( i < 0 ? len : 0 );
181 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
185 return this.prevObject || this.constructor();
188 // For internal use only.
189 // Behaves like an Array's method, not like a jQuery method.
195 jQuery.extend = jQuery.fn.extend = function() {
196 var options, name, src, copy, copyIsArray, clone,
197 target = arguments[ 0 ] || {},
199 length = arguments.length,
202 // Handle a deep copy situation
203 if ( typeof target === "boolean" ) {
206 // Skip the boolean and the target
207 target = arguments[ i ] || {};
211 // Handle case when target is a string or something (possible in deep copy)
212 if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
216 // Extend jQuery itself if only one argument is passed
217 if ( i === length ) {
222 for ( ; i < length; i++ ) {
224 // Only deal with non-null/undefined values
225 if ( ( options = arguments[ i ] ) != null ) {
227 // Extend the base object
228 for ( name in options ) {
229 src = target[ name ];
230 copy = options[ name ];
232 // Prevent never-ending loop
233 if ( target === copy ) {
237 // Recurse if we're merging plain objects or arrays
238 if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
239 ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
243 clone = src && jQuery.isArray( src ) ? src : [];
246 clone = src && jQuery.isPlainObject( src ) ? src : {};
249 // Never move original objects, clone them
250 target[ name ] = jQuery.extend( deep, clone, copy );
252 // Don't bring in undefined values
253 } else if ( copy !== undefined ) {
254 target[ name ] = copy;
260 // Return the modified object
266 // Unique for each copy of jQuery on the page
267 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
269 // Assume jQuery is ready without the ready module
272 error: function( msg ) {
273 throw new Error( msg );
278 isFunction: function( obj ) {
279 return jQuery.type( obj ) === "function";
282 isArray: Array.isArray,
284 isWindow: function( obj ) {
285 return obj != null && obj === obj.window;
288 isNumeric: function( obj ) {
290 // As of jQuery 3.0, isNumeric is limited to
291 // strings and numbers (primitives or objects)
292 // that can be coerced to finite numbers (gh-2662)
293 var type = jQuery.type( obj );
294 return ( type === "number" || type === "string" ) &&
296 // parseFloat NaNs numeric-cast false positives ("")
297 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
298 // subtraction forces infinities to NaN
299 !isNaN( obj - parseFloat( obj ) );
302 isPlainObject: function( obj ) {
305 // Detect obvious negatives
306 // Use toString instead of jQuery.type to catch host objects
307 if ( !obj || toString.call( obj ) !== "[object Object]" ) {
311 proto = getProto( obj );
313 // Objects with no prototype (e.g., `Object.create( null )`) are plain
318 // Objects with prototype are plain iff they were constructed by a global Object function
319 Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
320 return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
323 isEmptyObject: function( obj ) {
325 /* eslint-disable no-unused-vars */
326 // See https://github.com/eslint/eslint/issues/6125
329 for ( name in obj ) {
335 type: function( obj ) {
340 // Support: Android <=2.3 only (functionish RegExp)
341 return typeof obj === "object" || typeof obj === "function" ?
342 class2type[ toString.call( obj ) ] || "object" :
346 // Evaluates a script in a global context
347 globalEval: function( code ) {
351 // Convert dashed to camelCase; used by the css and data modules
352 // Support: IE <=9 - 11, Edge 12 - 13
353 // Microsoft forgot to hump their vendor prefix (#9572)
354 camelCase: function( string ) {
355 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
358 nodeName: function( elem, name ) {
359 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
362 each: function( obj, callback ) {
365 if ( isArrayLike( obj ) ) {
367 for ( ; i < length; i++ ) {
368 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
374 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
383 // Support: Android <=4.0 only
384 trim: function( text ) {
385 return text == null ?
387 ( text + "" ).replace( rtrim, "" );
390 // results is for internal usage only
391 makeArray: function( arr, results ) {
392 var ret = results || [];
395 if ( isArrayLike( Object( arr ) ) ) {
397 typeof arr === "string" ?
401 push.call( ret, arr );
408 inArray: function( elem, arr, i ) {
409 return arr == null ? -1 : indexOf.call( arr, elem, i );
412 // Support: Android <=4.0 only, PhantomJS 1 only
413 // push.apply(_, arraylike) throws on ancient WebKit
414 merge: function( first, second ) {
415 var len = +second.length,
419 for ( ; j < len; j++ ) {
420 first[ i++ ] = second[ j ];
428 grep: function( elems, callback, invert ) {
432 length = elems.length,
433 callbackExpect = !invert;
435 // Go through the array, only saving the items
436 // that pass the validator function
437 for ( ; i < length; i++ ) {
438 callbackInverse = !callback( elems[ i ], i );
439 if ( callbackInverse !== callbackExpect ) {
440 matches.push( elems[ i ] );
447 // arg is for internal usage only
448 map: function( elems, callback, arg ) {
453 // Go through the array, translating each of the items to their new values
454 if ( isArrayLike( elems ) ) {
455 length = elems.length;
456 for ( ; i < length; i++ ) {
457 value = callback( elems[ i ], i, arg );
459 if ( value != null ) {
464 // Go through every key on the object,
467 value = callback( elems[ i ], i, arg );
469 if ( value != null ) {
475 // Flatten any nested arrays
476 return concat.apply( [], ret );
479 // A global GUID counter for objects
482 // Bind a function to a context, optionally partially applying any
484 proxy: function( fn, context ) {
485 var tmp, args, proxy;
487 if ( typeof context === "string" ) {
493 // Quick check to determine if target is callable, in the spec
494 // this throws a TypeError, but we will just return undefined.
495 if ( !jQuery.isFunction( fn ) ) {
500 args = slice.call( arguments, 2 );
502 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
505 // Set the guid of unique handler to the same of original handler, so it can be removed
506 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
513 // jQuery.support is not used in Core but other projects attach their
514 // properties to it so it needs to exist.
518 if ( typeof Symbol === "function" ) {
519 jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
522 // Populate the class2type map
523 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
524 function( i, name ) {
525 class2type[ "[object " + name + "]" ] = name.toLowerCase();
528 function isArrayLike( obj ) {
530 // Support: real iOS 8.2 only (not reproducible in simulator)
531 // `in` check used to prevent JIT error (gh-2145)
532 // hasOwn isn't used here due to false negatives
533 // regarding Nodelist length in IE
534 var length = !!obj && "length" in obj && obj.length,
535 type = jQuery.type( obj );
537 if ( type === "function" || jQuery.isWindow( obj ) ) {
541 return type === "array" || length === 0 ||
542 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
546 * Sizzle CSS Selector Engine v2.3.3
547 * https://sizzlejs.com/
549 * Copyright jQuery Foundation and other contributors
550 * Released under the MIT license
551 * http://jquery.org/license
555 (function( window ) {
569 // Local document vars
579 // Instance-specific data
580 expando = "sizzle" + 1 * new Date(),
581 preferredDoc = window.document,
584 classCache = createCache(),
585 tokenCache = createCache(),
586 compilerCache = createCache(),
587 sortOrder = function( a, b ) {
595 hasOwn = ({}).hasOwnProperty,
598 push_native = arr.push,
601 // Use a stripped-down indexOf as it's faster than native
602 // https://jsperf.com/thor-indexof-vs-for/5
603 indexOf = function( list, elem ) {
606 for ( ; i < len; i++ ) {
607 if ( list[i] === elem ) {
614 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
616 // Regular expressions
618 // http://www.w3.org/TR/css3-selectors/#whitespace
619 whitespace = "[\\x20\\t\\r\\n\\f]",
621 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
622 identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
624 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
625 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
626 // Operator (capture 2)
627 "*([*^$|!~]?=)" + whitespace +
628 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
629 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
632 pseudos = ":(" + identifier + ")(?:\\((" +
633 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
634 // 1. quoted (capture 3; capture 4 or capture 5)
635 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
636 // 2. simple (capture 6)
637 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
638 // 3. anything else (capture 2)
642 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
643 rwhitespace = new RegExp( whitespace + "+", "g" ),
644 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
646 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
647 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
649 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
651 rpseudo = new RegExp( pseudos ),
652 ridentifier = new RegExp( "^" + identifier + "$" ),
655 "ID": new RegExp( "^#(" + identifier + ")" ),
656 "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
657 "TAG": new RegExp( "^(" + identifier + "|[*])" ),
658 "ATTR": new RegExp( "^" + attributes ),
659 "PSEUDO": new RegExp( "^" + pseudos ),
660 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
661 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
662 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
663 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
664 // For use in libraries implementing .is()
665 // We use this for POS matching in `select`
666 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
667 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
670 rinputs = /^(?:input|select|textarea|button)$/i,
673 rnative = /^[^{]+\{\s*\[native \w/,
675 // Easily-parseable/retrievable ID or TAG or CLASS selectors
676 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
681 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
682 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
683 funescape = function( _, escaped, escapedWhitespace ) {
684 var high = "0x" + escaped - 0x10000;
685 // NaN means non-codepoint
686 // Support: Firefox<24
687 // Workaround erroneous numeric interpretation of +"0x"
688 return high !== high || escapedWhitespace ?
692 String.fromCharCode( high + 0x10000 ) :
693 // Supplemental Plane codepoint (surrogate pair)
694 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
697 // CSS string/identifier serialization
698 // https://drafts.csswg.org/cssom/#common-serializing-idioms
699 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
700 fcssescape = function( ch, asCodePoint ) {
703 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
708 // Control characters and (dependent upon position) numbers get escaped as code points
709 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
712 // Other potentially-special ASCII characters get backslash-escaped
718 // Removing the function wrapper causes a "Permission Denied"
720 unloadHandler = function() {
724 disabledAncestor = addCombinator(
726 return elem.disabled === true && ("form" in elem || "label" in elem);
728 { dir: "parentNode", next: "legend" }
731 // Optimize for push.apply( _, NodeList )
734 (arr = slice.call( preferredDoc.childNodes )),
735 preferredDoc.childNodes
737 // Support: Android<4.0
738 // Detect silently failing push.apply
739 arr[ preferredDoc.childNodes.length ].nodeType;
741 push = { apply: arr.length ?
743 // Leverage slice if possible
744 function( target, els ) {
745 push_native.apply( target, slice.call(els) );
749 // Otherwise append directly
750 function( target, els ) {
751 var j = target.length,
753 // Can't trust NodeList.length
754 while ( (target[j++] = els[i++]) ) {}
755 target.length = j - 1;
760 function Sizzle( selector, context, results, seed ) {
761 var m, i, elem, nid, match, groups, newSelector,
762 newContext = context && context.ownerDocument,
764 // nodeType defaults to 9, since context defaults to document
765 nodeType = context ? context.nodeType : 9;
767 results = results || [];
769 // Return early from calls with invalid selector or context
770 if ( typeof selector !== "string" || !selector ||
771 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
776 // Try to shortcut find operations (as opposed to filters) in HTML documents
779 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
780 setDocument( context );
782 context = context || document;
784 if ( documentIsHTML ) {
786 // If the selector is sufficiently simple, try using a "get*By*" DOM method
787 // (excepting DocumentFragment context, where the methods don't exist)
788 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
791 if ( (m = match[1]) ) {
794 if ( nodeType === 9 ) {
795 if ( (elem = context.getElementById( m )) ) {
797 // Support: IE, Opera, Webkit
798 // TODO: identify versions
799 // getElementById can match elements by name instead of ID
800 if ( elem.id === m ) {
801 results.push( elem );
811 // Support: IE, Opera, Webkit
812 // TODO: identify versions
813 // getElementById can match elements by name instead of ID
814 if ( newContext && (elem = newContext.getElementById( m )) &&
815 contains( context, elem ) &&
818 results.push( elem );
824 } else if ( match[2] ) {
825 push.apply( results, context.getElementsByTagName( selector ) );
829 } else if ( (m = match[3]) && support.getElementsByClassName &&
830 context.getElementsByClassName ) {
832 push.apply( results, context.getElementsByClassName( m ) );
837 // Take advantage of querySelectorAll
839 !compilerCache[ selector + " " ] &&
840 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
842 if ( nodeType !== 1 ) {
843 newContext = context;
844 newSelector = selector;
846 // qSA looks outside Element context, which is not what we want
847 // Thanks to Andrew Dupont for this workaround technique
849 // Exclude object elements
850 } else if ( context.nodeName.toLowerCase() !== "object" ) {
852 // Capture the context ID, setting it first if necessary
853 if ( (nid = context.getAttribute( "id" )) ) {
854 nid = nid.replace( rcssescape, fcssescape );
856 context.setAttribute( "id", (nid = expando) );
859 // Prefix every selector in the list
860 groups = tokenize( selector );
863 groups[i] = "#" + nid + " " + toSelector( groups[i] );
865 newSelector = groups.join( "," );
867 // Expand context for sibling selectors
868 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
875 newContext.querySelectorAll( newSelector )
878 } catch ( qsaError ) {
880 if ( nid === expando ) {
881 context.removeAttribute( "id" );
890 return select( selector.replace( rtrim, "$1" ), context, results, seed );
894 * Create key-value caches of limited size
895 * @returns {function(string, object)} Returns the Object data after storing it on itself with
896 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
897 * deleting the oldest entry
899 function createCache() {
902 function cache( key, value ) {
903 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
904 if ( keys.push( key + " " ) > Expr.cacheLength ) {
905 // Only keep the most recent entries
906 delete cache[ keys.shift() ];
908 return (cache[ key + " " ] = value);
914 * Mark a function for special use by Sizzle
915 * @param {Function} fn The function to mark
917 function markFunction( fn ) {
918 fn[ expando ] = true;
923 * Support testing using an element
924 * @param {Function} fn Passed the created element and returns a boolean result
926 function assert( fn ) {
927 var el = document.createElement("fieldset");
934 // Remove from its parent by default
935 if ( el.parentNode ) {
936 el.parentNode.removeChild( el );
938 // release memory in IE
944 * Adds the same handler for all of the specified attrs
945 * @param {String} attrs Pipe-separated list of attributes
946 * @param {Function} handler The method that will be applied
948 function addHandle( attrs, handler ) {
949 var arr = attrs.split("|"),
953 Expr.attrHandle[ arr[i] ] = handler;
958 * Checks document order of two siblings
961 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
963 function siblingCheck( a, b ) {
965 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
966 a.sourceIndex - b.sourceIndex;
968 // Use IE sourceIndex if available on both nodes
973 // Check if b follows a
975 while ( (cur = cur.nextSibling) ) {
986 * Returns a function to use in pseudos for input types
987 * @param {String} type
989 function createInputPseudo( type ) {
990 return function( elem ) {
991 var name = elem.nodeName.toLowerCase();
992 return name === "input" && elem.type === type;
997 * Returns a function to use in pseudos for buttons
998 * @param {String} type
1000 function createButtonPseudo( type ) {
1001 return function( elem ) {
1002 var name = elem.nodeName.toLowerCase();
1003 return (name === "input" || name === "button") && elem.type === type;
1008 * Returns a function to use in pseudos for :enabled/:disabled
1009 * @param {Boolean} disabled true for :disabled; false for :enabled
1011 function createDisabledPseudo( disabled ) {
1013 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1014 return function( elem ) {
1016 // Only certain elements can match :enabled or :disabled
1017 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1018 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1019 if ( "form" in elem ) {
1021 // Check for inherited disabledness on relevant non-disabled elements:
1022 // * listed form-associated elements in a disabled fieldset
1023 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
1024 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1025 // * option elements in a disabled optgroup
1026 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1027 // All such elements have a "form" property.
1028 if ( elem.parentNode && elem.disabled === false ) {
1030 // Option elements defer to a parent optgroup if present
1031 if ( "label" in elem ) {
1032 if ( "label" in elem.parentNode ) {
1033 return elem.parentNode.disabled === disabled;
1035 return elem.disabled === disabled;
1039 // Support: IE 6 - 11
1040 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
1041 return elem.isDisabled === disabled ||
1043 // Where there is no isDisabled, check manually
1045 elem.isDisabled !== !disabled &&
1046 disabledAncestor( elem ) === disabled;
1049 return elem.disabled === disabled;
1051 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1052 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1053 // even exist on them, let alone have a boolean value.
1054 } else if ( "label" in elem ) {
1055 return elem.disabled === disabled;
1058 // Remaining elements are neither :enabled nor :disabled
1064 * Returns a function to use in pseudos for positionals
1065 * @param {Function} fn
1067 function createPositionalPseudo( fn ) {
1068 return markFunction(function( argument ) {
1069 argument = +argument;
1070 return markFunction(function( seed, matches ) {
1072 matchIndexes = fn( [], seed.length, argument ),
1073 i = matchIndexes.length;
1075 // Match elements found at the specified indexes
1077 if ( seed[ (j = matchIndexes[i]) ] ) {
1078 seed[j] = !(matches[j] = seed[j]);
1086 * Checks a node for validity as a Sizzle context
1087 * @param {Element|Object=} context
1088 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1090 function testContext( context ) {
1091 return context && typeof context.getElementsByTagName !== "undefined" && context;
1094 // Expose support vars for convenience
1095 support = Sizzle.support = {};
1099 * @param {Element|Object} elem An element or a document
1100 * @returns {Boolean} True iff elem is a non-HTML XML node
1102 isXML = Sizzle.isXML = function( elem ) {
1103 // documentElement is verified for cases where it doesn't yet exist
1104 // (such as loading iframes in IE - #4833)
1105 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1106 return documentElement ? documentElement.nodeName !== "HTML" : false;
1110 * Sets document-related variables once based on the current document
1111 * @param {Element|Object} [doc] An element or document object to use to set the document
1112 * @returns {Object} Returns the current document
1114 setDocument = Sizzle.setDocument = function( node ) {
1115 var hasCompare, subWindow,
1116 doc = node ? node.ownerDocument || node : preferredDoc;
1118 // Return early if doc is invalid or already selected
1119 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1123 // Update global variables
1125 docElem = document.documentElement;
1126 documentIsHTML = !isXML( document );
1128 // Support: IE 9-11, Edge
1129 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1130 if ( preferredDoc !== document &&
1131 (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
1133 // Support: IE 11, Edge
1134 if ( subWindow.addEventListener ) {
1135 subWindow.addEventListener( "unload", unloadHandler, false );
1137 // Support: IE 9 - 10 only
1138 } else if ( subWindow.attachEvent ) {
1139 subWindow.attachEvent( "onunload", unloadHandler );
1144 ---------------------------------------------------------------------- */
1147 // Verify that getAttribute really returns attributes and not properties
1148 // (excepting IE8 booleans)
1149 support.attributes = assert(function( el ) {
1151 return !el.getAttribute("className");
1155 ---------------------------------------------------------------------- */
1157 // Check if getElementsByTagName("*") returns only elements
1158 support.getElementsByTagName = assert(function( el ) {
1159 el.appendChild( document.createComment("") );
1160 return !el.getElementsByTagName("*").length;
1164 support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1167 // Check if getElementById returns elements by name
1168 // The broken getElementById methods don't pick up programmatically-set names,
1169 // so use a roundabout getElementsByName test
1170 support.getById = assert(function( el ) {
1171 docElem.appendChild( el ).id = expando;
1172 return !document.getElementsByName || !document.getElementsByName( expando ).length;
1175 // ID filter and find
1176 if ( support.getById ) {
1177 Expr.filter["ID"] = function( id ) {
1178 var attrId = id.replace( runescape, funescape );
1179 return function( elem ) {
1180 return elem.getAttribute("id") === attrId;
1183 Expr.find["ID"] = function( id, context ) {
1184 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1185 var elem = context.getElementById( id );
1186 return elem ? [ elem ] : [];
1190 Expr.filter["ID"] = function( id ) {
1191 var attrId = id.replace( runescape, funescape );
1192 return function( elem ) {
1193 var node = typeof elem.getAttributeNode !== "undefined" &&
1194 elem.getAttributeNode("id");
1195 return node && node.value === attrId;
1199 // Support: IE 6 - 7 only
1200 // getElementById is not reliable as a find shortcut
1201 Expr.find["ID"] = function( id, context ) {
1202 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1204 elem = context.getElementById( id );
1208 // Verify the id attribute
1209 node = elem.getAttributeNode("id");
1210 if ( node && node.value === id ) {
1214 // Fall back on getElementsByName
1215 elems = context.getElementsByName( id );
1217 while ( (elem = elems[i++]) ) {
1218 node = elem.getAttributeNode("id");
1219 if ( node && node.value === id ) {
1231 Expr.find["TAG"] = support.getElementsByTagName ?
1232 function( tag, context ) {
1233 if ( typeof context.getElementsByTagName !== "undefined" ) {
1234 return context.getElementsByTagName( tag );
1236 // DocumentFragment nodes don't have gEBTN
1237 } else if ( support.qsa ) {
1238 return context.querySelectorAll( tag );
1242 function( tag, context ) {
1246 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1247 results = context.getElementsByTagName( tag );
1249 // Filter out possible comments
1250 if ( tag === "*" ) {
1251 while ( (elem = results[i++]) ) {
1252 if ( elem.nodeType === 1 ) {
1263 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1264 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1265 return context.getElementsByClassName( className );
1269 /* QSA/matchesSelector
1270 ---------------------------------------------------------------------- */
1272 // QSA and matchesSelector support
1274 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1277 // qSa(:focus) reports false when true (Chrome 21)
1278 // We allow this because of a bug in IE8/9 that throws an error
1279 // whenever `document.activeElement` is accessed on an iframe
1280 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1281 // See https://bugs.jquery.com/ticket/13378
1284 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
1286 // Regex strategy adopted from Diego Perini
1287 assert(function( el ) {
1288 // Select is set to empty string on purpose
1289 // This is to test IE's treatment of not explicitly
1290 // setting a boolean content attribute,
1291 // since its presence should be enough
1292 // https://bugs.jquery.com/ticket/12359
1293 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
1294 "<select id='" + expando + "-\r\\' msallowcapture=''>" +
1295 "<option selected=''></option></select>";
1297 // Support: IE8, Opera 11-12.16
1298 // Nothing should be selected when empty strings follow ^= or $= or *=
1299 // The test attribute must be unknown in Opera but "safe" for WinRT
1300 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1301 if ( el.querySelectorAll("[msallowcapture^='']").length ) {
1302 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1306 // Boolean attributes and "value" are not treated correctly
1307 if ( !el.querySelectorAll("[selected]").length ) {
1308 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1311 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1312 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1313 rbuggyQSA.push("~=");
1316 // Webkit/Opera - :checked should return selected option elements
1317 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1318 // IE8 throws error here and will not see later tests
1319 if ( !el.querySelectorAll(":checked").length ) {
1320 rbuggyQSA.push(":checked");
1323 // Support: Safari 8+, iOS 8+
1324 // https://bugs.webkit.org/show_bug.cgi?id=136851
1325 // In-page `selector#id sibling-combinator selector` fails
1326 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
1327 rbuggyQSA.push(".#.+[+~]");
1331 assert(function( el ) {
1332 el.innerHTML = "<a href='' disabled='disabled'></a>" +
1333 "<select disabled='disabled'><option/></select>";
1335 // Support: Windows 8 Native Apps
1336 // The type and name attributes are restricted during .innerHTML assignment
1337 var input = document.createElement("input");
1338 input.setAttribute( "type", "hidden" );
1339 el.appendChild( input ).setAttribute( "name", "D" );
1342 // Enforce case-sensitivity of name attribute
1343 if ( el.querySelectorAll("[name=d]").length ) {
1344 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1347 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1348 // IE8 throws error here and will not see later tests
1349 if ( el.querySelectorAll(":enabled").length !== 2 ) {
1350 rbuggyQSA.push( ":enabled", ":disabled" );
1354 // IE's :disabled selector does not pick up the children of disabled fieldsets
1355 docElem.appendChild( el ).disabled = true;
1356 if ( el.querySelectorAll(":disabled").length !== 2 ) {
1357 rbuggyQSA.push( ":enabled", ":disabled" );
1360 // Opera 10-11 does not throw on post-comma invalid pseudos
1361 el.querySelectorAll("*,:x");
1362 rbuggyQSA.push(",.*:");
1366 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1367 docElem.webkitMatchesSelector ||
1368 docElem.mozMatchesSelector ||
1369 docElem.oMatchesSelector ||
1370 docElem.msMatchesSelector) )) ) {
1372 assert(function( el ) {
1373 // Check to see if it's possible to do matchesSelector
1374 // on a disconnected node (IE 9)
1375 support.disconnectedMatch = matches.call( el, "*" );
1377 // This should fail with an exception
1378 // Gecko does not error, returns false instead
1379 matches.call( el, "[s!='']:x" );
1380 rbuggyMatches.push( "!=", pseudos );
1384 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1385 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1388 ---------------------------------------------------------------------- */
1389 hasCompare = rnative.test( docElem.compareDocumentPosition );
1391 // Element contains another
1392 // Purposefully self-exclusive
1393 // As in, an element does not contain itself
1394 contains = hasCompare || rnative.test( docElem.contains ) ?
1396 var adown = a.nodeType === 9 ? a.documentElement : a,
1397 bup = b && b.parentNode;
1398 return a === bup || !!( bup && bup.nodeType === 1 && (
1400 adown.contains( bup ) :
1401 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1406 while ( (b = b.parentNode) ) {
1416 ---------------------------------------------------------------------- */
1418 // Document order sorting
1419 sortOrder = hasCompare ?
1422 // Flag for duplicate removal
1424 hasDuplicate = true;
1428 // Sort on method existence if only one input has compareDocumentPosition
1429 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1434 // Calculate position if both inputs belong to the same document
1435 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1436 a.compareDocumentPosition( b ) :
1438 // Otherwise we know they are disconnected
1441 // Disconnected nodes
1443 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1445 // Choose the first element that is related to our preferred document
1446 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1449 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1453 // Maintain original order
1455 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1459 return compare & 4 ? -1 : 1;
1462 // Exit early if the nodes are identical
1464 hasDuplicate = true;
1475 // Parentless nodes are either documents or disconnected
1476 if ( !aup || !bup ) {
1477 return a === document ? -1 :
1478 b === document ? 1 :
1482 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1485 // If the nodes are siblings, we can do a quick check
1486 } else if ( aup === bup ) {
1487 return siblingCheck( a, b );
1490 // Otherwise we need full lists of their ancestors for comparison
1492 while ( (cur = cur.parentNode) ) {
1496 while ( (cur = cur.parentNode) ) {
1500 // Walk down the tree looking for a discrepancy
1501 while ( ap[i] === bp[i] ) {
1506 // Do a sibling check if the nodes have a common ancestor
1507 siblingCheck( ap[i], bp[i] ) :
1509 // Otherwise nodes in our document sort first
1510 ap[i] === preferredDoc ? -1 :
1511 bp[i] === preferredDoc ? 1 :
1518 Sizzle.matches = function( expr, elements ) {
1519 return Sizzle( expr, null, null, elements );
1522 Sizzle.matchesSelector = function( elem, expr ) {
1523 // Set document vars if needed
1524 if ( ( elem.ownerDocument || elem ) !== document ) {
1525 setDocument( elem );
1528 // Make sure that attribute selectors are quoted
1529 expr = expr.replace( rattributeQuotes, "='$1']" );
1531 if ( support.matchesSelector && documentIsHTML &&
1532 !compilerCache[ expr + " " ] &&
1533 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1534 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1537 var ret = matches.call( elem, expr );
1539 // IE 9's matchesSelector returns false on disconnected nodes
1540 if ( ret || support.disconnectedMatch ||
1541 // As well, disconnected nodes are said to be in a document
1543 elem.document && elem.document.nodeType !== 11 ) {
1549 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1552 Sizzle.contains = function( context, elem ) {
1553 // Set document vars if needed
1554 if ( ( context.ownerDocument || context ) !== document ) {
1555 setDocument( context );
1557 return contains( context, elem );
1560 Sizzle.attr = function( elem, name ) {
1561 // Set document vars if needed
1562 if ( ( elem.ownerDocument || elem ) !== document ) {
1563 setDocument( elem );
1566 var fn = Expr.attrHandle[ name.toLowerCase() ],
1567 // Don't get fooled by Object.prototype properties (jQuery #13807)
1568 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1569 fn( elem, name, !documentIsHTML ) :
1572 return val !== undefined ?
1574 support.attributes || !documentIsHTML ?
1575 elem.getAttribute( name ) :
1576 (val = elem.getAttributeNode(name)) && val.specified ?
1581 Sizzle.escape = function( sel ) {
1582 return (sel + "").replace( rcssescape, fcssescape );
1585 Sizzle.error = function( msg ) {
1586 throw new Error( "Syntax error, unrecognized expression: " + msg );
1590 * Document sorting and removing duplicates
1591 * @param {ArrayLike} results
1593 Sizzle.uniqueSort = function( results ) {
1599 // Unless we *know* we can detect duplicates, assume their presence
1600 hasDuplicate = !support.detectDuplicates;
1601 sortInput = !support.sortStable && results.slice( 0 );
1602 results.sort( sortOrder );
1604 if ( hasDuplicate ) {
1605 while ( (elem = results[i++]) ) {
1606 if ( elem === results[ i ] ) {
1607 j = duplicates.push( i );
1611 results.splice( duplicates[ j ], 1 );
1615 // Clear input after sorting to release objects
1616 // See https://github.com/jquery/sizzle/pull/225
1623 * Utility function for retrieving the text value of an array of DOM nodes
1624 * @param {Array|Element} elem
1626 getText = Sizzle.getText = function( elem ) {
1630 nodeType = elem.nodeType;
1633 // If no nodeType, this is expected to be an array
1634 while ( (node = elem[i++]) ) {
1635 // Do not traverse comment nodes
1636 ret += getText( node );
1638 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1639 // Use textContent for elements
1640 // innerText usage removed for consistency of new lines (jQuery #11153)
1641 if ( typeof elem.textContent === "string" ) {
1642 return elem.textContent;
1644 // Traverse its children
1645 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1646 ret += getText( elem );
1649 } else if ( nodeType === 3 || nodeType === 4 ) {
1650 return elem.nodeValue;
1652 // Do not include comment or processing instruction nodes
1657 Expr = Sizzle.selectors = {
1659 // Can be adjusted by the user
1662 createPseudo: markFunction,
1671 ">": { dir: "parentNode", first: true },
1672 " ": { dir: "parentNode" },
1673 "+": { dir: "previousSibling", first: true },
1674 "~": { dir: "previousSibling" }
1678 "ATTR": function( match ) {
1679 match[1] = match[1].replace( runescape, funescape );
1681 // Move the given value to match[3] whether quoted or unquoted
1682 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1684 if ( match[2] === "~=" ) {
1685 match[3] = " " + match[3] + " ";
1688 return match.slice( 0, 4 );
1691 "CHILD": function( match ) {
1692 /* matches from matchExpr["CHILD"]
1693 1 type (only|nth|...)
1694 2 what (child|of-type)
1695 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1696 4 xn-component of xn+y argument ([+-]?\d*n|)
1697 5 sign of xn-component
1699 7 sign of y-component
1702 match[1] = match[1].toLowerCase();
1704 if ( match[1].slice( 0, 3 ) === "nth" ) {
1705 // nth-* requires argument
1707 Sizzle.error( match[0] );
1710 // numeric x and y parameters for Expr.filter.CHILD
1711 // remember that false/true cast respectively to 0/1
1712 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1713 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1715 // other types prohibit arguments
1716 } else if ( match[3] ) {
1717 Sizzle.error( match[0] );
1723 "PSEUDO": function( match ) {
1725 unquoted = !match[6] && match[2];
1727 if ( matchExpr["CHILD"].test( match[0] ) ) {
1731 // Accept quoted arguments as-is
1733 match[2] = match[4] || match[5] || "";
1735 // Strip excess characters from unquoted arguments
1736 } else if ( unquoted && rpseudo.test( unquoted ) &&
1737 // Get excess from tokenize (recursively)
1738 (excess = tokenize( unquoted, true )) &&
1739 // advance to the next closing parenthesis
1740 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1742 // excess is a negative index
1743 match[0] = match[0].slice( 0, excess );
1744 match[2] = unquoted.slice( 0, excess );
1747 // Return only captures needed by the pseudo filter method (type and argument)
1748 return match.slice( 0, 3 );
1754 "TAG": function( nodeNameSelector ) {
1755 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1756 return nodeNameSelector === "*" ?
1757 function() { return true; } :
1759 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1763 "CLASS": function( className ) {
1764 var pattern = classCache[ className + " " ];
1767 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1768 classCache( className, function( elem ) {
1769 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1773 "ATTR": function( name, operator, check ) {
1774 return function( elem ) {
1775 var result = Sizzle.attr( elem, name );
1777 if ( result == null ) {
1778 return operator === "!=";
1786 return operator === "=" ? result === check :
1787 operator === "!=" ? result !== check :
1788 operator === "^=" ? check && result.indexOf( check ) === 0 :
1789 operator === "*=" ? check && result.indexOf( check ) > -1 :
1790 operator === "$=" ? check && result.slice( -check.length ) === check :
1791 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1792 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1797 "CHILD": function( type, what, argument, first, last ) {
1798 var simple = type.slice( 0, 3 ) !== "nth",
1799 forward = type.slice( -4 ) !== "last",
1800 ofType = what === "of-type";
1802 return first === 1 && last === 0 ?
1804 // Shortcut for :nth-*(n)
1806 return !!elem.parentNode;
1809 function( elem, context, xml ) {
1810 var cache, uniqueCache, outerCache, node, nodeIndex, start,
1811 dir = simple !== forward ? "nextSibling" : "previousSibling",
1812 parent = elem.parentNode,
1813 name = ofType && elem.nodeName.toLowerCase(),
1814 useCache = !xml && !ofType,
1819 // :(first|last|only)-(child|of-type)
1823 while ( (node = node[ dir ]) ) {
1825 node.nodeName.toLowerCase() === name :
1826 node.nodeType === 1 ) {
1831 // Reverse direction for :only-* (if we haven't yet done so)
1832 start = dir = type === "only" && !start && "nextSibling";
1837 start = [ forward ? parent.firstChild : parent.lastChild ];
1839 // non-xml :nth-child(...) stores cache data on `parent`
1840 if ( forward && useCache ) {
1842 // Seek `elem` from a previously-cached index
1844 // ...in a gzip-friendly way
1846 outerCache = node[ expando ] || (node[ expando ] = {});
1848 // Support: IE <9 only
1849 // Defend against cloned attroperties (jQuery gh-1709)
1850 uniqueCache = outerCache[ node.uniqueID ] ||
1851 (outerCache[ node.uniqueID ] = {});
1853 cache = uniqueCache[ type ] || [];
1854 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1855 diff = nodeIndex && cache[ 2 ];
1856 node = nodeIndex && parent.childNodes[ nodeIndex ];
1858 while ( (node = ++nodeIndex && node && node[ dir ] ||
1860 // Fallback to seeking `elem` from the start
1861 (diff = nodeIndex = 0) || start.pop()) ) {
1863 // When found, cache indexes on `parent` and break
1864 if ( node.nodeType === 1 && ++diff && node === elem ) {
1865 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1871 // Use previously-cached element index if available
1873 // ...in a gzip-friendly way
1875 outerCache = node[ expando ] || (node[ expando ] = {});
1877 // Support: IE <9 only
1878 // Defend against cloned attroperties (jQuery gh-1709)
1879 uniqueCache = outerCache[ node.uniqueID ] ||
1880 (outerCache[ node.uniqueID ] = {});
1882 cache = uniqueCache[ type ] || [];
1883 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1887 // xml :nth-child(...)
1888 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1889 if ( diff === false ) {
1890 // Use the same loop as above to seek `elem` from the start
1891 while ( (node = ++nodeIndex && node && node[ dir ] ||
1892 (diff = nodeIndex = 0) || start.pop()) ) {
1895 node.nodeName.toLowerCase() === name :
1896 node.nodeType === 1 ) &&
1899 // Cache the index of each encountered element
1901 outerCache = node[ expando ] || (node[ expando ] = {});
1903 // Support: IE <9 only
1904 // Defend against cloned attroperties (jQuery gh-1709)
1905 uniqueCache = outerCache[ node.uniqueID ] ||
1906 (outerCache[ node.uniqueID ] = {});
1908 uniqueCache[ type ] = [ dirruns, diff ];
1911 if ( node === elem ) {
1919 // Incorporate the offset, then check against cycle size
1921 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1926 "PSEUDO": function( pseudo, argument ) {
1927 // pseudo-class names are case-insensitive
1928 // http://www.w3.org/TR/selectors/#pseudo-classes
1929 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1930 // Remember that setFilters inherits from pseudos
1932 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1933 Sizzle.error( "unsupported pseudo: " + pseudo );
1935 // The user may use createPseudo to indicate that
1936 // arguments are needed to create the filter function
1937 // just as Sizzle does
1938 if ( fn[ expando ] ) {
1939 return fn( argument );
1942 // But maintain support for old signatures
1943 if ( fn.length > 1 ) {
1944 args = [ pseudo, pseudo, "", argument ];
1945 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1946 markFunction(function( seed, matches ) {
1948 matched = fn( seed, argument ),
1951 idx = indexOf( seed, matched[i] );
1952 seed[ idx ] = !( matches[ idx ] = matched[i] );
1956 return fn( elem, 0, args );
1965 // Potentially complex pseudos
1966 "not": markFunction(function( selector ) {
1967 // Trim the selector passed to compile
1968 // to avoid treating leading and trailing
1969 // spaces as combinators
1972 matcher = compile( selector.replace( rtrim, "$1" ) );
1974 return matcher[ expando ] ?
1975 markFunction(function( seed, matches, context, xml ) {
1977 unmatched = matcher( seed, null, xml, [] ),
1980 // Match elements unmatched by `matcher`
1982 if ( (elem = unmatched[i]) ) {
1983 seed[i] = !(matches[i] = elem);
1987 function( elem, context, xml ) {
1989 matcher( input, null, xml, results );
1990 // Don't keep the element (issue #299)
1992 return !results.pop();
1996 "has": markFunction(function( selector ) {
1997 return function( elem ) {
1998 return Sizzle( selector, elem ).length > 0;
2002 "contains": markFunction(function( text ) {
2003 text = text.replace( runescape, funescape );
2004 return function( elem ) {
2005 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
2009 // "Whether an element is represented by a :lang() selector
2010 // is based solely on the element's language value
2011 // being equal to the identifier C,
2012 // or beginning with the identifier C immediately followed by "-".
2013 // The matching of C against the element's language value is performed case-insensitively.
2014 // The identifier C does not have to be a valid language name."
2015 // http://www.w3.org/TR/selectors/#lang-pseudo
2016 "lang": markFunction( function( lang ) {
2017 // lang value must be a valid identifier
2018 if ( !ridentifier.test(lang || "") ) {
2019 Sizzle.error( "unsupported lang: " + lang );
2021 lang = lang.replace( runescape, funescape ).toLowerCase();
2022 return function( elem ) {
2025 if ( (elemLang = documentIsHTML ?
2027 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
2029 elemLang = elemLang.toLowerCase();
2030 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
2032 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
2038 "target": function( elem ) {
2039 var hash = window.location && window.location.hash;
2040 return hash && hash.slice( 1 ) === elem.id;
2043 "root": function( elem ) {
2044 return elem === docElem;
2047 "focus": function( elem ) {
2048 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
2051 // Boolean properties
2052 "enabled": createDisabledPseudo( false ),
2053 "disabled": createDisabledPseudo( true ),
2055 "checked": function( elem ) {
2056 // In CSS3, :checked should return both checked and selected elements
2057 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2058 var nodeName = elem.nodeName.toLowerCase();
2059 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
2062 "selected": function( elem ) {
2063 // Accessing this property makes selected-by-default
2064 // options in Safari work properly
2065 if ( elem.parentNode ) {
2066 elem.parentNode.selectedIndex;
2069 return elem.selected === true;
2073 "empty": function( elem ) {
2074 // http://www.w3.org/TR/selectors/#empty-pseudo
2075 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2076 // but not by others (comment: 8; processing instruction: 7; etc.)
2077 // nodeType < 6 works because attributes (2) do not appear as children
2078 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
2079 if ( elem.nodeType < 6 ) {
2086 "parent": function( elem ) {
2087 return !Expr.pseudos["empty"]( elem );
2090 // Element/input types
2091 "header": function( elem ) {
2092 return rheader.test( elem.nodeName );
2095 "input": function( elem ) {
2096 return rinputs.test( elem.nodeName );
2099 "button": function( elem ) {
2100 var name = elem.nodeName.toLowerCase();
2101 return name === "input" && elem.type === "button" || name === "button";
2104 "text": function( elem ) {
2106 return elem.nodeName.toLowerCase() === "input" &&
2107 elem.type === "text" &&
2110 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2111 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
2114 // Position-in-collection
2115 "first": createPositionalPseudo(function() {
2119 "last": createPositionalPseudo(function( matchIndexes, length ) {
2120 return [ length - 1 ];
2123 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
2124 return [ argument < 0 ? argument + length : argument ];
2127 "even": createPositionalPseudo(function( matchIndexes, length ) {
2129 for ( ; i < length; i += 2 ) {
2130 matchIndexes.push( i );
2132 return matchIndexes;
2135 "odd": createPositionalPseudo(function( matchIndexes, length ) {
2137 for ( ; i < length; i += 2 ) {
2138 matchIndexes.push( i );
2140 return matchIndexes;
2143 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2144 var i = argument < 0 ? argument + length : argument;
2145 for ( ; --i >= 0; ) {
2146 matchIndexes.push( i );
2148 return matchIndexes;
2151 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2152 var i = argument < 0 ? argument + length : argument;
2153 for ( ; ++i < length; ) {
2154 matchIndexes.push( i );
2156 return matchIndexes;
2161 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2163 // Add button/input type pseudos
2164 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2165 Expr.pseudos[ i ] = createInputPseudo( i );
2167 for ( i in { submit: true, reset: true } ) {
2168 Expr.pseudos[ i ] = createButtonPseudo( i );
2171 // Easy API for creating new setFilters
2172 function setFilters() {}
2173 setFilters.prototype = Expr.filters = Expr.pseudos;
2174 Expr.setFilters = new setFilters();
2176 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2177 var matched, match, tokens, type,
2178 soFar, groups, preFilters,
2179 cached = tokenCache[ selector + " " ];
2182 return parseOnly ? 0 : cached.slice( 0 );
2187 preFilters = Expr.preFilter;
2191 // Comma and first run
2192 if ( !matched || (match = rcomma.exec( soFar )) ) {
2194 // Don't consume trailing commas as valid
2195 soFar = soFar.slice( match[0].length ) || soFar;
2197 groups.push( (tokens = []) );
2203 if ( (match = rcombinators.exec( soFar )) ) {
2204 matched = match.shift();
2207 // Cast descendant combinators to space
2208 type: match[0].replace( rtrim, " " )
2210 soFar = soFar.slice( matched.length );
2214 for ( type in Expr.filter ) {
2215 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2216 (match = preFilters[ type ]( match ))) ) {
2217 matched = match.shift();
2223 soFar = soFar.slice( matched.length );
2232 // Return the length of the invalid excess
2233 // if we're just parsing
2234 // Otherwise, throw an error or return tokens
2238 Sizzle.error( selector ) :
2240 tokenCache( selector, groups ).slice( 0 );
2243 function toSelector( tokens ) {
2245 len = tokens.length,
2247 for ( ; i < len; i++ ) {
2248 selector += tokens[i].value;
2253 function addCombinator( matcher, combinator, base ) {
2254 var dir = combinator.dir,
2255 skip = combinator.next,
2257 checkNonElements = base && key === "parentNode",
2260 return combinator.first ?
2261 // Check against closest ancestor/preceding element
2262 function( elem, context, xml ) {
2263 while ( (elem = elem[ dir ]) ) {
2264 if ( elem.nodeType === 1 || checkNonElements ) {
2265 return matcher( elem, context, xml );
2271 // Check against all ancestor/preceding elements
2272 function( elem, context, xml ) {
2273 var oldCache, uniqueCache, outerCache,
2274 newCache = [ dirruns, doneName ];
2276 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2278 while ( (elem = elem[ dir ]) ) {
2279 if ( elem.nodeType === 1 || checkNonElements ) {
2280 if ( matcher( elem, context, xml ) ) {
2286 while ( (elem = elem[ dir ]) ) {
2287 if ( elem.nodeType === 1 || checkNonElements ) {
2288 outerCache = elem[ expando ] || (elem[ expando ] = {});
2290 // Support: IE <9 only
2291 // Defend against cloned attroperties (jQuery gh-1709)
2292 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2294 if ( skip && skip === elem.nodeName.toLowerCase() ) {
2295 elem = elem[ dir ] || elem;
2296 } else if ( (oldCache = uniqueCache[ key ]) &&
2297 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2299 // Assign to newCache so results back-propagate to previous elements
2300 return (newCache[ 2 ] = oldCache[ 2 ]);
2302 // Reuse newcache so results back-propagate to previous elements
2303 uniqueCache[ key ] = newCache;
2305 // A match means we're done; a fail means we have to keep checking
2306 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2317 function elementMatcher( matchers ) {
2318 return matchers.length > 1 ?
2319 function( elem, context, xml ) {
2320 var i = matchers.length;
2322 if ( !matchers[i]( elem, context, xml ) ) {
2331 function multipleContexts( selector, contexts, results ) {
2333 len = contexts.length;
2334 for ( ; i < len; i++ ) {
2335 Sizzle( selector, contexts[i], results );
2340 function condense( unmatched, map, filter, context, xml ) {
2344 len = unmatched.length,
2345 mapped = map != null;
2347 for ( ; i < len; i++ ) {
2348 if ( (elem = unmatched[i]) ) {
2349 if ( !filter || filter( elem, context, xml ) ) {
2350 newUnmatched.push( elem );
2358 return newUnmatched;
2361 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2362 if ( postFilter && !postFilter[ expando ] ) {
2363 postFilter = setMatcher( postFilter );
2365 if ( postFinder && !postFinder[ expando ] ) {
2366 postFinder = setMatcher( postFinder, postSelector );
2368 return markFunction(function( seed, results, context, xml ) {
2372 preexisting = results.length,
2374 // Get initial elements from seed or context
2375 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2377 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2378 matcherIn = preFilter && ( seed || !selector ) ?
2379 condense( elems, preMap, preFilter, context, xml ) :
2382 matcherOut = matcher ?
2383 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2384 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2386 // ...intermediate processing is necessary
2389 // ...otherwise use results directly
2393 // Find primary matches
2395 matcher( matcherIn, matcherOut, context, xml );
2400 temp = condense( matcherOut, postMap );
2401 postFilter( temp, [], context, xml );
2403 // Un-match failing elements by moving them back to matcherIn
2406 if ( (elem = temp[i]) ) {
2407 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2413 if ( postFinder || preFilter ) {
2415 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2417 i = matcherOut.length;
2419 if ( (elem = matcherOut[i]) ) {
2420 // Restore matcherIn since elem is not yet a final match
2421 temp.push( (matcherIn[i] = elem) );
2424 postFinder( null, (matcherOut = []), temp, xml );
2427 // Move matched elements from seed to results to keep them synchronized
2428 i = matcherOut.length;
2430 if ( (elem = matcherOut[i]) &&
2431 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2433 seed[temp] = !(results[temp] = elem);
2438 // Add elements to results, through postFinder if defined
2440 matcherOut = condense(
2441 matcherOut === results ?
2442 matcherOut.splice( preexisting, matcherOut.length ) :
2446 postFinder( null, results, matcherOut, xml );
2448 push.apply( results, matcherOut );
2454 function matcherFromTokens( tokens ) {
2455 var checkContext, matcher, j,
2456 len = tokens.length,
2457 leadingRelative = Expr.relative[ tokens[0].type ],
2458 implicitRelative = leadingRelative || Expr.relative[" "],
2459 i = leadingRelative ? 1 : 0,
2461 // The foundational matcher ensures that elements are reachable from top-level context(s)
2462 matchContext = addCombinator( function( elem ) {
2463 return elem === checkContext;
2464 }, implicitRelative, true ),
2465 matchAnyContext = addCombinator( function( elem ) {
2466 return indexOf( checkContext, elem ) > -1;
2467 }, implicitRelative, true ),
2468 matchers = [ function( elem, context, xml ) {
2469 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2470 (checkContext = context).nodeType ?
2471 matchContext( elem, context, xml ) :
2472 matchAnyContext( elem, context, xml ) );
2473 // Avoid hanging onto element (issue #299)
2474 checkContext = null;
2478 for ( ; i < len; i++ ) {
2479 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2480 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2482 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2484 // Return special upon seeing a positional matcher
2485 if ( matcher[ expando ] ) {
2486 // Find the next relative operator (if any) for proper handling
2488 for ( ; j < len; j++ ) {
2489 if ( Expr.relative[ tokens[j].type ] ) {
2494 i > 1 && elementMatcher( matchers ),
2495 i > 1 && toSelector(
2496 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2497 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2498 ).replace( rtrim, "$1" ),
2500 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2501 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2502 j < len && toSelector( tokens )
2505 matchers.push( matcher );
2509 return elementMatcher( matchers );
2512 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2513 var bySet = setMatchers.length > 0,
2514 byElement = elementMatchers.length > 0,
2515 superMatcher = function( seed, context, xml, results, outermost ) {
2516 var elem, j, matcher,
2519 unmatched = seed && [],
2521 contextBackup = outermostContext,
2522 // We must always have either seed elements or outermost context
2523 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2524 // Use integer dirruns iff this is the outermost matcher
2525 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2529 outermostContext = context === document || context || outermost;
2532 // Add elements passing elementMatchers directly to results
2533 // Support: IE<9, Safari
2534 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2535 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2536 if ( byElement && elem ) {
2538 if ( !context && elem.ownerDocument !== document ) {
2539 setDocument( elem );
2540 xml = !documentIsHTML;
2542 while ( (matcher = elementMatchers[j++]) ) {
2543 if ( matcher( elem, context || document, xml) ) {
2544 results.push( elem );
2549 dirruns = dirrunsUnique;
2553 // Track unmatched elements for set filters
2555 // They will have gone through all possible matchers
2556 if ( (elem = !matcher && elem) ) {
2560 // Lengthen the array for every element, matched or not
2562 unmatched.push( elem );
2567 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2568 // makes the latter nonnegative.
2571 // Apply set filters to unmatched elements
2572 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2573 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2574 // no element matchers and no seed.
2575 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2576 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2577 // numerically zero.
2578 if ( bySet && i !== matchedCount ) {
2580 while ( (matcher = setMatchers[j++]) ) {
2581 matcher( unmatched, setMatched, context, xml );
2585 // Reintegrate element matches to eliminate the need for sorting
2586 if ( matchedCount > 0 ) {
2588 if ( !(unmatched[i] || setMatched[i]) ) {
2589 setMatched[i] = pop.call( results );
2594 // Discard index placeholder values to get only actual matches
2595 setMatched = condense( setMatched );
2598 // Add matches to results
2599 push.apply( results, setMatched );
2601 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2602 if ( outermost && !seed && setMatched.length > 0 &&
2603 ( matchedCount + setMatchers.length ) > 1 ) {
2605 Sizzle.uniqueSort( results );
2609 // Override manipulation of globals by nested matchers
2611 dirruns = dirrunsUnique;
2612 outermostContext = contextBackup;
2619 markFunction( superMatcher ) :
2623 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2626 elementMatchers = [],
2627 cached = compilerCache[ selector + " " ];
2630 // Generate a function of recursive functions that can be used to check each element
2632 match = tokenize( selector );
2636 cached = matcherFromTokens( match[i] );
2637 if ( cached[ expando ] ) {
2638 setMatchers.push( cached );
2640 elementMatchers.push( cached );
2644 // Cache the compiled function
2645 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2647 // Save selector and tokenization
2648 cached.selector = selector;
2654 * A low-level selection function that works with Sizzle's compiled
2655 * selector functions
2656 * @param {String|Function} selector A selector or a pre-compiled
2657 * selector function built with Sizzle.compile
2658 * @param {Element} context
2659 * @param {Array} [results]
2660 * @param {Array} [seed] A set of elements to match against
2662 select = Sizzle.select = function( selector, context, results, seed ) {
2663 var i, tokens, token, type, find,
2664 compiled = typeof selector === "function" && selector,
2665 match = !seed && tokenize( (selector = compiled.selector || selector) );
2667 results = results || [];
2669 // Try to minimize operations if there is only one selector in the list and no seed
2670 // (the latter of which guarantees us context)
2671 if ( match.length === 1 ) {
2673 // Reduce context if the leading compound selector is an ID
2674 tokens = match[0] = match[0].slice( 0 );
2675 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2676 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
2678 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2682 // Precompiled matchers will still verify ancestry, so step up a level
2683 } else if ( compiled ) {
2684 context = context.parentNode;
2687 selector = selector.slice( tokens.shift().value.length );
2690 // Fetch a seed set for right-to-left matching
2691 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2695 // Abort if we hit a combinator
2696 if ( Expr.relative[ (type = token.type) ] ) {
2699 if ( (find = Expr.find[ type ]) ) {
2700 // Search, expanding context for leading sibling combinators
2702 token.matches[0].replace( runescape, funescape ),
2703 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2706 // If seed is empty or no tokens remain, we can return early
2707 tokens.splice( i, 1 );
2708 selector = seed.length && toSelector( tokens );
2710 push.apply( results, seed );
2720 // Compile and execute a filtering function if one is not provided
2721 // Provide `match` to avoid retokenization if we modified the selector above
2722 ( compiled || compile( selector, match ) )(
2727 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2732 // One-time assignments
2735 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2737 // Support: Chrome 14-35+
2738 // Always assume duplicates if they aren't passed to the comparison function
2739 support.detectDuplicates = !!hasDuplicate;
2741 // Initialize against the default document
2744 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2745 // Detached nodes confoundingly follow *each other*
2746 support.sortDetached = assert(function( el ) {
2747 // Should return 1, but returns 4 (following)
2748 return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
2752 // Prevent attribute/property "interpolation"
2753 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2754 if ( !assert(function( el ) {
2755 el.innerHTML = "<a href='#'></a>";
2756 return el.firstChild.getAttribute("href") === "#" ;
2758 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2760 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2766 // Use defaultValue in place of getAttribute("value")
2767 if ( !support.attributes || !assert(function( el ) {
2768 el.innerHTML = "<input/>";
2769 el.firstChild.setAttribute( "value", "" );
2770 return el.firstChild.getAttribute( "value" ) === "";
2772 addHandle( "value", function( elem, name, isXML ) {
2773 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2774 return elem.defaultValue;
2780 // Use getAttributeNode to fetch booleans when getAttribute lies
2781 if ( !assert(function( el ) {
2782 return el.getAttribute("disabled") == null;
2784 addHandle( booleans, function( elem, name, isXML ) {
2787 return elem[ name ] === true ? name.toLowerCase() :
2788 (val = elem.getAttributeNode( name )) && val.specified ?
2801 jQuery.find = Sizzle;
2802 jQuery.expr = Sizzle.selectors;
2805 jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2806 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
2807 jQuery.text = Sizzle.getText;
2808 jQuery.isXMLDoc = Sizzle.isXML;
2809 jQuery.contains = Sizzle.contains;
2810 jQuery.escapeSelector = Sizzle.escape;
2815 var dir = function( elem, dir, until ) {
2817 truncate = until !== undefined;
2819 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2820 if ( elem.nodeType === 1 ) {
2821 if ( truncate && jQuery( elem ).is( until ) ) {
2824 matched.push( elem );
2831 var siblings = function( n, elem ) {
2834 for ( ; n; n = n.nextSibling ) {
2835 if ( n.nodeType === 1 && n !== elem ) {
2844 var rneedsContext = jQuery.expr.match.needsContext;
2846 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2850 var risSimple = /^.[^:#\[\.,]*$/;
2852 // Implement the identical functionality for filter and not
2853 function winnow( elements, qualifier, not ) {
2854 if ( jQuery.isFunction( qualifier ) ) {
2855 return jQuery.grep( elements, function( elem, i ) {
2856 return !!qualifier.call( elem, i, elem ) !== not;
2861 if ( qualifier.nodeType ) {
2862 return jQuery.grep( elements, function( elem ) {
2863 return ( elem === qualifier ) !== not;
2867 // Arraylike of elements (jQuery, arguments, Array)
2868 if ( typeof qualifier !== "string" ) {
2869 return jQuery.grep( elements, function( elem ) {
2870 return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
2874 // Simple selector that can be filtered directly, removing non-Elements
2875 if ( risSimple.test( qualifier ) ) {
2876 return jQuery.filter( qualifier, elements, not );
2879 // Complex selector, compare the two sets, removing non-Elements
2880 qualifier = jQuery.filter( qualifier, elements );
2881 return jQuery.grep( elements, function( elem ) {
2882 return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
2886 jQuery.filter = function( expr, elems, not ) {
2887 var elem = elems[ 0 ];
2890 expr = ":not(" + expr + ")";
2893 if ( elems.length === 1 && elem.nodeType === 1 ) {
2894 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
2897 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2898 return elem.nodeType === 1;
2903 find: function( selector ) {
2908 if ( typeof selector !== "string" ) {
2909 return this.pushStack( jQuery( selector ).filter( function() {
2910 for ( i = 0; i < len; i++ ) {
2911 if ( jQuery.contains( self[ i ], this ) ) {
2918 ret = this.pushStack( [] );
2920 for ( i = 0; i < len; i++ ) {
2921 jQuery.find( selector, self[ i ], ret );
2924 return len > 1 ? jQuery.uniqueSort( ret ) : ret;
2926 filter: function( selector ) {
2927 return this.pushStack( winnow( this, selector || [], false ) );
2929 not: function( selector ) {
2930 return this.pushStack( winnow( this, selector || [], true ) );
2932 is: function( selector ) {
2936 // If this is a positional/relative selector, check membership in the returned set
2937 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2938 typeof selector === "string" && rneedsContext.test( selector ) ?
2939 jQuery( selector ) :
2947 // Initialize a jQuery object
2950 // A central reference to the root jQuery(document)
2953 // A simple way to check for HTML strings
2954 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2955 // Strict HTML recognition (#11290: must start with <)
2956 // Shortcut simple #id case for speed
2957 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2959 init = jQuery.fn.init = function( selector, context, root ) {
2962 // HANDLE: $(""), $(null), $(undefined), $(false)
2967 // Method init() accepts an alternate rootjQuery
2968 // so migrate can support jQuery.sub (gh-2101)
2969 root = root || rootjQuery;
2971 // Handle HTML strings
2972 if ( typeof selector === "string" ) {
2973 if ( selector[ 0 ] === "<" &&
2974 selector[ selector.length - 1 ] === ">" &&
2975 selector.length >= 3 ) {
2977 // Assume that strings that start and end with <> are HTML and skip the regex check
2978 match = [ null, selector, null ];
2981 match = rquickExpr.exec( selector );
2984 // Match html or make sure no context is specified for #id
2985 if ( match && ( match[ 1 ] || !context ) ) {
2987 // HANDLE: $(html) -> $(array)
2989 context = context instanceof jQuery ? context[ 0 ] : context;
2991 // Option to run scripts is true for back-compat
2992 // Intentionally let the error be thrown if parseHTML is not present
2993 jQuery.merge( this, jQuery.parseHTML(
2995 context && context.nodeType ? context.ownerDocument || context : document,
2999 // HANDLE: $(html, props)
3000 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
3001 for ( match in context ) {
3003 // Properties of context are called as methods if possible
3004 if ( jQuery.isFunction( this[ match ] ) ) {
3005 this[ match ]( context[ match ] );
3007 // ...and otherwise set as attributes
3009 this.attr( match, context[ match ] );
3018 elem = document.getElementById( match[ 2 ] );
3022 // Inject the element directly into the jQuery object
3029 // HANDLE: $(expr, $(...))
3030 } else if ( !context || context.jquery ) {
3031 return ( context || root ).find( selector );
3033 // HANDLE: $(expr, context)
3034 // (which is just equivalent to: $(context).find(expr)
3036 return this.constructor( context ).find( selector );
3039 // HANDLE: $(DOMElement)
3040 } else if ( selector.nodeType ) {
3041 this[ 0 ] = selector;
3045 // HANDLE: $(function)
3046 // Shortcut for document ready
3047 } else if ( jQuery.isFunction( selector ) ) {
3048 return root.ready !== undefined ?
3049 root.ready( selector ) :
3051 // Execute immediately if ready is not present
3055 return jQuery.makeArray( selector, this );
3058 // Give the init function the jQuery prototype for later instantiation
3059 init.prototype = jQuery.fn;
3061 // Initialize central reference
3062 rootjQuery = jQuery( document );
3065 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
3067 // Methods guaranteed to produce a unique set when starting from a unique set
3068 guaranteedUnique = {
3076 has: function( target ) {
3077 var targets = jQuery( target, this ),
3080 return this.filter( function() {
3082 for ( ; i < l; i++ ) {
3083 if ( jQuery.contains( this, targets[ i ] ) ) {
3090 closest: function( selectors, context ) {
3095 targets = typeof selectors !== "string" && jQuery( selectors );
3097 // Positional selectors never match, since there's no _selection_ context
3098 if ( !rneedsContext.test( selectors ) ) {
3099 for ( ; i < l; i++ ) {
3100 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3102 // Always skip document fragments
3103 if ( cur.nodeType < 11 && ( targets ?
3104 targets.index( cur ) > -1 :
3106 // Don't pass non-elements to Sizzle
3107 cur.nodeType === 1 &&
3108 jQuery.find.matchesSelector( cur, selectors ) ) ) {
3110 matched.push( cur );
3117 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3120 // Determine the position of an element within the set
3121 index: function( elem ) {
3123 // No argument, return index in parent
3125 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3128 // Index in selector
3129 if ( typeof elem === "string" ) {
3130 return indexOf.call( jQuery( elem ), this[ 0 ] );
3133 // Locate the position of the desired element
3134 return indexOf.call( this,
3136 // If it receives a jQuery object, the first element is used
3137 elem.jquery ? elem[ 0 ] : elem
3141 add: function( selector, context ) {
3142 return this.pushStack(
3144 jQuery.merge( this.get(), jQuery( selector, context ) )
3149 addBack: function( selector ) {
3150 return this.add( selector == null ?
3151 this.prevObject : this.prevObject.filter( selector )
3156 function sibling( cur, dir ) {
3157 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
3162 parent: function( elem ) {
3163 var parent = elem.parentNode;
3164 return parent && parent.nodeType !== 11 ? parent : null;
3166 parents: function( elem ) {
3167 return dir( elem, "parentNode" );
3169 parentsUntil: function( elem, i, until ) {
3170 return dir( elem, "parentNode", until );
3172 next: function( elem ) {
3173 return sibling( elem, "nextSibling" );
3175 prev: function( elem ) {
3176 return sibling( elem, "previousSibling" );
3178 nextAll: function( elem ) {
3179 return dir( elem, "nextSibling" );
3181 prevAll: function( elem ) {
3182 return dir( elem, "previousSibling" );
3184 nextUntil: function( elem, i, until ) {
3185 return dir( elem, "nextSibling", until );
3187 prevUntil: function( elem, i, until ) {
3188 return dir( elem, "previousSibling", until );
3190 siblings: function( elem ) {
3191 return siblings( ( elem.parentNode || {} ).firstChild, elem );
3193 children: function( elem ) {
3194 return siblings( elem.firstChild );
3196 contents: function( elem ) {
3197 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
3199 }, function( name, fn ) {
3200 jQuery.fn[ name ] = function( until, selector ) {
3201 var matched = jQuery.map( this, fn, until );
3203 if ( name.slice( -5 ) !== "Until" ) {
3207 if ( selector && typeof selector === "string" ) {
3208 matched = jQuery.filter( selector, matched );
3211 if ( this.length > 1 ) {
3213 // Remove duplicates
3214 if ( !guaranteedUnique[ name ] ) {
3215 jQuery.uniqueSort( matched );
3218 // Reverse order for parents* and prev-derivatives
3219 if ( rparentsprev.test( name ) ) {
3224 return this.pushStack( matched );
3227 var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
3231 // Convert String-formatted options into Object-formatted ones
3232 function createOptions( options ) {
3234 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
3235 object[ flag ] = true;
3241 * Create a callback list using the following parameters:
3243 * options: an optional list of space-separated options that will change how
3244 * the callback list behaves or a more traditional option object
3246 * By default a callback list will act like an event callback list and can be
3247 * "fired" multiple times.
3251 * once: will ensure the callback list can only be fired once (like a Deferred)
3253 * memory: will keep track of previous values and will call any callback added
3254 * after the list has been fired right away with the latest "memorized"
3255 * values (like a Deferred)
3257 * unique: will ensure a callback can only be added once (no duplicate in the list)
3259 * stopOnFalse: interrupt callings when a callback returns false
3262 jQuery.Callbacks = function( options ) {
3264 // Convert options from String-formatted to Object-formatted if needed
3265 // (we check in cache first)
3266 options = typeof options === "string" ?
3267 createOptions( options ) :
3268 jQuery.extend( {}, options );
3270 var // Flag to know if list is currently firing
3273 // Last fire value for non-forgettable lists
3276 // Flag to know if list was already fired
3279 // Flag to prevent firing
3282 // Actual callback list
3285 // Queue of execution data for repeatable lists
3288 // Index of currently firing callback (modified by add/remove as needed)
3294 // Enforce single-firing
3295 locked = options.once;
3297 // Execute callbacks for all pending executions,
3298 // respecting firingIndex overrides and runtime changes
3299 fired = firing = true;
3300 for ( ; queue.length; firingIndex = -1 ) {
3301 memory = queue.shift();
3302 while ( ++firingIndex < list.length ) {
3304 // Run callback and check for early termination
3305 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3306 options.stopOnFalse ) {
3308 // Jump to end and forget the data so .add doesn't re-fire
3309 firingIndex = list.length;
3315 // Forget the data if we're done with it
3316 if ( !options.memory ) {
3322 // Clean up if we're done firing for good
3325 // Keep an empty list if we have data for future add calls
3329 // Otherwise, this object is spent
3336 // Actual Callbacks object
3339 // Add a callback or a collection of callbacks to the list
3343 // If we have memory from a past run, we should fire after adding
3344 if ( memory && !firing ) {
3345 firingIndex = list.length - 1;
3346 queue.push( memory );
3349 ( function add( args ) {
3350 jQuery.each( args, function( _, arg ) {
3351 if ( jQuery.isFunction( arg ) ) {
3352 if ( !options.unique || !self.has( arg ) ) {
3355 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
3357 // Inspect recursively
3363 if ( memory && !firing ) {
3370 // Remove a callback from the list
3371 remove: function() {
3372 jQuery.each( arguments, function( _, arg ) {
3374 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3375 list.splice( index, 1 );
3377 // Handle firing indexes
3378 if ( index <= firingIndex ) {
3386 // Check if a given callback is in the list.
3387 // If no argument is given, return whether or not list has callbacks attached.
3388 has: function( fn ) {
3390 jQuery.inArray( fn, list ) > -1 :
3394 // Remove all callbacks from the list
3402 // Disable .fire and .add
3403 // Abort any current/pending executions
3404 // Clear all callbacks and values
3405 disable: function() {
3406 locked = queue = [];
3410 disabled: function() {
3415 // Also disable .add unless we have memory (since it would have no effect)
3416 // Abort any pending executions
3418 locked = queue = [];
3419 if ( !memory && !firing ) {
3424 locked: function() {
3428 // Call all callbacks with the given context and arguments
3429 fireWith: function( context, args ) {
3432 args = [ context, args.slice ? args.slice() : args ];
3441 // Call all the callbacks with the given arguments
3443 self.fireWith( this, arguments );
3447 // To know if the callbacks have already been called at least once
3457 function Identity( v ) {
3460 function Thrower( ex ) {
3464 function adoptValue( value, resolve, reject ) {
3469 // Check for promise aspect first to privilege synchronous behavior
3470 if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
3471 method.call( value ).done( resolve ).fail( reject );
3474 } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
3475 method.call( value, resolve, reject );
3477 // Other non-thenables
3480 // Support: Android 4.0 only
3481 // Strict mode functions invoked without .call/.apply get global-object context
3482 resolve.call( undefined, value );
3485 // For Promises/A+, convert exceptions into rejections
3486 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3487 // Deferred#then to conditionally suppress rejection.
3490 // Support: Android 4.0 only
3491 // Strict mode functions invoked without .call/.apply get global-object context
3492 reject.call( undefined, value );
3498 Deferred: function( func ) {
3501 // action, add listener, callbacks,
3502 // ... .then handlers, argument index, [final state]
3503 [ "notify", "progress", jQuery.Callbacks( "memory" ),
3504 jQuery.Callbacks( "memory" ), 2 ],
3505 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
3506 jQuery.Callbacks( "once memory" ), 0, "resolved" ],
3507 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
3508 jQuery.Callbacks( "once memory" ), 1, "rejected" ]
3515 always: function() {
3516 deferred.done( arguments ).fail( arguments );
3519 "catch": function( fn ) {
3520 return promise.then( null, fn );
3523 // Keep pipe for back-compat
3524 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3525 var fns = arguments;
3527 return jQuery.Deferred( function( newDefer ) {
3528 jQuery.each( tuples, function( i, tuple ) {
3530 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3531 var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
3533 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3534 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3535 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3536 deferred[ tuple[ 1 ] ]( function() {
3537 var returned = fn && fn.apply( this, arguments );
3538 if ( returned && jQuery.isFunction( returned.promise ) ) {
3540 .progress( newDefer.notify )
3541 .done( newDefer.resolve )
3542 .fail( newDefer.reject );
3544 newDefer[ tuple[ 0 ] + "With" ](
3546 fn ? [ returned ] : arguments
3554 then: function( onFulfilled, onRejected, onProgress ) {
3556 function resolve( depth, deferred, handler, special ) {
3560 mightThrow = function() {
3563 // Support: Promises/A+ section 2.3.3.3.3
3564 // https://promisesaplus.com/#point-59
3565 // Ignore double-resolution attempts
3566 if ( depth < maxDepth ) {
3570 returned = handler.apply( that, args );
3572 // Support: Promises/A+ section 2.3.1
3573 // https://promisesaplus.com/#point-48
3574 if ( returned === deferred.promise() ) {
3575 throw new TypeError( "Thenable self-resolution" );
3578 // Support: Promises/A+ sections 2.3.3.1, 3.5
3579 // https://promisesaplus.com/#point-54
3580 // https://promisesaplus.com/#point-75
3581 // Retrieve `then` only once
3584 // Support: Promises/A+ section 2.3.4
3585 // https://promisesaplus.com/#point-64
3586 // Only check objects and functions for thenability
3587 ( typeof returned === "object" ||
3588 typeof returned === "function" ) &&
3591 // Handle a returned thenable
3592 if ( jQuery.isFunction( then ) ) {
3594 // Special processors (notify) just wait for resolution
3598 resolve( maxDepth, deferred, Identity, special ),
3599 resolve( maxDepth, deferred, Thrower, special )
3602 // Normal processors (resolve) also hook into progress
3605 // ...and disregard older resolution values
3610 resolve( maxDepth, deferred, Identity, special ),
3611 resolve( maxDepth, deferred, Thrower, special ),
3612 resolve( maxDepth, deferred, Identity,
3613 deferred.notifyWith )
3617 // Handle all other returned values
3620 // Only substitute handlers pass on context
3621 // and multiple values (non-spec behavior)
3622 if ( handler !== Identity ) {
3624 args = [ returned ];
3627 // Process the value(s)
3628 // Default process is resolve
3629 ( special || deferred.resolveWith )( that, args );
3633 // Only normal processors (resolve) catch and reject exceptions
3641 if ( jQuery.Deferred.exceptionHook ) {
3642 jQuery.Deferred.exceptionHook( e,
3643 process.stackTrace );
3646 // Support: Promises/A+ section 2.3.3.3.4.1
3647 // https://promisesaplus.com/#point-61
3648 // Ignore post-resolution exceptions
3649 if ( depth + 1 >= maxDepth ) {
3651 // Only substitute handlers pass on context
3652 // and multiple values (non-spec behavior)
3653 if ( handler !== Thrower ) {
3658 deferred.rejectWith( that, args );
3663 // Support: Promises/A+ section 2.3.3.3.1
3664 // https://promisesaplus.com/#point-57
3665 // Re-resolve promises immediately to dodge false rejection from
3666 // subsequent errors
3671 // Call an optional hook to record the stack, in case of exception
3672 // since it's otherwise lost when execution goes async
3673 if ( jQuery.Deferred.getStackHook ) {
3674 process.stackTrace = jQuery.Deferred.getStackHook();
3676 window.setTimeout( process );
3681 return jQuery.Deferred( function( newDefer ) {
3683 // progress_handlers.add( ... )
3684 tuples[ 0 ][ 3 ].add(
3688 jQuery.isFunction( onProgress ) ?
3695 // fulfilled_handlers.add( ... )
3696 tuples[ 1 ][ 3 ].add(
3700 jQuery.isFunction( onFulfilled ) ?
3706 // rejected_handlers.add( ... )
3707 tuples[ 2 ][ 3 ].add(
3711 jQuery.isFunction( onRejected ) ?
3719 // Get a promise for this deferred
3720 // If obj is provided, the promise aspect is added to the object
3721 promise: function( obj ) {
3722 return obj != null ? jQuery.extend( obj, promise ) : promise;
3727 // Add list-specific methods
3728 jQuery.each( tuples, function( i, tuple ) {
3729 var list = tuple[ 2 ],
3730 stateString = tuple[ 5 ];
3732 // promise.progress = list.add
3733 // promise.done = list.add
3734 // promise.fail = list.add
3735 promise[ tuple[ 1 ] ] = list.add;
3738 if ( stateString ) {
3742 // state = "resolved" (i.e., fulfilled)
3743 // state = "rejected"
3744 state = stateString;
3747 // rejected_callbacks.disable
3748 // fulfilled_callbacks.disable
3749 tuples[ 3 - i ][ 2 ].disable,
3751 // progress_callbacks.lock
3752 tuples[ 0 ][ 2 ].lock
3756 // progress_handlers.fire
3757 // fulfilled_handlers.fire
3758 // rejected_handlers.fire
3759 list.add( tuple[ 3 ].fire );
3761 // deferred.notify = function() { deferred.notifyWith(...) }
3762 // deferred.resolve = function() { deferred.resolveWith(...) }
3763 // deferred.reject = function() { deferred.rejectWith(...) }
3764 deferred[ tuple[ 0 ] ] = function() {
3765 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
3769 // deferred.notifyWith = list.fireWith
3770 // deferred.resolveWith = list.fireWith
3771 // deferred.rejectWith = list.fireWith
3772 deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3775 // Make the deferred a promise
3776 promise.promise( deferred );
3778 // Call given func if any
3780 func.call( deferred, deferred );
3788 when: function( singleValue ) {
3791 // count of uncompleted subordinates
3792 remaining = arguments.length,
3794 // count of unprocessed arguments
3797 // subordinate fulfillment data
3798 resolveContexts = Array( i ),
3799 resolveValues = slice.call( arguments ),
3801 // the master Deferred
3802 master = jQuery.Deferred(),
3804 // subordinate callback factory
3805 updateFunc = function( i ) {
3806 return function( value ) {
3807 resolveContexts[ i ] = this;
3808 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3809 if ( !( --remaining ) ) {
3810 master.resolveWith( resolveContexts, resolveValues );
3815 // Single- and empty arguments are adopted like Promise.resolve
3816 if ( remaining <= 1 ) {
3817 adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject );
3819 // Use .then() to unwrap secondary thenables (cf. gh-3000)
3820 if ( master.state() === "pending" ||
3821 jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
3823 return master.then();
3827 // Multiple arguments are aggregated like Promise.all array elements
3829 adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
3832 return master.promise();
3837 // These usually indicate a programmer mistake during development,
3838 // warn about them ASAP rather than swallowing them by default.
3839 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3841 jQuery.Deferred.exceptionHook = function( error, stack ) {
3843 // Support: IE 8 - 9 only
3844 // Console exists when dev tools are open, which can happen at any time
3845 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
3846 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
3853 jQuery.readyException = function( error ) {
3854 window.setTimeout( function() {
3862 // The deferred used on DOM ready
3863 var readyList = jQuery.Deferred();
3865 jQuery.fn.ready = function( fn ) {
3870 // Wrap jQuery.readyException in a function so that the lookup
3871 // happens at the time of error handling instead of callback
3873 .catch( function( error ) {
3874 jQuery.readyException( error );
3882 // Is the DOM ready to be used? Set to true once it occurs.
3885 // A counter to track how many items to wait for before
3886 // the ready event fires. See #6781
3889 // Hold (or release) the ready event
3890 holdReady: function( hold ) {
3894 jQuery.ready( true );
3898 // Handle when the DOM is ready
3899 ready: function( wait ) {
3901 // Abort if there are pending holds or we're already ready
3902 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3906 // Remember that the DOM is ready
3907 jQuery.isReady = true;
3909 // If a normal DOM Ready event fired, decrement, and wait if need be
3910 if ( wait !== true && --jQuery.readyWait > 0 ) {
3914 // If there are functions bound, to execute
3915 readyList.resolveWith( document, [ jQuery ] );
3919 jQuery.ready.then = readyList.then;
3921 // The ready event handler and self cleanup method
3922 function completed() {
3923 document.removeEventListener( "DOMContentLoaded", completed );
3924 window.removeEventListener( "load", completed );
3928 // Catch cases where $(document).ready() is called
3929 // after the browser event has already occurred.
3930 // Support: IE <=9 - 10 only
3931 // Older IE sometimes signals "interactive" too soon
3932 if ( document.readyState === "complete" ||
3933 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3935 // Handle it asynchronously to allow scripts the opportunity to delay ready
3936 window.setTimeout( jQuery.ready );
3940 // Use the handy event callback
3941 document.addEventListener( "DOMContentLoaded", completed );
3943 // A fallback to window.onload, that will always work
3944 window.addEventListener( "load", completed );
3950 // Multifunctional method to get and set values of a collection
3951 // The value/s can optionally be executed if it's a function
3952 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3958 if ( jQuery.type( key ) === "object" ) {
3961 access( elems, fn, i, key[ i ], true, emptyGet, raw );
3965 } else if ( value !== undefined ) {
3968 if ( !jQuery.isFunction( value ) ) {
3974 // Bulk operations run against the entire set
3976 fn.call( elems, value );
3979 // ...except when executing function values
3982 fn = function( elem, key, value ) {
3983 return bulk.call( jQuery( elem ), value );
3989 for ( ; i < len; i++ ) {
3991 elems[ i ], key, raw ?
3993 value.call( elems[ i ], i, fn( elems[ i ], key ) )
4005 return fn.call( elems );
4008 return len ? fn( elems[ 0 ], key ) : emptyGet;
4010 var acceptData = function( owner ) {
4014 // - Node.ELEMENT_NODE
4015 // - Node.DOCUMENT_NODE
4018 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
4025 this.expando = jQuery.expando + Data.uid++;
4032 cache: function( owner ) {
4034 // Check if the owner object already has a cache
4035 var value = owner[ this.expando ];
4037 // If not, create one
4041 // We can accept data for non-element nodes in modern browsers,
4042 // but we should not, see #8335.
4043 // Always return an empty object.
4044 if ( acceptData( owner ) ) {
4046 // If it is a node unlikely to be stringify-ed or looped over
4047 // use plain assignment
4048 if ( owner.nodeType ) {
4049 owner[ this.expando ] = value;
4051 // Otherwise secure it in a non-enumerable property
4052 // configurable must be true to allow the property to be
4053 // deleted when data is removed
4055 Object.defineProperty( owner, this.expando, {
4065 set: function( owner, data, value ) {
4067 cache = this.cache( owner );
4069 // Handle: [ owner, key, value ] args
4070 // Always use camelCase key (gh-2257)
4071 if ( typeof data === "string" ) {
4072 cache[ jQuery.camelCase( data ) ] = value;
4074 // Handle: [ owner, { properties } ] args
4077 // Copy the properties one-by-one to the cache object
4078 for ( prop in data ) {
4079 cache[ jQuery.camelCase( prop ) ] = data[ prop ];
4084 get: function( owner, key ) {
4085 return key === undefined ?
4086 this.cache( owner ) :
4088 // Always use camelCase key (gh-2257)
4089 owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
4091 access: function( owner, key, value ) {
4093 // In cases where either:
4095 // 1. No key was specified
4096 // 2. A string key was specified, but no value provided
4098 // Take the "read" path and allow the get method to determine
4099 // which value to return, respectively either:
4101 // 1. The entire cache object
4102 // 2. The data stored at the key
4104 if ( key === undefined ||
4105 ( ( key && typeof key === "string" ) && value === undefined ) ) {
4107 return this.get( owner, key );
4110 // When the key is not a string, or both a key and value
4111 // are specified, set or extend (existing objects) with either:
4113 // 1. An object of properties
4114 // 2. A key and value
4116 this.set( owner, key, value );
4118 // Since the "set" path can have two possible entry points
4119 // return the expected data based on which path was taken[*]
4120 return value !== undefined ? value : key;
4122 remove: function( owner, key ) {
4124 cache = owner[ this.expando ];
4126 if ( cache === undefined ) {
4130 if ( key !== undefined ) {
4132 // Support array or space separated string of keys
4133 if ( jQuery.isArray( key ) ) {
4135 // If key is an array of keys...
4136 // We always set camelCase keys, so remove that.
4137 key = key.map( jQuery.camelCase );
4139 key = jQuery.camelCase( key );
4141 // If a key with the spaces exists, use it.
4142 // Otherwise, create an array by matching non-whitespace
4143 key = key in cache ?
4145 ( key.match( rnothtmlwhite ) || [] );
4151 delete cache[ key[ i ] ];
4155 // Remove the expando if there's no more data
4156 if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
4158 // Support: Chrome <=35 - 45
4159 // Webkit & Blink performance suffers when deleting properties
4160 // from DOM nodes, so set to undefined instead
4161 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4162 if ( owner.nodeType ) {
4163 owner[ this.expando ] = undefined;
4165 delete owner[ this.expando ];
4169 hasData: function( owner ) {
4170 var cache = owner[ this.expando ];
4171 return cache !== undefined && !jQuery.isEmptyObject( cache );
4174 var dataPriv = new Data();
4176 var dataUser = new Data();
4180 // Implementation Summary
4182 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4183 // 2. Improve the module's maintainability by reducing the storage
4184 // paths to a single mechanism.
4185 // 3. Use the same single mechanism to support "private" and "user" data.
4186 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4187 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4188 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4190 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4191 rmultiDash = /[A-Z]/g;
4193 function getData( data ) {
4194 if ( data === "true" ) {
4198 if ( data === "false" ) {
4202 if ( data === "null" ) {
4206 // Only convert to a number if it doesn't change the string
4207 if ( data === +data + "" ) {
4211 if ( rbrace.test( data ) ) {
4212 return JSON.parse( data );
4218 function dataAttr( elem, key, data ) {
4221 // If nothing was found internally, try to fetch any
4222 // data from the HTML5 data-* attribute
4223 if ( data === undefined && elem.nodeType === 1 ) {
4224 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
4225 data = elem.getAttribute( name );
4227 if ( typeof data === "string" ) {
4229 data = getData( data );
4232 // Make sure we set the data so it isn't changed later
4233 dataUser.set( elem, key, data );
4242 hasData: function( elem ) {
4243 return dataUser.hasData( elem ) || dataPriv.hasData( elem );
4246 data: function( elem, name, data ) {
4247 return dataUser.access( elem, name, data );
4250 removeData: function( elem, name ) {
4251 dataUser.remove( elem, name );
4254 // TODO: Now that all calls to _data and _removeData have been replaced
4255 // with direct calls to dataPriv methods, these can be deprecated.
4256 _data: function( elem, name, data ) {
4257 return dataPriv.access( elem, name, data );
4260 _removeData: function( elem, name ) {
4261 dataPriv.remove( elem, name );
4266 data: function( key, value ) {
4269 attrs = elem && elem.attributes;
4272 if ( key === undefined ) {
4273 if ( this.length ) {
4274 data = dataUser.get( elem );
4276 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
4280 // Support: IE 11 only
4281 // The attrs elements can be null (#14894)
4283 name = attrs[ i ].name;
4284 if ( name.indexOf( "data-" ) === 0 ) {
4285 name = jQuery.camelCase( name.slice( 5 ) );
4286 dataAttr( elem, name, data[ name ] );
4290 dataPriv.set( elem, "hasDataAttrs", true );
4297 // Sets multiple values
4298 if ( typeof key === "object" ) {
4299 return this.each( function() {
4300 dataUser.set( this, key );
4304 return access( this, function( value ) {
4307 // The calling jQuery object (element matches) is not empty
4308 // (and therefore has an element appears at this[ 0 ]) and the
4309 // `value` parameter was not undefined. An empty jQuery object
4310 // will result in `undefined` for elem = this[ 0 ] which will
4311 // throw an exception if an attempt to read a data cache is made.
4312 if ( elem && value === undefined ) {
4314 // Attempt to get data from the cache
4315 // The key will always be camelCased in Data
4316 data = dataUser.get( elem, key );
4317 if ( data !== undefined ) {
4321 // Attempt to "discover" the data in
4322 // HTML5 custom data-* attrs
4323 data = dataAttr( elem, key );
4324 if ( data !== undefined ) {
4328 // We tried really hard, but the data doesn't exist.
4333 this.each( function() {
4335 // We always store the camelCased key
4336 dataUser.set( this, key, value );
4338 }, null, value, arguments.length > 1, null, true );
4341 removeData: function( key ) {
4342 return this.each( function() {
4343 dataUser.remove( this, key );
4350 queue: function( elem, type, data ) {
4354 type = ( type || "fx" ) + "queue";
4355 queue = dataPriv.get( elem, type );
4357 // Speed up dequeue by getting out quickly if this is just a lookup
4359 if ( !queue || jQuery.isArray( data ) ) {
4360 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
4369 dequeue: function( elem, type ) {
4370 type = type || "fx";
4372 var queue = jQuery.queue( elem, type ),
4373 startLength = queue.length,
4375 hooks = jQuery._queueHooks( elem, type ),
4377 jQuery.dequeue( elem, type );
4380 // If the fx queue is dequeued, always remove the progress sentinel
4381 if ( fn === "inprogress" ) {
4388 // Add a progress sentinel to prevent the fx queue from being
4389 // automatically dequeued
4390 if ( type === "fx" ) {
4391 queue.unshift( "inprogress" );
4394 // Clear up the last queue stop function
4396 fn.call( elem, next, hooks );
4399 if ( !startLength && hooks ) {
4404 // Not public - generate a queueHooks object, or return the current one
4405 _queueHooks: function( elem, type ) {
4406 var key = type + "queueHooks";
4407 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
4408 empty: jQuery.Callbacks( "once memory" ).add( function() {
4409 dataPriv.remove( elem, [ type + "queue", key ] );
4416 queue: function( type, data ) {
4419 if ( typeof type !== "string" ) {
4425 if ( arguments.length < setter ) {
4426 return jQuery.queue( this[ 0 ], type );
4429 return data === undefined ?
4431 this.each( function() {
4432 var queue = jQuery.queue( this, type, data );
4434 // Ensure a hooks for this queue
4435 jQuery._queueHooks( this, type );
4437 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4438 jQuery.dequeue( this, type );
4442 dequeue: function( type ) {
4443 return this.each( function() {
4444 jQuery.dequeue( this, type );
4447 clearQueue: function( type ) {
4448 return this.queue( type || "fx", [] );
4451 // Get a promise resolved when queues of a certain type
4452 // are emptied (fx is the type by default)
4453 promise: function( type, obj ) {
4456 defer = jQuery.Deferred(),
4459 resolve = function() {
4460 if ( !( --count ) ) {
4461 defer.resolveWith( elements, [ elements ] );
4465 if ( typeof type !== "string" ) {
4469 type = type || "fx";
4472 tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
4473 if ( tmp && tmp.empty ) {
4475 tmp.empty.add( resolve );
4479 return defer.promise( obj );
4482 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4484 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4487 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4489 var isHiddenWithinTree = function( elem, el ) {
4491 // isHiddenWithinTree might be called from jQuery#filter function;
4492 // in that case, element will be second argument
4495 // Inline style trumps all
4496 return elem.style.display === "none" ||
4497 elem.style.display === "" &&
4499 // Otherwise, check computed style
4500 // Support: Firefox <=43 - 45
4501 // Disconnected elements can have computed display: none, so first confirm that elem is
4503 jQuery.contains( elem.ownerDocument, elem ) &&
4505 jQuery.css( elem, "display" ) === "none";
4508 var swap = function( elem, options, callback, args ) {
4512 // Remember the old values, and insert the new ones
4513 for ( name in options ) {
4514 old[ name ] = elem.style[ name ];
4515 elem.style[ name ] = options[ name ];
4518 ret = callback.apply( elem, args || [] );
4520 // Revert the old values
4521 for ( name in options ) {
4522 elem.style[ name ] = old[ name ];
4531 function adjustCSS( elem, prop, valueParts, tween ) {
4535 currentValue = tween ?
4540 return jQuery.css( elem, prop, "" );
4542 initial = currentValue(),
4543 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4545 // Starting value computation is required for potential unit mismatches
4546 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4547 rcssNum.exec( jQuery.css( elem, prop ) );
4549 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4551 // Trust units reported by jQuery.css
4552 unit = unit || initialInUnit[ 3 ];
4554 // Make sure we update the tween properties later on
4555 valueParts = valueParts || [];
4557 // Iteratively approximate from a nonzero starting point
4558 initialInUnit = +initial || 1;
4562 // If previous iteration zeroed out, double until we get *something*.
4563 // Use string for doubling so we don't accidentally see scale as unchanged below
4564 scale = scale || ".5";
4567 initialInUnit = initialInUnit / scale;
4568 jQuery.style( elem, prop, initialInUnit + unit );
4570 // Update scale, tolerating zero or NaN from tween.cur()
4571 // Break the loop if scale is unchanged or perfect, or if we've just had enough.
4573 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
4578 initialInUnit = +initialInUnit || +initial || 0;
4580 // Apply relative offset (+=/-=) if specified
4581 adjusted = valueParts[ 1 ] ?
4582 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4586 tween.start = initialInUnit;
4587 tween.end = adjusted;
4594 var defaultDisplayMap = {};
4596 function getDefaultDisplay( elem ) {
4598 doc = elem.ownerDocument,
4599 nodeName = elem.nodeName,
4600 display = defaultDisplayMap[ nodeName ];
4606 temp = doc.body.appendChild( doc.createElement( nodeName ) );
4607 display = jQuery.css( temp, "display" );
4609 temp.parentNode.removeChild( temp );
4611 if ( display === "none" ) {
4614 defaultDisplayMap[ nodeName ] = display;
4619 function showHide( elements, show ) {
4623 length = elements.length;
4625 // Determine new display value for elements that need to change
4626 for ( ; index < length; index++ ) {
4627 elem = elements[ index ];
4628 if ( !elem.style ) {
4632 display = elem.style.display;
4635 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4636 // check is required in this first loop unless we have a nonempty display value (either
4637 // inline or about-to-be-restored)
4638 if ( display === "none" ) {
4639 values[ index ] = dataPriv.get( elem, "display" ) || null;
4640 if ( !values[ index ] ) {
4641 elem.style.display = "";
4644 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
4645 values[ index ] = getDefaultDisplay( elem );
4648 if ( display !== "none" ) {
4649 values[ index ] = "none";
4651 // Remember what we're overwriting
4652 dataPriv.set( elem, "display", display );
4657 // Set the display of the elements in a second loop to avoid constant reflow
4658 for ( index = 0; index < length; index++ ) {
4659 if ( values[ index ] != null ) {
4660 elements[ index ].style.display = values[ index ];
4669 return showHide( this, true );
4672 return showHide( this );
4674 toggle: function( state ) {
4675 if ( typeof state === "boolean" ) {
4676 return state ? this.show() : this.hide();
4679 return this.each( function() {
4680 if ( isHiddenWithinTree( this ) ) {
4681 jQuery( this ).show();
4683 jQuery( this ).hide();
4688 var rcheckableType = ( /^(?:checkbox|radio)$/i );
4690 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
4692 var rscriptType = ( /^$|\/(?:java|ecma)script/i );
4696 // We have to close these tags to support XHTML (#13200)
4699 // Support: IE <=9 only
4700 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4702 // XHTML parsers do not magically insert elements in the
4703 // same way that tag soup parsers do. So we cannot shorten
4704 // this by omitting <tbody> or other required elements.
4705 thead: [ 1, "<table>", "</table>" ],
4706 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4707 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4708 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4710 _default: [ 0, "", "" ]
4713 // Support: IE <=9 only
4714 wrapMap.optgroup = wrapMap.option;
4716 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4717 wrapMap.th = wrapMap.td;
4720 function getAll( context, tag ) {
4722 // Support: IE <=9 - 11 only
4723 // Use typeof to avoid zero-argument method invocation on host objects (#15151)
4726 if ( typeof context.getElementsByTagName !== "undefined" ) {
4727 ret = context.getElementsByTagName( tag || "*" );
4729 } else if ( typeof context.querySelectorAll !== "undefined" ) {
4730 ret = context.querySelectorAll( tag || "*" );
4736 if ( tag === undefined || tag && jQuery.nodeName( context, tag ) ) {
4737 return jQuery.merge( [ context ], ret );
4744 // Mark scripts as having already been evaluated
4745 function setGlobalEval( elems, refElements ) {
4749 for ( ; i < l; i++ ) {
4753 !refElements || dataPriv.get( refElements[ i ], "globalEval" )
4759 var rhtml = /<|&#?\w+;/;
4761 function buildFragment( elems, context, scripts, selection, ignored ) {
4762 var elem, tmp, tag, wrap, contains, j,
4763 fragment = context.createDocumentFragment(),
4768 for ( ; i < l; i++ ) {
4771 if ( elem || elem === 0 ) {
4773 // Add nodes directly
4774 if ( jQuery.type( elem ) === "object" ) {
4776 // Support: Android <=4.0 only, PhantomJS 1 only
4777 // push.apply(_, arraylike) throws on ancient WebKit
4778 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4780 // Convert non-html into a text node
4781 } else if ( !rhtml.test( elem ) ) {
4782 nodes.push( context.createTextNode( elem ) );
4784 // Convert html into DOM nodes
4786 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4788 // Deserialize a standard representation
4789 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4790 wrap = wrapMap[ tag ] || wrapMap._default;
4791 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4793 // Descend through wrappers to the right content
4796 tmp = tmp.lastChild;
4799 // Support: Android <=4.0 only, PhantomJS 1 only
4800 // push.apply(_, arraylike) throws on ancient WebKit
4801 jQuery.merge( nodes, tmp.childNodes );
4803 // Remember the top-level container
4804 tmp = fragment.firstChild;
4806 // Ensure the created nodes are orphaned (#12392)
4807 tmp.textContent = "";
4812 // Remove wrapper from fragment
4813 fragment.textContent = "";
4816 while ( ( elem = nodes[ i++ ] ) ) {
4818 // Skip elements already in the context collection (trac-4087)
4819 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4821 ignored.push( elem );
4826 contains = jQuery.contains( elem.ownerDocument, elem );
4828 // Append to fragment
4829 tmp = getAll( fragment.appendChild( elem ), "script" );
4831 // Preserve script evaluation history
4833 setGlobalEval( tmp );
4836 // Capture executables
4839 while ( ( elem = tmp[ j++ ] ) ) {
4840 if ( rscriptType.test( elem.type || "" ) ) {
4841 scripts.push( elem );
4852 var fragment = document.createDocumentFragment(),
4853 div = fragment.appendChild( document.createElement( "div" ) ),
4854 input = document.createElement( "input" );
4856 // Support: Android 4.0 - 4.3 only
4857 // Check state lost if the name is set (#11217)
4858 // Support: Windows Web Apps (WWA)
4859 // `name` and `type` must use .setAttribute for WWA (#14901)
4860 input.setAttribute( "type", "radio" );
4861 input.setAttribute( "checked", "checked" );
4862 input.setAttribute( "name", "t" );
4864 div.appendChild( input );
4866 // Support: Android <=4.1 only
4867 // Older WebKit doesn't clone checked state correctly in fragments
4868 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4870 // Support: IE <=11 only
4871 // Make sure textarea (and checkbox) defaultValue is properly cloned
4872 div.innerHTML = "<textarea>x</textarea>";
4873 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4875 var documentElement = document.documentElement;
4881 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4882 rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4884 function returnTrue() {
4888 function returnFalse() {
4892 // Support: IE <=9 only
4893 // See #13393 for more info
4894 function safeActiveElement() {
4896 return document.activeElement;
4900 function on( elem, types, selector, data, fn, one ) {
4903 // Types can be a map of types/handlers
4904 if ( typeof types === "object" ) {
4906 // ( types-Object, selector, data )
4907 if ( typeof selector !== "string" ) {
4909 // ( types-Object, data )
4910 data = data || selector;
4911 selector = undefined;
4913 for ( type in types ) {
4914 on( elem, type, selector, data, types[ type ], one );
4919 if ( data == null && fn == null ) {
4923 data = selector = undefined;
4924 } else if ( fn == null ) {
4925 if ( typeof selector === "string" ) {
4927 // ( types, selector, fn )
4932 // ( types, data, fn )
4935 selector = undefined;
4938 if ( fn === false ) {
4946 fn = function( event ) {
4948 // Can use an empty set, since event contains the info
4949 jQuery().off( event );
4950 return origFn.apply( this, arguments );
4953 // Use same guid so caller can remove using origFn
4954 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4956 return elem.each( function() {
4957 jQuery.event.add( this, types, fn, data, selector );
4962 * Helper functions for managing events -- not part of the public interface.
4963 * Props to Dean Edwards' addEvent library for many of the ideas.
4969 add: function( elem, types, handler, data, selector ) {
4971 var handleObjIn, eventHandle, tmp,
4972 events, t, handleObj,
4973 special, handlers, type, namespaces, origType,
4974 elemData = dataPriv.get( elem );
4976 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4981 // Caller can pass in an object of custom data in lieu of the handler
4982 if ( handler.handler ) {
4983 handleObjIn = handler;
4984 handler = handleObjIn.handler;
4985 selector = handleObjIn.selector;
4988 // Ensure that invalid selectors throw exceptions at attach time
4989 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
4991 jQuery.find.matchesSelector( documentElement, selector );
4994 // Make sure that the handler has a unique ID, used to find/remove it later
4995 if ( !handler.guid ) {
4996 handler.guid = jQuery.guid++;
4999 // Init the element's event structure and main handler, if this is the first
5000 if ( !( events = elemData.events ) ) {
5001 events = elemData.events = {};
5003 if ( !( eventHandle = elemData.handle ) ) {
5004 eventHandle = elemData.handle = function( e ) {
5006 // Discard the second event of a jQuery.event.trigger() and
5007 // when an event is called after a page has unloaded
5008 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
5009 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
5013 // Handle multiple events separated by a space
5014 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
5017 tmp = rtypenamespace.exec( types[ t ] ) || [];
5018 type = origType = tmp[ 1 ];
5019 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5021 // There *must* be a type, no attaching namespace-only handlers
5026 // If event changes its type, use the special event handlers for the changed type
5027 special = jQuery.event.special[ type ] || {};
5029 // If selector defined, determine special event api type, otherwise given type
5030 type = ( selector ? special.delegateType : special.bindType ) || type;
5032 // Update special based on newly reset type
5033 special = jQuery.event.special[ type ] || {};
5035 // handleObj is passed to all event handlers
5036 handleObj = jQuery.extend( {
5043 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
5044 namespace: namespaces.join( "." )
5047 // Init the event handler queue if we're the first
5048 if ( !( handlers = events[ type ] ) ) {
5049 handlers = events[ type ] = [];
5050 handlers.delegateCount = 0;
5052 // Only use addEventListener if the special events handler returns false
5053 if ( !special.setup ||
5054 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
5056 if ( elem.addEventListener ) {
5057 elem.addEventListener( type, eventHandle );
5062 if ( special.add ) {
5063 special.add.call( elem, handleObj );
5065 if ( !handleObj.handler.guid ) {
5066 handleObj.handler.guid = handler.guid;
5070 // Add to the element's handler list, delegates in front
5072 handlers.splice( handlers.delegateCount++, 0, handleObj );
5074 handlers.push( handleObj );
5077 // Keep track of which events have ever been used, for event optimization
5078 jQuery.event.global[ type ] = true;
5083 // Detach an event or set of events from an element
5084 remove: function( elem, types, handler, selector, mappedTypes ) {
5086 var j, origCount, tmp,
5087 events, t, handleObj,
5088 special, handlers, type, namespaces, origType,
5089 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
5091 if ( !elemData || !( events = elemData.events ) ) {
5095 // Once for each type.namespace in types; type may be omitted
5096 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
5099 tmp = rtypenamespace.exec( types[ t ] ) || [];
5100 type = origType = tmp[ 1 ];
5101 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5103 // Unbind all events (on this namespace, if provided) for the element
5105 for ( type in events ) {
5106 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5111 special = jQuery.event.special[ type ] || {};
5112 type = ( selector ? special.delegateType : special.bindType ) || type;
5113 handlers = events[ type ] || [];
5115 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5117 // Remove matching events
5118 origCount = j = handlers.length;
5120 handleObj = handlers[ j ];
5122 if ( ( mappedTypes || origType === handleObj.origType ) &&
5123 ( !handler || handler.guid === handleObj.guid ) &&
5124 ( !tmp || tmp.test( handleObj.namespace ) ) &&
5125 ( !selector || selector === handleObj.selector ||
5126 selector === "**" && handleObj.selector ) ) {
5127 handlers.splice( j, 1 );
5129 if ( handleObj.selector ) {
5130 handlers.delegateCount--;
5132 if ( special.remove ) {
5133 special.remove.call( elem, handleObj );
5138 // Remove generic event handler if we removed something and no more handlers exist
5139 // (avoids potential for endless recursion during removal of special event handlers)
5140 if ( origCount && !handlers.length ) {
5141 if ( !special.teardown ||
5142 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5144 jQuery.removeEvent( elem, type, elemData.handle );
5147 delete events[ type ];
5151 // Remove data and the expando if it's no longer used
5152 if ( jQuery.isEmptyObject( events ) ) {
5153 dataPriv.remove( elem, "handle events" );
5157 dispatch: function( nativeEvent ) {
5159 // Make a writable jQuery.Event from the native event object
5160 var event = jQuery.event.fix( nativeEvent );
5162 var i, j, ret, matched, handleObj, handlerQueue,
5163 args = new Array( arguments.length ),
5164 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
5165 special = jQuery.event.special[ event.type ] || {};
5167 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5170 for ( i = 1; i < arguments.length; i++ ) {
5171 args[ i ] = arguments[ i ];
5174 event.delegateTarget = this;
5176 // Call the preDispatch hook for the mapped type, and let it bail if desired
5177 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5181 // Determine handlers
5182 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5184 // Run delegates first; they may want to stop propagation beneath us
5186 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5187 event.currentTarget = matched.elem;
5190 while ( ( handleObj = matched.handlers[ j++ ] ) &&
5191 !event.isImmediatePropagationStopped() ) {
5193 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5194 // a subset or equal to those in the bound event (both can have no namespace).
5195 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
5197 event.handleObj = handleObj;
5198 event.data = handleObj.data;
5200 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5201 handleObj.handler ).apply( matched.elem, args );
5203 if ( ret !== undefined ) {
5204 if ( ( event.result = ret ) === false ) {
5205 event.preventDefault();
5206 event.stopPropagation();
5213 // Call the postDispatch hook for the mapped type
5214 if ( special.postDispatch ) {
5215 special.postDispatch.call( this, event );
5218 return event.result;
5221 handlers: function( event, handlers ) {
5222 var i, handleObj, sel, matchedHandlers, matchedSelectors,
5224 delegateCount = handlers.delegateCount,
5227 // Find delegate handlers
5228 if ( delegateCount &&
5231 // Black-hole SVG <use> instance trees (trac-13180)
5234 // Support: Firefox <=42
5235 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5236 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5237 // Support: IE 11 only
5238 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5239 !( event.type === "click" && event.button >= 1 ) ) {
5241 for ( ; cur !== this; cur = cur.parentNode || this ) {
5243 // Don't check non-elements (#13208)
5244 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5245 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
5246 matchedHandlers = [];
5247 matchedSelectors = {};
5248 for ( i = 0; i < delegateCount; i++ ) {
5249 handleObj = handlers[ i ];
5251 // Don't conflict with Object.prototype properties (#13203)
5252 sel = handleObj.selector + " ";
5254 if ( matchedSelectors[ sel ] === undefined ) {
5255 matchedSelectors[ sel ] = handleObj.needsContext ?
5256 jQuery( sel, this ).index( cur ) > -1 :
5257 jQuery.find( sel, this, null, [ cur ] ).length;
5259 if ( matchedSelectors[ sel ] ) {
5260 matchedHandlers.push( handleObj );
5263 if ( matchedHandlers.length ) {
5264 handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
5270 // Add the remaining (directly-bound) handlers
5272 if ( delegateCount < handlers.length ) {
5273 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
5276 return handlerQueue;
5279 addProp: function( name, hook ) {
5280 Object.defineProperty( jQuery.Event.prototype, name, {
5284 get: jQuery.isFunction( hook ) ?
5286 if ( this.originalEvent ) {
5287 return hook( this.originalEvent );
5291 if ( this.originalEvent ) {
5292 return this.originalEvent[ name ];
5296 set: function( value ) {
5297 Object.defineProperty( this, name, {
5307 fix: function( originalEvent ) {
5308 return originalEvent[ jQuery.expando ] ?
5310 new jQuery.Event( originalEvent );
5316 // Prevent triggered image.load events from bubbling to window.load
5321 // Fire native event if possible so blur/focus sequence is correct
5322 trigger: function() {
5323 if ( this !== safeActiveElement() && this.focus ) {
5328 delegateType: "focusin"
5331 trigger: function() {
5332 if ( this === safeActiveElement() && this.blur ) {
5337 delegateType: "focusout"
5341 // For checkbox, fire native event so checked state will be right
5342 trigger: function() {
5343 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
5349 // For cross-browser consistency, don't fire native .click() on links
5350 _default: function( event ) {
5351 return jQuery.nodeName( event.target, "a" );
5356 postDispatch: function( event ) {
5358 // Support: Firefox 20+
5359 // Firefox doesn't alert if the returnValue field is not set.
5360 if ( event.result !== undefined && event.originalEvent ) {
5361 event.originalEvent.returnValue = event.result;
5368 jQuery.removeEvent = function( elem, type, handle ) {
5370 // This "if" is needed for plain objects
5371 if ( elem.removeEventListener ) {
5372 elem.removeEventListener( type, handle );
5376 jQuery.Event = function( src, props ) {
5378 // Allow instantiation without the 'new' keyword
5379 if ( !( this instanceof jQuery.Event ) ) {
5380 return new jQuery.Event( src, props );
5384 if ( src && src.type ) {
5385 this.originalEvent = src;
5386 this.type = src.type;
5388 // Events bubbling up the document may have been marked as prevented
5389 // by a handler lower down the tree; reflect the correct value.
5390 this.isDefaultPrevented = src.defaultPrevented ||
5391 src.defaultPrevented === undefined &&
5393 // Support: Android <=2.3 only
5394 src.returnValue === false ?
5398 // Create target properties
5399 // Support: Safari <=6 - 7 only
5400 // Target should not be a text node (#504, #13143)
5401 this.target = ( src.target && src.target.nodeType === 3 ) ?
5402 src.target.parentNode :
5405 this.currentTarget = src.currentTarget;
5406 this.relatedTarget = src.relatedTarget;
5413 // Put explicitly provided properties onto the event object
5415 jQuery.extend( this, props );
5418 // Create a timestamp if incoming event doesn't have one
5419 this.timeStamp = src && src.timeStamp || jQuery.now();
5422 this[ jQuery.expando ] = true;
5425 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5426 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5427 jQuery.Event.prototype = {
5428 constructor: jQuery.Event,
5429 isDefaultPrevented: returnFalse,
5430 isPropagationStopped: returnFalse,
5431 isImmediatePropagationStopped: returnFalse,
5434 preventDefault: function() {
5435 var e = this.originalEvent;
5437 this.isDefaultPrevented = returnTrue;
5439 if ( e && !this.isSimulated ) {
5443 stopPropagation: function() {
5444 var e = this.originalEvent;
5446 this.isPropagationStopped = returnTrue;
5448 if ( e && !this.isSimulated ) {
5449 e.stopPropagation();
5452 stopImmediatePropagation: function() {
5453 var e = this.originalEvent;
5455 this.isImmediatePropagationStopped = returnTrue;
5457 if ( e && !this.isSimulated ) {
5458 e.stopImmediatePropagation();
5461 this.stopPropagation();
5465 // Includes all common event props including KeyEvent and MouseEvent specific props
5470 changedTouches: true,
5493 targetTouches: true,
5497 which: function( event ) {
5498 var button = event.button;
5500 // Add which for key events
5501 if ( event.which == null && rkeyEvent.test( event.type ) ) {
5502 return event.charCode != null ? event.charCode : event.keyCode;
5505 // Add which for click: 1 === left; 2 === middle; 3 === right
5506 if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
5524 }, jQuery.event.addProp );
5526 // Create mouseenter/leave events using mouseover/out and event-time checks
5527 // so that event delegation works in jQuery.
5528 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5530 // Support: Safari 7 only
5531 // Safari sends mouseenter too often; see:
5532 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5533 // for the description of the bug (it existed in older Chrome versions as well).
5535 mouseenter: "mouseover",
5536 mouseleave: "mouseout",
5537 pointerenter: "pointerover",
5538 pointerleave: "pointerout"
5539 }, function( orig, fix ) {
5540 jQuery.event.special[ orig ] = {
5544 handle: function( event ) {
5547 related = event.relatedTarget,
5548 handleObj = event.handleObj;
5550 // For mouseenter/leave call the handler if related is outside the target.
5551 // NB: No relatedTarget if the mouse left/entered the browser window
5552 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5553 event.type = handleObj.origType;
5554 ret = handleObj.handler.apply( this, arguments );
5564 on: function( types, selector, data, fn ) {
5565 return on( this, types, selector, data, fn );
5567 one: function( types, selector, data, fn ) {
5568 return on( this, types, selector, data, fn, 1 );
5570 off: function( types, selector, fn ) {
5571 var handleObj, type;
5572 if ( types && types.preventDefault && types.handleObj ) {
5574 // ( event ) dispatched jQuery.Event
5575 handleObj = types.handleObj;
5576 jQuery( types.delegateTarget ).off(
5577 handleObj.namespace ?
5578 handleObj.origType + "." + handleObj.namespace :
5585 if ( typeof types === "object" ) {
5587 // ( types-object [, selector] )
5588 for ( type in types ) {
5589 this.off( type, selector, types[ type ] );
5593 if ( selector === false || typeof selector === "function" ) {
5597 selector = undefined;
5599 if ( fn === false ) {
5602 return this.each( function() {
5603 jQuery.event.remove( this, types, fn, selector );
5611 /* eslint-disable max-len */
5613 // See https://github.com/eslint/eslint/issues/3229
5614 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
5618 // Support: IE <=10 - 11, Edge 12 - 13
5619 // In IE/Edge using regex groups here causes severe slowdowns.
5620 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5621 rnoInnerhtml = /<script|<style|<link/i,
5623 // checked="checked" or checked
5624 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5625 rscriptTypeMasked = /^true\/(.*)/,
5626 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5628 function manipulationTarget( elem, content ) {
5629 if ( jQuery.nodeName( elem, "table" ) &&
5630 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
5632 return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
5638 // Replace/restore the type attribute of script elements for safe DOM manipulation
5639 function disableScript( elem ) {
5640 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
5643 function restoreScript( elem ) {
5644 var match = rscriptTypeMasked.exec( elem.type );
5647 elem.type = match[ 1 ];
5649 elem.removeAttribute( "type" );
5655 function cloneCopyEvent( src, dest ) {
5656 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
5658 if ( dest.nodeType !== 1 ) {
5662 // 1. Copy private data: events, handlers, etc.
5663 if ( dataPriv.hasData( src ) ) {
5664 pdataOld = dataPriv.access( src );
5665 pdataCur = dataPriv.set( dest, pdataOld );
5666 events = pdataOld.events;
5669 delete pdataCur.handle;
5670 pdataCur.events = {};
5672 for ( type in events ) {
5673 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5674 jQuery.event.add( dest, type, events[ type ][ i ] );
5680 // 2. Copy user data
5681 if ( dataUser.hasData( src ) ) {
5682 udataOld = dataUser.access( src );
5683 udataCur = jQuery.extend( {}, udataOld );
5685 dataUser.set( dest, udataCur );
5689 // Fix IE bugs, see support tests
5690 function fixInput( src, dest ) {
5691 var nodeName = dest.nodeName.toLowerCase();
5693 // Fails to persist the checked state of a cloned checkbox or radio button.
5694 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5695 dest.checked = src.checked;
5697 // Fails to return the selected option to the default selected state when cloning options
5698 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5699 dest.defaultValue = src.defaultValue;
5703 function domManip( collection, args, callback, ignored ) {
5705 // Flatten any nested arrays
5706 args = concat.apply( [], args );
5708 var fragment, first, scripts, hasScripts, node, doc,
5710 l = collection.length,
5713 isFunction = jQuery.isFunction( value );
5715 // We can't cloneNode fragments that contain checked, in WebKit
5717 ( l > 1 && typeof value === "string" &&
5718 !support.checkClone && rchecked.test( value ) ) ) {
5719 return collection.each( function( index ) {
5720 var self = collection.eq( index );
5722 args[ 0 ] = value.call( this, index, self.html() );
5724 domManip( self, args, callback, ignored );
5729 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5730 first = fragment.firstChild;
5732 if ( fragment.childNodes.length === 1 ) {
5736 // Require either new content or an interest in ignored elements to invoke the callback
5737 if ( first || ignored ) {
5738 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5739 hasScripts = scripts.length;
5741 // Use the original fragment for the last item
5742 // instead of the first because it can end up
5743 // being emptied incorrectly in certain situations (#8070).
5744 for ( ; i < l; i++ ) {
5747 if ( i !== iNoClone ) {
5748 node = jQuery.clone( node, true, true );
5750 // Keep references to cloned scripts for later restoration
5753 // Support: Android <=4.0 only, PhantomJS 1 only
5754 // push.apply(_, arraylike) throws on ancient WebKit
5755 jQuery.merge( scripts, getAll( node, "script" ) );
5759 callback.call( collection[ i ], node, i );
5763 doc = scripts[ scripts.length - 1 ].ownerDocument;
5766 jQuery.map( scripts, restoreScript );
5768 // Evaluate executable scripts on first document insertion
5769 for ( i = 0; i < hasScripts; i++ ) {
5770 node = scripts[ i ];
5771 if ( rscriptType.test( node.type || "" ) &&
5772 !dataPriv.access( node, "globalEval" ) &&
5773 jQuery.contains( doc, node ) ) {
5777 // Optional AJAX dependency, but won't run scripts if not present
5778 if ( jQuery._evalUrl ) {
5779 jQuery._evalUrl( node.src );
5782 DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
5793 function remove( elem, selector, keepData ) {
5795 nodes = selector ? jQuery.filter( selector, elem ) : elem,
5798 for ( ; ( node = nodes[ i ] ) != null; i++ ) {
5799 if ( !keepData && node.nodeType === 1 ) {
5800 jQuery.cleanData( getAll( node ) );
5803 if ( node.parentNode ) {
5804 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
5805 setGlobalEval( getAll( node, "script" ) );
5807 node.parentNode.removeChild( node );
5815 htmlPrefilter: function( html ) {
5816 return html.replace( rxhtmlTag, "<$1></$2>" );
5819 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5820 var i, l, srcElements, destElements,
5821 clone = elem.cloneNode( true ),
5822 inPage = jQuery.contains( elem.ownerDocument, elem );
5824 // Fix IE cloning issues
5825 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5826 !jQuery.isXMLDoc( elem ) ) {
5828 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
5829 destElements = getAll( clone );
5830 srcElements = getAll( elem );
5832 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5833 fixInput( srcElements[ i ], destElements[ i ] );
5837 // Copy the events from the original to the clone
5838 if ( dataAndEvents ) {
5839 if ( deepDataAndEvents ) {
5840 srcElements = srcElements || getAll( elem );
5841 destElements = destElements || getAll( clone );
5843 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5844 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
5847 cloneCopyEvent( elem, clone );
5851 // Preserve script evaluation history
5852 destElements = getAll( clone, "script" );
5853 if ( destElements.length > 0 ) {
5854 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5857 // Return the cloned set
5861 cleanData: function( elems ) {
5862 var data, elem, type,
5863 special = jQuery.event.special,
5866 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
5867 if ( acceptData( elem ) ) {
5868 if ( ( data = elem[ dataPriv.expando ] ) ) {
5869 if ( data.events ) {
5870 for ( type in data.events ) {
5871 if ( special[ type ] ) {
5872 jQuery.event.remove( elem, type );
5874 // This is a shortcut to avoid jQuery.event.remove's overhead
5876 jQuery.removeEvent( elem, type, data.handle );
5881 // Support: Chrome <=35 - 45+
5882 // Assign undefined instead of using delete, see Data#remove
5883 elem[ dataPriv.expando ] = undefined;
5885 if ( elem[ dataUser.expando ] ) {
5887 // Support: Chrome <=35 - 45+
5888 // Assign undefined instead of using delete, see Data#remove
5889 elem[ dataUser.expando ] = undefined;
5897 detach: function( selector ) {
5898 return remove( this, selector, true );
5901 remove: function( selector ) {
5902 return remove( this, selector );
5905 text: function( value ) {
5906 return access( this, function( value ) {
5907 return value === undefined ?
5908 jQuery.text( this ) :
5909 this.empty().each( function() {
5910 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5911 this.textContent = value;
5914 }, null, value, arguments.length );
5917 append: function() {
5918 return domManip( this, arguments, function( elem ) {
5919 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5920 var target = manipulationTarget( this, elem );
5921 target.appendChild( elem );
5926 prepend: function() {
5927 return domManip( this, arguments, function( elem ) {
5928 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5929 var target = manipulationTarget( this, elem );
5930 target.insertBefore( elem, target.firstChild );
5935 before: function() {
5936 return domManip( this, arguments, function( elem ) {
5937 if ( this.parentNode ) {
5938 this.parentNode.insertBefore( elem, this );
5944 return domManip( this, arguments, function( elem ) {
5945 if ( this.parentNode ) {
5946 this.parentNode.insertBefore( elem, this.nextSibling );
5955 for ( ; ( elem = this[ i ] ) != null; i++ ) {
5956 if ( elem.nodeType === 1 ) {
5958 // Prevent memory leaks
5959 jQuery.cleanData( getAll( elem, false ) );
5961 // Remove any remaining nodes
5962 elem.textContent = "";
5969 clone: function( dataAndEvents, deepDataAndEvents ) {
5970 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5971 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5973 return this.map( function() {
5974 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5978 html: function( value ) {
5979 return access( this, function( value ) {
5980 var elem = this[ 0 ] || {},
5984 if ( value === undefined && elem.nodeType === 1 ) {
5985 return elem.innerHTML;
5988 // See if we can take a shortcut and just use innerHTML
5989 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5990 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5992 value = jQuery.htmlPrefilter( value );
5995 for ( ; i < l; i++ ) {
5996 elem = this[ i ] || {};
5998 // Remove element nodes and prevent memory leaks
5999 if ( elem.nodeType === 1 ) {
6000 jQuery.cleanData( getAll( elem, false ) );
6001 elem.innerHTML = value;
6007 // If using innerHTML throws an exception, use the fallback method
6012 this.empty().append( value );
6014 }, null, value, arguments.length );
6017 replaceWith: function() {
6020 // Make the changes, replacing each non-ignored context element with the new content
6021 return domManip( this, arguments, function( elem ) {
6022 var parent = this.parentNode;
6024 if ( jQuery.inArray( this, ignored ) < 0 ) {
6025 jQuery.cleanData( getAll( this ) );
6027 parent.replaceChild( elem, this );
6031 // Force callback invocation
6038 prependTo: "prepend",
6039 insertBefore: "before",
6040 insertAfter: "after",
6041 replaceAll: "replaceWith"
6042 }, function( name, original ) {
6043 jQuery.fn[ name ] = function( selector ) {
6046 insert = jQuery( selector ),
6047 last = insert.length - 1,
6050 for ( ; i <= last; i++ ) {
6051 elems = i === last ? this : this.clone( true );
6052 jQuery( insert[ i ] )[ original ]( elems );
6054 // Support: Android <=4.0 only, PhantomJS 1 only
6055 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6056 push.apply( ret, elems.get() );
6059 return this.pushStack( ret );
6062 var rmargin = ( /^margin/ );
6064 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6066 var getStyles = function( elem ) {
6068 // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
6069 // IE throws on elements created in popups
6070 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6071 var view = elem.ownerDocument.defaultView;
6073 if ( !view || !view.opener ) {
6077 return view.getComputedStyle( elem );
6084 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6085 // so they're executed at the same time to save the second computation.
6086 function computeStyleTests() {
6088 // This is a singleton, we need to execute it only once
6094 "box-sizing:border-box;" +
6095 "position:relative;display:block;" +
6096 "margin:auto;border:1px;padding:1px;" +
6099 documentElement.appendChild( container );
6101 var divStyle = window.getComputedStyle( div );
6102 pixelPositionVal = divStyle.top !== "1%";
6104 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6105 reliableMarginLeftVal = divStyle.marginLeft === "2px";
6106 boxSizingReliableVal = divStyle.width === "4px";
6108 // Support: Android 4.0 - 4.3 only
6109 // Some styles come back with percentage values, even though they shouldn't
6110 div.style.marginRight = "50%";
6111 pixelMarginRightVal = divStyle.marginRight === "4px";
6113 documentElement.removeChild( container );
6115 // Nullify the div so it wouldn't be stored in the memory and
6116 // it will also be a sign that checks already performed
6120 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
6121 container = document.createElement( "div" ),
6122 div = document.createElement( "div" );
6124 // Finish early in limited (non-browser) environments
6129 // Support: IE <=9 - 11 only
6130 // Style of cloned element affects source element cloned (#8908)
6131 div.style.backgroundClip = "content-box";
6132 div.cloneNode( true ).style.backgroundClip = "";
6133 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6135 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
6136 "padding:0;margin-top:1px;position:absolute";
6137 container.appendChild( div );
6139 jQuery.extend( support, {
6140 pixelPosition: function() {
6141 computeStyleTests();
6142 return pixelPositionVal;
6144 boxSizingReliable: function() {
6145 computeStyleTests();
6146 return boxSizingReliableVal;
6148 pixelMarginRight: function() {
6149 computeStyleTests();
6150 return pixelMarginRightVal;
6152 reliableMarginLeft: function() {
6153 computeStyleTests();
6154 return reliableMarginLeftVal;
6160 function curCSS( elem, name, computed ) {
6161 var width, minWidth, maxWidth, ret,
6164 computed = computed || getStyles( elem );
6166 // Support: IE <=9 only
6167 // getPropertyValue is only needed for .css('filter') (#12537)
6169 ret = computed.getPropertyValue( name ) || computed[ name ];
6171 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6172 ret = jQuery.style( elem, name );
6175 // A tribute to the "awesome hack by Dean Edwards"
6176 // Android Browser returns percentage for some values,
6177 // but width seems to be reliably pixels.
6178 // This is against the CSSOM draft spec:
6179 // https://drafts.csswg.org/cssom/#resolved-values
6180 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6182 // Remember the original values
6183 width = style.width;
6184 minWidth = style.minWidth;
6185 maxWidth = style.maxWidth;
6187 // Put in the new values to get a computed value out
6188 style.minWidth = style.maxWidth = style.width = ret;
6189 ret = computed.width;
6191 // Revert the changed values
6192 style.width = width;
6193 style.minWidth = minWidth;
6194 style.maxWidth = maxWidth;
6198 return ret !== undefined ?
6200 // Support: IE <=9 - 11 only
6201 // IE returns zIndex value as an integer.
6207 function addGetHookIf( conditionFn, hookFn ) {
6209 // Define the hook, we'll check on the first run if it's really needed.
6212 if ( conditionFn() ) {
6214 // Hook not needed (or it's not possible to use it due
6215 // to missing dependency), remove it.
6220 // Hook needed; redefine it so that the support test is not executed again.
6221 return ( this.get = hookFn ).apply( this, arguments );
6229 // Swappable if display is none or starts with table
6230 // except "table", "table-cell", or "table-caption"
6231 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6232 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6233 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6234 cssNormalTransform = {
6239 cssPrefixes = [ "Webkit", "Moz", "ms" ],
6240 emptyStyle = document.createElement( "div" ).style;
6242 // Return a css property mapped to a potentially vendor prefixed property
6243 function vendorPropName( name ) {
6245 // Shortcut for names that are not vendor prefixed
6246 if ( name in emptyStyle ) {
6250 // Check for vendor prefixed names
6251 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
6252 i = cssPrefixes.length;
6255 name = cssPrefixes[ i ] + capName;
6256 if ( name in emptyStyle ) {
6262 function setPositiveNumber( elem, value, subtract ) {
6264 // Any relative (+/-) values have already been
6265 // normalized at this point
6266 var matches = rcssNum.exec( value );
6269 // Guard against undefined "subtract", e.g., when used as in cssHooks
6270 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
6274 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
6278 // If we already have the right measurement, avoid augmentation
6279 if ( extra === ( isBorderBox ? "border" : "content" ) ) {
6282 // Otherwise initialize for horizontal or vertical properties
6284 i = name === "width" ? 1 : 0;
6287 for ( ; i < 4; i += 2 ) {
6289 // Both box models exclude margin, so add it if we want it
6290 if ( extra === "margin" ) {
6291 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
6294 if ( isBorderBox ) {
6296 // border-box includes padding, so remove it if we want content
6297 if ( extra === "content" ) {
6298 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6301 // At this point, extra isn't border nor margin, so remove border
6302 if ( extra !== "margin" ) {
6303 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6307 // At this point, extra isn't content, so add padding
6308 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6310 // At this point, extra isn't content nor padding, so add border
6311 if ( extra !== "padding" ) {
6312 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6320 function getWidthOrHeight( elem, name, extra ) {
6322 // Start with offset property, which is equivalent to the border-box value
6324 valueIsBorderBox = true,
6325 styles = getStyles( elem ),
6326 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6328 // Support: IE <=11 only
6329 // Running getBoundingClientRect on a disconnected node
6330 // in IE throws an error.
6331 if ( elem.getClientRects().length ) {
6332 val = elem.getBoundingClientRect()[ name ];
6335 // Some non-html elements return undefined for offsetWidth, so check for null/undefined
6336 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6337 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6338 if ( val <= 0 || val == null ) {
6340 // Fall back to computed then uncomputed css if necessary
6341 val = curCSS( elem, name, styles );
6342 if ( val < 0 || val == null ) {
6343 val = elem.style[ name ];
6346 // Computed unit is not pixels. Stop here and return.
6347 if ( rnumnonpx.test( val ) ) {
6351 // Check for style in case a browser which returns unreliable values
6352 // for getComputedStyle silently falls back to the reliable elem.style
6353 valueIsBorderBox = isBorderBox &&
6354 ( support.boxSizingReliable() || val === elem.style[ name ] );
6356 // Normalize "", auto, and prepare for extra
6357 val = parseFloat( val ) || 0;
6360 // Use the active box-sizing model to add/subtract irrelevant styles
6362 augmentWidthOrHeight(
6365 extra || ( isBorderBox ? "border" : "content" ),
6374 // Add in style property hooks for overriding the default
6375 // behavior of getting and setting a style property
6378 get: function( elem, computed ) {
6381 // We should always get a number back from opacity
6382 var ret = curCSS( elem, "opacity" );
6383 return ret === "" ? "1" : ret;
6389 // Don't automatically add "px" to these possibly-unitless properties
6391 "animationIterationCount": true,
6392 "columnCount": true,
6393 "fillOpacity": true,
6406 // Add in properties whose names you wish to fix before
6407 // setting or getting the value
6412 // Get and set the style property on a DOM Node
6413 style: function( elem, name, value, extra ) {
6415 // Don't set styles on text and comment nodes
6416 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6420 // Make sure that we're working with the right name
6421 var ret, type, hooks,
6422 origName = jQuery.camelCase( name ),
6425 name = jQuery.cssProps[ origName ] ||
6426 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
6428 // Gets hook for the prefixed version, then unprefixed version
6429 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6431 // Check if we're setting a value
6432 if ( value !== undefined ) {
6433 type = typeof value;
6435 // Convert "+=" or "-=" to relative numbers (#7345)
6436 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
6437 value = adjustCSS( elem, name, ret );
6443 // Make sure that null and NaN values aren't set (#7116)
6444 if ( value == null || value !== value ) {
6448 // If a number was passed in, add the unit (except for certain CSS properties)
6449 if ( type === "number" ) {
6450 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
6453 // background-* props affect original clone's values
6454 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
6455 style[ name ] = "inherit";
6458 // If a hook was provided, use that value, otherwise just set the specified value
6459 if ( !hooks || !( "set" in hooks ) ||
6460 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
6462 style[ name ] = value;
6467 // If a hook was provided get the non-computed value from there
6468 if ( hooks && "get" in hooks &&
6469 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
6474 // Otherwise just get the value from the style object
6475 return style[ name ];
6479 css: function( elem, name, extra, styles ) {
6480 var val, num, hooks,
6481 origName = jQuery.camelCase( name );
6483 // Make sure that we're working with the right name
6484 name = jQuery.cssProps[ origName ] ||
6485 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
6487 // Try prefixed name followed by the unprefixed name
6488 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6490 // If a hook was provided get the computed value from there
6491 if ( hooks && "get" in hooks ) {
6492 val = hooks.get( elem, true, extra );
6495 // Otherwise, if a way to get the computed value exists, use that
6496 if ( val === undefined ) {
6497 val = curCSS( elem, name, styles );
6500 // Convert "normal" to computed value
6501 if ( val === "normal" && name in cssNormalTransform ) {
6502 val = cssNormalTransform[ name ];
6505 // Make numeric if forced or a qualifier was provided and val looks numeric
6506 if ( extra === "" || extra ) {
6507 num = parseFloat( val );
6508 return extra === true || isFinite( num ) ? num || 0 : val;
6514 jQuery.each( [ "height", "width" ], function( i, name ) {
6515 jQuery.cssHooks[ name ] = {
6516 get: function( elem, computed, extra ) {
6519 // Certain elements can have dimension info if we invisibly show them
6520 // but it must have a current display style that would benefit
6521 return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
6523 // Support: Safari 8+
6524 // Table columns in Safari have non-zero offsetWidth & zero
6525 // getBoundingClientRect().width unless display is changed.
6526 // Support: IE <=11 only
6527 // Running getBoundingClientRect on a disconnected node
6528 // in IE throws an error.
6529 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
6530 swap( elem, cssShow, function() {
6531 return getWidthOrHeight( elem, name, extra );
6533 getWidthOrHeight( elem, name, extra );
6537 set: function( elem, value, extra ) {
6539 styles = extra && getStyles( elem ),
6540 subtract = extra && augmentWidthOrHeight(
6544 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6548 // Convert to pixels if value adjustment is needed
6549 if ( subtract && ( matches = rcssNum.exec( value ) ) &&
6550 ( matches[ 3 ] || "px" ) !== "px" ) {
6552 elem.style[ name ] = value;
6553 value = jQuery.css( elem, name );
6556 return setPositiveNumber( elem, value, subtract );
6561 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
6562 function( elem, computed ) {
6564 return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
6565 elem.getBoundingClientRect().left -
6566 swap( elem, { marginLeft: 0 }, function() {
6567 return elem.getBoundingClientRect().left;
6574 // These hooks are used by animate to expand properties
6579 }, function( prefix, suffix ) {
6580 jQuery.cssHooks[ prefix + suffix ] = {
6581 expand: function( value ) {
6585 // Assumes a single number if not a string
6586 parts = typeof value === "string" ? value.split( " " ) : [ value ];
6588 for ( ; i < 4; i++ ) {
6589 expanded[ prefix + cssExpand[ i ] + suffix ] =
6590 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6597 if ( !rmargin.test( prefix ) ) {
6598 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6603 css: function( name, value ) {
6604 return access( this, function( elem, name, value ) {
6609 if ( jQuery.isArray( name ) ) {
6610 styles = getStyles( elem );
6613 for ( ; i < len; i++ ) {
6614 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6620 return value !== undefined ?
6621 jQuery.style( elem, name, value ) :
6622 jQuery.css( elem, name );
6623 }, name, value, arguments.length > 1 );
6628 function Tween( elem, options, prop, end, easing ) {
6629 return new Tween.prototype.init( elem, options, prop, end, easing );
6631 jQuery.Tween = Tween;
6635 init: function( elem, options, prop, end, easing, unit ) {
6638 this.easing = easing || jQuery.easing._default;
6639 this.options = options;
6640 this.start = this.now = this.cur();
6642 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
6645 var hooks = Tween.propHooks[ this.prop ];
6647 return hooks && hooks.get ?
6649 Tween.propHooks._default.get( this );
6651 run: function( percent ) {
6653 hooks = Tween.propHooks[ this.prop ];
6655 if ( this.options.duration ) {
6656 this.pos = eased = jQuery.easing[ this.easing ](
6657 percent, this.options.duration * percent, 0, 1, this.options.duration
6660 this.pos = eased = percent;
6662 this.now = ( this.end - this.start ) * eased + this.start;
6664 if ( this.options.step ) {
6665 this.options.step.call( this.elem, this.now, this );
6668 if ( hooks && hooks.set ) {
6671 Tween.propHooks._default.set( this );
6677 Tween.prototype.init.prototype = Tween.prototype;
6681 get: function( tween ) {
6684 // Use a property on the element directly when it is not a DOM element,
6685 // or when there is no matching style property that exists.
6686 if ( tween.elem.nodeType !== 1 ||
6687 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
6688 return tween.elem[ tween.prop ];
6691 // Passing an empty string as a 3rd parameter to .css will automatically
6692 // attempt a parseFloat and fallback to a string if the parse fails.
6693 // Simple values such as "10px" are parsed to Float;
6694 // complex values such as "rotate(1rad)" are returned as-is.
6695 result = jQuery.css( tween.elem, tween.prop, "" );
6697 // Empty strings, null, undefined and "auto" are converted to 0.
6698 return !result || result === "auto" ? 0 : result;
6700 set: function( tween ) {
6702 // Use step hook for back compat.
6703 // Use cssHook if its there.
6704 // Use .style if available and use plain properties where available.
6705 if ( jQuery.fx.step[ tween.prop ] ) {
6706 jQuery.fx.step[ tween.prop ]( tween );
6707 } else if ( tween.elem.nodeType === 1 &&
6708 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
6709 jQuery.cssHooks[ tween.prop ] ) ) {
6710 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
6712 tween.elem[ tween.prop ] = tween.now;
6718 // Support: IE <=9 only
6719 // Panic based approach to setting things on disconnected nodes
6720 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
6721 set: function( tween ) {
6722 if ( tween.elem.nodeType && tween.elem.parentNode ) {
6723 tween.elem[ tween.prop ] = tween.now;
6729 linear: function( p ) {
6732 swing: function( p ) {
6733 return 0.5 - Math.cos( p * Math.PI ) / 2;
6738 jQuery.fx = Tween.prototype.init;
6740 // Back compat <1.8 extension point
6741 jQuery.fx.step = {};
6748 rfxtypes = /^(?:toggle|show|hide)$/,
6749 rrun = /queueHooks$/;
6753 window.requestAnimationFrame( raf );
6758 // Animations created synchronously will run synchronously
6759 function createFxNow() {
6760 window.setTimeout( function() {
6763 return ( fxNow = jQuery.now() );
6766 // Generate parameters to create a standard animation
6767 function genFx( type, includeWidth ) {
6770 attrs = { height: type };
6772 // If we include width, step value is 1 to do all cssExpand values,
6773 // otherwise step value is 2 to skip over Left and Right
6774 includeWidth = includeWidth ? 1 : 0;
6775 for ( ; i < 4; i += 2 - includeWidth ) {
6776 which = cssExpand[ i ];
6777 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
6780 if ( includeWidth ) {
6781 attrs.opacity = attrs.width = type;
6787 function createTween( value, prop, animation ) {
6789 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
6791 length = collection.length;
6792 for ( ; index < length; index++ ) {
6793 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
6795 // We're done with this property
6801 function defaultPrefilter( elem, props, opts ) {
6802 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
6803 isBox = "width" in props || "height" in props,
6807 hidden = elem.nodeType && isHiddenWithinTree( elem ),
6808 dataShow = dataPriv.get( elem, "fxshow" );
6810 // Queue-skipping animations hijack the fx hooks
6811 if ( !opts.queue ) {
6812 hooks = jQuery._queueHooks( elem, "fx" );
6813 if ( hooks.unqueued == null ) {
6815 oldfire = hooks.empty.fire;
6816 hooks.empty.fire = function() {
6817 if ( !hooks.unqueued ) {
6824 anim.always( function() {
6826 // Ensure the complete handler is called before this completes
6827 anim.always( function() {
6829 if ( !jQuery.queue( elem, "fx" ).length ) {
6836 // Detect show/hide animations
6837 for ( prop in props ) {
6838 value = props[ prop ];
6839 if ( rfxtypes.test( value ) ) {
6840 delete props[ prop ];
6841 toggle = toggle || value === "toggle";
6842 if ( value === ( hidden ? "hide" : "show" ) ) {
6844 // Pretend to be hidden if this is a "show" and
6845 // there is still data from a stopped show/hide
6846 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
6849 // Ignore all other no-op show/hide data
6854 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
6858 // Bail out if this is a no-op like .hide().hide()
6859 propTween = !jQuery.isEmptyObject( props );
6860 if ( !propTween && jQuery.isEmptyObject( orig ) ) {
6864 // Restrict "overflow" and "display" styles during box animations
6865 if ( isBox && elem.nodeType === 1 ) {
6867 // Support: IE <=9 - 11, Edge 12 - 13
6868 // Record all 3 overflow attributes because IE does not infer the shorthand
6869 // from identically-valued overflowX and overflowY
6870 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
6872 // Identify a display type, preferring old show/hide data over the CSS cascade
6873 restoreDisplay = dataShow && dataShow.display;
6874 if ( restoreDisplay == null ) {
6875 restoreDisplay = dataPriv.get( elem, "display" );
6877 display = jQuery.css( elem, "display" );
6878 if ( display === "none" ) {
6879 if ( restoreDisplay ) {
6880 display = restoreDisplay;
6883 // Get nonempty value(s) by temporarily forcing visibility
6884 showHide( [ elem ], true );
6885 restoreDisplay = elem.style.display || restoreDisplay;
6886 display = jQuery.css( elem, "display" );
6887 showHide( [ elem ] );
6891 // Animate inline elements as inline-block
6892 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
6893 if ( jQuery.css( elem, "float" ) === "none" ) {
6895 // Restore the original display value at the end of pure show/hide animations
6897 anim.done( function() {
6898 style.display = restoreDisplay;
6900 if ( restoreDisplay == null ) {
6901 display = style.display;
6902 restoreDisplay = display === "none" ? "" : display;
6905 style.display = "inline-block";
6910 if ( opts.overflow ) {
6911 style.overflow = "hidden";
6912 anim.always( function() {
6913 style.overflow = opts.overflow[ 0 ];
6914 style.overflowX = opts.overflow[ 1 ];
6915 style.overflowY = opts.overflow[ 2 ];
6919 // Implement show/hide animations
6921 for ( prop in orig ) {
6923 // General show/hide setup for this element animation
6926 if ( "hidden" in dataShow ) {
6927 hidden = dataShow.hidden;
6930 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
6933 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
6935 dataShow.hidden = !hidden;
6938 // Show elements before animating them
6940 showHide( [ elem ], true );
6943 /* eslint-disable no-loop-func */
6945 anim.done( function() {
6947 /* eslint-enable no-loop-func */
6949 // The final step of a "hide" animation is actually hiding the element
6951 showHide( [ elem ] );
6953 dataPriv.remove( elem, "fxshow" );
6954 for ( prop in orig ) {
6955 jQuery.style( elem, prop, orig[ prop ] );
6960 // Per-property setup
6961 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
6962 if ( !( prop in dataShow ) ) {
6963 dataShow[ prop ] = propTween.start;
6965 propTween.end = propTween.start;
6966 propTween.start = 0;
6972 function propFilter( props, specialEasing ) {
6973 var index, name, easing, value, hooks;
6975 // camelCase, specialEasing and expand cssHook pass
6976 for ( index in props ) {
6977 name = jQuery.camelCase( index );
6978 easing = specialEasing[ name ];
6979 value = props[ index ];
6980 if ( jQuery.isArray( value ) ) {
6981 easing = value[ 1 ];
6982 value = props[ index ] = value[ 0 ];
6985 if ( index !== name ) {
6986 props[ name ] = value;
6987 delete props[ index ];
6990 hooks = jQuery.cssHooks[ name ];
6991 if ( hooks && "expand" in hooks ) {
6992 value = hooks.expand( value );
6993 delete props[ name ];
6995 // Not quite $.extend, this won't overwrite existing keys.
6996 // Reusing 'index' because we have the correct "name"
6997 for ( index in value ) {
6998 if ( !( index in props ) ) {
6999 props[ index ] = value[ index ];
7000 specialEasing[ index ] = easing;
7004 specialEasing[ name ] = easing;
7009 function Animation( elem, properties, options ) {
7013 length = Animation.prefilters.length,
7014 deferred = jQuery.Deferred().always( function() {
7016 // Don't match elem in the :animated selector
7023 var currentTime = fxNow || createFxNow(),
7024 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7026 // Support: Android 2.3 only
7027 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
7028 temp = remaining / animation.duration || 0,
7031 length = animation.tweens.length;
7033 for ( ; index < length; index++ ) {
7034 animation.tweens[ index ].run( percent );
7037 deferred.notifyWith( elem, [ animation, percent, remaining ] );
7039 if ( percent < 1 && length ) {
7042 deferred.resolveWith( elem, [ animation ] );
7046 animation = deferred.promise( {
7048 props: jQuery.extend( {}, properties ),
7049 opts: jQuery.extend( true, {
7051 easing: jQuery.easing._default
7053 originalProperties: properties,
7054 originalOptions: options,
7055 startTime: fxNow || createFxNow(),
7056 duration: options.duration,
7058 createTween: function( prop, end ) {
7059 var tween = jQuery.Tween( elem, animation.opts, prop, end,
7060 animation.opts.specialEasing[ prop ] || animation.opts.easing );
7061 animation.tweens.push( tween );
7064 stop: function( gotoEnd ) {
7067 // If we are going to the end, we want to run all the tweens
7068 // otherwise we skip this part
7069 length = gotoEnd ? animation.tweens.length : 0;
7074 for ( ; index < length; index++ ) {
7075 animation.tweens[ index ].run( 1 );
7078 // Resolve when we played the last frame; otherwise, reject
7080 deferred.notifyWith( elem, [ animation, 1, 0 ] );
7081 deferred.resolveWith( elem, [ animation, gotoEnd ] );
7083 deferred.rejectWith( elem, [ animation, gotoEnd ] );
7088 props = animation.props;
7090 propFilter( props, animation.opts.specialEasing );
7092 for ( ; index < length; index++ ) {
7093 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
7095 if ( jQuery.isFunction( result.stop ) ) {
7096 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
7097 jQuery.proxy( result.stop, result );
7103 jQuery.map( props, createTween, animation );
7105 if ( jQuery.isFunction( animation.opts.start ) ) {
7106 animation.opts.start.call( elem, animation );
7110 jQuery.extend( tick, {
7113 queue: animation.opts.queue
7117 // attach callbacks from options
7118 return animation.progress( animation.opts.progress )
7119 .done( animation.opts.done, animation.opts.complete )
7120 .fail( animation.opts.fail )
7121 .always( animation.opts.always );
7124 jQuery.Animation = jQuery.extend( Animation, {
7127 "*": [ function( prop, value ) {
7128 var tween = this.createTween( prop, value );
7129 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
7134 tweener: function( props, callback ) {
7135 if ( jQuery.isFunction( props ) ) {
7139 props = props.match( rnothtmlwhite );
7144 length = props.length;
7146 for ( ; index < length; index++ ) {
7147 prop = props[ index ];
7148 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
7149 Animation.tweeners[ prop ].unshift( callback );
7153 prefilters: [ defaultPrefilter ],
7155 prefilter: function( callback, prepend ) {
7157 Animation.prefilters.unshift( callback );
7159 Animation.prefilters.push( callback );
7164 jQuery.speed = function( speed, easing, fn ) {
7165 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7166 complete: fn || !fn && easing ||
7167 jQuery.isFunction( speed ) && speed,
7169 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
7172 // Go to the end state if fx are off or if document is hidden
7173 if ( jQuery.fx.off || document.hidden ) {
7177 if ( typeof opt.duration !== "number" ) {
7178 if ( opt.duration in jQuery.fx.speeds ) {
7179 opt.duration = jQuery.fx.speeds[ opt.duration ];
7182 opt.duration = jQuery.fx.speeds._default;
7187 // Normalize opt.queue - true/undefined/null -> "fx"
7188 if ( opt.queue == null || opt.queue === true ) {
7193 opt.old = opt.complete;
7195 opt.complete = function() {
7196 if ( jQuery.isFunction( opt.old ) ) {
7197 opt.old.call( this );
7201 jQuery.dequeue( this, opt.queue );
7209 fadeTo: function( speed, to, easing, callback ) {
7211 // Show any hidden elements after setting opacity to 0
7212 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
7214 // Animate to the value specified
7215 .end().animate( { opacity: to }, speed, easing, callback );
7217 animate: function( prop, speed, easing, callback ) {
7218 var empty = jQuery.isEmptyObject( prop ),
7219 optall = jQuery.speed( speed, easing, callback ),
7220 doAnimation = function() {
7222 // Operate on a copy of prop so per-property easing won't be lost
7223 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7225 // Empty animations, or finishing resolves immediately
7226 if ( empty || dataPriv.get( this, "finish" ) ) {
7230 doAnimation.finish = doAnimation;
7232 return empty || optall.queue === false ?
7233 this.each( doAnimation ) :
7234 this.queue( optall.queue, doAnimation );
7236 stop: function( type, clearQueue, gotoEnd ) {
7237 var stopQueue = function( hooks ) {
7238 var stop = hooks.stop;
7243 if ( typeof type !== "string" ) {
7244 gotoEnd = clearQueue;
7248 if ( clearQueue && type !== false ) {
7249 this.queue( type || "fx", [] );
7252 return this.each( function() {
7254 index = type != null && type + "queueHooks",
7255 timers = jQuery.timers,
7256 data = dataPriv.get( this );
7259 if ( data[ index ] && data[ index ].stop ) {
7260 stopQueue( data[ index ] );
7263 for ( index in data ) {
7264 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7265 stopQueue( data[ index ] );
7270 for ( index = timers.length; index--; ) {
7271 if ( timers[ index ].elem === this &&
7272 ( type == null || timers[ index ].queue === type ) ) {
7274 timers[ index ].anim.stop( gotoEnd );
7276 timers.splice( index, 1 );
7280 // Start the next in the queue if the last step wasn't forced.
7281 // Timers currently will call their complete callbacks, which
7282 // will dequeue but only if they were gotoEnd.
7283 if ( dequeue || !gotoEnd ) {
7284 jQuery.dequeue( this, type );
7288 finish: function( type ) {
7289 if ( type !== false ) {
7290 type = type || "fx";
7292 return this.each( function() {
7294 data = dataPriv.get( this ),
7295 queue = data[ type + "queue" ],
7296 hooks = data[ type + "queueHooks" ],
7297 timers = jQuery.timers,
7298 length = queue ? queue.length : 0;
7300 // Enable finishing flag on private data
7303 // Empty the queue first
7304 jQuery.queue( this, type, [] );
7306 if ( hooks && hooks.stop ) {
7307 hooks.stop.call( this, true );
7310 // Look for any active animations, and finish them
7311 for ( index = timers.length; index--; ) {
7312 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
7313 timers[ index ].anim.stop( true );
7314 timers.splice( index, 1 );
7318 // Look for any animations in the old queue and finish them
7319 for ( index = 0; index < length; index++ ) {
7320 if ( queue[ index ] && queue[ index ].finish ) {
7321 queue[ index ].finish.call( this );
7325 // Turn off finishing flag
7331 jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
7332 var cssFn = jQuery.fn[ name ];
7333 jQuery.fn[ name ] = function( speed, easing, callback ) {
7334 return speed == null || typeof speed === "boolean" ?
7335 cssFn.apply( this, arguments ) :
7336 this.animate( genFx( name, true ), speed, easing, callback );
7340 // Generate shortcuts for custom animations
7342 slideDown: genFx( "show" ),
7343 slideUp: genFx( "hide" ),
7344 slideToggle: genFx( "toggle" ),
7345 fadeIn: { opacity: "show" },
7346 fadeOut: { opacity: "hide" },
7347 fadeToggle: { opacity: "toggle" }
7348 }, function( name, props ) {
7349 jQuery.fn[ name ] = function( speed, easing, callback ) {
7350 return this.animate( props, speed, easing, callback );
7355 jQuery.fx.tick = function() {
7358 timers = jQuery.timers;
7360 fxNow = jQuery.now();
7362 for ( ; i < timers.length; i++ ) {
7363 timer = timers[ i ];
7365 // Checks the timer has not already been removed
7366 if ( !timer() && timers[ i ] === timer ) {
7367 timers.splice( i--, 1 );
7371 if ( !timers.length ) {
7377 jQuery.fx.timer = function( timer ) {
7378 jQuery.timers.push( timer );
7382 jQuery.timers.pop();
7386 jQuery.fx.interval = 13;
7387 jQuery.fx.start = function() {
7389 timerId = window.requestAnimationFrame ?
7390 window.requestAnimationFrame( raf ) :
7391 window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
7395 jQuery.fx.stop = function() {
7396 if ( window.cancelAnimationFrame ) {
7397 window.cancelAnimationFrame( timerId );
7399 window.clearInterval( timerId );
7405 jQuery.fx.speeds = {
7414 // Based off of the plugin by Clint Helfers, with permission.
7415 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
7416 jQuery.fn.delay = function( time, type ) {
7417 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
7418 type = type || "fx";
7420 return this.queue( type, function( next, hooks ) {
7421 var timeout = window.setTimeout( next, time );
7422 hooks.stop = function() {
7423 window.clearTimeout( timeout );
7430 var input = document.createElement( "input" ),
7431 select = document.createElement( "select" ),
7432 opt = select.appendChild( document.createElement( "option" ) );
7434 input.type = "checkbox";
7436 // Support: Android <=4.3 only
7437 // Default value for a checkbox should be "on"
7438 support.checkOn = input.value !== "";
7440 // Support: IE <=11 only
7441 // Must access selectedIndex to make default options select
7442 support.optSelected = opt.selected;
7444 // Support: IE <=11 only
7445 // An input loses its value after becoming a radio
7446 input = document.createElement( "input" );
7448 input.type = "radio";
7449 support.radioValue = input.value === "t";
7454 attrHandle = jQuery.expr.attrHandle;
7457 attr: function( name, value ) {
7458 return access( this, jQuery.attr, name, value, arguments.length > 1 );
7461 removeAttr: function( name ) {
7462 return this.each( function() {
7463 jQuery.removeAttr( this, name );
7469 attr: function( elem, name, value ) {
7471 nType = elem.nodeType;
7473 // Don't get/set attributes on text, comment and attribute nodes
7474 if ( nType === 3 || nType === 8 || nType === 2 ) {
7478 // Fallback to prop when attributes are not supported
7479 if ( typeof elem.getAttribute === "undefined" ) {
7480 return jQuery.prop( elem, name, value );
7483 // Attribute hooks are determined by the lowercase version
7484 // Grab necessary hook if one is defined
7485 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7486 hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
7487 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
7490 if ( value !== undefined ) {
7491 if ( value === null ) {
7492 jQuery.removeAttr( elem, name );
7496 if ( hooks && "set" in hooks &&
7497 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
7501 elem.setAttribute( name, value + "" );
7505 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
7509 ret = jQuery.find.attr( elem, name );
7511 // Non-existent attributes return null, we normalize to undefined
7512 return ret == null ? undefined : ret;
7517 set: function( elem, value ) {
7518 if ( !support.radioValue && value === "radio" &&
7519 jQuery.nodeName( elem, "input" ) ) {
7520 var val = elem.value;
7521 elem.setAttribute( "type", value );
7531 removeAttr: function( elem, value ) {
7535 // Attribute names can contain non-HTML whitespace characters
7536 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
7537 attrNames = value && value.match( rnothtmlwhite );
7539 if ( attrNames && elem.nodeType === 1 ) {
7540 while ( ( name = attrNames[ i++ ] ) ) {
7541 elem.removeAttribute( name );
7547 // Hooks for boolean attributes
7549 set: function( elem, value, name ) {
7550 if ( value === false ) {
7552 // Remove boolean attributes when set to false
7553 jQuery.removeAttr( elem, name );
7555 elem.setAttribute( name, name );
7561 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
7562 var getter = attrHandle[ name ] || jQuery.find.attr;
7564 attrHandle[ name ] = function( elem, name, isXML ) {
7566 lowercaseName = name.toLowerCase();
7570 // Avoid an infinite loop by temporarily removing this function from the getter
7571 handle = attrHandle[ lowercaseName ];
7572 attrHandle[ lowercaseName ] = ret;
7573 ret = getter( elem, name, isXML ) != null ?
7576 attrHandle[ lowercaseName ] = handle;
7585 var rfocusable = /^(?:input|select|textarea|button)$/i,
7586 rclickable = /^(?:a|area)$/i;
7589 prop: function( name, value ) {
7590 return access( this, jQuery.prop, name, value, arguments.length > 1 );
7593 removeProp: function( name ) {
7594 return this.each( function() {
7595 delete this[ jQuery.propFix[ name ] || name ];
7601 prop: function( elem, name, value ) {
7603 nType = elem.nodeType;
7605 // Don't get/set properties on text, comment and attribute nodes
7606 if ( nType === 3 || nType === 8 || nType === 2 ) {
7610 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7612 // Fix name and attach hooks
7613 name = jQuery.propFix[ name ] || name;
7614 hooks = jQuery.propHooks[ name ];
7617 if ( value !== undefined ) {
7618 if ( hooks && "set" in hooks &&
7619 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
7623 return ( elem[ name ] = value );
7626 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
7630 return elem[ name ];
7635 get: function( elem ) {
7637 // Support: IE <=9 - 11 only
7638 // elem.tabIndex doesn't always return the
7639 // correct value when it hasn't been explicitly set
7640 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
7641 // Use proper attribute retrieval(#12072)
7642 var tabindex = jQuery.find.attr( elem, "tabindex" );
7645 return parseInt( tabindex, 10 );
7649 rfocusable.test( elem.nodeName ) ||
7650 rclickable.test( elem.nodeName ) &&
7663 "class": "className"
7667 // Support: IE <=11 only
7668 // Accessing the selectedIndex property
7669 // forces the browser to respect setting selected
7671 // The getter ensures a default option is selected
7672 // when in an optgroup
7673 // eslint rule "no-unused-expressions" is disabled for this code
7674 // since it considers such accessions noop
7675 if ( !support.optSelected ) {
7676 jQuery.propHooks.selected = {
7677 get: function( elem ) {
7679 /* eslint no-unused-expressions: "off" */
7681 var parent = elem.parentNode;
7682 if ( parent && parent.parentNode ) {
7683 parent.parentNode.selectedIndex;
7687 set: function( elem ) {
7689 /* eslint no-unused-expressions: "off" */
7691 var parent = elem.parentNode;
7693 parent.selectedIndex;
7695 if ( parent.parentNode ) {
7696 parent.parentNode.selectedIndex;
7715 jQuery.propFix[ this.toLowerCase() ] = this;
7721 // Strip and collapse whitespace according to HTML spec
7722 // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace
7723 function stripAndCollapse( value ) {
7724 var tokens = value.match( rnothtmlwhite ) || [];
7725 return tokens.join( " " );
7729 function getClass( elem ) {
7730 return elem.getAttribute && elem.getAttribute( "class" ) || "";
7734 addClass: function( value ) {
7735 var classes, elem, cur, curValue, clazz, j, finalValue,
7738 if ( jQuery.isFunction( value ) ) {
7739 return this.each( function( j ) {
7740 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
7744 if ( typeof value === "string" && value ) {
7745 classes = value.match( rnothtmlwhite ) || [];
7747 while ( ( elem = this[ i++ ] ) ) {
7748 curValue = getClass( elem );
7749 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
7753 while ( ( clazz = classes[ j++ ] ) ) {
7754 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
7759 // Only assign if different to avoid unneeded rendering.
7760 finalValue = stripAndCollapse( cur );
7761 if ( curValue !== finalValue ) {
7762 elem.setAttribute( "class", finalValue );
7771 removeClass: function( value ) {
7772 var classes, elem, cur, curValue, clazz, j, finalValue,
7775 if ( jQuery.isFunction( value ) ) {
7776 return this.each( function( j ) {
7777 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
7781 if ( !arguments.length ) {
7782 return this.attr( "class", "" );
7785 if ( typeof value === "string" && value ) {
7786 classes = value.match( rnothtmlwhite ) || [];
7788 while ( ( elem = this[ i++ ] ) ) {
7789 curValue = getClass( elem );
7791 // This expression is here for better compressibility (see addClass)
7792 cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
7796 while ( ( clazz = classes[ j++ ] ) ) {
7798 // Remove *all* instances
7799 while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
7800 cur = cur.replace( " " + clazz + " ", " " );
7804 // Only assign if different to avoid unneeded rendering.
7805 finalValue = stripAndCollapse( cur );
7806 if ( curValue !== finalValue ) {
7807 elem.setAttribute( "class", finalValue );
7816 toggleClass: function( value, stateVal ) {
7817 var type = typeof value;
7819 if ( typeof stateVal === "boolean" && type === "string" ) {
7820 return stateVal ? this.addClass( value ) : this.removeClass( value );
7823 if ( jQuery.isFunction( value ) ) {
7824 return this.each( function( i ) {
7825 jQuery( this ).toggleClass(
7826 value.call( this, i, getClass( this ), stateVal ),
7832 return this.each( function() {
7833 var className, i, self, classNames;
7835 if ( type === "string" ) {
7837 // Toggle individual class names
7839 self = jQuery( this );
7840 classNames = value.match( rnothtmlwhite ) || [];
7842 while ( ( className = classNames[ i++ ] ) ) {
7844 // Check each className given, space separated list
7845 if ( self.hasClass( className ) ) {
7846 self.removeClass( className );
7848 self.addClass( className );
7852 // Toggle whole class name
7853 } else if ( value === undefined || type === "boolean" ) {
7854 className = getClass( this );
7857 // Store className if set
7858 dataPriv.set( this, "__className__", className );
7861 // If the element has a class name or if we're passed `false`,
7862 // then remove the whole classname (if there was one, the above saved it).
7863 // Otherwise bring back whatever was previously saved (if anything),
7864 // falling back to the empty string if nothing was stored.
7865 if ( this.setAttribute ) {
7866 this.setAttribute( "class",
7867 className || value === false ?
7869 dataPriv.get( this, "__className__" ) || ""
7876 hasClass: function( selector ) {
7877 var className, elem,
7880 className = " " + selector + " ";
7881 while ( ( elem = this[ i++ ] ) ) {
7882 if ( elem.nodeType === 1 &&
7883 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
7895 var rreturn = /\r/g;
7898 val: function( value ) {
7899 var hooks, ret, isFunction,
7902 if ( !arguments.length ) {
7904 hooks = jQuery.valHooks[ elem.type ] ||
7905 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
7909 ( ret = hooks.get( elem, "value" ) ) !== undefined
7916 // Handle most common string cases
7917 if ( typeof ret === "string" ) {
7918 return ret.replace( rreturn, "" );
7921 // Handle cases where value is null/undef or number
7922 return ret == null ? "" : ret;
7928 isFunction = jQuery.isFunction( value );
7930 return this.each( function( i ) {
7933 if ( this.nodeType !== 1 ) {
7938 val = value.call( this, i, jQuery( this ).val() );
7943 // Treat null/undefined as ""; convert numbers to string
7944 if ( val == null ) {
7947 } else if ( typeof val === "number" ) {
7950 } else if ( jQuery.isArray( val ) ) {
7951 val = jQuery.map( val, function( value ) {
7952 return value == null ? "" : value + "";
7956 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7958 // If set returns undefined, fall back to normal setting
7959 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
7969 get: function( elem ) {
7971 var val = jQuery.find.attr( elem, "value" );
7972 return val != null ?
7975 // Support: IE <=10 - 11 only
7976 // option.text throws exceptions (#14686, #14858)
7977 // Strip and collapse whitespace
7978 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
7979 stripAndCollapse( jQuery.text( elem ) );
7983 get: function( elem ) {
7984 var value, option, i,
7985 options = elem.options,
7986 index = elem.selectedIndex,
7987 one = elem.type === "select-one",
7988 values = one ? null : [],
7989 max = one ? index + 1 : options.length;
7995 i = one ? index : 0;
7998 // Loop through all the selected options
7999 for ( ; i < max; i++ ) {
8000 option = options[ i ];
8002 // Support: IE <=9 only
8003 // IE8-9 doesn't update selected after form reset (#2551)
8004 if ( ( option.selected || i === index ) &&
8006 // Don't return options that are disabled or in a disabled optgroup
8008 ( !option.parentNode.disabled ||
8009 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
8011 // Get the specific value for the option
8012 value = jQuery( option ).val();
8014 // We don't need an array for one selects
8019 // Multi-Selects return an array
8020 values.push( value );
8027 set: function( elem, value ) {
8028 var optionSet, option,
8029 options = elem.options,
8030 values = jQuery.makeArray( value ),
8034 option = options[ i ];
8036 /* eslint-disable no-cond-assign */
8038 if ( option.selected =
8039 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
8044 /* eslint-enable no-cond-assign */
8047 // Force browsers to behave consistently when non-matching value is set
8049 elem.selectedIndex = -1;
8057 // Radios and checkboxes getter/setter
8058 jQuery.each( [ "radio", "checkbox" ], function() {
8059 jQuery.valHooks[ this ] = {
8060 set: function( elem, value ) {
8061 if ( jQuery.isArray( value ) ) {
8062 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
8066 if ( !support.checkOn ) {
8067 jQuery.valHooks[ this ].get = function( elem ) {
8068 return elem.getAttribute( "value" ) === null ? "on" : elem.value;
8076 // Return jQuery for attributes-only inclusion
8079 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
8081 jQuery.extend( jQuery.event, {
8083 trigger: function( event, data, elem, onlyHandlers ) {
8085 var i, cur, tmp, bubbleType, ontype, handle, special,
8086 eventPath = [ elem || document ],
8087 type = hasOwn.call( event, "type" ) ? event.type : event,
8088 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
8090 cur = tmp = elem = elem || document;
8092 // Don't do events on text and comment nodes
8093 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
8097 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8098 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
8102 if ( type.indexOf( "." ) > -1 ) {
8104 // Namespaced trigger; create a regexp to match event type in handle()
8105 namespaces = type.split( "." );
8106 type = namespaces.shift();
8109 ontype = type.indexOf( ":" ) < 0 && "on" + type;
8111 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8112 event = event[ jQuery.expando ] ?
8114 new jQuery.Event( type, typeof event === "object" && event );
8116 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8117 event.isTrigger = onlyHandlers ? 2 : 3;
8118 event.namespace = namespaces.join( "." );
8119 event.rnamespace = event.namespace ?
8120 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8123 // Clean up the event in case it is being reused
8124 event.result = undefined;
8125 if ( !event.target ) {
8126 event.target = elem;
8129 // Clone any incoming data and prepend the event, creating the handler arg list
8130 data = data == null ?
8132 jQuery.makeArray( data, [ event ] );
8134 // Allow special events to draw outside the lines
8135 special = jQuery.event.special[ type ] || {};
8136 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
8140 // Determine event propagation path in advance, per W3C events spec (#9951)
8141 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
8142 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
8144 bubbleType = special.delegateType || type;
8145 if ( !rfocusMorph.test( bubbleType + type ) ) {
8146 cur = cur.parentNode;
8148 for ( ; cur; cur = cur.parentNode ) {
8149 eventPath.push( cur );
8153 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8154 if ( tmp === ( elem.ownerDocument || document ) ) {
8155 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
8159 // Fire handlers on the event path
8161 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
8163 event.type = i > 1 ?
8165 special.bindType || type;
8168 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
8169 dataPriv.get( cur, "handle" );
8171 handle.apply( cur, data );
8175 handle = ontype && cur[ ontype ];
8176 if ( handle && handle.apply && acceptData( cur ) ) {
8177 event.result = handle.apply( cur, data );
8178 if ( event.result === false ) {
8179 event.preventDefault();
8185 // If nobody prevented the default action, do it now
8186 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
8188 if ( ( !special._default ||
8189 special._default.apply( eventPath.pop(), data ) === false ) &&
8190 acceptData( elem ) ) {
8192 // Call a native DOM method on the target with the same name as the event.
8193 // Don't do default actions on window, that's where global variables be (#6170)
8194 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
8196 // Don't re-trigger an onFOO event when we call its FOO() method
8197 tmp = elem[ ontype ];
8200 elem[ ontype ] = null;
8203 // Prevent re-triggering of the same event, since we already bubbled it above
8204 jQuery.event.triggered = type;
8206 jQuery.event.triggered = undefined;
8209 elem[ ontype ] = tmp;
8215 return event.result;
8218 // Piggyback on a donor event to simulate a different one
8219 // Used only for `focus(in | out)` events
8220 simulate: function( type, elem, event ) {
8221 var e = jQuery.extend(
8230 jQuery.event.trigger( e, null, elem );
8237 trigger: function( type, data ) {
8238 return this.each( function() {
8239 jQuery.event.trigger( type, data, this );
8242 triggerHandler: function( type, data ) {
8243 var elem = this[ 0 ];
8245 return jQuery.event.trigger( type, data, elem, true );
8251 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
8252 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
8253 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
8254 function( i, name ) {
8256 // Handle event binding
8257 jQuery.fn[ name ] = function( data, fn ) {
8258 return arguments.length > 0 ?
8259 this.on( name, null, data, fn ) :
8260 this.trigger( name );
8265 hover: function( fnOver, fnOut ) {
8266 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
8273 support.focusin = "onfocusin" in window;
8276 // Support: Firefox <=44
8277 // Firefox doesn't have focus(in | out) events
8278 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
8280 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
8281 // focus(in | out) events fire after focus & blur events,
8282 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
8283 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
8284 if ( !support.focusin ) {
8285 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
8287 // Attach a single capturing handler on the document while someone wants focusin/focusout
8288 var handler = function( event ) {
8289 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
8292 jQuery.event.special[ fix ] = {
8294 var doc = this.ownerDocument || this,
8295 attaches = dataPriv.access( doc, fix );
8298 doc.addEventListener( orig, handler, true );
8300 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
8302 teardown: function() {
8303 var doc = this.ownerDocument || this,
8304 attaches = dataPriv.access( doc, fix ) - 1;
8307 doc.removeEventListener( orig, handler, true );
8308 dataPriv.remove( doc, fix );
8311 dataPriv.access( doc, fix, attaches );
8317 var location = window.location;
8319 var nonce = jQuery.now();
8321 var rquery = ( /\?/ );
8325 // Cross-browser xml parsing
8326 jQuery.parseXML = function( data ) {
8328 if ( !data || typeof data !== "string" ) {
8332 // Support: IE 9 - 11 only
8333 // IE throws on parseFromString with invalid input.
8335 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
8340 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
8341 jQuery.error( "Invalid XML: " + data );
8350 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
8351 rsubmittable = /^(?:input|select|textarea|keygen)/i;
8353 function buildParams( prefix, obj, traditional, add ) {
8356 if ( jQuery.isArray( obj ) ) {
8358 // Serialize array item.
8359 jQuery.each( obj, function( i, v ) {
8360 if ( traditional || rbracket.test( prefix ) ) {
8362 // Treat each array item as a scalar.
8367 // Item is non-scalar (array or object), encode its numeric index.
8369 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
8377 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
8379 // Serialize object item.
8380 for ( name in obj ) {
8381 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
8386 // Serialize scalar item.
8391 // Serialize an array of form elements or a set of
8392 // key/values into a query string
8393 jQuery.param = function( a, traditional ) {
8396 add = function( key, valueOrFunction ) {
8398 // If value is a function, invoke it and use its return value
8399 var value = jQuery.isFunction( valueOrFunction ) ?
8403 s[ s.length ] = encodeURIComponent( key ) + "=" +
8404 encodeURIComponent( value == null ? "" : value );
8407 // If an array was passed in, assume that it is an array of form elements.
8408 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
8410 // Serialize the form elements
8411 jQuery.each( a, function() {
8412 add( this.name, this.value );
8417 // If traditional, encode the "old" way (the way 1.3.2 or older
8418 // did it), otherwise encode params recursively.
8419 for ( prefix in a ) {
8420 buildParams( prefix, a[ prefix ], traditional, add );
8424 // Return the resulting serialization
8425 return s.join( "&" );
8429 serialize: function() {
8430 return jQuery.param( this.serializeArray() );
8432 serializeArray: function() {
8433 return this.map( function() {
8435 // Can add propHook for "elements" to filter or add form elements
8436 var elements = jQuery.prop( this, "elements" );
8437 return elements ? jQuery.makeArray( elements ) : this;
8439 .filter( function() {
8440 var type = this.type;
8442 // Use .is( ":disabled" ) so that fieldset[disabled] works
8443 return this.name && !jQuery( this ).is( ":disabled" ) &&
8444 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
8445 ( this.checked || !rcheckableType.test( type ) );
8447 .map( function( i, elem ) {
8448 var val = jQuery( this ).val();
8450 if ( val == null ) {
8454 if ( jQuery.isArray( val ) ) {
8455 return jQuery.map( val, function( val ) {
8456 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8460 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8469 rantiCache = /([?&])_=[^&]*/,
8470 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
8472 // #7653, #8125, #8152: local protocol detection
8473 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8474 rnoContent = /^(?:GET|HEAD)$/,
8475 rprotocol = /^\/\//,
8478 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8479 * 2) These are called:
8480 * - BEFORE asking for a transport
8481 * - AFTER param serialization (s.data is a string if s.processData is true)
8482 * 3) key is the dataType
8483 * 4) the catchall symbol "*" can be used
8484 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8488 /* Transports bindings
8489 * 1) key is the dataType
8490 * 2) the catchall symbol "*" can be used
8491 * 3) selection will start with transport dataType and THEN go to "*" if needed
8495 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8496 allTypes = "*/".concat( "*" ),
8498 // Anchor tag for parsing the document origin
8499 originAnchor = document.createElement( "a" );
8500 originAnchor.href = location.href;
8502 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8503 function addToPrefiltersOrTransports( structure ) {
8505 // dataTypeExpression is optional and defaults to "*"
8506 return function( dataTypeExpression, func ) {
8508 if ( typeof dataTypeExpression !== "string" ) {
8509 func = dataTypeExpression;
8510 dataTypeExpression = "*";
8515 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
8517 if ( jQuery.isFunction( func ) ) {
8519 // For each dataType in the dataTypeExpression
8520 while ( ( dataType = dataTypes[ i++ ] ) ) {
8522 // Prepend if requested
8523 if ( dataType[ 0 ] === "+" ) {
8524 dataType = dataType.slice( 1 ) || "*";
8525 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
8529 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
8536 // Base inspection function for prefilters and transports
8537 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
8540 seekingTransport = ( structure === transports );
8542 function inspect( dataType ) {
8544 inspected[ dataType ] = true;
8545 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
8546 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
8547 if ( typeof dataTypeOrTransport === "string" &&
8548 !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
8550 options.dataTypes.unshift( dataTypeOrTransport );
8551 inspect( dataTypeOrTransport );
8553 } else if ( seekingTransport ) {
8554 return !( selected = dataTypeOrTransport );
8560 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
8563 // A special extend for ajax options
8564 // that takes "flat" options (not to be deep extended)
8566 function ajaxExtend( target, src ) {
8568 flatOptions = jQuery.ajaxSettings.flatOptions || {};
8570 for ( key in src ) {
8571 if ( src[ key ] !== undefined ) {
8572 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
8576 jQuery.extend( true, target, deep );
8582 /* Handles responses to an ajax request:
8583 * - finds the right dataType (mediates between content-type and expected dataType)
8584 * - returns the corresponding response
8586 function ajaxHandleResponses( s, jqXHR, responses ) {
8588 var ct, type, finalDataType, firstDataType,
8589 contents = s.contents,
8590 dataTypes = s.dataTypes;
8592 // Remove auto dataType and get content-type in the process
8593 while ( dataTypes[ 0 ] === "*" ) {
8595 if ( ct === undefined ) {
8596 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
8600 // Check if we're dealing with a known content-type
8602 for ( type in contents ) {
8603 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8604 dataTypes.unshift( type );
8610 // Check to see if we have a response for the expected dataType
8611 if ( dataTypes[ 0 ] in responses ) {
8612 finalDataType = dataTypes[ 0 ];
8615 // Try convertible dataTypes
8616 for ( type in responses ) {
8617 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
8618 finalDataType = type;
8621 if ( !firstDataType ) {
8622 firstDataType = type;
8626 // Or just use first one
8627 finalDataType = finalDataType || firstDataType;
8630 // If we found a dataType
8631 // We add the dataType to the list if needed
8632 // and return the corresponding response
8633 if ( finalDataType ) {
8634 if ( finalDataType !== dataTypes[ 0 ] ) {
8635 dataTypes.unshift( finalDataType );
8637 return responses[ finalDataType ];
8641 /* Chain conversions given the request and the original response
8642 * Also sets the responseXXX fields on the jqXHR instance
8644 function ajaxConvert( s, response, jqXHR, isSuccess ) {
8645 var conv2, current, conv, tmp, prev,
8648 // Work with a copy of dataTypes in case we need to modify it for conversion
8649 dataTypes = s.dataTypes.slice();
8651 // Create converters map with lowercased keys
8652 if ( dataTypes[ 1 ] ) {
8653 for ( conv in s.converters ) {
8654 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8658 current = dataTypes.shift();
8660 // Convert to each sequential dataType
8663 if ( s.responseFields[ current ] ) {
8664 jqXHR[ s.responseFields[ current ] ] = response;
8667 // Apply the dataFilter if provided
8668 if ( !prev && isSuccess && s.dataFilter ) {
8669 response = s.dataFilter( response, s.dataType );
8673 current = dataTypes.shift();
8677 // There's only work to do if current dataType is non-auto
8678 if ( current === "*" ) {
8682 // Convert response if prev dataType is non-auto and differs from current
8683 } else if ( prev !== "*" && prev !== current ) {
8685 // Seek a direct converter
8686 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8688 // If none found, seek a pair
8690 for ( conv2 in converters ) {
8692 // If conv2 outputs current
8693 tmp = conv2.split( " " );
8694 if ( tmp[ 1 ] === current ) {
8696 // If prev can be converted to accepted input
8697 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8698 converters[ "* " + tmp[ 0 ] ];
8701 // Condense equivalence converters
8702 if ( conv === true ) {
8703 conv = converters[ conv2 ];
8705 // Otherwise, insert the intermediate dataType
8706 } else if ( converters[ conv2 ] !== true ) {
8708 dataTypes.unshift( tmp[ 1 ] );
8716 // Apply converter (if not an equivalence)
8717 if ( conv !== true ) {
8719 // Unless errors are allowed to bubble, catch and return them
8720 if ( conv && s.throws ) {
8721 response = conv( response );
8724 response = conv( response );
8727 state: "parsererror",
8728 error: conv ? e : "No conversion from " + prev + " to " + current
8737 return { state: "success", data: response };
8742 // Counter for holding the number of active queries
8745 // Last-Modified header cache for next request
8752 isLocal: rlocalProtocol.test( location.protocol ),
8756 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
8774 xml: "application/xml, text/xml",
8775 json: "application/json, text/javascript"
8786 text: "responseText",
8787 json: "responseJSON"
8791 // Keys separate source (or catchall "*") and destination types with a single space
8794 // Convert anything to text
8797 // Text to html (true = no transformation)
8800 // Evaluate text as a json expression
8801 "text json": JSON.parse,
8803 // Parse text as xml
8804 "text xml": jQuery.parseXML
8807 // For options that shouldn't be deep extended:
8808 // you can add your own custom options here if
8809 // and when you create one that shouldn't be
8810 // deep extended (see ajaxExtend)
8817 // Creates a full fledged settings object into target
8818 // with both ajaxSettings and settings fields.
8819 // If target is omitted, writes into ajaxSettings.
8820 ajaxSetup: function( target, settings ) {
8823 // Building a settings object
8824 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
8826 // Extending ajaxSettings
8827 ajaxExtend( jQuery.ajaxSettings, target );
8830 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
8831 ajaxTransport: addToPrefiltersOrTransports( transports ),
8834 ajax: function( url, options ) {
8836 // If url is an object, simulate pre-1.5 signature
8837 if ( typeof url === "object" ) {
8842 // Force options to be an object
8843 options = options || {};
8847 // URL without anti-cache param
8851 responseHeadersString,
8860 // Request state (becomes false upon send and true upon completion)
8863 // To know if global events are to be dispatched
8869 // uncached part of the url
8872 // Create the final options object
8873 s = jQuery.ajaxSetup( {}, options ),
8875 // Callbacks context
8876 callbackContext = s.context || s,
8878 // Context for global events is callbackContext if it is a DOM node or jQuery collection
8879 globalEventContext = s.context &&
8880 ( callbackContext.nodeType || callbackContext.jquery ) ?
8881 jQuery( callbackContext ) :
8885 deferred = jQuery.Deferred(),
8886 completeDeferred = jQuery.Callbacks( "once memory" ),
8888 // Status-dependent callbacks
8889 statusCode = s.statusCode || {},
8891 // Headers (they are sent all at once)
8892 requestHeaders = {},
8893 requestHeadersNames = {},
8895 // Default abort message
8896 strAbort = "canceled",
8902 // Builds headers hashtable if needed
8903 getResponseHeader: function( key ) {
8906 if ( !responseHeaders ) {
8907 responseHeaders = {};
8908 while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
8909 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
8912 match = responseHeaders[ key.toLowerCase() ];
8914 return match == null ? null : match;
8918 getAllResponseHeaders: function() {
8919 return completed ? responseHeadersString : null;
8922 // Caches the header
8923 setRequestHeader: function( name, value ) {
8924 if ( completed == null ) {
8925 name = requestHeadersNames[ name.toLowerCase() ] =
8926 requestHeadersNames[ name.toLowerCase() ] || name;
8927 requestHeaders[ name ] = value;
8932 // Overrides response content-type header
8933 overrideMimeType: function( type ) {
8934 if ( completed == null ) {
8940 // Status-dependent callbacks
8941 statusCode: function( map ) {
8946 // Execute the appropriate callbacks
8947 jqXHR.always( map[ jqXHR.status ] );
8950 // Lazy-add the new callbacks in a way that preserves old ones
8951 for ( code in map ) {
8952 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
8959 // Cancel the request
8960 abort: function( statusText ) {
8961 var finalText = statusText || strAbort;
8963 transport.abort( finalText );
8965 done( 0, finalText );
8971 deferred.promise( jqXHR );
8973 // Add protocol if not provided (prefilters might expect it)
8974 // Handle falsy url in the settings object (#10093: consistency with old signature)
8975 // We also use the url parameter if available
8976 s.url = ( ( url || s.url || location.href ) + "" )
8977 .replace( rprotocol, location.protocol + "//" );
8979 // Alias method option to type as per ticket #12004
8980 s.type = options.method || options.type || s.method || s.type;
8982 // Extract dataTypes list
8983 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
8985 // A cross-domain request is in order when the origin doesn't match the current origin.
8986 if ( s.crossDomain == null ) {
8987 urlAnchor = document.createElement( "a" );
8989 // Support: IE <=8 - 11, Edge 12 - 13
8990 // IE throws exception on accessing the href property if url is malformed,
8991 // e.g. http://example.com:80x/
8993 urlAnchor.href = s.url;
8995 // Support: IE <=8 - 11 only
8996 // Anchor's host property isn't correctly set when s.url is relative
8997 urlAnchor.href = urlAnchor.href;
8998 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
8999 urlAnchor.protocol + "//" + urlAnchor.host;
9002 // If there is an error parsing the URL, assume it is crossDomain,
9003 // it can be rejected by the transport if it is invalid
9004 s.crossDomain = true;
9008 // Convert data if not already a string
9009 if ( s.data && s.processData && typeof s.data !== "string" ) {
9010 s.data = jQuery.param( s.data, s.traditional );
9014 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9016 // If request was aborted inside a prefilter, stop there
9021 // We can fire global events as of now if asked to
9022 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9023 fireGlobals = jQuery.event && s.global;
9025 // Watch for a new set of requests
9026 if ( fireGlobals && jQuery.active++ === 0 ) {
9027 jQuery.event.trigger( "ajaxStart" );
9030 // Uppercase the type
9031 s.type = s.type.toUpperCase();
9033 // Determine if request has content
9034 s.hasContent = !rnoContent.test( s.type );
9036 // Save the URL in case we're toying with the If-Modified-Since
9037 // and/or If-None-Match header later on
9038 // Remove hash to simplify url manipulation
9039 cacheURL = s.url.replace( rhash, "" );
9041 // More options handling for requests with no content
9042 if ( !s.hasContent ) {
9044 // Remember the hash so we can put it back
9045 uncached = s.url.slice( cacheURL.length );
9047 // If data is available, append data to url
9049 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
9051 // #9682: remove data so that it's not used in an eventual retry
9055 // Add or update anti-cache param if needed
9056 if ( s.cache === false ) {
9057 cacheURL = cacheURL.replace( rantiCache, "$1" );
9058 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
9061 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9062 s.url = cacheURL + uncached;
9064 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9065 } else if ( s.data && s.processData &&
9066 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9067 s.data = s.data.replace( r20, "+" );
9070 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9071 if ( s.ifModified ) {
9072 if ( jQuery.lastModified[ cacheURL ] ) {
9073 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9075 if ( jQuery.etag[ cacheURL ] ) {
9076 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9080 // Set the correct header, if data is being sent
9081 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9082 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9085 // Set the Accepts header for the server, depending on the dataType
9086 jqXHR.setRequestHeader(
9088 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
9089 s.accepts[ s.dataTypes[ 0 ] ] +
9090 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9094 // Check for headers option
9095 for ( i in s.headers ) {
9096 jqXHR.setRequestHeader( i, s.headers[ i ] );
9099 // Allow custom headers/mimetypes and early abort
9100 if ( s.beforeSend &&
9101 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
9103 // Abort if not done already and return
9104 return jqXHR.abort();
9107 // Aborting is no longer a cancellation
9110 // Install callbacks on deferreds
9111 completeDeferred.add( s.complete );
9112 jqXHR.done( s.success );
9113 jqXHR.fail( s.error );
9116 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9118 // If no transport, we auto-abort
9120 done( -1, "No Transport" );
9122 jqXHR.readyState = 1;
9124 // Send global event
9125 if ( fireGlobals ) {
9126 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9129 // If request was aborted inside ajaxSend, stop there
9135 if ( s.async && s.timeout > 0 ) {
9136 timeoutTimer = window.setTimeout( function() {
9137 jqXHR.abort( "timeout" );
9143 transport.send( requestHeaders, done );
9146 // Rethrow post-completion exceptions
9151 // Propagate others as results
9156 // Callback for when everything is done
9157 function done( status, nativeStatusText, responses, headers ) {
9158 var isSuccess, success, error, response, modified,
9159 statusText = nativeStatusText;
9161 // Ignore repeat invocations
9168 // Clear timeout if it exists
9169 if ( timeoutTimer ) {
9170 window.clearTimeout( timeoutTimer );
9173 // Dereference transport for early garbage collection
9174 // (no matter how long the jqXHR object will be used)
9175 transport = undefined;
9177 // Cache response headers
9178 responseHeadersString = headers || "";
9181 jqXHR.readyState = status > 0 ? 4 : 0;
9183 // Determine if successful
9184 isSuccess = status >= 200 && status < 300 || status === 304;
9186 // Get response data
9188 response = ajaxHandleResponses( s, jqXHR, responses );
9191 // Convert no matter what (that way responseXXX fields are always set)
9192 response = ajaxConvert( s, response, jqXHR, isSuccess );
9194 // If successful, handle type chaining
9197 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9198 if ( s.ifModified ) {
9199 modified = jqXHR.getResponseHeader( "Last-Modified" );
9201 jQuery.lastModified[ cacheURL ] = modified;
9203 modified = jqXHR.getResponseHeader( "etag" );
9205 jQuery.etag[ cacheURL ] = modified;
9210 if ( status === 204 || s.type === "HEAD" ) {
9211 statusText = "nocontent";
9214 } else if ( status === 304 ) {
9215 statusText = "notmodified";
9217 // If we have data, let's convert it
9219 statusText = response.state;
9220 success = response.data;
9221 error = response.error;
9226 // Extract error from statusText and normalize for non-aborts
9228 if ( status || !statusText ) {
9229 statusText = "error";
9236 // Set data for the fake xhr object
9237 jqXHR.status = status;
9238 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9242 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9244 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9247 // Status-dependent callbacks
9248 jqXHR.statusCode( statusCode );
9249 statusCode = undefined;
9251 if ( fireGlobals ) {
9252 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9253 [ jqXHR, s, isSuccess ? success : error ] );
9257 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9259 if ( fireGlobals ) {
9260 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9262 // Handle the global AJAX counter
9263 if ( !( --jQuery.active ) ) {
9264 jQuery.event.trigger( "ajaxStop" );
9272 getJSON: function( url, data, callback ) {
9273 return jQuery.get( url, data, callback, "json" );
9276 getScript: function( url, callback ) {
9277 return jQuery.get( url, undefined, callback, "script" );
9281 jQuery.each( [ "get", "post" ], function( i, method ) {
9282 jQuery[ method ] = function( url, data, callback, type ) {
9284 // Shift arguments if data argument was omitted
9285 if ( jQuery.isFunction( data ) ) {
9286 type = type || callback;
9291 // The url can be an options object (which then must have .url)
9292 return jQuery.ajax( jQuery.extend( {
9298 }, jQuery.isPlainObject( url ) && url ) );
9303 jQuery._evalUrl = function( url ) {
9304 return jQuery.ajax( {
9307 // Make this explicit, since user can override this through ajaxSetup (#11264)
9319 wrapAll: function( html ) {
9323 if ( jQuery.isFunction( html ) ) {
9324 html = html.call( this[ 0 ] );
9327 // The elements to wrap the target around
9328 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
9330 if ( this[ 0 ].parentNode ) {
9331 wrap.insertBefore( this[ 0 ] );
9334 wrap.map( function() {
9337 while ( elem.firstElementChild ) {
9338 elem = elem.firstElementChild;
9348 wrapInner: function( html ) {
9349 if ( jQuery.isFunction( html ) ) {
9350 return this.each( function( i ) {
9351 jQuery( this ).wrapInner( html.call( this, i ) );
9355 return this.each( function() {
9356 var self = jQuery( this ),
9357 contents = self.contents();
9359 if ( contents.length ) {
9360 contents.wrapAll( html );
9363 self.append( html );
9368 wrap: function( html ) {
9369 var isFunction = jQuery.isFunction( html );
9371 return this.each( function( i ) {
9372 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
9376 unwrap: function( selector ) {
9377 this.parent( selector ).not( "body" ).each( function() {
9378 jQuery( this ).replaceWith( this.childNodes );
9385 jQuery.expr.pseudos.hidden = function( elem ) {
9386 return !jQuery.expr.pseudos.visible( elem );
9388 jQuery.expr.pseudos.visible = function( elem ) {
9389 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
9395 jQuery.ajaxSettings.xhr = function() {
9397 return new window.XMLHttpRequest();
9401 var xhrSuccessStatus = {
9403 // File protocol always yields status code 0, assume 200
9406 // Support: IE <=9 only
9407 // #1450: sometimes IE returns 1223 when it should be 204
9410 xhrSupported = jQuery.ajaxSettings.xhr();
9412 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
9413 support.ajax = xhrSupported = !!xhrSupported;
9415 jQuery.ajaxTransport( function( options ) {
9416 var callback, errorCallback;
9418 // Cross domain only allowed if supported through XMLHttpRequest
9419 if ( support.cors || xhrSupported && !options.crossDomain ) {
9421 send: function( headers, complete ) {
9423 xhr = options.xhr();
9433 // Apply custom fields if provided
9434 if ( options.xhrFields ) {
9435 for ( i in options.xhrFields ) {
9436 xhr[ i ] = options.xhrFields[ i ];
9440 // Override mime type if needed
9441 if ( options.mimeType && xhr.overrideMimeType ) {
9442 xhr.overrideMimeType( options.mimeType );
9445 // X-Requested-With header
9446 // For cross-domain requests, seeing as conditions for a preflight are
9447 // akin to a jigsaw puzzle, we simply never set it to be sure.
9448 // (it can always be set on a per-request basis or even using ajaxSetup)
9449 // For same-domain requests, won't change header if already provided.
9450 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
9451 headers[ "X-Requested-With" ] = "XMLHttpRequest";
9455 for ( i in headers ) {
9456 xhr.setRequestHeader( i, headers[ i ] );
9460 callback = function( type ) {
9463 callback = errorCallback = xhr.onload =
9464 xhr.onerror = xhr.onabort = xhr.onreadystatechange = null;
9466 if ( type === "abort" ) {
9468 } else if ( type === "error" ) {
9470 // Support: IE <=9 only
9471 // On a manual native abort, IE9 throws
9472 // errors on any property access that is not readyState
9473 if ( typeof xhr.status !== "number" ) {
9474 complete( 0, "error" );
9478 // File: protocol always yields status 0; see #8605, #14207
9485 xhrSuccessStatus[ xhr.status ] || xhr.status,
9488 // Support: IE <=9 only
9489 // IE9 has no XHR2 but throws on binary (trac-11426)
9490 // For XHR2 non-text, let the caller handle it (gh-2498)
9491 ( xhr.responseType || "text" ) !== "text" ||
9492 typeof xhr.responseText !== "string" ?
9493 { binary: xhr.response } :
9494 { text: xhr.responseText },
9495 xhr.getAllResponseHeaders()
9503 xhr.onload = callback();
9504 errorCallback = xhr.onerror = callback( "error" );
9506 // Support: IE 9 only
9507 // Use onreadystatechange to replace onabort
9508 // to handle uncaught aborts
9509 if ( xhr.onabort !== undefined ) {
9510 xhr.onabort = errorCallback;
9512 xhr.onreadystatechange = function() {
9514 // Check readyState before timeout as it changes
9515 if ( xhr.readyState === 4 ) {
9517 // Allow onerror to be called first,
9518 // but that will not handle a native abort
9519 // Also, save errorCallback to a variable
9520 // as xhr.onerror cannot be accessed
9521 window.setTimeout( function() {
9530 // Create the abort callback
9531 callback = callback( "abort" );
9535 // Do send the request (this may raise an exception)
9536 xhr.send( options.hasContent && options.data || null );
9539 // #14683: Only rethrow if this hasn't been notified as an error yet
9558 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
9559 jQuery.ajaxPrefilter( function( s ) {
9560 if ( s.crossDomain ) {
9561 s.contents.script = false;
9565 // Install script dataType
9568 script: "text/javascript, application/javascript, " +
9569 "application/ecmascript, application/x-ecmascript"
9572 script: /\b(?:java|ecma)script\b/
9575 "text script": function( text ) {
9576 jQuery.globalEval( text );
9582 // Handle cache's special case and crossDomain
9583 jQuery.ajaxPrefilter( "script", function( s ) {
9584 if ( s.cache === undefined ) {
9587 if ( s.crossDomain ) {
9592 // Bind script tag hack transport
9593 jQuery.ajaxTransport( "script", function( s ) {
9595 // This transport only deals with cross domain requests
9596 if ( s.crossDomain ) {
9597 var script, callback;
9599 send: function( _, complete ) {
9600 script = jQuery( "<script>" ).prop( {
9601 charset: s.scriptCharset,
9605 callback = function( evt ) {
9609 complete( evt.type === "error" ? 404 : 200, evt.type );
9614 // Use native DOM manipulation to avoid our domManip AJAX trickery
9615 document.head.appendChild( script[ 0 ] );
9629 var oldCallbacks = [],
9630 rjsonp = /(=)\?(?=&|$)|\?\?/;
9632 // Default jsonp settings
9635 jsonpCallback: function() {
9636 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
9637 this[ callback ] = true;
9642 // Detect, normalize options and install callbacks for jsonp requests
9643 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
9645 var callbackName, overwritten, responseContainer,
9646 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
9648 typeof s.data === "string" &&
9649 ( s.contentType || "" )
9650 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
9651 rjsonp.test( s.data ) && "data"
9654 // Handle iff the expected data type is "jsonp" or we have a parameter to set
9655 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
9657 // Get callback name, remembering preexisting value associated with it
9658 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
9662 // Insert callback into url or form data
9664 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
9665 } else if ( s.jsonp !== false ) {
9666 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
9669 // Use data converter to retrieve json after script execution
9670 s.converters[ "script json" ] = function() {
9671 if ( !responseContainer ) {
9672 jQuery.error( callbackName + " was not called" );
9674 return responseContainer[ 0 ];
9677 // Force json dataType
9678 s.dataTypes[ 0 ] = "json";
9681 overwritten = window[ callbackName ];
9682 window[ callbackName ] = function() {
9683 responseContainer = arguments;
9686 // Clean-up function (fires after converters)
9687 jqXHR.always( function() {
9689 // If previous value didn't exist - remove it
9690 if ( overwritten === undefined ) {
9691 jQuery( window ).removeProp( callbackName );
9693 // Otherwise restore preexisting value
9695 window[ callbackName ] = overwritten;
9698 // Save back as free
9699 if ( s[ callbackName ] ) {
9701 // Make sure that re-using the options doesn't screw things around
9702 s.jsonpCallback = originalSettings.jsonpCallback;
9704 // Save the callback name for future use
9705 oldCallbacks.push( callbackName );
9708 // Call if it was a function and we have a response
9709 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
9710 overwritten( responseContainer[ 0 ] );
9713 responseContainer = overwritten = undefined;
9716 // Delegate to script
9724 // Support: Safari 8 only
9725 // In Safari 8 documents created via document.implementation.createHTMLDocument
9726 // collapse sibling forms: the second one becomes a child of the first one.
9727 // Because of that, this security measure has to be disabled in Safari 8.
9728 // https://bugs.webkit.org/show_bug.cgi?id=137337
9729 support.createHTMLDocument = ( function() {
9730 var body = document.implementation.createHTMLDocument( "" ).body;
9731 body.innerHTML = "<form></form><form></form>";
9732 return body.childNodes.length === 2;
9736 // Argument "data" should be string of html
9737 // context (optional): If specified, the fragment will be created in this context,
9738 // defaults to document
9739 // keepScripts (optional): If true, will include scripts passed in the html string
9740 jQuery.parseHTML = function( data, context, keepScripts ) {
9741 if ( typeof data !== "string" ) {
9744 if ( typeof context === "boolean" ) {
9745 keepScripts = context;
9749 var base, parsed, scripts;
9753 // Stop scripts or inline event handlers from being executed immediately
9754 // by using document.implementation
9755 if ( support.createHTMLDocument ) {
9756 context = document.implementation.createHTMLDocument( "" );
9758 // Set the base href for the created document
9759 // so any parsed elements with URLs
9760 // are based on the document's URL (gh-2965)
9761 base = context.createElement( "base" );
9762 base.href = document.location.href;
9763 context.head.appendChild( base );
9769 parsed = rsingleTag.exec( data );
9770 scripts = !keepScripts && [];
9774 return [ context.createElement( parsed[ 1 ] ) ];
9777 parsed = buildFragment( [ data ], context, scripts );
9779 if ( scripts && scripts.length ) {
9780 jQuery( scripts ).remove();
9783 return jQuery.merge( [], parsed.childNodes );
9788 * Load a url into a page
9790 jQuery.fn.load = function( url, params, callback ) {
9791 var selector, type, response,
9793 off = url.indexOf( " " );
9796 selector = stripAndCollapse( url.slice( off ) );
9797 url = url.slice( 0, off );
9800 // If it's a function
9801 if ( jQuery.isFunction( params ) ) {
9803 // We assume that it's the callback
9807 // Otherwise, build a param string
9808 } else if ( params && typeof params === "object" ) {
9812 // If we have elements to modify, make the request
9813 if ( self.length > 0 ) {
9817 // If "type" variable is undefined, then "GET" method will be used.
9818 // Make value of this field explicit since
9819 // user can override it through ajaxSetup method
9820 type: type || "GET",
9823 } ).done( function( responseText ) {
9825 // Save response for use in complete callback
9826 response = arguments;
9828 self.html( selector ?
9830 // If a selector was specified, locate the right elements in a dummy div
9831 // Exclude scripts to avoid IE 'Permission Denied' errors
9832 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
9834 // Otherwise use the full result
9837 // If the request succeeds, this function gets "data", "status", "jqXHR"
9838 // but they are ignored because response was set above.
9839 // If it fails, this function gets "jqXHR", "status", "error"
9840 } ).always( callback && function( jqXHR, status ) {
9841 self.each( function() {
9842 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
9853 // Attach a bunch of functions for handling common AJAX events
9861 ], function( i, type ) {
9862 jQuery.fn[ type ] = function( fn ) {
9863 return this.on( type, fn );
9870 jQuery.expr.pseudos.animated = function( elem ) {
9871 return jQuery.grep( jQuery.timers, function( fn ) {
9872 return elem === fn.elem;
9880 * Gets a window from an element
9882 function getWindow( elem ) {
9883 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
9887 setOffset: function( elem, options, i ) {
9888 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
9889 position = jQuery.css( elem, "position" ),
9890 curElem = jQuery( elem ),
9893 // Set position first, in-case top/left are set even on static elem
9894 if ( position === "static" ) {
9895 elem.style.position = "relative";
9898 curOffset = curElem.offset();
9899 curCSSTop = jQuery.css( elem, "top" );
9900 curCSSLeft = jQuery.css( elem, "left" );
9901 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
9902 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
9904 // Need to be able to calculate position if either
9905 // top or left is auto and position is either absolute or fixed
9906 if ( calculatePosition ) {
9907 curPosition = curElem.position();
9908 curTop = curPosition.top;
9909 curLeft = curPosition.left;
9912 curTop = parseFloat( curCSSTop ) || 0;
9913 curLeft = parseFloat( curCSSLeft ) || 0;
9916 if ( jQuery.isFunction( options ) ) {
9918 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
9919 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
9922 if ( options.top != null ) {
9923 props.top = ( options.top - curOffset.top ) + curTop;
9925 if ( options.left != null ) {
9926 props.left = ( options.left - curOffset.left ) + curLeft;
9929 if ( "using" in options ) {
9930 options.using.call( elem, props );
9933 curElem.css( props );
9939 offset: function( options ) {
9941 // Preserve chaining for setter
9942 if ( arguments.length ) {
9943 return options === undefined ?
9945 this.each( function( i ) {
9946 jQuery.offset.setOffset( this, options, i );
9950 var docElem, win, rect, doc,
9957 // Support: IE <=11 only
9958 // Running getBoundingClientRect on a
9959 // disconnected node in IE throws an error
9960 if ( !elem.getClientRects().length ) {
9961 return { top: 0, left: 0 };
9964 rect = elem.getBoundingClientRect();
9966 // Make sure element is not hidden (display: none)
9967 if ( rect.width || rect.height ) {
9968 doc = elem.ownerDocument;
9969 win = getWindow( doc );
9970 docElem = doc.documentElement;
9973 top: rect.top + win.pageYOffset - docElem.clientTop,
9974 left: rect.left + win.pageXOffset - docElem.clientLeft
9978 // Return zeros for disconnected and hidden elements (gh-2310)
9982 position: function() {
9987 var offsetParent, offset,
9989 parentOffset = { top: 0, left: 0 };
9991 // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
9992 // because it is its only offset parent
9993 if ( jQuery.css( elem, "position" ) === "fixed" ) {
9995 // Assume getBoundingClientRect is there when computed position is fixed
9996 offset = elem.getBoundingClientRect();
10000 // Get *real* offsetParent
10001 offsetParent = this.offsetParent();
10003 // Get correct offsets
10004 offset = this.offset();
10005 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
10006 parentOffset = offsetParent.offset();
10009 // Add offsetParent borders
10011 top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
10012 left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
10016 // Subtract parent offsets and element margins
10018 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10019 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
10023 // This method will return documentElement in the following cases:
10024 // 1) For the element inside the iframe without offsetParent, this method will return
10025 // documentElement of the parent window
10026 // 2) For the hidden or detached element
10027 // 3) For body or html element, i.e. in case of the html node - it will return itself
10029 // but those exceptions were never presented as a real life use-cases
10030 // and might be considered as more preferable results.
10032 // This logic, however, is not guaranteed and can change at any point in the future
10033 offsetParent: function() {
10034 return this.map( function() {
10035 var offsetParent = this.offsetParent;
10037 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
10038 offsetParent = offsetParent.offsetParent;
10041 return offsetParent || documentElement;
10046 // Create scrollLeft and scrollTop methods
10047 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10048 var top = "pageYOffset" === prop;
10050 jQuery.fn[ method ] = function( val ) {
10051 return access( this, function( elem, method, val ) {
10052 var win = getWindow( elem );
10054 if ( val === undefined ) {
10055 return win ? win[ prop ] : elem[ method ];
10060 !top ? val : win.pageXOffset,
10061 top ? val : win.pageYOffset
10065 elem[ method ] = val;
10067 }, method, val, arguments.length );
10071 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10072 // Add the top/left cssHooks using jQuery.fn.position
10073 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10074 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10075 // getComputedStyle returns percent when specified for top/left/bottom/right;
10076 // rather than make the css module depend on the offset module, just check for it here
10077 jQuery.each( [ "top", "left" ], function( i, prop ) {
10078 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10079 function( elem, computed ) {
10081 computed = curCSS( elem, prop );
10083 // If curCSS returns percentage, fallback to offset
10084 return rnumnonpx.test( computed ) ?
10085 jQuery( elem ).position()[ prop ] + "px" :
10093 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10094 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10095 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
10096 function( defaultExtra, funcName ) {
10098 // Margin is only for outerHeight, outerWidth
10099 jQuery.fn[ funcName ] = function( margin, value ) {
10100 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10101 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10103 return access( this, function( elem, type, value ) {
10106 if ( jQuery.isWindow( elem ) ) {
10108 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10109 return funcName.indexOf( "outer" ) === 0 ?
10110 elem[ "inner" + name ] :
10111 elem.document.documentElement[ "client" + name ];
10114 // Get document width or height
10115 if ( elem.nodeType === 9 ) {
10116 doc = elem.documentElement;
10118 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10119 // whichever is greatest
10121 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10122 elem.body[ "offset" + name ], doc[ "offset" + name ],
10123 doc[ "client" + name ]
10127 return value === undefined ?
10129 // Get width or height on the element, requesting but not forcing parseFloat
10130 jQuery.css( elem, type, extra ) :
10132 // Set width or height on the element
10133 jQuery.style( elem, type, value, extra );
10134 }, type, chainable ? margin : undefined, chainable );
10140 jQuery.fn.extend( {
10142 bind: function( types, data, fn ) {
10143 return this.on( types, null, data, fn );
10145 unbind: function( types, fn ) {
10146 return this.off( types, null, fn );
10149 delegate: function( selector, types, data, fn ) {
10150 return this.on( types, selector, data, fn );
10152 undelegate: function( selector, types, fn ) {
10154 // ( namespace ) or ( selector, types [, fn] )
10155 return arguments.length === 1 ?
10156 this.off( selector, "**" ) :
10157 this.off( types, selector || "**", fn );
10161 jQuery.parseJSON = JSON.parse;
10166 // Register as a named AMD module, since jQuery can be concatenated with other
10167 // files that may use define, but not via a proper concatenation script that
10168 // understands anonymous AMD modules. A named AMD is safest and most robust
10169 // way to register. Lowercase jquery is used because AMD module names are
10170 // derived from file names, and jQuery is normally delivered in a lowercase
10171 // file name. Do this after creating the global so that if an AMD module wants
10172 // to call noConflict to hide this version of jQuery, it will work.
10174 // Note that for maximum portability, libraries that are not jQuery should
10175 // declare themselves as anonymous modules, and avoid setting a global if an
10176 // AMD loader is present. jQuery is a special case. For more information, see
10177 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10179 if ( typeof define === "function" && define.amd ) {
10180 define( "jquery", [], function() {
10190 // Map over jQuery in case of overwrite
10191 _jQuery = window.jQuery,
10193 // Map over the $ in case of overwrite
10196 jQuery.noConflict = function( deep ) {
10197 if ( window.$ === jQuery ) {
10201 if ( deep && window.jQuery === jQuery ) {
10202 window.jQuery = _jQuery;
10208 // Expose jQuery and $ identifiers, even in AMD
10209 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10210 // and CommonJS for browser emulators (#13566)
10212 window.jQuery = window.$ = jQuery;