1 /*eslint-disable no-unused-vars*/
3 * jQuery JavaScript Library v3.1.0 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated
7 * https://sizzlejs.com/
9 * Copyright jQuery Foundation and other contributors
10 * Released under the MIT license
11 * https://jquery.org/license
13 * Date: 2016-07-07T21:44Z
15 ( function( global, factory ) {
19 if ( typeof module === "object" && typeof module.exports === "object" ) {
21 // For CommonJS and CommonJS-like environments where a proper `window`
22 // is present, execute the factory and get jQuery.
23 // For environments that do not have a `window` with a `document`
24 // (such as Node.js), expose a factory as module.exports.
25 // This accentuates the need for the creation of a real `window`.
26 // e.g. var jQuery = require("jquery")(window);
27 // See ticket #14549 for more info.
28 module.exports = global.document ?
29 factory( global, true ) :
32 throw new Error( "jQuery requires a window with a document" );
40 // Pass this if window is not defined yet
41 } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
43 // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
44 // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
45 // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
46 // enough that all such attempts are guarded in a try block.
51 var document = window.document;
53 var getProto = Object.getPrototypeOf;
55 var slice = arr.slice;
57 var concat = arr.concat;
61 var indexOf = arr.indexOf;
65 var toString = class2type.toString;
67 var hasOwn = class2type.hasOwnProperty;
69 var fnToString = hasOwn.toString;
71 var ObjectFunctionString = fnToString.call( Object );
77 function DOMEval( code, doc ) {
78 doc = doc || document;
80 var script = doc.createElement( "script" );
83 doc.head.appendChild( script ).parentNode.removeChild( script );
86 // Defining this global in .eslintrc would create a danger of using the global
87 // unguarded in another place, it seems safer to define global only for this module
92 version = "3.1.0 -ajax,-ajax/jsonp,-ajax/load,-ajax/parseXML,-ajax/script,-ajax/var/location,-ajax/var/nonce,-ajax/var/rquery,-ajax/xhr,-manipulation/_evalUrl,-event/ajax,-effects,-effects/Tween,-effects/animatedSelector,-deprecated",
94 // Define a local copy of jQuery
95 jQuery = function( selector, context ) {
97 // The jQuery object is actually just the init constructor 'enhanced'
98 // Need init if jQuery is called (just allow error to be thrown if not included)
99 return new jQuery.fn.init( selector, context );
102 // Support: Android <=4.0 only
103 // Make sure we trim BOM and NBSP
104 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
106 // Matches dashed string for camelizing
108 rdashAlpha = /-([a-z])/g,
110 // Used by jQuery.camelCase as callback to replace()
111 fcamelCase = function( all, letter ) {
112 return letter.toUpperCase();
115 jQuery.fn = jQuery.prototype = {
117 // The current version of jQuery being used
122 // The default length of a jQuery object is 0
125 toArray: function() {
126 return slice.call( this );
129 // Get the Nth element in the matched element set OR
130 // Get the whole matched element set as a clean array
131 get: function( num ) {
134 // Return just the one element from the set
135 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
137 // Return all the elements in a clean array
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.0
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)|^-$|[^\x80-\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;
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 ) {
1012 // Known :disabled false positives:
1013 // IE: *[disabled]:not(button, input, select, textarea, optgroup, option, menuitem, fieldset)
1014 // not IE: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1015 return function( elem ) {
1017 // Check form elements and option elements for explicit disabling
1018 return "label" in elem && elem.disabled === disabled ||
1019 "form" in elem && elem.disabled === disabled ||
1021 // Check non-disabled form elements for fieldset[disabled] ancestors
1022 "form" in elem && elem.disabled === false && (
1024 // Ancestry is covered for us
1025 elem.isDisabled === disabled ||
1027 // Otherwise, assume any non-<option> under fieldset[disabled] is disabled
1029 elem.isDisabled !== !disabled &&
1030 ("label" in elem || !disabledAncestor( elem )) !== disabled
1036 * Returns a function to use in pseudos for positionals
1037 * @param {Function} fn
1039 function createPositionalPseudo( fn ) {
1040 return markFunction(function( argument ) {
1041 argument = +argument;
1042 return markFunction(function( seed, matches ) {
1044 matchIndexes = fn( [], seed.length, argument ),
1045 i = matchIndexes.length;
1047 // Match elements found at the specified indexes
1049 if ( seed[ (j = matchIndexes[i]) ] ) {
1050 seed[j] = !(matches[j] = seed[j]);
1058 * Checks a node for validity as a Sizzle context
1059 * @param {Element|Object=} context
1060 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1062 function testContext( context ) {
1063 return context && typeof context.getElementsByTagName !== "undefined" && context;
1066 // Expose support vars for convenience
1067 support = Sizzle.support = {};
1071 * @param {Element|Object} elem An element or a document
1072 * @returns {Boolean} True iff elem is a non-HTML XML node
1074 isXML = Sizzle.isXML = function( elem ) {
1075 // documentElement is verified for cases where it doesn't yet exist
1076 // (such as loading iframes in IE - #4833)
1077 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1078 return documentElement ? documentElement.nodeName !== "HTML" : false;
1082 * Sets document-related variables once based on the current document
1083 * @param {Element|Object} [doc] An element or document object to use to set the document
1084 * @returns {Object} Returns the current document
1086 setDocument = Sizzle.setDocument = function( node ) {
1087 var hasCompare, subWindow,
1088 doc = node ? node.ownerDocument || node : preferredDoc;
1090 // Return early if doc is invalid or already selected
1091 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1095 // Update global variables
1097 docElem = document.documentElement;
1098 documentIsHTML = !isXML( document );
1100 // Support: IE 9-11, Edge
1101 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1102 if ( preferredDoc !== document &&
1103 (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
1105 // Support: IE 11, Edge
1106 if ( subWindow.addEventListener ) {
1107 subWindow.addEventListener( "unload", unloadHandler, false );
1109 // Support: IE 9 - 10 only
1110 } else if ( subWindow.attachEvent ) {
1111 subWindow.attachEvent( "onunload", unloadHandler );
1116 ---------------------------------------------------------------------- */
1119 // Verify that getAttribute really returns attributes and not properties
1120 // (excepting IE8 booleans)
1121 support.attributes = assert(function( el ) {
1123 return !el.getAttribute("className");
1127 ---------------------------------------------------------------------- */
1129 // Check if getElementsByTagName("*") returns only elements
1130 support.getElementsByTagName = assert(function( el ) {
1131 el.appendChild( document.createComment("") );
1132 return !el.getElementsByTagName("*").length;
1136 support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1139 // Check if getElementById returns elements by name
1140 // The broken getElementById methods don't pick up programmatically-set names,
1141 // so use a roundabout getElementsByName test
1142 support.getById = assert(function( el ) {
1143 docElem.appendChild( el ).id = expando;
1144 return !document.getElementsByName || !document.getElementsByName( expando ).length;
1147 // ID find and filter
1148 if ( support.getById ) {
1149 Expr.find["ID"] = function( id, context ) {
1150 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1151 var m = context.getElementById( id );
1152 return m ? [ m ] : [];
1155 Expr.filter["ID"] = function( id ) {
1156 var attrId = id.replace( runescape, funescape );
1157 return function( elem ) {
1158 return elem.getAttribute("id") === attrId;
1163 // getElementById is not reliable as a find shortcut
1164 delete Expr.find["ID"];
1166 Expr.filter["ID"] = function( id ) {
1167 var attrId = id.replace( runescape, funescape );
1168 return function( elem ) {
1169 var node = typeof elem.getAttributeNode !== "undefined" &&
1170 elem.getAttributeNode("id");
1171 return node && node.value === attrId;
1177 Expr.find["TAG"] = support.getElementsByTagName ?
1178 function( tag, context ) {
1179 if ( typeof context.getElementsByTagName !== "undefined" ) {
1180 return context.getElementsByTagName( tag );
1182 // DocumentFragment nodes don't have gEBTN
1183 } else if ( support.qsa ) {
1184 return context.querySelectorAll( tag );
1188 function( tag, context ) {
1192 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1193 results = context.getElementsByTagName( tag );
1195 // Filter out possible comments
1196 if ( tag === "*" ) {
1197 while ( (elem = results[i++]) ) {
1198 if ( elem.nodeType === 1 ) {
1209 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1210 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1211 return context.getElementsByClassName( className );
1215 /* QSA/matchesSelector
1216 ---------------------------------------------------------------------- */
1218 // QSA and matchesSelector support
1220 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1223 // qSa(:focus) reports false when true (Chrome 21)
1224 // We allow this because of a bug in IE8/9 that throws an error
1225 // whenever `document.activeElement` is accessed on an iframe
1226 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1227 // See https://bugs.jquery.com/ticket/13378
1230 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
1232 // Regex strategy adopted from Diego Perini
1233 assert(function( el ) {
1234 // Select is set to empty string on purpose
1235 // This is to test IE's treatment of not explicitly
1236 // setting a boolean content attribute,
1237 // since its presence should be enough
1238 // https://bugs.jquery.com/ticket/12359
1239 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
1240 "<select id='" + expando + "-\r\\' msallowcapture=''>" +
1241 "<option selected=''></option></select>";
1243 // Support: IE8, Opera 11-12.16
1244 // Nothing should be selected when empty strings follow ^= or $= or *=
1245 // The test attribute must be unknown in Opera but "safe" for WinRT
1246 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1247 if ( el.querySelectorAll("[msallowcapture^='']").length ) {
1248 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1252 // Boolean attributes and "value" are not treated correctly
1253 if ( !el.querySelectorAll("[selected]").length ) {
1254 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1257 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1258 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1259 rbuggyQSA.push("~=");
1262 // Webkit/Opera - :checked should return selected option elements
1263 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1264 // IE8 throws error here and will not see later tests
1265 if ( !el.querySelectorAll(":checked").length ) {
1266 rbuggyQSA.push(":checked");
1269 // Support: Safari 8+, iOS 8+
1270 // https://bugs.webkit.org/show_bug.cgi?id=136851
1271 // In-page `selector#id sibling-combinator selector` fails
1272 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
1273 rbuggyQSA.push(".#.+[+~]");
1277 assert(function( el ) {
1278 el.innerHTML = "<a href='' disabled='disabled'></a>" +
1279 "<select disabled='disabled'><option/></select>";
1281 // Support: Windows 8 Native Apps
1282 // The type and name attributes are restricted during .innerHTML assignment
1283 var input = document.createElement("input");
1284 input.setAttribute( "type", "hidden" );
1285 el.appendChild( input ).setAttribute( "name", "D" );
1288 // Enforce case-sensitivity of name attribute
1289 if ( el.querySelectorAll("[name=d]").length ) {
1290 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1293 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1294 // IE8 throws error here and will not see later tests
1295 if ( el.querySelectorAll(":enabled").length !== 2 ) {
1296 rbuggyQSA.push( ":enabled", ":disabled" );
1300 // IE's :disabled selector does not pick up the children of disabled fieldsets
1301 docElem.appendChild( el ).disabled = true;
1302 if ( el.querySelectorAll(":disabled").length !== 2 ) {
1303 rbuggyQSA.push( ":enabled", ":disabled" );
1306 // Opera 10-11 does not throw on post-comma invalid pseudos
1307 el.querySelectorAll("*,:x");
1308 rbuggyQSA.push(",.*:");
1312 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1313 docElem.webkitMatchesSelector ||
1314 docElem.mozMatchesSelector ||
1315 docElem.oMatchesSelector ||
1316 docElem.msMatchesSelector) )) ) {
1318 assert(function( el ) {
1319 // Check to see if it's possible to do matchesSelector
1320 // on a disconnected node (IE 9)
1321 support.disconnectedMatch = matches.call( el, "*" );
1323 // This should fail with an exception
1324 // Gecko does not error, returns false instead
1325 matches.call( el, "[s!='']:x" );
1326 rbuggyMatches.push( "!=", pseudos );
1330 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1331 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1334 ---------------------------------------------------------------------- */
1335 hasCompare = rnative.test( docElem.compareDocumentPosition );
1337 // Element contains another
1338 // Purposefully self-exclusive
1339 // As in, an element does not contain itself
1340 contains = hasCompare || rnative.test( docElem.contains ) ?
1342 var adown = a.nodeType === 9 ? a.documentElement : a,
1343 bup = b && b.parentNode;
1344 return a === bup || !!( bup && bup.nodeType === 1 && (
1346 adown.contains( bup ) :
1347 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1352 while ( (b = b.parentNode) ) {
1362 ---------------------------------------------------------------------- */
1364 // Document order sorting
1365 sortOrder = hasCompare ?
1368 // Flag for duplicate removal
1370 hasDuplicate = true;
1374 // Sort on method existence if only one input has compareDocumentPosition
1375 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1380 // Calculate position if both inputs belong to the same document
1381 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1382 a.compareDocumentPosition( b ) :
1384 // Otherwise we know they are disconnected
1387 // Disconnected nodes
1389 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1391 // Choose the first element that is related to our preferred document
1392 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1395 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1399 // Maintain original order
1401 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1405 return compare & 4 ? -1 : 1;
1408 // Exit early if the nodes are identical
1410 hasDuplicate = true;
1421 // Parentless nodes are either documents or disconnected
1422 if ( !aup || !bup ) {
1423 return a === document ? -1 :
1424 b === document ? 1 :
1428 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1431 // If the nodes are siblings, we can do a quick check
1432 } else if ( aup === bup ) {
1433 return siblingCheck( a, b );
1436 // Otherwise we need full lists of their ancestors for comparison
1438 while ( (cur = cur.parentNode) ) {
1442 while ( (cur = cur.parentNode) ) {
1446 // Walk down the tree looking for a discrepancy
1447 while ( ap[i] === bp[i] ) {
1452 // Do a sibling check if the nodes have a common ancestor
1453 siblingCheck( ap[i], bp[i] ) :
1455 // Otherwise nodes in our document sort first
1456 ap[i] === preferredDoc ? -1 :
1457 bp[i] === preferredDoc ? 1 :
1464 Sizzle.matches = function( expr, elements ) {
1465 return Sizzle( expr, null, null, elements );
1468 Sizzle.matchesSelector = function( elem, expr ) {
1469 // Set document vars if needed
1470 if ( ( elem.ownerDocument || elem ) !== document ) {
1471 setDocument( elem );
1474 // Make sure that attribute selectors are quoted
1475 expr = expr.replace( rattributeQuotes, "='$1']" );
1477 if ( support.matchesSelector && documentIsHTML &&
1478 !compilerCache[ expr + " " ] &&
1479 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1480 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1483 var ret = matches.call( elem, expr );
1485 // IE 9's matchesSelector returns false on disconnected nodes
1486 if ( ret || support.disconnectedMatch ||
1487 // As well, disconnected nodes are said to be in a document
1489 elem.document && elem.document.nodeType !== 11 ) {
1495 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1498 Sizzle.contains = function( context, elem ) {
1499 // Set document vars if needed
1500 if ( ( context.ownerDocument || context ) !== document ) {
1501 setDocument( context );
1503 return contains( context, elem );
1506 Sizzle.attr = function( elem, name ) {
1507 // Set document vars if needed
1508 if ( ( elem.ownerDocument || elem ) !== document ) {
1509 setDocument( elem );
1512 var fn = Expr.attrHandle[ name.toLowerCase() ],
1513 // Don't get fooled by Object.prototype properties (jQuery #13807)
1514 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1515 fn( elem, name, !documentIsHTML ) :
1518 return val !== undefined ?
1520 support.attributes || !documentIsHTML ?
1521 elem.getAttribute( name ) :
1522 (val = elem.getAttributeNode(name)) && val.specified ?
1527 Sizzle.escape = function( sel ) {
1528 return (sel + "").replace( rcssescape, fcssescape );
1531 Sizzle.error = function( msg ) {
1532 throw new Error( "Syntax error, unrecognized expression: " + msg );
1536 * Document sorting and removing duplicates
1537 * @param {ArrayLike} results
1539 Sizzle.uniqueSort = function( results ) {
1545 // Unless we *know* we can detect duplicates, assume their presence
1546 hasDuplicate = !support.detectDuplicates;
1547 sortInput = !support.sortStable && results.slice( 0 );
1548 results.sort( sortOrder );
1550 if ( hasDuplicate ) {
1551 while ( (elem = results[i++]) ) {
1552 if ( elem === results[ i ] ) {
1553 j = duplicates.push( i );
1557 results.splice( duplicates[ j ], 1 );
1561 // Clear input after sorting to release objects
1562 // See https://github.com/jquery/sizzle/pull/225
1569 * Utility function for retrieving the text value of an array of DOM nodes
1570 * @param {Array|Element} elem
1572 getText = Sizzle.getText = function( elem ) {
1576 nodeType = elem.nodeType;
1579 // If no nodeType, this is expected to be an array
1580 while ( (node = elem[i++]) ) {
1581 // Do not traverse comment nodes
1582 ret += getText( node );
1584 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1585 // Use textContent for elements
1586 // innerText usage removed for consistency of new lines (jQuery #11153)
1587 if ( typeof elem.textContent === "string" ) {
1588 return elem.textContent;
1590 // Traverse its children
1591 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1592 ret += getText( elem );
1595 } else if ( nodeType === 3 || nodeType === 4 ) {
1596 return elem.nodeValue;
1598 // Do not include comment or processing instruction nodes
1603 Expr = Sizzle.selectors = {
1605 // Can be adjusted by the user
1608 createPseudo: markFunction,
1617 ">": { dir: "parentNode", first: true },
1618 " ": { dir: "parentNode" },
1619 "+": { dir: "previousSibling", first: true },
1620 "~": { dir: "previousSibling" }
1624 "ATTR": function( match ) {
1625 match[1] = match[1].replace( runescape, funescape );
1627 // Move the given value to match[3] whether quoted or unquoted
1628 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1630 if ( match[2] === "~=" ) {
1631 match[3] = " " + match[3] + " ";
1634 return match.slice( 0, 4 );
1637 "CHILD": function( match ) {
1638 /* matches from matchExpr["CHILD"]
1639 1 type (only|nth|...)
1640 2 what (child|of-type)
1641 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1642 4 xn-component of xn+y argument ([+-]?\d*n|)
1643 5 sign of xn-component
1645 7 sign of y-component
1648 match[1] = match[1].toLowerCase();
1650 if ( match[1].slice( 0, 3 ) === "nth" ) {
1651 // nth-* requires argument
1653 Sizzle.error( match[0] );
1656 // numeric x and y parameters for Expr.filter.CHILD
1657 // remember that false/true cast respectively to 0/1
1658 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1659 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1661 // other types prohibit arguments
1662 } else if ( match[3] ) {
1663 Sizzle.error( match[0] );
1669 "PSEUDO": function( match ) {
1671 unquoted = !match[6] && match[2];
1673 if ( matchExpr["CHILD"].test( match[0] ) ) {
1677 // Accept quoted arguments as-is
1679 match[2] = match[4] || match[5] || "";
1681 // Strip excess characters from unquoted arguments
1682 } else if ( unquoted && rpseudo.test( unquoted ) &&
1683 // Get excess from tokenize (recursively)
1684 (excess = tokenize( unquoted, true )) &&
1685 // advance to the next closing parenthesis
1686 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1688 // excess is a negative index
1689 match[0] = match[0].slice( 0, excess );
1690 match[2] = unquoted.slice( 0, excess );
1693 // Return only captures needed by the pseudo filter method (type and argument)
1694 return match.slice( 0, 3 );
1700 "TAG": function( nodeNameSelector ) {
1701 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1702 return nodeNameSelector === "*" ?
1703 function() { return true; } :
1705 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1709 "CLASS": function( className ) {
1710 var pattern = classCache[ className + " " ];
1713 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1714 classCache( className, function( elem ) {
1715 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1719 "ATTR": function( name, operator, check ) {
1720 return function( elem ) {
1721 var result = Sizzle.attr( elem, name );
1723 if ( result == null ) {
1724 return operator === "!=";
1732 return operator === "=" ? result === check :
1733 operator === "!=" ? result !== check :
1734 operator === "^=" ? check && result.indexOf( check ) === 0 :
1735 operator === "*=" ? check && result.indexOf( check ) > -1 :
1736 operator === "$=" ? check && result.slice( -check.length ) === check :
1737 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1738 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1743 "CHILD": function( type, what, argument, first, last ) {
1744 var simple = type.slice( 0, 3 ) !== "nth",
1745 forward = type.slice( -4 ) !== "last",
1746 ofType = what === "of-type";
1748 return first === 1 && last === 0 ?
1750 // Shortcut for :nth-*(n)
1752 return !!elem.parentNode;
1755 function( elem, context, xml ) {
1756 var cache, uniqueCache, outerCache, node, nodeIndex, start,
1757 dir = simple !== forward ? "nextSibling" : "previousSibling",
1758 parent = elem.parentNode,
1759 name = ofType && elem.nodeName.toLowerCase(),
1760 useCache = !xml && !ofType,
1765 // :(first|last|only)-(child|of-type)
1769 while ( (node = node[ dir ]) ) {
1771 node.nodeName.toLowerCase() === name :
1772 node.nodeType === 1 ) {
1777 // Reverse direction for :only-* (if we haven't yet done so)
1778 start = dir = type === "only" && !start && "nextSibling";
1783 start = [ forward ? parent.firstChild : parent.lastChild ];
1785 // non-xml :nth-child(...) stores cache data on `parent`
1786 if ( forward && useCache ) {
1788 // Seek `elem` from a previously-cached index
1790 // ...in a gzip-friendly way
1792 outerCache = node[ expando ] || (node[ expando ] = {});
1794 // Support: IE <9 only
1795 // Defend against cloned attroperties (jQuery gh-1709)
1796 uniqueCache = outerCache[ node.uniqueID ] ||
1797 (outerCache[ node.uniqueID ] = {});
1799 cache = uniqueCache[ type ] || [];
1800 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1801 diff = nodeIndex && cache[ 2 ];
1802 node = nodeIndex && parent.childNodes[ nodeIndex ];
1804 while ( (node = ++nodeIndex && node && node[ dir ] ||
1806 // Fallback to seeking `elem` from the start
1807 (diff = nodeIndex = 0) || start.pop()) ) {
1809 // When found, cache indexes on `parent` and break
1810 if ( node.nodeType === 1 && ++diff && node === elem ) {
1811 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1817 // Use previously-cached element index if available
1819 // ...in a gzip-friendly way
1821 outerCache = node[ expando ] || (node[ expando ] = {});
1823 // Support: IE <9 only
1824 // Defend against cloned attroperties (jQuery gh-1709)
1825 uniqueCache = outerCache[ node.uniqueID ] ||
1826 (outerCache[ node.uniqueID ] = {});
1828 cache = uniqueCache[ type ] || [];
1829 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1833 // xml :nth-child(...)
1834 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1835 if ( diff === false ) {
1836 // Use the same loop as above to seek `elem` from the start
1837 while ( (node = ++nodeIndex && node && node[ dir ] ||
1838 (diff = nodeIndex = 0) || start.pop()) ) {
1841 node.nodeName.toLowerCase() === name :
1842 node.nodeType === 1 ) &&
1845 // Cache the index of each encountered element
1847 outerCache = node[ expando ] || (node[ expando ] = {});
1849 // Support: IE <9 only
1850 // Defend against cloned attroperties (jQuery gh-1709)
1851 uniqueCache = outerCache[ node.uniqueID ] ||
1852 (outerCache[ node.uniqueID ] = {});
1854 uniqueCache[ type ] = [ dirruns, diff ];
1857 if ( node === elem ) {
1865 // Incorporate the offset, then check against cycle size
1867 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1872 "PSEUDO": function( pseudo, argument ) {
1873 // pseudo-class names are case-insensitive
1874 // http://www.w3.org/TR/selectors/#pseudo-classes
1875 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1876 // Remember that setFilters inherits from pseudos
1878 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1879 Sizzle.error( "unsupported pseudo: " + pseudo );
1881 // The user may use createPseudo to indicate that
1882 // arguments are needed to create the filter function
1883 // just as Sizzle does
1884 if ( fn[ expando ] ) {
1885 return fn( argument );
1888 // But maintain support for old signatures
1889 if ( fn.length > 1 ) {
1890 args = [ pseudo, pseudo, "", argument ];
1891 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1892 markFunction(function( seed, matches ) {
1894 matched = fn( seed, argument ),
1897 idx = indexOf( seed, matched[i] );
1898 seed[ idx ] = !( matches[ idx ] = matched[i] );
1902 return fn( elem, 0, args );
1911 // Potentially complex pseudos
1912 "not": markFunction(function( selector ) {
1913 // Trim the selector passed to compile
1914 // to avoid treating leading and trailing
1915 // spaces as combinators
1918 matcher = compile( selector.replace( rtrim, "$1" ) );
1920 return matcher[ expando ] ?
1921 markFunction(function( seed, matches, context, xml ) {
1923 unmatched = matcher( seed, null, xml, [] ),
1926 // Match elements unmatched by `matcher`
1928 if ( (elem = unmatched[i]) ) {
1929 seed[i] = !(matches[i] = elem);
1933 function( elem, context, xml ) {
1935 matcher( input, null, xml, results );
1936 // Don't keep the element (issue #299)
1938 return !results.pop();
1942 "has": markFunction(function( selector ) {
1943 return function( elem ) {
1944 return Sizzle( selector, elem ).length > 0;
1948 "contains": markFunction(function( text ) {
1949 text = text.replace( runescape, funescape );
1950 return function( elem ) {
1951 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1955 // "Whether an element is represented by a :lang() selector
1956 // is based solely on the element's language value
1957 // being equal to the identifier C,
1958 // or beginning with the identifier C immediately followed by "-".
1959 // The matching of C against the element's language value is performed case-insensitively.
1960 // The identifier C does not have to be a valid language name."
1961 // http://www.w3.org/TR/selectors/#lang-pseudo
1962 "lang": markFunction( function( lang ) {
1963 // lang value must be a valid identifier
1964 if ( !ridentifier.test(lang || "") ) {
1965 Sizzle.error( "unsupported lang: " + lang );
1967 lang = lang.replace( runescape, funescape ).toLowerCase();
1968 return function( elem ) {
1971 if ( (elemLang = documentIsHTML ?
1973 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1975 elemLang = elemLang.toLowerCase();
1976 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1978 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1984 "target": function( elem ) {
1985 var hash = window.location && window.location.hash;
1986 return hash && hash.slice( 1 ) === elem.id;
1989 "root": function( elem ) {
1990 return elem === docElem;
1993 "focus": function( elem ) {
1994 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1997 // Boolean properties
1998 "enabled": createDisabledPseudo( false ),
1999 "disabled": createDisabledPseudo( true ),
2001 "checked": function( elem ) {
2002 // In CSS3, :checked should return both checked and selected elements
2003 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2004 var nodeName = elem.nodeName.toLowerCase();
2005 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
2008 "selected": function( elem ) {
2009 // Accessing this property makes selected-by-default
2010 // options in Safari work properly
2011 if ( elem.parentNode ) {
2012 elem.parentNode.selectedIndex;
2015 return elem.selected === true;
2019 "empty": function( elem ) {
2020 // http://www.w3.org/TR/selectors/#empty-pseudo
2021 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2022 // but not by others (comment: 8; processing instruction: 7; etc.)
2023 // nodeType < 6 works because attributes (2) do not appear as children
2024 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
2025 if ( elem.nodeType < 6 ) {
2032 "parent": function( elem ) {
2033 return !Expr.pseudos["empty"]( elem );
2036 // Element/input types
2037 "header": function( elem ) {
2038 return rheader.test( elem.nodeName );
2041 "input": function( elem ) {
2042 return rinputs.test( elem.nodeName );
2045 "button": function( elem ) {
2046 var name = elem.nodeName.toLowerCase();
2047 return name === "input" && elem.type === "button" || name === "button";
2050 "text": function( elem ) {
2052 return elem.nodeName.toLowerCase() === "input" &&
2053 elem.type === "text" &&
2056 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2057 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
2060 // Position-in-collection
2061 "first": createPositionalPseudo(function() {
2065 "last": createPositionalPseudo(function( matchIndexes, length ) {
2066 return [ length - 1 ];
2069 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
2070 return [ argument < 0 ? argument + length : argument ];
2073 "even": createPositionalPseudo(function( matchIndexes, length ) {
2075 for ( ; i < length; i += 2 ) {
2076 matchIndexes.push( i );
2078 return matchIndexes;
2081 "odd": createPositionalPseudo(function( matchIndexes, length ) {
2083 for ( ; i < length; i += 2 ) {
2084 matchIndexes.push( i );
2086 return matchIndexes;
2089 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2090 var i = argument < 0 ? argument + length : argument;
2091 for ( ; --i >= 0; ) {
2092 matchIndexes.push( i );
2094 return matchIndexes;
2097 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2098 var i = argument < 0 ? argument + length : argument;
2099 for ( ; ++i < length; ) {
2100 matchIndexes.push( i );
2102 return matchIndexes;
2107 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2109 // Add button/input type pseudos
2110 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2111 Expr.pseudos[ i ] = createInputPseudo( i );
2113 for ( i in { submit: true, reset: true } ) {
2114 Expr.pseudos[ i ] = createButtonPseudo( i );
2117 // Easy API for creating new setFilters
2118 function setFilters() {}
2119 setFilters.prototype = Expr.filters = Expr.pseudos;
2120 Expr.setFilters = new setFilters();
2122 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2123 var matched, match, tokens, type,
2124 soFar, groups, preFilters,
2125 cached = tokenCache[ selector + " " ];
2128 return parseOnly ? 0 : cached.slice( 0 );
2133 preFilters = Expr.preFilter;
2137 // Comma and first run
2138 if ( !matched || (match = rcomma.exec( soFar )) ) {
2140 // Don't consume trailing commas as valid
2141 soFar = soFar.slice( match[0].length ) || soFar;
2143 groups.push( (tokens = []) );
2149 if ( (match = rcombinators.exec( soFar )) ) {
2150 matched = match.shift();
2153 // Cast descendant combinators to space
2154 type: match[0].replace( rtrim, " " )
2156 soFar = soFar.slice( matched.length );
2160 for ( type in Expr.filter ) {
2161 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2162 (match = preFilters[ type ]( match ))) ) {
2163 matched = match.shift();
2169 soFar = soFar.slice( matched.length );
2178 // Return the length of the invalid excess
2179 // if we're just parsing
2180 // Otherwise, throw an error or return tokens
2184 Sizzle.error( selector ) :
2186 tokenCache( selector, groups ).slice( 0 );
2189 function toSelector( tokens ) {
2191 len = tokens.length,
2193 for ( ; i < len; i++ ) {
2194 selector += tokens[i].value;
2199 function addCombinator( matcher, combinator, base ) {
2200 var dir = combinator.dir,
2201 skip = combinator.next,
2203 checkNonElements = base && key === "parentNode",
2206 return combinator.first ?
2207 // Check against closest ancestor/preceding element
2208 function( elem, context, xml ) {
2209 while ( (elem = elem[ dir ]) ) {
2210 if ( elem.nodeType === 1 || checkNonElements ) {
2211 return matcher( elem, context, xml );
2216 // Check against all ancestor/preceding elements
2217 function( elem, context, xml ) {
2218 var oldCache, uniqueCache, outerCache,
2219 newCache = [ dirruns, doneName ];
2221 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2223 while ( (elem = elem[ dir ]) ) {
2224 if ( elem.nodeType === 1 || checkNonElements ) {
2225 if ( matcher( elem, context, xml ) ) {
2231 while ( (elem = elem[ dir ]) ) {
2232 if ( elem.nodeType === 1 || checkNonElements ) {
2233 outerCache = elem[ expando ] || (elem[ expando ] = {});
2235 // Support: IE <9 only
2236 // Defend against cloned attroperties (jQuery gh-1709)
2237 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2239 if ( skip && skip === elem.nodeName.toLowerCase() ) {
2240 elem = elem[ dir ] || elem;
2241 } else if ( (oldCache = uniqueCache[ key ]) &&
2242 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2244 // Assign to newCache so results back-propagate to previous elements
2245 return (newCache[ 2 ] = oldCache[ 2 ]);
2247 // Reuse newcache so results back-propagate to previous elements
2248 uniqueCache[ key ] = newCache;
2250 // A match means we're done; a fail means we have to keep checking
2251 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2261 function elementMatcher( matchers ) {
2262 return matchers.length > 1 ?
2263 function( elem, context, xml ) {
2264 var i = matchers.length;
2266 if ( !matchers[i]( elem, context, xml ) ) {
2275 function multipleContexts( selector, contexts, results ) {
2277 len = contexts.length;
2278 for ( ; i < len; i++ ) {
2279 Sizzle( selector, contexts[i], results );
2284 function condense( unmatched, map, filter, context, xml ) {
2288 len = unmatched.length,
2289 mapped = map != null;
2291 for ( ; i < len; i++ ) {
2292 if ( (elem = unmatched[i]) ) {
2293 if ( !filter || filter( elem, context, xml ) ) {
2294 newUnmatched.push( elem );
2302 return newUnmatched;
2305 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2306 if ( postFilter && !postFilter[ expando ] ) {
2307 postFilter = setMatcher( postFilter );
2309 if ( postFinder && !postFinder[ expando ] ) {
2310 postFinder = setMatcher( postFinder, postSelector );
2312 return markFunction(function( seed, results, context, xml ) {
2316 preexisting = results.length,
2318 // Get initial elements from seed or context
2319 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2321 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2322 matcherIn = preFilter && ( seed || !selector ) ?
2323 condense( elems, preMap, preFilter, context, xml ) :
2326 matcherOut = matcher ?
2327 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2328 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2330 // ...intermediate processing is necessary
2333 // ...otherwise use results directly
2337 // Find primary matches
2339 matcher( matcherIn, matcherOut, context, xml );
2344 temp = condense( matcherOut, postMap );
2345 postFilter( temp, [], context, xml );
2347 // Un-match failing elements by moving them back to matcherIn
2350 if ( (elem = temp[i]) ) {
2351 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2357 if ( postFinder || preFilter ) {
2359 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2361 i = matcherOut.length;
2363 if ( (elem = matcherOut[i]) ) {
2364 // Restore matcherIn since elem is not yet a final match
2365 temp.push( (matcherIn[i] = elem) );
2368 postFinder( null, (matcherOut = []), temp, xml );
2371 // Move matched elements from seed to results to keep them synchronized
2372 i = matcherOut.length;
2374 if ( (elem = matcherOut[i]) &&
2375 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2377 seed[temp] = !(results[temp] = elem);
2382 // Add elements to results, through postFinder if defined
2384 matcherOut = condense(
2385 matcherOut === results ?
2386 matcherOut.splice( preexisting, matcherOut.length ) :
2390 postFinder( null, results, matcherOut, xml );
2392 push.apply( results, matcherOut );
2398 function matcherFromTokens( tokens ) {
2399 var checkContext, matcher, j,
2400 len = tokens.length,
2401 leadingRelative = Expr.relative[ tokens[0].type ],
2402 implicitRelative = leadingRelative || Expr.relative[" "],
2403 i = leadingRelative ? 1 : 0,
2405 // The foundational matcher ensures that elements are reachable from top-level context(s)
2406 matchContext = addCombinator( function( elem ) {
2407 return elem === checkContext;
2408 }, implicitRelative, true ),
2409 matchAnyContext = addCombinator( function( elem ) {
2410 return indexOf( checkContext, elem ) > -1;
2411 }, implicitRelative, true ),
2412 matchers = [ function( elem, context, xml ) {
2413 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2414 (checkContext = context).nodeType ?
2415 matchContext( elem, context, xml ) :
2416 matchAnyContext( elem, context, xml ) );
2417 // Avoid hanging onto element (issue #299)
2418 checkContext = null;
2422 for ( ; i < len; i++ ) {
2423 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2424 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2426 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2428 // Return special upon seeing a positional matcher
2429 if ( matcher[ expando ] ) {
2430 // Find the next relative operator (if any) for proper handling
2432 for ( ; j < len; j++ ) {
2433 if ( Expr.relative[ tokens[j].type ] ) {
2438 i > 1 && elementMatcher( matchers ),
2439 i > 1 && toSelector(
2440 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2441 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2442 ).replace( rtrim, "$1" ),
2444 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2445 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2446 j < len && toSelector( tokens )
2449 matchers.push( matcher );
2453 return elementMatcher( matchers );
2456 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2457 var bySet = setMatchers.length > 0,
2458 byElement = elementMatchers.length > 0,
2459 superMatcher = function( seed, context, xml, results, outermost ) {
2460 var elem, j, matcher,
2463 unmatched = seed && [],
2465 contextBackup = outermostContext,
2466 // We must always have either seed elements or outermost context
2467 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2468 // Use integer dirruns iff this is the outermost matcher
2469 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2473 outermostContext = context === document || context || outermost;
2476 // Add elements passing elementMatchers directly to results
2477 // Support: IE<9, Safari
2478 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2479 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2480 if ( byElement && elem ) {
2482 if ( !context && elem.ownerDocument !== document ) {
2483 setDocument( elem );
2484 xml = !documentIsHTML;
2486 while ( (matcher = elementMatchers[j++]) ) {
2487 if ( matcher( elem, context || document, xml) ) {
2488 results.push( elem );
2493 dirruns = dirrunsUnique;
2497 // Track unmatched elements for set filters
2499 // They will have gone through all possible matchers
2500 if ( (elem = !matcher && elem) ) {
2504 // Lengthen the array for every element, matched or not
2506 unmatched.push( elem );
2511 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2512 // makes the latter nonnegative.
2515 // Apply set filters to unmatched elements
2516 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2517 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2518 // no element matchers and no seed.
2519 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2520 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2521 // numerically zero.
2522 if ( bySet && i !== matchedCount ) {
2524 while ( (matcher = setMatchers[j++]) ) {
2525 matcher( unmatched, setMatched, context, xml );
2529 // Reintegrate element matches to eliminate the need for sorting
2530 if ( matchedCount > 0 ) {
2532 if ( !(unmatched[i] || setMatched[i]) ) {
2533 setMatched[i] = pop.call( results );
2538 // Discard index placeholder values to get only actual matches
2539 setMatched = condense( setMatched );
2542 // Add matches to results
2543 push.apply( results, setMatched );
2545 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2546 if ( outermost && !seed && setMatched.length > 0 &&
2547 ( matchedCount + setMatchers.length ) > 1 ) {
2549 Sizzle.uniqueSort( results );
2553 // Override manipulation of globals by nested matchers
2555 dirruns = dirrunsUnique;
2556 outermostContext = contextBackup;
2563 markFunction( superMatcher ) :
2567 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2570 elementMatchers = [],
2571 cached = compilerCache[ selector + " " ];
2574 // Generate a function of recursive functions that can be used to check each element
2576 match = tokenize( selector );
2580 cached = matcherFromTokens( match[i] );
2581 if ( cached[ expando ] ) {
2582 setMatchers.push( cached );
2584 elementMatchers.push( cached );
2588 // Cache the compiled function
2589 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2591 // Save selector and tokenization
2592 cached.selector = selector;
2598 * A low-level selection function that works with Sizzle's compiled
2599 * selector functions
2600 * @param {String|Function} selector A selector or a pre-compiled
2601 * selector function built with Sizzle.compile
2602 * @param {Element} context
2603 * @param {Array} [results]
2604 * @param {Array} [seed] A set of elements to match against
2606 select = Sizzle.select = function( selector, context, results, seed ) {
2607 var i, tokens, token, type, find,
2608 compiled = typeof selector === "function" && selector,
2609 match = !seed && tokenize( (selector = compiled.selector || selector) );
2611 results = results || [];
2613 // Try to minimize operations if there is only one selector in the list and no seed
2614 // (the latter of which guarantees us context)
2615 if ( match.length === 1 ) {
2617 // Reduce context if the leading compound selector is an ID
2618 tokens = match[0] = match[0].slice( 0 );
2619 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2620 support.getById && context.nodeType === 9 && documentIsHTML &&
2621 Expr.relative[ tokens[1].type ] ) {
2623 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2627 // Precompiled matchers will still verify ancestry, so step up a level
2628 } else if ( compiled ) {
2629 context = context.parentNode;
2632 selector = selector.slice( tokens.shift().value.length );
2635 // Fetch a seed set for right-to-left matching
2636 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2640 // Abort if we hit a combinator
2641 if ( Expr.relative[ (type = token.type) ] ) {
2644 if ( (find = Expr.find[ type ]) ) {
2645 // Search, expanding context for leading sibling combinators
2647 token.matches[0].replace( runescape, funescape ),
2648 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2651 // If seed is empty or no tokens remain, we can return early
2652 tokens.splice( i, 1 );
2653 selector = seed.length && toSelector( tokens );
2655 push.apply( results, seed );
2665 // Compile and execute a filtering function if one is not provided
2666 // Provide `match` to avoid retokenization if we modified the selector above
2667 ( compiled || compile( selector, match ) )(
2672 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2677 // One-time assignments
2680 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2682 // Support: Chrome 14-35+
2683 // Always assume duplicates if they aren't passed to the comparison function
2684 support.detectDuplicates = !!hasDuplicate;
2686 // Initialize against the default document
2689 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2690 // Detached nodes confoundingly follow *each other*
2691 support.sortDetached = assert(function( el ) {
2692 // Should return 1, but returns 4 (following)
2693 return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
2697 // Prevent attribute/property "interpolation"
2698 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2699 if ( !assert(function( el ) {
2700 el.innerHTML = "<a href='#'></a>";
2701 return el.firstChild.getAttribute("href") === "#" ;
2703 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2705 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2711 // Use defaultValue in place of getAttribute("value")
2712 if ( !support.attributes || !assert(function( el ) {
2713 el.innerHTML = "<input/>";
2714 el.firstChild.setAttribute( "value", "" );
2715 return el.firstChild.getAttribute( "value" ) === "";
2717 addHandle( "value", function( elem, name, isXML ) {
2718 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2719 return elem.defaultValue;
2725 // Use getAttributeNode to fetch booleans when getAttribute lies
2726 if ( !assert(function( el ) {
2727 return el.getAttribute("disabled") == null;
2729 addHandle( booleans, function( elem, name, isXML ) {
2732 return elem[ name ] === true ? name.toLowerCase() :
2733 (val = elem.getAttributeNode( name )) && val.specified ?
2746 jQuery.find = Sizzle;
2747 jQuery.expr = Sizzle.selectors;
2750 jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2751 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
2752 jQuery.text = Sizzle.getText;
2753 jQuery.isXMLDoc = Sizzle.isXML;
2754 jQuery.contains = Sizzle.contains;
2755 jQuery.escapeSelector = Sizzle.escape;
2760 var dir = function( elem, dir, until ) {
2762 truncate = until !== undefined;
2764 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2765 if ( elem.nodeType === 1 ) {
2766 if ( truncate && jQuery( elem ).is( until ) ) {
2769 matched.push( elem );
2776 var siblings = function( n, elem ) {
2779 for ( ; n; n = n.nextSibling ) {
2780 if ( n.nodeType === 1 && n !== elem ) {
2789 var rneedsContext = jQuery.expr.match.needsContext;
2791 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2795 var risSimple = /^.[^:#\[\.,]*$/;
2797 // Implement the identical functionality for filter and not
2798 function winnow( elements, qualifier, not ) {
2799 if ( jQuery.isFunction( qualifier ) ) {
2800 return jQuery.grep( elements, function( elem, i ) {
2801 return !!qualifier.call( elem, i, elem ) !== not;
2806 if ( qualifier.nodeType ) {
2807 return jQuery.grep( elements, function( elem ) {
2808 return ( elem === qualifier ) !== not;
2813 if ( typeof qualifier === "string" ) {
2814 if ( risSimple.test( qualifier ) ) {
2815 return jQuery.filter( qualifier, elements, not );
2818 qualifier = jQuery.filter( qualifier, elements );
2821 return jQuery.grep( elements, function( elem ) {
2822 return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1;
2826 jQuery.filter = function( expr, elems, not ) {
2827 var elem = elems[ 0 ];
2830 expr = ":not(" + expr + ")";
2833 return elems.length === 1 && elem.nodeType === 1 ?
2834 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2835 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2836 return elem.nodeType === 1;
2841 find: function( selector ) {
2846 if ( typeof selector !== "string" ) {
2847 return this.pushStack( jQuery( selector ).filter( function() {
2848 for ( i = 0; i < len; i++ ) {
2849 if ( jQuery.contains( self[ i ], this ) ) {
2856 ret = this.pushStack( [] );
2858 for ( i = 0; i < len; i++ ) {
2859 jQuery.find( selector, self[ i ], ret );
2862 return len > 1 ? jQuery.uniqueSort( ret ) : ret;
2864 filter: function( selector ) {
2865 return this.pushStack( winnow( this, selector || [], false ) );
2867 not: function( selector ) {
2868 return this.pushStack( winnow( this, selector || [], true ) );
2870 is: function( selector ) {
2874 // If this is a positional/relative selector, check membership in the returned set
2875 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2876 typeof selector === "string" && rneedsContext.test( selector ) ?
2877 jQuery( selector ) :
2885 // Initialize a jQuery object
2888 // A central reference to the root jQuery(document)
2891 // A simple way to check for HTML strings
2892 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2893 // Strict HTML recognition (#11290: must start with <)
2894 // Shortcut simple #id case for speed
2895 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2897 init = jQuery.fn.init = function( selector, context, root ) {
2900 // HANDLE: $(""), $(null), $(undefined), $(false)
2905 // Method init() accepts an alternate rootjQuery
2906 // so migrate can support jQuery.sub (gh-2101)
2907 root = root || rootjQuery;
2909 // Handle HTML strings
2910 if ( typeof selector === "string" ) {
2911 if ( selector[ 0 ] === "<" &&
2912 selector[ selector.length - 1 ] === ">" &&
2913 selector.length >= 3 ) {
2915 // Assume that strings that start and end with <> are HTML and skip the regex check
2916 match = [ null, selector, null ];
2919 match = rquickExpr.exec( selector );
2922 // Match html or make sure no context is specified for #id
2923 if ( match && ( match[ 1 ] || !context ) ) {
2925 // HANDLE: $(html) -> $(array)
2927 context = context instanceof jQuery ? context[ 0 ] : context;
2929 // Option to run scripts is true for back-compat
2930 // Intentionally let the error be thrown if parseHTML is not present
2931 jQuery.merge( this, jQuery.parseHTML(
2933 context && context.nodeType ? context.ownerDocument || context : document,
2937 // HANDLE: $(html, props)
2938 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2939 for ( match in context ) {
2941 // Properties of context are called as methods if possible
2942 if ( jQuery.isFunction( this[ match ] ) ) {
2943 this[ match ]( context[ match ] );
2945 // ...and otherwise set as attributes
2947 this.attr( match, context[ match ] );
2956 elem = document.getElementById( match[ 2 ] );
2960 // Inject the element directly into the jQuery object
2967 // HANDLE: $(expr, $(...))
2968 } else if ( !context || context.jquery ) {
2969 return ( context || root ).find( selector );
2971 // HANDLE: $(expr, context)
2972 // (which is just equivalent to: $(context).find(expr)
2974 return this.constructor( context ).find( selector );
2977 // HANDLE: $(DOMElement)
2978 } else if ( selector.nodeType ) {
2979 this[ 0 ] = selector;
2983 // HANDLE: $(function)
2984 // Shortcut for document ready
2985 } else if ( jQuery.isFunction( selector ) ) {
2986 return root.ready !== undefined ?
2987 root.ready( selector ) :
2989 // Execute immediately if ready is not present
2993 return jQuery.makeArray( selector, this );
2996 // Give the init function the jQuery prototype for later instantiation
2997 init.prototype = jQuery.fn;
2999 // Initialize central reference
3000 rootjQuery = jQuery( document );
3003 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
3005 // Methods guaranteed to produce a unique set when starting from a unique set
3006 guaranteedUnique = {
3014 has: function( target ) {
3015 var targets = jQuery( target, this ),
3018 return this.filter( function() {
3020 for ( ; i < l; i++ ) {
3021 if ( jQuery.contains( this, targets[ i ] ) ) {
3028 closest: function( selectors, context ) {
3033 targets = typeof selectors !== "string" && jQuery( selectors );
3035 // Positional selectors never match, since there's no _selection_ context
3036 if ( !rneedsContext.test( selectors ) ) {
3037 for ( ; i < l; i++ ) {
3038 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3040 // Always skip document fragments
3041 if ( cur.nodeType < 11 && ( targets ?
3042 targets.index( cur ) > -1 :
3044 // Don't pass non-elements to Sizzle
3045 cur.nodeType === 1 &&
3046 jQuery.find.matchesSelector( cur, selectors ) ) ) {
3048 matched.push( cur );
3055 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3058 // Determine the position of an element within the set
3059 index: function( elem ) {
3061 // No argument, return index in parent
3063 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3066 // Index in selector
3067 if ( typeof elem === "string" ) {
3068 return indexOf.call( jQuery( elem ), this[ 0 ] );
3071 // Locate the position of the desired element
3072 return indexOf.call( this,
3074 // If it receives a jQuery object, the first element is used
3075 elem.jquery ? elem[ 0 ] : elem
3079 add: function( selector, context ) {
3080 return this.pushStack(
3082 jQuery.merge( this.get(), jQuery( selector, context ) )
3087 addBack: function( selector ) {
3088 return this.add( selector == null ?
3089 this.prevObject : this.prevObject.filter( selector )
3094 function sibling( cur, dir ) {
3095 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
3100 parent: function( elem ) {
3101 var parent = elem.parentNode;
3102 return parent && parent.nodeType !== 11 ? parent : null;
3104 parents: function( elem ) {
3105 return dir( elem, "parentNode" );
3107 parentsUntil: function( elem, i, until ) {
3108 return dir( elem, "parentNode", until );
3110 next: function( elem ) {
3111 return sibling( elem, "nextSibling" );
3113 prev: function( elem ) {
3114 return sibling( elem, "previousSibling" );
3116 nextAll: function( elem ) {
3117 return dir( elem, "nextSibling" );
3119 prevAll: function( elem ) {
3120 return dir( elem, "previousSibling" );
3122 nextUntil: function( elem, i, until ) {
3123 return dir( elem, "nextSibling", until );
3125 prevUntil: function( elem, i, until ) {
3126 return dir( elem, "previousSibling", until );
3128 siblings: function( elem ) {
3129 return siblings( ( elem.parentNode || {} ).firstChild, elem );
3131 children: function( elem ) {
3132 return siblings( elem.firstChild );
3134 contents: function( elem ) {
3135 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
3137 }, function( name, fn ) {
3138 jQuery.fn[ name ] = function( until, selector ) {
3139 var matched = jQuery.map( this, fn, until );
3141 if ( name.slice( -5 ) !== "Until" ) {
3145 if ( selector && typeof selector === "string" ) {
3146 matched = jQuery.filter( selector, matched );
3149 if ( this.length > 1 ) {
3151 // Remove duplicates
3152 if ( !guaranteedUnique[ name ] ) {
3153 jQuery.uniqueSort( matched );
3156 // Reverse order for parents* and prev-derivatives
3157 if ( rparentsprev.test( name ) ) {
3162 return this.pushStack( matched );
3165 var rnotwhite = ( /\S+/g );
3169 // Convert String-formatted options into Object-formatted ones
3170 function createOptions( options ) {
3172 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3173 object[ flag ] = true;
3179 * Create a callback list using the following parameters:
3181 * options: an optional list of space-separated options that will change how
3182 * the callback list behaves or a more traditional option object
3184 * By default a callback list will act like an event callback list and can be
3185 * "fired" multiple times.
3189 * once: will ensure the callback list can only be fired once (like a Deferred)
3191 * memory: will keep track of previous values and will call any callback added
3192 * after the list has been fired right away with the latest "memorized"
3193 * values (like a Deferred)
3195 * unique: will ensure a callback can only be added once (no duplicate in the list)
3197 * stopOnFalse: interrupt callings when a callback returns false
3200 jQuery.Callbacks = function( options ) {
3202 // Convert options from String-formatted to Object-formatted if needed
3203 // (we check in cache first)
3204 options = typeof options === "string" ?
3205 createOptions( options ) :
3206 jQuery.extend( {}, options );
3208 var // Flag to know if list is currently firing
3211 // Last fire value for non-forgettable lists
3214 // Flag to know if list was already fired
3217 // Flag to prevent firing
3220 // Actual callback list
3223 // Queue of execution data for repeatable lists
3226 // Index of currently firing callback (modified by add/remove as needed)
3232 // Enforce single-firing
3233 locked = options.once;
3235 // Execute callbacks for all pending executions,
3236 // respecting firingIndex overrides and runtime changes
3237 fired = firing = true;
3238 for ( ; queue.length; firingIndex = -1 ) {
3239 memory = queue.shift();
3240 while ( ++firingIndex < list.length ) {
3242 // Run callback and check for early termination
3243 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3244 options.stopOnFalse ) {
3246 // Jump to end and forget the data so .add doesn't re-fire
3247 firingIndex = list.length;
3253 // Forget the data if we're done with it
3254 if ( !options.memory ) {
3260 // Clean up if we're done firing for good
3263 // Keep an empty list if we have data for future add calls
3267 // Otherwise, this object is spent
3274 // Actual Callbacks object
3277 // Add a callback or a collection of callbacks to the list
3281 // If we have memory from a past run, we should fire after adding
3282 if ( memory && !firing ) {
3283 firingIndex = list.length - 1;
3284 queue.push( memory );
3287 ( function add( args ) {
3288 jQuery.each( args, function( _, arg ) {
3289 if ( jQuery.isFunction( arg ) ) {
3290 if ( !options.unique || !self.has( arg ) ) {
3293 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
3295 // Inspect recursively
3301 if ( memory && !firing ) {
3308 // Remove a callback from the list
3309 remove: function() {
3310 jQuery.each( arguments, function( _, arg ) {
3312 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3313 list.splice( index, 1 );
3315 // Handle firing indexes
3316 if ( index <= firingIndex ) {
3324 // Check if a given callback is in the list.
3325 // If no argument is given, return whether or not list has callbacks attached.
3326 has: function( fn ) {
3328 jQuery.inArray( fn, list ) > -1 :
3332 // Remove all callbacks from the list
3340 // Disable .fire and .add
3341 // Abort any current/pending executions
3342 // Clear all callbacks and values
3343 disable: function() {
3344 locked = queue = [];
3348 disabled: function() {
3353 // Also disable .add unless we have memory (since it would have no effect)
3354 // Abort any pending executions
3356 locked = queue = [];
3357 if ( !memory && !firing ) {
3362 locked: function() {
3366 // Call all callbacks with the given context and arguments
3367 fireWith: function( context, args ) {
3370 args = [ context, args.slice ? args.slice() : args ];
3379 // Call all the callbacks with the given arguments
3381 self.fireWith( this, arguments );
3385 // To know if the callbacks have already been called at least once
3395 function Identity( v ) {
3398 function Thrower( ex ) {
3402 function adoptValue( value, resolve, reject ) {
3407 // Check for promise aspect first to privilege synchronous behavior
3408 if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
3409 method.call( value ).done( resolve ).fail( reject );
3412 } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
3413 method.call( value, resolve, reject );
3415 // Other non-thenables
3418 // Support: Android 4.0 only
3419 // Strict mode functions invoked without .call/.apply get global-object context
3420 resolve.call( undefined, value );
3423 // For Promises/A+, convert exceptions into rejections
3424 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3425 // Deferred#then to conditionally suppress rejection.
3428 // Support: Android 4.0 only
3429 // Strict mode functions invoked without .call/.apply get global-object context
3430 reject.call( undefined, value );
3436 Deferred: function( func ) {
3439 // action, add listener, callbacks,
3440 // ... .then handlers, argument index, [final state]
3441 [ "notify", "progress", jQuery.Callbacks( "memory" ),
3442 jQuery.Callbacks( "memory" ), 2 ],
3443 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
3444 jQuery.Callbacks( "once memory" ), 0, "resolved" ],
3445 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
3446 jQuery.Callbacks( "once memory" ), 1, "rejected" ]
3453 always: function() {
3454 deferred.done( arguments ).fail( arguments );
3457 "catch": function( fn ) {
3458 return promise.then( null, fn );
3461 // Keep pipe for back-compat
3462 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3463 var fns = arguments;
3465 return jQuery.Deferred( function( newDefer ) {
3466 jQuery.each( tuples, function( i, tuple ) {
3468 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3469 var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
3471 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3472 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3473 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3474 deferred[ tuple[ 1 ] ]( function() {
3475 var returned = fn && fn.apply( this, arguments );
3476 if ( returned && jQuery.isFunction( returned.promise ) ) {
3478 .progress( newDefer.notify )
3479 .done( newDefer.resolve )
3480 .fail( newDefer.reject );
3482 newDefer[ tuple[ 0 ] + "With" ](
3484 fn ? [ returned ] : arguments
3492 then: function( onFulfilled, onRejected, onProgress ) {
3494 function resolve( depth, deferred, handler, special ) {
3498 mightThrow = function() {
3501 // Support: Promises/A+ section 2.3.3.3.3
3502 // https://promisesaplus.com/#point-59
3503 // Ignore double-resolution attempts
3504 if ( depth < maxDepth ) {
3508 returned = handler.apply( that, args );
3510 // Support: Promises/A+ section 2.3.1
3511 // https://promisesaplus.com/#point-48
3512 if ( returned === deferred.promise() ) {
3513 throw new TypeError( "Thenable self-resolution" );
3516 // Support: Promises/A+ sections 2.3.3.1, 3.5
3517 // https://promisesaplus.com/#point-54
3518 // https://promisesaplus.com/#point-75
3519 // Retrieve `then` only once
3522 // Support: Promises/A+ section 2.3.4
3523 // https://promisesaplus.com/#point-64
3524 // Only check objects and functions for thenability
3525 ( typeof returned === "object" ||
3526 typeof returned === "function" ) &&
3529 // Handle a returned thenable
3530 if ( jQuery.isFunction( then ) ) {
3532 // Special processors (notify) just wait for resolution
3536 resolve( maxDepth, deferred, Identity, special ),
3537 resolve( maxDepth, deferred, Thrower, special )
3540 // Normal processors (resolve) also hook into progress
3543 // ...and disregard older resolution values
3548 resolve( maxDepth, deferred, Identity, special ),
3549 resolve( maxDepth, deferred, Thrower, special ),
3550 resolve( maxDepth, deferred, Identity,
3551 deferred.notifyWith )
3555 // Handle all other returned values
3558 // Only substitute handlers pass on context
3559 // and multiple values (non-spec behavior)
3560 if ( handler !== Identity ) {
3562 args = [ returned ];
3565 // Process the value(s)
3566 // Default process is resolve
3567 ( special || deferred.resolveWith )( that, args );
3571 // Only normal processors (resolve) catch and reject exceptions
3579 if ( jQuery.Deferred.exceptionHook ) {
3580 jQuery.Deferred.exceptionHook( e,
3581 process.stackTrace );
3584 // Support: Promises/A+ section 2.3.3.3.4.1
3585 // https://promisesaplus.com/#point-61
3586 // Ignore post-resolution exceptions
3587 if ( depth + 1 >= maxDepth ) {
3589 // Only substitute handlers pass on context
3590 // and multiple values (non-spec behavior)
3591 if ( handler !== Thrower ) {
3596 deferred.rejectWith( that, args );
3601 // Support: Promises/A+ section 2.3.3.3.1
3602 // https://promisesaplus.com/#point-57
3603 // Re-resolve promises immediately to dodge false rejection from
3604 // subsequent errors
3609 // Call an optional hook to record the stack, in case of exception
3610 // since it's otherwise lost when execution goes async
3611 if ( jQuery.Deferred.getStackHook ) {
3612 process.stackTrace = jQuery.Deferred.getStackHook();
3614 window.setTimeout( process );
3619 return jQuery.Deferred( function( newDefer ) {
3621 // progress_handlers.add( ... )
3622 tuples[ 0 ][ 3 ].add(
3626 jQuery.isFunction( onProgress ) ?
3633 // fulfilled_handlers.add( ... )
3634 tuples[ 1 ][ 3 ].add(
3638 jQuery.isFunction( onFulfilled ) ?
3644 // rejected_handlers.add( ... )
3645 tuples[ 2 ][ 3 ].add(
3649 jQuery.isFunction( onRejected ) ?
3657 // Get a promise for this deferred
3658 // If obj is provided, the promise aspect is added to the object
3659 promise: function( obj ) {
3660 return obj != null ? jQuery.extend( obj, promise ) : promise;
3665 // Add list-specific methods
3666 jQuery.each( tuples, function( i, tuple ) {
3667 var list = tuple[ 2 ],
3668 stateString = tuple[ 5 ];
3670 // promise.progress = list.add
3671 // promise.done = list.add
3672 // promise.fail = list.add
3673 promise[ tuple[ 1 ] ] = list.add;
3676 if ( stateString ) {
3680 // state = "resolved" (i.e., fulfilled)
3681 // state = "rejected"
3682 state = stateString;
3685 // rejected_callbacks.disable
3686 // fulfilled_callbacks.disable
3687 tuples[ 3 - i ][ 2 ].disable,
3689 // progress_callbacks.lock
3690 tuples[ 0 ][ 2 ].lock
3694 // progress_handlers.fire
3695 // fulfilled_handlers.fire
3696 // rejected_handlers.fire
3697 list.add( tuple[ 3 ].fire );
3699 // deferred.notify = function() { deferred.notifyWith(...) }
3700 // deferred.resolve = function() { deferred.resolveWith(...) }
3701 // deferred.reject = function() { deferred.rejectWith(...) }
3702 deferred[ tuple[ 0 ] ] = function() {
3703 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
3707 // deferred.notifyWith = list.fireWith
3708 // deferred.resolveWith = list.fireWith
3709 // deferred.rejectWith = list.fireWith
3710 deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3713 // Make the deferred a promise
3714 promise.promise( deferred );
3716 // Call given func if any
3718 func.call( deferred, deferred );
3726 when: function( singleValue ) {
3729 // count of uncompleted subordinates
3730 remaining = arguments.length,
3732 // count of unprocessed arguments
3735 // subordinate fulfillment data
3736 resolveContexts = Array( i ),
3737 resolveValues = slice.call( arguments ),
3739 // the master Deferred
3740 master = jQuery.Deferred(),
3742 // subordinate callback factory
3743 updateFunc = function( i ) {
3744 return function( value ) {
3745 resolveContexts[ i ] = this;
3746 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3747 if ( !( --remaining ) ) {
3748 master.resolveWith( resolveContexts, resolveValues );
3753 // Single- and empty arguments are adopted like Promise.resolve
3754 if ( remaining <= 1 ) {
3755 adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject );
3757 // Use .then() to unwrap secondary thenables (cf. gh-3000)
3758 if ( master.state() === "pending" ||
3759 jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
3761 return master.then();
3765 // Multiple arguments are aggregated like Promise.all array elements
3767 adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
3770 return master.promise();
3775 // These usually indicate a programmer mistake during development,
3776 // warn about them ASAP rather than swallowing them by default.
3777 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
3779 jQuery.Deferred.exceptionHook = function( error, stack ) {
3781 // Support: IE 8 - 9 only
3782 // Console exists when dev tools are open, which can happen at any time
3783 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
3784 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
3791 jQuery.readyException = function( error ) {
3792 window.setTimeout( function() {
3800 // The deferred used on DOM ready
3801 var readyList = jQuery.Deferred();
3803 jQuery.fn.ready = function( fn ) {
3808 // Wrap jQuery.readyException in a function so that the lookup
3809 // happens at the time of error handling instead of callback
3811 .catch( function( error ) {
3812 jQuery.readyException( error );
3820 // Is the DOM ready to be used? Set to true once it occurs.
3823 // A counter to track how many items to wait for before
3824 // the ready event fires. See #6781
3827 // Hold (or release) the ready event
3828 holdReady: function( hold ) {
3832 jQuery.ready( true );
3836 // Handle when the DOM is ready
3837 ready: function( wait ) {
3839 // Abort if there are pending holds or we're already ready
3840 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3844 // Remember that the DOM is ready
3845 jQuery.isReady = true;
3847 // If a normal DOM Ready event fired, decrement, and wait if need be
3848 if ( wait !== true && --jQuery.readyWait > 0 ) {
3852 // If there are functions bound, to execute
3853 readyList.resolveWith( document, [ jQuery ] );
3857 jQuery.ready.then = readyList.then;
3859 // The ready event handler and self cleanup method
3860 function completed() {
3861 document.removeEventListener( "DOMContentLoaded", completed );
3862 window.removeEventListener( "load", completed );
3866 // Catch cases where $(document).ready() is called
3867 // after the browser event has already occurred.
3868 // Support: IE <=9 - 10 only
3869 // Older IE sometimes signals "interactive" too soon
3870 if ( document.readyState === "complete" ||
3871 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3873 // Handle it asynchronously to allow scripts the opportunity to delay ready
3874 window.setTimeout( jQuery.ready );
3878 // Use the handy event callback
3879 document.addEventListener( "DOMContentLoaded", completed );
3881 // A fallback to window.onload, that will always work
3882 window.addEventListener( "load", completed );
3888 // Multifunctional method to get and set values of a collection
3889 // The value/s can optionally be executed if it's a function
3890 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3896 if ( jQuery.type( key ) === "object" ) {
3899 access( elems, fn, i, key[ i ], true, emptyGet, raw );
3903 } else if ( value !== undefined ) {
3906 if ( !jQuery.isFunction( value ) ) {
3912 // Bulk operations run against the entire set
3914 fn.call( elems, value );
3917 // ...except when executing function values
3920 fn = function( elem, key, value ) {
3921 return bulk.call( jQuery( elem ), value );
3927 for ( ; i < len; i++ ) {
3929 elems[ i ], key, raw ?
3931 value.call( elems[ i ], i, fn( elems[ i ], key ) )
3943 len ? fn( elems[ 0 ], key ) : emptyGet;
3945 var acceptData = function( owner ) {
3949 // - Node.ELEMENT_NODE
3950 // - Node.DOCUMENT_NODE
3953 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
3960 this.expando = jQuery.expando + Data.uid++;
3967 cache: function( owner ) {
3969 // Check if the owner object already has a cache
3970 var value = owner[ this.expando ];
3972 // If not, create one
3976 // We can accept data for non-element nodes in modern browsers,
3977 // but we should not, see #8335.
3978 // Always return an empty object.
3979 if ( acceptData( owner ) ) {
3981 // If it is a node unlikely to be stringify-ed or looped over
3982 // use plain assignment
3983 if ( owner.nodeType ) {
3984 owner[ this.expando ] = value;
3986 // Otherwise secure it in a non-enumerable property
3987 // configurable must be true to allow the property to be
3988 // deleted when data is removed
3990 Object.defineProperty( owner, this.expando, {
4000 set: function( owner, data, value ) {
4002 cache = this.cache( owner );
4004 // Handle: [ owner, key, value ] args
4005 // Always use camelCase key (gh-2257)
4006 if ( typeof data === "string" ) {
4007 cache[ jQuery.camelCase( data ) ] = value;
4009 // Handle: [ owner, { properties } ] args
4012 // Copy the properties one-by-one to the cache object
4013 for ( prop in data ) {
4014 cache[ jQuery.camelCase( prop ) ] = data[ prop ];
4019 get: function( owner, key ) {
4020 return key === undefined ?
4021 this.cache( owner ) :
4023 // Always use camelCase key (gh-2257)
4024 owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
4026 access: function( owner, key, value ) {
4028 // In cases where either:
4030 // 1. No key was specified
4031 // 2. A string key was specified, but no value provided
4033 // Take the "read" path and allow the get method to determine
4034 // which value to return, respectively either:
4036 // 1. The entire cache object
4037 // 2. The data stored at the key
4039 if ( key === undefined ||
4040 ( ( key && typeof key === "string" ) && value === undefined ) ) {
4042 return this.get( owner, key );
4045 // When the key is not a string, or both a key and value
4046 // are specified, set or extend (existing objects) with either:
4048 // 1. An object of properties
4049 // 2. A key and value
4051 this.set( owner, key, value );
4053 // Since the "set" path can have two possible entry points
4054 // return the expected data based on which path was taken[*]
4055 return value !== undefined ? value : key;
4057 remove: function( owner, key ) {
4059 cache = owner[ this.expando ];
4061 if ( cache === undefined ) {
4065 if ( key !== undefined ) {
4067 // Support array or space separated string of keys
4068 if ( jQuery.isArray( key ) ) {
4070 // If key is an array of keys...
4071 // We always set camelCase keys, so remove that.
4072 key = key.map( jQuery.camelCase );
4074 key = jQuery.camelCase( key );
4076 // If a key with the spaces exists, use it.
4077 // Otherwise, create an array by matching non-whitespace
4078 key = key in cache ?
4080 ( key.match( rnotwhite ) || [] );
4086 delete cache[ key[ i ] ];
4090 // Remove the expando if there's no more data
4091 if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
4093 // Support: Chrome <=35 - 45
4094 // Webkit & Blink performance suffers when deleting properties
4095 // from DOM nodes, so set to undefined instead
4096 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4097 if ( owner.nodeType ) {
4098 owner[ this.expando ] = undefined;
4100 delete owner[ this.expando ];
4104 hasData: function( owner ) {
4105 var cache = owner[ this.expando ];
4106 return cache !== undefined && !jQuery.isEmptyObject( cache );
4109 var dataPriv = new Data();
4111 var dataUser = new Data();
4115 // Implementation Summary
4117 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4118 // 2. Improve the module's maintainability by reducing the storage
4119 // paths to a single mechanism.
4120 // 3. Use the same single mechanism to support "private" and "user" data.
4121 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4122 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4123 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4125 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4126 rmultiDash = /[A-Z]/g;
4128 function dataAttr( elem, key, data ) {
4131 // If nothing was found internally, try to fetch any
4132 // data from the HTML5 data-* attribute
4133 if ( data === undefined && elem.nodeType === 1 ) {
4134 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
4135 data = elem.getAttribute( name );
4137 if ( typeof data === "string" ) {
4139 data = data === "true" ? true :
4140 data === "false" ? false :
4141 data === "null" ? null :
4143 // Only convert to a number if it doesn't change the string
4144 +data + "" === data ? +data :
4145 rbrace.test( data ) ? JSON.parse( data ) :
4149 // Make sure we set the data so it isn't changed later
4150 dataUser.set( elem, key, data );
4159 hasData: function( elem ) {
4160 return dataUser.hasData( elem ) || dataPriv.hasData( elem );
4163 data: function( elem, name, data ) {
4164 return dataUser.access( elem, name, data );
4167 removeData: function( elem, name ) {
4168 dataUser.remove( elem, name );
4171 // TODO: Now that all calls to _data and _removeData have been replaced
4172 // with direct calls to dataPriv methods, these can be deprecated.
4173 _data: function( elem, name, data ) {
4174 return dataPriv.access( elem, name, data );
4177 _removeData: function( elem, name ) {
4178 dataPriv.remove( elem, name );
4183 data: function( key, value ) {
4186 attrs = elem && elem.attributes;
4189 if ( key === undefined ) {
4190 if ( this.length ) {
4191 data = dataUser.get( elem );
4193 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
4197 // Support: IE 11 only
4198 // The attrs elements can be null (#14894)
4200 name = attrs[ i ].name;
4201 if ( name.indexOf( "data-" ) === 0 ) {
4202 name = jQuery.camelCase( name.slice( 5 ) );
4203 dataAttr( elem, name, data[ name ] );
4207 dataPriv.set( elem, "hasDataAttrs", true );
4214 // Sets multiple values
4215 if ( typeof key === "object" ) {
4216 return this.each( function() {
4217 dataUser.set( this, key );
4221 return access( this, function( value ) {
4224 // The calling jQuery object (element matches) is not empty
4225 // (and therefore has an element appears at this[ 0 ]) and the
4226 // `value` parameter was not undefined. An empty jQuery object
4227 // will result in `undefined` for elem = this[ 0 ] which will
4228 // throw an exception if an attempt to read a data cache is made.
4229 if ( elem && value === undefined ) {
4231 // Attempt to get data from the cache
4232 // The key will always be camelCased in Data
4233 data = dataUser.get( elem, key );
4234 if ( data !== undefined ) {
4238 // Attempt to "discover" the data in
4239 // HTML5 custom data-* attrs
4240 data = dataAttr( elem, key );
4241 if ( data !== undefined ) {
4245 // We tried really hard, but the data doesn't exist.
4250 this.each( function() {
4252 // We always store the camelCased key
4253 dataUser.set( this, key, value );
4255 }, null, value, arguments.length > 1, null, true );
4258 removeData: function( key ) {
4259 return this.each( function() {
4260 dataUser.remove( this, key );
4267 queue: function( elem, type, data ) {
4271 type = ( type || "fx" ) + "queue";
4272 queue = dataPriv.get( elem, type );
4274 // Speed up dequeue by getting out quickly if this is just a lookup
4276 if ( !queue || jQuery.isArray( data ) ) {
4277 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
4286 dequeue: function( elem, type ) {
4287 type = type || "fx";
4289 var queue = jQuery.queue( elem, type ),
4290 startLength = queue.length,
4292 hooks = jQuery._queueHooks( elem, type ),
4294 jQuery.dequeue( elem, type );
4297 // If the fx queue is dequeued, always remove the progress sentinel
4298 if ( fn === "inprogress" ) {
4305 // Add a progress sentinel to prevent the fx queue from being
4306 // automatically dequeued
4307 if ( type === "fx" ) {
4308 queue.unshift( "inprogress" );
4311 // Clear up the last queue stop function
4313 fn.call( elem, next, hooks );
4316 if ( !startLength && hooks ) {
4321 // Not public - generate a queueHooks object, or return the current one
4322 _queueHooks: function( elem, type ) {
4323 var key = type + "queueHooks";
4324 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
4325 empty: jQuery.Callbacks( "once memory" ).add( function() {
4326 dataPriv.remove( elem, [ type + "queue", key ] );
4333 queue: function( type, data ) {
4336 if ( typeof type !== "string" ) {
4342 if ( arguments.length < setter ) {
4343 return jQuery.queue( this[ 0 ], type );
4346 return data === undefined ?
4348 this.each( function() {
4349 var queue = jQuery.queue( this, type, data );
4351 // Ensure a hooks for this queue
4352 jQuery._queueHooks( this, type );
4354 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4355 jQuery.dequeue( this, type );
4359 dequeue: function( type ) {
4360 return this.each( function() {
4361 jQuery.dequeue( this, type );
4364 clearQueue: function( type ) {
4365 return this.queue( type || "fx", [] );
4368 // Get a promise resolved when queues of a certain type
4369 // are emptied (fx is the type by default)
4370 promise: function( type, obj ) {
4373 defer = jQuery.Deferred(),
4376 resolve = function() {
4377 if ( !( --count ) ) {
4378 defer.resolveWith( elements, [ elements ] );
4382 if ( typeof type !== "string" ) {
4386 type = type || "fx";
4389 tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
4390 if ( tmp && tmp.empty ) {
4392 tmp.empty.add( resolve );
4396 return defer.promise( obj );
4399 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4401 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4404 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4406 var isHiddenWithinTree = function( elem, el ) {
4408 // isHiddenWithinTree might be called from jQuery#filter function;
4409 // in that case, element will be second argument
4412 // Inline style trumps all
4413 return elem.style.display === "none" ||
4414 elem.style.display === "" &&
4416 // Otherwise, check computed style
4417 // Support: Firefox <=43 - 45
4418 // Disconnected elements can have computed display: none, so first confirm that elem is
4420 jQuery.contains( elem.ownerDocument, elem ) &&
4422 jQuery.css( elem, "display" ) === "none";
4425 var swap = function( elem, options, callback, args ) {
4429 // Remember the old values, and insert the new ones
4430 for ( name in options ) {
4431 old[ name ] = elem.style[ name ];
4432 elem.style[ name ] = options[ name ];
4435 ret = callback.apply( elem, args || [] );
4437 // Revert the old values
4438 for ( name in options ) {
4439 elem.style[ name ] = old[ name ];
4448 function adjustCSS( elem, prop, valueParts, tween ) {
4452 currentValue = tween ?
4457 return jQuery.css( elem, prop, "" );
4459 initial = currentValue(),
4460 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4462 // Starting value computation is required for potential unit mismatches
4463 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4464 rcssNum.exec( jQuery.css( elem, prop ) );
4466 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4468 // Trust units reported by jQuery.css
4469 unit = unit || initialInUnit[ 3 ];
4471 // Make sure we update the tween properties later on
4472 valueParts = valueParts || [];
4474 // Iteratively approximate from a nonzero starting point
4475 initialInUnit = +initial || 1;
4479 // If previous iteration zeroed out, double until we get *something*.
4480 // Use string for doubling so we don't accidentally see scale as unchanged below
4481 scale = scale || ".5";
4484 initialInUnit = initialInUnit / scale;
4485 jQuery.style( elem, prop, initialInUnit + unit );
4487 // Update scale, tolerating zero or NaN from tween.cur()
4488 // Break the loop if scale is unchanged or perfect, or if we've just had enough.
4490 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
4495 initialInUnit = +initialInUnit || +initial || 0;
4497 // Apply relative offset (+=/-=) if specified
4498 adjusted = valueParts[ 1 ] ?
4499 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4503 tween.start = initialInUnit;
4504 tween.end = adjusted;
4511 var defaultDisplayMap = {};
4513 function getDefaultDisplay( elem ) {
4515 doc = elem.ownerDocument,
4516 nodeName = elem.nodeName,
4517 display = defaultDisplayMap[ nodeName ];
4523 temp = doc.body.appendChild( doc.createElement( nodeName ) ),
4524 display = jQuery.css( temp, "display" );
4526 temp.parentNode.removeChild( temp );
4528 if ( display === "none" ) {
4531 defaultDisplayMap[ nodeName ] = display;
4536 function showHide( elements, show ) {
4540 length = elements.length;
4542 // Determine new display value for elements that need to change
4543 for ( ; index < length; index++ ) {
4544 elem = elements[ index ];
4545 if ( !elem.style ) {
4549 display = elem.style.display;
4552 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4553 // check is required in this first loop unless we have a nonempty display value (either
4554 // inline or about-to-be-restored)
4555 if ( display === "none" ) {
4556 values[ index ] = dataPriv.get( elem, "display" ) || null;
4557 if ( !values[ index ] ) {
4558 elem.style.display = "";
4561 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
4562 values[ index ] = getDefaultDisplay( elem );
4565 if ( display !== "none" ) {
4566 values[ index ] = "none";
4568 // Remember what we're overwriting
4569 dataPriv.set( elem, "display", display );
4574 // Set the display of the elements in a second loop to avoid constant reflow
4575 for ( index = 0; index < length; index++ ) {
4576 if ( values[ index ] != null ) {
4577 elements[ index ].style.display = values[ index ];
4586 return showHide( this, true );
4589 return showHide( this );
4591 toggle: function( state ) {
4592 if ( typeof state === "boolean" ) {
4593 return state ? this.show() : this.hide();
4596 return this.each( function() {
4597 if ( isHiddenWithinTree( this ) ) {
4598 jQuery( this ).show();
4600 jQuery( this ).hide();
4605 var rcheckableType = ( /^(?:checkbox|radio)$/i );
4607 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i );
4609 var rscriptType = ( /^$|\/(?:java|ecma)script/i );
4613 // We have to close these tags to support XHTML (#13200)
4616 // Support: IE <=9 only
4617 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4619 // XHTML parsers do not magically insert elements in the
4620 // same way that tag soup parsers do. So we cannot shorten
4621 // this by omitting <tbody> or other required elements.
4622 thead: [ 1, "<table>", "</table>" ],
4623 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4624 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4625 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4627 _default: [ 0, "", "" ]
4630 // Support: IE <=9 only
4631 wrapMap.optgroup = wrapMap.option;
4633 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4634 wrapMap.th = wrapMap.td;
4637 function getAll( context, tag ) {
4639 // Support: IE <=9 - 11 only
4640 // Use typeof to avoid zero-argument method invocation on host objects (#15151)
4641 var ret = typeof context.getElementsByTagName !== "undefined" ?
4642 context.getElementsByTagName( tag || "*" ) :
4643 typeof context.querySelectorAll !== "undefined" ?
4644 context.querySelectorAll( tag || "*" ) :
4647 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
4648 jQuery.merge( [ context ], ret ) :
4653 // Mark scripts as having already been evaluated
4654 function setGlobalEval( elems, refElements ) {
4658 for ( ; i < l; i++ ) {
4662 !refElements || dataPriv.get( refElements[ i ], "globalEval" )
4668 var rhtml = /<|&#?\w+;/;
4670 function buildFragment( elems, context, scripts, selection, ignored ) {
4671 var elem, tmp, tag, wrap, contains, j,
4672 fragment = context.createDocumentFragment(),
4677 for ( ; i < l; i++ ) {
4680 if ( elem || elem === 0 ) {
4682 // Add nodes directly
4683 if ( jQuery.type( elem ) === "object" ) {
4685 // Support: Android <=4.0 only, PhantomJS 1 only
4686 // push.apply(_, arraylike) throws on ancient WebKit
4687 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4689 // Convert non-html into a text node
4690 } else if ( !rhtml.test( elem ) ) {
4691 nodes.push( context.createTextNode( elem ) );
4693 // Convert html into DOM nodes
4695 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
4697 // Deserialize a standard representation
4698 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4699 wrap = wrapMap[ tag ] || wrapMap._default;
4700 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4702 // Descend through wrappers to the right content
4705 tmp = tmp.lastChild;
4708 // Support: Android <=4.0 only, PhantomJS 1 only
4709 // push.apply(_, arraylike) throws on ancient WebKit
4710 jQuery.merge( nodes, tmp.childNodes );
4712 // Remember the top-level container
4713 tmp = fragment.firstChild;
4715 // Ensure the created nodes are orphaned (#12392)
4716 tmp.textContent = "";
4721 // Remove wrapper from fragment
4722 fragment.textContent = "";
4725 while ( ( elem = nodes[ i++ ] ) ) {
4727 // Skip elements already in the context collection (trac-4087)
4728 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4730 ignored.push( elem );
4735 contains = jQuery.contains( elem.ownerDocument, elem );
4737 // Append to fragment
4738 tmp = getAll( fragment.appendChild( elem ), "script" );
4740 // Preserve script evaluation history
4742 setGlobalEval( tmp );
4745 // Capture executables
4748 while ( ( elem = tmp[ j++ ] ) ) {
4749 if ( rscriptType.test( elem.type || "" ) ) {
4750 scripts.push( elem );
4761 var fragment = document.createDocumentFragment(),
4762 div = fragment.appendChild( document.createElement( "div" ) ),
4763 input = document.createElement( "input" );
4765 // Support: Android 4.0 - 4.3 only
4766 // Check state lost if the name is set (#11217)
4767 // Support: Windows Web Apps (WWA)
4768 // `name` and `type` must use .setAttribute for WWA (#14901)
4769 input.setAttribute( "type", "radio" );
4770 input.setAttribute( "checked", "checked" );
4771 input.setAttribute( "name", "t" );
4773 div.appendChild( input );
4775 // Support: Android <=4.1 only
4776 // Older WebKit doesn't clone checked state correctly in fragments
4777 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4779 // Support: IE <=11 only
4780 // Make sure textarea (and checkbox) defaultValue is properly cloned
4781 div.innerHTML = "<textarea>x</textarea>";
4782 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4784 var documentElement = document.documentElement;
4790 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4791 rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4793 function returnTrue() {
4797 function returnFalse() {
4801 // Support: IE <=9 only
4802 // See #13393 for more info
4803 function safeActiveElement() {
4805 return document.activeElement;
4809 function on( elem, types, selector, data, fn, one ) {
4812 // Types can be a map of types/handlers
4813 if ( typeof types === "object" ) {
4815 // ( types-Object, selector, data )
4816 if ( typeof selector !== "string" ) {
4818 // ( types-Object, data )
4819 data = data || selector;
4820 selector = undefined;
4822 for ( type in types ) {
4823 on( elem, type, selector, data, types[ type ], one );
4828 if ( data == null && fn == null ) {
4832 data = selector = undefined;
4833 } else if ( fn == null ) {
4834 if ( typeof selector === "string" ) {
4836 // ( types, selector, fn )
4841 // ( types, data, fn )
4844 selector = undefined;
4847 if ( fn === false ) {
4855 fn = function( event ) {
4857 // Can use an empty set, since event contains the info
4858 jQuery().off( event );
4859 return origFn.apply( this, arguments );
4862 // Use same guid so caller can remove using origFn
4863 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4865 return elem.each( function() {
4866 jQuery.event.add( this, types, fn, data, selector );
4871 * Helper functions for managing events -- not part of the public interface.
4872 * Props to Dean Edwards' addEvent library for many of the ideas.
4878 add: function( elem, types, handler, data, selector ) {
4880 var handleObjIn, eventHandle, tmp,
4881 events, t, handleObj,
4882 special, handlers, type, namespaces, origType,
4883 elemData = dataPriv.get( elem );
4885 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4890 // Caller can pass in an object of custom data in lieu of the handler
4891 if ( handler.handler ) {
4892 handleObjIn = handler;
4893 handler = handleObjIn.handler;
4894 selector = handleObjIn.selector;
4897 // Ensure that invalid selectors throw exceptions at attach time
4898 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
4900 jQuery.find.matchesSelector( documentElement, selector );
4903 // Make sure that the handler has a unique ID, used to find/remove it later
4904 if ( !handler.guid ) {
4905 handler.guid = jQuery.guid++;
4908 // Init the element's event structure and main handler, if this is the first
4909 if ( !( events = elemData.events ) ) {
4910 events = elemData.events = {};
4912 if ( !( eventHandle = elemData.handle ) ) {
4913 eventHandle = elemData.handle = function( e ) {
4915 // Discard the second event of a jQuery.event.trigger() and
4916 // when an event is called after a page has unloaded
4917 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
4918 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
4922 // Handle multiple events separated by a space
4923 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4926 tmp = rtypenamespace.exec( types[ t ] ) || [];
4927 type = origType = tmp[ 1 ];
4928 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4930 // There *must* be a type, no attaching namespace-only handlers
4935 // If event changes its type, use the special event handlers for the changed type
4936 special = jQuery.event.special[ type ] || {};
4938 // If selector defined, determine special event api type, otherwise given type
4939 type = ( selector ? special.delegateType : special.bindType ) || type;
4941 // Update special based on newly reset type
4942 special = jQuery.event.special[ type ] || {};
4944 // handleObj is passed to all event handlers
4945 handleObj = jQuery.extend( {
4952 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4953 namespace: namespaces.join( "." )
4956 // Init the event handler queue if we're the first
4957 if ( !( handlers = events[ type ] ) ) {
4958 handlers = events[ type ] = [];
4959 handlers.delegateCount = 0;
4961 // Only use addEventListener if the special events handler returns false
4962 if ( !special.setup ||
4963 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4965 if ( elem.addEventListener ) {
4966 elem.addEventListener( type, eventHandle );
4971 if ( special.add ) {
4972 special.add.call( elem, handleObj );
4974 if ( !handleObj.handler.guid ) {
4975 handleObj.handler.guid = handler.guid;
4979 // Add to the element's handler list, delegates in front
4981 handlers.splice( handlers.delegateCount++, 0, handleObj );
4983 handlers.push( handleObj );
4986 // Keep track of which events have ever been used, for event optimization
4987 jQuery.event.global[ type ] = true;
4992 // Detach an event or set of events from an element
4993 remove: function( elem, types, handler, selector, mappedTypes ) {
4995 var j, origCount, tmp,
4996 events, t, handleObj,
4997 special, handlers, type, namespaces, origType,
4998 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
5000 if ( !elemData || !( events = elemData.events ) ) {
5004 // Once for each type.namespace in types; type may be omitted
5005 types = ( types || "" ).match( rnotwhite ) || [ "" ];
5008 tmp = rtypenamespace.exec( types[ t ] ) || [];
5009 type = origType = tmp[ 1 ];
5010 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5012 // Unbind all events (on this namespace, if provided) for the element
5014 for ( type in events ) {
5015 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5020 special = jQuery.event.special[ type ] || {};
5021 type = ( selector ? special.delegateType : special.bindType ) || type;
5022 handlers = events[ type ] || [];
5024 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5026 // Remove matching events
5027 origCount = j = handlers.length;
5029 handleObj = handlers[ j ];
5031 if ( ( mappedTypes || origType === handleObj.origType ) &&
5032 ( !handler || handler.guid === handleObj.guid ) &&
5033 ( !tmp || tmp.test( handleObj.namespace ) ) &&
5034 ( !selector || selector === handleObj.selector ||
5035 selector === "**" && handleObj.selector ) ) {
5036 handlers.splice( j, 1 );
5038 if ( handleObj.selector ) {
5039 handlers.delegateCount--;
5041 if ( special.remove ) {
5042 special.remove.call( elem, handleObj );
5047 // Remove generic event handler if we removed something and no more handlers exist
5048 // (avoids potential for endless recursion during removal of special event handlers)
5049 if ( origCount && !handlers.length ) {
5050 if ( !special.teardown ||
5051 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5053 jQuery.removeEvent( elem, type, elemData.handle );
5056 delete events[ type ];
5060 // Remove data and the expando if it's no longer used
5061 if ( jQuery.isEmptyObject( events ) ) {
5062 dataPriv.remove( elem, "handle events" );
5066 dispatch: function( nativeEvent ) {
5068 // Make a writable jQuery.Event from the native event object
5069 var event = jQuery.event.fix( nativeEvent );
5071 var i, j, ret, matched, handleObj, handlerQueue,
5072 args = new Array( arguments.length ),
5073 handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
5074 special = jQuery.event.special[ event.type ] || {};
5076 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5079 for ( i = 1; i < arguments.length; i++ ) {
5080 args[ i ] = arguments[ i ];
5083 event.delegateTarget = this;
5085 // Call the preDispatch hook for the mapped type, and let it bail if desired
5086 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5090 // Determine handlers
5091 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5093 // Run delegates first; they may want to stop propagation beneath us
5095 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5096 event.currentTarget = matched.elem;
5099 while ( ( handleObj = matched.handlers[ j++ ] ) &&
5100 !event.isImmediatePropagationStopped() ) {
5102 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5103 // a subset or equal to those in the bound event (both can have no namespace).
5104 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
5106 event.handleObj = handleObj;
5107 event.data = handleObj.data;
5109 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5110 handleObj.handler ).apply( matched.elem, args );
5112 if ( ret !== undefined ) {
5113 if ( ( event.result = ret ) === false ) {
5114 event.preventDefault();
5115 event.stopPropagation();
5122 // Call the postDispatch hook for the mapped type
5123 if ( special.postDispatch ) {
5124 special.postDispatch.call( this, event );
5127 return event.result;
5130 handlers: function( event, handlers ) {
5131 var i, matches, sel, handleObj,
5133 delegateCount = handlers.delegateCount,
5137 // Find delegate handlers
5138 // Black-hole SVG <use> instance trees (#13180)
5140 // Support: Firefox <=42
5141 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
5142 if ( delegateCount && cur.nodeType &&
5143 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
5145 for ( ; cur !== this; cur = cur.parentNode || this ) {
5147 // Don't check non-elements (#13208)
5148 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5149 if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
5151 for ( i = 0; i < delegateCount; i++ ) {
5152 handleObj = handlers[ i ];
5154 // Don't conflict with Object.prototype properties (#13203)
5155 sel = handleObj.selector + " ";
5157 if ( matches[ sel ] === undefined ) {
5158 matches[ sel ] = handleObj.needsContext ?
5159 jQuery( sel, this ).index( cur ) > -1 :
5160 jQuery.find( sel, this, null, [ cur ] ).length;
5162 if ( matches[ sel ] ) {
5163 matches.push( handleObj );
5166 if ( matches.length ) {
5167 handlerQueue.push( { elem: cur, handlers: matches } );
5173 // Add the remaining (directly-bound) handlers
5174 if ( delegateCount < handlers.length ) {
5175 handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
5178 return handlerQueue;
5181 addProp: function( name, hook ) {
5182 Object.defineProperty( jQuery.Event.prototype, name, {
5186 get: jQuery.isFunction( hook ) ?
5188 if ( this.originalEvent ) {
5189 return hook( this.originalEvent );
5193 if ( this.originalEvent ) {
5194 return this.originalEvent[ name ];
5198 set: function( value ) {
5199 Object.defineProperty( this, name, {
5209 fix: function( originalEvent ) {
5210 return originalEvent[ jQuery.expando ] ?
5212 new jQuery.Event( originalEvent );
5218 // Prevent triggered image.load events from bubbling to window.load
5223 // Fire native event if possible so blur/focus sequence is correct
5224 trigger: function() {
5225 if ( this !== safeActiveElement() && this.focus ) {
5230 delegateType: "focusin"
5233 trigger: function() {
5234 if ( this === safeActiveElement() && this.blur ) {
5239 delegateType: "focusout"
5243 // For checkbox, fire native event so checked state will be right
5244 trigger: function() {
5245 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
5251 // For cross-browser consistency, don't fire native .click() on links
5252 _default: function( event ) {
5253 return jQuery.nodeName( event.target, "a" );
5258 postDispatch: function( event ) {
5260 // Support: Firefox 20+
5261 // Firefox doesn't alert if the returnValue field is not set.
5262 if ( event.result !== undefined && event.originalEvent ) {
5263 event.originalEvent.returnValue = event.result;
5270 jQuery.removeEvent = function( elem, type, handle ) {
5272 // This "if" is needed for plain objects
5273 if ( elem.removeEventListener ) {
5274 elem.removeEventListener( type, handle );
5278 jQuery.Event = function( src, props ) {
5280 // Allow instantiation without the 'new' keyword
5281 if ( !( this instanceof jQuery.Event ) ) {
5282 return new jQuery.Event( src, props );
5286 if ( src && src.type ) {
5287 this.originalEvent = src;
5288 this.type = src.type;
5290 // Events bubbling up the document may have been marked as prevented
5291 // by a handler lower down the tree; reflect the correct value.
5292 this.isDefaultPrevented = src.defaultPrevented ||
5293 src.defaultPrevented === undefined &&
5295 // Support: Android <=2.3 only
5296 src.returnValue === false ?
5300 // Create target properties
5301 // Support: Safari <=6 - 7 only
5302 // Target should not be a text node (#504, #13143)
5303 this.target = ( src.target && src.target.nodeType === 3 ) ?
5304 src.target.parentNode :
5307 this.currentTarget = src.currentTarget;
5308 this.relatedTarget = src.relatedTarget;
5315 // Put explicitly provided properties onto the event object
5317 jQuery.extend( this, props );
5320 // Create a timestamp if incoming event doesn't have one
5321 this.timeStamp = src && src.timeStamp || jQuery.now();
5324 this[ jQuery.expando ] = true;
5327 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5328 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5329 jQuery.Event.prototype = {
5330 constructor: jQuery.Event,
5331 isDefaultPrevented: returnFalse,
5332 isPropagationStopped: returnFalse,
5333 isImmediatePropagationStopped: returnFalse,
5336 preventDefault: function() {
5337 var e = this.originalEvent;
5339 this.isDefaultPrevented = returnTrue;
5341 if ( e && !this.isSimulated ) {
5345 stopPropagation: function() {
5346 var e = this.originalEvent;
5348 this.isPropagationStopped = returnTrue;
5350 if ( e && !this.isSimulated ) {
5351 e.stopPropagation();
5354 stopImmediatePropagation: function() {
5355 var e = this.originalEvent;
5357 this.isImmediatePropagationStopped = returnTrue;
5359 if ( e && !this.isSimulated ) {
5360 e.stopImmediatePropagation();
5363 this.stopPropagation();
5367 // Includes all common event props including KeyEvent and MouseEvent specific props
5372 changedTouches: true,
5395 targetTouches: true,
5399 which: function( event ) {
5400 var button = event.button;
5402 // Add which for key events
5403 if ( event.which == null && rkeyEvent.test( event.type ) ) {
5404 return event.charCode != null ? event.charCode : event.keyCode;
5407 // Add which for click: 1 === left; 2 === middle; 3 === right
5408 if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
5409 return ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
5414 }, jQuery.event.addProp );
5416 // Create mouseenter/leave events using mouseover/out and event-time checks
5417 // so that event delegation works in jQuery.
5418 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5420 // Support: Safari 7 only
5421 // Safari sends mouseenter too often; see:
5422 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5423 // for the description of the bug (it existed in older Chrome versions as well).
5425 mouseenter: "mouseover",
5426 mouseleave: "mouseout",
5427 pointerenter: "pointerover",
5428 pointerleave: "pointerout"
5429 }, function( orig, fix ) {
5430 jQuery.event.special[ orig ] = {
5434 handle: function( event ) {
5437 related = event.relatedTarget,
5438 handleObj = event.handleObj;
5440 // For mouseenter/leave call the handler if related is outside the target.
5441 // NB: No relatedTarget if the mouse left/entered the browser window
5442 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5443 event.type = handleObj.origType;
5444 ret = handleObj.handler.apply( this, arguments );
5454 on: function( types, selector, data, fn ) {
5455 return on( this, types, selector, data, fn );
5457 one: function( types, selector, data, fn ) {
5458 return on( this, types, selector, data, fn, 1 );
5460 off: function( types, selector, fn ) {
5461 var handleObj, type;
5462 if ( types && types.preventDefault && types.handleObj ) {
5464 // ( event ) dispatched jQuery.Event
5465 handleObj = types.handleObj;
5466 jQuery( types.delegateTarget ).off(
5467 handleObj.namespace ?
5468 handleObj.origType + "." + handleObj.namespace :
5475 if ( typeof types === "object" ) {
5477 // ( types-object [, selector] )
5478 for ( type in types ) {
5479 this.off( type, selector, types[ type ] );
5483 if ( selector === false || typeof selector === "function" ) {
5487 selector = undefined;
5489 if ( fn === false ) {
5492 return this.each( function() {
5493 jQuery.event.remove( this, types, fn, selector );
5501 /* eslint-disable max-len */
5503 // See https://github.com/eslint/eslint/issues/3229
5504 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
5508 // Support: IE <=10 - 11, Edge 12 - 13
5509 // In IE/Edge using regex groups here causes severe slowdowns.
5510 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5511 rnoInnerhtml = /<script|<style|<link/i,
5513 // checked="checked" or checked
5514 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5515 rscriptTypeMasked = /^true\/(.*)/,
5516 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5518 function manipulationTarget( elem, content ) {
5519 if ( jQuery.nodeName( elem, "table" ) &&
5520 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
5522 return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
5528 // Replace/restore the type attribute of script elements for safe DOM manipulation
5529 function disableScript( elem ) {
5530 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
5533 function restoreScript( elem ) {
5534 var match = rscriptTypeMasked.exec( elem.type );
5537 elem.type = match[ 1 ];
5539 elem.removeAttribute( "type" );
5545 function cloneCopyEvent( src, dest ) {
5546 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
5548 if ( dest.nodeType !== 1 ) {
5552 // 1. Copy private data: events, handlers, etc.
5553 if ( dataPriv.hasData( src ) ) {
5554 pdataOld = dataPriv.access( src );
5555 pdataCur = dataPriv.set( dest, pdataOld );
5556 events = pdataOld.events;
5559 delete pdataCur.handle;
5560 pdataCur.events = {};
5562 for ( type in events ) {
5563 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5564 jQuery.event.add( dest, type, events[ type ][ i ] );
5570 // 2. Copy user data
5571 if ( dataUser.hasData( src ) ) {
5572 udataOld = dataUser.access( src );
5573 udataCur = jQuery.extend( {}, udataOld );
5575 dataUser.set( dest, udataCur );
5579 // Fix IE bugs, see support tests
5580 function fixInput( src, dest ) {
5581 var nodeName = dest.nodeName.toLowerCase();
5583 // Fails to persist the checked state of a cloned checkbox or radio button.
5584 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5585 dest.checked = src.checked;
5587 // Fails to return the selected option to the default selected state when cloning options
5588 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5589 dest.defaultValue = src.defaultValue;
5593 function domManip( collection, args, callback, ignored ) {
5595 // Flatten any nested arrays
5596 args = concat.apply( [], args );
5598 var fragment, first, scripts, hasScripts, node, doc,
5600 l = collection.length,
5603 isFunction = jQuery.isFunction( value );
5605 // We can't cloneNode fragments that contain checked, in WebKit
5607 ( l > 1 && typeof value === "string" &&
5608 !support.checkClone && rchecked.test( value ) ) ) {
5609 return collection.each( function( index ) {
5610 var self = collection.eq( index );
5612 args[ 0 ] = value.call( this, index, self.html() );
5614 domManip( self, args, callback, ignored );
5619 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
5620 first = fragment.firstChild;
5622 if ( fragment.childNodes.length === 1 ) {
5626 // Require either new content or an interest in ignored elements to invoke the callback
5627 if ( first || ignored ) {
5628 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5629 hasScripts = scripts.length;
5631 // Use the original fragment for the last item
5632 // instead of the first because it can end up
5633 // being emptied incorrectly in certain situations (#8070).
5634 for ( ; i < l; i++ ) {
5637 if ( i !== iNoClone ) {
5638 node = jQuery.clone( node, true, true );
5640 // Keep references to cloned scripts for later restoration
5643 // Support: Android <=4.0 only, PhantomJS 1 only
5644 // push.apply(_, arraylike) throws on ancient WebKit
5645 jQuery.merge( scripts, getAll( node, "script" ) );
5649 callback.call( collection[ i ], node, i );
5653 doc = scripts[ scripts.length - 1 ].ownerDocument;
5656 jQuery.map( scripts, restoreScript );
5658 // Evaluate executable scripts on first document insertion
5659 for ( i = 0; i < hasScripts; i++ ) {
5660 node = scripts[ i ];
5661 if ( rscriptType.test( node.type || "" ) &&
5662 !dataPriv.access( node, "globalEval" ) &&
5663 jQuery.contains( doc, node ) ) {
5667 // Optional AJAX dependency, but won't run scripts if not present
5668 if ( jQuery._evalUrl ) {
5669 jQuery._evalUrl( node.src );
5672 DOMEval( node.textContent.replace( rcleanScript, "" ), doc );
5683 function remove( elem, selector, keepData ) {
5685 nodes = selector ? jQuery.filter( selector, elem ) : elem,
5688 for ( ; ( node = nodes[ i ] ) != null; i++ ) {
5689 if ( !keepData && node.nodeType === 1 ) {
5690 jQuery.cleanData( getAll( node ) );
5693 if ( node.parentNode ) {
5694 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
5695 setGlobalEval( getAll( node, "script" ) );
5697 node.parentNode.removeChild( node );
5705 htmlPrefilter: function( html ) {
5706 return html.replace( rxhtmlTag, "<$1></$2>" );
5709 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5710 var i, l, srcElements, destElements,
5711 clone = elem.cloneNode( true ),
5712 inPage = jQuery.contains( elem.ownerDocument, elem );
5714 // Fix IE cloning issues
5715 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5716 !jQuery.isXMLDoc( elem ) ) {
5718 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
5719 destElements = getAll( clone );
5720 srcElements = getAll( elem );
5722 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5723 fixInput( srcElements[ i ], destElements[ i ] );
5727 // Copy the events from the original to the clone
5728 if ( dataAndEvents ) {
5729 if ( deepDataAndEvents ) {
5730 srcElements = srcElements || getAll( elem );
5731 destElements = destElements || getAll( clone );
5733 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5734 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
5737 cloneCopyEvent( elem, clone );
5741 // Preserve script evaluation history
5742 destElements = getAll( clone, "script" );
5743 if ( destElements.length > 0 ) {
5744 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5747 // Return the cloned set
5751 cleanData: function( elems ) {
5752 var data, elem, type,
5753 special = jQuery.event.special,
5756 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
5757 if ( acceptData( elem ) ) {
5758 if ( ( data = elem[ dataPriv.expando ] ) ) {
5759 if ( data.events ) {
5760 for ( type in data.events ) {
5761 if ( special[ type ] ) {
5762 jQuery.event.remove( elem, type );
5764 // This is a shortcut to avoid jQuery.event.remove's overhead
5766 jQuery.removeEvent( elem, type, data.handle );
5771 // Support: Chrome <=35 - 45+
5772 // Assign undefined instead of using delete, see Data#remove
5773 elem[ dataPriv.expando ] = undefined;
5775 if ( elem[ dataUser.expando ] ) {
5777 // Support: Chrome <=35 - 45+
5778 // Assign undefined instead of using delete, see Data#remove
5779 elem[ dataUser.expando ] = undefined;
5787 detach: function( selector ) {
5788 return remove( this, selector, true );
5791 remove: function( selector ) {
5792 return remove( this, selector );
5795 text: function( value ) {
5796 return access( this, function( value ) {
5797 return value === undefined ?
5798 jQuery.text( this ) :
5799 this.empty().each( function() {
5800 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5801 this.textContent = value;
5804 }, null, value, arguments.length );
5807 append: function() {
5808 return domManip( this, arguments, function( elem ) {
5809 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5810 var target = manipulationTarget( this, elem );
5811 target.appendChild( elem );
5816 prepend: function() {
5817 return domManip( this, arguments, function( elem ) {
5818 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5819 var target = manipulationTarget( this, elem );
5820 target.insertBefore( elem, target.firstChild );
5825 before: function() {
5826 return domManip( this, arguments, function( elem ) {
5827 if ( this.parentNode ) {
5828 this.parentNode.insertBefore( elem, this );
5834 return domManip( this, arguments, function( elem ) {
5835 if ( this.parentNode ) {
5836 this.parentNode.insertBefore( elem, this.nextSibling );
5845 for ( ; ( elem = this[ i ] ) != null; i++ ) {
5846 if ( elem.nodeType === 1 ) {
5848 // Prevent memory leaks
5849 jQuery.cleanData( getAll( elem, false ) );
5851 // Remove any remaining nodes
5852 elem.textContent = "";
5859 clone: function( dataAndEvents, deepDataAndEvents ) {
5860 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5861 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5863 return this.map( function() {
5864 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5868 html: function( value ) {
5869 return access( this, function( value ) {
5870 var elem = this[ 0 ] || {},
5874 if ( value === undefined && elem.nodeType === 1 ) {
5875 return elem.innerHTML;
5878 // See if we can take a shortcut and just use innerHTML
5879 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5880 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5882 value = jQuery.htmlPrefilter( value );
5885 for ( ; i < l; i++ ) {
5886 elem = this[ i ] || {};
5888 // Remove element nodes and prevent memory leaks
5889 if ( elem.nodeType === 1 ) {
5890 jQuery.cleanData( getAll( elem, false ) );
5891 elem.innerHTML = value;
5897 // If using innerHTML throws an exception, use the fallback method
5902 this.empty().append( value );
5904 }, null, value, arguments.length );
5907 replaceWith: function() {
5910 // Make the changes, replacing each non-ignored context element with the new content
5911 return domManip( this, arguments, function( elem ) {
5912 var parent = this.parentNode;
5914 if ( jQuery.inArray( this, ignored ) < 0 ) {
5915 jQuery.cleanData( getAll( this ) );
5917 parent.replaceChild( elem, this );
5921 // Force callback invocation
5928 prependTo: "prepend",
5929 insertBefore: "before",
5930 insertAfter: "after",
5931 replaceAll: "replaceWith"
5932 }, function( name, original ) {
5933 jQuery.fn[ name ] = function( selector ) {
5936 insert = jQuery( selector ),
5937 last = insert.length - 1,
5940 for ( ; i <= last; i++ ) {
5941 elems = i === last ? this : this.clone( true );
5942 jQuery( insert[ i ] )[ original ]( elems );
5944 // Support: Android <=4.0 only, PhantomJS 1 only
5945 // .get() because push.apply(_, arraylike) throws on ancient WebKit
5946 push.apply( ret, elems.get() );
5949 return this.pushStack( ret );
5952 var rmargin = ( /^margin/ );
5954 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
5956 var getStyles = function( elem ) {
5958 // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
5959 // IE throws on elements created in popups
5960 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
5961 var view = elem.ownerDocument.defaultView;
5963 if ( !view || !view.opener ) {
5967 return view.getComputedStyle( elem );
5974 // Executing both pixelPosition & boxSizingReliable tests require only one layout
5975 // so they're executed at the same time to save the second computation.
5976 function computeStyleTests() {
5978 // This is a singleton, we need to execute it only once
5984 "box-sizing:border-box;" +
5985 "position:relative;display:block;" +
5986 "margin:auto;border:1px;padding:1px;" +
5989 documentElement.appendChild( container );
5991 var divStyle = window.getComputedStyle( div );
5992 pixelPositionVal = divStyle.top !== "1%";
5994 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
5995 reliableMarginLeftVal = divStyle.marginLeft === "2px";
5996 boxSizingReliableVal = divStyle.width === "4px";
5998 // Support: Android 4.0 - 4.3 only
5999 // Some styles come back with percentage values, even though they shouldn't
6000 div.style.marginRight = "50%";
6001 pixelMarginRightVal = divStyle.marginRight === "4px";
6003 documentElement.removeChild( container );
6005 // Nullify the div so it wouldn't be stored in the memory and
6006 // it will also be a sign that checks already performed
6010 var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal,
6011 container = document.createElement( "div" ),
6012 div = document.createElement( "div" );
6014 // Finish early in limited (non-browser) environments
6019 // Support: IE <=9 - 11 only
6020 // Style of cloned element affects source element cloned (#8908)
6021 div.style.backgroundClip = "content-box";
6022 div.cloneNode( true ).style.backgroundClip = "";
6023 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6025 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
6026 "padding:0;margin-top:1px;position:absolute";
6027 container.appendChild( div );
6029 jQuery.extend( support, {
6030 pixelPosition: function() {
6031 computeStyleTests();
6032 return pixelPositionVal;
6034 boxSizingReliable: function() {
6035 computeStyleTests();
6036 return boxSizingReliableVal;
6038 pixelMarginRight: function() {
6039 computeStyleTests();
6040 return pixelMarginRightVal;
6042 reliableMarginLeft: function() {
6043 computeStyleTests();
6044 return reliableMarginLeftVal;
6050 function curCSS( elem, name, computed ) {
6051 var width, minWidth, maxWidth, ret,
6054 computed = computed || getStyles( elem );
6056 // Support: IE <=9 only
6057 // getPropertyValue is only needed for .css('filter') (#12537)
6059 ret = computed.getPropertyValue( name ) || computed[ name ];
6061 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6062 ret = jQuery.style( elem, name );
6065 // A tribute to the "awesome hack by Dean Edwards"
6066 // Android Browser returns percentage for some values,
6067 // but width seems to be reliably pixels.
6068 // This is against the CSSOM draft spec:
6069 // https://drafts.csswg.org/cssom/#resolved-values
6070 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6072 // Remember the original values
6073 width = style.width;
6074 minWidth = style.minWidth;
6075 maxWidth = style.maxWidth;
6077 // Put in the new values to get a computed value out
6078 style.minWidth = style.maxWidth = style.width = ret;
6079 ret = computed.width;
6081 // Revert the changed values
6082 style.width = width;
6083 style.minWidth = minWidth;
6084 style.maxWidth = maxWidth;
6088 return ret !== undefined ?
6090 // Support: IE <=9 - 11 only
6091 // IE returns zIndex value as an integer.
6097 function addGetHookIf( conditionFn, hookFn ) {
6099 // Define the hook, we'll check on the first run if it's really needed.
6102 if ( conditionFn() ) {
6104 // Hook not needed (or it's not possible to use it due
6105 // to missing dependency), remove it.
6110 // Hook needed; redefine it so that the support test is not executed again.
6111 return ( this.get = hookFn ).apply( this, arguments );
6119 // Swappable if display is none or starts with table
6120 // except "table", "table-cell", or "table-caption"
6121 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6122 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6123 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6124 cssNormalTransform = {
6129 cssPrefixes = [ "Webkit", "Moz", "ms" ],
6130 emptyStyle = document.createElement( "div" ).style;
6132 // Return a css property mapped to a potentially vendor prefixed property
6133 function vendorPropName( name ) {
6135 // Shortcut for names that are not vendor prefixed
6136 if ( name in emptyStyle ) {
6140 // Check for vendor prefixed names
6141 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
6142 i = cssPrefixes.length;
6145 name = cssPrefixes[ i ] + capName;
6146 if ( name in emptyStyle ) {
6152 function setPositiveNumber( elem, value, subtract ) {
6154 // Any relative (+/-) values have already been
6155 // normalized at this point
6156 var matches = rcssNum.exec( value );
6159 // Guard against undefined "subtract", e.g., when used as in cssHooks
6160 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
6164 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
6165 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6167 // If we already have the right measurement, avoid augmentation
6170 // Otherwise initialize for horizontal or vertical properties
6171 name === "width" ? 1 : 0,
6175 for ( ; i < 4; i += 2 ) {
6177 // Both box models exclude margin, so add it if we want it
6178 if ( extra === "margin" ) {
6179 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
6182 if ( isBorderBox ) {
6184 // border-box includes padding, so remove it if we want content
6185 if ( extra === "content" ) {
6186 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6189 // At this point, extra isn't border nor margin, so remove border
6190 if ( extra !== "margin" ) {
6191 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6195 // At this point, extra isn't content, so add padding
6196 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6198 // At this point, extra isn't content nor padding, so add border
6199 if ( extra !== "padding" ) {
6200 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6208 function getWidthOrHeight( elem, name, extra ) {
6210 // Start with offset property, which is equivalent to the border-box value
6212 valueIsBorderBox = true,
6213 styles = getStyles( elem ),
6214 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6216 // Support: IE <=11 only
6217 // Running getBoundingClientRect on a disconnected node
6218 // in IE throws an error.
6219 if ( elem.getClientRects().length ) {
6220 val = elem.getBoundingClientRect()[ name ];
6223 // Some non-html elements return undefined for offsetWidth, so check for null/undefined
6224 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6225 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6226 if ( val <= 0 || val == null ) {
6228 // Fall back to computed then uncomputed css if necessary
6229 val = curCSS( elem, name, styles );
6230 if ( val < 0 || val == null ) {
6231 val = elem.style[ name ];
6234 // Computed unit is not pixels. Stop here and return.
6235 if ( rnumnonpx.test( val ) ) {
6239 // Check for style in case a browser which returns unreliable values
6240 // for getComputedStyle silently falls back to the reliable elem.style
6241 valueIsBorderBox = isBorderBox &&
6242 ( support.boxSizingReliable() || val === elem.style[ name ] );
6244 // Normalize "", auto, and prepare for extra
6245 val = parseFloat( val ) || 0;
6248 // Use the active box-sizing model to add/subtract irrelevant styles
6250 augmentWidthOrHeight(
6253 extra || ( isBorderBox ? "border" : "content" ),
6262 // Add in style property hooks for overriding the default
6263 // behavior of getting and setting a style property
6266 get: function( elem, computed ) {
6269 // We should always get a number back from opacity
6270 var ret = curCSS( elem, "opacity" );
6271 return ret === "" ? "1" : ret;
6277 // Don't automatically add "px" to these possibly-unitless properties
6279 "animationIterationCount": true,
6280 "columnCount": true,
6281 "fillOpacity": true,
6294 // Add in properties whose names you wish to fix before
6295 // setting or getting the value
6300 // Get and set the style property on a DOM Node
6301 style: function( elem, name, value, extra ) {
6303 // Don't set styles on text and comment nodes
6304 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6308 // Make sure that we're working with the right name
6309 var ret, type, hooks,
6310 origName = jQuery.camelCase( name ),
6313 name = jQuery.cssProps[ origName ] ||
6314 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
6316 // Gets hook for the prefixed version, then unprefixed version
6317 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6319 // Check if we're setting a value
6320 if ( value !== undefined ) {
6321 type = typeof value;
6323 // Convert "+=" or "-=" to relative numbers (#7345)
6324 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
6325 value = adjustCSS( elem, name, ret );
6331 // Make sure that null and NaN values aren't set (#7116)
6332 if ( value == null || value !== value ) {
6336 // If a number was passed in, add the unit (except for certain CSS properties)
6337 if ( type === "number" ) {
6338 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
6341 // background-* props affect original clone's values
6342 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
6343 style[ name ] = "inherit";
6346 // If a hook was provided, use that value, otherwise just set the specified value
6347 if ( !hooks || !( "set" in hooks ) ||
6348 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
6350 style[ name ] = value;
6355 // If a hook was provided get the non-computed value from there
6356 if ( hooks && "get" in hooks &&
6357 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
6362 // Otherwise just get the value from the style object
6363 return style[ name ];
6367 css: function( elem, name, extra, styles ) {
6368 var val, num, hooks,
6369 origName = jQuery.camelCase( name );
6371 // Make sure that we're working with the right name
6372 name = jQuery.cssProps[ origName ] ||
6373 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
6375 // Try prefixed name followed by the unprefixed name
6376 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6378 // If a hook was provided get the computed value from there
6379 if ( hooks && "get" in hooks ) {
6380 val = hooks.get( elem, true, extra );
6383 // Otherwise, if a way to get the computed value exists, use that
6384 if ( val === undefined ) {
6385 val = curCSS( elem, name, styles );
6388 // Convert "normal" to computed value
6389 if ( val === "normal" && name in cssNormalTransform ) {
6390 val = cssNormalTransform[ name ];
6393 // Make numeric if forced or a qualifier was provided and val looks numeric
6394 if ( extra === "" || extra ) {
6395 num = parseFloat( val );
6396 return extra === true || isFinite( num ) ? num || 0 : val;
6402 jQuery.each( [ "height", "width" ], function( i, name ) {
6403 jQuery.cssHooks[ name ] = {
6404 get: function( elem, computed, extra ) {
6407 // Certain elements can have dimension info if we invisibly show them
6408 // but it must have a current display style that would benefit
6409 return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
6411 // Support: Safari 8+
6412 // Table columns in Safari have non-zero offsetWidth & zero
6413 // getBoundingClientRect().width unless display is changed.
6414 // Support: IE <=11 only
6415 // Running getBoundingClientRect on a disconnected node
6416 // in IE throws an error.
6417 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
6418 swap( elem, cssShow, function() {
6419 return getWidthOrHeight( elem, name, extra );
6421 getWidthOrHeight( elem, name, extra );
6425 set: function( elem, value, extra ) {
6427 styles = extra && getStyles( elem ),
6428 subtract = extra && augmentWidthOrHeight(
6432 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6436 // Convert to pixels if value adjustment is needed
6437 if ( subtract && ( matches = rcssNum.exec( value ) ) &&
6438 ( matches[ 3 ] || "px" ) !== "px" ) {
6440 elem.style[ name ] = value;
6441 value = jQuery.css( elem, name );
6444 return setPositiveNumber( elem, value, subtract );
6449 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
6450 function( elem, computed ) {
6452 return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
6453 elem.getBoundingClientRect().left -
6454 swap( elem, { marginLeft: 0 }, function() {
6455 return elem.getBoundingClientRect().left;
6462 // These hooks are used by animate to expand properties
6467 }, function( prefix, suffix ) {
6468 jQuery.cssHooks[ prefix + suffix ] = {
6469 expand: function( value ) {
6473 // Assumes a single number if not a string
6474 parts = typeof value === "string" ? value.split( " " ) : [ value ];
6476 for ( ; i < 4; i++ ) {
6477 expanded[ prefix + cssExpand[ i ] + suffix ] =
6478 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6485 if ( !rmargin.test( prefix ) ) {
6486 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6491 css: function( name, value ) {
6492 return access( this, function( elem, name, value ) {
6497 if ( jQuery.isArray( name ) ) {
6498 styles = getStyles( elem );
6501 for ( ; i < len; i++ ) {
6502 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6508 return value !== undefined ?
6509 jQuery.style( elem, name, value ) :
6510 jQuery.css( elem, name );
6511 }, name, value, arguments.length > 1 );
6516 // Based off of the plugin by Clint Helfers, with permission.
6517 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
6518 jQuery.fn.delay = function( time, type ) {
6519 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
6520 type = type || "fx";
6522 return this.queue( type, function( next, hooks ) {
6523 var timeout = window.setTimeout( next, time );
6524 hooks.stop = function() {
6525 window.clearTimeout( timeout );
6532 var input = document.createElement( "input" ),
6533 select = document.createElement( "select" ),
6534 opt = select.appendChild( document.createElement( "option" ) );
6536 input.type = "checkbox";
6538 // Support: Android <=4.3 only
6539 // Default value for a checkbox should be "on"
6540 support.checkOn = input.value !== "";
6542 // Support: IE <=11 only
6543 // Must access selectedIndex to make default options select
6544 support.optSelected = opt.selected;
6546 // Support: IE <=11 only
6547 // An input loses its value after becoming a radio
6548 input = document.createElement( "input" );
6550 input.type = "radio";
6551 support.radioValue = input.value === "t";
6556 attrHandle = jQuery.expr.attrHandle;
6559 attr: function( name, value ) {
6560 return access( this, jQuery.attr, name, value, arguments.length > 1 );
6563 removeAttr: function( name ) {
6564 return this.each( function() {
6565 jQuery.removeAttr( this, name );
6571 attr: function( elem, name, value ) {
6573 nType = elem.nodeType;
6575 // Don't get/set attributes on text, comment and attribute nodes
6576 if ( nType === 3 || nType === 8 || nType === 2 ) {
6580 // Fallback to prop when attributes are not supported
6581 if ( typeof elem.getAttribute === "undefined" ) {
6582 return jQuery.prop( elem, name, value );
6585 // Attribute hooks are determined by the lowercase version
6586 // Grab necessary hook if one is defined
6587 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
6588 hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
6589 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
6592 if ( value !== undefined ) {
6593 if ( value === null ) {
6594 jQuery.removeAttr( elem, name );
6598 if ( hooks && "set" in hooks &&
6599 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
6603 elem.setAttribute( name, value + "" );
6607 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
6611 ret = jQuery.find.attr( elem, name );
6613 // Non-existent attributes return null, we normalize to undefined
6614 return ret == null ? undefined : ret;
6619 set: function( elem, value ) {
6620 if ( !support.radioValue && value === "radio" &&
6621 jQuery.nodeName( elem, "input" ) ) {
6622 var val = elem.value;
6623 elem.setAttribute( "type", value );
6633 removeAttr: function( elem, value ) {
6636 attrNames = value && value.match( rnotwhite );
6638 if ( attrNames && elem.nodeType === 1 ) {
6639 while ( ( name = attrNames[ i++ ] ) ) {
6640 elem.removeAttribute( name );
6646 // Hooks for boolean attributes
6648 set: function( elem, value, name ) {
6649 if ( value === false ) {
6651 // Remove boolean attributes when set to false
6652 jQuery.removeAttr( elem, name );
6654 elem.setAttribute( name, name );
6660 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
6661 var getter = attrHandle[ name ] || jQuery.find.attr;
6663 attrHandle[ name ] = function( elem, name, isXML ) {
6665 lowercaseName = name.toLowerCase();
6669 // Avoid an infinite loop by temporarily removing this function from the getter
6670 handle = attrHandle[ lowercaseName ];
6671 attrHandle[ lowercaseName ] = ret;
6672 ret = getter( elem, name, isXML ) != null ?
6675 attrHandle[ lowercaseName ] = handle;
6684 var rfocusable = /^(?:input|select|textarea|button)$/i,
6685 rclickable = /^(?:a|area)$/i;
6688 prop: function( name, value ) {
6689 return access( this, jQuery.prop, name, value, arguments.length > 1 );
6692 removeProp: function( name ) {
6693 return this.each( function() {
6694 delete this[ jQuery.propFix[ name ] || name ];
6700 prop: function( elem, name, value ) {
6702 nType = elem.nodeType;
6704 // Don't get/set properties on text, comment and attribute nodes
6705 if ( nType === 3 || nType === 8 || nType === 2 ) {
6709 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
6711 // Fix name and attach hooks
6712 name = jQuery.propFix[ name ] || name;
6713 hooks = jQuery.propHooks[ name ];
6716 if ( value !== undefined ) {
6717 if ( hooks && "set" in hooks &&
6718 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
6722 return ( elem[ name ] = value );
6725 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
6729 return elem[ name ];
6734 get: function( elem ) {
6736 // Support: IE <=9 - 11 only
6737 // elem.tabIndex doesn't always return the
6738 // correct value when it hasn't been explicitly set
6739 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
6740 // Use proper attribute retrieval(#12072)
6741 var tabindex = jQuery.find.attr( elem, "tabindex" );
6744 parseInt( tabindex, 10 ) :
6745 rfocusable.test( elem.nodeName ) ||
6746 rclickable.test( elem.nodeName ) && elem.href ?
6755 "class": "className"
6759 // Support: IE <=11 only
6760 // Accessing the selectedIndex property
6761 // forces the browser to respect setting selected
6763 // The getter ensures a default option is selected
6764 // when in an optgroup
6765 if ( !support.optSelected ) {
6766 jQuery.propHooks.selected = {
6767 get: function( elem ) {
6768 var parent = elem.parentNode;
6769 if ( parent && parent.parentNode ) {
6770 parent.parentNode.selectedIndex;
6774 set: function( elem ) {
6775 var parent = elem.parentNode;
6777 parent.selectedIndex;
6779 if ( parent.parentNode ) {
6780 parent.parentNode.selectedIndex;
6799 jQuery.propFix[ this.toLowerCase() ] = this;
6805 var rclass = /[\t\r\n\f]/g;
6807 function getClass( elem ) {
6808 return elem.getAttribute && elem.getAttribute( "class" ) || "";
6812 addClass: function( value ) {
6813 var classes, elem, cur, curValue, clazz, j, finalValue,
6816 if ( jQuery.isFunction( value ) ) {
6817 return this.each( function( j ) {
6818 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
6822 if ( typeof value === "string" && value ) {
6823 classes = value.match( rnotwhite ) || [];
6825 while ( ( elem = this[ i++ ] ) ) {
6826 curValue = getClass( elem );
6827 cur = elem.nodeType === 1 &&
6828 ( " " + curValue + " " ).replace( rclass, " " );
6832 while ( ( clazz = classes[ j++ ] ) ) {
6833 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
6838 // Only assign if different to avoid unneeded rendering.
6839 finalValue = jQuery.trim( cur );
6840 if ( curValue !== finalValue ) {
6841 elem.setAttribute( "class", finalValue );
6850 removeClass: function( value ) {
6851 var classes, elem, cur, curValue, clazz, j, finalValue,
6854 if ( jQuery.isFunction( value ) ) {
6855 return this.each( function( j ) {
6856 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
6860 if ( !arguments.length ) {
6861 return this.attr( "class", "" );
6864 if ( typeof value === "string" && value ) {
6865 classes = value.match( rnotwhite ) || [];
6867 while ( ( elem = this[ i++ ] ) ) {
6868 curValue = getClass( elem );
6870 // This expression is here for better compressibility (see addClass)
6871 cur = elem.nodeType === 1 &&
6872 ( " " + curValue + " " ).replace( rclass, " " );
6876 while ( ( clazz = classes[ j++ ] ) ) {
6878 // Remove *all* instances
6879 while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
6880 cur = cur.replace( " " + clazz + " ", " " );
6884 // Only assign if different to avoid unneeded rendering.
6885 finalValue = jQuery.trim( cur );
6886 if ( curValue !== finalValue ) {
6887 elem.setAttribute( "class", finalValue );
6896 toggleClass: function( value, stateVal ) {
6897 var type = typeof value;
6899 if ( typeof stateVal === "boolean" && type === "string" ) {
6900 return stateVal ? this.addClass( value ) : this.removeClass( value );
6903 if ( jQuery.isFunction( value ) ) {
6904 return this.each( function( i ) {
6905 jQuery( this ).toggleClass(
6906 value.call( this, i, getClass( this ), stateVal ),
6912 return this.each( function() {
6913 var className, i, self, classNames;
6915 if ( type === "string" ) {
6917 // Toggle individual class names
6919 self = jQuery( this );
6920 classNames = value.match( rnotwhite ) || [];
6922 while ( ( className = classNames[ i++ ] ) ) {
6924 // Check each className given, space separated list
6925 if ( self.hasClass( className ) ) {
6926 self.removeClass( className );
6928 self.addClass( className );
6932 // Toggle whole class name
6933 } else if ( value === undefined || type === "boolean" ) {
6934 className = getClass( this );
6937 // Store className if set
6938 dataPriv.set( this, "__className__", className );
6941 // If the element has a class name or if we're passed `false`,
6942 // then remove the whole classname (if there was one, the above saved it).
6943 // Otherwise bring back whatever was previously saved (if anything),
6944 // falling back to the empty string if nothing was stored.
6945 if ( this.setAttribute ) {
6946 this.setAttribute( "class",
6947 className || value === false ?
6949 dataPriv.get( this, "__className__" ) || ""
6956 hasClass: function( selector ) {
6957 var className, elem,
6960 className = " " + selector + " ";
6961 while ( ( elem = this[ i++ ] ) ) {
6962 if ( elem.nodeType === 1 &&
6963 ( " " + getClass( elem ) + " " ).replace( rclass, " " )
6964 .indexOf( className ) > -1
6977 var rreturn = /\r/g,
6978 rspaces = /[\x20\t\r\n\f]+/g;
6981 val: function( value ) {
6982 var hooks, ret, isFunction,
6985 if ( !arguments.length ) {
6987 hooks = jQuery.valHooks[ elem.type ] ||
6988 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
6992 ( ret = hooks.get( elem, "value" ) ) !== undefined
6999 return typeof ret === "string" ?
7001 // Handle most common string cases
7002 ret.replace( rreturn, "" ) :
7004 // Handle cases where value is null/undef or number
7005 ret == null ? "" : ret;
7011 isFunction = jQuery.isFunction( value );
7013 return this.each( function( i ) {
7016 if ( this.nodeType !== 1 ) {
7021 val = value.call( this, i, jQuery( this ).val() );
7026 // Treat null/undefined as ""; convert numbers to string
7027 if ( val == null ) {
7030 } else if ( typeof val === "number" ) {
7033 } else if ( jQuery.isArray( val ) ) {
7034 val = jQuery.map( val, function( value ) {
7035 return value == null ? "" : value + "";
7039 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7041 // If set returns undefined, fall back to normal setting
7042 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
7052 get: function( elem ) {
7054 var val = jQuery.find.attr( elem, "value" );
7055 return val != null ?
7058 // Support: IE <=10 - 11 only
7059 // option.text throws exceptions (#14686, #14858)
7060 // Strip and collapse whitespace
7061 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
7062 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
7066 get: function( elem ) {
7068 options = elem.options,
7069 index = elem.selectedIndex,
7070 one = elem.type === "select-one",
7071 values = one ? null : [],
7072 max = one ? index + 1 : options.length,
7077 // Loop through all the selected options
7078 for ( ; i < max; i++ ) {
7079 option = options[ i ];
7081 // Support: IE <=9 only
7082 // IE8-9 doesn't update selected after form reset (#2551)
7083 if ( ( option.selected || i === index ) &&
7085 // Don't return options that are disabled or in a disabled optgroup
7087 ( !option.parentNode.disabled ||
7088 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
7090 // Get the specific value for the option
7091 value = jQuery( option ).val();
7093 // We don't need an array for one selects
7098 // Multi-Selects return an array
7099 values.push( value );
7106 set: function( elem, value ) {
7107 var optionSet, option,
7108 options = elem.options,
7109 values = jQuery.makeArray( value ),
7113 option = options[ i ];
7115 /* eslint-disable no-cond-assign */
7117 if ( option.selected =
7118 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
7123 /* eslint-enable no-cond-assign */
7126 // Force browsers to behave consistently when non-matching value is set
7128 elem.selectedIndex = -1;
7136 // Radios and checkboxes getter/setter
7137 jQuery.each( [ "radio", "checkbox" ], function() {
7138 jQuery.valHooks[ this ] = {
7139 set: function( elem, value ) {
7140 if ( jQuery.isArray( value ) ) {
7141 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
7145 if ( !support.checkOn ) {
7146 jQuery.valHooks[ this ].get = function( elem ) {
7147 return elem.getAttribute( "value" ) === null ? "on" : elem.value;
7155 // Return jQuery for attributes-only inclusion
7158 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
7160 jQuery.extend( jQuery.event, {
7162 trigger: function( event, data, elem, onlyHandlers ) {
7164 var i, cur, tmp, bubbleType, ontype, handle, special,
7165 eventPath = [ elem || document ],
7166 type = hasOwn.call( event, "type" ) ? event.type : event,
7167 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
7169 cur = tmp = elem = elem || document;
7171 // Don't do events on text and comment nodes
7172 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
7176 // focus/blur morphs to focusin/out; ensure we're not firing them right now
7177 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
7181 if ( type.indexOf( "." ) > -1 ) {
7183 // Namespaced trigger; create a regexp to match event type in handle()
7184 namespaces = type.split( "." );
7185 type = namespaces.shift();
7188 ontype = type.indexOf( ":" ) < 0 && "on" + type;
7190 // Caller can pass in a jQuery.Event object, Object, or just an event type string
7191 event = event[ jQuery.expando ] ?
7193 new jQuery.Event( type, typeof event === "object" && event );
7195 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
7196 event.isTrigger = onlyHandlers ? 2 : 3;
7197 event.namespace = namespaces.join( "." );
7198 event.rnamespace = event.namespace ?
7199 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
7202 // Clean up the event in case it is being reused
7203 event.result = undefined;
7204 if ( !event.target ) {
7205 event.target = elem;
7208 // Clone any incoming data and prepend the event, creating the handler arg list
7209 data = data == null ?
7211 jQuery.makeArray( data, [ event ] );
7213 // Allow special events to draw outside the lines
7214 special = jQuery.event.special[ type ] || {};
7215 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
7219 // Determine event propagation path in advance, per W3C events spec (#9951)
7220 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
7221 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
7223 bubbleType = special.delegateType || type;
7224 if ( !rfocusMorph.test( bubbleType + type ) ) {
7225 cur = cur.parentNode;
7227 for ( ; cur; cur = cur.parentNode ) {
7228 eventPath.push( cur );
7232 // Only add window if we got to document (e.g., not plain obj or detached DOM)
7233 if ( tmp === ( elem.ownerDocument || document ) ) {
7234 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
7238 // Fire handlers on the event path
7240 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
7242 event.type = i > 1 ?
7244 special.bindType || type;
7247 handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
7248 dataPriv.get( cur, "handle" );
7250 handle.apply( cur, data );
7254 handle = ontype && cur[ ontype ];
7255 if ( handle && handle.apply && acceptData( cur ) ) {
7256 event.result = handle.apply( cur, data );
7257 if ( event.result === false ) {
7258 event.preventDefault();
7264 // If nobody prevented the default action, do it now
7265 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
7267 if ( ( !special._default ||
7268 special._default.apply( eventPath.pop(), data ) === false ) &&
7269 acceptData( elem ) ) {
7271 // Call a native DOM method on the target with the same name as the event.
7272 // Don't do default actions on window, that's where global variables be (#6170)
7273 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
7275 // Don't re-trigger an onFOO event when we call its FOO() method
7276 tmp = elem[ ontype ];
7279 elem[ ontype ] = null;
7282 // Prevent re-triggering of the same event, since we already bubbled it above
7283 jQuery.event.triggered = type;
7285 jQuery.event.triggered = undefined;
7288 elem[ ontype ] = tmp;
7294 return event.result;
7297 // Piggyback on a donor event to simulate a different one
7298 // Used only for `focus(in | out)` events
7299 simulate: function( type, elem, event ) {
7300 var e = jQuery.extend(
7309 jQuery.event.trigger( e, null, elem );
7316 trigger: function( type, data ) {
7317 return this.each( function() {
7318 jQuery.event.trigger( type, data, this );
7321 triggerHandler: function( type, data ) {
7322 var elem = this[ 0 ];
7324 return jQuery.event.trigger( type, data, elem, true );
7330 jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
7331 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7332 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
7333 function( i, name ) {
7335 // Handle event binding
7336 jQuery.fn[ name ] = function( data, fn ) {
7337 return arguments.length > 0 ?
7338 this.on( name, null, data, fn ) :
7339 this.trigger( name );
7344 hover: function( fnOver, fnOut ) {
7345 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
7352 support.focusin = "onfocusin" in window;
7355 // Support: Firefox <=44
7356 // Firefox doesn't have focus(in | out) events
7357 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
7359 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
7360 // focus(in | out) events fire after focus & blur events,
7361 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
7362 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
7363 if ( !support.focusin ) {
7364 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
7366 // Attach a single capturing handler on the document while someone wants focusin/focusout
7367 var handler = function( event ) {
7368 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
7371 jQuery.event.special[ fix ] = {
7373 var doc = this.ownerDocument || this,
7374 attaches = dataPriv.access( doc, fix );
7377 doc.addEventListener( orig, handler, true );
7379 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
7381 teardown: function() {
7382 var doc = this.ownerDocument || this,
7383 attaches = dataPriv.access( doc, fix ) - 1;
7386 doc.removeEventListener( orig, handler, true );
7387 dataPriv.remove( doc, fix );
7390 dataPriv.access( doc, fix, attaches );
7401 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
7402 rsubmittable = /^(?:input|select|textarea|keygen)/i;
7404 function buildParams( prefix, obj, traditional, add ) {
7407 if ( jQuery.isArray( obj ) ) {
7409 // Serialize array item.
7410 jQuery.each( obj, function( i, v ) {
7411 if ( traditional || rbracket.test( prefix ) ) {
7413 // Treat each array item as a scalar.
7418 // Item is non-scalar (array or object), encode its numeric index.
7420 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
7428 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
7430 // Serialize object item.
7431 for ( name in obj ) {
7432 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7437 // Serialize scalar item.
7442 // Serialize an array of form elements or a set of
7443 // key/values into a query string
7444 jQuery.param = function( a, traditional ) {
7447 add = function( key, valueOrFunction ) {
7449 // If value is a function, invoke it and use its return value
7450 var value = jQuery.isFunction( valueOrFunction ) ?
7454 s[ s.length ] = encodeURIComponent( key ) + "=" +
7455 encodeURIComponent( value == null ? "" : value );
7458 // If an array was passed in, assume that it is an array of form elements.
7459 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7461 // Serialize the form elements
7462 jQuery.each( a, function() {
7463 add( this.name, this.value );
7468 // If traditional, encode the "old" way (the way 1.3.2 or older
7469 // did it), otherwise encode params recursively.
7470 for ( prefix in a ) {
7471 buildParams( prefix, a[ prefix ], traditional, add );
7475 // Return the resulting serialization
7476 return s.join( "&" );
7480 serialize: function() {
7481 return jQuery.param( this.serializeArray() );
7483 serializeArray: function() {
7484 return this.map( function() {
7486 // Can add propHook for "elements" to filter or add form elements
7487 var elements = jQuery.prop( this, "elements" );
7488 return elements ? jQuery.makeArray( elements ) : this;
7490 .filter( function() {
7491 var type = this.type;
7493 // Use .is( ":disabled" ) so that fieldset[disabled] works
7494 return this.name && !jQuery( this ).is( ":disabled" ) &&
7495 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
7496 ( this.checked || !rcheckableType.test( type ) );
7498 .map( function( i, elem ) {
7499 var val = jQuery( this ).val();
7501 return val == null ?
7503 jQuery.isArray( val ) ?
7504 jQuery.map( val, function( val ) {
7505 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7507 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7514 wrapAll: function( html ) {
7518 if ( jQuery.isFunction( html ) ) {
7519 html = html.call( this[ 0 ] );
7522 // The elements to wrap the target around
7523 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
7525 if ( this[ 0 ].parentNode ) {
7526 wrap.insertBefore( this[ 0 ] );
7529 wrap.map( function() {
7532 while ( elem.firstElementChild ) {
7533 elem = elem.firstElementChild;
7543 wrapInner: function( html ) {
7544 if ( jQuery.isFunction( html ) ) {
7545 return this.each( function( i ) {
7546 jQuery( this ).wrapInner( html.call( this, i ) );
7550 return this.each( function() {
7551 var self = jQuery( this ),
7552 contents = self.contents();
7554 if ( contents.length ) {
7555 contents.wrapAll( html );
7558 self.append( html );
7563 wrap: function( html ) {
7564 var isFunction = jQuery.isFunction( html );
7566 return this.each( function( i ) {
7567 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
7571 unwrap: function( selector ) {
7572 this.parent( selector ).not( "body" ).each( function() {
7573 jQuery( this ).replaceWith( this.childNodes );
7580 jQuery.expr.pseudos.hidden = function( elem ) {
7581 return !jQuery.expr.pseudos.visible( elem );
7583 jQuery.expr.pseudos.visible = function( elem ) {
7584 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
7590 // Support: Safari 8 only
7591 // In Safari 8 documents created via document.implementation.createHTMLDocument
7592 // collapse sibling forms: the second one becomes a child of the first one.
7593 // Because of that, this security measure has to be disabled in Safari 8.
7594 // https://bugs.webkit.org/show_bug.cgi?id=137337
7595 support.createHTMLDocument = ( function() {
7596 var body = document.implementation.createHTMLDocument( "" ).body;
7597 body.innerHTML = "<form></form><form></form>";
7598 return body.childNodes.length === 2;
7602 // Argument "data" should be string of html
7603 // context (optional): If specified, the fragment will be created in this context,
7604 // defaults to document
7605 // keepScripts (optional): If true, will include scripts passed in the html string
7606 jQuery.parseHTML = function( data, context, keepScripts ) {
7607 if ( typeof data !== "string" ) {
7610 if ( typeof context === "boolean" ) {
7611 keepScripts = context;
7615 var base, parsed, scripts;
7619 // Stop scripts or inline event handlers from being executed immediately
7620 // by using document.implementation
7621 if ( support.createHTMLDocument ) {
7622 context = document.implementation.createHTMLDocument( "" );
7624 // Set the base href for the created document
7625 // so any parsed elements with URLs
7626 // are based on the document's URL (gh-2965)
7627 base = context.createElement( "base" );
7628 base.href = document.location.href;
7629 context.head.appendChild( base );
7635 parsed = rsingleTag.exec( data );
7636 scripts = !keepScripts && [];
7640 return [ context.createElement( parsed[ 1 ] ) ];
7643 parsed = buildFragment( [ data ], context, scripts );
7645 if ( scripts && scripts.length ) {
7646 jQuery( scripts ).remove();
7649 return jQuery.merge( [], parsed.childNodes );
7654 * Gets a window from an element
7656 function getWindow( elem ) {
7657 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
7661 setOffset: function( elem, options, i ) {
7662 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
7663 position = jQuery.css( elem, "position" ),
7664 curElem = jQuery( elem ),
7667 // Set position first, in-case top/left are set even on static elem
7668 if ( position === "static" ) {
7669 elem.style.position = "relative";
7672 curOffset = curElem.offset();
7673 curCSSTop = jQuery.css( elem, "top" );
7674 curCSSLeft = jQuery.css( elem, "left" );
7675 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
7676 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
7678 // Need to be able to calculate position if either
7679 // top or left is auto and position is either absolute or fixed
7680 if ( calculatePosition ) {
7681 curPosition = curElem.position();
7682 curTop = curPosition.top;
7683 curLeft = curPosition.left;
7686 curTop = parseFloat( curCSSTop ) || 0;
7687 curLeft = parseFloat( curCSSLeft ) || 0;
7690 if ( jQuery.isFunction( options ) ) {
7692 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
7693 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
7696 if ( options.top != null ) {
7697 props.top = ( options.top - curOffset.top ) + curTop;
7699 if ( options.left != null ) {
7700 props.left = ( options.left - curOffset.left ) + curLeft;
7703 if ( "using" in options ) {
7704 options.using.call( elem, props );
7707 curElem.css( props );
7713 offset: function( options ) {
7715 // Preserve chaining for setter
7716 if ( arguments.length ) {
7717 return options === undefined ?
7719 this.each( function( i ) {
7720 jQuery.offset.setOffset( this, options, i );
7724 var docElem, win, rect, doc,
7731 // Support: IE <=11 only
7732 // Running getBoundingClientRect on a
7733 // disconnected node in IE throws an error
7734 if ( !elem.getClientRects().length ) {
7735 return { top: 0, left: 0 };
7738 rect = elem.getBoundingClientRect();
7740 // Make sure element is not hidden (display: none)
7741 if ( rect.width || rect.height ) {
7742 doc = elem.ownerDocument;
7743 win = getWindow( doc );
7744 docElem = doc.documentElement;
7747 top: rect.top + win.pageYOffset - docElem.clientTop,
7748 left: rect.left + win.pageXOffset - docElem.clientLeft
7752 // Return zeros for disconnected and hidden elements (gh-2310)
7756 position: function() {
7761 var offsetParent, offset,
7763 parentOffset = { top: 0, left: 0 };
7765 // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
7766 // because it is its only offset parent
7767 if ( jQuery.css( elem, "position" ) === "fixed" ) {
7769 // Assume getBoundingClientRect is there when computed position is fixed
7770 offset = elem.getBoundingClientRect();
7774 // Get *real* offsetParent
7775 offsetParent = this.offsetParent();
7777 // Get correct offsets
7778 offset = this.offset();
7779 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
7780 parentOffset = offsetParent.offset();
7783 // Add offsetParent borders
7785 top: parentOffset.top + jQuery.css( offsetParent[ 0 ], "borderTopWidth", true ),
7786 left: parentOffset.left + jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true )
7790 // Subtract parent offsets and element margins
7792 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
7793 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
7797 // This method will return documentElement in the following cases:
7798 // 1) For the element inside the iframe without offsetParent, this method will return
7799 // documentElement of the parent window
7800 // 2) For the hidden or detached element
7801 // 3) For body or html element, i.e. in case of the html node - it will return itself
7803 // but those exceptions were never presented as a real life use-cases
7804 // and might be considered as more preferable results.
7806 // This logic, however, is not guaranteed and can change at any point in the future
7807 offsetParent: function() {
7808 return this.map( function() {
7809 var offsetParent = this.offsetParent;
7811 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
7812 offsetParent = offsetParent.offsetParent;
7815 return offsetParent || documentElement;
7820 // Create scrollLeft and scrollTop methods
7821 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
7822 var top = "pageYOffset" === prop;
7824 jQuery.fn[ method ] = function( val ) {
7825 return access( this, function( elem, method, val ) {
7826 var win = getWindow( elem );
7828 if ( val === undefined ) {
7829 return win ? win[ prop ] : elem[ method ];
7834 !top ? val : win.pageXOffset,
7835 top ? val : win.pageYOffset
7839 elem[ method ] = val;
7841 }, method, val, arguments.length );
7845 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
7846 // Add the top/left cssHooks using jQuery.fn.position
7847 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7848 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
7849 // getComputedStyle returns percent when specified for top/left/bottom/right;
7850 // rather than make the css module depend on the offset module, just check for it here
7851 jQuery.each( [ "top", "left" ], function( i, prop ) {
7852 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
7853 function( elem, computed ) {
7855 computed = curCSS( elem, prop );
7857 // If curCSS returns percentage, fallback to offset
7858 return rnumnonpx.test( computed ) ?
7859 jQuery( elem ).position()[ prop ] + "px" :
7867 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
7868 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
7869 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
7870 function( defaultExtra, funcName ) {
7872 // Margin is only for outerHeight, outerWidth
7873 jQuery.fn[ funcName ] = function( margin, value ) {
7874 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
7875 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
7877 return access( this, function( elem, type, value ) {
7880 if ( jQuery.isWindow( elem ) ) {
7882 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
7883 return funcName.indexOf( "outer" ) === 0 ?
7884 elem[ "inner" + name ] :
7885 elem.document.documentElement[ "client" + name ];
7888 // Get document width or height
7889 if ( elem.nodeType === 9 ) {
7890 doc = elem.documentElement;
7892 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
7893 // whichever is greatest
7895 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
7896 elem.body[ "offset" + name ], doc[ "offset" + name ],
7897 doc[ "client" + name ]
7901 return value === undefined ?
7903 // Get width or height on the element, requesting but not forcing parseFloat
7904 jQuery.css( elem, type, extra ) :
7906 // Set width or height on the element
7907 jQuery.style( elem, type, value, extra );
7908 }, type, chainable ? margin : undefined, chainable );
7914 // Register as a named AMD module, since jQuery can be concatenated with other
7915 // files that may use define, but not via a proper concatenation script that
7916 // understands anonymous AMD modules. A named AMD is safest and most robust
7917 // way to register. Lowercase jquery is used because AMD module names are
7918 // derived from file names, and jQuery is normally delivered in a lowercase
7919 // file name. Do this after creating the global so that if an AMD module wants
7920 // to call noConflict to hide this version of jQuery, it will work.
7922 // Note that for maximum portability, libraries that are not jQuery should
7923 // declare themselves as anonymous modules, and avoid setting a global if an
7924 // AMD loader is present. jQuery is a special case. For more information, see
7925 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
7927 if ( typeof define === "function" && define.amd ) {
7928 define( "jquery", [], function() {
7939 // Map over jQuery in case of overwrite
7940 _jQuery = window.jQuery,
7942 // Map over the $ in case of overwrite
7945 jQuery.noConflict = function( deep ) {
7946 if ( window.$ === jQuery ) {
7950 if ( deep && window.jQuery === jQuery ) {
7951 window.jQuery = _jQuery;
7957 // Expose jQuery and $ identifiers, even in AMD
7958 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
7959 // and CommonJS for browser emulators (#13566)
7961 window.jQuery = window.$ = jQuery;