2 * jQuery JavaScript Library v1.11.0
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2014-01-23T21:02Z
15 // modified by Bob Hanson for local MSIE 11 reading remote files
17 (function( global, factory ) {
19 if ( typeof module === "object" && typeof module.exports === "object" ) {
20 // For CommonJS and CommonJS-like environments where a proper window is present,
21 // execute the factory and get jQuery
22 // For environments that do not inherently posses a window with a document
23 // (such as Node.js), expose a jQuery-making factory as module.exports
24 // This accentuates the need for the creation of a real window
25 // e.g. var jQuery = require("jquery")(window);
26 // See ticket #14549 for more info
27 module.exports = global.document ?
28 factory( global, true ) :
31 throw new Error( "jQuery requires a window with a document" );
39 // Pass this if window is not defined yet
40 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
42 // Can't do this because several apps including ASP.NET trace
43 // the stack via arguments.caller.callee and Firefox dies if
44 // you try to trace through "use strict" call chains. (#13335)
45 // Support: Firefox 18+
50 var slice = deletedIds.slice;
52 var concat = deletedIds.concat;
54 var push = deletedIds.push;
56 var indexOf = deletedIds.indexOf;
60 var toString = class2type.toString;
62 var hasOwn = class2type.hasOwnProperty;
73 // Define a local copy of jQuery
74 jQuery = function( selector, context ) {
75 // The jQuery object is actually just the init constructor 'enhanced'
76 // Need init if jQuery is called (just allow error to be thrown if not included)
77 return new jQuery.fn.init( selector, context );
80 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
83 // Matches dashed string for camelizing
85 rdashAlpha = /-([\da-z])/gi,
87 // Used by jQuery.camelCase as callback to replace()
88 fcamelCase = function( all, letter ) {
89 return letter.toUpperCase();
92 jQuery.fn = jQuery.prototype = {
93 // The current version of jQuery being used
98 // Start with an empty selector
101 // The default length of a jQuery object is 0
104 toArray: function() {
105 return slice.call( this );
108 // Get the Nth element in the matched element set OR
109 // Get the whole matched element set as a clean array
110 get: function( num ) {
113 // Return a 'clean' array
114 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116 // Return just the object
120 // Take an array of elements and push it onto the stack
121 // (returning the new matched element set)
122 pushStack: function( elems ) {
124 // Build a new jQuery matched element set
125 var ret = jQuery.merge( this.constructor(), elems );
127 // Add the old object onto the stack (as a reference)
128 ret.prevObject = this;
129 ret.context = this.context;
131 // Return the newly-formed element set
135 // Execute a callback for every element in the matched set.
136 // (You can seed the arguments with an array of args, but this is
137 // only used internally.)
138 each: function( callback, args ) {
139 return jQuery.each( this, callback, args );
142 map: function( callback ) {
143 return this.pushStack( jQuery.map(this, function( elem, i ) {
144 return callback.call( elem, i, elem );
149 return this.pushStack( slice.apply( this, arguments ) );
157 return this.eq( -1 );
161 var len = this.length,
162 j = +i + ( i < 0 ? len : 0 );
163 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
167 return this.prevObject || this.constructor(null);
170 // For internal use only.
171 // Behaves like an Array's method, not like a jQuery method.
173 sort: deletedIds.sort,
174 splice: deletedIds.splice
177 jQuery.extend = jQuery.fn.extend = function() {
178 var src, copyIsArray, copy, name, options, clone,
179 target = arguments[0] || {},
181 length = arguments.length,
184 // Handle a deep copy situation
185 if ( typeof target === "boolean" ) {
188 // skip the boolean and the target
189 target = arguments[ i ] || {};
193 // Handle case when target is a string or something (possible in deep copy)
194 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
198 // extend jQuery itself if only one argument is passed
199 if ( i === length ) {
204 for ( ; i < length; i++ ) {
205 // Only deal with non-null/undefined values
206 if ( (options = arguments[ i ]) != null ) {
207 // Extend the base object
208 for ( name in options ) {
209 src = target[ name ];
210 copy = options[ name ];
212 // Prevent never-ending loop
213 if ( target === copy ) {
217 // Recurse if we're merging plain objects or arrays
218 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
221 clone = src && jQuery.isArray(src) ? src : [];
224 clone = src && jQuery.isPlainObject(src) ? src : {};
227 // Never move original objects, clone them
228 target[ name ] = jQuery.extend( deep, clone, copy );
230 // Don't bring in undefined values
231 } else if ( copy !== undefined ) {
232 target[ name ] = copy;
238 // Return the modified object
243 // Unique for each copy of jQuery on the page
244 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
246 // Assume jQuery is ready without the ready module
249 error: function( msg ) {
250 throw new Error( msg );
255 // See test/unit/core.js for details concerning isFunction.
256 // Since version 1.3, DOM methods and functions like alert
257 // aren't supported. They return false on IE (#2968).
258 isFunction: function( obj ) {
259 return jQuery.type(obj) === "function";
262 isArray: Array.isArray || function( obj ) {
263 return jQuery.type(obj) === "array";
266 isWindow: function( obj ) {
267 /* jshint eqeqeq: false */
268 return obj != null && obj == obj.window;
271 isNumeric: function( obj ) {
272 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
273 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
274 // subtraction forces infinities to NaN
275 return obj - parseFloat( obj ) >= 0;
278 isEmptyObject: function( obj ) {
280 for ( name in obj ) {
286 isPlainObject: function( obj ) {
289 // Must be an Object.
290 // Because of IE, we also have to check the presence of the constructor property.
291 // Make sure that DOM nodes and window objects don't pass through, as well
292 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
297 // Not own constructor property must be Object
298 if ( obj.constructor &&
299 !hasOwn.call(obj, "constructor") &&
300 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
304 // IE8,9 Will throw exceptions on certain host objects #9897
309 // Handle iteration over inherited properties before own properties.
310 if ( support.ownLast ) {
312 return hasOwn.call( obj, key );
316 // Own properties are enumerated firstly, so to speed up,
317 // if last one is own, then all properties are own.
318 for ( key in obj ) {}
320 return key === undefined || hasOwn.call( obj, key );
323 type: function( obj ) {
327 return typeof obj === "object" || typeof obj === "function" ?
328 class2type[ toString.call(obj) ] || "object" :
332 // Evaluates a script in a global context
333 // Workarounds based on findings by Jim Driscoll
334 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
335 globalEval: function( data ) {
336 if ( data && jQuery.trim( data ) ) {
337 // We use execScript on Internet Explorer
338 // We use an anonymous function so that context is window
339 // rather than jQuery in Firefox
340 ( window.execScript || function( data ) {
341 window[ "eval" ].call( window, data );
346 // Convert dashed to camelCase; used by the css and data modules
347 // Microsoft forgot to hump their vendor prefix (#9572)
348 camelCase: function( string ) {
349 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
352 nodeName: function( elem, name ) {
353 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
356 // args is for internal usage only
357 each: function( obj, callback, args ) {
361 isArray = isArraylike( obj );
365 for ( ; i < length; i++ ) {
366 value = callback.apply( obj[ i ], args );
368 if ( value === false ) {
374 value = callback.apply( obj[ i ], args );
376 if ( value === false ) {
382 // A special, fast, case for the most common use of each
385 for ( ; i < length; i++ ) {
386 value = callback.call( obj[ i ], i, obj[ i ] );
388 if ( value === false ) {
394 value = callback.call( obj[ i ], i, obj[ i ] );
396 if ( value === false ) {
406 // Use native String.trim function wherever possible
407 trim: trim && !trim.call("\uFEFF\xA0") ?
409 return text == null ?
414 // Otherwise use our own trimming functionality
416 return text == null ?
418 ( text + "" ).replace( rtrim, "" );
421 // results is for internal usage only
422 makeArray: function( arr, results ) {
423 var ret = results || [];
426 if ( isArraylike( Object(arr) ) ) {
428 typeof arr === "string" ?
432 push.call( ret, arr );
439 inArray: function( elem, arr, i ) {
444 return indexOf.call( arr, elem, i );
448 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
450 for ( ; i < len; i++ ) {
451 // Skip accessing in sparse arrays
452 if ( i in arr && arr[ i ] === elem ) {
461 merge: function( first, second ) {
462 var len = +second.length,
467 first[ i++ ] = second[ j++ ];
471 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
473 while ( second[j] !== undefined ) {
474 first[ i++ ] = second[ j++ ];
483 grep: function( elems, callback, invert ) {
487 length = elems.length,
488 callbackExpect = !invert;
490 // Go through the array, only saving the items
491 // that pass the validator function
492 for ( ; i < length; i++ ) {
493 callbackInverse = !callback( elems[ i ], i );
494 if ( callbackInverse !== callbackExpect ) {
495 matches.push( elems[ i ] );
502 // arg is for internal usage only
503 map: function( elems, callback, arg ) {
506 length = elems.length,
507 isArray = isArraylike( elems ),
510 // Go through the array, translating each of the items to their new values
512 for ( ; i < length; i++ ) {
513 value = callback( elems[ i ], i, arg );
515 if ( value != null ) {
520 // Go through every key on the object,
523 value = callback( elems[ i ], i, arg );
525 if ( value != null ) {
531 // Flatten any nested arrays
532 return concat.apply( [], ret );
535 // A global GUID counter for objects
538 // Bind a function to a context, optionally partially applying any
540 proxy: function( fn, context ) {
541 var args, proxy, tmp;
543 if ( typeof context === "string" ) {
549 // Quick check to determine if target is callable, in the spec
550 // this throws a TypeError, but we will just return undefined.
551 if ( !jQuery.isFunction( fn ) ) {
556 args = slice.call( arguments, 2 );
558 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
561 // Set the guid of unique handler to the same of original handler, so it can be removed
562 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
568 return +( new Date() );
571 // jQuery.support is not used in Core but other projects attach their
572 // properties to it so it needs to exist.
576 // Populate the class2type map
577 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
578 class2type[ "[object " + name + "]" ] = name.toLowerCase();
581 function isArraylike( obj ) {
582 var length = obj.length,
583 type = jQuery.type( obj );
585 if ( type === "function" || jQuery.isWindow( obj ) ) {
589 if ( obj.nodeType === 1 && length ) {
593 return type === "array" || length === 0 ||
594 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
598 * Sizzle CSS Selector Engine v1.10.16
599 * http://sizzlejs.com/
601 * Copyright 2013 jQuery Foundation, Inc. and other contributors
602 * Released under the MIT license
603 * http://jquery.org/license
607 (function( window ) {
619 // Local document vars
629 // Instance-specific data
630 expando = "sizzle" + -(new Date()),
631 preferredDoc = window.document,
634 classCache = createCache(),
635 tokenCache = createCache(),
636 compilerCache = createCache(),
637 sortOrder = function( a, b ) {
644 // General-purpose constants
645 strundefined = typeof undefined,
646 MAX_NEGATIVE = 1 << 31,
649 hasOwn = ({}).hasOwnProperty,
652 push_native = arr.push,
655 // Use a stripped-down indexOf if we can't use a native one
656 indexOf = arr.indexOf || function( elem ) {
659 for ( ; i < len; i++ ) {
660 if ( this[i] === elem ) {
667 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
669 // Regular expressions
671 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
672 whitespace = "[\\x20\\t\\r\\n\\f]",
673 // http://www.w3.org/TR/css3-syntax/#characters
674 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
676 // Loosely modeled on CSS identifier characters
677 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
678 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
679 identifier = characterEncoding.replace( "w", "w#" ),
681 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
682 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
683 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
685 // Prefer arguments quoted,
686 // then not containing pseudos/brackets,
687 // then attribute selectors/non-parenthetical expressions,
688 // then anything else
689 // These preferences are here to reduce the number of selectors
690 // needing tokenize in the PSEUDO preFilter
691 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
693 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
694 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
696 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
697 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
699 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
701 rpseudo = new RegExp( pseudos ),
702 ridentifier = new RegExp( "^" + identifier + "$" ),
705 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
706 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
707 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
708 "ATTR": new RegExp( "^" + attributes ),
709 "PSEUDO": new RegExp( "^" + pseudos ),
710 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
711 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
712 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
713 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
714 // For use in libraries implementing .is()
715 // We use this for POS matching in `select`
716 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
717 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
720 rinputs = /^(?:input|select|textarea|button)$/i,
723 rnative = /^[^{]+\{\s*\[native \w/,
725 // Easily-parseable/retrievable ID or TAG or CLASS selectors
726 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
731 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
732 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
733 funescape = function( _, escaped, escapedWhitespace ) {
734 var high = "0x" + escaped - 0x10000;
735 // NaN means non-codepoint
737 // Workaround erroneous numeric interpretation of +"0x"
738 return high !== high || escapedWhitespace ?
742 String.fromCharCode( high + 0x10000 ) :
743 // Supplemental Plane codepoint (surrogate pair)
744 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
747 // Optimize for push.apply( _, NodeList )
750 (arr = slice.call( preferredDoc.childNodes )),
751 preferredDoc.childNodes
753 // Support: Android<4.0
754 // Detect silently failing push.apply
755 arr[ preferredDoc.childNodes.length ].nodeType;
757 push = { apply: arr.length ?
759 // Leverage slice if possible
760 function( target, els ) {
761 push_native.apply( target, slice.call(els) );
765 // Otherwise append directly
766 function( target, els ) {
767 var j = target.length,
769 // Can't trust NodeList.length
770 while ( (target[j++] = els[i++]) ) {}
771 target.length = j - 1;
776 function Sizzle( selector, context, results, seed ) {
777 var match, elem, m, nodeType,
779 i, groups, old, nid, newContext, newSelector;
781 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
782 setDocument( context );
785 context = context || document;
786 results = results || [];
788 if ( !selector || typeof selector !== "string" ) {
792 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
796 if ( documentIsHTML && !seed ) {
799 if ( (match = rquickExpr.exec( selector )) ) {
800 // Speed-up: Sizzle("#ID")
801 if ( (m = match[1]) ) {
802 if ( nodeType === 9 ) {
803 elem = context.getElementById( m );
804 // Check parentNode to catch when Blackberry 4.6 returns
805 // nodes that are no longer in the document (jQuery #6963)
806 if ( elem && elem.parentNode ) {
807 // Handle the case where IE, Opera, and Webkit return items
808 // by name instead of ID
809 if ( elem.id === m ) {
810 results.push( elem );
817 // Context is not a document
818 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
819 contains( context, elem ) && elem.id === m ) {
820 results.push( elem );
825 // Speed-up: Sizzle("TAG")
826 } else if ( match[2] ) {
827 push.apply( results, context.getElementsByTagName( selector ) );
830 // Speed-up: Sizzle(".CLASS")
831 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
832 push.apply( results, context.getElementsByClassName( m ) );
838 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
840 newContext = context;
841 newSelector = nodeType === 9 && selector;
843 // qSA works strangely on Element-rooted queries
844 // We can work around this by specifying an extra ID on the root
845 // and working up from there (Thanks to Andrew Dupont for the technique)
846 // IE 8 doesn't work on object elements
847 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
848 groups = tokenize( selector );
850 if ( (old = context.getAttribute("id")) ) {
851 nid = old.replace( rescape, "\\$&" );
853 context.setAttribute( "id", nid );
855 nid = "[id='" + nid + "'] ";
859 groups[i] = nid + toSelector( groups[i] );
861 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
862 newSelector = groups.join(",");
868 newContext.querySelectorAll( newSelector )
874 context.removeAttribute("id");
882 return select( selector.replace( rtrim, "$1" ), context, results, seed );
886 * Create key-value caches of limited size
887 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
888 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
889 * deleting the oldest entry
891 function createCache() {
894 function cache( key, value ) {
895 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
896 if ( keys.push( key + " " ) > Expr.cacheLength ) {
897 // Only keep the most recent entries
898 delete cache[ keys.shift() ];
900 return (cache[ key + " " ] = value);
906 * Mark a function for special use by Sizzle
907 * @param {Function} fn The function to mark
909 function markFunction( fn ) {
910 fn[ expando ] = true;
915 * Support testing using an element
916 * @param {Function} fn Passed the created div and expects a boolean result
918 function assert( fn ) {
919 var div = document.createElement("div");
926 // Remove from its parent by default
927 if ( div.parentNode ) {
928 div.parentNode.removeChild( div );
930 // release memory in IE
936 * Adds the same handler for all of the specified attrs
937 * @param {String} attrs Pipe-separated list of attributes
938 * @param {Function} handler The method that will be applied
940 function addHandle( attrs, handler ) {
941 var arr = attrs.split("|"),
945 Expr.attrHandle[ arr[i] ] = handler;
950 * Checks document order of two siblings
953 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
955 function siblingCheck( a, b ) {
957 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
958 ( ~b.sourceIndex || MAX_NEGATIVE ) -
959 ( ~a.sourceIndex || MAX_NEGATIVE );
961 // Use IE sourceIndex if available on both nodes
966 // Check if b follows a
968 while ( (cur = cur.nextSibling) ) {
979 * Returns a function to use in pseudos for input types
980 * @param {String} type
982 function createInputPseudo( type ) {
983 return function( elem ) {
984 var name = elem.nodeName.toLowerCase();
985 return name === "input" && elem.type === type;
990 * Returns a function to use in pseudos for buttons
991 * @param {String} type
993 function createButtonPseudo( type ) {
994 return function( elem ) {
995 var name = elem.nodeName.toLowerCase();
996 return (name === "input" || name === "button") && elem.type === type;
1001 * Returns a function to use in pseudos for positionals
1002 * @param {Function} fn
1004 function createPositionalPseudo( fn ) {
1005 return markFunction(function( argument ) {
1006 argument = +argument;
1007 return markFunction(function( seed, matches ) {
1009 matchIndexes = fn( [], seed.length, argument ),
1010 i = matchIndexes.length;
1012 // Match elements found at the specified indexes
1014 if ( seed[ (j = matchIndexes[i]) ] ) {
1015 seed[j] = !(matches[j] = seed[j]);
1023 * Checks a node for validity as a Sizzle context
1024 * @param {Element|Object=} context
1025 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1027 function testContext( context ) {
1028 return context && typeof context.getElementsByTagName !== strundefined && context;
1031 // Expose support vars for convenience
1032 support = Sizzle.support = {};
1036 * @param {Element|Object} elem An element or a document
1037 * @returns {Boolean} True iff elem is a non-HTML XML node
1039 isXML = Sizzle.isXML = function( elem ) {
1040 // documentElement is verified for cases where it doesn't yet exist
1041 // (such as loading iframes in IE - #4833)
1042 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1043 return documentElement ? documentElement.nodeName !== "HTML" : false;
1047 * Sets document-related variables once based on the current document
1048 * @param {Element|Object} [doc] An element or document object to use to set the document
1049 * @returns {Object} Returns the current document
1051 setDocument = Sizzle.setDocument = function( node ) {
1053 doc = node ? node.ownerDocument || node : preferredDoc,
1054 parent = doc.defaultView;
1056 // If no document and documentElement is available, return
1057 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1063 docElem = doc.documentElement;
1066 documentIsHTML = !isXML( doc );
1069 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1070 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1071 // IE6-8 do not support the defaultView property so parent will be undefined
1072 if ( parent && parent !== parent.top ) {
1073 // IE11 does not have attachEvent, so all must suffer
1074 if ( parent.addEventListener ) {
1075 parent.addEventListener( "unload", function() {
1078 } else if ( parent.attachEvent ) {
1079 parent.attachEvent( "onunload", function() {
1086 ---------------------------------------------------------------------- */
1089 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1090 support.attributes = assert(function( div ) {
1091 div.className = "i";
1092 return !div.getAttribute("className");
1096 ---------------------------------------------------------------------- */
1098 // Check if getElementsByTagName("*") returns only elements
1099 support.getElementsByTagName = assert(function( div ) {
1100 div.appendChild( doc.createComment("") );
1101 return !div.getElementsByTagName("*").length;
1104 // Check if getElementsByClassName can be trusted
1105 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
1106 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1108 // Support: Safari<4
1109 // Catch class over-caching
1110 div.firstChild.className = "i";
1111 // Support: Opera<10
1112 // Catch gEBCN failure to find non-leading classes
1113 return div.getElementsByClassName("i").length === 2;
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 !== strundefined && 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 !== strundefined && elem.getAttributeNode("id");
1150 return node && node.value === attrId;
1156 Expr.find["TAG"] = support.getElementsByTagName ?
1157 function( tag, context ) {
1158 if ( typeof context.getElementsByTagName !== strundefined ) {
1159 return context.getElementsByTagName( tag );
1162 function( tag, context ) {
1166 results = context.getElementsByTagName( tag );
1168 // Filter out possible comments
1169 if ( tag === "*" ) {
1170 while ( (elem = results[i++]) ) {
1171 if ( elem.nodeType === 1 ) {
1182 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1183 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1184 return context.getElementsByClassName( className );
1188 /* QSA/matchesSelector
1189 ---------------------------------------------------------------------- */
1191 // QSA and matchesSelector support
1193 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1196 // qSa(:focus) reports false when true (Chrome 21)
1197 // We allow this because of a bug in IE8/9 that throws an error
1198 // whenever `document.activeElement` is accessed on an iframe
1199 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1200 // See http://bugs.jquery.com/ticket/13378
1203 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1205 // Regex strategy adopted from Diego Perini
1206 assert(function( div ) {
1207 // Select is set to empty string on purpose
1208 // This is to test IE's treatment of not explicitly
1209 // setting a boolean content attribute,
1210 // since its presence should be enough
1211 // http://bugs.jquery.com/ticket/12359
1212 div.innerHTML = "<select t=''><option selected=''></option></select>";
1214 // Support: IE8, Opera 10-12
1215 // Nothing should be selected when empty strings follow ^= or $= or *=
1216 if ( div.querySelectorAll("[t^='']").length ) {
1217 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1221 // Boolean attributes and "value" are not treated correctly
1222 if ( !div.querySelectorAll("[selected]").length ) {
1223 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1226 // Webkit/Opera - :checked should return selected option elements
1227 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1228 // IE8 throws error here and will not see later tests
1229 if ( !div.querySelectorAll(":checked").length ) {
1230 rbuggyQSA.push(":checked");
1234 assert(function( div ) {
1235 // Support: Windows 8 Native Apps
1236 // The type and name attributes are restricted during .innerHTML assignment
1237 var input = doc.createElement("input");
1238 input.setAttribute( "type", "hidden" );
1239 div.appendChild( input ).setAttribute( "name", "D" );
1242 // Enforce case-sensitivity of name attribute
1243 if ( div.querySelectorAll("[name=d]").length ) {
1244 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1247 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1248 // IE8 throws error here and will not see later tests
1249 if ( !div.querySelectorAll(":enabled").length ) {
1250 rbuggyQSA.push( ":enabled", ":disabled" );
1253 // Opera 10-11 does not throw on post-comma invalid pseudos
1254 div.querySelectorAll("*,:x");
1255 rbuggyQSA.push(",.*:");
1259 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
1260 docElem.mozMatchesSelector ||
1261 docElem.oMatchesSelector ||
1262 docElem.msMatchesSelector) )) ) {
1264 assert(function( div ) {
1265 // Check to see if it's possible to do matchesSelector
1266 // on a disconnected node (IE 9)
1267 support.disconnectedMatch = matches.call( div, "div" );
1269 // This should fail with an exception
1270 // Gecko does not error, returns false instead
1271 matches.call( div, "[s!='']:x" );
1272 rbuggyMatches.push( "!=", pseudos );
1276 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1277 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1280 ---------------------------------------------------------------------- */
1281 hasCompare = rnative.test( docElem.compareDocumentPosition );
1283 // Element contains another
1284 // Purposefully does not implement inclusive descendent
1285 // As in, an element does not contain itself
1286 contains = hasCompare || rnative.test( docElem.contains ) ?
1288 var adown = a.nodeType === 9 ? a.documentElement : a,
1289 bup = b && b.parentNode;
1290 return a === bup || !!( bup && bup.nodeType === 1 && (
1292 adown.contains( bup ) :
1293 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1298 while ( (b = b.parentNode) ) {
1308 ---------------------------------------------------------------------- */
1310 // Document order sorting
1311 sortOrder = hasCompare ?
1314 // Flag for duplicate removal
1316 hasDuplicate = true;
1320 // Sort on method existence if only one input has compareDocumentPosition
1321 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1326 // Calculate position if both inputs belong to the same document
1327 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1328 a.compareDocumentPosition( b ) :
1330 // Otherwise we know they are disconnected
1333 // Disconnected nodes
1335 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1337 // Choose the first element that is related to our preferred document
1338 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1341 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1345 // Maintain original order
1347 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1351 return compare & 4 ? -1 : 1;
1354 // Exit early if the nodes are identical
1356 hasDuplicate = true;
1367 // Parentless nodes are either documents or disconnected
1368 if ( !aup || !bup ) {
1369 return a === doc ? -1 :
1374 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1377 // If the nodes are siblings, we can do a quick check
1378 } else if ( aup === bup ) {
1379 return siblingCheck( a, b );
1382 // Otherwise we need full lists of their ancestors for comparison
1384 while ( (cur = cur.parentNode) ) {
1388 while ( (cur = cur.parentNode) ) {
1392 // Walk down the tree looking for a discrepancy
1393 while ( ap[i] === bp[i] ) {
1398 // Do a sibling check if the nodes have a common ancestor
1399 siblingCheck( ap[i], bp[i] ) :
1401 // Otherwise nodes in our document sort first
1402 ap[i] === preferredDoc ? -1 :
1403 bp[i] === preferredDoc ? 1 :
1410 Sizzle.matches = function( expr, elements ) {
1411 return Sizzle( expr, null, null, elements );
1414 Sizzle.matchesSelector = function( elem, expr ) {
1415 // Set document vars if needed
1416 if ( ( elem.ownerDocument || elem ) !== document ) {
1417 setDocument( elem );
1420 // Make sure that attribute selectors are quoted
1421 expr = expr.replace( rattributeQuotes, "='$1']" );
1423 if ( support.matchesSelector && documentIsHTML &&
1424 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1425 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1428 var ret = matches.call( elem, expr );
1430 // IE 9's matchesSelector returns false on disconnected nodes
1431 if ( ret || support.disconnectedMatch ||
1432 // As well, disconnected nodes are said to be in a document
1434 elem.document && elem.document.nodeType !== 11 ) {
1440 return Sizzle( expr, document, null, [elem] ).length > 0;
1443 Sizzle.contains = function( context, elem ) {
1444 // Set document vars if needed
1445 if ( ( context.ownerDocument || context ) !== document ) {
1446 setDocument( context );
1448 return contains( context, elem );
1451 Sizzle.attr = function( elem, name ) {
1452 // Set document vars if needed
1453 if ( ( elem.ownerDocument || elem ) !== document ) {
1454 setDocument( elem );
1457 var fn = Expr.attrHandle[ name.toLowerCase() ],
1458 // Don't get fooled by Object.prototype properties (jQuery #13807)
1459 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1460 fn( elem, name, !documentIsHTML ) :
1463 return val !== undefined ?
1465 support.attributes || !documentIsHTML ?
1466 elem.getAttribute( name ) :
1467 (val = elem.getAttributeNode(name)) && val.specified ?
1472 Sizzle.error = function( msg ) {
1473 throw new Error( "Syntax error, unrecognized expression: " + msg );
1477 * Document sorting and removing duplicates
1478 * @param {ArrayLike} results
1480 Sizzle.uniqueSort = function( results ) {
1486 // Unless we *know* we can detect duplicates, assume their presence
1487 hasDuplicate = !support.detectDuplicates;
1488 sortInput = !support.sortStable && results.slice( 0 );
1489 results.sort( sortOrder );
1491 if ( hasDuplicate ) {
1492 while ( (elem = results[i++]) ) {
1493 if ( elem === results[ i ] ) {
1494 j = duplicates.push( i );
1498 results.splice( duplicates[ j ], 1 );
1502 // Clear input after sorting to release objects
1503 // See https://github.com/jquery/sizzle/pull/225
1510 * Utility function for retrieving the text value of an array of DOM nodes
1511 * @param {Array|Element} elem
1513 getText = Sizzle.getText = function( elem ) {
1517 nodeType = elem.nodeType;
1520 // If no nodeType, this is expected to be an array
1521 while ( (node = elem[i++]) ) {
1522 // Do not traverse comment nodes
1523 ret += getText( node );
1525 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1526 // Use textContent for elements
1527 // innerText usage removed for consistency of new lines (jQuery #11153)
1528 if ( typeof elem.textContent === "string" ) {
1529 return elem.textContent;
1531 // Traverse its children
1532 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1533 ret += getText( elem );
1536 } else if ( nodeType === 3 || nodeType === 4 ) {
1537 return elem.nodeValue;
1539 // Do not include comment or processing instruction nodes
1544 Expr = Sizzle.selectors = {
1546 // Can be adjusted by the user
1549 createPseudo: markFunction,
1558 ">": { dir: "parentNode", first: true },
1559 " ": { dir: "parentNode" },
1560 "+": { dir: "previousSibling", first: true },
1561 "~": { dir: "previousSibling" }
1565 "ATTR": function( match ) {
1566 match[1] = match[1].replace( runescape, funescape );
1568 // Move the given value to match[3] whether quoted or unquoted
1569 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
1571 if ( match[2] === "~=" ) {
1572 match[3] = " " + match[3] + " ";
1575 return match.slice( 0, 4 );
1578 "CHILD": function( match ) {
1579 /* matches from matchExpr["CHILD"]
1580 1 type (only|nth|...)
1581 2 what (child|of-type)
1582 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1583 4 xn-component of xn+y argument ([+-]?\d*n|)
1584 5 sign of xn-component
1586 7 sign of y-component
1589 match[1] = match[1].toLowerCase();
1591 if ( match[1].slice( 0, 3 ) === "nth" ) {
1592 // nth-* requires argument
1594 Sizzle.error( match[0] );
1597 // numeric x and y parameters for Expr.filter.CHILD
1598 // remember that false/true cast respectively to 0/1
1599 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1600 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1602 // other types prohibit arguments
1603 } else if ( match[3] ) {
1604 Sizzle.error( match[0] );
1610 "PSEUDO": function( match ) {
1612 unquoted = !match[5] && match[2];
1614 if ( matchExpr["CHILD"].test( match[0] ) ) {
1618 // Accept quoted arguments as-is
1619 if ( match[3] && match[4] !== undefined ) {
1620 match[2] = match[4];
1622 // Strip excess characters from unquoted arguments
1623 } else if ( unquoted && rpseudo.test( unquoted ) &&
1624 // Get excess from tokenize (recursively)
1625 (excess = tokenize( unquoted, true )) &&
1626 // advance to the next closing parenthesis
1627 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1629 // excess is a negative index
1630 match[0] = match[0].slice( 0, excess );
1631 match[2] = unquoted.slice( 0, excess );
1634 // Return only captures needed by the pseudo filter method (type and argument)
1635 return match.slice( 0, 3 );
1641 "TAG": function( nodeNameSelector ) {
1642 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1643 return nodeNameSelector === "*" ?
1644 function() { return true; } :
1646 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1650 "CLASS": function( className ) {
1651 var pattern = classCache[ className + " " ];
1654 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1655 classCache( className, function( elem ) {
1656 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1660 "ATTR": function( name, operator, check ) {
1661 return function( elem ) {
1662 var result = Sizzle.attr( elem, name );
1664 if ( result == null ) {
1665 return operator === "!=";
1673 return operator === "=" ? result === check :
1674 operator === "!=" ? result !== check :
1675 operator === "^=" ? check && result.indexOf( check ) === 0 :
1676 operator === "*=" ? check && result.indexOf( check ) > -1 :
1677 operator === "$=" ? check && result.slice( -check.length ) === check :
1678 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1679 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1684 "CHILD": function( type, what, argument, first, last ) {
1685 var simple = type.slice( 0, 3 ) !== "nth",
1686 forward = type.slice( -4 ) !== "last",
1687 ofType = what === "of-type";
1689 return first === 1 && last === 0 ?
1691 // Shortcut for :nth-*(n)
1693 return !!elem.parentNode;
1696 function( elem, context, xml ) {
1697 var cache, outerCache, node, diff, nodeIndex, start,
1698 dir = simple !== forward ? "nextSibling" : "previousSibling",
1699 parent = elem.parentNode,
1700 name = ofType && elem.nodeName.toLowerCase(),
1701 useCache = !xml && !ofType;
1705 // :(first|last|only)-(child|of-type)
1709 while ( (node = node[ dir ]) ) {
1710 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1714 // Reverse direction for :only-* (if we haven't yet done so)
1715 start = dir = type === "only" && !start && "nextSibling";
1720 start = [ forward ? parent.firstChild : parent.lastChild ];
1722 // non-xml :nth-child(...) stores cache data on `parent`
1723 if ( forward && useCache ) {
1724 // Seek `elem` from a previously-cached index
1725 outerCache = parent[ expando ] || (parent[ expando ] = {});
1726 cache = outerCache[ type ] || [];
1727 nodeIndex = cache[0] === dirruns && cache[1];
1728 diff = cache[0] === dirruns && cache[2];
1729 node = nodeIndex && parent.childNodes[ nodeIndex ];
1731 while ( (node = ++nodeIndex && node && node[ dir ] ||
1733 // Fallback to seeking `elem` from the start
1734 (diff = nodeIndex = 0) || start.pop()) ) {
1736 // When found, cache indexes on `parent` and break
1737 if ( node.nodeType === 1 && ++diff && node === elem ) {
1738 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1743 // Use previously-cached element index if available
1744 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1747 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1749 // Use the same loop as above to seek `elem` from the start
1750 while ( (node = ++nodeIndex && node && node[ dir ] ||
1751 (diff = nodeIndex = 0) || start.pop()) ) {
1753 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1754 // Cache the index of each encountered element
1756 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1759 if ( node === elem ) {
1766 // Incorporate the offset, then check against cycle size
1768 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1773 "PSEUDO": function( pseudo, argument ) {
1774 // pseudo-class names are case-insensitive
1775 // http://www.w3.org/TR/selectors/#pseudo-classes
1776 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1777 // Remember that setFilters inherits from pseudos
1779 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1780 Sizzle.error( "unsupported pseudo: " + pseudo );
1782 // The user may use createPseudo to indicate that
1783 // arguments are needed to create the filter function
1784 // just as Sizzle does
1785 if ( fn[ expando ] ) {
1786 return fn( argument );
1789 // But maintain support for old signatures
1790 if ( fn.length > 1 ) {
1791 args = [ pseudo, pseudo, "", argument ];
1792 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1793 markFunction(function( seed, matches ) {
1795 matched = fn( seed, argument ),
1798 idx = indexOf.call( seed, matched[i] );
1799 seed[ idx ] = !( matches[ idx ] = matched[i] );
1803 return fn( elem, 0, args );
1812 // Potentially complex pseudos
1813 "not": markFunction(function( selector ) {
1814 // Trim the selector passed to compile
1815 // to avoid treating leading and trailing
1816 // spaces as combinators
1819 matcher = compile( selector.replace( rtrim, "$1" ) );
1821 return matcher[ expando ] ?
1822 markFunction(function( seed, matches, context, xml ) {
1824 unmatched = matcher( seed, null, xml, [] ),
1827 // Match elements unmatched by `matcher`
1829 if ( (elem = unmatched[i]) ) {
1830 seed[i] = !(matches[i] = elem);
1834 function( elem, context, xml ) {
1836 matcher( input, null, xml, results );
1837 return !results.pop();
1841 "has": markFunction(function( selector ) {
1842 return function( elem ) {
1843 return Sizzle( selector, elem ).length > 0;
1847 "contains": markFunction(function( text ) {
1848 return function( elem ) {
1849 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1853 // "Whether an element is represented by a :lang() selector
1854 // is based solely on the element's language value
1855 // being equal to the identifier C,
1856 // or beginning with the identifier C immediately followed by "-".
1857 // The matching of C against the element's language value is performed case-insensitively.
1858 // The identifier C does not have to be a valid language name."
1859 // http://www.w3.org/TR/selectors/#lang-pseudo
1860 "lang": markFunction( function( lang ) {
1861 // lang value must be a valid identifier
1862 if ( !ridentifier.test(lang || "") ) {
1863 Sizzle.error( "unsupported lang: " + lang );
1865 lang = lang.replace( runescape, funescape ).toLowerCase();
1866 return function( elem ) {
1869 if ( (elemLang = documentIsHTML ?
1871 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1873 elemLang = elemLang.toLowerCase();
1874 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1876 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1882 "target": function( elem ) {
1883 var hash = window.location && window.location.hash;
1884 return hash && hash.slice( 1 ) === elem.id;
1887 "root": function( elem ) {
1888 return elem === docElem;
1891 "focus": function( elem ) {
1892 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1895 // Boolean properties
1896 "enabled": function( elem ) {
1897 return elem.disabled === false;
1900 "disabled": function( elem ) {
1901 return elem.disabled === true;
1904 "checked": function( elem ) {
1905 // In CSS3, :checked should return both checked and selected elements
1906 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1907 var nodeName = elem.nodeName.toLowerCase();
1908 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1911 "selected": function( elem ) {
1912 // Accessing this property makes selected-by-default
1913 // options in Safari work properly
1914 if ( elem.parentNode ) {
1915 elem.parentNode.selectedIndex;
1918 return elem.selected === true;
1922 "empty": function( elem ) {
1923 // http://www.w3.org/TR/selectors/#empty-pseudo
1924 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1925 // but not by others (comment: 8; processing instruction: 7; etc.)
1926 // nodeType < 6 works because attributes (2) do not appear as children
1927 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1928 if ( elem.nodeType < 6 ) {
1935 "parent": function( elem ) {
1936 return !Expr.pseudos["empty"]( elem );
1939 // Element/input types
1940 "header": function( elem ) {
1941 return rheader.test( elem.nodeName );
1944 "input": function( elem ) {
1945 return rinputs.test( elem.nodeName );
1948 "button": function( elem ) {
1949 var name = elem.nodeName.toLowerCase();
1950 return name === "input" && elem.type === "button" || name === "button";
1953 "text": function( elem ) {
1955 return elem.nodeName.toLowerCase() === "input" &&
1956 elem.type === "text" &&
1959 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1960 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1963 // Position-in-collection
1964 "first": createPositionalPseudo(function() {
1968 "last": createPositionalPseudo(function( matchIndexes, length ) {
1969 return [ length - 1 ];
1972 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1973 return [ argument < 0 ? argument + length : argument ];
1976 "even": createPositionalPseudo(function( matchIndexes, length ) {
1978 for ( ; i < length; i += 2 ) {
1979 matchIndexes.push( i );
1981 return matchIndexes;
1984 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1986 for ( ; i < length; i += 2 ) {
1987 matchIndexes.push( i );
1989 return matchIndexes;
1992 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1993 var i = argument < 0 ? argument + length : argument;
1994 for ( ; --i >= 0; ) {
1995 matchIndexes.push( i );
1997 return matchIndexes;
2000 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2001 var i = argument < 0 ? argument + length : argument;
2002 for ( ; ++i < length; ) {
2003 matchIndexes.push( i );
2005 return matchIndexes;
2010 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2012 // Add button/input type pseudos
2013 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2014 Expr.pseudos[ i ] = createInputPseudo( i );
2016 for ( i in { submit: true, reset: true } ) {
2017 Expr.pseudos[ i ] = createButtonPseudo( i );
2020 // Easy API for creating new setFilters
2021 function setFilters() {}
2022 setFilters.prototype = Expr.filters = Expr.pseudos;
2023 Expr.setFilters = new setFilters();
2025 function tokenize( selector, parseOnly ) {
2026 var matched, match, tokens, type,
2027 soFar, groups, preFilters,
2028 cached = tokenCache[ selector + " " ];
2031 return parseOnly ? 0 : cached.slice( 0 );
2036 preFilters = Expr.preFilter;
2040 // Comma and first run
2041 if ( !matched || (match = rcomma.exec( soFar )) ) {
2043 // Don't consume trailing commas as valid
2044 soFar = soFar.slice( match[0].length ) || soFar;
2046 groups.push( (tokens = []) );
2052 if ( (match = rcombinators.exec( soFar )) ) {
2053 matched = match.shift();
2056 // Cast descendant combinators to space
2057 type: match[0].replace( rtrim, " " )
2059 soFar = soFar.slice( matched.length );
2063 for ( type in Expr.filter ) {
2064 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2065 (match = preFilters[ type ]( match ))) ) {
2066 matched = match.shift();
2072 soFar = soFar.slice( matched.length );
2081 // Return the length of the invalid excess
2082 // if we're just parsing
2083 // Otherwise, throw an error or return tokens
2087 Sizzle.error( selector ) :
2089 tokenCache( selector, groups ).slice( 0 );
2092 function toSelector( tokens ) {
2094 len = tokens.length,
2096 for ( ; i < len; i++ ) {
2097 selector += tokens[i].value;
2102 function addCombinator( matcher, combinator, base ) {
2103 var dir = combinator.dir,
2104 checkNonElements = base && dir === "parentNode",
2107 return combinator.first ?
2108 // Check against closest ancestor/preceding element
2109 function( elem, context, xml ) {
2110 while ( (elem = elem[ dir ]) ) {
2111 if ( elem.nodeType === 1 || checkNonElements ) {
2112 return matcher( elem, context, xml );
2117 // Check against all ancestor/preceding elements
2118 function( elem, context, xml ) {
2119 var oldCache, outerCache,
2120 newCache = [ dirruns, doneName ];
2122 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2124 while ( (elem = elem[ dir ]) ) {
2125 if ( elem.nodeType === 1 || checkNonElements ) {
2126 if ( matcher( elem, context, xml ) ) {
2132 while ( (elem = elem[ dir ]) ) {
2133 if ( elem.nodeType === 1 || checkNonElements ) {
2134 outerCache = elem[ expando ] || (elem[ expando ] = {});
2135 if ( (oldCache = outerCache[ dir ]) &&
2136 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2138 // Assign to newCache so results back-propagate to previous elements
2139 return (newCache[ 2 ] = oldCache[ 2 ]);
2141 // Reuse newcache so results back-propagate to previous elements
2142 outerCache[ dir ] = newCache;
2144 // A match means we're done; a fail means we have to keep checking
2145 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2155 function elementMatcher( matchers ) {
2156 return matchers.length > 1 ?
2157 function( elem, context, xml ) {
2158 var i = matchers.length;
2160 if ( !matchers[i]( elem, context, xml ) ) {
2169 function condense( unmatched, map, filter, context, xml ) {
2173 len = unmatched.length,
2174 mapped = map != null;
2176 for ( ; i < len; i++ ) {
2177 if ( (elem = unmatched[i]) ) {
2178 if ( !filter || filter( elem, context, xml ) ) {
2179 newUnmatched.push( elem );
2187 return newUnmatched;
2190 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2191 if ( postFilter && !postFilter[ expando ] ) {
2192 postFilter = setMatcher( postFilter );
2194 if ( postFinder && !postFinder[ expando ] ) {
2195 postFinder = setMatcher( postFinder, postSelector );
2197 return markFunction(function( seed, results, context, xml ) {
2201 preexisting = results.length,
2203 // Get initial elements from seed or context
2204 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2206 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2207 matcherIn = preFilter && ( seed || !selector ) ?
2208 condense( elems, preMap, preFilter, context, xml ) :
2211 matcherOut = matcher ?
2212 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2213 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2215 // ...intermediate processing is necessary
2218 // ...otherwise use results directly
2222 // Find primary matches
2224 matcher( matcherIn, matcherOut, context, xml );
2229 temp = condense( matcherOut, postMap );
2230 postFilter( temp, [], context, xml );
2232 // Un-match failing elements by moving them back to matcherIn
2235 if ( (elem = temp[i]) ) {
2236 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2242 if ( postFinder || preFilter ) {
2244 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2246 i = matcherOut.length;
2248 if ( (elem = matcherOut[i]) ) {
2249 // Restore matcherIn since elem is not yet a final match
2250 temp.push( (matcherIn[i] = elem) );
2253 postFinder( null, (matcherOut = []), temp, xml );
2256 // Move matched elements from seed to results to keep them synchronized
2257 i = matcherOut.length;
2259 if ( (elem = matcherOut[i]) &&
2260 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2262 seed[temp] = !(results[temp] = elem);
2267 // Add elements to results, through postFinder if defined
2269 matcherOut = condense(
2270 matcherOut === results ?
2271 matcherOut.splice( preexisting, matcherOut.length ) :
2275 postFinder( null, results, matcherOut, xml );
2277 push.apply( results, matcherOut );
2283 function matcherFromTokens( tokens ) {
2284 var checkContext, matcher, j,
2285 len = tokens.length,
2286 leadingRelative = Expr.relative[ tokens[0].type ],
2287 implicitRelative = leadingRelative || Expr.relative[" "],
2288 i = leadingRelative ? 1 : 0,
2290 // The foundational matcher ensures that elements are reachable from top-level context(s)
2291 matchContext = addCombinator( function( elem ) {
2292 return elem === checkContext;
2293 }, implicitRelative, true ),
2294 matchAnyContext = addCombinator( function( elem ) {
2295 return indexOf.call( checkContext, elem ) > -1;
2296 }, implicitRelative, true ),
2297 matchers = [ function( elem, context, xml ) {
2298 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2299 (checkContext = context).nodeType ?
2300 matchContext( elem, context, xml ) :
2301 matchAnyContext( elem, context, xml ) );
2304 for ( ; i < len; i++ ) {
2305 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2306 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2308 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2310 // Return special upon seeing a positional matcher
2311 if ( matcher[ expando ] ) {
2312 // Find the next relative operator (if any) for proper handling
2314 for ( ; j < len; j++ ) {
2315 if ( Expr.relative[ tokens[j].type ] ) {
2320 i > 1 && elementMatcher( matchers ),
2321 i > 1 && toSelector(
2322 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2323 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2324 ).replace( rtrim, "$1" ),
2326 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2327 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2328 j < len && toSelector( tokens )
2331 matchers.push( matcher );
2335 return elementMatcher( matchers );
2338 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2339 var bySet = setMatchers.length > 0,
2340 byElement = elementMatchers.length > 0,
2341 superMatcher = function( seed, context, xml, results, outermost ) {
2342 var elem, j, matcher,
2345 unmatched = seed && [],
2347 contextBackup = outermostContext,
2348 // We must always have either seed elements or outermost context
2349 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2350 // Use integer dirruns iff this is the outermost matcher
2351 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2355 outermostContext = context !== document && context;
2358 // Add elements passing elementMatchers directly to results
2359 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2360 // Support: IE<9, Safari
2361 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2362 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2363 if ( byElement && elem ) {
2365 while ( (matcher = elementMatchers[j++]) ) {
2366 if ( matcher( elem, context, xml ) ) {
2367 results.push( elem );
2372 dirruns = dirrunsUnique;
2376 // Track unmatched elements for set filters
2378 // They will have gone through all possible matchers
2379 if ( (elem = !matcher && elem) ) {
2383 // Lengthen the array for every element, matched or not
2385 unmatched.push( elem );
2390 // Apply set filters to unmatched elements
2392 if ( bySet && i !== matchedCount ) {
2394 while ( (matcher = setMatchers[j++]) ) {
2395 matcher( unmatched, setMatched, context, xml );
2399 // Reintegrate element matches to eliminate the need for sorting
2400 if ( matchedCount > 0 ) {
2402 if ( !(unmatched[i] || setMatched[i]) ) {
2403 setMatched[i] = pop.call( results );
2408 // Discard index placeholder values to get only actual matches
2409 setMatched = condense( setMatched );
2412 // Add matches to results
2413 push.apply( results, setMatched );
2415 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2416 if ( outermost && !seed && setMatched.length > 0 &&
2417 ( matchedCount + setMatchers.length ) > 1 ) {
2419 Sizzle.uniqueSort( results );
2423 // Override manipulation of globals by nested matchers
2425 dirruns = dirrunsUnique;
2426 outermostContext = contextBackup;
2433 markFunction( superMatcher ) :
2437 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
2440 elementMatchers = [],
2441 cached = compilerCache[ selector + " " ];
2444 // Generate a function of recursive functions that can be used to check each element
2446 group = tokenize( selector );
2450 cached = matcherFromTokens( group[i] );
2451 if ( cached[ expando ] ) {
2452 setMatchers.push( cached );
2454 elementMatchers.push( cached );
2458 // Cache the compiled function
2459 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2464 function multipleContexts( selector, contexts, results ) {
2466 len = contexts.length;
2467 for ( ; i < len; i++ ) {
2468 Sizzle( selector, contexts[i], results );
2473 function select( selector, context, results, seed ) {
2474 var i, tokens, token, type, find,
2475 match = tokenize( selector );
2478 // Try to minimize operations if there is only one group
2479 if ( match.length === 1 ) {
2481 // Take a shortcut and set the context if the root selector is an ID
2482 tokens = match[0] = match[0].slice( 0 );
2483 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2484 support.getById && context.nodeType === 9 && documentIsHTML &&
2485 Expr.relative[ tokens[1].type ] ) {
2487 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2491 selector = selector.slice( tokens.shift().value.length );
2494 // Fetch a seed set for right-to-left matching
2495 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2499 // Abort if we hit a combinator
2500 if ( Expr.relative[ (type = token.type) ] ) {
2503 if ( (find = Expr.find[ type ]) ) {
2504 // Search, expanding context for leading sibling combinators
2506 token.matches[0].replace( runescape, funescape ),
2507 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2510 // If seed is empty or no tokens remain, we can return early
2511 tokens.splice( i, 1 );
2512 selector = seed.length && toSelector( tokens );
2514 push.apply( results, seed );
2525 // Compile and execute a filtering function
2526 // Provide `match` to avoid retokenization if we modified the selector above
2527 compile( selector, match )(
2532 rsibling.test( selector ) && testContext( context.parentNode ) || context
2537 // One-time assignments
2540 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2542 // Support: Chrome<14
2543 // Always assume duplicates if they aren't passed to the comparison function
2544 support.detectDuplicates = !!hasDuplicate;
2546 // Initialize against the default document
2549 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2550 // Detached nodes confoundingly follow *each other*
2551 support.sortDetached = assert(function( div1 ) {
2552 // Should return 1, but returns 4 (following)
2553 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2557 // Prevent attribute/property "interpolation"
2558 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2559 if ( !assert(function( div ) {
2560 div.innerHTML = "<a href='#'></a>";
2561 return div.firstChild.getAttribute("href") === "#" ;
2563 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2565 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2571 // Use defaultValue in place of getAttribute("value")
2572 if ( !support.attributes || !assert(function( div ) {
2573 div.innerHTML = "<input/>";
2574 div.firstChild.setAttribute( "value", "" );
2575 return div.firstChild.getAttribute( "value" ) === "";
2577 addHandle( "value", function( elem, name, isXML ) {
2578 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2579 return elem.defaultValue;
2585 // Use getAttributeNode to fetch booleans when getAttribute lies
2586 if ( !assert(function( div ) {
2587 return div.getAttribute("disabled") == null;
2589 addHandle( booleans, function( elem, name, isXML ) {
2592 return elem[ name ] === true ? name.toLowerCase() :
2593 (val = elem.getAttributeNode( name )) && val.specified ?
2606 jQuery.find = Sizzle;
2607 jQuery.expr = Sizzle.selectors;
2608 jQuery.expr[":"] = jQuery.expr.pseudos;
2609 jQuery.unique = Sizzle.uniqueSort;
2610 jQuery.text = Sizzle.getText;
2611 jQuery.isXMLDoc = Sizzle.isXML;
2612 jQuery.contains = Sizzle.contains;
2616 var rneedsContext = jQuery.expr.match.needsContext;
2618 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2622 var risSimple = /^.[^:#\[\.,]*$/;
2624 // Implement the identical functionality for filter and not
2625 function winnow( elements, qualifier, not ) {
2626 if ( jQuery.isFunction( qualifier ) ) {
2627 return jQuery.grep( elements, function( elem, i ) {
2629 return !!qualifier.call( elem, i, elem ) !== not;
2634 if ( qualifier.nodeType ) {
2635 return jQuery.grep( elements, function( elem ) {
2636 return ( elem === qualifier ) !== not;
2641 if ( typeof qualifier === "string" ) {
2642 if ( risSimple.test( qualifier ) ) {
2643 return jQuery.filter( qualifier, elements, not );
2646 qualifier = jQuery.filter( qualifier, elements );
2649 return jQuery.grep( elements, function( elem ) {
2650 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2654 jQuery.filter = function( expr, elems, not ) {
2655 var elem = elems[ 0 ];
2658 expr = ":not(" + expr + ")";
2661 return elems.length === 1 && elem.nodeType === 1 ?
2662 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2663 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2664 return elem.nodeType === 1;
2669 find: function( selector ) {
2675 if ( typeof selector !== "string" ) {
2676 return this.pushStack( jQuery( selector ).filter(function() {
2677 for ( i = 0; i < len; i++ ) {
2678 if ( jQuery.contains( self[ i ], this ) ) {
2685 for ( i = 0; i < len; i++ ) {
2686 jQuery.find( selector, self[ i ], ret );
2689 // Needed because $( selector, context ) becomes $( context ).find( selector )
2690 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2691 ret.selector = this.selector ? this.selector + " " + selector : selector;
2694 filter: function( selector ) {
2695 return this.pushStack( winnow(this, selector || [], false) );
2697 not: function( selector ) {
2698 return this.pushStack( winnow(this, selector || [], true) );
2700 is: function( selector ) {
2704 // If this is a positional/relative selector, check membership in the returned set
2705 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2706 typeof selector === "string" && rneedsContext.test( selector ) ?
2707 jQuery( selector ) :
2715 // Initialize a jQuery object
2718 // A central reference to the root jQuery(document)
2721 // Use the correct document accordingly with window argument (sandbox)
2722 document = window.document,
2724 // A simple way to check for HTML strings
2725 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2726 // Strict HTML recognition (#11290: must start with <)
2727 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2729 init = jQuery.fn.init = function( selector, context ) {
2732 // HANDLE: $(""), $(null), $(undefined), $(false)
2737 // Handle HTML strings
2738 if ( typeof selector === "string" ) {
2739 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2740 // Assume that strings that start and end with <> are HTML and skip the regex check
2741 match = [ null, selector, null ];
2744 match = rquickExpr.exec( selector );
2747 // Match html or make sure no context is specified for #id
2748 if ( match && (match[1] || !context) ) {
2750 // HANDLE: $(html) -> $(array)
2752 context = context instanceof jQuery ? context[0] : context;
2754 // scripts is true for back-compat
2755 // Intentionally let the error be thrown if parseHTML is not present
2756 jQuery.merge( this, jQuery.parseHTML(
2758 context && context.nodeType ? context.ownerDocument || context : document,
2762 // HANDLE: $(html, props)
2763 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2764 for ( match in context ) {
2765 // Properties of context are called as methods if possible
2766 if ( jQuery.isFunction( this[ match ] ) ) {
2767 this[ match ]( context[ match ] );
2769 // ...and otherwise set as attributes
2771 this.attr( match, context[ match ] );
2780 elem = document.getElementById( match[2] );
2782 // Check parentNode to catch when Blackberry 4.6 returns
2783 // nodes that are no longer in the document #6963
2784 if ( elem && elem.parentNode ) {
2785 // Handle the case where IE and Opera return items
2786 // by name instead of ID
2787 if ( elem.id !== match[2] ) {
2788 return rootjQuery.find( selector );
2791 // Otherwise, we inject the element directly into the jQuery object
2796 this.context = document;
2797 this.selector = selector;
2801 // HANDLE: $(expr, $(...))
2802 } else if ( !context || context.jquery ) {
2803 return ( context || rootjQuery ).find( selector );
2805 // HANDLE: $(expr, context)
2806 // (which is just equivalent to: $(context).find(expr)
2808 return this.constructor( context ).find( selector );
2811 // HANDLE: $(DOMElement)
2812 } else if ( selector.nodeType ) {
2813 this.context = this[0] = selector;
2817 // HANDLE: $(function)
2818 // Shortcut for document ready
2819 } else if ( jQuery.isFunction( selector ) ) {
2820 return typeof rootjQuery.ready !== "undefined" ?
2821 rootjQuery.ready( selector ) :
2822 // Execute immediately if ready is not present
2826 if ( selector.selector !== undefined ) {
2827 this.selector = selector.selector;
2828 this.context = selector.context;
2831 return jQuery.makeArray( selector, this );
2834 // Give the init function the jQuery prototype for later instantiation
2835 init.prototype = jQuery.fn;
2837 // Initialize central reference
2838 rootjQuery = jQuery( document );
2841 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2842 // methods guaranteed to produce a unique set when starting from a unique set
2843 guaranteedUnique = {
2851 dir: function( elem, dir, until ) {
2855 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2856 if ( cur.nodeType === 1 ) {
2857 matched.push( cur );
2864 sibling: function( n, elem ) {
2867 for ( ; n; n = n.nextSibling ) {
2868 if ( n.nodeType === 1 && n !== elem ) {
2878 has: function( target ) {
2880 targets = jQuery( target, this ),
2881 len = targets.length;
2883 return this.filter(function() {
2884 for ( i = 0; i < len; i++ ) {
2885 if ( jQuery.contains( this, targets[i] ) ) {
2892 closest: function( selectors, context ) {
2897 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
2898 jQuery( selectors, context || this.context ) :
2901 for ( ; i < l; i++ ) {
2902 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
2903 // Always skip document fragments
2904 if ( cur.nodeType < 11 && (pos ?
2905 pos.index(cur) > -1 :
2907 // Don't pass non-elements to Sizzle
2908 cur.nodeType === 1 &&
2909 jQuery.find.matchesSelector(cur, selectors)) ) {
2911 matched.push( cur );
2917 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
2920 // Determine the position of an element within
2921 // the matched set of elements
2922 index: function( elem ) {
2924 // No argument, return index in parent
2926 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
2929 // index in selector
2930 if ( typeof elem === "string" ) {
2931 return jQuery.inArray( this[0], jQuery( elem ) );
2934 // Locate the position of the desired element
2935 return jQuery.inArray(
2936 // If it receives a jQuery object, the first element is used
2937 elem.jquery ? elem[0] : elem, this );
2940 add: function( selector, context ) {
2941 return this.pushStack(
2943 jQuery.merge( this.get(), jQuery( selector, context ) )
2948 addBack: function( selector ) {
2949 return this.add( selector == null ?
2950 this.prevObject : this.prevObject.filter(selector)
2955 function sibling( cur, dir ) {
2958 } while ( cur && cur.nodeType !== 1 );
2964 parent: function( elem ) {
2965 var parent = elem.parentNode;
2966 return parent && parent.nodeType !== 11 ? parent : null;
2968 parents: function( elem ) {
2969 return jQuery.dir( elem, "parentNode" );
2971 parentsUntil: function( elem, i, until ) {
2972 return jQuery.dir( elem, "parentNode", until );
2974 next: function( elem ) {
2975 return sibling( elem, "nextSibling" );
2977 prev: function( elem ) {
2978 return sibling( elem, "previousSibling" );
2980 nextAll: function( elem ) {
2981 return jQuery.dir( elem, "nextSibling" );
2983 prevAll: function( elem ) {
2984 return jQuery.dir( elem, "previousSibling" );
2986 nextUntil: function( elem, i, until ) {
2987 return jQuery.dir( elem, "nextSibling", until );
2989 prevUntil: function( elem, i, until ) {
2990 return jQuery.dir( elem, "previousSibling", until );
2992 siblings: function( elem ) {
2993 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
2995 children: function( elem ) {
2996 return jQuery.sibling( elem.firstChild );
2998 contents: function( elem ) {
2999 return jQuery.nodeName( elem, "iframe" ) ?
3000 elem.contentDocument || elem.contentWindow.document :
3001 jQuery.merge( [], elem.childNodes );
3003 }, function( name, fn ) {
3004 jQuery.fn[ name ] = function( until, selector ) {
3005 var ret = jQuery.map( this, fn, until );
3007 if ( name.slice( -5 ) !== "Until" ) {
3011 if ( selector && typeof selector === "string" ) {
3012 ret = jQuery.filter( selector, ret );
3015 if ( this.length > 1 ) {
3016 // Remove duplicates
3017 if ( !guaranteedUnique[ name ] ) {
3018 ret = jQuery.unique( ret );
3021 // Reverse order for parents* and prev-derivatives
3022 if ( rparentsprev.test( name ) ) {
3023 ret = ret.reverse();
3027 return this.pushStack( ret );
3030 var rnotwhite = (/\S+/g);
3034 // String to Object options format cache
3035 var optionsCache = {};
3037 // Convert String-formatted options into Object-formatted ones and store in cache
3038 function createOptions( options ) {
3039 var object = optionsCache[ options ] = {};
3040 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3041 object[ flag ] = true;
3047 * Create a callback list using the following parameters:
3049 * options: an optional list of space-separated options that will change how
3050 * the callback list behaves or a more traditional option object
3052 * By default a callback list will act like an event callback list and can be
3053 * "fired" multiple times.
3057 * once: will ensure the callback list can only be fired once (like a Deferred)
3059 * memory: will keep track of previous values and will call any callback added
3060 * after the list has been fired right away with the latest "memorized"
3061 * values (like a Deferred)
3063 * unique: will ensure a callback can only be added once (no duplicate in the list)
3065 * stopOnFalse: interrupt callings when a callback returns false
3068 jQuery.Callbacks = function( options ) {
3070 // Convert options from String-formatted to Object-formatted if needed
3071 // (we check in cache first)
3072 options = typeof options === "string" ?
3073 ( optionsCache[ options ] || createOptions( options ) ) :
3074 jQuery.extend( {}, options );
3076 var // Flag to know if list is currently firing
3078 // Last fire value (for non-forgettable lists)
3080 // Flag to know if list was already fired
3082 // End of the loop when firing
3084 // Index of currently firing callback (modified by remove if needed)
3086 // First callback to fire (used internally by add and fireWith)
3088 // Actual callback list
3090 // Stack of fire calls for repeatable lists
3091 stack = !options.once && [],
3093 fire = function( data ) {
3094 memory = options.memory && data;
3096 firingIndex = firingStart || 0;
3098 firingLength = list.length;
3100 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3101 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
3102 memory = false; // To prevent further calls using add
3109 if ( stack.length ) {
3110 fire( stack.shift() );
3112 } else if ( memory ) {
3119 // Actual Callbacks object
3121 // Add a callback or a collection of callbacks to the list
3124 // First, we save the current length
3125 var start = list.length;
3126 (function add( args ) {
3127 jQuery.each( args, function( _, arg ) {
3128 var type = jQuery.type( arg );
3129 if ( type === "function" ) {
3130 if ( !options.unique || !self.has( arg ) ) {
3133 } else if ( arg && arg.length && type !== "string" ) {
3134 // Inspect recursively
3139 // Do we need to add the callbacks to the
3140 // current firing batch?
3142 firingLength = list.length;
3143 // With memory, if we're not firing then
3144 // we should call right away
3145 } else if ( memory ) {
3146 firingStart = start;
3152 // Remove a callback from the list
3153 remove: function() {
3155 jQuery.each( arguments, function( _, arg ) {
3157 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3158 list.splice( index, 1 );
3159 // Handle firing indexes
3161 if ( index <= firingLength ) {
3164 if ( index <= firingIndex ) {
3173 // Check if a given callback is in the list.
3174 // If no argument is given, return whether or not list has callbacks attached.
3175 has: function( fn ) {
3176 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
3178 // Remove all callbacks from the list
3184 // Have the list do nothing anymore
3185 disable: function() {
3186 list = stack = memory = undefined;
3190 disabled: function() {
3193 // Lock the list in its current state
3202 locked: function() {
3205 // Call all callbacks with the given context and arguments
3206 fireWith: function( context, args ) {
3207 if ( list && ( !fired || stack ) ) {
3209 args = [ context, args.slice ? args.slice() : args ];
3218 // Call all the callbacks with the given arguments
3220 self.fireWith( this, arguments );
3223 // To know if the callbacks have already been called at least once
3235 Deferred: function( func ) {
3237 // action, add listener, listener list, final state
3238 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
3239 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
3240 [ "notify", "progress", jQuery.Callbacks("memory") ]
3247 always: function() {
3248 deferred.done( arguments ).fail( arguments );
3251 then: function( /* fnDone, fnFail, fnProgress */ ) {
3252 var fns = arguments;
3253 return jQuery.Deferred(function( newDefer ) {
3254 jQuery.each( tuples, function( i, tuple ) {
3255 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3256 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3257 deferred[ tuple[1] ](function() {
3258 var returned = fn && fn.apply( this, arguments );
3259 if ( returned && jQuery.isFunction( returned.promise ) ) {
3261 .done( newDefer.resolve )
3262 .fail( newDefer.reject )
3263 .progress( newDefer.notify );
3265 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
3272 // Get a promise for this deferred
3273 // If obj is provided, the promise aspect is added to the object
3274 promise: function( obj ) {
3275 return obj != null ? jQuery.extend( obj, promise ) : promise;
3280 // Keep pipe for back-compat
3281 promise.pipe = promise.then;
3283 // Add list-specific methods
3284 jQuery.each( tuples, function( i, tuple ) {
3285 var list = tuple[ 2 ],
3286 stateString = tuple[ 3 ];
3288 // promise[ done | fail | progress ] = list.add
3289 promise[ tuple[1] ] = list.add;
3292 if ( stateString ) {
3293 list.add(function() {
3294 // state = [ resolved | rejected ]
3295 state = stateString;
3297 // [ reject_list | resolve_list ].disable; progress_list.lock
3298 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3301 // deferred[ resolve | reject | notify ]
3302 deferred[ tuple[0] ] = function() {
3303 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
3306 deferred[ tuple[0] + "With" ] = list.fireWith;
3309 // Make the deferred a promise
3310 promise.promise( deferred );
3312 // Call given func if any
3314 func.call( deferred, deferred );
3322 when: function( subordinate /* , ..., subordinateN */ ) {
3324 resolveValues = slice.call( arguments ),
3325 length = resolveValues.length,
3327 // the count of uncompleted subordinates
3328 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3330 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3331 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3333 // Update function for both resolve and progress values
3334 updateFunc = function( i, contexts, values ) {
3335 return function( value ) {
3336 contexts[ i ] = this;
3337 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3338 if ( values === progressValues ) {
3339 deferred.notifyWith( contexts, values );
3341 } else if ( !(--remaining) ) {
3342 deferred.resolveWith( contexts, values );
3347 progressValues, progressContexts, resolveContexts;
3349 // add listeners to Deferred subordinates; treat others as resolved
3351 progressValues = new Array( length );
3352 progressContexts = new Array( length );
3353 resolveContexts = new Array( length );
3354 for ( ; i < length; i++ ) {
3355 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3356 resolveValues[ i ].promise()
3357 .done( updateFunc( i, resolveContexts, resolveValues ) )
3358 .fail( deferred.reject )
3359 .progress( updateFunc( i, progressContexts, progressValues ) );
3366 // if we're not waiting on anything, resolve the master
3368 deferred.resolveWith( resolveContexts, resolveValues );
3371 return deferred.promise();
3376 // The deferred used on DOM ready
3379 jQuery.fn.ready = function( fn ) {
3381 jQuery.ready.promise().done( fn );
3387 // Is the DOM ready to be used? Set to true once it occurs.
3390 // A counter to track how many items to wait for before
3391 // the ready event fires. See #6781
3394 // Hold (or release) the ready event
3395 holdReady: function( hold ) {
3399 jQuery.ready( true );
3403 // Handle when the DOM is ready
3404 ready: function( wait ) {
3406 // Abort if there are pending holds or we're already ready
3407 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3411 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
3412 if ( !document.body ) {
3413 return setTimeout( jQuery.ready );
3416 // Remember that the DOM is ready
3417 jQuery.isReady = true;
3419 // If a normal DOM Ready event fired, decrement, and wait if need be
3420 if ( wait !== true && --jQuery.readyWait > 0 ) {
3424 // If there are functions bound, to execute
3425 readyList.resolveWith( document, [ jQuery ] );
3427 // Trigger any bound ready events
3428 if ( jQuery.fn.trigger ) {
3429 jQuery( document ).trigger("ready").off("ready");
3435 * Clean-up method for dom ready events
3438 if ( document.addEventListener ) {
3439 document.removeEventListener( "DOMContentLoaded", completed, false );
3440 window.removeEventListener( "load", completed, false );
3443 document.detachEvent( "onreadystatechange", completed );
3444 window.detachEvent( "onload", completed );
3449 * The ready event handler and self cleanup method
3451 function completed() {
3452 // readyState === "complete" is good enough for us to call the dom ready in oldIE
3453 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
3459 jQuery.ready.promise = function( obj ) {
3462 readyList = jQuery.Deferred();
3464 // Catch cases where $(document).ready() is called after the browser event has already occurred.
3465 // we once tried to use readyState "interactive" here, but it caused issues like the one
3466 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
3467 if ( document.readyState === "complete" ) {
3468 // Handle it asynchronously to allow scripts the opportunity to delay ready
3469 setTimeout( jQuery.ready );
3471 // Standards-based browsers support DOMContentLoaded
3472 } else if ( document.addEventListener ) {
3473 // Use the handy event callback
3474 document.addEventListener( "DOMContentLoaded", completed, false );
3476 // A fallback to window.onload, that will always work
3477 window.addEventListener( "load", completed, false );
3479 // If IE event model is used
3481 // Ensure firing before onload, maybe late but safe also for iframes
3482 document.attachEvent( "onreadystatechange", completed );
3484 // A fallback to window.onload, that will always work
3485 window.attachEvent( "onload", completed );
3487 // If IE and not a frame
3488 // continually check to see if the document is ready
3492 top = window.frameElement == null && document.documentElement;
3495 if ( top && top.doScroll ) {
3496 (function doScrollCheck() {
3497 if ( !jQuery.isReady ) {
3500 // Use the trick by Diego Perini
3501 // http://javascript.nwbox.com/IEContentLoaded/
3502 top.doScroll("left");
3504 return setTimeout( doScrollCheck, 50 );
3507 // detach all dom ready events
3510 // and execute any waiting functions
3517 return readyList.promise( obj );
3521 var strundefined = typeof undefined;
3526 // Iteration over object's inherited properties before its own
3528 for ( i in jQuery( support ) ) {
3531 support.ownLast = i !== "0";
3533 // Note: most support tests are defined in their respective modules.
3534 // false until the test is run
3535 support.inlineBlockNeedsLayout = false;
3538 // We need to execute this one support test ASAP because we need to know
3539 // if body.style.zoom needs to be set.
3542 body = document.getElementsByTagName("body")[0];
3545 // Return for frameset docs that don't have a body
3550 container = document.createElement( "div" );
3551 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
3553 div = document.createElement( "div" );
3554 body.appendChild( container ).appendChild( div );
3556 if ( typeof div.style.zoom !== strundefined ) {
3558 // Check if natively block-level elements act like inline-block
3559 // elements when setting their display to 'inline' and giving
3561 div.style.cssText = "border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1";
3563 if ( (support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 )) ) {
3564 // Prevent IE 6 from affecting layout for positioned elements #11048
3565 // Prevent IE from shrinking the body in IE 7 mode #12869
3567 body.style.zoom = 1;
3571 body.removeChild( container );
3573 // Null elements to avoid leaks in IE
3574 container = div = null;
3581 var div = document.createElement( "div" );
3583 // Execute the test only if not already executed in another module.
3584 if (support.deleteExpando == null) {
3586 support.deleteExpando = true;
3590 support.deleteExpando = false;
3594 // Null elements to avoid leaks in IE.
3600 * Determines whether an object can have data
3602 jQuery.acceptData = function( elem ) {
3603 var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
3604 nodeType = +elem.nodeType || 1;
3606 // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
3607 return nodeType !== 1 && nodeType !== 9 ?
3610 // Nodes accept data unless otherwise specified; rejection can be conditional
3611 !noData || noData !== true && elem.getAttribute("classid") === noData;
3615 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3616 rmultiDash = /([A-Z])/g;
3618 function dataAttr( elem, key, data ) {
3619 // If nothing was found internally, try to fetch any
3620 // data from the HTML5 data-* attribute
3621 if ( data === undefined && elem.nodeType === 1 ) {
3623 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3625 data = elem.getAttribute( name );
3627 if ( typeof data === "string" ) {
3629 data = data === "true" ? true :
3630 data === "false" ? false :
3631 data === "null" ? null :
3632 // Only convert to a number if it doesn't change the string
3633 +data + "" === data ? +data :
3634 rbrace.test( data ) ? jQuery.parseJSON( data ) :
3638 // Make sure we set the data so it isn't changed later
3639 jQuery.data( elem, key, data );
3649 // checks a cache object for emptiness
3650 function isEmptyDataObject( obj ) {
3652 for ( name in obj ) {
3654 // if the public data object is empty, the private is still empty
3655 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
3658 if ( name !== "toJSON" ) {
3666 function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
3667 if ( !jQuery.acceptData( elem ) ) {
3672 internalKey = jQuery.expando,
3674 // We have to handle DOM nodes and JS objects differently because IE6-7
3675 // can't GC object references properly across the DOM-JS boundary
3676 isNode = elem.nodeType,
3678 // Only DOM nodes need the global jQuery cache; JS object data is
3679 // attached directly to the object so GC can occur automatically
3680 cache = isNode ? jQuery.cache : elem,
3682 // Only defining an ID for JS objects if its cache already exists allows
3683 // the code to shortcut on the same path as a DOM node with no cache
3684 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
3686 // Avoid doing any more work than we need to when trying to get data on an
3687 // object that has no data at all
3688 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
3693 // Only DOM nodes need a new unique ID for each element since their data
3694 // ends up in the global cache
3696 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
3702 if ( !cache[ id ] ) {
3703 // Avoid exposing jQuery metadata on plain JS objects when the object
3704 // is serialized using JSON.stringify
3705 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
3708 // An object can be passed to jQuery.data instead of a key/value pair; this gets
3709 // shallow copied over onto the existing cache
3710 if ( typeof name === "object" || typeof name === "function" ) {
3712 cache[ id ] = jQuery.extend( cache[ id ], name );
3714 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
3718 thisCache = cache[ id ];
3720 // jQuery data() is stored in a separate object inside the object's internal data
3721 // cache in order to avoid key collisions between internal data and user-defined
3724 if ( !thisCache.data ) {
3725 thisCache.data = {};
3728 thisCache = thisCache.data;
3731 if ( data !== undefined ) {
3732 thisCache[ jQuery.camelCase( name ) ] = data;
3735 // Check for both converted-to-camel and non-converted data property names
3736 // If a data property was specified
3737 if ( typeof name === "string" ) {
3739 // First Try to find as-is property data
3740 ret = thisCache[ name ];
3742 // Test for null|undefined property data
3743 if ( ret == null ) {
3745 // Try to find the camelCased property
3746 ret = thisCache[ jQuery.camelCase( name ) ];
3755 function internalRemoveData( elem, name, pvt ) {
3756 if ( !jQuery.acceptData( elem ) ) {
3761 isNode = elem.nodeType,
3763 // See jQuery.data for more information
3764 cache = isNode ? jQuery.cache : elem,
3765 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
3767 // If there is already no cache entry for this object, there is no
3768 // purpose in continuing
3769 if ( !cache[ id ] ) {
3775 thisCache = pvt ? cache[ id ] : cache[ id ].data;
3779 // Support array or space separated string names for data keys
3780 if ( !jQuery.isArray( name ) ) {
3782 // try the string as a key before any manipulation
3783 if ( name in thisCache ) {
3787 // split the camel cased version by spaces unless a key with the spaces exists
3788 name = jQuery.camelCase( name );
3789 if ( name in thisCache ) {
3792 name = name.split(" ");
3796 // If "name" is an array of keys...
3797 // When data is initially created, via ("key", "val") signature,
3798 // keys will be converted to camelCase.
3799 // Since there is no way to tell _how_ a key was added, remove
3800 // both plain key and camelCase key. #12786
3801 // This will only penalize the array argument path.
3802 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
3807 delete thisCache[ name[i] ];
3810 // If there is no data left in the cache, we want to continue
3811 // and let the cache object itself get destroyed
3812 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
3818 // See jQuery.data for more information
3820 delete cache[ id ].data;
3822 // Don't destroy the parent cache unless the internal data object
3823 // had been the only thing left in it
3824 if ( !isEmptyDataObject( cache[ id ] ) ) {
3829 // Destroy the cache
3831 jQuery.cleanData( [ elem ], true );
3833 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
3834 /* jshint eqeqeq: false */
3835 } else if ( support.deleteExpando || cache != cache.window ) {
3836 /* jshint eqeqeq: true */
3839 // When all else fails, null
3848 // The following elements (space-suffixed to avoid Object.prototype collisions)
3849 // throw uncatchable exceptions if you attempt to set expando properties
3853 // ...but Flash objects (which have this classid) *can* handle expandos
3854 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
3857 hasData: function( elem ) {
3858 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
3859 return !!elem && !isEmptyDataObject( elem );
3862 data: function( elem, name, data ) {
3863 return internalData( elem, name, data );
3866 removeData: function( elem, name ) {
3867 return internalRemoveData( elem, name );
3870 // For internal use only.
3871 _data: function( elem, name, data ) {
3872 return internalData( elem, name, data, true );
3875 _removeData: function( elem, name ) {
3876 return internalRemoveData( elem, name, true );
3881 data: function( key, value ) {
3884 attrs = elem && elem.attributes;
3886 // Special expections of .data basically thwart jQuery.access,
3887 // so implement the relevant behavior ourselves
3890 if ( key === undefined ) {
3891 if ( this.length ) {
3892 data = jQuery.data( elem );
3894 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
3897 name = attrs[i].name;
3899 if ( name.indexOf("data-") === 0 ) {
3900 name = jQuery.camelCase( name.slice(5) );
3902 dataAttr( elem, name, data[ name ] );
3905 jQuery._data( elem, "parsedAttrs", true );
3912 // Sets multiple values
3913 if ( typeof key === "object" ) {
3914 return this.each(function() {
3915 jQuery.data( this, key );
3919 return arguments.length > 1 ?
3922 this.each(function() {
3923 jQuery.data( this, key, value );
3927 // Try to fetch any internally stored data first
3928 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
3931 removeData: function( key ) {
3932 return this.each(function() {
3933 jQuery.removeData( this, key );
3940 queue: function( elem, type, data ) {
3944 type = ( type || "fx" ) + "queue";
3945 queue = jQuery._data( elem, type );
3947 // Speed up dequeue by getting out quickly if this is just a lookup
3949 if ( !queue || jQuery.isArray(data) ) {
3950 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
3959 dequeue: function( elem, type ) {
3960 type = type || "fx";
3962 var queue = jQuery.queue( elem, type ),
3963 startLength = queue.length,
3965 hooks = jQuery._queueHooks( elem, type ),
3967 jQuery.dequeue( elem, type );
3970 // If the fx queue is dequeued, always remove the progress sentinel
3971 if ( fn === "inprogress" ) {
3978 // Add a progress sentinel to prevent the fx queue from being
3979 // automatically dequeued
3980 if ( type === "fx" ) {
3981 queue.unshift( "inprogress" );
3984 // clear up the last queue stop function
3986 fn.call( elem, next, hooks );
3989 if ( !startLength && hooks ) {
3994 // not intended for public consumption - generates a queueHooks object, or returns the current one
3995 _queueHooks: function( elem, type ) {
3996 var key = type + "queueHooks";
3997 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
3998 empty: jQuery.Callbacks("once memory").add(function() {
3999 jQuery._removeData( elem, type + "queue" );
4000 jQuery._removeData( elem, key );
4007 queue: function( type, data ) {
4010 if ( typeof type !== "string" ) {
4016 if ( arguments.length < setter ) {
4017 return jQuery.queue( this[0], type );
4020 return data === undefined ?
4022 this.each(function() {
4023 var queue = jQuery.queue( this, type, data );
4025 // ensure a hooks for this queue
4026 jQuery._queueHooks( this, type );
4028 if ( type === "fx" && queue[0] !== "inprogress" ) {
4029 jQuery.dequeue( this, type );
4033 dequeue: function( type ) {
4034 return this.each(function() {
4035 jQuery.dequeue( this, type );
4038 clearQueue: function( type ) {
4039 return this.queue( type || "fx", [] );
4041 // Get a promise resolved when queues of a certain type
4042 // are emptied (fx is the type by default)
4043 promise: function( type, obj ) {
4046 defer = jQuery.Deferred(),
4049 resolve = function() {
4050 if ( !( --count ) ) {
4051 defer.resolveWith( elements, [ elements ] );
4055 if ( typeof type !== "string" ) {
4059 type = type || "fx";
4062 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
4063 if ( tmp && tmp.empty ) {
4065 tmp.empty.add( resolve );
4069 return defer.promise( obj );
4072 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
4074 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4076 var isHidden = function( elem, el ) {
4077 // isHidden might be called from jQuery#filter function;
4078 // in that case, element will be second argument
4080 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
4085 // Multifunctional method to get and set values of a collection
4086 // The value/s can optionally be executed if it's a function
4087 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4089 length = elems.length,
4093 if ( jQuery.type( key ) === "object" ) {
4096 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
4100 } else if ( value !== undefined ) {
4103 if ( !jQuery.isFunction( value ) ) {
4108 // Bulk operations run against the entire set
4110 fn.call( elems, value );
4113 // ...except when executing function values
4116 fn = function( elem, key, value ) {
4117 return bulk.call( jQuery( elem ), value );
4123 for ( ; i < length; i++ ) {
4124 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
4135 length ? fn( elems[0], key ) : emptyGet;
4137 var rcheckableType = (/^(?:checkbox|radio)$/i);
4142 var fragment = document.createDocumentFragment(),
4143 div = document.createElement("div"),
4144 input = document.createElement("input");
4147 div.setAttribute( "className", "t" );
4148 div.innerHTML = " <link/><table></table><a href='/a'>a</a>";
4150 // IE strips leading whitespace when .innerHTML is used
4151 support.leadingWhitespace = div.firstChild.nodeType === 3;
4153 // Make sure that tbody elements aren't automatically inserted
4154 // IE will insert them into empty tables
4155 support.tbody = !div.getElementsByTagName( "tbody" ).length;
4157 // Make sure that link elements get serialized correctly by innerHTML
4158 // This requires a wrapper element in IE
4159 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
4161 // Makes sure cloning an html5 element does not cause problems
4162 // Where outerHTML is undefined, this still works
4163 support.html5Clone =
4164 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
4166 // Check if a disconnected checkbox will retain its checked
4167 // value of true after appended to the DOM (IE6/7)
4168 input.type = "checkbox";
4169 input.checked = true;
4170 fragment.appendChild( input );
4171 support.appendChecked = input.checked;
4173 // Make sure textarea (and checkbox) defaultValue is properly cloned
4174 // Support: IE6-IE11+
4175 div.innerHTML = "<textarea>x</textarea>";
4176 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4178 // #11217 - WebKit loses check when the name is after the checked attribute
4179 fragment.appendChild( div );
4180 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
4182 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
4183 // old WebKit doesn't clone checked state correctly in fragments
4184 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4187 // Opera does not clone events (and typeof div.attachEvent === undefined).
4188 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
4189 support.noCloneEvent = true;
4190 if ( div.attachEvent ) {
4191 div.attachEvent( "onclick", function() {
4192 support.noCloneEvent = false;
4195 div.cloneNode( true ).click();
4198 // Execute the test only if not already executed in another module.
4199 if (support.deleteExpando == null) {
4201 support.deleteExpando = true;
4205 support.deleteExpando = false;
4209 // Null elements to avoid leaks in IE.
4210 fragment = div = input = null;
4216 div = document.createElement( "div" );
4218 // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
4219 for ( i in { submit: true, change: true, focusin: true }) {
4220 eventName = "on" + i;
4222 if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
4223 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
4224 div.setAttribute( eventName, "t" );
4225 support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
4229 // Null elements to avoid leaks in IE.
4234 var rformElems = /^(?:input|select|textarea)$/i,
4236 rmouseEvent = /^(?:mouse|contextmenu)|click/,
4237 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4238 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
4240 function returnTrue() {
4244 function returnFalse() {
4248 function safeActiveElement() {
4250 return document.activeElement;
4255 * Helper functions for managing events -- not part of the public interface.
4256 * Props to Dean Edwards' addEvent library for many of the ideas.
4262 add: function( elem, types, handler, data, selector ) {
4263 var tmp, events, t, handleObjIn,
4264 special, eventHandle, handleObj,
4265 handlers, type, namespaces, origType,
4266 elemData = jQuery._data( elem );
4268 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4273 // Caller can pass in an object of custom data in lieu of the handler
4274 if ( handler.handler ) {
4275 handleObjIn = handler;
4276 handler = handleObjIn.handler;
4277 selector = handleObjIn.selector;
4280 // Make sure that the handler has a unique ID, used to find/remove it later
4281 if ( !handler.guid ) {
4282 handler.guid = jQuery.guid++;
4285 // Init the element's event structure and main handler, if this is the first
4286 if ( !(events = elemData.events) ) {
4287 events = elemData.events = {};
4289 if ( !(eventHandle = elemData.handle) ) {
4290 eventHandle = elemData.handle = function( e ) {
4291 // Discard the second event of a jQuery.event.trigger() and
4292 // when an event is called after a page has unloaded
4293 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
4294 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
4297 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
4298 eventHandle.elem = elem;
4301 // Handle multiple events separated by a space
4302 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4305 tmp = rtypenamespace.exec( types[t] ) || [];
4306 type = origType = tmp[1];
4307 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4309 // There *must* be a type, no attaching namespace-only handlers
4314 // If event changes its type, use the special event handlers for the changed type
4315 special = jQuery.event.special[ type ] || {};
4317 // If selector defined, determine special event api type, otherwise given type
4318 type = ( selector ? special.delegateType : special.bindType ) || type;
4320 // Update special based on newly reset type
4321 special = jQuery.event.special[ type ] || {};
4323 // handleObj is passed to all event handlers
4324 handleObj = jQuery.extend({
4331 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4332 namespace: namespaces.join(".")
4335 // Init the event handler queue if we're the first
4336 if ( !(handlers = events[ type ]) ) {
4337 handlers = events[ type ] = [];
4338 handlers.delegateCount = 0;
4340 // Only use addEventListener/attachEvent if the special events handler returns false
4341 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4342 // Bind the global event handler to the element
4343 if ( elem.addEventListener ) {
4344 elem.addEventListener( type, eventHandle, false );
4346 } else if ( elem.attachEvent ) {
4347 elem.attachEvent( "on" + type, eventHandle );
4352 if ( special.add ) {
4353 special.add.call( elem, handleObj );
4355 if ( !handleObj.handler.guid ) {
4356 handleObj.handler.guid = handler.guid;
4360 // Add to the element's handler list, delegates in front
4362 handlers.splice( handlers.delegateCount++, 0, handleObj );
4364 handlers.push( handleObj );
4367 // Keep track of which events have ever been used, for event optimization
4368 jQuery.event.global[ type ] = true;
4371 // Nullify elem to prevent memory leaks in IE
4375 // Detach an event or set of events from an element
4376 remove: function( elem, types, handler, selector, mappedTypes ) {
4377 var j, handleObj, tmp,
4378 origCount, t, events,
4379 special, handlers, type,
4380 namespaces, origType,
4381 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
4383 if ( !elemData || !(events = elemData.events) ) {
4387 // Once for each type.namespace in types; type may be omitted
4388 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4391 tmp = rtypenamespace.exec( types[t] ) || [];
4392 type = origType = tmp[1];
4393 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4395 // Unbind all events (on this namespace, if provided) for the element
4397 for ( type in events ) {
4398 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4403 special = jQuery.event.special[ type ] || {};
4404 type = ( selector ? special.delegateType : special.bindType ) || type;
4405 handlers = events[ type ] || [];
4406 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4408 // Remove matching events
4409 origCount = j = handlers.length;
4411 handleObj = handlers[ j ];
4413 if ( ( mappedTypes || origType === handleObj.origType ) &&
4414 ( !handler || handler.guid === handleObj.guid ) &&
4415 ( !tmp || tmp.test( handleObj.namespace ) ) &&
4416 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
4417 handlers.splice( j, 1 );
4419 if ( handleObj.selector ) {
4420 handlers.delegateCount--;
4422 if ( special.remove ) {
4423 special.remove.call( elem, handleObj );
4428 // Remove generic event handler if we removed something and no more handlers exist
4429 // (avoids potential for endless recursion during removal of special event handlers)
4430 if ( origCount && !handlers.length ) {
4431 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
4432 jQuery.removeEvent( elem, type, elemData.handle );
4435 delete events[ type ];
4439 // Remove the expando if it's no longer used
4440 if ( jQuery.isEmptyObject( events ) ) {
4441 delete elemData.handle;
4443 // removeData also checks for emptiness and clears the expando if empty
4444 // so use it instead of delete
4445 jQuery._removeData( elem, "events" );
4449 trigger: function( event, data, elem, onlyHandlers ) {
4450 var handle, ontype, cur,
4451 bubbleType, special, tmp, i,
4452 eventPath = [ elem || document ],
4453 type = hasOwn.call( event, "type" ) ? event.type : event,
4454 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
4456 cur = tmp = elem = elem || document;
4458 // Don't do events on text and comment nodes
4459 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
4463 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4464 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
4468 if ( type.indexOf(".") >= 0 ) {
4469 // Namespaced trigger; create a regexp to match event type in handle()
4470 namespaces = type.split(".");
4471 type = namespaces.shift();
4474 ontype = type.indexOf(":") < 0 && "on" + type;
4476 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4477 event = event[ jQuery.expando ] ?
4479 new jQuery.Event( type, typeof event === "object" && event );
4481 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4482 event.isTrigger = onlyHandlers ? 2 : 3;
4483 event.namespace = namespaces.join(".");
4484 event.namespace_re = event.namespace ?
4485 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4488 // Clean up the event in case it is being reused
4489 event.result = undefined;
4490 if ( !event.target ) {
4491 event.target = elem;
4494 // Clone any incoming data and prepend the event, creating the handler arg list
4495 data = data == null ?
4497 jQuery.makeArray( data, [ event ] );
4499 // Allow special events to draw outside the lines
4500 special = jQuery.event.special[ type ] || {};
4501 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
4505 // Determine event propagation path in advance, per W3C events spec (#9951)
4506 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4507 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
4509 bubbleType = special.delegateType || type;
4510 if ( !rfocusMorph.test( bubbleType + type ) ) {
4511 cur = cur.parentNode;
4513 for ( ; cur; cur = cur.parentNode ) {
4514 eventPath.push( cur );
4518 // Only add window if we got to document (e.g., not plain obj or detached DOM)
4519 if ( tmp === (elem.ownerDocument || document) ) {
4520 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
4524 // Fire handlers on the event path
4526 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
4528 event.type = i > 1 ?
4530 special.bindType || type;
4533 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
4535 handle.apply( cur, data );
4539 handle = ontype && cur[ ontype ];
4540 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
4541 event.result = handle.apply( cur, data );
4542 if ( event.result === false ) {
4543 event.preventDefault();
4549 // If nobody prevented the default action, do it now
4550 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
4552 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
4553 jQuery.acceptData( elem ) ) {
4555 // Call a native DOM method on the target with the same name name as the event.
4556 // Can't use an .isFunction() check here because IE6/7 fails that test.
4557 // Don't do default actions on window, that's where global variables be (#6170)
4558 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
4560 // Don't re-trigger an onFOO event when we call its FOO() method
4561 tmp = elem[ ontype ];
4564 elem[ ontype ] = null;
4567 // Prevent re-triggering of the same event, since we already bubbled it above
4568 jQuery.event.triggered = type;
4572 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
4573 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
4575 jQuery.event.triggered = undefined;
4578 elem[ ontype ] = tmp;
4584 return event.result;
4587 dispatch: function( event ) {
4589 // Make a writable jQuery.Event from the native event object
4590 event = jQuery.event.fix( event );
4592 var i, ret, handleObj, matched, j,
4594 args = slice.call( arguments ),
4595 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
4596 special = jQuery.event.special[ event.type ] || {};
4598 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4600 event.delegateTarget = this;
4602 // Call the preDispatch hook for the mapped type, and let it bail if desired
4603 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
4607 // Determine handlers
4608 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
4610 // Run delegates first; they may want to stop propagation beneath us
4612 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
4613 event.currentTarget = matched.elem;
4616 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
4618 // Triggered event must either 1) have no namespace, or
4619 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
4620 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
4622 event.handleObj = handleObj;
4623 event.data = handleObj.data;
4625 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
4626 .apply( matched.elem, args );
4628 if ( ret !== undefined ) {
4629 if ( (event.result = ret) === false ) {
4630 event.preventDefault();
4631 event.stopPropagation();
4638 // Call the postDispatch hook for the mapped type
4639 if ( special.postDispatch ) {
4640 special.postDispatch.call( this, event );
4643 return event.result;
4646 handlers: function( event, handlers ) {
4647 var sel, handleObj, matches, i,
4649 delegateCount = handlers.delegateCount,
4652 // Find delegate handlers
4653 // Black-hole SVG <use> instance trees (#13180)
4654 // Avoid non-left-click bubbling in Firefox (#3861)
4655 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
4657 /* jshint eqeqeq: false */
4658 for ( ; cur != this; cur = cur.parentNode || this ) {
4659 /* jshint eqeqeq: true */
4661 // Don't check non-elements (#13208)
4662 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4663 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
4665 for ( i = 0; i < delegateCount; i++ ) {
4666 handleObj = handlers[ i ];
4668 // Don't conflict with Object.prototype properties (#13203)
4669 sel = handleObj.selector + " ";
4671 if ( matches[ sel ] === undefined ) {
4672 matches[ sel ] = handleObj.needsContext ?
4673 jQuery( sel, this ).index( cur ) >= 0 :
4674 jQuery.find( sel, this, null, [ cur ] ).length;
4676 if ( matches[ sel ] ) {
4677 matches.push( handleObj );
4680 if ( matches.length ) {
4681 handlerQueue.push({ elem: cur, handlers: matches });
4687 // Add the remaining (directly-bound) handlers
4688 if ( delegateCount < handlers.length ) {
4689 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
4692 return handlerQueue;
4695 fix: function( event ) {
4696 if ( event[ jQuery.expando ] ) {
4700 // Create a writable copy of the event object and normalize some properties
4703 originalEvent = event,
4704 fixHook = this.fixHooks[ type ];
4707 this.fixHooks[ type ] = fixHook =
4708 rmouseEvent.test( type ) ? this.mouseHooks :
4709 rkeyEvent.test( type ) ? this.keyHooks :
4712 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
4714 event = new jQuery.Event( originalEvent );
4719 event[ prop ] = originalEvent[ prop ];
4723 // Fix target property (#1925)
4724 if ( !event.target ) {
4725 event.target = originalEvent.srcElement || document;
4728 // Support: Chrome 23+, Safari?
4729 // Target should not be a text node (#504, #13143)
4730 if ( event.target.nodeType === 3 ) {
4731 event.target = event.target.parentNode;
4735 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
4736 event.metaKey = !!event.metaKey;
4738 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
4741 // Includes some event props shared by KeyEvent and MouseEvent
4742 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
4747 props: "char charCode key keyCode".split(" "),
4748 filter: function( event, original ) {
4750 // Add which for key events
4751 if ( event.which == null ) {
4752 event.which = original.charCode != null ? original.charCode : original.keyCode;
4760 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
4761 filter: function( event, original ) {
4762 var body, eventDoc, doc,
4763 button = original.button,
4764 fromElement = original.fromElement;
4766 // Calculate pageX/Y if missing and clientX/Y available
4767 if ( event.pageX == null && original.clientX != null ) {
4768 eventDoc = event.target.ownerDocument || document;
4769 doc = eventDoc.documentElement;
4770 body = eventDoc.body;
4772 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
4773 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
4776 // Add relatedTarget, if necessary
4777 if ( !event.relatedTarget && fromElement ) {
4778 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
4781 // Add which for click: 1 === left; 2 === middle; 3 === right
4782 // Note: button is not normalized, so don't use it
4783 if ( !event.which && button !== undefined ) {
4784 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
4793 // Prevent triggered image.load events from bubbling to window.load
4797 // Fire native event if possible so blur/focus sequence is correct
4798 trigger: function() {
4799 if ( this !== safeActiveElement() && this.focus ) {
4805 // If we error on focus to hidden element (#1486, #12518),
4806 // let .trigger() run the handlers
4810 delegateType: "focusin"
4813 trigger: function() {
4814 if ( this === safeActiveElement() && this.blur ) {
4819 delegateType: "focusout"
4822 // For checkbox, fire native event so checked state will be right
4823 trigger: function() {
4824 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
4830 // For cross-browser consistency, don't fire native .click() on links
4831 _default: function( event ) {
4832 return jQuery.nodeName( event.target, "a" );
4837 postDispatch: function( event ) {
4839 // Even when returnValue equals to undefined Firefox will still show alert
4840 if ( event.result !== undefined ) {
4841 event.originalEvent.returnValue = event.result;
4847 simulate: function( type, elem, event, bubble ) {
4848 // Piggyback on a donor event to simulate a different one.
4849 // Fake originalEvent to avoid donor's stopPropagation, but if the
4850 // simulated event prevents default then we do the same on the donor.
4851 var e = jQuery.extend(
4861 jQuery.event.trigger( e, null, elem );
4863 jQuery.event.dispatch.call( elem, e );
4865 if ( e.isDefaultPrevented() ) {
4866 event.preventDefault();
4871 jQuery.removeEvent = document.removeEventListener ?
4872 function( elem, type, handle ) {
4873 if ( elem.removeEventListener ) {
4874 elem.removeEventListener( type, handle, false );
4877 function( elem, type, handle ) {
4878 var name = "on" + type;
4880 if ( elem.detachEvent ) {
4882 // #8545, #7054, preventing memory leaks for custom events in IE6-8
4883 // detachEvent needed property on element, by name of that event, to properly expose it to GC
4884 if ( typeof elem[ name ] === strundefined ) {
4885 elem[ name ] = null;
4888 elem.detachEvent( name, handle );
4892 jQuery.Event = function( src, props ) {
4893 // Allow instantiation without the 'new' keyword
4894 if ( !(this instanceof jQuery.Event) ) {
4895 return new jQuery.Event( src, props );
4899 if ( src && src.type ) {
4900 this.originalEvent = src;
4901 this.type = src.type;
4903 // Events bubbling up the document may have been marked as prevented
4904 // by a handler lower down the tree; reflect the correct value.
4905 this.isDefaultPrevented = src.defaultPrevented ||
4906 src.defaultPrevented === undefined && (
4908 src.returnValue === false ||
4909 // Support: Android < 4.0
4910 src.getPreventDefault && src.getPreventDefault() ) ?
4919 // Put explicitly provided properties onto the event object
4921 jQuery.extend( this, props );
4924 // Create a timestamp if incoming event doesn't have one
4925 this.timeStamp = src && src.timeStamp || jQuery.now();
4928 this[ jQuery.expando ] = true;
4931 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4932 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4933 jQuery.Event.prototype = {
4934 isDefaultPrevented: returnFalse,
4935 isPropagationStopped: returnFalse,
4936 isImmediatePropagationStopped: returnFalse,
4938 preventDefault: function() {
4939 var e = this.originalEvent;
4941 this.isDefaultPrevented = returnTrue;
4946 // If preventDefault exists, run it on the original event
4947 if ( e.preventDefault ) {
4951 // Otherwise set the returnValue property of the original event to false
4953 e.returnValue = false;
4956 stopPropagation: function() {
4957 var e = this.originalEvent;
4959 this.isPropagationStopped = returnTrue;
4963 // If stopPropagation exists, run it on the original event
4964 if ( e.stopPropagation ) {
4965 e.stopPropagation();
4969 // Set the cancelBubble property of the original event to true
4970 e.cancelBubble = true;
4972 stopImmediatePropagation: function() {
4973 this.isImmediatePropagationStopped = returnTrue;
4974 this.stopPropagation();
4978 // Create mouseenter/leave events using mouseover/out and event-time checks
4980 mouseenter: "mouseover",
4981 mouseleave: "mouseout"
4982 }, function( orig, fix ) {
4983 jQuery.event.special[ orig ] = {
4987 handle: function( event ) {
4990 related = event.relatedTarget,
4991 handleObj = event.handleObj;
4993 // For mousenter/leave call the handler if related is outside the target.
4994 // NB: No relatedTarget if the mouse left/entered the browser window
4995 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
4996 event.type = handleObj.origType;
4997 ret = handleObj.handler.apply( this, arguments );
5005 // IE submit delegation
5006 if ( !support.submitBubbles ) {
5008 jQuery.event.special.submit = {
5010 // Only need this for delegated form submit events
5011 if ( jQuery.nodeName( this, "form" ) ) {
5015 // Lazy-add a submit handler when a descendant form may potentially be submitted
5016 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
5017 // Node name check avoids a VML-related crash in IE (#9807)
5018 var elem = e.target,
5019 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
5020 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
5021 jQuery.event.add( form, "submit._submit", function( event ) {
5022 event._submit_bubble = true;
5024 jQuery._data( form, "submitBubbles", true );
5027 // return undefined since we don't need an event listener
5030 postDispatch: function( event ) {
5031 // If form was submitted by the user, bubble the event up the tree
5032 if ( event._submit_bubble ) {
5033 delete event._submit_bubble;
5034 if ( this.parentNode && !event.isTrigger ) {
5035 jQuery.event.simulate( "submit", this.parentNode, event, true );
5040 teardown: function() {
5041 // Only need this for delegated form submit events
5042 if ( jQuery.nodeName( this, "form" ) ) {
5046 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
5047 jQuery.event.remove( this, "._submit" );
5052 // IE change delegation and checkbox/radio fix
5053 if ( !support.changeBubbles ) {
5055 jQuery.event.special.change = {
5059 if ( rformElems.test( this.nodeName ) ) {
5060 // IE doesn't fire change on a check/radio until blur; trigger it on click
5061 // after a propertychange. Eat the blur-change in special.change.handle.
5062 // This still fires onchange a second time for check/radio after blur.
5063 if ( this.type === "checkbox" || this.type === "radio" ) {
5064 jQuery.event.add( this, "propertychange._change", function( event ) {
5065 if ( event.originalEvent.propertyName === "checked" ) {
5066 this._just_changed = true;
5069 jQuery.event.add( this, "click._change", function( event ) {
5070 if ( this._just_changed && !event.isTrigger ) {
5071 this._just_changed = false;
5073 // Allow triggered, simulated change events (#11500)
5074 jQuery.event.simulate( "change", this, event, true );
5079 // Delegated event; lazy-add a change handler on descendant inputs
5080 jQuery.event.add( this, "beforeactivate._change", function( e ) {
5081 var elem = e.target;
5083 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
5084 jQuery.event.add( elem, "change._change", function( event ) {
5085 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
5086 jQuery.event.simulate( "change", this.parentNode, event, true );
5089 jQuery._data( elem, "changeBubbles", true );
5094 handle: function( event ) {
5095 var elem = event.target;
5097 // Swallow native change events from checkbox/radio, we already triggered them above
5098 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
5099 return event.handleObj.handler.apply( this, arguments );
5103 teardown: function() {
5104 jQuery.event.remove( this, "._change" );
5106 return !rformElems.test( this.nodeName );
5111 // Create "bubbling" focus and blur events
5112 if ( !support.focusinBubbles ) {
5113 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
5115 // Attach a single capturing handler on the document while someone wants focusin/focusout
5116 var handler = function( event ) {
5117 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
5120 jQuery.event.special[ fix ] = {
5122 var doc = this.ownerDocument || this,
5123 attaches = jQuery._data( doc, fix );
5126 doc.addEventListener( orig, handler, true );
5128 jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
5130 teardown: function() {
5131 var doc = this.ownerDocument || this,
5132 attaches = jQuery._data( doc, fix ) - 1;
5135 doc.removeEventListener( orig, handler, true );
5136 jQuery._removeData( doc, fix );
5138 jQuery._data( doc, fix, attaches );
5147 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
5150 // Types can be a map of types/handlers
5151 if ( typeof types === "object" ) {
5152 // ( types-Object, selector, data )
5153 if ( typeof selector !== "string" ) {
5154 // ( types-Object, data )
5155 data = data || selector;
5156 selector = undefined;
5158 for ( type in types ) {
5159 this.on( type, selector, data, types[ type ], one );
5164 if ( data == null && fn == null ) {
5167 data = selector = undefined;
5168 } else if ( fn == null ) {
5169 if ( typeof selector === "string" ) {
5170 // ( types, selector, fn )
5174 // ( types, data, fn )
5177 selector = undefined;
5180 if ( fn === false ) {
5188 fn = function( event ) {
5189 // Can use an empty set, since event contains the info
5190 jQuery().off( event );
5191 return origFn.apply( this, arguments );
5193 // Use same guid so caller can remove using origFn
5194 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
5196 return this.each( function() {
5197 jQuery.event.add( this, types, fn, data, selector );
5200 one: function( types, selector, data, fn ) {
5201 return this.on( types, selector, data, fn, 1 );
5203 off: function( types, selector, fn ) {
5204 var handleObj, type;
5205 if ( types && types.preventDefault && types.handleObj ) {
5206 // ( event ) dispatched jQuery.Event
5207 handleObj = types.handleObj;
5208 jQuery( types.delegateTarget ).off(
5209 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
5215 if ( typeof types === "object" ) {
5216 // ( types-object [, selector] )
5217 for ( type in types ) {
5218 this.off( type, selector, types[ type ] );
5222 if ( selector === false || typeof selector === "function" ) {
5225 selector = undefined;
5227 if ( fn === false ) {
5230 return this.each(function() {
5231 jQuery.event.remove( this, types, fn, selector );
5235 trigger: function( type, data ) {
5236 return this.each(function() {
5237 jQuery.event.trigger( type, data, this );
5240 triggerHandler: function( type, data ) {
5243 return jQuery.event.trigger( type, data, elem, true );
5249 function createSafeFragment( document ) {
5250 var list = nodeNames.split( "|" ),
5251 safeFrag = document.createDocumentFragment();
5253 if ( safeFrag.createElement ) {
5254 while ( list.length ) {
5255 safeFrag.createElement(
5263 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5264 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5265 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5266 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5267 rleadingWhitespace = /^\s+/,
5268 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5269 rtagName = /<([\w:]+)/,
5271 rhtml = /<|&#?\w+;/,
5272 rnoInnerhtml = /<(?:script|style|link)/i,
5273 // checked="checked" or checked
5274 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5275 rscriptType = /^$|\/(?:java|ecma)script/i,
5276 rscriptTypeMasked = /^true\/(.*)/,
5277 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
5279 // We have to close these tags to support XHTML (#13200)
5281 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5282 legend: [ 1, "<fieldset>", "</fieldset>" ],
5283 area: [ 1, "<map>", "</map>" ],
5284 param: [ 1, "<object>", "</object>" ],
5285 thead: [ 1, "<table>", "</table>" ],
5286 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5287 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5288 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5290 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5291 // unless wrapped in a div with non-breaking characters in front of it.
5292 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
5294 safeFragment = createSafeFragment( document ),
5295 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5297 wrapMap.optgroup = wrapMap.option;
5298 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5299 wrapMap.th = wrapMap.td;
5301 function getAll( context, tag ) {
5304 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
5305 typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
5309 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
5310 if ( !tag || jQuery.nodeName( elem, tag ) ) {
5313 jQuery.merge( found, getAll( elem, tag ) );
5318 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
5319 jQuery.merge( [ context ], found ) :
5323 // Used in buildFragment, fixes the defaultChecked property
5324 function fixDefaultChecked( elem ) {
5325 if ( rcheckableType.test( elem.type ) ) {
5326 elem.defaultChecked = elem.checked;
5331 // Manipulating tables requires a tbody
5332 function manipulationTarget( elem, content ) {
5333 return jQuery.nodeName( elem, "table" ) &&
5334 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
5336 elem.getElementsByTagName("tbody")[0] ||
5337 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
5341 // Replace/restore the type attribute of script elements for safe DOM manipulation
5342 function disableScript( elem ) {
5343 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
5346 function restoreScript( elem ) {
5347 var match = rscriptTypeMasked.exec( elem.type );
5349 elem.type = match[1];
5351 elem.removeAttribute("type");
5356 // Mark scripts as having already been evaluated
5357 function setGlobalEval( elems, refElements ) {
5360 for ( ; (elem = elems[i]) != null; i++ ) {
5361 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
5365 function cloneCopyEvent( src, dest ) {
5367 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5372 oldData = jQuery._data( src ),
5373 curData = jQuery._data( dest, oldData ),
5374 events = oldData.events;
5377 delete curData.handle;
5378 curData.events = {};
5380 for ( type in events ) {
5381 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5382 jQuery.event.add( dest, type, events[ type ][ i ] );
5387 // make the cloned public data object a copy from the original
5388 if ( curData.data ) {
5389 curData.data = jQuery.extend( {}, curData.data );
5393 function fixCloneNodeIssues( src, dest ) {
5394 var nodeName, e, data;
5396 // We do not need to do anything for non-Elements
5397 if ( dest.nodeType !== 1 ) {
5401 nodeName = dest.nodeName.toLowerCase();
5403 // IE6-8 copies events bound via attachEvent when using cloneNode.
5404 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
5405 data = jQuery._data( dest );
5407 for ( e in data.events ) {
5408 jQuery.removeEvent( dest, e, data.handle );
5411 // Event data gets referenced instead of copied if the expando gets copied too
5412 dest.removeAttribute( jQuery.expando );
5415 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
5416 if ( nodeName === "script" && dest.text !== src.text ) {
5417 disableScript( dest ).text = src.text;
5418 restoreScript( dest );
5420 // IE6-10 improperly clones children of object elements using classid.
5421 // IE10 throws NoModificationAllowedError if parent is null, #12132.
5422 } else if ( nodeName === "object" ) {
5423 if ( dest.parentNode ) {
5424 dest.outerHTML = src.outerHTML;
5427 // This path appears unavoidable for IE9. When cloning an object
5428 // element in IE9, the outerHTML strategy above is not sufficient.
5429 // If the src has innerHTML and the destination does not,
5430 // copy the src.innerHTML into the dest.innerHTML. #10324
5431 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
5432 dest.innerHTML = src.innerHTML;
5435 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5436 // IE6-8 fails to persist the checked state of a cloned checkbox
5437 // or radio button. Worse, IE6-7 fail to give the cloned element
5438 // a checked appearance if the defaultChecked value isn't also set
5440 dest.defaultChecked = dest.checked = src.checked;
5442 // IE6-7 get confused and end up setting the value of a cloned
5443 // checkbox/radio button to an empty string instead of "on"
5444 if ( dest.value !== src.value ) {
5445 dest.value = src.value;
5448 // IE6-8 fails to return the selected option to the default selected
5449 // state when cloning options
5450 } else if ( nodeName === "option" ) {
5451 dest.defaultSelected = dest.selected = src.defaultSelected;
5453 // IE6-8 fails to set the defaultValue to the correct value when
5454 // cloning other types of input fields
5455 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5456 dest.defaultValue = src.defaultValue;
5461 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5462 var destElements, node, clone, i, srcElements,
5463 inPage = jQuery.contains( elem.ownerDocument, elem );
5465 if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
5466 clone = elem.cloneNode( true );
5468 // IE<=8 does not properly clone detached, unknown element nodes
5470 fragmentDiv.innerHTML = elem.outerHTML;
5471 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
5474 if ( (!support.noCloneEvent || !support.noCloneChecked) &&
5475 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
5477 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5478 destElements = getAll( clone );
5479 srcElements = getAll( elem );
5481 // Fix all IE cloning issues
5482 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
5483 // Ensure that the destination node is not null; Fixes #9587
5484 if ( destElements[i] ) {
5485 fixCloneNodeIssues( node, destElements[i] );
5490 // Copy the events from the original to the clone
5491 if ( dataAndEvents ) {
5492 if ( deepDataAndEvents ) {
5493 srcElements = srcElements || getAll( elem );
5494 destElements = destElements || getAll( clone );
5496 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
5497 cloneCopyEvent( node, destElements[i] );
5500 cloneCopyEvent( elem, clone );
5504 // Preserve script evaluation history
5505 destElements = getAll( clone, "script" );
5506 if ( destElements.length > 0 ) {
5507 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5510 destElements = srcElements = node = null;
5512 // Return the cloned set
5516 buildFragment: function( elems, context, scripts, selection ) {
5517 var j, elem, contains,
5518 tmp, tag, tbody, wrap,
5521 // Ensure a safe fragment
5522 safe = createSafeFragment( context ),
5527 for ( ; i < l; i++ ) {
5530 if ( elem || elem === 0 ) {
5532 // Add nodes directly
5533 if ( jQuery.type( elem ) === "object" ) {
5534 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
5536 // Convert non-html into a text node
5537 } else if ( !rhtml.test( elem ) ) {
5538 nodes.push( context.createTextNode( elem ) );
5540 // Convert html into DOM nodes
5542 tmp = tmp || safe.appendChild( context.createElement("div") );
5544 // Deserialize a standard representation
5545 tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
5546 wrap = wrapMap[ tag ] || wrapMap._default;
5548 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
5550 // Descend through wrappers to the right content
5553 tmp = tmp.lastChild;
5556 // Manually add leading whitespace removed by IE
5557 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
5558 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
5561 // Remove IE's autoinserted <tbody> from table fragments
5562 if ( !support.tbody ) {
5564 // String was a <table>, *may* have spurious <tbody>
5565 elem = tag === "table" && !rtbody.test( elem ) ?
5568 // String was a bare <thead> or <tfoot>
5569 wrap[1] === "<table>" && !rtbody.test( elem ) ?
5573 j = elem && elem.childNodes.length;
5575 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
5576 elem.removeChild( tbody );
5581 jQuery.merge( nodes, tmp.childNodes );
5583 // Fix #12392 for WebKit and IE > 9
5584 tmp.textContent = "";
5586 // Fix #12392 for oldIE
5587 while ( tmp.firstChild ) {
5588 tmp.removeChild( tmp.firstChild );
5591 // Remember the top-level container for proper cleanup
5592 tmp = safe.lastChild;
5597 // Fix #11356: Clear elements from fragment
5599 safe.removeChild( tmp );
5602 // Reset defaultChecked for any radios and checkboxes
5603 // about to be appended to the DOM in IE 6/7 (#8060)
5604 if ( !support.appendChecked ) {
5605 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
5609 while ( (elem = nodes[ i++ ]) ) {
5611 // #4087 - If origin and destination elements are the same, and this is
5612 // that element, do not do anything
5613 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
5617 contains = jQuery.contains( elem.ownerDocument, elem );
5619 // Append to fragment
5620 tmp = getAll( safe.appendChild( elem ), "script" );
5622 // Preserve script evaluation history
5624 setGlobalEval( tmp );
5627 // Capture executables
5630 while ( (elem = tmp[ j++ ]) ) {
5631 if ( rscriptType.test( elem.type || "" ) ) {
5632 scripts.push( elem );
5643 cleanData: function( elems, /* internal */ acceptData ) {
5644 var elem, type, id, data,
5646 internalKey = jQuery.expando,
5647 cache = jQuery.cache,
5648 deleteExpando = support.deleteExpando,
5649 special = jQuery.event.special;
5651 for ( ; (elem = elems[i]) != null; i++ ) {
5652 if ( acceptData || jQuery.acceptData( elem ) ) {
5654 id = elem[ internalKey ];
5655 data = id && cache[ id ];
5658 if ( data.events ) {
5659 for ( type in data.events ) {
5660 if ( special[ type ] ) {
5661 jQuery.event.remove( elem, type );
5663 // This is a shortcut to avoid jQuery.event.remove's overhead
5665 jQuery.removeEvent( elem, type, data.handle );
5670 // Remove cache only if it was not already removed by jQuery.event.remove
5671 if ( cache[ id ] ) {
5675 // IE does not allow us to delete expando properties from nodes,
5676 // nor does it have a removeAttribute function on Document nodes;
5677 // we must handle all of these cases
5678 if ( deleteExpando ) {
5679 delete elem[ internalKey ];
5681 } else if ( typeof elem.removeAttribute !== strundefined ) {
5682 elem.removeAttribute( internalKey );
5685 elem[ internalKey ] = null;
5688 deletedIds.push( id );
5697 text: function( value ) {
5698 return access( this, function( value ) {
5699 return value === undefined ?
5700 jQuery.text( this ) :
5701 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5702 }, null, value, arguments.length );
5705 append: function() {
5706 return this.domManip( arguments, function( elem ) {
5707 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5708 var target = manipulationTarget( this, elem );
5709 target.appendChild( elem );
5714 prepend: function() {
5715 return this.domManip( arguments, function( elem ) {
5716 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5717 var target = manipulationTarget( this, elem );
5718 target.insertBefore( elem, target.firstChild );
5723 before: function() {
5724 return this.domManip( arguments, function( elem ) {
5725 if ( this.parentNode ) {
5726 this.parentNode.insertBefore( elem, this );
5732 return this.domManip( arguments, function( elem ) {
5733 if ( this.parentNode ) {
5734 this.parentNode.insertBefore( elem, this.nextSibling );
5739 remove: function( selector, keepData /* Internal Use Only */ ) {
5741 elems = selector ? jQuery.filter( selector, this ) : this,
5744 for ( ; (elem = elems[i]) != null; i++ ) {
5746 if ( !keepData && elem.nodeType === 1 ) {
5747 jQuery.cleanData( getAll( elem ) );
5750 if ( elem.parentNode ) {
5751 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
5752 setGlobalEval( getAll( elem, "script" ) );
5754 elem.parentNode.removeChild( elem );
5765 for ( ; (elem = this[i]) != null; i++ ) {
5766 // Remove element nodes and prevent memory leaks
5767 if ( elem.nodeType === 1 ) {
5768 jQuery.cleanData( getAll( elem, false ) );
5771 // Remove any remaining nodes
5772 while ( elem.firstChild ) {
5773 elem.removeChild( elem.firstChild );
5776 // If this is a select, ensure that it displays empty (#12336)
5778 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
5779 elem.options.length = 0;
5786 clone: function( dataAndEvents, deepDataAndEvents ) {
5787 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5788 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5790 return this.map(function() {
5791 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5795 html: function( value ) {
5796 return access( this, function( value ) {
5797 var elem = this[ 0 ] || {},
5801 if ( value === undefined ) {
5802 return elem.nodeType === 1 ?
5803 elem.innerHTML.replace( rinlinejQuery, "" ) :
5807 // See if we can take a shortcut and just use innerHTML
5808 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5809 ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5810 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5811 !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
5813 value = value.replace( rxhtmlTag, "<$1></$2>" );
5816 for (; i < l; i++ ) {
5817 // Remove element nodes and prevent memory leaks
5818 elem = this[i] || {};
5819 if ( elem.nodeType === 1 ) {
5820 jQuery.cleanData( getAll( elem, false ) );
5821 elem.innerHTML = value;
5827 // If using innerHTML throws an exception, use the fallback method
5832 this.empty().append( value );
5834 }, null, value, arguments.length );
5837 replaceWith: function() {
5838 var arg = arguments[ 0 ];
5840 // Make the changes, replacing each context element with the new content
5841 this.domManip( arguments, function( elem ) {
5842 arg = this.parentNode;
5844 jQuery.cleanData( getAll( this ) );
5847 arg.replaceChild( elem, this );
5851 // Force removal if there was no new content (e.g., from empty arguments)
5852 return arg && (arg.length || arg.nodeType) ? this : this.remove();
5855 detach: function( selector ) {
5856 return this.remove( selector, true );
5859 domManip: function( args, callback ) {
5861 // Flatten any nested arrays
5862 args = concat.apply( [], args );
5864 var first, node, hasScripts,
5865 scripts, doc, fragment,
5871 isFunction = jQuery.isFunction( value );
5873 // We can't cloneNode fragments that contain checked, in WebKit
5875 ( l > 1 && typeof value === "string" &&
5876 !support.checkClone && rchecked.test( value ) ) ) {
5877 return this.each(function( index ) {
5878 var self = set.eq( index );
5880 args[0] = value.call( this, index, self.html() );
5882 self.domManip( args, callback );
5887 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
5888 first = fragment.firstChild;
5890 if ( fragment.childNodes.length === 1 ) {
5895 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5896 hasScripts = scripts.length;
5898 // Use the original fragment for the last item instead of the first because it can end up
5899 // being emptied incorrectly in certain situations (#8070).
5900 for ( ; i < l; i++ ) {
5903 if ( i !== iNoClone ) {
5904 node = jQuery.clone( node, true, true );
5906 // Keep references to cloned scripts for later restoration
5908 jQuery.merge( scripts, getAll( node, "script" ) );
5912 callback.call( this[i], node, i );
5916 doc = scripts[ scripts.length - 1 ].ownerDocument;
5919 jQuery.map( scripts, restoreScript );
5921 // Evaluate executable scripts on first document insertion
5922 for ( i = 0; i < hasScripts; i++ ) {
5923 node = scripts[ i ];
5924 if ( rscriptType.test( node.type || "" ) &&
5925 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
5928 // Optional AJAX dependency, but won't run scripts if not present
5929 if ( jQuery._evalUrl ) {
5930 jQuery._evalUrl( node.src );
5933 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
5939 // Fix #11809: Avoid leaking memory
5940 fragment = first = null;
5950 prependTo: "prepend",
5951 insertBefore: "before",
5952 insertAfter: "after",
5953 replaceAll: "replaceWith"
5954 }, function( name, original ) {
5955 jQuery.fn[ name ] = function( selector ) {
5959 insert = jQuery( selector ),
5960 last = insert.length - 1;
5962 for ( ; i <= last; i++ ) {
5963 elems = i === last ? this : this.clone(true);
5964 jQuery( insert[i] )[ original ]( elems );
5966 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
5967 push.apply( ret, elems.get() );
5970 return this.pushStack( ret );
5979 * Retrieve the actual display of a element
5980 * @param {String} name nodeName of the element
5981 * @param {Object} doc Document object
5983 // Called only from within defaultDisplay
5984 function actualDisplay( name, doc ) {
5985 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
5987 // getDefaultComputedStyle might be reliably used only on attached element
5988 display = window.getDefaultComputedStyle ?
5990 // Use of this method is a temporary fix (more like optmization) until something better comes along,
5991 // since it was removed from specification and supported only in FF
5992 window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
5994 // We don't have any data stored on the element,
5995 // so use "detach" method as fast way to get rid of the element
6002 * Try to determine the default display value of an element
6003 * @param {String} nodeName
6005 function defaultDisplay( nodeName ) {
6007 display = elemdisplay[ nodeName ];
6010 display = actualDisplay( nodeName, doc );
6012 // If the simple way fails, read from inside an iframe
6013 if ( display === "none" || !display ) {
6015 // Use the already-created iframe if possible
6016 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
6018 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
6019 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
6025 display = actualDisplay( nodeName, doc );
6029 // Store the correct default display
6030 elemdisplay[ nodeName ] = display;
6038 var a, shrinkWrapBlocksVal,
6039 div = document.createElement( "div" ),
6041 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
6042 "display:block;padding:0;margin:0;border:0";
6045 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
6046 a = div.getElementsByTagName( "a" )[ 0 ];
6048 a.style.cssText = "float:left;opacity:.5";
6050 // Make sure that element opacity exists
6051 // (IE uses filter instead)
6052 // Use a regex to work around a WebKit issue. See #5145
6053 support.opacity = /^0.5/.test( a.style.opacity );
6055 // Verify style float existence
6056 // (IE uses styleFloat instead of cssFloat)
6057 support.cssFloat = !!a.style.cssFloat;
6059 div.style.backgroundClip = "content-box";
6060 div.cloneNode( true ).style.backgroundClip = "";
6061 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6063 // Null elements to avoid leaks in IE.
6066 support.shrinkWrapBlocks = function() {
6067 var body, container, div, containerStyles;
6069 if ( shrinkWrapBlocksVal == null ) {
6070 body = document.getElementsByTagName( "body" )[ 0 ];
6072 // Test fired too early or in an unsupported environment, exit.
6076 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px";
6077 container = document.createElement( "div" );
6078 div = document.createElement( "div" );
6080 body.appendChild( container ).appendChild( div );
6082 // Will be changed later if needed.
6083 shrinkWrapBlocksVal = false;
6085 if ( typeof div.style.zoom !== strundefined ) {
6087 // Check if elements with layout shrink-wrap their children
6088 div.style.cssText = divReset + ";width:1px;padding:1px;zoom:1";
6089 div.innerHTML = "<div></div>";
6090 div.firstChild.style.width = "5px";
6091 shrinkWrapBlocksVal = div.offsetWidth !== 3;
6094 body.removeChild( container );
6096 // Null elements to avoid leaks in IE.
6097 body = container = div = null;
6100 return shrinkWrapBlocksVal;
6104 var rmargin = (/^margin/);
6106 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6110 var getStyles, curCSS,
6111 rposition = /^(top|right|bottom|left)$/;
6113 if ( window.getComputedStyle ) {
6114 getStyles = function( elem ) {
6115 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
6118 curCSS = function( elem, name, computed ) {
6119 var width, minWidth, maxWidth, ret,
6122 computed = computed || getStyles( elem );
6124 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6125 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
6129 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6130 ret = jQuery.style( elem, name );
6133 // A tribute to the "awesome hack by Dean Edwards"
6134 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6135 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6136 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6137 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6139 // Remember the original values
6140 width = style.width;
6141 minWidth = style.minWidth;
6142 maxWidth = style.maxWidth;
6144 // Put in the new values to get a computed value out
6145 style.minWidth = style.maxWidth = style.width = ret;
6146 ret = computed.width;
6148 // Revert the changed values
6149 style.width = width;
6150 style.minWidth = minWidth;
6151 style.maxWidth = maxWidth;
6156 // IE returns zIndex value as an integer.
6157 return ret === undefined ?
6161 } else if ( document.documentElement.currentStyle ) {
6162 getStyles = function( elem ) {
6163 return elem.currentStyle;
6166 curCSS = function( elem, name, computed ) {
6167 var left, rs, rsLeft, ret,
6170 computed = computed || getStyles( elem );
6171 ret = computed ? computed[ name ] : undefined;
6173 // Avoid setting ret to empty string here
6174 // so we don't default to auto
6175 if ( ret == null && style && style[ name ] ) {
6176 ret = style[ name ];
6179 // From the awesome hack by Dean Edwards
6180 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6182 // If we're not dealing with a regular pixel number
6183 // but a number that has a weird ending, we need to convert it to pixels
6184 // but not position css attributes, as those are proportional to the parent element instead
6185 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6186 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6188 // Remember the original values
6190 rs = elem.runtimeStyle;
6191 rsLeft = rs && rs.left;
6193 // Put in the new values to get a computed value out
6195 rs.left = elem.currentStyle.left;
6197 style.left = name === "fontSize" ? "1em" : ret;
6198 ret = style.pixelLeft + "px";
6200 // Revert the changed values
6208 // IE returns zIndex value as an integer.
6209 return ret === undefined ?
6218 function addGetHookIf( conditionFn, hookFn ) {
6219 // Define the hook, we'll check on the first run if it's really needed.
6222 var condition = conditionFn();
6224 if ( condition == null ) {
6225 // The test was not ready at this point; screw the hook this time
6226 // but check again when needed next time.
6231 // Hook not needed (or it's not possible to use it due to missing dependency),
6233 // Since there are no other hooks for marginRight, remove the whole object.
6238 // Hook needed; redefine it so that the support test is not executed again.
6240 return (this.get = hookFn).apply( this, arguments );
6247 var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal,
6248 pixelPositionVal, reliableMarginRightVal,
6249 div = document.createElement( "div" ),
6250 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px",
6252 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
6253 "display:block;padding:0;margin:0;border:0";
6256 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
6257 a = div.getElementsByTagName( "a" )[ 0 ];
6259 a.style.cssText = "float:left;opacity:.5";
6261 // Make sure that element opacity exists
6262 // (IE uses filter instead)
6263 // Use a regex to work around a WebKit issue. See #5145
6264 support.opacity = /^0.5/.test( a.style.opacity );
6266 // Verify style float existence
6267 // (IE uses styleFloat instead of cssFloat)
6268 support.cssFloat = !!a.style.cssFloat;
6270 div.style.backgroundClip = "content-box";
6271 div.cloneNode( true ).style.backgroundClip = "";
6272 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6274 // Null elements to avoid leaks in IE.
6277 jQuery.extend(support, {
6278 reliableHiddenOffsets: function() {
6279 if ( reliableHiddenOffsetsVal != null ) {
6280 return reliableHiddenOffsetsVal;
6283 var container, tds, isSupported,
6284 div = document.createElement( "div" ),
6285 body = document.getElementsByTagName( "body" )[ 0 ];
6288 // Return for frameset docs that don't have a body
6293 div.setAttribute( "className", "t" );
6294 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
6296 container = document.createElement( "div" );
6297 container.style.cssText = containerStyles;
6299 body.appendChild( container ).appendChild( div );
6302 // Check if table cells still have offsetWidth/Height when they are set
6303 // to display:none and there are still other visible table cells in a
6304 // table row; if so, offsetWidth/Height are not reliable for use when
6305 // determining if an element has been hidden directly using
6306 // display:none (it is still safe to use offsets if a parent element is
6307 // hidden; don safety goggles and see bug #4512 for more information).
6308 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
6309 tds = div.getElementsByTagName( "td" );
6310 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
6311 isSupported = ( tds[ 0 ].offsetHeight === 0 );
6313 tds[ 0 ].style.display = "";
6314 tds[ 1 ].style.display = "none";
6317 // Check if empty table cells still have offsetWidth/Height
6318 reliableHiddenOffsetsVal = isSupported && ( tds[ 0 ].offsetHeight === 0 );
6320 body.removeChild( container );
6322 // Null elements to avoid leaks in IE.
6325 return reliableHiddenOffsetsVal;
6328 boxSizing: function() {
6329 if ( boxSizingVal == null ) {
6330 computeStyleTests();
6332 return boxSizingVal;
6335 boxSizingReliable: function() {
6336 if ( boxSizingReliableVal == null ) {
6337 computeStyleTests();
6339 return boxSizingReliableVal;
6342 pixelPosition: function() {
6343 if ( pixelPositionVal == null ) {
6344 computeStyleTests();
6346 return pixelPositionVal;
6349 reliableMarginRight: function() {
6350 var body, container, div, marginDiv;
6352 // Use window.getComputedStyle because jsdom on node.js will break without it.
6353 if ( reliableMarginRightVal == null && window.getComputedStyle ) {
6354 body = document.getElementsByTagName( "body" )[ 0 ];
6356 // Test fired too early or in an unsupported environment, exit.
6360 container = document.createElement( "div" );
6361 div = document.createElement( "div" );
6362 container.style.cssText = containerStyles;
6364 body.appendChild( container ).appendChild( div );
6366 // Check if div with explicit width and no margin-right incorrectly
6367 // gets computed margin-right based on width of container. (#3333)
6368 // Fails in WebKit before Feb 2011 nightlies
6369 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6370 marginDiv = div.appendChild( document.createElement( "div" ) );
6371 marginDiv.style.cssText = div.style.cssText = divReset;
6372 marginDiv.style.marginRight = marginDiv.style.width = "0";
6373 div.style.width = "1px";
6375 reliableMarginRightVal =
6376 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
6378 body.removeChild( container );
6381 return reliableMarginRightVal;
6385 function computeStyleTests() {
6387 body = document.getElementsByTagName( "body" )[ 0 ];
6390 // Test fired too early or in an unsupported environment, exit.
6394 container = document.createElement( "div" );
6395 div = document.createElement( "div" );
6396 container.style.cssText = containerStyles;
6398 body.appendChild( container ).appendChild( div );
6401 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
6402 "position:absolute;display:block;padding:1px;border:1px;width:4px;" +
6403 "margin-top:1%;top:1%";
6405 // Workaround failing boxSizing test due to offsetWidth returning wrong value
6406 // with some non-1 values of body zoom, ticket #13543
6407 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
6408 boxSizingVal = div.offsetWidth === 4;
6411 // Will be changed later if needed.
6412 boxSizingReliableVal = true;
6413 pixelPositionVal = false;
6414 reliableMarginRightVal = true;
6416 // Use window.getComputedStyle because jsdom on node.js will break without it.
6417 if ( window.getComputedStyle ) {
6418 pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
6419 boxSizingReliableVal =
6420 ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
6423 body.removeChild( container );
6425 // Null elements to avoid leaks in IE.
6432 // A method for quickly swapping in/out CSS properties to get correct calculations.
6433 jQuery.swap = function( elem, options, callback, args ) {
6437 // Remember the old values, and insert the new ones
6438 for ( name in options ) {
6439 old[ name ] = elem.style[ name ];
6440 elem.style[ name ] = options[ name ];
6443 ret = callback.apply( elem, args || [] );
6445 // Revert the old values
6446 for ( name in options ) {
6447 elem.style[ name ] = old[ name ];
6455 ralpha = /alpha\([^)]*\)/i,
6456 ropacity = /opacity\s*=\s*([^)]*)/,
6458 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6459 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6460 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6461 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
6462 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
6464 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6465 cssNormalTransform = {
6470 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
6473 // return a css property mapped to a potentially vendor prefixed property
6474 function vendorPropName( style, name ) {
6476 // shortcut for names that are not vendor prefixed
6477 if ( name in style ) {
6481 // check for vendor prefixed names
6482 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6484 i = cssPrefixes.length;
6487 name = cssPrefixes[ i ] + capName;
6488 if ( name in style ) {
6496 function showHide( elements, show ) {
6497 var display, elem, hidden,
6500 length = elements.length;
6502 for ( ; index < length; index++ ) {
6503 elem = elements[ index ];
6504 if ( !elem.style ) {
6508 values[ index ] = jQuery._data( elem, "olddisplay" );
6509 display = elem.style.display;
6511 // Reset the inline display of this element to learn if it is
6512 // being hidden by cascaded rules or not
6513 if ( !values[ index ] && display === "none" ) {
6514 elem.style.display = "";
6517 // Set elements which have been overridden with display: none
6518 // in a stylesheet to whatever the default browser style is
6519 // for such an element
6520 if ( elem.style.display === "" && isHidden( elem ) ) {
6521 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
6525 if ( !values[ index ] ) {
6526 hidden = isHidden( elem );
6528 if ( display && display !== "none" || !hidden ) {
6529 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
6535 // Set the display of most of the elements in a second loop
6536 // to avoid the constant reflow
6537 for ( index = 0; index < length; index++ ) {
6538 elem = elements[ index ];
6539 if ( !elem.style ) {
6542 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6543 elem.style.display = show ? values[ index ] || "" : "none";
6550 function setPositiveNumber( elem, value, subtract ) {
6551 var matches = rnumsplit.exec( value );
6553 // Guard against undefined "subtract", e.g., when used as in cssHooks
6554 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6558 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
6559 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6560 // If we already have the right measurement, avoid augmentation
6562 // Otherwise initialize for horizontal or vertical properties
6563 name === "width" ? 1 : 0,
6567 for ( ; i < 4; i += 2 ) {
6568 // both box models exclude margin, so add it if we want it
6569 if ( extra === "margin" ) {
6570 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
6573 if ( isBorderBox ) {
6574 // border-box includes padding, so remove it if we want content
6575 if ( extra === "content" ) {
6576 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6579 // at this point, extra isn't border nor margin, so remove border
6580 if ( extra !== "margin" ) {
6581 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6584 // at this point, extra isn't content, so add padding
6585 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6587 // at this point, extra isn't content nor padding, so add border
6588 if ( extra !== "padding" ) {
6589 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6597 function getWidthOrHeight( elem, name, extra ) {
6599 // Start with offset property, which is equivalent to the border-box value
6600 var valueIsBorderBox = true,
6601 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6602 styles = getStyles( elem ),
6603 isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6605 // some non-html elements return undefined for offsetWidth, so check for null/undefined
6606 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6607 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6608 if ( val <= 0 || val == null ) {
6609 // Fall back to computed then uncomputed css if necessary
6610 val = curCSS( elem, name, styles );
6611 if ( val < 0 || val == null ) {
6612 val = elem.style[ name ];
6615 // Computed unit is not pixels. Stop here and return.
6616 if ( rnumnonpx.test(val) ) {
6620 // we need the check for style in case a browser which returns unreliable values
6621 // for getComputedStyle silently falls back to the reliable elem.style
6622 valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
6624 // Normalize "", auto, and prepare for extra
6625 val = parseFloat( val ) || 0;
6628 // use the active box-sizing model to add/subtract irrelevant styles
6630 augmentWidthOrHeight(
6633 extra || ( isBorderBox ? "border" : "content" ),
6641 // Add in style property hooks for overriding the default
6642 // behavior of getting and setting a style property
6645 get: function( elem, computed ) {
6647 // We should always get a number back from opacity
6648 var ret = curCSS( elem, "opacity" );
6649 return ret === "" ? "1" : ret;
6655 // Don't automatically add "px" to these possibly-unitless properties
6657 "columnCount": true,
6658 "fillOpacity": true,
6669 // Add in properties whose names you wish to fix before
6670 // setting or getting the value
6672 // normalize float css property
6673 "float": support.cssFloat ? "cssFloat" : "styleFloat"
6676 // Get and set the style property on a DOM Node
6677 style: function( elem, name, value, extra ) {
6678 // Don't set styles on text and comment nodes
6679 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6683 // Make sure that we're working with the right name
6684 var ret, type, hooks,
6685 origName = jQuery.camelCase( name ),
6688 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6690 // gets hook for the prefixed version
6691 // followed by the unprefixed version
6692 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6694 // Check if we're setting a value
6695 if ( value !== undefined ) {
6696 type = typeof value;
6698 // convert relative number strings (+= or -=) to relative numbers. #7345
6699 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6700 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6705 // Make sure that null and NaN values aren't set. See: #7116
6706 if ( value == null || value !== value ) {
6710 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6711 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6715 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
6716 // but it would mean to define eight (for every problematic property) identical functions
6717 if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
6718 style[ name ] = "inherit";
6721 // If a hook was provided, use that value, otherwise just set the specified value
6722 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6725 // Swallow errors from 'invalid' CSS values (#5509)
6727 // Support: Chrome, Safari
6728 // Setting style to blank string required to delete "style: x !important;"
6730 style[ name ] = value;
6735 // If a hook was provided get the non-computed value from there
6736 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6740 // Otherwise just get the value from the style object
6741 return style[ name ];
6745 css: function( elem, name, extra, styles ) {
6746 var num, val, hooks,
6747 origName = jQuery.camelCase( name );
6749 // Make sure that we're working with the right name
6750 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6752 // gets hook for the prefixed version
6753 // followed by the unprefixed version
6754 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6756 // If a hook was provided get the computed value from there
6757 if ( hooks && "get" in hooks ) {
6758 val = hooks.get( elem, true, extra );
6761 // Otherwise, if a way to get the computed value exists, use that
6762 if ( val === undefined ) {
6763 val = curCSS( elem, name, styles );
6766 //convert "normal" to computed value
6767 if ( val === "normal" && name in cssNormalTransform ) {
6768 val = cssNormalTransform[ name ];
6771 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6772 if ( extra === "" || extra ) {
6773 num = parseFloat( val );
6774 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
6780 jQuery.each([ "height", "width" ], function( i, name ) {
6781 jQuery.cssHooks[ name ] = {
6782 get: function( elem, computed, extra ) {
6784 // certain elements can have dimension info if we invisibly show them
6785 // however, it must have a current display style that would benefit from this
6786 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
6787 jQuery.swap( elem, cssShow, function() {
6788 return getWidthOrHeight( elem, name, extra );
6790 getWidthOrHeight( elem, name, extra );
6794 set: function( elem, value, extra ) {
6795 var styles = extra && getStyles( elem );
6796 return setPositiveNumber( elem, value, extra ?
6797 augmentWidthOrHeight(
6801 support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6809 if ( !support.opacity ) {
6810 jQuery.cssHooks.opacity = {
6811 get: function( elem, computed ) {
6812 // IE uses filters for opacity
6813 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6814 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
6815 computed ? "1" : "";
6818 set: function( elem, value ) {
6819 var style = elem.style,
6820 currentStyle = elem.currentStyle,
6821 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
6822 filter = currentStyle && currentStyle.filter || style.filter || "";
6824 // IE has trouble with opacity if it does not have layout
6825 // Force it by setting the zoom level
6828 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6829 // if value === "", then remove inline opacity #12685
6830 if ( ( value >= 1 || value === "" ) &&
6831 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
6832 style.removeAttribute ) {
6834 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6835 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6836 // style.removeAttribute is IE Only, but so apparently is this code path...
6837 style.removeAttribute( "filter" );
6839 // if there is no filter style applied in a css rule or unset inline opacity, we are done
6840 if ( value === "" || currentStyle && !currentStyle.filter ) {
6845 // otherwise, set new filter values
6846 style.filter = ralpha.test( filter ) ?
6847 filter.replace( ralpha, opacity ) :
6848 filter + " " + opacity;
6853 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
6854 function( elem, computed ) {
6856 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6857 // Work around by temporarily setting element display to inline-block
6858 return jQuery.swap( elem, { "display": "inline-block" },
6859 curCSS, [ elem, "marginRight" ] );
6864 // These hooks are used by animate to expand properties
6869 }, function( prefix, suffix ) {
6870 jQuery.cssHooks[ prefix + suffix ] = {
6871 expand: function( value ) {
6875 // assumes a single number if not a string
6876 parts = typeof value === "string" ? value.split(" ") : [ value ];
6878 for ( ; i < 4; i++ ) {
6879 expanded[ prefix + cssExpand[ i ] + suffix ] =
6880 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6887 if ( !rmargin.test( prefix ) ) {
6888 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6893 css: function( name, value ) {
6894 return access( this, function( elem, name, value ) {
6899 if ( jQuery.isArray( name ) ) {
6900 styles = getStyles( elem );
6903 for ( ; i < len; i++ ) {
6904 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6910 return value !== undefined ?
6911 jQuery.style( elem, name, value ) :
6912 jQuery.css( elem, name );
6913 }, name, value, arguments.length > 1 );
6916 return showHide( this, true );
6919 return showHide( this );
6921 toggle: function( state ) {
6922 if ( typeof state === "boolean" ) {
6923 return state ? this.show() : this.hide();
6926 return this.each(function() {
6927 if ( isHidden( this ) ) {
6928 jQuery( this ).show();
6930 jQuery( this ).hide();
6937 function Tween( elem, options, prop, end, easing ) {
6938 return new Tween.prototype.init( elem, options, prop, end, easing );
6940 jQuery.Tween = Tween;
6944 init: function( elem, options, prop, end, easing, unit ) {
6947 this.easing = easing || "swing";
6948 this.options = options;
6949 this.start = this.now = this.cur();
6951 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
6954 var hooks = Tween.propHooks[ this.prop ];
6956 return hooks && hooks.get ?
6958 Tween.propHooks._default.get( this );
6960 run: function( percent ) {
6962 hooks = Tween.propHooks[ this.prop ];
6964 if ( this.options.duration ) {
6965 this.pos = eased = jQuery.easing[ this.easing ](
6966 percent, this.options.duration * percent, 0, 1, this.options.duration
6969 this.pos = eased = percent;
6971 this.now = ( this.end - this.start ) * eased + this.start;
6973 if ( this.options.step ) {
6974 this.options.step.call( this.elem, this.now, this );
6977 if ( hooks && hooks.set ) {
6980 Tween.propHooks._default.set( this );
6986 Tween.prototype.init.prototype = Tween.prototype;
6990 get: function( tween ) {
6993 if ( tween.elem[ tween.prop ] != null &&
6994 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
6995 return tween.elem[ tween.prop ];
6998 // passing an empty string as a 3rd parameter to .css will automatically
6999 // attempt a parseFloat and fallback to a string if the parse fails
7000 // so, simple values such as "10px" are parsed to Float.
7001 // complex values such as "rotate(1rad)" are returned as is.
7002 result = jQuery.css( tween.elem, tween.prop, "" );
7003 // Empty strings, null, undefined and "auto" are converted to 0.
7004 return !result || result === "auto" ? 0 : result;
7006 set: function( tween ) {
7007 // use step hook for back compat - use cssHook if its there - use .style if its
7008 // available and use plain properties where available
7009 if ( jQuery.fx.step[ tween.prop ] ) {
7010 jQuery.fx.step[ tween.prop ]( tween );
7011 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
7012 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
7014 tween.elem[ tween.prop ] = tween.now;
7021 // Panic based approach to setting things on disconnected nodes
7023 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
7024 set: function( tween ) {
7025 if ( tween.elem.nodeType && tween.elem.parentNode ) {
7026 tween.elem[ tween.prop ] = tween.now;
7032 linear: function( p ) {
7035 swing: function( p ) {
7036 return 0.5 - Math.cos( p * Math.PI ) / 2;
7040 jQuery.fx = Tween.prototype.init;
7042 // Back Compat <1.8 extension point
7043 jQuery.fx.step = {};
7050 rfxtypes = /^(?:toggle|show|hide)$/,
7051 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
7052 rrun = /queueHooks$/,
7053 animationPrefilters = [ defaultPrefilter ],
7055 "*": [ function( prop, value ) {
7056 var tween = this.createTween( prop, value ),
7057 target = tween.cur(),
7058 parts = rfxnum.exec( value ),
7059 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
7061 // Starting value computation is required for potential unit mismatches
7062 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
7063 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
7067 if ( start && start[ 3 ] !== unit ) {
7068 // Trust units reported by jQuery.css
7069 unit = unit || start[ 3 ];
7071 // Make sure we update the tween properties later on
7072 parts = parts || [];
7074 // Iteratively approximate from a nonzero starting point
7075 start = +target || 1;
7078 // If previous iteration zeroed out, double until we get *something*
7079 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
7080 scale = scale || ".5";
7083 start = start / scale;
7084 jQuery.style( tween.elem, prop, start + unit );
7086 // Update scale, tolerating zero or NaN from tween.cur()
7087 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
7088 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
7091 // Update tween properties
7093 start = tween.start = +start || +target || 0;
7095 // If a +=/-= token was provided, we're doing a relative animation
7096 tween.end = parts[ 1 ] ?
7097 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
7105 // Animations created synchronously will run synchronously
7106 function createFxNow() {
7107 setTimeout(function() {
7110 return ( fxNow = jQuery.now() );
7113 // Generate parameters to create a standard animation
7114 function genFx( type, includeWidth ) {
7116 attrs = { height: type },
7119 // if we include width, step value is 1 to do all cssExpand values,
7120 // if we don't include width, step value is 2 to skip over Left and Right
7121 includeWidth = includeWidth ? 1 : 0;
7122 for ( ; i < 4 ; i += 2 - includeWidth ) {
7123 which = cssExpand[ i ];
7124 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
7127 if ( includeWidth ) {
7128 attrs.opacity = attrs.width = type;
7134 function createTween( value, prop, animation ) {
7136 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
7138 length = collection.length;
7139 for ( ; index < length; index++ ) {
7140 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
7142 // we're done with this property
7148 function defaultPrefilter( elem, props, opts ) {
7149 /* jshint validthis: true */
7150 var prop, value, toggle, tween, hooks, oldfire, display, dDisplay,
7154 hidden = elem.nodeType && isHidden( elem ),
7155 dataShow = jQuery._data( elem, "fxshow" );
7157 // handle queue: false promises
7158 if ( !opts.queue ) {
7159 hooks = jQuery._queueHooks( elem, "fx" );
7160 if ( hooks.unqueued == null ) {
7162 oldfire = hooks.empty.fire;
7163 hooks.empty.fire = function() {
7164 if ( !hooks.unqueued ) {
7171 anim.always(function() {
7172 // doing this makes sure that the complete handler will be called
7173 // before this completes
7174 anim.always(function() {
7176 if ( !jQuery.queue( elem, "fx" ).length ) {
7183 // height/width overflow pass
7184 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
7185 // Make sure that nothing sneaks out
7186 // Record all 3 overflow attributes because IE does not
7187 // change the overflow attribute when overflowX and
7188 // overflowY are set to the same value
7189 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
7191 // Set display property to inline-block for height/width
7192 // animations on inline elements that are having width/height animated
7193 display = jQuery.css( elem, "display" );
7194 dDisplay = defaultDisplay( elem.nodeName );
7195 if ( display === "none" ) {
7198 if ( display === "inline" &&
7199 jQuery.css( elem, "float" ) === "none" ) {
7201 // inline-level elements accept inline-block;
7202 // block-level elements need to be inline with layout
7203 if ( !support.inlineBlockNeedsLayout || dDisplay === "inline" ) {
7204 style.display = "inline-block";
7211 if ( opts.overflow ) {
7212 style.overflow = "hidden";
7213 if ( !support.shrinkWrapBlocks() ) {
7214 anim.always(function() {
7215 style.overflow = opts.overflow[ 0 ];
7216 style.overflowX = opts.overflow[ 1 ];
7217 style.overflowY = opts.overflow[ 2 ];
7223 for ( prop in props ) {
7224 value = props[ prop ];
7225 if ( rfxtypes.exec( value ) ) {
7226 delete props[ prop ];
7227 toggle = toggle || value === "toggle";
7228 if ( value === ( hidden ? "hide" : "show" ) ) {
7230 // 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
7231 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
7237 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
7241 if ( !jQuery.isEmptyObject( orig ) ) {
7243 if ( "hidden" in dataShow ) {
7244 hidden = dataShow.hidden;
7247 dataShow = jQuery._data( elem, "fxshow", {} );
7250 // store state if its toggle - enables .stop().toggle() to "reverse"
7252 dataShow.hidden = !hidden;
7255 jQuery( elem ).show();
7257 anim.done(function() {
7258 jQuery( elem ).hide();
7261 anim.done(function() {
7263 jQuery._removeData( elem, "fxshow" );
7264 for ( prop in orig ) {
7265 jQuery.style( elem, prop, orig[ prop ] );
7268 for ( prop in orig ) {
7269 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
7271 if ( !( prop in dataShow ) ) {
7272 dataShow[ prop ] = tween.start;
7274 tween.end = tween.start;
7275 tween.start = prop === "width" || prop === "height" ? 1 : 0;
7282 function propFilter( props, specialEasing ) {
7283 var index, name, easing, value, hooks;
7285 // camelCase, specialEasing and expand cssHook pass
7286 for ( index in props ) {
7287 name = jQuery.camelCase( index );
7288 easing = specialEasing[ name ];
7289 value = props[ index ];
7290 if ( jQuery.isArray( value ) ) {
7291 easing = value[ 1 ];
7292 value = props[ index ] = value[ 0 ];
7295 if ( index !== name ) {
7296 props[ name ] = value;
7297 delete props[ index ];
7300 hooks = jQuery.cssHooks[ name ];
7301 if ( hooks && "expand" in hooks ) {
7302 value = hooks.expand( value );
7303 delete props[ name ];
7305 // not quite $.extend, this wont overwrite keys already present.
7306 // also - reusing 'index' from above because we have the correct "name"
7307 for ( index in value ) {
7308 if ( !( index in props ) ) {
7309 props[ index ] = value[ index ];
7310 specialEasing[ index ] = easing;
7314 specialEasing[ name ] = easing;
7319 function Animation( elem, properties, options ) {
7323 length = animationPrefilters.length,
7324 deferred = jQuery.Deferred().always( function() {
7325 // don't match elem in the :animated selector
7332 var currentTime = fxNow || createFxNow(),
7333 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7334 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
7335 temp = remaining / animation.duration || 0,
7338 length = animation.tweens.length;
7340 for ( ; index < length ; index++ ) {
7341 animation.tweens[ index ].run( percent );
7344 deferred.notifyWith( elem, [ animation, percent, remaining ]);
7346 if ( percent < 1 && length ) {
7349 deferred.resolveWith( elem, [ animation ] );
7353 animation = deferred.promise({
7355 props: jQuery.extend( {}, properties ),
7356 opts: jQuery.extend( true, { specialEasing: {} }, options ),
7357 originalProperties: properties,
7358 originalOptions: options,
7359 startTime: fxNow || createFxNow(),
7360 duration: options.duration,
7362 createTween: function( prop, end ) {
7363 var tween = jQuery.Tween( elem, animation.opts, prop, end,
7364 animation.opts.specialEasing[ prop ] || animation.opts.easing );
7365 animation.tweens.push( tween );
7368 stop: function( gotoEnd ) {
7370 // if we are going to the end, we want to run all the tweens
7371 // otherwise we skip this part
7372 length = gotoEnd ? animation.tweens.length : 0;
7377 for ( ; index < length ; index++ ) {
7378 animation.tweens[ index ].run( 1 );
7381 // resolve when we played the last frame
7382 // otherwise, reject
7384 deferred.resolveWith( elem, [ animation, gotoEnd ] );
7386 deferred.rejectWith( elem, [ animation, gotoEnd ] );
7391 props = animation.props;
7393 propFilter( props, animation.opts.specialEasing );
7395 for ( ; index < length ; index++ ) {
7396 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
7402 jQuery.map( props, createTween, animation );
7404 if ( jQuery.isFunction( animation.opts.start ) ) {
7405 animation.opts.start.call( elem, animation );
7409 jQuery.extend( tick, {
7412 queue: animation.opts.queue
7416 // attach callbacks from options
7417 return animation.progress( animation.opts.progress )
7418 .done( animation.opts.done, animation.opts.complete )
7419 .fail( animation.opts.fail )
7420 .always( animation.opts.always );
7423 jQuery.Animation = jQuery.extend( Animation, {
7424 tweener: function( props, callback ) {
7425 if ( jQuery.isFunction( props ) ) {
7429 props = props.split(" ");
7434 length = props.length;
7436 for ( ; index < length ; index++ ) {
7437 prop = props[ index ];
7438 tweeners[ prop ] = tweeners[ prop ] || [];
7439 tweeners[ prop ].unshift( callback );
7443 prefilter: function( callback, prepend ) {
7445 animationPrefilters.unshift( callback );
7447 animationPrefilters.push( callback );
7452 jQuery.speed = function( speed, easing, fn ) {
7453 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7454 complete: fn || !fn && easing ||
7455 jQuery.isFunction( speed ) && speed,
7457 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
7460 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
7461 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
7463 // normalize opt.queue - true/undefined/null -> "fx"
7464 if ( opt.queue == null || opt.queue === true ) {
7469 opt.old = opt.complete;
7471 opt.complete = function() {
7472 if ( jQuery.isFunction( opt.old ) ) {
7473 opt.old.call( this );
7477 jQuery.dequeue( this, opt.queue );
7485 fadeTo: function( speed, to, easing, callback ) {
7487 // show any hidden elements after setting opacity to 0
7488 return this.filter( isHidden ).css( "opacity", 0 ).show()
7490 // animate to the value specified
7491 .end().animate({ opacity: to }, speed, easing, callback );
7493 animate: function( prop, speed, easing, callback ) {
7494 var empty = jQuery.isEmptyObject( prop ),
7495 optall = jQuery.speed( speed, easing, callback ),
7496 doAnimation = function() {
7497 // Operate on a copy of prop so per-property easing won't be lost
7498 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7500 // Empty animations, or finishing resolves immediately
7501 if ( empty || jQuery._data( this, "finish" ) ) {
7505 doAnimation.finish = doAnimation;
7507 return empty || optall.queue === false ?
7508 this.each( doAnimation ) :
7509 this.queue( optall.queue, doAnimation );
7511 stop: function( type, clearQueue, gotoEnd ) {
7512 var stopQueue = function( hooks ) {
7513 var stop = hooks.stop;
7518 if ( typeof type !== "string" ) {
7519 gotoEnd = clearQueue;
7523 if ( clearQueue && type !== false ) {
7524 this.queue( type || "fx", [] );
7527 return this.each(function() {
7529 index = type != null && type + "queueHooks",
7530 timers = jQuery.timers,
7531 data = jQuery._data( this );
7534 if ( data[ index ] && data[ index ].stop ) {
7535 stopQueue( data[ index ] );
7538 for ( index in data ) {
7539 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7540 stopQueue( data[ index ] );
7545 for ( index = timers.length; index--; ) {
7546 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
7547 timers[ index ].anim.stop( gotoEnd );
7549 timers.splice( index, 1 );
7553 // start the next in the queue if the last step wasn't forced
7554 // timers currently will call their complete callbacks, which will dequeue
7555 // but only if they were gotoEnd
7556 if ( dequeue || !gotoEnd ) {
7557 jQuery.dequeue( this, type );
7561 finish: function( type ) {
7562 if ( type !== false ) {
7563 type = type || "fx";
7565 return this.each(function() {
7567 data = jQuery._data( this ),
7568 queue = data[ type + "queue" ],
7569 hooks = data[ type + "queueHooks" ],
7570 timers = jQuery.timers,
7571 length = queue ? queue.length : 0;
7573 // enable finishing flag on private data
7576 // empty the queue first
7577 jQuery.queue( this, type, [] );
7579 if ( hooks && hooks.stop ) {
7580 hooks.stop.call( this, true );
7583 // look for any active animations, and finish them
7584 for ( index = timers.length; index--; ) {
7585 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
7586 timers[ index ].anim.stop( true );
7587 timers.splice( index, 1 );
7591 // look for any animations in the old queue and finish them
7592 for ( index = 0; index < length; index++ ) {
7593 if ( queue[ index ] && queue[ index ].finish ) {
7594 queue[ index ].finish.call( this );
7598 // turn off finishing flag
7604 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
7605 var cssFn = jQuery.fn[ name ];
7606 jQuery.fn[ name ] = function( speed, easing, callback ) {
7607 return speed == null || typeof speed === "boolean" ?
7608 cssFn.apply( this, arguments ) :
7609 this.animate( genFx( name, true ), speed, easing, callback );
7613 // Generate shortcuts for custom animations
7615 slideDown: genFx("show"),
7616 slideUp: genFx("hide"),
7617 slideToggle: genFx("toggle"),
7618 fadeIn: { opacity: "show" },
7619 fadeOut: { opacity: "hide" },
7620 fadeToggle: { opacity: "toggle" }
7621 }, function( name, props ) {
7622 jQuery.fn[ name ] = function( speed, easing, callback ) {
7623 return this.animate( props, speed, easing, callback );
7628 jQuery.fx.tick = function() {
7630 timers = jQuery.timers,
7633 fxNow = jQuery.now();
7635 for ( ; i < timers.length; i++ ) {
7636 timer = timers[ i ];
7637 // Checks the timer has not already been removed
7638 if ( !timer() && timers[ i ] === timer ) {
7639 timers.splice( i--, 1 );
7643 if ( !timers.length ) {
7649 jQuery.fx.timer = function( timer ) {
7650 jQuery.timers.push( timer );
7654 jQuery.timers.pop();
7658 jQuery.fx.interval = 13;
7660 jQuery.fx.start = function() {
7662 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
7666 jQuery.fx.stop = function() {
7667 clearInterval( timerId );
7671 jQuery.fx.speeds = {
7679 // Based off of the plugin by Clint Helfers, with permission.
7680 // http://blindsignals.com/index.php/2009/07/jquery-delay/
7681 jQuery.fn.delay = function( time, type ) {
7682 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
7683 type = type || "fx";
7685 return this.queue( type, function( next, hooks ) {
7686 var timeout = setTimeout( next, time );
7687 hooks.stop = function() {
7688 clearTimeout( timeout );
7695 var a, input, select, opt,
7696 div = document.createElement("div" );
7699 div.setAttribute( "className", "t" );
7700 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
7701 a = div.getElementsByTagName("a")[ 0 ];
7703 // First batch of tests.
7704 select = document.createElement("select");
7705 opt = select.appendChild( document.createElement("option") );
7706 input = div.getElementsByTagName("input")[ 0 ];
7708 a.style.cssText = "top:1px";
7710 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
7711 support.getSetAttribute = div.className !== "t";
7713 // Get the style information from getAttribute
7714 // (IE uses .cssText instead)
7715 support.style = /top/.test( a.getAttribute("style") );
7717 // Make sure that URLs aren't manipulated
7718 // (IE normalizes it by default)
7719 support.hrefNormalized = a.getAttribute("href") === "/a";
7721 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
7722 support.checkOn = !!input.value;
7724 // Make sure that a selected-by-default option has a working selected property.
7725 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
7726 support.optSelected = opt.selected;
7728 // Tests for enctype support on a form (#6743)
7729 support.enctype = !!document.createElement("form").enctype;
7731 // Make sure that the options inside disabled selects aren't marked as disabled
7732 // (WebKit marks them as disabled)
7733 select.disabled = true;
7734 support.optDisabled = !opt.disabled;
7736 // Support: IE8 only
7737 // Check if we can trust getAttribute("value")
7738 input = document.createElement( "input" );
7739 input.setAttribute( "value", "" );
7740 support.input = input.getAttribute( "value" ) === "";
7742 // Check if an input maintains its value after becoming a radio
7744 input.setAttribute( "type", "radio" );
7745 support.radioValue = input.value === "t";
7747 // Null elements to avoid leaks in IE.
7748 a = input = select = opt = div = null;
7752 var rreturn = /\r/g;
7755 val: function( value ) {
7756 var hooks, ret, isFunction,
7759 if ( !arguments.length ) {
7761 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
7763 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
7769 return typeof ret === "string" ?
7770 // handle most common string cases
7771 ret.replace(rreturn, "") :
7772 // handle cases where value is null/undef or number
7773 ret == null ? "" : ret;
7779 isFunction = jQuery.isFunction( value );
7781 return this.each(function( i ) {
7784 if ( this.nodeType !== 1 ) {
7789 val = value.call( this, i, jQuery( this ).val() );
7794 // Treat null/undefined as ""; convert numbers to string
7795 if ( val == null ) {
7797 } else if ( typeof val === "number" ) {
7799 } else if ( jQuery.isArray( val ) ) {
7800 val = jQuery.map( val, function( value ) {
7801 return value == null ? "" : value + "";
7805 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7807 // If set returns undefined, fall back to normal setting
7808 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
7818 get: function( elem ) {
7819 var val = jQuery.find.attr( elem, "value" );
7820 return val != null ?
7822 jQuery.text( elem );
7826 get: function( elem ) {
7828 options = elem.options,
7829 index = elem.selectedIndex,
7830 one = elem.type === "select-one" || index < 0,
7831 values = one ? null : [],
7832 max = one ? index + 1 : options.length,
7837 // Loop through all the selected options
7838 for ( ; i < max; i++ ) {
7839 option = options[ i ];
7841 // oldIE doesn't update selected after form reset (#2551)
7842 if ( ( option.selected || i === index ) &&
7843 // Don't return options that are disabled or in a disabled optgroup
7844 ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
7845 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
7847 // Get the specific value for the option
7848 value = jQuery( option ).val();
7850 // We don't need an array for one selects
7855 // Multi-Selects return an array
7856 values.push( value );
7863 set: function( elem, value ) {
7864 var optionSet, option,
7865 options = elem.options,
7866 values = jQuery.makeArray( value ),
7870 option = options[ i ];
7872 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
7875 // When new option element is added to select box we need to
7876 // force reflow of newly added node in order to workaround delay
7877 // of initialization properties
7879 option.selected = optionSet = true;
7883 // Will be executed only in IE6
7884 option.scrollHeight;
7888 option.selected = false;
7892 // Force browsers to behave consistently when non-matching value is set
7894 elem.selectedIndex = -1;
7903 // Radios and checkboxes getter/setter
7904 jQuery.each([ "radio", "checkbox" ], function() {
7905 jQuery.valHooks[ this ] = {
7906 set: function( elem, value ) {
7907 if ( jQuery.isArray( value ) ) {
7908 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
7912 if ( !support.checkOn ) {
7913 jQuery.valHooks[ this ].get = function( elem ) {
7915 // "" is returned instead of "on" if a value isn't specified
7916 return elem.getAttribute("value") === null ? "on" : elem.value;
7924 var nodeHook, boolHook,
7925 attrHandle = jQuery.expr.attrHandle,
7926 ruseDefault = /^(?:checked|selected)$/i,
7927 getSetAttribute = support.getSetAttribute,
7928 getSetInput = support.input;
7931 attr: function( name, value ) {
7932 return access( this, jQuery.attr, name, value, arguments.length > 1 );
7935 removeAttr: function( name ) {
7936 return this.each(function() {
7937 jQuery.removeAttr( this, name );
7943 attr: function( elem, name, value ) {
7945 nType = elem.nodeType;
7947 // don't get/set attributes on text, comment and attribute nodes
7948 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
7952 // Fallback to prop when attributes are not supported
7953 if ( typeof elem.getAttribute === strundefined ) {
7954 return jQuery.prop( elem, name, value );
7957 // All attributes are lowercase
7958 // Grab necessary hook if one is defined
7959 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
7960 name = name.toLowerCase();
7961 hooks = jQuery.attrHooks[ name ] ||
7962 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
7965 if ( value !== undefined ) {
7967 if ( value === null ) {
7968 jQuery.removeAttr( elem, name );
7970 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
7974 elem.setAttribute( name, value + "" );
7978 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
7982 ret = jQuery.find.attr( elem, name );
7984 // Non-existent attributes return null, we normalize to undefined
7985 return ret == null ?
7991 removeAttr: function( elem, value ) {
7994 attrNames = value && value.match( rnotwhite );
7996 if ( attrNames && elem.nodeType === 1 ) {
7997 while ( (name = attrNames[i++]) ) {
7998 propName = jQuery.propFix[ name ] || name;
8000 // Boolean attributes get special treatment (#10870)
8001 if ( jQuery.expr.match.bool.test( name ) ) {
8002 // Set corresponding property to false
8003 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8004 elem[ propName ] = false;
8006 // Also clear defaultChecked/defaultSelected (if appropriate)
8008 elem[ jQuery.camelCase( "default-" + name ) ] =
8009 elem[ propName ] = false;
8012 // See #9699 for explanation of this approach (setting first, then removal)
8014 jQuery.attr( elem, name, "" );
8017 elem.removeAttribute( getSetAttribute ? name : propName );
8024 set: function( elem, value ) {
8025 if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
8026 // Setting the type on a radio button after the value resets the value in IE6-9
8027 // Reset value to default in case type is set after value during creation
8028 var val = elem.value;
8029 elem.setAttribute( "type", value );
8040 // Hook for boolean attributes
8042 set: function( elem, value, name ) {
8043 if ( value === false ) {
8044 // Remove boolean attributes when set to false
8045 jQuery.removeAttr( elem, name );
8046 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
8047 // IE<8 needs the *property* name
8048 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
8050 // Use defaultChecked and defaultSelected for oldIE
8052 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
8059 // Retrieve booleans specially
8060 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
8062 var getter = attrHandle[ name ] || jQuery.find.attr;
8064 attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
8065 function( elem, name, isXML ) {
8068 // Avoid an infinite loop by temporarily removing this function from the getter
8069 handle = attrHandle[ name ];
8070 attrHandle[ name ] = ret;
8071 ret = getter( elem, name, isXML ) != null ?
8072 name.toLowerCase() :
8074 attrHandle[ name ] = handle;
8078 function( elem, name, isXML ) {
8080 return elem[ jQuery.camelCase( "default-" + name ) ] ?
8081 name.toLowerCase() :
8087 // fix oldIE attroperties
8088 if ( !getSetInput || !getSetAttribute ) {
8089 jQuery.attrHooks.value = {
8090 set: function( elem, value, name ) {
8091 if ( jQuery.nodeName( elem, "input" ) ) {
8092 // Does not return so that setAttribute is also used
8093 elem.defaultValue = value;
8095 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
8096 return nodeHook && nodeHook.set( elem, value, name );
8102 // IE6/7 do not support getting/setting some attributes with get/setAttribute
8103 if ( !getSetAttribute ) {
8105 // Use this for any attribute in IE6/7
8106 // This fixes almost every IE6/7 issue
8108 set: function( elem, value, name ) {
8109 // Set the existing or create a new attribute node
8110 var ret = elem.getAttributeNode( name );
8112 elem.setAttributeNode(
8113 (ret = elem.ownerDocument.createAttribute( name ))
8117 ret.value = value += "";
8119 // Break association with cloned elements by also using setAttribute (#9646)
8120 if ( name === "value" || value === elem.getAttribute( name ) ) {
8126 // Some attributes are constructed with empty-string values when not defined
8127 attrHandle.id = attrHandle.name = attrHandle.coords =
8128 function( elem, name, isXML ) {
8131 return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
8137 // Fixing value retrieval on a button requires this module
8138 jQuery.valHooks.button = {
8139 get: function( elem, name ) {
8140 var ret = elem.getAttributeNode( name );
8141 if ( ret && ret.specified ) {
8148 // Set contenteditable to false on removals(#10429)
8149 // Setting to empty string throws an error as an invalid value
8150 jQuery.attrHooks.contenteditable = {
8151 set: function( elem, value, name ) {
8152 nodeHook.set( elem, value === "" ? false : value, name );
8156 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
8157 // This is for removals
8158 jQuery.each([ "width", "height" ], function( i, name ) {
8159 jQuery.attrHooks[ name ] = {
8160 set: function( elem, value ) {
8161 if ( value === "" ) {
8162 elem.setAttribute( name, "auto" );
8170 if ( !support.style ) {
8171 jQuery.attrHooks.style = {
8172 get: function( elem ) {
8173 // Return undefined in the case of empty string
8174 // Note: IE uppercases css property names, but if we were to .toLowerCase()
8175 // .cssText, that would destroy case senstitivity in URL's, like in "background"
8176 return elem.style.cssText || undefined;
8178 set: function( elem, value ) {
8179 return ( elem.style.cssText = value + "" );
8187 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
8188 rclickable = /^(?:a|area)$/i;
8191 prop: function( name, value ) {
8192 return access( this, jQuery.prop, name, value, arguments.length > 1 );
8195 removeProp: function( name ) {
8196 name = jQuery.propFix[ name ] || name;
8197 return this.each(function() {
8198 // try/catch handles cases where IE balks (such as removing a property on window)
8200 this[ name ] = undefined;
8201 delete this[ name ];
8210 "class": "className"
8213 prop: function( elem, name, value ) {
8214 var ret, hooks, notxml,
8215 nType = elem.nodeType;
8217 // don't get/set properties on text, comment and attribute nodes
8218 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
8222 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
8225 // Fix name and attach hooks
8226 name = jQuery.propFix[ name ] || name;
8227 hooks = jQuery.propHooks[ name ];
8230 if ( value !== undefined ) {
8231 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
8233 ( elem[ name ] = value );
8236 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
8244 get: function( elem ) {
8245 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
8246 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
8247 // Use proper attribute retrieval(#12072)
8248 var tabindex = jQuery.find.attr( elem, "tabindex" );
8251 parseInt( tabindex, 10 ) :
8252 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
8260 // Some attributes require a special call on IE
8261 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
8262 if ( !support.hrefNormalized ) {
8263 // href/src property should get the full normalized URL (#10299/#12915)
8264 jQuery.each([ "href", "src" ], function( i, name ) {
8265 jQuery.propHooks[ name ] = {
8266 get: function( elem ) {
8267 return elem.getAttribute( name, 4 );
8273 // Support: Safari, IE9+
8274 // mis-reports the default selected property of an option
8275 // Accessing the parent's selectedIndex property fixes it
8276 if ( !support.optSelected ) {
8277 jQuery.propHooks.selected = {
8278 get: function( elem ) {
8279 var parent = elem.parentNode;
8282 parent.selectedIndex;
8284 // Make sure that it also works with optgroups, see #5701
8285 if ( parent.parentNode ) {
8286 parent.parentNode.selectedIndex;
8306 jQuery.propFix[ this.toLowerCase() ] = this;
8309 // IE6/7 call enctype encoding
8310 if ( !support.enctype ) {
8311 jQuery.propFix.enctype = "encoding";
8317 var rclass = /[\t\r\n\f]/g;
8320 addClass: function( value ) {
8321 var classes, elem, cur, clazz, j, finalValue,
8324 proceed = typeof value === "string" && value;
8326 if ( jQuery.isFunction( value ) ) {
8327 return this.each(function( j ) {
8328 jQuery( this ).addClass( value.call( this, j, this.className ) );
8333 // The disjunction here is for better compressibility (see removeClass)
8334 classes = ( value || "" ).match( rnotwhite ) || [];
8336 for ( ; i < len; i++ ) {
8338 cur = elem.nodeType === 1 && ( elem.className ?
8339 ( " " + elem.className + " " ).replace( rclass, " " ) :
8345 while ( (clazz = classes[j++]) ) {
8346 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
8351 // only assign if different to avoid unneeded rendering.
8352 finalValue = jQuery.trim( cur );
8353 if ( elem.className !== finalValue ) {
8354 elem.className = finalValue;
8363 removeClass: function( value ) {
8364 var classes, elem, cur, clazz, j, finalValue,
8367 proceed = arguments.length === 0 || typeof value === "string" && value;
8369 if ( jQuery.isFunction( value ) ) {
8370 return this.each(function( j ) {
8371 jQuery( this ).removeClass( value.call( this, j, this.className ) );
8375 classes = ( value || "" ).match( rnotwhite ) || [];
8377 for ( ; i < len; i++ ) {
8379 // This expression is here for better compressibility (see addClass)
8380 cur = elem.nodeType === 1 && ( elem.className ?
8381 ( " " + elem.className + " " ).replace( rclass, " " ) :
8387 while ( (clazz = classes[j++]) ) {
8388 // Remove *all* instances
8389 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
8390 cur = cur.replace( " " + clazz + " ", " " );
8394 // only assign if different to avoid unneeded rendering.
8395 finalValue = value ? jQuery.trim( cur ) : "";
8396 if ( elem.className !== finalValue ) {
8397 elem.className = finalValue;
8406 toggleClass: function( value, stateVal ) {
8407 var type = typeof value;
8409 if ( typeof stateVal === "boolean" && type === "string" ) {
8410 return stateVal ? this.addClass( value ) : this.removeClass( value );
8413 if ( jQuery.isFunction( value ) ) {
8414 return this.each(function( i ) {
8415 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
8419 return this.each(function() {
8420 if ( type === "string" ) {
8421 // toggle individual class names
8424 self = jQuery( this ),
8425 classNames = value.match( rnotwhite ) || [];
8427 while ( (className = classNames[ i++ ]) ) {
8428 // check each className given, space separated list
8429 if ( self.hasClass( className ) ) {
8430 self.removeClass( className );
8432 self.addClass( className );
8436 // Toggle whole class name
8437 } else if ( type === strundefined || type === "boolean" ) {
8438 if ( this.className ) {
8439 // store className if set
8440 jQuery._data( this, "__className__", this.className );
8443 // If the element has a class name or if we're passed "false",
8444 // then remove the whole classname (if there was one, the above saved it).
8445 // Otherwise bring back whatever was previously saved (if anything),
8446 // falling back to the empty string if nothing was stored.
8447 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
8452 hasClass: function( selector ) {
8453 var className = " " + selector + " ",
8456 for ( ; i < l; i++ ) {
8457 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
8469 // Return jQuery for attributes-only inclusion
8472 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
8473 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
8474 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
8476 // Handle event binding
8477 jQuery.fn[ name ] = function( data, fn ) {
8478 return arguments.length > 0 ?
8479 this.on( name, null, data, fn ) :
8480 this.trigger( name );
8485 hover: function( fnOver, fnOut ) {
8486 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
8489 bind: function( types, data, fn ) {
8490 return this.on( types, null, data, fn );
8492 unbind: function( types, fn ) {
8493 return this.off( types, null, fn );
8496 delegate: function( selector, types, data, fn ) {
8497 return this.on( types, selector, data, fn );
8499 undelegate: function( selector, types, fn ) {
8500 // ( namespace ) or ( selector, types [, fn] )
8501 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
8506 var nonce = jQuery.now();
8508 var rquery = (/\?/);
8512 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
8514 jQuery.parseJSON = function( data ) {
8515 // Attempt to parse using the native JSON parser first
8516 if ( window.JSON && window.JSON.parse ) {
8517 // Support: Android 2.3
8518 // Workaround failure to string-cast null input
8519 return window.JSON.parse( data + "" );
8522 var requireNonComma,
8524 str = jQuery.trim( data + "" );
8526 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
8527 // after removing valid tokens
8528 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
8530 // Force termination if we see a misplaced comma
8531 if ( requireNonComma && comma ) {
8535 // Perform no more replacements after returning to outermost depth
8536 if ( depth === 0 ) {
8540 // Commas must not follow "[", "{", or ","
8541 requireNonComma = open || comma;
8543 // Determine new depth
8544 // array/object open ("[" or "{"): depth += true - false (increment)
8545 // array/object close ("]" or "}"): depth += false - true (decrement)
8546 // other cases ("," or primitive): depth += true - true (numeric cast)
8547 depth += !close - !open;
8549 // Remove this token
8552 ( Function( "return " + str ) )() :
8553 jQuery.error( "Invalid JSON: " + data );
8557 // Cross-browser xml parsing
8558 jQuery.parseXML = function( data ) {
8560 if ( !data || typeof data !== "string" ) {
8564 if ( window.DOMParser ) { // Standard
8565 tmp = new DOMParser();
8566 xml = tmp.parseFromString( data, "text/xml" );
8568 xml = new ActiveXObject( "Microsoft.XMLDOM" );
8569 xml.async = "false";
8570 xml.loadXML( data );
8575 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
8576 jQuery.error( "Invalid XML: " + data );
8583 // Document location
8588 rts = /([?&])_=[^&]*/,
8589 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
8590 // #7653, #8125, #8152: local protocol detection
8591 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
8592 rnoContent = /^(?:GET|HEAD)$/,
8593 rprotocol = /^\/\//,
8594 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
8597 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
8598 * 2) These are called:
8599 * - BEFORE asking for a transport
8600 * - AFTER param serialization (s.data is a string if s.processData is true)
8601 * 3) key is the dataType
8602 * 4) the catchall symbol "*" can be used
8603 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
8607 /* Transports bindings
8608 * 1) key is the dataType
8609 * 2) the catchall symbol "*" can be used
8610 * 3) selection will start with transport dataType and THEN go to "*" if needed
8614 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
8615 allTypes = "*/".concat("*");
8617 // #8138, IE may throw an exception when accessing
8618 // a field from window.location if document.domain has been set
8620 ajaxLocation = location.href;
8622 // Use the href attribute of an A element
8623 // since IE will modify it given document.location
8624 ajaxLocation = document.createElement( "a" );
8625 ajaxLocation.href = "";
8626 ajaxLocation = ajaxLocation.href;
8629 // Segment location into parts
8630 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
8632 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
8633 function addToPrefiltersOrTransports( structure ) {
8635 // dataTypeExpression is optional and defaults to "*"
8636 return function( dataTypeExpression, func ) {
8638 if ( typeof dataTypeExpression !== "string" ) {
8639 func = dataTypeExpression;
8640 dataTypeExpression = "*";
8645 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
8647 if ( jQuery.isFunction( func ) ) {
8648 // For each dataType in the dataTypeExpression
8649 while ( (dataType = dataTypes[i++]) ) {
8650 // Prepend if requested
8651 if ( dataType.charAt( 0 ) === "+" ) {
8652 dataType = dataType.slice( 1 ) || "*";
8653 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
8657 (structure[ dataType ] = structure[ dataType ] || []).push( func );
8664 // Base inspection function for prefilters and transports
8665 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
8668 seekingTransport = ( structure === transports );
8670 function inspect( dataType ) {
8672 inspected[ dataType ] = true;
8673 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
8674 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
8675 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
8676 options.dataTypes.unshift( dataTypeOrTransport );
8677 inspect( dataTypeOrTransport );
8679 } else if ( seekingTransport ) {
8680 return !( selected = dataTypeOrTransport );
8686 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
8689 // A special extend for ajax options
8690 // that takes "flat" options (not to be deep extended)
8692 function ajaxExtend( target, src ) {
8694 flatOptions = jQuery.ajaxSettings.flatOptions || {};
8696 for ( key in src ) {
8697 if ( src[ key ] !== undefined ) {
8698 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
8702 jQuery.extend( true, target, deep );
8708 /* Handles responses to an ajax request:
8709 * - finds the right dataType (mediates between content-type and expected dataType)
8710 * - returns the corresponding response
8712 function ajaxHandleResponses( s, jqXHR, responses ) {
8713 var firstDataType, ct, finalDataType, type,
8714 contents = s.contents,
8715 dataTypes = s.dataTypes;
8717 // Remove auto dataType and get content-type in the process
8718 while ( dataTypes[ 0 ] === "*" ) {
8720 if ( ct === undefined ) {
8721 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
8725 // Check if we're dealing with a known content-type
8727 for ( type in contents ) {
8728 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8729 dataTypes.unshift( type );
8735 // Check to see if we have a response for the expected dataType
8736 if ( dataTypes[ 0 ] in responses ) {
8737 finalDataType = dataTypes[ 0 ];
8739 // Try convertible dataTypes
8740 for ( type in responses ) {
8741 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8742 finalDataType = type;
8745 if ( !firstDataType ) {
8746 firstDataType = type;
8749 // Or just use first one
8750 finalDataType = finalDataType || firstDataType;
8753 // If we found a dataType
8754 // We add the dataType to the list if needed
8755 // and return the corresponding response
8756 if ( finalDataType ) {
8757 if ( finalDataType !== dataTypes[ 0 ] ) {
8758 dataTypes.unshift( finalDataType );
8760 return responses[ finalDataType ];
8764 /* Chain conversions given the request and the original response
8765 * Also sets the responseXXX fields on the jqXHR instance
8767 function ajaxConvert( s, response, jqXHR, isSuccess ) {
8768 var conv2, current, conv, tmp, prev,
8770 // Work with a copy of dataTypes in case we need to modify it for conversion
8771 dataTypes = s.dataTypes.slice();
8773 // Create converters map with lowercased keys
8774 if ( dataTypes[ 1 ] ) {
8775 for ( conv in s.converters ) {
8776 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8780 current = dataTypes.shift();
8782 // Convert to each sequential dataType
8785 if ( s.responseFields[ current ] ) {
8786 jqXHR[ s.responseFields[ current ] ] = response;
8789 // Apply the dataFilter if provided
8790 if ( !prev && isSuccess && s.dataFilter ) {
8791 response = s.dataFilter( response, s.dataType );
8795 current = dataTypes.shift();
8799 // There's only work to do if current dataType is non-auto
8800 if ( current === "*" ) {
8804 // Convert response if prev dataType is non-auto and differs from current
8805 } else if ( prev !== "*" && prev !== current ) {
8807 // Seek a direct converter
8808 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8810 // If none found, seek a pair
8812 for ( conv2 in converters ) {
8814 // If conv2 outputs current
8815 tmp = conv2.split( " " );
8816 if ( tmp[ 1 ] === current ) {
8818 // If prev can be converted to accepted input
8819 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8820 converters[ "* " + tmp[ 0 ] ];
8822 // Condense equivalence converters
8823 if ( conv === true ) {
8824 conv = converters[ conv2 ];
8826 // Otherwise, insert the intermediate dataType
8827 } else if ( converters[ conv2 ] !== true ) {
8829 dataTypes.unshift( tmp[ 1 ] );
8837 // Apply converter (if not an equivalence)
8838 if ( conv !== true ) {
8840 // Unless errors are allowed to bubble, catch and return them
8841 if ( conv && s[ "throws" ] ) {
8842 response = conv( response );
8845 response = conv( response );
8847 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8855 return { state: "success", data: response };
8860 // Counter for holding the number of active queries
8863 // Last-Modified header cache for next request
8870 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
8874 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
8891 xml: "application/xml, text/xml",
8892 json: "application/json, text/javascript"
8903 text: "responseText",
8904 json: "responseJSON"
8908 // Keys separate source (or catchall "*") and destination types with a single space
8911 // Convert anything to text
8914 // Text to html (true = no transformation)
8917 // Evaluate text as a json expression
8918 "text json": jQuery.parseJSON,
8920 // Parse text as xml
8921 "text xml": jQuery.parseXML
8924 // For options that shouldn't be deep extended:
8925 // you can add your own custom options here if
8926 // and when you create one that shouldn't be
8927 // deep extended (see ajaxExtend)
8934 // Creates a full fledged settings object into target
8935 // with both ajaxSettings and settings fields.
8936 // If target is omitted, writes into ajaxSettings.
8937 ajaxSetup: function( target, settings ) {
8940 // Building a settings object
8941 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
8943 // Extending ajaxSettings
8944 ajaxExtend( jQuery.ajaxSettings, target );
8947 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
8948 ajaxTransport: addToPrefiltersOrTransports( transports ),
8951 ajax: function( url, options ) {
8953 // If url is an object, simulate pre-1.5 signature
8954 if ( typeof url === "object" ) {
8959 // Force options to be an object
8960 options = options || {};
8962 var // Cross-domain detection vars
8966 // URL without anti-cache param
8968 // Response headers as string
8969 responseHeadersString,
8973 // To know if global events are to be dispatched
8979 // Create the final options object
8980 s = jQuery.ajaxSetup( {}, options ),
8981 // Callbacks context
8982 callbackContext = s.context || s,
8983 // Context for global events is callbackContext if it is a DOM node or jQuery collection
8984 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
8985 jQuery( callbackContext ) :
8988 deferred = jQuery.Deferred(),
8989 completeDeferred = jQuery.Callbacks("once memory"),
8990 // Status-dependent callbacks
8991 statusCode = s.statusCode || {},
8992 // Headers (they are sent all at once)
8993 requestHeaders = {},
8994 requestHeadersNames = {},
8997 // Default abort message
8998 strAbort = "canceled",
9003 // Builds headers hashtable if needed
9004 getResponseHeader: function( key ) {
9006 if ( state === 2 ) {
9007 if ( !responseHeaders ) {
9008 responseHeaders = {};
9009 while ( (match = rheaders.exec( responseHeadersString )) ) {
9010 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
9013 match = responseHeaders[ key.toLowerCase() ];
9015 return match == null ? null : match;
9019 getAllResponseHeaders: function() {
9020 return state === 2 ? responseHeadersString : null;
9023 // Caches the header
9024 setRequestHeader: function( name, value ) {
9025 var lname = name.toLowerCase();
9027 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
9028 requestHeaders[ name ] = value;
9033 // Overrides response content-type header
9034 overrideMimeType: function( type ) {
9041 // Status-dependent callbacks
9042 statusCode: function( map ) {
9046 for ( code in map ) {
9047 // Lazy-add the new callback in a way that preserves old ones
9048 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
9051 // Execute the appropriate callbacks
9052 jqXHR.always( map[ jqXHR.status ] );
9058 // Cancel the request
9059 abort: function( statusText ) {
9060 var finalText = statusText || strAbort;
9062 transport.abort( finalText );
9064 done( 0, finalText );
9070 deferred.promise( jqXHR ).complete = completeDeferred.add;
9071 jqXHR.success = jqXHR.done;
9072 jqXHR.error = jqXHR.fail;
9074 // Remove hash character (#7531: and string promotion)
9075 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
9076 // Handle falsy url in the settings object (#10093: consistency with old signature)
9077 // We also use the url parameter if available
9078 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
9080 // Alias method option to type as per ticket #12004
9081 s.type = options.method || options.type || s.method || s.type;
9083 // Extract dataTypes list
9084 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
9086 // A cross-domain request is in order when we have a protocol:host:port mismatch
9087 if ( s.crossDomain == null ) {
9088 parts = rurl.exec( s.url.toLowerCase() );
9089 s.crossDomain = !!( parts &&
9090 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
9091 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
9092 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
9096 // Convert data if not already a string
9097 if ( s.data && s.processData && typeof s.data !== "string" ) {
9098 s.data = jQuery.param( s.data, s.traditional );
9102 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9104 // If request was aborted inside a prefilter, stop there
9105 if ( state === 2 ) {
9109 // We can fire global events as of now if asked to
9110 fireGlobals = s.global;
9112 // Watch for a new set of requests
9113 if ( fireGlobals && jQuery.active++ === 0 ) {
9114 jQuery.event.trigger("ajaxStart");
9117 // Uppercase the type
9118 s.type = s.type.toUpperCase();
9120 // Determine if request has content
9121 s.hasContent = !rnoContent.test( s.type );
9123 // Save the URL in case we're toying with the If-Modified-Since
9124 // and/or If-None-Match header later on
9127 // More options handling for requests with no content
9128 if ( !s.hasContent ) {
9130 // If data is available, append data to url
9132 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
9133 // #9682: remove data so that it's not used in an eventual retry
9137 // Add anti-cache in url if needed
9138 if ( s.cache === false ) {
9139 s.url = rts.test( cacheURL ) ?
9141 // If there is already a '_' parameter, set its value
9142 cacheURL.replace( rts, "$1_=" + nonce++ ) :
9144 // Otherwise add one to the end
9145 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
9149 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9150 if ( s.ifModified ) {
9151 if ( jQuery.lastModified[ cacheURL ] ) {
9152 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9154 if ( jQuery.etag[ cacheURL ] ) {
9155 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9159 // Set the correct header, if data is being sent
9160 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9161 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9164 // Set the Accepts header for the server, depending on the dataType
9165 jqXHR.setRequestHeader(
9167 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
9168 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9172 // Check for headers option
9173 for ( i in s.headers ) {
9174 jqXHR.setRequestHeader( i, s.headers[ i ] );
9177 // Allow custom headers/mimetypes and early abort
9178 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
9179 // Abort if not done already and return
9180 return jqXHR.abort();
9183 // aborting is no longer a cancellation
9186 // Install callbacks on deferreds
9187 for ( i in { success: 1, error: 1, complete: 1 } ) {
9188 jqXHR[ i ]( s[ i ] );
9192 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9194 // If no transport, we auto-abort
9196 done( -1, "No Transport" );
9198 jqXHR.readyState = 1;
9200 // Send global event
9201 if ( fireGlobals ) {
9202 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9205 if ( s.async && s.timeout > 0 ) {
9206 timeoutTimer = setTimeout(function() {
9207 jqXHR.abort("timeout");
9213 transport.send( requestHeaders, done );
9215 // Propagate exception as error if not done
9218 // Simply rethrow otherwise
9225 // Callback for when everything is done
9226 function done( status, nativeStatusText, responses, headers ) {
9227 var isSuccess, success, error, response, modified,
9228 statusText = nativeStatusText;
9231 if ( state === 2 ) {
9235 // State is "done" now
9238 // Clear timeout if it exists
9239 if ( timeoutTimer ) {
9240 clearTimeout( timeoutTimer );
9243 // Dereference transport for early garbage collection
9244 // (no matter how long the jqXHR object will be used)
9245 transport = undefined;
9247 // Cache response headers
9248 responseHeadersString = headers || "";
9251 jqXHR.readyState = status > 0 ? 4 : 0;
9253 // Determine if successful
9254 isSuccess = status >= 200 && status < 300 || status === 304;
9256 // Get response data
9258 response = ajaxHandleResponses( s, jqXHR, responses );
9261 // Convert no matter what (that way responseXXX fields are always set)
9262 response = ajaxConvert( s, response, jqXHR, isSuccess );
9264 // If successful, handle type chaining
9267 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9268 if ( s.ifModified ) {
9269 modified = jqXHR.getResponseHeader("Last-Modified");
9271 jQuery.lastModified[ cacheURL ] = modified;
9273 modified = jqXHR.getResponseHeader("etag");
9275 jQuery.etag[ cacheURL ] = modified;
9280 if ( status === 204 || s.type === "HEAD" ) {
9281 statusText = "nocontent";
9284 } else if ( status === 304 ) {
9285 statusText = "notmodified";
9287 // If we have data, let's convert it
9289 statusText = response.state;
9290 success = response.data;
9291 error = response.error;
9295 // We extract error from statusText
9296 // then normalize statusText and status for non-aborts
9298 if ( status || !statusText ) {
9299 statusText = "error";
9306 // Set data for the fake xhr object
9307 jqXHR.status = status;
9308 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9312 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9314 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9317 // Status-dependent callbacks
9318 jqXHR.statusCode( statusCode );
9319 statusCode = undefined;
9321 if ( fireGlobals ) {
9322 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9323 [ jqXHR, s, isSuccess ? success : error ] );
9327 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9329 if ( fireGlobals ) {
9330 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9331 // Handle the global AJAX counter
9332 if ( !( --jQuery.active ) ) {
9333 jQuery.event.trigger("ajaxStop");
9341 getJSON: function( url, data, callback ) {
9342 return jQuery.get( url, data, callback, "json" );
9345 getScript: function( url, callback ) {
9346 return jQuery.get( url, undefined, callback, "script" );
9350 jQuery.each( [ "get", "post" ], function( i, method ) {
9351 jQuery[ method ] = function( url, data, callback, type ) {
9352 // shift arguments if data argument was omitted
9353 if ( jQuery.isFunction( data ) ) {
9354 type = type || callback;
9359 return jQuery.ajax({
9369 // Attach a bunch of functions for handling common AJAX events
9370 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
9371 jQuery.fn[ type ] = function( fn ) {
9372 return this.on( type, fn );
9377 jQuery._evalUrl = function( url ) {
9378 return jQuery.ajax({
9390 wrapAll: function( html ) {
9391 if ( jQuery.isFunction( html ) ) {
9392 return this.each(function(i) {
9393 jQuery(this).wrapAll( html.call(this, i) );
9398 // The elements to wrap the target around
9399 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
9401 if ( this[0].parentNode ) {
9402 wrap.insertBefore( this[0] );
9405 wrap.map(function() {
9408 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
9409 elem = elem.firstChild;
9419 wrapInner: function( html ) {
9420 if ( jQuery.isFunction( html ) ) {
9421 return this.each(function(i) {
9422 jQuery(this).wrapInner( html.call(this, i) );
9426 return this.each(function() {
9427 var self = jQuery( this ),
9428 contents = self.contents();
9430 if ( contents.length ) {
9431 contents.wrapAll( html );
9434 self.append( html );
9439 wrap: function( html ) {
9440 var isFunction = jQuery.isFunction( html );
9442 return this.each(function(i) {
9443 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
9447 unwrap: function() {
9448 return this.parent().each(function() {
9449 if ( !jQuery.nodeName( this, "body" ) ) {
9450 jQuery( this ).replaceWith( this.childNodes );
9457 jQuery.expr.filters.hidden = function( elem ) {
9458 // Support: Opera <= 12.12
9459 // Opera reports offsetWidths and offsetHeights less than zero on some elements
9460 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
9461 (!support.reliableHiddenOffsets() &&
9462 ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
9465 jQuery.expr.filters.visible = function( elem ) {
9466 return !jQuery.expr.filters.hidden( elem );
9475 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
9476 rsubmittable = /^(?:input|select|textarea|keygen)/i;
9478 function buildParams( prefix, obj, traditional, add ) {
9481 if ( jQuery.isArray( obj ) ) {
9482 // Serialize array item.
9483 jQuery.each( obj, function( i, v ) {
9484 if ( traditional || rbracket.test( prefix ) ) {
9485 // Treat each array item as a scalar.
9489 // Item is non-scalar (array or object), encode its numeric index.
9490 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
9494 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
9495 // Serialize object item.
9496 for ( name in obj ) {
9497 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
9501 // Serialize scalar item.
9506 // Serialize an array of form elements or a set of
9507 // key/values into a query string
9508 jQuery.param = function( a, traditional ) {
9511 add = function( key, value ) {
9512 // If value is a function, invoke it and return its value
9513 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
9514 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
9517 // Set traditional to true for jQuery <= 1.3.2 behavior.
9518 if ( traditional === undefined ) {
9519 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
9522 // If an array was passed in, assume that it is an array of form elements.
9523 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
9524 // Serialize the form elements
9525 jQuery.each( a, function() {
9526 add( this.name, this.value );
9530 // If traditional, encode the "old" way (the way 1.3.2 or older
9531 // did it), otherwise encode params recursively.
9532 for ( prefix in a ) {
9533 buildParams( prefix, a[ prefix ], traditional, add );
9537 // Return the resulting serialization
9538 return s.join( "&" ).replace( r20, "+" );
9542 serialize: function() {
9543 return jQuery.param( this.serializeArray() );
9545 serializeArray: function() {
9546 return this.map(function() {
9547 // Can add propHook for "elements" to filter or add form elements
9548 var elements = jQuery.prop( this, "elements" );
9549 return elements ? jQuery.makeArray( elements ) : this;
9551 .filter(function() {
9552 var type = this.type;
9553 // Use .is(":disabled") so that fieldset[disabled] works
9554 return this.name && !jQuery( this ).is( ":disabled" ) &&
9555 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
9556 ( this.checked || !rcheckableType.test( type ) );
9558 .map(function( i, elem ) {
9559 var val = jQuery( this ).val();
9561 return val == null ?
9563 jQuery.isArray( val ) ?
9564 jQuery.map( val, function( val ) {
9565 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9567 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9573 // Create the request object
9574 // (This is still attached to ajaxSettings for backward compatibility)
9575 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
9579 // XHR cannot access local files, always use ActiveX for that case
9580 return !this.isLocal &&
9583 // oldIE XHR does not support non-RFC2616 methods (#13240)
9584 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
9585 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
9586 // Although this check for six methods instead of eight
9587 // since IE also does not support "trace" and "connect"
9588 /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
9590 createStandardXHR() || createActiveXHR();
9592 // For all other browsers, use the standard XMLHttpRequest object
9597 function createXHR(isMSIE) {
9599 return (isMSIE ? new window.ActiveXObject( "Microsoft.XMLHTTP" ) : new window.XMLHttpRequest());
9603 jQuery.ajaxSettings.xhr = (window.ActiveXObject === undefined ? createXHR :
9605 return (this.url == document.location || this.url.indexOf("http") == 0 || !this.isLocal) && // BH MSIE fix
9606 /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
9607 createXHR() || createXHR(1);
9615 xhrSupported = jQuery.ajaxSettings.xhr();
9618 // Open requests must be manually aborted on unload (#5280)
9619 if ( window.ActiveXObject ) {
9620 jQuery( window ).on( "unload", function() {
9621 for ( var key in xhrCallbacks ) {
9622 xhrCallbacks[ key ]( undefined, true );
9627 // Determine support properties
9628 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
9629 xhrSupported = support.ajax = !!xhrSupported;
9631 // Create transport if the browser can provide an xhr
9632 if ( xhrSupported ) {
9634 jQuery.ajaxTransport(function( options ) {
9635 // Cross domain only allowed if supported through XMLHttpRequest
9636 if ( !options.crossDomain || support.cors ) {
9641 send: function( headers, complete ) {
9643 xhr = options.xhr(),
9647 console.log("xhr.open async=" + options.async + " url=" + options.url);
9648 xhr.open( options.type, options.url, options.async, options.username, options.password );
9650 // Apply custom fields if provided
9651 if ( options.xhrFields ) {
9652 for ( i in options.xhrFields ) {
9653 xhr[ i ] = options.xhrFields[ i ];
9657 // Override mime type if needed
9658 if ( options.mimeType && xhr.overrideMimeType ) {
9659 xhr.overrideMimeType( options.mimeType );
9662 // X-Requested-With header
9663 // For cross-domain requests, seeing as conditions for a preflight are
9664 // akin to a jigsaw puzzle, we simply never set it to be sure.
9665 // (it can always be set on a per-request basis or even using ajaxSetup)
9666 // For same-domain requests, won't change header if already provided.
9667 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
9668 headers["X-Requested-With"] = "XMLHttpRequest";
9672 for ( i in headers ) {
9674 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
9675 // request header to a null-value.
9677 // To keep consistent with other XHR implementations, cast the value
9678 // to string and ignore `undefined`.
9679 if ( headers[ i ] !== undefined ) {
9680 xhr.setRequestHeader( i, headers[ i ] + "" );
9684 // Do send the request
9685 // This may raise an exception which is actually
9686 // handled in jQuery.ajax (so no try/catch here)
9687 xhr.send( ( options.hasContent && options.data ) || null );
9690 callback = function( _, isAbort ) {
9691 var status, statusText, responses;
9693 // Was never called and is aborted or complete
9694 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
9696 delete xhrCallbacks[ id ];
9697 callback = undefined;
9698 xhr.onreadystatechange = jQuery.noop;
9700 // Abort manually if needed
9702 if ( xhr.readyState !== 4 ) {
9707 status = xhr.status;
9710 // Accessing binary-data responseText throws an exception
9712 if ( typeof xhr.responseText === "string" ) {
9713 responses.text = xhr.responseText;
9716 // Firefox throws an exception when accessing
9717 // statusText for faulty cross-domain requests
9719 statusText = xhr.statusText;
9721 // We normalize with Webkit giving an empty statusText
9725 // Filter status for non standard behaviors
9727 // If the request is local and we have data: assume a success
9728 // (success with no data won't get notified, that's the best we
9729 // can do given current implementations)
9730 if ( !status && options.isLocal && !options.crossDomain ) {
9731 status = responses.text ? 200 : 404;
9732 // IE - #1450: sometimes returns 1223 when it should be 204
9733 } else if ( status === 1223 ) {
9739 // Call complete if needed
9741 complete( status, statusText, responses, xhr.getAllResponseHeaders() );
9745 if ( !options.async ) {
9746 // if we're in sync mode we fire the callback
9748 } else if ( xhr.readyState === 4 ) {
9749 // (IE6 & IE7) if it's in cache and has been
9750 // retrieved directly we need to fire the callback
9751 setTimeout( callback );
9753 // Add to the list of active xhr callbacks
9754 xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
9760 callback( undefined, true );
9768 // Functions to create xhrs
9769 function createStandardXHR() {
9771 return new window.XMLHttpRequest();
9775 function createActiveXHR() {
9777 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
9784 // Install script dataType
9787 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
9790 script: /(?:java|ecma)script/
9793 "text script": function( text ) {
9794 jQuery.globalEval( text );
9800 // Handle cache's special case and global
9801 jQuery.ajaxPrefilter( "script", function( s ) {
9802 if ( s.cache === undefined ) {
9805 if ( s.crossDomain ) {
9811 // Bind script tag hack transport
9812 jQuery.ajaxTransport( "script", function(s) {
9814 // This transport only deals with cross domain requests
9815 if ( s.crossDomain ) {
9818 head = document.head || jQuery("head")[0] || document.documentElement;
9822 send: function( _, callback ) {
9824 script = document.createElement("script");
9826 script.async = true;
9828 if ( s.scriptCharset ) {
9829 script.charset = s.scriptCharset;
9834 // Attach handlers for all browsers
9835 script.onload = script.onreadystatechange = function( _, isAbort ) {
9837 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
9839 // Handle memory leak in IE
9840 script.onload = script.onreadystatechange = null;
9842 // Remove the script
9843 if ( script.parentNode ) {
9844 script.parentNode.removeChild( script );
9847 // Dereference the script
9850 // Callback if not abort
9852 callback( 200, "success" );
9857 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
9858 // Use native DOM manipulation to avoid our domManip AJAX trickery
9859 head.insertBefore( script, head.firstChild );
9864 script.onload( undefined, true );
9874 var oldCallbacks = [],
9875 rjsonp = /(=)\?(?=&|$)|\?\?/;
9877 // Default jsonp settings
9880 jsonpCallback: function() {
9881 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
9882 this[ callback ] = true;
9887 // Detect, normalize options and install callbacks for jsonp requests
9888 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
9890 var callbackName, overwritten, responseContainer,
9891 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
9893 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
9896 // Handle iff the expected data type is "jsonp" or we have a parameter to set
9897 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
9899 // Get callback name, remembering preexisting value associated with it
9900 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
9904 // Insert callback into url or form data
9906 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
9907 } else if ( s.jsonp !== false ) {
9908 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
9911 // Use data converter to retrieve json after script execution
9912 s.converters["script json"] = function() {
9913 if ( !responseContainer ) {
9914 jQuery.error( callbackName + " was not called" );
9916 return responseContainer[ 0 ];
9919 // force json dataType
9920 s.dataTypes[ 0 ] = "json";
9923 overwritten = window[ callbackName ];
9924 window[ callbackName ] = function() {
9925 responseContainer = arguments;
9928 // Clean-up function (fires after converters)
9929 jqXHR.always(function() {
9930 // Restore preexisting value
9931 window[ callbackName ] = overwritten;
9933 // Save back as free
9934 if ( s[ callbackName ] ) {
9935 // make sure that re-using the options doesn't screw things around
9936 s.jsonpCallback = originalSettings.jsonpCallback;
9938 // save the callback name for future use
9939 oldCallbacks.push( callbackName );
9942 // Call if it was a function and we have a response
9943 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
9944 overwritten( responseContainer[ 0 ] );
9947 responseContainer = overwritten = undefined;
9950 // Delegate to script
9958 // data: string of html
9959 // context (optional): If specified, the fragment will be created in this context, defaults to document
9960 // keepScripts (optional): If true, will include scripts passed in the html string
9961 jQuery.parseHTML = function( data, context, keepScripts ) {
9962 if ( !data || typeof data !== "string" ) {
9965 if ( typeof context === "boolean" ) {
9966 keepScripts = context;
9969 context = context || document;
9971 var parsed = rsingleTag.exec( data ),
9972 scripts = !keepScripts && [];
9976 return [ context.createElement( parsed[1] ) ];
9979 parsed = jQuery.buildFragment( [ data ], context, scripts );
9981 if ( scripts && scripts.length ) {
9982 jQuery( scripts ).remove();
9985 return jQuery.merge( [], parsed.childNodes );
9989 // Keep a copy of the old load method
9990 var _load = jQuery.fn.load;
9993 * Load a url into a page
9995 jQuery.fn.load = function( url, params, callback ) {
9996 if ( typeof url !== "string" && _load ) {
9997 return _load.apply( this, arguments );
10000 var selector, response, type,
10002 off = url.indexOf(" ");
10005 selector = url.slice( off, url.length );
10006 url = url.slice( 0, off );
10009 // If it's a function
10010 if ( jQuery.isFunction( params ) ) {
10012 // We assume that it's the callback
10014 params = undefined;
10016 // Otherwise, build a param string
10017 } else if ( params && typeof params === "object" ) {
10021 // If we have elements to modify, make the request
10022 if ( self.length > 0 ) {
10026 // if "type" variable is undefined, then "GET" method will be used
10030 }).done(function( responseText ) {
10032 // Save response for use in complete callback
10033 response = arguments;
10035 self.html( selector ?
10037 // If a selector was specified, locate the right elements in a dummy div
10038 // Exclude scripts to avoid IE 'Permission Denied' errors
10039 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
10041 // Otherwise use the full result
10044 }).complete( callback && function( jqXHR, status ) {
10045 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
10055 jQuery.expr.filters.animated = function( elem ) {
10056 return jQuery.grep(jQuery.timers, function( fn ) {
10057 return elem === fn.elem;
10065 var docElem = window.document.documentElement;
10068 * Gets a window from an element
10070 function getWindow( elem ) {
10071 return jQuery.isWindow( elem ) ?
10073 elem.nodeType === 9 ?
10074 elem.defaultView || elem.parentWindow :
10079 setOffset: function( elem, options, i ) {
10080 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
10081 position = jQuery.css( elem, "position" ),
10082 curElem = jQuery( elem ),
10085 // set position first, in-case top/left are set even on static elem
10086 if ( position === "static" ) {
10087 elem.style.position = "relative";
10090 curOffset = curElem.offset();
10091 curCSSTop = jQuery.css( elem, "top" );
10092 curCSSLeft = jQuery.css( elem, "left" );
10093 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
10094 jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
10096 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
10097 if ( calculatePosition ) {
10098 curPosition = curElem.position();
10099 curTop = curPosition.top;
10100 curLeft = curPosition.left;
10102 curTop = parseFloat( curCSSTop ) || 0;
10103 curLeft = parseFloat( curCSSLeft ) || 0;
10106 if ( jQuery.isFunction( options ) ) {
10107 options = options.call( elem, i, curOffset );
10110 if ( options.top != null ) {
10111 props.top = ( options.top - curOffset.top ) + curTop;
10113 if ( options.left != null ) {
10114 props.left = ( options.left - curOffset.left ) + curLeft;
10117 if ( "using" in options ) {
10118 options.using.call( elem, props );
10120 curElem.css( props );
10126 offset: function( options ) {
10127 if ( arguments.length ) {
10128 return options === undefined ?
10130 this.each(function( i ) {
10131 jQuery.offset.setOffset( this, options, i );
10136 box = { top: 0, left: 0 },
10138 doc = elem && elem.ownerDocument;
10144 docElem = doc.documentElement;
10146 // Make sure it's not a disconnected DOM node
10147 if ( !jQuery.contains( docElem, elem ) ) {
10151 // If we don't have gBCR, just use 0,0 rather than error
10152 // BlackBerry 5, iOS 3 (original iPhone)
10153 if ( typeof elem.getBoundingClientRect !== strundefined ) {
10154 box = elem.getBoundingClientRect();
10156 win = getWindow( doc );
10158 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
10159 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
10163 position: function() {
10164 if ( !this[ 0 ] ) {
10168 var offsetParent, offset,
10169 parentOffset = { top: 0, left: 0 },
10172 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
10173 if ( jQuery.css( elem, "position" ) === "fixed" ) {
10174 // we assume that getBoundingClientRect is available when computed position is fixed
10175 offset = elem.getBoundingClientRect();
10177 // Get *real* offsetParent
10178 offsetParent = this.offsetParent();
10180 // Get correct offsets
10181 offset = this.offset();
10182 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
10183 parentOffset = offsetParent.offset();
10186 // Add offsetParent borders
10187 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
10188 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
10191 // Subtract parent offsets and element margins
10192 // note: when an element has margin: auto the offsetLeft and marginLeft
10193 // are the same in Safari causing offset.left to incorrectly be 0
10195 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10196 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
10200 offsetParent: function() {
10201 return this.map(function() {
10202 var offsetParent = this.offsetParent || docElem;
10204 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
10205 offsetParent = offsetParent.offsetParent;
10207 return offsetParent || docElem;
10212 // Create scrollLeft and scrollTop methods
10213 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10214 var top = /Y/.test( prop );
10216 jQuery.fn[ method ] = function( val ) {
10217 return access( this, function( elem, method, val ) {
10218 var win = getWindow( elem );
10220 if ( val === undefined ) {
10221 return win ? (prop in win) ? win[ prop ] :
10222 win.document.documentElement[ method ] :
10228 !top ? val : jQuery( win ).scrollLeft(),
10229 top ? val : jQuery( win ).scrollTop()
10233 elem[ method ] = val;
10235 }, method, val, arguments.length, null );
10239 // Add the top/left cssHooks using jQuery.fn.position
10240 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10241 // getComputedStyle returns percent when specified for top/left/bottom/right
10242 // rather than make the css module depend on the offset module, we just check for it here
10243 jQuery.each( [ "top", "left" ], function( i, prop ) {
10244 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10245 function( elem, computed ) {
10247 computed = curCSS( elem, prop );
10248 // if curCSS returns percentage, fallback to offset
10249 return rnumnonpx.test( computed ) ?
10250 jQuery( elem ).position()[ prop ] + "px" :
10258 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10259 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10260 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
10261 // margin is only for outerHeight, outerWidth
10262 jQuery.fn[ funcName ] = function( margin, value ) {
10263 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10264 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10266 return access( this, function( elem, type, value ) {
10269 if ( jQuery.isWindow( elem ) ) {
10270 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
10271 // isn't a whole lot we can do. See pull request at this URL for discussion:
10272 // https://github.com/jquery/jquery/pull/764
10273 return elem.document.documentElement[ "client" + name ];
10276 // Get document width or height
10277 if ( elem.nodeType === 9 ) {
10278 doc = elem.documentElement;
10280 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
10281 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
10283 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10284 elem.body[ "offset" + name ], doc[ "offset" + name ],
10285 doc[ "client" + name ]
10289 return value === undefined ?
10290 // Get width or height on the element, requesting but not forcing parseFloat
10291 jQuery.css( elem, type, extra ) :
10293 // Set width or height on the element
10294 jQuery.style( elem, type, value, extra );
10295 }, type, chainable ? margin : undefined, chainable, null );
10301 // The number of elements contained in the matched element set
10302 jQuery.fn.size = function() {
10303 return this.length;
10306 jQuery.fn.andSelf = jQuery.fn.addBack;
10311 // Register as a named AMD module, since jQuery can be concatenated with other
10312 // files that may use define, but not via a proper concatenation script that
10313 // understands anonymous AMD modules. A named AMD is safest and most robust
10314 // way to register. Lowercase jquery is used because AMD module names are
10315 // derived from file names, and jQuery is normally delivered in a lowercase
10316 // file name. Do this after creating the global so that if an AMD module wants
10317 // to call noConflict to hide this version of jQuery, it will work.
10318 if ( typeof define === "function" && define.amd ) {
10319 define( "jquery", [], function() {
10328 // Map over jQuery in case of overwrite
10329 _jQuery = window.jQuery,
10331 // Map over the $ in case of overwrite
10334 jQuery.noConflict = function( deep ) {
10335 if ( window.$ === jQuery ) {
10339 if ( deep && window.jQuery === jQuery ) {
10340 window.jQuery = _jQuery;
10346 // Expose jQuery and $ identifiers, even in
10347 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10348 // and CommonJS for browser emulators (#13566)
10349 if ( typeof noGlobal === strundefined ) {
10350 window.jQuery = window.$ = jQuery;