2 * jQuery JavaScript Library v1.12.4
8 * Copyright jQuery Foundation and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2016-05-20T17:17Z
15 (function( global, factory ) {
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper `window`
19 // is present, execute the factory and get jQuery.
20 // For environments that do not have a `window` with a `document`
21 // (such as Node.js), expose a factory as module.exports.
22 // This accentuates the need for the creation of a real `window`.
23 // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info.
25 module.exports = global.document ?
26 factory( global, true ) :
29 throw new Error( "jQuery requires a window with a document" );
37 // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40 // Support: Firefox 18+
41 // Can't be in strict mode, several libs including ASP.NET trace
42 // the stack via arguments.caller.callee and Firefox dies if
43 // you try to trace through "use strict" call chains. (#13335)
47 var document = window.document;
49 var slice = deletedIds.slice;
51 var concat = deletedIds.concat;
53 var push = deletedIds.push;
55 var indexOf = deletedIds.indexOf;
59 var toString = class2type.toString;
61 var hasOwn = class2type.hasOwnProperty;
70 // Define a local copy of jQuery
71 jQuery = function( selector, context ) {
73 // The jQuery object is actually just the init constructor 'enhanced'
74 // Need init if jQuery is called (just allow error to be thrown if not included)
75 return new jQuery.fn.init( selector, context );
78 // Support: Android<4.1, IE<9
79 // Make sure we trim BOM and NBSP
80 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
82 // Matches dashed string for camelizing
84 rdashAlpha = /-([\da-z])/gi,
86 // Used by jQuery.camelCase as callback to replace()
87 fcamelCase = function( all, letter ) {
88 return letter.toUpperCase();
91 jQuery.fn = jQuery.prototype = {
93 // The current version of jQuery being used
98 // Start with an empty selector
101 // The default length of a jQuery object is 0
104 toArray: function() {
105 return slice.call( this );
108 // Get the Nth element in the matched element set OR
109 // Get the whole matched element set as a clean array
110 get: function( num ) {
113 // Return just the one element from the set
114 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116 // Return all the elements in a clean array
120 // Take an array of elements and push it onto the stack
121 // (returning the new matched element set)
122 pushStack: function( elems ) {
124 // Build a new jQuery matched element set
125 var ret = jQuery.merge( this.constructor(), elems );
127 // Add the old object onto the stack (as a reference)
128 ret.prevObject = this;
129 ret.context = this.context;
131 // Return the newly-formed element set
135 // Execute a callback for every element in the matched set.
136 each: function( callback ) {
137 return jQuery.each( this, callback );
140 map: function( callback ) {
141 return this.pushStack( jQuery.map( this, function( elem, i ) {
142 return callback.call( elem, i, elem );
147 return this.pushStack( slice.apply( this, arguments ) );
155 return this.eq( -1 );
159 var len = this.length,
160 j = +i + ( i < 0 ? len : 0 );
161 return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
165 return this.prevObject || this.constructor();
168 // For internal use only.
169 // Behaves like an Array's method, not like a jQuery method.
171 sort: deletedIds.sort,
172 splice: deletedIds.splice
175 jQuery.extend = jQuery.fn.extend = function() {
176 var src, copyIsArray, copy, name, options, clone,
177 target = arguments[ 0 ] || {},
179 length = arguments.length,
182 // Handle a deep copy situation
183 if ( typeof target === "boolean" ) {
186 // skip the boolean and the target
187 target = arguments[ i ] || {};
191 // Handle case when target is a string or something (possible in deep copy)
192 if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
196 // extend jQuery itself if only one argument is passed
197 if ( i === length ) {
202 for ( ; i < length; i++ ) {
204 // Only deal with non-null/undefined values
205 if ( ( options = arguments[ i ] ) != null ) {
207 // Extend the base object
208 for ( name in options ) {
209 src = target[ name ];
210 copy = options[ name ];
212 // Prevent never-ending loop
213 if ( target === copy ) {
217 // Recurse if we're merging plain objects or arrays
218 if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
219 ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
223 clone = src && jQuery.isArray( src ) ? src : [];
226 clone = src && jQuery.isPlainObject( src ) ? src : {};
229 // Never move original objects, clone them
230 target[ name ] = jQuery.extend( deep, clone, copy );
232 // Don't bring in undefined values
233 } else if ( copy !== undefined ) {
234 target[ name ] = copy;
240 // Return the modified object
246 // Unique for each copy of jQuery on the page
247 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
249 // Assume jQuery is ready without the ready module
252 error: function( msg ) {
253 throw new Error( msg );
258 // See test/unit/core.js for details concerning isFunction.
259 // Since version 1.3, DOM methods and functions like alert
260 // aren't supported. They return false on IE (#2968).
261 isFunction: function( obj ) {
262 return jQuery.type( obj ) === "function";
265 isArray: Array.isArray || function( obj ) {
266 return jQuery.type( obj ) === "array";
269 isWindow: function( obj ) {
270 /* jshint eqeqeq: false */
271 return obj != null && obj == obj.window;
274 isNumeric: function( obj ) {
276 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
277 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
278 // subtraction forces infinities to NaN
279 // adding 1 corrects loss of precision from parseFloat (#15100)
280 var realStringObj = obj && obj.toString();
281 return !jQuery.isArray( obj ) && ( realStringObj - parseFloat( realStringObj ) + 1 ) >= 0;
284 isEmptyObject: function( obj ) {
286 for ( name in obj ) {
292 isPlainObject: function( obj ) {
295 // Must be an Object.
296 // Because of IE, we also have to check the presence of the constructor property.
297 // Make sure that DOM nodes and window objects don't pass through, as well
298 if ( !obj || jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
304 // Not own constructor property must be Object
305 if ( obj.constructor &&
306 !hasOwn.call( obj, "constructor" ) &&
307 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
312 // IE8,9 Will throw exceptions on certain host objects #9897
317 // Handle iteration over inherited properties before own properties.
318 if ( !support.ownFirst ) {
320 return hasOwn.call( obj, key );
324 // Own properties are enumerated firstly, so to speed up,
325 // if last one is own, then all properties are own.
326 for ( key in obj ) {}
328 return key === undefined || hasOwn.call( obj, key );
331 type: function( obj ) {
335 return typeof obj === "object" || typeof obj === "function" ?
336 class2type[ toString.call( obj ) ] || "object" :
340 // Workarounds based on findings by Jim Driscoll
341 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
342 globalEval: function( data ) {
343 if ( data && jQuery.trim( data ) ) {
345 // We use execScript on Internet Explorer
346 // We use an anonymous function so that context is window
347 // rather than jQuery in Firefox
348 ( window.execScript || function( data ) {
349 window[ "eval" ].call( window, data ); // jscs:ignore requireDotNotation
354 // Convert dashed to camelCase; used by the css and data modules
355 // Microsoft forgot to hump their vendor prefix (#9572)
356 camelCase: function( string ) {
357 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
360 nodeName: function( elem, name ) {
361 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
364 each: function( obj, callback ) {
367 if ( isArrayLike( obj ) ) {
369 for ( ; i < length; i++ ) {
370 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
376 if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
385 // Support: Android<4.1, IE<9
386 trim: function( text ) {
387 return text == null ?
389 ( text + "" ).replace( rtrim, "" );
392 // results is for internal usage only
393 makeArray: function( arr, results ) {
394 var ret = results || [];
397 if ( isArrayLike( Object( arr ) ) ) {
399 typeof arr === "string" ?
403 push.call( ret, arr );
410 inArray: function( elem, arr, i ) {
415 return indexOf.call( arr, elem, i );
419 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
421 for ( ; i < len; i++ ) {
423 // Skip accessing in sparse arrays
424 if ( i in arr && arr[ i ] === elem ) {
433 merge: function( first, second ) {
434 var len = +second.length,
439 first[ i++ ] = second[ j++ ];
443 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
445 while ( second[ j ] !== undefined ) {
446 first[ i++ ] = second[ j++ ];
455 grep: function( elems, callback, invert ) {
459 length = elems.length,
460 callbackExpect = !invert;
462 // Go through the array, only saving the items
463 // that pass the validator function
464 for ( ; i < length; i++ ) {
465 callbackInverse = !callback( elems[ i ], i );
466 if ( callbackInverse !== callbackExpect ) {
467 matches.push( elems[ i ] );
474 // arg is for internal usage only
475 map: function( elems, callback, arg ) {
480 // Go through the array, translating each of the items to their new values
481 if ( isArrayLike( elems ) ) {
482 length = elems.length;
483 for ( ; i < length; i++ ) {
484 value = callback( elems[ i ], i, arg );
486 if ( value != null ) {
491 // Go through every key on the object,
494 value = callback( elems[ i ], i, arg );
496 if ( value != null ) {
502 // Flatten any nested arrays
503 return concat.apply( [], ret );
506 // A global GUID counter for objects
509 // Bind a function to a context, optionally partially applying any
511 proxy: function( fn, context ) {
512 var args, proxy, tmp;
514 if ( typeof context === "string" ) {
520 // Quick check to determine if target is callable, in the spec
521 // this throws a TypeError, but we will just return undefined.
522 if ( !jQuery.isFunction( fn ) ) {
527 args = slice.call( arguments, 2 );
529 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
532 // Set the guid of unique handler to the same of original handler, so it can be removed
533 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
539 return +( new Date() );
542 // jQuery.support is not used in Core but other projects attach their
543 // properties to it so it needs to exist.
547 // JSHint would error on this code due to the Symbol not being defined in ES5.
548 // Defining this global in .jshintrc would create a danger of using the global
549 // unguarded in another place, it seems safer to just disable JSHint for these
551 /* jshint ignore: start */
552 if ( typeof Symbol === "function" ) {
553 jQuery.fn[ Symbol.iterator ] = deletedIds[ Symbol.iterator ];
555 /* jshint ignore: end */
557 // Populate the class2type map
558 jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
559 function( i, name ) {
560 class2type[ "[object " + name + "]" ] = name.toLowerCase();
563 function isArrayLike( obj ) {
565 // Support: iOS 8.2 (not reproducible in simulator)
566 // `in` check used to prevent JIT error (gh-2145)
567 // hasOwn isn't used here due to false negatives
568 // regarding Nodelist length in IE
569 var length = !!obj && "length" in obj && obj.length,
570 type = jQuery.type( obj );
572 if ( type === "function" || jQuery.isWindow( obj ) ) {
576 return type === "array" || length === 0 ||
577 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
581 * Sizzle CSS Selector Engine v2.2.1
582 * http://sizzlejs.com/
584 * Copyright jQuery Foundation and other contributors
585 * Released under the MIT license
586 * http://jquery.org/license
590 (function( window ) {
604 // Local document vars
614 // Instance-specific data
615 expando = "sizzle" + 1 * new Date(),
616 preferredDoc = window.document,
619 classCache = createCache(),
620 tokenCache = createCache(),
621 compilerCache = createCache(),
622 sortOrder = function( a, b ) {
629 // General-purpose constants
630 MAX_NEGATIVE = 1 << 31,
633 hasOwn = ({}).hasOwnProperty,
636 push_native = arr.push,
639 // Use a stripped-down indexOf as it's faster than native
640 // http://jsperf.com/thor-indexof-vs-for/5
641 indexOf = function( list, elem ) {
644 for ( ; i < len; i++ ) {
645 if ( list[i] === elem ) {
652 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
654 // Regular expressions
656 // http://www.w3.org/TR/css3-selectors/#whitespace
657 whitespace = "[\\x20\\t\\r\\n\\f]",
659 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
660 identifier = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
662 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
663 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
664 // Operator (capture 2)
665 "*([*^$|!~]?=)" + whitespace +
666 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
667 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
670 pseudos = ":(" + identifier + ")(?:\\((" +
671 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
672 // 1. quoted (capture 3; capture 4 or capture 5)
673 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
674 // 2. simple (capture 6)
675 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
676 // 3. anything else (capture 2)
680 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
681 rwhitespace = new RegExp( whitespace + "+", "g" ),
682 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
684 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
685 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
687 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
689 rpseudo = new RegExp( pseudos ),
690 ridentifier = new RegExp( "^" + identifier + "$" ),
693 "ID": new RegExp( "^#(" + identifier + ")" ),
694 "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
695 "TAG": new RegExp( "^(" + identifier + "|[*])" ),
696 "ATTR": new RegExp( "^" + attributes ),
697 "PSEUDO": new RegExp( "^" + pseudos ),
698 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
699 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
700 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
701 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
702 // For use in libraries implementing .is()
703 // We use this for POS matching in `select`
704 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
705 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
708 rinputs = /^(?:input|select|textarea|button)$/i,
711 rnative = /^[^{]+\{\s*\[native \w/,
713 // Easily-parseable/retrievable ID or TAG or CLASS selectors
714 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
719 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
720 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
721 funescape = function( _, escaped, escapedWhitespace ) {
722 var high = "0x" + escaped - 0x10000;
723 // NaN means non-codepoint
724 // Support: Firefox<24
725 // Workaround erroneous numeric interpretation of +"0x"
726 return high !== high || escapedWhitespace ?
730 String.fromCharCode( high + 0x10000 ) :
731 // Supplemental Plane codepoint (surrogate pair)
732 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
737 // Removing the function wrapper causes a "Permission Denied"
739 unloadHandler = function() {
743 // Optimize for push.apply( _, NodeList )
746 (arr = slice.call( preferredDoc.childNodes )),
747 preferredDoc.childNodes
749 // Support: Android<4.0
750 // Detect silently failing push.apply
751 arr[ preferredDoc.childNodes.length ].nodeType;
753 push = { apply: arr.length ?
755 // Leverage slice if possible
756 function( target, els ) {
757 push_native.apply( target, slice.call(els) );
761 // Otherwise append directly
762 function( target, els ) {
763 var j = target.length,
765 // Can't trust NodeList.length
766 while ( (target[j++] = els[i++]) ) {}
767 target.length = j - 1;
772 function Sizzle( selector, context, results, seed ) {
773 var m, i, elem, nid, nidselect, match, groups, newSelector,
774 newContext = context && context.ownerDocument,
776 // nodeType defaults to 9, since context defaults to document
777 nodeType = context ? context.nodeType : 9;
779 results = results || [];
781 // Return early from calls with invalid selector or context
782 if ( typeof selector !== "string" || !selector ||
783 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
788 // Try to shortcut find operations (as opposed to filters) in HTML documents
791 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
792 setDocument( context );
794 context = context || document;
796 if ( documentIsHTML ) {
798 // If the selector is sufficiently simple, try using a "get*By*" DOM method
799 // (excepting DocumentFragment context, where the methods don't exist)
800 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
803 if ( (m = match[1]) ) {
806 if ( nodeType === 9 ) {
807 if ( (elem = context.getElementById( m )) ) {
809 // Support: IE, Opera, Webkit
810 // TODO: identify versions
811 // getElementById can match elements by name instead of ID
812 if ( elem.id === m ) {
813 results.push( elem );
823 // Support: IE, Opera, Webkit
824 // TODO: identify versions
825 // getElementById can match elements by name instead of ID
826 if ( newContext && (elem = newContext.getElementById( m )) &&
827 contains( context, elem ) &&
830 results.push( elem );
836 } else if ( match[2] ) {
837 push.apply( results, context.getElementsByTagName( selector ) );
841 } else if ( (m = match[3]) && support.getElementsByClassName &&
842 context.getElementsByClassName ) {
844 push.apply( results, context.getElementsByClassName( m ) );
849 // Take advantage of querySelectorAll
851 !compilerCache[ selector + " " ] &&
852 (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
854 if ( nodeType !== 1 ) {
855 newContext = context;
856 newSelector = selector;
858 // qSA looks outside Element context, which is not what we want
859 // Thanks to Andrew Dupont for this workaround technique
861 // Exclude object elements
862 } else if ( context.nodeName.toLowerCase() !== "object" ) {
864 // Capture the context ID, setting it first if necessary
865 if ( (nid = context.getAttribute( "id" )) ) {
866 nid = nid.replace( rescape, "\\$&" );
868 context.setAttribute( "id", (nid = expando) );
871 // Prefix every selector in the list
872 groups = tokenize( selector );
874 nidselect = ridentifier.test( nid ) ? "#" + nid : "[id='" + nid + "']";
876 groups[i] = nidselect + " " + toSelector( groups[i] );
878 newSelector = groups.join( "," );
880 // Expand context for sibling selectors
881 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
888 newContext.querySelectorAll( newSelector )
891 } catch ( qsaError ) {
893 if ( nid === expando ) {
894 context.removeAttribute( "id" );
903 return select( selector.replace( rtrim, "$1" ), context, results, seed );
907 * Create key-value caches of limited size
908 * @returns {function(string, object)} Returns the Object data after storing it on itself with
909 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
910 * deleting the oldest entry
912 function createCache() {
915 function cache( key, value ) {
916 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
917 if ( keys.push( key + " " ) > Expr.cacheLength ) {
918 // Only keep the most recent entries
919 delete cache[ keys.shift() ];
921 return (cache[ key + " " ] = value);
927 * Mark a function for special use by Sizzle
928 * @param {Function} fn The function to mark
930 function markFunction( fn ) {
931 fn[ expando ] = true;
936 * Support testing using an element
937 * @param {Function} fn Passed the created div and expects a boolean result
939 function assert( fn ) {
940 var div = document.createElement("div");
947 // Remove from its parent by default
948 if ( div.parentNode ) {
949 div.parentNode.removeChild( div );
951 // release memory in IE
957 * Adds the same handler for all of the specified attrs
958 * @param {String} attrs Pipe-separated list of attributes
959 * @param {Function} handler The method that will be applied
961 function addHandle( attrs, handler ) {
962 var arr = attrs.split("|"),
966 Expr.attrHandle[ arr[i] ] = handler;
971 * Checks document order of two siblings
974 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
976 function siblingCheck( a, b ) {
978 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
979 ( ~b.sourceIndex || MAX_NEGATIVE ) -
980 ( ~a.sourceIndex || MAX_NEGATIVE );
982 // Use IE sourceIndex if available on both nodes
987 // Check if b follows a
989 while ( (cur = cur.nextSibling) ) {
1000 * Returns a function to use in pseudos for input types
1001 * @param {String} type
1003 function createInputPseudo( type ) {
1004 return function( elem ) {
1005 var name = elem.nodeName.toLowerCase();
1006 return name === "input" && elem.type === type;
1011 * Returns a function to use in pseudos for buttons
1012 * @param {String} type
1014 function createButtonPseudo( type ) {
1015 return function( elem ) {
1016 var name = elem.nodeName.toLowerCase();
1017 return (name === "input" || name === "button") && elem.type === type;
1022 * Returns a function to use in pseudos for positionals
1023 * @param {Function} fn
1025 function createPositionalPseudo( fn ) {
1026 return markFunction(function( argument ) {
1027 argument = +argument;
1028 return markFunction(function( seed, matches ) {
1030 matchIndexes = fn( [], seed.length, argument ),
1031 i = matchIndexes.length;
1033 // Match elements found at the specified indexes
1035 if ( seed[ (j = matchIndexes[i]) ] ) {
1036 seed[j] = !(matches[j] = seed[j]);
1044 * Checks a node for validity as a Sizzle context
1045 * @param {Element|Object=} context
1046 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1048 function testContext( context ) {
1049 return context && typeof context.getElementsByTagName !== "undefined" && context;
1052 // Expose support vars for convenience
1053 support = Sizzle.support = {};
1057 * @param {Element|Object} elem An element or a document
1058 * @returns {Boolean} True iff elem is a non-HTML XML node
1060 isXML = Sizzle.isXML = function( elem ) {
1061 // documentElement is verified for cases where it doesn't yet exist
1062 // (such as loading iframes in IE - #4833)
1063 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1064 return documentElement ? documentElement.nodeName !== "HTML" : false;
1068 * Sets document-related variables once based on the current document
1069 * @param {Element|Object} [doc] An element or document object to use to set the document
1070 * @returns {Object} Returns the current document
1072 setDocument = Sizzle.setDocument = function( node ) {
1073 var hasCompare, parent,
1074 doc = node ? node.ownerDocument || node : preferredDoc;
1076 // Return early if doc is invalid or already selected
1077 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1081 // Update global variables
1083 docElem = document.documentElement;
1084 documentIsHTML = !isXML( document );
1086 // Support: IE 9-11, Edge
1087 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1088 if ( (parent = document.defaultView) && parent.top !== parent ) {
1090 if ( parent.addEventListener ) {
1091 parent.addEventListener( "unload", unloadHandler, false );
1093 // Support: IE 9 - 10 only
1094 } else if ( parent.attachEvent ) {
1095 parent.attachEvent( "onunload", unloadHandler );
1100 ---------------------------------------------------------------------- */
1103 // Verify that getAttribute really returns attributes and not properties
1104 // (excepting IE8 booleans)
1105 support.attributes = assert(function( div ) {
1106 div.className = "i";
1107 return !div.getAttribute("className");
1111 ---------------------------------------------------------------------- */
1113 // Check if getElementsByTagName("*") returns only elements
1114 support.getElementsByTagName = assert(function( div ) {
1115 div.appendChild( document.createComment("") );
1116 return !div.getElementsByTagName("*").length;
1120 support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1123 // Check if getElementById returns elements by name
1124 // The broken getElementById methods don't pick up programatically-set names,
1125 // so use a roundabout getElementsByName test
1126 support.getById = assert(function( div ) {
1127 docElem.appendChild( div ).id = expando;
1128 return !document.getElementsByName || !document.getElementsByName( expando ).length;
1131 // ID find and filter
1132 if ( support.getById ) {
1133 Expr.find["ID"] = function( id, context ) {
1134 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1135 var m = context.getElementById( id );
1136 return m ? [ m ] : [];
1139 Expr.filter["ID"] = function( id ) {
1140 var attrId = id.replace( runescape, funescape );
1141 return function( elem ) {
1142 return elem.getAttribute("id") === attrId;
1147 // getElementById is not reliable as a find shortcut
1148 delete Expr.find["ID"];
1150 Expr.filter["ID"] = function( id ) {
1151 var attrId = id.replace( runescape, funescape );
1152 return function( elem ) {
1153 var node = typeof elem.getAttributeNode !== "undefined" &&
1154 elem.getAttributeNode("id");
1155 return node && node.value === attrId;
1161 Expr.find["TAG"] = support.getElementsByTagName ?
1162 function( tag, context ) {
1163 if ( typeof context.getElementsByTagName !== "undefined" ) {
1164 return context.getElementsByTagName( tag );
1166 // DocumentFragment nodes don't have gEBTN
1167 } else if ( support.qsa ) {
1168 return context.querySelectorAll( tag );
1172 function( tag, context ) {
1176 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1177 results = context.getElementsByTagName( tag );
1179 // Filter out possible comments
1180 if ( tag === "*" ) {
1181 while ( (elem = results[i++]) ) {
1182 if ( elem.nodeType === 1 ) {
1193 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1194 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1195 return context.getElementsByClassName( className );
1199 /* QSA/matchesSelector
1200 ---------------------------------------------------------------------- */
1202 // QSA and matchesSelector support
1204 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1207 // qSa(:focus) reports false when true (Chrome 21)
1208 // We allow this because of a bug in IE8/9 that throws an error
1209 // whenever `document.activeElement` is accessed on an iframe
1210 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1211 // See http://bugs.jquery.com/ticket/13378
1214 if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
1216 // Regex strategy adopted from Diego Perini
1217 assert(function( div ) {
1218 // Select is set to empty string on purpose
1219 // This is to test IE's treatment of not explicitly
1220 // setting a boolean content attribute,
1221 // since its presence should be enough
1222 // http://bugs.jquery.com/ticket/12359
1223 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1224 "<select id='" + expando + "-\r\\' msallowcapture=''>" +
1225 "<option selected=''></option></select>";
1227 // Support: IE8, Opera 11-12.16
1228 // Nothing should be selected when empty strings follow ^= or $= or *=
1229 // The test attribute must be unknown in Opera but "safe" for WinRT
1230 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1231 if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1232 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1236 // Boolean attributes and "value" are not treated correctly
1237 if ( !div.querySelectorAll("[selected]").length ) {
1238 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1241 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1242 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1243 rbuggyQSA.push("~=");
1246 // Webkit/Opera - :checked should return selected option elements
1247 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1248 // IE8 throws error here and will not see later tests
1249 if ( !div.querySelectorAll(":checked").length ) {
1250 rbuggyQSA.push(":checked");
1253 // Support: Safari 8+, iOS 8+
1254 // https://bugs.webkit.org/show_bug.cgi?id=136851
1255 // In-page `selector#id sibing-combinator selector` fails
1256 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1257 rbuggyQSA.push(".#.+[+~]");
1261 assert(function( div ) {
1262 // Support: Windows 8 Native Apps
1263 // The type and name attributes are restricted during .innerHTML assignment
1264 var input = document.createElement("input");
1265 input.setAttribute( "type", "hidden" );
1266 div.appendChild( input ).setAttribute( "name", "D" );
1269 // Enforce case-sensitivity of name attribute
1270 if ( div.querySelectorAll("[name=d]").length ) {
1271 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1274 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1275 // IE8 throws error here and will not see later tests
1276 if ( !div.querySelectorAll(":enabled").length ) {
1277 rbuggyQSA.push( ":enabled", ":disabled" );
1280 // Opera 10-11 does not throw on post-comma invalid pseudos
1281 div.querySelectorAll("*,:x");
1282 rbuggyQSA.push(",.*:");
1286 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1287 docElem.webkitMatchesSelector ||
1288 docElem.mozMatchesSelector ||
1289 docElem.oMatchesSelector ||
1290 docElem.msMatchesSelector) )) ) {
1292 assert(function( div ) {
1293 // Check to see if it's possible to do matchesSelector
1294 // on a disconnected node (IE 9)
1295 support.disconnectedMatch = matches.call( div, "div" );
1297 // This should fail with an exception
1298 // Gecko does not error, returns false instead
1299 matches.call( div, "[s!='']:x" );
1300 rbuggyMatches.push( "!=", pseudos );
1304 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1305 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1308 ---------------------------------------------------------------------- */
1309 hasCompare = rnative.test( docElem.compareDocumentPosition );
1311 // Element contains another
1312 // Purposefully self-exclusive
1313 // As in, an element does not contain itself
1314 contains = hasCompare || rnative.test( docElem.contains ) ?
1316 var adown = a.nodeType === 9 ? a.documentElement : a,
1317 bup = b && b.parentNode;
1318 return a === bup || !!( bup && bup.nodeType === 1 && (
1320 adown.contains( bup ) :
1321 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1326 while ( (b = b.parentNode) ) {
1336 ---------------------------------------------------------------------- */
1338 // Document order sorting
1339 sortOrder = hasCompare ?
1342 // Flag for duplicate removal
1344 hasDuplicate = true;
1348 // Sort on method existence if only one input has compareDocumentPosition
1349 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1354 // Calculate position if both inputs belong to the same document
1355 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1356 a.compareDocumentPosition( b ) :
1358 // Otherwise we know they are disconnected
1361 // Disconnected nodes
1363 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1365 // Choose the first element that is related to our preferred document
1366 if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1369 if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1373 // Maintain original order
1375 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1379 return compare & 4 ? -1 : 1;
1382 // Exit early if the nodes are identical
1384 hasDuplicate = true;
1395 // Parentless nodes are either documents or disconnected
1396 if ( !aup || !bup ) {
1397 return a === document ? -1 :
1398 b === document ? 1 :
1402 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1405 // If the nodes are siblings, we can do a quick check
1406 } else if ( aup === bup ) {
1407 return siblingCheck( a, b );
1410 // Otherwise we need full lists of their ancestors for comparison
1412 while ( (cur = cur.parentNode) ) {
1416 while ( (cur = cur.parentNode) ) {
1420 // Walk down the tree looking for a discrepancy
1421 while ( ap[i] === bp[i] ) {
1426 // Do a sibling check if the nodes have a common ancestor
1427 siblingCheck( ap[i], bp[i] ) :
1429 // Otherwise nodes in our document sort first
1430 ap[i] === preferredDoc ? -1 :
1431 bp[i] === preferredDoc ? 1 :
1438 Sizzle.matches = function( expr, elements ) {
1439 return Sizzle( expr, null, null, elements );
1442 Sizzle.matchesSelector = function( elem, expr ) {
1443 // Set document vars if needed
1444 if ( ( elem.ownerDocument || elem ) !== document ) {
1445 setDocument( elem );
1448 // Make sure that attribute selectors are quoted
1449 expr = expr.replace( rattributeQuotes, "='$1']" );
1451 if ( support.matchesSelector && documentIsHTML &&
1452 !compilerCache[ expr + " " ] &&
1453 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1454 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1457 var ret = matches.call( elem, expr );
1459 // IE 9's matchesSelector returns false on disconnected nodes
1460 if ( ret || support.disconnectedMatch ||
1461 // As well, disconnected nodes are said to be in a document
1463 elem.document && elem.document.nodeType !== 11 ) {
1469 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1472 Sizzle.contains = function( context, elem ) {
1473 // Set document vars if needed
1474 if ( ( context.ownerDocument || context ) !== document ) {
1475 setDocument( context );
1477 return contains( context, elem );
1480 Sizzle.attr = function( elem, name ) {
1481 // Set document vars if needed
1482 if ( ( elem.ownerDocument || elem ) !== document ) {
1483 setDocument( elem );
1486 var fn = Expr.attrHandle[ name.toLowerCase() ],
1487 // Don't get fooled by Object.prototype properties (jQuery #13807)
1488 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1489 fn( elem, name, !documentIsHTML ) :
1492 return val !== undefined ?
1494 support.attributes || !documentIsHTML ?
1495 elem.getAttribute( name ) :
1496 (val = elem.getAttributeNode(name)) && val.specified ?
1501 Sizzle.error = function( msg ) {
1502 throw new Error( "Syntax error, unrecognized expression: " + msg );
1506 * Document sorting and removing duplicates
1507 * @param {ArrayLike} results
1509 Sizzle.uniqueSort = function( results ) {
1515 // Unless we *know* we can detect duplicates, assume their presence
1516 hasDuplicate = !support.detectDuplicates;
1517 sortInput = !support.sortStable && results.slice( 0 );
1518 results.sort( sortOrder );
1520 if ( hasDuplicate ) {
1521 while ( (elem = results[i++]) ) {
1522 if ( elem === results[ i ] ) {
1523 j = duplicates.push( i );
1527 results.splice( duplicates[ j ], 1 );
1531 // Clear input after sorting to release objects
1532 // See https://github.com/jquery/sizzle/pull/225
1539 * Utility function for retrieving the text value of an array of DOM nodes
1540 * @param {Array|Element} elem
1542 getText = Sizzle.getText = function( elem ) {
1546 nodeType = elem.nodeType;
1549 // If no nodeType, this is expected to be an array
1550 while ( (node = elem[i++]) ) {
1551 // Do not traverse comment nodes
1552 ret += getText( node );
1554 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1555 // Use textContent for elements
1556 // innerText usage removed for consistency of new lines (jQuery #11153)
1557 if ( typeof elem.textContent === "string" ) {
1558 return elem.textContent;
1560 // Traverse its children
1561 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1562 ret += getText( elem );
1565 } else if ( nodeType === 3 || nodeType === 4 ) {
1566 return elem.nodeValue;
1568 // Do not include comment or processing instruction nodes
1573 Expr = Sizzle.selectors = {
1575 // Can be adjusted by the user
1578 createPseudo: markFunction,
1587 ">": { dir: "parentNode", first: true },
1588 " ": { dir: "parentNode" },
1589 "+": { dir: "previousSibling", first: true },
1590 "~": { dir: "previousSibling" }
1594 "ATTR": function( match ) {
1595 match[1] = match[1].replace( runescape, funescape );
1597 // Move the given value to match[3] whether quoted or unquoted
1598 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1600 if ( match[2] === "~=" ) {
1601 match[3] = " " + match[3] + " ";
1604 return match.slice( 0, 4 );
1607 "CHILD": function( match ) {
1608 /* matches from matchExpr["CHILD"]
1609 1 type (only|nth|...)
1610 2 what (child|of-type)
1611 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1612 4 xn-component of xn+y argument ([+-]?\d*n|)
1613 5 sign of xn-component
1615 7 sign of y-component
1618 match[1] = match[1].toLowerCase();
1620 if ( match[1].slice( 0, 3 ) === "nth" ) {
1621 // nth-* requires argument
1623 Sizzle.error( match[0] );
1626 // numeric x and y parameters for Expr.filter.CHILD
1627 // remember that false/true cast respectively to 0/1
1628 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1629 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1631 // other types prohibit arguments
1632 } else if ( match[3] ) {
1633 Sizzle.error( match[0] );
1639 "PSEUDO": function( match ) {
1641 unquoted = !match[6] && match[2];
1643 if ( matchExpr["CHILD"].test( match[0] ) ) {
1647 // Accept quoted arguments as-is
1649 match[2] = match[4] || match[5] || "";
1651 // Strip excess characters from unquoted arguments
1652 } else if ( unquoted && rpseudo.test( unquoted ) &&
1653 // Get excess from tokenize (recursively)
1654 (excess = tokenize( unquoted, true )) &&
1655 // advance to the next closing parenthesis
1656 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1658 // excess is a negative index
1659 match[0] = match[0].slice( 0, excess );
1660 match[2] = unquoted.slice( 0, excess );
1663 // Return only captures needed by the pseudo filter method (type and argument)
1664 return match.slice( 0, 3 );
1670 "TAG": function( nodeNameSelector ) {
1671 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1672 return nodeNameSelector === "*" ?
1673 function() { return true; } :
1675 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1679 "CLASS": function( className ) {
1680 var pattern = classCache[ className + " " ];
1683 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1684 classCache( className, function( elem ) {
1685 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1689 "ATTR": function( name, operator, check ) {
1690 return function( elem ) {
1691 var result = Sizzle.attr( elem, name );
1693 if ( result == null ) {
1694 return operator === "!=";
1702 return operator === "=" ? result === check :
1703 operator === "!=" ? result !== check :
1704 operator === "^=" ? check && result.indexOf( check ) === 0 :
1705 operator === "*=" ? check && result.indexOf( check ) > -1 :
1706 operator === "$=" ? check && result.slice( -check.length ) === check :
1707 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1708 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1713 "CHILD": function( type, what, argument, first, last ) {
1714 var simple = type.slice( 0, 3 ) !== "nth",
1715 forward = type.slice( -4 ) !== "last",
1716 ofType = what === "of-type";
1718 return first === 1 && last === 0 ?
1720 // Shortcut for :nth-*(n)
1722 return !!elem.parentNode;
1725 function( elem, context, xml ) {
1726 var cache, uniqueCache, outerCache, node, nodeIndex, start,
1727 dir = simple !== forward ? "nextSibling" : "previousSibling",
1728 parent = elem.parentNode,
1729 name = ofType && elem.nodeName.toLowerCase(),
1730 useCache = !xml && !ofType,
1735 // :(first|last|only)-(child|of-type)
1739 while ( (node = node[ dir ]) ) {
1741 node.nodeName.toLowerCase() === name :
1742 node.nodeType === 1 ) {
1747 // Reverse direction for :only-* (if we haven't yet done so)
1748 start = dir = type === "only" && !start && "nextSibling";
1753 start = [ forward ? parent.firstChild : parent.lastChild ];
1755 // non-xml :nth-child(...) stores cache data on `parent`
1756 if ( forward && useCache ) {
1758 // Seek `elem` from a previously-cached index
1760 // ...in a gzip-friendly way
1762 outerCache = node[ expando ] || (node[ expando ] = {});
1764 // Support: IE <9 only
1765 // Defend against cloned attroperties (jQuery gh-1709)
1766 uniqueCache = outerCache[ node.uniqueID ] ||
1767 (outerCache[ node.uniqueID ] = {});
1769 cache = uniqueCache[ type ] || [];
1770 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1771 diff = nodeIndex && cache[ 2 ];
1772 node = nodeIndex && parent.childNodes[ nodeIndex ];
1774 while ( (node = ++nodeIndex && node && node[ dir ] ||
1776 // Fallback to seeking `elem` from the start
1777 (diff = nodeIndex = 0) || start.pop()) ) {
1779 // When found, cache indexes on `parent` and break
1780 if ( node.nodeType === 1 && ++diff && node === elem ) {
1781 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1787 // Use previously-cached element index if available
1789 // ...in a gzip-friendly way
1791 outerCache = node[ expando ] || (node[ expando ] = {});
1793 // Support: IE <9 only
1794 // Defend against cloned attroperties (jQuery gh-1709)
1795 uniqueCache = outerCache[ node.uniqueID ] ||
1796 (outerCache[ node.uniqueID ] = {});
1798 cache = uniqueCache[ type ] || [];
1799 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1803 // xml :nth-child(...)
1804 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1805 if ( diff === false ) {
1806 // Use the same loop as above to seek `elem` from the start
1807 while ( (node = ++nodeIndex && node && node[ dir ] ||
1808 (diff = nodeIndex = 0) || start.pop()) ) {
1811 node.nodeName.toLowerCase() === name :
1812 node.nodeType === 1 ) &&
1815 // Cache the index of each encountered element
1817 outerCache = node[ expando ] || (node[ expando ] = {});
1819 // Support: IE <9 only
1820 // Defend against cloned attroperties (jQuery gh-1709)
1821 uniqueCache = outerCache[ node.uniqueID ] ||
1822 (outerCache[ node.uniqueID ] = {});
1824 uniqueCache[ type ] = [ dirruns, diff ];
1827 if ( node === elem ) {
1835 // Incorporate the offset, then check against cycle size
1837 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1842 "PSEUDO": function( pseudo, argument ) {
1843 // pseudo-class names are case-insensitive
1844 // http://www.w3.org/TR/selectors/#pseudo-classes
1845 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1846 // Remember that setFilters inherits from pseudos
1848 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1849 Sizzle.error( "unsupported pseudo: " + pseudo );
1851 // The user may use createPseudo to indicate that
1852 // arguments are needed to create the filter function
1853 // just as Sizzle does
1854 if ( fn[ expando ] ) {
1855 return fn( argument );
1858 // But maintain support for old signatures
1859 if ( fn.length > 1 ) {
1860 args = [ pseudo, pseudo, "", argument ];
1861 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1862 markFunction(function( seed, matches ) {
1864 matched = fn( seed, argument ),
1867 idx = indexOf( seed, matched[i] );
1868 seed[ idx ] = !( matches[ idx ] = matched[i] );
1872 return fn( elem, 0, args );
1881 // Potentially complex pseudos
1882 "not": markFunction(function( selector ) {
1883 // Trim the selector passed to compile
1884 // to avoid treating leading and trailing
1885 // spaces as combinators
1888 matcher = compile( selector.replace( rtrim, "$1" ) );
1890 return matcher[ expando ] ?
1891 markFunction(function( seed, matches, context, xml ) {
1893 unmatched = matcher( seed, null, xml, [] ),
1896 // Match elements unmatched by `matcher`
1898 if ( (elem = unmatched[i]) ) {
1899 seed[i] = !(matches[i] = elem);
1903 function( elem, context, xml ) {
1905 matcher( input, null, xml, results );
1906 // Don't keep the element (issue #299)
1908 return !results.pop();
1912 "has": markFunction(function( selector ) {
1913 return function( elem ) {
1914 return Sizzle( selector, elem ).length > 0;
1918 "contains": markFunction(function( text ) {
1919 text = text.replace( runescape, funescape );
1920 return function( elem ) {
1921 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1925 // "Whether an element is represented by a :lang() selector
1926 // is based solely on the element's language value
1927 // being equal to the identifier C,
1928 // or beginning with the identifier C immediately followed by "-".
1929 // The matching of C against the element's language value is performed case-insensitively.
1930 // The identifier C does not have to be a valid language name."
1931 // http://www.w3.org/TR/selectors/#lang-pseudo
1932 "lang": markFunction( function( lang ) {
1933 // lang value must be a valid identifier
1934 if ( !ridentifier.test(lang || "") ) {
1935 Sizzle.error( "unsupported lang: " + lang );
1937 lang = lang.replace( runescape, funescape ).toLowerCase();
1938 return function( elem ) {
1941 if ( (elemLang = documentIsHTML ?
1943 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1945 elemLang = elemLang.toLowerCase();
1946 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1948 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1954 "target": function( elem ) {
1955 var hash = window.location && window.location.hash;
1956 return hash && hash.slice( 1 ) === elem.id;
1959 "root": function( elem ) {
1960 return elem === docElem;
1963 "focus": function( elem ) {
1964 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1967 // Boolean properties
1968 "enabled": function( elem ) {
1969 return elem.disabled === false;
1972 "disabled": function( elem ) {
1973 return elem.disabled === true;
1976 "checked": function( elem ) {
1977 // In CSS3, :checked should return both checked and selected elements
1978 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1979 var nodeName = elem.nodeName.toLowerCase();
1980 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1983 "selected": function( elem ) {
1984 // Accessing this property makes selected-by-default
1985 // options in Safari work properly
1986 if ( elem.parentNode ) {
1987 elem.parentNode.selectedIndex;
1990 return elem.selected === true;
1994 "empty": function( elem ) {
1995 // http://www.w3.org/TR/selectors/#empty-pseudo
1996 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1997 // but not by others (comment: 8; processing instruction: 7; etc.)
1998 // nodeType < 6 works because attributes (2) do not appear as children
1999 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
2000 if ( elem.nodeType < 6 ) {
2007 "parent": function( elem ) {
2008 return !Expr.pseudos["empty"]( elem );
2011 // Element/input types
2012 "header": function( elem ) {
2013 return rheader.test( elem.nodeName );
2016 "input": function( elem ) {
2017 return rinputs.test( elem.nodeName );
2020 "button": function( elem ) {
2021 var name = elem.nodeName.toLowerCase();
2022 return name === "input" && elem.type === "button" || name === "button";
2025 "text": function( elem ) {
2027 return elem.nodeName.toLowerCase() === "input" &&
2028 elem.type === "text" &&
2031 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2032 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
2035 // Position-in-collection
2036 "first": createPositionalPseudo(function() {
2040 "last": createPositionalPseudo(function( matchIndexes, length ) {
2041 return [ length - 1 ];
2044 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
2045 return [ argument < 0 ? argument + length : argument ];
2048 "even": createPositionalPseudo(function( matchIndexes, length ) {
2050 for ( ; i < length; i += 2 ) {
2051 matchIndexes.push( i );
2053 return matchIndexes;
2056 "odd": createPositionalPseudo(function( matchIndexes, length ) {
2058 for ( ; i < length; i += 2 ) {
2059 matchIndexes.push( i );
2061 return matchIndexes;
2064 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2065 var i = argument < 0 ? argument + length : argument;
2066 for ( ; --i >= 0; ) {
2067 matchIndexes.push( i );
2069 return matchIndexes;
2072 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2073 var i = argument < 0 ? argument + length : argument;
2074 for ( ; ++i < length; ) {
2075 matchIndexes.push( i );
2077 return matchIndexes;
2082 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2084 // Add button/input type pseudos
2085 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2086 Expr.pseudos[ i ] = createInputPseudo( i );
2088 for ( i in { submit: true, reset: true } ) {
2089 Expr.pseudos[ i ] = createButtonPseudo( i );
2092 // Easy API for creating new setFilters
2093 function setFilters() {}
2094 setFilters.prototype = Expr.filters = Expr.pseudos;
2095 Expr.setFilters = new setFilters();
2097 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2098 var matched, match, tokens, type,
2099 soFar, groups, preFilters,
2100 cached = tokenCache[ selector + " " ];
2103 return parseOnly ? 0 : cached.slice( 0 );
2108 preFilters = Expr.preFilter;
2112 // Comma and first run
2113 if ( !matched || (match = rcomma.exec( soFar )) ) {
2115 // Don't consume trailing commas as valid
2116 soFar = soFar.slice( match[0].length ) || soFar;
2118 groups.push( (tokens = []) );
2124 if ( (match = rcombinators.exec( soFar )) ) {
2125 matched = match.shift();
2128 // Cast descendant combinators to space
2129 type: match[0].replace( rtrim, " " )
2131 soFar = soFar.slice( matched.length );
2135 for ( type in Expr.filter ) {
2136 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2137 (match = preFilters[ type ]( match ))) ) {
2138 matched = match.shift();
2144 soFar = soFar.slice( matched.length );
2153 // Return the length of the invalid excess
2154 // if we're just parsing
2155 // Otherwise, throw an error or return tokens
2159 Sizzle.error( selector ) :
2161 tokenCache( selector, groups ).slice( 0 );
2164 function toSelector( tokens ) {
2166 len = tokens.length,
2168 for ( ; i < len; i++ ) {
2169 selector += tokens[i].value;
2174 function addCombinator( matcher, combinator, base ) {
2175 var dir = combinator.dir,
2176 checkNonElements = base && dir === "parentNode",
2179 return combinator.first ?
2180 // Check against closest ancestor/preceding element
2181 function( elem, context, xml ) {
2182 while ( (elem = elem[ dir ]) ) {
2183 if ( elem.nodeType === 1 || checkNonElements ) {
2184 return matcher( elem, context, xml );
2189 // Check against all ancestor/preceding elements
2190 function( elem, context, xml ) {
2191 var oldCache, uniqueCache, outerCache,
2192 newCache = [ dirruns, doneName ];
2194 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2196 while ( (elem = elem[ dir ]) ) {
2197 if ( elem.nodeType === 1 || checkNonElements ) {
2198 if ( matcher( elem, context, xml ) ) {
2204 while ( (elem = elem[ dir ]) ) {
2205 if ( elem.nodeType === 1 || checkNonElements ) {
2206 outerCache = elem[ expando ] || (elem[ expando ] = {});
2208 // Support: IE <9 only
2209 // Defend against cloned attroperties (jQuery gh-1709)
2210 uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
2212 if ( (oldCache = uniqueCache[ dir ]) &&
2213 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2215 // Assign to newCache so results back-propagate to previous elements
2216 return (newCache[ 2 ] = oldCache[ 2 ]);
2218 // Reuse newcache so results back-propagate to previous elements
2219 uniqueCache[ dir ] = newCache;
2221 // A match means we're done; a fail means we have to keep checking
2222 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2232 function elementMatcher( matchers ) {
2233 return matchers.length > 1 ?
2234 function( elem, context, xml ) {
2235 var i = matchers.length;
2237 if ( !matchers[i]( elem, context, xml ) ) {
2246 function multipleContexts( selector, contexts, results ) {
2248 len = contexts.length;
2249 for ( ; i < len; i++ ) {
2250 Sizzle( selector, contexts[i], results );
2255 function condense( unmatched, map, filter, context, xml ) {
2259 len = unmatched.length,
2260 mapped = map != null;
2262 for ( ; i < len; i++ ) {
2263 if ( (elem = unmatched[i]) ) {
2264 if ( !filter || filter( elem, context, xml ) ) {
2265 newUnmatched.push( elem );
2273 return newUnmatched;
2276 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2277 if ( postFilter && !postFilter[ expando ] ) {
2278 postFilter = setMatcher( postFilter );
2280 if ( postFinder && !postFinder[ expando ] ) {
2281 postFinder = setMatcher( postFinder, postSelector );
2283 return markFunction(function( seed, results, context, xml ) {
2287 preexisting = results.length,
2289 // Get initial elements from seed or context
2290 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2292 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2293 matcherIn = preFilter && ( seed || !selector ) ?
2294 condense( elems, preMap, preFilter, context, xml ) :
2297 matcherOut = matcher ?
2298 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2299 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2301 // ...intermediate processing is necessary
2304 // ...otherwise use results directly
2308 // Find primary matches
2310 matcher( matcherIn, matcherOut, context, xml );
2315 temp = condense( matcherOut, postMap );
2316 postFilter( temp, [], context, xml );
2318 // Un-match failing elements by moving them back to matcherIn
2321 if ( (elem = temp[i]) ) {
2322 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2328 if ( postFinder || preFilter ) {
2330 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2332 i = matcherOut.length;
2334 if ( (elem = matcherOut[i]) ) {
2335 // Restore matcherIn since elem is not yet a final match
2336 temp.push( (matcherIn[i] = elem) );
2339 postFinder( null, (matcherOut = []), temp, xml );
2342 // Move matched elements from seed to results to keep them synchronized
2343 i = matcherOut.length;
2345 if ( (elem = matcherOut[i]) &&
2346 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2348 seed[temp] = !(results[temp] = elem);
2353 // Add elements to results, through postFinder if defined
2355 matcherOut = condense(
2356 matcherOut === results ?
2357 matcherOut.splice( preexisting, matcherOut.length ) :
2361 postFinder( null, results, matcherOut, xml );
2363 push.apply( results, matcherOut );
2369 function matcherFromTokens( tokens ) {
2370 var checkContext, matcher, j,
2371 len = tokens.length,
2372 leadingRelative = Expr.relative[ tokens[0].type ],
2373 implicitRelative = leadingRelative || Expr.relative[" "],
2374 i = leadingRelative ? 1 : 0,
2376 // The foundational matcher ensures that elements are reachable from top-level context(s)
2377 matchContext = addCombinator( function( elem ) {
2378 return elem === checkContext;
2379 }, implicitRelative, true ),
2380 matchAnyContext = addCombinator( function( elem ) {
2381 return indexOf( checkContext, elem ) > -1;
2382 }, implicitRelative, true ),
2383 matchers = [ function( elem, context, xml ) {
2384 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2385 (checkContext = context).nodeType ?
2386 matchContext( elem, context, xml ) :
2387 matchAnyContext( elem, context, xml ) );
2388 // Avoid hanging onto element (issue #299)
2389 checkContext = null;
2393 for ( ; i < len; i++ ) {
2394 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2395 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2397 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2399 // Return special upon seeing a positional matcher
2400 if ( matcher[ expando ] ) {
2401 // Find the next relative operator (if any) for proper handling
2403 for ( ; j < len; j++ ) {
2404 if ( Expr.relative[ tokens[j].type ] ) {
2409 i > 1 && elementMatcher( matchers ),
2410 i > 1 && toSelector(
2411 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2412 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2413 ).replace( rtrim, "$1" ),
2415 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2416 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2417 j < len && toSelector( tokens )
2420 matchers.push( matcher );
2424 return elementMatcher( matchers );
2427 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2428 var bySet = setMatchers.length > 0,
2429 byElement = elementMatchers.length > 0,
2430 superMatcher = function( seed, context, xml, results, outermost ) {
2431 var elem, j, matcher,
2434 unmatched = seed && [],
2436 contextBackup = outermostContext,
2437 // We must always have either seed elements or outermost context
2438 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2439 // Use integer dirruns iff this is the outermost matcher
2440 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2444 outermostContext = context === document || context || outermost;
2447 // Add elements passing elementMatchers directly to results
2448 // Support: IE<9, Safari
2449 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2450 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2451 if ( byElement && elem ) {
2453 if ( !context && elem.ownerDocument !== document ) {
2454 setDocument( elem );
2455 xml = !documentIsHTML;
2457 while ( (matcher = elementMatchers[j++]) ) {
2458 if ( matcher( elem, context || document, xml) ) {
2459 results.push( elem );
2464 dirruns = dirrunsUnique;
2468 // Track unmatched elements for set filters
2470 // They will have gone through all possible matchers
2471 if ( (elem = !matcher && elem) ) {
2475 // Lengthen the array for every element, matched or not
2477 unmatched.push( elem );
2482 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2483 // makes the latter nonnegative.
2486 // Apply set filters to unmatched elements
2487 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2488 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2489 // no element matchers and no seed.
2490 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2491 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2492 // numerically zero.
2493 if ( bySet && i !== matchedCount ) {
2495 while ( (matcher = setMatchers[j++]) ) {
2496 matcher( unmatched, setMatched, context, xml );
2500 // Reintegrate element matches to eliminate the need for sorting
2501 if ( matchedCount > 0 ) {
2503 if ( !(unmatched[i] || setMatched[i]) ) {
2504 setMatched[i] = pop.call( results );
2509 // Discard index placeholder values to get only actual matches
2510 setMatched = condense( setMatched );
2513 // Add matches to results
2514 push.apply( results, setMatched );
2516 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2517 if ( outermost && !seed && setMatched.length > 0 &&
2518 ( matchedCount + setMatchers.length ) > 1 ) {
2520 Sizzle.uniqueSort( results );
2524 // Override manipulation of globals by nested matchers
2526 dirruns = dirrunsUnique;
2527 outermostContext = contextBackup;
2534 markFunction( superMatcher ) :
2538 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2541 elementMatchers = [],
2542 cached = compilerCache[ selector + " " ];
2545 // Generate a function of recursive functions that can be used to check each element
2547 match = tokenize( selector );
2551 cached = matcherFromTokens( match[i] );
2552 if ( cached[ expando ] ) {
2553 setMatchers.push( cached );
2555 elementMatchers.push( cached );
2559 // Cache the compiled function
2560 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2562 // Save selector and tokenization
2563 cached.selector = selector;
2569 * A low-level selection function that works with Sizzle's compiled
2570 * selector functions
2571 * @param {String|Function} selector A selector or a pre-compiled
2572 * selector function built with Sizzle.compile
2573 * @param {Element} context
2574 * @param {Array} [results]
2575 * @param {Array} [seed] A set of elements to match against
2577 select = Sizzle.select = function( selector, context, results, seed ) {
2578 var i, tokens, token, type, find,
2579 compiled = typeof selector === "function" && selector,
2580 match = !seed && tokenize( (selector = compiled.selector || selector) );
2582 results = results || [];
2584 // Try to minimize operations if there is only one selector in the list and no seed
2585 // (the latter of which guarantees us context)
2586 if ( match.length === 1 ) {
2588 // Reduce context if the leading compound selector is an ID
2589 tokens = match[0] = match[0].slice( 0 );
2590 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2591 support.getById && context.nodeType === 9 && documentIsHTML &&
2592 Expr.relative[ tokens[1].type ] ) {
2594 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2598 // Precompiled matchers will still verify ancestry, so step up a level
2599 } else if ( compiled ) {
2600 context = context.parentNode;
2603 selector = selector.slice( tokens.shift().value.length );
2606 // Fetch a seed set for right-to-left matching
2607 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2611 // Abort if we hit a combinator
2612 if ( Expr.relative[ (type = token.type) ] ) {
2615 if ( (find = Expr.find[ type ]) ) {
2616 // Search, expanding context for leading sibling combinators
2618 token.matches[0].replace( runescape, funescape ),
2619 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2622 // If seed is empty or no tokens remain, we can return early
2623 tokens.splice( i, 1 );
2624 selector = seed.length && toSelector( tokens );
2626 push.apply( results, seed );
2636 // Compile and execute a filtering function if one is not provided
2637 // Provide `match` to avoid retokenization if we modified the selector above
2638 ( compiled || compile( selector, match ) )(
2643 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2648 // One-time assignments
2651 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2653 // Support: Chrome 14-35+
2654 // Always assume duplicates if they aren't passed to the comparison function
2655 support.detectDuplicates = !!hasDuplicate;
2657 // Initialize against the default document
2660 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2661 // Detached nodes confoundingly follow *each other*
2662 support.sortDetached = assert(function( div1 ) {
2663 // Should return 1, but returns 4 (following)
2664 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2668 // Prevent attribute/property "interpolation"
2669 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2670 if ( !assert(function( div ) {
2671 div.innerHTML = "<a href='#'></a>";
2672 return div.firstChild.getAttribute("href") === "#" ;
2674 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2676 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2682 // Use defaultValue in place of getAttribute("value")
2683 if ( !support.attributes || !assert(function( div ) {
2684 div.innerHTML = "<input/>";
2685 div.firstChild.setAttribute( "value", "" );
2686 return div.firstChild.getAttribute( "value" ) === "";
2688 addHandle( "value", function( elem, name, isXML ) {
2689 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2690 return elem.defaultValue;
2696 // Use getAttributeNode to fetch booleans when getAttribute lies
2697 if ( !assert(function( div ) {
2698 return div.getAttribute("disabled") == null;
2700 addHandle( booleans, function( elem, name, isXML ) {
2703 return elem[ name ] === true ? name.toLowerCase() :
2704 (val = elem.getAttributeNode( name )) && val.specified ?
2717 jQuery.find = Sizzle;
2718 jQuery.expr = Sizzle.selectors;
2719 jQuery.expr[ ":" ] = jQuery.expr.pseudos;
2720 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
2721 jQuery.text = Sizzle.getText;
2722 jQuery.isXMLDoc = Sizzle.isXML;
2723 jQuery.contains = Sizzle.contains;
2727 var dir = function( elem, dir, until ) {
2729 truncate = until !== undefined;
2731 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
2732 if ( elem.nodeType === 1 ) {
2733 if ( truncate && jQuery( elem ).is( until ) ) {
2736 matched.push( elem );
2743 var siblings = function( n, elem ) {
2746 for ( ; n; n = n.nextSibling ) {
2747 if ( n.nodeType === 1 && n !== elem ) {
2756 var rneedsContext = jQuery.expr.match.needsContext;
2758 var rsingleTag = ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ );
2762 var risSimple = /^.[^:#\[\.,]*$/;
2764 // Implement the identical functionality for filter and not
2765 function winnow( elements, qualifier, not ) {
2766 if ( jQuery.isFunction( qualifier ) ) {
2767 return jQuery.grep( elements, function( elem, i ) {
2769 return !!qualifier.call( elem, i, elem ) !== not;
2774 if ( qualifier.nodeType ) {
2775 return jQuery.grep( elements, function( elem ) {
2776 return ( elem === qualifier ) !== not;
2781 if ( typeof qualifier === "string" ) {
2782 if ( risSimple.test( qualifier ) ) {
2783 return jQuery.filter( qualifier, elements, not );
2786 qualifier = jQuery.filter( qualifier, elements );
2789 return jQuery.grep( elements, function( elem ) {
2790 return ( jQuery.inArray( elem, qualifier ) > -1 ) !== not;
2794 jQuery.filter = function( expr, elems, not ) {
2795 var elem = elems[ 0 ];
2798 expr = ":not(" + expr + ")";
2801 return elems.length === 1 && elem.nodeType === 1 ?
2802 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2803 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2804 return elem.nodeType === 1;
2809 find: function( selector ) {
2815 if ( typeof selector !== "string" ) {
2816 return this.pushStack( jQuery( selector ).filter( function() {
2817 for ( i = 0; i < len; i++ ) {
2818 if ( jQuery.contains( self[ i ], this ) ) {
2825 for ( i = 0; i < len; i++ ) {
2826 jQuery.find( selector, self[ i ], ret );
2829 // Needed because $( selector, context ) becomes $( context ).find( selector )
2830 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2831 ret.selector = this.selector ? this.selector + " " + selector : selector;
2834 filter: function( selector ) {
2835 return this.pushStack( winnow( this, selector || [], false ) );
2837 not: function( selector ) {
2838 return this.pushStack( winnow( this, selector || [], true ) );
2840 is: function( selector ) {
2844 // If this is a positional/relative selector, check membership in the returned set
2845 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2846 typeof selector === "string" && rneedsContext.test( selector ) ?
2847 jQuery( selector ) :
2855 // Initialize a jQuery object
2858 // A central reference to the root jQuery(document)
2861 // A simple way to check for HTML strings
2862 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2863 // Strict HTML recognition (#11290: must start with <)
2864 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2866 init = jQuery.fn.init = function( selector, context, root ) {
2869 // HANDLE: $(""), $(null), $(undefined), $(false)
2874 // init accepts an alternate rootjQuery
2875 // so migrate can support jQuery.sub (gh-2101)
2876 root = root || rootjQuery;
2878 // Handle HTML strings
2879 if ( typeof selector === "string" ) {
2880 if ( selector.charAt( 0 ) === "<" &&
2881 selector.charAt( selector.length - 1 ) === ">" &&
2882 selector.length >= 3 ) {
2884 // Assume that strings that start and end with <> are HTML and skip the regex check
2885 match = [ null, selector, null ];
2888 match = rquickExpr.exec( selector );
2891 // Match html or make sure no context is specified for #id
2892 if ( match && ( match[ 1 ] || !context ) ) {
2894 // HANDLE: $(html) -> $(array)
2896 context = context instanceof jQuery ? context[ 0 ] : context;
2898 // scripts is true for back-compat
2899 // Intentionally let the error be thrown if parseHTML is not present
2900 jQuery.merge( this, jQuery.parseHTML(
2902 context && context.nodeType ? context.ownerDocument || context : document,
2906 // HANDLE: $(html, props)
2907 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
2908 for ( match in context ) {
2910 // Properties of context are called as methods if possible
2911 if ( jQuery.isFunction( this[ match ] ) ) {
2912 this[ match ]( context[ match ] );
2914 // ...and otherwise set as attributes
2916 this.attr( match, context[ match ] );
2925 elem = document.getElementById( match[ 2 ] );
2927 // Check parentNode to catch when Blackberry 4.6 returns
2928 // nodes that are no longer in the document #6963
2929 if ( elem && elem.parentNode ) {
2931 // Handle the case where IE and Opera return items
2932 // by name instead of ID
2933 if ( elem.id !== match[ 2 ] ) {
2934 return rootjQuery.find( selector );
2937 // Otherwise, we inject the element directly into the jQuery object
2942 this.context = document;
2943 this.selector = selector;
2947 // HANDLE: $(expr, $(...))
2948 } else if ( !context || context.jquery ) {
2949 return ( context || root ).find( selector );
2951 // HANDLE: $(expr, context)
2952 // (which is just equivalent to: $(context).find(expr)
2954 return this.constructor( context ).find( selector );
2957 // HANDLE: $(DOMElement)
2958 } else if ( selector.nodeType ) {
2959 this.context = this[ 0 ] = selector;
2963 // HANDLE: $(function)
2964 // Shortcut for document ready
2965 } else if ( jQuery.isFunction( selector ) ) {
2966 return typeof root.ready !== "undefined" ?
2967 root.ready( selector ) :
2969 // Execute immediately if ready is not present
2973 if ( selector.selector !== undefined ) {
2974 this.selector = selector.selector;
2975 this.context = selector.context;
2978 return jQuery.makeArray( selector, this );
2981 // Give the init function the jQuery prototype for later instantiation
2982 init.prototype = jQuery.fn;
2984 // Initialize central reference
2985 rootjQuery = jQuery( document );
2988 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2990 // methods guaranteed to produce a unique set when starting from a unique set
2991 guaranteedUnique = {
2999 has: function( target ) {
3001 targets = jQuery( target, this ),
3002 len = targets.length;
3004 return this.filter( function() {
3005 for ( i = 0; i < len; i++ ) {
3006 if ( jQuery.contains( this, targets[ i ] ) ) {
3013 closest: function( selectors, context ) {
3018 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
3019 jQuery( selectors, context || this.context ) :
3022 for ( ; i < l; i++ ) {
3023 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3025 // Always skip document fragments
3026 if ( cur.nodeType < 11 && ( pos ?
3027 pos.index( cur ) > -1 :
3029 // Don't pass non-elements to Sizzle
3030 cur.nodeType === 1 &&
3031 jQuery.find.matchesSelector( cur, selectors ) ) ) {
3033 matched.push( cur );
3039 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3042 // Determine the position of an element within
3043 // the matched set of elements
3044 index: function( elem ) {
3046 // No argument, return index in parent
3048 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3051 // index in selector
3052 if ( typeof elem === "string" ) {
3053 return jQuery.inArray( this[ 0 ], jQuery( elem ) );
3056 // Locate the position of the desired element
3057 return jQuery.inArray(
3059 // If it receives a jQuery object, the first element is used
3060 elem.jquery ? elem[ 0 ] : elem, this );
3063 add: function( selector, context ) {
3064 return this.pushStack(
3066 jQuery.merge( this.get(), jQuery( selector, context ) )
3071 addBack: function( selector ) {
3072 return this.add( selector == null ?
3073 this.prevObject : this.prevObject.filter( selector )
3078 function sibling( cur, dir ) {
3081 } while ( cur && cur.nodeType !== 1 );
3087 parent: function( elem ) {
3088 var parent = elem.parentNode;
3089 return parent && parent.nodeType !== 11 ? parent : null;
3091 parents: function( elem ) {
3092 return dir( elem, "parentNode" );
3094 parentsUntil: function( elem, i, until ) {
3095 return dir( elem, "parentNode", until );
3097 next: function( elem ) {
3098 return sibling( elem, "nextSibling" );
3100 prev: function( elem ) {
3101 return sibling( elem, "previousSibling" );
3103 nextAll: function( elem ) {
3104 return dir( elem, "nextSibling" );
3106 prevAll: function( elem ) {
3107 return dir( elem, "previousSibling" );
3109 nextUntil: function( elem, i, until ) {
3110 return dir( elem, "nextSibling", until );
3112 prevUntil: function( elem, i, until ) {
3113 return dir( elem, "previousSibling", until );
3115 siblings: function( elem ) {
3116 return siblings( ( elem.parentNode || {} ).firstChild, elem );
3118 children: function( elem ) {
3119 return siblings( elem.firstChild );
3121 contents: function( elem ) {
3122 return jQuery.nodeName( elem, "iframe" ) ?
3123 elem.contentDocument || elem.contentWindow.document :
3124 jQuery.merge( [], elem.childNodes );
3126 }, function( name, fn ) {
3127 jQuery.fn[ name ] = function( until, selector ) {
3128 var ret = jQuery.map( this, fn, until );
3130 if ( name.slice( -5 ) !== "Until" ) {
3134 if ( selector && typeof selector === "string" ) {
3135 ret = jQuery.filter( selector, ret );
3138 if ( this.length > 1 ) {
3140 // Remove duplicates
3141 if ( !guaranteedUnique[ name ] ) {
3142 ret = jQuery.uniqueSort( ret );
3145 // Reverse order for parents* and prev-derivatives
3146 if ( rparentsprev.test( name ) ) {
3147 ret = ret.reverse();
3151 return this.pushStack( ret );
3154 var rnotwhite = ( /\S+/g );
3158 // Convert String-formatted options into Object-formatted ones
3159 function createOptions( options ) {
3161 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3162 object[ flag ] = true;
3168 * Create a callback list using the following parameters:
3170 * options: an optional list of space-separated options that will change how
3171 * the callback list behaves or a more traditional option object
3173 * By default a callback list will act like an event callback list and can be
3174 * "fired" multiple times.
3178 * once: will ensure the callback list can only be fired once (like a Deferred)
3180 * memory: will keep track of previous values and will call any callback added
3181 * after the list has been fired right away with the latest "memorized"
3182 * values (like a Deferred)
3184 * unique: will ensure a callback can only be added once (no duplicate in the list)
3186 * stopOnFalse: interrupt callings when a callback returns false
3189 jQuery.Callbacks = function( options ) {
3191 // Convert options from String-formatted to Object-formatted if needed
3192 // (we check in cache first)
3193 options = typeof options === "string" ?
3194 createOptions( options ) :
3195 jQuery.extend( {}, options );
3197 var // Flag to know if list is currently firing
3200 // Last fire value for non-forgettable lists
3203 // Flag to know if list was already fired
3206 // Flag to prevent firing
3209 // Actual callback list
3212 // Queue of execution data for repeatable lists
3215 // Index of currently firing callback (modified by add/remove as needed)
3221 // Enforce single-firing
3222 locked = options.once;
3224 // Execute callbacks for all pending executions,
3225 // respecting firingIndex overrides and runtime changes
3226 fired = firing = true;
3227 for ( ; queue.length; firingIndex = -1 ) {
3228 memory = queue.shift();
3229 while ( ++firingIndex < list.length ) {
3231 // Run callback and check for early termination
3232 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3233 options.stopOnFalse ) {
3235 // Jump to end and forget the data so .add doesn't re-fire
3236 firingIndex = list.length;
3242 // Forget the data if we're done with it
3243 if ( !options.memory ) {
3249 // Clean up if we're done firing for good
3252 // Keep an empty list if we have data for future add calls
3256 // Otherwise, this object is spent
3263 // Actual Callbacks object
3266 // Add a callback or a collection of callbacks to the list
3270 // If we have memory from a past run, we should fire after adding
3271 if ( memory && !firing ) {
3272 firingIndex = list.length - 1;
3273 queue.push( memory );
3276 ( function add( args ) {
3277 jQuery.each( args, function( _, arg ) {
3278 if ( jQuery.isFunction( arg ) ) {
3279 if ( !options.unique || !self.has( arg ) ) {
3282 } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) {
3284 // Inspect recursively
3290 if ( memory && !firing ) {
3297 // Remove a callback from the list
3298 remove: function() {
3299 jQuery.each( arguments, function( _, arg ) {
3301 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3302 list.splice( index, 1 );
3304 // Handle firing indexes
3305 if ( index <= firingIndex ) {
3313 // Check if a given callback is in the list.
3314 // If no argument is given, return whether or not list has callbacks attached.
3315 has: function( fn ) {
3317 jQuery.inArray( fn, list ) > -1 :
3321 // Remove all callbacks from the list
3329 // Disable .fire and .add
3330 // Abort any current/pending executions
3331 // Clear all callbacks and values
3332 disable: function() {
3333 locked = queue = [];
3337 disabled: function() {
3342 // Also disable .add unless we have memory (since it would have no effect)
3343 // Abort any pending executions
3351 locked: function() {
3355 // Call all callbacks with the given context and arguments
3356 fireWith: function( context, args ) {
3359 args = [ context, args.slice ? args.slice() : args ];
3368 // Call all the callbacks with the given arguments
3370 self.fireWith( this, arguments );
3374 // To know if the callbacks have already been called at least once
3386 Deferred: function( func ) {
3389 // action, add listener, listener list, final state
3390 [ "resolve", "done", jQuery.Callbacks( "once memory" ), "resolved" ],
3391 [ "reject", "fail", jQuery.Callbacks( "once memory" ), "rejected" ],
3392 [ "notify", "progress", jQuery.Callbacks( "memory" ) ]
3399 always: function() {
3400 deferred.done( arguments ).fail( arguments );
3403 then: function( /* fnDone, fnFail, fnProgress */ ) {
3404 var fns = arguments;
3405 return jQuery.Deferred( function( newDefer ) {
3406 jQuery.each( tuples, function( i, tuple ) {
3407 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3409 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3410 deferred[ tuple[ 1 ] ]( function() {
3411 var returned = fn && fn.apply( this, arguments );
3412 if ( returned && jQuery.isFunction( returned.promise ) ) {
3414 .progress( newDefer.notify )
3415 .done( newDefer.resolve )
3416 .fail( newDefer.reject );
3418 newDefer[ tuple[ 0 ] + "With" ](
3419 this === promise ? newDefer.promise() : this,
3420 fn ? [ returned ] : arguments
3429 // Get a promise for this deferred
3430 // If obj is provided, the promise aspect is added to the object
3431 promise: function( obj ) {
3432 return obj != null ? jQuery.extend( obj, promise ) : promise;
3437 // Keep pipe for back-compat
3438 promise.pipe = promise.then;
3440 // Add list-specific methods
3441 jQuery.each( tuples, function( i, tuple ) {
3442 var list = tuple[ 2 ],
3443 stateString = tuple[ 3 ];
3445 // promise[ done | fail | progress ] = list.add
3446 promise[ tuple[ 1 ] ] = list.add;
3449 if ( stateString ) {
3450 list.add( function() {
3452 // state = [ resolved | rejected ]
3453 state = stateString;
3455 // [ reject_list | resolve_list ].disable; progress_list.lock
3456 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3459 // deferred[ resolve | reject | notify ]
3460 deferred[ tuple[ 0 ] ] = function() {
3461 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? promise : this, arguments );
3464 deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
3467 // Make the deferred a promise
3468 promise.promise( deferred );
3470 // Call given func if any
3472 func.call( deferred, deferred );
3480 when: function( subordinate /* , ..., subordinateN */ ) {
3482 resolveValues = slice.call( arguments ),
3483 length = resolveValues.length,
3485 // the count of uncompleted subordinates
3486 remaining = length !== 1 ||
3487 ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3489 // the master Deferred.
3490 // If resolveValues consist of only a single Deferred, just use that.
3491 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3493 // Update function for both resolve and progress values
3494 updateFunc = function( i, contexts, values ) {
3495 return function( value ) {
3496 contexts[ i ] = this;
3497 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3498 if ( values === progressValues ) {
3499 deferred.notifyWith( contexts, values );
3501 } else if ( !( --remaining ) ) {
3502 deferred.resolveWith( contexts, values );
3507 progressValues, progressContexts, resolveContexts;
3509 // add listeners to Deferred subordinates; treat others as resolved
3511 progressValues = new Array( length );
3512 progressContexts = new Array( length );
3513 resolveContexts = new Array( length );
3514 for ( ; i < length; i++ ) {
3515 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3516 resolveValues[ i ].promise()
3517 .progress( updateFunc( i, progressContexts, progressValues ) )
3518 .done( updateFunc( i, resolveContexts, resolveValues ) )
3519 .fail( deferred.reject );
3526 // if we're not waiting on anything, resolve the master
3528 deferred.resolveWith( resolveContexts, resolveValues );
3531 return deferred.promise();
3536 // The deferred used on DOM ready
3539 jQuery.fn.ready = function( fn ) {
3542 jQuery.ready.promise().done( fn );
3549 // Is the DOM ready to be used? Set to true once it occurs.
3552 // A counter to track how many items to wait for before
3553 // the ready event fires. See #6781
3556 // Hold (or release) the ready event
3557 holdReady: function( hold ) {
3561 jQuery.ready( true );
3565 // Handle when the DOM is ready
3566 ready: function( wait ) {
3568 // Abort if there are pending holds or we're already ready
3569 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3573 // Remember that the DOM is ready
3574 jQuery.isReady = true;
3576 // If a normal DOM Ready event fired, decrement, and wait if need be
3577 if ( wait !== true && --jQuery.readyWait > 0 ) {
3581 // If there are functions bound, to execute
3582 readyList.resolveWith( document, [ jQuery ] );
3584 // Trigger any bound ready events
3585 if ( jQuery.fn.triggerHandler ) {
3586 jQuery( document ).triggerHandler( "ready" );
3587 jQuery( document ).off( "ready" );
3593 * Clean-up method for dom ready events
3596 if ( document.addEventListener ) {
3597 document.removeEventListener( "DOMContentLoaded", completed );
3598 window.removeEventListener( "load", completed );
3601 document.detachEvent( "onreadystatechange", completed );
3602 window.detachEvent( "onload", completed );
3607 * The ready event handler and self cleanup method
3609 function completed() {
3611 // readyState === "complete" is good enough for us to call the dom ready in oldIE
3612 if ( document.addEventListener ||
3613 window.event.type === "load" ||
3614 document.readyState === "complete" ) {
3621 jQuery.ready.promise = function( obj ) {
3624 readyList = jQuery.Deferred();
3626 // Catch cases where $(document).ready() is called
3627 // after the browser event has already occurred.
3629 // Older IE sometimes signals "interactive" too soon
3630 if ( document.readyState === "complete" ||
3631 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
3633 // Handle it asynchronously to allow scripts the opportunity to delay ready
3634 window.setTimeout( jQuery.ready );
3636 // Standards-based browsers support DOMContentLoaded
3637 } else if ( document.addEventListener ) {
3639 // Use the handy event callback
3640 document.addEventListener( "DOMContentLoaded", completed );
3642 // A fallback to window.onload, that will always work
3643 window.addEventListener( "load", completed );
3645 // If IE event model is used
3648 // Ensure firing before onload, maybe late but safe also for iframes
3649 document.attachEvent( "onreadystatechange", completed );
3651 // A fallback to window.onload, that will always work
3652 window.attachEvent( "onload", completed );
3654 // If IE and not a frame
3655 // continually check to see if the document is ready
3659 top = window.frameElement == null && document.documentElement;
3662 if ( top && top.doScroll ) {
3663 ( function doScrollCheck() {
3664 if ( !jQuery.isReady ) {
3668 // Use the trick by Diego Perini
3669 // http://javascript.nwbox.com/IEContentLoaded/
3670 top.doScroll( "left" );
3672 return window.setTimeout( doScrollCheck, 50 );
3675 // detach all dom ready events
3678 // and execute any waiting functions
3685 return readyList.promise( obj );
3688 // Kick off the DOM ready check even if the user does not
3689 jQuery.ready.promise();
3695 // Iteration over object's inherited properties before its own
3697 for ( i in jQuery( support ) ) {
3700 support.ownFirst = i === "0";
3702 // Note: most support tests are defined in their respective modules.
3703 // false until the test is run
3704 support.inlineBlockNeedsLayout = false;
3706 // Execute ASAP in case we need to set body.style.zoom
3707 jQuery( function() {
3709 // Minified: var a,b,c,d
3710 var val, div, body, container;
3712 body = document.getElementsByTagName( "body" )[ 0 ];
3713 if ( !body || !body.style ) {
3715 // Return for frameset docs that don't have a body
3720 div = document.createElement( "div" );
3721 container = document.createElement( "div" );
3722 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
3723 body.appendChild( container ).appendChild( div );
3725 if ( typeof div.style.zoom !== "undefined" ) {
3728 // Check if natively block-level elements act like inline-block
3729 // elements when setting their display to 'inline' and giving
3731 div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
3733 support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
3736 // Prevent IE 6 from affecting layout for positioned elements #11048
3737 // Prevent IE from shrinking the body in IE 7 mode #12869
3739 body.style.zoom = 1;
3743 body.removeChild( container );
3748 var div = document.createElement( "div" );
3751 support.deleteExpando = true;
3755 support.deleteExpando = false;
3758 // Null elements to avoid leaks in IE.
3761 var acceptData = function( elem ) {
3762 var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
3763 nodeType = +elem.nodeType || 1;
3765 // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
3766 return nodeType !== 1 && nodeType !== 9 ?
3769 // Nodes accept data unless otherwise specified; rejection can be conditional
3770 !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
3776 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3777 rmultiDash = /([A-Z])/g;
3779 function dataAttr( elem, key, data ) {
3781 // If nothing was found internally, try to fetch any
3782 // data from the HTML5 data-* attribute
3783 if ( data === undefined && elem.nodeType === 1 ) {
3785 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3787 data = elem.getAttribute( name );
3789 if ( typeof data === "string" ) {
3791 data = data === "true" ? true :
3792 data === "false" ? false :
3793 data === "null" ? null :
3795 // Only convert to a number if it doesn't change the string
3796 +data + "" === data ? +data :
3797 rbrace.test( data ) ? jQuery.parseJSON( data ) :
3801 // Make sure we set the data so it isn't changed later
3802 jQuery.data( elem, key, data );
3812 // checks a cache object for emptiness
3813 function isEmptyDataObject( obj ) {
3815 for ( name in obj ) {
3817 // if the public data object is empty, the private is still empty
3818 if ( name === "data" && jQuery.isEmptyObject( obj[ name ] ) ) {
3821 if ( name !== "toJSON" ) {
3829 function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
3830 if ( !acceptData( elem ) ) {
3835 internalKey = jQuery.expando,
3837 // We have to handle DOM nodes and JS objects differently because IE6-7
3838 // can't GC object references properly across the DOM-JS boundary
3839 isNode = elem.nodeType,
3841 // Only DOM nodes need the global jQuery cache; JS object data is
3842 // attached directly to the object so GC can occur automatically
3843 cache = isNode ? jQuery.cache : elem,
3845 // Only defining an ID for JS objects if its cache already exists allows
3846 // the code to shortcut on the same path as a DOM node with no cache
3847 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
3849 // Avoid doing any more work than we need to when trying to get data on an
3850 // object that has no data at all
3851 if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
3852 data === undefined && typeof name === "string" ) {
3858 // Only DOM nodes need a new unique ID for each element since their data
3859 // ends up in the global cache
3861 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
3867 if ( !cache[ id ] ) {
3869 // Avoid exposing jQuery metadata on plain JS objects when the object
3870 // is serialized using JSON.stringify
3871 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
3874 // An object can be passed to jQuery.data instead of a key/value pair; this gets
3875 // shallow copied over onto the existing cache
3876 if ( typeof name === "object" || typeof name === "function" ) {
3878 cache[ id ] = jQuery.extend( cache[ id ], name );
3880 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
3884 thisCache = cache[ id ];
3886 // jQuery data() is stored in a separate object inside the object's internal data
3887 // cache in order to avoid key collisions between internal data and user-defined
3890 if ( !thisCache.data ) {
3891 thisCache.data = {};
3894 thisCache = thisCache.data;
3897 if ( data !== undefined ) {
3898 thisCache[ jQuery.camelCase( name ) ] = data;
3901 // Check for both converted-to-camel and non-converted data property names
3902 // If a data property was specified
3903 if ( typeof name === "string" ) {
3905 // First Try to find as-is property data
3906 ret = thisCache[ name ];
3908 // Test for null|undefined property data
3909 if ( ret == null ) {
3911 // Try to find the camelCased property
3912 ret = thisCache[ jQuery.camelCase( name ) ];
3921 function internalRemoveData( elem, name, pvt ) {
3922 if ( !acceptData( elem ) ) {
3927 isNode = elem.nodeType,
3929 // See jQuery.data for more information
3930 cache = isNode ? jQuery.cache : elem,
3931 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
3933 // If there is already no cache entry for this object, there is no
3934 // purpose in continuing
3935 if ( !cache[ id ] ) {
3941 thisCache = pvt ? cache[ id ] : cache[ id ].data;
3945 // Support array or space separated string names for data keys
3946 if ( !jQuery.isArray( name ) ) {
3948 // try the string as a key before any manipulation
3949 if ( name in thisCache ) {
3953 // split the camel cased version by spaces unless a key with the spaces exists
3954 name = jQuery.camelCase( name );
3955 if ( name in thisCache ) {
3958 name = name.split( " " );
3963 // If "name" is an array of keys...
3964 // When data is initially created, via ("key", "val") signature,
3965 // keys will be converted to camelCase.
3966 // Since there is no way to tell _how_ a key was added, remove
3967 // both plain key and camelCase key. #12786
3968 // This will only penalize the array argument path.
3969 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
3974 delete thisCache[ name[ i ] ];
3977 // If there is no data left in the cache, we want to continue
3978 // and let the cache object itself get destroyed
3979 if ( pvt ? !isEmptyDataObject( thisCache ) : !jQuery.isEmptyObject( thisCache ) ) {
3985 // See jQuery.data for more information
3987 delete cache[ id ].data;
3989 // Don't destroy the parent cache unless the internal data object
3990 // had been the only thing left in it
3991 if ( !isEmptyDataObject( cache[ id ] ) ) {
3996 // Destroy the cache
3998 jQuery.cleanData( [ elem ], true );
4000 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
4001 /* jshint eqeqeq: false */
4002 } else if ( support.deleteExpando || cache != cache.window ) {
4003 /* jshint eqeqeq: true */
4006 // When all else fails, undefined
4008 cache[ id ] = undefined;
4015 // The following elements (space-suffixed to avoid Object.prototype collisions)
4016 // throw uncatchable exceptions if you attempt to set expando properties
4021 // ...but Flash objects (which have this classid) *can* handle expandos
4022 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
4025 hasData: function( elem ) {
4026 elem = elem.nodeType ? jQuery.cache[ elem[ jQuery.expando ] ] : elem[ jQuery.expando ];
4027 return !!elem && !isEmptyDataObject( elem );
4030 data: function( elem, name, data ) {
4031 return internalData( elem, name, data );
4034 removeData: function( elem, name ) {
4035 return internalRemoveData( elem, name );
4038 // For internal use only.
4039 _data: function( elem, name, data ) {
4040 return internalData( elem, name, data, true );
4043 _removeData: function( elem, name ) {
4044 return internalRemoveData( elem, name, true );
4049 data: function( key, value ) {
4052 attrs = elem && elem.attributes;
4054 // Special expections of .data basically thwart jQuery.access,
4055 // so implement the relevant behavior ourselves
4058 if ( key === undefined ) {
4059 if ( this.length ) {
4060 data = jQuery.data( elem );
4062 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
4067 // The attrs elements can be null (#14894)
4069 name = attrs[ i ].name;
4070 if ( name.indexOf( "data-" ) === 0 ) {
4071 name = jQuery.camelCase( name.slice( 5 ) );
4072 dataAttr( elem, name, data[ name ] );
4076 jQuery._data( elem, "parsedAttrs", true );
4083 // Sets multiple values
4084 if ( typeof key === "object" ) {
4085 return this.each( function() {
4086 jQuery.data( this, key );
4090 return arguments.length > 1 ?
4093 this.each( function() {
4094 jQuery.data( this, key, value );
4098 // Try to fetch any internally stored data first
4099 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
4102 removeData: function( key ) {
4103 return this.each( function() {
4104 jQuery.removeData( this, key );
4111 queue: function( elem, type, data ) {
4115 type = ( type || "fx" ) + "queue";
4116 queue = jQuery._data( elem, type );
4118 // Speed up dequeue by getting out quickly if this is just a lookup
4120 if ( !queue || jQuery.isArray( data ) ) {
4121 queue = jQuery._data( elem, type, jQuery.makeArray( data ) );
4130 dequeue: function( elem, type ) {
4131 type = type || "fx";
4133 var queue = jQuery.queue( elem, type ),
4134 startLength = queue.length,
4136 hooks = jQuery._queueHooks( elem, type ),
4138 jQuery.dequeue( elem, type );
4141 // If the fx queue is dequeued, always remove the progress sentinel
4142 if ( fn === "inprogress" ) {
4149 // Add a progress sentinel to prevent the fx queue from being
4150 // automatically dequeued
4151 if ( type === "fx" ) {
4152 queue.unshift( "inprogress" );
4155 // clear up the last queue stop function
4157 fn.call( elem, next, hooks );
4160 if ( !startLength && hooks ) {
4165 // not intended for public consumption - generates a queueHooks object,
4166 // or returns the current one
4167 _queueHooks: function( elem, type ) {
4168 var key = type + "queueHooks";
4169 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
4170 empty: jQuery.Callbacks( "once memory" ).add( function() {
4171 jQuery._removeData( elem, type + "queue" );
4172 jQuery._removeData( elem, key );
4179 queue: function( type, data ) {
4182 if ( typeof type !== "string" ) {
4188 if ( arguments.length < setter ) {
4189 return jQuery.queue( this[ 0 ], type );
4192 return data === undefined ?
4194 this.each( function() {
4195 var queue = jQuery.queue( this, type, data );
4197 // ensure a hooks for this queue
4198 jQuery._queueHooks( this, type );
4200 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4201 jQuery.dequeue( this, type );
4205 dequeue: function( type ) {
4206 return this.each( function() {
4207 jQuery.dequeue( this, type );
4210 clearQueue: function( type ) {
4211 return this.queue( type || "fx", [] );
4214 // Get a promise resolved when queues of a certain type
4215 // are emptied (fx is the type by default)
4216 promise: function( type, obj ) {
4219 defer = jQuery.Deferred(),
4222 resolve = function() {
4223 if ( !( --count ) ) {
4224 defer.resolveWith( elements, [ elements ] );
4228 if ( typeof type !== "string" ) {
4232 type = type || "fx";
4235 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
4236 if ( tmp && tmp.empty ) {
4238 tmp.empty.add( resolve );
4242 return defer.promise( obj );
4248 var shrinkWrapBlocksVal;
4250 support.shrinkWrapBlocks = function() {
4251 if ( shrinkWrapBlocksVal != null ) {
4252 return shrinkWrapBlocksVal;
4255 // Will be changed later if needed.
4256 shrinkWrapBlocksVal = false;
4258 // Minified: var b,c,d
4259 var div, body, container;
4261 body = document.getElementsByTagName( "body" )[ 0 ];
4262 if ( !body || !body.style ) {
4264 // Test fired too early or in an unsupported environment, exit.
4269 div = document.createElement( "div" );
4270 container = document.createElement( "div" );
4271 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
4272 body.appendChild( container ).appendChild( div );
4275 // Check if elements with layout shrink-wrap their children
4276 if ( typeof div.style.zoom !== "undefined" ) {
4278 // Reset CSS: box-sizing; display; margin; border
4281 // Support: Firefox<29, Android 2.3
4282 // Vendor-prefix box-sizing
4283 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
4284 "box-sizing:content-box;display:block;margin:0;border:0;" +
4285 "padding:1px;width:1px;zoom:1";
4286 div.appendChild( document.createElement( "div" ) ).style.width = "5px";
4287 shrinkWrapBlocksVal = div.offsetWidth !== 3;
4290 body.removeChild( container );
4292 return shrinkWrapBlocksVal;
4296 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4298 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4301 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4303 var isHidden = function( elem, el ) {
4305 // isHidden might be called from jQuery#filter function;
4306 // in that case, element will be second argument
4308 return jQuery.css( elem, "display" ) === "none" ||
4309 !jQuery.contains( elem.ownerDocument, elem );
4314 function adjustCSS( elem, prop, valueParts, tween ) {
4318 currentValue = tween ?
4319 function() { return tween.cur(); } :
4320 function() { return jQuery.css( elem, prop, "" ); },
4321 initial = currentValue(),
4322 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4324 // Starting value computation is required for potential unit mismatches
4325 initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4326 rcssNum.exec( jQuery.css( elem, prop ) );
4328 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4330 // Trust units reported by jQuery.css
4331 unit = unit || initialInUnit[ 3 ];
4333 // Make sure we update the tween properties later on
4334 valueParts = valueParts || [];
4336 // Iteratively approximate from a nonzero starting point
4337 initialInUnit = +initial || 1;
4341 // If previous iteration zeroed out, double until we get *something*.
4342 // Use string for doubling so we don't accidentally see scale as unchanged below
4343 scale = scale || ".5";
4346 initialInUnit = initialInUnit / scale;
4347 jQuery.style( elem, prop, initialInUnit + unit );
4349 // Update scale, tolerating zero or NaN from tween.cur()
4350 // Break the loop if scale is unchanged or perfect, or if we've just had enough.
4352 scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations
4357 initialInUnit = +initialInUnit || +initial || 0;
4359 // Apply relative offset (+=/-=) if specified
4360 adjusted = valueParts[ 1 ] ?
4361 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4365 tween.start = initialInUnit;
4366 tween.end = adjusted;
4373 // Multifunctional method to get and set values of a collection
4374 // The value/s can optionally be executed if it's a function
4375 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4377 length = elems.length,
4381 if ( jQuery.type( key ) === "object" ) {
4384 access( elems, fn, i, key[ i ], true, emptyGet, raw );
4388 } else if ( value !== undefined ) {
4391 if ( !jQuery.isFunction( value ) ) {
4397 // Bulk operations run against the entire set
4399 fn.call( elems, value );
4402 // ...except when executing function values
4405 fn = function( elem, key, value ) {
4406 return bulk.call( jQuery( elem ), value );
4412 for ( ; i < length; i++ ) {
4416 raw ? value : value.call( elems[ i ], i, fn( elems[ i ], key ) )
4428 length ? fn( elems[ 0 ], key ) : emptyGet;
4430 var rcheckableType = ( /^(?:checkbox|radio)$/i );
4432 var rtagName = ( /<([\w:-]+)/ );
4434 var rscriptType = ( /^$|\/(?:java|ecma)script/i );
4436 var rleadingWhitespace = ( /^\s+/ );
4438 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|" +
4439 "details|dialog|figcaption|figure|footer|header|hgroup|main|" +
4440 "mark|meter|nav|output|picture|progress|section|summary|template|time|video";
4444 function createSafeFragment( document ) {
4445 var list = nodeNames.split( "|" ),
4446 safeFrag = document.createDocumentFragment();
4448 if ( safeFrag.createElement ) {
4449 while ( list.length ) {
4450 safeFrag.createElement(
4460 var div = document.createElement( "div" ),
4461 fragment = document.createDocumentFragment(),
4462 input = document.createElement( "input" );
4465 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
4467 // IE strips leading whitespace when .innerHTML is used
4468 support.leadingWhitespace = div.firstChild.nodeType === 3;
4470 // Make sure that tbody elements aren't automatically inserted
4471 // IE will insert them into empty tables
4472 support.tbody = !div.getElementsByTagName( "tbody" ).length;
4474 // Make sure that link elements get serialized correctly by innerHTML
4475 // This requires a wrapper element in IE
4476 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
4478 // Makes sure cloning an html5 element does not cause problems
4479 // Where outerHTML is undefined, this still works
4480 support.html5Clone =
4481 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
4483 // Check if a disconnected checkbox will retain its checked
4484 // value of true after appended to the DOM (IE6/7)
4485 input.type = "checkbox";
4486 input.checked = true;
4487 fragment.appendChild( input );
4488 support.appendChecked = input.checked;
4490 // Make sure textarea (and checkbox) defaultValue is properly cloned
4491 // Support: IE6-IE11+
4492 div.innerHTML = "<textarea>x</textarea>";
4493 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4495 // #11217 - WebKit loses check when the name is after the checked attribute
4496 fragment.appendChild( div );
4498 // Support: Windows Web Apps (WWA)
4499 // `name` and `type` must use .setAttribute for WWA (#14901)
4500 input = document.createElement( "input" );
4501 input.setAttribute( "type", "radio" );
4502 input.setAttribute( "checked", "checked" );
4503 input.setAttribute( "name", "t" );
4505 div.appendChild( input );
4507 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
4508 // old WebKit doesn't clone checked state correctly in fragments
4509 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4512 // Cloned elements keep attachEvent handlers, we use addEventListener on IE9+
4513 support.noCloneEvent = !!div.addEventListener;
4516 // Since attributes and properties are the same in IE,
4517 // cleanData must set properties to undefined rather than use removeAttribute
4518 div[ jQuery.expando ] = 1;
4519 support.attributes = !div.getAttribute( jQuery.expando );
4523 // We have to close these tags to support XHTML (#13200)
4525 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4526 legend: [ 1, "<fieldset>", "</fieldset>" ],
4527 area: [ 1, "<map>", "</map>" ],
4530 param: [ 1, "<object>", "</object>" ],
4531 thead: [ 1, "<table>", "</table>" ],
4532 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4533 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
4534 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4536 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
4537 // unless wrapped in a div with non-breaking characters in front of it.
4538 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
4542 wrapMap.optgroup = wrapMap.option;
4544 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4545 wrapMap.th = wrapMap.td;
4548 function getAll( context, tag ) {
4551 found = typeof context.getElementsByTagName !== "undefined" ?
4552 context.getElementsByTagName( tag || "*" ) :
4553 typeof context.querySelectorAll !== "undefined" ?
4554 context.querySelectorAll( tag || "*" ) :
4558 for ( found = [], elems = context.childNodes || context;
4559 ( elem = elems[ i ] ) != null;
4562 if ( !tag || jQuery.nodeName( elem, tag ) ) {
4565 jQuery.merge( found, getAll( elem, tag ) );
4570 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
4571 jQuery.merge( [ context ], found ) :
4576 // Mark scripts as having already been evaluated
4577 function setGlobalEval( elems, refElements ) {
4580 for ( ; ( elem = elems[ i ] ) != null; i++ ) {
4584 !refElements || jQuery._data( refElements[ i ], "globalEval" )
4590 var rhtml = /<|&#?\w+;/,
4593 function fixDefaultChecked( elem ) {
4594 if ( rcheckableType.test( elem.type ) ) {
4595 elem.defaultChecked = elem.checked;
4599 function buildFragment( elems, context, scripts, selection, ignored ) {
4600 var j, elem, contains,
4601 tmp, tag, tbody, wrap,
4604 // Ensure a safe fragment
4605 safe = createSafeFragment( context ),
4610 for ( ; i < l; i++ ) {
4613 if ( elem || elem === 0 ) {
4615 // Add nodes directly
4616 if ( jQuery.type( elem ) === "object" ) {
4617 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
4619 // Convert non-html into a text node
4620 } else if ( !rhtml.test( elem ) ) {
4621 nodes.push( context.createTextNode( elem ) );
4623 // Convert html into DOM nodes
4625 tmp = tmp || safe.appendChild( context.createElement( "div" ) );
4627 // Deserialize a standard representation
4628 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
4629 wrap = wrapMap[ tag ] || wrapMap._default;
4631 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
4633 // Descend through wrappers to the right content
4636 tmp = tmp.lastChild;
4639 // Manually add leading whitespace removed by IE
4640 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
4641 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[ 0 ] ) );
4644 // Remove IE's autoinserted <tbody> from table fragments
4645 if ( !support.tbody ) {
4647 // String was a <table>, *may* have spurious <tbody>
4648 elem = tag === "table" && !rtbody.test( elem ) ?
4651 // String was a bare <thead> or <tfoot>
4652 wrap[ 1 ] === "<table>" && !rtbody.test( elem ) ?
4656 j = elem && elem.childNodes.length;
4658 if ( jQuery.nodeName( ( tbody = elem.childNodes[ j ] ), "tbody" ) &&
4659 !tbody.childNodes.length ) {
4661 elem.removeChild( tbody );
4666 jQuery.merge( nodes, tmp.childNodes );
4668 // Fix #12392 for WebKit and IE > 9
4669 tmp.textContent = "";
4671 // Fix #12392 for oldIE
4672 while ( tmp.firstChild ) {
4673 tmp.removeChild( tmp.firstChild );
4676 // Remember the top-level container for proper cleanup
4677 tmp = safe.lastChild;
4682 // Fix #11356: Clear elements from fragment
4684 safe.removeChild( tmp );
4687 // Reset defaultChecked for any radios and checkboxes
4688 // about to be appended to the DOM in IE 6/7 (#8060)
4689 if ( !support.appendChecked ) {
4690 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
4694 while ( ( elem = nodes[ i++ ] ) ) {
4696 // Skip elements already in the context collection (trac-4087)
4697 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
4699 ignored.push( elem );
4705 contains = jQuery.contains( elem.ownerDocument, elem );
4707 // Append to fragment
4708 tmp = getAll( safe.appendChild( elem ), "script" );
4710 // Preserve script evaluation history
4712 setGlobalEval( tmp );
4715 // Capture executables
4718 while ( ( elem = tmp[ j++ ] ) ) {
4719 if ( rscriptType.test( elem.type || "" ) ) {
4720 scripts.push( elem );
4734 div = document.createElement( "div" );
4736 // Support: IE<9 (lack submit/change bubble), Firefox (lack focus(in | out) events)
4737 for ( i in { submit: true, change: true, focusin: true } ) {
4738 eventName = "on" + i;
4740 if ( !( support[ i ] = eventName in window ) ) {
4742 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
4743 div.setAttribute( eventName, "t" );
4744 support[ i ] = div.attributes[ eventName ].expando === false;
4748 // Null elements to avoid leaks in IE.
4753 var rformElems = /^(?:input|select|textarea)$/i,
4755 rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
4756 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4757 rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
4759 function returnTrue() {
4763 function returnFalse() {
4768 // See #13393 for more info
4769 function safeActiveElement() {
4771 return document.activeElement;
4775 function on( elem, types, selector, data, fn, one ) {
4778 // Types can be a map of types/handlers
4779 if ( typeof types === "object" ) {
4781 // ( types-Object, selector, data )
4782 if ( typeof selector !== "string" ) {
4784 // ( types-Object, data )
4785 data = data || selector;
4786 selector = undefined;
4788 for ( type in types ) {
4789 on( elem, type, selector, data, types[ type ], one );
4794 if ( data == null && fn == null ) {
4798 data = selector = undefined;
4799 } else if ( fn == null ) {
4800 if ( typeof selector === "string" ) {
4802 // ( types, selector, fn )
4807 // ( types, data, fn )
4810 selector = undefined;
4813 if ( fn === false ) {
4821 fn = function( event ) {
4823 // Can use an empty set, since event contains the info
4824 jQuery().off( event );
4825 return origFn.apply( this, arguments );
4828 // Use same guid so caller can remove using origFn
4829 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4831 return elem.each( function() {
4832 jQuery.event.add( this, types, fn, data, selector );
4837 * Helper functions for managing events -- not part of the public interface.
4838 * Props to Dean Edwards' addEvent library for many of the ideas.
4844 add: function( elem, types, handler, data, selector ) {
4845 var tmp, events, t, handleObjIn,
4846 special, eventHandle, handleObj,
4847 handlers, type, namespaces, origType,
4848 elemData = jQuery._data( elem );
4850 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4855 // Caller can pass in an object of custom data in lieu of the handler
4856 if ( handler.handler ) {
4857 handleObjIn = handler;
4858 handler = handleObjIn.handler;
4859 selector = handleObjIn.selector;
4862 // Make sure that the handler has a unique ID, used to find/remove it later
4863 if ( !handler.guid ) {
4864 handler.guid = jQuery.guid++;
4867 // Init the element's event structure and main handler, if this is the first
4868 if ( !( events = elemData.events ) ) {
4869 events = elemData.events = {};
4871 if ( !( eventHandle = elemData.handle ) ) {
4872 eventHandle = elemData.handle = function( e ) {
4874 // Discard the second event of a jQuery.event.trigger() and
4875 // when an event is called after a page has unloaded
4876 return typeof jQuery !== "undefined" &&
4877 ( !e || jQuery.event.triggered !== e.type ) ?
4878 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
4882 // Add elem as a property of the handle fn to prevent a memory leak
4883 // with IE non-native events
4884 eventHandle.elem = elem;
4887 // Handle multiple events separated by a space
4888 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4891 tmp = rtypenamespace.exec( types[ t ] ) || [];
4892 type = origType = tmp[ 1 ];
4893 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4895 // There *must* be a type, no attaching namespace-only handlers
4900 // If event changes its type, use the special event handlers for the changed type
4901 special = jQuery.event.special[ type ] || {};
4903 // If selector defined, determine special event api type, otherwise given type
4904 type = ( selector ? special.delegateType : special.bindType ) || type;
4906 // Update special based on newly reset type
4907 special = jQuery.event.special[ type ] || {};
4909 // handleObj is passed to all event handlers
4910 handleObj = jQuery.extend( {
4917 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4918 namespace: namespaces.join( "." )
4921 // Init the event handler queue if we're the first
4922 if ( !( handlers = events[ type ] ) ) {
4923 handlers = events[ type ] = [];
4924 handlers.delegateCount = 0;
4926 // Only use addEventListener/attachEvent if the special events handler returns false
4927 if ( !special.setup ||
4928 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4930 // Bind the global event handler to the element
4931 if ( elem.addEventListener ) {
4932 elem.addEventListener( type, eventHandle, false );
4934 } else if ( elem.attachEvent ) {
4935 elem.attachEvent( "on" + type, eventHandle );
4940 if ( special.add ) {
4941 special.add.call( elem, handleObj );
4943 if ( !handleObj.handler.guid ) {
4944 handleObj.handler.guid = handler.guid;
4948 // Add to the element's handler list, delegates in front
4950 handlers.splice( handlers.delegateCount++, 0, handleObj );
4952 handlers.push( handleObj );
4955 // Keep track of which events have ever been used, for event optimization
4956 jQuery.event.global[ type ] = true;
4959 // Nullify elem to prevent memory leaks in IE
4963 // Detach an event or set of events from an element
4964 remove: function( elem, types, handler, selector, mappedTypes ) {
4965 var j, handleObj, tmp,
4966 origCount, t, events,
4967 special, handlers, type,
4968 namespaces, origType,
4969 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
4971 if ( !elemData || !( events = elemData.events ) ) {
4975 // Once for each type.namespace in types; type may be omitted
4976 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4979 tmp = rtypenamespace.exec( types[ t ] ) || [];
4980 type = origType = tmp[ 1 ];
4981 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
4983 // Unbind all events (on this namespace, if provided) for the element
4985 for ( type in events ) {
4986 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4991 special = jQuery.event.special[ type ] || {};
4992 type = ( selector ? special.delegateType : special.bindType ) || type;
4993 handlers = events[ type ] || [];
4995 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
4997 // Remove matching events
4998 origCount = j = handlers.length;
5000 handleObj = handlers[ j ];
5002 if ( ( mappedTypes || origType === handleObj.origType ) &&
5003 ( !handler || handler.guid === handleObj.guid ) &&
5004 ( !tmp || tmp.test( handleObj.namespace ) ) &&
5005 ( !selector || selector === handleObj.selector ||
5006 selector === "**" && handleObj.selector ) ) {
5007 handlers.splice( j, 1 );
5009 if ( handleObj.selector ) {
5010 handlers.delegateCount--;
5012 if ( special.remove ) {
5013 special.remove.call( elem, handleObj );
5018 // Remove generic event handler if we removed something and no more handlers exist
5019 // (avoids potential for endless recursion during removal of special event handlers)
5020 if ( origCount && !handlers.length ) {
5021 if ( !special.teardown ||
5022 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5024 jQuery.removeEvent( elem, type, elemData.handle );
5027 delete events[ type ];
5031 // Remove the expando if it's no longer used
5032 if ( jQuery.isEmptyObject( events ) ) {
5033 delete elemData.handle;
5035 // removeData also checks for emptiness and clears the expando if empty
5036 // so use it instead of delete
5037 jQuery._removeData( elem, "events" );
5041 trigger: function( event, data, elem, onlyHandlers ) {
5042 var handle, ontype, cur,
5043 bubbleType, special, tmp, i,
5044 eventPath = [ elem || document ],
5045 type = hasOwn.call( event, "type" ) ? event.type : event,
5046 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
5048 cur = tmp = elem = elem || document;
5050 // Don't do events on text and comment nodes
5051 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
5055 // focus/blur morphs to focusin/out; ensure we're not firing them right now
5056 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
5060 if ( type.indexOf( "." ) > -1 ) {
5062 // Namespaced trigger; create a regexp to match event type in handle()
5063 namespaces = type.split( "." );
5064 type = namespaces.shift();
5067 ontype = type.indexOf( ":" ) < 0 && "on" + type;
5069 // Caller can pass in a jQuery.Event object, Object, or just an event type string
5070 event = event[ jQuery.expando ] ?
5072 new jQuery.Event( type, typeof event === "object" && event );
5074 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
5075 event.isTrigger = onlyHandlers ? 2 : 3;
5076 event.namespace = namespaces.join( "." );
5077 event.rnamespace = event.namespace ?
5078 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
5081 // Clean up the event in case it is being reused
5082 event.result = undefined;
5083 if ( !event.target ) {
5084 event.target = elem;
5087 // Clone any incoming data and prepend the event, creating the handler arg list
5088 data = data == null ?
5090 jQuery.makeArray( data, [ event ] );
5092 // Allow special events to draw outside the lines
5093 special = jQuery.event.special[ type ] || {};
5094 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
5098 // Determine event propagation path in advance, per W3C events spec (#9951)
5099 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
5100 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
5102 bubbleType = special.delegateType || type;
5103 if ( !rfocusMorph.test( bubbleType + type ) ) {
5104 cur = cur.parentNode;
5106 for ( ; cur; cur = cur.parentNode ) {
5107 eventPath.push( cur );
5111 // Only add window if we got to document (e.g., not plain obj or detached DOM)
5112 if ( tmp === ( elem.ownerDocument || document ) ) {
5113 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
5117 // Fire handlers on the event path
5119 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
5121 event.type = i > 1 ?
5123 special.bindType || type;
5126 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] &&
5127 jQuery._data( cur, "handle" );
5130 handle.apply( cur, data );
5134 handle = ontype && cur[ ontype ];
5135 if ( handle && handle.apply && acceptData( cur ) ) {
5136 event.result = handle.apply( cur, data );
5137 if ( event.result === false ) {
5138 event.preventDefault();
5144 // If nobody prevented the default action, do it now
5145 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
5148 ( !special._default ||
5149 special._default.apply( eventPath.pop(), data ) === false
5150 ) && acceptData( elem )
5153 // Call a native DOM method on the target with the same name name as the event.
5154 // Can't use an .isFunction() check here because IE6/7 fails that test.
5155 // Don't do default actions on window, that's where global variables be (#6170)
5156 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
5158 // Don't re-trigger an onFOO event when we call its FOO() method
5159 tmp = elem[ ontype ];
5162 elem[ ontype ] = null;
5165 // Prevent re-triggering of the same event, since we already bubbled it above
5166 jQuery.event.triggered = type;
5171 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
5172 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
5174 jQuery.event.triggered = undefined;
5177 elem[ ontype ] = tmp;
5183 return event.result;
5186 dispatch: function( event ) {
5188 // Make a writable jQuery.Event from the native event object
5189 event = jQuery.event.fix( event );
5191 var i, j, ret, matched, handleObj,
5193 args = slice.call( arguments ),
5194 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
5195 special = jQuery.event.special[ event.type ] || {};
5197 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5199 event.delegateTarget = this;
5201 // Call the preDispatch hook for the mapped type, and let it bail if desired
5202 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5206 // Determine handlers
5207 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5209 // Run delegates first; they may want to stop propagation beneath us
5211 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5212 event.currentTarget = matched.elem;
5215 while ( ( handleObj = matched.handlers[ j++ ] ) &&
5216 !event.isImmediatePropagationStopped() ) {
5218 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
5219 // a subset or equal to those in the bound event (both can have no namespace).
5220 if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) {
5222 event.handleObj = handleObj;
5223 event.data = handleObj.data;
5225 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5226 handleObj.handler ).apply( matched.elem, args );
5228 if ( ret !== undefined ) {
5229 if ( ( event.result = ret ) === false ) {
5230 event.preventDefault();
5231 event.stopPropagation();
5238 // Call the postDispatch hook for the mapped type
5239 if ( special.postDispatch ) {
5240 special.postDispatch.call( this, event );
5243 return event.result;
5246 handlers: function( event, handlers ) {
5247 var i, matches, sel, handleObj,
5249 delegateCount = handlers.delegateCount,
5252 // Support (at least): Chrome, IE9
5253 // Find delegate handlers
5254 // Black-hole SVG <use> instance trees (#13180)
5256 // Support: Firefox<=42+
5257 // Avoid non-left-click in FF but don't block IE radio events (#3861, gh-2343)
5258 if ( delegateCount && cur.nodeType &&
5259 ( event.type !== "click" || isNaN( event.button ) || event.button < 1 ) ) {
5261 /* jshint eqeqeq: false */
5262 for ( ; cur != this; cur = cur.parentNode || this ) {
5263 /* jshint eqeqeq: true */
5265 // Don't check non-elements (#13208)
5266 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5267 if ( cur.nodeType === 1 && ( cur.disabled !== true || event.type !== "click" ) ) {
5269 for ( i = 0; i < delegateCount; i++ ) {
5270 handleObj = handlers[ i ];
5272 // Don't conflict with Object.prototype properties (#13203)
5273 sel = handleObj.selector + " ";
5275 if ( matches[ sel ] === undefined ) {
5276 matches[ sel ] = handleObj.needsContext ?
5277 jQuery( sel, this ).index( cur ) > -1 :
5278 jQuery.find( sel, this, null, [ cur ] ).length;
5280 if ( matches[ sel ] ) {
5281 matches.push( handleObj );
5284 if ( matches.length ) {
5285 handlerQueue.push( { elem: cur, handlers: matches } );
5291 // Add the remaining (directly-bound) handlers
5292 if ( delegateCount < handlers.length ) {
5293 handlerQueue.push( { elem: this, handlers: handlers.slice( delegateCount ) } );
5296 return handlerQueue;
5299 fix: function( event ) {
5300 if ( event[ jQuery.expando ] ) {
5304 // Create a writable copy of the event object and normalize some properties
5307 originalEvent = event,
5308 fixHook = this.fixHooks[ type ];
5311 this.fixHooks[ type ] = fixHook =
5312 rmouseEvent.test( type ) ? this.mouseHooks :
5313 rkeyEvent.test( type ) ? this.keyHooks :
5316 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
5318 event = new jQuery.Event( originalEvent );
5323 event[ prop ] = originalEvent[ prop ];
5327 // Fix target property (#1925)
5328 if ( !event.target ) {
5329 event.target = originalEvent.srcElement || document;
5332 // Support: Safari 6-8+
5333 // Target should not be a text node (#504, #13143)
5334 if ( event.target.nodeType === 3 ) {
5335 event.target = event.target.parentNode;
5339 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
5340 event.metaKey = !!event.metaKey;
5342 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
5345 // Includes some event props shared by KeyEvent and MouseEvent
5346 props: ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
5347 "metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " ),
5352 props: "char charCode key keyCode".split( " " ),
5353 filter: function( event, original ) {
5355 // Add which for key events
5356 if ( event.which == null ) {
5357 event.which = original.charCode != null ? original.charCode : original.keyCode;
5365 props: ( "button buttons clientX clientY fromElement offsetX offsetY " +
5366 "pageX pageY screenX screenY toElement" ).split( " " ),
5367 filter: function( event, original ) {
5368 var body, eventDoc, doc,
5369 button = original.button,
5370 fromElement = original.fromElement;
5372 // Calculate pageX/Y if missing and clientX/Y available
5373 if ( event.pageX == null && original.clientX != null ) {
5374 eventDoc = event.target.ownerDocument || document;
5375 doc = eventDoc.documentElement;
5376 body = eventDoc.body;
5378 event.pageX = original.clientX +
5379 ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) -
5380 ( doc && doc.clientLeft || body && body.clientLeft || 0 );
5381 event.pageY = original.clientY +
5382 ( doc && doc.scrollTop || body && body.scrollTop || 0 ) -
5383 ( doc && doc.clientTop || body && body.clientTop || 0 );
5386 // Add relatedTarget, if necessary
5387 if ( !event.relatedTarget && fromElement ) {
5388 event.relatedTarget = fromElement === event.target ?
5389 original.toElement :
5393 // Add which for click: 1 === left; 2 === middle; 3 === right
5394 // Note: button is not normalized, so don't use it
5395 if ( !event.which && button !== undefined ) {
5396 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
5406 // Prevent triggered image.load events from bubbling to window.load
5411 // Fire native event if possible so blur/focus sequence is correct
5412 trigger: function() {
5413 if ( this !== safeActiveElement() && this.focus ) {
5420 // If we error on focus to hidden element (#1486, #12518),
5421 // let .trigger() run the handlers
5425 delegateType: "focusin"
5428 trigger: function() {
5429 if ( this === safeActiveElement() && this.blur ) {
5434 delegateType: "focusout"
5438 // For checkbox, fire native event so checked state will be right
5439 trigger: function() {
5440 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
5446 // For cross-browser consistency, don't fire native .click() on links
5447 _default: function( event ) {
5448 return jQuery.nodeName( event.target, "a" );
5453 postDispatch: function( event ) {
5455 // Support: Firefox 20+
5456 // Firefox doesn't alert if the returnValue field is not set.
5457 if ( event.result !== undefined && event.originalEvent ) {
5458 event.originalEvent.returnValue = event.result;
5464 // Piggyback on a donor event to simulate a different one
5465 simulate: function( type, elem, event ) {
5466 var e = jQuery.extend(
5473 // Previously, `originalEvent: {}` was set here, so stopPropagation call
5474 // would not be triggered on donor event, since in our own
5475 // jQuery.event.stopPropagation function we had a check for existence of
5476 // originalEvent.stopPropagation method, so, consequently it would be a noop.
5478 // Guard for simulated events was moved to jQuery.event.stopPropagation function
5479 // since `originalEvent` should point to the original event for the
5480 // constancy with other events and for more focused logic
5484 jQuery.event.trigger( e, null, elem );
5486 if ( e.isDefaultPrevented() ) {
5487 event.preventDefault();
5492 jQuery.removeEvent = document.removeEventListener ?
5493 function( elem, type, handle ) {
5495 // This "if" is needed for plain objects
5496 if ( elem.removeEventListener ) {
5497 elem.removeEventListener( type, handle );
5500 function( elem, type, handle ) {
5501 var name = "on" + type;
5503 if ( elem.detachEvent ) {
5505 // #8545, #7054, preventing memory leaks for custom events in IE6-8
5506 // detachEvent needed property on element, by name of that event,
5507 // to properly expose it to GC
5508 if ( typeof elem[ name ] === "undefined" ) {
5509 elem[ name ] = null;
5512 elem.detachEvent( name, handle );
5516 jQuery.Event = function( src, props ) {
5518 // Allow instantiation without the 'new' keyword
5519 if ( !( this instanceof jQuery.Event ) ) {
5520 return new jQuery.Event( src, props );
5524 if ( src && src.type ) {
5525 this.originalEvent = src;
5526 this.type = src.type;
5528 // Events bubbling up the document may have been marked as prevented
5529 // by a handler lower down the tree; reflect the correct value.
5530 this.isDefaultPrevented = src.defaultPrevented ||
5531 src.defaultPrevented === undefined &&
5533 // Support: IE < 9, Android < 4.0
5534 src.returnValue === false ?
5543 // Put explicitly provided properties onto the event object
5545 jQuery.extend( this, props );
5548 // Create a timestamp if incoming event doesn't have one
5549 this.timeStamp = src && src.timeStamp || jQuery.now();
5552 this[ jQuery.expando ] = true;
5555 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5556 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5557 jQuery.Event.prototype = {
5558 constructor: jQuery.Event,
5559 isDefaultPrevented: returnFalse,
5560 isPropagationStopped: returnFalse,
5561 isImmediatePropagationStopped: returnFalse,
5563 preventDefault: function() {
5564 var e = this.originalEvent;
5566 this.isDefaultPrevented = returnTrue;
5571 // If preventDefault exists, run it on the original event
5572 if ( e.preventDefault ) {
5576 // Otherwise set the returnValue property of the original event to false
5578 e.returnValue = false;
5581 stopPropagation: function() {
5582 var e = this.originalEvent;
5584 this.isPropagationStopped = returnTrue;
5586 if ( !e || this.isSimulated ) {
5590 // If stopPropagation exists, run it on the original event
5591 if ( e.stopPropagation ) {
5592 e.stopPropagation();
5596 // Set the cancelBubble property of the original event to true
5597 e.cancelBubble = true;
5599 stopImmediatePropagation: function() {
5600 var e = this.originalEvent;
5602 this.isImmediatePropagationStopped = returnTrue;
5604 if ( e && e.stopImmediatePropagation ) {
5605 e.stopImmediatePropagation();
5608 this.stopPropagation();
5612 // Create mouseenter/leave events using mouseover/out and event-time checks
5613 // so that event delegation works in jQuery.
5614 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5616 // Support: Safari 7 only
5617 // Safari sends mouseenter too often; see:
5618 // https://code.google.com/p/chromium/issues/detail?id=470258
5619 // for the description of the bug (it existed in older Chrome versions as well).
5621 mouseenter: "mouseover",
5622 mouseleave: "mouseout",
5623 pointerenter: "pointerover",
5624 pointerleave: "pointerout"
5625 }, function( orig, fix ) {
5626 jQuery.event.special[ orig ] = {
5630 handle: function( event ) {
5633 related = event.relatedTarget,
5634 handleObj = event.handleObj;
5636 // For mouseenter/leave call the handler if related is outside the target.
5637 // NB: No relatedTarget if the mouse left/entered the browser window
5638 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5639 event.type = handleObj.origType;
5640 ret = handleObj.handler.apply( this, arguments );
5648 // IE submit delegation
5649 if ( !support.submit ) {
5651 jQuery.event.special.submit = {
5654 // Only need this for delegated form submit events
5655 if ( jQuery.nodeName( this, "form" ) ) {
5659 // Lazy-add a submit handler when a descendant form may potentially be submitted
5660 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
5662 // Node name check avoids a VML-related crash in IE (#9807)
5663 var elem = e.target,
5664 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ?
5667 // We use jQuery.prop instead of elem.form
5668 // to allow fixing the IE8 delegated submit issue (gh-2332)
5669 // by 3rd party polyfills/workarounds.
5670 jQuery.prop( elem, "form" ) :
5673 if ( form && !jQuery._data( form, "submit" ) ) {
5674 jQuery.event.add( form, "submit._submit", function( event ) {
5675 event._submitBubble = true;
5677 jQuery._data( form, "submit", true );
5681 // return undefined since we don't need an event listener
5684 postDispatch: function( event ) {
5686 // If form was submitted by the user, bubble the event up the tree
5687 if ( event._submitBubble ) {
5688 delete event._submitBubble;
5689 if ( this.parentNode && !event.isTrigger ) {
5690 jQuery.event.simulate( "submit", this.parentNode, event );
5695 teardown: function() {
5697 // Only need this for delegated form submit events
5698 if ( jQuery.nodeName( this, "form" ) ) {
5702 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
5703 jQuery.event.remove( this, "._submit" );
5708 // IE change delegation and checkbox/radio fix
5709 if ( !support.change ) {
5711 jQuery.event.special.change = {
5715 if ( rformElems.test( this.nodeName ) ) {
5717 // IE doesn't fire change on a check/radio until blur; trigger it on click
5718 // after a propertychange. Eat the blur-change in special.change.handle.
5719 // This still fires onchange a second time for check/radio after blur.
5720 if ( this.type === "checkbox" || this.type === "radio" ) {
5721 jQuery.event.add( this, "propertychange._change", function( event ) {
5722 if ( event.originalEvent.propertyName === "checked" ) {
5723 this._justChanged = true;
5726 jQuery.event.add( this, "click._change", function( event ) {
5727 if ( this._justChanged && !event.isTrigger ) {
5728 this._justChanged = false;
5731 // Allow triggered, simulated change events (#11500)
5732 jQuery.event.simulate( "change", this, event );
5738 // Delegated event; lazy-add a change handler on descendant inputs
5739 jQuery.event.add( this, "beforeactivate._change", function( e ) {
5740 var elem = e.target;
5742 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "change" ) ) {
5743 jQuery.event.add( elem, "change._change", function( event ) {
5744 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
5745 jQuery.event.simulate( "change", this.parentNode, event );
5748 jQuery._data( elem, "change", true );
5753 handle: function( event ) {
5754 var elem = event.target;
5756 // Swallow native change events from checkbox/radio, we already triggered them above
5757 if ( this !== elem || event.isSimulated || event.isTrigger ||
5758 ( elem.type !== "radio" && elem.type !== "checkbox" ) ) {
5760 return event.handleObj.handler.apply( this, arguments );
5764 teardown: function() {
5765 jQuery.event.remove( this, "._change" );
5767 return !rformElems.test( this.nodeName );
5773 // Firefox doesn't have focus(in | out) events
5774 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
5776 // Support: Chrome, Safari
5777 // focus(in | out) events fire after focus & blur events,
5778 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
5779 // Related ticket - https://code.google.com/p/chromium/issues/detail?id=449857
5780 if ( !support.focusin ) {
5781 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
5783 // Attach a single capturing handler on the document while someone wants focusin/focusout
5784 var handler = function( event ) {
5785 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
5788 jQuery.event.special[ fix ] = {
5790 var doc = this.ownerDocument || this,
5791 attaches = jQuery._data( doc, fix );
5794 doc.addEventListener( orig, handler, true );
5796 jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
5798 teardown: function() {
5799 var doc = this.ownerDocument || this,
5800 attaches = jQuery._data( doc, fix ) - 1;
5803 doc.removeEventListener( orig, handler, true );
5804 jQuery._removeData( doc, fix );
5806 jQuery._data( doc, fix, attaches );
5815 on: function( types, selector, data, fn ) {
5816 return on( this, types, selector, data, fn );
5818 one: function( types, selector, data, fn ) {
5819 return on( this, types, selector, data, fn, 1 );
5821 off: function( types, selector, fn ) {
5822 var handleObj, type;
5823 if ( types && types.preventDefault && types.handleObj ) {
5825 // ( event ) dispatched jQuery.Event
5826 handleObj = types.handleObj;
5827 jQuery( types.delegateTarget ).off(
5828 handleObj.namespace ?
5829 handleObj.origType + "." + handleObj.namespace :
5836 if ( typeof types === "object" ) {
5838 // ( types-object [, selector] )
5839 for ( type in types ) {
5840 this.off( type, selector, types[ type ] );
5844 if ( selector === false || typeof selector === "function" ) {
5848 selector = undefined;
5850 if ( fn === false ) {
5853 return this.each( function() {
5854 jQuery.event.remove( this, types, fn, selector );
5858 trigger: function( type, data ) {
5859 return this.each( function() {
5860 jQuery.event.trigger( type, data, this );
5863 triggerHandler: function( type, data ) {
5864 var elem = this[ 0 ];
5866 return jQuery.event.trigger( type, data, elem, true );
5872 var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5873 rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
5874 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
5876 // Support: IE 10-11, Edge 10240+
5877 // In IE/Edge using regex groups here causes severe slowdowns.
5878 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5879 rnoInnerhtml = /<script|<style|<link/i,
5881 // checked="checked" or checked
5882 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5883 rscriptTypeMasked = /^true\/(.*)/,
5884 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
5885 safeFragment = createSafeFragment( document ),
5886 fragmentDiv = safeFragment.appendChild( document.createElement( "div" ) );
5889 // Manipulating tables requires a tbody
5890 function manipulationTarget( elem, content ) {
5891 return jQuery.nodeName( elem, "table" ) &&
5892 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
5894 elem.getElementsByTagName( "tbody" )[ 0 ] ||
5895 elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) :
5899 // Replace/restore the type attribute of script elements for safe DOM manipulation
5900 function disableScript( elem ) {
5901 elem.type = ( jQuery.find.attr( elem, "type" ) !== null ) + "/" + elem.type;
5904 function restoreScript( elem ) {
5905 var match = rscriptTypeMasked.exec( elem.type );
5907 elem.type = match[ 1 ];
5909 elem.removeAttribute( "type" );
5914 function cloneCopyEvent( src, dest ) {
5915 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5920 oldData = jQuery._data( src ),
5921 curData = jQuery._data( dest, oldData ),
5922 events = oldData.events;
5925 delete curData.handle;
5926 curData.events = {};
5928 for ( type in events ) {
5929 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5930 jQuery.event.add( dest, type, events[ type ][ i ] );
5935 // make the cloned public data object a copy from the original
5936 if ( curData.data ) {
5937 curData.data = jQuery.extend( {}, curData.data );
5941 function fixCloneNodeIssues( src, dest ) {
5942 var nodeName, e, data;
5944 // We do not need to do anything for non-Elements
5945 if ( dest.nodeType !== 1 ) {
5949 nodeName = dest.nodeName.toLowerCase();
5951 // IE6-8 copies events bound via attachEvent when using cloneNode.
5952 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
5953 data = jQuery._data( dest );
5955 for ( e in data.events ) {
5956 jQuery.removeEvent( dest, e, data.handle );
5959 // Event data gets referenced instead of copied if the expando gets copied too
5960 dest.removeAttribute( jQuery.expando );
5963 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
5964 if ( nodeName === "script" && dest.text !== src.text ) {
5965 disableScript( dest ).text = src.text;
5966 restoreScript( dest );
5968 // IE6-10 improperly clones children of object elements using classid.
5969 // IE10 throws NoModificationAllowedError if parent is null, #12132.
5970 } else if ( nodeName === "object" ) {
5971 if ( dest.parentNode ) {
5972 dest.outerHTML = src.outerHTML;
5975 // This path appears unavoidable for IE9. When cloning an object
5976 // element in IE9, the outerHTML strategy above is not sufficient.
5977 // If the src has innerHTML and the destination does not,
5978 // copy the src.innerHTML into the dest.innerHTML. #10324
5979 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim( dest.innerHTML ) ) ) {
5980 dest.innerHTML = src.innerHTML;
5983 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5985 // IE6-8 fails to persist the checked state of a cloned checkbox
5986 // or radio button. Worse, IE6-7 fail to give the cloned element
5987 // a checked appearance if the defaultChecked value isn't also set
5989 dest.defaultChecked = dest.checked = src.checked;
5991 // IE6-7 get confused and end up setting the value of a cloned
5992 // checkbox/radio button to an empty string instead of "on"
5993 if ( dest.value !== src.value ) {
5994 dest.value = src.value;
5997 // IE6-8 fails to return the selected option to the default selected
5998 // state when cloning options
5999 } else if ( nodeName === "option" ) {
6000 dest.defaultSelected = dest.selected = src.defaultSelected;
6002 // IE6-8 fails to set the defaultValue to the correct value when
6003 // cloning other types of input fields
6004 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6005 dest.defaultValue = src.defaultValue;
6009 function domManip( collection, args, callback, ignored ) {
6011 // Flatten any nested arrays
6012 args = concat.apply( [], args );
6014 var first, node, hasScripts,
6015 scripts, doc, fragment,
6017 l = collection.length,
6020 isFunction = jQuery.isFunction( value );
6022 // We can't cloneNode fragments that contain checked, in WebKit
6024 ( l > 1 && typeof value === "string" &&
6025 !support.checkClone && rchecked.test( value ) ) ) {
6026 return collection.each( function( index ) {
6027 var self = collection.eq( index );
6029 args[ 0 ] = value.call( this, index, self.html() );
6031 domManip( self, args, callback, ignored );
6036 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
6037 first = fragment.firstChild;
6039 if ( fragment.childNodes.length === 1 ) {
6043 // Require either new content or an interest in ignored elements to invoke the callback
6044 if ( first || ignored ) {
6045 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6046 hasScripts = scripts.length;
6048 // Use the original fragment for the last item
6049 // instead of the first because it can end up
6050 // being emptied incorrectly in certain situations (#8070).
6051 for ( ; i < l; i++ ) {
6054 if ( i !== iNoClone ) {
6055 node = jQuery.clone( node, true, true );
6057 // Keep references to cloned scripts for later restoration
6060 // Support: Android<4.1, PhantomJS<2
6061 // push.apply(_, arraylike) throws on ancient WebKit
6062 jQuery.merge( scripts, getAll( node, "script" ) );
6066 callback.call( collection[ i ], node, i );
6070 doc = scripts[ scripts.length - 1 ].ownerDocument;
6073 jQuery.map( scripts, restoreScript );
6075 // Evaluate executable scripts on first document insertion
6076 for ( i = 0; i < hasScripts; i++ ) {
6077 node = scripts[ i ];
6078 if ( rscriptType.test( node.type || "" ) &&
6079 !jQuery._data( node, "globalEval" ) &&
6080 jQuery.contains( doc, node ) ) {
6084 // Optional AJAX dependency, but won't run scripts if not present
6085 if ( jQuery._evalUrl ) {
6086 jQuery._evalUrl( node.src );
6090 ( node.text || node.textContent || node.innerHTML || "" )
6091 .replace( rcleanScript, "" )
6098 // Fix #11809: Avoid leaking memory
6099 fragment = first = null;
6106 function remove( elem, selector, keepData ) {
6108 elems = selector ? jQuery.filter( selector, elem ) : elem,
6111 for ( ; ( node = elems[ i ] ) != null; i++ ) {
6113 if ( !keepData && node.nodeType === 1 ) {
6114 jQuery.cleanData( getAll( node ) );
6117 if ( node.parentNode ) {
6118 if ( keepData && jQuery.contains( node.ownerDocument, node ) ) {
6119 setGlobalEval( getAll( node, "script" ) );
6121 node.parentNode.removeChild( node );
6129 htmlPrefilter: function( html ) {
6130 return html.replace( rxhtmlTag, "<$1></$2>" );
6133 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6134 var destElements, node, clone, i, srcElements,
6135 inPage = jQuery.contains( elem.ownerDocument, elem );
6137 if ( support.html5Clone || jQuery.isXMLDoc( elem ) ||
6138 !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6140 clone = elem.cloneNode( true );
6142 // IE<=8 does not properly clone detached, unknown element nodes
6144 fragmentDiv.innerHTML = elem.outerHTML;
6145 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6148 if ( ( !support.noCloneEvent || !support.noCloneChecked ) &&
6149 ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
6151 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
6152 destElements = getAll( clone );
6153 srcElements = getAll( elem );
6155 // Fix all IE cloning issues
6156 for ( i = 0; ( node = srcElements[ i ] ) != null; ++i ) {
6158 // Ensure that the destination node is not null; Fixes #9587
6159 if ( destElements[ i ] ) {
6160 fixCloneNodeIssues( node, destElements[ i ] );
6165 // Copy the events from the original to the clone
6166 if ( dataAndEvents ) {
6167 if ( deepDataAndEvents ) {
6168 srcElements = srcElements || getAll( elem );
6169 destElements = destElements || getAll( clone );
6171 for ( i = 0; ( node = srcElements[ i ] ) != null; i++ ) {
6172 cloneCopyEvent( node, destElements[ i ] );
6175 cloneCopyEvent( elem, clone );
6179 // Preserve script evaluation history
6180 destElements = getAll( clone, "script" );
6181 if ( destElements.length > 0 ) {
6182 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6185 destElements = srcElements = node = null;
6187 // Return the cloned set
6191 cleanData: function( elems, /* internal */ forceAcceptData ) {
6192 var elem, type, id, data,
6194 internalKey = jQuery.expando,
6195 cache = jQuery.cache,
6196 attributes = support.attributes,
6197 special = jQuery.event.special;
6199 for ( ; ( elem = elems[ i ] ) != null; i++ ) {
6200 if ( forceAcceptData || acceptData( elem ) ) {
6202 id = elem[ internalKey ];
6203 data = id && cache[ id ];
6206 if ( data.events ) {
6207 for ( type in data.events ) {
6208 if ( special[ type ] ) {
6209 jQuery.event.remove( elem, type );
6211 // This is a shortcut to avoid jQuery.event.remove's overhead
6213 jQuery.removeEvent( elem, type, data.handle );
6218 // Remove cache only if it was not already removed by jQuery.event.remove
6219 if ( cache[ id ] ) {
6224 // IE does not allow us to delete expando properties from nodes
6225 // IE creates expando attributes along with the property
6226 // IE does not have a removeAttribute function on Document nodes
6227 if ( !attributes && typeof elem.removeAttribute !== "undefined" ) {
6228 elem.removeAttribute( internalKey );
6230 // Webkit & Blink performance suffers when deleting properties
6231 // from DOM nodes, so set to undefined instead
6232 // https://code.google.com/p/chromium/issues/detail?id=378607
6234 elem[ internalKey ] = undefined;
6237 deletedIds.push( id );
6247 // Keep domManip exposed until 3.0 (gh-2225)
6250 detach: function( selector ) {
6251 return remove( this, selector, true );
6254 remove: function( selector ) {
6255 return remove( this, selector );
6258 text: function( value ) {
6259 return access( this, function( value ) {
6260 return value === undefined ?
6261 jQuery.text( this ) :
6262 this.empty().append(
6263 ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value )
6265 }, null, value, arguments.length );
6268 append: function() {
6269 return domManip( this, arguments, function( elem ) {
6270 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6271 var target = manipulationTarget( this, elem );
6272 target.appendChild( elem );
6277 prepend: function() {
6278 return domManip( this, arguments, function( elem ) {
6279 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6280 var target = manipulationTarget( this, elem );
6281 target.insertBefore( elem, target.firstChild );
6286 before: function() {
6287 return domManip( this, arguments, function( elem ) {
6288 if ( this.parentNode ) {
6289 this.parentNode.insertBefore( elem, this );
6295 return domManip( this, arguments, function( elem ) {
6296 if ( this.parentNode ) {
6297 this.parentNode.insertBefore( elem, this.nextSibling );
6306 for ( ; ( elem = this[ i ] ) != null; i++ ) {
6308 // Remove element nodes and prevent memory leaks
6309 if ( elem.nodeType === 1 ) {
6310 jQuery.cleanData( getAll( elem, false ) );
6313 // Remove any remaining nodes
6314 while ( elem.firstChild ) {
6315 elem.removeChild( elem.firstChild );
6318 // If this is a select, ensure that it displays empty (#12336)
6320 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
6321 elem.options.length = 0;
6328 clone: function( dataAndEvents, deepDataAndEvents ) {
6329 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6330 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6332 return this.map( function() {
6333 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6337 html: function( value ) {
6338 return access( this, function( value ) {
6339 var elem = this[ 0 ] || {},
6343 if ( value === undefined ) {
6344 return elem.nodeType === 1 ?
6345 elem.innerHTML.replace( rinlinejQuery, "" ) :
6349 // See if we can take a shortcut and just use innerHTML
6350 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6351 ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
6352 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
6353 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
6355 value = jQuery.htmlPrefilter( value );
6358 for ( ; i < l; i++ ) {
6360 // Remove element nodes and prevent memory leaks
6361 elem = this[ i ] || {};
6362 if ( elem.nodeType === 1 ) {
6363 jQuery.cleanData( getAll( elem, false ) );
6364 elem.innerHTML = value;
6370 // If using innerHTML throws an exception, use the fallback method
6375 this.empty().append( value );
6377 }, null, value, arguments.length );
6380 replaceWith: function() {
6383 // Make the changes, replacing each non-ignored context element with the new content
6384 return domManip( this, arguments, function( elem ) {
6385 var parent = this.parentNode;
6387 if ( jQuery.inArray( this, ignored ) < 0 ) {
6388 jQuery.cleanData( getAll( this ) );
6390 parent.replaceChild( elem, this );
6394 // Force callback invocation
6401 prependTo: "prepend",
6402 insertBefore: "before",
6403 insertAfter: "after",
6404 replaceAll: "replaceWith"
6405 }, function( name, original ) {
6406 jQuery.fn[ name ] = function( selector ) {
6410 insert = jQuery( selector ),
6411 last = insert.length - 1;
6413 for ( ; i <= last; i++ ) {
6414 elems = i === last ? this : this.clone( true );
6415 jQuery( insert[ i ] )[ original ]( elems );
6417 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
6418 push.apply( ret, elems.get() );
6421 return this.pushStack( ret );
6430 // We have to pre-define these values for FF (#10227)
6436 * Retrieve the actual display of a element
6437 * @param {String} name nodeName of the element
6438 * @param {Object} doc Document object
6441 // Called only from within defaultDisplay
6442 function actualDisplay( name, doc ) {
6443 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
6445 display = jQuery.css( elem[ 0 ], "display" );
6447 // We don't have any data stored on the element,
6448 // so use "detach" method as fast way to get rid of the element
6455 * Try to determine the default display value of an element
6456 * @param {String} nodeName
6458 function defaultDisplay( nodeName ) {
6460 display = elemdisplay[ nodeName ];
6463 display = actualDisplay( nodeName, doc );
6465 // If the simple way fails, read from inside an iframe
6466 if ( display === "none" || !display ) {
6468 // Use the already-created iframe if possible
6469 iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
6470 .appendTo( doc.documentElement );
6472 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
6473 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
6479 display = actualDisplay( nodeName, doc );
6483 // Store the correct default display
6484 elemdisplay[ nodeName ] = display;
6489 var rmargin = ( /^margin/ );
6491 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6493 var swap = function( elem, options, callback, args ) {
6497 // Remember the old values, and insert the new ones
6498 for ( name in options ) {
6499 old[ name ] = elem.style[ name ];
6500 elem.style[ name ] = options[ name ];
6503 ret = callback.apply( elem, args || [] );
6505 // Revert the old values
6506 for ( name in options ) {
6507 elem.style[ name ] = old[ name ];
6514 var documentElement = document.documentElement;
6519 var pixelPositionVal, pixelMarginRightVal, boxSizingReliableVal,
6520 reliableHiddenOffsetsVal, reliableMarginRightVal, reliableMarginLeftVal,
6521 container = document.createElement( "div" ),
6522 div = document.createElement( "div" );
6524 // Finish early in limited (non-browser) environments
6529 div.style.cssText = "float:left;opacity:.5";
6532 // Make sure that element opacity exists (as opposed to filter)
6533 support.opacity = div.style.opacity === "0.5";
6535 // Verify style float existence
6536 // (IE uses styleFloat instead of cssFloat)
6537 support.cssFloat = !!div.style.cssFloat;
6539 div.style.backgroundClip = "content-box";
6540 div.cloneNode( true ).style.backgroundClip = "";
6541 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6543 container = document.createElement( "div" );
6544 container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" +
6545 "padding:0;margin-top:1px;position:absolute";
6547 container.appendChild( div );
6549 // Support: Firefox<29, Android 2.3
6550 // Vendor-prefix box-sizing
6551 support.boxSizing = div.style.boxSizing === "" || div.style.MozBoxSizing === "" ||
6552 div.style.WebkitBoxSizing === "";
6554 jQuery.extend( support, {
6555 reliableHiddenOffsets: function() {
6556 if ( pixelPositionVal == null ) {
6557 computeStyleTests();
6559 return reliableHiddenOffsetsVal;
6562 boxSizingReliable: function() {
6564 // We're checking for pixelPositionVal here instead of boxSizingReliableVal
6565 // since that compresses better and they're computed together anyway.
6566 if ( pixelPositionVal == null ) {
6567 computeStyleTests();
6569 return boxSizingReliableVal;
6572 pixelMarginRight: function() {
6574 // Support: Android 4.0-4.3
6575 if ( pixelPositionVal == null ) {
6576 computeStyleTests();
6578 return pixelMarginRightVal;
6581 pixelPosition: function() {
6582 if ( pixelPositionVal == null ) {
6583 computeStyleTests();
6585 return pixelPositionVal;
6588 reliableMarginRight: function() {
6590 // Support: Android 2.3
6591 if ( pixelPositionVal == null ) {
6592 computeStyleTests();
6594 return reliableMarginRightVal;
6597 reliableMarginLeft: function() {
6599 // Support: IE <=8 only, Android 4.0 - 4.3 only, Firefox <=3 - 37
6600 if ( pixelPositionVal == null ) {
6601 computeStyleTests();
6603 return reliableMarginLeftVal;
6607 function computeStyleTests() {
6608 var contents, divStyle,
6609 documentElement = document.documentElement;
6612 documentElement.appendChild( container );
6616 // Support: Android 2.3
6617 // Vendor-prefix box-sizing
6618 "-webkit-box-sizing:border-box;box-sizing:border-box;" +
6619 "position:relative;display:block;" +
6620 "margin:auto;border:1px;padding:1px;" +
6624 // Assume reasonable values in the absence of getComputedStyle
6625 pixelPositionVal = boxSizingReliableVal = reliableMarginLeftVal = false;
6626 pixelMarginRightVal = reliableMarginRightVal = true;
6628 // Check for getComputedStyle so that this code is not run in IE<9.
6629 if ( window.getComputedStyle ) {
6630 divStyle = window.getComputedStyle( div );
6631 pixelPositionVal = ( divStyle || {} ).top !== "1%";
6632 reliableMarginLeftVal = ( divStyle || {} ).marginLeft === "2px";
6633 boxSizingReliableVal = ( divStyle || { width: "4px" } ).width === "4px";
6635 // Support: Android 4.0 - 4.3 only
6636 // Some styles come back with percentage values, even though they shouldn't
6637 div.style.marginRight = "50%";
6638 pixelMarginRightVal = ( divStyle || { marginRight: "4px" } ).marginRight === "4px";
6640 // Support: Android 2.3 only
6641 // Div with explicit width and no margin-right incorrectly
6642 // gets computed margin-right based on width of container (#3333)
6643 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6644 contents = div.appendChild( document.createElement( "div" ) );
6646 // Reset CSS: box-sizing; display; margin; border; padding
6647 contents.style.cssText = div.style.cssText =
6649 // Support: Android 2.3
6650 // Vendor-prefix box-sizing
6651 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
6652 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
6653 contents.style.marginRight = contents.style.width = "0";
6654 div.style.width = "1px";
6656 reliableMarginRightVal =
6657 !parseFloat( ( window.getComputedStyle( contents ) || {} ).marginRight );
6659 div.removeChild( contents );
6663 // First check that getClientRects works as expected
6664 // Check if table cells still have offsetWidth/Height when they are set
6665 // to display:none and there are still other visible table cells in a
6666 // table row; if so, offsetWidth/Height are not reliable for use when
6667 // determining if an element has been hidden directly using
6668 // display:none (it is still safe to use offsets if a parent element is
6669 // hidden; don safety goggles and see bug #4512 for more information).
6670 div.style.display = "none";
6671 reliableHiddenOffsetsVal = div.getClientRects().length === 0;
6672 if ( reliableHiddenOffsetsVal ) {
6673 div.style.display = "";
6674 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
6675 div.childNodes[ 0 ].style.borderCollapse = "separate";
6676 contents = div.getElementsByTagName( "td" );
6677 contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
6678 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
6679 if ( reliableHiddenOffsetsVal ) {
6680 contents[ 0 ].style.display = "";
6681 contents[ 1 ].style.display = "none";
6682 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
6687 documentElement.removeChild( container );
6693 var getStyles, curCSS,
6694 rposition = /^(top|right|bottom|left)$/;
6696 if ( window.getComputedStyle ) {
6697 getStyles = function( elem ) {
6699 // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
6700 // IE throws on elements created in popups
6701 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6702 var view = elem.ownerDocument.defaultView;
6704 if ( !view || !view.opener ) {
6708 return view.getComputedStyle( elem );
6711 curCSS = function( elem, name, computed ) {
6712 var width, minWidth, maxWidth, ret,
6715 computed = computed || getStyles( elem );
6717 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6718 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
6720 // Support: Opera 12.1x only
6721 // Fall back to style even without computed
6722 // computed is undefined for elems on document fragments
6723 if ( ( ret === "" || ret === undefined ) && !jQuery.contains( elem.ownerDocument, elem ) ) {
6724 ret = jQuery.style( elem, name );
6729 // A tribute to the "awesome hack by Dean Edwards"
6730 // Chrome < 17 and Safari 5.0 uses "computed value"
6731 // instead of "used value" for margin-right
6732 // Safari 5.1.7 (at least) returns percentage for a larger set of values,
6733 // but width seems to be reliably pixels
6734 // this is against the CSSOM draft spec:
6735 // http://dev.w3.org/csswg/cssom/#resolved-values
6736 if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6738 // Remember the original values
6739 width = style.width;
6740 minWidth = style.minWidth;
6741 maxWidth = style.maxWidth;
6743 // Put in the new values to get a computed value out
6744 style.minWidth = style.maxWidth = style.width = ret;
6745 ret = computed.width;
6747 // Revert the changed values
6748 style.width = width;
6749 style.minWidth = minWidth;
6750 style.maxWidth = maxWidth;
6755 // IE returns zIndex value as an integer.
6756 return ret === undefined ?
6760 } else if ( documentElement.currentStyle ) {
6761 getStyles = function( elem ) {
6762 return elem.currentStyle;
6765 curCSS = function( elem, name, computed ) {
6766 var left, rs, rsLeft, ret,
6769 computed = computed || getStyles( elem );
6770 ret = computed ? computed[ name ] : undefined;
6772 // Avoid setting ret to empty string here
6773 // so we don't default to auto
6774 if ( ret == null && style && style[ name ] ) {
6775 ret = style[ name ];
6778 // From the awesome hack by Dean Edwards
6779 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6781 // If we're not dealing with a regular pixel number
6782 // but a number that has a weird ending, we need to convert it to pixels
6783 // but not position css attributes, as those are
6784 // proportional to the parent element instead
6785 // and we can't measure the parent instead because it
6786 // might trigger a "stacking dolls" problem
6787 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6789 // Remember the original values
6791 rs = elem.runtimeStyle;
6792 rsLeft = rs && rs.left;
6794 // Put in the new values to get a computed value out
6796 rs.left = elem.currentStyle.left;
6798 style.left = name === "fontSize" ? "1em" : ret;
6799 ret = style.pixelLeft + "px";
6801 // Revert the changed values
6809 // IE returns zIndex value as an integer.
6810 return ret === undefined ?
6819 function addGetHookIf( conditionFn, hookFn ) {
6821 // Define the hook, we'll check on the first run if it's really needed.
6824 if ( conditionFn() ) {
6826 // Hook not needed (or it's not possible to use it due
6827 // to missing dependency), remove it.
6832 // Hook needed; redefine it so that the support test is not executed again.
6833 return ( this.get = hookFn ).apply( this, arguments );
6841 ralpha = /alpha\([^)]*\)/i,
6842 ropacity = /opacity\s*=\s*([^)]*)/i,
6844 // swappable if display is none or starts with table except
6845 // "table", "table-cell", or "table-caption"
6846 // see here for display values:
6847 // https://developer.mozilla.org/en-US/docs/CSS/display
6848 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6849 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
6851 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6852 cssNormalTransform = {
6857 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
6858 emptyStyle = document.createElement( "div" ).style;
6861 // return a css property mapped to a potentially vendor prefixed property
6862 function vendorPropName( name ) {
6864 // shortcut for names that are not vendor prefixed
6865 if ( name in emptyStyle ) {
6869 // check for vendor prefixed names
6870 var capName = name.charAt( 0 ).toUpperCase() + name.slice( 1 ),
6871 i = cssPrefixes.length;
6874 name = cssPrefixes[ i ] + capName;
6875 if ( name in emptyStyle ) {
6881 function showHide( elements, show ) {
6882 var display, elem, hidden,
6885 length = elements.length;
6887 for ( ; index < length; index++ ) {
6888 elem = elements[ index ];
6889 if ( !elem.style ) {
6893 values[ index ] = jQuery._data( elem, "olddisplay" );
6894 display = elem.style.display;
6897 // Reset the inline display of this element to learn if it is
6898 // being hidden by cascaded rules or not
6899 if ( !values[ index ] && display === "none" ) {
6900 elem.style.display = "";
6903 // Set elements which have been overridden with display: none
6904 // in a stylesheet to whatever the default browser style is
6905 // for such an element
6906 if ( elem.style.display === "" && isHidden( elem ) ) {
6908 jQuery._data( elem, "olddisplay", defaultDisplay( elem.nodeName ) );
6911 hidden = isHidden( elem );
6913 if ( display && display !== "none" || !hidden ) {
6917 hidden ? display : jQuery.css( elem, "display" )
6923 // Set the display of most of the elements in a second loop
6924 // to avoid the constant reflow
6925 for ( index = 0; index < length; index++ ) {
6926 elem = elements[ index ];
6927 if ( !elem.style ) {
6930 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6931 elem.style.display = show ? values[ index ] || "" : "none";
6938 function setPositiveNumber( elem, value, subtract ) {
6939 var matches = rnumsplit.exec( value );
6942 // Guard against undefined "subtract", e.g., when used as in cssHooks
6943 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6947 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
6948 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6950 // If we already have the right measurement, avoid augmentation
6953 // Otherwise initialize for horizontal or vertical properties
6954 name === "width" ? 1 : 0,
6958 for ( ; i < 4; i += 2 ) {
6960 // both box models exclude margin, so add it if we want it
6961 if ( extra === "margin" ) {
6962 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
6965 if ( isBorderBox ) {
6967 // border-box includes padding, so remove it if we want content
6968 if ( extra === "content" ) {
6969 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6972 // at this point, extra isn't border nor margin, so remove border
6973 if ( extra !== "margin" ) {
6974 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6978 // at this point, extra isn't content, so add padding
6979 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6981 // at this point, extra isn't content nor padding, so add border
6982 if ( extra !== "padding" ) {
6983 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6991 function getWidthOrHeight( elem, name, extra ) {
6993 // Start with offset property, which is equivalent to the border-box value
6994 var valueIsBorderBox = true,
6995 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6996 styles = getStyles( elem ),
6997 isBorderBox = support.boxSizing &&
6998 jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
7000 // some non-html elements return undefined for offsetWidth, so check for null/undefined
7001 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
7002 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
7003 if ( val <= 0 || val == null ) {
7005 // Fall back to computed then uncomputed css if necessary
7006 val = curCSS( elem, name, styles );
7007 if ( val < 0 || val == null ) {
7008 val = elem.style[ name ];
7011 // Computed unit is not pixels. Stop here and return.
7012 if ( rnumnonpx.test( val ) ) {
7016 // we need the check for style in case a browser which returns unreliable values
7017 // for getComputedStyle silently falls back to the reliable elem.style
7018 valueIsBorderBox = isBorderBox &&
7019 ( support.boxSizingReliable() || val === elem.style[ name ] );
7021 // Normalize "", auto, and prepare for extra
7022 val = parseFloat( val ) || 0;
7025 // use the active box-sizing model to add/subtract irrelevant styles
7027 augmentWidthOrHeight(
7030 extra || ( isBorderBox ? "border" : "content" ),
7039 // Add in style property hooks for overriding the default
7040 // behavior of getting and setting a style property
7043 get: function( elem, computed ) {
7046 // We should always get a number back from opacity
7047 var ret = curCSS( elem, "opacity" );
7048 return ret === "" ? "1" : ret;
7054 // Don't automatically add "px" to these possibly-unitless properties
7056 "animationIterationCount": true,
7057 "columnCount": true,
7058 "fillOpacity": true,
7071 // Add in properties whose names you wish to fix before
7072 // setting or getting the value
7075 // normalize float css property
7076 "float": support.cssFloat ? "cssFloat" : "styleFloat"
7079 // Get and set the style property on a DOM Node
7080 style: function( elem, name, value, extra ) {
7082 // Don't set styles on text and comment nodes
7083 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
7087 // Make sure that we're working with the right name
7088 var ret, type, hooks,
7089 origName = jQuery.camelCase( name ),
7092 name = jQuery.cssProps[ origName ] ||
7093 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
7095 // gets hook for the prefixed version
7096 // followed by the unprefixed version
7097 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7099 // Check if we're setting a value
7100 if ( value !== undefined ) {
7101 type = typeof value;
7103 // Convert "+=" or "-=" to relative numbers (#7345)
7104 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
7105 value = adjustCSS( elem, name, ret );
7111 // Make sure that null and NaN values aren't set. See: #7116
7112 if ( value == null || value !== value ) {
7116 // If a number was passed in, add the unit (except for certain CSS properties)
7117 if ( type === "number" ) {
7118 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
7121 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
7122 // but it would mean to define eight
7123 // (for every problematic property) identical functions
7124 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
7125 style[ name ] = "inherit";
7128 // If a hook was provided, use that value, otherwise just set the specified value
7129 if ( !hooks || !( "set" in hooks ) ||
7130 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
7133 // Swallow errors from 'invalid' CSS values (#5509)
7135 style[ name ] = value;
7141 // If a hook was provided get the non-computed value from there
7142 if ( hooks && "get" in hooks &&
7143 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
7148 // Otherwise just get the value from the style object
7149 return style[ name ];
7153 css: function( elem, name, extra, styles ) {
7154 var num, val, hooks,
7155 origName = jQuery.camelCase( name );
7157 // Make sure that we're working with the right name
7158 name = jQuery.cssProps[ origName ] ||
7159 ( jQuery.cssProps[ origName ] = vendorPropName( origName ) || origName );
7161 // gets hook for the prefixed version
7162 // followed by the unprefixed version
7163 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7165 // If a hook was provided get the computed value from there
7166 if ( hooks && "get" in hooks ) {
7167 val = hooks.get( elem, true, extra );
7170 // Otherwise, if a way to get the computed value exists, use that
7171 if ( val === undefined ) {
7172 val = curCSS( elem, name, styles );
7175 //convert "normal" to computed value
7176 if ( val === "normal" && name in cssNormalTransform ) {
7177 val = cssNormalTransform[ name ];
7180 // Return, converting to number if forced or a qualifier was provided and val looks numeric
7181 if ( extra === "" || extra ) {
7182 num = parseFloat( val );
7183 return extra === true || isFinite( num ) ? num || 0 : val;
7189 jQuery.each( [ "height", "width" ], function( i, name ) {
7190 jQuery.cssHooks[ name ] = {
7191 get: function( elem, computed, extra ) {
7194 // certain elements can have dimension info if we invisibly show them
7195 // however, it must have a current display style that would benefit from this
7196 return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
7197 elem.offsetWidth === 0 ?
7198 swap( elem, cssShow, function() {
7199 return getWidthOrHeight( elem, name, extra );
7201 getWidthOrHeight( elem, name, extra );
7205 set: function( elem, value, extra ) {
7206 var styles = extra && getStyles( elem );
7207 return setPositiveNumber( elem, value, extra ?
7208 augmentWidthOrHeight(
7212 support.boxSizing &&
7213 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
7221 if ( !support.opacity ) {
7222 jQuery.cssHooks.opacity = {
7223 get: function( elem, computed ) {
7225 // IE uses filters for opacity
7226 return ropacity.test( ( computed && elem.currentStyle ?
7227 elem.currentStyle.filter :
7228 elem.style.filter ) || "" ) ?
7229 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7230 computed ? "1" : "";
7233 set: function( elem, value ) {
7234 var style = elem.style,
7235 currentStyle = elem.currentStyle,
7236 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7237 filter = currentStyle && currentStyle.filter || style.filter || "";
7239 // IE has trouble with opacity if it does not have layout
7240 // Force it by setting the zoom level
7243 // if setting opacity to 1, and no other filters exist -
7244 // attempt to remove filter attribute #6652
7245 // if value === "", then remove inline opacity #12685
7246 if ( ( value >= 1 || value === "" ) &&
7247 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7248 style.removeAttribute ) {
7250 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7251 // if "filter:" is present at all, clearType is disabled, we want to avoid this
7252 // style.removeAttribute is IE Only, but so apparently is this code path...
7253 style.removeAttribute( "filter" );
7255 // if there is no filter style applied in a css rule
7256 // or unset inline opacity, we are done
7257 if ( value === "" || currentStyle && !currentStyle.filter ) {
7262 // otherwise, set new filter values
7263 style.filter = ralpha.test( filter ) ?
7264 filter.replace( ralpha, opacity ) :
7265 filter + " " + opacity;
7270 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
7271 function( elem, computed ) {
7273 return swap( elem, { "display": "inline-block" },
7274 curCSS, [ elem, "marginRight" ] );
7279 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
7280 function( elem, computed ) {
7283 parseFloat( curCSS( elem, "marginLeft" ) ) ||
7286 // Running getBoundingClientRect on a disconnected node in IE throws an error
7287 // Support: IE8 only
7288 // getClientRects() errors on disconnected elems
7289 ( jQuery.contains( elem.ownerDocument, elem ) ?
7290 elem.getBoundingClientRect().left -
7291 swap( elem, { marginLeft: 0 }, function() {
7292 return elem.getBoundingClientRect().left;
7301 // These hooks are used by animate to expand properties
7306 }, function( prefix, suffix ) {
7307 jQuery.cssHooks[ prefix + suffix ] = {
7308 expand: function( value ) {
7312 // assumes a single number if not a string
7313 parts = typeof value === "string" ? value.split( " " ) : [ value ];
7315 for ( ; i < 4; i++ ) {
7316 expanded[ prefix + cssExpand[ i ] + suffix ] =
7317 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7324 if ( !rmargin.test( prefix ) ) {
7325 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7330 css: function( name, value ) {
7331 return access( this, function( elem, name, value ) {
7336 if ( jQuery.isArray( name ) ) {
7337 styles = getStyles( elem );
7340 for ( ; i < len; i++ ) {
7341 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
7347 return value !== undefined ?
7348 jQuery.style( elem, name, value ) :
7349 jQuery.css( elem, name );
7350 }, name, value, arguments.length > 1 );
7353 return showHide( this, true );
7356 return showHide( this );
7358 toggle: function( state ) {
7359 if ( typeof state === "boolean" ) {
7360 return state ? this.show() : this.hide();
7363 return this.each( function() {
7364 if ( isHidden( this ) ) {
7365 jQuery( this ).show();
7367 jQuery( this ).hide();
7374 function Tween( elem, options, prop, end, easing ) {
7375 return new Tween.prototype.init( elem, options, prop, end, easing );
7377 jQuery.Tween = Tween;
7381 init: function( elem, options, prop, end, easing, unit ) {
7384 this.easing = easing || jQuery.easing._default;
7385 this.options = options;
7386 this.start = this.now = this.cur();
7388 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
7391 var hooks = Tween.propHooks[ this.prop ];
7393 return hooks && hooks.get ?
7395 Tween.propHooks._default.get( this );
7397 run: function( percent ) {
7399 hooks = Tween.propHooks[ this.prop ];
7401 if ( this.options.duration ) {
7402 this.pos = eased = jQuery.easing[ this.easing ](
7403 percent, this.options.duration * percent, 0, 1, this.options.duration
7406 this.pos = eased = percent;
7408 this.now = ( this.end - this.start ) * eased + this.start;
7410 if ( this.options.step ) {
7411 this.options.step.call( this.elem, this.now, this );
7414 if ( hooks && hooks.set ) {
7417 Tween.propHooks._default.set( this );
7423 Tween.prototype.init.prototype = Tween.prototype;
7427 get: function( tween ) {
7430 // Use a property on the element directly when it is not a DOM element,
7431 // or when there is no matching style property that exists.
7432 if ( tween.elem.nodeType !== 1 ||
7433 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
7434 return tween.elem[ tween.prop ];
7437 // passing an empty string as a 3rd parameter to .css will automatically
7438 // attempt a parseFloat and fallback to a string if the parse fails
7439 // so, simple values such as "10px" are parsed to Float.
7440 // complex values such as "rotate(1rad)" are returned as is.
7441 result = jQuery.css( tween.elem, tween.prop, "" );
7443 // Empty strings, null, undefined and "auto" are converted to 0.
7444 return !result || result === "auto" ? 0 : result;
7446 set: function( tween ) {
7448 // use step hook for back compat - use cssHook if its there - use .style if its
7449 // available and use plain properties where available
7450 if ( jQuery.fx.step[ tween.prop ] ) {
7451 jQuery.fx.step[ tween.prop ]( tween );
7452 } else if ( tween.elem.nodeType === 1 &&
7453 ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null ||
7454 jQuery.cssHooks[ tween.prop ] ) ) {
7455 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
7457 tween.elem[ tween.prop ] = tween.now;
7464 // Panic based approach to setting things on disconnected nodes
7466 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
7467 set: function( tween ) {
7468 if ( tween.elem.nodeType && tween.elem.parentNode ) {
7469 tween.elem[ tween.prop ] = tween.now;
7475 linear: function( p ) {
7478 swing: function( p ) {
7479 return 0.5 - Math.cos( p * Math.PI ) / 2;
7484 jQuery.fx = Tween.prototype.init;
7486 // Back Compat <1.8 extension point
7487 jQuery.fx.step = {};
7494 rfxtypes = /^(?:toggle|show|hide)$/,
7495 rrun = /queueHooks$/;
7497 // Animations created synchronously will run synchronously
7498 function createFxNow() {
7499 window.setTimeout( function() {
7502 return ( fxNow = jQuery.now() );
7505 // Generate parameters to create a standard animation
7506 function genFx( type, includeWidth ) {
7508 attrs = { height: type },
7511 // if we include width, step value is 1 to do all cssExpand values,
7512 // if we don't include width, step value is 2 to skip over Left and Right
7513 includeWidth = includeWidth ? 1 : 0;
7514 for ( ; i < 4 ; i += 2 - includeWidth ) {
7515 which = cssExpand[ i ];
7516 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
7519 if ( includeWidth ) {
7520 attrs.opacity = attrs.width = type;
7526 function createTween( value, prop, animation ) {
7528 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
7530 length = collection.length;
7531 for ( ; index < length; index++ ) {
7532 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
7534 // we're done with this property
7540 function defaultPrefilter( elem, props, opts ) {
7541 /* jshint validthis: true */
7542 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
7546 hidden = elem.nodeType && isHidden( elem ),
7547 dataShow = jQuery._data( elem, "fxshow" );
7549 // handle queue: false promises
7550 if ( !opts.queue ) {
7551 hooks = jQuery._queueHooks( elem, "fx" );
7552 if ( hooks.unqueued == null ) {
7554 oldfire = hooks.empty.fire;
7555 hooks.empty.fire = function() {
7556 if ( !hooks.unqueued ) {
7563 anim.always( function() {
7565 // doing this makes sure that the complete handler will be called
7566 // before this completes
7567 anim.always( function() {
7569 if ( !jQuery.queue( elem, "fx" ).length ) {
7576 // height/width overflow pass
7577 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
7579 // Make sure that nothing sneaks out
7580 // Record all 3 overflow attributes because IE does not
7581 // change the overflow attribute when overflowX and
7582 // overflowY are set to the same value
7583 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
7585 // Set display property to inline-block for height/width
7586 // animations on inline elements that are having width/height animated
7587 display = jQuery.css( elem, "display" );
7589 // Test default display if display is currently "none"
7590 checkDisplay = display === "none" ?
7591 jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
7593 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
7595 // inline-level elements accept inline-block;
7596 // block-level elements need to be inline with layout
7597 if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
7598 style.display = "inline-block";
7605 if ( opts.overflow ) {
7606 style.overflow = "hidden";
7607 if ( !support.shrinkWrapBlocks() ) {
7608 anim.always( function() {
7609 style.overflow = opts.overflow[ 0 ];
7610 style.overflowX = opts.overflow[ 1 ];
7611 style.overflowY = opts.overflow[ 2 ];
7617 for ( prop in props ) {
7618 value = props[ prop ];
7619 if ( rfxtypes.exec( value ) ) {
7620 delete props[ prop ];
7621 toggle = toggle || value === "toggle";
7622 if ( value === ( hidden ? "hide" : "show" ) ) {
7624 // If there is dataShow left over from a stopped hide or show
7625 // and we are going to proceed with show, we should pretend to be hidden
7626 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
7632 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
7634 // Any non-fx value stops us from restoring the original display value
7636 display = undefined;
7640 if ( !jQuery.isEmptyObject( orig ) ) {
7642 if ( "hidden" in dataShow ) {
7643 hidden = dataShow.hidden;
7646 dataShow = jQuery._data( elem, "fxshow", {} );
7649 // store state if its toggle - enables .stop().toggle() to "reverse"
7651 dataShow.hidden = !hidden;
7654 jQuery( elem ).show();
7656 anim.done( function() {
7657 jQuery( elem ).hide();
7660 anim.done( function() {
7662 jQuery._removeData( elem, "fxshow" );
7663 for ( prop in orig ) {
7664 jQuery.style( elem, prop, orig[ prop ] );
7667 for ( prop in orig ) {
7668 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
7670 if ( !( prop in dataShow ) ) {
7671 dataShow[ prop ] = tween.start;
7673 tween.end = tween.start;
7674 tween.start = prop === "width" || prop === "height" ? 1 : 0;
7679 // If this is a noop like .hide().hide(), restore an overwritten display value
7680 } else if ( ( display === "none" ? defaultDisplay( elem.nodeName ) : display ) === "inline" ) {
7681 style.display = display;
7685 function propFilter( props, specialEasing ) {
7686 var index, name, easing, value, hooks;
7688 // camelCase, specialEasing and expand cssHook pass
7689 for ( index in props ) {
7690 name = jQuery.camelCase( index );
7691 easing = specialEasing[ name ];
7692 value = props[ index ];
7693 if ( jQuery.isArray( value ) ) {
7694 easing = value[ 1 ];
7695 value = props[ index ] = value[ 0 ];
7698 if ( index !== name ) {
7699 props[ name ] = value;
7700 delete props[ index ];
7703 hooks = jQuery.cssHooks[ name ];
7704 if ( hooks && "expand" in hooks ) {
7705 value = hooks.expand( value );
7706 delete props[ name ];
7708 // not quite $.extend, this wont overwrite keys already present.
7709 // also - reusing 'index' from above because we have the correct "name"
7710 for ( index in value ) {
7711 if ( !( index in props ) ) {
7712 props[ index ] = value[ index ];
7713 specialEasing[ index ] = easing;
7717 specialEasing[ name ] = easing;
7722 function Animation( elem, properties, options ) {
7726 length = Animation.prefilters.length,
7727 deferred = jQuery.Deferred().always( function() {
7729 // don't match elem in the :animated selector
7736 var currentTime = fxNow || createFxNow(),
7737 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7739 // Support: Android 2.3
7740 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
7741 temp = remaining / animation.duration || 0,
7744 length = animation.tweens.length;
7746 for ( ; index < length ; index++ ) {
7747 animation.tweens[ index ].run( percent );
7750 deferred.notifyWith( elem, [ animation, percent, remaining ] );
7752 if ( percent < 1 && length ) {
7755 deferred.resolveWith( elem, [ animation ] );
7759 animation = deferred.promise( {
7761 props: jQuery.extend( {}, properties ),
7762 opts: jQuery.extend( true, {
7764 easing: jQuery.easing._default
7766 originalProperties: properties,
7767 originalOptions: options,
7768 startTime: fxNow || createFxNow(),
7769 duration: options.duration,
7771 createTween: function( prop, end ) {
7772 var tween = jQuery.Tween( elem, animation.opts, prop, end,
7773 animation.opts.specialEasing[ prop ] || animation.opts.easing );
7774 animation.tweens.push( tween );
7777 stop: function( gotoEnd ) {
7780 // if we are going to the end, we want to run all the tweens
7781 // otherwise we skip this part
7782 length = gotoEnd ? animation.tweens.length : 0;
7787 for ( ; index < length ; index++ ) {
7788 animation.tweens[ index ].run( 1 );
7791 // resolve when we played the last frame
7792 // otherwise, reject
7794 deferred.notifyWith( elem, [ animation, 1, 0 ] );
7795 deferred.resolveWith( elem, [ animation, gotoEnd ] );
7797 deferred.rejectWith( elem, [ animation, gotoEnd ] );
7802 props = animation.props;
7804 propFilter( props, animation.opts.specialEasing );
7806 for ( ; index < length ; index++ ) {
7807 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
7809 if ( jQuery.isFunction( result.stop ) ) {
7810 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
7811 jQuery.proxy( result.stop, result );
7817 jQuery.map( props, createTween, animation );
7819 if ( jQuery.isFunction( animation.opts.start ) ) {
7820 animation.opts.start.call( elem, animation );
7824 jQuery.extend( tick, {
7827 queue: animation.opts.queue
7831 // attach callbacks from options
7832 return animation.progress( animation.opts.progress )
7833 .done( animation.opts.done, animation.opts.complete )
7834 .fail( animation.opts.fail )
7835 .always( animation.opts.always );
7838 jQuery.Animation = jQuery.extend( Animation, {
7841 "*": [ function( prop, value ) {
7842 var tween = this.createTween( prop, value );
7843 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
7848 tweener: function( props, callback ) {
7849 if ( jQuery.isFunction( props ) ) {
7853 props = props.match( rnotwhite );
7858 length = props.length;
7860 for ( ; index < length ; index++ ) {
7861 prop = props[ index ];
7862 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
7863 Animation.tweeners[ prop ].unshift( callback );
7867 prefilters: [ defaultPrefilter ],
7869 prefilter: function( callback, prepend ) {
7871 Animation.prefilters.unshift( callback );
7873 Animation.prefilters.push( callback );
7878 jQuery.speed = function( speed, easing, fn ) {
7879 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7880 complete: fn || !fn && easing ||
7881 jQuery.isFunction( speed ) && speed,
7883 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
7886 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
7887 opt.duration in jQuery.fx.speeds ?
7888 jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
7890 // normalize opt.queue - true/undefined/null -> "fx"
7891 if ( opt.queue == null || opt.queue === true ) {
7896 opt.old = opt.complete;
7898 opt.complete = function() {
7899 if ( jQuery.isFunction( opt.old ) ) {
7900 opt.old.call( this );
7904 jQuery.dequeue( this, opt.queue );
7912 fadeTo: function( speed, to, easing, callback ) {
7914 // show any hidden elements after setting opacity to 0
7915 return this.filter( isHidden ).css( "opacity", 0 ).show()
7917 // animate to the value specified
7918 .end().animate( { opacity: to }, speed, easing, callback );
7920 animate: function( prop, speed, easing, callback ) {
7921 var empty = jQuery.isEmptyObject( prop ),
7922 optall = jQuery.speed( speed, easing, callback ),
7923 doAnimation = function() {
7925 // Operate on a copy of prop so per-property easing won't be lost
7926 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7928 // Empty animations, or finishing resolves immediately
7929 if ( empty || jQuery._data( this, "finish" ) ) {
7933 doAnimation.finish = doAnimation;
7935 return empty || optall.queue === false ?
7936 this.each( doAnimation ) :
7937 this.queue( optall.queue, doAnimation );
7939 stop: function( type, clearQueue, gotoEnd ) {
7940 var stopQueue = function( hooks ) {
7941 var stop = hooks.stop;
7946 if ( typeof type !== "string" ) {
7947 gotoEnd = clearQueue;
7951 if ( clearQueue && type !== false ) {
7952 this.queue( type || "fx", [] );
7955 return this.each( function() {
7957 index = type != null && type + "queueHooks",
7958 timers = jQuery.timers,
7959 data = jQuery._data( this );
7962 if ( data[ index ] && data[ index ].stop ) {
7963 stopQueue( data[ index ] );
7966 for ( index in data ) {
7967 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7968 stopQueue( data[ index ] );
7973 for ( index = timers.length; index--; ) {
7974 if ( timers[ index ].elem === this &&
7975 ( type == null || timers[ index ].queue === type ) ) {
7977 timers[ index ].anim.stop( gotoEnd );
7979 timers.splice( index, 1 );
7983 // start the next in the queue if the last step wasn't forced
7984 // timers currently will call their complete callbacks, which will dequeue
7985 // but only if they were gotoEnd
7986 if ( dequeue || !gotoEnd ) {
7987 jQuery.dequeue( this, type );
7991 finish: function( type ) {
7992 if ( type !== false ) {
7993 type = type || "fx";
7995 return this.each( function() {
7997 data = jQuery._data( this ),
7998 queue = data[ type + "queue" ],
7999 hooks = data[ type + "queueHooks" ],
8000 timers = jQuery.timers,
8001 length = queue ? queue.length : 0;
8003 // enable finishing flag on private data
8006 // empty the queue first
8007 jQuery.queue( this, type, [] );
8009 if ( hooks && hooks.stop ) {
8010 hooks.stop.call( this, true );
8013 // look for any active animations, and finish them
8014 for ( index = timers.length; index--; ) {
8015 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
8016 timers[ index ].anim.stop( true );
8017 timers.splice( index, 1 );
8021 // look for any animations in the old queue and finish them
8022 for ( index = 0; index < length; index++ ) {
8023 if ( queue[ index ] && queue[ index ].finish ) {
8024 queue[ index ].finish.call( this );
8028 // turn off finishing flag
8034 jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
8035 var cssFn = jQuery.fn[ name ];
8036 jQuery.fn[ name ] = function( speed, easing, callback ) {
8037 return speed == null || typeof speed === "boolean" ?
8038 cssFn.apply( this, arguments ) :
8039 this.animate( genFx( name, true ), speed, easing, callback );
8043 // Generate shortcuts for custom animations
8045 slideDown: genFx( "show" ),
8046 slideUp: genFx( "hide" ),
8047 slideToggle: genFx( "toggle" ),
8048 fadeIn: { opacity: "show" },
8049 fadeOut: { opacity: "hide" },
8050 fadeToggle: { opacity: "toggle" }
8051 }, function( name, props ) {
8052 jQuery.fn[ name ] = function( speed, easing, callback ) {
8053 return this.animate( props, speed, easing, callback );
8058 jQuery.fx.tick = function() {
8060 timers = jQuery.timers,
8063 fxNow = jQuery.now();
8065 for ( ; i < timers.length; i++ ) {
8066 timer = timers[ i ];
8068 // Checks the timer has not already been removed
8069 if ( !timer() && timers[ i ] === timer ) {
8070 timers.splice( i--, 1 );
8074 if ( !timers.length ) {
8080 jQuery.fx.timer = function( timer ) {
8081 jQuery.timers.push( timer );
8085 jQuery.timers.pop();
8089 jQuery.fx.interval = 13;
8091 jQuery.fx.start = function() {
8093 timerId = window.setInterval( jQuery.fx.tick, jQuery.fx.interval );
8097 jQuery.fx.stop = function() {
8098 window.clearInterval( timerId );
8102 jQuery.fx.speeds = {
8111 // Based off of the plugin by Clint Helfers, with permission.
8112 // http://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
8113 jQuery.fn.delay = function( time, type ) {
8114 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
8115 type = type || "fx";
8117 return this.queue( type, function( next, hooks ) {
8118 var timeout = window.setTimeout( next, time );
8119 hooks.stop = function() {
8120 window.clearTimeout( timeout );
8128 input = document.createElement( "input" ),
8129 div = document.createElement( "div" ),
8130 select = document.createElement( "select" ),
8131 opt = select.appendChild( document.createElement( "option" ) );
8134 div = document.createElement( "div" );
8135 div.setAttribute( "className", "t" );
8136 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
8137 a = div.getElementsByTagName( "a" )[ 0 ];
8139 // Support: Windows Web Apps (WWA)
8140 // `type` must use .setAttribute for WWA (#14901)
8141 input.setAttribute( "type", "checkbox" );
8142 div.appendChild( input );
8144 a = div.getElementsByTagName( "a" )[ 0 ];
8146 // First batch of tests.
8147 a.style.cssText = "top:1px";
8149 // Test setAttribute on camelCase class.
8150 // If it works, we need attrFixes when doing get/setAttribute (ie6/7)
8151 support.getSetAttribute = div.className !== "t";
8153 // Get the style information from getAttribute
8154 // (IE uses .cssText instead)
8155 support.style = /top/.test( a.getAttribute( "style" ) );
8157 // Make sure that URLs aren't manipulated
8158 // (IE normalizes it by default)
8159 support.hrefNormalized = a.getAttribute( "href" ) === "/a";
8161 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
8162 support.checkOn = !!input.value;
8164 // Make sure that a selected-by-default option has a working selected property.
8165 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
8166 support.optSelected = opt.selected;
8168 // Tests for enctype support on a form (#6743)
8169 support.enctype = !!document.createElement( "form" ).enctype;
8171 // Make sure that the options inside disabled selects aren't marked as disabled
8172 // (WebKit marks them as disabled)
8173 select.disabled = true;
8174 support.optDisabled = !opt.disabled;
8176 // Support: IE8 only
8177 // Check if we can trust getAttribute("value")
8178 input = document.createElement( "input" );
8179 input.setAttribute( "value", "" );
8180 support.input = input.getAttribute( "value" ) === "";
8182 // Check if an input maintains its value after becoming a radio
8184 input.setAttribute( "type", "radio" );
8185 support.radioValue = input.value === "t";
8189 var rreturn = /\r/g,
8190 rspaces = /[\x20\t\r\n\f]+/g;
8193 val: function( value ) {
8194 var hooks, ret, isFunction,
8197 if ( !arguments.length ) {
8199 hooks = jQuery.valHooks[ elem.type ] ||
8200 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
8205 ( ret = hooks.get( elem, "value" ) ) !== undefined
8212 return typeof ret === "string" ?
8214 // handle most common string cases
8215 ret.replace( rreturn, "" ) :
8217 // handle cases where value is null/undef or number
8218 ret == null ? "" : ret;
8224 isFunction = jQuery.isFunction( value );
8226 return this.each( function( i ) {
8229 if ( this.nodeType !== 1 ) {
8234 val = value.call( this, i, jQuery( this ).val() );
8239 // Treat null/undefined as ""; convert numbers to string
8240 if ( val == null ) {
8242 } else if ( typeof val === "number" ) {
8244 } else if ( jQuery.isArray( val ) ) {
8245 val = jQuery.map( val, function( value ) {
8246 return value == null ? "" : value + "";
8250 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
8252 // If set returns undefined, fall back to normal setting
8253 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
8263 get: function( elem ) {
8264 var val = jQuery.find.attr( elem, "value" );
8265 return val != null ?
8268 // Support: IE10-11+
8269 // option.text throws exceptions (#14686, #14858)
8270 // Strip and collapse whitespace
8271 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8272 jQuery.trim( jQuery.text( elem ) ).replace( rspaces, " " );
8276 get: function( elem ) {
8278 options = elem.options,
8279 index = elem.selectedIndex,
8280 one = elem.type === "select-one" || index < 0,
8281 values = one ? null : [],
8282 max = one ? index + 1 : options.length,
8287 // Loop through all the selected options
8288 for ( ; i < max; i++ ) {
8289 option = options[ i ];
8291 // oldIE doesn't update selected after form reset (#2551)
8292 if ( ( option.selected || i === index ) &&
8294 // Don't return options that are disabled or in a disabled optgroup
8295 ( support.optDisabled ?
8297 option.getAttribute( "disabled" ) === null ) &&
8298 ( !option.parentNode.disabled ||
8299 !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
8301 // Get the specific value for the option
8302 value = jQuery( option ).val();
8304 // We don't need an array for one selects
8309 // Multi-Selects return an array
8310 values.push( value );
8317 set: function( elem, value ) {
8318 var optionSet, option,
8319 options = elem.options,
8320 values = jQuery.makeArray( value ),
8324 option = options[ i ];
8326 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 ) {
8329 // When new option element is added to select box we need to
8330 // force reflow of newly added node in order to workaround delay
8331 // of initialization properties
8333 option.selected = optionSet = true;
8337 // Will be executed only in IE6
8338 option.scrollHeight;
8342 option.selected = false;
8346 // Force browsers to behave consistently when non-matching value is set
8348 elem.selectedIndex = -1;
8357 // Radios and checkboxes getter/setter
8358 jQuery.each( [ "radio", "checkbox" ], function() {
8359 jQuery.valHooks[ this ] = {
8360 set: function( elem, value ) {
8361 if ( jQuery.isArray( value ) ) {
8362 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
8366 if ( !support.checkOn ) {
8367 jQuery.valHooks[ this ].get = function( elem ) {
8368 return elem.getAttribute( "value" ) === null ? "on" : elem.value;
8376 var nodeHook, boolHook,
8377 attrHandle = jQuery.expr.attrHandle,
8378 ruseDefault = /^(?:checked|selected)$/i,
8379 getSetAttribute = support.getSetAttribute,
8380 getSetInput = support.input;
8383 attr: function( name, value ) {
8384 return access( this, jQuery.attr, name, value, arguments.length > 1 );
8387 removeAttr: function( name ) {
8388 return this.each( function() {
8389 jQuery.removeAttr( this, name );
8395 attr: function( elem, name, value ) {
8397 nType = elem.nodeType;
8399 // Don't get/set attributes on text, comment and attribute nodes
8400 if ( nType === 3 || nType === 8 || nType === 2 ) {
8404 // Fallback to prop when attributes are not supported
8405 if ( typeof elem.getAttribute === "undefined" ) {
8406 return jQuery.prop( elem, name, value );
8409 // All attributes are lowercase
8410 // Grab necessary hook if one is defined
8411 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
8412 name = name.toLowerCase();
8413 hooks = jQuery.attrHooks[ name ] ||
8414 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
8417 if ( value !== undefined ) {
8418 if ( value === null ) {
8419 jQuery.removeAttr( elem, name );
8423 if ( hooks && "set" in hooks &&
8424 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
8428 elem.setAttribute( name, value + "" );
8432 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
8436 ret = jQuery.find.attr( elem, name );
8438 // Non-existent attributes return null, we normalize to undefined
8439 return ret == null ? undefined : ret;
8444 set: function( elem, value ) {
8445 if ( !support.radioValue && value === "radio" &&
8446 jQuery.nodeName( elem, "input" ) ) {
8448 // Setting the type on a radio button after the value resets the value in IE8-9
8449 // Reset value to default in case type is set after value during creation
8450 var val = elem.value;
8451 elem.setAttribute( "type", value );
8461 removeAttr: function( elem, value ) {
8464 attrNames = value && value.match( rnotwhite );
8466 if ( attrNames && elem.nodeType === 1 ) {
8467 while ( ( name = attrNames[ i++ ] ) ) {
8468 propName = jQuery.propFix[ name ] || name;
8470 // Boolean attributes get special treatment (#10870)
8471 if ( jQuery.expr.match.bool.test( name ) ) {
8473 // Set corresponding property to false
8474 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8475 elem[ propName ] = false;
8478 // Also clear defaultChecked/defaultSelected (if appropriate)
8480 elem[ jQuery.camelCase( "default-" + name ) ] =
8481 elem[ propName ] = false;
8484 // See #9699 for explanation of this approach (setting first, then removal)
8486 jQuery.attr( elem, name, "" );
8489 elem.removeAttribute( getSetAttribute ? name : propName );
8495 // Hooks for boolean attributes
8497 set: function( elem, value, name ) {
8498 if ( value === false ) {
8500 // Remove boolean attributes when set to false
8501 jQuery.removeAttr( elem, name );
8502 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8504 // IE<8 needs the *property* name
8505 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
8510 // Use defaultChecked and defaultSelected for oldIE
8511 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
8517 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
8518 var getter = attrHandle[ name ] || jQuery.find.attr;
8520 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8521 attrHandle[ name ] = function( elem, name, isXML ) {
8525 // Avoid an infinite loop by temporarily removing this function from the getter
8526 handle = attrHandle[ name ];
8527 attrHandle[ name ] = ret;
8528 ret = getter( elem, name, isXML ) != null ?
8529 name.toLowerCase() :
8531 attrHandle[ name ] = handle;
8536 attrHandle[ name ] = function( elem, name, isXML ) {
8538 return elem[ jQuery.camelCase( "default-" + name ) ] ?
8539 name.toLowerCase() :
8546 // fix oldIE attroperties
8547 if ( !getSetInput || !getSetAttribute ) {
8548 jQuery.attrHooks.value = {
8549 set: function( elem, value, name ) {
8550 if ( jQuery.nodeName( elem, "input" ) ) {
8552 // Does not return so that setAttribute is also used
8553 elem.defaultValue = value;
8556 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
8557 return nodeHook && nodeHook.set( elem, value, name );
8563 // IE6/7 do not support getting/setting some attributes with get/setAttribute
8564 if ( !getSetAttribute ) {
8566 // Use this for any attribute in IE6/7
8567 // This fixes almost every IE6/7 issue
8569 set: function( elem, value, name ) {
8571 // Set the existing or create a new attribute node
8572 var ret = elem.getAttributeNode( name );
8574 elem.setAttributeNode(
8575 ( ret = elem.ownerDocument.createAttribute( name ) )
8579 ret.value = value += "";
8581 // Break association with cloned elements by also using setAttribute (#9646)
8582 if ( name === "value" || value === elem.getAttribute( name ) ) {
8588 // Some attributes are constructed with empty-string values when not defined
8589 attrHandle.id = attrHandle.name = attrHandle.coords =
8590 function( elem, name, isXML ) {
8593 return ( ret = elem.getAttributeNode( name ) ) && ret.value !== "" ?
8599 // Fixing value retrieval on a button requires this module
8600 jQuery.valHooks.button = {
8601 get: function( elem, name ) {
8602 var ret = elem.getAttributeNode( name );
8603 if ( ret && ret.specified ) {
8610 // Set contenteditable to false on removals(#10429)
8611 // Setting to empty string throws an error as an invalid value
8612 jQuery.attrHooks.contenteditable = {
8613 set: function( elem, value, name ) {
8614 nodeHook.set( elem, value === "" ? false : value, name );
8618 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
8619 // This is for removals
8620 jQuery.each( [ "width", "height" ], function( i, name ) {
8621 jQuery.attrHooks[ name ] = {
8622 set: function( elem, value ) {
8623 if ( value === "" ) {
8624 elem.setAttribute( name, "auto" );
8632 if ( !support.style ) {
8633 jQuery.attrHooks.style = {
8634 get: function( elem ) {
8636 // Return undefined in the case of empty string
8637 // Note: IE uppercases css property names, but if we were to .toLowerCase()
8638 // .cssText, that would destroy case sensitivity in URL's, like in "background"
8639 return elem.style.cssText || undefined;
8641 set: function( elem, value ) {
8642 return ( elem.style.cssText = value + "" );
8650 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
8651 rclickable = /^(?:a|area)$/i;
8654 prop: function( name, value ) {
8655 return access( this, jQuery.prop, name, value, arguments.length > 1 );
8658 removeProp: function( name ) {
8659 name = jQuery.propFix[ name ] || name;
8660 return this.each( function() {
8662 // try/catch handles cases where IE balks (such as removing a property on window)
8664 this[ name ] = undefined;
8665 delete this[ name ];
8672 prop: function( elem, name, value ) {
8674 nType = elem.nodeType;
8676 // Don't get/set properties on text, comment and attribute nodes
8677 if ( nType === 3 || nType === 8 || nType === 2 ) {
8681 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
8683 // Fix name and attach hooks
8684 name = jQuery.propFix[ name ] || name;
8685 hooks = jQuery.propHooks[ name ];
8688 if ( value !== undefined ) {
8689 if ( hooks && "set" in hooks &&
8690 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
8694 return ( elem[ name ] = value );
8697 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
8701 return elem[ name ];
8706 get: function( elem ) {
8708 // elem.tabIndex doesn't always return the
8709 // correct value when it hasn't been explicitly set
8710 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
8711 // Use proper attribute retrieval(#12072)
8712 var tabindex = jQuery.find.attr( elem, "tabindex" );
8715 parseInt( tabindex, 10 ) :
8716 rfocusable.test( elem.nodeName ) ||
8717 rclickable.test( elem.nodeName ) && elem.href ?
8726 "class": "className"
8730 // Some attributes require a special call on IE
8731 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
8732 if ( !support.hrefNormalized ) {
8734 // href/src property should get the full normalized URL (#10299/#12915)
8735 jQuery.each( [ "href", "src" ], function( i, name ) {
8736 jQuery.propHooks[ name ] = {
8737 get: function( elem ) {
8738 return elem.getAttribute( name, 4 );
8744 // Support: Safari, IE9+
8745 // Accessing the selectedIndex property
8746 // forces the browser to respect setting selected
8748 // The getter ensures a default option is selected
8749 // when in an optgroup
8750 if ( !support.optSelected ) {
8751 jQuery.propHooks.selected = {
8752 get: function( elem ) {
8753 var parent = elem.parentNode;
8756 parent.selectedIndex;
8758 // Make sure that it also works with optgroups, see #5701
8759 if ( parent.parentNode ) {
8760 parent.parentNode.selectedIndex;
8765 set: function( elem ) {
8766 var parent = elem.parentNode;
8768 parent.selectedIndex;
8770 if ( parent.parentNode ) {
8771 parent.parentNode.selectedIndex;
8790 jQuery.propFix[ this.toLowerCase() ] = this;
8793 // IE6/7 call enctype encoding
8794 if ( !support.enctype ) {
8795 jQuery.propFix.enctype = "encoding";
8801 var rclass = /[\t\r\n\f]/g;
8803 function getClass( elem ) {
8804 return jQuery.attr( elem, "class" ) || "";
8808 addClass: function( value ) {
8809 var classes, elem, cur, curValue, clazz, j, finalValue,
8812 if ( jQuery.isFunction( value ) ) {
8813 return this.each( function( j ) {
8814 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
8818 if ( typeof value === "string" && value ) {
8819 classes = value.match( rnotwhite ) || [];
8821 while ( ( elem = this[ i++ ] ) ) {
8822 curValue = getClass( elem );
8823 cur = elem.nodeType === 1 &&
8824 ( " " + curValue + " " ).replace( rclass, " " );
8828 while ( ( clazz = classes[ j++ ] ) ) {
8829 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
8834 // only assign if different to avoid unneeded rendering.
8835 finalValue = jQuery.trim( cur );
8836 if ( curValue !== finalValue ) {
8837 jQuery.attr( elem, "class", finalValue );
8846 removeClass: function( value ) {
8847 var classes, elem, cur, curValue, clazz, j, finalValue,
8850 if ( jQuery.isFunction( value ) ) {
8851 return this.each( function( j ) {
8852 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
8856 if ( !arguments.length ) {
8857 return this.attr( "class", "" );
8860 if ( typeof value === "string" && value ) {
8861 classes = value.match( rnotwhite ) || [];
8863 while ( ( elem = this[ i++ ] ) ) {
8864 curValue = getClass( elem );
8866 // This expression is here for better compressibility (see addClass)
8867 cur = elem.nodeType === 1 &&
8868 ( " " + curValue + " " ).replace( rclass, " " );
8872 while ( ( clazz = classes[ j++ ] ) ) {
8874 // Remove *all* instances
8875 while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
8876 cur = cur.replace( " " + clazz + " ", " " );
8880 // Only assign if different to avoid unneeded rendering.
8881 finalValue = jQuery.trim( cur );
8882 if ( curValue !== finalValue ) {
8883 jQuery.attr( elem, "class", finalValue );
8892 toggleClass: function( value, stateVal ) {
8893 var type = typeof value;
8895 if ( typeof stateVal === "boolean" && type === "string" ) {
8896 return stateVal ? this.addClass( value ) : this.removeClass( value );
8899 if ( jQuery.isFunction( value ) ) {
8900 return this.each( function( i ) {
8901 jQuery( this ).toggleClass(
8902 value.call( this, i, getClass( this ), stateVal ),
8908 return this.each( function() {
8909 var className, i, self, classNames;
8911 if ( type === "string" ) {
8913 // Toggle individual class names
8915 self = jQuery( this );
8916 classNames = value.match( rnotwhite ) || [];
8918 while ( ( className = classNames[ i++ ] ) ) {
8920 // Check each className given, space separated list
8921 if ( self.hasClass( className ) ) {
8922 self.removeClass( className );
8924 self.addClass( className );
8928 // Toggle whole class name
8929 } else if ( value === undefined || type === "boolean" ) {
8930 className = getClass( this );
8933 // store className if set
8934 jQuery._data( this, "__className__", className );
8937 // If the element has a class name or if we're passed "false",
8938 // then remove the whole classname (if there was one, the above saved it).
8939 // Otherwise bring back whatever was previously saved (if anything),
8940 // falling back to the empty string if nothing was stored.
8941 jQuery.attr( this, "class",
8942 className || value === false ?
8944 jQuery._data( this, "__className__" ) || ""
8950 hasClass: function( selector ) {
8951 var className, elem,
8954 className = " " + selector + " ";
8955 while ( ( elem = this[ i++ ] ) ) {
8956 if ( elem.nodeType === 1 &&
8957 ( " " + getClass( elem ) + " " ).replace( rclass, " " )
8958 .indexOf( className ) > -1
8971 // Return jQuery for attributes-only inclusion
8974 jQuery.each( ( "blur focus focusin focusout load resize scroll unload click dblclick " +
8975 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
8976 "change select submit keydown keypress keyup error contextmenu" ).split( " " ),
8977 function( i, name ) {
8979 // Handle event binding
8980 jQuery.fn[ name ] = function( data, fn ) {
8981 return arguments.length > 0 ?
8982 this.on( name, null, data, fn ) :
8983 this.trigger( name );
8988 hover: function( fnOver, fnOut ) {
8989 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
8994 var location = window.location;
8996 var nonce = jQuery.now();
8998 var rquery = ( /\?/ );
9002 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
9004 jQuery.parseJSON = function( data ) {
9006 // Attempt to parse using the native JSON parser first
9007 if ( window.JSON && window.JSON.parse ) {
9009 // Support: Android 2.3
9010 // Workaround failure to string-cast null input
9011 return window.JSON.parse( data + "" );
9014 var requireNonComma,
9016 str = jQuery.trim( data + "" );
9018 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
9019 // after removing valid tokens
9020 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
9022 // Force termination if we see a misplaced comma
9023 if ( requireNonComma && comma ) {
9027 // Perform no more replacements after returning to outermost depth
9028 if ( depth === 0 ) {
9032 // Commas must not follow "[", "{", or ","
9033 requireNonComma = open || comma;
9035 // Determine new depth
9036 // array/object open ("[" or "{"): depth += true - false (increment)
9037 // array/object close ("]" or "}"): depth += false - true (decrement)
9038 // other cases ("," or primitive): depth += true - true (numeric cast)
9039 depth += !close - !open;
9041 // Remove this token
9044 ( Function( "return " + str ) )() :
9045 jQuery.error( "Invalid JSON: " + data );
9049 // Cross-browser xml parsing
9050 jQuery.parseXML = function( data ) {
9052 if ( !data || typeof data !== "string" ) {
9056 if ( window.DOMParser ) { // Standard
9057 tmp = new window.DOMParser();
9058 xml = tmp.parseFromString( data, "text/xml" );
9060 xml = new window.ActiveXObject( "Microsoft.XMLDOM" );
9061 xml.async = "false";
9062 xml.loadXML( data );
9067 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
9068 jQuery.error( "Invalid XML: " + data );
9076 rts = /([?&])_=[^&]*/,
9078 // IE leaves an \r character at EOL
9079 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg,
9081 // #7653, #8125, #8152: local protocol detection
9082 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
9083 rnoContent = /^(?:GET|HEAD)$/,
9084 rprotocol = /^\/\//,
9085 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
9088 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
9089 * 2) These are called:
9090 * - BEFORE asking for a transport
9091 * - AFTER param serialization (s.data is a string if s.processData is true)
9092 * 3) key is the dataType
9093 * 4) the catchall symbol "*" can be used
9094 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
9098 /* Transports bindings
9099 * 1) key is the dataType
9100 * 2) the catchall symbol "*" can be used
9101 * 3) selection will start with transport dataType and THEN go to "*" if needed
9105 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
9106 allTypes = "*/".concat( "*" ),
9108 // Document location
9109 ajaxLocation = location.href,
9111 // Segment location into parts
9112 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
9114 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
9115 function addToPrefiltersOrTransports( structure ) {
9117 // dataTypeExpression is optional and defaults to "*"
9118 return function( dataTypeExpression, func ) {
9120 if ( typeof dataTypeExpression !== "string" ) {
9121 func = dataTypeExpression;
9122 dataTypeExpression = "*";
9127 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
9129 if ( jQuery.isFunction( func ) ) {
9131 // For each dataType in the dataTypeExpression
9132 while ( ( dataType = dataTypes[ i++ ] ) ) {
9134 // Prepend if requested
9135 if ( dataType.charAt( 0 ) === "+" ) {
9136 dataType = dataType.slice( 1 ) || "*";
9137 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
9141 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
9148 // Base inspection function for prefilters and transports
9149 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
9152 seekingTransport = ( structure === transports );
9154 function inspect( dataType ) {
9156 inspected[ dataType ] = true;
9157 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
9158 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
9159 if ( typeof dataTypeOrTransport === "string" &&
9160 !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
9162 options.dataTypes.unshift( dataTypeOrTransport );
9163 inspect( dataTypeOrTransport );
9165 } else if ( seekingTransport ) {
9166 return !( selected = dataTypeOrTransport );
9172 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
9175 // A special extend for ajax options
9176 // that takes "flat" options (not to be deep extended)
9178 function ajaxExtend( target, src ) {
9180 flatOptions = jQuery.ajaxSettings.flatOptions || {};
9182 for ( key in src ) {
9183 if ( src[ key ] !== undefined ) {
9184 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
9188 jQuery.extend( true, target, deep );
9194 /* Handles responses to an ajax request:
9195 * - finds the right dataType (mediates between content-type and expected dataType)
9196 * - returns the corresponding response
9198 function ajaxHandleResponses( s, jqXHR, responses ) {
9199 var firstDataType, ct, finalDataType, type,
9200 contents = s.contents,
9201 dataTypes = s.dataTypes;
9203 // Remove auto dataType and get content-type in the process
9204 while ( dataTypes[ 0 ] === "*" ) {
9206 if ( ct === undefined ) {
9207 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
9211 // Check if we're dealing with a known content-type
9213 for ( type in contents ) {
9214 if ( contents[ type ] && contents[ type ].test( ct ) ) {
9215 dataTypes.unshift( type );
9221 // Check to see if we have a response for the expected dataType
9222 if ( dataTypes[ 0 ] in responses ) {
9223 finalDataType = dataTypes[ 0 ];
9226 // Try convertible dataTypes
9227 for ( type in responses ) {
9228 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
9229 finalDataType = type;
9232 if ( !firstDataType ) {
9233 firstDataType = type;
9237 // Or just use first one
9238 finalDataType = finalDataType || firstDataType;
9241 // If we found a dataType
9242 // We add the dataType to the list if needed
9243 // and return the corresponding response
9244 if ( finalDataType ) {
9245 if ( finalDataType !== dataTypes[ 0 ] ) {
9246 dataTypes.unshift( finalDataType );
9248 return responses[ finalDataType ];
9252 /* Chain conversions given the request and the original response
9253 * Also sets the responseXXX fields on the jqXHR instance
9255 function ajaxConvert( s, response, jqXHR, isSuccess ) {
9256 var conv2, current, conv, tmp, prev,
9259 // Work with a copy of dataTypes in case we need to modify it for conversion
9260 dataTypes = s.dataTypes.slice();
9262 // Create converters map with lowercased keys
9263 if ( dataTypes[ 1 ] ) {
9264 for ( conv in s.converters ) {
9265 converters[ conv.toLowerCase() ] = s.converters[ conv ];
9269 current = dataTypes.shift();
9271 // Convert to each sequential dataType
9274 if ( s.responseFields[ current ] ) {
9275 jqXHR[ s.responseFields[ current ] ] = response;
9278 // Apply the dataFilter if provided
9279 if ( !prev && isSuccess && s.dataFilter ) {
9280 response = s.dataFilter( response, s.dataType );
9284 current = dataTypes.shift();
9288 // There's only work to do if current dataType is non-auto
9289 if ( current === "*" ) {
9293 // Convert response if prev dataType is non-auto and differs from current
9294 } else if ( prev !== "*" && prev !== current ) {
9296 // Seek a direct converter
9297 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
9299 // If none found, seek a pair
9301 for ( conv2 in converters ) {
9303 // If conv2 outputs current
9304 tmp = conv2.split( " " );
9305 if ( tmp[ 1 ] === current ) {
9307 // If prev can be converted to accepted input
9308 conv = converters[ prev + " " + tmp[ 0 ] ] ||
9309 converters[ "* " + tmp[ 0 ] ];
9312 // Condense equivalence converters
9313 if ( conv === true ) {
9314 conv = converters[ conv2 ];
9316 // Otherwise, insert the intermediate dataType
9317 } else if ( converters[ conv2 ] !== true ) {
9319 dataTypes.unshift( tmp[ 1 ] );
9327 // Apply converter (if not an equivalence)
9328 if ( conv !== true ) {
9330 // Unless errors are allowed to bubble, catch and return them
9331 if ( conv && s[ "throws" ] ) { // jscs:ignore requireDotNotation
9332 response = conv( response );
9335 response = conv( response );
9338 state: "parsererror",
9339 error: conv ? e : "No conversion from " + prev + " to " + current
9348 return { state: "success", data: response };
9353 // Counter for holding the number of active queries
9356 // Last-Modified header cache for next request
9363 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
9367 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
9384 xml: "application/xml, text/xml",
9385 json: "application/json, text/javascript"
9396 text: "responseText",
9397 json: "responseJSON"
9401 // Keys separate source (or catchall "*") and destination types with a single space
9404 // Convert anything to text
9407 // Text to html (true = no transformation)
9410 // Evaluate text as a json expression
9411 "text json": jQuery.parseJSON,
9413 // Parse text as xml
9414 "text xml": jQuery.parseXML
9417 // For options that shouldn't be deep extended:
9418 // you can add your own custom options here if
9419 // and when you create one that shouldn't be
9420 // deep extended (see ajaxExtend)
9427 // Creates a full fledged settings object into target
9428 // with both ajaxSettings and settings fields.
9429 // If target is omitted, writes into ajaxSettings.
9430 ajaxSetup: function( target, settings ) {
9433 // Building a settings object
9434 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
9436 // Extending ajaxSettings
9437 ajaxExtend( jQuery.ajaxSettings, target );
9440 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
9441 ajaxTransport: addToPrefiltersOrTransports( transports ),
9444 ajax: function( url, options ) {
9446 // If url is an object, simulate pre-1.5 signature
9447 if ( typeof url === "object" ) {
9452 // Force options to be an object
9453 options = options || {};
9457 // Cross-domain detection vars
9463 // URL without anti-cache param
9466 // Response headers as string
9467 responseHeadersString,
9472 // To know if global events are to be dispatched
9480 // Create the final options object
9481 s = jQuery.ajaxSetup( {}, options ),
9483 // Callbacks context
9484 callbackContext = s.context || s,
9486 // Context for global events is callbackContext if it is a DOM node or jQuery collection
9487 globalEventContext = s.context &&
9488 ( callbackContext.nodeType || callbackContext.jquery ) ?
9489 jQuery( callbackContext ) :
9493 deferred = jQuery.Deferred(),
9494 completeDeferred = jQuery.Callbacks( "once memory" ),
9496 // Status-dependent callbacks
9497 statusCode = s.statusCode || {},
9499 // Headers (they are sent all at once)
9500 requestHeaders = {},
9501 requestHeadersNames = {},
9506 // Default abort message
9507 strAbort = "canceled",
9513 // Builds headers hashtable if needed
9514 getResponseHeader: function( key ) {
9516 if ( state === 2 ) {
9517 if ( !responseHeaders ) {
9518 responseHeaders = {};
9519 while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
9520 responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
9523 match = responseHeaders[ key.toLowerCase() ];
9525 return match == null ? null : match;
9529 getAllResponseHeaders: function() {
9530 return state === 2 ? responseHeadersString : null;
9533 // Caches the header
9534 setRequestHeader: function( name, value ) {
9535 var lname = name.toLowerCase();
9537 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
9538 requestHeaders[ name ] = value;
9543 // Overrides response content-type header
9544 overrideMimeType: function( type ) {
9551 // Status-dependent callbacks
9552 statusCode: function( map ) {
9556 for ( code in map ) {
9558 // Lazy-add the new callback in a way that preserves old ones
9559 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
9563 // Execute the appropriate callbacks
9564 jqXHR.always( map[ jqXHR.status ] );
9570 // Cancel the request
9571 abort: function( statusText ) {
9572 var finalText = statusText || strAbort;
9574 transport.abort( finalText );
9576 done( 0, finalText );
9582 deferred.promise( jqXHR ).complete = completeDeferred.add;
9583 jqXHR.success = jqXHR.done;
9584 jqXHR.error = jqXHR.fail;
9586 // Remove hash character (#7531: and string promotion)
9587 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
9588 // Handle falsy url in the settings object (#10093: consistency with old signature)
9589 // We also use the url parameter if available
9590 s.url = ( ( url || s.url || ajaxLocation ) + "" )
9591 .replace( rhash, "" )
9592 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
9594 // Alias method option to type as per ticket #12004
9595 s.type = options.method || options.type || s.method || s.type;
9597 // Extract dataTypes list
9598 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
9600 // A cross-domain request is in order when we have a protocol:host:port mismatch
9601 if ( s.crossDomain == null ) {
9602 parts = rurl.exec( s.url.toLowerCase() );
9603 s.crossDomain = !!( parts &&
9604 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
9605 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
9606 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
9610 // Convert data if not already a string
9611 if ( s.data && s.processData && typeof s.data !== "string" ) {
9612 s.data = jQuery.param( s.data, s.traditional );
9616 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9618 // If request was aborted inside a prefilter, stop there
9619 if ( state === 2 ) {
9623 // We can fire global events as of now if asked to
9624 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9625 fireGlobals = jQuery.event && s.global;
9627 // Watch for a new set of requests
9628 if ( fireGlobals && jQuery.active++ === 0 ) {
9629 jQuery.event.trigger( "ajaxStart" );
9632 // Uppercase the type
9633 s.type = s.type.toUpperCase();
9635 // Determine if request has content
9636 s.hasContent = !rnoContent.test( s.type );
9638 // Save the URL in case we're toying with the If-Modified-Since
9639 // and/or If-None-Match header later on
9642 // More options handling for requests with no content
9643 if ( !s.hasContent ) {
9645 // If data is available, append data to url
9647 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
9649 // #9682: remove data so that it's not used in an eventual retry
9653 // Add anti-cache in url if needed
9654 if ( s.cache === false ) {
9655 s.url = rts.test( cacheURL ) ?
9657 // If there is already a '_' parameter, set its value
9658 cacheURL.replace( rts, "$1_=" + nonce++ ) :
9660 // Otherwise add one to the end
9661 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
9665 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9666 if ( s.ifModified ) {
9667 if ( jQuery.lastModified[ cacheURL ] ) {
9668 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9670 if ( jQuery.etag[ cacheURL ] ) {
9671 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9675 // Set the correct header, if data is being sent
9676 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9677 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9680 // Set the Accepts header for the server, depending on the dataType
9681 jqXHR.setRequestHeader(
9683 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
9684 s.accepts[ s.dataTypes[ 0 ] ] +
9685 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9689 // Check for headers option
9690 for ( i in s.headers ) {
9691 jqXHR.setRequestHeader( i, s.headers[ i ] );
9694 // Allow custom headers/mimetypes and early abort
9695 if ( s.beforeSend &&
9696 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
9698 // Abort if not done already and return
9699 return jqXHR.abort();
9702 // aborting is no longer a cancellation
9705 // Install callbacks on deferreds
9706 for ( i in { success: 1, error: 1, complete: 1 } ) {
9707 jqXHR[ i ]( s[ i ] );
9711 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9713 // If no transport, we auto-abort
9715 done( -1, "No Transport" );
9717 jqXHR.readyState = 1;
9719 // Send global event
9720 if ( fireGlobals ) {
9721 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9724 // If request was aborted inside ajaxSend, stop there
9725 if ( state === 2 ) {
9730 if ( s.async && s.timeout > 0 ) {
9731 timeoutTimer = window.setTimeout( function() {
9732 jqXHR.abort( "timeout" );
9738 transport.send( requestHeaders, done );
9741 // Propagate exception as error if not done
9745 // Simply rethrow otherwise
9752 // Callback for when everything is done
9753 function done( status, nativeStatusText, responses, headers ) {
9754 var isSuccess, success, error, response, modified,
9755 statusText = nativeStatusText;
9758 if ( state === 2 ) {
9762 // State is "done" now
9765 // Clear timeout if it exists
9766 if ( timeoutTimer ) {
9767 window.clearTimeout( timeoutTimer );
9770 // Dereference transport for early garbage collection
9771 // (no matter how long the jqXHR object will be used)
9772 transport = undefined;
9774 // Cache response headers
9775 responseHeadersString = headers || "";
9778 jqXHR.readyState = status > 0 ? 4 : 0;
9780 // Determine if successful
9781 isSuccess = status >= 200 && status < 300 || status === 304;
9783 // Get response data
9785 response = ajaxHandleResponses( s, jqXHR, responses );
9788 // Convert no matter what (that way responseXXX fields are always set)
9789 response = ajaxConvert( s, response, jqXHR, isSuccess );
9791 // If successful, handle type chaining
9794 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9795 if ( s.ifModified ) {
9796 modified = jqXHR.getResponseHeader( "Last-Modified" );
9798 jQuery.lastModified[ cacheURL ] = modified;
9800 modified = jqXHR.getResponseHeader( "etag" );
9802 jQuery.etag[ cacheURL ] = modified;
9807 if ( status === 204 || s.type === "HEAD" ) {
9808 statusText = "nocontent";
9811 } else if ( status === 304 ) {
9812 statusText = "notmodified";
9814 // If we have data, let's convert it
9816 statusText = response.state;
9817 success = response.data;
9818 error = response.error;
9823 // We extract error from statusText
9824 // then normalize statusText and status for non-aborts
9826 if ( status || !statusText ) {
9827 statusText = "error";
9834 // Set data for the fake xhr object
9835 jqXHR.status = status;
9836 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9840 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9842 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9845 // Status-dependent callbacks
9846 jqXHR.statusCode( statusCode );
9847 statusCode = undefined;
9849 if ( fireGlobals ) {
9850 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9851 [ jqXHR, s, isSuccess ? success : error ] );
9855 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9857 if ( fireGlobals ) {
9858 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9860 // Handle the global AJAX counter
9861 if ( !( --jQuery.active ) ) {
9862 jQuery.event.trigger( "ajaxStop" );
9870 getJSON: function( url, data, callback ) {
9871 return jQuery.get( url, data, callback, "json" );
9874 getScript: function( url, callback ) {
9875 return jQuery.get( url, undefined, callback, "script" );
9879 jQuery.each( [ "get", "post" ], function( i, method ) {
9880 jQuery[ method ] = function( url, data, callback, type ) {
9882 // shift arguments if data argument was omitted
9883 if ( jQuery.isFunction( data ) ) {
9884 type = type || callback;
9889 // The url can be an options object (which then must have .url)
9890 return jQuery.ajax( jQuery.extend( {
9896 }, jQuery.isPlainObject( url ) && url ) );
9901 jQuery._evalUrl = function( url ) {
9902 return jQuery.ajax( {
9905 // Make this explicit, since user can override this through ajaxSetup (#11264)
9917 wrapAll: function( html ) {
9918 if ( jQuery.isFunction( html ) ) {
9919 return this.each( function( i ) {
9920 jQuery( this ).wrapAll( html.call( this, i ) );
9926 // The elements to wrap the target around
9927 var wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
9929 if ( this[ 0 ].parentNode ) {
9930 wrap.insertBefore( this[ 0 ] );
9933 wrap.map( function() {
9936 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
9937 elem = elem.firstChild;
9947 wrapInner: function( html ) {
9948 if ( jQuery.isFunction( html ) ) {
9949 return this.each( function( i ) {
9950 jQuery( this ).wrapInner( html.call( this, i ) );
9954 return this.each( function() {
9955 var self = jQuery( this ),
9956 contents = self.contents();
9958 if ( contents.length ) {
9959 contents.wrapAll( html );
9962 self.append( html );
9967 wrap: function( html ) {
9968 var isFunction = jQuery.isFunction( html );
9970 return this.each( function( i ) {
9971 jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
9975 unwrap: function() {
9976 return this.parent().each( function() {
9977 if ( !jQuery.nodeName( this, "body" ) ) {
9978 jQuery( this ).replaceWith( this.childNodes );
9985 function getDisplay( elem ) {
9986 return elem.style && elem.style.display || jQuery.css( elem, "display" );
9989 function filterHidden( elem ) {
9991 // Disconnected elements are considered hidden
9992 if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
9995 while ( elem && elem.nodeType === 1 ) {
9996 if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
9999 elem = elem.parentNode;
10004 jQuery.expr.filters.hidden = function( elem ) {
10006 // Support: Opera <= 12.12
10007 // Opera reports offsetWidths and offsetHeights less than zero on some elements
10008 return support.reliableHiddenOffsets() ?
10009 ( elem.offsetWidth <= 0 && elem.offsetHeight <= 0 &&
10010 !elem.getClientRects().length ) :
10011 filterHidden( elem );
10014 jQuery.expr.filters.visible = function( elem ) {
10015 return !jQuery.expr.filters.hidden( elem );
10022 rbracket = /\[\]$/,
10024 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
10025 rsubmittable = /^(?:input|select|textarea|keygen)/i;
10027 function buildParams( prefix, obj, traditional, add ) {
10030 if ( jQuery.isArray( obj ) ) {
10032 // Serialize array item.
10033 jQuery.each( obj, function( i, v ) {
10034 if ( traditional || rbracket.test( prefix ) ) {
10036 // Treat each array item as a scalar.
10041 // Item is non-scalar (array or object), encode its numeric index.
10043 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
10051 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
10053 // Serialize object item.
10054 for ( name in obj ) {
10055 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
10060 // Serialize scalar item.
10061 add( prefix, obj );
10065 // Serialize an array of form elements or a set of
10066 // key/values into a query string
10067 jQuery.param = function( a, traditional ) {
10070 add = function( key, value ) {
10072 // If value is a function, invoke it and return its value
10073 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
10074 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
10077 // Set traditional to true for jQuery <= 1.3.2 behavior.
10078 if ( traditional === undefined ) {
10079 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
10082 // If an array was passed in, assume that it is an array of form elements.
10083 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
10085 // Serialize the form elements
10086 jQuery.each( a, function() {
10087 add( this.name, this.value );
10092 // If traditional, encode the "old" way (the way 1.3.2 or older
10093 // did it), otherwise encode params recursively.
10094 for ( prefix in a ) {
10095 buildParams( prefix, a[ prefix ], traditional, add );
10099 // Return the resulting serialization
10100 return s.join( "&" ).replace( r20, "+" );
10103 jQuery.fn.extend( {
10104 serialize: function() {
10105 return jQuery.param( this.serializeArray() );
10107 serializeArray: function() {
10108 return this.map( function() {
10110 // Can add propHook for "elements" to filter or add form elements
10111 var elements = jQuery.prop( this, "elements" );
10112 return elements ? jQuery.makeArray( elements ) : this;
10114 .filter( function() {
10115 var type = this.type;
10117 // Use .is(":disabled") so that fieldset[disabled] works
10118 return this.name && !jQuery( this ).is( ":disabled" ) &&
10119 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
10120 ( this.checked || !rcheckableType.test( type ) );
10122 .map( function( i, elem ) {
10123 var val = jQuery( this ).val();
10125 return val == null ?
10127 jQuery.isArray( val ) ?
10128 jQuery.map( val, function( val ) {
10129 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
10131 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
10137 // Create the request object
10138 // (This is still attached to ajaxSettings for backward compatibility)
10139 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
10141 // Support: IE6-IE8
10144 // XHR cannot access local files, always use ActiveX for that case
10145 if ( this.isLocal ) {
10146 return createActiveXHR();
10149 // Support: IE 9-11
10150 // IE seems to error on cross-domain PATCH requests when ActiveX XHR
10151 // is used. In IE 9+ always use the native XHR.
10152 // Note: this condition won't catch Edge as it doesn't define
10153 // document.documentMode but it also doesn't support ActiveX so it won't
10154 // reach this code.
10155 if ( document.documentMode > 8 ) {
10156 return createStandardXHR();
10160 // oldIE XHR does not support non-RFC2616 methods (#13240)
10161 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
10162 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
10163 // Although this check for six methods instead of eight
10164 // since IE also does not support "trace" and "connect"
10165 return /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
10166 createStandardXHR() || createActiveXHR();
10169 // For all other browsers, use the standard XMLHttpRequest object
10174 xhrSupported = jQuery.ajaxSettings.xhr();
10177 // Open requests must be manually aborted on unload (#5280)
10178 // See https://support.microsoft.com/kb/2856746 for more info
10179 if ( window.attachEvent ) {
10180 window.attachEvent( "onunload", function() {
10181 for ( var key in xhrCallbacks ) {
10182 xhrCallbacks[ key ]( undefined, true );
10187 // Determine support properties
10188 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
10189 xhrSupported = support.ajax = !!xhrSupported;
10191 // Create transport if the browser can provide an xhr
10192 if ( xhrSupported ) {
10194 jQuery.ajaxTransport( function( options ) {
10196 // Cross domain only allowed if supported through XMLHttpRequest
10197 if ( !options.crossDomain || support.cors ) {
10202 send: function( headers, complete ) {
10204 xhr = options.xhr(),
10216 // Apply custom fields if provided
10217 if ( options.xhrFields ) {
10218 for ( i in options.xhrFields ) {
10219 xhr[ i ] = options.xhrFields[ i ];
10223 // Override mime type if needed
10224 if ( options.mimeType && xhr.overrideMimeType ) {
10225 xhr.overrideMimeType( options.mimeType );
10228 // X-Requested-With header
10229 // For cross-domain requests, seeing as conditions for a preflight are
10230 // akin to a jigsaw puzzle, we simply never set it to be sure.
10231 // (it can always be set on a per-request basis or even using ajaxSetup)
10232 // For same-domain requests, won't change header if already provided.
10233 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
10234 headers[ "X-Requested-With" ] = "XMLHttpRequest";
10238 for ( i in headers ) {
10241 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
10242 // request header to a null-value.
10244 // To keep consistent with other XHR implementations, cast the value
10245 // to string and ignore `undefined`.
10246 if ( headers[ i ] !== undefined ) {
10247 xhr.setRequestHeader( i, headers[ i ] + "" );
10251 // Do send the request
10252 // This may raise an exception which is actually
10253 // handled in jQuery.ajax (so no try/catch here)
10254 xhr.send( ( options.hasContent && options.data ) || null );
10257 callback = function( _, isAbort ) {
10258 var status, statusText, responses;
10260 // Was never called and is aborted or complete
10261 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
10264 delete xhrCallbacks[ id ];
10265 callback = undefined;
10266 xhr.onreadystatechange = jQuery.noop;
10268 // Abort manually if needed
10270 if ( xhr.readyState !== 4 ) {
10275 status = xhr.status;
10278 // Accessing binary-data responseText throws an exception
10280 if ( typeof xhr.responseText === "string" ) {
10281 responses.text = xhr.responseText;
10284 // Firefox throws an exception when accessing
10285 // statusText for faulty cross-domain requests
10287 statusText = xhr.statusText;
10290 // We normalize with Webkit giving an empty statusText
10294 // Filter status for non standard behaviors
10296 // If the request is local and we have data: assume a success
10297 // (success with no data won't get notified, that's the best we
10298 // can do given current implementations)
10299 if ( !status && options.isLocal && !options.crossDomain ) {
10300 status = responses.text ? 200 : 404;
10302 // IE - #1450: sometimes returns 1223 when it should be 204
10303 } else if ( status === 1223 ) {
10309 // Call complete if needed
10311 complete( status, statusText, responses, xhr.getAllResponseHeaders() );
10315 // Do send the request
10316 // `xhr.send` may raise an exception, but it will be
10317 // handled in jQuery.ajax (so no try/catch here)
10318 if ( !options.async ) {
10320 // If we're in sync mode we fire the callback
10322 } else if ( xhr.readyState === 4 ) {
10324 // (IE6 & IE7) if it's in cache and has been
10325 // retrieved directly we need to fire the callback
10326 window.setTimeout( callback );
10329 // Register the callback, but delay it in case `xhr.send` throws
10330 // Add to the list of active xhr callbacks
10331 xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
10335 abort: function() {
10337 callback( undefined, true );
10345 // Functions to create xhrs
10346 function createStandardXHR() {
10348 return new window.XMLHttpRequest();
10352 function createActiveXHR() {
10354 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
10361 // Install script dataType
10362 jQuery.ajaxSetup( {
10364 script: "text/javascript, application/javascript, " +
10365 "application/ecmascript, application/x-ecmascript"
10368 script: /\b(?:java|ecma)script\b/
10371 "text script": function( text ) {
10372 jQuery.globalEval( text );
10378 // Handle cache's special case and global
10379 jQuery.ajaxPrefilter( "script", function( s ) {
10380 if ( s.cache === undefined ) {
10383 if ( s.crossDomain ) {
10389 // Bind script tag hack transport
10390 jQuery.ajaxTransport( "script", function( s ) {
10392 // This transport only deals with cross domain requests
10393 if ( s.crossDomain ) {
10396 head = document.head || jQuery( "head" )[ 0 ] || document.documentElement;
10400 send: function( _, callback ) {
10402 script = document.createElement( "script" );
10404 script.async = true;
10406 if ( s.scriptCharset ) {
10407 script.charset = s.scriptCharset;
10410 script.src = s.url;
10412 // Attach handlers for all browsers
10413 script.onload = script.onreadystatechange = function( _, isAbort ) {
10415 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
10417 // Handle memory leak in IE
10418 script.onload = script.onreadystatechange = null;
10420 // Remove the script
10421 if ( script.parentNode ) {
10422 script.parentNode.removeChild( script );
10425 // Dereference the script
10428 // Callback if not abort
10430 callback( 200, "success" );
10435 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
10436 // Use native DOM manipulation to avoid our domManip AJAX trickery
10437 head.insertBefore( script, head.firstChild );
10440 abort: function() {
10442 script.onload( undefined, true );
10452 var oldCallbacks = [],
10453 rjsonp = /(=)\?(?=&|$)|\?\?/;
10455 // Default jsonp settings
10456 jQuery.ajaxSetup( {
10458 jsonpCallback: function() {
10459 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
10460 this[ callback ] = true;
10465 // Detect, normalize options and install callbacks for jsonp requests
10466 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
10468 var callbackName, overwritten, responseContainer,
10469 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
10471 typeof s.data === "string" &&
10472 ( s.contentType || "" )
10473 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
10474 rjsonp.test( s.data ) && "data"
10477 // Handle iff the expected data type is "jsonp" or we have a parameter to set
10478 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
10480 // Get callback name, remembering preexisting value associated with it
10481 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
10482 s.jsonpCallback() :
10485 // Insert callback into url or form data
10487 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
10488 } else if ( s.jsonp !== false ) {
10489 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
10492 // Use data converter to retrieve json after script execution
10493 s.converters[ "script json" ] = function() {
10494 if ( !responseContainer ) {
10495 jQuery.error( callbackName + " was not called" );
10497 return responseContainer[ 0 ];
10500 // force json dataType
10501 s.dataTypes[ 0 ] = "json";
10503 // Install callback
10504 overwritten = window[ callbackName ];
10505 window[ callbackName ] = function() {
10506 responseContainer = arguments;
10509 // Clean-up function (fires after converters)
10510 jqXHR.always( function() {
10512 // If previous value didn't exist - remove it
10513 if ( overwritten === undefined ) {
10514 jQuery( window ).removeProp( callbackName );
10516 // Otherwise restore preexisting value
10518 window[ callbackName ] = overwritten;
10521 // Save back as free
10522 if ( s[ callbackName ] ) {
10524 // make sure that re-using the options doesn't screw things around
10525 s.jsonpCallback = originalSettings.jsonpCallback;
10527 // save the callback name for future use
10528 oldCallbacks.push( callbackName );
10531 // Call if it was a function and we have a response
10532 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
10533 overwritten( responseContainer[ 0 ] );
10536 responseContainer = overwritten = undefined;
10539 // Delegate to script
10547 // data: string of html
10548 // context (optional): If specified, the fragment will be created in this context,
10549 // defaults to document
10550 // keepScripts (optional): If true, will include scripts passed in the html string
10551 jQuery.parseHTML = function( data, context, keepScripts ) {
10552 if ( !data || typeof data !== "string" ) {
10555 if ( typeof context === "boolean" ) {
10556 keepScripts = context;
10559 context = context || document;
10561 var parsed = rsingleTag.exec( data ),
10562 scripts = !keepScripts && [];
10566 return [ context.createElement( parsed[ 1 ] ) ];
10569 parsed = buildFragment( [ data ], context, scripts );
10571 if ( scripts && scripts.length ) {
10572 jQuery( scripts ).remove();
10575 return jQuery.merge( [], parsed.childNodes );
10579 // Keep a copy of the old load method
10580 var _load = jQuery.fn.load;
10583 * Load a url into a page
10585 jQuery.fn.load = function( url, params, callback ) {
10586 if ( typeof url !== "string" && _load ) {
10587 return _load.apply( this, arguments );
10590 var selector, type, response,
10592 off = url.indexOf( " " );
10595 selector = jQuery.trim( url.slice( off, url.length ) );
10596 url = url.slice( 0, off );
10599 // If it's a function
10600 if ( jQuery.isFunction( params ) ) {
10602 // We assume that it's the callback
10604 params = undefined;
10606 // Otherwise, build a param string
10607 } else if ( params && typeof params === "object" ) {
10611 // If we have elements to modify, make the request
10612 if ( self.length > 0 ) {
10616 // If "type" variable is undefined, then "GET" method will be used.
10617 // Make value of this field explicit since
10618 // user can override it through ajaxSetup method
10619 type: type || "GET",
10622 } ).done( function( responseText ) {
10624 // Save response for use in complete callback
10625 response = arguments;
10627 self.html( selector ?
10629 // If a selector was specified, locate the right elements in a dummy div
10630 // Exclude scripts to avoid IE 'Permission Denied' errors
10631 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
10633 // Otherwise use the full result
10636 // If the request succeeds, this function gets "data", "status", "jqXHR"
10637 // but they are ignored because response was set above.
10638 // If it fails, this function gets "jqXHR", "status", "error"
10639 } ).always( callback && function( jqXHR, status ) {
10640 self.each( function() {
10641 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
10652 // Attach a bunch of functions for handling common AJAX events
10660 ], function( i, type ) {
10661 jQuery.fn[ type ] = function( fn ) {
10662 return this.on( type, fn );
10669 jQuery.expr.filters.animated = function( elem ) {
10670 return jQuery.grep( jQuery.timers, function( fn ) {
10671 return elem === fn.elem;
10680 * Gets a window from an element
10682 function getWindow( elem ) {
10683 return jQuery.isWindow( elem ) ?
10685 elem.nodeType === 9 ?
10686 elem.defaultView || elem.parentWindow :
10691 setOffset: function( elem, options, i ) {
10692 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
10693 position = jQuery.css( elem, "position" ),
10694 curElem = jQuery( elem ),
10697 // set position first, in-case top/left are set even on static elem
10698 if ( position === "static" ) {
10699 elem.style.position = "relative";
10702 curOffset = curElem.offset();
10703 curCSSTop = jQuery.css( elem, "top" );
10704 curCSSLeft = jQuery.css( elem, "left" );
10705 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
10706 jQuery.inArray( "auto", [ curCSSTop, curCSSLeft ] ) > -1;
10708 // need to be able to calculate position if either top or left
10709 // is auto and position is either absolute or fixed
10710 if ( calculatePosition ) {
10711 curPosition = curElem.position();
10712 curTop = curPosition.top;
10713 curLeft = curPosition.left;
10715 curTop = parseFloat( curCSSTop ) || 0;
10716 curLeft = parseFloat( curCSSLeft ) || 0;
10719 if ( jQuery.isFunction( options ) ) {
10721 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
10722 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
10725 if ( options.top != null ) {
10726 props.top = ( options.top - curOffset.top ) + curTop;
10728 if ( options.left != null ) {
10729 props.left = ( options.left - curOffset.left ) + curLeft;
10732 if ( "using" in options ) {
10733 options.using.call( elem, props );
10735 curElem.css( props );
10740 jQuery.fn.extend( {
10741 offset: function( options ) {
10742 if ( arguments.length ) {
10743 return options === undefined ?
10745 this.each( function( i ) {
10746 jQuery.offset.setOffset( this, options, i );
10751 box = { top: 0, left: 0 },
10753 doc = elem && elem.ownerDocument;
10759 docElem = doc.documentElement;
10761 // Make sure it's not a disconnected DOM node
10762 if ( !jQuery.contains( docElem, elem ) ) {
10766 // If we don't have gBCR, just use 0,0 rather than error
10767 // BlackBerry 5, iOS 3 (original iPhone)
10768 if ( typeof elem.getBoundingClientRect !== "undefined" ) {
10769 box = elem.getBoundingClientRect();
10771 win = getWindow( doc );
10773 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
10774 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
10778 position: function() {
10779 if ( !this[ 0 ] ) {
10783 var offsetParent, offset,
10784 parentOffset = { top: 0, left: 0 },
10787 // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
10788 // because it is its only offset parent
10789 if ( jQuery.css( elem, "position" ) === "fixed" ) {
10791 // we assume that getBoundingClientRect is available when computed position is fixed
10792 offset = elem.getBoundingClientRect();
10795 // Get *real* offsetParent
10796 offsetParent = this.offsetParent();
10798 // Get correct offsets
10799 offset = this.offset();
10800 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
10801 parentOffset = offsetParent.offset();
10804 // Add offsetParent borders
10805 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
10806 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
10809 // Subtract parent offsets and element margins
10810 // note: when an element has margin: auto the offsetLeft and marginLeft
10811 // are the same in Safari causing offset.left to incorrectly be 0
10813 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10814 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
10818 offsetParent: function() {
10819 return this.map( function() {
10820 var offsetParent = this.offsetParent;
10822 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
10823 jQuery.css( offsetParent, "position" ) === "static" ) ) {
10824 offsetParent = offsetParent.offsetParent;
10826 return offsetParent || documentElement;
10831 // Create scrollLeft and scrollTop methods
10832 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10833 var top = /Y/.test( prop );
10835 jQuery.fn[ method ] = function( val ) {
10836 return access( this, function( elem, method, val ) {
10837 var win = getWindow( elem );
10839 if ( val === undefined ) {
10840 return win ? ( prop in win ) ? win[ prop ] :
10841 win.document.documentElement[ method ] :
10847 !top ? val : jQuery( win ).scrollLeft(),
10848 top ? val : jQuery( win ).scrollTop()
10852 elem[ method ] = val;
10854 }, method, val, arguments.length, null );
10858 // Support: Safari<7-8+, Chrome<37-44+
10859 // Add the top/left cssHooks using jQuery.fn.position
10860 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10861 // getComputedStyle returns percent when specified for top/left/bottom/right
10862 // rather than make the css module depend on the offset module, we just check for it here
10863 jQuery.each( [ "top", "left" ], function( i, prop ) {
10864 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10865 function( elem, computed ) {
10867 computed = curCSS( elem, prop );
10869 // if curCSS returns percentage, fallback to offset
10870 return rnumnonpx.test( computed ) ?
10871 jQuery( elem ).position()[ prop ] + "px" :
10879 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10880 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10881 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
10882 function( defaultExtra, funcName ) {
10884 // margin is only for outerHeight, outerWidth
10885 jQuery.fn[ funcName ] = function( margin, value ) {
10886 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10887 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10889 return access( this, function( elem, type, value ) {
10892 if ( jQuery.isWindow( elem ) ) {
10894 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
10895 // isn't a whole lot we can do. See pull request at this URL for discussion:
10896 // https://github.com/jquery/jquery/pull/764
10897 return elem.document.documentElement[ "client" + name ];
10900 // Get document width or height
10901 if ( elem.nodeType === 9 ) {
10902 doc = elem.documentElement;
10904 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10905 // whichever is greatest
10906 // unfortunately, this causes bug #3838 in IE6/8 only,
10907 // but there is currently no good, small way to fix it.
10909 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10910 elem.body[ "offset" + name ], doc[ "offset" + name ],
10911 doc[ "client" + name ]
10915 return value === undefined ?
10917 // Get width or height on the element, requesting but not forcing parseFloat
10918 jQuery.css( elem, type, extra ) :
10920 // Set width or height on the element
10921 jQuery.style( elem, type, value, extra );
10922 }, type, chainable ? margin : undefined, chainable, null );
10928 jQuery.fn.extend( {
10930 bind: function( types, data, fn ) {
10931 return this.on( types, null, data, fn );
10933 unbind: function( types, fn ) {
10934 return this.off( types, null, fn );
10937 delegate: function( selector, types, data, fn ) {
10938 return this.on( types, selector, data, fn );
10940 undelegate: function( selector, types, fn ) {
10942 // ( namespace ) or ( selector, types [, fn] )
10943 return arguments.length === 1 ?
10944 this.off( selector, "**" ) :
10945 this.off( types, selector || "**", fn );
10949 // The number of elements contained in the matched element set
10950 jQuery.fn.size = function() {
10951 return this.length;
10954 jQuery.fn.andSelf = jQuery.fn.addBack;
10959 // Register as a named AMD module, since jQuery can be concatenated with other
10960 // files that may use define, but not via a proper concatenation script that
10961 // understands anonymous AMD modules. A named AMD is safest and most robust
10962 // way to register. Lowercase jquery is used because AMD module names are
10963 // derived from file names, and jQuery is normally delivered in a lowercase
10964 // file name. Do this after creating the global so that if an AMD module wants
10965 // to call noConflict to hide this version of jQuery, it will work.
10967 // Note that for maximum portability, libraries that are not jQuery should
10968 // declare themselves as anonymous modules, and avoid setting a global if an
10969 // AMD loader is present. jQuery is a special case. For more information, see
10970 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10972 if ( typeof define === "function" && define.amd ) {
10973 define( "jquery", [], function() {
10982 // Map over jQuery in case of overwrite
10983 _jQuery = window.jQuery,
10985 // Map over the $ in case of overwrite
10988 jQuery.noConflict = function( deep ) {
10989 if ( window.$ === jQuery ) {
10993 if ( deep && window.jQuery === jQuery ) {
10994 window.jQuery = _jQuery;
11000 // Expose jQuery and $ identifiers, even in
11001 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
11002 // and CommonJS for browser emulators (#13566)
11004 window.jQuery = window.$ = jQuery;