2 * jQuery JavaScript Library v1.11.3
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2015-04-28T16:19Z
15 (function( global, factory ) {
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper window is present,
19 // execute the factory and get jQuery
20 // For environments that do not inherently posses a window with a document
21 // (such as Node.js), expose a jQuery-making 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 // Can't do this because several apps including ASP.NET trace
41 // the stack via arguments.caller.callee and Firefox dies if
42 // you try to trace through "use strict" call chains. (#13335)
43 // Support: Firefox 18+
48 var slice = deletedIds.slice;
50 var concat = deletedIds.concat;
52 var push = deletedIds.push;
54 var indexOf = deletedIds.indexOf;
58 var toString = class2type.toString;
60 var hasOwn = class2type.hasOwnProperty;
69 // Define a local copy of jQuery
70 jQuery = function( selector, context ) {
71 // The jQuery object is actually just the init constructor 'enhanced'
72 // Need init if jQuery is called (just allow error to be thrown if not included)
73 return new jQuery.fn.init( selector, context );
76 // Support: Android<4.1, IE<9
77 // Make sure we trim BOM and NBSP
78 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
80 // Matches dashed string for camelizing
82 rdashAlpha = /-([\da-z])/gi,
84 // Used by jQuery.camelCase as callback to replace()
85 fcamelCase = function( all, letter ) {
86 return letter.toUpperCase();
89 jQuery.fn = jQuery.prototype = {
90 // The current version of jQuery being used
95 // Start with an empty selector
98 // The default length of a jQuery object is 0
101 toArray: function() {
102 return slice.call( this );
105 // Get the Nth element in the matched element set OR
106 // Get the whole matched element set as a clean array
107 get: function( num ) {
110 // Return just the one element from the set
111 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
113 // Return all the elements in a clean array
117 // Take an array of elements and push it onto the stack
118 // (returning the new matched element set)
119 pushStack: function( elems ) {
121 // Build a new jQuery matched element set
122 var ret = jQuery.merge( this.constructor(), elems );
124 // Add the old object onto the stack (as a reference)
125 ret.prevObject = this;
126 ret.context = this.context;
128 // Return the newly-formed element set
132 // Execute a callback for every element in the matched set.
133 // (You can seed the arguments with an array of args, but this is
134 // only used internally.)
135 each: function( callback, args ) {
136 return jQuery.each( this, callback, args );
139 map: function( callback ) {
140 return this.pushStack( jQuery.map(this, function( elem, i ) {
141 return callback.call( elem, i, elem );
146 return this.pushStack( slice.apply( this, arguments ) );
154 return this.eq( -1 );
158 var len = this.length,
159 j = +i + ( i < 0 ? len : 0 );
160 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
164 return this.prevObject || this.constructor(null);
167 // For internal use only.
168 // Behaves like an Array's method, not like a jQuery method.
170 sort: deletedIds.sort,
171 splice: deletedIds.splice
174 jQuery.extend = jQuery.fn.extend = function() {
175 var src, copyIsArray, copy, name, options, clone,
176 target = arguments[0] || {},
178 length = arguments.length,
181 // Handle a deep copy situation
182 if ( typeof target === "boolean" ) {
185 // skip the boolean and the target
186 target = arguments[ i ] || {};
190 // Handle case when target is a string or something (possible in deep copy)
191 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
195 // extend jQuery itself if only one argument is passed
196 if ( i === length ) {
201 for ( ; i < length; i++ ) {
202 // Only deal with non-null/undefined values
203 if ( (options = arguments[ i ]) != null ) {
204 // Extend the base object
205 for ( name in options ) {
206 src = target[ name ];
207 copy = options[ name ];
209 // Prevent never-ending loop
210 if ( target === copy ) {
214 // Recurse if we're merging plain objects or arrays
215 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
218 clone = src && jQuery.isArray(src) ? src : [];
221 clone = src && jQuery.isPlainObject(src) ? src : {};
224 // Never move original objects, clone them
225 target[ name ] = jQuery.extend( deep, clone, copy );
227 // Don't bring in undefined values
228 } else if ( copy !== undefined ) {
229 target[ name ] = copy;
235 // Return the modified object
240 // Unique for each copy of jQuery on the page
241 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
243 // Assume jQuery is ready without the ready module
246 error: function( msg ) {
247 throw new Error( msg );
252 // See test/unit/core.js for details concerning isFunction.
253 // Since version 1.3, DOM methods and functions like alert
254 // aren't supported. They return false on IE (#2968).
255 isFunction: function( obj ) {
256 return jQuery.type(obj) === "function";
259 isArray: Array.isArray || function( obj ) {
260 return jQuery.type(obj) === "array";
263 isWindow: function( obj ) {
264 /* jshint eqeqeq: false */
265 return obj != null && obj == obj.window;
268 isNumeric: function( obj ) {
269 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
270 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
271 // subtraction forces infinities to NaN
272 // adding 1 corrects loss of precision from parseFloat (#15100)
273 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
276 isEmptyObject: function( obj ) {
278 for ( name in obj ) {
284 isPlainObject: function( obj ) {
287 // Must be an Object.
288 // Because of IE, we also have to check the presence of the constructor property.
289 // Make sure that DOM nodes and window objects don't pass through, as well
290 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
295 // Not own constructor property must be Object
296 if ( obj.constructor &&
297 !hasOwn.call(obj, "constructor") &&
298 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
302 // IE8,9 Will throw exceptions on certain host objects #9897
307 // Handle iteration over inherited properties before own properties.
308 if ( support.ownLast ) {
310 return hasOwn.call( obj, key );
314 // Own properties are enumerated firstly, so to speed up,
315 // if last one is own, then all properties are own.
316 for ( key in obj ) {}
318 return key === undefined || hasOwn.call( obj, key );
321 type: function( obj ) {
325 return typeof obj === "object" || typeof obj === "function" ?
326 class2type[ toString.call(obj) ] || "object" :
330 // Evaluates a script in a global context
331 // Workarounds based on findings by Jim Driscoll
332 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
333 globalEval: function( data ) {
334 if ( data && jQuery.trim( data ) ) {
335 // We use execScript on Internet Explorer
336 // We use an anonymous function so that context is window
337 // rather than jQuery in Firefox
338 ( window.execScript || function( data ) {
339 window[ "eval" ].call( window, data );
344 // Convert dashed to camelCase; used by the css and data modules
345 // Microsoft forgot to hump their vendor prefix (#9572)
346 camelCase: function( string ) {
347 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
350 nodeName: function( elem, name ) {
351 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
354 // args is for internal usage only
355 each: function( obj, callback, args ) {
359 isArray = isArraylike( obj );
363 for ( ; i < length; i++ ) {
364 value = callback.apply( obj[ i ], args );
366 if ( value === false ) {
372 value = callback.apply( obj[ i ], args );
374 if ( value === false ) {
380 // A special, fast, case for the most common use of each
383 for ( ; i < length; i++ ) {
384 value = callback.call( obj[ i ], i, obj[ i ] );
386 if ( value === false ) {
392 value = callback.call( obj[ i ], i, obj[ i ] );
394 if ( value === false ) {
404 // Support: Android<4.1, IE<9
405 trim: function( text ) {
406 return text == null ?
408 ( text + "" ).replace( rtrim, "" );
411 // results is for internal usage only
412 makeArray: function( arr, results ) {
413 var ret = results || [];
416 if ( isArraylike( Object(arr) ) ) {
418 typeof arr === "string" ?
422 push.call( ret, arr );
429 inArray: function( elem, arr, i ) {
434 return indexOf.call( arr, elem, i );
438 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
440 for ( ; i < len; i++ ) {
441 // Skip accessing in sparse arrays
442 if ( i in arr && arr[ i ] === elem ) {
451 merge: function( first, second ) {
452 var len = +second.length,
457 first[ i++ ] = second[ j++ ];
461 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
463 while ( second[j] !== undefined ) {
464 first[ i++ ] = second[ j++ ];
473 grep: function( elems, callback, invert ) {
477 length = elems.length,
478 callbackExpect = !invert;
480 // Go through the array, only saving the items
481 // that pass the validator function
482 for ( ; i < length; i++ ) {
483 callbackInverse = !callback( elems[ i ], i );
484 if ( callbackInverse !== callbackExpect ) {
485 matches.push( elems[ i ] );
492 // arg is for internal usage only
493 map: function( elems, callback, arg ) {
496 length = elems.length,
497 isArray = isArraylike( elems ),
500 // Go through the array, translating each of the items to their new values
502 for ( ; i < length; i++ ) {
503 value = callback( elems[ i ], i, arg );
505 if ( value != null ) {
510 // Go through every key on the object,
513 value = callback( elems[ i ], i, arg );
515 if ( value != null ) {
521 // Flatten any nested arrays
522 return concat.apply( [], ret );
525 // A global GUID counter for objects
528 // Bind a function to a context, optionally partially applying any
530 proxy: function( fn, context ) {
531 var args, proxy, tmp;
533 if ( typeof context === "string" ) {
539 // Quick check to determine if target is callable, in the spec
540 // this throws a TypeError, but we will just return undefined.
541 if ( !jQuery.isFunction( fn ) ) {
546 args = slice.call( arguments, 2 );
548 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
551 // Set the guid of unique handler to the same of original handler, so it can be removed
552 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
558 return +( new Date() );
561 // jQuery.support is not used in Core but other projects attach their
562 // properties to it so it needs to exist.
566 // Populate the class2type map
567 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
568 class2type[ "[object " + name + "]" ] = name.toLowerCase();
571 function isArraylike( obj ) {
573 // Support: iOS 8.2 (not reproducible in simulator)
574 // `in` check used to prevent JIT error (gh-2145)
575 // hasOwn isn't used here due to false negatives
576 // regarding Nodelist length in IE
577 var length = "length" in obj && obj.length,
578 type = jQuery.type( obj );
580 if ( type === "function" || jQuery.isWindow( obj ) ) {
584 if ( obj.nodeType === 1 && length ) {
588 return type === "array" || length === 0 ||
589 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
593 * Sizzle CSS Selector Engine v2.2.0-pre
594 * http://sizzlejs.com/
596 * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
597 * Released under the MIT license
598 * http://jquery.org/license
602 (function( window ) {
616 // Local document vars
626 // Instance-specific data
627 expando = "sizzle" + 1 * new Date(),
628 preferredDoc = window.document,
631 classCache = createCache(),
632 tokenCache = createCache(),
633 compilerCache = createCache(),
634 sortOrder = function( a, b ) {
641 // General-purpose constants
642 MAX_NEGATIVE = 1 << 31,
645 hasOwn = ({}).hasOwnProperty,
648 push_native = arr.push,
651 // Use a stripped-down indexOf as it's faster than native
652 // http://jsperf.com/thor-indexof-vs-for/5
653 indexOf = function( list, elem ) {
656 for ( ; i < len; i++ ) {
657 if ( list[i] === elem ) {
664 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
666 // Regular expressions
668 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
669 whitespace = "[\\x20\\t\\r\\n\\f]",
670 // http://www.w3.org/TR/css3-syntax/#characters
671 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
673 // Loosely modeled on CSS identifier characters
674 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
675 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
676 identifier = characterEncoding.replace( "w", "w#" ),
678 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
679 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
680 // Operator (capture 2)
681 "*([*^$|!~]?=)" + whitespace +
682 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
683 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
686 pseudos = ":(" + characterEncoding + ")(?:\\((" +
687 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
688 // 1. quoted (capture 3; capture 4 or capture 5)
689 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
690 // 2. simple (capture 6)
691 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
692 // 3. anything else (capture 2)
696 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
697 rwhitespace = new RegExp( whitespace + "+", "g" ),
698 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
700 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
701 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
703 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
705 rpseudo = new RegExp( pseudos ),
706 ridentifier = new RegExp( "^" + identifier + "$" ),
709 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
710 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
711 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
712 "ATTR": new RegExp( "^" + attributes ),
713 "PSEUDO": new RegExp( "^" + pseudos ),
714 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
715 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
716 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
717 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
718 // For use in libraries implementing .is()
719 // We use this for POS matching in `select`
720 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
721 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
724 rinputs = /^(?:input|select|textarea|button)$/i,
727 rnative = /^[^{]+\{\s*\[native \w/,
729 // Easily-parseable/retrievable ID or TAG or CLASS selectors
730 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
735 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
736 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
737 funescape = function( _, escaped, escapedWhitespace ) {
738 var high = "0x" + escaped - 0x10000;
739 // NaN means non-codepoint
740 // Support: Firefox<24
741 // Workaround erroneous numeric interpretation of +"0x"
742 return high !== high || escapedWhitespace ?
746 String.fromCharCode( high + 0x10000 ) :
747 // Supplemental Plane codepoint (surrogate pair)
748 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
753 // Removing the function wrapper causes a "Permission Denied"
755 unloadHandler = function() {
759 // Optimize for push.apply( _, NodeList )
762 (arr = slice.call( preferredDoc.childNodes )),
763 preferredDoc.childNodes
765 // Support: Android<4.0
766 // Detect silently failing push.apply
767 arr[ preferredDoc.childNodes.length ].nodeType;
769 push = { apply: arr.length ?
771 // Leverage slice if possible
772 function( target, els ) {
773 push_native.apply( target, slice.call(els) );
777 // Otherwise append directly
778 function( target, els ) {
779 var j = target.length,
781 // Can't trust NodeList.length
782 while ( (target[j++] = els[i++]) ) {}
783 target.length = j - 1;
788 function Sizzle( selector, context, results, seed ) {
789 var match, elem, m, nodeType,
791 i, groups, old, nid, newContext, newSelector;
793 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
794 setDocument( context );
797 context = context || document;
798 results = results || [];
799 nodeType = context.nodeType;
801 if ( typeof selector !== "string" || !selector ||
802 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
807 if ( !seed && documentIsHTML ) {
809 // Try to shortcut find operations when possible (e.g., not under DocumentFragment)
810 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
811 // Speed-up: Sizzle("#ID")
812 if ( (m = match[1]) ) {
813 if ( nodeType === 9 ) {
814 elem = context.getElementById( m );
815 // Check parentNode to catch when Blackberry 4.6 returns
816 // nodes that are no longer in the document (jQuery #6963)
817 if ( elem && elem.parentNode ) {
818 // Handle the case where IE, Opera, and Webkit return items
819 // by name instead of ID
820 if ( elem.id === m ) {
821 results.push( elem );
828 // Context is not a document
829 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
830 contains( context, elem ) && elem.id === m ) {
831 results.push( elem );
836 // Speed-up: Sizzle("TAG")
837 } else if ( match[2] ) {
838 push.apply( results, context.getElementsByTagName( selector ) );
841 // Speed-up: Sizzle(".CLASS")
842 } else if ( (m = match[3]) && support.getElementsByClassName ) {
843 push.apply( results, context.getElementsByClassName( m ) );
849 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
851 newContext = context;
852 newSelector = nodeType !== 1 && selector;
854 // qSA works strangely on Element-rooted queries
855 // We can work around this by specifying an extra ID on the root
856 // and working up from there (Thanks to Andrew Dupont for the technique)
857 // IE 8 doesn't work on object elements
858 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
859 groups = tokenize( selector );
861 if ( (old = context.getAttribute("id")) ) {
862 nid = old.replace( rescape, "\\$&" );
864 context.setAttribute( "id", nid );
866 nid = "[id='" + nid + "'] ";
870 groups[i] = nid + toSelector( groups[i] );
872 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
873 newSelector = groups.join(",");
879 newContext.querySelectorAll( newSelector )
885 context.removeAttribute("id");
893 return select( selector.replace( rtrim, "$1" ), context, results, seed );
897 * Create key-value caches of limited size
898 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
899 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
900 * deleting the oldest entry
902 function createCache() {
905 function cache( key, value ) {
906 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
907 if ( keys.push( key + " " ) > Expr.cacheLength ) {
908 // Only keep the most recent entries
909 delete cache[ keys.shift() ];
911 return (cache[ key + " " ] = value);
917 * Mark a function for special use by Sizzle
918 * @param {Function} fn The function to mark
920 function markFunction( fn ) {
921 fn[ expando ] = true;
926 * Support testing using an element
927 * @param {Function} fn Passed the created div and expects a boolean result
929 function assert( fn ) {
930 var div = document.createElement("div");
937 // Remove from its parent by default
938 if ( div.parentNode ) {
939 div.parentNode.removeChild( div );
941 // release memory in IE
947 * Adds the same handler for all of the specified attrs
948 * @param {String} attrs Pipe-separated list of attributes
949 * @param {Function} handler The method that will be applied
951 function addHandle( attrs, handler ) {
952 var arr = attrs.split("|"),
956 Expr.attrHandle[ arr[i] ] = handler;
961 * Checks document order of two siblings
964 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
966 function siblingCheck( a, b ) {
968 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
969 ( ~b.sourceIndex || MAX_NEGATIVE ) -
970 ( ~a.sourceIndex || MAX_NEGATIVE );
972 // Use IE sourceIndex if available on both nodes
977 // Check if b follows a
979 while ( (cur = cur.nextSibling) ) {
990 * Returns a function to use in pseudos for input types
991 * @param {String} type
993 function createInputPseudo( type ) {
994 return function( elem ) {
995 var name = elem.nodeName.toLowerCase();
996 return name === "input" && elem.type === type;
1001 * Returns a function to use in pseudos for buttons
1002 * @param {String} type
1004 function createButtonPseudo( type ) {
1005 return function( elem ) {
1006 var name = elem.nodeName.toLowerCase();
1007 return (name === "input" || name === "button") && elem.type === type;
1012 * Returns a function to use in pseudos for positionals
1013 * @param {Function} fn
1015 function createPositionalPseudo( fn ) {
1016 return markFunction(function( argument ) {
1017 argument = +argument;
1018 return markFunction(function( seed, matches ) {
1020 matchIndexes = fn( [], seed.length, argument ),
1021 i = matchIndexes.length;
1023 // Match elements found at the specified indexes
1025 if ( seed[ (j = matchIndexes[i]) ] ) {
1026 seed[j] = !(matches[j] = seed[j]);
1034 * Checks a node for validity as a Sizzle context
1035 * @param {Element|Object=} context
1036 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1038 function testContext( context ) {
1039 return context && typeof context.getElementsByTagName !== "undefined" && context;
1042 // Expose support vars for convenience
1043 support = Sizzle.support = {};
1047 * @param {Element|Object} elem An element or a document
1048 * @returns {Boolean} True iff elem is a non-HTML XML node
1050 isXML = Sizzle.isXML = function( elem ) {
1051 // documentElement is verified for cases where it doesn't yet exist
1052 // (such as loading iframes in IE - #4833)
1053 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1054 return documentElement ? documentElement.nodeName !== "HTML" : false;
1058 * Sets document-related variables once based on the current document
1059 * @param {Element|Object} [doc] An element or document object to use to set the document
1060 * @returns {Object} Returns the current document
1062 setDocument = Sizzle.setDocument = function( node ) {
1063 var hasCompare, parent,
1064 doc = node ? node.ownerDocument || node : preferredDoc;
1066 // If no document and documentElement is available, return
1067 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1073 docElem = doc.documentElement;
1074 parent = doc.defaultView;
1077 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1078 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1079 // IE6-8 do not support the defaultView property so parent will be undefined
1080 if ( parent && parent !== parent.top ) {
1081 // IE11 does not have attachEvent, so all must suffer
1082 if ( parent.addEventListener ) {
1083 parent.addEventListener( "unload", unloadHandler, false );
1084 } else if ( parent.attachEvent ) {
1085 parent.attachEvent( "onunload", unloadHandler );
1090 ---------------------------------------------------------------------- */
1091 documentIsHTML = !isXML( doc );
1094 ---------------------------------------------------------------------- */
1097 // Verify that getAttribute really returns attributes and not properties
1098 // (excepting IE8 booleans)
1099 support.attributes = assert(function( div ) {
1100 div.className = "i";
1101 return !div.getAttribute("className");
1105 ---------------------------------------------------------------------- */
1107 // Check if getElementsByTagName("*") returns only elements
1108 support.getElementsByTagName = assert(function( div ) {
1109 div.appendChild( doc.createComment("") );
1110 return !div.getElementsByTagName("*").length;
1114 support.getElementsByClassName = rnative.test( doc.getElementsByClassName );
1117 // Check if getElementById returns elements by name
1118 // The broken getElementById methods don't pick up programatically-set names,
1119 // so use a roundabout getElementsByName test
1120 support.getById = assert(function( div ) {
1121 docElem.appendChild( div ).id = expando;
1122 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1125 // ID find and filter
1126 if ( support.getById ) {
1127 Expr.find["ID"] = function( id, context ) {
1128 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1129 var m = context.getElementById( id );
1130 // Check parentNode to catch when Blackberry 4.6 returns
1131 // nodes that are no longer in the document #6963
1132 return m && m.parentNode ? [ m ] : [];
1135 Expr.filter["ID"] = function( id ) {
1136 var attrId = id.replace( runescape, funescape );
1137 return function( elem ) {
1138 return elem.getAttribute("id") === attrId;
1143 // getElementById is not reliable as a find shortcut
1144 delete Expr.find["ID"];
1146 Expr.filter["ID"] = function( id ) {
1147 var attrId = id.replace( runescape, funescape );
1148 return function( elem ) {
1149 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
1150 return node && node.value === attrId;
1156 Expr.find["TAG"] = support.getElementsByTagName ?
1157 function( tag, context ) {
1158 if ( typeof context.getElementsByTagName !== "undefined" ) {
1159 return context.getElementsByTagName( tag );
1161 // DocumentFragment nodes don't have gEBTN
1162 } else if ( support.qsa ) {
1163 return context.querySelectorAll( tag );
1167 function( tag, context ) {
1171 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1172 results = context.getElementsByTagName( tag );
1174 // Filter out possible comments
1175 if ( tag === "*" ) {
1176 while ( (elem = results[i++]) ) {
1177 if ( elem.nodeType === 1 ) {
1188 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1189 if ( documentIsHTML ) {
1190 return context.getElementsByClassName( className );
1194 /* QSA/matchesSelector
1195 ---------------------------------------------------------------------- */
1197 // QSA and matchesSelector support
1199 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1202 // qSa(:focus) reports false when true (Chrome 21)
1203 // We allow this because of a bug in IE8/9 that throws an error
1204 // whenever `document.activeElement` is accessed on an iframe
1205 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1206 // See http://bugs.jquery.com/ticket/13378
1209 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1211 // Regex strategy adopted from Diego Perini
1212 assert(function( div ) {
1213 // Select is set to empty string on purpose
1214 // This is to test IE's treatment of not explicitly
1215 // setting a boolean content attribute,
1216 // since its presence should be enough
1217 // http://bugs.jquery.com/ticket/12359
1218 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1219 "<select id='" + expando + "-\f]' msallowcapture=''>" +
1220 "<option selected=''></option></select>";
1222 // Support: IE8, Opera 11-12.16
1223 // Nothing should be selected when empty strings follow ^= or $= or *=
1224 // The test attribute must be unknown in Opera but "safe" for WinRT
1225 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1226 if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1227 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1231 // Boolean attributes and "value" are not treated correctly
1232 if ( !div.querySelectorAll("[selected]").length ) {
1233 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1236 // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
1237 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1238 rbuggyQSA.push("~=");
1241 // Webkit/Opera - :checked should return selected option elements
1242 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1243 // IE8 throws error here and will not see later tests
1244 if ( !div.querySelectorAll(":checked").length ) {
1245 rbuggyQSA.push(":checked");
1248 // Support: Safari 8+, iOS 8+
1249 // https://bugs.webkit.org/show_bug.cgi?id=136851
1250 // In-page `selector#id sibing-combinator selector` fails
1251 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1252 rbuggyQSA.push(".#.+[+~]");
1256 assert(function( div ) {
1257 // Support: Windows 8 Native Apps
1258 // The type and name attributes are restricted during .innerHTML assignment
1259 var input = doc.createElement("input");
1260 input.setAttribute( "type", "hidden" );
1261 div.appendChild( input ).setAttribute( "name", "D" );
1264 // Enforce case-sensitivity of name attribute
1265 if ( div.querySelectorAll("[name=d]").length ) {
1266 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1269 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1270 // IE8 throws error here and will not see later tests
1271 if ( !div.querySelectorAll(":enabled").length ) {
1272 rbuggyQSA.push( ":enabled", ":disabled" );
1275 // Opera 10-11 does not throw on post-comma invalid pseudos
1276 div.querySelectorAll("*,:x");
1277 rbuggyQSA.push(",.*:");
1281 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1282 docElem.webkitMatchesSelector ||
1283 docElem.mozMatchesSelector ||
1284 docElem.oMatchesSelector ||
1285 docElem.msMatchesSelector) )) ) {
1287 assert(function( div ) {
1288 // Check to see if it's possible to do matchesSelector
1289 // on a disconnected node (IE 9)
1290 support.disconnectedMatch = matches.call( div, "div" );
1292 // This should fail with an exception
1293 // Gecko does not error, returns false instead
1294 matches.call( div, "[s!='']:x" );
1295 rbuggyMatches.push( "!=", pseudos );
1299 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1300 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1303 ---------------------------------------------------------------------- */
1304 hasCompare = rnative.test( docElem.compareDocumentPosition );
1306 // Element contains another
1307 // Purposefully does not implement inclusive descendent
1308 // As in, an element does not contain itself
1309 contains = hasCompare || rnative.test( docElem.contains ) ?
1311 var adown = a.nodeType === 9 ? a.documentElement : a,
1312 bup = b && b.parentNode;
1313 return a === bup || !!( bup && bup.nodeType === 1 && (
1315 adown.contains( bup ) :
1316 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1321 while ( (b = b.parentNode) ) {
1331 ---------------------------------------------------------------------- */
1333 // Document order sorting
1334 sortOrder = hasCompare ?
1337 // Flag for duplicate removal
1339 hasDuplicate = true;
1343 // Sort on method existence if only one input has compareDocumentPosition
1344 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1349 // Calculate position if both inputs belong to the same document
1350 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1351 a.compareDocumentPosition( b ) :
1353 // Otherwise we know they are disconnected
1356 // Disconnected nodes
1358 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1360 // Choose the first element that is related to our preferred document
1361 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1364 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1368 // Maintain original order
1370 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1374 return compare & 4 ? -1 : 1;
1377 // Exit early if the nodes are identical
1379 hasDuplicate = true;
1390 // Parentless nodes are either documents or disconnected
1391 if ( !aup || !bup ) {
1392 return a === doc ? -1 :
1397 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1400 // If the nodes are siblings, we can do a quick check
1401 } else if ( aup === bup ) {
1402 return siblingCheck( a, b );
1405 // Otherwise we need full lists of their ancestors for comparison
1407 while ( (cur = cur.parentNode) ) {
1411 while ( (cur = cur.parentNode) ) {
1415 // Walk down the tree looking for a discrepancy
1416 while ( ap[i] === bp[i] ) {
1421 // Do a sibling check if the nodes have a common ancestor
1422 siblingCheck( ap[i], bp[i] ) :
1424 // Otherwise nodes in our document sort first
1425 ap[i] === preferredDoc ? -1 :
1426 bp[i] === preferredDoc ? 1 :
1433 Sizzle.matches = function( expr, elements ) {
1434 return Sizzle( expr, null, null, elements );
1437 Sizzle.matchesSelector = function( elem, expr ) {
1438 // Set document vars if needed
1439 if ( ( elem.ownerDocument || elem ) !== document ) {
1440 setDocument( elem );
1443 // Make sure that attribute selectors are quoted
1444 expr = expr.replace( rattributeQuotes, "='$1']" );
1446 if ( support.matchesSelector && documentIsHTML &&
1447 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1448 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1451 var ret = matches.call( elem, expr );
1453 // IE 9's matchesSelector returns false on disconnected nodes
1454 if ( ret || support.disconnectedMatch ||
1455 // As well, disconnected nodes are said to be in a document
1457 elem.document && elem.document.nodeType !== 11 ) {
1463 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1466 Sizzle.contains = function( context, elem ) {
1467 // Set document vars if needed
1468 if ( ( context.ownerDocument || context ) !== document ) {
1469 setDocument( context );
1471 return contains( context, elem );
1474 Sizzle.attr = function( elem, name ) {
1475 // Set document vars if needed
1476 if ( ( elem.ownerDocument || elem ) !== document ) {
1477 setDocument( elem );
1480 var fn = Expr.attrHandle[ name.toLowerCase() ],
1481 // Don't get fooled by Object.prototype properties (jQuery #13807)
1482 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1483 fn( elem, name, !documentIsHTML ) :
1486 return val !== undefined ?
1488 support.attributes || !documentIsHTML ?
1489 elem.getAttribute( name ) :
1490 (val = elem.getAttributeNode(name)) && val.specified ?
1495 Sizzle.error = function( msg ) {
1496 throw new Error( "Syntax error, unrecognized expression: " + msg );
1500 * Document sorting and removing duplicates
1501 * @param {ArrayLike} results
1503 Sizzle.uniqueSort = function( results ) {
1509 // Unless we *know* we can detect duplicates, assume their presence
1510 hasDuplicate = !support.detectDuplicates;
1511 sortInput = !support.sortStable && results.slice( 0 );
1512 results.sort( sortOrder );
1514 if ( hasDuplicate ) {
1515 while ( (elem = results[i++]) ) {
1516 if ( elem === results[ i ] ) {
1517 j = duplicates.push( i );
1521 results.splice( duplicates[ j ], 1 );
1525 // Clear input after sorting to release objects
1526 // See https://github.com/jquery/sizzle/pull/225
1533 * Utility function for retrieving the text value of an array of DOM nodes
1534 * @param {Array|Element} elem
1536 getText = Sizzle.getText = function( elem ) {
1540 nodeType = elem.nodeType;
1543 // If no nodeType, this is expected to be an array
1544 while ( (node = elem[i++]) ) {
1545 // Do not traverse comment nodes
1546 ret += getText( node );
1548 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1549 // Use textContent for elements
1550 // innerText usage removed for consistency of new lines (jQuery #11153)
1551 if ( typeof elem.textContent === "string" ) {
1552 return elem.textContent;
1554 // Traverse its children
1555 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1556 ret += getText( elem );
1559 } else if ( nodeType === 3 || nodeType === 4 ) {
1560 return elem.nodeValue;
1562 // Do not include comment or processing instruction nodes
1567 Expr = Sizzle.selectors = {
1569 // Can be adjusted by the user
1572 createPseudo: markFunction,
1581 ">": { dir: "parentNode", first: true },
1582 " ": { dir: "parentNode" },
1583 "+": { dir: "previousSibling", first: true },
1584 "~": { dir: "previousSibling" }
1588 "ATTR": function( match ) {
1589 match[1] = match[1].replace( runescape, funescape );
1591 // Move the given value to match[3] whether quoted or unquoted
1592 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1594 if ( match[2] === "~=" ) {
1595 match[3] = " " + match[3] + " ";
1598 return match.slice( 0, 4 );
1601 "CHILD": function( match ) {
1602 /* matches from matchExpr["CHILD"]
1603 1 type (only|nth|...)
1604 2 what (child|of-type)
1605 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1606 4 xn-component of xn+y argument ([+-]?\d*n|)
1607 5 sign of xn-component
1609 7 sign of y-component
1612 match[1] = match[1].toLowerCase();
1614 if ( match[1].slice( 0, 3 ) === "nth" ) {
1615 // nth-* requires argument
1617 Sizzle.error( match[0] );
1620 // numeric x and y parameters for Expr.filter.CHILD
1621 // remember that false/true cast respectively to 0/1
1622 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1623 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1625 // other types prohibit arguments
1626 } else if ( match[3] ) {
1627 Sizzle.error( match[0] );
1633 "PSEUDO": function( match ) {
1635 unquoted = !match[6] && match[2];
1637 if ( matchExpr["CHILD"].test( match[0] ) ) {
1641 // Accept quoted arguments as-is
1643 match[2] = match[4] || match[5] || "";
1645 // Strip excess characters from unquoted arguments
1646 } else if ( unquoted && rpseudo.test( unquoted ) &&
1647 // Get excess from tokenize (recursively)
1648 (excess = tokenize( unquoted, true )) &&
1649 // advance to the next closing parenthesis
1650 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1652 // excess is a negative index
1653 match[0] = match[0].slice( 0, excess );
1654 match[2] = unquoted.slice( 0, excess );
1657 // Return only captures needed by the pseudo filter method (type and argument)
1658 return match.slice( 0, 3 );
1664 "TAG": function( nodeNameSelector ) {
1665 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1666 return nodeNameSelector === "*" ?
1667 function() { return true; } :
1669 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1673 "CLASS": function( className ) {
1674 var pattern = classCache[ className + " " ];
1677 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1678 classCache( className, function( elem ) {
1679 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1683 "ATTR": function( name, operator, check ) {
1684 return function( elem ) {
1685 var result = Sizzle.attr( elem, name );
1687 if ( result == null ) {
1688 return operator === "!=";
1696 return operator === "=" ? result === check :
1697 operator === "!=" ? result !== check :
1698 operator === "^=" ? check && result.indexOf( check ) === 0 :
1699 operator === "*=" ? check && result.indexOf( check ) > -1 :
1700 operator === "$=" ? check && result.slice( -check.length ) === check :
1701 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1702 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1707 "CHILD": function( type, what, argument, first, last ) {
1708 var simple = type.slice( 0, 3 ) !== "nth",
1709 forward = type.slice( -4 ) !== "last",
1710 ofType = what === "of-type";
1712 return first === 1 && last === 0 ?
1714 // Shortcut for :nth-*(n)
1716 return !!elem.parentNode;
1719 function( elem, context, xml ) {
1720 var cache, outerCache, node, diff, nodeIndex, start,
1721 dir = simple !== forward ? "nextSibling" : "previousSibling",
1722 parent = elem.parentNode,
1723 name = ofType && elem.nodeName.toLowerCase(),
1724 useCache = !xml && !ofType;
1728 // :(first|last|only)-(child|of-type)
1732 while ( (node = node[ dir ]) ) {
1733 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1737 // Reverse direction for :only-* (if we haven't yet done so)
1738 start = dir = type === "only" && !start && "nextSibling";
1743 start = [ forward ? parent.firstChild : parent.lastChild ];
1745 // non-xml :nth-child(...) stores cache data on `parent`
1746 if ( forward && useCache ) {
1747 // Seek `elem` from a previously-cached index
1748 outerCache = parent[ expando ] || (parent[ expando ] = {});
1749 cache = outerCache[ type ] || [];
1750 nodeIndex = cache[0] === dirruns && cache[1];
1751 diff = cache[0] === dirruns && cache[2];
1752 node = nodeIndex && parent.childNodes[ nodeIndex ];
1754 while ( (node = ++nodeIndex && node && node[ dir ] ||
1756 // Fallback to seeking `elem` from the start
1757 (diff = nodeIndex = 0) || start.pop()) ) {
1759 // When found, cache indexes on `parent` and break
1760 if ( node.nodeType === 1 && ++diff && node === elem ) {
1761 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1766 // Use previously-cached element index if available
1767 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1770 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1772 // Use the same loop as above to seek `elem` from the start
1773 while ( (node = ++nodeIndex && node && node[ dir ] ||
1774 (diff = nodeIndex = 0) || start.pop()) ) {
1776 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1777 // Cache the index of each encountered element
1779 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1782 if ( node === elem ) {
1789 // Incorporate the offset, then check against cycle size
1791 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1796 "PSEUDO": function( pseudo, argument ) {
1797 // pseudo-class names are case-insensitive
1798 // http://www.w3.org/TR/selectors/#pseudo-classes
1799 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1800 // Remember that setFilters inherits from pseudos
1802 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1803 Sizzle.error( "unsupported pseudo: " + pseudo );
1805 // The user may use createPseudo to indicate that
1806 // arguments are needed to create the filter function
1807 // just as Sizzle does
1808 if ( fn[ expando ] ) {
1809 return fn( argument );
1812 // But maintain support for old signatures
1813 if ( fn.length > 1 ) {
1814 args = [ pseudo, pseudo, "", argument ];
1815 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1816 markFunction(function( seed, matches ) {
1818 matched = fn( seed, argument ),
1821 idx = indexOf( seed, matched[i] );
1822 seed[ idx ] = !( matches[ idx ] = matched[i] );
1826 return fn( elem, 0, args );
1835 // Potentially complex pseudos
1836 "not": markFunction(function( selector ) {
1837 // Trim the selector passed to compile
1838 // to avoid treating leading and trailing
1839 // spaces as combinators
1842 matcher = compile( selector.replace( rtrim, "$1" ) );
1844 return matcher[ expando ] ?
1845 markFunction(function( seed, matches, context, xml ) {
1847 unmatched = matcher( seed, null, xml, [] ),
1850 // Match elements unmatched by `matcher`
1852 if ( (elem = unmatched[i]) ) {
1853 seed[i] = !(matches[i] = elem);
1857 function( elem, context, xml ) {
1859 matcher( input, null, xml, results );
1860 // Don't keep the element (issue #299)
1862 return !results.pop();
1866 "has": markFunction(function( selector ) {
1867 return function( elem ) {
1868 return Sizzle( selector, elem ).length > 0;
1872 "contains": markFunction(function( text ) {
1873 text = text.replace( runescape, funescape );
1874 return function( elem ) {
1875 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1879 // "Whether an element is represented by a :lang() selector
1880 // is based solely on the element's language value
1881 // being equal to the identifier C,
1882 // or beginning with the identifier C immediately followed by "-".
1883 // The matching of C against the element's language value is performed case-insensitively.
1884 // The identifier C does not have to be a valid language name."
1885 // http://www.w3.org/TR/selectors/#lang-pseudo
1886 "lang": markFunction( function( lang ) {
1887 // lang value must be a valid identifier
1888 if ( !ridentifier.test(lang || "") ) {
1889 Sizzle.error( "unsupported lang: " + lang );
1891 lang = lang.replace( runescape, funescape ).toLowerCase();
1892 return function( elem ) {
1895 if ( (elemLang = documentIsHTML ?
1897 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1899 elemLang = elemLang.toLowerCase();
1900 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1902 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1908 "target": function( elem ) {
1909 var hash = window.location && window.location.hash;
1910 return hash && hash.slice( 1 ) === elem.id;
1913 "root": function( elem ) {
1914 return elem === docElem;
1917 "focus": function( elem ) {
1918 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1921 // Boolean properties
1922 "enabled": function( elem ) {
1923 return elem.disabled === false;
1926 "disabled": function( elem ) {
1927 return elem.disabled === true;
1930 "checked": function( elem ) {
1931 // In CSS3, :checked should return both checked and selected elements
1932 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1933 var nodeName = elem.nodeName.toLowerCase();
1934 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1937 "selected": function( elem ) {
1938 // Accessing this property makes selected-by-default
1939 // options in Safari work properly
1940 if ( elem.parentNode ) {
1941 elem.parentNode.selectedIndex;
1944 return elem.selected === true;
1948 "empty": function( elem ) {
1949 // http://www.w3.org/TR/selectors/#empty-pseudo
1950 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1951 // but not by others (comment: 8; processing instruction: 7; etc.)
1952 // nodeType < 6 works because attributes (2) do not appear as children
1953 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1954 if ( elem.nodeType < 6 ) {
1961 "parent": function( elem ) {
1962 return !Expr.pseudos["empty"]( elem );
1965 // Element/input types
1966 "header": function( elem ) {
1967 return rheader.test( elem.nodeName );
1970 "input": function( elem ) {
1971 return rinputs.test( elem.nodeName );
1974 "button": function( elem ) {
1975 var name = elem.nodeName.toLowerCase();
1976 return name === "input" && elem.type === "button" || name === "button";
1979 "text": function( elem ) {
1981 return elem.nodeName.toLowerCase() === "input" &&
1982 elem.type === "text" &&
1985 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1986 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1989 // Position-in-collection
1990 "first": createPositionalPseudo(function() {
1994 "last": createPositionalPseudo(function( matchIndexes, length ) {
1995 return [ length - 1 ];
1998 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1999 return [ argument < 0 ? argument + length : argument ];
2002 "even": createPositionalPseudo(function( matchIndexes, length ) {
2004 for ( ; i < length; i += 2 ) {
2005 matchIndexes.push( i );
2007 return matchIndexes;
2010 "odd": createPositionalPseudo(function( matchIndexes, length ) {
2012 for ( ; i < length; i += 2 ) {
2013 matchIndexes.push( i );
2015 return matchIndexes;
2018 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2019 var i = argument < 0 ? argument + length : argument;
2020 for ( ; --i >= 0; ) {
2021 matchIndexes.push( i );
2023 return matchIndexes;
2026 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2027 var i = argument < 0 ? argument + length : argument;
2028 for ( ; ++i < length; ) {
2029 matchIndexes.push( i );
2031 return matchIndexes;
2036 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2038 // Add button/input type pseudos
2039 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2040 Expr.pseudos[ i ] = createInputPseudo( i );
2042 for ( i in { submit: true, reset: true } ) {
2043 Expr.pseudos[ i ] = createButtonPseudo( i );
2046 // Easy API for creating new setFilters
2047 function setFilters() {}
2048 setFilters.prototype = Expr.filters = Expr.pseudos;
2049 Expr.setFilters = new setFilters();
2051 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2052 var matched, match, tokens, type,
2053 soFar, groups, preFilters,
2054 cached = tokenCache[ selector + " " ];
2057 return parseOnly ? 0 : cached.slice( 0 );
2062 preFilters = Expr.preFilter;
2066 // Comma and first run
2067 if ( !matched || (match = rcomma.exec( soFar )) ) {
2069 // Don't consume trailing commas as valid
2070 soFar = soFar.slice( match[0].length ) || soFar;
2072 groups.push( (tokens = []) );
2078 if ( (match = rcombinators.exec( soFar )) ) {
2079 matched = match.shift();
2082 // Cast descendant combinators to space
2083 type: match[0].replace( rtrim, " " )
2085 soFar = soFar.slice( matched.length );
2089 for ( type in Expr.filter ) {
2090 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2091 (match = preFilters[ type ]( match ))) ) {
2092 matched = match.shift();
2098 soFar = soFar.slice( matched.length );
2107 // Return the length of the invalid excess
2108 // if we're just parsing
2109 // Otherwise, throw an error or return tokens
2113 Sizzle.error( selector ) :
2115 tokenCache( selector, groups ).slice( 0 );
2118 function toSelector( tokens ) {
2120 len = tokens.length,
2122 for ( ; i < len; i++ ) {
2123 selector += tokens[i].value;
2128 function addCombinator( matcher, combinator, base ) {
2129 var dir = combinator.dir,
2130 checkNonElements = base && dir === "parentNode",
2133 return combinator.first ?
2134 // Check against closest ancestor/preceding element
2135 function( elem, context, xml ) {
2136 while ( (elem = elem[ dir ]) ) {
2137 if ( elem.nodeType === 1 || checkNonElements ) {
2138 return matcher( elem, context, xml );
2143 // Check against all ancestor/preceding elements
2144 function( elem, context, xml ) {
2145 var oldCache, outerCache,
2146 newCache = [ dirruns, doneName ];
2148 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2150 while ( (elem = elem[ dir ]) ) {
2151 if ( elem.nodeType === 1 || checkNonElements ) {
2152 if ( matcher( elem, context, xml ) ) {
2158 while ( (elem = elem[ dir ]) ) {
2159 if ( elem.nodeType === 1 || checkNonElements ) {
2160 outerCache = elem[ expando ] || (elem[ expando ] = {});
2161 if ( (oldCache = outerCache[ dir ]) &&
2162 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2164 // Assign to newCache so results back-propagate to previous elements
2165 return (newCache[ 2 ] = oldCache[ 2 ]);
2167 // Reuse newcache so results back-propagate to previous elements
2168 outerCache[ dir ] = newCache;
2170 // A match means we're done; a fail means we have to keep checking
2171 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2181 function elementMatcher( matchers ) {
2182 return matchers.length > 1 ?
2183 function( elem, context, xml ) {
2184 var i = matchers.length;
2186 if ( !matchers[i]( elem, context, xml ) ) {
2195 function multipleContexts( selector, contexts, results ) {
2197 len = contexts.length;
2198 for ( ; i < len; i++ ) {
2199 Sizzle( selector, contexts[i], results );
2204 function condense( unmatched, map, filter, context, xml ) {
2208 len = unmatched.length,
2209 mapped = map != null;
2211 for ( ; i < len; i++ ) {
2212 if ( (elem = unmatched[i]) ) {
2213 if ( !filter || filter( elem, context, xml ) ) {
2214 newUnmatched.push( elem );
2222 return newUnmatched;
2225 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2226 if ( postFilter && !postFilter[ expando ] ) {
2227 postFilter = setMatcher( postFilter );
2229 if ( postFinder && !postFinder[ expando ] ) {
2230 postFinder = setMatcher( postFinder, postSelector );
2232 return markFunction(function( seed, results, context, xml ) {
2236 preexisting = results.length,
2238 // Get initial elements from seed or context
2239 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2241 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2242 matcherIn = preFilter && ( seed || !selector ) ?
2243 condense( elems, preMap, preFilter, context, xml ) :
2246 matcherOut = matcher ?
2247 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2248 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2250 // ...intermediate processing is necessary
2253 // ...otherwise use results directly
2257 // Find primary matches
2259 matcher( matcherIn, matcherOut, context, xml );
2264 temp = condense( matcherOut, postMap );
2265 postFilter( temp, [], context, xml );
2267 // Un-match failing elements by moving them back to matcherIn
2270 if ( (elem = temp[i]) ) {
2271 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2277 if ( postFinder || preFilter ) {
2279 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2281 i = matcherOut.length;
2283 if ( (elem = matcherOut[i]) ) {
2284 // Restore matcherIn since elem is not yet a final match
2285 temp.push( (matcherIn[i] = elem) );
2288 postFinder( null, (matcherOut = []), temp, xml );
2291 // Move matched elements from seed to results to keep them synchronized
2292 i = matcherOut.length;
2294 if ( (elem = matcherOut[i]) &&
2295 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2297 seed[temp] = !(results[temp] = elem);
2302 // Add elements to results, through postFinder if defined
2304 matcherOut = condense(
2305 matcherOut === results ?
2306 matcherOut.splice( preexisting, matcherOut.length ) :
2310 postFinder( null, results, matcherOut, xml );
2312 push.apply( results, matcherOut );
2318 function matcherFromTokens( tokens ) {
2319 var checkContext, matcher, j,
2320 len = tokens.length,
2321 leadingRelative = Expr.relative[ tokens[0].type ],
2322 implicitRelative = leadingRelative || Expr.relative[" "],
2323 i = leadingRelative ? 1 : 0,
2325 // The foundational matcher ensures that elements are reachable from top-level context(s)
2326 matchContext = addCombinator( function( elem ) {
2327 return elem === checkContext;
2328 }, implicitRelative, true ),
2329 matchAnyContext = addCombinator( function( elem ) {
2330 return indexOf( checkContext, elem ) > -1;
2331 }, implicitRelative, true ),
2332 matchers = [ function( elem, context, xml ) {
2333 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2334 (checkContext = context).nodeType ?
2335 matchContext( elem, context, xml ) :
2336 matchAnyContext( elem, context, xml ) );
2337 // Avoid hanging onto element (issue #299)
2338 checkContext = null;
2342 for ( ; i < len; i++ ) {
2343 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2344 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2346 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2348 // Return special upon seeing a positional matcher
2349 if ( matcher[ expando ] ) {
2350 // Find the next relative operator (if any) for proper handling
2352 for ( ; j < len; j++ ) {
2353 if ( Expr.relative[ tokens[j].type ] ) {
2358 i > 1 && elementMatcher( matchers ),
2359 i > 1 && toSelector(
2360 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2361 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2362 ).replace( rtrim, "$1" ),
2364 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2365 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2366 j < len && toSelector( tokens )
2369 matchers.push( matcher );
2373 return elementMatcher( matchers );
2376 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2377 var bySet = setMatchers.length > 0,
2378 byElement = elementMatchers.length > 0,
2379 superMatcher = function( seed, context, xml, results, outermost ) {
2380 var elem, j, matcher,
2383 unmatched = seed && [],
2385 contextBackup = outermostContext,
2386 // We must always have either seed elements or outermost context
2387 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2388 // Use integer dirruns iff this is the outermost matcher
2389 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2393 outermostContext = context !== document && context;
2396 // Add elements passing elementMatchers directly to results
2397 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2398 // Support: IE<9, Safari
2399 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2400 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2401 if ( byElement && elem ) {
2403 while ( (matcher = elementMatchers[j++]) ) {
2404 if ( matcher( elem, context, xml ) ) {
2405 results.push( elem );
2410 dirruns = dirrunsUnique;
2414 // Track unmatched elements for set filters
2416 // They will have gone through all possible matchers
2417 if ( (elem = !matcher && elem) ) {
2421 // Lengthen the array for every element, matched or not
2423 unmatched.push( elem );
2428 // Apply set filters to unmatched elements
2430 if ( bySet && i !== matchedCount ) {
2432 while ( (matcher = setMatchers[j++]) ) {
2433 matcher( unmatched, setMatched, context, xml );
2437 // Reintegrate element matches to eliminate the need for sorting
2438 if ( matchedCount > 0 ) {
2440 if ( !(unmatched[i] || setMatched[i]) ) {
2441 setMatched[i] = pop.call( results );
2446 // Discard index placeholder values to get only actual matches
2447 setMatched = condense( setMatched );
2450 // Add matches to results
2451 push.apply( results, setMatched );
2453 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2454 if ( outermost && !seed && setMatched.length > 0 &&
2455 ( matchedCount + setMatchers.length ) > 1 ) {
2457 Sizzle.uniqueSort( results );
2461 // Override manipulation of globals by nested matchers
2463 dirruns = dirrunsUnique;
2464 outermostContext = contextBackup;
2471 markFunction( superMatcher ) :
2475 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2478 elementMatchers = [],
2479 cached = compilerCache[ selector + " " ];
2482 // Generate a function of recursive functions that can be used to check each element
2484 match = tokenize( selector );
2488 cached = matcherFromTokens( match[i] );
2489 if ( cached[ expando ] ) {
2490 setMatchers.push( cached );
2492 elementMatchers.push( cached );
2496 // Cache the compiled function
2497 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2499 // Save selector and tokenization
2500 cached.selector = selector;
2506 * A low-level selection function that works with Sizzle's compiled
2507 * selector functions
2508 * @param {String|Function} selector A selector or a pre-compiled
2509 * selector function built with Sizzle.compile
2510 * @param {Element} context
2511 * @param {Array} [results]
2512 * @param {Array} [seed] A set of elements to match against
2514 select = Sizzle.select = function( selector, context, results, seed ) {
2515 var i, tokens, token, type, find,
2516 compiled = typeof selector === "function" && selector,
2517 match = !seed && tokenize( (selector = compiled.selector || selector) );
2519 results = results || [];
2521 // Try to minimize operations if there is no seed and only one group
2522 if ( match.length === 1 ) {
2524 // Take a shortcut and set the context if the root selector is an ID
2525 tokens = match[0] = match[0].slice( 0 );
2526 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2527 support.getById && context.nodeType === 9 && documentIsHTML &&
2528 Expr.relative[ tokens[1].type ] ) {
2530 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2534 // Precompiled matchers will still verify ancestry, so step up a level
2535 } else if ( compiled ) {
2536 context = context.parentNode;
2539 selector = selector.slice( tokens.shift().value.length );
2542 // Fetch a seed set for right-to-left matching
2543 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2547 // Abort if we hit a combinator
2548 if ( Expr.relative[ (type = token.type) ] ) {
2551 if ( (find = Expr.find[ type ]) ) {
2552 // Search, expanding context for leading sibling combinators
2554 token.matches[0].replace( runescape, funescape ),
2555 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2558 // If seed is empty or no tokens remain, we can return early
2559 tokens.splice( i, 1 );
2560 selector = seed.length && toSelector( tokens );
2562 push.apply( results, seed );
2572 // Compile and execute a filtering function if one is not provided
2573 // Provide `match` to avoid retokenization if we modified the selector above
2574 ( compiled || compile( selector, match ) )(
2579 rsibling.test( selector ) && testContext( context.parentNode ) || context
2584 // One-time assignments
2587 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2589 // Support: Chrome 14-35+
2590 // Always assume duplicates if they aren't passed to the comparison function
2591 support.detectDuplicates = !!hasDuplicate;
2593 // Initialize against the default document
2596 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2597 // Detached nodes confoundingly follow *each other*
2598 support.sortDetached = assert(function( div1 ) {
2599 // Should return 1, but returns 4 (following)
2600 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2604 // Prevent attribute/property "interpolation"
2605 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2606 if ( !assert(function( div ) {
2607 div.innerHTML = "<a href='#'></a>";
2608 return div.firstChild.getAttribute("href") === "#" ;
2610 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2612 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2618 // Use defaultValue in place of getAttribute("value")
2619 if ( !support.attributes || !assert(function( div ) {
2620 div.innerHTML = "<input/>";
2621 div.firstChild.setAttribute( "value", "" );
2622 return div.firstChild.getAttribute( "value" ) === "";
2624 addHandle( "value", function( elem, name, isXML ) {
2625 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2626 return elem.defaultValue;
2632 // Use getAttributeNode to fetch booleans when getAttribute lies
2633 if ( !assert(function( div ) {
2634 return div.getAttribute("disabled") == null;
2636 addHandle( booleans, function( elem, name, isXML ) {
2639 return elem[ name ] === true ? name.toLowerCase() :
2640 (val = elem.getAttributeNode( name )) && val.specified ?
2653 jQuery.find = Sizzle;
2654 jQuery.expr = Sizzle.selectors;
2655 jQuery.expr[":"] = jQuery.expr.pseudos;
2656 jQuery.unique = Sizzle.uniqueSort;
2657 jQuery.text = Sizzle.getText;
2658 jQuery.isXMLDoc = Sizzle.isXML;
2659 jQuery.contains = Sizzle.contains;
2663 var rneedsContext = jQuery.expr.match.needsContext;
2665 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2669 var risSimple = /^.[^:#\[\.,]*$/;
2671 // Implement the identical functionality for filter and not
2672 function winnow( elements, qualifier, not ) {
2673 if ( jQuery.isFunction( qualifier ) ) {
2674 return jQuery.grep( elements, function( elem, i ) {
2676 return !!qualifier.call( elem, i, elem ) !== not;
2681 if ( qualifier.nodeType ) {
2682 return jQuery.grep( elements, function( elem ) {
2683 return ( elem === qualifier ) !== not;
2688 if ( typeof qualifier === "string" ) {
2689 if ( risSimple.test( qualifier ) ) {
2690 return jQuery.filter( qualifier, elements, not );
2693 qualifier = jQuery.filter( qualifier, elements );
2696 return jQuery.grep( elements, function( elem ) {
2697 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2701 jQuery.filter = function( expr, elems, not ) {
2702 var elem = elems[ 0 ];
2705 expr = ":not(" + expr + ")";
2708 return elems.length === 1 && elem.nodeType === 1 ?
2709 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2710 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2711 return elem.nodeType === 1;
2716 find: function( selector ) {
2722 if ( typeof selector !== "string" ) {
2723 return this.pushStack( jQuery( selector ).filter(function() {
2724 for ( i = 0; i < len; i++ ) {
2725 if ( jQuery.contains( self[ i ], this ) ) {
2732 for ( i = 0; i < len; i++ ) {
2733 jQuery.find( selector, self[ i ], ret );
2736 // Needed because $( selector, context ) becomes $( context ).find( selector )
2737 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2738 ret.selector = this.selector ? this.selector + " " + selector : selector;
2741 filter: function( selector ) {
2742 return this.pushStack( winnow(this, selector || [], false) );
2744 not: function( selector ) {
2745 return this.pushStack( winnow(this, selector || [], true) );
2747 is: function( selector ) {
2751 // If this is a positional/relative selector, check membership in the returned set
2752 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2753 typeof selector === "string" && rneedsContext.test( selector ) ?
2754 jQuery( selector ) :
2762 // Initialize a jQuery object
2765 // A central reference to the root jQuery(document)
2768 // Use the correct document accordingly with window argument (sandbox)
2769 document = window.document,
2771 // A simple way to check for HTML strings
2772 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2773 // Strict HTML recognition (#11290: must start with <)
2774 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2776 init = jQuery.fn.init = function( selector, context ) {
2779 // HANDLE: $(""), $(null), $(undefined), $(false)
2784 // Handle HTML strings
2785 if ( typeof selector === "string" ) {
2786 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2787 // Assume that strings that start and end with <> are HTML and skip the regex check
2788 match = [ null, selector, null ];
2791 match = rquickExpr.exec( selector );
2794 // Match html or make sure no context is specified for #id
2795 if ( match && (match[1] || !context) ) {
2797 // HANDLE: $(html) -> $(array)
2799 context = context instanceof jQuery ? context[0] : context;
2801 // scripts is true for back-compat
2802 // Intentionally let the error be thrown if parseHTML is not present
2803 jQuery.merge( this, jQuery.parseHTML(
2805 context && context.nodeType ? context.ownerDocument || context : document,
2809 // HANDLE: $(html, props)
2810 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2811 for ( match in context ) {
2812 // Properties of context are called as methods if possible
2813 if ( jQuery.isFunction( this[ match ] ) ) {
2814 this[ match ]( context[ match ] );
2816 // ...and otherwise set as attributes
2818 this.attr( match, context[ match ] );
2827 elem = document.getElementById( match[2] );
2829 // Check parentNode to catch when Blackberry 4.6 returns
2830 // nodes that are no longer in the document #6963
2831 if ( elem && elem.parentNode ) {
2832 // Handle the case where IE and Opera return items
2833 // by name instead of ID
2834 if ( elem.id !== match[2] ) {
2835 return rootjQuery.find( selector );
2838 // Otherwise, we inject the element directly into the jQuery object
2843 this.context = document;
2844 this.selector = selector;
2848 // HANDLE: $(expr, $(...))
2849 } else if ( !context || context.jquery ) {
2850 return ( context || rootjQuery ).find( selector );
2852 // HANDLE: $(expr, context)
2853 // (which is just equivalent to: $(context).find(expr)
2855 return this.constructor( context ).find( selector );
2858 // HANDLE: $(DOMElement)
2859 } else if ( selector.nodeType ) {
2860 this.context = this[0] = selector;
2864 // HANDLE: $(function)
2865 // Shortcut for document ready
2866 } else if ( jQuery.isFunction( selector ) ) {
2867 return typeof rootjQuery.ready !== "undefined" ?
2868 rootjQuery.ready( selector ) :
2869 // Execute immediately if ready is not present
2873 if ( selector.selector !== undefined ) {
2874 this.selector = selector.selector;
2875 this.context = selector.context;
2878 return jQuery.makeArray( selector, this );
2881 // Give the init function the jQuery prototype for later instantiation
2882 init.prototype = jQuery.fn;
2884 // Initialize central reference
2885 rootjQuery = jQuery( document );
2888 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2889 // methods guaranteed to produce a unique set when starting from a unique set
2890 guaranteedUnique = {
2898 dir: function( elem, dir, until ) {
2902 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2903 if ( cur.nodeType === 1 ) {
2904 matched.push( cur );
2911 sibling: function( n, elem ) {
2914 for ( ; n; n = n.nextSibling ) {
2915 if ( n.nodeType === 1 && n !== elem ) {
2925 has: function( target ) {
2927 targets = jQuery( target, this ),
2928 len = targets.length;
2930 return this.filter(function() {
2931 for ( i = 0; i < len; i++ ) {
2932 if ( jQuery.contains( this, targets[i] ) ) {
2939 closest: function( selectors, context ) {
2944 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
2945 jQuery( selectors, context || this.context ) :
2948 for ( ; i < l; i++ ) {
2949 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
2950 // Always skip document fragments
2951 if ( cur.nodeType < 11 && (pos ?
2952 pos.index(cur) > -1 :
2954 // Don't pass non-elements to Sizzle
2955 cur.nodeType === 1 &&
2956 jQuery.find.matchesSelector(cur, selectors)) ) {
2958 matched.push( cur );
2964 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
2967 // Determine the position of an element within
2968 // the matched set of elements
2969 index: function( elem ) {
2971 // No argument, return index in parent
2973 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
2976 // index in selector
2977 if ( typeof elem === "string" ) {
2978 return jQuery.inArray( this[0], jQuery( elem ) );
2981 // Locate the position of the desired element
2982 return jQuery.inArray(
2983 // If it receives a jQuery object, the first element is used
2984 elem.jquery ? elem[0] : elem, this );
2987 add: function( selector, context ) {
2988 return this.pushStack(
2990 jQuery.merge( this.get(), jQuery( selector, context ) )
2995 addBack: function( selector ) {
2996 return this.add( selector == null ?
2997 this.prevObject : this.prevObject.filter(selector)
3002 function sibling( cur, dir ) {
3005 } while ( cur && cur.nodeType !== 1 );
3011 parent: function( elem ) {
3012 var parent = elem.parentNode;
3013 return parent && parent.nodeType !== 11 ? parent : null;
3015 parents: function( elem ) {
3016 return jQuery.dir( elem, "parentNode" );
3018 parentsUntil: function( elem, i, until ) {
3019 return jQuery.dir( elem, "parentNode", until );
3021 next: function( elem ) {
3022 return sibling( elem, "nextSibling" );
3024 prev: function( elem ) {
3025 return sibling( elem, "previousSibling" );
3027 nextAll: function( elem ) {
3028 return jQuery.dir( elem, "nextSibling" );
3030 prevAll: function( elem ) {
3031 return jQuery.dir( elem, "previousSibling" );
3033 nextUntil: function( elem, i, until ) {
3034 return jQuery.dir( elem, "nextSibling", until );
3036 prevUntil: function( elem, i, until ) {
3037 return jQuery.dir( elem, "previousSibling", until );
3039 siblings: function( elem ) {
3040 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
3042 children: function( elem ) {
3043 return jQuery.sibling( elem.firstChild );
3045 contents: function( elem ) {
3046 return jQuery.nodeName( elem, "iframe" ) ?
3047 elem.contentDocument || elem.contentWindow.document :
3048 jQuery.merge( [], elem.childNodes );
3050 }, function( name, fn ) {
3051 jQuery.fn[ name ] = function( until, selector ) {
3052 var ret = jQuery.map( this, fn, until );
3054 if ( name.slice( -5 ) !== "Until" ) {
3058 if ( selector && typeof selector === "string" ) {
3059 ret = jQuery.filter( selector, ret );
3062 if ( this.length > 1 ) {
3063 // Remove duplicates
3064 if ( !guaranteedUnique[ name ] ) {
3065 ret = jQuery.unique( ret );
3068 // Reverse order for parents* and prev-derivatives
3069 if ( rparentsprev.test( name ) ) {
3070 ret = ret.reverse();
3074 return this.pushStack( ret );
3077 var rnotwhite = (/\S+/g);
3081 // String to Object options format cache
3082 var optionsCache = {};
3084 // Convert String-formatted options into Object-formatted ones and store in cache
3085 function createOptions( options ) {
3086 var object = optionsCache[ options ] = {};
3087 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3088 object[ flag ] = true;
3094 * Create a callback list using the following parameters:
3096 * options: an optional list of space-separated options that will change how
3097 * the callback list behaves or a more traditional option object
3099 * By default a callback list will act like an event callback list and can be
3100 * "fired" multiple times.
3104 * once: will ensure the callback list can only be fired once (like a Deferred)
3106 * memory: will keep track of previous values and will call any callback added
3107 * after the list has been fired right away with the latest "memorized"
3108 * values (like a Deferred)
3110 * unique: will ensure a callback can only be added once (no duplicate in the list)
3112 * stopOnFalse: interrupt callings when a callback returns false
3115 jQuery.Callbacks = function( options ) {
3117 // Convert options from String-formatted to Object-formatted if needed
3118 // (we check in cache first)
3119 options = typeof options === "string" ?
3120 ( optionsCache[ options ] || createOptions( options ) ) :
3121 jQuery.extend( {}, options );
3123 var // Flag to know if list is currently firing
3125 // Last fire value (for non-forgettable lists)
3127 // Flag to know if list was already fired
3129 // End of the loop when firing
3131 // Index of currently firing callback (modified by remove if needed)
3133 // First callback to fire (used internally by add and fireWith)
3135 // Actual callback list
3137 // Stack of fire calls for repeatable lists
3138 stack = !options.once && [],
3140 fire = function( data ) {
3141 memory = options.memory && data;
3143 firingIndex = firingStart || 0;
3145 firingLength = list.length;
3147 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3148 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
3149 memory = false; // To prevent further calls using add
3156 if ( stack.length ) {
3157 fire( stack.shift() );
3159 } else if ( memory ) {
3166 // Actual Callbacks object
3168 // Add a callback or a collection of callbacks to the list
3171 // First, we save the current length
3172 var start = list.length;
3173 (function add( args ) {
3174 jQuery.each( args, function( _, arg ) {
3175 var type = jQuery.type( arg );
3176 if ( type === "function" ) {
3177 if ( !options.unique || !self.has( arg ) ) {
3180 } else if ( arg && arg.length && type !== "string" ) {
3181 // Inspect recursively
3186 // Do we need to add the callbacks to the
3187 // current firing batch?
3189 firingLength = list.length;
3190 // With memory, if we're not firing then
3191 // we should call right away
3192 } else if ( memory ) {
3193 firingStart = start;
3199 // Remove a callback from the list
3200 remove: function() {
3202 jQuery.each( arguments, function( _, arg ) {
3204 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3205 list.splice( index, 1 );
3206 // Handle firing indexes
3208 if ( index <= firingLength ) {
3211 if ( index <= firingIndex ) {
3220 // Check if a given callback is in the list.
3221 // If no argument is given, return whether or not list has callbacks attached.
3222 has: function( fn ) {
3223 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
3225 // Remove all callbacks from the list
3231 // Have the list do nothing anymore
3232 disable: function() {
3233 list = stack = memory = undefined;
3237 disabled: function() {
3240 // Lock the list in its current state
3249 locked: function() {
3252 // Call all callbacks with the given context and arguments
3253 fireWith: function( context, args ) {
3254 if ( list && ( !fired || stack ) ) {
3256 args = [ context, args.slice ? args.slice() : args ];
3265 // Call all the callbacks with the given arguments
3267 self.fireWith( this, arguments );
3270 // To know if the callbacks have already been called at least once
3282 Deferred: function( func ) {
3284 // action, add listener, listener list, final state
3285 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
3286 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
3287 [ "notify", "progress", jQuery.Callbacks("memory") ]
3294 always: function() {
3295 deferred.done( arguments ).fail( arguments );
3298 then: function( /* fnDone, fnFail, fnProgress */ ) {
3299 var fns = arguments;
3300 return jQuery.Deferred(function( newDefer ) {
3301 jQuery.each( tuples, function( i, tuple ) {
3302 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3303 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3304 deferred[ tuple[1] ](function() {
3305 var returned = fn && fn.apply( this, arguments );
3306 if ( returned && jQuery.isFunction( returned.promise ) ) {
3308 .done( newDefer.resolve )
3309 .fail( newDefer.reject )
3310 .progress( newDefer.notify );
3312 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
3319 // Get a promise for this deferred
3320 // If obj is provided, the promise aspect is added to the object
3321 promise: function( obj ) {
3322 return obj != null ? jQuery.extend( obj, promise ) : promise;
3327 // Keep pipe for back-compat
3328 promise.pipe = promise.then;
3330 // Add list-specific methods
3331 jQuery.each( tuples, function( i, tuple ) {
3332 var list = tuple[ 2 ],
3333 stateString = tuple[ 3 ];
3335 // promise[ done | fail | progress ] = list.add
3336 promise[ tuple[1] ] = list.add;
3339 if ( stateString ) {
3340 list.add(function() {
3341 // state = [ resolved | rejected ]
3342 state = stateString;
3344 // [ reject_list | resolve_list ].disable; progress_list.lock
3345 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3348 // deferred[ resolve | reject | notify ]
3349 deferred[ tuple[0] ] = function() {
3350 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
3353 deferred[ tuple[0] + "With" ] = list.fireWith;
3356 // Make the deferred a promise
3357 promise.promise( deferred );
3359 // Call given func if any
3361 func.call( deferred, deferred );
3369 when: function( subordinate /* , ..., subordinateN */ ) {
3371 resolveValues = slice.call( arguments ),
3372 length = resolveValues.length,
3374 // the count of uncompleted subordinates
3375 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3377 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3378 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3380 // Update function for both resolve and progress values
3381 updateFunc = function( i, contexts, values ) {
3382 return function( value ) {
3383 contexts[ i ] = this;
3384 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3385 if ( values === progressValues ) {
3386 deferred.notifyWith( contexts, values );
3388 } else if ( !(--remaining) ) {
3389 deferred.resolveWith( contexts, values );
3394 progressValues, progressContexts, resolveContexts;
3396 // add listeners to Deferred subordinates; treat others as resolved
3398 progressValues = new Array( length );
3399 progressContexts = new Array( length );
3400 resolveContexts = new Array( length );
3401 for ( ; i < length; i++ ) {
3402 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3403 resolveValues[ i ].promise()
3404 .done( updateFunc( i, resolveContexts, resolveValues ) )
3405 .fail( deferred.reject )
3406 .progress( updateFunc( i, progressContexts, progressValues ) );
3413 // if we're not waiting on anything, resolve the master
3415 deferred.resolveWith( resolveContexts, resolveValues );
3418 return deferred.promise();
3423 // The deferred used on DOM ready
3426 jQuery.fn.ready = function( fn ) {
3428 jQuery.ready.promise().done( fn );
3434 // Is the DOM ready to be used? Set to true once it occurs.
3437 // A counter to track how many items to wait for before
3438 // the ready event fires. See #6781
3441 // Hold (or release) the ready event
3442 holdReady: function( hold ) {
3446 jQuery.ready( true );
3450 // Handle when the DOM is ready
3451 ready: function( wait ) {
3453 // Abort if there are pending holds or we're already ready
3454 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3458 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
3459 if ( !document.body ) {
3460 return setTimeout( jQuery.ready );
3463 // Remember that the DOM is ready
3464 jQuery.isReady = true;
3466 // If a normal DOM Ready event fired, decrement, and wait if need be
3467 if ( wait !== true && --jQuery.readyWait > 0 ) {
3471 // If there are functions bound, to execute
3472 readyList.resolveWith( document, [ jQuery ] );
3474 // Trigger any bound ready events
3475 if ( jQuery.fn.triggerHandler ) {
3476 jQuery( document ).triggerHandler( "ready" );
3477 jQuery( document ).off( "ready" );
3483 * Clean-up method for dom ready events
3486 if ( document.addEventListener ) {
3487 document.removeEventListener( "DOMContentLoaded", completed, false );
3488 window.removeEventListener( "load", completed, false );
3491 document.detachEvent( "onreadystatechange", completed );
3492 window.detachEvent( "onload", completed );
3497 * The ready event handler and self cleanup method
3499 function completed() {
3500 // readyState === "complete" is good enough for us to call the dom ready in oldIE
3501 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
3507 jQuery.ready.promise = function( obj ) {
3510 readyList = jQuery.Deferred();
3512 // Catch cases where $(document).ready() is called after the browser event has already occurred.
3513 // we once tried to use readyState "interactive" here, but it caused issues like the one
3514 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
3515 if ( document.readyState === "complete" ) {
3516 // Handle it asynchronously to allow scripts the opportunity to delay ready
3517 setTimeout( jQuery.ready );
3519 // Standards-based browsers support DOMContentLoaded
3520 } else if ( document.addEventListener ) {
3521 // Use the handy event callback
3522 document.addEventListener( "DOMContentLoaded", completed, false );
3524 // A fallback to window.onload, that will always work
3525 window.addEventListener( "load", completed, false );
3527 // If IE event model is used
3529 // Ensure firing before onload, maybe late but safe also for iframes
3530 document.attachEvent( "onreadystatechange", completed );
3532 // A fallback to window.onload, that will always work
3533 window.attachEvent( "onload", completed );
3535 // If IE and not a frame
3536 // continually check to see if the document is ready
3540 top = window.frameElement == null && document.documentElement;
3543 if ( top && top.doScroll ) {
3544 (function doScrollCheck() {
3545 if ( !jQuery.isReady ) {
3548 // Use the trick by Diego Perini
3549 // http://javascript.nwbox.com/IEContentLoaded/
3550 top.doScroll("left");
3552 return setTimeout( doScrollCheck, 50 );
3555 // detach all dom ready events
3558 // and execute any waiting functions
3565 return readyList.promise( obj );
3569 var strundefined = typeof undefined;
3574 // Iteration over object's inherited properties before its own
3576 for ( i in jQuery( support ) ) {
3579 support.ownLast = i !== "0";
3581 // Note: most support tests are defined in their respective modules.
3582 // false until the test is run
3583 support.inlineBlockNeedsLayout = false;
3585 // Execute ASAP in case we need to set body.style.zoom
3587 // Minified: var a,b,c,d
3588 var val, div, body, container;
3590 body = document.getElementsByTagName( "body" )[ 0 ];
3591 if ( !body || !body.style ) {
3592 // Return for frameset docs that don't have a body
3597 div = document.createElement( "div" );
3598 container = document.createElement( "div" );
3599 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
3600 body.appendChild( container ).appendChild( div );
3602 if ( typeof div.style.zoom !== strundefined ) {
3604 // Check if natively block-level elements act like inline-block
3605 // elements when setting their display to 'inline' and giving
3607 div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
3609 support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
3611 // Prevent IE 6 from affecting layout for positioned elements #11048
3612 // Prevent IE from shrinking the body in IE 7 mode #12869
3614 body.style.zoom = 1;
3618 body.removeChild( container );
3625 var div = document.createElement( "div" );
3627 // Execute the test only if not already executed in another module.
3628 if (support.deleteExpando == null) {
3630 support.deleteExpando = true;
3634 support.deleteExpando = false;
3638 // Null elements to avoid leaks in IE.
3644 * Determines whether an object can have data
3646 jQuery.acceptData = function( elem ) {
3647 var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
3648 nodeType = +elem.nodeType || 1;
3650 // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
3651 return nodeType !== 1 && nodeType !== 9 ?
3654 // Nodes accept data unless otherwise specified; rejection can be conditional
3655 !noData || noData !== true && elem.getAttribute("classid") === noData;
3659 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3660 rmultiDash = /([A-Z])/g;
3662 function dataAttr( elem, key, data ) {
3663 // If nothing was found internally, try to fetch any
3664 // data from the HTML5 data-* attribute
3665 if ( data === undefined && elem.nodeType === 1 ) {
3667 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3669 data = elem.getAttribute( name );
3671 if ( typeof data === "string" ) {
3673 data = data === "true" ? true :
3674 data === "false" ? false :
3675 data === "null" ? null :
3676 // Only convert to a number if it doesn't change the string
3677 +data + "" === data ? +data :
3678 rbrace.test( data ) ? jQuery.parseJSON( data ) :
3682 // Make sure we set the data so it isn't changed later
3683 jQuery.data( elem, key, data );
3693 // checks a cache object for emptiness
3694 function isEmptyDataObject( obj ) {
3696 for ( name in obj ) {
3698 // if the public data object is empty, the private is still empty
3699 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
3702 if ( name !== "toJSON" ) {
3710 function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
3711 if ( !jQuery.acceptData( elem ) ) {
3716 internalKey = jQuery.expando,
3718 // We have to handle DOM nodes and JS objects differently because IE6-7
3719 // can't GC object references properly across the DOM-JS boundary
3720 isNode = elem.nodeType,
3722 // Only DOM nodes need the global jQuery cache; JS object data is
3723 // attached directly to the object so GC can occur automatically
3724 cache = isNode ? jQuery.cache : elem,
3726 // Only defining an ID for JS objects if its cache already exists allows
3727 // the code to shortcut on the same path as a DOM node with no cache
3728 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
3730 // Avoid doing any more work than we need to when trying to get data on an
3731 // object that has no data at all
3732 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
3737 // Only DOM nodes need a new unique ID for each element since their data
3738 // ends up in the global cache
3740 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
3746 if ( !cache[ id ] ) {
3747 // Avoid exposing jQuery metadata on plain JS objects when the object
3748 // is serialized using JSON.stringify
3749 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
3752 // An object can be passed to jQuery.data instead of a key/value pair; this gets
3753 // shallow copied over onto the existing cache
3754 if ( typeof name === "object" || typeof name === "function" ) {
3756 cache[ id ] = jQuery.extend( cache[ id ], name );
3758 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
3762 thisCache = cache[ id ];
3764 // jQuery data() is stored in a separate object inside the object's internal data
3765 // cache in order to avoid key collisions between internal data and user-defined
3768 if ( !thisCache.data ) {
3769 thisCache.data = {};
3772 thisCache = thisCache.data;
3775 if ( data !== undefined ) {
3776 thisCache[ jQuery.camelCase( name ) ] = data;
3779 // Check for both converted-to-camel and non-converted data property names
3780 // If a data property was specified
3781 if ( typeof name === "string" ) {
3783 // First Try to find as-is property data
3784 ret = thisCache[ name ];
3786 // Test for null|undefined property data
3787 if ( ret == null ) {
3789 // Try to find the camelCased property
3790 ret = thisCache[ jQuery.camelCase( name ) ];
3799 function internalRemoveData( elem, name, pvt ) {
3800 if ( !jQuery.acceptData( elem ) ) {
3805 isNode = elem.nodeType,
3807 // See jQuery.data for more information
3808 cache = isNode ? jQuery.cache : elem,
3809 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
3811 // If there is already no cache entry for this object, there is no
3812 // purpose in continuing
3813 if ( !cache[ id ] ) {
3819 thisCache = pvt ? cache[ id ] : cache[ id ].data;
3823 // Support array or space separated string names for data keys
3824 if ( !jQuery.isArray( name ) ) {
3826 // try the string as a key before any manipulation
3827 if ( name in thisCache ) {
3831 // split the camel cased version by spaces unless a key with the spaces exists
3832 name = jQuery.camelCase( name );
3833 if ( name in thisCache ) {
3836 name = name.split(" ");
3840 // If "name" is an array of keys...
3841 // When data is initially created, via ("key", "val") signature,
3842 // keys will be converted to camelCase.
3843 // Since there is no way to tell _how_ a key was added, remove
3844 // both plain key and camelCase key. #12786
3845 // This will only penalize the array argument path.
3846 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
3851 delete thisCache[ name[i] ];
3854 // If there is no data left in the cache, we want to continue
3855 // and let the cache object itself get destroyed
3856 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
3862 // See jQuery.data for more information
3864 delete cache[ id ].data;
3866 // Don't destroy the parent cache unless the internal data object
3867 // had been the only thing left in it
3868 if ( !isEmptyDataObject( cache[ id ] ) ) {
3873 // Destroy the cache
3875 jQuery.cleanData( [ elem ], true );
3877 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
3878 /* jshint eqeqeq: false */
3879 } else if ( support.deleteExpando || cache != cache.window ) {
3880 /* jshint eqeqeq: true */
3883 // When all else fails, null
3892 // The following elements (space-suffixed to avoid Object.prototype collisions)
3893 // throw uncatchable exceptions if you attempt to set expando properties
3897 // ...but Flash objects (which have this classid) *can* handle expandos
3898 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
3901 hasData: function( elem ) {
3902 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
3903 return !!elem && !isEmptyDataObject( elem );
3906 data: function( elem, name, data ) {
3907 return internalData( elem, name, data );
3910 removeData: function( elem, name ) {
3911 return internalRemoveData( elem, name );
3914 // For internal use only.
3915 _data: function( elem, name, data ) {
3916 return internalData( elem, name, data, true );
3919 _removeData: function( elem, name ) {
3920 return internalRemoveData( elem, name, true );
3925 data: function( key, value ) {
3928 attrs = elem && elem.attributes;
3930 // Special expections of .data basically thwart jQuery.access,
3931 // so implement the relevant behavior ourselves
3934 if ( key === undefined ) {
3935 if ( this.length ) {
3936 data = jQuery.data( elem );
3938 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
3943 // The attrs elements can be null (#14894)
3945 name = attrs[ i ].name;
3946 if ( name.indexOf( "data-" ) === 0 ) {
3947 name = jQuery.camelCase( name.slice(5) );
3948 dataAttr( elem, name, data[ name ] );
3952 jQuery._data( elem, "parsedAttrs", true );
3959 // Sets multiple values
3960 if ( typeof key === "object" ) {
3961 return this.each(function() {
3962 jQuery.data( this, key );
3966 return arguments.length > 1 ?
3969 this.each(function() {
3970 jQuery.data( this, key, value );
3974 // Try to fetch any internally stored data first
3975 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
3978 removeData: function( key ) {
3979 return this.each(function() {
3980 jQuery.removeData( this, key );
3987 queue: function( elem, type, data ) {
3991 type = ( type || "fx" ) + "queue";
3992 queue = jQuery._data( elem, type );
3994 // Speed up dequeue by getting out quickly if this is just a lookup
3996 if ( !queue || jQuery.isArray(data) ) {
3997 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
4006 dequeue: function( elem, type ) {
4007 type = type || "fx";
4009 var queue = jQuery.queue( elem, type ),
4010 startLength = queue.length,
4012 hooks = jQuery._queueHooks( elem, type ),
4014 jQuery.dequeue( elem, type );
4017 // If the fx queue is dequeued, always remove the progress sentinel
4018 if ( fn === "inprogress" ) {
4025 // Add a progress sentinel to prevent the fx queue from being
4026 // automatically dequeued
4027 if ( type === "fx" ) {
4028 queue.unshift( "inprogress" );
4031 // clear up the last queue stop function
4033 fn.call( elem, next, hooks );
4036 if ( !startLength && hooks ) {
4041 // not intended for public consumption - generates a queueHooks object, or returns the current one
4042 _queueHooks: function( elem, type ) {
4043 var key = type + "queueHooks";
4044 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
4045 empty: jQuery.Callbacks("once memory").add(function() {
4046 jQuery._removeData( elem, type + "queue" );
4047 jQuery._removeData( elem, key );
4054 queue: function( type, data ) {
4057 if ( typeof type !== "string" ) {
4063 if ( arguments.length < setter ) {
4064 return jQuery.queue( this[0], type );
4067 return data === undefined ?
4069 this.each(function() {
4070 var queue = jQuery.queue( this, type, data );
4072 // ensure a hooks for this queue
4073 jQuery._queueHooks( this, type );
4075 if ( type === "fx" && queue[0] !== "inprogress" ) {
4076 jQuery.dequeue( this, type );
4080 dequeue: function( type ) {
4081 return this.each(function() {
4082 jQuery.dequeue( this, type );
4085 clearQueue: function( type ) {
4086 return this.queue( type || "fx", [] );
4088 // Get a promise resolved when queues of a certain type
4089 // are emptied (fx is the type by default)
4090 promise: function( type, obj ) {
4093 defer = jQuery.Deferred(),
4096 resolve = function() {
4097 if ( !( --count ) ) {
4098 defer.resolveWith( elements, [ elements ] );
4102 if ( typeof type !== "string" ) {
4106 type = type || "fx";
4109 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
4110 if ( tmp && tmp.empty ) {
4112 tmp.empty.add( resolve );
4116 return defer.promise( obj );
4119 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
4121 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4123 var isHidden = function( elem, el ) {
4124 // isHidden might be called from jQuery#filter function;
4125 // in that case, element will be second argument
4127 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
4132 // Multifunctional method to get and set values of a collection
4133 // The value/s can optionally be executed if it's a function
4134 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4136 length = elems.length,
4140 if ( jQuery.type( key ) === "object" ) {
4143 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
4147 } else if ( value !== undefined ) {
4150 if ( !jQuery.isFunction( value ) ) {
4155 // Bulk operations run against the entire set
4157 fn.call( elems, value );
4160 // ...except when executing function values
4163 fn = function( elem, key, value ) {
4164 return bulk.call( jQuery( elem ), value );
4170 for ( ; i < length; i++ ) {
4171 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
4182 length ? fn( elems[0], key ) : emptyGet;
4184 var rcheckableType = (/^(?:checkbox|radio)$/i);
4189 // Minified: var a,b,c
4190 var input = document.createElement( "input" ),
4191 div = document.createElement( "div" ),
4192 fragment = document.createDocumentFragment();
4195 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
4197 // IE strips leading whitespace when .innerHTML is used
4198 support.leadingWhitespace = div.firstChild.nodeType === 3;
4200 // Make sure that tbody elements aren't automatically inserted
4201 // IE will insert them into empty tables
4202 support.tbody = !div.getElementsByTagName( "tbody" ).length;
4204 // Make sure that link elements get serialized correctly by innerHTML
4205 // This requires a wrapper element in IE
4206 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
4208 // Makes sure cloning an html5 element does not cause problems
4209 // Where outerHTML is undefined, this still works
4210 support.html5Clone =
4211 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
4213 // Check if a disconnected checkbox will retain its checked
4214 // value of true after appended to the DOM (IE6/7)
4215 input.type = "checkbox";
4216 input.checked = true;
4217 fragment.appendChild( input );
4218 support.appendChecked = input.checked;
4220 // Make sure textarea (and checkbox) defaultValue is properly cloned
4221 // Support: IE6-IE11+
4222 div.innerHTML = "<textarea>x</textarea>";
4223 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4225 // #11217 - WebKit loses check when the name is after the checked attribute
4226 fragment.appendChild( div );
4227 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
4229 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
4230 // old WebKit doesn't clone checked state correctly in fragments
4231 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4234 // Opera does not clone events (and typeof div.attachEvent === undefined).
4235 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
4236 support.noCloneEvent = true;
4237 if ( div.attachEvent ) {
4238 div.attachEvent( "onclick", function() {
4239 support.noCloneEvent = false;
4242 div.cloneNode( true ).click();
4245 // Execute the test only if not already executed in another module.
4246 if (support.deleteExpando == null) {
4248 support.deleteExpando = true;
4252 support.deleteExpando = false;
4260 div = document.createElement( "div" );
4262 // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
4263 for ( i in { submit: true, change: true, focusin: true }) {
4264 eventName = "on" + i;
4266 if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
4267 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
4268 div.setAttribute( eventName, "t" );
4269 support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
4273 // Null elements to avoid leaks in IE.
4278 var rformElems = /^(?:input|select|textarea)$/i,
4280 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
4281 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4282 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
4284 function returnTrue() {
4288 function returnFalse() {
4292 function safeActiveElement() {
4294 return document.activeElement;
4299 * Helper functions for managing events -- not part of the public interface.
4300 * Props to Dean Edwards' addEvent library for many of the ideas.
4306 add: function( elem, types, handler, data, selector ) {
4307 var tmp, events, t, handleObjIn,
4308 special, eventHandle, handleObj,
4309 handlers, type, namespaces, origType,
4310 elemData = jQuery._data( elem );
4312 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4317 // Caller can pass in an object of custom data in lieu of the handler
4318 if ( handler.handler ) {
4319 handleObjIn = handler;
4320 handler = handleObjIn.handler;
4321 selector = handleObjIn.selector;
4324 // Make sure that the handler has a unique ID, used to find/remove it later
4325 if ( !handler.guid ) {
4326 handler.guid = jQuery.guid++;
4329 // Init the element's event structure and main handler, if this is the first
4330 if ( !(events = elemData.events) ) {
4331 events = elemData.events = {};
4333 if ( !(eventHandle = elemData.handle) ) {
4334 eventHandle = elemData.handle = function( e ) {
4335 // Discard the second event of a jQuery.event.trigger() and
4336 // when an event is called after a page has unloaded
4337 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
4338 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
4341 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
4342 eventHandle.elem = elem;
4345 // Handle multiple events separated by a space
4346 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4349 tmp = rtypenamespace.exec( types[t] ) || [];
4350 type = origType = tmp[1];
4351 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4353 // There *must* be a type, no attaching namespace-only handlers
4358 // If event changes its type, use the special event handlers for the changed type
4359 special = jQuery.event.special[ type ] || {};
4361 // If selector defined, determine special event api type, otherwise given type
4362 type = ( selector ? special.delegateType : special.bindType ) || type;
4364 // Update special based on newly reset type
4365 special = jQuery.event.special[ type ] || {};
4367 // handleObj is passed to all event handlers
4368 handleObj = jQuery.extend({
4375 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4376 namespace: namespaces.join(".")
4379 // Init the event handler queue if we're the first
4380 if ( !(handlers = events[ type ]) ) {
4381 handlers = events[ type ] = [];
4382 handlers.delegateCount = 0;
4384 // Only use addEventListener/attachEvent if the special events handler returns false
4385 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4386 // Bind the global event handler to the element
4387 if ( elem.addEventListener ) {
4388 elem.addEventListener( type, eventHandle, false );
4390 } else if ( elem.attachEvent ) {
4391 elem.attachEvent( "on" + type, eventHandle );
4396 if ( special.add ) {
4397 special.add.call( elem, handleObj );
4399 if ( !handleObj.handler.guid ) {
4400 handleObj.handler.guid = handler.guid;
4404 // Add to the element's handler list, delegates in front
4406 handlers.splice( handlers.delegateCount++, 0, handleObj );
4408 handlers.push( handleObj );
4411 // Keep track of which events have ever been used, for event optimization
4412 jQuery.event.global[ type ] = true;
4415 // Nullify elem to prevent memory leaks in IE
4419 // Detach an event or set of events from an element
4420 remove: function( elem, types, handler, selector, mappedTypes ) {
4421 var j, handleObj, tmp,
4422 origCount, t, events,
4423 special, handlers, type,
4424 namespaces, origType,
4425 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
4427 if ( !elemData || !(events = elemData.events) ) {
4431 // Once for each type.namespace in types; type may be omitted
4432 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4435 tmp = rtypenamespace.exec( types[t] ) || [];
4436 type = origType = tmp[1];
4437 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4439 // Unbind all events (on this namespace, if provided) for the element
4441 for ( type in events ) {
4442 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4447 special = jQuery.event.special[ type ] || {};
4448 type = ( selector ? special.delegateType : special.bindType ) || type;
4449 handlers = events[ type ] || [];
4450 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4452 // Remove matching events
4453 origCount = j = handlers.length;
4455 handleObj = handlers[ j ];
4457 if ( ( mappedTypes || origType === handleObj.origType ) &&
4458 ( !handler || handler.guid === handleObj.guid ) &&
4459 ( !tmp || tmp.test( handleObj.namespace ) ) &&
4460 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
4461 handlers.splice( j, 1 );
4463 if ( handleObj.selector ) {
4464 handlers.delegateCount--;
4466 if ( special.remove ) {
4467 special.remove.call( elem, handleObj );
4472 // Remove generic event handler if we removed something and no more handlers exist
4473 // (avoids potential for endless recursion during removal of special event handlers)
4474 if ( origCount && !handlers.length ) {
4475 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
4476 jQuery.removeEvent( elem, type, elemData.handle );
4479 delete events[ type ];
4483 // Remove the expando if it's no longer used
4484 if ( jQuery.isEmptyObject( events ) ) {
4485 delete elemData.handle;
4487 // removeData also checks for emptiness and clears the expando if empty
4488 // so use it instead of delete
4489 jQuery._removeData( elem, "events" );
4493 trigger: function( event, data, elem, onlyHandlers ) {
4494 var handle, ontype, cur,
4495 bubbleType, special, tmp, i,
4496 eventPath = [ elem || document ],
4497 type = hasOwn.call( event, "type" ) ? event.type : event,
4498 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
4500 cur = tmp = elem = elem || document;
4502 // Don't do events on text and comment nodes
4503 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
4507 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4508 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
4512 if ( type.indexOf(".") >= 0 ) {
4513 // Namespaced trigger; create a regexp to match event type in handle()
4514 namespaces = type.split(".");
4515 type = namespaces.shift();
4518 ontype = type.indexOf(":") < 0 && "on" + type;
4520 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4521 event = event[ jQuery.expando ] ?
4523 new jQuery.Event( type, typeof event === "object" && event );
4525 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4526 event.isTrigger = onlyHandlers ? 2 : 3;
4527 event.namespace = namespaces.join(".");
4528 event.namespace_re = event.namespace ?
4529 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4532 // Clean up the event in case it is being reused
4533 event.result = undefined;
4534 if ( !event.target ) {
4535 event.target = elem;
4538 // Clone any incoming data and prepend the event, creating the handler arg list
4539 data = data == null ?
4541 jQuery.makeArray( data, [ event ] );
4543 // Allow special events to draw outside the lines
4544 special = jQuery.event.special[ type ] || {};
4545 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
4549 // Determine event propagation path in advance, per W3C events spec (#9951)
4550 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4551 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
4553 bubbleType = special.delegateType || type;
4554 if ( !rfocusMorph.test( bubbleType + type ) ) {
4555 cur = cur.parentNode;
4557 for ( ; cur; cur = cur.parentNode ) {
4558 eventPath.push( cur );
4562 // Only add window if we got to document (e.g., not plain obj or detached DOM)
4563 if ( tmp === (elem.ownerDocument || document) ) {
4564 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
4568 // Fire handlers on the event path
4570 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
4572 event.type = i > 1 ?
4574 special.bindType || type;
4577 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
4579 handle.apply( cur, data );
4583 handle = ontype && cur[ ontype ];
4584 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
4585 event.result = handle.apply( cur, data );
4586 if ( event.result === false ) {
4587 event.preventDefault();
4593 // If nobody prevented the default action, do it now
4594 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
4596 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
4597 jQuery.acceptData( elem ) ) {
4599 // Call a native DOM method on the target with the same name name as the event.
4600 // Can't use an .isFunction() check here because IE6/7 fails that test.
4601 // Don't do default actions on window, that's where global variables be (#6170)
4602 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
4604 // Don't re-trigger an onFOO event when we call its FOO() method
4605 tmp = elem[ ontype ];
4608 elem[ ontype ] = null;
4611 // Prevent re-triggering of the same event, since we already bubbled it above
4612 jQuery.event.triggered = type;
4616 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
4617 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
4619 jQuery.event.triggered = undefined;
4622 elem[ ontype ] = tmp;
4628 return event.result;
4631 dispatch: function( event ) {
4633 // Make a writable jQuery.Event from the native event object
4634 event = jQuery.event.fix( event );
4636 var i, ret, handleObj, matched, j,
4638 args = slice.call( arguments ),
4639 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
4640 special = jQuery.event.special[ event.type ] || {};
4642 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4644 event.delegateTarget = this;
4646 // Call the preDispatch hook for the mapped type, and let it bail if desired
4647 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
4651 // Determine handlers
4652 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
4654 // Run delegates first; they may want to stop propagation beneath us
4656 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
4657 event.currentTarget = matched.elem;
4660 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
4662 // Triggered event must either 1) have no namespace, or
4663 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
4664 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
4666 event.handleObj = handleObj;
4667 event.data = handleObj.data;
4669 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
4670 .apply( matched.elem, args );
4672 if ( ret !== undefined ) {
4673 if ( (event.result = ret) === false ) {
4674 event.preventDefault();
4675 event.stopPropagation();
4682 // Call the postDispatch hook for the mapped type
4683 if ( special.postDispatch ) {
4684 special.postDispatch.call( this, event );
4687 return event.result;
4690 handlers: function( event, handlers ) {
4691 var sel, handleObj, matches, i,
4693 delegateCount = handlers.delegateCount,
4696 // Find delegate handlers
4697 // Black-hole SVG <use> instance trees (#13180)
4698 // Avoid non-left-click bubbling in Firefox (#3861)
4699 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
4701 /* jshint eqeqeq: false */
4702 for ( ; cur != this; cur = cur.parentNode || this ) {
4703 /* jshint eqeqeq: true */
4705 // Don't check non-elements (#13208)
4706 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4707 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
4709 for ( i = 0; i < delegateCount; i++ ) {
4710 handleObj = handlers[ i ];
4712 // Don't conflict with Object.prototype properties (#13203)
4713 sel = handleObj.selector + " ";
4715 if ( matches[ sel ] === undefined ) {
4716 matches[ sel ] = handleObj.needsContext ?
4717 jQuery( sel, this ).index( cur ) >= 0 :
4718 jQuery.find( sel, this, null, [ cur ] ).length;
4720 if ( matches[ sel ] ) {
4721 matches.push( handleObj );
4724 if ( matches.length ) {
4725 handlerQueue.push({ elem: cur, handlers: matches });
4731 // Add the remaining (directly-bound) handlers
4732 if ( delegateCount < handlers.length ) {
4733 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
4736 return handlerQueue;
4739 fix: function( event ) {
4740 if ( event[ jQuery.expando ] ) {
4744 // Create a writable copy of the event object and normalize some properties
4747 originalEvent = event,
4748 fixHook = this.fixHooks[ type ];
4751 this.fixHooks[ type ] = fixHook =
4752 rmouseEvent.test( type ) ? this.mouseHooks :
4753 rkeyEvent.test( type ) ? this.keyHooks :
4756 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
4758 event = new jQuery.Event( originalEvent );
4763 event[ prop ] = originalEvent[ prop ];
4767 // Fix target property (#1925)
4768 if ( !event.target ) {
4769 event.target = originalEvent.srcElement || document;
4772 // Support: Chrome 23+, Safari?
4773 // Target should not be a text node (#504, #13143)
4774 if ( event.target.nodeType === 3 ) {
4775 event.target = event.target.parentNode;
4779 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
4780 event.metaKey = !!event.metaKey;
4782 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
4785 // Includes some event props shared by KeyEvent and MouseEvent
4786 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
4791 props: "char charCode key keyCode".split(" "),
4792 filter: function( event, original ) {
4794 // Add which for key events
4795 if ( event.which == null ) {
4796 event.which = original.charCode != null ? original.charCode : original.keyCode;
4804 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
4805 filter: function( event, original ) {
4806 var body, eventDoc, doc,
4807 button = original.button,
4808 fromElement = original.fromElement;
4810 // Calculate pageX/Y if missing and clientX/Y available
4811 if ( event.pageX == null && original.clientX != null ) {
4812 eventDoc = event.target.ownerDocument || document;
4813 doc = eventDoc.documentElement;
4814 body = eventDoc.body;
4816 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
4817 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
4820 // Add relatedTarget, if necessary
4821 if ( !event.relatedTarget && fromElement ) {
4822 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
4825 // Add which for click: 1 === left; 2 === middle; 3 === right
4826 // Note: button is not normalized, so don't use it
4827 if ( !event.which && button !== undefined ) {
4828 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
4837 // Prevent triggered image.load events from bubbling to window.load
4841 // Fire native event if possible so blur/focus sequence is correct
4842 trigger: function() {
4843 if ( this !== safeActiveElement() && this.focus ) {
4849 // If we error on focus to hidden element (#1486, #12518),
4850 // let .trigger() run the handlers
4854 delegateType: "focusin"
4857 trigger: function() {
4858 if ( this === safeActiveElement() && this.blur ) {
4863 delegateType: "focusout"
4866 // For checkbox, fire native event so checked state will be right
4867 trigger: function() {
4868 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
4874 // For cross-browser consistency, don't fire native .click() on links
4875 _default: function( event ) {
4876 return jQuery.nodeName( event.target, "a" );
4881 postDispatch: function( event ) {
4883 // Support: Firefox 20+
4884 // Firefox doesn't alert if the returnValue field is not set.
4885 if ( event.result !== undefined && event.originalEvent ) {
4886 event.originalEvent.returnValue = event.result;
4892 simulate: function( type, elem, event, bubble ) {
4893 // Piggyback on a donor event to simulate a different one.
4894 // Fake originalEvent to avoid donor's stopPropagation, but if the
4895 // simulated event prevents default then we do the same on the donor.
4896 var e = jQuery.extend(
4906 jQuery.event.trigger( e, null, elem );
4908 jQuery.event.dispatch.call( elem, e );
4910 if ( e.isDefaultPrevented() ) {
4911 event.preventDefault();
4916 jQuery.removeEvent = document.removeEventListener ?
4917 function( elem, type, handle ) {
4918 if ( elem.removeEventListener ) {
4919 elem.removeEventListener( type, handle, false );
4922 function( elem, type, handle ) {
4923 var name = "on" + type;
4925 if ( elem.detachEvent ) {
4927 // #8545, #7054, preventing memory leaks for custom events in IE6-8
4928 // detachEvent needed property on element, by name of that event, to properly expose it to GC
4929 if ( typeof elem[ name ] === strundefined ) {
4930 elem[ name ] = null;
4933 elem.detachEvent( name, handle );
4937 jQuery.Event = function( src, props ) {
4938 // Allow instantiation without the 'new' keyword
4939 if ( !(this instanceof jQuery.Event) ) {
4940 return new jQuery.Event( src, props );
4944 if ( src && src.type ) {
4945 this.originalEvent = src;
4946 this.type = src.type;
4948 // Events bubbling up the document may have been marked as prevented
4949 // by a handler lower down the tree; reflect the correct value.
4950 this.isDefaultPrevented = src.defaultPrevented ||
4951 src.defaultPrevented === undefined &&
4952 // Support: IE < 9, Android < 4.0
4953 src.returnValue === false ?
4962 // Put explicitly provided properties onto the event object
4964 jQuery.extend( this, props );
4967 // Create a timestamp if incoming event doesn't have one
4968 this.timeStamp = src && src.timeStamp || jQuery.now();
4971 this[ jQuery.expando ] = true;
4974 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4975 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4976 jQuery.Event.prototype = {
4977 isDefaultPrevented: returnFalse,
4978 isPropagationStopped: returnFalse,
4979 isImmediatePropagationStopped: returnFalse,
4981 preventDefault: function() {
4982 var e = this.originalEvent;
4984 this.isDefaultPrevented = returnTrue;
4989 // If preventDefault exists, run it on the original event
4990 if ( e.preventDefault ) {
4994 // Otherwise set the returnValue property of the original event to false
4996 e.returnValue = false;
4999 stopPropagation: function() {
5000 var e = this.originalEvent;
5002 this.isPropagationStopped = returnTrue;
5006 // If stopPropagation exists, run it on the original event
5007 if ( e.stopPropagation ) {
5008 e.stopPropagation();
5012 // Set the cancelBubble property of the original event to true
5013 e.cancelBubble = true;
5015 stopImmediatePropagation: function() {
5016 var e = this.originalEvent;
5018 this.isImmediatePropagationStopped = returnTrue;
5020 if ( e && e.stopImmediatePropagation ) {
5021 e.stopImmediatePropagation();
5024 this.stopPropagation();
5028 // Create mouseenter/leave events using mouseover/out and event-time checks
5030 mouseenter: "mouseover",
5031 mouseleave: "mouseout",
5032 pointerenter: "pointerover",
5033 pointerleave: "pointerout"
5034 }, function( orig, fix ) {
5035 jQuery.event.special[ orig ] = {
5039 handle: function( event ) {
5042 related = event.relatedTarget,
5043 handleObj = event.handleObj;
5045 // For mousenter/leave call the handler if related is outside the target.
5046 // NB: No relatedTarget if the mouse left/entered the browser window
5047 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
5048 event.type = handleObj.origType;
5049 ret = handleObj.handler.apply( this, arguments );
5057 // IE submit delegation
5058 if ( !support.submitBubbles ) {
5060 jQuery.event.special.submit = {
5062 // Only need this for delegated form submit events
5063 if ( jQuery.nodeName( this, "form" ) ) {
5067 // Lazy-add a submit handler when a descendant form may potentially be submitted
5068 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
5069 // Node name check avoids a VML-related crash in IE (#9807)
5070 var elem = e.target,
5071 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
5072 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
5073 jQuery.event.add( form, "submit._submit", function( event ) {
5074 event._submit_bubble = true;
5076 jQuery._data( form, "submitBubbles", true );
5079 // return undefined since we don't need an event listener
5082 postDispatch: function( event ) {
5083 // If form was submitted by the user, bubble the event up the tree
5084 if ( event._submit_bubble ) {
5085 delete event._submit_bubble;
5086 if ( this.parentNode && !event.isTrigger ) {
5087 jQuery.event.simulate( "submit", this.parentNode, event, true );
5092 teardown: function() {
5093 // Only need this for delegated form submit events
5094 if ( jQuery.nodeName( this, "form" ) ) {
5098 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
5099 jQuery.event.remove( this, "._submit" );
5104 // IE change delegation and checkbox/radio fix
5105 if ( !support.changeBubbles ) {
5107 jQuery.event.special.change = {
5111 if ( rformElems.test( this.nodeName ) ) {
5112 // IE doesn't fire change on a check/radio until blur; trigger it on click
5113 // after a propertychange. Eat the blur-change in special.change.handle.
5114 // This still fires onchange a second time for check/radio after blur.
5115 if ( this.type === "checkbox" || this.type === "radio" ) {
5116 jQuery.event.add( this, "propertychange._change", function( event ) {
5117 if ( event.originalEvent.propertyName === "checked" ) {
5118 this._just_changed = true;
5121 jQuery.event.add( this, "click._change", function( event ) {
5122 if ( this._just_changed && !event.isTrigger ) {
5123 this._just_changed = false;
5125 // Allow triggered, simulated change events (#11500)
5126 jQuery.event.simulate( "change", this, event, true );
5131 // Delegated event; lazy-add a change handler on descendant inputs
5132 jQuery.event.add( this, "beforeactivate._change", function( e ) {
5133 var elem = e.target;
5135 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
5136 jQuery.event.add( elem, "change._change", function( event ) {
5137 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
5138 jQuery.event.simulate( "change", this.parentNode, event, true );
5141 jQuery._data( elem, "changeBubbles", true );
5146 handle: function( event ) {
5147 var elem = event.target;
5149 // Swallow native change events from checkbox/radio, we already triggered them above
5150 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
5151 return event.handleObj.handler.apply( this, arguments );
5155 teardown: function() {
5156 jQuery.event.remove( this, "._change" );
5158 return !rformElems.test( this.nodeName );
5163 // Create "bubbling" focus and blur events
5164 if ( !support.focusinBubbles ) {
5165 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
5167 // Attach a single capturing handler on the document while someone wants focusin/focusout
5168 var handler = function( event ) {
5169 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
5172 jQuery.event.special[ fix ] = {
5174 var doc = this.ownerDocument || this,
5175 attaches = jQuery._data( doc, fix );
5178 doc.addEventListener( orig, handler, true );
5180 jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
5182 teardown: function() {
5183 var doc = this.ownerDocument || this,
5184 attaches = jQuery._data( doc, fix ) - 1;
5187 doc.removeEventListener( orig, handler, true );
5188 jQuery._removeData( doc, fix );
5190 jQuery._data( doc, fix, attaches );
5199 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
5202 // Types can be a map of types/handlers
5203 if ( typeof types === "object" ) {
5204 // ( types-Object, selector, data )
5205 if ( typeof selector !== "string" ) {
5206 // ( types-Object, data )
5207 data = data || selector;
5208 selector = undefined;
5210 for ( type in types ) {
5211 this.on( type, selector, data, types[ type ], one );
5216 if ( data == null && fn == null ) {
5219 data = selector = undefined;
5220 } else if ( fn == null ) {
5221 if ( typeof selector === "string" ) {
5222 // ( types, selector, fn )
5226 // ( types, data, fn )
5229 selector = undefined;
5232 if ( fn === false ) {
5240 fn = function( event ) {
5241 // Can use an empty set, since event contains the info
5242 jQuery().off( event );
5243 return origFn.apply( this, arguments );
5245 // Use same guid so caller can remove using origFn
5246 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
5248 return this.each( function() {
5249 jQuery.event.add( this, types, fn, data, selector );
5252 one: function( types, selector, data, fn ) {
5253 return this.on( types, selector, data, fn, 1 );
5255 off: function( types, selector, fn ) {
5256 var handleObj, type;
5257 if ( types && types.preventDefault && types.handleObj ) {
5258 // ( event ) dispatched jQuery.Event
5259 handleObj = types.handleObj;
5260 jQuery( types.delegateTarget ).off(
5261 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
5267 if ( typeof types === "object" ) {
5268 // ( types-object [, selector] )
5269 for ( type in types ) {
5270 this.off( type, selector, types[ type ] );
5274 if ( selector === false || typeof selector === "function" ) {
5277 selector = undefined;
5279 if ( fn === false ) {
5282 return this.each(function() {
5283 jQuery.event.remove( this, types, fn, selector );
5287 trigger: function( type, data ) {
5288 return this.each(function() {
5289 jQuery.event.trigger( type, data, this );
5292 triggerHandler: function( type, data ) {
5295 return jQuery.event.trigger( type, data, elem, true );
5301 function createSafeFragment( document ) {
5302 var list = nodeNames.split( "|" ),
5303 safeFrag = document.createDocumentFragment();
5305 if ( safeFrag.createElement ) {
5306 while ( list.length ) {
5307 safeFrag.createElement(
5315 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5316 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5317 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5318 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5319 rleadingWhitespace = /^\s+/,
5320 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5321 rtagName = /<([\w:]+)/,
5323 rhtml = /<|&#?\w+;/,
5324 rnoInnerhtml = /<(?:script|style|link)/i,
5325 // checked="checked" or checked
5326 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5327 rscriptType = /^$|\/(?:java|ecma)script/i,
5328 rscriptTypeMasked = /^true\/(.*)/,
5329 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
5331 // We have to close these tags to support XHTML (#13200)
5333 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5334 legend: [ 1, "<fieldset>", "</fieldset>" ],
5335 area: [ 1, "<map>", "</map>" ],
5336 param: [ 1, "<object>", "</object>" ],
5337 thead: [ 1, "<table>", "</table>" ],
5338 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5339 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5340 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5342 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5343 // unless wrapped in a div with non-breaking characters in front of it.
5344 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
5346 safeFragment = createSafeFragment( document ),
5347 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5349 wrapMap.optgroup = wrapMap.option;
5350 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5351 wrapMap.th = wrapMap.td;
5353 function getAll( context, tag ) {
5356 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
5357 typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
5361 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
5362 if ( !tag || jQuery.nodeName( elem, tag ) ) {
5365 jQuery.merge( found, getAll( elem, tag ) );
5370 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
5371 jQuery.merge( [ context ], found ) :
5375 // Used in buildFragment, fixes the defaultChecked property
5376 function fixDefaultChecked( elem ) {
5377 if ( rcheckableType.test( elem.type ) ) {
5378 elem.defaultChecked = elem.checked;
5383 // Manipulating tables requires a tbody
5384 function manipulationTarget( elem, content ) {
5385 return jQuery.nodeName( elem, "table" ) &&
5386 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
5388 elem.getElementsByTagName("tbody")[0] ||
5389 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
5393 // Replace/restore the type attribute of script elements for safe DOM manipulation
5394 function disableScript( elem ) {
5395 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
5398 function restoreScript( elem ) {
5399 var match = rscriptTypeMasked.exec( elem.type );
5401 elem.type = match[1];
5403 elem.removeAttribute("type");
5408 // Mark scripts as having already been evaluated
5409 function setGlobalEval( elems, refElements ) {
5412 for ( ; (elem = elems[i]) != null; i++ ) {
5413 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
5417 function cloneCopyEvent( src, dest ) {
5419 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5424 oldData = jQuery._data( src ),
5425 curData = jQuery._data( dest, oldData ),
5426 events = oldData.events;
5429 delete curData.handle;
5430 curData.events = {};
5432 for ( type in events ) {
5433 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5434 jQuery.event.add( dest, type, events[ type ][ i ] );
5439 // make the cloned public data object a copy from the original
5440 if ( curData.data ) {
5441 curData.data = jQuery.extend( {}, curData.data );
5445 function fixCloneNodeIssues( src, dest ) {
5446 var nodeName, e, data;
5448 // We do not need to do anything for non-Elements
5449 if ( dest.nodeType !== 1 ) {
5453 nodeName = dest.nodeName.toLowerCase();
5455 // IE6-8 copies events bound via attachEvent when using cloneNode.
5456 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
5457 data = jQuery._data( dest );
5459 for ( e in data.events ) {
5460 jQuery.removeEvent( dest, e, data.handle );
5463 // Event data gets referenced instead of copied if the expando gets copied too
5464 dest.removeAttribute( jQuery.expando );
5467 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
5468 if ( nodeName === "script" && dest.text !== src.text ) {
5469 disableScript( dest ).text = src.text;
5470 restoreScript( dest );
5472 // IE6-10 improperly clones children of object elements using classid.
5473 // IE10 throws NoModificationAllowedError if parent is null, #12132.
5474 } else if ( nodeName === "object" ) {
5475 if ( dest.parentNode ) {
5476 dest.outerHTML = src.outerHTML;
5479 // This path appears unavoidable for IE9. When cloning an object
5480 // element in IE9, the outerHTML strategy above is not sufficient.
5481 // If the src has innerHTML and the destination does not,
5482 // copy the src.innerHTML into the dest.innerHTML. #10324
5483 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
5484 dest.innerHTML = src.innerHTML;
5487 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5488 // IE6-8 fails to persist the checked state of a cloned checkbox
5489 // or radio button. Worse, IE6-7 fail to give the cloned element
5490 // a checked appearance if the defaultChecked value isn't also set
5492 dest.defaultChecked = dest.checked = src.checked;
5494 // IE6-7 get confused and end up setting the value of a cloned
5495 // checkbox/radio button to an empty string instead of "on"
5496 if ( dest.value !== src.value ) {
5497 dest.value = src.value;
5500 // IE6-8 fails to return the selected option to the default selected
5501 // state when cloning options
5502 } else if ( nodeName === "option" ) {
5503 dest.defaultSelected = dest.selected = src.defaultSelected;
5505 // IE6-8 fails to set the defaultValue to the correct value when
5506 // cloning other types of input fields
5507 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5508 dest.defaultValue = src.defaultValue;
5513 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5514 var destElements, node, clone, i, srcElements,
5515 inPage = jQuery.contains( elem.ownerDocument, elem );
5517 if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
5518 clone = elem.cloneNode( true );
5520 // IE<=8 does not properly clone detached, unknown element nodes
5522 fragmentDiv.innerHTML = elem.outerHTML;
5523 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
5526 if ( (!support.noCloneEvent || !support.noCloneChecked) &&
5527 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
5529 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5530 destElements = getAll( clone );
5531 srcElements = getAll( elem );
5533 // Fix all IE cloning issues
5534 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
5535 // Ensure that the destination node is not null; Fixes #9587
5536 if ( destElements[i] ) {
5537 fixCloneNodeIssues( node, destElements[i] );
5542 // Copy the events from the original to the clone
5543 if ( dataAndEvents ) {
5544 if ( deepDataAndEvents ) {
5545 srcElements = srcElements || getAll( elem );
5546 destElements = destElements || getAll( clone );
5548 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
5549 cloneCopyEvent( node, destElements[i] );
5552 cloneCopyEvent( elem, clone );
5556 // Preserve script evaluation history
5557 destElements = getAll( clone, "script" );
5558 if ( destElements.length > 0 ) {
5559 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5562 destElements = srcElements = node = null;
5564 // Return the cloned set
5568 buildFragment: function( elems, context, scripts, selection ) {
5569 var j, elem, contains,
5570 tmp, tag, tbody, wrap,
5573 // Ensure a safe fragment
5574 safe = createSafeFragment( context ),
5579 for ( ; i < l; i++ ) {
5582 if ( elem || elem === 0 ) {
5584 // Add nodes directly
5585 if ( jQuery.type( elem ) === "object" ) {
5586 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
5588 // Convert non-html into a text node
5589 } else if ( !rhtml.test( elem ) ) {
5590 nodes.push( context.createTextNode( elem ) );
5592 // Convert html into DOM nodes
5594 tmp = tmp || safe.appendChild( context.createElement("div") );
5596 // Deserialize a standard representation
5597 tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
5598 wrap = wrapMap[ tag ] || wrapMap._default;
5600 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
5602 // Descend through wrappers to the right content
5605 tmp = tmp.lastChild;
5608 // Manually add leading whitespace removed by IE
5609 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
5610 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
5613 // Remove IE's autoinserted <tbody> from table fragments
5614 if ( !support.tbody ) {
5616 // String was a <table>, *may* have spurious <tbody>
5617 elem = tag === "table" && !rtbody.test( elem ) ?
5620 // String was a bare <thead> or <tfoot>
5621 wrap[1] === "<table>" && !rtbody.test( elem ) ?
5625 j = elem && elem.childNodes.length;
5627 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
5628 elem.removeChild( tbody );
5633 jQuery.merge( nodes, tmp.childNodes );
5635 // Fix #12392 for WebKit and IE > 9
5636 tmp.textContent = "";
5638 // Fix #12392 for oldIE
5639 while ( tmp.firstChild ) {
5640 tmp.removeChild( tmp.firstChild );
5643 // Remember the top-level container for proper cleanup
5644 tmp = safe.lastChild;
5649 // Fix #11356: Clear elements from fragment
5651 safe.removeChild( tmp );
5654 // Reset defaultChecked for any radios and checkboxes
5655 // about to be appended to the DOM in IE 6/7 (#8060)
5656 if ( !support.appendChecked ) {
5657 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
5661 while ( (elem = nodes[ i++ ]) ) {
5663 // #4087 - If origin and destination elements are the same, and this is
5664 // that element, do not do anything
5665 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
5669 contains = jQuery.contains( elem.ownerDocument, elem );
5671 // Append to fragment
5672 tmp = getAll( safe.appendChild( elem ), "script" );
5674 // Preserve script evaluation history
5676 setGlobalEval( tmp );
5679 // Capture executables
5682 while ( (elem = tmp[ j++ ]) ) {
5683 if ( rscriptType.test( elem.type || "" ) ) {
5684 scripts.push( elem );
5695 cleanData: function( elems, /* internal */ acceptData ) {
5696 var elem, type, id, data,
5698 internalKey = jQuery.expando,
5699 cache = jQuery.cache,
5700 deleteExpando = support.deleteExpando,
5701 special = jQuery.event.special;
5703 for ( ; (elem = elems[i]) != null; i++ ) {
5704 if ( acceptData || jQuery.acceptData( elem ) ) {
5706 id = elem[ internalKey ];
5707 data = id && cache[ id ];
5710 if ( data.events ) {
5711 for ( type in data.events ) {
5712 if ( special[ type ] ) {
5713 jQuery.event.remove( elem, type );
5715 // This is a shortcut to avoid jQuery.event.remove's overhead
5717 jQuery.removeEvent( elem, type, data.handle );
5722 // Remove cache only if it was not already removed by jQuery.event.remove
5723 if ( cache[ id ] ) {
5727 // IE does not allow us to delete expando properties from nodes,
5728 // nor does it have a removeAttribute function on Document nodes;
5729 // we must handle all of these cases
5730 if ( deleteExpando ) {
5731 delete elem[ internalKey ];
5733 } else if ( typeof elem.removeAttribute !== strundefined ) {
5734 elem.removeAttribute( internalKey );
5737 elem[ internalKey ] = null;
5740 deletedIds.push( id );
5749 text: function( value ) {
5750 return access( this, function( value ) {
5751 return value === undefined ?
5752 jQuery.text( this ) :
5753 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5754 }, null, value, arguments.length );
5757 append: function() {
5758 return this.domManip( arguments, function( elem ) {
5759 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5760 var target = manipulationTarget( this, elem );
5761 target.appendChild( elem );
5766 prepend: function() {
5767 return this.domManip( arguments, function( elem ) {
5768 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5769 var target = manipulationTarget( this, elem );
5770 target.insertBefore( elem, target.firstChild );
5775 before: function() {
5776 return this.domManip( arguments, function( elem ) {
5777 if ( this.parentNode ) {
5778 this.parentNode.insertBefore( elem, this );
5784 return this.domManip( arguments, function( elem ) {
5785 if ( this.parentNode ) {
5786 this.parentNode.insertBefore( elem, this.nextSibling );
5791 remove: function( selector, keepData /* Internal Use Only */ ) {
5793 elems = selector ? jQuery.filter( selector, this ) : this,
5796 for ( ; (elem = elems[i]) != null; i++ ) {
5798 if ( !keepData && elem.nodeType === 1 ) {
5799 jQuery.cleanData( getAll( elem ) );
5802 if ( elem.parentNode ) {
5803 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
5804 setGlobalEval( getAll( elem, "script" ) );
5806 elem.parentNode.removeChild( elem );
5817 for ( ; (elem = this[i]) != null; i++ ) {
5818 // Remove element nodes and prevent memory leaks
5819 if ( elem.nodeType === 1 ) {
5820 jQuery.cleanData( getAll( elem, false ) );
5823 // Remove any remaining nodes
5824 while ( elem.firstChild ) {
5825 elem.removeChild( elem.firstChild );
5828 // If this is a select, ensure that it displays empty (#12336)
5830 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
5831 elem.options.length = 0;
5838 clone: function( dataAndEvents, deepDataAndEvents ) {
5839 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5840 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5842 return this.map(function() {
5843 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5847 html: function( value ) {
5848 return access( this, function( value ) {
5849 var elem = this[ 0 ] || {},
5853 if ( value === undefined ) {
5854 return elem.nodeType === 1 ?
5855 elem.innerHTML.replace( rinlinejQuery, "" ) :
5859 // See if we can take a shortcut and just use innerHTML
5860 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5861 ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5862 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5863 !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
5865 value = value.replace( rxhtmlTag, "<$1></$2>" );
5868 for (; i < l; i++ ) {
5869 // Remove element nodes and prevent memory leaks
5870 elem = this[i] || {};
5871 if ( elem.nodeType === 1 ) {
5872 jQuery.cleanData( getAll( elem, false ) );
5873 elem.innerHTML = value;
5879 // If using innerHTML throws an exception, use the fallback method
5884 this.empty().append( value );
5886 }, null, value, arguments.length );
5889 replaceWith: function() {
5890 var arg = arguments[ 0 ];
5892 // Make the changes, replacing each context element with the new content
5893 this.domManip( arguments, function( elem ) {
5894 arg = this.parentNode;
5896 jQuery.cleanData( getAll( this ) );
5899 arg.replaceChild( elem, this );
5903 // Force removal if there was no new content (e.g., from empty arguments)
5904 return arg && (arg.length || arg.nodeType) ? this : this.remove();
5907 detach: function( selector ) {
5908 return this.remove( selector, true );
5911 domManip: function( args, callback ) {
5913 // Flatten any nested arrays
5914 args = concat.apply( [], args );
5916 var first, node, hasScripts,
5917 scripts, doc, fragment,
5923 isFunction = jQuery.isFunction( value );
5925 // We can't cloneNode fragments that contain checked, in WebKit
5927 ( l > 1 && typeof value === "string" &&
5928 !support.checkClone && rchecked.test( value ) ) ) {
5929 return this.each(function( index ) {
5930 var self = set.eq( index );
5932 args[0] = value.call( this, index, self.html() );
5934 self.domManip( args, callback );
5939 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
5940 first = fragment.firstChild;
5942 if ( fragment.childNodes.length === 1 ) {
5947 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5948 hasScripts = scripts.length;
5950 // Use the original fragment for the last item instead of the first because it can end up
5951 // being emptied incorrectly in certain situations (#8070).
5952 for ( ; i < l; i++ ) {
5955 if ( i !== iNoClone ) {
5956 node = jQuery.clone( node, true, true );
5958 // Keep references to cloned scripts for later restoration
5960 jQuery.merge( scripts, getAll( node, "script" ) );
5964 callback.call( this[i], node, i );
5968 doc = scripts[ scripts.length - 1 ].ownerDocument;
5971 jQuery.map( scripts, restoreScript );
5973 // Evaluate executable scripts on first document insertion
5974 for ( i = 0; i < hasScripts; i++ ) {
5975 node = scripts[ i ];
5976 if ( rscriptType.test( node.type || "" ) &&
5977 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
5980 // Optional AJAX dependency, but won't run scripts if not present
5981 if ( jQuery._evalUrl ) {
5982 jQuery._evalUrl( node.src );
5985 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
5991 // Fix #11809: Avoid leaking memory
5992 fragment = first = null;
6002 prependTo: "prepend",
6003 insertBefore: "before",
6004 insertAfter: "after",
6005 replaceAll: "replaceWith"
6006 }, function( name, original ) {
6007 jQuery.fn[ name ] = function( selector ) {
6011 insert = jQuery( selector ),
6012 last = insert.length - 1;
6014 for ( ; i <= last; i++ ) {
6015 elems = i === last ? this : this.clone(true);
6016 jQuery( insert[i] )[ original ]( elems );
6018 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
6019 push.apply( ret, elems.get() );
6022 return this.pushStack( ret );
6031 * Retrieve the actual display of a element
6032 * @param {String} name nodeName of the element
6033 * @param {Object} doc Document object
6035 // Called only from within defaultDisplay
6036 function actualDisplay( name, doc ) {
6038 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
6040 // getDefaultComputedStyle might be reliably used only on attached element
6041 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
6043 // Use of this method is a temporary fix (more like optmization) until something better comes along,
6044 // since it was removed from specification and supported only in FF
6045 style.display : jQuery.css( elem[ 0 ], "display" );
6047 // We don't have any data stored on the element,
6048 // so use "detach" method as fast way to get rid of the element
6055 * Try to determine the default display value of an element
6056 * @param {String} nodeName
6058 function defaultDisplay( nodeName ) {
6060 display = elemdisplay[ nodeName ];
6063 display = actualDisplay( nodeName, doc );
6065 // If the simple way fails, read from inside an iframe
6066 if ( display === "none" || !display ) {
6068 // Use the already-created iframe if possible
6069 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
6071 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
6072 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
6078 display = actualDisplay( nodeName, doc );
6082 // Store the correct default display
6083 elemdisplay[ nodeName ] = display;
6091 var shrinkWrapBlocksVal;
6093 support.shrinkWrapBlocks = function() {
6094 if ( shrinkWrapBlocksVal != null ) {
6095 return shrinkWrapBlocksVal;
6098 // Will be changed later if needed.
6099 shrinkWrapBlocksVal = false;
6101 // Minified: var b,c,d
6102 var div, body, container;
6104 body = document.getElementsByTagName( "body" )[ 0 ];
6105 if ( !body || !body.style ) {
6106 // Test fired too early or in an unsupported environment, exit.
6111 div = document.createElement( "div" );
6112 container = document.createElement( "div" );
6113 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
6114 body.appendChild( container ).appendChild( div );
6117 // Check if elements with layout shrink-wrap their children
6118 if ( typeof div.style.zoom !== strundefined ) {
6119 // Reset CSS: box-sizing; display; margin; border
6121 // Support: Firefox<29, Android 2.3
6122 // Vendor-prefix box-sizing
6123 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
6124 "box-sizing:content-box;display:block;margin:0;border:0;" +
6125 "padding:1px;width:1px;zoom:1";
6126 div.appendChild( document.createElement( "div" ) ).style.width = "5px";
6127 shrinkWrapBlocksVal = div.offsetWidth !== 3;
6130 body.removeChild( container );
6132 return shrinkWrapBlocksVal;
6136 var rmargin = (/^margin/);
6138 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6142 var getStyles, curCSS,
6143 rposition = /^(top|right|bottom|left)$/;
6145 if ( window.getComputedStyle ) {
6146 getStyles = function( elem ) {
6147 // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
6148 // IE throws on elements created in popups
6149 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6150 if ( elem.ownerDocument.defaultView.opener ) {
6151 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
6154 return window.getComputedStyle( elem, null );
6157 curCSS = function( elem, name, computed ) {
6158 var width, minWidth, maxWidth, ret,
6161 computed = computed || getStyles( elem );
6163 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6164 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
6168 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6169 ret = jQuery.style( elem, name );
6172 // A tribute to the "awesome hack by Dean Edwards"
6173 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6174 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6175 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6176 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6178 // Remember the original values
6179 width = style.width;
6180 minWidth = style.minWidth;
6181 maxWidth = style.maxWidth;
6183 // Put in the new values to get a computed value out
6184 style.minWidth = style.maxWidth = style.width = ret;
6185 ret = computed.width;
6187 // Revert the changed values
6188 style.width = width;
6189 style.minWidth = minWidth;
6190 style.maxWidth = maxWidth;
6195 // IE returns zIndex value as an integer.
6196 return ret === undefined ?
6200 } else if ( document.documentElement.currentStyle ) {
6201 getStyles = function( elem ) {
6202 return elem.currentStyle;
6205 curCSS = function( elem, name, computed ) {
6206 var left, rs, rsLeft, ret,
6209 computed = computed || getStyles( elem );
6210 ret = computed ? computed[ name ] : undefined;
6212 // Avoid setting ret to empty string here
6213 // so we don't default to auto
6214 if ( ret == null && style && style[ name ] ) {
6215 ret = style[ name ];
6218 // From the awesome hack by Dean Edwards
6219 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6221 // If we're not dealing with a regular pixel number
6222 // but a number that has a weird ending, we need to convert it to pixels
6223 // but not position css attributes, as those are proportional to the parent element instead
6224 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6225 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6227 // Remember the original values
6229 rs = elem.runtimeStyle;
6230 rsLeft = rs && rs.left;
6232 // Put in the new values to get a computed value out
6234 rs.left = elem.currentStyle.left;
6236 style.left = name === "fontSize" ? "1em" : ret;
6237 ret = style.pixelLeft + "px";
6239 // Revert the changed values
6247 // IE returns zIndex value as an integer.
6248 return ret === undefined ?
6257 function addGetHookIf( conditionFn, hookFn ) {
6258 // Define the hook, we'll check on the first run if it's really needed.
6261 var condition = conditionFn();
6263 if ( condition == null ) {
6264 // The test was not ready at this point; screw the hook this time
6265 // but check again when needed next time.
6270 // Hook not needed (or it's not possible to use it due to missing dependency),
6272 // Since there are no other hooks for marginRight, remove the whole object.
6277 // Hook needed; redefine it so that the support test is not executed again.
6279 return (this.get = hookFn).apply( this, arguments );
6286 // Minified: var b,c,d,e,f,g, h,i
6287 var div, style, a, pixelPositionVal, boxSizingReliableVal,
6288 reliableHiddenOffsetsVal, reliableMarginRightVal;
6291 div = document.createElement( "div" );
6292 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
6293 a = div.getElementsByTagName( "a" )[ 0 ];
6294 style = a && a.style;
6296 // Finish early in limited (non-browser) environments
6301 style.cssText = "float:left;opacity:.5";
6304 // Make sure that element opacity exists (as opposed to filter)
6305 support.opacity = style.opacity === "0.5";
6307 // Verify style float existence
6308 // (IE uses styleFloat instead of cssFloat)
6309 support.cssFloat = !!style.cssFloat;
6311 div.style.backgroundClip = "content-box";
6312 div.cloneNode( true ).style.backgroundClip = "";
6313 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6315 // Support: Firefox<29, Android 2.3
6316 // Vendor-prefix box-sizing
6317 support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
6318 style.WebkitBoxSizing === "";
6320 jQuery.extend(support, {
6321 reliableHiddenOffsets: function() {
6322 if ( reliableHiddenOffsetsVal == null ) {
6323 computeStyleTests();
6325 return reliableHiddenOffsetsVal;
6328 boxSizingReliable: function() {
6329 if ( boxSizingReliableVal == null ) {
6330 computeStyleTests();
6332 return boxSizingReliableVal;
6335 pixelPosition: function() {
6336 if ( pixelPositionVal == null ) {
6337 computeStyleTests();
6339 return pixelPositionVal;
6342 // Support: Android 2.3
6343 reliableMarginRight: function() {
6344 if ( reliableMarginRightVal == null ) {
6345 computeStyleTests();
6347 return reliableMarginRightVal;
6351 function computeStyleTests() {
6352 // Minified: var b,c,d,j
6353 var div, body, container, contents;
6355 body = document.getElementsByTagName( "body" )[ 0 ];
6356 if ( !body || !body.style ) {
6357 // Test fired too early or in an unsupported environment, exit.
6362 div = document.createElement( "div" );
6363 container = document.createElement( "div" );
6364 container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
6365 body.appendChild( container ).appendChild( div );
6368 // Support: Firefox<29, Android 2.3
6369 // Vendor-prefix box-sizing
6370 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
6371 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
6372 "border:1px;padding:1px;width:4px;position:absolute";
6375 // Assume reasonable values in the absence of getComputedStyle
6376 pixelPositionVal = boxSizingReliableVal = false;
6377 reliableMarginRightVal = true;
6379 // Check for getComputedStyle so that this code is not run in IE<9.
6380 if ( window.getComputedStyle ) {
6381 pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
6382 boxSizingReliableVal =
6383 ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
6385 // Support: Android 2.3
6386 // Div with explicit width and no margin-right incorrectly
6387 // gets computed margin-right based on width of container (#3333)
6388 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6389 contents = div.appendChild( document.createElement( "div" ) );
6391 // Reset CSS: box-sizing; display; margin; border; padding
6392 contents.style.cssText = div.style.cssText =
6393 // Support: Firefox<29, Android 2.3
6394 // Vendor-prefix box-sizing
6395 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
6396 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
6397 contents.style.marginRight = contents.style.width = "0";
6398 div.style.width = "1px";
6400 reliableMarginRightVal =
6401 !parseFloat( ( window.getComputedStyle( contents, null ) || {} ).marginRight );
6403 div.removeChild( contents );
6407 // Check if table cells still have offsetWidth/Height when they are set
6408 // to display:none and there are still other visible table cells in a
6409 // table row; if so, offsetWidth/Height are not reliable for use when
6410 // determining if an element has been hidden directly using
6411 // display:none (it is still safe to use offsets if a parent element is
6412 // hidden; don safety goggles and see bug #4512 for more information).
6413 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
6414 contents = div.getElementsByTagName( "td" );
6415 contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
6416 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
6417 if ( reliableHiddenOffsetsVal ) {
6418 contents[ 0 ].style.display = "";
6419 contents[ 1 ].style.display = "none";
6420 reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
6423 body.removeChild( container );
6429 // A method for quickly swapping in/out CSS properties to get correct calculations.
6430 jQuery.swap = function( elem, options, callback, args ) {
6434 // Remember the old values, and insert the new ones
6435 for ( name in options ) {
6436 old[ name ] = elem.style[ name ];
6437 elem.style[ name ] = options[ name ];
6440 ret = callback.apply( elem, args || [] );
6442 // Revert the old values
6443 for ( name in options ) {
6444 elem.style[ name ] = old[ name ];
6452 ralpha = /alpha\([^)]*\)/i,
6453 ropacity = /opacity\s*=\s*([^)]*)/,
6455 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6456 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6457 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6458 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
6459 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
6461 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6462 cssNormalTransform = {
6467 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
6470 // return a css property mapped to a potentially vendor prefixed property
6471 function vendorPropName( style, name ) {
6473 // shortcut for names that are not vendor prefixed
6474 if ( name in style ) {
6478 // check for vendor prefixed names
6479 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6481 i = cssPrefixes.length;
6484 name = cssPrefixes[ i ] + capName;
6485 if ( name in style ) {
6493 function showHide( elements, show ) {
6494 var display, elem, hidden,
6497 length = elements.length;
6499 for ( ; index < length; index++ ) {
6500 elem = elements[ index ];
6501 if ( !elem.style ) {
6505 values[ index ] = jQuery._data( elem, "olddisplay" );
6506 display = elem.style.display;
6508 // Reset the inline display of this element to learn if it is
6509 // being hidden by cascaded rules or not
6510 if ( !values[ index ] && display === "none" ) {
6511 elem.style.display = "";
6514 // Set elements which have been overridden with display: none
6515 // in a stylesheet to whatever the default browser style is
6516 // for such an element
6517 if ( elem.style.display === "" && isHidden( elem ) ) {
6518 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
6521 hidden = isHidden( elem );
6523 if ( display && display !== "none" || !hidden ) {
6524 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
6529 // Set the display of most of the elements in a second loop
6530 // to avoid the constant reflow
6531 for ( index = 0; index < length; index++ ) {
6532 elem = elements[ index ];
6533 if ( !elem.style ) {
6536 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6537 elem.style.display = show ? values[ index ] || "" : "none";
6544 function setPositiveNumber( elem, value, subtract ) {
6545 var matches = rnumsplit.exec( value );
6547 // Guard against undefined "subtract", e.g., when used as in cssHooks
6548 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6552 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
6553 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6554 // If we already have the right measurement, avoid augmentation
6556 // Otherwise initialize for horizontal or vertical properties
6557 name === "width" ? 1 : 0,
6561 for ( ; i < 4; i += 2 ) {
6562 // both box models exclude margin, so add it if we want it
6563 if ( extra === "margin" ) {
6564 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
6567 if ( isBorderBox ) {
6568 // border-box includes padding, so remove it if we want content
6569 if ( extra === "content" ) {
6570 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6573 // at this point, extra isn't border nor margin, so remove border
6574 if ( extra !== "margin" ) {
6575 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6578 // at this point, extra isn't content, so add padding
6579 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6581 // at this point, extra isn't content nor padding, so add border
6582 if ( extra !== "padding" ) {
6583 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6591 function getWidthOrHeight( elem, name, extra ) {
6593 // Start with offset property, which is equivalent to the border-box value
6594 var valueIsBorderBox = true,
6595 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6596 styles = getStyles( elem ),
6597 isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6599 // some non-html elements return undefined for offsetWidth, so check for null/undefined
6600 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6601 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6602 if ( val <= 0 || val == null ) {
6603 // Fall back to computed then uncomputed css if necessary
6604 val = curCSS( elem, name, styles );
6605 if ( val < 0 || val == null ) {
6606 val = elem.style[ name ];
6609 // Computed unit is not pixels. Stop here and return.
6610 if ( rnumnonpx.test(val) ) {
6614 // we need the check for style in case a browser which returns unreliable values
6615 // for getComputedStyle silently falls back to the reliable elem.style
6616 valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
6618 // Normalize "", auto, and prepare for extra
6619 val = parseFloat( val ) || 0;
6622 // use the active box-sizing model to add/subtract irrelevant styles
6624 augmentWidthOrHeight(
6627 extra || ( isBorderBox ? "border" : "content" ),
6635 // Add in style property hooks for overriding the default
6636 // behavior of getting and setting a style property
6639 get: function( elem, computed ) {
6641 // We should always get a number back from opacity
6642 var ret = curCSS( elem, "opacity" );
6643 return ret === "" ? "1" : ret;
6649 // Don't automatically add "px" to these possibly-unitless properties
6651 "columnCount": true,
6652 "fillOpacity": true,
6665 // Add in properties whose names you wish to fix before
6666 // setting or getting the value
6668 // normalize float css property
6669 "float": support.cssFloat ? "cssFloat" : "styleFloat"
6672 // Get and set the style property on a DOM Node
6673 style: function( elem, name, value, extra ) {
6674 // Don't set styles on text and comment nodes
6675 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6679 // Make sure that we're working with the right name
6680 var ret, type, hooks,
6681 origName = jQuery.camelCase( name ),
6684 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6686 // gets hook for the prefixed version
6687 // followed by the unprefixed version
6688 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6690 // Check if we're setting a value
6691 if ( value !== undefined ) {
6692 type = typeof value;
6694 // convert relative number strings (+= or -=) to relative numbers. #7345
6695 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6696 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6701 // Make sure that null and NaN values aren't set. See: #7116
6702 if ( value == null || value !== value ) {
6706 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6707 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6711 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
6712 // but it would mean to define eight (for every problematic property) identical functions
6713 if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
6714 style[ name ] = "inherit";
6717 // If a hook was provided, use that value, otherwise just set the specified value
6718 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6721 // Swallow errors from 'invalid' CSS values (#5509)
6723 style[ name ] = value;
6728 // If a hook was provided get the non-computed value from there
6729 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6733 // Otherwise just get the value from the style object
6734 return style[ name ];
6738 css: function( elem, name, extra, styles ) {
6739 var num, val, hooks,
6740 origName = jQuery.camelCase( name );
6742 // Make sure that we're working with the right name
6743 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6745 // gets hook for the prefixed version
6746 // followed by the unprefixed version
6747 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6749 // If a hook was provided get the computed value from there
6750 if ( hooks && "get" in hooks ) {
6751 val = hooks.get( elem, true, extra );
6754 // Otherwise, if a way to get the computed value exists, use that
6755 if ( val === undefined ) {
6756 val = curCSS( elem, name, styles );
6759 //convert "normal" to computed value
6760 if ( val === "normal" && name in cssNormalTransform ) {
6761 val = cssNormalTransform[ name ];
6764 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6765 if ( extra === "" || extra ) {
6766 num = parseFloat( val );
6767 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
6773 jQuery.each([ "height", "width" ], function( i, name ) {
6774 jQuery.cssHooks[ name ] = {
6775 get: function( elem, computed, extra ) {
6777 // certain elements can have dimension info if we invisibly show them
6778 // however, it must have a current display style that would benefit from this
6779 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
6780 jQuery.swap( elem, cssShow, function() {
6781 return getWidthOrHeight( elem, name, extra );
6783 getWidthOrHeight( elem, name, extra );
6787 set: function( elem, value, extra ) {
6788 var styles = extra && getStyles( elem );
6789 return setPositiveNumber( elem, value, extra ?
6790 augmentWidthOrHeight(
6794 support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6802 if ( !support.opacity ) {
6803 jQuery.cssHooks.opacity = {
6804 get: function( elem, computed ) {
6805 // IE uses filters for opacity
6806 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6807 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
6808 computed ? "1" : "";
6811 set: function( elem, value ) {
6812 var style = elem.style,
6813 currentStyle = elem.currentStyle,
6814 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
6815 filter = currentStyle && currentStyle.filter || style.filter || "";
6817 // IE has trouble with opacity if it does not have layout
6818 // Force it by setting the zoom level
6821 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6822 // if value === "", then remove inline opacity #12685
6823 if ( ( value >= 1 || value === "" ) &&
6824 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
6825 style.removeAttribute ) {
6827 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6828 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6829 // style.removeAttribute is IE Only, but so apparently is this code path...
6830 style.removeAttribute( "filter" );
6832 // if there is no filter style applied in a css rule or unset inline opacity, we are done
6833 if ( value === "" || currentStyle && !currentStyle.filter ) {
6838 // otherwise, set new filter values
6839 style.filter = ralpha.test( filter ) ?
6840 filter.replace( ralpha, opacity ) :
6841 filter + " " + opacity;
6846 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
6847 function( elem, computed ) {
6849 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6850 // Work around by temporarily setting element display to inline-block
6851 return jQuery.swap( elem, { "display": "inline-block" },
6852 curCSS, [ elem, "marginRight" ] );
6857 // These hooks are used by animate to expand properties
6862 }, function( prefix, suffix ) {
6863 jQuery.cssHooks[ prefix + suffix ] = {
6864 expand: function( value ) {
6868 // assumes a single number if not a string
6869 parts = typeof value === "string" ? value.split(" ") : [ value ];
6871 for ( ; i < 4; i++ ) {
6872 expanded[ prefix + cssExpand[ i ] + suffix ] =
6873 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6880 if ( !rmargin.test( prefix ) ) {
6881 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6886 css: function( name, value ) {
6887 return access( this, function( elem, name, value ) {
6892 if ( jQuery.isArray( name ) ) {
6893 styles = getStyles( elem );
6896 for ( ; i < len; i++ ) {
6897 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6903 return value !== undefined ?
6904 jQuery.style( elem, name, value ) :
6905 jQuery.css( elem, name );
6906 }, name, value, arguments.length > 1 );
6909 return showHide( this, true );
6912 return showHide( this );
6914 toggle: function( state ) {
6915 if ( typeof state === "boolean" ) {
6916 return state ? this.show() : this.hide();
6919 return this.each(function() {
6920 if ( isHidden( this ) ) {
6921 jQuery( this ).show();
6923 jQuery( this ).hide();
6930 function Tween( elem, options, prop, end, easing ) {
6931 return new Tween.prototype.init( elem, options, prop, end, easing );
6933 jQuery.Tween = Tween;
6937 init: function( elem, options, prop, end, easing, unit ) {
6940 this.easing = easing || "swing";
6941 this.options = options;
6942 this.start = this.now = this.cur();
6944 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
6947 var hooks = Tween.propHooks[ this.prop ];
6949 return hooks && hooks.get ?
6951 Tween.propHooks._default.get( this );
6953 run: function( percent ) {
6955 hooks = Tween.propHooks[ this.prop ];
6957 if ( this.options.duration ) {
6958 this.pos = eased = jQuery.easing[ this.easing ](
6959 percent, this.options.duration * percent, 0, 1, this.options.duration
6962 this.pos = eased = percent;
6964 this.now = ( this.end - this.start ) * eased + this.start;
6966 if ( this.options.step ) {
6967 this.options.step.call( this.elem, this.now, this );
6970 if ( hooks && hooks.set ) {
6973 Tween.propHooks._default.set( this );
6979 Tween.prototype.init.prototype = Tween.prototype;
6983 get: function( tween ) {
6986 if ( tween.elem[ tween.prop ] != null &&
6987 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
6988 return tween.elem[ tween.prop ];
6991 // passing an empty string as a 3rd parameter to .css will automatically
6992 // attempt a parseFloat and fallback to a string if the parse fails
6993 // so, simple values such as "10px" are parsed to Float.
6994 // complex values such as "rotate(1rad)" are returned as is.
6995 result = jQuery.css( tween.elem, tween.prop, "" );
6996 // Empty strings, null, undefined and "auto" are converted to 0.
6997 return !result || result === "auto" ? 0 : result;
6999 set: function( tween ) {
7000 // use step hook for back compat - use cssHook if its there - use .style if its
7001 // available and use plain properties where available
7002 if ( jQuery.fx.step[ tween.prop ] ) {
7003 jQuery.fx.step[ tween.prop ]( tween );
7004 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
7005 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
7007 tween.elem[ tween.prop ] = tween.now;
7014 // Panic based approach to setting things on disconnected nodes
7016 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
7017 set: function( tween ) {
7018 if ( tween.elem.nodeType && tween.elem.parentNode ) {
7019 tween.elem[ tween.prop ] = tween.now;
7025 linear: function( p ) {
7028 swing: function( p ) {
7029 return 0.5 - Math.cos( p * Math.PI ) / 2;
7033 jQuery.fx = Tween.prototype.init;
7035 // Back Compat <1.8 extension point
7036 jQuery.fx.step = {};
7043 rfxtypes = /^(?:toggle|show|hide)$/,
7044 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
7045 rrun = /queueHooks$/,
7046 animationPrefilters = [ defaultPrefilter ],
7048 "*": [ function( prop, value ) {
7049 var tween = this.createTween( prop, value ),
7050 target = tween.cur(),
7051 parts = rfxnum.exec( value ),
7052 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
7054 // Starting value computation is required for potential unit mismatches
7055 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
7056 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
7060 if ( start && start[ 3 ] !== unit ) {
7061 // Trust units reported by jQuery.css
7062 unit = unit || start[ 3 ];
7064 // Make sure we update the tween properties later on
7065 parts = parts || [];
7067 // Iteratively approximate from a nonzero starting point
7068 start = +target || 1;
7071 // If previous iteration zeroed out, double until we get *something*
7072 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
7073 scale = scale || ".5";
7076 start = start / scale;
7077 jQuery.style( tween.elem, prop, start + unit );
7079 // Update scale, tolerating zero or NaN from tween.cur()
7080 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
7081 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
7084 // Update tween properties
7086 start = tween.start = +start || +target || 0;
7088 // If a +=/-= token was provided, we're doing a relative animation
7089 tween.end = parts[ 1 ] ?
7090 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
7098 // Animations created synchronously will run synchronously
7099 function createFxNow() {
7100 setTimeout(function() {
7103 return ( fxNow = jQuery.now() );
7106 // Generate parameters to create a standard animation
7107 function genFx( type, includeWidth ) {
7109 attrs = { height: type },
7112 // if we include width, step value is 1 to do all cssExpand values,
7113 // if we don't include width, step value is 2 to skip over Left and Right
7114 includeWidth = includeWidth ? 1 : 0;
7115 for ( ; i < 4 ; i += 2 - includeWidth ) {
7116 which = cssExpand[ i ];
7117 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
7120 if ( includeWidth ) {
7121 attrs.opacity = attrs.width = type;
7127 function createTween( value, prop, animation ) {
7129 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
7131 length = collection.length;
7132 for ( ; index < length; index++ ) {
7133 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
7135 // we're done with this property
7141 function defaultPrefilter( elem, props, opts ) {
7142 /* jshint validthis: true */
7143 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
7147 hidden = elem.nodeType && isHidden( elem ),
7148 dataShow = jQuery._data( elem, "fxshow" );
7150 // handle queue: false promises
7151 if ( !opts.queue ) {
7152 hooks = jQuery._queueHooks( elem, "fx" );
7153 if ( hooks.unqueued == null ) {
7155 oldfire = hooks.empty.fire;
7156 hooks.empty.fire = function() {
7157 if ( !hooks.unqueued ) {
7164 anim.always(function() {
7165 // doing this makes sure that the complete handler will be called
7166 // before this completes
7167 anim.always(function() {
7169 if ( !jQuery.queue( elem, "fx" ).length ) {
7176 // height/width overflow pass
7177 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
7178 // Make sure that nothing sneaks out
7179 // Record all 3 overflow attributes because IE does not
7180 // change the overflow attribute when overflowX and
7181 // overflowY are set to the same value
7182 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
7184 // Set display property to inline-block for height/width
7185 // animations on inline elements that are having width/height animated
7186 display = jQuery.css( elem, "display" );
7188 // Test default display if display is currently "none"
7189 checkDisplay = display === "none" ?
7190 jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
7192 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
7194 // inline-level elements accept inline-block;
7195 // block-level elements need to be inline with layout
7196 if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
7197 style.display = "inline-block";
7204 if ( opts.overflow ) {
7205 style.overflow = "hidden";
7206 if ( !support.shrinkWrapBlocks() ) {
7207 anim.always(function() {
7208 style.overflow = opts.overflow[ 0 ];
7209 style.overflowX = opts.overflow[ 1 ];
7210 style.overflowY = opts.overflow[ 2 ];
7216 for ( prop in props ) {
7217 value = props[ prop ];
7218 if ( rfxtypes.exec( value ) ) {
7219 delete props[ prop ];
7220 toggle = toggle || value === "toggle";
7221 if ( value === ( hidden ? "hide" : "show" ) ) {
7223 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
7224 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
7230 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
7232 // Any non-fx value stops us from restoring the original display value
7234 display = undefined;
7238 if ( !jQuery.isEmptyObject( orig ) ) {
7240 if ( "hidden" in dataShow ) {
7241 hidden = dataShow.hidden;
7244 dataShow = jQuery._data( elem, "fxshow", {} );
7247 // store state if its toggle - enables .stop().toggle() to "reverse"
7249 dataShow.hidden = !hidden;
7252 jQuery( elem ).show();
7254 anim.done(function() {
7255 jQuery( elem ).hide();
7258 anim.done(function() {
7260 jQuery._removeData( elem, "fxshow" );
7261 for ( prop in orig ) {
7262 jQuery.style( elem, prop, orig[ prop ] );
7265 for ( prop in orig ) {
7266 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
7268 if ( !( prop in dataShow ) ) {
7269 dataShow[ prop ] = tween.start;
7271 tween.end = tween.start;
7272 tween.start = prop === "width" || prop === "height" ? 1 : 0;
7277 // If this is a noop like .hide().hide(), restore an overwritten display value
7278 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
7279 style.display = display;
7283 function propFilter( props, specialEasing ) {
7284 var index, name, easing, value, hooks;
7286 // camelCase, specialEasing and expand cssHook pass
7287 for ( index in props ) {
7288 name = jQuery.camelCase( index );
7289 easing = specialEasing[ name ];
7290 value = props[ index ];
7291 if ( jQuery.isArray( value ) ) {
7292 easing = value[ 1 ];
7293 value = props[ index ] = value[ 0 ];
7296 if ( index !== name ) {
7297 props[ name ] = value;
7298 delete props[ index ];
7301 hooks = jQuery.cssHooks[ name ];
7302 if ( hooks && "expand" in hooks ) {
7303 value = hooks.expand( value );
7304 delete props[ name ];
7306 // not quite $.extend, this wont overwrite keys already present.
7307 // also - reusing 'index' from above because we have the correct "name"
7308 for ( index in value ) {
7309 if ( !( index in props ) ) {
7310 props[ index ] = value[ index ];
7311 specialEasing[ index ] = easing;
7315 specialEasing[ name ] = easing;
7320 function Animation( elem, properties, options ) {
7324 length = animationPrefilters.length,
7325 deferred = jQuery.Deferred().always( function() {
7326 // don't match elem in the :animated selector
7333 var currentTime = fxNow || createFxNow(),
7334 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7335 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
7336 temp = remaining / animation.duration || 0,
7339 length = animation.tweens.length;
7341 for ( ; index < length ; index++ ) {
7342 animation.tweens[ index ].run( percent );
7345 deferred.notifyWith( elem, [ animation, percent, remaining ]);
7347 if ( percent < 1 && length ) {
7350 deferred.resolveWith( elem, [ animation ] );
7354 animation = deferred.promise({
7356 props: jQuery.extend( {}, properties ),
7357 opts: jQuery.extend( true, { specialEasing: {} }, options ),
7358 originalProperties: properties,
7359 originalOptions: options,
7360 startTime: fxNow || createFxNow(),
7361 duration: options.duration,
7363 createTween: function( prop, end ) {
7364 var tween = jQuery.Tween( elem, animation.opts, prop, end,
7365 animation.opts.specialEasing[ prop ] || animation.opts.easing );
7366 animation.tweens.push( tween );
7369 stop: function( gotoEnd ) {
7371 // if we are going to the end, we want to run all the tweens
7372 // otherwise we skip this part
7373 length = gotoEnd ? animation.tweens.length : 0;
7378 for ( ; index < length ; index++ ) {
7379 animation.tweens[ index ].run( 1 );
7382 // resolve when we played the last frame
7383 // otherwise, reject
7385 deferred.resolveWith( elem, [ animation, gotoEnd ] );
7387 deferred.rejectWith( elem, [ animation, gotoEnd ] );
7392 props = animation.props;
7394 propFilter( props, animation.opts.specialEasing );
7396 for ( ; index < length ; index++ ) {
7397 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
7403 jQuery.map( props, createTween, animation );
7405 if ( jQuery.isFunction( animation.opts.start ) ) {
7406 animation.opts.start.call( elem, animation );
7410 jQuery.extend( tick, {
7413 queue: animation.opts.queue
7417 // attach callbacks from options
7418 return animation.progress( animation.opts.progress )
7419 .done( animation.opts.done, animation.opts.complete )
7420 .fail( animation.opts.fail )
7421 .always( animation.opts.always );
7424 jQuery.Animation = jQuery.extend( Animation, {
7425 tweener: function( props, callback ) {
7426 if ( jQuery.isFunction( props ) ) {
7430 props = props.split(" ");
7435 length = props.length;
7437 for ( ; index < length ; index++ ) {
7438 prop = props[ index ];
7439 tweeners[ prop ] = tweeners[ prop ] || [];
7440 tweeners[ prop ].unshift( callback );
7444 prefilter: function( callback, prepend ) {
7446 animationPrefilters.unshift( callback );
7448 animationPrefilters.push( callback );
7453 jQuery.speed = function( speed, easing, fn ) {
7454 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7455 complete: fn || !fn && easing ||
7456 jQuery.isFunction( speed ) && speed,
7458 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
7461 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
7462 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
7464 // normalize opt.queue - true/undefined/null -> "fx"
7465 if ( opt.queue == null || opt.queue === true ) {
7470 opt.old = opt.complete;
7472 opt.complete = function() {
7473 if ( jQuery.isFunction( opt.old ) ) {
7474 opt.old.call( this );
7478 jQuery.dequeue( this, opt.queue );
7486 fadeTo: function( speed, to, easing, callback ) {
7488 // show any hidden elements after setting opacity to 0
7489 return this.filter( isHidden ).css( "opacity", 0 ).show()
7491 // animate to the value specified
7492 .end().animate({ opacity: to }, speed, easing, callback );
7494 animate: function( prop, speed, easing, callback ) {
7495 var empty = jQuery.isEmptyObject( prop ),
7496 optall = jQuery.speed( speed, easing, callback ),
7497 doAnimation = function() {
7498 // Operate on a copy of prop so per-property easing won't be lost
7499 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7501 // Empty animations, or finishing resolves immediately
7502 if ( empty || jQuery._data( this, "finish" ) ) {
7506 doAnimation.finish = doAnimation;
7508 return empty || optall.queue === false ?
7509 this.each( doAnimation ) :
7510 this.queue( optall.queue, doAnimation );
7512 stop: function( type, clearQueue, gotoEnd ) {
7513 var stopQueue = function( hooks ) {
7514 var stop = hooks.stop;
7519 if ( typeof type !== "string" ) {
7520 gotoEnd = clearQueue;
7524 if ( clearQueue && type !== false ) {
7525 this.queue( type || "fx", [] );
7528 return this.each(function() {
7530 index = type != null && type + "queueHooks",
7531 timers = jQuery.timers,
7532 data = jQuery._data( this );
7535 if ( data[ index ] && data[ index ].stop ) {
7536 stopQueue( data[ index ] );
7539 for ( index in data ) {
7540 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7541 stopQueue( data[ index ] );
7546 for ( index = timers.length; index--; ) {
7547 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
7548 timers[ index ].anim.stop( gotoEnd );
7550 timers.splice( index, 1 );
7554 // start the next in the queue if the last step wasn't forced
7555 // timers currently will call their complete callbacks, which will dequeue
7556 // but only if they were gotoEnd
7557 if ( dequeue || !gotoEnd ) {
7558 jQuery.dequeue( this, type );
7562 finish: function( type ) {
7563 if ( type !== false ) {
7564 type = type || "fx";
7566 return this.each(function() {
7568 data = jQuery._data( this ),
7569 queue = data[ type + "queue" ],
7570 hooks = data[ type + "queueHooks" ],
7571 timers = jQuery.timers,
7572 length = queue ? queue.length : 0;
7574 // enable finishing flag on private data
7577 // empty the queue first
7578 jQuery.queue( this, type, [] );
7580 if ( hooks && hooks.stop ) {
7581 hooks.stop.call( this, true );
7584 // look for any active animations, and finish them
7585 for ( index = timers.length; index--; ) {
7586 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
7587 timers[ index ].anim.stop( true );
7588 timers.splice( index, 1 );
7592 // look for any animations in the old queue and finish them
7593 for ( index = 0; index < length; index++ ) {
7594 if ( queue[ index ] && queue[ index ].finish ) {
7595 queue[ index ].finish.call( this );
7599 // turn off finishing flag
7605 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
7606 var cssFn = jQuery.fn[ name ];
7607 jQuery.fn[ name ] = function( speed, easing, callback ) {
7608 return speed == null || typeof speed === "boolean" ?
7609 cssFn.apply( this, arguments ) :
7610 this.animate( genFx( name, true ), speed, easing, callback );
7614 // Generate shortcuts for custom animations
7616 slideDown: genFx("show"),
7617 slideUp: genFx("hide"),
7618 slideToggle: genFx("toggle"),
7619 fadeIn: { opacity: "show" },
7620 fadeOut: { opacity: "hide" },
7621 fadeToggle: { opacity: "toggle" }
7622 }, function( name, props ) {
7623 jQuery.fn[ name ] = function( speed, easing, callback ) {
7624 return this.animate( props, speed, easing, callback );
7629 jQuery.fx.tick = function() {
7631 timers = jQuery.timers,
7634 fxNow = jQuery.now();
7636 for ( ; i < timers.length; i++ ) {
7637 timer = timers[ i ];
7638 // Checks the timer has not already been removed
7639 if ( !timer() && timers[ i ] === timer ) {
7640 timers.splice( i--, 1 );
7644 if ( !timers.length ) {
7650 jQuery.fx.timer = function( timer ) {
7651 jQuery.timers.push( timer );
7655 jQuery.timers.pop();
7659 jQuery.fx.interval = 13;
7661 jQuery.fx.start = function() {
7663 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
7667 jQuery.fx.stop = function() {
7668 clearInterval( timerId );
7672 jQuery.fx.speeds = {
7680 // Based off of the plugin by Clint Helfers, with permission.
7681 // http://blindsignals.com/index.php/2009/07/jquery-delay/
7682 jQuery.fn.delay = function( time, type ) {
7683 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
7684 type = type || "fx";
7686 return this.queue( type, function( next, hooks ) {
7687 var timeout = setTimeout( next, time );
7688 hooks.stop = function() {
7689 clearTimeout( timeout );
7696 // Minified: var a,b,c,d,e
7697 var input, div, select, a, opt;
7700 div = document.createElement( "div" );
7701 div.setAttribute( "className", "t" );
7702 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
7703 a = div.getElementsByTagName("a")[ 0 ];
7705 // First batch of tests.
7706 select = document.createElement("select");
7707 opt = select.appendChild( document.createElement("option") );
7708 input = div.getElementsByTagName("input")[ 0 ];
7710 a.style.cssText = "top:1px";
7712 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
7713 support.getSetAttribute = div.className !== "t";
7715 // Get the style information from getAttribute
7716 // (IE uses .cssText instead)
7717 support.style = /top/.test( a.getAttribute("style") );
7719 // Make sure that URLs aren't manipulated
7720 // (IE normalizes it by default)
7721 support.hrefNormalized = a.getAttribute("href") === "/a";
7723 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
7724 support.checkOn = !!input.value;
7726 // Make sure that a selected-by-default option has a working selected property.
7727 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
7728 support.optSelected = opt.selected;
7730 // Tests for enctype support on a form (#6743)
7731 support.enctype = !!document.createElement("form").enctype;
7733 // Make sure that the options inside disabled selects aren't marked as disabled
7734 // (WebKit marks them as disabled)
7735 select.disabled = true;
7736 support.optDisabled = !opt.disabled;
7738 // Support: IE8 only
7739 // Check if we can trust getAttribute("value")
7740 input = document.createElement( "input" );
7741 input.setAttribute( "value", "" );
7742 support.input = input.getAttribute( "value" ) === "";
7744 // Check if an input maintains its value after becoming a radio
7746 input.setAttribute( "type", "radio" );
7747 support.radioValue = input.value === "t";
7751 var rreturn = /\r/g;
7754 val: function( value ) {
7755 var hooks, ret, isFunction,
7758 if ( !arguments.length ) {
7760 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
7762 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
7768 return typeof ret === "string" ?
7769 // handle most common string cases
7770 ret.replace(rreturn, "") :
7771 // handle cases where value is null/undef or number
7772 ret == null ? "" : ret;
7778 isFunction = jQuery.isFunction( value );
7780 return this.each(function( i ) {
7783 if ( this.nodeType !== 1 ) {
7788 val = value.call( this, i, jQuery( this ).val() );
7793 // Treat null/undefined as ""; convert numbers to string
7794 if ( val == null ) {
7796 } else if ( typeof val === "number" ) {
7798 } else if ( jQuery.isArray( val ) ) {
7799 val = jQuery.map( val, function( value ) {
7800 return value == null ? "" : value + "";
7804 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7806 // If set returns undefined, fall back to normal setting
7807 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
7817 get: function( elem ) {
7818 var val = jQuery.find.attr( elem, "value" );
7819 return val != null ?
7821 // Support: IE10-11+
7822 // option.text throws exceptions (#14686, #14858)
7823 jQuery.trim( jQuery.text( elem ) );
7827 get: function( elem ) {
7829 options = elem.options,
7830 index = elem.selectedIndex,
7831 one = elem.type === "select-one" || index < 0,
7832 values = one ? null : [],
7833 max = one ? index + 1 : options.length,
7838 // Loop through all the selected options
7839 for ( ; i < max; i++ ) {
7840 option = options[ i ];
7842 // oldIE doesn't update selected after form reset (#2551)
7843 if ( ( option.selected || i === index ) &&
7844 // Don't return options that are disabled or in a disabled optgroup
7845 ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
7846 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
7848 // Get the specific value for the option
7849 value = jQuery( option ).val();
7851 // We don't need an array for one selects
7856 // Multi-Selects return an array
7857 values.push( value );
7864 set: function( elem, value ) {
7865 var optionSet, option,
7866 options = elem.options,
7867 values = jQuery.makeArray( value ),
7871 option = options[ i ];
7873 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
7876 // When new option element is added to select box we need to
7877 // force reflow of newly added node in order to workaround delay
7878 // of initialization properties
7880 option.selected = optionSet = true;
7884 // Will be executed only in IE6
7885 option.scrollHeight;
7889 option.selected = false;
7893 // Force browsers to behave consistently when non-matching value is set
7895 elem.selectedIndex = -1;
7904 // Radios and checkboxes getter/setter
7905 jQuery.each([ "radio", "checkbox" ], function() {
7906 jQuery.valHooks[ this ] = {
7907 set: function( elem, value ) {
7908 if ( jQuery.isArray( value ) ) {
7909 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
7913 if ( !support.checkOn ) {
7914 jQuery.valHooks[ this ].get = function( elem ) {
7916 // "" is returned instead of "on" if a value isn't specified
7917 return elem.getAttribute("value") === null ? "on" : elem.value;
7925 var nodeHook, boolHook,
7926 attrHandle = jQuery.expr.attrHandle,
7927 ruseDefault = /^(?:checked|selected)$/i,
7928 getSetAttribute = support.getSetAttribute,
7929 getSetInput = support.input;
7932 attr: function( name, value ) {
7933 return access( this, jQuery.attr, name, value, arguments.length > 1 );
7936 removeAttr: function( name ) {
7937 return this.each(function() {
7938 jQuery.removeAttr( this, name );
7944 attr: function( elem, name, value ) {
7946 nType = elem.nodeType;
7948 // don't get/set attributes on text, comment and attribute nodes
7949 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
7953 // Fallback to prop when attributes are not supported
7954 if ( typeof elem.getAttribute === strundefined ) {
7955 return jQuery.prop( elem, name, value );
7958 // All attributes are lowercase
7959 // Grab necessary hook if one is defined
7960 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7961 name = name.toLowerCase();
7962 hooks = jQuery.attrHooks[ name ] ||
7963 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
7966 if ( value !== undefined ) {
7968 if ( value === null ) {
7969 jQuery.removeAttr( elem, name );
7971 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
7975 elem.setAttribute( name, value + "" );
7979 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
7983 ret = jQuery.find.attr( elem, name );
7985 // Non-existent attributes return null, we normalize to undefined
7986 return ret == null ?
7992 removeAttr: function( elem, value ) {
7995 attrNames = value && value.match( rnotwhite );
7997 if ( attrNames && elem.nodeType === 1 ) {
7998 while ( (name = attrNames[i++]) ) {
7999 propName = jQuery.propFix[ name ] || name;
8001 // Boolean attributes get special treatment (#10870)
8002 if ( jQuery.expr.match.bool.test( name ) ) {
8003 // Set corresponding property to false
8004 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8005 elem[ propName ] = false;
8007 // Also clear defaultChecked/defaultSelected (if appropriate)
8009 elem[ jQuery.camelCase( "default-" + name ) ] =
8010 elem[ propName ] = false;
8013 // See #9699 for explanation of this approach (setting first, then removal)
8015 jQuery.attr( elem, name, "" );
8018 elem.removeAttribute( getSetAttribute ? name : propName );
8025 set: function( elem, value ) {
8026 if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
8027 // Setting the type on a radio button after the value resets the value in IE6-9
8028 // Reset value to default in case type is set after value during creation
8029 var val = elem.value;
8030 elem.setAttribute( "type", value );
8041 // Hook for boolean attributes
8043 set: function( elem, value, name ) {
8044 if ( value === false ) {
8045 // Remove boolean attributes when set to false
8046 jQuery.removeAttr( elem, name );
8047 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8048 // IE<8 needs the *property* name
8049 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
8051 // Use defaultChecked and defaultSelected for oldIE
8053 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
8060 // Retrieve booleans specially
8061 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
8063 var getter = attrHandle[ name ] || jQuery.find.attr;
8065 attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
8066 function( elem, name, isXML ) {
8069 // Avoid an infinite loop by temporarily removing this function from the getter
8070 handle = attrHandle[ name ];
8071 attrHandle[ name ] = ret;
8072 ret = getter( elem, name, isXML ) != null ?
8073 name.toLowerCase() :
8075 attrHandle[ name ] = handle;
8079 function( elem, name, isXML ) {
8081 return elem[ jQuery.camelCase( "default-" + name ) ] ?
8082 name.toLowerCase() :
8088 // fix oldIE attroperties
8089 if ( !getSetInput || !getSetAttribute ) {
8090 jQuery.attrHooks.value = {
8091 set: function( elem, value, name ) {
8092 if ( jQuery.nodeName( elem, "input" ) ) {
8093 // Does not return so that setAttribute is also used
8094 elem.defaultValue = value;
8096 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
8097 return nodeHook && nodeHook.set( elem, value, name );
8103 // IE6/7 do not support getting/setting some attributes with get/setAttribute
8104 if ( !getSetAttribute ) {
8106 // Use this for any attribute in IE6/7
8107 // This fixes almost every IE6/7 issue
8109 set: function( elem, value, name ) {
8110 // Set the existing or create a new attribute node
8111 var ret = elem.getAttributeNode( name );
8113 elem.setAttributeNode(
8114 (ret = elem.ownerDocument.createAttribute( name ))
8118 ret.value = value += "";
8120 // Break association with cloned elements by also using setAttribute (#9646)
8121 if ( name === "value" || value === elem.getAttribute( name ) ) {
8127 // Some attributes are constructed with empty-string values when not defined
8128 attrHandle.id = attrHandle.name = attrHandle.coords =
8129 function( elem, name, isXML ) {
8132 return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
8138 // Fixing value retrieval on a button requires this module
8139 jQuery.valHooks.button = {
8140 get: function( elem, name ) {
8141 var ret = elem.getAttributeNode( name );
8142 if ( ret && ret.specified ) {
8149 // Set contenteditable to false on removals(#10429)
8150 // Setting to empty string throws an error as an invalid value
8151 jQuery.attrHooks.contenteditable = {
8152 set: function( elem, value, name ) {
8153 nodeHook.set( elem, value === "" ? false : value, name );
8157 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
8158 // This is for removals
8159 jQuery.each([ "width", "height" ], function( i, name ) {
8160 jQuery.attrHooks[ name ] = {
8161 set: function( elem, value ) {
8162 if ( value === "" ) {
8163 elem.setAttribute( name, "auto" );
8171 if ( !support.style ) {
8172 jQuery.attrHooks.style = {
8173 get: function( elem ) {
8174 // Return undefined in the case of empty string
8175 // Note: IE uppercases css property names, but if we were to .toLowerCase()
8176 // .cssText, that would destroy case senstitivity in URL's, like in "background"
8177 return elem.style.cssText || undefined;
8179 set: function( elem, value ) {
8180 return ( elem.style.cssText = value + "" );
8188 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
8189 rclickable = /^(?:a|area)$/i;
8192 prop: function( name, value ) {
8193 return access( this, jQuery.prop, name, value, arguments.length > 1 );
8196 removeProp: function( name ) {
8197 name = jQuery.propFix[ name ] || name;
8198 return this.each(function() {
8199 // try/catch handles cases where IE balks (such as removing a property on window)
8201 this[ name ] = undefined;
8202 delete this[ name ];
8211 "class": "className"
8214 prop: function( elem, name, value ) {
8215 var ret, hooks, notxml,
8216 nType = elem.nodeType;
8218 // don't get/set properties on text, comment and attribute nodes
8219 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
8223 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
8226 // Fix name and attach hooks
8227 name = jQuery.propFix[ name ] || name;
8228 hooks = jQuery.propHooks[ name ];
8231 if ( value !== undefined ) {
8232 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
8234 ( elem[ name ] = value );
8237 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
8245 get: function( elem ) {
8246 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
8247 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
8248 // Use proper attribute retrieval(#12072)
8249 var tabindex = jQuery.find.attr( elem, "tabindex" );
8252 parseInt( tabindex, 10 ) :
8253 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
8261 // Some attributes require a special call on IE
8262 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
8263 if ( !support.hrefNormalized ) {
8264 // href/src property should get the full normalized URL (#10299/#12915)
8265 jQuery.each([ "href", "src" ], function( i, name ) {
8266 jQuery.propHooks[ name ] = {
8267 get: function( elem ) {
8268 return elem.getAttribute( name, 4 );
8274 // Support: Safari, IE9+
8275 // mis-reports the default selected property of an option
8276 // Accessing the parent's selectedIndex property fixes it
8277 if ( !support.optSelected ) {
8278 jQuery.propHooks.selected = {
8279 get: function( elem ) {
8280 var parent = elem.parentNode;
8283 parent.selectedIndex;
8285 // Make sure that it also works with optgroups, see #5701
8286 if ( parent.parentNode ) {
8287 parent.parentNode.selectedIndex;
8307 jQuery.propFix[ this.toLowerCase() ] = this;
8310 // IE6/7 call enctype encoding
8311 if ( !support.enctype ) {
8312 jQuery.propFix.enctype = "encoding";
8318 var rclass = /[\t\r\n\f]/g;
8321 addClass: function( value ) {
8322 var classes, elem, cur, clazz, j, finalValue,
8325 proceed = typeof value === "string" && value;
8327 if ( jQuery.isFunction( value ) ) {
8328 return this.each(function( j ) {
8329 jQuery( this ).addClass( value.call( this, j, this.className ) );
8334 // The disjunction here is for better compressibility (see removeClass)
8335 classes = ( value || "" ).match( rnotwhite ) || [];
8337 for ( ; i < len; i++ ) {
8339 cur = elem.nodeType === 1 && ( elem.className ?
8340 ( " " + elem.className + " " ).replace( rclass, " " ) :
8346 while ( (clazz = classes[j++]) ) {
8347 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
8352 // only assign if different to avoid unneeded rendering.
8353 finalValue = jQuery.trim( cur );
8354 if ( elem.className !== finalValue ) {
8355 elem.className = finalValue;
8364 removeClass: function( value ) {
8365 var classes, elem, cur, clazz, j, finalValue,
8368 proceed = arguments.length === 0 || typeof value === "string" && value;
8370 if ( jQuery.isFunction( value ) ) {
8371 return this.each(function( j ) {
8372 jQuery( this ).removeClass( value.call( this, j, this.className ) );
8376 classes = ( value || "" ).match( rnotwhite ) || [];
8378 for ( ; i < len; i++ ) {
8380 // This expression is here for better compressibility (see addClass)
8381 cur = elem.nodeType === 1 && ( elem.className ?
8382 ( " " + elem.className + " " ).replace( rclass, " " ) :
8388 while ( (clazz = classes[j++]) ) {
8389 // Remove *all* instances
8390 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
8391 cur = cur.replace( " " + clazz + " ", " " );
8395 // only assign if different to avoid unneeded rendering.
8396 finalValue = value ? jQuery.trim( cur ) : "";
8397 if ( elem.className !== finalValue ) {
8398 elem.className = finalValue;
8407 toggleClass: function( value, stateVal ) {
8408 var type = typeof value;
8410 if ( typeof stateVal === "boolean" && type === "string" ) {
8411 return stateVal ? this.addClass( value ) : this.removeClass( value );
8414 if ( jQuery.isFunction( value ) ) {
8415 return this.each(function( i ) {
8416 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
8420 return this.each(function() {
8421 if ( type === "string" ) {
8422 // toggle individual class names
8425 self = jQuery( this ),
8426 classNames = value.match( rnotwhite ) || [];
8428 while ( (className = classNames[ i++ ]) ) {
8429 // check each className given, space separated list
8430 if ( self.hasClass( className ) ) {
8431 self.removeClass( className );
8433 self.addClass( className );
8437 // Toggle whole class name
8438 } else if ( type === strundefined || type === "boolean" ) {
8439 if ( this.className ) {
8440 // store className if set
8441 jQuery._data( this, "__className__", this.className );
8444 // If the element has a class name or if we're passed "false",
8445 // then remove the whole classname (if there was one, the above saved it).
8446 // Otherwise bring back whatever was previously saved (if anything),
8447 // falling back to the empty string if nothing was stored.
8448 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
8453 hasClass: function( selector ) {
8454 var className = " " + selector + " ",
8457 for ( ; i < l; i++ ) {
8458 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
8470 // Return jQuery for attributes-only inclusion
8473 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
8474 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
8475 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
8477 // Handle event binding
8478 jQuery.fn[ name ] = function( data, fn ) {
8479 return arguments.length > 0 ?
8480 this.on( name, null, data, fn ) :
8481 this.trigger( name );
8486 hover: function( fnOver, fnOut ) {
8487 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
8490 bind: function( types, data, fn ) {
8491 return this.on( types, null, data, fn );
8493 unbind: function( types, fn ) {
8494 return this.off( types, null, fn );
8497 delegate: function( selector, types, data, fn ) {
8498 return this.on( types, selector, data, fn );
8500 undelegate: function( selector, types, fn ) {
8501 // ( namespace ) or ( selector, types [, fn] )
8502 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
8507 var nonce = jQuery.now();
8509 var rquery = (/\?/);
8513 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
8515 jQuery.parseJSON = function( data ) {
8516 // Attempt to parse using the native JSON parser first
8517 if ( window.JSON && window.JSON.parse ) {
8518 // Support: Android 2.3
8519 // Workaround failure to string-cast null input
8520 return window.JSON.parse( data + "" );
8523 var requireNonComma,
8525 str = jQuery.trim( data + "" );
8527 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
8528 // after removing valid tokens
8529 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
8531 // Force termination if we see a misplaced comma
8532 if ( requireNonComma && comma ) {
8536 // Perform no more replacements after returning to outermost depth
8537 if ( depth === 0 ) {
8541 // Commas must not follow "[", "{", or ","
8542 requireNonComma = open || comma;
8544 // Determine new depth
8545 // array/object open ("[" or "{"): depth += true - false (increment)
8546 // array/object close ("]" or "}"): depth += false - true (decrement)
8547 // other cases ("," or primitive): depth += true - true (numeric cast)
8548 depth += !close - !open;
8550 // Remove this token
8553 ( Function( "return " + str ) )() :
8554 jQuery.error( "Invalid JSON: " + data );
8558 // Cross-browser xml parsing
8559 jQuery.parseXML = function( data ) {
8561 if ( !data || typeof data !== "string" ) {
8565 if ( window.DOMParser ) { // Standard
8566 tmp = new DOMParser();
8567 xml = tmp.parseFromString( data, "text/xml" );
8569 xml = new ActiveXObject( "Microsoft.XMLDOM" );
8570 xml.async = "false";
8571 xml.loadXML( data );
8576 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
8577 jQuery.error( "Invalid XML: " + data );
8584 // Document location
8589 rts = /([?&])_=[^&]*/,
8590 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
8591 // #7653, #8125, #8152: local protocol detection
8592 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8593 rnoContent = /^(?:GET|HEAD)$/,
8594 rprotocol = /^\/\//,
8595 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
8598 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8599 * 2) These are called:
8600 * - BEFORE asking for a transport
8601 * - AFTER param serialization (s.data is a string if s.processData is true)
8602 * 3) key is the dataType
8603 * 4) the catchall symbol "*" can be used
8604 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8608 /* Transports bindings
8609 * 1) key is the dataType
8610 * 2) the catchall symbol "*" can be used
8611 * 3) selection will start with transport dataType and THEN go to "*" if needed
8615 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8616 allTypes = "*/".concat("*");
8618 // #8138, IE may throw an exception when accessing
8619 // a field from window.location if document.domain has been set
8621 ajaxLocation = location.href;
8623 // Use the href attribute of an A element
8624 // since IE will modify it given document.location
8625 ajaxLocation = document.createElement( "a" );
8626 ajaxLocation.href = "";
8627 ajaxLocation = ajaxLocation.href;
8630 // Segment location into parts
8631 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
8633 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8634 function addToPrefiltersOrTransports( structure ) {
8636 // dataTypeExpression is optional and defaults to "*"
8637 return function( dataTypeExpression, func ) {
8639 if ( typeof dataTypeExpression !== "string" ) {
8640 func = dataTypeExpression;
8641 dataTypeExpression = "*";
8646 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
8648 if ( jQuery.isFunction( func ) ) {
8649 // For each dataType in the dataTypeExpression
8650 while ( (dataType = dataTypes[i++]) ) {
8651 // Prepend if requested
8652 if ( dataType.charAt( 0 ) === "+" ) {
8653 dataType = dataType.slice( 1 ) || "*";
8654 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
8658 (structure[ dataType ] = structure[ dataType ] || []).push( func );
8665 // Base inspection function for prefilters and transports
8666 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
8669 seekingTransport = ( structure === transports );
8671 function inspect( dataType ) {
8673 inspected[ dataType ] = true;
8674 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
8675 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
8676 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
8677 options.dataTypes.unshift( dataTypeOrTransport );
8678 inspect( dataTypeOrTransport );
8680 } else if ( seekingTransport ) {
8681 return !( selected = dataTypeOrTransport );
8687 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
8690 // A special extend for ajax options
8691 // that takes "flat" options (not to be deep extended)
8693 function ajaxExtend( target, src ) {
8695 flatOptions = jQuery.ajaxSettings.flatOptions || {};
8697 for ( key in src ) {
8698 if ( src[ key ] !== undefined ) {
8699 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
8703 jQuery.extend( true, target, deep );
8709 /* Handles responses to an ajax request:
8710 * - finds the right dataType (mediates between content-type and expected dataType)
8711 * - returns the corresponding response
8713 function ajaxHandleResponses( s, jqXHR, responses ) {
8714 var firstDataType, ct, finalDataType, type,
8715 contents = s.contents,
8716 dataTypes = s.dataTypes;
8718 // Remove auto dataType and get content-type in the process
8719 while ( dataTypes[ 0 ] === "*" ) {
8721 if ( ct === undefined ) {
8722 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
8726 // Check if we're dealing with a known content-type
8728 for ( type in contents ) {
8729 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8730 dataTypes.unshift( type );
8736 // Check to see if we have a response for the expected dataType
8737 if ( dataTypes[ 0 ] in responses ) {
8738 finalDataType = dataTypes[ 0 ];
8740 // Try convertible dataTypes
8741 for ( type in responses ) {
8742 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8743 finalDataType = type;
8746 if ( !firstDataType ) {
8747 firstDataType = type;
8750 // Or just use first one
8751 finalDataType = finalDataType || firstDataType;
8754 // If we found a dataType
8755 // We add the dataType to the list if needed
8756 // and return the corresponding response
8757 if ( finalDataType ) {
8758 if ( finalDataType !== dataTypes[ 0 ] ) {
8759 dataTypes.unshift( finalDataType );
8761 return responses[ finalDataType ];
8765 /* Chain conversions given the request and the original response
8766 * Also sets the responseXXX fields on the jqXHR instance
8768 function ajaxConvert( s, response, jqXHR, isSuccess ) {
8769 var conv2, current, conv, tmp, prev,
8771 // Work with a copy of dataTypes in case we need to modify it for conversion
8772 dataTypes = s.dataTypes.slice();
8774 // Create converters map with lowercased keys
8775 if ( dataTypes[ 1 ] ) {
8776 for ( conv in s.converters ) {
8777 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8781 current = dataTypes.shift();
8783 // Convert to each sequential dataType
8786 if ( s.responseFields[ current ] ) {
8787 jqXHR[ s.responseFields[ current ] ] = response;
8790 // Apply the dataFilter if provided
8791 if ( !prev && isSuccess && s.dataFilter ) {
8792 response = s.dataFilter( response, s.dataType );
8796 current = dataTypes.shift();
8800 // There's only work to do if current dataType is non-auto
8801 if ( current === "*" ) {
8805 // Convert response if prev dataType is non-auto and differs from current
8806 } else if ( prev !== "*" && prev !== current ) {
8808 // Seek a direct converter
8809 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8811 // If none found, seek a pair
8813 for ( conv2 in converters ) {
8815 // If conv2 outputs current
8816 tmp = conv2.split( " " );
8817 if ( tmp[ 1 ] === current ) {
8819 // If prev can be converted to accepted input
8820 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8821 converters[ "* " + tmp[ 0 ] ];
8823 // Condense equivalence converters
8824 if ( conv === true ) {
8825 conv = converters[ conv2 ];
8827 // Otherwise, insert the intermediate dataType
8828 } else if ( converters[ conv2 ] !== true ) {
8830 dataTypes.unshift( tmp[ 1 ] );
8838 // Apply converter (if not an equivalence)
8839 if ( conv !== true ) {
8841 // Unless errors are allowed to bubble, catch and return them
8842 if ( conv && s[ "throws" ] ) {
8843 response = conv( response );
8846 response = conv( response );
8848 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8856 return { state: "success", data: response };
8861 // Counter for holding the number of active queries
8864 // Last-Modified header cache for next request
8871 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
8875 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
8892 xml: "application/xml, text/xml",
8893 json: "application/json, text/javascript"
8904 text: "responseText",
8905 json: "responseJSON"
8909 // Keys separate source (or catchall "*") and destination types with a single space
8912 // Convert anything to text
8915 // Text to html (true = no transformation)
8918 // Evaluate text as a json expression
8919 "text json": jQuery.parseJSON,
8921 // Parse text as xml
8922 "text xml": jQuery.parseXML
8925 // For options that shouldn't be deep extended:
8926 // you can add your own custom options here if
8927 // and when you create one that shouldn't be
8928 // deep extended (see ajaxExtend)
8935 // Creates a full fledged settings object into target
8936 // with both ajaxSettings and settings fields.
8937 // If target is omitted, writes into ajaxSettings.
8938 ajaxSetup: function( target, settings ) {
8941 // Building a settings object
8942 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
8944 // Extending ajaxSettings
8945 ajaxExtend( jQuery.ajaxSettings, target );
8948 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
8949 ajaxTransport: addToPrefiltersOrTransports( transports ),
8952 ajax: function( url, options ) {
8954 // If url is an object, simulate pre-1.5 signature
8955 if ( typeof url === "object" ) {
8960 // Force options to be an object
8961 options = options || {};
8963 var // Cross-domain detection vars
8967 // URL without anti-cache param
8969 // Response headers as string
8970 responseHeadersString,
8974 // To know if global events are to be dispatched
8980 // Create the final options object
8981 s = jQuery.ajaxSetup( {}, options ),
8982 // Callbacks context
8983 callbackContext = s.context || s,
8984 // Context for global events is callbackContext if it is a DOM node or jQuery collection
8985 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
8986 jQuery( callbackContext ) :
8989 deferred = jQuery.Deferred(),
8990 completeDeferred = jQuery.Callbacks("once memory"),
8991 // Status-dependent callbacks
8992 statusCode = s.statusCode || {},
8993 // Headers (they are sent all at once)
8994 requestHeaders = {},
8995 requestHeadersNames = {},
8998 // Default abort message
8999 strAbort = "canceled",
9004 // Builds headers hashtable if needed
9005 getResponseHeader: function( key ) {
9007 if ( state === 2 ) {
9008 if ( !responseHeaders ) {
9009 responseHeaders = {};
9010 while ( (match = rheaders.exec( responseHeadersString )) ) {
9011 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
9014 match = responseHeaders[ key.toLowerCase() ];
9016 return match == null ? null : match;
9020 getAllResponseHeaders: function() {
9021 return state === 2 ? responseHeadersString : null;
9024 // Caches the header
9025 setRequestHeader: function( name, value ) {
9026 var lname = name.toLowerCase();
9028 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
9029 requestHeaders[ name ] = value;
9034 // Overrides response content-type header
9035 overrideMimeType: function( type ) {
9042 // Status-dependent callbacks
9043 statusCode: function( map ) {
9047 for ( code in map ) {
9048 // Lazy-add the new callback in a way that preserves old ones
9049 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
9052 // Execute the appropriate callbacks
9053 jqXHR.always( map[ jqXHR.status ] );
9059 // Cancel the request
9060 abort: function( statusText ) {
9061 var finalText = statusText || strAbort;
9063 transport.abort( finalText );
9065 done( 0, finalText );
9071 deferred.promise( jqXHR ).complete = completeDeferred.add;
9072 jqXHR.success = jqXHR.done;
9073 jqXHR.error = jqXHR.fail;
9075 // Remove hash character (#7531: and string promotion)
9076 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
9077 // Handle falsy url in the settings object (#10093: consistency with old signature)
9078 // We also use the url parameter if available
9079 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
9081 // Alias method option to type as per ticket #12004
9082 s.type = options.method || options.type || s.method || s.type;
9084 // Extract dataTypes list
9085 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
9087 // A cross-domain request is in order when we have a protocol:host:port mismatch
9088 if ( s.crossDomain == null ) {
9089 parts = rurl.exec( s.url.toLowerCase() );
9090 s.crossDomain = !!( parts &&
9091 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
9092 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
9093 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
9097 // Convert data if not already a string
9098 if ( s.data && s.processData && typeof s.data !== "string" ) {
9099 s.data = jQuery.param( s.data, s.traditional );
9103 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9105 // If request was aborted inside a prefilter, stop there
9106 if ( state === 2 ) {
9110 // We can fire global events as of now if asked to
9111 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9112 fireGlobals = jQuery.event && s.global;
9114 // Watch for a new set of requests
9115 if ( fireGlobals && jQuery.active++ === 0 ) {
9116 jQuery.event.trigger("ajaxStart");
9119 // Uppercase the type
9120 s.type = s.type.toUpperCase();
9122 // Determine if request has content
9123 s.hasContent = !rnoContent.test( s.type );
9125 // Save the URL in case we're toying with the If-Modified-Since
9126 // and/or If-None-Match header later on
9129 // More options handling for requests with no content
9130 if ( !s.hasContent ) {
9132 // If data is available, append data to url
9134 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
9135 // #9682: remove data so that it's not used in an eventual retry
9139 // Add anti-cache in url if needed
9140 if ( s.cache === false ) {
9141 s.url = rts.test( cacheURL ) ?
9143 // If there is already a '_' parameter, set its value
9144 cacheURL.replace( rts, "$1_=" + nonce++ ) :
9146 // Otherwise add one to the end
9147 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
9151 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9152 if ( s.ifModified ) {
9153 if ( jQuery.lastModified[ cacheURL ] ) {
9154 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9156 if ( jQuery.etag[ cacheURL ] ) {
9157 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9161 // Set the correct header, if data is being sent
9162 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9163 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9166 // Set the Accepts header for the server, depending on the dataType
9167 jqXHR.setRequestHeader(
9169 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
9170 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9174 // Check for headers option
9175 for ( i in s.headers ) {
9176 jqXHR.setRequestHeader( i, s.headers[ i ] );
9179 // Allow custom headers/mimetypes and early abort
9180 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
9181 // Abort if not done already and return
9182 return jqXHR.abort();
9185 // aborting is no longer a cancellation
9188 // Install callbacks on deferreds
9189 for ( i in { success: 1, error: 1, complete: 1 } ) {
9190 jqXHR[ i ]( s[ i ] );
9194 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9196 // If no transport, we auto-abort
9198 done( -1, "No Transport" );
9200 jqXHR.readyState = 1;
9202 // Send global event
9203 if ( fireGlobals ) {
9204 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9207 if ( s.async && s.timeout > 0 ) {
9208 timeoutTimer = setTimeout(function() {
9209 jqXHR.abort("timeout");
9215 transport.send( requestHeaders, done );
9217 // Propagate exception as error if not done
9220 // Simply rethrow otherwise
9227 // Callback for when everything is done
9228 function done( status, nativeStatusText, responses, headers ) {
9229 var isSuccess, success, error, response, modified,
9230 statusText = nativeStatusText;
9233 if ( state === 2 ) {
9237 // State is "done" now
9240 // Clear timeout if it exists
9241 if ( timeoutTimer ) {
9242 clearTimeout( timeoutTimer );
9245 // Dereference transport for early garbage collection
9246 // (no matter how long the jqXHR object will be used)
9247 transport = undefined;
9249 // Cache response headers
9250 responseHeadersString = headers || "";
9253 jqXHR.readyState = status > 0 ? 4 : 0;
9255 // Determine if successful
9256 isSuccess = status >= 200 && status < 300 || status === 304;
9258 // Get response data
9260 response = ajaxHandleResponses( s, jqXHR, responses );
9263 // Convert no matter what (that way responseXXX fields are always set)
9264 response = ajaxConvert( s, response, jqXHR, isSuccess );
9266 // If successful, handle type chaining
9269 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9270 if ( s.ifModified ) {
9271 modified = jqXHR.getResponseHeader("Last-Modified");
9273 jQuery.lastModified[ cacheURL ] = modified;
9275 modified = jqXHR.getResponseHeader("etag");
9277 jQuery.etag[ cacheURL ] = modified;
9282 if ( status === 204 || s.type === "HEAD" ) {
9283 statusText = "nocontent";
9286 } else if ( status === 304 ) {
9287 statusText = "notmodified";
9289 // If we have data, let's convert it
9291 statusText = response.state;
9292 success = response.data;
9293 error = response.error;
9297 // We extract error from statusText
9298 // then normalize statusText and status for non-aborts
9300 if ( status || !statusText ) {
9301 statusText = "error";
9308 // Set data for the fake xhr object
9309 jqXHR.status = status;
9310 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9314 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9316 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9319 // Status-dependent callbacks
9320 jqXHR.statusCode( statusCode );
9321 statusCode = undefined;
9323 if ( fireGlobals ) {
9324 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9325 [ jqXHR, s, isSuccess ? success : error ] );
9329 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9331 if ( fireGlobals ) {
9332 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9333 // Handle the global AJAX counter
9334 if ( !( --jQuery.active ) ) {
9335 jQuery.event.trigger("ajaxStop");
9343 getJSON: function( url, data, callback ) {
9344 return jQuery.get( url, data, callback, "json" );
9347 getScript: function( url, callback ) {
9348 return jQuery.get( url, undefined, callback, "script" );
9352 jQuery.each( [ "get", "post" ], function( i, method ) {
9353 jQuery[ method ] = function( url, data, callback, type ) {
9354 // shift arguments if data argument was omitted
9355 if ( jQuery.isFunction( data ) ) {
9356 type = type || callback;
9361 return jQuery.ajax({
9372 jQuery._evalUrl = function( url ) {
9373 return jQuery.ajax({
9385 wrapAll: function( html ) {
9386 if ( jQuery.isFunction( html ) ) {
9387 return this.each(function(i) {
9388 jQuery(this).wrapAll( html.call(this, i) );
9393 // The elements to wrap the target around
9394 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
9396 if ( this[0].parentNode ) {
9397 wrap.insertBefore( this[0] );
9400 wrap.map(function() {
9403 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
9404 elem = elem.firstChild;
9414 wrapInner: function( html ) {
9415 if ( jQuery.isFunction( html ) ) {
9416 return this.each(function(i) {
9417 jQuery(this).wrapInner( html.call(this, i) );
9421 return this.each(function() {
9422 var self = jQuery( this ),
9423 contents = self.contents();
9425 if ( contents.length ) {
9426 contents.wrapAll( html );
9429 self.append( html );
9434 wrap: function( html ) {
9435 var isFunction = jQuery.isFunction( html );
9437 return this.each(function(i) {
9438 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
9442 unwrap: function() {
9443 return this.parent().each(function() {
9444 if ( !jQuery.nodeName( this, "body" ) ) {
9445 jQuery( this ).replaceWith( this.childNodes );
9452 jQuery.expr.filters.hidden = function( elem ) {
9453 // Support: Opera <= 12.12
9454 // Opera reports offsetWidths and offsetHeights less than zero on some elements
9455 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
9456 (!support.reliableHiddenOffsets() &&
9457 ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
9460 jQuery.expr.filters.visible = function( elem ) {
9461 return !jQuery.expr.filters.hidden( elem );
9470 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
9471 rsubmittable = /^(?:input|select|textarea|keygen)/i;
9473 function buildParams( prefix, obj, traditional, add ) {
9476 if ( jQuery.isArray( obj ) ) {
9477 // Serialize array item.
9478 jQuery.each( obj, function( i, v ) {
9479 if ( traditional || rbracket.test( prefix ) ) {
9480 // Treat each array item as a scalar.
9484 // Item is non-scalar (array or object), encode its numeric index.
9485 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
9489 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
9490 // Serialize object item.
9491 for ( name in obj ) {
9492 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
9496 // Serialize scalar item.
9501 // Serialize an array of form elements or a set of
9502 // key/values into a query string
9503 jQuery.param = function( a, traditional ) {
9506 add = function( key, value ) {
9507 // If value is a function, invoke it and return its value
9508 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
9509 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
9512 // Set traditional to true for jQuery <= 1.3.2 behavior.
9513 if ( traditional === undefined ) {
9514 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
9517 // If an array was passed in, assume that it is an array of form elements.
9518 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
9519 // Serialize the form elements
9520 jQuery.each( a, function() {
9521 add( this.name, this.value );
9525 // If traditional, encode the "old" way (the way 1.3.2 or older
9526 // did it), otherwise encode params recursively.
9527 for ( prefix in a ) {
9528 buildParams( prefix, a[ prefix ], traditional, add );
9532 // Return the resulting serialization
9533 return s.join( "&" ).replace( r20, "+" );
9537 serialize: function() {
9538 return jQuery.param( this.serializeArray() );
9540 serializeArray: function() {
9541 return this.map(function() {
9542 // Can add propHook for "elements" to filter or add form elements
9543 var elements = jQuery.prop( this, "elements" );
9544 return elements ? jQuery.makeArray( elements ) : this;
9546 .filter(function() {
9547 var type = this.type;
9548 // Use .is(":disabled") so that fieldset[disabled] works
9549 return this.name && !jQuery( this ).is( ":disabled" ) &&
9550 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
9551 ( this.checked || !rcheckableType.test( type ) );
9553 .map(function( i, elem ) {
9554 var val = jQuery( this ).val();
9556 return val == null ?
9558 jQuery.isArray( val ) ?
9559 jQuery.map( val, function( val ) {
9560 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9562 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9568 // Create the request object
9569 // (This is still attached to ajaxSettings for backward compatibility)
9570 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
9574 // XHR cannot access local files, always use ActiveX for that case
9575 return !this.isLocal &&
9578 // oldIE XHR does not support non-RFC2616 methods (#13240)
9579 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
9580 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
9581 // Although this check for six methods instead of eight
9582 // since IE also does not support "trace" and "connect"
9583 /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
9585 createStandardXHR() || createActiveXHR();
9587 // For all other browsers, use the standard XMLHttpRequest object
9592 xhrSupported = jQuery.ajaxSettings.xhr();
9595 // Open requests must be manually aborted on unload (#5280)
9596 // See https://support.microsoft.com/kb/2856746 for more info
9597 if ( window.attachEvent ) {
9598 window.attachEvent( "onunload", function() {
9599 for ( var key in xhrCallbacks ) {
9600 xhrCallbacks[ key ]( undefined, true );
9605 // Determine support properties
9606 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
9607 xhrSupported = support.ajax = !!xhrSupported;
9609 // Create transport if the browser can provide an xhr
9610 if ( xhrSupported ) {
9612 jQuery.ajaxTransport(function( options ) {
9613 // Cross domain only allowed if supported through XMLHttpRequest
9614 if ( !options.crossDomain || support.cors ) {
9619 send: function( headers, complete ) {
9621 xhr = options.xhr(),
9625 xhr.open( options.type, options.url, options.async, options.username, options.password );
9627 // Apply custom fields if provided
9628 if ( options.xhrFields ) {
9629 for ( i in options.xhrFields ) {
9630 xhr[ i ] = options.xhrFields[ i ];
9634 // Override mime type if needed
9635 if ( options.mimeType && xhr.overrideMimeType ) {
9636 xhr.overrideMimeType( options.mimeType );
9639 // X-Requested-With header
9640 // For cross-domain requests, seeing as conditions for a preflight are
9641 // akin to a jigsaw puzzle, we simply never set it to be sure.
9642 // (it can always be set on a per-request basis or even using ajaxSetup)
9643 // For same-domain requests, won't change header if already provided.
9644 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
9645 headers["X-Requested-With"] = "XMLHttpRequest";
9649 for ( i in headers ) {
9651 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
9652 // request header to a null-value.
9654 // To keep consistent with other XHR implementations, cast the value
9655 // to string and ignore `undefined`.
9656 if ( headers[ i ] !== undefined ) {
9657 xhr.setRequestHeader( i, headers[ i ] + "" );
9661 // Do send the request
9662 // This may raise an exception which is actually
9663 // handled in jQuery.ajax (so no try/catch here)
9664 xhr.send( ( options.hasContent && options.data ) || null );
9667 callback = function( _, isAbort ) {
9668 var status, statusText, responses;
9670 // Was never called and is aborted or complete
9671 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
9673 delete xhrCallbacks[ id ];
9674 callback = undefined;
9675 xhr.onreadystatechange = jQuery.noop;
9677 // Abort manually if needed
9679 if ( xhr.readyState !== 4 ) {
9684 status = xhr.status;
9687 // Accessing binary-data responseText throws an exception
9689 if ( typeof xhr.responseText === "string" ) {
9690 responses.text = xhr.responseText;
9693 // Firefox throws an exception when accessing
9694 // statusText for faulty cross-domain requests
9696 statusText = xhr.statusText;
9698 // We normalize with Webkit giving an empty statusText
9702 // Filter status for non standard behaviors
9704 // If the request is local and we have data: assume a success
9705 // (success with no data won't get notified, that's the best we
9706 // can do given current implementations)
9707 if ( !status && options.isLocal && !options.crossDomain ) {
9708 status = responses.text ? 200 : 404;
9709 // IE - #1450: sometimes returns 1223 when it should be 204
9710 } else if ( status === 1223 ) {
9716 // Call complete if needed
9718 complete( status, statusText, responses, xhr.getAllResponseHeaders() );
9722 if ( !options.async ) {
9723 // if we're in sync mode we fire the callback
9725 } else if ( xhr.readyState === 4 ) {
9726 // (IE6 & IE7) if it's in cache and has been
9727 // retrieved directly we need to fire the callback
9728 setTimeout( callback );
9730 // Add to the list of active xhr callbacks
9731 xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
9737 callback( undefined, true );
9745 // Functions to create xhrs
9746 function createStandardXHR() {
9748 return new window.XMLHttpRequest();
9752 function createActiveXHR() {
9754 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
9761 // Install script dataType
9764 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
9767 script: /(?:java|ecma)script/
9770 "text script": function( text ) {
9771 jQuery.globalEval( text );
9777 // Handle cache's special case and global
9778 jQuery.ajaxPrefilter( "script", function( s ) {
9779 if ( s.cache === undefined ) {
9782 if ( s.crossDomain ) {
9788 // Bind script tag hack transport
9789 jQuery.ajaxTransport( "script", function(s) {
9791 // This transport only deals with cross domain requests
9792 if ( s.crossDomain ) {
9795 head = document.head || jQuery("head")[0] || document.documentElement;
9799 send: function( _, callback ) {
9801 script = document.createElement("script");
9803 script.async = true;
9805 if ( s.scriptCharset ) {
9806 script.charset = s.scriptCharset;
9811 // Attach handlers for all browsers
9812 script.onload = script.onreadystatechange = function( _, isAbort ) {
9814 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
9816 // Handle memory leak in IE
9817 script.onload = script.onreadystatechange = null;
9819 // Remove the script
9820 if ( script.parentNode ) {
9821 script.parentNode.removeChild( script );
9824 // Dereference the script
9827 // Callback if not abort
9829 callback( 200, "success" );
9834 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
9835 // Use native DOM manipulation to avoid our domManip AJAX trickery
9836 head.insertBefore( script, head.firstChild );
9841 script.onload( undefined, true );
9851 var oldCallbacks = [],
9852 rjsonp = /(=)\?(?=&|$)|\?\?/;
9854 // Default jsonp settings
9857 jsonpCallback: function() {
9858 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
9859 this[ callback ] = true;
9864 // Detect, normalize options and install callbacks for jsonp requests
9865 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
9867 var callbackName, overwritten, responseContainer,
9868 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
9870 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
9873 // Handle iff the expected data type is "jsonp" or we have a parameter to set
9874 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
9876 // Get callback name, remembering preexisting value associated with it
9877 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
9881 // Insert callback into url or form data
9883 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
9884 } else if ( s.jsonp !== false ) {
9885 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
9888 // Use data converter to retrieve json after script execution
9889 s.converters["script json"] = function() {
9890 if ( !responseContainer ) {
9891 jQuery.error( callbackName + " was not called" );
9893 return responseContainer[ 0 ];
9896 // force json dataType
9897 s.dataTypes[ 0 ] = "json";
9900 overwritten = window[ callbackName ];
9901 window[ callbackName ] = function() {
9902 responseContainer = arguments;
9905 // Clean-up function (fires after converters)
9906 jqXHR.always(function() {
9907 // Restore preexisting value
9908 window[ callbackName ] = overwritten;
9910 // Save back as free
9911 if ( s[ callbackName ] ) {
9912 // make sure that re-using the options doesn't screw things around
9913 s.jsonpCallback = originalSettings.jsonpCallback;
9915 // save the callback name for future use
9916 oldCallbacks.push( callbackName );
9919 // Call if it was a function and we have a response
9920 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
9921 overwritten( responseContainer[ 0 ] );
9924 responseContainer = overwritten = undefined;
9927 // Delegate to script
9935 // data: string of html
9936 // context (optional): If specified, the fragment will be created in this context, defaults to document
9937 // keepScripts (optional): If true, will include scripts passed in the html string
9938 jQuery.parseHTML = function( data, context, keepScripts ) {
9939 if ( !data || typeof data !== "string" ) {
9942 if ( typeof context === "boolean" ) {
9943 keepScripts = context;
9946 context = context || document;
9948 var parsed = rsingleTag.exec( data ),
9949 scripts = !keepScripts && [];
9953 return [ context.createElement( parsed[1] ) ];
9956 parsed = jQuery.buildFragment( [ data ], context, scripts );
9958 if ( scripts && scripts.length ) {
9959 jQuery( scripts ).remove();
9962 return jQuery.merge( [], parsed.childNodes );
9966 // Keep a copy of the old load method
9967 var _load = jQuery.fn.load;
9970 * Load a url into a page
9972 jQuery.fn.load = function( url, params, callback ) {
9973 if ( typeof url !== "string" && _load ) {
9974 return _load.apply( this, arguments );
9977 var selector, response, type,
9979 off = url.indexOf(" ");
9982 selector = jQuery.trim( url.slice( off, url.length ) );
9983 url = url.slice( 0, off );
9986 // If it's a function
9987 if ( jQuery.isFunction( params ) ) {
9989 // We assume that it's the callback
9993 // Otherwise, build a param string
9994 } else if ( params && typeof params === "object" ) {
9998 // If we have elements to modify, make the request
9999 if ( self.length > 0 ) {
10003 // if "type" variable is undefined, then "GET" method will be used
10007 }).done(function( responseText ) {
10009 // Save response for use in complete callback
10010 response = arguments;
10012 self.html( selector ?
10014 // If a selector was specified, locate the right elements in a dummy div
10015 // Exclude scripts to avoid IE 'Permission Denied' errors
10016 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
10018 // Otherwise use the full result
10021 }).complete( callback && function( jqXHR, status ) {
10022 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
10032 // Attach a bunch of functions for handling common AJAX events
10033 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
10034 jQuery.fn[ type ] = function( fn ) {
10035 return this.on( type, fn );
10042 jQuery.expr.filters.animated = function( elem ) {
10043 return jQuery.grep(jQuery.timers, function( fn ) {
10044 return elem === fn.elem;
10052 var docElem = window.document.documentElement;
10055 * Gets a window from an element
10057 function getWindow( elem ) {
10058 return jQuery.isWindow( elem ) ?
10060 elem.nodeType === 9 ?
10061 elem.defaultView || elem.parentWindow :
10066 setOffset: function( elem, options, i ) {
10067 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
10068 position = jQuery.css( elem, "position" ),
10069 curElem = jQuery( elem ),
10072 // set position first, in-case top/left are set even on static elem
10073 if ( position === "static" ) {
10074 elem.style.position = "relative";
10077 curOffset = curElem.offset();
10078 curCSSTop = jQuery.css( elem, "top" );
10079 curCSSLeft = jQuery.css( elem, "left" );
10080 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
10081 jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
10083 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
10084 if ( calculatePosition ) {
10085 curPosition = curElem.position();
10086 curTop = curPosition.top;
10087 curLeft = curPosition.left;
10089 curTop = parseFloat( curCSSTop ) || 0;
10090 curLeft = parseFloat( curCSSLeft ) || 0;
10093 if ( jQuery.isFunction( options ) ) {
10094 options = options.call( elem, i, curOffset );
10097 if ( options.top != null ) {
10098 props.top = ( options.top - curOffset.top ) + curTop;
10100 if ( options.left != null ) {
10101 props.left = ( options.left - curOffset.left ) + curLeft;
10104 if ( "using" in options ) {
10105 options.using.call( elem, props );
10107 curElem.css( props );
10113 offset: function( options ) {
10114 if ( arguments.length ) {
10115 return options === undefined ?
10117 this.each(function( i ) {
10118 jQuery.offset.setOffset( this, options, i );
10123 box = { top: 0, left: 0 },
10125 doc = elem && elem.ownerDocument;
10131 docElem = doc.documentElement;
10133 // Make sure it's not a disconnected DOM node
10134 if ( !jQuery.contains( docElem, elem ) ) {
10138 // If we don't have gBCR, just use 0,0 rather than error
10139 // BlackBerry 5, iOS 3 (original iPhone)
10140 if ( typeof elem.getBoundingClientRect !== strundefined ) {
10141 box = elem.getBoundingClientRect();
10143 win = getWindow( doc );
10145 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
10146 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
10150 position: function() {
10151 if ( !this[ 0 ] ) {
10155 var offsetParent, offset,
10156 parentOffset = { top: 0, left: 0 },
10159 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
10160 if ( jQuery.css( elem, "position" ) === "fixed" ) {
10161 // we assume that getBoundingClientRect is available when computed position is fixed
10162 offset = elem.getBoundingClientRect();
10164 // Get *real* offsetParent
10165 offsetParent = this.offsetParent();
10167 // Get correct offsets
10168 offset = this.offset();
10169 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
10170 parentOffset = offsetParent.offset();
10173 // Add offsetParent borders
10174 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
10175 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
10178 // Subtract parent offsets and element margins
10179 // note: when an element has margin: auto the offsetLeft and marginLeft
10180 // are the same in Safari causing offset.left to incorrectly be 0
10182 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10183 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
10187 offsetParent: function() {
10188 return this.map(function() {
10189 var offsetParent = this.offsetParent || docElem;
10191 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
10192 offsetParent = offsetParent.offsetParent;
10194 return offsetParent || docElem;
10199 // Create scrollLeft and scrollTop methods
10200 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10201 var top = /Y/.test( prop );
10203 jQuery.fn[ method ] = function( val ) {
10204 return access( this, function( elem, method, val ) {
10205 var win = getWindow( elem );
10207 if ( val === undefined ) {
10208 return win ? (prop in win) ? win[ prop ] :
10209 win.document.documentElement[ method ] :
10215 !top ? val : jQuery( win ).scrollLeft(),
10216 top ? val : jQuery( win ).scrollTop()
10220 elem[ method ] = val;
10222 }, method, val, arguments.length, null );
10226 // Add the top/left cssHooks using jQuery.fn.position
10227 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10228 // getComputedStyle returns percent when specified for top/left/bottom/right
10229 // rather than make the css module depend on the offset module, we just check for it here
10230 jQuery.each( [ "top", "left" ], function( i, prop ) {
10231 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10232 function( elem, computed ) {
10234 computed = curCSS( elem, prop );
10235 // if curCSS returns percentage, fallback to offset
10236 return rnumnonpx.test( computed ) ?
10237 jQuery( elem ).position()[ prop ] + "px" :
10245 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10246 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10247 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
10248 // margin is only for outerHeight, outerWidth
10249 jQuery.fn[ funcName ] = function( margin, value ) {
10250 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10251 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10253 return access( this, function( elem, type, value ) {
10256 if ( jQuery.isWindow( elem ) ) {
10257 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
10258 // isn't a whole lot we can do. See pull request at this URL for discussion:
10259 // https://github.com/jquery/jquery/pull/764
10260 return elem.document.documentElement[ "client" + name ];
10263 // Get document width or height
10264 if ( elem.nodeType === 9 ) {
10265 doc = elem.documentElement;
10267 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
10268 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
10270 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10271 elem.body[ "offset" + name ], doc[ "offset" + name ],
10272 doc[ "client" + name ]
10276 return value === undefined ?
10277 // Get width or height on the element, requesting but not forcing parseFloat
10278 jQuery.css( elem, type, extra ) :
10280 // Set width or height on the element
10281 jQuery.style( elem, type, value, extra );
10282 }, type, chainable ? margin : undefined, chainable, null );
10288 // The number of elements contained in the matched element set
10289 jQuery.fn.size = function() {
10290 return this.length;
10293 jQuery.fn.andSelf = jQuery.fn.addBack;
10298 // Register as a named AMD module, since jQuery can be concatenated with other
10299 // files that may use define, but not via a proper concatenation script that
10300 // understands anonymous AMD modules. A named AMD is safest and most robust
10301 // way to register. Lowercase jquery is used because AMD module names are
10302 // derived from file names, and jQuery is normally delivered in a lowercase
10303 // file name. Do this after creating the global so that if an AMD module wants
10304 // to call noConflict to hide this version of jQuery, it will work.
10306 // Note that for maximum portability, libraries that are not jQuery should
10307 // declare themselves as anonymous modules, and avoid setting a global if an
10308 // AMD loader is present. jQuery is a special case. For more information, see
10309 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10311 if ( typeof define === "function" && define.amd ) {
10312 define( "jquery", [], function() {
10321 // Map over jQuery in case of overwrite
10322 _jQuery = window.jQuery,
10324 // Map over the $ in case of overwrite
10327 jQuery.noConflict = function( deep ) {
10328 if ( window.$ === jQuery ) {
10332 if ( deep && window.jQuery === jQuery ) {
10333 window.jQuery = _jQuery;
10339 // Expose jQuery and $ identifiers, even in
10340 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10341 // and CommonJS for browser emulators (#13566)
10342 if ( typeof noGlobal === strundefined ) {
10343 window.jQuery = window.$ = jQuery;