2 * jQuery JavaScript Library v2.1.3
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2014-12-18T15:11Z
15 (function( global, factory ) {
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper `window`
19 // is present, execute the factory and get jQuery.
20 // For environments that do not have a `window` with a `document`
21 // (such as Node.js), expose a factory as module.exports.
22 // This accentuates the need for the creation of a real `window`.
23 // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info.
25 module.exports = global.document ?
26 factory( global, true ) :
29 throw new Error( "jQuery requires a window with a document" );
37 // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40 // Support: Firefox 18+
41 // Can't be in strict mode, several libs including ASP.NET trace
42 // the stack via arguments.caller.callee and Firefox dies if
43 // you try to trace through "use strict" call chains. (#13335)
48 var slice = arr.slice;
50 var concat = arr.concat;
54 var indexOf = arr.indexOf;
58 var toString = class2type.toString;
60 var hasOwn = class2type.hasOwnProperty;
67 // Use the correct document accordingly with window argument (sandbox)
68 document = window.document,
72 // Define a local copy of jQuery
73 jQuery = function( selector, context ) {
74 // The jQuery object is actually just the init constructor 'enhanced'
75 // Need init if jQuery is called (just allow error to be thrown if not included)
76 return new jQuery.fn.init( selector, context );
79 // Support: Android<4.1
80 // Make sure we trim BOM and NBSP
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 just the one element from the set
114 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116 // Return all the elements in a clean array
120 // Take an array of elements and push it onto the stack
121 // (returning the new matched element set)
122 pushStack: function( elems ) {
124 // Build a new jQuery matched element set
125 var ret = jQuery.merge( this.constructor(), elems );
127 // Add the old object onto the stack (as a reference)
128 ret.prevObject = this;
129 ret.context = this.context;
131 // Return the newly-formed element set
135 // Execute a callback for every element in the matched set.
136 // (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.
177 jQuery.extend = jQuery.fn.extend = function() {
178 var options, name, src, copy, copyIsArray, 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 isFunction: function( obj ) {
256 return jQuery.type(obj) === "function";
259 isArray: Array.isArray,
261 isWindow: function( obj ) {
262 return obj != null && obj === obj.window;
265 isNumeric: function( obj ) {
266 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
267 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
268 // subtraction forces infinities to NaN
269 // adding 1 corrects loss of precision from parseFloat (#15100)
270 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
273 isPlainObject: function( obj ) {
274 // Not plain objects:
275 // - Any object or value whose internal [[Class]] property is not "[object Object]"
278 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
282 if ( obj.constructor &&
283 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
287 // If the function hasn't returned already, we're confident that
288 // |obj| is a plain object, created by {} or constructed with new Object
292 isEmptyObject: function( obj ) {
294 for ( name in obj ) {
300 type: function( obj ) {
304 // Support: Android<4.0, iOS<6 (functionish RegExp)
305 return typeof obj === "object" || typeof obj === "function" ?
306 class2type[ toString.call(obj) ] || "object" :
310 // Evaluates a script in a global context
311 globalEval: function( code ) {
315 code = jQuery.trim( code );
318 // If the code includes a valid, prologue position
319 // strict mode pragma, execute code by injecting a
320 // script tag into the document.
321 if ( code.indexOf("use strict") === 1 ) {
322 script = document.createElement("script");
324 document.head.appendChild( script ).parentNode.removeChild( script );
326 // Otherwise, avoid the DOM node creation, insertion
327 // and removal by using an indirect global eval
333 // Convert dashed to camelCase; used by the css and data modules
335 // Microsoft forgot to hump their vendor prefix (#9572)
336 camelCase: function( string ) {
337 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
340 nodeName: function( elem, name ) {
341 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
344 // args is for internal usage only
345 each: function( obj, callback, args ) {
349 isArray = isArraylike( obj );
353 for ( ; i < length; i++ ) {
354 value = callback.apply( obj[ i ], args );
356 if ( value === false ) {
362 value = callback.apply( obj[ i ], args );
364 if ( value === false ) {
370 // A special, fast, case for the most common use of each
373 for ( ; i < length; i++ ) {
374 value = callback.call( obj[ i ], i, obj[ i ] );
376 if ( value === false ) {
382 value = callback.call( obj[ i ], i, obj[ i ] );
384 if ( value === false ) {
394 // Support: Android<4.1
395 trim: function( text ) {
396 return text == null ?
398 ( text + "" ).replace( rtrim, "" );
401 // results is for internal usage only
402 makeArray: function( arr, results ) {
403 var ret = results || [];
406 if ( isArraylike( Object(arr) ) ) {
408 typeof arr === "string" ?
412 push.call( ret, arr );
419 inArray: function( elem, arr, i ) {
420 return arr == null ? -1 : indexOf.call( arr, elem, i );
423 merge: function( first, second ) {
424 var len = +second.length,
428 for ( ; j < len; j++ ) {
429 first[ i++ ] = second[ j ];
437 grep: function( elems, callback, invert ) {
441 length = elems.length,
442 callbackExpect = !invert;
444 // Go through the array, only saving the items
445 // that pass the validator function
446 for ( ; i < length; i++ ) {
447 callbackInverse = !callback( elems[ i ], i );
448 if ( callbackInverse !== callbackExpect ) {
449 matches.push( elems[ i ] );
456 // arg is for internal usage only
457 map: function( elems, callback, arg ) {
460 length = elems.length,
461 isArray = isArraylike( elems ),
464 // Go through the array, translating each of the items to their new values
466 for ( ; i < length; i++ ) {
467 value = callback( elems[ i ], i, arg );
469 if ( value != null ) {
474 // Go through every key on the object,
477 value = callback( elems[ i ], i, arg );
479 if ( value != null ) {
485 // Flatten any nested arrays
486 return concat.apply( [], ret );
489 // A global GUID counter for objects
492 // Bind a function to a context, optionally partially applying any
494 proxy: function( fn, context ) {
495 var tmp, args, proxy;
497 if ( typeof context === "string" ) {
503 // Quick check to determine if target is callable, in the spec
504 // this throws a TypeError, but we will just return undefined.
505 if ( !jQuery.isFunction( fn ) ) {
510 args = slice.call( arguments, 2 );
512 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
515 // Set the guid of unique handler to the same of original handler, so it can be removed
516 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
523 // jQuery.support is not used in Core but other projects attach their
524 // properties to it so it needs to exist.
528 // Populate the class2type map
529 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
530 class2type[ "[object " + name + "]" ] = name.toLowerCase();
533 function isArraylike( obj ) {
534 var length = obj.length,
535 type = jQuery.type( obj );
537 if ( type === "function" || jQuery.isWindow( obj ) ) {
541 if ( obj.nodeType === 1 && length ) {
545 return type === "array" || length === 0 ||
546 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
550 * Sizzle CSS Selector Engine v2.2.0-pre
551 * http://sizzlejs.com/
553 * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
554 * Released under the MIT license
555 * http://jquery.org/license
559 (function( window ) {
573 // Local document vars
583 // Instance-specific data
584 expando = "sizzle" + 1 * new Date(),
585 preferredDoc = window.document,
588 classCache = createCache(),
589 tokenCache = createCache(),
590 compilerCache = createCache(),
591 sortOrder = function( a, b ) {
598 // General-purpose constants
599 MAX_NEGATIVE = 1 << 31,
602 hasOwn = ({}).hasOwnProperty,
605 push_native = arr.push,
608 // Use a stripped-down indexOf as it's faster than native
609 // http://jsperf.com/thor-indexof-vs-for/5
610 indexOf = function( list, elem ) {
613 for ( ; i < len; i++ ) {
614 if ( list[i] === elem ) {
621 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
623 // Regular expressions
625 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
626 whitespace = "[\\x20\\t\\r\\n\\f]",
627 // http://www.w3.org/TR/css3-syntax/#characters
628 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
630 // Loosely modeled on CSS identifier characters
631 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
632 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
633 identifier = characterEncoding.replace( "w", "w#" ),
635 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
636 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
637 // Operator (capture 2)
638 "*([*^$|!~]?=)" + whitespace +
639 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
640 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
643 pseudos = ":(" + characterEncoding + ")(?:\\((" +
644 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
645 // 1. quoted (capture 3; capture 4 or capture 5)
646 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
647 // 2. simple (capture 6)
648 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
649 // 3. anything else (capture 2)
653 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
654 rwhitespace = new RegExp( whitespace + "+", "g" ),
655 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
657 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
658 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
660 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
662 rpseudo = new RegExp( pseudos ),
663 ridentifier = new RegExp( "^" + identifier + "$" ),
666 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
667 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
668 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
669 "ATTR": new RegExp( "^" + attributes ),
670 "PSEUDO": new RegExp( "^" + pseudos ),
671 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
672 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
673 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
674 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
675 // For use in libraries implementing .is()
676 // We use this for POS matching in `select`
677 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
678 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
681 rinputs = /^(?:input|select|textarea|button)$/i,
684 rnative = /^[^{]+\{\s*\[native \w/,
686 // Easily-parseable/retrievable ID or TAG or CLASS selectors
687 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
692 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
693 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
694 funescape = function( _, escaped, escapedWhitespace ) {
695 var high = "0x" + escaped - 0x10000;
696 // NaN means non-codepoint
697 // Support: Firefox<24
698 // Workaround erroneous numeric interpretation of +"0x"
699 return high !== high || escapedWhitespace ?
703 String.fromCharCode( high + 0x10000 ) :
704 // Supplemental Plane codepoint (surrogate pair)
705 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
710 // Removing the function wrapper causes a "Permission Denied"
712 unloadHandler = function() {
716 // Optimize for push.apply( _, NodeList )
719 (arr = slice.call( preferredDoc.childNodes )),
720 preferredDoc.childNodes
722 // Support: Android<4.0
723 // Detect silently failing push.apply
724 arr[ preferredDoc.childNodes.length ].nodeType;
726 push = { apply: arr.length ?
728 // Leverage slice if possible
729 function( target, els ) {
730 push_native.apply( target, slice.call(els) );
734 // Otherwise append directly
735 function( target, els ) {
736 var j = target.length,
738 // Can't trust NodeList.length
739 while ( (target[j++] = els[i++]) ) {}
740 target.length = j - 1;
745 function Sizzle( selector, context, results, seed ) {
746 var match, elem, m, nodeType,
748 i, groups, old, nid, newContext, newSelector;
750 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
751 setDocument( context );
754 context = context || document;
755 results = results || [];
756 nodeType = context.nodeType;
758 if ( typeof selector !== "string" || !selector ||
759 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
764 if ( !seed && documentIsHTML ) {
766 // Try to shortcut find operations when possible (e.g., not under DocumentFragment)
767 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
768 // Speed-up: Sizzle("#ID")
769 if ( (m = match[1]) ) {
770 if ( nodeType === 9 ) {
771 elem = context.getElementById( m );
772 // Check parentNode to catch when Blackberry 4.6 returns
773 // nodes that are no longer in the document (jQuery #6963)
774 if ( elem && elem.parentNode ) {
775 // Handle the case where IE, Opera, and Webkit return items
776 // by name instead of ID
777 if ( elem.id === m ) {
778 results.push( elem );
785 // Context is not a document
786 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
787 contains( context, elem ) && elem.id === m ) {
788 results.push( elem );
793 // Speed-up: Sizzle("TAG")
794 } else if ( match[2] ) {
795 push.apply( results, context.getElementsByTagName( selector ) );
798 // Speed-up: Sizzle(".CLASS")
799 } else if ( (m = match[3]) && support.getElementsByClassName ) {
800 push.apply( results, context.getElementsByClassName( m ) );
806 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
808 newContext = context;
809 newSelector = nodeType !== 1 && selector;
811 // qSA works strangely on Element-rooted queries
812 // We can work around this by specifying an extra ID on the root
813 // and working up from there (Thanks to Andrew Dupont for the technique)
814 // IE 8 doesn't work on object elements
815 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
816 groups = tokenize( selector );
818 if ( (old = context.getAttribute("id")) ) {
819 nid = old.replace( rescape, "\\$&" );
821 context.setAttribute( "id", nid );
823 nid = "[id='" + nid + "'] ";
827 groups[i] = nid + toSelector( groups[i] );
829 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
830 newSelector = groups.join(",");
836 newContext.querySelectorAll( newSelector )
842 context.removeAttribute("id");
850 return select( selector.replace( rtrim, "$1" ), context, results, seed );
854 * Create key-value caches of limited size
855 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
856 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
857 * deleting the oldest entry
859 function createCache() {
862 function cache( key, value ) {
863 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
864 if ( keys.push( key + " " ) > Expr.cacheLength ) {
865 // Only keep the most recent entries
866 delete cache[ keys.shift() ];
868 return (cache[ key + " " ] = value);
874 * Mark a function for special use by Sizzle
875 * @param {Function} fn The function to mark
877 function markFunction( fn ) {
878 fn[ expando ] = true;
883 * Support testing using an element
884 * @param {Function} fn Passed the created div and expects a boolean result
886 function assert( fn ) {
887 var div = document.createElement("div");
894 // Remove from its parent by default
895 if ( div.parentNode ) {
896 div.parentNode.removeChild( div );
898 // release memory in IE
904 * Adds the same handler for all of the specified attrs
905 * @param {String} attrs Pipe-separated list of attributes
906 * @param {Function} handler The method that will be applied
908 function addHandle( attrs, handler ) {
909 var arr = attrs.split("|"),
913 Expr.attrHandle[ arr[i] ] = handler;
918 * Checks document order of two siblings
921 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
923 function siblingCheck( a, b ) {
925 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
926 ( ~b.sourceIndex || MAX_NEGATIVE ) -
927 ( ~a.sourceIndex || MAX_NEGATIVE );
929 // Use IE sourceIndex if available on both nodes
934 // Check if b follows a
936 while ( (cur = cur.nextSibling) ) {
947 * Returns a function to use in pseudos for input types
948 * @param {String} type
950 function createInputPseudo( type ) {
951 return function( elem ) {
952 var name = elem.nodeName.toLowerCase();
953 return name === "input" && elem.type === type;
958 * Returns a function to use in pseudos for buttons
959 * @param {String} type
961 function createButtonPseudo( type ) {
962 return function( elem ) {
963 var name = elem.nodeName.toLowerCase();
964 return (name === "input" || name === "button") && elem.type === type;
969 * Returns a function to use in pseudos for positionals
970 * @param {Function} fn
972 function createPositionalPseudo( fn ) {
973 return markFunction(function( argument ) {
974 argument = +argument;
975 return markFunction(function( seed, matches ) {
977 matchIndexes = fn( [], seed.length, argument ),
978 i = matchIndexes.length;
980 // Match elements found at the specified indexes
982 if ( seed[ (j = matchIndexes[i]) ] ) {
983 seed[j] = !(matches[j] = seed[j]);
991 * Checks a node for validity as a Sizzle context
992 * @param {Element|Object=} context
993 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
995 function testContext( context ) {
996 return context && typeof context.getElementsByTagName !== "undefined" && context;
999 // Expose support vars for convenience
1000 support = Sizzle.support = {};
1004 * @param {Element|Object} elem An element or a document
1005 * @returns {Boolean} True iff elem is a non-HTML XML node
1007 isXML = Sizzle.isXML = function( elem ) {
1008 // documentElement is verified for cases where it doesn't yet exist
1009 // (such as loading iframes in IE - #4833)
1010 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1011 return documentElement ? documentElement.nodeName !== "HTML" : false;
1015 * Sets document-related variables once based on the current document
1016 * @param {Element|Object} [doc] An element or document object to use to set the document
1017 * @returns {Object} Returns the current document
1019 setDocument = Sizzle.setDocument = function( node ) {
1020 var hasCompare, parent,
1021 doc = node ? node.ownerDocument || node : preferredDoc;
1023 // If no document and documentElement is available, return
1024 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1030 docElem = doc.documentElement;
1031 parent = doc.defaultView;
1034 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1035 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1036 // IE6-8 do not support the defaultView property so parent will be undefined
1037 if ( parent && parent !== parent.top ) {
1038 // IE11 does not have attachEvent, so all must suffer
1039 if ( parent.addEventListener ) {
1040 parent.addEventListener( "unload", unloadHandler, false );
1041 } else if ( parent.attachEvent ) {
1042 parent.attachEvent( "onunload", unloadHandler );
1047 ---------------------------------------------------------------------- */
1048 documentIsHTML = !isXML( doc );
1051 ---------------------------------------------------------------------- */
1054 // Verify that getAttribute really returns attributes and not properties
1055 // (excepting IE8 booleans)
1056 support.attributes = assert(function( div ) {
1057 div.className = "i";
1058 return !div.getAttribute("className");
1062 ---------------------------------------------------------------------- */
1064 // Check if getElementsByTagName("*") returns only elements
1065 support.getElementsByTagName = assert(function( div ) {
1066 div.appendChild( doc.createComment("") );
1067 return !div.getElementsByTagName("*").length;
1071 support.getElementsByClassName = rnative.test( doc.getElementsByClassName );
1074 // Check if getElementById returns elements by name
1075 // The broken getElementById methods don't pick up programatically-set names,
1076 // so use a roundabout getElementsByName test
1077 support.getById = assert(function( div ) {
1078 docElem.appendChild( div ).id = expando;
1079 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1082 // ID find and filter
1083 if ( support.getById ) {
1084 Expr.find["ID"] = function( id, context ) {
1085 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1086 var m = context.getElementById( id );
1087 // Check parentNode to catch when Blackberry 4.6 returns
1088 // nodes that are no longer in the document #6963
1089 return m && m.parentNode ? [ m ] : [];
1092 Expr.filter["ID"] = function( id ) {
1093 var attrId = id.replace( runescape, funescape );
1094 return function( elem ) {
1095 return elem.getAttribute("id") === attrId;
1100 // getElementById is not reliable as a find shortcut
1101 delete Expr.find["ID"];
1103 Expr.filter["ID"] = function( id ) {
1104 var attrId = id.replace( runescape, funescape );
1105 return function( elem ) {
1106 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
1107 return node && node.value === attrId;
1113 Expr.find["TAG"] = support.getElementsByTagName ?
1114 function( tag, context ) {
1115 if ( typeof context.getElementsByTagName !== "undefined" ) {
1116 return context.getElementsByTagName( tag );
1118 // DocumentFragment nodes don't have gEBTN
1119 } else if ( support.qsa ) {
1120 return context.querySelectorAll( tag );
1124 function( tag, context ) {
1128 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1129 results = context.getElementsByTagName( tag );
1131 // Filter out possible comments
1132 if ( tag === "*" ) {
1133 while ( (elem = results[i++]) ) {
1134 if ( elem.nodeType === 1 ) {
1145 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1146 if ( documentIsHTML ) {
1147 return context.getElementsByClassName( className );
1151 /* QSA/matchesSelector
1152 ---------------------------------------------------------------------- */
1154 // QSA and matchesSelector support
1156 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1159 // qSa(:focus) reports false when true (Chrome 21)
1160 // We allow this because of a bug in IE8/9 that throws an error
1161 // whenever `document.activeElement` is accessed on an iframe
1162 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1163 // See http://bugs.jquery.com/ticket/13378
1166 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1168 // Regex strategy adopted from Diego Perini
1169 assert(function( div ) {
1170 // Select is set to empty string on purpose
1171 // This is to test IE's treatment of not explicitly
1172 // setting a boolean content attribute,
1173 // since its presence should be enough
1174 // http://bugs.jquery.com/ticket/12359
1175 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1176 "<select id='" + expando + "-\f]' msallowcapture=''>" +
1177 "<option selected=''></option></select>";
1179 // Support: IE8, Opera 11-12.16
1180 // Nothing should be selected when empty strings follow ^= or $= or *=
1181 // The test attribute must be unknown in Opera but "safe" for WinRT
1182 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1183 if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1184 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1188 // Boolean attributes and "value" are not treated correctly
1189 if ( !div.querySelectorAll("[selected]").length ) {
1190 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1193 // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
1194 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1195 rbuggyQSA.push("~=");
1198 // Webkit/Opera - :checked should return selected option elements
1199 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1200 // IE8 throws error here and will not see later tests
1201 if ( !div.querySelectorAll(":checked").length ) {
1202 rbuggyQSA.push(":checked");
1205 // Support: Safari 8+, iOS 8+
1206 // https://bugs.webkit.org/show_bug.cgi?id=136851
1207 // In-page `selector#id sibing-combinator selector` fails
1208 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1209 rbuggyQSA.push(".#.+[+~]");
1213 assert(function( div ) {
1214 // Support: Windows 8 Native Apps
1215 // The type and name attributes are restricted during .innerHTML assignment
1216 var input = doc.createElement("input");
1217 input.setAttribute( "type", "hidden" );
1218 div.appendChild( input ).setAttribute( "name", "D" );
1221 // Enforce case-sensitivity of name attribute
1222 if ( div.querySelectorAll("[name=d]").length ) {
1223 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1226 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1227 // IE8 throws error here and will not see later tests
1228 if ( !div.querySelectorAll(":enabled").length ) {
1229 rbuggyQSA.push( ":enabled", ":disabled" );
1232 // Opera 10-11 does not throw on post-comma invalid pseudos
1233 div.querySelectorAll("*,:x");
1234 rbuggyQSA.push(",.*:");
1238 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1239 docElem.webkitMatchesSelector ||
1240 docElem.mozMatchesSelector ||
1241 docElem.oMatchesSelector ||
1242 docElem.msMatchesSelector) )) ) {
1244 assert(function( div ) {
1245 // Check to see if it's possible to do matchesSelector
1246 // on a disconnected node (IE 9)
1247 support.disconnectedMatch = matches.call( div, "div" );
1249 // This should fail with an exception
1250 // Gecko does not error, returns false instead
1251 matches.call( div, "[s!='']:x" );
1252 rbuggyMatches.push( "!=", pseudos );
1256 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1257 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1260 ---------------------------------------------------------------------- */
1261 hasCompare = rnative.test( docElem.compareDocumentPosition );
1263 // Element contains another
1264 // Purposefully does not implement inclusive descendent
1265 // As in, an element does not contain itself
1266 contains = hasCompare || rnative.test( docElem.contains ) ?
1268 var adown = a.nodeType === 9 ? a.documentElement : a,
1269 bup = b && b.parentNode;
1270 return a === bup || !!( bup && bup.nodeType === 1 && (
1272 adown.contains( bup ) :
1273 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1278 while ( (b = b.parentNode) ) {
1288 ---------------------------------------------------------------------- */
1290 // Document order sorting
1291 sortOrder = hasCompare ?
1294 // Flag for duplicate removal
1296 hasDuplicate = true;
1300 // Sort on method existence if only one input has compareDocumentPosition
1301 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1306 // Calculate position if both inputs belong to the same document
1307 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1308 a.compareDocumentPosition( b ) :
1310 // Otherwise we know they are disconnected
1313 // Disconnected nodes
1315 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1317 // Choose the first element that is related to our preferred document
1318 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1321 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1325 // Maintain original order
1327 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1331 return compare & 4 ? -1 : 1;
1334 // Exit early if the nodes are identical
1336 hasDuplicate = true;
1347 // Parentless nodes are either documents or disconnected
1348 if ( !aup || !bup ) {
1349 return a === doc ? -1 :
1354 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1357 // If the nodes are siblings, we can do a quick check
1358 } else if ( aup === bup ) {
1359 return siblingCheck( a, b );
1362 // Otherwise we need full lists of their ancestors for comparison
1364 while ( (cur = cur.parentNode) ) {
1368 while ( (cur = cur.parentNode) ) {
1372 // Walk down the tree looking for a discrepancy
1373 while ( ap[i] === bp[i] ) {
1378 // Do a sibling check if the nodes have a common ancestor
1379 siblingCheck( ap[i], bp[i] ) :
1381 // Otherwise nodes in our document sort first
1382 ap[i] === preferredDoc ? -1 :
1383 bp[i] === preferredDoc ? 1 :
1390 Sizzle.matches = function( expr, elements ) {
1391 return Sizzle( expr, null, null, elements );
1394 Sizzle.matchesSelector = function( elem, expr ) {
1395 // Set document vars if needed
1396 if ( ( elem.ownerDocument || elem ) !== document ) {
1397 setDocument( elem );
1400 // Make sure that attribute selectors are quoted
1401 expr = expr.replace( rattributeQuotes, "='$1']" );
1403 if ( support.matchesSelector && documentIsHTML &&
1404 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1405 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1408 var ret = matches.call( elem, expr );
1410 // IE 9's matchesSelector returns false on disconnected nodes
1411 if ( ret || support.disconnectedMatch ||
1412 // As well, disconnected nodes are said to be in a document
1414 elem.document && elem.document.nodeType !== 11 ) {
1420 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1423 Sizzle.contains = function( context, elem ) {
1424 // Set document vars if needed
1425 if ( ( context.ownerDocument || context ) !== document ) {
1426 setDocument( context );
1428 return contains( context, elem );
1431 Sizzle.attr = function( elem, name ) {
1432 // Set document vars if needed
1433 if ( ( elem.ownerDocument || elem ) !== document ) {
1434 setDocument( elem );
1437 var fn = Expr.attrHandle[ name.toLowerCase() ],
1438 // Don't get fooled by Object.prototype properties (jQuery #13807)
1439 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1440 fn( elem, name, !documentIsHTML ) :
1443 return val !== undefined ?
1445 support.attributes || !documentIsHTML ?
1446 elem.getAttribute( name ) :
1447 (val = elem.getAttributeNode(name)) && val.specified ?
1452 Sizzle.error = function( msg ) {
1453 throw new Error( "Syntax error, unrecognized expression: " + msg );
1457 * Document sorting and removing duplicates
1458 * @param {ArrayLike} results
1460 Sizzle.uniqueSort = function( results ) {
1466 // Unless we *know* we can detect duplicates, assume their presence
1467 hasDuplicate = !support.detectDuplicates;
1468 sortInput = !support.sortStable && results.slice( 0 );
1469 results.sort( sortOrder );
1471 if ( hasDuplicate ) {
1472 while ( (elem = results[i++]) ) {
1473 if ( elem === results[ i ] ) {
1474 j = duplicates.push( i );
1478 results.splice( duplicates[ j ], 1 );
1482 // Clear input after sorting to release objects
1483 // See https://github.com/jquery/sizzle/pull/225
1490 * Utility function for retrieving the text value of an array of DOM nodes
1491 * @param {Array|Element} elem
1493 getText = Sizzle.getText = function( elem ) {
1497 nodeType = elem.nodeType;
1500 // If no nodeType, this is expected to be an array
1501 while ( (node = elem[i++]) ) {
1502 // Do not traverse comment nodes
1503 ret += getText( node );
1505 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1506 // Use textContent for elements
1507 // innerText usage removed for consistency of new lines (jQuery #11153)
1508 if ( typeof elem.textContent === "string" ) {
1509 return elem.textContent;
1511 // Traverse its children
1512 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1513 ret += getText( elem );
1516 } else if ( nodeType === 3 || nodeType === 4 ) {
1517 return elem.nodeValue;
1519 // Do not include comment or processing instruction nodes
1524 Expr = Sizzle.selectors = {
1526 // Can be adjusted by the user
1529 createPseudo: markFunction,
1538 ">": { dir: "parentNode", first: true },
1539 " ": { dir: "parentNode" },
1540 "+": { dir: "previousSibling", first: true },
1541 "~": { dir: "previousSibling" }
1545 "ATTR": function( match ) {
1546 match[1] = match[1].replace( runescape, funescape );
1548 // Move the given value to match[3] whether quoted or unquoted
1549 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1551 if ( match[2] === "~=" ) {
1552 match[3] = " " + match[3] + " ";
1555 return match.slice( 0, 4 );
1558 "CHILD": function( match ) {
1559 /* matches from matchExpr["CHILD"]
1560 1 type (only|nth|...)
1561 2 what (child|of-type)
1562 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1563 4 xn-component of xn+y argument ([+-]?\d*n|)
1564 5 sign of xn-component
1566 7 sign of y-component
1569 match[1] = match[1].toLowerCase();
1571 if ( match[1].slice( 0, 3 ) === "nth" ) {
1572 // nth-* requires argument
1574 Sizzle.error( match[0] );
1577 // numeric x and y parameters for Expr.filter.CHILD
1578 // remember that false/true cast respectively to 0/1
1579 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1580 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1582 // other types prohibit arguments
1583 } else if ( match[3] ) {
1584 Sizzle.error( match[0] );
1590 "PSEUDO": function( match ) {
1592 unquoted = !match[6] && match[2];
1594 if ( matchExpr["CHILD"].test( match[0] ) ) {
1598 // Accept quoted arguments as-is
1600 match[2] = match[4] || match[5] || "";
1602 // Strip excess characters from unquoted arguments
1603 } else if ( unquoted && rpseudo.test( unquoted ) &&
1604 // Get excess from tokenize (recursively)
1605 (excess = tokenize( unquoted, true )) &&
1606 // advance to the next closing parenthesis
1607 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1609 // excess is a negative index
1610 match[0] = match[0].slice( 0, excess );
1611 match[2] = unquoted.slice( 0, excess );
1614 // Return only captures needed by the pseudo filter method (type and argument)
1615 return match.slice( 0, 3 );
1621 "TAG": function( nodeNameSelector ) {
1622 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1623 return nodeNameSelector === "*" ?
1624 function() { return true; } :
1626 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1630 "CLASS": function( className ) {
1631 var pattern = classCache[ className + " " ];
1634 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1635 classCache( className, function( elem ) {
1636 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1640 "ATTR": function( name, operator, check ) {
1641 return function( elem ) {
1642 var result = Sizzle.attr( elem, name );
1644 if ( result == null ) {
1645 return operator === "!=";
1653 return operator === "=" ? result === check :
1654 operator === "!=" ? result !== check :
1655 operator === "^=" ? check && result.indexOf( check ) === 0 :
1656 operator === "*=" ? check && result.indexOf( check ) > -1 :
1657 operator === "$=" ? check && result.slice( -check.length ) === check :
1658 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1659 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1664 "CHILD": function( type, what, argument, first, last ) {
1665 var simple = type.slice( 0, 3 ) !== "nth",
1666 forward = type.slice( -4 ) !== "last",
1667 ofType = what === "of-type";
1669 return first === 1 && last === 0 ?
1671 // Shortcut for :nth-*(n)
1673 return !!elem.parentNode;
1676 function( elem, context, xml ) {
1677 var cache, outerCache, node, diff, nodeIndex, start,
1678 dir = simple !== forward ? "nextSibling" : "previousSibling",
1679 parent = elem.parentNode,
1680 name = ofType && elem.nodeName.toLowerCase(),
1681 useCache = !xml && !ofType;
1685 // :(first|last|only)-(child|of-type)
1689 while ( (node = node[ dir ]) ) {
1690 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1694 // Reverse direction for :only-* (if we haven't yet done so)
1695 start = dir = type === "only" && !start && "nextSibling";
1700 start = [ forward ? parent.firstChild : parent.lastChild ];
1702 // non-xml :nth-child(...) stores cache data on `parent`
1703 if ( forward && useCache ) {
1704 // Seek `elem` from a previously-cached index
1705 outerCache = parent[ expando ] || (parent[ expando ] = {});
1706 cache = outerCache[ type ] || [];
1707 nodeIndex = cache[0] === dirruns && cache[1];
1708 diff = cache[0] === dirruns && cache[2];
1709 node = nodeIndex && parent.childNodes[ nodeIndex ];
1711 while ( (node = ++nodeIndex && node && node[ dir ] ||
1713 // Fallback to seeking `elem` from the start
1714 (diff = nodeIndex = 0) || start.pop()) ) {
1716 // When found, cache indexes on `parent` and break
1717 if ( node.nodeType === 1 && ++diff && node === elem ) {
1718 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1723 // Use previously-cached element index if available
1724 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1727 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1729 // Use the same loop as above to seek `elem` from the start
1730 while ( (node = ++nodeIndex && node && node[ dir ] ||
1731 (diff = nodeIndex = 0) || start.pop()) ) {
1733 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1734 // Cache the index of each encountered element
1736 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1739 if ( node === elem ) {
1746 // Incorporate the offset, then check against cycle size
1748 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1753 "PSEUDO": function( pseudo, argument ) {
1754 // pseudo-class names are case-insensitive
1755 // http://www.w3.org/TR/selectors/#pseudo-classes
1756 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1757 // Remember that setFilters inherits from pseudos
1759 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1760 Sizzle.error( "unsupported pseudo: " + pseudo );
1762 // The user may use createPseudo to indicate that
1763 // arguments are needed to create the filter function
1764 // just as Sizzle does
1765 if ( fn[ expando ] ) {
1766 return fn( argument );
1769 // But maintain support for old signatures
1770 if ( fn.length > 1 ) {
1771 args = [ pseudo, pseudo, "", argument ];
1772 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1773 markFunction(function( seed, matches ) {
1775 matched = fn( seed, argument ),
1778 idx = indexOf( seed, matched[i] );
1779 seed[ idx ] = !( matches[ idx ] = matched[i] );
1783 return fn( elem, 0, args );
1792 // Potentially complex pseudos
1793 "not": markFunction(function( selector ) {
1794 // Trim the selector passed to compile
1795 // to avoid treating leading and trailing
1796 // spaces as combinators
1799 matcher = compile( selector.replace( rtrim, "$1" ) );
1801 return matcher[ expando ] ?
1802 markFunction(function( seed, matches, context, xml ) {
1804 unmatched = matcher( seed, null, xml, [] ),
1807 // Match elements unmatched by `matcher`
1809 if ( (elem = unmatched[i]) ) {
1810 seed[i] = !(matches[i] = elem);
1814 function( elem, context, xml ) {
1816 matcher( input, null, xml, results );
1817 // Don't keep the element (issue #299)
1819 return !results.pop();
1823 "has": markFunction(function( selector ) {
1824 return function( elem ) {
1825 return Sizzle( selector, elem ).length > 0;
1829 "contains": markFunction(function( text ) {
1830 text = text.replace( runescape, funescape );
1831 return function( elem ) {
1832 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1836 // "Whether an element is represented by a :lang() selector
1837 // is based solely on the element's language value
1838 // being equal to the identifier C,
1839 // or beginning with the identifier C immediately followed by "-".
1840 // The matching of C against the element's language value is performed case-insensitively.
1841 // The identifier C does not have to be a valid language name."
1842 // http://www.w3.org/TR/selectors/#lang-pseudo
1843 "lang": markFunction( function( lang ) {
1844 // lang value must be a valid identifier
1845 if ( !ridentifier.test(lang || "") ) {
1846 Sizzle.error( "unsupported lang: " + lang );
1848 lang = lang.replace( runescape, funescape ).toLowerCase();
1849 return function( elem ) {
1852 if ( (elemLang = documentIsHTML ?
1854 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1856 elemLang = elemLang.toLowerCase();
1857 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1859 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1865 "target": function( elem ) {
1866 var hash = window.location && window.location.hash;
1867 return hash && hash.slice( 1 ) === elem.id;
1870 "root": function( elem ) {
1871 return elem === docElem;
1874 "focus": function( elem ) {
1875 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1878 // Boolean properties
1879 "enabled": function( elem ) {
1880 return elem.disabled === false;
1883 "disabled": function( elem ) {
1884 return elem.disabled === true;
1887 "checked": function( elem ) {
1888 // In CSS3, :checked should return both checked and selected elements
1889 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1890 var nodeName = elem.nodeName.toLowerCase();
1891 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1894 "selected": function( elem ) {
1895 // Accessing this property makes selected-by-default
1896 // options in Safari work properly
1897 if ( elem.parentNode ) {
1898 elem.parentNode.selectedIndex;
1901 return elem.selected === true;
1905 "empty": function( elem ) {
1906 // http://www.w3.org/TR/selectors/#empty-pseudo
1907 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1908 // but not by others (comment: 8; processing instruction: 7; etc.)
1909 // nodeType < 6 works because attributes (2) do not appear as children
1910 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1911 if ( elem.nodeType < 6 ) {
1918 "parent": function( elem ) {
1919 return !Expr.pseudos["empty"]( elem );
1922 // Element/input types
1923 "header": function( elem ) {
1924 return rheader.test( elem.nodeName );
1927 "input": function( elem ) {
1928 return rinputs.test( elem.nodeName );
1931 "button": function( elem ) {
1932 var name = elem.nodeName.toLowerCase();
1933 return name === "input" && elem.type === "button" || name === "button";
1936 "text": function( elem ) {
1938 return elem.nodeName.toLowerCase() === "input" &&
1939 elem.type === "text" &&
1942 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1943 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1946 // Position-in-collection
1947 "first": createPositionalPseudo(function() {
1951 "last": createPositionalPseudo(function( matchIndexes, length ) {
1952 return [ length - 1 ];
1955 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1956 return [ argument < 0 ? argument + length : argument ];
1959 "even": createPositionalPseudo(function( matchIndexes, length ) {
1961 for ( ; i < length; i += 2 ) {
1962 matchIndexes.push( i );
1964 return matchIndexes;
1967 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1969 for ( ; i < length; i += 2 ) {
1970 matchIndexes.push( i );
1972 return matchIndexes;
1975 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1976 var i = argument < 0 ? argument + length : argument;
1977 for ( ; --i >= 0; ) {
1978 matchIndexes.push( i );
1980 return matchIndexes;
1983 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1984 var i = argument < 0 ? argument + length : argument;
1985 for ( ; ++i < length; ) {
1986 matchIndexes.push( i );
1988 return matchIndexes;
1993 Expr.pseudos["nth"] = Expr.pseudos["eq"];
1995 // Add button/input type pseudos
1996 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
1997 Expr.pseudos[ i ] = createInputPseudo( i );
1999 for ( i in { submit: true, reset: true } ) {
2000 Expr.pseudos[ i ] = createButtonPseudo( i );
2003 // Easy API for creating new setFilters
2004 function setFilters() {}
2005 setFilters.prototype = Expr.filters = Expr.pseudos;
2006 Expr.setFilters = new setFilters();
2008 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2009 var matched, match, tokens, type,
2010 soFar, groups, preFilters,
2011 cached = tokenCache[ selector + " " ];
2014 return parseOnly ? 0 : cached.slice( 0 );
2019 preFilters = Expr.preFilter;
2023 // Comma and first run
2024 if ( !matched || (match = rcomma.exec( soFar )) ) {
2026 // Don't consume trailing commas as valid
2027 soFar = soFar.slice( match[0].length ) || soFar;
2029 groups.push( (tokens = []) );
2035 if ( (match = rcombinators.exec( soFar )) ) {
2036 matched = match.shift();
2039 // Cast descendant combinators to space
2040 type: match[0].replace( rtrim, " " )
2042 soFar = soFar.slice( matched.length );
2046 for ( type in Expr.filter ) {
2047 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2048 (match = preFilters[ type ]( match ))) ) {
2049 matched = match.shift();
2055 soFar = soFar.slice( matched.length );
2064 // Return the length of the invalid excess
2065 // if we're just parsing
2066 // Otherwise, throw an error or return tokens
2070 Sizzle.error( selector ) :
2072 tokenCache( selector, groups ).slice( 0 );
2075 function toSelector( tokens ) {
2077 len = tokens.length,
2079 for ( ; i < len; i++ ) {
2080 selector += tokens[i].value;
2085 function addCombinator( matcher, combinator, base ) {
2086 var dir = combinator.dir,
2087 checkNonElements = base && dir === "parentNode",
2090 return combinator.first ?
2091 // Check against closest ancestor/preceding element
2092 function( elem, context, xml ) {
2093 while ( (elem = elem[ dir ]) ) {
2094 if ( elem.nodeType === 1 || checkNonElements ) {
2095 return matcher( elem, context, xml );
2100 // Check against all ancestor/preceding elements
2101 function( elem, context, xml ) {
2102 var oldCache, outerCache,
2103 newCache = [ dirruns, doneName ];
2105 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2107 while ( (elem = elem[ dir ]) ) {
2108 if ( elem.nodeType === 1 || checkNonElements ) {
2109 if ( matcher( elem, context, xml ) ) {
2115 while ( (elem = elem[ dir ]) ) {
2116 if ( elem.nodeType === 1 || checkNonElements ) {
2117 outerCache = elem[ expando ] || (elem[ expando ] = {});
2118 if ( (oldCache = outerCache[ dir ]) &&
2119 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2121 // Assign to newCache so results back-propagate to previous elements
2122 return (newCache[ 2 ] = oldCache[ 2 ]);
2124 // Reuse newcache so results back-propagate to previous elements
2125 outerCache[ dir ] = newCache;
2127 // A match means we're done; a fail means we have to keep checking
2128 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2138 function elementMatcher( matchers ) {
2139 return matchers.length > 1 ?
2140 function( elem, context, xml ) {
2141 var i = matchers.length;
2143 if ( !matchers[i]( elem, context, xml ) ) {
2152 function multipleContexts( selector, contexts, results ) {
2154 len = contexts.length;
2155 for ( ; i < len; i++ ) {
2156 Sizzle( selector, contexts[i], results );
2161 function condense( unmatched, map, filter, context, xml ) {
2165 len = unmatched.length,
2166 mapped = map != null;
2168 for ( ; i < len; i++ ) {
2169 if ( (elem = unmatched[i]) ) {
2170 if ( !filter || filter( elem, context, xml ) ) {
2171 newUnmatched.push( elem );
2179 return newUnmatched;
2182 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2183 if ( postFilter && !postFilter[ expando ] ) {
2184 postFilter = setMatcher( postFilter );
2186 if ( postFinder && !postFinder[ expando ] ) {
2187 postFinder = setMatcher( postFinder, postSelector );
2189 return markFunction(function( seed, results, context, xml ) {
2193 preexisting = results.length,
2195 // Get initial elements from seed or context
2196 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2198 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2199 matcherIn = preFilter && ( seed || !selector ) ?
2200 condense( elems, preMap, preFilter, context, xml ) :
2203 matcherOut = matcher ?
2204 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2205 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2207 // ...intermediate processing is necessary
2210 // ...otherwise use results directly
2214 // Find primary matches
2216 matcher( matcherIn, matcherOut, context, xml );
2221 temp = condense( matcherOut, postMap );
2222 postFilter( temp, [], context, xml );
2224 // Un-match failing elements by moving them back to matcherIn
2227 if ( (elem = temp[i]) ) {
2228 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2234 if ( postFinder || preFilter ) {
2236 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2238 i = matcherOut.length;
2240 if ( (elem = matcherOut[i]) ) {
2241 // Restore matcherIn since elem is not yet a final match
2242 temp.push( (matcherIn[i] = elem) );
2245 postFinder( null, (matcherOut = []), temp, xml );
2248 // Move matched elements from seed to results to keep them synchronized
2249 i = matcherOut.length;
2251 if ( (elem = matcherOut[i]) &&
2252 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2254 seed[temp] = !(results[temp] = elem);
2259 // Add elements to results, through postFinder if defined
2261 matcherOut = condense(
2262 matcherOut === results ?
2263 matcherOut.splice( preexisting, matcherOut.length ) :
2267 postFinder( null, results, matcherOut, xml );
2269 push.apply( results, matcherOut );
2275 function matcherFromTokens( tokens ) {
2276 var checkContext, matcher, j,
2277 len = tokens.length,
2278 leadingRelative = Expr.relative[ tokens[0].type ],
2279 implicitRelative = leadingRelative || Expr.relative[" "],
2280 i = leadingRelative ? 1 : 0,
2282 // The foundational matcher ensures that elements are reachable from top-level context(s)
2283 matchContext = addCombinator( function( elem ) {
2284 return elem === checkContext;
2285 }, implicitRelative, true ),
2286 matchAnyContext = addCombinator( function( elem ) {
2287 return indexOf( checkContext, elem ) > -1;
2288 }, implicitRelative, true ),
2289 matchers = [ function( elem, context, xml ) {
2290 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2291 (checkContext = context).nodeType ?
2292 matchContext( elem, context, xml ) :
2293 matchAnyContext( elem, context, xml ) );
2294 // Avoid hanging onto element (issue #299)
2295 checkContext = null;
2299 for ( ; i < len; i++ ) {
2300 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2301 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2303 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2305 // Return special upon seeing a positional matcher
2306 if ( matcher[ expando ] ) {
2307 // Find the next relative operator (if any) for proper handling
2309 for ( ; j < len; j++ ) {
2310 if ( Expr.relative[ tokens[j].type ] ) {
2315 i > 1 && elementMatcher( matchers ),
2316 i > 1 && toSelector(
2317 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2318 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2319 ).replace( rtrim, "$1" ),
2321 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2322 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2323 j < len && toSelector( tokens )
2326 matchers.push( matcher );
2330 return elementMatcher( matchers );
2333 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2334 var bySet = setMatchers.length > 0,
2335 byElement = elementMatchers.length > 0,
2336 superMatcher = function( seed, context, xml, results, outermost ) {
2337 var elem, j, matcher,
2340 unmatched = seed && [],
2342 contextBackup = outermostContext,
2343 // We must always have either seed elements or outermost context
2344 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2345 // Use integer dirruns iff this is the outermost matcher
2346 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2350 outermostContext = context !== document && context;
2353 // Add elements passing elementMatchers directly to results
2354 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2355 // Support: IE<9, Safari
2356 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2357 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2358 if ( byElement && elem ) {
2360 while ( (matcher = elementMatchers[j++]) ) {
2361 if ( matcher( elem, context, xml ) ) {
2362 results.push( elem );
2367 dirruns = dirrunsUnique;
2371 // Track unmatched elements for set filters
2373 // They will have gone through all possible matchers
2374 if ( (elem = !matcher && elem) ) {
2378 // Lengthen the array for every element, matched or not
2380 unmatched.push( elem );
2385 // Apply set filters to unmatched elements
2387 if ( bySet && i !== matchedCount ) {
2389 while ( (matcher = setMatchers[j++]) ) {
2390 matcher( unmatched, setMatched, context, xml );
2394 // Reintegrate element matches to eliminate the need for sorting
2395 if ( matchedCount > 0 ) {
2397 if ( !(unmatched[i] || setMatched[i]) ) {
2398 setMatched[i] = pop.call( results );
2403 // Discard index placeholder values to get only actual matches
2404 setMatched = condense( setMatched );
2407 // Add matches to results
2408 push.apply( results, setMatched );
2410 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2411 if ( outermost && !seed && setMatched.length > 0 &&
2412 ( matchedCount + setMatchers.length ) > 1 ) {
2414 Sizzle.uniqueSort( results );
2418 // Override manipulation of globals by nested matchers
2420 dirruns = dirrunsUnique;
2421 outermostContext = contextBackup;
2428 markFunction( superMatcher ) :
2432 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2435 elementMatchers = [],
2436 cached = compilerCache[ selector + " " ];
2439 // Generate a function of recursive functions that can be used to check each element
2441 match = tokenize( selector );
2445 cached = matcherFromTokens( match[i] );
2446 if ( cached[ expando ] ) {
2447 setMatchers.push( cached );
2449 elementMatchers.push( cached );
2453 // Cache the compiled function
2454 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2456 // Save selector and tokenization
2457 cached.selector = selector;
2463 * A low-level selection function that works with Sizzle's compiled
2464 * selector functions
2465 * @param {String|Function} selector A selector or a pre-compiled
2466 * selector function built with Sizzle.compile
2467 * @param {Element} context
2468 * @param {Array} [results]
2469 * @param {Array} [seed] A set of elements to match against
2471 select = Sizzle.select = function( selector, context, results, seed ) {
2472 var i, tokens, token, type, find,
2473 compiled = typeof selector === "function" && selector,
2474 match = !seed && tokenize( (selector = compiled.selector || selector) );
2476 results = results || [];
2478 // Try to minimize operations if there is no seed and 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 // Precompiled matchers will still verify ancestry, so step up a level
2492 } else if ( compiled ) {
2493 context = context.parentNode;
2496 selector = selector.slice( tokens.shift().value.length );
2499 // Fetch a seed set for right-to-left matching
2500 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2504 // Abort if we hit a combinator
2505 if ( Expr.relative[ (type = token.type) ] ) {
2508 if ( (find = Expr.find[ type ]) ) {
2509 // Search, expanding context for leading sibling combinators
2511 token.matches[0].replace( runescape, funescape ),
2512 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2515 // If seed is empty or no tokens remain, we can return early
2516 tokens.splice( i, 1 );
2517 selector = seed.length && toSelector( tokens );
2519 push.apply( results, seed );
2529 // Compile and execute a filtering function if one is not provided
2530 // Provide `match` to avoid retokenization if we modified the selector above
2531 ( compiled || compile( selector, match ) )(
2536 rsibling.test( selector ) && testContext( context.parentNode ) || context
2541 // One-time assignments
2544 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2546 // Support: Chrome 14-35+
2547 // Always assume duplicates if they aren't passed to the comparison function
2548 support.detectDuplicates = !!hasDuplicate;
2550 // Initialize against the default document
2553 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2554 // Detached nodes confoundingly follow *each other*
2555 support.sortDetached = assert(function( div1 ) {
2556 // Should return 1, but returns 4 (following)
2557 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2561 // Prevent attribute/property "interpolation"
2562 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2563 if ( !assert(function( div ) {
2564 div.innerHTML = "<a href='#'></a>";
2565 return div.firstChild.getAttribute("href") === "#" ;
2567 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2569 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2575 // Use defaultValue in place of getAttribute("value")
2576 if ( !support.attributes || !assert(function( div ) {
2577 div.innerHTML = "<input/>";
2578 div.firstChild.setAttribute( "value", "" );
2579 return div.firstChild.getAttribute( "value" ) === "";
2581 addHandle( "value", function( elem, name, isXML ) {
2582 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2583 return elem.defaultValue;
2589 // Use getAttributeNode to fetch booleans when getAttribute lies
2590 if ( !assert(function( div ) {
2591 return div.getAttribute("disabled") == null;
2593 addHandle( booleans, function( elem, name, isXML ) {
2596 return elem[ name ] === true ? name.toLowerCase() :
2597 (val = elem.getAttributeNode( name )) && val.specified ?
2610 jQuery.find = Sizzle;
2611 jQuery.expr = Sizzle.selectors;
2612 jQuery.expr[":"] = jQuery.expr.pseudos;
2613 jQuery.unique = Sizzle.uniqueSort;
2614 jQuery.text = Sizzle.getText;
2615 jQuery.isXMLDoc = Sizzle.isXML;
2616 jQuery.contains = Sizzle.contains;
2620 var rneedsContext = jQuery.expr.match.needsContext;
2622 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2626 var risSimple = /^.[^:#\[\.,]*$/;
2628 // Implement the identical functionality for filter and not
2629 function winnow( elements, qualifier, not ) {
2630 if ( jQuery.isFunction( qualifier ) ) {
2631 return jQuery.grep( elements, function( elem, i ) {
2633 return !!qualifier.call( elem, i, elem ) !== not;
2638 if ( qualifier.nodeType ) {
2639 return jQuery.grep( elements, function( elem ) {
2640 return ( elem === qualifier ) !== not;
2645 if ( typeof qualifier === "string" ) {
2646 if ( risSimple.test( qualifier ) ) {
2647 return jQuery.filter( qualifier, elements, not );
2650 qualifier = jQuery.filter( qualifier, elements );
2653 return jQuery.grep( elements, function( elem ) {
2654 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
2658 jQuery.filter = function( expr, elems, not ) {
2659 var elem = elems[ 0 ];
2662 expr = ":not(" + expr + ")";
2665 return elems.length === 1 && elem.nodeType === 1 ?
2666 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2667 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2668 return elem.nodeType === 1;
2673 find: function( selector ) {
2679 if ( typeof selector !== "string" ) {
2680 return this.pushStack( jQuery( selector ).filter(function() {
2681 for ( i = 0; i < len; i++ ) {
2682 if ( jQuery.contains( self[ i ], this ) ) {
2689 for ( i = 0; i < len; i++ ) {
2690 jQuery.find( selector, self[ i ], ret );
2693 // Needed because $( selector, context ) becomes $( context ).find( selector )
2694 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2695 ret.selector = this.selector ? this.selector + " " + selector : selector;
2698 filter: function( selector ) {
2699 return this.pushStack( winnow(this, selector || [], false) );
2701 not: function( selector ) {
2702 return this.pushStack( winnow(this, selector || [], true) );
2704 is: function( selector ) {
2708 // If this is a positional/relative selector, check membership in the returned set
2709 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2710 typeof selector === "string" && rneedsContext.test( selector ) ?
2711 jQuery( selector ) :
2719 // Initialize a jQuery object
2722 // A central reference to the root jQuery(document)
2725 // A simple way to check for HTML strings
2726 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2727 // Strict HTML recognition (#11290: must start with <)
2728 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2730 init = jQuery.fn.init = function( selector, context ) {
2733 // HANDLE: $(""), $(null), $(undefined), $(false)
2738 // Handle HTML strings
2739 if ( typeof selector === "string" ) {
2740 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
2741 // Assume that strings that start and end with <> are HTML and skip the regex check
2742 match = [ null, selector, null ];
2745 match = rquickExpr.exec( selector );
2748 // Match html or make sure no context is specified for #id
2749 if ( match && (match[1] || !context) ) {
2751 // HANDLE: $(html) -> $(array)
2753 context = context instanceof jQuery ? context[0] : context;
2755 // Option to run scripts is true for back-compat
2756 // Intentionally let the error be thrown if parseHTML is not present
2757 jQuery.merge( this, jQuery.parseHTML(
2759 context && context.nodeType ? context.ownerDocument || context : document,
2763 // HANDLE: $(html, props)
2764 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2765 for ( match in context ) {
2766 // Properties of context are called as methods if possible
2767 if ( jQuery.isFunction( this[ match ] ) ) {
2768 this[ match ]( context[ match ] );
2770 // ...and otherwise set as attributes
2772 this.attr( match, context[ match ] );
2781 elem = document.getElementById( match[2] );
2783 // Support: Blackberry 4.6
2784 // gEBID returns nodes no longer in the document (#6963)
2785 if ( elem && elem.parentNode ) {
2786 // Inject the element directly into the jQuery object
2791 this.context = document;
2792 this.selector = selector;
2796 // HANDLE: $(expr, $(...))
2797 } else if ( !context || context.jquery ) {
2798 return ( context || rootjQuery ).find( selector );
2800 // HANDLE: $(expr, context)
2801 // (which is just equivalent to: $(context).find(expr)
2803 return this.constructor( context ).find( selector );
2806 // HANDLE: $(DOMElement)
2807 } else if ( selector.nodeType ) {
2808 this.context = this[0] = selector;
2812 // HANDLE: $(function)
2813 // Shortcut for document ready
2814 } else if ( jQuery.isFunction( selector ) ) {
2815 return typeof rootjQuery.ready !== "undefined" ?
2816 rootjQuery.ready( selector ) :
2817 // Execute immediately if ready is not present
2821 if ( selector.selector !== undefined ) {
2822 this.selector = selector.selector;
2823 this.context = selector.context;
2826 return jQuery.makeArray( selector, this );
2829 // Give the init function the jQuery prototype for later instantiation
2830 init.prototype = jQuery.fn;
2832 // Initialize central reference
2833 rootjQuery = jQuery( document );
2836 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2837 // Methods guaranteed to produce a unique set when starting from a unique set
2838 guaranteedUnique = {
2846 dir: function( elem, dir, until ) {
2848 truncate = until !== undefined;
2850 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
2851 if ( elem.nodeType === 1 ) {
2852 if ( truncate && jQuery( elem ).is( until ) ) {
2855 matched.push( elem );
2861 sibling: function( n, elem ) {
2864 for ( ; n; n = n.nextSibling ) {
2865 if ( n.nodeType === 1 && n !== elem ) {
2875 has: function( target ) {
2876 var targets = jQuery( target, this ),
2879 return this.filter(function() {
2881 for ( ; i < l; i++ ) {
2882 if ( jQuery.contains( this, targets[i] ) ) {
2889 closest: function( selectors, context ) {
2894 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
2895 jQuery( selectors, context || this.context ) :
2898 for ( ; i < l; i++ ) {
2899 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
2900 // Always skip document fragments
2901 if ( cur.nodeType < 11 && (pos ?
2902 pos.index(cur) > -1 :
2904 // Don't pass non-elements to Sizzle
2905 cur.nodeType === 1 &&
2906 jQuery.find.matchesSelector(cur, selectors)) ) {
2908 matched.push( cur );
2914 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
2917 // Determine the position of an element within the set
2918 index: function( elem ) {
2920 // No argument, return index in parent
2922 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
2925 // Index in selector
2926 if ( typeof elem === "string" ) {
2927 return indexOf.call( jQuery( elem ), this[ 0 ] );
2930 // Locate the position of the desired element
2931 return indexOf.call( this,
2933 // If it receives a jQuery object, the first element is used
2934 elem.jquery ? elem[ 0 ] : elem
2938 add: function( selector, context ) {
2939 return this.pushStack(
2941 jQuery.merge( this.get(), jQuery( selector, context ) )
2946 addBack: function( selector ) {
2947 return this.add( selector == null ?
2948 this.prevObject : this.prevObject.filter(selector)
2953 function sibling( cur, dir ) {
2954 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
2959 parent: function( elem ) {
2960 var parent = elem.parentNode;
2961 return parent && parent.nodeType !== 11 ? parent : null;
2963 parents: function( elem ) {
2964 return jQuery.dir( elem, "parentNode" );
2966 parentsUntil: function( elem, i, until ) {
2967 return jQuery.dir( elem, "parentNode", until );
2969 next: function( elem ) {
2970 return sibling( elem, "nextSibling" );
2972 prev: function( elem ) {
2973 return sibling( elem, "previousSibling" );
2975 nextAll: function( elem ) {
2976 return jQuery.dir( elem, "nextSibling" );
2978 prevAll: function( elem ) {
2979 return jQuery.dir( elem, "previousSibling" );
2981 nextUntil: function( elem, i, until ) {
2982 return jQuery.dir( elem, "nextSibling", until );
2984 prevUntil: function( elem, i, until ) {
2985 return jQuery.dir( elem, "previousSibling", until );
2987 siblings: function( elem ) {
2988 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
2990 children: function( elem ) {
2991 return jQuery.sibling( elem.firstChild );
2993 contents: function( elem ) {
2994 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
2996 }, function( name, fn ) {
2997 jQuery.fn[ name ] = function( until, selector ) {
2998 var matched = jQuery.map( this, fn, until );
3000 if ( name.slice( -5 ) !== "Until" ) {
3004 if ( selector && typeof selector === "string" ) {
3005 matched = jQuery.filter( selector, matched );
3008 if ( this.length > 1 ) {
3009 // Remove duplicates
3010 if ( !guaranteedUnique[ name ] ) {
3011 jQuery.unique( matched );
3014 // Reverse order for parents* and prev-derivatives
3015 if ( rparentsprev.test( name ) ) {
3020 return this.pushStack( matched );
3023 var rnotwhite = (/\S+/g);
3027 // String to Object options format cache
3028 var optionsCache = {};
3030 // Convert String-formatted options into Object-formatted ones and store in cache
3031 function createOptions( options ) {
3032 var object = optionsCache[ options ] = {};
3033 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
3034 object[ flag ] = true;
3040 * Create a callback list using the following parameters:
3042 * options: an optional list of space-separated options that will change how
3043 * the callback list behaves or a more traditional option object
3045 * By default a callback list will act like an event callback list and can be
3046 * "fired" multiple times.
3050 * once: will ensure the callback list can only be fired once (like a Deferred)
3052 * memory: will keep track of previous values and will call any callback added
3053 * after the list has been fired right away with the latest "memorized"
3054 * values (like a Deferred)
3056 * unique: will ensure a callback can only be added once (no duplicate in the list)
3058 * stopOnFalse: interrupt callings when a callback returns false
3061 jQuery.Callbacks = function( options ) {
3063 // Convert options from String-formatted to Object-formatted if needed
3064 // (we check in cache first)
3065 options = typeof options === "string" ?
3066 ( optionsCache[ options ] || createOptions( options ) ) :
3067 jQuery.extend( {}, options );
3069 var // Last fire value (for non-forgettable lists)
3071 // Flag to know if list was already fired
3073 // Flag to know if list is currently firing
3075 // First callback to fire (used internally by add and fireWith)
3077 // End of the loop when firing
3079 // Index of currently firing callback (modified by remove if needed)
3081 // Actual callback list
3083 // Stack of fire calls for repeatable lists
3084 stack = !options.once && [],
3086 fire = function( data ) {
3087 memory = options.memory && data;
3089 firingIndex = firingStart || 0;
3091 firingLength = list.length;
3093 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3094 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
3095 memory = false; // To prevent further calls using add
3102 if ( stack.length ) {
3103 fire( stack.shift() );
3105 } else if ( memory ) {
3112 // Actual Callbacks object
3114 // Add a callback or a collection of callbacks to the list
3117 // First, we save the current length
3118 var start = list.length;
3119 (function add( args ) {
3120 jQuery.each( args, function( _, arg ) {
3121 var type = jQuery.type( arg );
3122 if ( type === "function" ) {
3123 if ( !options.unique || !self.has( arg ) ) {
3126 } else if ( arg && arg.length && type !== "string" ) {
3127 // Inspect recursively
3132 // Do we need to add the callbacks to the
3133 // current firing batch?
3135 firingLength = list.length;
3136 // With memory, if we're not firing then
3137 // we should call right away
3138 } else if ( memory ) {
3139 firingStart = start;
3145 // Remove a callback from the list
3146 remove: function() {
3148 jQuery.each( arguments, function( _, arg ) {
3150 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3151 list.splice( index, 1 );
3152 // Handle firing indexes
3154 if ( index <= firingLength ) {
3157 if ( index <= firingIndex ) {
3166 // Check if a given callback is in the list.
3167 // If no argument is given, return whether or not list has callbacks attached.
3168 has: function( fn ) {
3169 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
3171 // Remove all callbacks from the list
3177 // Have the list do nothing anymore
3178 disable: function() {
3179 list = stack = memory = undefined;
3183 disabled: function() {
3186 // Lock the list in its current state
3195 locked: function() {
3198 // Call all callbacks with the given context and arguments
3199 fireWith: function( context, args ) {
3200 if ( list && ( !fired || stack ) ) {
3202 args = [ context, args.slice ? args.slice() : args ];
3211 // Call all the callbacks with the given arguments
3213 self.fireWith( this, arguments );
3216 // To know if the callbacks have already been called at least once
3228 Deferred: function( func ) {
3230 // action, add listener, listener list, final state
3231 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
3232 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
3233 [ "notify", "progress", jQuery.Callbacks("memory") ]
3240 always: function() {
3241 deferred.done( arguments ).fail( arguments );
3244 then: function( /* fnDone, fnFail, fnProgress */ ) {
3245 var fns = arguments;
3246 return jQuery.Deferred(function( newDefer ) {
3247 jQuery.each( tuples, function( i, tuple ) {
3248 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3249 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3250 deferred[ tuple[1] ](function() {
3251 var returned = fn && fn.apply( this, arguments );
3252 if ( returned && jQuery.isFunction( returned.promise ) ) {
3254 .done( newDefer.resolve )
3255 .fail( newDefer.reject )
3256 .progress( newDefer.notify );
3258 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
3265 // Get a promise for this deferred
3266 // If obj is provided, the promise aspect is added to the object
3267 promise: function( obj ) {
3268 return obj != null ? jQuery.extend( obj, promise ) : promise;
3273 // Keep pipe for back-compat
3274 promise.pipe = promise.then;
3276 // Add list-specific methods
3277 jQuery.each( tuples, function( i, tuple ) {
3278 var list = tuple[ 2 ],
3279 stateString = tuple[ 3 ];
3281 // promise[ done | fail | progress ] = list.add
3282 promise[ tuple[1] ] = list.add;
3285 if ( stateString ) {
3286 list.add(function() {
3287 // state = [ resolved | rejected ]
3288 state = stateString;
3290 // [ reject_list | resolve_list ].disable; progress_list.lock
3291 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3294 // deferred[ resolve | reject | notify ]
3295 deferred[ tuple[0] ] = function() {
3296 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
3299 deferred[ tuple[0] + "With" ] = list.fireWith;
3302 // Make the deferred a promise
3303 promise.promise( deferred );
3305 // Call given func if any
3307 func.call( deferred, deferred );
3315 when: function( subordinate /* , ..., subordinateN */ ) {
3317 resolveValues = slice.call( arguments ),
3318 length = resolveValues.length,
3320 // the count of uncompleted subordinates
3321 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3323 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3324 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3326 // Update function for both resolve and progress values
3327 updateFunc = function( i, contexts, values ) {
3328 return function( value ) {
3329 contexts[ i ] = this;
3330 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
3331 if ( values === progressValues ) {
3332 deferred.notifyWith( contexts, values );
3333 } else if ( !( --remaining ) ) {
3334 deferred.resolveWith( contexts, values );
3339 progressValues, progressContexts, resolveContexts;
3341 // Add listeners to Deferred subordinates; treat others as resolved
3343 progressValues = new Array( length );
3344 progressContexts = new Array( length );
3345 resolveContexts = new Array( length );
3346 for ( ; i < length; i++ ) {
3347 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3348 resolveValues[ i ].promise()
3349 .done( updateFunc( i, resolveContexts, resolveValues ) )
3350 .fail( deferred.reject )
3351 .progress( updateFunc( i, progressContexts, progressValues ) );
3358 // If we're not waiting on anything, resolve the master
3360 deferred.resolveWith( resolveContexts, resolveValues );
3363 return deferred.promise();
3368 // The deferred used on DOM ready
3371 jQuery.fn.ready = function( fn ) {
3373 jQuery.ready.promise().done( fn );
3379 // Is the DOM ready to be used? Set to true once it occurs.
3382 // A counter to track how many items to wait for before
3383 // the ready event fires. See #6781
3386 // Hold (or release) the ready event
3387 holdReady: function( hold ) {
3391 jQuery.ready( true );
3395 // Handle when the DOM is ready
3396 ready: function( wait ) {
3398 // Abort if there are pending holds or we're already ready
3399 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
3403 // Remember that the DOM is ready
3404 jQuery.isReady = true;
3406 // If a normal DOM Ready event fired, decrement, and wait if need be
3407 if ( wait !== true && --jQuery.readyWait > 0 ) {
3411 // If there are functions bound, to execute
3412 readyList.resolveWith( document, [ jQuery ] );
3414 // Trigger any bound ready events
3415 if ( jQuery.fn.triggerHandler ) {
3416 jQuery( document ).triggerHandler( "ready" );
3417 jQuery( document ).off( "ready" );
3423 * The ready event handler and self cleanup method
3425 function completed() {
3426 document.removeEventListener( "DOMContentLoaded", completed, false );
3427 window.removeEventListener( "load", completed, false );
3431 jQuery.ready.promise = function( obj ) {
3434 readyList = jQuery.Deferred();
3436 // Catch cases where $(document).ready() is called after the browser event has already occurred.
3437 // We once tried to use readyState "interactive" here, but it caused issues like the one
3438 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
3439 if ( document.readyState === "complete" ) {
3440 // Handle it asynchronously to allow scripts the opportunity to delay ready
3441 setTimeout( jQuery.ready );
3445 // Use the handy event callback
3446 document.addEventListener( "DOMContentLoaded", completed, false );
3448 // A fallback to window.onload, that will always work
3449 window.addEventListener( "load", completed, false );
3452 return readyList.promise( obj );
3455 // Kick off the DOM ready check even if the user does not
3456 jQuery.ready.promise();
3461 // Multifunctional method to get and set values of a collection
3462 // The value/s can optionally be executed if it's a function
3463 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
3469 if ( jQuery.type( key ) === "object" ) {
3472 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
3476 } else if ( value !== undefined ) {
3479 if ( !jQuery.isFunction( value ) ) {
3484 // Bulk operations run against the entire set
3486 fn.call( elems, value );
3489 // ...except when executing function values
3492 fn = function( elem, key, value ) {
3493 return bulk.call( jQuery( elem ), value );
3499 for ( ; i < len; i++ ) {
3500 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
3511 len ? fn( elems[0], key ) : emptyGet;
3516 * Determines whether an object can have data
3518 jQuery.acceptData = function( owner ) {
3521 // - Node.ELEMENT_NODE
3522 // - Node.DOCUMENT_NODE
3526 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
3531 // Support: Android<4,
3532 // Old WebKit does not have Object.preventExtensions/freeze method,
3533 // return new empty object instead with no [[set]] accessor
3534 Object.defineProperty( this.cache = {}, 0, {
3540 this.expando = jQuery.expando + Data.uid++;
3544 Data.accepts = jQuery.acceptData;
3547 key: function( owner ) {
3548 // We can accept data for non-element nodes in modern browsers,
3549 // but we should not, see #8335.
3550 // Always return the key for a frozen object.
3551 if ( !Data.accepts( owner ) ) {
3555 var descriptor = {},
3556 // Check if the owner object already has a cache key
3557 unlock = owner[ this.expando ];
3559 // If not, create one
3561 unlock = Data.uid++;
3563 // Secure it in a non-enumerable, non-writable property
3565 descriptor[ this.expando ] = { value: unlock };
3566 Object.defineProperties( owner, descriptor );
3568 // Support: Android<4
3569 // Fallback to a less secure definition
3571 descriptor[ this.expando ] = unlock;
3572 jQuery.extend( owner, descriptor );
3576 // Ensure the cache object
3577 if ( !this.cache[ unlock ] ) {
3578 this.cache[ unlock ] = {};
3583 set: function( owner, data, value ) {
3585 // There may be an unlock assigned to this node,
3586 // if there is no entry for this "owner", create one inline
3587 // and set the unlock as though an owner entry had always existed
3588 unlock = this.key( owner ),
3589 cache = this.cache[ unlock ];
3591 // Handle: [ owner, key, value ] args
3592 if ( typeof data === "string" ) {
3593 cache[ data ] = value;
3595 // Handle: [ owner, { properties } ] args
3597 // Fresh assignments by object are shallow copied
3598 if ( jQuery.isEmptyObject( cache ) ) {
3599 jQuery.extend( this.cache[ unlock ], data );
3600 // Otherwise, copy the properties one-by-one to the cache object
3602 for ( prop in data ) {
3603 cache[ prop ] = data[ prop ];
3609 get: function( owner, key ) {
3610 // Either a valid cache is found, or will be created.
3611 // New caches will be created and the unlock returned,
3612 // allowing direct access to the newly created
3613 // empty data object. A valid owner object must be provided.
3614 var cache = this.cache[ this.key( owner ) ];
3616 return key === undefined ?
3617 cache : cache[ key ];
3619 access: function( owner, key, value ) {
3621 // In cases where either:
3623 // 1. No key was specified
3624 // 2. A string key was specified, but no value provided
3626 // Take the "read" path and allow the get method to determine
3627 // which value to return, respectively either:
3629 // 1. The entire cache object
3630 // 2. The data stored at the key
3632 if ( key === undefined ||
3633 ((key && typeof key === "string") && value === undefined) ) {
3635 stored = this.get( owner, key );
3637 return stored !== undefined ?
3638 stored : this.get( owner, jQuery.camelCase(key) );
3641 // [*]When the key is not a string, or both a key and value
3642 // are specified, set or extend (existing objects) with either:
3644 // 1. An object of properties
3645 // 2. A key and value
3647 this.set( owner, key, value );
3649 // Since the "set" path can have two possible entry points
3650 // return the expected data based on which path was taken[*]
3651 return value !== undefined ? value : key;
3653 remove: function( owner, key ) {
3655 unlock = this.key( owner ),
3656 cache = this.cache[ unlock ];
3658 if ( key === undefined ) {
3659 this.cache[ unlock ] = {};
3662 // Support array or space separated string of keys
3663 if ( jQuery.isArray( key ) ) {
3664 // If "name" is an array of keys...
3665 // When data is initially created, via ("key", "val") signature,
3666 // keys will be converted to camelCase.
3667 // Since there is no way to tell _how_ a key was added, remove
3668 // both plain key and camelCase key. #12786
3669 // This will only penalize the array argument path.
3670 name = key.concat( key.map( jQuery.camelCase ) );
3672 camel = jQuery.camelCase( key );
3673 // Try the string as a key before any manipulation
3674 if ( key in cache ) {
3675 name = [ key, camel ];
3677 // If a key with the spaces exists, use it.
3678 // Otherwise, create an array by matching non-whitespace
3680 name = name in cache ?
3681 [ name ] : ( name.match( rnotwhite ) || [] );
3687 delete cache[ name[ i ] ];
3691 hasData: function( owner ) {
3692 return !jQuery.isEmptyObject(
3693 this.cache[ owner[ this.expando ] ] || {}
3696 discard: function( owner ) {
3697 if ( owner[ this.expando ] ) {
3698 delete this.cache[ owner[ this.expando ] ];
3702 var data_priv = new Data();
3704 var data_user = new Data();
3708 // Implementation Summary
3710 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
3711 // 2. Improve the module's maintainability by reducing the storage
3712 // paths to a single mechanism.
3713 // 3. Use the same single mechanism to support "private" and "user" data.
3714 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
3715 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
3716 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
3718 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3719 rmultiDash = /([A-Z])/g;
3721 function dataAttr( elem, key, data ) {
3724 // If nothing was found internally, try to fetch any
3725 // data from the HTML5 data-* attribute
3726 if ( data === undefined && elem.nodeType === 1 ) {
3727 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3728 data = elem.getAttribute( name );
3730 if ( typeof data === "string" ) {
3732 data = data === "true" ? true :
3733 data === "false" ? false :
3734 data === "null" ? null :
3735 // Only convert to a number if it doesn't change the string
3736 +data + "" === data ? +data :
3737 rbrace.test( data ) ? jQuery.parseJSON( data ) :
3741 // Make sure we set the data so it isn't changed later
3742 data_user.set( elem, key, data );
3751 hasData: function( elem ) {
3752 return data_user.hasData( elem ) || data_priv.hasData( elem );
3755 data: function( elem, name, data ) {
3756 return data_user.access( elem, name, data );
3759 removeData: function( elem, name ) {
3760 data_user.remove( elem, name );
3763 // TODO: Now that all calls to _data and _removeData have been replaced
3764 // with direct calls to data_priv methods, these can be deprecated.
3765 _data: function( elem, name, data ) {
3766 return data_priv.access( elem, name, data );
3769 _removeData: function( elem, name ) {
3770 data_priv.remove( elem, name );
3775 data: function( key, value ) {
3778 attrs = elem && elem.attributes;
3781 if ( key === undefined ) {
3782 if ( this.length ) {
3783 data = data_user.get( elem );
3785 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
3790 // The attrs elements can be null (#14894)
3792 name = attrs[ i ].name;
3793 if ( name.indexOf( "data-" ) === 0 ) {
3794 name = jQuery.camelCase( name.slice(5) );
3795 dataAttr( elem, name, data[ name ] );
3799 data_priv.set( elem, "hasDataAttrs", true );
3806 // Sets multiple values
3807 if ( typeof key === "object" ) {
3808 return this.each(function() {
3809 data_user.set( this, key );
3813 return access( this, function( value ) {
3815 camelKey = jQuery.camelCase( key );
3817 // The calling jQuery object (element matches) is not empty
3818 // (and therefore has an element appears at this[ 0 ]) and the
3819 // `value` parameter was not undefined. An empty jQuery object
3820 // will result in `undefined` for elem = this[ 0 ] which will
3821 // throw an exception if an attempt to read a data cache is made.
3822 if ( elem && value === undefined ) {
3823 // Attempt to get data from the cache
3824 // with the key as-is
3825 data = data_user.get( elem, key );
3826 if ( data !== undefined ) {
3830 // Attempt to get data from the cache
3831 // with the key camelized
3832 data = data_user.get( elem, camelKey );
3833 if ( data !== undefined ) {
3837 // Attempt to "discover" the data in
3838 // HTML5 custom data-* attrs
3839 data = dataAttr( elem, camelKey, undefined );
3840 if ( data !== undefined ) {
3844 // We tried really hard, but the data doesn't exist.
3849 this.each(function() {
3850 // First, attempt to store a copy or reference of any
3851 // data that might've been store with a camelCased key.
3852 var data = data_user.get( this, camelKey );
3854 // For HTML5 data-* attribute interop, we have to
3855 // store property names with dashes in a camelCase form.
3856 // This might not apply to all properties...*
3857 data_user.set( this, camelKey, value );
3859 // *... In the case of properties that might _actually_
3860 // have dashes, we need to also store a copy of that
3861 // unchanged property.
3862 if ( key.indexOf("-") !== -1 && data !== undefined ) {
3863 data_user.set( this, key, value );
3866 }, null, value, arguments.length > 1, null, true );
3869 removeData: function( key ) {
3870 return this.each(function() {
3871 data_user.remove( this, key );
3878 queue: function( elem, type, data ) {
3882 type = ( type || "fx" ) + "queue";
3883 queue = data_priv.get( elem, type );
3885 // Speed up dequeue by getting out quickly if this is just a lookup
3887 if ( !queue || jQuery.isArray( data ) ) {
3888 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
3897 dequeue: function( elem, type ) {
3898 type = type || "fx";
3900 var queue = jQuery.queue( elem, type ),
3901 startLength = queue.length,
3903 hooks = jQuery._queueHooks( elem, type ),
3905 jQuery.dequeue( elem, type );
3908 // If the fx queue is dequeued, always remove the progress sentinel
3909 if ( fn === "inprogress" ) {
3916 // Add a progress sentinel to prevent the fx queue from being
3917 // automatically dequeued
3918 if ( type === "fx" ) {
3919 queue.unshift( "inprogress" );
3922 // Clear up the last queue stop function
3924 fn.call( elem, next, hooks );
3927 if ( !startLength && hooks ) {
3932 // Not public - generate a queueHooks object, or return the current one
3933 _queueHooks: function( elem, type ) {
3934 var key = type + "queueHooks";
3935 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
3936 empty: jQuery.Callbacks("once memory").add(function() {
3937 data_priv.remove( elem, [ type + "queue", key ] );
3944 queue: function( type, data ) {
3947 if ( typeof type !== "string" ) {
3953 if ( arguments.length < setter ) {
3954 return jQuery.queue( this[0], type );
3957 return data === undefined ?
3959 this.each(function() {
3960 var queue = jQuery.queue( this, type, data );
3962 // Ensure a hooks for this queue
3963 jQuery._queueHooks( this, type );
3965 if ( type === "fx" && queue[0] !== "inprogress" ) {
3966 jQuery.dequeue( this, type );
3970 dequeue: function( type ) {
3971 return this.each(function() {
3972 jQuery.dequeue( this, type );
3975 clearQueue: function( type ) {
3976 return this.queue( type || "fx", [] );
3978 // Get a promise resolved when queues of a certain type
3979 // are emptied (fx is the type by default)
3980 promise: function( type, obj ) {
3983 defer = jQuery.Deferred(),
3986 resolve = function() {
3987 if ( !( --count ) ) {
3988 defer.resolveWith( elements, [ elements ] );
3992 if ( typeof type !== "string" ) {
3996 type = type || "fx";
3999 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
4000 if ( tmp && tmp.empty ) {
4002 tmp.empty.add( resolve );
4006 return defer.promise( obj );
4009 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
4011 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4013 var isHidden = function( elem, el ) {
4014 // isHidden might be called from jQuery#filter function;
4015 // in that case, element will be second argument
4017 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
4020 var rcheckableType = (/^(?:checkbox|radio)$/i);
4025 var fragment = document.createDocumentFragment(),
4026 div = fragment.appendChild( document.createElement( "div" ) ),
4027 input = document.createElement( "input" );
4029 // Support: Safari<=5.1
4030 // Check state lost if the name is set (#11217)
4031 // Support: Windows Web Apps (WWA)
4032 // `name` and `type` must use .setAttribute for WWA (#14901)
4033 input.setAttribute( "type", "radio" );
4034 input.setAttribute( "checked", "checked" );
4035 input.setAttribute( "name", "t" );
4037 div.appendChild( input );
4039 // Support: Safari<=5.1, Android<4.2
4040 // Older WebKit doesn't clone checked state correctly in fragments
4041 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4044 // Make sure textarea (and checkbox) defaultValue is properly cloned
4045 div.innerHTML = "<textarea>x</textarea>";
4046 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4048 var strundefined = typeof undefined;
4052 support.focusinBubbles = "onfocusin" in window;
4057 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
4058 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4059 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
4061 function returnTrue() {
4065 function returnFalse() {
4069 function safeActiveElement() {
4071 return document.activeElement;
4076 * Helper functions for managing events -- not part of the public interface.
4077 * Props to Dean Edwards' addEvent library for many of the ideas.
4083 add: function( elem, types, handler, data, selector ) {
4085 var handleObjIn, eventHandle, tmp,
4086 events, t, handleObj,
4087 special, handlers, type, namespaces, origType,
4088 elemData = data_priv.get( elem );
4090 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4095 // Caller can pass in an object of custom data in lieu of the handler
4096 if ( handler.handler ) {
4097 handleObjIn = handler;
4098 handler = handleObjIn.handler;
4099 selector = handleObjIn.selector;
4102 // Make sure that the handler has a unique ID, used to find/remove it later
4103 if ( !handler.guid ) {
4104 handler.guid = jQuery.guid++;
4107 // Init the element's event structure and main handler, if this is the first
4108 if ( !(events = elemData.events) ) {
4109 events = elemData.events = {};
4111 if ( !(eventHandle = elemData.handle) ) {
4112 eventHandle = elemData.handle = function( e ) {
4113 // Discard the second event of a jQuery.event.trigger() and
4114 // when an event is called after a page has unloaded
4115 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
4116 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
4120 // Handle multiple events separated by a space
4121 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4124 tmp = rtypenamespace.exec( types[t] ) || [];
4125 type = origType = tmp[1];
4126 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4128 // There *must* be a type, no attaching namespace-only handlers
4133 // If event changes its type, use the special event handlers for the changed type
4134 special = jQuery.event.special[ type ] || {};
4136 // If selector defined, determine special event api type, otherwise given type
4137 type = ( selector ? special.delegateType : special.bindType ) || type;
4139 // Update special based on newly reset type
4140 special = jQuery.event.special[ type ] || {};
4142 // handleObj is passed to all event handlers
4143 handleObj = jQuery.extend({
4150 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4151 namespace: namespaces.join(".")
4154 // Init the event handler queue if we're the first
4155 if ( !(handlers = events[ type ]) ) {
4156 handlers = events[ type ] = [];
4157 handlers.delegateCount = 0;
4159 // Only use addEventListener if the special events handler returns false
4160 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4161 if ( elem.addEventListener ) {
4162 elem.addEventListener( type, eventHandle, false );
4167 if ( special.add ) {
4168 special.add.call( elem, handleObj );
4170 if ( !handleObj.handler.guid ) {
4171 handleObj.handler.guid = handler.guid;
4175 // Add to the element's handler list, delegates in front
4177 handlers.splice( handlers.delegateCount++, 0, handleObj );
4179 handlers.push( handleObj );
4182 // Keep track of which events have ever been used, for event optimization
4183 jQuery.event.global[ type ] = true;
4188 // Detach an event or set of events from an element
4189 remove: function( elem, types, handler, selector, mappedTypes ) {
4191 var j, origCount, tmp,
4192 events, t, handleObj,
4193 special, handlers, type, namespaces, origType,
4194 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
4196 if ( !elemData || !(events = elemData.events) ) {
4200 // Once for each type.namespace in types; type may be omitted
4201 types = ( types || "" ).match( rnotwhite ) || [ "" ];
4204 tmp = rtypenamespace.exec( types[t] ) || [];
4205 type = origType = tmp[1];
4206 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4208 // Unbind all events (on this namespace, if provided) for the element
4210 for ( type in events ) {
4211 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4216 special = jQuery.event.special[ type ] || {};
4217 type = ( selector ? special.delegateType : special.bindType ) || type;
4218 handlers = events[ type ] || [];
4219 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4221 // Remove matching events
4222 origCount = j = handlers.length;
4224 handleObj = handlers[ j ];
4226 if ( ( mappedTypes || origType === handleObj.origType ) &&
4227 ( !handler || handler.guid === handleObj.guid ) &&
4228 ( !tmp || tmp.test( handleObj.namespace ) ) &&
4229 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
4230 handlers.splice( j, 1 );
4232 if ( handleObj.selector ) {
4233 handlers.delegateCount--;
4235 if ( special.remove ) {
4236 special.remove.call( elem, handleObj );
4241 // Remove generic event handler if we removed something and no more handlers exist
4242 // (avoids potential for endless recursion during removal of special event handlers)
4243 if ( origCount && !handlers.length ) {
4244 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
4245 jQuery.removeEvent( elem, type, elemData.handle );
4248 delete events[ type ];
4252 // Remove the expando if it's no longer used
4253 if ( jQuery.isEmptyObject( events ) ) {
4254 delete elemData.handle;
4255 data_priv.remove( elem, "events" );
4259 trigger: function( event, data, elem, onlyHandlers ) {
4261 var i, cur, tmp, bubbleType, ontype, handle, special,
4262 eventPath = [ elem || document ],
4263 type = hasOwn.call( event, "type" ) ? event.type : event,
4264 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
4266 cur = tmp = elem = elem || document;
4268 // Don't do events on text and comment nodes
4269 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
4273 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4274 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
4278 if ( type.indexOf(".") >= 0 ) {
4279 // Namespaced trigger; create a regexp to match event type in handle()
4280 namespaces = type.split(".");
4281 type = namespaces.shift();
4284 ontype = type.indexOf(":") < 0 && "on" + type;
4286 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4287 event = event[ jQuery.expando ] ?
4289 new jQuery.Event( type, typeof event === "object" && event );
4291 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4292 event.isTrigger = onlyHandlers ? 2 : 3;
4293 event.namespace = namespaces.join(".");
4294 event.namespace_re = event.namespace ?
4295 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4298 // Clean up the event in case it is being reused
4299 event.result = undefined;
4300 if ( !event.target ) {
4301 event.target = elem;
4304 // Clone any incoming data and prepend the event, creating the handler arg list
4305 data = data == null ?
4307 jQuery.makeArray( data, [ event ] );
4309 // Allow special events to draw outside the lines
4310 special = jQuery.event.special[ type ] || {};
4311 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
4315 // Determine event propagation path in advance, per W3C events spec (#9951)
4316 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4317 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
4319 bubbleType = special.delegateType || type;
4320 if ( !rfocusMorph.test( bubbleType + type ) ) {
4321 cur = cur.parentNode;
4323 for ( ; cur; cur = cur.parentNode ) {
4324 eventPath.push( cur );
4328 // Only add window if we got to document (e.g., not plain obj or detached DOM)
4329 if ( tmp === (elem.ownerDocument || document) ) {
4330 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
4334 // Fire handlers on the event path
4336 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
4338 event.type = i > 1 ?
4340 special.bindType || type;
4343 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
4345 handle.apply( cur, data );
4349 handle = ontype && cur[ ontype ];
4350 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
4351 event.result = handle.apply( cur, data );
4352 if ( event.result === false ) {
4353 event.preventDefault();
4359 // If nobody prevented the default action, do it now
4360 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
4362 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
4363 jQuery.acceptData( elem ) ) {
4365 // Call a native DOM method on the target with the same name name as the event.
4366 // Don't do default actions on window, that's where global variables be (#6170)
4367 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
4369 // Don't re-trigger an onFOO event when we call its FOO() method
4370 tmp = elem[ ontype ];
4373 elem[ ontype ] = null;
4376 // Prevent re-triggering of the same event, since we already bubbled it above
4377 jQuery.event.triggered = type;
4379 jQuery.event.triggered = undefined;
4382 elem[ ontype ] = tmp;
4388 return event.result;
4391 dispatch: function( event ) {
4393 // Make a writable jQuery.Event from the native event object
4394 event = jQuery.event.fix( event );
4396 var i, j, ret, matched, handleObj,
4398 args = slice.call( arguments ),
4399 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
4400 special = jQuery.event.special[ event.type ] || {};
4402 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4404 event.delegateTarget = this;
4406 // Call the preDispatch hook for the mapped type, and let it bail if desired
4407 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
4411 // Determine handlers
4412 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
4414 // Run delegates first; they may want to stop propagation beneath us
4416 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
4417 event.currentTarget = matched.elem;
4420 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
4422 // Triggered event must either 1) have no namespace, or 2) have namespace(s)
4423 // a subset or equal to those in the bound event (both can have no namespace).
4424 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
4426 event.handleObj = handleObj;
4427 event.data = handleObj.data;
4429 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
4430 .apply( matched.elem, args );
4432 if ( ret !== undefined ) {
4433 if ( (event.result = ret) === false ) {
4434 event.preventDefault();
4435 event.stopPropagation();
4442 // Call the postDispatch hook for the mapped type
4443 if ( special.postDispatch ) {
4444 special.postDispatch.call( this, event );
4447 return event.result;
4450 handlers: function( event, handlers ) {
4451 var i, matches, sel, handleObj,
4453 delegateCount = handlers.delegateCount,
4456 // Find delegate handlers
4457 // Black-hole SVG <use> instance trees (#13180)
4458 // Avoid non-left-click bubbling in Firefox (#3861)
4459 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
4461 for ( ; cur !== this; cur = cur.parentNode || this ) {
4463 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4464 if ( cur.disabled !== true || event.type !== "click" ) {
4466 for ( i = 0; i < delegateCount; i++ ) {
4467 handleObj = handlers[ i ];
4469 // Don't conflict with Object.prototype properties (#13203)
4470 sel = handleObj.selector + " ";
4472 if ( matches[ sel ] === undefined ) {
4473 matches[ sel ] = handleObj.needsContext ?
4474 jQuery( sel, this ).index( cur ) >= 0 :
4475 jQuery.find( sel, this, null, [ cur ] ).length;
4477 if ( matches[ sel ] ) {
4478 matches.push( handleObj );
4481 if ( matches.length ) {
4482 handlerQueue.push({ elem: cur, handlers: matches });
4488 // Add the remaining (directly-bound) handlers
4489 if ( delegateCount < handlers.length ) {
4490 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
4493 return handlerQueue;
4496 // Includes some event props shared by KeyEvent and MouseEvent
4497 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
4502 props: "char charCode key keyCode".split(" "),
4503 filter: function( event, original ) {
4505 // Add which for key events
4506 if ( event.which == null ) {
4507 event.which = original.charCode != null ? original.charCode : original.keyCode;
4515 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
4516 filter: function( event, original ) {
4517 var eventDoc, doc, body,
4518 button = original.button;
4520 // Calculate pageX/Y if missing and clientX/Y available
4521 if ( event.pageX == null && original.clientX != null ) {
4522 eventDoc = event.target.ownerDocument || document;
4523 doc = eventDoc.documentElement;
4524 body = eventDoc.body;
4526 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
4527 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
4530 // Add which for click: 1 === left; 2 === middle; 3 === right
4531 // Note: button is not normalized, so don't use it
4532 if ( !event.which && button !== undefined ) {
4533 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
4540 fix: function( event ) {
4541 if ( event[ jQuery.expando ] ) {
4545 // Create a writable copy of the event object and normalize some properties
4548 originalEvent = event,
4549 fixHook = this.fixHooks[ type ];
4552 this.fixHooks[ type ] = fixHook =
4553 rmouseEvent.test( type ) ? this.mouseHooks :
4554 rkeyEvent.test( type ) ? this.keyHooks :
4557 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
4559 event = new jQuery.Event( originalEvent );
4564 event[ prop ] = originalEvent[ prop ];
4567 // Support: Cordova 2.5 (WebKit) (#13255)
4568 // All events should have a target; Cordova deviceready doesn't
4569 if ( !event.target ) {
4570 event.target = document;
4573 // Support: Safari 6.0+, Chrome<28
4574 // Target should not be a text node (#504, #13143)
4575 if ( event.target.nodeType === 3 ) {
4576 event.target = event.target.parentNode;
4579 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
4584 // Prevent triggered image.load events from bubbling to window.load
4588 // Fire native event if possible so blur/focus sequence is correct
4589 trigger: function() {
4590 if ( this !== safeActiveElement() && this.focus ) {
4595 delegateType: "focusin"
4598 trigger: function() {
4599 if ( this === safeActiveElement() && this.blur ) {
4604 delegateType: "focusout"
4607 // For checkbox, fire native event so checked state will be right
4608 trigger: function() {
4609 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
4615 // For cross-browser consistency, don't fire native .click() on links
4616 _default: function( event ) {
4617 return jQuery.nodeName( event.target, "a" );
4622 postDispatch: function( event ) {
4624 // Support: Firefox 20+
4625 // Firefox doesn't alert if the returnValue field is not set.
4626 if ( event.result !== undefined && event.originalEvent ) {
4627 event.originalEvent.returnValue = event.result;
4633 simulate: function( type, elem, event, bubble ) {
4634 // Piggyback on a donor event to simulate a different one.
4635 // Fake originalEvent to avoid donor's stopPropagation, but if the
4636 // simulated event prevents default then we do the same on the donor.
4637 var e = jQuery.extend(
4647 jQuery.event.trigger( e, null, elem );
4649 jQuery.event.dispatch.call( elem, e );
4651 if ( e.isDefaultPrevented() ) {
4652 event.preventDefault();
4657 jQuery.removeEvent = function( elem, type, handle ) {
4658 if ( elem.removeEventListener ) {
4659 elem.removeEventListener( type, handle, false );
4663 jQuery.Event = function( src, props ) {
4664 // Allow instantiation without the 'new' keyword
4665 if ( !(this instanceof jQuery.Event) ) {
4666 return new jQuery.Event( src, props );
4670 if ( src && src.type ) {
4671 this.originalEvent = src;
4672 this.type = src.type;
4674 // Events bubbling up the document may have been marked as prevented
4675 // by a handler lower down the tree; reflect the correct value.
4676 this.isDefaultPrevented = src.defaultPrevented ||
4677 src.defaultPrevented === undefined &&
4678 // Support: Android<4.0
4679 src.returnValue === false ?
4688 // Put explicitly provided properties onto the event object
4690 jQuery.extend( this, props );
4693 // Create a timestamp if incoming event doesn't have one
4694 this.timeStamp = src && src.timeStamp || jQuery.now();
4697 this[ jQuery.expando ] = true;
4700 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4701 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4702 jQuery.Event.prototype = {
4703 isDefaultPrevented: returnFalse,
4704 isPropagationStopped: returnFalse,
4705 isImmediatePropagationStopped: returnFalse,
4707 preventDefault: function() {
4708 var e = this.originalEvent;
4710 this.isDefaultPrevented = returnTrue;
4712 if ( e && e.preventDefault ) {
4716 stopPropagation: function() {
4717 var e = this.originalEvent;
4719 this.isPropagationStopped = returnTrue;
4721 if ( e && e.stopPropagation ) {
4722 e.stopPropagation();
4725 stopImmediatePropagation: function() {
4726 var e = this.originalEvent;
4728 this.isImmediatePropagationStopped = returnTrue;
4730 if ( e && e.stopImmediatePropagation ) {
4731 e.stopImmediatePropagation();
4734 this.stopPropagation();
4738 // Create mouseenter/leave events using mouseover/out and event-time checks
4739 // Support: Chrome 15+
4741 mouseenter: "mouseover",
4742 mouseleave: "mouseout",
4743 pointerenter: "pointerover",
4744 pointerleave: "pointerout"
4745 }, function( orig, fix ) {
4746 jQuery.event.special[ orig ] = {
4750 handle: function( event ) {
4753 related = event.relatedTarget,
4754 handleObj = event.handleObj;
4756 // For mousenter/leave call the handler if related is outside the target.
4757 // NB: No relatedTarget if the mouse left/entered the browser window
4758 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
4759 event.type = handleObj.origType;
4760 ret = handleObj.handler.apply( this, arguments );
4768 // Support: Firefox, Chrome, Safari
4769 // Create "bubbling" focus and blur events
4770 if ( !support.focusinBubbles ) {
4771 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
4773 // Attach a single capturing handler on the document while someone wants focusin/focusout
4774 var handler = function( event ) {
4775 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
4778 jQuery.event.special[ fix ] = {
4780 var doc = this.ownerDocument || this,
4781 attaches = data_priv.access( doc, fix );
4784 doc.addEventListener( orig, handler, true );
4786 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
4788 teardown: function() {
4789 var doc = this.ownerDocument || this,
4790 attaches = data_priv.access( doc, fix ) - 1;
4793 doc.removeEventListener( orig, handler, true );
4794 data_priv.remove( doc, fix );
4797 data_priv.access( doc, fix, attaches );
4806 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
4809 // Types can be a map of types/handlers
4810 if ( typeof types === "object" ) {
4811 // ( types-Object, selector, data )
4812 if ( typeof selector !== "string" ) {
4813 // ( types-Object, data )
4814 data = data || selector;
4815 selector = undefined;
4817 for ( type in types ) {
4818 this.on( type, selector, data, types[ type ], one );
4823 if ( data == null && fn == null ) {
4826 data = selector = undefined;
4827 } else if ( fn == null ) {
4828 if ( typeof selector === "string" ) {
4829 // ( types, selector, fn )
4833 // ( types, data, fn )
4836 selector = undefined;
4839 if ( fn === false ) {
4847 fn = function( event ) {
4848 // Can use an empty set, since event contains the info
4849 jQuery().off( event );
4850 return origFn.apply( this, arguments );
4852 // Use same guid so caller can remove using origFn
4853 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
4855 return this.each( function() {
4856 jQuery.event.add( this, types, fn, data, selector );
4859 one: function( types, selector, data, fn ) {
4860 return this.on( types, selector, data, fn, 1 );
4862 off: function( types, selector, fn ) {
4863 var handleObj, type;
4864 if ( types && types.preventDefault && types.handleObj ) {
4865 // ( event ) dispatched jQuery.Event
4866 handleObj = types.handleObj;
4867 jQuery( types.delegateTarget ).off(
4868 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
4874 if ( typeof types === "object" ) {
4875 // ( types-object [, selector] )
4876 for ( type in types ) {
4877 this.off( type, selector, types[ type ] );
4881 if ( selector === false || typeof selector === "function" ) {
4884 selector = undefined;
4886 if ( fn === false ) {
4889 return this.each(function() {
4890 jQuery.event.remove( this, types, fn, selector );
4894 trigger: function( type, data ) {
4895 return this.each(function() {
4896 jQuery.event.trigger( type, data, this );
4899 triggerHandler: function( type, data ) {
4902 return jQuery.event.trigger( type, data, elem, true );
4909 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
4910 rtagName = /<([\w:]+)/,
4911 rhtml = /<|&#?\w+;/,
4912 rnoInnerhtml = /<(?:script|style|link)/i,
4913 // checked="checked" or checked
4914 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
4915 rscriptType = /^$|\/(?:java|ecma)script/i,
4916 rscriptTypeMasked = /^true\/(.*)/,
4917 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
4919 // We have to close these tags to support XHTML (#13200)
4923 option: [ 1, "<select multiple='multiple'>", "</select>" ],
4925 thead: [ 1, "<table>", "</table>" ],
4926 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4927 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4928 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4930 _default: [ 0, "", "" ]
4934 wrapMap.optgroup = wrapMap.option;
4936 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
4937 wrapMap.th = wrapMap.td;
4939 // Support: 1.x compatibility
4940 // Manipulating tables requires a tbody
4941 function manipulationTarget( elem, content ) {
4942 return jQuery.nodeName( elem, "table" ) &&
4943 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
4945 elem.getElementsByTagName("tbody")[0] ||
4946 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
4950 // Replace/restore the type attribute of script elements for safe DOM manipulation
4951 function disableScript( elem ) {
4952 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
4955 function restoreScript( elem ) {
4956 var match = rscriptTypeMasked.exec( elem.type );
4959 elem.type = match[ 1 ];
4961 elem.removeAttribute("type");
4967 // Mark scripts as having already been evaluated
4968 function setGlobalEval( elems, refElements ) {
4972 for ( ; i < l; i++ ) {
4974 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
4979 function cloneCopyEvent( src, dest ) {
4980 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
4982 if ( dest.nodeType !== 1 ) {
4986 // 1. Copy private data: events, handlers, etc.
4987 if ( data_priv.hasData( src ) ) {
4988 pdataOld = data_priv.access( src );
4989 pdataCur = data_priv.set( dest, pdataOld );
4990 events = pdataOld.events;
4993 delete pdataCur.handle;
4994 pdataCur.events = {};
4996 for ( type in events ) {
4997 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
4998 jQuery.event.add( dest, type, events[ type ][ i ] );
5004 // 2. Copy user data
5005 if ( data_user.hasData( src ) ) {
5006 udataOld = data_user.access( src );
5007 udataCur = jQuery.extend( {}, udataOld );
5009 data_user.set( dest, udataCur );
5013 function getAll( context, tag ) {
5014 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
5015 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
5018 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
5019 jQuery.merge( [ context ], ret ) :
5023 // Fix IE bugs, see support tests
5024 function fixInput( src, dest ) {
5025 var nodeName = dest.nodeName.toLowerCase();
5027 // Fails to persist the checked state of a cloned checkbox or radio button.
5028 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5029 dest.checked = src.checked;
5031 // Fails to return the selected option to the default selected state when cloning options
5032 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5033 dest.defaultValue = src.defaultValue;
5038 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
5039 var i, l, srcElements, destElements,
5040 clone = elem.cloneNode( true ),
5041 inPage = jQuery.contains( elem.ownerDocument, elem );
5043 // Fix IE cloning issues
5044 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
5045 !jQuery.isXMLDoc( elem ) ) {
5047 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5048 destElements = getAll( clone );
5049 srcElements = getAll( elem );
5051 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5052 fixInput( srcElements[ i ], destElements[ i ] );
5056 // Copy the events from the original to the clone
5057 if ( dataAndEvents ) {
5058 if ( deepDataAndEvents ) {
5059 srcElements = srcElements || getAll( elem );
5060 destElements = destElements || getAll( clone );
5062 for ( i = 0, l = srcElements.length; i < l; i++ ) {
5063 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
5066 cloneCopyEvent( elem, clone );
5070 // Preserve script evaluation history
5071 destElements = getAll( clone, "script" );
5072 if ( destElements.length > 0 ) {
5073 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
5076 // Return the cloned set
5080 buildFragment: function( elems, context, scripts, selection ) {
5081 var elem, tmp, tag, wrap, contains, j,
5082 fragment = context.createDocumentFragment(),
5087 for ( ; i < l; i++ ) {
5090 if ( elem || elem === 0 ) {
5092 // Add nodes directly
5093 if ( jQuery.type( elem ) === "object" ) {
5094 // Support: QtWebKit, PhantomJS
5095 // push.apply(_, arraylike) throws on ancient WebKit
5096 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
5098 // Convert non-html into a text node
5099 } else if ( !rhtml.test( elem ) ) {
5100 nodes.push( context.createTextNode( elem ) );
5102 // Convert html into DOM nodes
5104 tmp = tmp || fragment.appendChild( context.createElement("div") );
5106 // Deserialize a standard representation
5107 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
5108 wrap = wrapMap[ tag ] || wrapMap._default;
5109 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
5111 // Descend through wrappers to the right content
5114 tmp = tmp.lastChild;
5117 // Support: QtWebKit, PhantomJS
5118 // push.apply(_, arraylike) throws on ancient WebKit
5119 jQuery.merge( nodes, tmp.childNodes );
5121 // Remember the top-level container
5122 tmp = fragment.firstChild;
5124 // Ensure the created nodes are orphaned (#12392)
5125 tmp.textContent = "";
5130 // Remove wrapper from fragment
5131 fragment.textContent = "";
5134 while ( (elem = nodes[ i++ ]) ) {
5136 // #4087 - If origin and destination elements are the same, and this is
5137 // that element, do not do anything
5138 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
5142 contains = jQuery.contains( elem.ownerDocument, elem );
5144 // Append to fragment
5145 tmp = getAll( fragment.appendChild( elem ), "script" );
5147 // Preserve script evaluation history
5149 setGlobalEval( tmp );
5152 // Capture executables
5155 while ( (elem = tmp[ j++ ]) ) {
5156 if ( rscriptType.test( elem.type || "" ) ) {
5157 scripts.push( elem );
5166 cleanData: function( elems ) {
5167 var data, elem, type, key,
5168 special = jQuery.event.special,
5171 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
5172 if ( jQuery.acceptData( elem ) ) {
5173 key = elem[ data_priv.expando ];
5175 if ( key && (data = data_priv.cache[ key ]) ) {
5176 if ( data.events ) {
5177 for ( type in data.events ) {
5178 if ( special[ type ] ) {
5179 jQuery.event.remove( elem, type );
5181 // This is a shortcut to avoid jQuery.event.remove's overhead
5183 jQuery.removeEvent( elem, type, data.handle );
5187 if ( data_priv.cache[ key ] ) {
5188 // Discard any remaining `private` data
5189 delete data_priv.cache[ key ];
5193 // Discard any remaining `user` data
5194 delete data_user.cache[ elem[ data_user.expando ] ];
5200 text: function( value ) {
5201 return access( this, function( value ) {
5202 return value === undefined ?
5203 jQuery.text( this ) :
5204 this.empty().each(function() {
5205 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5206 this.textContent = value;
5209 }, null, value, arguments.length );
5212 append: function() {
5213 return this.domManip( arguments, function( elem ) {
5214 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5215 var target = manipulationTarget( this, elem );
5216 target.appendChild( elem );
5221 prepend: function() {
5222 return this.domManip( arguments, function( elem ) {
5223 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5224 var target = manipulationTarget( this, elem );
5225 target.insertBefore( elem, target.firstChild );
5230 before: function() {
5231 return this.domManip( arguments, function( elem ) {
5232 if ( this.parentNode ) {
5233 this.parentNode.insertBefore( elem, this );
5239 return this.domManip( arguments, function( elem ) {
5240 if ( this.parentNode ) {
5241 this.parentNode.insertBefore( elem, this.nextSibling );
5246 remove: function( selector, keepData /* Internal Use Only */ ) {
5248 elems = selector ? jQuery.filter( selector, this ) : this,
5251 for ( ; (elem = elems[i]) != null; i++ ) {
5252 if ( !keepData && elem.nodeType === 1 ) {
5253 jQuery.cleanData( getAll( elem ) );
5256 if ( elem.parentNode ) {
5257 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
5258 setGlobalEval( getAll( elem, "script" ) );
5260 elem.parentNode.removeChild( elem );
5271 for ( ; (elem = this[i]) != null; i++ ) {
5272 if ( elem.nodeType === 1 ) {
5274 // Prevent memory leaks
5275 jQuery.cleanData( getAll( elem, false ) );
5277 // Remove any remaining nodes
5278 elem.textContent = "";
5285 clone: function( dataAndEvents, deepDataAndEvents ) {
5286 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5287 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5289 return this.map(function() {
5290 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5294 html: function( value ) {
5295 return access( this, function( value ) {
5296 var elem = this[ 0 ] || {},
5300 if ( value === undefined && elem.nodeType === 1 ) {
5301 return elem.innerHTML;
5304 // See if we can take a shortcut and just use innerHTML
5305 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5306 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5308 value = value.replace( rxhtmlTag, "<$1></$2>" );
5311 for ( ; i < l; i++ ) {
5312 elem = this[ i ] || {};
5314 // Remove element nodes and prevent memory leaks
5315 if ( elem.nodeType === 1 ) {
5316 jQuery.cleanData( getAll( elem, false ) );
5317 elem.innerHTML = value;
5323 // If using innerHTML throws an exception, use the fallback method
5328 this.empty().append( value );
5330 }, null, value, arguments.length );
5333 replaceWith: function() {
5334 var arg = arguments[ 0 ];
5336 // Make the changes, replacing each context element with the new content
5337 this.domManip( arguments, function( elem ) {
5338 arg = this.parentNode;
5340 jQuery.cleanData( getAll( this ) );
5343 arg.replaceChild( elem, this );
5347 // Force removal if there was no new content (e.g., from empty arguments)
5348 return arg && (arg.length || arg.nodeType) ? this : this.remove();
5351 detach: function( selector ) {
5352 return this.remove( selector, true );
5355 domManip: function( args, callback ) {
5357 // Flatten any nested arrays
5358 args = concat.apply( [], args );
5360 var fragment, first, scripts, hasScripts, node, doc,
5366 isFunction = jQuery.isFunction( value );
5368 // We can't cloneNode fragments that contain checked, in WebKit
5370 ( l > 1 && typeof value === "string" &&
5371 !support.checkClone && rchecked.test( value ) ) ) {
5372 return this.each(function( index ) {
5373 var self = set.eq( index );
5375 args[ 0 ] = value.call( this, index, self.html() );
5377 self.domManip( args, callback );
5382 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
5383 first = fragment.firstChild;
5385 if ( fragment.childNodes.length === 1 ) {
5390 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
5391 hasScripts = scripts.length;
5393 // Use the original fragment for the last item instead of the first because it can end up
5394 // being emptied incorrectly in certain situations (#8070).
5395 for ( ; i < l; i++ ) {
5398 if ( i !== iNoClone ) {
5399 node = jQuery.clone( node, true, true );
5401 // Keep references to cloned scripts for later restoration
5403 // Support: QtWebKit
5404 // jQuery.merge because push.apply(_, arraylike) throws
5405 jQuery.merge( scripts, getAll( node, "script" ) );
5409 callback.call( this[ i ], node, i );
5413 doc = scripts[ scripts.length - 1 ].ownerDocument;
5416 jQuery.map( scripts, restoreScript );
5418 // Evaluate executable scripts on first document insertion
5419 for ( i = 0; i < hasScripts; i++ ) {
5420 node = scripts[ i ];
5421 if ( rscriptType.test( node.type || "" ) &&
5422 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
5425 // Optional AJAX dependency, but won't run scripts if not present
5426 if ( jQuery._evalUrl ) {
5427 jQuery._evalUrl( node.src );
5430 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
5444 prependTo: "prepend",
5445 insertBefore: "before",
5446 insertAfter: "after",
5447 replaceAll: "replaceWith"
5448 }, function( name, original ) {
5449 jQuery.fn[ name ] = function( selector ) {
5452 insert = jQuery( selector ),
5453 last = insert.length - 1,
5456 for ( ; i <= last; i++ ) {
5457 elems = i === last ? this : this.clone( true );
5458 jQuery( insert[ i ] )[ original ]( elems );
5460 // Support: QtWebKit
5461 // .get() because push.apply(_, arraylike) throws
5462 push.apply( ret, elems.get() );
5465 return this.pushStack( ret );
5474 * Retrieve the actual display of a element
5475 * @param {String} name nodeName of the element
5476 * @param {Object} doc Document object
5478 // Called only from within defaultDisplay
5479 function actualDisplay( name, doc ) {
5481 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
5483 // getDefaultComputedStyle might be reliably used only on attached element
5484 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
5486 // Use of this method is a temporary fix (more like optimization) until something better comes along,
5487 // since it was removed from specification and supported only in FF
5488 style.display : jQuery.css( elem[ 0 ], "display" );
5490 // We don't have any data stored on the element,
5491 // so use "detach" method as fast way to get rid of the element
5498 * Try to determine the default display value of an element
5499 * @param {String} nodeName
5501 function defaultDisplay( nodeName ) {
5503 display = elemdisplay[ nodeName ];
5506 display = actualDisplay( nodeName, doc );
5508 // If the simple way fails, read from inside an iframe
5509 if ( display === "none" || !display ) {
5511 // Use the already-created iframe if possible
5512 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
5514 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
5515 doc = iframe[ 0 ].contentDocument;
5521 display = actualDisplay( nodeName, doc );
5525 // Store the correct default display
5526 elemdisplay[ nodeName ] = display;
5531 var rmargin = (/^margin/);
5533 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
5535 var getStyles = function( elem ) {
5536 // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
5537 // IE throws on elements created in popups
5538 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
5539 if ( elem.ownerDocument.defaultView.opener ) {
5540 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
5543 return window.getComputedStyle( elem, null );
5548 function curCSS( elem, name, computed ) {
5549 var width, minWidth, maxWidth, ret,
5552 computed = computed || getStyles( elem );
5555 // getPropertyValue is only needed for .css('filter') (#12537)
5557 ret = computed.getPropertyValue( name ) || computed[ name ];
5562 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
5563 ret = jQuery.style( elem, name );
5567 // A tribute to the "awesome hack by Dean Edwards"
5568 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
5569 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
5570 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
5572 // Remember the original values
5573 width = style.width;
5574 minWidth = style.minWidth;
5575 maxWidth = style.maxWidth;
5577 // Put in the new values to get a computed value out
5578 style.minWidth = style.maxWidth = style.width = ret;
5579 ret = computed.width;
5581 // Revert the changed values
5582 style.width = width;
5583 style.minWidth = minWidth;
5584 style.maxWidth = maxWidth;
5588 return ret !== undefined ?
5590 // IE returns zIndex value as an integer.
5596 function addGetHookIf( conditionFn, hookFn ) {
5597 // Define the hook, we'll check on the first run if it's really needed.
5600 if ( conditionFn() ) {
5601 // Hook not needed (or it's not possible to use it due
5602 // to missing dependency), remove it.
5607 // Hook needed; redefine it so that the support test is not executed again.
5608 return (this.get = hookFn).apply( this, arguments );
5615 var pixelPositionVal, boxSizingReliableVal,
5616 docElem = document.documentElement,
5617 container = document.createElement( "div" ),
5618 div = document.createElement( "div" );
5625 // Style of cloned element affects source element cloned (#8908)
5626 div.style.backgroundClip = "content-box";
5627 div.cloneNode( true ).style.backgroundClip = "";
5628 support.clearCloneStyle = div.style.backgroundClip === "content-box";
5630 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
5631 "position:absolute";
5632 container.appendChild( div );
5634 // Executing both pixelPosition & boxSizingReliable tests require only one layout
5635 // so they're executed at the same time to save the second computation.
5636 function computePixelPositionAndBoxSizingReliable() {
5638 // Support: Firefox<29, Android 2.3
5639 // Vendor-prefix box-sizing
5640 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
5641 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
5642 "border:1px;padding:1px;width:4px;position:absolute";
5644 docElem.appendChild( container );
5646 var divStyle = window.getComputedStyle( div, null );
5647 pixelPositionVal = divStyle.top !== "1%";
5648 boxSizingReliableVal = divStyle.width === "4px";
5650 docElem.removeChild( container );
5653 // Support: node.js jsdom
5654 // Don't assume that getComputedStyle is a property of the global object
5655 if ( window.getComputedStyle ) {
5656 jQuery.extend( support, {
5657 pixelPosition: function() {
5659 // This test is executed only once but we still do memoizing
5660 // since we can use the boxSizingReliable pre-computing.
5661 // No need to check if the test was already performed, though.
5662 computePixelPositionAndBoxSizingReliable();
5663 return pixelPositionVal;
5665 boxSizingReliable: function() {
5666 if ( boxSizingReliableVal == null ) {
5667 computePixelPositionAndBoxSizingReliable();
5669 return boxSizingReliableVal;
5671 reliableMarginRight: function() {
5673 // Support: Android 2.3
5674 // Check if div with explicit width and no margin-right incorrectly
5675 // gets computed margin-right based on width of container. (#3333)
5676 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
5677 // This support function is only executed once so no memoizing is needed.
5679 marginDiv = div.appendChild( document.createElement( "div" ) );
5681 // Reset CSS: box-sizing; display; margin; border; padding
5682 marginDiv.style.cssText = div.style.cssText =
5683 // Support: Firefox<29, Android 2.3
5684 // Vendor-prefix box-sizing
5685 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
5686 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
5687 marginDiv.style.marginRight = marginDiv.style.width = "0";
5688 div.style.width = "1px";
5689 docElem.appendChild( container );
5691 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
5693 docElem.removeChild( container );
5694 div.removeChild( marginDiv );
5703 // A method for quickly swapping in/out CSS properties to get correct calculations.
5704 jQuery.swap = function( elem, options, callback, args ) {
5708 // Remember the old values, and insert the new ones
5709 for ( name in options ) {
5710 old[ name ] = elem.style[ name ];
5711 elem.style[ name ] = options[ name ];
5714 ret = callback.apply( elem, args || [] );
5716 // Revert the old values
5717 for ( name in options ) {
5718 elem.style[ name ] = old[ name ];
5726 // Swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
5727 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
5728 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
5729 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
5730 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
5732 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
5733 cssNormalTransform = {
5738 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
5740 // Return a css property mapped to a potentially vendor prefixed property
5741 function vendorPropName( style, name ) {
5743 // Shortcut for names that are not vendor prefixed
5744 if ( name in style ) {
5748 // Check for vendor prefixed names
5749 var capName = name[0].toUpperCase() + name.slice(1),
5751 i = cssPrefixes.length;
5754 name = cssPrefixes[ i ] + capName;
5755 if ( name in style ) {
5763 function setPositiveNumber( elem, value, subtract ) {
5764 var matches = rnumsplit.exec( value );
5766 // Guard against undefined "subtract", e.g., when used as in cssHooks
5767 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
5771 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
5772 var i = extra === ( isBorderBox ? "border" : "content" ) ?
5773 // If we already have the right measurement, avoid augmentation
5775 // Otherwise initialize for horizontal or vertical properties
5776 name === "width" ? 1 : 0,
5780 for ( ; i < 4; i += 2 ) {
5781 // Both box models exclude margin, so add it if we want it
5782 if ( extra === "margin" ) {
5783 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
5786 if ( isBorderBox ) {
5787 // border-box includes padding, so remove it if we want content
5788 if ( extra === "content" ) {
5789 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
5792 // At this point, extra isn't border nor margin, so remove border
5793 if ( extra !== "margin" ) {
5794 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
5797 // At this point, extra isn't content, so add padding
5798 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
5800 // At this point, extra isn't content nor padding, so add border
5801 if ( extra !== "padding" ) {
5802 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
5810 function getWidthOrHeight( elem, name, extra ) {
5812 // Start with offset property, which is equivalent to the border-box value
5813 var valueIsBorderBox = true,
5814 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
5815 styles = getStyles( elem ),
5816 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
5818 // Some non-html elements return undefined for offsetWidth, so check for null/undefined
5819 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
5820 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
5821 if ( val <= 0 || val == null ) {
5822 // Fall back to computed then uncomputed css if necessary
5823 val = curCSS( elem, name, styles );
5824 if ( val < 0 || val == null ) {
5825 val = elem.style[ name ];
5828 // Computed unit is not pixels. Stop here and return.
5829 if ( rnumnonpx.test(val) ) {
5833 // Check for style in case a browser which returns unreliable values
5834 // for getComputedStyle silently falls back to the reliable elem.style
5835 valueIsBorderBox = isBorderBox &&
5836 ( support.boxSizingReliable() || val === elem.style[ name ] );
5838 // Normalize "", auto, and prepare for extra
5839 val = parseFloat( val ) || 0;
5842 // Use the active box-sizing model to add/subtract irrelevant styles
5844 augmentWidthOrHeight(
5847 extra || ( isBorderBox ? "border" : "content" ),
5854 function showHide( elements, show ) {
5855 var display, elem, hidden,
5858 length = elements.length;
5860 for ( ; index < length; index++ ) {
5861 elem = elements[ index ];
5862 if ( !elem.style ) {
5866 values[ index ] = data_priv.get( elem, "olddisplay" );
5867 display = elem.style.display;
5869 // Reset the inline display of this element to learn if it is
5870 // being hidden by cascaded rules or not
5871 if ( !values[ index ] && display === "none" ) {
5872 elem.style.display = "";
5875 // Set elements which have been overridden with display: none
5876 // in a stylesheet to whatever the default browser style is
5877 // for such an element
5878 if ( elem.style.display === "" && isHidden( elem ) ) {
5879 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
5882 hidden = isHidden( elem );
5884 if ( display !== "none" || !hidden ) {
5885 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
5890 // Set the display of most of the elements in a second loop
5891 // to avoid the constant reflow
5892 for ( index = 0; index < length; index++ ) {
5893 elem = elements[ index ];
5894 if ( !elem.style ) {
5897 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
5898 elem.style.display = show ? values[ index ] || "" : "none";
5907 // Add in style property hooks for overriding the default
5908 // behavior of getting and setting a style property
5911 get: function( elem, computed ) {
5914 // We should always get a number back from opacity
5915 var ret = curCSS( elem, "opacity" );
5916 return ret === "" ? "1" : ret;
5922 // Don't automatically add "px" to these possibly-unitless properties
5924 "columnCount": true,
5925 "fillOpacity": true,
5938 // Add in properties whose names you wish to fix before
5939 // setting or getting the value
5944 // Get and set the style property on a DOM Node
5945 style: function( elem, name, value, extra ) {
5947 // Don't set styles on text and comment nodes
5948 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
5952 // Make sure that we're working with the right name
5953 var ret, type, hooks,
5954 origName = jQuery.camelCase( name ),
5957 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
5959 // Gets hook for the prefixed version, then unprefixed version
5960 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
5962 // Check if we're setting a value
5963 if ( value !== undefined ) {
5964 type = typeof value;
5966 // Convert "+=" or "-=" to relative numbers (#7345)
5967 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
5968 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
5973 // Make sure that null and NaN values aren't set (#7116)
5974 if ( value == null || value !== value ) {
5978 // If a number, add 'px' to the (except for certain CSS properties)
5979 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
5984 // background-* props affect original clone's values
5985 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
5986 style[ name ] = "inherit";
5989 // If a hook was provided, use that value, otherwise just set the specified value
5990 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
5991 style[ name ] = value;
5995 // If a hook was provided get the non-computed value from there
5996 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6000 // Otherwise just get the value from the style object
6001 return style[ name ];
6005 css: function( elem, name, extra, styles ) {
6006 var val, num, hooks,
6007 origName = jQuery.camelCase( name );
6009 // Make sure that we're working with the right name
6010 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6012 // Try prefixed name followed by the unprefixed name
6013 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6015 // If a hook was provided get the computed value from there
6016 if ( hooks && "get" in hooks ) {
6017 val = hooks.get( elem, true, extra );
6020 // Otherwise, if a way to get the computed value exists, use that
6021 if ( val === undefined ) {
6022 val = curCSS( elem, name, styles );
6025 // Convert "normal" to computed value
6026 if ( val === "normal" && name in cssNormalTransform ) {
6027 val = cssNormalTransform[ name ];
6030 // Make numeric if forced or a qualifier was provided and val looks numeric
6031 if ( extra === "" || extra ) {
6032 num = parseFloat( val );
6033 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
6039 jQuery.each([ "height", "width" ], function( i, name ) {
6040 jQuery.cssHooks[ name ] = {
6041 get: function( elem, computed, extra ) {
6044 // Certain elements can have dimension info if we invisibly show them
6045 // but it must have a current display style that would benefit
6046 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
6047 jQuery.swap( elem, cssShow, function() {
6048 return getWidthOrHeight( elem, name, extra );
6050 getWidthOrHeight( elem, name, extra );
6054 set: function( elem, value, extra ) {
6055 var styles = extra && getStyles( elem );
6056 return setPositiveNumber( elem, value, extra ?
6057 augmentWidthOrHeight(
6061 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6069 // Support: Android 2.3
6070 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
6071 function( elem, computed ) {
6073 return jQuery.swap( elem, { "display": "inline-block" },
6074 curCSS, [ elem, "marginRight" ] );
6079 // These hooks are used by animate to expand properties
6084 }, function( prefix, suffix ) {
6085 jQuery.cssHooks[ prefix + suffix ] = {
6086 expand: function( value ) {
6090 // Assumes a single number if not a string
6091 parts = typeof value === "string" ? value.split(" ") : [ value ];
6093 for ( ; i < 4; i++ ) {
6094 expanded[ prefix + cssExpand[ i ] + suffix ] =
6095 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6102 if ( !rmargin.test( prefix ) ) {
6103 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6108 css: function( name, value ) {
6109 return access( this, function( elem, name, value ) {
6114 if ( jQuery.isArray( name ) ) {
6115 styles = getStyles( elem );
6118 for ( ; i < len; i++ ) {
6119 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6125 return value !== undefined ?
6126 jQuery.style( elem, name, value ) :
6127 jQuery.css( elem, name );
6128 }, name, value, arguments.length > 1 );
6131 return showHide( this, true );
6134 return showHide( this );
6136 toggle: function( state ) {
6137 if ( typeof state === "boolean" ) {
6138 return state ? this.show() : this.hide();
6141 return this.each(function() {
6142 if ( isHidden( this ) ) {
6143 jQuery( this ).show();
6145 jQuery( this ).hide();
6152 function Tween( elem, options, prop, end, easing ) {
6153 return new Tween.prototype.init( elem, options, prop, end, easing );
6155 jQuery.Tween = Tween;
6159 init: function( elem, options, prop, end, easing, unit ) {
6162 this.easing = easing || "swing";
6163 this.options = options;
6164 this.start = this.now = this.cur();
6166 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
6169 var hooks = Tween.propHooks[ this.prop ];
6171 return hooks && hooks.get ?
6173 Tween.propHooks._default.get( this );
6175 run: function( percent ) {
6177 hooks = Tween.propHooks[ this.prop ];
6179 if ( this.options.duration ) {
6180 this.pos = eased = jQuery.easing[ this.easing ](
6181 percent, this.options.duration * percent, 0, 1, this.options.duration
6184 this.pos = eased = percent;
6186 this.now = ( this.end - this.start ) * eased + this.start;
6188 if ( this.options.step ) {
6189 this.options.step.call( this.elem, this.now, this );
6192 if ( hooks && hooks.set ) {
6195 Tween.propHooks._default.set( this );
6201 Tween.prototype.init.prototype = Tween.prototype;
6205 get: function( tween ) {
6208 if ( tween.elem[ tween.prop ] != null &&
6209 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
6210 return tween.elem[ tween.prop ];
6213 // Passing an empty string as a 3rd parameter to .css will automatically
6214 // attempt a parseFloat and fallback to a string if the parse fails.
6215 // Simple values such as "10px" are parsed to Float;
6216 // complex values such as "rotate(1rad)" are returned as-is.
6217 result = jQuery.css( tween.elem, tween.prop, "" );
6218 // Empty strings, null, undefined and "auto" are converted to 0.
6219 return !result || result === "auto" ? 0 : result;
6221 set: function( tween ) {
6222 // Use step hook for back compat.
6223 // Use cssHook if its there.
6224 // Use .style if available and use plain properties where available.
6225 if ( jQuery.fx.step[ tween.prop ] ) {
6226 jQuery.fx.step[ tween.prop ]( tween );
6227 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
6228 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
6230 tween.elem[ tween.prop ] = tween.now;
6237 // Panic based approach to setting things on disconnected nodes
6238 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
6239 set: function( tween ) {
6240 if ( tween.elem.nodeType && tween.elem.parentNode ) {
6241 tween.elem[ tween.prop ] = tween.now;
6247 linear: function( p ) {
6250 swing: function( p ) {
6251 return 0.5 - Math.cos( p * Math.PI ) / 2;
6255 jQuery.fx = Tween.prototype.init;
6257 // Back Compat <1.8 extension point
6258 jQuery.fx.step = {};
6265 rfxtypes = /^(?:toggle|show|hide)$/,
6266 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
6267 rrun = /queueHooks$/,
6268 animationPrefilters = [ defaultPrefilter ],
6270 "*": [ function( prop, value ) {
6271 var tween = this.createTween( prop, value ),
6272 target = tween.cur(),
6273 parts = rfxnum.exec( value ),
6274 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
6276 // Starting value computation is required for potential unit mismatches
6277 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
6278 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
6282 if ( start && start[ 3 ] !== unit ) {
6283 // Trust units reported by jQuery.css
6284 unit = unit || start[ 3 ];
6286 // Make sure we update the tween properties later on
6287 parts = parts || [];
6289 // Iteratively approximate from a nonzero starting point
6290 start = +target || 1;
6293 // If previous iteration zeroed out, double until we get *something*.
6294 // Use string for doubling so we don't accidentally see scale as unchanged below
6295 scale = scale || ".5";
6298 start = start / scale;
6299 jQuery.style( tween.elem, prop, start + unit );
6301 // Update scale, tolerating zero or NaN from tween.cur(),
6302 // break the loop if scale is unchanged or perfect, or if we've just had enough
6303 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
6306 // Update tween properties
6308 start = tween.start = +start || +target || 0;
6310 // If a +=/-= token was provided, we're doing a relative animation
6311 tween.end = parts[ 1 ] ?
6312 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
6320 // Animations created synchronously will run synchronously
6321 function createFxNow() {
6322 setTimeout(function() {
6325 return ( fxNow = jQuery.now() );
6328 // Generate parameters to create a standard animation
6329 function genFx( type, includeWidth ) {
6332 attrs = { height: type };
6334 // If we include width, step value is 1 to do all cssExpand values,
6335 // otherwise step value is 2 to skip over Left and Right
6336 includeWidth = includeWidth ? 1 : 0;
6337 for ( ; i < 4 ; i += 2 - includeWidth ) {
6338 which = cssExpand[ i ];
6339 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
6342 if ( includeWidth ) {
6343 attrs.opacity = attrs.width = type;
6349 function createTween( value, prop, animation ) {
6351 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
6353 length = collection.length;
6354 for ( ; index < length; index++ ) {
6355 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
6357 // We're done with this property
6363 function defaultPrefilter( elem, props, opts ) {
6364 /* jshint validthis: true */
6365 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
6369 hidden = elem.nodeType && isHidden( elem ),
6370 dataShow = data_priv.get( elem, "fxshow" );
6372 // Handle queue: false promises
6373 if ( !opts.queue ) {
6374 hooks = jQuery._queueHooks( elem, "fx" );
6375 if ( hooks.unqueued == null ) {
6377 oldfire = hooks.empty.fire;
6378 hooks.empty.fire = function() {
6379 if ( !hooks.unqueued ) {
6386 anim.always(function() {
6387 // Ensure the complete handler is called before this completes
6388 anim.always(function() {
6390 if ( !jQuery.queue( elem, "fx" ).length ) {
6397 // Height/width overflow pass
6398 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
6399 // Make sure that nothing sneaks out
6400 // Record all 3 overflow attributes because IE9-10 do not
6401 // change the overflow attribute when overflowX and
6402 // overflowY are set to the same value
6403 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
6405 // Set display property to inline-block for height/width
6406 // animations on inline elements that are having width/height animated
6407 display = jQuery.css( elem, "display" );
6409 // Test default display if display is currently "none"
6410 checkDisplay = display === "none" ?
6411 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
6413 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
6414 style.display = "inline-block";
6418 if ( opts.overflow ) {
6419 style.overflow = "hidden";
6420 anim.always(function() {
6421 style.overflow = opts.overflow[ 0 ];
6422 style.overflowX = opts.overflow[ 1 ];
6423 style.overflowY = opts.overflow[ 2 ];
6428 for ( prop in props ) {
6429 value = props[ prop ];
6430 if ( rfxtypes.exec( value ) ) {
6431 delete props[ prop ];
6432 toggle = toggle || value === "toggle";
6433 if ( value === ( hidden ? "hide" : "show" ) ) {
6435 // 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
6436 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
6442 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
6444 // Any non-fx value stops us from restoring the original display value
6446 display = undefined;
6450 if ( !jQuery.isEmptyObject( orig ) ) {
6452 if ( "hidden" in dataShow ) {
6453 hidden = dataShow.hidden;
6456 dataShow = data_priv.access( elem, "fxshow", {} );
6459 // Store state if its toggle - enables .stop().toggle() to "reverse"
6461 dataShow.hidden = !hidden;
6464 jQuery( elem ).show();
6466 anim.done(function() {
6467 jQuery( elem ).hide();
6470 anim.done(function() {
6473 data_priv.remove( elem, "fxshow" );
6474 for ( prop in orig ) {
6475 jQuery.style( elem, prop, orig[ prop ] );
6478 for ( prop in orig ) {
6479 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
6481 if ( !( prop in dataShow ) ) {
6482 dataShow[ prop ] = tween.start;
6484 tween.end = tween.start;
6485 tween.start = prop === "width" || prop === "height" ? 1 : 0;
6490 // If this is a noop like .hide().hide(), restore an overwritten display value
6491 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
6492 style.display = display;
6496 function propFilter( props, specialEasing ) {
6497 var index, name, easing, value, hooks;
6499 // camelCase, specialEasing and expand cssHook pass
6500 for ( index in props ) {
6501 name = jQuery.camelCase( index );
6502 easing = specialEasing[ name ];
6503 value = props[ index ];
6504 if ( jQuery.isArray( value ) ) {
6505 easing = value[ 1 ];
6506 value = props[ index ] = value[ 0 ];
6509 if ( index !== name ) {
6510 props[ name ] = value;
6511 delete props[ index ];
6514 hooks = jQuery.cssHooks[ name ];
6515 if ( hooks && "expand" in hooks ) {
6516 value = hooks.expand( value );
6517 delete props[ name ];
6519 // Not quite $.extend, this won't overwrite existing keys.
6520 // Reusing 'index' because we have the correct "name"
6521 for ( index in value ) {
6522 if ( !( index in props ) ) {
6523 props[ index ] = value[ index ];
6524 specialEasing[ index ] = easing;
6528 specialEasing[ name ] = easing;
6533 function Animation( elem, properties, options ) {
6537 length = animationPrefilters.length,
6538 deferred = jQuery.Deferred().always( function() {
6539 // Don't match elem in the :animated selector
6546 var currentTime = fxNow || createFxNow(),
6547 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
6548 // Support: Android 2.3
6549 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
6550 temp = remaining / animation.duration || 0,
6553 length = animation.tweens.length;
6555 for ( ; index < length ; index++ ) {
6556 animation.tweens[ index ].run( percent );
6559 deferred.notifyWith( elem, [ animation, percent, remaining ]);
6561 if ( percent < 1 && length ) {
6564 deferred.resolveWith( elem, [ animation ] );
6568 animation = deferred.promise({
6570 props: jQuery.extend( {}, properties ),
6571 opts: jQuery.extend( true, { specialEasing: {} }, options ),
6572 originalProperties: properties,
6573 originalOptions: options,
6574 startTime: fxNow || createFxNow(),
6575 duration: options.duration,
6577 createTween: function( prop, end ) {
6578 var tween = jQuery.Tween( elem, animation.opts, prop, end,
6579 animation.opts.specialEasing[ prop ] || animation.opts.easing );
6580 animation.tweens.push( tween );
6583 stop: function( gotoEnd ) {
6585 // If we are going to the end, we want to run all the tweens
6586 // otherwise we skip this part
6587 length = gotoEnd ? animation.tweens.length : 0;
6592 for ( ; index < length ; index++ ) {
6593 animation.tweens[ index ].run( 1 );
6596 // Resolve when we played the last frame; otherwise, reject
6598 deferred.resolveWith( elem, [ animation, gotoEnd ] );
6600 deferred.rejectWith( elem, [ animation, gotoEnd ] );
6605 props = animation.props;
6607 propFilter( props, animation.opts.specialEasing );
6609 for ( ; index < length ; index++ ) {
6610 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
6616 jQuery.map( props, createTween, animation );
6618 if ( jQuery.isFunction( animation.opts.start ) ) {
6619 animation.opts.start.call( elem, animation );
6623 jQuery.extend( tick, {
6626 queue: animation.opts.queue
6630 // attach callbacks from options
6631 return animation.progress( animation.opts.progress )
6632 .done( animation.opts.done, animation.opts.complete )
6633 .fail( animation.opts.fail )
6634 .always( animation.opts.always );
6637 jQuery.Animation = jQuery.extend( Animation, {
6639 tweener: function( props, callback ) {
6640 if ( jQuery.isFunction( props ) ) {
6644 props = props.split(" ");
6649 length = props.length;
6651 for ( ; index < length ; index++ ) {
6652 prop = props[ index ];
6653 tweeners[ prop ] = tweeners[ prop ] || [];
6654 tweeners[ prop ].unshift( callback );
6658 prefilter: function( callback, prepend ) {
6660 animationPrefilters.unshift( callback );
6662 animationPrefilters.push( callback );
6667 jQuery.speed = function( speed, easing, fn ) {
6668 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
6669 complete: fn || !fn && easing ||
6670 jQuery.isFunction( speed ) && speed,
6672 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
6675 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
6676 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
6678 // Normalize opt.queue - true/undefined/null -> "fx"
6679 if ( opt.queue == null || opt.queue === true ) {
6684 opt.old = opt.complete;
6686 opt.complete = function() {
6687 if ( jQuery.isFunction( opt.old ) ) {
6688 opt.old.call( this );
6692 jQuery.dequeue( this, opt.queue );
6700 fadeTo: function( speed, to, easing, callback ) {
6702 // Show any hidden elements after setting opacity to 0
6703 return this.filter( isHidden ).css( "opacity", 0 ).show()
6705 // Animate to the value specified
6706 .end().animate({ opacity: to }, speed, easing, callback );
6708 animate: function( prop, speed, easing, callback ) {
6709 var empty = jQuery.isEmptyObject( prop ),
6710 optall = jQuery.speed( speed, easing, callback ),
6711 doAnimation = function() {
6712 // Operate on a copy of prop so per-property easing won't be lost
6713 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
6715 // Empty animations, or finishing resolves immediately
6716 if ( empty || data_priv.get( this, "finish" ) ) {
6720 doAnimation.finish = doAnimation;
6722 return empty || optall.queue === false ?
6723 this.each( doAnimation ) :
6724 this.queue( optall.queue, doAnimation );
6726 stop: function( type, clearQueue, gotoEnd ) {
6727 var stopQueue = function( hooks ) {
6728 var stop = hooks.stop;
6733 if ( typeof type !== "string" ) {
6734 gotoEnd = clearQueue;
6738 if ( clearQueue && type !== false ) {
6739 this.queue( type || "fx", [] );
6742 return this.each(function() {
6744 index = type != null && type + "queueHooks",
6745 timers = jQuery.timers,
6746 data = data_priv.get( this );
6749 if ( data[ index ] && data[ index ].stop ) {
6750 stopQueue( data[ index ] );
6753 for ( index in data ) {
6754 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
6755 stopQueue( data[ index ] );
6760 for ( index = timers.length; index--; ) {
6761 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
6762 timers[ index ].anim.stop( gotoEnd );
6764 timers.splice( index, 1 );
6768 // Start the next in the queue if the last step wasn't forced.
6769 // Timers currently will call their complete callbacks, which
6770 // will dequeue but only if they were gotoEnd.
6771 if ( dequeue || !gotoEnd ) {
6772 jQuery.dequeue( this, type );
6776 finish: function( type ) {
6777 if ( type !== false ) {
6778 type = type || "fx";
6780 return this.each(function() {
6782 data = data_priv.get( this ),
6783 queue = data[ type + "queue" ],
6784 hooks = data[ type + "queueHooks" ],
6785 timers = jQuery.timers,
6786 length = queue ? queue.length : 0;
6788 // Enable finishing flag on private data
6791 // Empty the queue first
6792 jQuery.queue( this, type, [] );
6794 if ( hooks && hooks.stop ) {
6795 hooks.stop.call( this, true );
6798 // Look for any active animations, and finish them
6799 for ( index = timers.length; index--; ) {
6800 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
6801 timers[ index ].anim.stop( true );
6802 timers.splice( index, 1 );
6806 // Look for any animations in the old queue and finish them
6807 for ( index = 0; index < length; index++ ) {
6808 if ( queue[ index ] && queue[ index ].finish ) {
6809 queue[ index ].finish.call( this );
6813 // Turn off finishing flag
6819 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
6820 var cssFn = jQuery.fn[ name ];
6821 jQuery.fn[ name ] = function( speed, easing, callback ) {
6822 return speed == null || typeof speed === "boolean" ?
6823 cssFn.apply( this, arguments ) :
6824 this.animate( genFx( name, true ), speed, easing, callback );
6828 // Generate shortcuts for custom animations
6830 slideDown: genFx("show"),
6831 slideUp: genFx("hide"),
6832 slideToggle: genFx("toggle"),
6833 fadeIn: { opacity: "show" },
6834 fadeOut: { opacity: "hide" },
6835 fadeToggle: { opacity: "toggle" }
6836 }, function( name, props ) {
6837 jQuery.fn[ name ] = function( speed, easing, callback ) {
6838 return this.animate( props, speed, easing, callback );
6843 jQuery.fx.tick = function() {
6846 timers = jQuery.timers;
6848 fxNow = jQuery.now();
6850 for ( ; i < timers.length; i++ ) {
6851 timer = timers[ i ];
6852 // Checks the timer has not already been removed
6853 if ( !timer() && timers[ i ] === timer ) {
6854 timers.splice( i--, 1 );
6858 if ( !timers.length ) {
6864 jQuery.fx.timer = function( timer ) {
6865 jQuery.timers.push( timer );
6869 jQuery.timers.pop();
6873 jQuery.fx.interval = 13;
6875 jQuery.fx.start = function() {
6877 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
6881 jQuery.fx.stop = function() {
6882 clearInterval( timerId );
6886 jQuery.fx.speeds = {
6894 // Based off of the plugin by Clint Helfers, with permission.
6895 // http://blindsignals.com/index.php/2009/07/jquery-delay/
6896 jQuery.fn.delay = function( time, type ) {
6897 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
6898 type = type || "fx";
6900 return this.queue( type, function( next, hooks ) {
6901 var timeout = setTimeout( next, time );
6902 hooks.stop = function() {
6903 clearTimeout( timeout );
6910 var input = document.createElement( "input" ),
6911 select = document.createElement( "select" ),
6912 opt = select.appendChild( document.createElement( "option" ) );
6914 input.type = "checkbox";
6916 // Support: iOS<=5.1, Android<=4.2+
6917 // Default value for a checkbox should be "on"
6918 support.checkOn = input.value !== "";
6921 // Must access selectedIndex to make default options select
6922 support.optSelected = opt.selected;
6924 // Support: Android<=2.3
6925 // Options inside disabled selects are incorrectly marked as disabled
6926 select.disabled = true;
6927 support.optDisabled = !opt.disabled;
6930 // An input loses its value after becoming a radio
6931 input = document.createElement( "input" );
6933 input.type = "radio";
6934 support.radioValue = input.value === "t";
6938 var nodeHook, boolHook,
6939 attrHandle = jQuery.expr.attrHandle;
6942 attr: function( name, value ) {
6943 return access( this, jQuery.attr, name, value, arguments.length > 1 );
6946 removeAttr: function( name ) {
6947 return this.each(function() {
6948 jQuery.removeAttr( this, name );
6954 attr: function( elem, name, value ) {
6956 nType = elem.nodeType;
6958 // don't get/set attributes on text, comment and attribute nodes
6959 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
6963 // Fallback to prop when attributes are not supported
6964 if ( typeof elem.getAttribute === strundefined ) {
6965 return jQuery.prop( elem, name, value );
6968 // All attributes are lowercase
6969 // Grab necessary hook if one is defined
6970 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
6971 name = name.toLowerCase();
6972 hooks = jQuery.attrHooks[ name ] ||
6973 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
6976 if ( value !== undefined ) {
6978 if ( value === null ) {
6979 jQuery.removeAttr( elem, name );
6981 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
6985 elem.setAttribute( name, value + "" );
6989 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
6993 ret = jQuery.find.attr( elem, name );
6995 // Non-existent attributes return null, we normalize to undefined
6996 return ret == null ?
7002 removeAttr: function( elem, value ) {
7005 attrNames = value && value.match( rnotwhite );
7007 if ( attrNames && elem.nodeType === 1 ) {
7008 while ( (name = attrNames[i++]) ) {
7009 propName = jQuery.propFix[ name ] || name;
7011 // Boolean attributes get special treatment (#10870)
7012 if ( jQuery.expr.match.bool.test( name ) ) {
7013 // Set corresponding property to false
7014 elem[ propName ] = false;
7017 elem.removeAttribute( name );
7024 set: function( elem, value ) {
7025 if ( !support.radioValue && value === "radio" &&
7026 jQuery.nodeName( elem, "input" ) ) {
7027 var val = elem.value;
7028 elem.setAttribute( "type", value );
7039 // Hooks for boolean attributes
7041 set: function( elem, value, name ) {
7042 if ( value === false ) {
7043 // Remove boolean attributes when set to false
7044 jQuery.removeAttr( elem, name );
7046 elem.setAttribute( name, name );
7051 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
7052 var getter = attrHandle[ name ] || jQuery.find.attr;
7054 attrHandle[ name ] = function( elem, name, isXML ) {
7057 // Avoid an infinite loop by temporarily removing this function from the getter
7058 handle = attrHandle[ name ];
7059 attrHandle[ name ] = ret;
7060 ret = getter( elem, name, isXML ) != null ?
7061 name.toLowerCase() :
7063 attrHandle[ name ] = handle;
7072 var rfocusable = /^(?:input|select|textarea|button)$/i;
7075 prop: function( name, value ) {
7076 return access( this, jQuery.prop, name, value, arguments.length > 1 );
7079 removeProp: function( name ) {
7080 return this.each(function() {
7081 delete this[ jQuery.propFix[ name ] || name ];
7089 "class": "className"
7092 prop: function( elem, name, value ) {
7093 var ret, hooks, notxml,
7094 nType = elem.nodeType;
7096 // Don't get/set properties on text, comment and attribute nodes
7097 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
7101 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
7104 // Fix name and attach hooks
7105 name = jQuery.propFix[ name ] || name;
7106 hooks = jQuery.propHooks[ name ];
7109 if ( value !== undefined ) {
7110 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
7112 ( elem[ name ] = value );
7115 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
7123 get: function( elem ) {
7124 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
7132 if ( !support.optSelected ) {
7133 jQuery.propHooks.selected = {
7134 get: function( elem ) {
7135 var parent = elem.parentNode;
7136 if ( parent && parent.parentNode ) {
7137 parent.parentNode.selectedIndex;
7156 jQuery.propFix[ this.toLowerCase() ] = this;
7162 var rclass = /[\t\r\n\f]/g;
7165 addClass: function( value ) {
7166 var classes, elem, cur, clazz, j, finalValue,
7167 proceed = typeof value === "string" && value,
7171 if ( jQuery.isFunction( value ) ) {
7172 return this.each(function( j ) {
7173 jQuery( this ).addClass( value.call( this, j, this.className ) );
7178 // The disjunction here is for better compressibility (see removeClass)
7179 classes = ( value || "" ).match( rnotwhite ) || [];
7181 for ( ; i < len; i++ ) {
7183 cur = elem.nodeType === 1 && ( elem.className ?
7184 ( " " + elem.className + " " ).replace( rclass, " " ) :
7190 while ( (clazz = classes[j++]) ) {
7191 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
7196 // only assign if different to avoid unneeded rendering.
7197 finalValue = jQuery.trim( cur );
7198 if ( elem.className !== finalValue ) {
7199 elem.className = finalValue;
7208 removeClass: function( value ) {
7209 var classes, elem, cur, clazz, j, finalValue,
7210 proceed = arguments.length === 0 || typeof value === "string" && value,
7214 if ( jQuery.isFunction( value ) ) {
7215 return this.each(function( j ) {
7216 jQuery( this ).removeClass( value.call( this, j, this.className ) );
7220 classes = ( value || "" ).match( rnotwhite ) || [];
7222 for ( ; i < len; i++ ) {
7224 // This expression is here for better compressibility (see addClass)
7225 cur = elem.nodeType === 1 && ( elem.className ?
7226 ( " " + elem.className + " " ).replace( rclass, " " ) :
7232 while ( (clazz = classes[j++]) ) {
7233 // Remove *all* instances
7234 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
7235 cur = cur.replace( " " + clazz + " ", " " );
7239 // Only assign if different to avoid unneeded rendering.
7240 finalValue = value ? jQuery.trim( cur ) : "";
7241 if ( elem.className !== finalValue ) {
7242 elem.className = finalValue;
7251 toggleClass: function( value, stateVal ) {
7252 var type = typeof value;
7254 if ( typeof stateVal === "boolean" && type === "string" ) {
7255 return stateVal ? this.addClass( value ) : this.removeClass( value );
7258 if ( jQuery.isFunction( value ) ) {
7259 return this.each(function( i ) {
7260 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
7264 return this.each(function() {
7265 if ( type === "string" ) {
7266 // Toggle individual class names
7269 self = jQuery( this ),
7270 classNames = value.match( rnotwhite ) || [];
7272 while ( (className = classNames[ i++ ]) ) {
7273 // Check each className given, space separated list
7274 if ( self.hasClass( className ) ) {
7275 self.removeClass( className );
7277 self.addClass( className );
7281 // Toggle whole class name
7282 } else if ( type === strundefined || type === "boolean" ) {
7283 if ( this.className ) {
7284 // store className if set
7285 data_priv.set( this, "__className__", this.className );
7288 // If the element has a class name or if we're passed `false`,
7289 // then remove the whole classname (if there was one, the above saved it).
7290 // Otherwise bring back whatever was previously saved (if anything),
7291 // falling back to the empty string if nothing was stored.
7292 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
7297 hasClass: function( selector ) {
7298 var className = " " + selector + " ",
7301 for ( ; i < l; i++ ) {
7302 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
7314 var rreturn = /\r/g;
7317 val: function( value ) {
7318 var hooks, ret, isFunction,
7321 if ( !arguments.length ) {
7323 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
7325 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
7331 return typeof ret === "string" ?
7332 // Handle most common string cases
7333 ret.replace(rreturn, "") :
7334 // Handle cases where value is null/undef or number
7335 ret == null ? "" : ret;
7341 isFunction = jQuery.isFunction( value );
7343 return this.each(function( i ) {
7346 if ( this.nodeType !== 1 ) {
7351 val = value.call( this, i, jQuery( this ).val() );
7356 // Treat null/undefined as ""; convert numbers to string
7357 if ( val == null ) {
7360 } else if ( typeof val === "number" ) {
7363 } else if ( jQuery.isArray( val ) ) {
7364 val = jQuery.map( val, function( value ) {
7365 return value == null ? "" : value + "";
7369 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
7371 // If set returns undefined, fall back to normal setting
7372 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
7382 get: function( elem ) {
7383 var val = jQuery.find.attr( elem, "value" );
7384 return val != null ?
7386 // Support: IE10-11+
7387 // option.text throws exceptions (#14686, #14858)
7388 jQuery.trim( jQuery.text( elem ) );
7392 get: function( elem ) {
7394 options = elem.options,
7395 index = elem.selectedIndex,
7396 one = elem.type === "select-one" || index < 0,
7397 values = one ? null : [],
7398 max = one ? index + 1 : options.length,
7403 // Loop through all the selected options
7404 for ( ; i < max; i++ ) {
7405 option = options[ i ];
7407 // IE6-9 doesn't update selected after form reset (#2551)
7408 if ( ( option.selected || i === index ) &&
7409 // Don't return options that are disabled or in a disabled optgroup
7410 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
7411 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
7413 // Get the specific value for the option
7414 value = jQuery( option ).val();
7416 // We don't need an array for one selects
7421 // Multi-Selects return an array
7422 values.push( value );
7429 set: function( elem, value ) {
7430 var optionSet, option,
7431 options = elem.options,
7432 values = jQuery.makeArray( value ),
7436 option = options[ i ];
7437 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
7442 // Force browsers to behave consistently when non-matching value is set
7444 elem.selectedIndex = -1;
7452 // Radios and checkboxes getter/setter
7453 jQuery.each([ "radio", "checkbox" ], function() {
7454 jQuery.valHooks[ this ] = {
7455 set: function( elem, value ) {
7456 if ( jQuery.isArray( value ) ) {
7457 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
7461 if ( !support.checkOn ) {
7462 jQuery.valHooks[ this ].get = function( elem ) {
7463 return elem.getAttribute("value") === null ? "on" : elem.value;
7471 // Return jQuery for attributes-only inclusion
7474 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
7475 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7476 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
7478 // Handle event binding
7479 jQuery.fn[ name ] = function( data, fn ) {
7480 return arguments.length > 0 ?
7481 this.on( name, null, data, fn ) :
7482 this.trigger( name );
7487 hover: function( fnOver, fnOut ) {
7488 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
7491 bind: function( types, data, fn ) {
7492 return this.on( types, null, data, fn );
7494 unbind: function( types, fn ) {
7495 return this.off( types, null, fn );
7498 delegate: function( selector, types, data, fn ) {
7499 return this.on( types, selector, data, fn );
7501 undelegate: function( selector, types, fn ) {
7502 // ( namespace ) or ( selector, types [, fn] )
7503 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
7508 var nonce = jQuery.now();
7510 var rquery = (/\?/);
7514 // Support: Android 2.3
7515 // Workaround failure to string-cast null input
7516 jQuery.parseJSON = function( data ) {
7517 return JSON.parse( data + "" );
7521 // Cross-browser xml parsing
7522 jQuery.parseXML = function( data ) {
7524 if ( !data || typeof data !== "string" ) {
7530 tmp = new DOMParser();
7531 xml = tmp.parseFromString( data, "text/xml" );
7536 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
7537 jQuery.error( "Invalid XML: " + data );
7545 rts = /([?&])_=[^&]*/,
7546 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
7547 // #7653, #8125, #8152: local protocol detection
7548 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7549 rnoContent = /^(?:GET|HEAD)$/,
7550 rprotocol = /^\/\//,
7551 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
7554 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7555 * 2) These are called:
7556 * - BEFORE asking for a transport
7557 * - AFTER param serialization (s.data is a string if s.processData is true)
7558 * 3) key is the dataType
7559 * 4) the catchall symbol "*" can be used
7560 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7564 /* Transports bindings
7565 * 1) key is the dataType
7566 * 2) the catchall symbol "*" can be used
7567 * 3) selection will start with transport dataType and THEN go to "*" if needed
7571 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7572 allTypes = "*/".concat( "*" ),
7574 // Document location
7575 ajaxLocation = window.location.href,
7577 // Segment location into parts
7578 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7580 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7581 function addToPrefiltersOrTransports( structure ) {
7583 // dataTypeExpression is optional and defaults to "*"
7584 return function( dataTypeExpression, func ) {
7586 if ( typeof dataTypeExpression !== "string" ) {
7587 func = dataTypeExpression;
7588 dataTypeExpression = "*";
7593 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
7595 if ( jQuery.isFunction( func ) ) {
7596 // For each dataType in the dataTypeExpression
7597 while ( (dataType = dataTypes[i++]) ) {
7598 // Prepend if requested
7599 if ( dataType[0] === "+" ) {
7600 dataType = dataType.slice( 1 ) || "*";
7601 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
7605 (structure[ dataType ] = structure[ dataType ] || []).push( func );
7612 // Base inspection function for prefilters and transports
7613 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
7616 seekingTransport = ( structure === transports );
7618 function inspect( dataType ) {
7620 inspected[ dataType ] = true;
7621 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
7622 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
7623 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
7624 options.dataTypes.unshift( dataTypeOrTransport );
7625 inspect( dataTypeOrTransport );
7627 } else if ( seekingTransport ) {
7628 return !( selected = dataTypeOrTransport );
7634 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
7637 // A special extend for ajax options
7638 // that takes "flat" options (not to be deep extended)
7640 function ajaxExtend( target, src ) {
7642 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7644 for ( key in src ) {
7645 if ( src[ key ] !== undefined ) {
7646 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
7650 jQuery.extend( true, target, deep );
7656 /* Handles responses to an ajax request:
7657 * - finds the right dataType (mediates between content-type and expected dataType)
7658 * - returns the corresponding response
7660 function ajaxHandleResponses( s, jqXHR, responses ) {
7662 var ct, type, finalDataType, firstDataType,
7663 contents = s.contents,
7664 dataTypes = s.dataTypes;
7666 // Remove auto dataType and get content-type in the process
7667 while ( dataTypes[ 0 ] === "*" ) {
7669 if ( ct === undefined ) {
7670 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
7674 // Check if we're dealing with a known content-type
7676 for ( type in contents ) {
7677 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7678 dataTypes.unshift( type );
7684 // Check to see if we have a response for the expected dataType
7685 if ( dataTypes[ 0 ] in responses ) {
7686 finalDataType = dataTypes[ 0 ];
7688 // Try convertible dataTypes
7689 for ( type in responses ) {
7690 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7691 finalDataType = type;
7694 if ( !firstDataType ) {
7695 firstDataType = type;
7698 // Or just use first one
7699 finalDataType = finalDataType || firstDataType;
7702 // If we found a dataType
7703 // We add the dataType to the list if needed
7704 // and return the corresponding response
7705 if ( finalDataType ) {
7706 if ( finalDataType !== dataTypes[ 0 ] ) {
7707 dataTypes.unshift( finalDataType );
7709 return responses[ finalDataType ];
7713 /* Chain conversions given the request and the original response
7714 * Also sets the responseXXX fields on the jqXHR instance
7716 function ajaxConvert( s, response, jqXHR, isSuccess ) {
7717 var conv2, current, conv, tmp, prev,
7719 // Work with a copy of dataTypes in case we need to modify it for conversion
7720 dataTypes = s.dataTypes.slice();
7722 // Create converters map with lowercased keys
7723 if ( dataTypes[ 1 ] ) {
7724 for ( conv in s.converters ) {
7725 converters[ conv.toLowerCase() ] = s.converters[ conv ];
7729 current = dataTypes.shift();
7731 // Convert to each sequential dataType
7734 if ( s.responseFields[ current ] ) {
7735 jqXHR[ s.responseFields[ current ] ] = response;
7738 // Apply the dataFilter if provided
7739 if ( !prev && isSuccess && s.dataFilter ) {
7740 response = s.dataFilter( response, s.dataType );
7744 current = dataTypes.shift();
7748 // There's only work to do if current dataType is non-auto
7749 if ( current === "*" ) {
7753 // Convert response if prev dataType is non-auto and differs from current
7754 } else if ( prev !== "*" && prev !== current ) {
7756 // Seek a direct converter
7757 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
7759 // If none found, seek a pair
7761 for ( conv2 in converters ) {
7763 // If conv2 outputs current
7764 tmp = conv2.split( " " );
7765 if ( tmp[ 1 ] === current ) {
7767 // If prev can be converted to accepted input
7768 conv = converters[ prev + " " + tmp[ 0 ] ] ||
7769 converters[ "* " + tmp[ 0 ] ];
7771 // Condense equivalence converters
7772 if ( conv === true ) {
7773 conv = converters[ conv2 ];
7775 // Otherwise, insert the intermediate dataType
7776 } else if ( converters[ conv2 ] !== true ) {
7778 dataTypes.unshift( tmp[ 1 ] );
7786 // Apply converter (if not an equivalence)
7787 if ( conv !== true ) {
7789 // Unless errors are allowed to bubble, catch and return them
7790 if ( conv && s[ "throws" ] ) {
7791 response = conv( response );
7794 response = conv( response );
7796 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
7804 return { state: "success", data: response };
7809 // Counter for holding the number of active queries
7812 // Last-Modified header cache for next request
7819 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7823 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7840 xml: "application/xml, text/xml",
7841 json: "application/json, text/javascript"
7852 text: "responseText",
7853 json: "responseJSON"
7857 // Keys separate source (or catchall "*") and destination types with a single space
7860 // Convert anything to text
7863 // Text to html (true = no transformation)
7866 // Evaluate text as a json expression
7867 "text json": jQuery.parseJSON,
7869 // Parse text as xml
7870 "text xml": jQuery.parseXML
7873 // For options that shouldn't be deep extended:
7874 // you can add your own custom options here if
7875 // and when you create one that shouldn't be
7876 // deep extended (see ajaxExtend)
7883 // Creates a full fledged settings object into target
7884 // with both ajaxSettings and settings fields.
7885 // If target is omitted, writes into ajaxSettings.
7886 ajaxSetup: function( target, settings ) {
7889 // Building a settings object
7890 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
7892 // Extending ajaxSettings
7893 ajaxExtend( jQuery.ajaxSettings, target );
7896 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7897 ajaxTransport: addToPrefiltersOrTransports( transports ),
7900 ajax: function( url, options ) {
7902 // If url is an object, simulate pre-1.5 signature
7903 if ( typeof url === "object" ) {
7908 // Force options to be an object
7909 options = options || {};
7912 // URL without anti-cache param
7915 responseHeadersString,
7919 // Cross-domain detection vars
7921 // To know if global events are to be dispatched
7925 // Create the final options object
7926 s = jQuery.ajaxSetup( {}, options ),
7927 // Callbacks context
7928 callbackContext = s.context || s,
7929 // Context for global events is callbackContext if it is a DOM node or jQuery collection
7930 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
7931 jQuery( callbackContext ) :
7934 deferred = jQuery.Deferred(),
7935 completeDeferred = jQuery.Callbacks("once memory"),
7936 // Status-dependent callbacks
7937 statusCode = s.statusCode || {},
7938 // Headers (they are sent all at once)
7939 requestHeaders = {},
7940 requestHeadersNames = {},
7943 // Default abort message
7944 strAbort = "canceled",
7949 // Builds headers hashtable if needed
7950 getResponseHeader: function( key ) {
7952 if ( state === 2 ) {
7953 if ( !responseHeaders ) {
7954 responseHeaders = {};
7955 while ( (match = rheaders.exec( responseHeadersString )) ) {
7956 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7959 match = responseHeaders[ key.toLowerCase() ];
7961 return match == null ? null : match;
7965 getAllResponseHeaders: function() {
7966 return state === 2 ? responseHeadersString : null;
7969 // Caches the header
7970 setRequestHeader: function( name, value ) {
7971 var lname = name.toLowerCase();
7973 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7974 requestHeaders[ name ] = value;
7979 // Overrides response content-type header
7980 overrideMimeType: function( type ) {
7987 // Status-dependent callbacks
7988 statusCode: function( map ) {
7992 for ( code in map ) {
7993 // Lazy-add the new callback in a way that preserves old ones
7994 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
7997 // Execute the appropriate callbacks
7998 jqXHR.always( map[ jqXHR.status ] );
8004 // Cancel the request
8005 abort: function( statusText ) {
8006 var finalText = statusText || strAbort;
8008 transport.abort( finalText );
8010 done( 0, finalText );
8016 deferred.promise( jqXHR ).complete = completeDeferred.add;
8017 jqXHR.success = jqXHR.done;
8018 jqXHR.error = jqXHR.fail;
8020 // Remove hash character (#7531: and string promotion)
8021 // Add protocol if not provided (prefilters might expect it)
8022 // Handle falsy url in the settings object (#10093: consistency with old signature)
8023 // We also use the url parameter if available
8024 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
8025 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
8027 // Alias method option to type as per ticket #12004
8028 s.type = options.method || options.type || s.method || s.type;
8030 // Extract dataTypes list
8031 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
8033 // A cross-domain request is in order when we have a protocol:host:port mismatch
8034 if ( s.crossDomain == null ) {
8035 parts = rurl.exec( s.url.toLowerCase() );
8036 s.crossDomain = !!( parts &&
8037 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
8038 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
8039 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
8043 // Convert data if not already a string
8044 if ( s.data && s.processData && typeof s.data !== "string" ) {
8045 s.data = jQuery.param( s.data, s.traditional );
8049 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
8051 // If request was aborted inside a prefilter, stop there
8052 if ( state === 2 ) {
8056 // We can fire global events as of now if asked to
8057 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
8058 fireGlobals = jQuery.event && s.global;
8060 // Watch for a new set of requests
8061 if ( fireGlobals && jQuery.active++ === 0 ) {
8062 jQuery.event.trigger("ajaxStart");
8065 // Uppercase the type
8066 s.type = s.type.toUpperCase();
8068 // Determine if request has content
8069 s.hasContent = !rnoContent.test( s.type );
8071 // Save the URL in case we're toying with the If-Modified-Since
8072 // and/or If-None-Match header later on
8075 // More options handling for requests with no content
8076 if ( !s.hasContent ) {
8078 // If data is available, append data to url
8080 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
8081 // #9682: remove data so that it's not used in an eventual retry
8085 // Add anti-cache in url if needed
8086 if ( s.cache === false ) {
8087 s.url = rts.test( cacheURL ) ?
8089 // If there is already a '_' parameter, set its value
8090 cacheURL.replace( rts, "$1_=" + nonce++ ) :
8092 // Otherwise add one to the end
8093 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
8097 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8098 if ( s.ifModified ) {
8099 if ( jQuery.lastModified[ cacheURL ] ) {
8100 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
8102 if ( jQuery.etag[ cacheURL ] ) {
8103 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
8107 // Set the correct header, if data is being sent
8108 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
8109 jqXHR.setRequestHeader( "Content-Type", s.contentType );
8112 // Set the Accepts header for the server, depending on the dataType
8113 jqXHR.setRequestHeader(
8115 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
8116 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
8120 // Check for headers option
8121 for ( i in s.headers ) {
8122 jqXHR.setRequestHeader( i, s.headers[ i ] );
8125 // Allow custom headers/mimetypes and early abort
8126 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
8127 // Abort if not done already and return
8128 return jqXHR.abort();
8131 // Aborting is no longer a cancellation
8134 // Install callbacks on deferreds
8135 for ( i in { success: 1, error: 1, complete: 1 } ) {
8136 jqXHR[ i ]( s[ i ] );
8140 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
8142 // If no transport, we auto-abort
8144 done( -1, "No Transport" );
8146 jqXHR.readyState = 1;
8148 // Send global event
8149 if ( fireGlobals ) {
8150 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
8153 if ( s.async && s.timeout > 0 ) {
8154 timeoutTimer = setTimeout(function() {
8155 jqXHR.abort("timeout");
8161 transport.send( requestHeaders, done );
8163 // Propagate exception as error if not done
8166 // Simply rethrow otherwise
8173 // Callback for when everything is done
8174 function done( status, nativeStatusText, responses, headers ) {
8175 var isSuccess, success, error, response, modified,
8176 statusText = nativeStatusText;
8179 if ( state === 2 ) {
8183 // State is "done" now
8186 // Clear timeout if it exists
8187 if ( timeoutTimer ) {
8188 clearTimeout( timeoutTimer );
8191 // Dereference transport for early garbage collection
8192 // (no matter how long the jqXHR object will be used)
8193 transport = undefined;
8195 // Cache response headers
8196 responseHeadersString = headers || "";
8199 jqXHR.readyState = status > 0 ? 4 : 0;
8201 // Determine if successful
8202 isSuccess = status >= 200 && status < 300 || status === 304;
8204 // Get response data
8206 response = ajaxHandleResponses( s, jqXHR, responses );
8209 // Convert no matter what (that way responseXXX fields are always set)
8210 response = ajaxConvert( s, response, jqXHR, isSuccess );
8212 // If successful, handle type chaining
8215 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8216 if ( s.ifModified ) {
8217 modified = jqXHR.getResponseHeader("Last-Modified");
8219 jQuery.lastModified[ cacheURL ] = modified;
8221 modified = jqXHR.getResponseHeader("etag");
8223 jQuery.etag[ cacheURL ] = modified;
8228 if ( status === 204 || s.type === "HEAD" ) {
8229 statusText = "nocontent";
8232 } else if ( status === 304 ) {
8233 statusText = "notmodified";
8235 // If we have data, let's convert it
8237 statusText = response.state;
8238 success = response.data;
8239 error = response.error;
8243 // Extract error from statusText and normalize for non-aborts
8245 if ( status || !statusText ) {
8246 statusText = "error";
8253 // Set data for the fake xhr object
8254 jqXHR.status = status;
8255 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
8259 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
8261 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
8264 // Status-dependent callbacks
8265 jqXHR.statusCode( statusCode );
8266 statusCode = undefined;
8268 if ( fireGlobals ) {
8269 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
8270 [ jqXHR, s, isSuccess ? success : error ] );
8274 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
8276 if ( fireGlobals ) {
8277 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
8278 // Handle the global AJAX counter
8279 if ( !( --jQuery.active ) ) {
8280 jQuery.event.trigger("ajaxStop");
8288 getJSON: function( url, data, callback ) {
8289 return jQuery.get( url, data, callback, "json" );
8292 getScript: function( url, callback ) {
8293 return jQuery.get( url, undefined, callback, "script" );
8297 jQuery.each( [ "get", "post" ], function( i, method ) {
8298 jQuery[ method ] = function( url, data, callback, type ) {
8299 // Shift arguments if data argument was omitted
8300 if ( jQuery.isFunction( data ) ) {
8301 type = type || callback;
8306 return jQuery.ajax({
8317 jQuery._evalUrl = function( url ) {
8318 return jQuery.ajax({
8330 wrapAll: function( html ) {
8333 if ( jQuery.isFunction( html ) ) {
8334 return this.each(function( i ) {
8335 jQuery( this ).wrapAll( html.call(this, i) );
8341 // The elements to wrap the target around
8342 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
8344 if ( this[ 0 ].parentNode ) {
8345 wrap.insertBefore( this[ 0 ] );
8348 wrap.map(function() {
8351 while ( elem.firstElementChild ) {
8352 elem = elem.firstElementChild;
8362 wrapInner: function( html ) {
8363 if ( jQuery.isFunction( html ) ) {
8364 return this.each(function( i ) {
8365 jQuery( this ).wrapInner( html.call(this, i) );
8369 return this.each(function() {
8370 var self = jQuery( this ),
8371 contents = self.contents();
8373 if ( contents.length ) {
8374 contents.wrapAll( html );
8377 self.append( html );
8382 wrap: function( html ) {
8383 var isFunction = jQuery.isFunction( html );
8385 return this.each(function( i ) {
8386 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
8390 unwrap: function() {
8391 return this.parent().each(function() {
8392 if ( !jQuery.nodeName( this, "body" ) ) {
8393 jQuery( this ).replaceWith( this.childNodes );
8400 jQuery.expr.filters.hidden = function( elem ) {
8401 // Support: Opera <= 12.12
8402 // Opera reports offsetWidths and offsetHeights less than zero on some elements
8403 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0;
8405 jQuery.expr.filters.visible = function( elem ) {
8406 return !jQuery.expr.filters.hidden( elem );
8415 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
8416 rsubmittable = /^(?:input|select|textarea|keygen)/i;
8418 function buildParams( prefix, obj, traditional, add ) {
8421 if ( jQuery.isArray( obj ) ) {
8422 // Serialize array item.
8423 jQuery.each( obj, function( i, v ) {
8424 if ( traditional || rbracket.test( prefix ) ) {
8425 // Treat each array item as a scalar.
8429 // Item is non-scalar (array or object), encode its numeric index.
8430 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
8434 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
8435 // Serialize object item.
8436 for ( name in obj ) {
8437 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
8441 // Serialize scalar item.
8446 // Serialize an array of form elements or a set of
8447 // key/values into a query string
8448 jQuery.param = function( a, traditional ) {
8451 add = function( key, value ) {
8452 // If value is a function, invoke it and return its value
8453 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
8454 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
8457 // Set traditional to true for jQuery <= 1.3.2 behavior.
8458 if ( traditional === undefined ) {
8459 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
8462 // If an array was passed in, assume that it is an array of form elements.
8463 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
8464 // Serialize the form elements
8465 jQuery.each( a, function() {
8466 add( this.name, this.value );
8470 // If traditional, encode the "old" way (the way 1.3.2 or older
8471 // did it), otherwise encode params recursively.
8472 for ( prefix in a ) {
8473 buildParams( prefix, a[ prefix ], traditional, add );
8477 // Return the resulting serialization
8478 return s.join( "&" ).replace( r20, "+" );
8482 serialize: function() {
8483 return jQuery.param( this.serializeArray() );
8485 serializeArray: function() {
8486 return this.map(function() {
8487 // Can add propHook for "elements" to filter or add form elements
8488 var elements = jQuery.prop( this, "elements" );
8489 return elements ? jQuery.makeArray( elements ) : this;
8491 .filter(function() {
8492 var type = this.type;
8494 // Use .is( ":disabled" ) so that fieldset[disabled] works
8495 return this.name && !jQuery( this ).is( ":disabled" ) &&
8496 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
8497 ( this.checked || !rcheckableType.test( type ) );
8499 .map(function( i, elem ) {
8500 var val = jQuery( this ).val();
8502 return val == null ?
8504 jQuery.isArray( val ) ?
8505 jQuery.map( val, function( val ) {
8506 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8508 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
8514 jQuery.ajaxSettings.xhr = function() {
8516 return new XMLHttpRequest();
8522 xhrSuccessStatus = {
8523 // file protocol always yields status code 0, assume 200
8526 // #1450: sometimes IE returns 1223 when it should be 204
8529 xhrSupported = jQuery.ajaxSettings.xhr();
8532 // Open requests must be manually aborted on unload (#5280)
8533 // See https://support.microsoft.com/kb/2856746 for more info
8534 if ( window.attachEvent ) {
8535 window.attachEvent( "onunload", function() {
8536 for ( var key in xhrCallbacks ) {
8537 xhrCallbacks[ key ]();
8542 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
8543 support.ajax = xhrSupported = !!xhrSupported;
8545 jQuery.ajaxTransport(function( options ) {
8548 // Cross domain only allowed if supported through XMLHttpRequest
8549 if ( support.cors || xhrSupported && !options.crossDomain ) {
8551 send: function( headers, complete ) {
8553 xhr = options.xhr(),
8556 xhr.open( options.type, options.url, options.async, options.username, options.password );
8558 // Apply custom fields if provided
8559 if ( options.xhrFields ) {
8560 for ( i in options.xhrFields ) {
8561 xhr[ i ] = options.xhrFields[ i ];
8565 // Override mime type if needed
8566 if ( options.mimeType && xhr.overrideMimeType ) {
8567 xhr.overrideMimeType( options.mimeType );
8570 // X-Requested-With header
8571 // For cross-domain requests, seeing as conditions for a preflight are
8572 // akin to a jigsaw puzzle, we simply never set it to be sure.
8573 // (it can always be set on a per-request basis or even using ajaxSetup)
8574 // For same-domain requests, won't change header if already provided.
8575 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
8576 headers["X-Requested-With"] = "XMLHttpRequest";
8580 for ( i in headers ) {
8581 xhr.setRequestHeader( i, headers[ i ] );
8585 callback = function( type ) {
8588 delete xhrCallbacks[ id ];
8589 callback = xhr.onload = xhr.onerror = null;
8591 if ( type === "abort" ) {
8593 } else if ( type === "error" ) {
8595 // file: protocol always yields status 0; see #8605, #14207
8601 xhrSuccessStatus[ xhr.status ] || xhr.status,
8604 // Accessing binary-data responseText throws an exception
8606 typeof xhr.responseText === "string" ? {
8607 text: xhr.responseText
8609 xhr.getAllResponseHeaders()
8617 xhr.onload = callback();
8618 xhr.onerror = callback("error");
8620 // Create the abort callback
8621 callback = xhrCallbacks[ id ] = callback("abort");
8624 // Do send the request (this may raise an exception)
8625 xhr.send( options.hasContent && options.data || null );
8627 // #14683: Only rethrow if this hasn't been notified as an error yet
8646 // Install script dataType
8649 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8652 script: /(?:java|ecma)script/
8655 "text script": function( text ) {
8656 jQuery.globalEval( text );
8662 // Handle cache's special case and crossDomain
8663 jQuery.ajaxPrefilter( "script", function( s ) {
8664 if ( s.cache === undefined ) {
8667 if ( s.crossDomain ) {
8672 // Bind script tag hack transport
8673 jQuery.ajaxTransport( "script", function( s ) {
8674 // This transport only deals with cross domain requests
8675 if ( s.crossDomain ) {
8676 var script, callback;
8678 send: function( _, complete ) {
8679 script = jQuery("<script>").prop({
8681 charset: s.scriptCharset,
8685 callback = function( evt ) {
8689 complete( evt.type === "error" ? 404 : 200, evt.type );
8693 document.head.appendChild( script[ 0 ] );
8707 var oldCallbacks = [],
8708 rjsonp = /(=)\?(?=&|$)|\?\?/;
8710 // Default jsonp settings
8713 jsonpCallback: function() {
8714 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
8715 this[ callback ] = true;
8720 // Detect, normalize options and install callbacks for jsonp requests
8721 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8723 var callbackName, overwritten, responseContainer,
8724 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
8726 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
8729 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8730 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
8732 // Get callback name, remembering preexisting value associated with it
8733 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8737 // Insert callback into url or form data
8739 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
8740 } else if ( s.jsonp !== false ) {
8741 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8744 // Use data converter to retrieve json after script execution
8745 s.converters["script json"] = function() {
8746 if ( !responseContainer ) {
8747 jQuery.error( callbackName + " was not called" );
8749 return responseContainer[ 0 ];
8752 // force json dataType
8753 s.dataTypes[ 0 ] = "json";
8756 overwritten = window[ callbackName ];
8757 window[ callbackName ] = function() {
8758 responseContainer = arguments;
8761 // Clean-up function (fires after converters)
8762 jqXHR.always(function() {
8763 // Restore preexisting value
8764 window[ callbackName ] = overwritten;
8766 // Save back as free
8767 if ( s[ callbackName ] ) {
8768 // make sure that re-using the options doesn't screw things around
8769 s.jsonpCallback = originalSettings.jsonpCallback;
8771 // save the callback name for future use
8772 oldCallbacks.push( callbackName );
8775 // Call if it was a function and we have a response
8776 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8777 overwritten( responseContainer[ 0 ] );
8780 responseContainer = overwritten = undefined;
8783 // Delegate to script
8791 // data: string of html
8792 // context (optional): If specified, the fragment will be created in this context, defaults to document
8793 // keepScripts (optional): If true, will include scripts passed in the html string
8794 jQuery.parseHTML = function( data, context, keepScripts ) {
8795 if ( !data || typeof data !== "string" ) {
8798 if ( typeof context === "boolean" ) {
8799 keepScripts = context;
8802 context = context || document;
8804 var parsed = rsingleTag.exec( data ),
8805 scripts = !keepScripts && [];
8809 return [ context.createElement( parsed[1] ) ];
8812 parsed = jQuery.buildFragment( [ data ], context, scripts );
8814 if ( scripts && scripts.length ) {
8815 jQuery( scripts ).remove();
8818 return jQuery.merge( [], parsed.childNodes );
8822 // Keep a copy of the old load method
8823 var _load = jQuery.fn.load;
8826 * Load a url into a page
8828 jQuery.fn.load = function( url, params, callback ) {
8829 if ( typeof url !== "string" && _load ) {
8830 return _load.apply( this, arguments );
8833 var selector, type, response,
8835 off = url.indexOf(" ");
8838 selector = jQuery.trim( url.slice( off ) );
8839 url = url.slice( 0, off );
8842 // If it's a function
8843 if ( jQuery.isFunction( params ) ) {
8845 // We assume that it's the callback
8849 // Otherwise, build a param string
8850 } else if ( params && typeof params === "object" ) {
8854 // If we have elements to modify, make the request
8855 if ( self.length > 0 ) {
8859 // if "type" variable is undefined, then "GET" method will be used
8863 }).done(function( responseText ) {
8865 // Save response for use in complete callback
8866 response = arguments;
8868 self.html( selector ?
8870 // If a selector was specified, locate the right elements in a dummy div
8871 // Exclude scripts to avoid IE 'Permission Denied' errors
8872 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
8874 // Otherwise use the full result
8877 }).complete( callback && function( jqXHR, status ) {
8878 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
8888 // Attach a bunch of functions for handling common AJAX events
8889 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
8890 jQuery.fn[ type ] = function( fn ) {
8891 return this.on( type, fn );
8898 jQuery.expr.filters.animated = function( elem ) {
8899 return jQuery.grep(jQuery.timers, function( fn ) {
8900 return elem === fn.elem;
8907 var docElem = window.document.documentElement;
8910 * Gets a window from an element
8912 function getWindow( elem ) {
8913 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
8917 setOffset: function( elem, options, i ) {
8918 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
8919 position = jQuery.css( elem, "position" ),
8920 curElem = jQuery( elem ),
8923 // Set position first, in-case top/left are set even on static elem
8924 if ( position === "static" ) {
8925 elem.style.position = "relative";
8928 curOffset = curElem.offset();
8929 curCSSTop = jQuery.css( elem, "top" );
8930 curCSSLeft = jQuery.css( elem, "left" );
8931 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
8932 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
8934 // Need to be able to calculate position if either
8935 // top or left is auto and position is either absolute or fixed
8936 if ( calculatePosition ) {
8937 curPosition = curElem.position();
8938 curTop = curPosition.top;
8939 curLeft = curPosition.left;
8942 curTop = parseFloat( curCSSTop ) || 0;
8943 curLeft = parseFloat( curCSSLeft ) || 0;
8946 if ( jQuery.isFunction( options ) ) {
8947 options = options.call( elem, i, curOffset );
8950 if ( options.top != null ) {
8951 props.top = ( options.top - curOffset.top ) + curTop;
8953 if ( options.left != null ) {
8954 props.left = ( options.left - curOffset.left ) + curLeft;
8957 if ( "using" in options ) {
8958 options.using.call( elem, props );
8961 curElem.css( props );
8967 offset: function( options ) {
8968 if ( arguments.length ) {
8969 return options === undefined ?
8971 this.each(function( i ) {
8972 jQuery.offset.setOffset( this, options, i );
8978 box = { top: 0, left: 0 },
8979 doc = elem && elem.ownerDocument;
8985 docElem = doc.documentElement;
8987 // Make sure it's not a disconnected DOM node
8988 if ( !jQuery.contains( docElem, elem ) ) {
8992 // Support: BlackBerry 5, iOS 3 (original iPhone)
8993 // If we don't have gBCR, just use 0,0 rather than error
8994 if ( typeof elem.getBoundingClientRect !== strundefined ) {
8995 box = elem.getBoundingClientRect();
8997 win = getWindow( doc );
8999 top: box.top + win.pageYOffset - docElem.clientTop,
9000 left: box.left + win.pageXOffset - docElem.clientLeft
9004 position: function() {
9009 var offsetParent, offset,
9011 parentOffset = { top: 0, left: 0 };
9013 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
9014 if ( jQuery.css( elem, "position" ) === "fixed" ) {
9015 // Assume getBoundingClientRect is there when computed position is fixed
9016 offset = elem.getBoundingClientRect();
9019 // Get *real* offsetParent
9020 offsetParent = this.offsetParent();
9022 // Get correct offsets
9023 offset = this.offset();
9024 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
9025 parentOffset = offsetParent.offset();
9028 // Add offsetParent borders
9029 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
9030 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
9033 // Subtract parent offsets and element margins
9035 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
9036 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
9040 offsetParent: function() {
9041 return this.map(function() {
9042 var offsetParent = this.offsetParent || docElem;
9044 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
9045 offsetParent = offsetParent.offsetParent;
9048 return offsetParent || docElem;
9053 // Create scrollLeft and scrollTop methods
9054 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
9055 var top = "pageYOffset" === prop;
9057 jQuery.fn[ method ] = function( val ) {
9058 return access( this, function( elem, method, val ) {
9059 var win = getWindow( elem );
9061 if ( val === undefined ) {
9062 return win ? win[ prop ] : elem[ method ];
9067 !top ? val : window.pageXOffset,
9068 top ? val : window.pageYOffset
9072 elem[ method ] = val;
9074 }, method, val, arguments.length, null );
9078 // Support: Safari<7+, Chrome<37+
9079 // Add the top/left cssHooks using jQuery.fn.position
9080 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
9081 // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280
9082 // getComputedStyle returns percent when specified for top/left/bottom/right;
9083 // rather than make the css module depend on the offset module, just check for it here
9084 jQuery.each( [ "top", "left" ], function( i, prop ) {
9085 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
9086 function( elem, computed ) {
9088 computed = curCSS( elem, prop );
9089 // If curCSS returns percentage, fallback to offset
9090 return rnumnonpx.test( computed ) ?
9091 jQuery( elem ).position()[ prop ] + "px" :
9099 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9100 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9101 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9102 // Margin is only for outerHeight, outerWidth
9103 jQuery.fn[ funcName ] = function( margin, value ) {
9104 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9105 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9107 return access( this, function( elem, type, value ) {
9110 if ( jQuery.isWindow( elem ) ) {
9111 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9112 // isn't a whole lot we can do. See pull request at this URL for discussion:
9113 // https://github.com/jquery/jquery/pull/764
9114 return elem.document.documentElement[ "client" + name ];
9117 // Get document width or height
9118 if ( elem.nodeType === 9 ) {
9119 doc = elem.documentElement;
9121 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
9122 // whichever is greatest
9124 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9125 elem.body[ "offset" + name ], doc[ "offset" + name ],
9126 doc[ "client" + name ]
9130 return value === undefined ?
9131 // Get width or height on the element, requesting but not forcing parseFloat
9132 jQuery.css( elem, type, extra ) :
9134 // Set width or height on the element
9135 jQuery.style( elem, type, value, extra );
9136 }, type, chainable ? margin : undefined, chainable, null );
9142 // The number of elements contained in the matched element set
9143 jQuery.fn.size = function() {
9147 jQuery.fn.andSelf = jQuery.fn.addBack;
9152 // Register as a named AMD module, since jQuery can be concatenated with other
9153 // files that may use define, but not via a proper concatenation script that
9154 // understands anonymous AMD modules. A named AMD is safest and most robust
9155 // way to register. Lowercase jquery is used because AMD module names are
9156 // derived from file names, and jQuery is normally delivered in a lowercase
9157 // file name. Do this after creating the global so that if an AMD module wants
9158 // to call noConflict to hide this version of jQuery, it will work.
9160 // Note that for maximum portability, libraries that are not jQuery should
9161 // declare themselves as anonymous modules, and avoid setting a global if an
9162 // AMD loader is present. jQuery is a special case. For more information, see
9163 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
9165 if ( typeof define === "function" && define.amd ) {
9166 define( "jquery", [], function() {
9175 // Map over jQuery in case of overwrite
9176 _jQuery = window.jQuery,
9178 // Map over the $ in case of overwrite
9181 jQuery.noConflict = function( deep ) {
9182 if ( window.$ === jQuery ) {
9186 if ( deep && window.jQuery === jQuery ) {
9187 window.jQuery = _jQuery;
9193 // Expose jQuery and $ identifiers, even in AMD
9194 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
9195 // and CommonJS for browser emulators (#13566)
9196 if ( typeof noGlobal === strundefined ) {
9197 window.jQuery = window.$ = jQuery;