2 * jQuery JavaScript Library v2.1.0
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2014-01-23T21:10Z
15 (function( global
, factory
) {
17 if ( typeof module
=== "object" && typeof module
.exports
=== "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper window is present,
19 // execute the factory and get jQuery
20 // For environments that do not inherently posses a window with a document
21 // (such as Node.js), expose a jQuery-making factory as module.exports
22 // This accentuates the need for the creation of a real window
23 // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info
25 module
.exports
= global
.document
?
26 factory( global
, true ) :
29 throw new Error( "jQuery requires a window with a document" );
37 // Pass this if window is not defined yet
38 }(typeof window
!== "undefined" ? window
: this, function( window
, noGlobal
) {
40 // Can't do this because several apps including ASP.NET trace
41 // the stack via arguments.caller.callee and Firefox dies if
42 // you try to trace through "use strict" call chains. (#13335)
43 // Support: Firefox 18+
48 var slice
= arr
.slice
;
50 var concat
= arr
.concat
;
54 var indexOf
= arr
.indexOf
;
58 var toString
= class2type
.toString
;
60 var hasOwn
= class2type
.hasOwnProperty
;
69 // Use the correct document accordingly with window argument (sandbox)
70 document
= window
.document
,
74 // Define a local copy of jQuery
75 jQuery = function( selector
, context
) {
76 // The jQuery object is actually just the init constructor 'enhanced'
77 // Need init if jQuery is called (just allow error to be thrown if not included)
78 return new jQuery
.fn
.init( selector
, context
);
81 // Matches dashed string for camelizing
83 rdashAlpha
= /-([\da-z])/gi,
85 // Used by jQuery.camelCase as callback to replace()
86 fcamelCase = function( all
, letter
) {
87 return letter
.toUpperCase();
90 jQuery
.fn
= jQuery
.prototype = {
91 // The current version of jQuery being used
96 // Start with an empty selector
99 // The default length of a jQuery object is 0
102 toArray: function() {
103 return slice
.call( this );
106 // Get the Nth element in the matched element set OR
107 // Get the whole matched element set as a clean array
108 get: function( num
) {
111 // Return a 'clean' array
112 ( num
< 0 ? this[ num
+ this.length
] : this[ num
] ) :
114 // Return just the object
118 // Take an array of elements and push it onto the stack
119 // (returning the new matched element set)
120 pushStack: function( elems
) {
122 // Build a new jQuery matched element set
123 var ret
= jQuery
.merge( this.constructor(), elems
);
125 // Add the old object onto the stack (as a reference)
126 ret
.prevObject
= this;
127 ret
.context
= this.context
;
129 // Return the newly-formed element set
133 // Execute a callback for every element in the matched set.
134 // (You can seed the arguments with an array of args, but this is
135 // only used internally.)
136 each: function( callback
, args
) {
137 return jQuery
.each( this, callback
, args
);
140 map: function( callback
) {
141 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
142 return callback
.call( elem
, i
, elem
);
147 return this.pushStack( slice
.apply( this, arguments
) );
155 return this.eq( -1 );
159 var len
= this.length
,
160 j
= +i
+ ( i
< 0 ? len
: 0 );
161 return this.pushStack( j
>= 0 && j
< len
? [ this[j
] ] : [] );
165 return this.prevObject
|| this.constructor(null);
168 // For internal use only.
169 // Behaves like an Array's method, not like a jQuery method.
175 jQuery
.extend
= jQuery
.fn
.extend = function() {
176 var options
, name
, src
, copy
, copyIsArray
, clone
,
177 target
= arguments
[0] || {},
179 length
= arguments
.length
,
182 // Handle a deep copy situation
183 if ( typeof target
=== "boolean" ) {
186 // skip the boolean and the target
187 target
= arguments
[ i
] || {};
191 // Handle case when target is a string or something (possible in deep copy)
192 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
196 // extend jQuery itself if only one argument is passed
197 if ( i
=== length
) {
202 for ( ; i
< length
; i
++ ) {
203 // Only deal with non-null/undefined values
204 if ( (options
= arguments
[ i
]) != null ) {
205 // Extend the base object
206 for ( name
in options
) {
207 src
= target
[ name
];
208 copy
= options
[ name
];
210 // Prevent never-ending loop
211 if ( target
=== copy
) {
215 // Recurse if we're merging plain objects or arrays
216 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || (copyIsArray
= jQuery
.isArray(copy
)) ) ) {
219 clone
= src
&& jQuery
.isArray(src
) ? src
: [];
222 clone
= src
&& jQuery
.isPlainObject(src
) ? src
: {};
225 // Never move original objects, clone them
226 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
228 // Don't bring in undefined values
229 } else if ( copy
!== undefined ) {
230 target
[ name
] = copy
;
236 // Return the modified object
241 // Unique for each copy of jQuery on the page
242 expando
: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
244 // Assume jQuery is ready without the ready module
247 error: function( msg
) {
248 throw new Error( msg
);
253 // See test/unit/core.js for details concerning isFunction.
254 // Since version 1.3, DOM methods and functions like alert
255 // aren't supported. They return false on IE (#2968).
256 isFunction: function( obj
) {
257 return jQuery
.type(obj
) === "function";
260 isArray
: Array
.isArray
,
262 isWindow: function( obj
) {
263 return obj
!= null && obj
=== obj
.window
;
266 isNumeric: function( obj
) {
267 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
268 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
269 // subtraction forces infinities to NaN
270 return obj
- parseFloat( obj
) >= 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 // Support: Firefox <20
283 // The try/catch suppresses exceptions thrown when attempting to access
284 // the "constructor" property of certain host objects, ie. |window.location|
285 // https://bugzilla.mozilla.org/show_bug.cgi?id=814622
287 if ( obj
.constructor &&
288 !hasOwn
.call( obj
.constructor.prototype, "isPrototypeOf" ) ) {
295 // If the function hasn't returned already, we're confident that
296 // |obj| is a plain object, created by {} or constructed with new Object
300 isEmptyObject: function( obj
) {
302 for ( name
in obj
) {
308 type: function( obj
) {
312 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
313 return typeof obj
=== "object" || typeof obj
=== "function" ?
314 class2type
[ toString
.call(obj
) ] || "object" :
318 // Evaluates a script in a global context
319 globalEval: function( code
) {
323 code
= jQuery
.trim( code
);
326 // If the code includes a valid, prologue position
327 // strict mode pragma, execute code by injecting a
328 // script tag into the document.
329 if ( code
.indexOf("use strict") === 1 ) {
330 script
= document
.createElement("script");
332 document
.head
.appendChild( script
).parentNode
.removeChild( script
);
334 // Otherwise, avoid the DOM node creation, insertion
335 // and removal by using an indirect global eval
341 // Convert dashed to camelCase; used by the css and data modules
342 // Microsoft forgot to hump their vendor prefix (#9572)
343 camelCase: function( string
) {
344 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
347 nodeName: function( elem
, name
) {
348 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
351 // args is for internal usage only
352 each: function( obj
, callback
, args
) {
356 isArray
= isArraylike( obj
);
360 for ( ; i
< length
; i
++ ) {
361 value
= callback
.apply( obj
[ i
], args
);
363 if ( value
=== false ) {
369 value
= callback
.apply( obj
[ i
], args
);
371 if ( value
=== false ) {
377 // A special, fast, case for the most common use of each
380 for ( ; i
< length
; i
++ ) {
381 value
= callback
.call( obj
[ i
], i
, obj
[ i
] );
383 if ( value
=== false ) {
389 value
= callback
.call( obj
[ i
], i
, obj
[ i
] );
391 if ( value
=== false ) {
401 trim: function( text
) {
402 return text
== null ? "" : trim
.call( text
);
405 // results is for internal usage only
406 makeArray: function( arr
, results
) {
407 var ret
= results
|| [];
410 if ( isArraylike( Object(arr
) ) ) {
412 typeof arr
=== "string" ?
416 push
.call( ret
, arr
);
423 inArray: function( elem
, arr
, i
) {
424 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
427 merge: function( first
, second
) {
428 var len
= +second
.length
,
432 for ( ; j
< len
; j
++ ) {
433 first
[ i
++ ] = second
[ j
];
441 grep: function( elems
, callback
, invert
) {
445 length
= elems
.length
,
446 callbackExpect
= !invert
;
448 // Go through the array, only saving the items
449 // that pass the validator function
450 for ( ; i
< length
; i
++ ) {
451 callbackInverse
= !callback( elems
[ i
], i
);
452 if ( callbackInverse
!== callbackExpect
) {
453 matches
.push( elems
[ i
] );
460 // arg is for internal usage only
461 map: function( elems
, callback
, arg
) {
464 length
= elems
.length
,
465 isArray
= isArraylike( elems
),
468 // Go through the array, translating each of the items to their new values
470 for ( ; i
< length
; i
++ ) {
471 value
= callback( elems
[ i
], i
, arg
);
473 if ( value
!= null ) {
478 // Go through every key on the object,
481 value
= callback( elems
[ i
], i
, arg
);
483 if ( value
!= null ) {
489 // Flatten any nested arrays
490 return concat
.apply( [], ret
);
493 // A global GUID counter for objects
496 // Bind a function to a context, optionally partially applying any
498 proxy: function( fn
, context
) {
499 var tmp
, args
, proxy
;
501 if ( typeof context
=== "string" ) {
507 // Quick check to determine if target is callable, in the spec
508 // this throws a TypeError, but we will just return undefined.
509 if ( !jQuery
.isFunction( fn
) ) {
514 args
= slice
.call( arguments
, 2 );
516 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
519 // Set the guid of unique handler to the same of original handler, so it can be removed
520 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
527 // jQuery.support is not used in Core but other projects attach their
528 // properties to it so it needs to exist.
532 // Populate the class2type map
533 jQuery
.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i
, name
) {
534 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
537 function isArraylike( obj
) {
538 var length
= obj
.length
,
539 type
= jQuery
.type( obj
);
541 if ( type
=== "function" || jQuery
.isWindow( obj
) ) {
545 if ( obj
.nodeType
=== 1 && length
) {
549 return type
=== "array" || length
=== 0 ||
550 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
554 * Sizzle CSS Selector Engine v1.10.16
555 * http://sizzlejs.com/
557 * Copyright 2013 jQuery Foundation, Inc. and other contributors
558 * Released under the MIT license
559 * http://jquery.org/license
563 (function( window
) {
575 // Local document vars
585 // Instance-specific data
586 expando
= "sizzle" + -(new Date()),
587 preferredDoc
= window
.document
,
590 classCache
= createCache(),
591 tokenCache
= createCache(),
592 compilerCache
= createCache(),
593 sortOrder = function( a
, b
) {
600 // General-purpose constants
601 strundefined
= typeof undefined,
602 MAX_NEGATIVE
= 1 << 31,
605 hasOwn
= ({}).hasOwnProperty
,
608 push_native
= arr
.push
,
611 // Use a stripped-down indexOf if we can't use a native one
612 indexOf
= arr
.indexOf
|| function( elem
) {
615 for ( ; i
< len
; i
++ ) {
616 if ( this[i
] === elem
) {
623 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
625 // Regular expressions
627 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
628 whitespace
= "[\\x20\\t\\r\\n\\f]",
629 // http://www.w3.org/TR/css3-syntax/#characters
630 characterEncoding
= "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
632 // Loosely modeled on CSS identifier characters
633 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
634 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
635 identifier
= characterEncoding
.replace( "w", "w#" ),
637 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
638 attributes
= "\\[" + whitespace
+ "*(" + characterEncoding
+ ")" + whitespace
+
639 "*(?:([*^$|!~]?=)" + whitespace
+ "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier
+ ")|)|)" + whitespace
+ "*\\]",
641 // Prefer arguments quoted,
642 // then not containing pseudos/brackets,
643 // then attribute selectors/non-parenthetical expressions,
644 // then anything else
645 // These preferences are here to reduce the number of selectors
646 // needing tokenize in the PSEUDO preFilter
647 pseudos
= ":(" + characterEncoding
+ ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes
.replace( 3, 8 ) + ")*)|.*)\\)|)",
649 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
650 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
652 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
653 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
655 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*?)" + whitespace
+ "*\\]", "g" ),
657 rpseudo
= new RegExp( pseudos
),
658 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
661 "ID": new RegExp( "^#(" + characterEncoding
+ ")" ),
662 "CLASS": new RegExp( "^\\.(" + characterEncoding
+ ")" ),
663 "TAG": new RegExp( "^(" + characterEncoding
.replace( "w", "w*" ) + ")" ),
664 "ATTR": new RegExp( "^" + attributes
),
665 "PSEUDO": new RegExp( "^" + pseudos
),
666 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
667 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
668 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
669 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
670 // For use in libraries implementing .is()
671 // We use this for POS matching in `select`
672 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
673 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
676 rinputs
= /^(?:input|select|textarea|button)$/i,
679 rnative
= /^[^{]+\{\s*\[native \w/,
681 // Easily-parseable/retrievable ID or TAG or CLASS selectors
682 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
687 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
688 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
689 funescape = function( _, escaped, escapedWhitespace ) {
690 var high = "0x" + escaped - 0x10000;
691 // NaN means non-codepoint
693 // Workaround erroneous numeric interpretation of +"0x"
694 return high !== high || escapedWhitespace ?
698 String.fromCharCode( high + 0x10000 ) :
699 // Supplemental Plane codepoint (surrogate pair)
700 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
703 // Optimize for push.apply( _, NodeList )
706 (arr = slice.call( preferredDoc.childNodes )),
707 preferredDoc.childNodes
709 // Support: Android<4.0
710 // Detect silently failing push.apply
711 arr[ preferredDoc.childNodes.length ].nodeType;
713 push = { apply: arr.length ?
715 // Leverage slice if possible
716 function( target, els ) {
717 push_native.apply( target, slice.call(els) );
721 // Otherwise append directly
722 function( target, els ) {
723 var j = target.length,
725 // Can't trust NodeList
.length
726 while ( (target
[j
++] = els
[i
++]) ) {}
727 target
.length
= j
- 1;
732 function Sizzle( selector
, context
, results
, seed
) {
733 var match
, elem
, m
, nodeType
,
735 i
, groups
, old
, nid
, newContext
, newSelector
;
737 if ( ( context
? context
.ownerDocument
|| context
: preferredDoc
) !== document
) {
738 setDocument( context
);
741 context
= context
|| document
;
742 results
= results
|| [];
744 if ( !selector
|| typeof selector
!== "string" ) {
748 if ( (nodeType
= context
.nodeType
) !== 1 && nodeType
!== 9 ) {
752 if ( documentIsHTML
&& !seed
) {
755 if ( (match
= rquickExpr
.exec( selector
)) ) {
756 // Speed-up: Sizzle("#ID")
757 if ( (m
= match
[1]) ) {
758 if ( nodeType
=== 9 ) {
759 elem
= context
.getElementById( m
);
760 // Check parentNode to catch when Blackberry 4.6 returns
761 // nodes that are no longer in the document (jQuery #6963)
762 if ( elem
&& elem
.parentNode
) {
763 // Handle the case where IE, Opera, and Webkit return items
764 // by name instead of ID
765 if ( elem
.id
=== m
) {
766 results
.push( elem
);
773 // Context is not a document
774 if ( context
.ownerDocument
&& (elem
= context
.ownerDocument
.getElementById( m
)) &&
775 contains( context
, elem
) && elem
.id
=== m
) {
776 results
.push( elem
);
781 // Speed-up: Sizzle("TAG")
782 } else if ( match
[2] ) {
783 push
.apply( results
, context
.getElementsByTagName( selector
) );
786 // Speed-up: Sizzle(".CLASS")
787 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&& context
.getElementsByClassName
) {
788 push
.apply( results
, context
.getElementsByClassName( m
) );
794 if ( support
.qsa
&& (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
796 newContext
= context
;
797 newSelector
= nodeType
=== 9 && selector
;
799 // qSA works strangely on Element-rooted queries
800 // We can work around this by specifying an extra ID on the root
801 // and working up from there (Thanks to Andrew Dupont for the technique)
802 // IE 8 doesn't work on object elements
803 if ( nodeType
=== 1 && context
.nodeName
.toLowerCase() !== "object" ) {
804 groups
= tokenize( selector
);
806 if ( (old
= context
.getAttribute("id")) ) {
807 nid
= old
.replace( rescape
, "\\$&" );
809 context
.setAttribute( "id", nid
);
811 nid
= "[id='" + nid
+ "'] ";
815 groups
[i
] = nid
+ toSelector( groups
[i
] );
817 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) || context
;
818 newSelector
= groups
.join(",");
824 newContext
.querySelectorAll( newSelector
)
830 context
.removeAttribute("id");
838 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
842 * Create key-value caches of limited size
843 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
844 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
845 * deleting the oldest entry
847 function createCache() {
850 function cache( key
, value
) {
851 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
852 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
853 // Only keep the most recent entries
854 delete cache
[ keys
.shift() ];
856 return (cache
[ key
+ " " ] = value
);
862 * Mark a function for special use by Sizzle
863 * @param {Function} fn The function to mark
865 function markFunction( fn
) {
866 fn
[ expando
] = true;
871 * Support testing using an element
872 * @param {Function} fn Passed the created div and expects a boolean result
874 function assert( fn
) {
875 var div
= document
.createElement("div");
882 // Remove from its parent by default
883 if ( div
.parentNode
) {
884 div
.parentNode
.removeChild( div
);
886 // release memory in IE
892 * Adds the same handler for all of the specified attrs
893 * @param {String} attrs Pipe-separated list of attributes
894 * @param {Function} handler The method that will be applied
896 function addHandle( attrs
, handler
) {
897 var arr
= attrs
.split("|"),
901 Expr
.attrHandle
[ arr
[i
] ] = handler
;
906 * Checks document order of two siblings
909 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
911 function siblingCheck( a
, b
) {
913 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
914 ( ~b
.sourceIndex
|| MAX_NEGATIVE
) -
915 ( ~a
.sourceIndex
|| MAX_NEGATIVE
);
917 // Use IE sourceIndex if available on both nodes
922 // Check if b follows a
924 while ( (cur
= cur
.nextSibling
) ) {
935 * Returns a function to use in pseudos for input types
936 * @param {String} type
938 function createInputPseudo( type
) {
939 return function( elem
) {
940 var name
= elem
.nodeName
.toLowerCase();
941 return name
=== "input" && elem
.type
=== type
;
946 * Returns a function to use in pseudos for buttons
947 * @param {String} type
949 function createButtonPseudo( type
) {
950 return function( elem
) {
951 var name
= elem
.nodeName
.toLowerCase();
952 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
957 * Returns a function to use in pseudos for positionals
958 * @param {Function} fn
960 function createPositionalPseudo( fn
) {
961 return markFunction(function( argument
) {
962 argument
= +argument
;
963 return markFunction(function( seed
, matches
) {
965 matchIndexes
= fn( [], seed
.length
, argument
),
966 i
= matchIndexes
.length
;
968 // Match elements found at the specified indexes
970 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
971 seed
[j
] = !(matches
[j
] = seed
[j
]);
979 * Checks a node for validity as a Sizzle context
980 * @param {Element|Object=} context
981 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
983 function testContext( context
) {
984 return context
&& typeof context
.getElementsByTagName
!== strundefined
&& context
;
987 // Expose support vars for convenience
988 support
= Sizzle
.support
= {};
992 * @param {Element|Object} elem An element or a document
993 * @returns {Boolean} True iff elem is a non-HTML XML node
995 isXML
= Sizzle
.isXML = function( elem
) {
996 // documentElement is verified for cases where it doesn't yet exist
997 // (such as loading iframes in IE - #4833)
998 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
999 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1003 * Sets document-related variables once based on the current document
1004 * @param {Element|Object} [doc] An element or document object to use to set the document
1005 * @returns {Object} Returns the current document
1007 setDocument
= Sizzle
.setDocument = function( node
) {
1009 doc
= node
? node
.ownerDocument
|| node
: preferredDoc
,
1010 parent
= doc
.defaultView
;
1012 // If no document and documentElement is available, return
1013 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1019 docElem
= doc
.documentElement
;
1022 documentIsHTML
= !isXML( doc
);
1025 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1026 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1027 // IE6-8 do not support the defaultView property so parent will be undefined
1028 if ( parent
&& parent
!== parent
.top
) {
1029 // IE11 does not have attachEvent, so all must suffer
1030 if ( parent
.addEventListener
) {
1031 parent
.addEventListener( "unload", function() {
1034 } else if ( parent
.attachEvent
) {
1035 parent
.attachEvent( "onunload", function() {
1042 ---------------------------------------------------------------------- */
1045 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1046 support
.attributes
= assert(function( div
) {
1047 div
.className
= "i";
1048 return !div
.getAttribute("className");
1052 ---------------------------------------------------------------------- */
1054 // Check if getElementsByTagName("*") returns only elements
1055 support
.getElementsByTagName
= assert(function( div
) {
1056 div
.appendChild( doc
.createComment("") );
1057 return !div
.getElementsByTagName("*").length
;
1060 // Check if getElementsByClassName can be trusted
1061 support
.getElementsByClassName
= rnative
.test( doc
.getElementsByClassName
) && assert(function( div
) {
1062 div
.innerHTML
= "<div class='a'></div><div class='a i'></div>";
1064 // Support: Safari<4
1065 // Catch class over-caching
1066 div
.firstChild
.className
= "i";
1067 // Support: Opera<10
1068 // Catch gEBCN failure to find non-leading classes
1069 return div
.getElementsByClassName("i").length
=== 2;
1073 // Check if getElementById returns elements by name
1074 // The broken getElementById methods don't pick up programatically-set names,
1075 // so use a roundabout getElementsByName test
1076 support
.getById
= assert(function( div
) {
1077 docElem
.appendChild( div
).id
= expando
;
1078 return !doc
.getElementsByName
|| !doc
.getElementsByName( expando
).length
;
1081 // ID find and filter
1082 if ( support
.getById
) {
1083 Expr
.find
["ID"] = function( id
, context
) {
1084 if ( typeof context
.getElementById
!== strundefined
&& documentIsHTML
) {
1085 var m
= context
.getElementById( id
);
1086 // Check parentNode to catch when Blackberry 4.6 returns
1087 // nodes that are no longer in the document #6963
1088 return m
&& m
.parentNode
? [m
] : [];
1091 Expr
.filter
["ID"] = function( id
) {
1092 var attrId
= id
.replace( runescape
, funescape
);
1093 return function( elem
) {
1094 return elem
.getAttribute("id") === attrId
;
1099 // getElementById is not reliable as a find shortcut
1100 delete Expr
.find
["ID"];
1102 Expr
.filter
["ID"] = function( id
) {
1103 var attrId
= id
.replace( runescape
, funescape
);
1104 return function( elem
) {
1105 var node
= typeof elem
.getAttributeNode
!== strundefined
&& elem
.getAttributeNode("id");
1106 return node
&& node
.value
=== attrId
;
1112 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1113 function( tag
, context
) {
1114 if ( typeof context
.getElementsByTagName
!== strundefined
) {
1115 return context
.getElementsByTagName( tag
);
1118 function( tag
, context
) {
1122 results
= context
.getElementsByTagName( tag
);
1124 // Filter out possible comments
1125 if ( tag
=== "*" ) {
1126 while ( (elem
= results
[i
++]) ) {
1127 if ( elem
.nodeType
=== 1 ) {
1138 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1139 if ( typeof context
.getElementsByClassName
!== strundefined
&& documentIsHTML
) {
1140 return context
.getElementsByClassName( className
);
1144 /* QSA/matchesSelector
1145 ---------------------------------------------------------------------- */
1147 // QSA and matchesSelector support
1149 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1152 // qSa(:focus) reports false when true (Chrome 21)
1153 // We allow this because of a bug in IE8/9 that throws an error
1154 // whenever `document.activeElement` is accessed on an iframe
1155 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1156 // See http://bugs.jquery.com/ticket/13378
1159 if ( (support
.qsa
= rnative
.test( doc
.querySelectorAll
)) ) {
1161 // Regex strategy adopted from Diego Perini
1162 assert(function( div
) {
1163 // Select is set to empty string on purpose
1164 // This is to test IE's treatment of not explicitly
1165 // setting a boolean content attribute,
1166 // since its presence should be enough
1167 // http://bugs.jquery.com/ticket/12359
1168 div
.innerHTML
= "<select t=''><option selected=''></option></select>";
1170 // Support: IE8, Opera 10-12
1171 // Nothing should be selected when empty strings follow ^= or $= or *=
1172 if ( div
.querySelectorAll("[t^='']").length
) {
1173 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1177 // Boolean attributes and "value" are not treated correctly
1178 if ( !div
.querySelectorAll("[selected]").length
) {
1179 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1182 // Webkit/Opera - :checked should return selected option elements
1183 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1184 // IE8 throws error here and will not see later tests
1185 if ( !div
.querySelectorAll(":checked").length
) {
1186 rbuggyQSA
.push(":checked");
1190 assert(function( div
) {
1191 // Support: Windows 8 Native Apps
1192 // The type and name attributes are restricted during .innerHTML assignment
1193 var input
= doc
.createElement("input");
1194 input
.setAttribute( "type", "hidden" );
1195 div
.appendChild( input
).setAttribute( "name", "D" );
1198 // Enforce case-sensitivity of name attribute
1199 if ( div
.querySelectorAll("[name=d]").length
) {
1200 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1203 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1204 // IE8 throws error here and will not see later tests
1205 if ( !div
.querySelectorAll(":enabled").length
) {
1206 rbuggyQSA
.push( ":enabled", ":disabled" );
1209 // Opera 10-11 does not throw on post-comma invalid pseudos
1210 div
.querySelectorAll("*,:x");
1211 rbuggyQSA
.push(",.*:");
1215 if ( (support
.matchesSelector
= rnative
.test( (matches
= docElem
.webkitMatchesSelector
||
1216 docElem
.mozMatchesSelector
||
1217 docElem
.oMatchesSelector
||
1218 docElem
.msMatchesSelector
) )) ) {
1220 assert(function( div
) {
1221 // Check to see if it's possible to do matchesSelector
1222 // on a disconnected node (IE 9)
1223 support
.disconnectedMatch
= matches
.call( div
, "div" );
1225 // This should fail with an exception
1226 // Gecko does not error, returns false instead
1227 matches
.call( div
, "[s!='']:x" );
1228 rbuggyMatches
.push( "!=", pseudos
);
1232 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1233 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1236 ---------------------------------------------------------------------- */
1237 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1239 // Element contains another
1240 // Purposefully does not implement inclusive descendent
1241 // As in, an element does not contain itself
1242 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1244 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
1245 bup
= b
&& b
.parentNode
;
1246 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1248 adown
.contains( bup
) :
1249 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1254 while ( (b
= b
.parentNode
) ) {
1264 ---------------------------------------------------------------------- */
1266 // Document order sorting
1267 sortOrder
= hasCompare
?
1270 // Flag for duplicate removal
1272 hasDuplicate
= true;
1276 // Sort on method existence if only one input has compareDocumentPosition
1277 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1282 // Calculate position if both inputs belong to the same document
1283 compare
= ( a
.ownerDocument
|| a
) === ( b
.ownerDocument
|| b
) ?
1284 a
.compareDocumentPosition( b
) :
1286 // Otherwise we know they are disconnected
1289 // Disconnected nodes
1291 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1293 // Choose the first element that is related to our preferred document
1294 if ( a
=== doc
|| a
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, a
) ) {
1297 if ( b
=== doc
|| b
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, b
) ) {
1301 // Maintain original order
1303 ( indexOf
.call( sortInput
, a
) - indexOf
.call( sortInput
, b
) ) :
1307 return compare
& 4 ? -1 : 1;
1310 // Exit early if the nodes are identical
1312 hasDuplicate
= true;
1323 // Parentless nodes are either documents or disconnected
1324 if ( !aup
|| !bup
) {
1325 return a
=== doc
? -1 :
1330 ( indexOf
.call( sortInput
, a
) - indexOf
.call( sortInput
, b
) ) :
1333 // If the nodes are siblings, we can do a quick check
1334 } else if ( aup
=== bup
) {
1335 return siblingCheck( a
, b
);
1338 // Otherwise we need full lists of their ancestors for comparison
1340 while ( (cur
= cur
.parentNode
) ) {
1344 while ( (cur
= cur
.parentNode
) ) {
1348 // Walk down the tree looking for a discrepancy
1349 while ( ap
[i
] === bp
[i
] ) {
1354 // Do a sibling check if the nodes have a common ancestor
1355 siblingCheck( ap
[i
], bp
[i
] ) :
1357 // Otherwise nodes in our document sort first
1358 ap
[i
] === preferredDoc
? -1 :
1359 bp
[i
] === preferredDoc
? 1 :
1366 Sizzle
.matches = function( expr
, elements
) {
1367 return Sizzle( expr
, null, null, elements
);
1370 Sizzle
.matchesSelector = function( elem
, expr
) {
1371 // Set document vars if needed
1372 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1373 setDocument( elem
);
1376 // Make sure that attribute selectors are quoted
1377 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1379 if ( support
.matchesSelector
&& documentIsHTML
&&
1380 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1381 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1384 var ret
= matches
.call( elem
, expr
);
1386 // IE 9's matchesSelector returns false on disconnected nodes
1387 if ( ret
|| support
.disconnectedMatch
||
1388 // As well, disconnected nodes are said to be in a document
1390 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1396 return Sizzle( expr
, document
, null, [elem
] ).length
> 0;
1399 Sizzle
.contains = function( context
, elem
) {
1400 // Set document vars if needed
1401 if ( ( context
.ownerDocument
|| context
) !== document
) {
1402 setDocument( context
);
1404 return contains( context
, elem
);
1407 Sizzle
.attr = function( elem
, name
) {
1408 // Set document vars if needed
1409 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1410 setDocument( elem
);
1413 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1414 // Don't get fooled by Object.prototype properties (jQuery #13807)
1415 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1416 fn( elem
, name
, !documentIsHTML
) :
1419 return val
!== undefined ?
1421 support
.attributes
|| !documentIsHTML
?
1422 elem
.getAttribute( name
) :
1423 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1428 Sizzle
.error = function( msg
) {
1429 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1433 * Document sorting and removing duplicates
1434 * @param {ArrayLike} results
1436 Sizzle
.uniqueSort = function( results
) {
1442 // Unless we *know* we can detect duplicates, assume their presence
1443 hasDuplicate
= !support
.detectDuplicates
;
1444 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1445 results
.sort( sortOrder
);
1447 if ( hasDuplicate
) {
1448 while ( (elem
= results
[i
++]) ) {
1449 if ( elem
=== results
[ i
] ) {
1450 j
= duplicates
.push( i
);
1454 results
.splice( duplicates
[ j
], 1 );
1458 // Clear input after sorting to release objects
1459 // See https://github.com/jquery/sizzle/pull/225
1466 * Utility function for retrieving the text value of an array of DOM nodes
1467 * @param {Array|Element} elem
1469 getText
= Sizzle
.getText = function( elem
) {
1473 nodeType
= elem
.nodeType
;
1476 // If no nodeType, this is expected to be an array
1477 while ( (node
= elem
[i
++]) ) {
1478 // Do not traverse comment nodes
1479 ret
+= getText( node
);
1481 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1482 // Use textContent for elements
1483 // innerText usage removed for consistency of new lines (jQuery #11153)
1484 if ( typeof elem
.textContent
=== "string" ) {
1485 return elem
.textContent
;
1487 // Traverse its children
1488 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1489 ret
+= getText( elem
);
1492 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1493 return elem
.nodeValue
;
1495 // Do not include comment or processing instruction nodes
1500 Expr
= Sizzle
.selectors
= {
1502 // Can be adjusted by the user
1505 createPseudo
: markFunction
,
1514 ">": { dir
: "parentNode", first
: true },
1515 " ": { dir
: "parentNode" },
1516 "+": { dir
: "previousSibling", first
: true },
1517 "~": { dir
: "previousSibling" }
1521 "ATTR": function( match
) {
1522 match
[1] = match
[1].replace( runescape
, funescape
);
1524 // Move the given value to match[3] whether quoted or unquoted
1525 match
[3] = ( match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1527 if ( match
[2] === "~=" ) {
1528 match
[3] = " " + match
[3] + " ";
1531 return match
.slice( 0, 4 );
1534 "CHILD": function( match
) {
1535 /* matches from matchExpr["CHILD"]
1536 1 type (only|nth|...)
1537 2 what (child|of-type)
1538 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1539 4 xn-component of xn+y argument ([+-]?\d*n|)
1540 5 sign of xn-component
1542 7 sign of y-component
1545 match
[1] = match
[1].toLowerCase();
1547 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1548 // nth-* requires argument
1550 Sizzle
.error( match
[0] );
1553 // numeric x and y parameters for Expr.filter.CHILD
1554 // remember that false/true cast respectively to 0/1
1555 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1556 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1558 // other types prohibit arguments
1559 } else if ( match
[3] ) {
1560 Sizzle
.error( match
[0] );
1566 "PSEUDO": function( match
) {
1568 unquoted
= !match
[5] && match
[2];
1570 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1574 // Accept quoted arguments as-is
1575 if ( match
[3] && match
[4] !== undefined ) {
1576 match
[2] = match
[4];
1578 // Strip excess characters from unquoted arguments
1579 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1580 // Get excess from tokenize (recursively)
1581 (excess
= tokenize( unquoted
, true )) &&
1582 // advance to the next closing parenthesis
1583 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1585 // excess is a negative index
1586 match
[0] = match
[0].slice( 0, excess
);
1587 match
[2] = unquoted
.slice( 0, excess
);
1590 // Return only captures needed by the pseudo filter method (type and argument)
1591 return match
.slice( 0, 3 );
1597 "TAG": function( nodeNameSelector
) {
1598 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1599 return nodeNameSelector
=== "*" ?
1600 function() { return true; } :
1602 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1606 "CLASS": function( className
) {
1607 var pattern
= classCache
[ className
+ " " ];
1610 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1611 classCache( className
, function( elem
) {
1612 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== strundefined
&& elem
.getAttribute("class") || "" );
1616 "ATTR": function( name
, operator
, check
) {
1617 return function( elem
) {
1618 var result
= Sizzle
.attr( elem
, name
);
1620 if ( result
== null ) {
1621 return operator
=== "!=";
1629 return operator
=== "=" ? result
=== check
:
1630 operator
=== "!=" ? result
!== check
:
1631 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1632 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1633 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check
:
1634 operator
=== "~=" ? ( " " + result
+ " " ).indexOf( check
) > -1 :
1635 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1640 "CHILD": function( type
, what
, argument
, first
, last
) {
1641 var simple
= type
.slice( 0, 3 ) !== "nth",
1642 forward
= type
.slice( -4 ) !== "last",
1643 ofType
= what
=== "of-type";
1645 return first
=== 1 && last
=== 0 ?
1647 // Shortcut for :nth-*(n)
1649 return !!elem
.parentNode
;
1652 function( elem
, context
, xml
) {
1653 var cache
, outerCache
, node
, diff
, nodeIndex
, start
,
1654 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1655 parent
= elem
.parentNode
,
1656 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1657 useCache
= !xml
&& !ofType
;
1661 // :(first|last|only)-(child|of-type)
1665 while ( (node
= node
[ dir
]) ) {
1666 if ( ofType
? node
.nodeName
.toLowerCase() === name
: node
.nodeType
=== 1 ) {
1670 // Reverse direction for :only-* (if we haven't yet done so)
1671 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1676 start
= [ forward
? parent
.firstChild
: parent
.lastChild
];
1678 // non-xml :nth-child(...) stores cache data on `parent`
1679 if ( forward
&& useCache
) {
1680 // Seek `elem` from a previously-cached index
1681 outerCache
= parent
[ expando
] || (parent
[ expando
] = {});
1682 cache
= outerCache
[ type
] || [];
1683 nodeIndex
= cache
[0] === dirruns
&& cache
[1];
1684 diff
= cache
[0] === dirruns
&& cache
[2];
1685 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1687 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1689 // Fallback to seeking `elem` from the start
1690 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1692 // When found, cache indexes on `parent` and break
1693 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1694 outerCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1699 // Use previously-cached element index if available
1700 } else if ( useCache
&& (cache
= (elem
[ expando
] || (elem
[ expando
] = {}))[ type
]) && cache
[0] === dirruns
) {
1703 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1705 // Use the same loop as above to seek `elem` from the start
1706 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1707 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1709 if ( ( ofType
? node
.nodeName
.toLowerCase() === name
: node
.nodeType
=== 1 ) && ++diff
) {
1710 // Cache the index of each encountered element
1712 (node
[ expando
] || (node
[ expando
] = {}))[ type
] = [ dirruns
, diff
];
1715 if ( node
=== elem
) {
1722 // Incorporate the offset, then check against cycle size
1724 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
1729 "PSEUDO": function( pseudo
, argument
) {
1730 // pseudo-class names are case-insensitive
1731 // http://www.w3.org/TR/selectors/#pseudo-classes
1732 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1733 // Remember that setFilters inherits from pseudos
1735 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
1736 Sizzle
.error( "unsupported pseudo: " + pseudo
);
1738 // The user may use createPseudo to indicate that
1739 // arguments are needed to create the filter function
1740 // just as Sizzle does
1741 if ( fn
[ expando
] ) {
1742 return fn( argument
);
1745 // But maintain support for old signatures
1746 if ( fn
.length
> 1 ) {
1747 args
= [ pseudo
, pseudo
, "", argument
];
1748 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
1749 markFunction(function( seed
, matches
) {
1751 matched
= fn( seed
, argument
),
1754 idx
= indexOf
.call( seed
, matched
[i
] );
1755 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
1759 return fn( elem
, 0, args
);
1768 // Potentially complex pseudos
1769 "not": markFunction(function( selector
) {
1770 // Trim the selector passed to compile
1771 // to avoid treating leading and trailing
1772 // spaces as combinators
1775 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
1777 return matcher
[ expando
] ?
1778 markFunction(function( seed
, matches
, context
, xml
) {
1780 unmatched
= matcher( seed
, null, xml
, [] ),
1783 // Match elements unmatched by `matcher`
1785 if ( (elem
= unmatched
[i
]) ) {
1786 seed
[i
] = !(matches
[i
] = elem
);
1790 function( elem
, context
, xml
) {
1792 matcher( input
, null, xml
, results
);
1793 return !results
.pop();
1797 "has": markFunction(function( selector
) {
1798 return function( elem
) {
1799 return Sizzle( selector
, elem
).length
> 0;
1803 "contains": markFunction(function( text
) {
1804 return function( elem
) {
1805 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
1809 // "Whether an element is represented by a :lang() selector
1810 // is based solely on the element's language value
1811 // being equal to the identifier C,
1812 // or beginning with the identifier C immediately followed by "-".
1813 // The matching of C against the element's language value is performed case-insensitively.
1814 // The identifier C does not have to be a valid language name."
1815 // http://www.w3.org/TR/selectors/#lang-pseudo
1816 "lang": markFunction( function( lang
) {
1817 // lang value must be a valid identifier
1818 if ( !ridentifier
.test(lang
|| "") ) {
1819 Sizzle
.error( "unsupported lang: " + lang
);
1821 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
1822 return function( elem
) {
1825 if ( (elemLang
= documentIsHTML
?
1827 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
1829 elemLang
= elemLang
.toLowerCase();
1830 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
1832 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
1838 "target": function( elem
) {
1839 var hash
= window
.location
&& window
.location
.hash
;
1840 return hash
&& hash
.slice( 1 ) === elem
.id
;
1843 "root": function( elem
) {
1844 return elem
=== docElem
;
1847 "focus": function( elem
) {
1848 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
1851 // Boolean properties
1852 "enabled": function( elem
) {
1853 return elem
.disabled
=== false;
1856 "disabled": function( elem
) {
1857 return elem
.disabled
=== true;
1860 "checked": function( elem
) {
1861 // In CSS3, :checked should return both checked and selected elements
1862 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1863 var nodeName
= elem
.nodeName
.toLowerCase();
1864 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
1867 "selected": function( elem
) {
1868 // Accessing this property makes selected-by-default
1869 // options in Safari work properly
1870 if ( elem
.parentNode
) {
1871 elem
.parentNode
.selectedIndex
;
1874 return elem
.selected
=== true;
1878 "empty": function( elem
) {
1879 // http://www.w3.org/TR/selectors/#empty-pseudo
1880 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1881 // but not by others (comment: 8; processing instruction: 7; etc.)
1882 // nodeType < 6 works because attributes (2) do not appear as children
1883 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1884 if ( elem
.nodeType
< 6 ) {
1891 "parent": function( elem
) {
1892 return !Expr
.pseudos
["empty"]( elem
);
1895 // Element/input types
1896 "header": function( elem
) {
1897 return rheader
.test( elem
.nodeName
);
1900 "input": function( elem
) {
1901 return rinputs
.test( elem
.nodeName
);
1904 "button": function( elem
) {
1905 var name
= elem
.nodeName
.toLowerCase();
1906 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
1909 "text": function( elem
) {
1911 return elem
.nodeName
.toLowerCase() === "input" &&
1912 elem
.type
=== "text" &&
1915 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1916 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === "text" );
1919 // Position-in-collection
1920 "first": createPositionalPseudo(function() {
1924 "last": createPositionalPseudo(function( matchIndexes
, length
) {
1925 return [ length
- 1 ];
1928 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
1929 return [ argument
< 0 ? argument
+ length
: argument
];
1932 "even": createPositionalPseudo(function( matchIndexes
, length
) {
1934 for ( ; i
< length
; i
+= 2 ) {
1935 matchIndexes
.push( i
);
1937 return matchIndexes
;
1940 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
1942 for ( ; i
< length
; i
+= 2 ) {
1943 matchIndexes
.push( i
);
1945 return matchIndexes
;
1948 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
1949 var i
= argument
< 0 ? argument
+ length
: argument
;
1950 for ( ; --i
>= 0; ) {
1951 matchIndexes
.push( i
);
1953 return matchIndexes
;
1956 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
1957 var i
= argument
< 0 ? argument
+ length
: argument
;
1958 for ( ; ++i
< length
; ) {
1959 matchIndexes
.push( i
);
1961 return matchIndexes
;
1966 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
1968 // Add button/input type pseudos
1969 for ( i
in { radio
: true, checkbox
: true, file
: true, password
: true, image
: true } ) {
1970 Expr
.pseudos
[ i
] = createInputPseudo( i
);
1972 for ( i
in { submit
: true, reset
: true } ) {
1973 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
1976 // Easy API for creating new setFilters
1977 function setFilters() {}
1978 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
1979 Expr
.setFilters
= new setFilters();
1981 function tokenize( selector
, parseOnly
) {
1982 var matched
, match
, tokens
, type
,
1983 soFar
, groups
, preFilters
,
1984 cached
= tokenCache
[ selector
+ " " ];
1987 return parseOnly
? 0 : cached
.slice( 0 );
1992 preFilters
= Expr
.preFilter
;
1996 // Comma and first run
1997 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
1999 // Don't consume trailing commas as valid
2000 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2002 groups
.push( (tokens
= []) );
2008 if ( (match
= rcombinators
.exec( soFar
)) ) {
2009 matched
= match
.shift();
2012 // Cast descendant combinators to space
2013 type
: match
[0].replace( rtrim
, " " )
2015 soFar
= soFar
.slice( matched
.length
);
2019 for ( type
in Expr
.filter
) {
2020 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2021 (match
= preFilters
[ type
]( match
))) ) {
2022 matched
= match
.shift();
2028 soFar
= soFar
.slice( matched
.length
);
2037 // Return the length of the invalid excess
2038 // if we're just parsing
2039 // Otherwise, throw an error or return tokens
2043 Sizzle
.error( selector
) :
2045 tokenCache( selector
, groups
).slice( 0 );
2048 function toSelector( tokens
) {
2050 len
= tokens
.length
,
2052 for ( ; i
< len
; i
++ ) {
2053 selector
+= tokens
[i
].value
;
2058 function addCombinator( matcher
, combinator
, base
) {
2059 var dir
= combinator
.dir
,
2060 checkNonElements
= base
&& dir
=== "parentNode",
2063 return combinator
.first
?
2064 // Check against closest ancestor/preceding element
2065 function( elem
, context
, xml
) {
2066 while ( (elem
= elem
[ dir
]) ) {
2067 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2068 return matcher( elem
, context
, xml
);
2073 // Check against all ancestor/preceding elements
2074 function( elem
, context
, xml
) {
2075 var oldCache
, outerCache
,
2076 newCache
= [ dirruns
, doneName
];
2078 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2080 while ( (elem
= elem
[ dir
]) ) {
2081 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2082 if ( matcher( elem
, context
, xml
) ) {
2088 while ( (elem
= elem
[ dir
]) ) {
2089 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2090 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2091 if ( (oldCache
= outerCache
[ dir
]) &&
2092 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2094 // Assign to newCache so results back-propagate to previous elements
2095 return (newCache
[ 2 ] = oldCache
[ 2 ]);
2097 // Reuse newcache so results back-propagate to previous elements
2098 outerCache
[ dir
] = newCache
;
2100 // A match means we're done; a fail means we have to keep checking
2101 if ( (newCache
[ 2 ] = matcher( elem
, context
, xml
)) ) {
2111 function elementMatcher( matchers
) {
2112 return matchers
.length
> 1 ?
2113 function( elem
, context
, xml
) {
2114 var i
= matchers
.length
;
2116 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2125 function condense( unmatched
, map
, filter
, context
, xml
) {
2129 len
= unmatched
.length
,
2130 mapped
= map
!= null;
2132 for ( ; i
< len
; i
++ ) {
2133 if ( (elem
= unmatched
[i
]) ) {
2134 if ( !filter
|| filter( elem
, context
, xml
) ) {
2135 newUnmatched
.push( elem
);
2143 return newUnmatched
;
2146 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2147 if ( postFilter
&& !postFilter
[ expando
] ) {
2148 postFilter
= setMatcher( postFilter
);
2150 if ( postFinder
&& !postFinder
[ expando
] ) {
2151 postFinder
= setMatcher( postFinder
, postSelector
);
2153 return markFunction(function( seed
, results
, context
, xml
) {
2157 preexisting
= results
.length
,
2159 // Get initial elements from seed or context
2160 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2162 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2163 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2164 condense( elems
, preMap
, preFilter
, context
, xml
) :
2167 matcherOut
= matcher
?
2168 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2169 postFinder
|| ( seed
? preFilter
: preexisting
|| postFilter
) ?
2171 // ...intermediate processing is necessary
2174 // ...otherwise use results directly
2178 // Find primary matches
2180 matcher( matcherIn
, matcherOut
, context
, xml
);
2185 temp
= condense( matcherOut
, postMap
);
2186 postFilter( temp
, [], context
, xml
);
2188 // Un-match failing elements by moving them back to matcherIn
2191 if ( (elem
= temp
[i
]) ) {
2192 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2198 if ( postFinder
|| preFilter
) {
2200 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2202 i
= matcherOut
.length
;
2204 if ( (elem
= matcherOut
[i
]) ) {
2205 // Restore matcherIn since elem is not yet a final match
2206 temp
.push( (matcherIn
[i
] = elem
) );
2209 postFinder( null, (matcherOut
= []), temp
, xml
);
2212 // Move matched elements from seed to results to keep them synchronized
2213 i
= matcherOut
.length
;
2215 if ( (elem
= matcherOut
[i
]) &&
2216 (temp
= postFinder
? indexOf
.call( seed
, elem
) : preMap
[i
]) > -1 ) {
2218 seed
[temp
] = !(results
[temp
] = elem
);
2223 // Add elements to results, through postFinder if defined
2225 matcherOut
= condense(
2226 matcherOut
=== results
?
2227 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2231 postFinder( null, results
, matcherOut
, xml
);
2233 push
.apply( results
, matcherOut
);
2239 function matcherFromTokens( tokens
) {
2240 var checkContext
, matcher
, j
,
2241 len
= tokens
.length
,
2242 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2243 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2244 i
= leadingRelative
? 1 : 0,
2246 // The foundational matcher ensures that elements are reachable from top-level context(s)
2247 matchContext
= addCombinator( function( elem
) {
2248 return elem
=== checkContext
;
2249 }, implicitRelative
, true ),
2250 matchAnyContext
= addCombinator( function( elem
) {
2251 return indexOf
.call( checkContext
, elem
) > -1;
2252 }, implicitRelative
, true ),
2253 matchers
= [ function( elem
, context
, xml
) {
2254 return ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2255 (checkContext
= context
).nodeType
?
2256 matchContext( elem
, context
, xml
) :
2257 matchAnyContext( elem
, context
, xml
) );
2260 for ( ; i
< len
; i
++ ) {
2261 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2262 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2264 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2266 // Return special upon seeing a positional matcher
2267 if ( matcher
[ expando
] ) {
2268 // Find the next relative operator (if any) for proper handling
2270 for ( ; j
< len
; j
++ ) {
2271 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2276 i
> 1 && elementMatcher( matchers
),
2277 i
> 1 && toSelector(
2278 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2279 tokens
.slice( 0, i
- 1 ).concat({ value
: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2280 ).replace( rtrim
, "$1" ),
2282 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2283 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2284 j
< len
&& toSelector( tokens
)
2287 matchers
.push( matcher
);
2291 return elementMatcher( matchers
);
2294 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2295 var bySet
= setMatchers
.length
> 0,
2296 byElement
= elementMatchers
.length
> 0,
2297 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2298 var elem
, j
, matcher
,
2301 unmatched
= seed
&& [],
2303 contextBackup
= outermostContext
,
2304 // We must always have either seed elements or outermost context
2305 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", outermost
),
2306 // Use integer dirruns iff this is the outermost matcher
2307 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1),
2311 outermostContext
= context
!== document
&& context
;
2314 // Add elements passing elementMatchers directly to results
2315 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2316 // Support: IE<9, Safari
2317 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2318 for ( ; i
!== len
&& (elem
= elems
[i
]) != null; i
++ ) {
2319 if ( byElement
&& elem
) {
2321 while ( (matcher
= elementMatchers
[j
++]) ) {
2322 if ( matcher( elem
, context
, xml
) ) {
2323 results
.push( elem
);
2328 dirruns
= dirrunsUnique
;
2332 // Track unmatched elements for set filters
2334 // They will have gone through all possible matchers
2335 if ( (elem
= !matcher
&& elem
) ) {
2339 // Lengthen the array for every element, matched or not
2341 unmatched
.push( elem
);
2346 // Apply set filters to unmatched elements
2348 if ( bySet
&& i
!== matchedCount
) {
2350 while ( (matcher
= setMatchers
[j
++]) ) {
2351 matcher( unmatched
, setMatched
, context
, xml
);
2355 // Reintegrate element matches to eliminate the need for sorting
2356 if ( matchedCount
> 0 ) {
2358 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2359 setMatched
[i
] = pop
.call( results
);
2364 // Discard index placeholder values to get only actual matches
2365 setMatched
= condense( setMatched
);
2368 // Add matches to results
2369 push
.apply( results
, setMatched
);
2371 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2372 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2373 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2375 Sizzle
.uniqueSort( results
);
2379 // Override manipulation of globals by nested matchers
2381 dirruns
= dirrunsUnique
;
2382 outermostContext
= contextBackup
;
2389 markFunction( superMatcher
) :
2393 compile
= Sizzle
.compile = function( selector
, group
/* Internal Use Only */ ) {
2396 elementMatchers
= [],
2397 cached
= compilerCache
[ selector
+ " " ];
2400 // Generate a function of recursive functions that can be used to check each element
2402 group
= tokenize( selector
);
2406 cached
= matcherFromTokens( group
[i
] );
2407 if ( cached
[ expando
] ) {
2408 setMatchers
.push( cached
);
2410 elementMatchers
.push( cached
);
2414 // Cache the compiled function
2415 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2420 function multipleContexts( selector
, contexts
, results
) {
2422 len
= contexts
.length
;
2423 for ( ; i
< len
; i
++ ) {
2424 Sizzle( selector
, contexts
[i
], results
);
2429 function select( selector
, context
, results
, seed
) {
2430 var i
, tokens
, token
, type
, find
,
2431 match
= tokenize( selector
);
2434 // Try to minimize operations if there is only one group
2435 if ( match
.length
=== 1 ) {
2437 // Take a shortcut and set the context if the root selector is an ID
2438 tokens
= match
[0] = match
[0].slice( 0 );
2439 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2440 support
.getById
&& context
.nodeType
=== 9 && documentIsHTML
&&
2441 Expr
.relative
[ tokens
[1].type
] ) {
2443 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2447 selector
= selector
.slice( tokens
.shift().value
.length
);
2450 // Fetch a seed set for right-to-left matching
2451 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2455 // Abort if we hit a combinator
2456 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2459 if ( (find
= Expr
.find
[ type
]) ) {
2460 // Search, expanding context for leading sibling combinators
2462 token
.matches
[0].replace( runescape
, funescape
),
2463 rsibling
.test( tokens
[0].type
) && testContext( context
.parentNode
) || context
2466 // If seed is empty or no tokens remain, we can return early
2467 tokens
.splice( i
, 1 );
2468 selector
= seed
.length
&& toSelector( tokens
);
2470 push
.apply( results
, seed
);
2481 // Compile and execute a filtering function
2482 // Provide `match` to avoid retokenization if we modified the selector above
2483 compile( selector
, match
)(
2488 rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2493 // One-time assignments
2496 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2498 // Support: Chrome<14
2499 // Always assume duplicates if they aren't passed to the comparison function
2500 support
.detectDuplicates
= !!hasDuplicate
;
2502 // Initialize against the default document
2505 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2506 // Detached nodes confoundingly follow *each other*
2507 support
.sortDetached
= assert(function( div1
) {
2508 // Should return 1, but returns 4 (following)
2509 return div1
.compareDocumentPosition( document
.createElement("div") ) & 1;
2513 // Prevent attribute/property "interpolation"
2514 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2515 if ( !assert(function( div
) {
2516 div
.innerHTML
= "<a href='#'></a>";
2517 return div
.firstChild
.getAttribute("href") === "#" ;
2519 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2521 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2527 // Use defaultValue in place of getAttribute("value")
2528 if ( !support
.attributes
|| !assert(function( div
) {
2529 div
.innerHTML
= "<input/>";
2530 div
.firstChild
.setAttribute( "value", "" );
2531 return div
.firstChild
.getAttribute( "value" ) === "";
2533 addHandle( "value", function( elem
, name
, isXML
) {
2534 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2535 return elem
.defaultValue
;
2541 // Use getAttributeNode to fetch booleans when getAttribute lies
2542 if ( !assert(function( div
) {
2543 return div
.getAttribute("disabled") == null;
2545 addHandle( booleans
, function( elem
, name
, isXML
) {
2548 return elem
[ name
] === true ? name
.toLowerCase() :
2549 (val
= elem
.getAttributeNode( name
)) && val
.specified
?
2562 jQuery
.find
= Sizzle
;
2563 jQuery
.expr
= Sizzle
.selectors
;
2564 jQuery
.expr
[":"] = jQuery
.expr
.pseudos
;
2565 jQuery
.unique
= Sizzle
.uniqueSort
;
2566 jQuery
.text
= Sizzle
.getText
;
2567 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2568 jQuery
.contains
= Sizzle
.contains
;
2572 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
2574 var rsingleTag
= (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2578 var risSimple
= /^.[^:#\[\.,]*$/;
2580 // Implement the identical functionality for filter and not
2581 function winnow( elements
, qualifier
, not
) {
2582 if ( jQuery
.isFunction( qualifier
) ) {
2583 return jQuery
.grep( elements
, function( elem
, i
) {
2585 return !!qualifier
.call( elem
, i
, elem
) !== not
;
2590 if ( qualifier
.nodeType
) {
2591 return jQuery
.grep( elements
, function( elem
) {
2592 return ( elem
=== qualifier
) !== not
;
2597 if ( typeof qualifier
=== "string" ) {
2598 if ( risSimple
.test( qualifier
) ) {
2599 return jQuery
.filter( qualifier
, elements
, not
);
2602 qualifier
= jQuery
.filter( qualifier
, elements
);
2605 return jQuery
.grep( elements
, function( elem
) {
2606 return ( indexOf
.call( qualifier
, elem
) >= 0 ) !== not
;
2610 jQuery
.filter = function( expr
, elems
, not
) {
2611 var elem
= elems
[ 0 ];
2614 expr
= ":not(" + expr
+ ")";
2617 return elems
.length
=== 1 && elem
.nodeType
=== 1 ?
2618 jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [] :
2619 jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
2620 return elem
.nodeType
=== 1;
2625 find: function( selector
) {
2631 if ( typeof selector
!== "string" ) {
2632 return this.pushStack( jQuery( selector
).filter(function() {
2633 for ( i
= 0; i
< len
; i
++ ) {
2634 if ( jQuery
.contains( self
[ i
], this ) ) {
2641 for ( i
= 0; i
< len
; i
++ ) {
2642 jQuery
.find( selector
, self
[ i
], ret
);
2645 // Needed because $( selector, context ) becomes $( context ).find( selector )
2646 ret
= this.pushStack( len
> 1 ? jQuery
.unique( ret
) : ret
);
2647 ret
.selector
= this.selector
? this.selector
+ " " + selector
: selector
;
2650 filter: function( selector
) {
2651 return this.pushStack( winnow(this, selector
|| [], false) );
2653 not: function( selector
) {
2654 return this.pushStack( winnow(this, selector
|| [], true) );
2656 is: function( selector
) {
2660 // If this is a positional/relative selector, check membership in the returned set
2661 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2662 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
2663 jQuery( selector
) :
2671 // Initialize a jQuery object
2674 // A central reference to the root jQuery(document)
2677 // A simple way to check for HTML strings
2678 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2679 // Strict HTML recognition (#11290: must start with <)
2680 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2682 init
= jQuery
.fn
.init = function( selector
, context
) {
2685 // HANDLE: $(""), $(null), $(undefined), $(false)
2690 // Handle HTML strings
2691 if ( typeof selector
=== "string" ) {
2692 if ( selector
[0] === "<" && selector
[ selector
.length
- 1 ] === ">" && selector
.length
>= 3 ) {
2693 // Assume that strings that start and end with <> are HTML and skip the regex check
2694 match
= [ null, selector
, null ];
2697 match
= rquickExpr
.exec( selector
);
2700 // Match html or make sure no context is specified for #id
2701 if ( match
&& (match
[1] || !context
) ) {
2703 // HANDLE: $(html) -> $(array)
2705 context
= context
instanceof jQuery
? context
[0] : context
;
2707 // scripts is true for back-compat
2708 // Intentionally let the error be thrown if parseHTML is not present
2709 jQuery
.merge( this, jQuery
.parseHTML(
2711 context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
,
2715 // HANDLE: $(html, props)
2716 if ( rsingleTag
.test( match
[1] ) && jQuery
.isPlainObject( context
) ) {
2717 for ( match
in context
) {
2718 // Properties of context are called as methods if possible
2719 if ( jQuery
.isFunction( this[ match
] ) ) {
2720 this[ match
]( context
[ match
] );
2722 // ...and otherwise set as attributes
2724 this.attr( match
, context
[ match
] );
2733 elem
= document
.getElementById( match
[2] );
2735 // Check parentNode to catch when Blackberry 4.6 returns
2736 // nodes that are no longer in the document #6963
2737 if ( elem
&& elem
.parentNode
) {
2738 // Inject the element directly into the jQuery object
2743 this.context
= document
;
2744 this.selector
= selector
;
2748 // HANDLE: $(expr, $(...))
2749 } else if ( !context
|| context
.jquery
) {
2750 return ( context
|| rootjQuery
).find( selector
);
2752 // HANDLE: $(expr, context)
2753 // (which is just equivalent to: $(context).find(expr)
2755 return this.constructor( context
).find( selector
);
2758 // HANDLE: $(DOMElement)
2759 } else if ( selector
.nodeType
) {
2760 this.context
= this[0] = selector
;
2764 // HANDLE: $(function)
2765 // Shortcut for document ready
2766 } else if ( jQuery
.isFunction( selector
) ) {
2767 return typeof rootjQuery
.ready
!== "undefined" ?
2768 rootjQuery
.ready( selector
) :
2769 // Execute immediately if ready is not present
2773 if ( selector
.selector
!== undefined ) {
2774 this.selector
= selector
.selector
;
2775 this.context
= selector
.context
;
2778 return jQuery
.makeArray( selector
, this );
2781 // Give the init function the jQuery prototype for later instantiation
2782 init
.prototype = jQuery
.fn
;
2784 // Initialize central reference
2785 rootjQuery
= jQuery( document
);
2788 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
2789 // methods guaranteed to produce a unique set when starting from a unique set
2790 guaranteedUnique
= {
2798 dir: function( elem
, dir
, until
) {
2800 truncate
= until
!== undefined;
2802 while ( (elem
= elem
[ dir
]) && elem
.nodeType
!== 9 ) {
2803 if ( elem
.nodeType
=== 1 ) {
2804 if ( truncate
&& jQuery( elem
).is( until
) ) {
2807 matched
.push( elem
);
2813 sibling: function( n
, elem
) {
2816 for ( ; n
; n
= n
.nextSibling
) {
2817 if ( n
.nodeType
=== 1 && n
!== elem
) {
2827 has: function( target
) {
2828 var targets
= jQuery( target
, this ),
2831 return this.filter(function() {
2833 for ( ; i
< l
; i
++ ) {
2834 if ( jQuery
.contains( this, targets
[i
] ) ) {
2841 closest: function( selectors
, context
) {
2846 pos
= rneedsContext
.test( selectors
) || typeof selectors
!== "string" ?
2847 jQuery( selectors
, context
|| this.context
) :
2850 for ( ; i
< l
; i
++ ) {
2851 for ( cur
= this[i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
2852 // Always skip document fragments
2853 if ( cur
.nodeType
< 11 && (pos
?
2854 pos
.index(cur
) > -1 :
2856 // Don't pass non-elements to Sizzle
2857 cur
.nodeType
=== 1 &&
2858 jQuery
.find
.matchesSelector(cur
, selectors
)) ) {
2860 matched
.push( cur
);
2866 return this.pushStack( matched
.length
> 1 ? jQuery
.unique( matched
) : matched
);
2869 // Determine the position of an element within
2870 // the matched set of elements
2871 index: function( elem
) {
2873 // No argument, return index in parent
2875 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length
: -1;
2878 // index in selector
2879 if ( typeof elem
=== "string" ) {
2880 return indexOf
.call( jQuery( elem
), this[ 0 ] );
2883 // Locate the position of the desired element
2884 return indexOf
.call( this,
2886 // If it receives a jQuery object, the first element is used
2887 elem
.jquery
? elem
[ 0 ] : elem
2891 add: function( selector
, context
) {
2892 return this.pushStack(
2894 jQuery
.merge( this.get(), jQuery( selector
, context
) )
2899 addBack: function( selector
) {
2900 return this.add( selector
== null ?
2901 this.prevObject
: this.prevObject
.filter(selector
)
2906 function sibling( cur
, dir
) {
2907 while ( (cur
= cur
[dir
]) && cur
.nodeType
!== 1 ) {}
2912 parent: function( elem
) {
2913 var parent
= elem
.parentNode
;
2914 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
2916 parents: function( elem
) {
2917 return jQuery
.dir( elem
, "parentNode" );
2919 parentsUntil: function( elem
, i
, until
) {
2920 return jQuery
.dir( elem
, "parentNode", until
);
2922 next: function( elem
) {
2923 return sibling( elem
, "nextSibling" );
2925 prev: function( elem
) {
2926 return sibling( elem
, "previousSibling" );
2928 nextAll: function( elem
) {
2929 return jQuery
.dir( elem
, "nextSibling" );
2931 prevAll: function( elem
) {
2932 return jQuery
.dir( elem
, "previousSibling" );
2934 nextUntil: function( elem
, i
, until
) {
2935 return jQuery
.dir( elem
, "nextSibling", until
);
2937 prevUntil: function( elem
, i
, until
) {
2938 return jQuery
.dir( elem
, "previousSibling", until
);
2940 siblings: function( elem
) {
2941 return jQuery
.sibling( ( elem
.parentNode
|| {} ).firstChild
, elem
);
2943 children: function( elem
) {
2944 return jQuery
.sibling( elem
.firstChild
);
2946 contents: function( elem
) {
2947 return elem
.contentDocument
|| jQuery
.merge( [], elem
.childNodes
);
2949 }, function( name
, fn
) {
2950 jQuery
.fn
[ name
] = function( until
, selector
) {
2951 var matched
= jQuery
.map( this, fn
, until
);
2953 if ( name
.slice( -5 ) !== "Until" ) {
2957 if ( selector
&& typeof selector
=== "string" ) {
2958 matched
= jQuery
.filter( selector
, matched
);
2961 if ( this.length
> 1 ) {
2962 // Remove duplicates
2963 if ( !guaranteedUnique
[ name
] ) {
2964 jQuery
.unique( matched
);
2967 // Reverse order for parents* and prev-derivatives
2968 if ( rparentsprev
.test( name
) ) {
2973 return this.pushStack( matched
);
2976 var rnotwhite
= (/\S+/g);
2980 // String to Object options format cache
2981 var optionsCache
= {};
2983 // Convert String-formatted options into Object-formatted ones and store in cache
2984 function createOptions( options
) {
2985 var object
= optionsCache
[ options
] = {};
2986 jQuery
.each( options
.match( rnotwhite
) || [], function( _
, flag
) {
2987 object
[ flag
] = true;
2993 * Create a callback list using the following parameters:
2995 * options: an optional list of space-separated options that will change how
2996 * the callback list behaves or a more traditional option object
2998 * By default a callback list will act like an event callback list and can be
2999 * "fired" multiple times.
3003 * once: will ensure the callback list can only be fired once (like a Deferred)
3005 * memory: will keep track of previous values and will call any callback added
3006 * after the list has been fired right away with the latest "memorized"
3007 * values (like a Deferred)
3009 * unique: will ensure a callback can only be added once (no duplicate in the list)
3011 * stopOnFalse: interrupt callings when a callback returns false
3014 jQuery
.Callbacks = function( options
) {
3016 // Convert options from String-formatted to Object-formatted if needed
3017 // (we check in cache first)
3018 options
= typeof options
=== "string" ?
3019 ( optionsCache
[ options
] || createOptions( options
) ) :
3020 jQuery
.extend( {}, options
);
3022 var // Last fire value (for non-forgettable lists)
3024 // Flag to know if list was already fired
3026 // Flag to know if list is currently firing
3028 // First callback to fire (used internally by add and fireWith)
3030 // End of the loop when firing
3032 // Index of currently firing callback (modified by remove if needed)
3034 // Actual callback list
3036 // Stack of fire calls for repeatable lists
3037 stack
= !options
.once
&& [],
3039 fire = function( data
) {
3040 memory
= options
.memory
&& data
;
3042 firingIndex
= firingStart
|| 0;
3044 firingLength
= list
.length
;
3046 for ( ; list
&& firingIndex
< firingLength
; firingIndex
++ ) {
3047 if ( list
[ firingIndex
].apply( data
[ 0 ], data
[ 1 ] ) === false && options
.stopOnFalse
) {
3048 memory
= false; // To prevent further calls using add
3055 if ( stack
.length
) {
3056 fire( stack
.shift() );
3058 } else if ( memory
) {
3065 // Actual Callbacks object
3067 // Add a callback or a collection of callbacks to the list
3070 // First, we save the current length
3071 var start
= list
.length
;
3072 (function add( args
) {
3073 jQuery
.each( args
, function( _
, arg
) {
3074 var type
= jQuery
.type( arg
);
3075 if ( type
=== "function" ) {
3076 if ( !options
.unique
|| !self
.has( arg
) ) {
3079 } else if ( arg
&& arg
.length
&& type
!== "string" ) {
3080 // Inspect recursively
3085 // Do we need to add the callbacks to the
3086 // current firing batch?
3088 firingLength
= list
.length
;
3089 // With memory, if we're not firing then
3090 // we should call right away
3091 } else if ( memory
) {
3092 firingStart
= start
;
3098 // Remove a callback from the list
3099 remove: function() {
3101 jQuery
.each( arguments
, function( _
, arg
) {
3103 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3104 list
.splice( index
, 1 );
3105 // Handle firing indexes
3107 if ( index
<= firingLength
) {
3110 if ( index
<= firingIndex
) {
3119 // Check if a given callback is in the list.
3120 // If no argument is given, return whether or not list has callbacks attached.
3121 has: function( fn
) {
3122 return fn
? jQuery
.inArray( fn
, list
) > -1 : !!( list
&& list
.length
);
3124 // Remove all callbacks from the list
3130 // Have the list do nothing anymore
3131 disable: function() {
3132 list
= stack
= memory
= undefined;
3136 disabled: function() {
3139 // Lock the list in its current state
3148 locked: function() {
3151 // Call all callbacks with the given context and arguments
3152 fireWith: function( context
, args
) {
3153 if ( list
&& ( !fired
|| stack
) ) {
3155 args
= [ context
, args
.slice
? args
.slice() : args
];
3164 // Call all the callbacks with the given arguments
3166 self
.fireWith( this, arguments
);
3169 // To know if the callbacks have already been called at least once
3181 Deferred: function( func
) {
3183 // action, add listener, listener list, final state
3184 [ "resolve", "done", jQuery
.Callbacks("once memory"), "resolved" ],
3185 [ "reject", "fail", jQuery
.Callbacks("once memory"), "rejected" ],
3186 [ "notify", "progress", jQuery
.Callbacks("memory") ]
3193 always: function() {
3194 deferred
.done( arguments
).fail( arguments
);
3197 then: function( /* fnDone, fnFail, fnProgress */ ) {
3198 var fns
= arguments
;
3199 return jQuery
.Deferred(function( newDefer
) {
3200 jQuery
.each( tuples
, function( i
, tuple
) {
3201 var fn
= jQuery
.isFunction( fns
[ i
] ) && fns
[ i
];
3202 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3203 deferred
[ tuple
[1] ](function() {
3204 var returned
= fn
&& fn
.apply( this, arguments
);
3205 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
3207 .done( newDefer
.resolve
)
3208 .fail( newDefer
.reject
)
3209 .progress( newDefer
.notify
);
3211 newDefer
[ tuple
[ 0 ] + "With" ]( this === promise
? newDefer
.promise() : this, fn
? [ returned
] : arguments
);
3218 // Get a promise for this deferred
3219 // If obj is provided, the promise aspect is added to the object
3220 promise: function( obj
) {
3221 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3226 // Keep pipe for back-compat
3227 promise
.pipe
= promise
.then
;
3229 // Add list-specific methods
3230 jQuery
.each( tuples
, function( i
, tuple
) {
3231 var list
= tuple
[ 2 ],
3232 stateString
= tuple
[ 3 ];
3234 // promise[ done | fail | progress ] = list.add
3235 promise
[ tuple
[1] ] = list
.add
;
3238 if ( stateString
) {
3239 list
.add(function() {
3240 // state = [ resolved | rejected ]
3241 state
= stateString
;
3243 // [ reject_list | resolve_list ].disable; progress_list.lock
3244 }, tuples
[ i
^ 1 ][ 2 ].disable
, tuples
[ 2 ][ 2 ].lock
);
3247 // deferred[ resolve | reject | notify ]
3248 deferred
[ tuple
[0] ] = function() {
3249 deferred
[ tuple
[0] + "With" ]( this === deferred
? promise
: this, arguments
);
3252 deferred
[ tuple
[0] + "With" ] = list
.fireWith
;
3255 // Make the deferred a promise
3256 promise
.promise( deferred
);
3258 // Call given func if any
3260 func
.call( deferred
, deferred
);
3268 when: function( subordinate
/* , ..., subordinateN */ ) {
3270 resolveValues
= slice
.call( arguments
),
3271 length
= resolveValues
.length
,
3273 // the count of uncompleted subordinates
3274 remaining
= length
!== 1 || ( subordinate
&& jQuery
.isFunction( subordinate
.promise
) ) ? length
: 0,
3276 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3277 deferred
= remaining
=== 1 ? subordinate
: jQuery
.Deferred(),
3279 // Update function for both resolve and progress values
3280 updateFunc = function( i
, contexts
, values
) {
3281 return function( value
) {
3282 contexts
[ i
] = this;
3283 values
[ i
] = arguments
.length
> 1 ? slice
.call( arguments
) : value
;
3284 if ( values
=== progressValues
) {
3285 deferred
.notifyWith( contexts
, values
);
3286 } else if ( !( --remaining
) ) {
3287 deferred
.resolveWith( contexts
, values
);
3292 progressValues
, progressContexts
, resolveContexts
;
3294 // add listeners to Deferred subordinates; treat others as resolved
3296 progressValues
= new Array( length
);
3297 progressContexts
= new Array( length
);
3298 resolveContexts
= new Array( length
);
3299 for ( ; i
< length
; i
++ ) {
3300 if ( resolveValues
[ i
] && jQuery
.isFunction( resolveValues
[ i
].promise
) ) {
3301 resolveValues
[ i
].promise()
3302 .done( updateFunc( i
, resolveContexts
, resolveValues
) )
3303 .fail( deferred
.reject
)
3304 .progress( updateFunc( i
, progressContexts
, progressValues
) );
3311 // if we're not waiting on anything, resolve the master
3313 deferred
.resolveWith( resolveContexts
, resolveValues
);
3316 return deferred
.promise();
3321 // The deferred used on DOM ready
3324 jQuery
.fn
.ready = function( fn
) {
3326 jQuery
.ready
.promise().done( fn
);
3332 // Is the DOM ready to be used? Set to true once it occurs.
3335 // A counter to track how many items to wait for before
3336 // the ready event fires. See #6781
3339 // Hold (or release) the ready event
3340 holdReady: function( hold
) {
3344 jQuery
.ready( true );
3348 // Handle when the DOM is ready
3349 ready: function( wait
) {
3351 // Abort if there are pending holds or we're already ready
3352 if ( wait
=== true ? --jQuery
.readyWait
: jQuery
.isReady
) {
3356 // Remember that the DOM is ready
3357 jQuery
.isReady
= true;
3359 // If a normal DOM Ready event fired, decrement, and wait if need be
3360 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
3364 // If there are functions bound, to execute
3365 readyList
.resolveWith( document
, [ jQuery
] );
3367 // Trigger any bound ready events
3368 if ( jQuery
.fn
.trigger
) {
3369 jQuery( document
).trigger("ready").off("ready");
3375 * The ready event handler and self cleanup method
3377 function completed() {
3378 document
.removeEventListener( "DOMContentLoaded", completed
, false );
3379 window
.removeEventListener( "load", completed
, false );
3383 jQuery
.ready
.promise = function( obj
) {
3386 readyList
= jQuery
.Deferred();
3388 // Catch cases where $(document).ready() is called after the browser event has already occurred.
3389 // we once tried to use readyState "interactive" here, but it caused issues like the one
3390 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
3391 if ( document
.readyState
=== "complete" ) {
3392 // Handle it asynchronously to allow scripts the opportunity to delay ready
3393 setTimeout( jQuery
.ready
);
3397 // Use the handy event callback
3398 document
.addEventListener( "DOMContentLoaded", completed
, false );
3400 // A fallback to window.onload, that will always work
3401 window
.addEventListener( "load", completed
, false );
3404 return readyList
.promise( obj
);
3407 // Kick off the DOM ready check even if the user does not
3408 jQuery
.ready
.promise();
3413 // Multifunctional method to get and set values of a collection
3414 // The value/s can optionally be executed if it's a function
3415 var access
= jQuery
.access = function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
3421 if ( jQuery
.type( key
) === "object" ) {
3424 jQuery
.access( elems
, fn
, i
, key
[i
], true, emptyGet
, raw
);
3428 } else if ( value
!== undefined ) {
3431 if ( !jQuery
.isFunction( value
) ) {
3436 // Bulk operations run against the entire set
3438 fn
.call( elems
, value
);
3441 // ...except when executing function values
3444 fn = function( elem
, key
, value
) {
3445 return bulk
.call( jQuery( elem
), value
);
3451 for ( ; i
< len
; i
++ ) {
3452 fn( elems
[i
], key
, raw
? value
: value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) );
3463 len
? fn( elems
[0], key
) : emptyGet
;
3468 * Determines whether an object can have data
3470 jQuery
.acceptData = function( owner
) {
3473 // - Node.ELEMENT_NODE
3474 // - Node.DOCUMENT_NODE
3478 return owner
.nodeType
=== 1 || owner
.nodeType
=== 9 || !( +owner
.nodeType
);
3483 // Support: Android < 4,
3484 // Old WebKit does not have Object.preventExtensions/freeze method,
3485 // return new empty object instead with no [[set]] accessor
3486 Object
.defineProperty( this.cache
= {}, 0, {
3492 this.expando
= jQuery
.expando
+ Math
.random();
3496 Data
.accepts
= jQuery
.acceptData
;
3499 key: function( owner
) {
3500 // We can accept data for non-element nodes in modern browsers,
3501 // but we should not, see #8335.
3502 // Always return the key for a frozen object.
3503 if ( !Data
.accepts( owner
) ) {
3507 var descriptor
= {},
3508 // Check if the owner object already has a cache key
3509 unlock
= owner
[ this.expando
];
3511 // If not, create one
3513 unlock
= Data
.uid
++;
3515 // Secure it in a non-enumerable, non-writable property
3517 descriptor
[ this.expando
] = { value
: unlock
};
3518 Object
.defineProperties( owner
, descriptor
);
3520 // Support: Android < 4
3521 // Fallback to a less secure definition
3523 descriptor
[ this.expando
] = unlock
;
3524 jQuery
.extend( owner
, descriptor
);
3528 // Ensure the cache object
3529 if ( !this.cache
[ unlock
] ) {
3530 this.cache
[ unlock
] = {};
3535 set: function( owner
, data
, value
) {
3537 // There may be an unlock assigned to this node,
3538 // if there is no entry for this "owner", create one inline
3539 // and set the unlock as though an owner entry had always existed
3540 unlock
= this.key( owner
),
3541 cache
= this.cache
[ unlock
];
3543 // Handle: [ owner, key, value ] args
3544 if ( typeof data
=== "string" ) {
3545 cache
[ data
] = value
;
3547 // Handle: [ owner, { properties } ] args
3549 // Fresh assignments by object are shallow copied
3550 if ( jQuery
.isEmptyObject( cache
) ) {
3551 jQuery
.extend( this.cache
[ unlock
], data
);
3552 // Otherwise, copy the properties one-by-one to the cache object
3554 for ( prop
in data
) {
3555 cache
[ prop
] = data
[ prop
];
3561 get: function( owner
, key
) {
3562 // Either a valid cache is found, or will be created.
3563 // New caches will be created and the unlock returned,
3564 // allowing direct access to the newly created
3565 // empty data object. A valid owner object must be provided.
3566 var cache
= this.cache
[ this.key( owner
) ];
3568 return key
=== undefined ?
3569 cache
: cache
[ key
];
3571 access: function( owner
, key
, value
) {
3573 // In cases where either:
3575 // 1. No key was specified
3576 // 2. A string key was specified, but no value provided
3578 // Take the "read" path and allow the get method to determine
3579 // which value to return, respectively either:
3581 // 1. The entire cache object
3582 // 2. The data stored at the key
3584 if ( key
=== undefined ||
3585 ((key
&& typeof key
=== "string") && value
=== undefined) ) {
3587 stored
= this.get( owner
, key
);
3589 return stored
!== undefined ?
3590 stored
: this.get( owner
, jQuery
.camelCase(key
) );
3593 // [*]When the key is not a string, or both a key and value
3594 // are specified, set or extend (existing objects) with either:
3596 // 1. An object of properties
3597 // 2. A key and value
3599 this.set( owner
, key
, value
);
3601 // Since the "set" path can have two possible entry points
3602 // return the expected data based on which path was taken[*]
3603 return value
!== undefined ? value
: key
;
3605 remove: function( owner
, key
) {
3607 unlock
= this.key( owner
),
3608 cache
= this.cache
[ unlock
];
3610 if ( key
=== undefined ) {
3611 this.cache
[ unlock
] = {};
3614 // Support array or space separated string of keys
3615 if ( jQuery
.isArray( key
) ) {
3616 // If "name" is an array of keys...
3617 // When data is initially created, via ("key", "val") signature,
3618 // keys will be converted to camelCase.
3619 // Since there is no way to tell _how_ a key was added, remove
3620 // both plain key and camelCase key. #12786
3621 // This will only penalize the array argument path.
3622 name
= key
.concat( key
.map( jQuery
.camelCase
) );
3624 camel
= jQuery
.camelCase( key
);
3625 // Try the string as a key before any manipulation
3626 if ( key
in cache
) {
3627 name
= [ key
, camel
];
3629 // If a key with the spaces exists, use it.
3630 // Otherwise, create an array by matching non-whitespace
3632 name
= name
in cache
?
3633 [ name
] : ( name
.match( rnotwhite
) || [] );
3639 delete cache
[ name
[ i
] ];
3643 hasData: function( owner
) {
3644 return !jQuery
.isEmptyObject(
3645 this.cache
[ owner
[ this.expando
] ] || {}
3648 discard: function( owner
) {
3649 if ( owner
[ this.expando
] ) {
3650 delete this.cache
[ owner
[ this.expando
] ];
3654 var data_priv
= new Data();
3656 var data_user
= new Data();
3661 Implementation Summary
3663 1. Enforce API surface and semantic compatibility with 1.9.x branch
3664 2. Improve the module's maintainability by reducing the storage
3665 paths to a single mechanism.
3666 3. Use the same single mechanism to support "private" and "user" data.
3667 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
3668 5. Avoid exposing implementation details on user objects (eg. expando properties)
3669 6. Provide a clear path for implementation upgrade to WeakMap in 2014
3671 var rbrace
= /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
3672 rmultiDash
= /([A-Z])/g;
3674 function dataAttr( elem
, key
, data
) {
3677 // If nothing was found internally, try to fetch any
3678 // data from the HTML5 data-* attribute
3679 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
3680 name
= "data-" + key
.replace( rmultiDash
, "-$1" ).toLowerCase();
3681 data
= elem
.getAttribute( name
);
3683 if ( typeof data
=== "string" ) {
3685 data
= data
=== "true" ? true :
3686 data
=== "false" ? false :
3687 data
=== "null" ? null :
3688 // Only convert to a number if it doesn't change the string
3689 +data
+ "" === data
? +data
:
3690 rbrace
.test( data
) ? jQuery
.parseJSON( data
) :
3694 // Make sure we set the data so it isn't changed later
3695 data_user
.set( elem
, key
, data
);
3704 hasData: function( elem
) {
3705 return data_user
.hasData( elem
) || data_priv
.hasData( elem
);
3708 data: function( elem
, name
, data
) {
3709 return data_user
.access( elem
, name
, data
);
3712 removeData: function( elem
, name
) {
3713 data_user
.remove( elem
, name
);
3716 // TODO: Now that all calls to _data and _removeData have been replaced
3717 // with direct calls to data_priv methods, these can be deprecated.
3718 _data: function( elem
, name
, data
) {
3719 return data_priv
.access( elem
, name
, data
);
3722 _removeData: function( elem
, name
) {
3723 data_priv
.remove( elem
, name
);
3728 data: function( key
, value
) {
3731 attrs
= elem
&& elem
.attributes
;
3734 if ( key
=== undefined ) {
3735 if ( this.length
) {
3736 data
= data_user
.get( elem
);
3738 if ( elem
.nodeType
=== 1 && !data_priv
.get( elem
, "hasDataAttrs" ) ) {
3741 name
= attrs
[ i
].name
;
3743 if ( name
.indexOf( "data-" ) === 0 ) {
3744 name
= jQuery
.camelCase( name
.slice(5) );
3745 dataAttr( elem
, name
, data
[ name
] );
3748 data_priv
.set( elem
, "hasDataAttrs", true );
3755 // Sets multiple values
3756 if ( typeof key
=== "object" ) {
3757 return this.each(function() {
3758 data_user
.set( this, key
);
3762 return access( this, function( value
) {
3764 camelKey
= jQuery
.camelCase( key
);
3766 // The calling jQuery object (element matches) is not empty
3767 // (and therefore has an element appears at this[ 0 ]) and the
3768 // `value` parameter was not undefined. An empty jQuery object
3769 // will result in `undefined` for elem = this[ 0 ] which will
3770 // throw an exception if an attempt to read a data cache is made.
3771 if ( elem
&& value
=== undefined ) {
3772 // Attempt to get data from the cache
3773 // with the key as-is
3774 data
= data_user
.get( elem
, key
);
3775 if ( data
!== undefined ) {
3779 // Attempt to get data from the cache
3780 // with the key camelized
3781 data
= data_user
.get( elem
, camelKey
);
3782 if ( data
!== undefined ) {
3786 // Attempt to "discover" the data in
3787 // HTML5 custom data-* attrs
3788 data
= dataAttr( elem
, camelKey
, undefined );
3789 if ( data
!== undefined ) {
3793 // We tried really hard, but the data doesn't exist.
3798 this.each(function() {
3799 // First, attempt to store a copy or reference of any
3800 // data that might've been store with a camelCased key.
3801 var data
= data_user
.get( this, camelKey
);
3803 // For HTML5 data-* attribute interop, we have to
3804 // store property names with dashes in a camelCase form.
3805 // This might not apply to all properties...*
3806 data_user
.set( this, camelKey
, value
);
3808 // *... In the case of properties that might _actually_
3809 // have dashes, we need to also store a copy of that
3810 // unchanged property.
3811 if ( key
.indexOf("-") !== -1 && data
!== undefined ) {
3812 data_user
.set( this, key
, value
);
3815 }, null, value
, arguments
.length
> 1, null, true );
3818 removeData: function( key
) {
3819 return this.each(function() {
3820 data_user
.remove( this, key
);
3827 queue: function( elem
, type
, data
) {
3831 type
= ( type
|| "fx" ) + "queue";
3832 queue
= data_priv
.get( elem
, type
);
3834 // Speed up dequeue by getting out quickly if this is just a lookup
3836 if ( !queue
|| jQuery
.isArray( data
) ) {
3837 queue
= data_priv
.access( elem
, type
, jQuery
.makeArray(data
) );
3846 dequeue: function( elem
, type
) {
3847 type
= type
|| "fx";
3849 var queue
= jQuery
.queue( elem
, type
),
3850 startLength
= queue
.length
,
3852 hooks
= jQuery
._queueHooks( elem
, type
),
3854 jQuery
.dequeue( elem
, type
);
3857 // If the fx queue is dequeued, always remove the progress sentinel
3858 if ( fn
=== "inprogress" ) {
3865 // Add a progress sentinel to prevent the fx queue from being
3866 // automatically dequeued
3867 if ( type
=== "fx" ) {
3868 queue
.unshift( "inprogress" );
3871 // clear up the last queue stop function
3873 fn
.call( elem
, next
, hooks
);
3876 if ( !startLength
&& hooks
) {
3881 // not intended for public consumption - generates a queueHooks object, or returns the current one
3882 _queueHooks: function( elem
, type
) {
3883 var key
= type
+ "queueHooks";
3884 return data_priv
.get( elem
, key
) || data_priv
.access( elem
, key
, {
3885 empty
: jQuery
.Callbacks("once memory").add(function() {
3886 data_priv
.remove( elem
, [ type
+ "queue", key
] );
3893 queue: function( type
, data
) {
3896 if ( typeof type
!== "string" ) {
3902 if ( arguments
.length
< setter
) {
3903 return jQuery
.queue( this[0], type
);
3906 return data
=== undefined ?
3908 this.each(function() {
3909 var queue
= jQuery
.queue( this, type
, data
);
3911 // ensure a hooks for this queue
3912 jQuery
._queueHooks( this, type
);
3914 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
3915 jQuery
.dequeue( this, type
);
3919 dequeue: function( type
) {
3920 return this.each(function() {
3921 jQuery
.dequeue( this, type
);
3924 clearQueue: function( type
) {
3925 return this.queue( type
|| "fx", [] );
3927 // Get a promise resolved when queues of a certain type
3928 // are emptied (fx is the type by default)
3929 promise: function( type
, obj
) {
3932 defer
= jQuery
.Deferred(),
3935 resolve = function() {
3936 if ( !( --count
) ) {
3937 defer
.resolveWith( elements
, [ elements
] );
3941 if ( typeof type
!== "string" ) {
3945 type
= type
|| "fx";
3948 tmp
= data_priv
.get( elements
[ i
], type
+ "queueHooks" );
3949 if ( tmp
&& tmp
.empty
) {
3951 tmp
.empty
.add( resolve
);
3955 return defer
.promise( obj
);
3958 var pnum
= (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source
;
3960 var cssExpand
= [ "Top", "Right", "Bottom", "Left" ];
3962 var isHidden = function( elem
, el
) {
3963 // isHidden might be called from jQuery#filter function;
3964 // in that case, element will be second argument
3966 return jQuery
.css( elem
, "display" ) === "none" || !jQuery
.contains( elem
.ownerDocument
, elem
);
3969 var rcheckableType
= (/^(?:checkbox|radio)$/i);
3974 var fragment
= document
.createDocumentFragment(),
3975 div
= fragment
.appendChild( document
.createElement( "div" ) );
3977 // #11217 - WebKit loses check when the name is after the checked attribute
3978 div
.innerHTML
= "<input type='radio' checked='checked' name='t'/>";
3980 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
3981 // old WebKit doesn't clone checked state correctly in fragments
3982 support
.checkClone
= div
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
3984 // Make sure textarea (and checkbox) defaultValue is properly cloned
3985 // Support: IE9-IE11+
3986 div
.innerHTML
= "<textarea>x</textarea>";
3987 support
.noCloneChecked
= !!div
.cloneNode( true ).lastChild
.defaultValue
;
3989 var strundefined
= typeof undefined;
3993 support
.focusinBubbles
= "onfocusin" in window
;
3998 rmouseEvent
= /^(?:mouse|contextmenu)|click/,
3999 rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
4000 rtypenamespace
= /^([^.]*)(?:\.(.+)|)$/;
4002 function returnTrue() {
4006 function returnFalse() {
4010 function safeActiveElement() {
4012 return document
.activeElement
;
4017 * Helper functions for managing events -- not part of the public interface.
4018 * Props to Dean Edwards' addEvent library for many of the ideas.
4024 add: function( elem
, types
, handler
, data
, selector
) {
4026 var handleObjIn
, eventHandle
, tmp
,
4027 events
, t
, handleObj
,
4028 special
, handlers
, type
, namespaces
, origType
,
4029 elemData
= data_priv
.get( elem
);
4031 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4036 // Caller can pass in an object of custom data in lieu of the handler
4037 if ( handler
.handler
) {
4038 handleObjIn
= handler
;
4039 handler
= handleObjIn
.handler
;
4040 selector
= handleObjIn
.selector
;
4043 // Make sure that the handler has a unique ID, used to find/remove it later
4044 if ( !handler
.guid
) {
4045 handler
.guid
= jQuery
.guid
++;
4048 // Init the element's event structure and main handler, if this is the first
4049 if ( !(events
= elemData
.events
) ) {
4050 events
= elemData
.events
= {};
4052 if ( !(eventHandle
= elemData
.handle
) ) {
4053 eventHandle
= elemData
.handle = function( e
) {
4054 // Discard the second event of a jQuery.event.trigger() and
4055 // when an event is called after a page has unloaded
4056 return typeof jQuery
!== strundefined
&& jQuery
.event
.triggered
!== e
.type
?
4057 jQuery
.event
.dispatch
.apply( elem
, arguments
) : undefined;
4061 // Handle multiple events separated by a space
4062 types
= ( types
|| "" ).match( rnotwhite
) || [ "" ];
4065 tmp
= rtypenamespace
.exec( types
[t
] ) || [];
4066 type
= origType
= tmp
[1];
4067 namespaces
= ( tmp
[2] || "" ).split( "." ).sort();
4069 // There *must* be a type, no attaching namespace-only handlers
4074 // If event changes its type, use the special event handlers for the changed type
4075 special
= jQuery
.event
.special
[ type
] || {};
4077 // If selector defined, determine special event api type, otherwise given type
4078 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
4080 // Update special based on newly reset type
4081 special
= jQuery
.event
.special
[ type
] || {};
4083 // handleObj is passed to all event handlers
4084 handleObj
= jQuery
.extend({
4091 needsContext
: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
4092 namespace: namespaces
.join(".")
4095 // Init the event handler queue if we're the first
4096 if ( !(handlers
= events
[ type
]) ) {
4097 handlers
= events
[ type
] = [];
4098 handlers
.delegateCount
= 0;
4100 // Only use addEventListener if the special events handler returns false
4101 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
4102 if ( elem
.addEventListener
) {
4103 elem
.addEventListener( type
, eventHandle
, false );
4108 if ( special
.add
) {
4109 special
.add
.call( elem
, handleObj
);
4111 if ( !handleObj
.handler
.guid
) {
4112 handleObj
.handler
.guid
= handler
.guid
;
4116 // Add to the element's handler list, delegates in front
4118 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
4120 handlers
.push( handleObj
);
4123 // Keep track of which events have ever been used, for event optimization
4124 jQuery
.event
.global
[ type
] = true;
4129 // Detach an event or set of events from an element
4130 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
4132 var j
, origCount
, tmp
,
4133 events
, t
, handleObj
,
4134 special
, handlers
, type
, namespaces
, origType
,
4135 elemData
= data_priv
.hasData( elem
) && data_priv
.get( elem
);
4137 if ( !elemData
|| !(events
= elemData
.events
) ) {
4141 // Once for each type.namespace in types; type may be omitted
4142 types
= ( types
|| "" ).match( rnotwhite
) || [ "" ];
4145 tmp
= rtypenamespace
.exec( types
[t
] ) || [];
4146 type
= origType
= tmp
[1];
4147 namespaces
= ( tmp
[2] || "" ).split( "." ).sort();
4149 // Unbind all events (on this namespace, if provided) for the element
4151 for ( type
in events
) {
4152 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
4157 special
= jQuery
.event
.special
[ type
] || {};
4158 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
4159 handlers
= events
[ type
] || [];
4160 tmp
= tmp
[2] && new RegExp( "(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4162 // Remove matching events
4163 origCount
= j
= handlers
.length
;
4165 handleObj
= handlers
[ j
];
4167 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
4168 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
4169 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
4170 ( !selector
|| selector
=== handleObj
.selector
|| selector
=== "**" && handleObj
.selector
) ) {
4171 handlers
.splice( j
, 1 );
4173 if ( handleObj
.selector
) {
4174 handlers
.delegateCount
--;
4176 if ( special
.remove
) {
4177 special
.remove
.call( elem
, handleObj
);
4182 // Remove generic event handler if we removed something and no more handlers exist
4183 // (avoids potential for endless recursion during removal of special event handlers)
4184 if ( origCount
&& !handlers
.length
) {
4185 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
4186 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
4189 delete events
[ type
];
4193 // Remove the expando if it's no longer used
4194 if ( jQuery
.isEmptyObject( events
) ) {
4195 delete elemData
.handle
;
4196 data_priv
.remove( elem
, "events" );
4200 trigger: function( event
, data
, elem
, onlyHandlers
) {
4202 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
,
4203 eventPath
= [ elem
|| document
],
4204 type
= hasOwn
.call( event
, "type" ) ? event
.type
: event
,
4205 namespaces
= hasOwn
.call( event
, "namespace" ) ? event
.namespace.split(".") : [];
4207 cur
= tmp
= elem
= elem
|| document
;
4209 // Don't do events on text and comment nodes
4210 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
4214 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4215 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
4219 if ( type
.indexOf(".") >= 0 ) {
4220 // Namespaced trigger; create a regexp to match event type in handle()
4221 namespaces
= type
.split(".");
4222 type
= namespaces
.shift();
4225 ontype
= type
.indexOf(":") < 0 && "on" + type
;
4227 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4228 event
= event
[ jQuery
.expando
] ?
4230 new jQuery
.Event( type
, typeof event
=== "object" && event
);
4232 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4233 event
.isTrigger
= onlyHandlers
? 2 : 3;
4234 event
.namespace = namespaces
.join(".");
4235 event
.namespace_re
= event
.namespace ?
4236 new RegExp( "(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4239 // Clean up the event in case it is being reused
4240 event
.result
= undefined;
4241 if ( !event
.target
) {
4242 event
.target
= elem
;
4245 // Clone any incoming data and prepend the event, creating the handler arg list
4246 data
= data
== null ?
4248 jQuery
.makeArray( data
, [ event
] );
4250 // Allow special events to draw outside the lines
4251 special
= jQuery
.event
.special
[ type
] || {};
4252 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
4256 // Determine event propagation path in advance, per W3C events spec (#9951)
4257 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4258 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
4260 bubbleType
= special
.delegateType
|| type
;
4261 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
4262 cur
= cur
.parentNode
;
4264 for ( ; cur
; cur
= cur
.parentNode
) {
4265 eventPath
.push( cur
);
4269 // Only add window if we got to document (e.g., not plain obj or detached DOM)
4270 if ( tmp
=== (elem
.ownerDocument
|| document
) ) {
4271 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
4275 // Fire handlers on the event path
4277 while ( (cur
= eventPath
[i
++]) && !event
.isPropagationStopped() ) {
4279 event
.type
= i
> 1 ?
4281 special
.bindType
|| type
;
4284 handle
= ( data_priv
.get( cur
, "events" ) || {} )[ event
.type
] && data_priv
.get( cur
, "handle" );
4286 handle
.apply( cur
, data
);
4290 handle
= ontype
&& cur
[ ontype
];
4291 if ( handle
&& handle
.apply
&& jQuery
.acceptData( cur
) ) {
4292 event
.result
= handle
.apply( cur
, data
);
4293 if ( event
.result
=== false ) {
4294 event
.preventDefault();
4300 // If nobody prevented the default action, do it now
4301 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
4303 if ( (!special
._default
|| special
._default
.apply( eventPath
.pop(), data
) === false) &&
4304 jQuery
.acceptData( elem
) ) {
4306 // Call a native DOM method on the target with the same name name as the event.
4307 // Don't do default actions on window, that's where global variables be (#6170)
4308 if ( ontype
&& jQuery
.isFunction( elem
[ type
] ) && !jQuery
.isWindow( elem
) ) {
4310 // Don't re-trigger an onFOO event when we call its FOO() method
4311 tmp
= elem
[ ontype
];
4314 elem
[ ontype
] = null;
4317 // Prevent re-triggering of the same event, since we already bubbled it above
4318 jQuery
.event
.triggered
= type
;
4320 jQuery
.event
.triggered
= undefined;
4323 elem
[ ontype
] = tmp
;
4329 return event
.result
;
4332 dispatch: function( event
) {
4334 // Make a writable jQuery.Event from the native event object
4335 event
= jQuery
.event
.fix( event
);
4337 var i
, j
, ret
, matched
, handleObj
,
4339 args
= slice
.call( arguments
),
4340 handlers
= ( data_priv
.get( this, "events" ) || {} )[ event
.type
] || [],
4341 special
= jQuery
.event
.special
[ event
.type
] || {};
4343 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4345 event
.delegateTarget
= this;
4347 // Call the preDispatch hook for the mapped type, and let it bail if desired
4348 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
4352 // Determine handlers
4353 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
4355 // Run delegates first; they may want to stop propagation beneath us
4357 while ( (matched
= handlerQueue
[ i
++ ]) && !event
.isPropagationStopped() ) {
4358 event
.currentTarget
= matched
.elem
;
4361 while ( (handleObj
= matched
.handlers
[ j
++ ]) && !event
.isImmediatePropagationStopped() ) {
4363 // Triggered event must either 1) have no namespace, or
4364 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
4365 if ( !event
.namespace_re
|| event
.namespace_re
.test( handleObj
.namespace ) ) {
4367 event
.handleObj
= handleObj
;
4368 event
.data
= handleObj
.data
;
4370 ret
= ( (jQuery
.event
.special
[ handleObj
.origType
] || {}).handle
|| handleObj
.handler
)
4371 .apply( matched
.elem
, args
);
4373 if ( ret
!== undefined ) {
4374 if ( (event
.result
= ret
) === false ) {
4375 event
.preventDefault();
4376 event
.stopPropagation();
4383 // Call the postDispatch hook for the mapped type
4384 if ( special
.postDispatch
) {
4385 special
.postDispatch
.call( this, event
);
4388 return event
.result
;
4391 handlers: function( event
, handlers
) {
4392 var i
, matches
, sel
, handleObj
,
4394 delegateCount
= handlers
.delegateCount
,
4397 // Find delegate handlers
4398 // Black-hole SVG <use> instance trees (#13180)
4399 // Avoid non-left-click bubbling in Firefox (#3861)
4400 if ( delegateCount
&& cur
.nodeType
&& (!event
.button
|| event
.type
!== "click") ) {
4402 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
4404 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4405 if ( cur
.disabled
!== true || event
.type
!== "click" ) {
4407 for ( i
= 0; i
< delegateCount
; i
++ ) {
4408 handleObj
= handlers
[ i
];
4410 // Don't conflict with Object.prototype properties (#13203)
4411 sel
= handleObj
.selector
+ " ";
4413 if ( matches
[ sel
] === undefined ) {
4414 matches
[ sel
] = handleObj
.needsContext
?
4415 jQuery( sel
, this ).index( cur
) >= 0 :
4416 jQuery
.find( sel
, this, null, [ cur
] ).length
;
4418 if ( matches
[ sel
] ) {
4419 matches
.push( handleObj
);
4422 if ( matches
.length
) {
4423 handlerQueue
.push({ elem
: cur
, handlers
: matches
});
4429 // Add the remaining (directly-bound) handlers
4430 if ( delegateCount
< handlers
.length
) {
4431 handlerQueue
.push({ elem
: this, handlers
: handlers
.slice( delegateCount
) });
4434 return handlerQueue
;
4437 // Includes some event props shared by KeyEvent and MouseEvent
4438 props
: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
4443 props
: "char charCode key keyCode".split(" "),
4444 filter: function( event
, original
) {
4446 // Add which for key events
4447 if ( event
.which
== null ) {
4448 event
.which
= original
.charCode
!= null ? original
.charCode
: original
.keyCode
;
4456 props
: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
4457 filter: function( event
, original
) {
4458 var eventDoc
, doc
, body
,
4459 button
= original
.button
;
4461 // Calculate pageX/Y if missing and clientX/Y available
4462 if ( event
.pageX
== null && original
.clientX
!= null ) {
4463 eventDoc
= event
.target
.ownerDocument
|| document
;
4464 doc
= eventDoc
.documentElement
;
4465 body
= eventDoc
.body
;
4467 event
.pageX
= original
.clientX
+ ( doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0 ) - ( doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0 );
4468 event
.pageY
= original
.clientY
+ ( doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0 ) - ( doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0 );
4471 // Add which for click: 1 === left; 2 === middle; 3 === right
4472 // Note: button is not normalized, so don't use it
4473 if ( !event
.which
&& button
!== undefined ) {
4474 event
.which
= ( button
& 1 ? 1 : ( button
& 2 ? 3 : ( button
& 4 ? 2 : 0 ) ) );
4481 fix: function( event
) {
4482 if ( event
[ jQuery
.expando
] ) {
4486 // Create a writable copy of the event object and normalize some properties
4489 originalEvent
= event
,
4490 fixHook
= this.fixHooks
[ type
];
4493 this.fixHooks
[ type
] = fixHook
=
4494 rmouseEvent
.test( type
) ? this.mouseHooks
:
4495 rkeyEvent
.test( type
) ? this.keyHooks
:
4498 copy
= fixHook
.props
? this.props
.concat( fixHook
.props
) : this.props
;
4500 event
= new jQuery
.Event( originalEvent
);
4505 event
[ prop
] = originalEvent
[ prop
];
4508 // Support: Cordova 2.5 (WebKit) (#13255)
4509 // All events should have a target; Cordova deviceready doesn't
4510 if ( !event
.target
) {
4511 event
.target
= document
;
4514 // Support: Safari 6.0+, Chrome < 28
4515 // Target should not be a text node (#504, #13143)
4516 if ( event
.target
.nodeType
=== 3 ) {
4517 event
.target
= event
.target
.parentNode
;
4520 return fixHook
.filter
? fixHook
.filter( event
, originalEvent
) : event
;
4525 // Prevent triggered image.load events from bubbling to window.load
4529 // Fire native event if possible so blur/focus sequence is correct
4530 trigger: function() {
4531 if ( this !== safeActiveElement() && this.focus
) {
4536 delegateType
: "focusin"
4539 trigger: function() {
4540 if ( this === safeActiveElement() && this.blur
) {
4545 delegateType
: "focusout"
4548 // For checkbox, fire native event so checked state will be right
4549 trigger: function() {
4550 if ( this.type
=== "checkbox" && this.click
&& jQuery
.nodeName( this, "input" ) ) {
4556 // For cross-browser consistency, don't fire native .click() on links
4557 _default: function( event
) {
4558 return jQuery
.nodeName( event
.target
, "a" );
4563 postDispatch: function( event
) {
4565 // Support: Firefox 20+
4566 // Firefox doesn't alert if the returnValue field is not set.
4567 if ( event
.result
!== undefined ) {
4568 event
.originalEvent
.returnValue
= event
.result
;
4574 simulate: function( type
, elem
, event
, bubble
) {
4575 // Piggyback on a donor event to simulate a different one.
4576 // Fake originalEvent to avoid donor's stopPropagation, but if the
4577 // simulated event prevents default then we do the same on the donor.
4578 var e
= jQuery
.extend(
4588 jQuery
.event
.trigger( e
, null, elem
);
4590 jQuery
.event
.dispatch
.call( elem
, e
);
4592 if ( e
.isDefaultPrevented() ) {
4593 event
.preventDefault();
4598 jQuery
.removeEvent = function( elem
, type
, handle
) {
4599 if ( elem
.removeEventListener
) {
4600 elem
.removeEventListener( type
, handle
, false );
4604 jQuery
.Event = function( src
, props
) {
4605 // Allow instantiation without the 'new' keyword
4606 if ( !(this instanceof jQuery
.Event
) ) {
4607 return new jQuery
.Event( src
, props
);
4611 if ( src
&& src
.type
) {
4612 this.originalEvent
= src
;
4613 this.type
= src
.type
;
4615 // Events bubbling up the document may have been marked as prevented
4616 // by a handler lower down the tree; reflect the correct value.
4617 this.isDefaultPrevented
= src
.defaultPrevented
||
4618 // Support: Android < 4.0
4619 src
.defaultPrevented
=== undefined &&
4620 src
.getPreventDefault
&& src
.getPreventDefault() ?
4629 // Put explicitly provided properties onto the event object
4631 jQuery
.extend( this, props
);
4634 // Create a timestamp if incoming event doesn't have one
4635 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
4638 this[ jQuery
.expando
] = true;
4641 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4642 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4643 jQuery
.Event
.prototype = {
4644 isDefaultPrevented
: returnFalse
,
4645 isPropagationStopped
: returnFalse
,
4646 isImmediatePropagationStopped
: returnFalse
,
4648 preventDefault: function() {
4649 var e
= this.originalEvent
;
4651 this.isDefaultPrevented
= returnTrue
;
4653 if ( e
&& e
.preventDefault
) {
4657 stopPropagation: function() {
4658 var e
= this.originalEvent
;
4660 this.isPropagationStopped
= returnTrue
;
4662 if ( e
&& e
.stopPropagation
) {
4663 e
.stopPropagation();
4666 stopImmediatePropagation: function() {
4667 this.isImmediatePropagationStopped
= returnTrue
;
4668 this.stopPropagation();
4672 // Create mouseenter/leave events using mouseover/out and event-time checks
4673 // Support: Chrome 15+
4675 mouseenter
: "mouseover",
4676 mouseleave
: "mouseout"
4677 }, function( orig
, fix
) {
4678 jQuery
.event
.special
[ orig
] = {
4682 handle: function( event
) {
4685 related
= event
.relatedTarget
,
4686 handleObj
= event
.handleObj
;
4688 // For mousenter/leave call the handler if related is outside the target.
4689 // NB: No relatedTarget if the mouse left/entered the browser window
4690 if ( !related
|| (related
!== target
&& !jQuery
.contains( target
, related
)) ) {
4691 event
.type
= handleObj
.origType
;
4692 ret
= handleObj
.handler
.apply( this, arguments
);
4700 // Create "bubbling" focus and blur events
4701 // Support: Firefox, Chrome, Safari
4702 if ( !support
.focusinBubbles
) {
4703 jQuery
.each({ focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
4705 // Attach a single capturing handler on the document while someone wants focusin/focusout
4706 var handler = function( event
) {
4707 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
), true );
4710 jQuery
.event
.special
[ fix
] = {
4712 var doc
= this.ownerDocument
|| this,
4713 attaches
= data_priv
.access( doc
, fix
);
4716 doc
.addEventListener( orig
, handler
, true );
4718 data_priv
.access( doc
, fix
, ( attaches
|| 0 ) + 1 );
4720 teardown: function() {
4721 var doc
= this.ownerDocument
|| this,
4722 attaches
= data_priv
.access( doc
, fix
) - 1;
4725 doc
.removeEventListener( orig
, handler
, true );
4726 data_priv
.remove( doc
, fix
);
4729 data_priv
.access( doc
, fix
, attaches
);
4738 on: function( types
, selector
, data
, fn
, /*INTERNAL*/ one
) {
4741 // Types can be a map of types/handlers
4742 if ( typeof types
=== "object" ) {
4743 // ( types-Object, selector, data )
4744 if ( typeof selector
!== "string" ) {
4745 // ( types-Object, data )
4746 data
= data
|| selector
;
4747 selector
= undefined;
4749 for ( type
in types
) {
4750 this.on( type
, selector
, data
, types
[ type
], one
);
4755 if ( data
== null && fn
== null ) {
4758 data
= selector
= undefined;
4759 } else if ( fn
== null ) {
4760 if ( typeof selector
=== "string" ) {
4761 // ( types, selector, fn )
4765 // ( types, data, fn )
4768 selector
= undefined;
4771 if ( fn
=== false ) {
4779 fn = function( event
) {
4780 // Can use an empty set, since event contains the info
4781 jQuery().off( event
);
4782 return origFn
.apply( this, arguments
);
4784 // Use same guid so caller can remove using origFn
4785 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
4787 return this.each( function() {
4788 jQuery
.event
.add( this, types
, fn
, data
, selector
);
4791 one: function( types
, selector
, data
, fn
) {
4792 return this.on( types
, selector
, data
, fn
, 1 );
4794 off: function( types
, selector
, fn
) {
4795 var handleObj
, type
;
4796 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
4797 // ( event ) dispatched jQuery.Event
4798 handleObj
= types
.handleObj
;
4799 jQuery( types
.delegateTarget
).off(
4800 handleObj
.namespace ? handleObj
.origType
+ "." + handleObj
.namespace : handleObj
.origType
,
4806 if ( typeof types
=== "object" ) {
4807 // ( types-object [, selector] )
4808 for ( type
in types
) {
4809 this.off( type
, selector
, types
[ type
] );
4813 if ( selector
=== false || typeof selector
=== "function" ) {
4816 selector
= undefined;
4818 if ( fn
=== false ) {
4821 return this.each(function() {
4822 jQuery
.event
.remove( this, types
, fn
, selector
);
4826 trigger: function( type
, data
) {
4827 return this.each(function() {
4828 jQuery
.event
.trigger( type
, data
, this );
4831 triggerHandler: function( type
, data
) {
4834 return jQuery
.event
.trigger( type
, data
, elem
, true );
4841 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
4842 rtagName
= /<([\w:]+)/,
4843 rhtml
= /<|&#?\w+;/,
4844 rnoInnerhtml
= /<(?:script|style|link)/i,
4845 // checked="checked" or checked
4846 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
4847 rscriptType
= /^$|\/(?:java|ecma)script/i,
4848 rscriptTypeMasked
= /^true\/(.*)/,
4849 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
4851 // We have to close these tags to support XHTML (#13200)
4855 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
4857 thead
: [ 1, "<table>", "</table>" ],
4858 col
: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4859 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
4860 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4862 _default
: [ 0, "", "" ]
4866 wrapMap
.optgroup
= wrapMap
.option
;
4868 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
4869 wrapMap
.th
= wrapMap
.td
;
4871 // Support: 1.x compatibility
4872 // Manipulating tables requires a tbody
4873 function manipulationTarget( elem
, content
) {
4874 return jQuery
.nodeName( elem
, "table" ) &&
4875 jQuery
.nodeName( content
.nodeType
!== 11 ? content
: content
.firstChild
, "tr" ) ?
4877 elem
.getElementsByTagName("tbody")[0] ||
4878 elem
.appendChild( elem
.ownerDocument
.createElement("tbody") ) :
4882 // Replace/restore the type attribute of script elements for safe DOM manipulation
4883 function disableScript( elem
) {
4884 elem
.type
= (elem
.getAttribute("type") !== null) + "/" + elem
.type
;
4887 function restoreScript( elem
) {
4888 var match
= rscriptTypeMasked
.exec( elem
.type
);
4891 elem
.type
= match
[ 1 ];
4893 elem
.removeAttribute("type");
4899 // Mark scripts as having already been evaluated
4900 function setGlobalEval( elems
, refElements
) {
4904 for ( ; i
< l
; i
++ ) {
4906 elems
[ i
], "globalEval", !refElements
|| data_priv
.get( refElements
[ i
], "globalEval" )
4911 function cloneCopyEvent( src
, dest
) {
4912 var i
, l
, type
, pdataOld
, pdataCur
, udataOld
, udataCur
, events
;
4914 if ( dest
.nodeType
!== 1 ) {
4918 // 1. Copy private data: events, handlers, etc.
4919 if ( data_priv
.hasData( src
) ) {
4920 pdataOld
= data_priv
.access( src
);
4921 pdataCur
= data_priv
.set( dest
, pdataOld
);
4922 events
= pdataOld
.events
;
4925 delete pdataCur
.handle
;
4926 pdataCur
.events
= {};
4928 for ( type
in events
) {
4929 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
4930 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
4936 // 2. Copy user data
4937 if ( data_user
.hasData( src
) ) {
4938 udataOld
= data_user
.access( src
);
4939 udataCur
= jQuery
.extend( {}, udataOld
);
4941 data_user
.set( dest
, udataCur
);
4945 function getAll( context
, tag
) {
4946 var ret
= context
.getElementsByTagName
? context
.getElementsByTagName( tag
|| "*" ) :
4947 context
.querySelectorAll
? context
.querySelectorAll( tag
|| "*" ) :
4950 return tag
=== undefined || tag
&& jQuery
.nodeName( context
, tag
) ?
4951 jQuery
.merge( [ context
], ret
) :
4956 function fixInput( src
, dest
) {
4957 var nodeName
= dest
.nodeName
.toLowerCase();
4959 // Fails to persist the checked state of a cloned checkbox or radio button.
4960 if ( nodeName
=== "input" && rcheckableType
.test( src
.type
) ) {
4961 dest
.checked
= src
.checked
;
4963 // Fails to return the selected option to the default selected state when cloning options
4964 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
4965 dest
.defaultValue
= src
.defaultValue
;
4970 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
4971 var i
, l
, srcElements
, destElements
,
4972 clone
= elem
.cloneNode( true ),
4973 inPage
= jQuery
.contains( elem
.ownerDocument
, elem
);
4976 // Fix Cloning issues
4977 if ( !support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) &&
4978 !jQuery
.isXMLDoc( elem
) ) {
4980 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
4981 destElements
= getAll( clone
);
4982 srcElements
= getAll( elem
);
4984 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
4985 fixInput( srcElements
[ i
], destElements
[ i
] );
4989 // Copy the events from the original to the clone
4990 if ( dataAndEvents
) {
4991 if ( deepDataAndEvents
) {
4992 srcElements
= srcElements
|| getAll( elem
);
4993 destElements
= destElements
|| getAll( clone
);
4995 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
4996 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
4999 cloneCopyEvent( elem
, clone
);
5003 // Preserve script evaluation history
5004 destElements
= getAll( clone
, "script" );
5005 if ( destElements
.length
> 0 ) {
5006 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
5009 // Return the cloned set
5013 buildFragment: function( elems
, context
, scripts
, selection
) {
5014 var elem
, tmp
, tag
, wrap
, contains
, j
,
5015 fragment
= context
.createDocumentFragment(),
5020 for ( ; i
< l
; i
++ ) {
5023 if ( elem
|| elem
=== 0 ) {
5025 // Add nodes directly
5026 if ( jQuery
.type( elem
) === "object" ) {
5027 // Support: QtWebKit
5028 // jQuery.merge because push.apply(_, arraylike) throws
5029 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
5031 // Convert non-html into a text node
5032 } else if ( !rhtml
.test( elem
) ) {
5033 nodes
.push( context
.createTextNode( elem
) );
5035 // Convert html into DOM nodes
5037 tmp
= tmp
|| fragment
.appendChild( context
.createElement("div") );
5039 // Deserialize a standard representation
5040 tag
= ( rtagName
.exec( elem
) || [ "", "" ] )[ 1 ].toLowerCase();
5041 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
5042 tmp
.innerHTML
= wrap
[ 1 ] + elem
.replace( rxhtmlTag
, "<$1></$2>" ) + wrap
[ 2 ];
5044 // Descend through wrappers to the right content
5047 tmp
= tmp
.lastChild
;
5050 // Support: QtWebKit
5051 // jQuery.merge because push.apply(_, arraylike) throws
5052 jQuery
.merge( nodes
, tmp
.childNodes
);
5054 // Remember the top-level container
5055 tmp
= fragment
.firstChild
;
5058 // Support: Webkit, IE
5059 tmp
.textContent
= "";
5064 // Remove wrapper from fragment
5065 fragment
.textContent
= "";
5068 while ( (elem
= nodes
[ i
++ ]) ) {
5070 // #4087 - If origin and destination elements are the same, and this is
5071 // that element, do not do anything
5072 if ( selection
&& jQuery
.inArray( elem
, selection
) !== -1 ) {
5076 contains
= jQuery
.contains( elem
.ownerDocument
, elem
);
5078 // Append to fragment
5079 tmp
= getAll( fragment
.appendChild( elem
), "script" );
5081 // Preserve script evaluation history
5083 setGlobalEval( tmp
);
5086 // Capture executables
5089 while ( (elem
= tmp
[ j
++ ]) ) {
5090 if ( rscriptType
.test( elem
.type
|| "" ) ) {
5091 scripts
.push( elem
);
5100 cleanData: function( elems
) {
5101 var data
, elem
, events
, type
, key
, j
,
5102 special
= jQuery
.event
.special
,
5105 for ( ; (elem
= elems
[ i
]) !== undefined; i
++ ) {
5106 if ( jQuery
.acceptData( elem
) ) {
5107 key
= elem
[ data_priv
.expando
];
5109 if ( key
&& (data
= data_priv
.cache
[ key
]) ) {
5110 events
= Object
.keys( data
.events
|| {} );
5111 if ( events
.length
) {
5112 for ( j
= 0; (type
= events
[j
]) !== undefined; j
++ ) {
5113 if ( special
[ type
] ) {
5114 jQuery
.event
.remove( elem
, type
);
5116 // This is a shortcut to avoid jQuery.event.remove's overhead
5118 jQuery
.removeEvent( elem
, type
, data
.handle
);
5122 if ( data_priv
.cache
[ key
] ) {
5123 // Discard any remaining `private` data
5124 delete data_priv
.cache
[ key
];
5128 // Discard any remaining `user` data
5129 delete data_user
.cache
[ elem
[ data_user
.expando
] ];
5135 text: function( value
) {
5136 return access( this, function( value
) {
5137 return value
=== undefined ?
5138 jQuery
.text( this ) :
5139 this.empty().each(function() {
5140 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5141 this.textContent
= value
;
5144 }, null, value
, arguments
.length
);
5147 append: function() {
5148 return this.domManip( arguments
, function( elem
) {
5149 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5150 var target
= manipulationTarget( this, elem
);
5151 target
.appendChild( elem
);
5156 prepend: function() {
5157 return this.domManip( arguments
, function( elem
) {
5158 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5159 var target
= manipulationTarget( this, elem
);
5160 target
.insertBefore( elem
, target
.firstChild
);
5165 before: function() {
5166 return this.domManip( arguments
, function( elem
) {
5167 if ( this.parentNode
) {
5168 this.parentNode
.insertBefore( elem
, this );
5174 return this.domManip( arguments
, function( elem
) {
5175 if ( this.parentNode
) {
5176 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5181 remove: function( selector
, keepData
/* Internal Use Only */ ) {
5183 elems
= selector
? jQuery
.filter( selector
, this ) : this,
5186 for ( ; (elem
= elems
[i
]) != null; i
++ ) {
5187 if ( !keepData
&& elem
.nodeType
=== 1 ) {
5188 jQuery
.cleanData( getAll( elem
) );
5191 if ( elem
.parentNode
) {
5192 if ( keepData
&& jQuery
.contains( elem
.ownerDocument
, elem
) ) {
5193 setGlobalEval( getAll( elem
, "script" ) );
5195 elem
.parentNode
.removeChild( elem
);
5206 for ( ; (elem
= this[i
]) != null; i
++ ) {
5207 if ( elem
.nodeType
=== 1 ) {
5209 // Prevent memory leaks
5210 jQuery
.cleanData( getAll( elem
, false ) );
5212 // Remove any remaining nodes
5213 elem
.textContent
= "";
5220 clone: function( dataAndEvents
, deepDataAndEvents
) {
5221 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5222 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents
: deepDataAndEvents
;
5224 return this.map(function() {
5225 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5229 html: function( value
) {
5230 return access( this, function( value
) {
5231 var elem
= this[ 0 ] || {},
5235 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
5236 return elem
.innerHTML
;
5239 // See if we can take a shortcut and just use innerHTML
5240 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5241 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5243 value
= value
.replace( rxhtmlTag
, "<$1></$2>" );
5246 for ( ; i
< l
; i
++ ) {
5247 elem
= this[ i
] || {};
5249 // Remove element nodes and prevent memory leaks
5250 if ( elem
.nodeType
=== 1 ) {
5251 jQuery
.cleanData( getAll( elem
, false ) );
5252 elem
.innerHTML
= value
;
5258 // If using innerHTML throws an exception, use the fallback method
5263 this.empty().append( value
);
5265 }, null, value
, arguments
.length
);
5268 replaceWith: function() {
5269 var arg
= arguments
[ 0 ];
5271 // Make the changes, replacing each context element with the new content
5272 this.domManip( arguments
, function( elem
) {
5273 arg
= this.parentNode
;
5275 jQuery
.cleanData( getAll( this ) );
5278 arg
.replaceChild( elem
, this );
5282 // Force removal if there was no new content (e.g., from empty arguments)
5283 return arg
&& (arg
.length
|| arg
.nodeType
) ? this : this.remove();
5286 detach: function( selector
) {
5287 return this.remove( selector
, true );
5290 domManip: function( args
, callback
) {
5292 // Flatten any nested arrays
5293 args
= concat
.apply( [], args
);
5295 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
5301 isFunction
= jQuery
.isFunction( value
);
5303 // We can't cloneNode fragments that contain checked, in WebKit
5305 ( l
> 1 && typeof value
=== "string" &&
5306 !support
.checkClone
&& rchecked
.test( value
) ) ) {
5307 return this.each(function( index
) {
5308 var self
= set.eq( index
);
5310 args
[ 0 ] = value
.call( this, index
, self
.html() );
5312 self
.domManip( args
, callback
);
5317 fragment
= jQuery
.buildFragment( args
, this[ 0 ].ownerDocument
, false, this );
5318 first
= fragment
.firstChild
;
5320 if ( fragment
.childNodes
.length
=== 1 ) {
5325 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
5326 hasScripts
= scripts
.length
;
5328 // Use the original fragment for the last item instead of the first because it can end up
5329 // being emptied incorrectly in certain situations (#8070).
5330 for ( ; i
< l
; i
++ ) {
5333 if ( i
!== iNoClone
) {
5334 node
= jQuery
.clone( node
, true, true );
5336 // Keep references to cloned scripts for later restoration
5338 // Support: QtWebKit
5339 // jQuery.merge because push.apply(_, arraylike) throws
5340 jQuery
.merge( scripts
, getAll( node
, "script" ) );
5344 callback
.call( this[ i
], node
, i
);
5348 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
5351 jQuery
.map( scripts
, restoreScript
);
5353 // Evaluate executable scripts on first document insertion
5354 for ( i
= 0; i
< hasScripts
; i
++ ) {
5355 node
= scripts
[ i
];
5356 if ( rscriptType
.test( node
.type
|| "" ) &&
5357 !data_priv
.access( node
, "globalEval" ) && jQuery
.contains( doc
, node
) ) {
5360 // Optional AJAX dependency, but won't run scripts if not present
5361 if ( jQuery
._evalUrl
) {
5362 jQuery
._evalUrl( node
.src
);
5365 jQuery
.globalEval( node
.textContent
.replace( rcleanScript
, "" ) );
5379 prependTo
: "prepend",
5380 insertBefore
: "before",
5381 insertAfter
: "after",
5382 replaceAll
: "replaceWith"
5383 }, function( name
, original
) {
5384 jQuery
.fn
[ name
] = function( selector
) {
5387 insert
= jQuery( selector
),
5388 last
= insert
.length
- 1,
5391 for ( ; i
<= last
; i
++ ) {
5392 elems
= i
=== last
? this : this.clone( true );
5393 jQuery( insert
[ i
] )[ original
]( elems
);
5395 // Support: QtWebKit
5396 // .get() because push.apply(_, arraylike) throws
5397 push
.apply( ret
, elems
.get() );
5400 return this.pushStack( ret
);
5409 * Retrieve the actual display of a element
5410 * @param {String} name nodeName of the element
5411 * @param {Object} doc Document object
5413 // Called only from within defaultDisplay
5414 function actualDisplay( name
, doc
) {
5415 var elem
= jQuery( doc
.createElement( name
) ).appendTo( doc
.body
),
5417 // getDefaultComputedStyle might be reliably used only on attached element
5418 display
= window
.getDefaultComputedStyle
?
5420 // Use of this method is a temporary fix (more like optmization) until something better comes along,
5421 // since it was removed from specification and supported only in FF
5422 window
.getDefaultComputedStyle( elem
[ 0 ] ).display
: jQuery
.css( elem
[ 0 ], "display" );
5424 // We don't have any data stored on the element,
5425 // so use "detach" method as fast way to get rid of the element
5432 * Try to determine the default display value of an element
5433 * @param {String} nodeName
5435 function defaultDisplay( nodeName
) {
5437 display
= elemdisplay
[ nodeName
];
5440 display
= actualDisplay( nodeName
, doc
);
5442 // If the simple way fails, read from inside an iframe
5443 if ( display
=== "none" || !display
) {
5445 // Use the already-created iframe if possible
5446 iframe
= (iframe
|| jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc
.documentElement
);
5448 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
5449 doc
= iframe
[ 0 ].contentDocument
;
5455 display
= actualDisplay( nodeName
, doc
);
5459 // Store the correct default display
5460 elemdisplay
[ nodeName
] = display
;
5465 var rmargin
= (/^margin/);
5467 var rnumnonpx
= new RegExp( "^(" + pnum
+ ")(?!px)[a-z%]+$", "i" );
5469 var getStyles = function( elem
) {
5470 return elem
.ownerDocument
.defaultView
.getComputedStyle( elem
, null );
5475 function curCSS( elem
, name
, computed
) {
5476 var width
, minWidth
, maxWidth
, ret
,
5479 computed
= computed
|| getStyles( elem
);
5482 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
5484 ret
= computed
.getPropertyValue( name
) || computed
[ name
];
5489 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
, elem
) ) {
5490 ret
= jQuery
.style( elem
, name
);
5494 // A tribute to the "awesome hack by Dean Edwards"
5495 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
5496 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
5497 if ( rnumnonpx
.test( ret
) && rmargin
.test( name
) ) {
5499 // Remember the original values
5500 width
= style
.width
;
5501 minWidth
= style
.minWidth
;
5502 maxWidth
= style
.maxWidth
;
5504 // Put in the new values to get a computed value out
5505 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
5506 ret
= computed
.width
;
5508 // Revert the changed values
5509 style
.width
= width
;
5510 style
.minWidth
= minWidth
;
5511 style
.maxWidth
= maxWidth
;
5515 return ret
!== undefined ?
5517 // IE returns zIndex value as an integer.
5523 function addGetHookIf( conditionFn
, hookFn
) {
5524 // Define the hook, we'll check on the first run if it's really needed.
5527 if ( conditionFn() ) {
5528 // Hook not needed (or it's not possible to use it due to missing dependency),
5530 // Since there are no other hooks for marginRight, remove the whole object.
5535 // Hook needed; redefine it so that the support test is not executed again.
5537 return (this.get = hookFn
).apply( this, arguments
);
5544 var pixelPositionVal
, boxSizingReliableVal
,
5545 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
5546 divReset
= "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" +
5547 "-moz-box-sizing:content-box;box-sizing:content-box",
5548 docElem
= document
.documentElement
,
5549 container
= document
.createElement( "div" ),
5550 div
= document
.createElement( "div" );
5552 div
.style
.backgroundClip
= "content-box";
5553 div
.cloneNode( true ).style
.backgroundClip
= "";
5554 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
5556 container
.style
.cssText
= "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" +
5558 container
.appendChild( div
);
5560 // Executing both pixelPosition & boxSizingReliable tests require only one layout
5561 // so they're executed at the same time to save the second computation.
5562 function computePixelPositionAndBoxSizingReliable() {
5563 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
5564 div
.style
.cssText
= "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
5565 "box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" +
5566 "position:absolute;top:1%";
5567 docElem
.appendChild( container
);
5569 var divStyle
= window
.getComputedStyle( div
, null );
5570 pixelPositionVal
= divStyle
.top
!== "1%";
5571 boxSizingReliableVal
= divStyle
.width
=== "4px";
5573 docElem
.removeChild( container
);
5576 // Use window.getComputedStyle because jsdom on node.js will break without it.
5577 if ( window
.getComputedStyle
) {
5578 jQuery
.extend(support
, {
5579 pixelPosition: function() {
5580 // This test is executed only once but we still do memoizing
5581 // since we can use the boxSizingReliable pre-computing.
5582 // No need to check if the test was already performed, though.
5583 computePixelPositionAndBoxSizingReliable();
5584 return pixelPositionVal
;
5586 boxSizingReliable: function() {
5587 if ( boxSizingReliableVal
== null ) {
5588 computePixelPositionAndBoxSizingReliable();
5590 return boxSizingReliableVal
;
5592 reliableMarginRight: function() {
5593 // Support: Android 2.3
5594 // Check if div with explicit width and no margin-right incorrectly
5595 // gets computed margin-right based on width of container. (#3333)
5596 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
5597 // This support function is only executed once so no memoizing is needed.
5599 marginDiv
= div
.appendChild( document
.createElement( "div" ) );
5600 marginDiv
.style
.cssText
= div
.style
.cssText
= divReset
;
5601 marginDiv
.style
.marginRight
= marginDiv
.style
.width
= "0";
5602 div
.style
.width
= "1px";
5603 docElem
.appendChild( container
);
5605 ret
= !parseFloat( window
.getComputedStyle( marginDiv
, null ).marginRight
);
5607 docElem
.removeChild( container
);
5609 // Clean up the div for other support tests.
5619 // A method for quickly swapping in/out CSS properties to get correct calculations.
5620 jQuery
.swap = function( elem
, options
, callback
, args
) {
5624 // Remember the old values, and insert the new ones
5625 for ( name
in options
) {
5626 old
[ name
] = elem
.style
[ name
];
5627 elem
.style
[ name
] = options
[ name
];
5630 ret
= callback
.apply( elem
, args
|| [] );
5632 // Revert the old values
5633 for ( name
in options
) {
5634 elem
.style
[ name
] = old
[ name
];
5642 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
5643 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
5644 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
5645 rnumsplit
= new RegExp( "^(" + pnum
+ ")(.*)$", "i" ),
5646 rrelNum
= new RegExp( "^([+-])=(" + pnum
+ ")", "i" ),
5648 cssShow
= { position
: "absolute", visibility
: "hidden", display
: "block" },
5649 cssNormalTransform
= {
5654 cssPrefixes
= [ "Webkit", "O", "Moz", "ms" ];
5656 // return a css property mapped to a potentially vendor prefixed property
5657 function vendorPropName( style
, name
) {
5659 // shortcut for names that are not vendor prefixed
5660 if ( name
in style
) {
5664 // check for vendor prefixed names
5665 var capName
= name
[0].toUpperCase() + name
.slice(1),
5667 i
= cssPrefixes
.length
;
5670 name
= cssPrefixes
[ i
] + capName
;
5671 if ( name
in style
) {
5679 function setPositiveNumber( elem
, value
, subtract
) {
5680 var matches
= rnumsplit
.exec( value
);
5682 // Guard against undefined "subtract", e.g., when used as in cssHooks
5683 Math
.max( 0, matches
[ 1 ] - ( subtract
|| 0 ) ) + ( matches
[ 2 ] || "px" ) :
5687 function augmentWidthOrHeight( elem
, name
, extra
, isBorderBox
, styles
) {
5688 var i
= extra
=== ( isBorderBox
? "border" : "content" ) ?
5689 // If we already have the right measurement, avoid augmentation
5691 // Otherwise initialize for horizontal or vertical properties
5692 name
=== "width" ? 1 : 0,
5696 for ( ; i
< 4; i
+= 2 ) {
5697 // both box models exclude margin, so add it if we want it
5698 if ( extra
=== "margin" ) {
5699 val
+= jQuery
.css( elem
, extra
+ cssExpand
[ i
], true, styles
);
5702 if ( isBorderBox
) {
5703 // border-box includes padding, so remove it if we want content
5704 if ( extra
=== "content" ) {
5705 val
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
5708 // at this point, extra isn't border nor margin, so remove border
5709 if ( extra
!== "margin" ) {
5710 val
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
5713 // at this point, extra isn't content, so add padding
5714 val
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
5716 // at this point, extra isn't content nor padding, so add border
5717 if ( extra
!== "padding" ) {
5718 val
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
5726 function getWidthOrHeight( elem
, name
, extra
) {
5728 // Start with offset property, which is equivalent to the border-box value
5729 var valueIsBorderBox
= true,
5730 val
= name
=== "width" ? elem
.offsetWidth
: elem
.offsetHeight
,
5731 styles
= getStyles( elem
),
5732 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box";
5734 // some non-html elements return undefined for offsetWidth, so check for null/undefined
5735 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
5736 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
5737 if ( val
<= 0 || val
== null ) {
5738 // Fall back to computed then uncomputed css if necessary
5739 val
= curCSS( elem
, name
, styles
);
5740 if ( val
< 0 || val
== null ) {
5741 val
= elem
.style
[ name
];
5744 // Computed unit is not pixels. Stop here and return.
5745 if ( rnumnonpx
.test(val
) ) {
5749 // we need the check for style in case a browser which returns unreliable values
5750 // for getComputedStyle silently falls back to the reliable elem.style
5751 valueIsBorderBox
= isBorderBox
&&
5752 ( support
.boxSizingReliable() || val
=== elem
.style
[ name
] );
5754 // Normalize "", auto, and prepare for extra
5755 val
= parseFloat( val
) || 0;
5758 // use the active box-sizing model to add/subtract irrelevant styles
5760 augmentWidthOrHeight(
5763 extra
|| ( isBorderBox
? "border" : "content" ),
5770 function showHide( elements
, show
) {
5771 var display
, elem
, hidden
,
5774 length
= elements
.length
;
5776 for ( ; index
< length
; index
++ ) {
5777 elem
= elements
[ index
];
5778 if ( !elem
.style
) {
5782 values
[ index
] = data_priv
.get( elem
, "olddisplay" );
5783 display
= elem
.style
.display
;
5785 // Reset the inline display of this element to learn if it is
5786 // being hidden by cascaded rules or not
5787 if ( !values
[ index
] && display
=== "none" ) {
5788 elem
.style
.display
= "";
5791 // Set elements which have been overridden with display: none
5792 // in a stylesheet to whatever the default browser style is
5793 // for such an element
5794 if ( elem
.style
.display
=== "" && isHidden( elem
) ) {
5795 values
[ index
] = data_priv
.access( elem
, "olddisplay", defaultDisplay(elem
.nodeName
) );
5799 if ( !values
[ index
] ) {
5800 hidden
= isHidden( elem
);
5802 if ( display
&& display
!== "none" || !hidden
) {
5803 data_priv
.set( elem
, "olddisplay", hidden
? display
: jQuery
.css(elem
, "display") );
5809 // Set the display of most of the elements in a second loop
5810 // to avoid the constant reflow
5811 for ( index
= 0; index
< length
; index
++ ) {
5812 elem
= elements
[ index
];
5813 if ( !elem
.style
) {
5816 if ( !show
|| elem
.style
.display
=== "none" || elem
.style
.display
=== "" ) {
5817 elem
.style
.display
= show
? values
[ index
] || "" : "none";
5825 // Add in style property hooks for overriding the default
5826 // behavior of getting and setting a style property
5829 get: function( elem
, computed
) {
5831 // We should always get a number back from opacity
5832 var ret
= curCSS( elem
, "opacity" );
5833 return ret
=== "" ? "1" : ret
;
5839 // Don't automatically add "px" to these possibly-unitless properties
5841 "columnCount": true,
5842 "fillOpacity": true,
5853 // Add in properties whose names you wish to fix before
5854 // setting or getting the value
5856 // normalize float css property
5860 // Get and set the style property on a DOM Node
5861 style: function( elem
, name
, value
, extra
) {
5862 // Don't set styles on text and comment nodes
5863 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
5867 // Make sure that we're working with the right name
5868 var ret
, type
, hooks
,
5869 origName
= jQuery
.camelCase( name
),
5872 name
= jQuery
.cssProps
[ origName
] || ( jQuery
.cssProps
[ origName
] = vendorPropName( style
, origName
) );
5874 // gets hook for the prefixed version
5875 // followed by the unprefixed version
5876 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
5878 // Check if we're setting a value
5879 if ( value
!== undefined ) {
5880 type
= typeof value
;
5882 // convert relative number strings (+= or -=) to relative numbers. #7345
5883 if ( type
=== "string" && (ret
= rrelNum
.exec( value
)) ) {
5884 value
= ( ret
[1] + 1 ) * ret
[2] + parseFloat( jQuery
.css( elem
, name
) );
5889 // Make sure that null and NaN values aren't set. See: #7116
5890 if ( value
== null || value
!== value
) {
5894 // If a number was passed in, add 'px' to the (except for certain CSS properties)
5895 if ( type
=== "number" && !jQuery
.cssNumber
[ origName
] ) {
5899 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
5900 // but it would mean to define eight (for every problematic property) identical functions
5901 if ( !support
.clearCloneStyle
&& value
=== "" && name
.indexOf( "background" ) === 0 ) {
5902 style
[ name
] = "inherit";
5905 // If a hook was provided, use that value, otherwise just set the specified value
5906 if ( !hooks
|| !("set" in hooks
) || (value
= hooks
.set( elem
, value
, extra
)) !== undefined ) {
5907 // Support: Chrome, Safari
5908 // Setting style to blank string required to delete "style: x !important;"
5910 style
[ name
] = value
;
5914 // If a hook was provided get the non-computed value from there
5915 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, false, extra
)) !== undefined ) {
5919 // Otherwise just get the value from the style object
5920 return style
[ name
];
5924 css: function( elem
, name
, extra
, styles
) {
5925 var val
, num
, hooks
,
5926 origName
= jQuery
.camelCase( name
);
5928 // Make sure that we're working with the right name
5929 name
= jQuery
.cssProps
[ origName
] || ( jQuery
.cssProps
[ origName
] = vendorPropName( elem
.style
, origName
) );
5931 // gets hook for the prefixed version
5932 // followed by the unprefixed version
5933 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
5935 // If a hook was provided get the computed value from there
5936 if ( hooks
&& "get" in hooks
) {
5937 val
= hooks
.get( elem
, true, extra
);
5940 // Otherwise, if a way to get the computed value exists, use that
5941 if ( val
=== undefined ) {
5942 val
= curCSS( elem
, name
, styles
);
5945 //convert "normal" to computed value
5946 if ( val
=== "normal" && name
in cssNormalTransform
) {
5947 val
= cssNormalTransform
[ name
];
5950 // Return, converting to number if forced or a qualifier was provided and val looks numeric
5951 if ( extra
=== "" || extra
) {
5952 num
= parseFloat( val
);
5953 return extra
=== true || jQuery
.isNumeric( num
) ? num
|| 0 : val
;
5959 jQuery
.each([ "height", "width" ], function( i
, name
) {
5960 jQuery
.cssHooks
[ name
] = {
5961 get: function( elem
, computed
, extra
) {
5963 // certain elements can have dimension info if we invisibly show them
5964 // however, it must have a current display style that would benefit from this
5965 return elem
.offsetWidth
=== 0 && rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) ?
5966 jQuery
.swap( elem
, cssShow
, function() {
5967 return getWidthOrHeight( elem
, name
, extra
);
5969 getWidthOrHeight( elem
, name
, extra
);
5973 set: function( elem
, value
, extra
) {
5974 var styles
= extra
&& getStyles( elem
);
5975 return setPositiveNumber( elem
, value
, extra
?
5976 augmentWidthOrHeight(
5980 jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
5988 // Support: Android 2.3
5989 jQuery
.cssHooks
.marginRight
= addGetHookIf( support
.reliableMarginRight
,
5990 function( elem
, computed
) {
5992 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
5993 // Work around by temporarily setting element display to inline-block
5994 return jQuery
.swap( elem
, { "display": "inline-block" },
5995 curCSS
, [ elem
, "marginRight" ] );
6000 // These hooks are used by animate to expand properties
6005 }, function( prefix
, suffix
) {
6006 jQuery
.cssHooks
[ prefix
+ suffix
] = {
6007 expand: function( value
) {
6011 // assumes a single number if not a string
6012 parts
= typeof value
=== "string" ? value
.split(" ") : [ value
];
6014 for ( ; i
< 4; i
++ ) {
6015 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
6016 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
6023 if ( !rmargin
.test( prefix
) ) {
6024 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
6029 css: function( name
, value
) {
6030 return access( this, function( elem
, name
, value
) {
6035 if ( jQuery
.isArray( name
) ) {
6036 styles
= getStyles( elem
);
6039 for ( ; i
< len
; i
++ ) {
6040 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
6046 return value
!== undefined ?
6047 jQuery
.style( elem
, name
, value
) :
6048 jQuery
.css( elem
, name
);
6049 }, name
, value
, arguments
.length
> 1 );
6052 return showHide( this, true );
6055 return showHide( this );
6057 toggle: function( state
) {
6058 if ( typeof state
=== "boolean" ) {
6059 return state
? this.show() : this.hide();
6062 return this.each(function() {
6063 if ( isHidden( this ) ) {
6064 jQuery( this ).show();
6066 jQuery( this ).hide();
6073 function Tween( elem
, options
, prop
, end
, easing
) {
6074 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
6076 jQuery
.Tween
= Tween
;
6080 init: function( elem
, options
, prop
, end
, easing
, unit
) {
6083 this.easing
= easing
|| "swing";
6084 this.options
= options
;
6085 this.start
= this.now
= this.cur();
6087 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
6090 var hooks
= Tween
.propHooks
[ this.prop
];
6092 return hooks
&& hooks
.get ?
6094 Tween
.propHooks
._default
.get( this );
6096 run: function( percent
) {
6098 hooks
= Tween
.propHooks
[ this.prop
];
6100 if ( this.options
.duration
) {
6101 this.pos
= eased
= jQuery
.easing
[ this.easing
](
6102 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
6105 this.pos
= eased
= percent
;
6107 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
6109 if ( this.options
.step
) {
6110 this.options
.step
.call( this.elem
, this.now
, this );
6113 if ( hooks
&& hooks
.set ) {
6116 Tween
.propHooks
._default
.set( this );
6122 Tween
.prototype.init
.prototype = Tween
.prototype;
6126 get: function( tween
) {
6129 if ( tween
.elem
[ tween
.prop
] != null &&
6130 (!tween
.elem
.style
|| tween
.elem
.style
[ tween
.prop
] == null) ) {
6131 return tween
.elem
[ tween
.prop
];
6134 // passing an empty string as a 3rd parameter to .css will automatically
6135 // attempt a parseFloat and fallback to a string if the parse fails
6136 // so, simple values such as "10px" are parsed to Float.
6137 // complex values such as "rotate(1rad)" are returned as is.
6138 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
6139 // Empty strings, null, undefined and "auto" are converted to 0.
6140 return !result
|| result
=== "auto" ? 0 : result
;
6142 set: function( tween
) {
6143 // use step hook for back compat - use cssHook if its there - use .style if its
6144 // available and use plain properties where available
6145 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
6146 jQuery
.fx
.step
[ tween
.prop
]( tween
);
6147 } else if ( tween
.elem
.style
&& ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null || jQuery
.cssHooks
[ tween
.prop
] ) ) {
6148 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
6150 tween
.elem
[ tween
.prop
] = tween
.now
;
6157 // Panic based approach to setting things on disconnected nodes
6159 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
6160 set: function( tween
) {
6161 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
6162 tween
.elem
[ tween
.prop
] = tween
.now
;
6168 linear: function( p
) {
6171 swing: function( p
) {
6172 return 0.5 - Math
.cos( p
* Math
.PI
) / 2;
6176 jQuery
.fx
= Tween
.prototype.init
;
6178 // Back Compat <1.8 extension point
6179 jQuery
.fx
.step
= {};
6186 rfxtypes
= /^(?:toggle|show|hide)$/,
6187 rfxnum
= new RegExp( "^(?:([+-])=|)(" + pnum
+ ")([a-z%]*)$", "i" ),
6188 rrun
= /queueHooks$/,
6189 animationPrefilters
= [ defaultPrefilter
],
6191 "*": [ function( prop
, value
) {
6192 var tween
= this.createTween( prop
, value
),
6193 target
= tween
.cur(),
6194 parts
= rfxnum
.exec( value
),
6195 unit
= parts
&& parts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
6197 // Starting value computation is required for potential unit mismatches
6198 start
= ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +target
) &&
6199 rfxnum
.exec( jQuery
.css( tween
.elem
, prop
) ),
6203 if ( start
&& start
[ 3 ] !== unit
) {
6204 // Trust units reported by jQuery.css
6205 unit
= unit
|| start
[ 3 ];
6207 // Make sure we update the tween properties later on
6208 parts
= parts
|| [];
6210 // Iteratively approximate from a nonzero starting point
6211 start
= +target
|| 1;
6214 // If previous iteration zeroed out, double until we get *something*
6215 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
6216 scale
= scale
|| ".5";
6219 start
= start
/ scale
;
6220 jQuery
.style( tween
.elem
, prop
, start
+ unit
);
6222 // Update scale, tolerating zero or NaN from tween.cur()
6223 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
6224 } while ( scale
!== (scale
= tween
.cur() / target
) && scale
!== 1 && --maxIterations
);
6227 // Update tween properties
6229 start
= tween
.start
= +start
|| +target
|| 0;
6231 // If a +=/-= token was provided, we're doing a relative animation
6232 tween
.end
= parts
[ 1 ] ?
6233 start
+ ( parts
[ 1 ] + 1 ) * parts
[ 2 ] :
6241 // Animations created synchronously will run synchronously
6242 function createFxNow() {
6243 setTimeout(function() {
6246 return ( fxNow
= jQuery
.now() );
6249 // Generate parameters to create a standard animation
6250 function genFx( type
, includeWidth
) {
6253 attrs
= { height
: type
};
6255 // if we include width, step value is 1 to do all cssExpand values,
6256 // if we don't include width, step value is 2 to skip over Left and Right
6257 includeWidth
= includeWidth
? 1 : 0;
6258 for ( ; i
< 4 ; i
+= 2 - includeWidth
) {
6259 which
= cssExpand
[ i
];
6260 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
6263 if ( includeWidth
) {
6264 attrs
.opacity
= attrs
.width
= type
;
6270 function createTween( value
, prop
, animation
) {
6272 collection
= ( tweeners
[ prop
] || [] ).concat( tweeners
[ "*" ] ),
6274 length
= collection
.length
;
6275 for ( ; index
< length
; index
++ ) {
6276 if ( (tween
= collection
[ index
].call( animation
, prop
, value
)) ) {
6278 // we're done with this property
6284 function defaultPrefilter( elem
, props
, opts
) {
6285 /* jshint validthis: true */
6286 var prop
, value
, toggle
, tween
, hooks
, oldfire
, display
,
6290 hidden
= elem
.nodeType
&& isHidden( elem
),
6291 dataShow
= data_priv
.get( elem
, "fxshow" );
6293 // handle queue: false promises
6294 if ( !opts
.queue
) {
6295 hooks
= jQuery
._queueHooks( elem
, "fx" );
6296 if ( hooks
.unqueued
== null ) {
6298 oldfire
= hooks
.empty
.fire
;
6299 hooks
.empty
.fire = function() {
6300 if ( !hooks
.unqueued
) {
6307 anim
.always(function() {
6308 // doing this makes sure that the complete handler will be called
6309 // before this completes
6310 anim
.always(function() {
6312 if ( !jQuery
.queue( elem
, "fx" ).length
) {
6319 // height/width overflow pass
6320 if ( elem
.nodeType
=== 1 && ( "height" in props
|| "width" in props
) ) {
6321 // Make sure that nothing sneaks out
6322 // Record all 3 overflow attributes because IE9-10 do not
6323 // change the overflow attribute when overflowX and
6324 // overflowY are set to the same value
6325 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
6327 // Set display property to inline-block for height/width
6328 // animations on inline elements that are having width/height animated
6329 display
= jQuery
.css( elem
, "display" );
6330 // Get default display if display is currently "none"
6331 if ( display
=== "none" ) {
6332 display
= defaultDisplay( elem
.nodeName
);
6334 if ( display
=== "inline" &&
6335 jQuery
.css( elem
, "float" ) === "none" ) {
6337 style
.display
= "inline-block";
6341 if ( opts
.overflow
) {
6342 style
.overflow
= "hidden";
6343 anim
.always(function() {
6344 style
.overflow
= opts
.overflow
[ 0 ];
6345 style
.overflowX
= opts
.overflow
[ 1 ];
6346 style
.overflowY
= opts
.overflow
[ 2 ];
6351 for ( prop
in props
) {
6352 value
= props
[ prop
];
6353 if ( rfxtypes
.exec( value
) ) {
6354 delete props
[ prop
];
6355 toggle
= toggle
|| value
=== "toggle";
6356 if ( value
=== ( hidden
? "hide" : "show" ) ) {
6358 // 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
6359 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
6365 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
6369 if ( !jQuery
.isEmptyObject( orig
) ) {
6371 if ( "hidden" in dataShow
) {
6372 hidden
= dataShow
.hidden
;
6375 dataShow
= data_priv
.access( elem
, "fxshow", {} );
6378 // store state if its toggle - enables .stop().toggle() to "reverse"
6380 dataShow
.hidden
= !hidden
;
6383 jQuery( elem
).show();
6385 anim
.done(function() {
6386 jQuery( elem
).hide();
6389 anim
.done(function() {
6392 data_priv
.remove( elem
, "fxshow" );
6393 for ( prop
in orig
) {
6394 jQuery
.style( elem
, prop
, orig
[ prop
] );
6397 for ( prop
in orig
) {
6398 tween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
6400 if ( !( prop
in dataShow
) ) {
6401 dataShow
[ prop
] = tween
.start
;
6403 tween
.end
= tween
.start
;
6404 tween
.start
= prop
=== "width" || prop
=== "height" ? 1 : 0;
6411 function propFilter( props
, specialEasing
) {
6412 var index
, name
, easing
, value
, hooks
;
6414 // camelCase, specialEasing and expand cssHook pass
6415 for ( index
in props
) {
6416 name
= jQuery
.camelCase( index
);
6417 easing
= specialEasing
[ name
];
6418 value
= props
[ index
];
6419 if ( jQuery
.isArray( value
) ) {
6420 easing
= value
[ 1 ];
6421 value
= props
[ index
] = value
[ 0 ];
6424 if ( index
!== name
) {
6425 props
[ name
] = value
;
6426 delete props
[ index
];
6429 hooks
= jQuery
.cssHooks
[ name
];
6430 if ( hooks
&& "expand" in hooks
) {
6431 value
= hooks
.expand( value
);
6432 delete props
[ name
];
6434 // not quite $.extend, this wont overwrite keys already present.
6435 // also - reusing 'index' from above because we have the correct "name"
6436 for ( index
in value
) {
6437 if ( !( index
in props
) ) {
6438 props
[ index
] = value
[ index
];
6439 specialEasing
[ index
] = easing
;
6443 specialEasing
[ name
] = easing
;
6448 function Animation( elem
, properties
, options
) {
6452 length
= animationPrefilters
.length
,
6453 deferred
= jQuery
.Deferred().always( function() {
6454 // don't match elem in the :animated selector
6461 var currentTime
= fxNow
|| createFxNow(),
6462 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
6463 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
6464 temp
= remaining
/ animation
.duration
|| 0,
6467 length
= animation
.tweens
.length
;
6469 for ( ; index
< length
; index
++ ) {
6470 animation
.tweens
[ index
].run( percent
);
6473 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
]);
6475 if ( percent
< 1 && length
) {
6478 deferred
.resolveWith( elem
, [ animation
] );
6482 animation
= deferred
.promise({
6484 props
: jQuery
.extend( {}, properties
),
6485 opts
: jQuery
.extend( true, { specialEasing
: {} }, options
),
6486 originalProperties
: properties
,
6487 originalOptions
: options
,
6488 startTime
: fxNow
|| createFxNow(),
6489 duration
: options
.duration
,
6491 createTween: function( prop
, end
) {
6492 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
6493 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
6494 animation
.tweens
.push( tween
);
6497 stop: function( gotoEnd
) {
6499 // if we are going to the end, we want to run all the tweens
6500 // otherwise we skip this part
6501 length
= gotoEnd
? animation
.tweens
.length
: 0;
6506 for ( ; index
< length
; index
++ ) {
6507 animation
.tweens
[ index
].run( 1 );
6510 // resolve when we played the last frame
6511 // otherwise, reject
6513 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
6515 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
6520 props
= animation
.props
;
6522 propFilter( props
, animation
.opts
.specialEasing
);
6524 for ( ; index
< length
; index
++ ) {
6525 result
= animationPrefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
6531 jQuery
.map( props
, createTween
, animation
);
6533 if ( jQuery
.isFunction( animation
.opts
.start
) ) {
6534 animation
.opts
.start
.call( elem
, animation
);
6538 jQuery
.extend( tick
, {
6541 queue
: animation
.opts
.queue
6545 // attach callbacks from options
6546 return animation
.progress( animation
.opts
.progress
)
6547 .done( animation
.opts
.done
, animation
.opts
.complete
)
6548 .fail( animation
.opts
.fail
)
6549 .always( animation
.opts
.always
);
6552 jQuery
.Animation
= jQuery
.extend( Animation
, {
6554 tweener: function( props
, callback
) {
6555 if ( jQuery
.isFunction( props
) ) {
6559 props
= props
.split(" ");
6564 length
= props
.length
;
6566 for ( ; index
< length
; index
++ ) {
6567 prop
= props
[ index
];
6568 tweeners
[ prop
] = tweeners
[ prop
] || [];
6569 tweeners
[ prop
].unshift( callback
);
6573 prefilter: function( callback
, prepend
) {
6575 animationPrefilters
.unshift( callback
);
6577 animationPrefilters
.push( callback
);
6582 jQuery
.speed = function( speed
, easing
, fn
) {
6583 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
6584 complete
: fn
|| !fn
&& easing
||
6585 jQuery
.isFunction( speed
) && speed
,
6587 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
6590 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration
:
6591 opt
.duration
in jQuery
.fx
.speeds
? jQuery
.fx
.speeds
[ opt
.duration
] : jQuery
.fx
.speeds
._default
;
6593 // normalize opt.queue - true/undefined/null -> "fx"
6594 if ( opt
.queue
== null || opt
.queue
=== true ) {
6599 opt
.old
= opt
.complete
;
6601 opt
.complete = function() {
6602 if ( jQuery
.isFunction( opt
.old
) ) {
6603 opt
.old
.call( this );
6607 jQuery
.dequeue( this, opt
.queue
);
6615 fadeTo: function( speed
, to
, easing
, callback
) {
6617 // show any hidden elements after setting opacity to 0
6618 return this.filter( isHidden
).css( "opacity", 0 ).show()
6620 // animate to the value specified
6621 .end().animate({ opacity
: to
}, speed
, easing
, callback
);
6623 animate: function( prop
, speed
, easing
, callback
) {
6624 var empty
= jQuery
.isEmptyObject( prop
),
6625 optall
= jQuery
.speed( speed
, easing
, callback
),
6626 doAnimation = function() {
6627 // Operate on a copy of prop so per-property easing won't be lost
6628 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
6630 // Empty animations, or finishing resolves immediately
6631 if ( empty
|| data_priv
.get( this, "finish" ) ) {
6635 doAnimation
.finish
= doAnimation
;
6637 return empty
|| optall
.queue
=== false ?
6638 this.each( doAnimation
) :
6639 this.queue( optall
.queue
, doAnimation
);
6641 stop: function( type
, clearQueue
, gotoEnd
) {
6642 var stopQueue = function( hooks
) {
6643 var stop
= hooks
.stop
;
6648 if ( typeof type
!== "string" ) {
6649 gotoEnd
= clearQueue
;
6653 if ( clearQueue
&& type
!== false ) {
6654 this.queue( type
|| "fx", [] );
6657 return this.each(function() {
6659 index
= type
!= null && type
+ "queueHooks",
6660 timers
= jQuery
.timers
,
6661 data
= data_priv
.get( this );
6664 if ( data
[ index
] && data
[ index
].stop
) {
6665 stopQueue( data
[ index
] );
6668 for ( index
in data
) {
6669 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
6670 stopQueue( data
[ index
] );
6675 for ( index
= timers
.length
; index
--; ) {
6676 if ( timers
[ index
].elem
=== this && (type
== null || timers
[ index
].queue
=== type
) ) {
6677 timers
[ index
].anim
.stop( gotoEnd
);
6679 timers
.splice( index
, 1 );
6683 // start the next in the queue if the last step wasn't forced
6684 // timers currently will call their complete callbacks, which will dequeue
6685 // but only if they were gotoEnd
6686 if ( dequeue
|| !gotoEnd
) {
6687 jQuery
.dequeue( this, type
);
6691 finish: function( type
) {
6692 if ( type
!== false ) {
6693 type
= type
|| "fx";
6695 return this.each(function() {
6697 data
= data_priv
.get( this ),
6698 queue
= data
[ type
+ "queue" ],
6699 hooks
= data
[ type
+ "queueHooks" ],
6700 timers
= jQuery
.timers
,
6701 length
= queue
? queue
.length
: 0;
6703 // enable finishing flag on private data
6706 // empty the queue first
6707 jQuery
.queue( this, type
, [] );
6709 if ( hooks
&& hooks
.stop
) {
6710 hooks
.stop
.call( this, true );
6713 // look for any active animations, and finish them
6714 for ( index
= timers
.length
; index
--; ) {
6715 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
6716 timers
[ index
].anim
.stop( true );
6717 timers
.splice( index
, 1 );
6721 // look for any animations in the old queue and finish them
6722 for ( index
= 0; index
< length
; index
++ ) {
6723 if ( queue
[ index
] && queue
[ index
].finish
) {
6724 queue
[ index
].finish
.call( this );
6728 // turn off finishing flag
6734 jQuery
.each([ "toggle", "show", "hide" ], function( i
, name
) {
6735 var cssFn
= jQuery
.fn
[ name
];
6736 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
6737 return speed
== null || typeof speed
=== "boolean" ?
6738 cssFn
.apply( this, arguments
) :
6739 this.animate( genFx( name
, true ), speed
, easing
, callback
);
6743 // Generate shortcuts for custom animations
6745 slideDown
: genFx("show"),
6746 slideUp
: genFx("hide"),
6747 slideToggle
: genFx("toggle"),
6748 fadeIn
: { opacity
: "show" },
6749 fadeOut
: { opacity
: "hide" },
6750 fadeToggle
: { opacity
: "toggle" }
6751 }, function( name
, props
) {
6752 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
6753 return this.animate( props
, speed
, easing
, callback
);
6758 jQuery
.fx
.tick = function() {
6761 timers
= jQuery
.timers
;
6763 fxNow
= jQuery
.now();
6765 for ( ; i
< timers
.length
; i
++ ) {
6766 timer
= timers
[ i
];
6767 // Checks the timer has not already been removed
6768 if ( !timer() && timers
[ i
] === timer
) {
6769 timers
.splice( i
--, 1 );
6773 if ( !timers
.length
) {
6779 jQuery
.fx
.timer = function( timer
) {
6780 jQuery
.timers
.push( timer
);
6784 jQuery
.timers
.pop();
6788 jQuery
.fx
.interval
= 13;
6790 jQuery
.fx
.start = function() {
6792 timerId
= setInterval( jQuery
.fx
.tick
, jQuery
.fx
.interval
);
6796 jQuery
.fx
.stop = function() {
6797 clearInterval( timerId
);
6801 jQuery
.fx
.speeds
= {
6809 // Based off of the plugin by Clint Helfers, with permission.
6810 // http://blindsignals.com/index.php/2009/07/jquery-delay/
6811 jQuery
.fn
.delay = function( time
, type
) {
6812 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
6813 type
= type
|| "fx";
6815 return this.queue( type
, function( next
, hooks
) {
6816 var timeout
= setTimeout( next
, time
);
6817 hooks
.stop = function() {
6818 clearTimeout( timeout
);
6825 var input
= document
.createElement( "input" ),
6826 select
= document
.createElement( "select" ),
6827 opt
= select
.appendChild( document
.createElement( "option" ) );
6829 input
.type
= "checkbox";
6831 // Support: iOS 5.1, Android 4.x, Android 2.3
6832 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
6833 support
.checkOn
= input
.value
!== "";
6835 // Must access the parent to make an option select properly
6836 // Support: IE9, IE10
6837 support
.optSelected
= opt
.selected
;
6839 // Make sure that the options inside disabled selects aren't marked as disabled
6840 // (WebKit marks them as disabled)
6841 select
.disabled
= true;
6842 support
.optDisabled
= !opt
.disabled
;
6844 // Check if an input maintains its value after becoming a radio
6845 // Support: IE9, IE10
6846 input
= document
.createElement( "input" );
6848 input
.type
= "radio";
6849 support
.radioValue
= input
.value
=== "t";
6853 var nodeHook
, boolHook
,
6854 attrHandle
= jQuery
.expr
.attrHandle
;
6857 attr: function( name
, value
) {
6858 return access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
6861 removeAttr: function( name
) {
6862 return this.each(function() {
6863 jQuery
.removeAttr( this, name
);
6869 attr: function( elem
, name
, value
) {
6871 nType
= elem
.nodeType
;
6873 // don't get/set attributes on text, comment and attribute nodes
6874 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
6878 // Fallback to prop when attributes are not supported
6879 if ( typeof elem
.getAttribute
=== strundefined
) {
6880 return jQuery
.prop( elem
, name
, value
);
6883 // All attributes are lowercase
6884 // Grab necessary hook if one is defined
6885 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
6886 name
= name
.toLowerCase();
6887 hooks
= jQuery
.attrHooks
[ name
] ||
6888 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook
: nodeHook
);
6891 if ( value
!== undefined ) {
6893 if ( value
=== null ) {
6894 jQuery
.removeAttr( elem
, name
);
6896 } else if ( hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
6900 elem
.setAttribute( name
, value
+ "" );
6904 } else if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
6908 ret
= jQuery
.find
.attr( elem
, name
);
6910 // Non-existent attributes return null, we normalize to undefined
6911 return ret
== null ?
6917 removeAttr: function( elem
, value
) {
6920 attrNames
= value
&& value
.match( rnotwhite
);
6922 if ( attrNames
&& elem
.nodeType
=== 1 ) {
6923 while ( (name
= attrNames
[i
++]) ) {
6924 propName
= jQuery
.propFix
[ name
] || name
;
6926 // Boolean attributes get special treatment (#10870)
6927 if ( jQuery
.expr
.match
.bool
.test( name
) ) {
6928 // Set corresponding property to false
6929 elem
[ propName
] = false;
6932 elem
.removeAttribute( name
);
6939 set: function( elem
, value
) {
6940 if ( !support
.radioValue
&& value
=== "radio" &&
6941 jQuery
.nodeName( elem
, "input" ) ) {
6942 // Setting the type on a radio button after the value resets the value in IE6-9
6943 // Reset value to default in case type is set after value during creation
6944 var val
= elem
.value
;
6945 elem
.setAttribute( "type", value
);
6956 // Hooks for boolean attributes
6958 set: function( elem
, value
, name
) {
6959 if ( value
=== false ) {
6960 // Remove boolean attributes when set to false
6961 jQuery
.removeAttr( elem
, name
);
6963 elem
.setAttribute( name
, name
);
6968 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( i
, name
) {
6969 var getter
= attrHandle
[ name
] || jQuery
.find
.attr
;
6971 attrHandle
[ name
] = function( elem
, name
, isXML
) {
6974 // Avoid an infinite loop by temporarily removing this function from the getter
6975 handle
= attrHandle
[ name
];
6976 attrHandle
[ name
] = ret
;
6977 ret
= getter( elem
, name
, isXML
) != null ?
6978 name
.toLowerCase() :
6980 attrHandle
[ name
] = handle
;
6989 var rfocusable
= /^(?:input|select|textarea|button)$/i;
6992 prop: function( name
, value
) {
6993 return access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
6996 removeProp: function( name
) {
6997 return this.each(function() {
6998 delete this[ jQuery
.propFix
[ name
] || name
];
7006 "class": "className"
7009 prop: function( elem
, name
, value
) {
7010 var ret
, hooks
, notxml
,
7011 nType
= elem
.nodeType
;
7013 // don't get/set properties on text, comment and attribute nodes
7014 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
7018 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
7021 // Fix name and attach hooks
7022 name
= jQuery
.propFix
[ name
] || name
;
7023 hooks
= jQuery
.propHooks
[ name
];
7026 if ( value
!== undefined ) {
7027 return hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ?
7029 ( elem
[ name
] = value
);
7032 return hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ?
7040 get: function( elem
) {
7041 return elem
.hasAttribute( "tabindex" ) || rfocusable
.test( elem
.nodeName
) || elem
.href
?
7050 // Selectedness for an option in an optgroup can be inaccurate
7051 if ( !support
.optSelected
) {
7052 jQuery
.propHooks
.selected
= {
7053 get: function( elem
) {
7054 var parent
= elem
.parentNode
;
7055 if ( parent
&& parent
.parentNode
) {
7056 parent
.parentNode
.selectedIndex
;
7075 jQuery
.propFix
[ this.toLowerCase() ] = this;
7081 var rclass
= /[\t\r\n\f]/g;
7084 addClass: function( value
) {
7085 var classes
, elem
, cur
, clazz
, j
, finalValue
,
7086 proceed
= typeof value
=== "string" && value
,
7090 if ( jQuery
.isFunction( value
) ) {
7091 return this.each(function( j
) {
7092 jQuery( this ).addClass( value
.call( this, j
, this.className
) );
7097 // The disjunction here is for better compressibility (see removeClass)
7098 classes
= ( value
|| "" ).match( rnotwhite
) || [];
7100 for ( ; i
< len
; i
++ ) {
7102 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
7103 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
7109 while ( (clazz
= classes
[j
++]) ) {
7110 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
7115 // only assign if different to avoid unneeded rendering.
7116 finalValue
= jQuery
.trim( cur
);
7117 if ( elem
.className
!== finalValue
) {
7118 elem
.className
= finalValue
;
7127 removeClass: function( value
) {
7128 var classes
, elem
, cur
, clazz
, j
, finalValue
,
7129 proceed
= arguments
.length
=== 0 || typeof value
=== "string" && value
,
7133 if ( jQuery
.isFunction( value
) ) {
7134 return this.each(function( j
) {
7135 jQuery( this ).removeClass( value
.call( this, j
, this.className
) );
7139 classes
= ( value
|| "" ).match( rnotwhite
) || [];
7141 for ( ; i
< len
; i
++ ) {
7143 // This expression is here for better compressibility (see addClass)
7144 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
7145 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
7151 while ( (clazz
= classes
[j
++]) ) {
7152 // Remove *all* instances
7153 while ( cur
.indexOf( " " + clazz
+ " " ) >= 0 ) {
7154 cur
= cur
.replace( " " + clazz
+ " ", " " );
7158 // only assign if different to avoid unneeded rendering.
7159 finalValue
= value
? jQuery
.trim( cur
) : "";
7160 if ( elem
.className
!== finalValue
) {
7161 elem
.className
= finalValue
;
7170 toggleClass: function( value
, stateVal
) {
7171 var type
= typeof value
;
7173 if ( typeof stateVal
=== "boolean" && type
=== "string" ) {
7174 return stateVal
? this.addClass( value
) : this.removeClass( value
);
7177 if ( jQuery
.isFunction( value
) ) {
7178 return this.each(function( i
) {
7179 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
7183 return this.each(function() {
7184 if ( type
=== "string" ) {
7185 // toggle individual class names
7188 self
= jQuery( this ),
7189 classNames
= value
.match( rnotwhite
) || [];
7191 while ( (className
= classNames
[ i
++ ]) ) {
7192 // check each className given, space separated list
7193 if ( self
.hasClass( className
) ) {
7194 self
.removeClass( className
);
7196 self
.addClass( className
);
7200 // Toggle whole class name
7201 } else if ( type
=== strundefined
|| type
=== "boolean" ) {
7202 if ( this.className
) {
7203 // store className if set
7204 data_priv
.set( this, "__className__", this.className
);
7207 // If the element has a class name or if we're passed "false",
7208 // then remove the whole classname (if there was one, the above saved it).
7209 // Otherwise bring back whatever was previously saved (if anything),
7210 // falling back to the empty string if nothing was stored.
7211 this.className
= this.className
|| value
=== false ? "" : data_priv
.get( this, "__className__" ) || "";
7216 hasClass: function( selector
) {
7217 var className
= " " + selector
+ " ",
7220 for ( ; i
< l
; i
++ ) {
7221 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) >= 0 ) {
7233 var rreturn
= /\r/g;
7236 val: function( value
) {
7237 var hooks
, ret
, isFunction
,
7240 if ( !arguments
.length
) {
7242 hooks
= jQuery
.valHooks
[ elem
.type
] || jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
7244 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, "value" )) !== undefined ) {
7250 return typeof ret
=== "string" ?
7251 // handle most common string cases
7252 ret
.replace(rreturn
, "") :
7253 // handle cases where value is null/undef or number
7254 ret
== null ? "" : ret
;
7260 isFunction
= jQuery
.isFunction( value
);
7262 return this.each(function( i
) {
7265 if ( this.nodeType
!== 1 ) {
7270 val
= value
.call( this, i
, jQuery( this ).val() );
7275 // Treat null/undefined as ""; convert numbers to string
7276 if ( val
== null ) {
7279 } else if ( typeof val
=== "number" ) {
7282 } else if ( jQuery
.isArray( val
) ) {
7283 val
= jQuery
.map( val
, function( value
) {
7284 return value
== null ? "" : value
+ "";
7288 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
7290 // If set returns undefined, fall back to normal setting
7291 if ( !hooks
|| !("set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
7301 get: function( elem
) {
7303 options
= elem
.options
,
7304 index
= elem
.selectedIndex
,
7305 one
= elem
.type
=== "select-one" || index
< 0,
7306 values
= one
? null : [],
7307 max
= one
? index
+ 1 : options
.length
,
7312 // Loop through all the selected options
7313 for ( ; i
< max
; i
++ ) {
7314 option
= options
[ i
];
7316 // IE6-9 doesn't update selected after form reset (#2551)
7317 if ( ( option
.selected
|| i
=== index
) &&
7318 // Don't return options that are disabled or in a disabled optgroup
7319 ( support
.optDisabled
? !option
.disabled
: option
.getAttribute( "disabled" ) === null ) &&
7320 ( !option
.parentNode
.disabled
|| !jQuery
.nodeName( option
.parentNode
, "optgroup" ) ) ) {
7322 // Get the specific value for the option
7323 value
= jQuery( option
).val();
7325 // We don't need an array for one selects
7330 // Multi-Selects return an array
7331 values
.push( value
);
7338 set: function( elem
, value
) {
7339 var optionSet
, option
,
7340 options
= elem
.options
,
7341 values
= jQuery
.makeArray( value
),
7345 option
= options
[ i
];
7346 if ( (option
.selected
= jQuery
.inArray( jQuery(option
).val(), values
) >= 0) ) {
7351 // force browsers to behave consistently when non-matching value is set
7353 elem
.selectedIndex
= -1;
7361 // Radios and checkboxes getter/setter
7362 jQuery
.each([ "radio", "checkbox" ], function() {
7363 jQuery
.valHooks
[ this ] = {
7364 set: function( elem
, value
) {
7365 if ( jQuery
.isArray( value
) ) {
7366 return ( elem
.checked
= jQuery
.inArray( jQuery(elem
).val(), value
) >= 0 );
7370 if ( !support
.checkOn
) {
7371 jQuery
.valHooks
[ this ].get = function( elem
) {
7373 // "" is returned instead of "on" if a value isn't specified
7374 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
7382 // Return jQuery for attributes-only inclusion
7385 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
7386 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7387 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i
, name
) {
7389 // Handle event binding
7390 jQuery
.fn
[ name
] = function( data
, fn
) {
7391 return arguments
.length
> 0 ?
7392 this.on( name
, null, data
, fn
) :
7393 this.trigger( name
);
7398 hover: function( fnOver
, fnOut
) {
7399 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
7402 bind: function( types
, data
, fn
) {
7403 return this.on( types
, null, data
, fn
);
7405 unbind: function( types
, fn
) {
7406 return this.off( types
, null, fn
);
7409 delegate: function( selector
, types
, data
, fn
) {
7410 return this.on( types
, selector
, data
, fn
);
7412 undelegate: function( selector
, types
, fn
) {
7413 // ( namespace ) or ( selector, types [, fn] )
7414 return arguments
.length
=== 1 ? this.off( selector
, "**" ) : this.off( types
, selector
|| "**", fn
);
7419 var nonce
= jQuery
.now();
7421 var rquery
= (/\?/);
7425 // Support: Android 2.3
7426 // Workaround failure to string-cast null input
7427 jQuery
.parseJSON = function( data
) {
7428 return JSON
.parse( data
+ "" );
7432 // Cross-browser xml parsing
7433 jQuery
.parseXML = function( data
) {
7435 if ( !data
|| typeof data
!== "string" ) {
7441 tmp
= new DOMParser();
7442 xml
= tmp
.parseFromString( data
, "text/xml" );
7447 if ( !xml
|| xml
.getElementsByTagName( "parsererror" ).length
) {
7448 jQuery
.error( "Invalid XML: " + data
);
7455 // Document location
7460 rts
= /([?&])_=[^&]*/,
7461 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg,
7462 // #7653, #8125, #8152: local protocol detection
7463 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7464 rnoContent
= /^(?:GET|HEAD)$/,
7465 rprotocol
= /^\/\//,
7466 rurl
= /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
7469 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7470 * 2) These are called:
7471 * - BEFORE asking for a transport
7472 * - AFTER param serialization (s.data is a string if s.processData is true)
7473 * 3) key is the dataType
7474 * 4) the catchall symbol "*" can be used
7475 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7479 /* Transports bindings
7480 * 1) key is the dataType
7481 * 2) the catchall symbol "*" can be used
7482 * 3) selection will start with transport dataType and THEN go to "*" if needed
7486 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7487 allTypes
= "*/".concat("*");
7489 // #8138, IE may throw an exception when accessing
7490 // a field from window.location if document.domain has been set
7492 ajaxLocation
= location
.href
;
7494 // Use the href attribute of an A element
7495 // since IE will modify it given document.location
7496 ajaxLocation
= document
.createElement( "a" );
7497 ajaxLocation
.href
= "";
7498 ajaxLocation
= ajaxLocation
.href
;
7501 // Segment location into parts
7502 ajaxLocParts
= rurl
.exec( ajaxLocation
.toLowerCase() ) || [];
7504 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7505 function addToPrefiltersOrTransports( structure
) {
7507 // dataTypeExpression is optional and defaults to "*"
7508 return function( dataTypeExpression
, func
) {
7510 if ( typeof dataTypeExpression
!== "string" ) {
7511 func
= dataTypeExpression
;
7512 dataTypeExpression
= "*";
7517 dataTypes
= dataTypeExpression
.toLowerCase().match( rnotwhite
) || [];
7519 if ( jQuery
.isFunction( func
) ) {
7520 // For each dataType in the dataTypeExpression
7521 while ( (dataType
= dataTypes
[i
++]) ) {
7522 // Prepend if requested
7523 if ( dataType
[0] === "+" ) {
7524 dataType
= dataType
.slice( 1 ) || "*";
7525 (structure
[ dataType
] = structure
[ dataType
] || []).unshift( func
);
7529 (structure
[ dataType
] = structure
[ dataType
] || []).push( func
);
7536 // Base inspection function for prefilters and transports
7537 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
7540 seekingTransport
= ( structure
=== transports
);
7542 function inspect( dataType
) {
7544 inspected
[ dataType
] = true;
7545 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
7546 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
7547 if ( typeof dataTypeOrTransport
=== "string" && !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
7548 options
.dataTypes
.unshift( dataTypeOrTransport
);
7549 inspect( dataTypeOrTransport
);
7551 } else if ( seekingTransport
) {
7552 return !( selected
= dataTypeOrTransport
);
7558 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
7561 // A special extend for ajax options
7562 // that takes "flat" options (not to be deep extended)
7564 function ajaxExtend( target
, src
) {
7566 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
7568 for ( key
in src
) {
7569 if ( src
[ key
] !== undefined ) {
7570 ( flatOptions
[ key
] ? target
: ( deep
|| (deep
= {}) ) )[ key
] = src
[ key
];
7574 jQuery
.extend( true, target
, deep
);
7580 /* Handles responses to an ajax request:
7581 * - finds the right dataType (mediates between content-type and expected dataType)
7582 * - returns the corresponding response
7584 function ajaxHandleResponses( s
, jqXHR
, responses
) {
7586 var ct
, type
, finalDataType
, firstDataType
,
7587 contents
= s
.contents
,
7588 dataTypes
= s
.dataTypes
;
7590 // Remove auto dataType and get content-type in the process
7591 while ( dataTypes
[ 0 ] === "*" ) {
7593 if ( ct
=== undefined ) {
7594 ct
= s
.mimeType
|| jqXHR
.getResponseHeader("Content-Type");
7598 // Check if we're dealing with a known content-type
7600 for ( type
in contents
) {
7601 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
7602 dataTypes
.unshift( type
);
7608 // Check to see if we have a response for the expected dataType
7609 if ( dataTypes
[ 0 ] in responses
) {
7610 finalDataType
= dataTypes
[ 0 ];
7612 // Try convertible dataTypes
7613 for ( type
in responses
) {
7614 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[0] ] ) {
7615 finalDataType
= type
;
7618 if ( !firstDataType
) {
7619 firstDataType
= type
;
7622 // Or just use first one
7623 finalDataType
= finalDataType
|| firstDataType
;
7626 // If we found a dataType
7627 // We add the dataType to the list if needed
7628 // and return the corresponding response
7629 if ( finalDataType
) {
7630 if ( finalDataType
!== dataTypes
[ 0 ] ) {
7631 dataTypes
.unshift( finalDataType
);
7633 return responses
[ finalDataType
];
7637 /* Chain conversions given the request and the original response
7638 * Also sets the responseXXX fields on the jqXHR instance
7640 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
7641 var conv2
, current
, conv
, tmp
, prev
,
7643 // Work with a copy of dataTypes in case we need to modify it for conversion
7644 dataTypes
= s
.dataTypes
.slice();
7646 // Create converters map with lowercased keys
7647 if ( dataTypes
[ 1 ] ) {
7648 for ( conv
in s
.converters
) {
7649 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
7653 current
= dataTypes
.shift();
7655 // Convert to each sequential dataType
7658 if ( s
.responseFields
[ current
] ) {
7659 jqXHR
[ s
.responseFields
[ current
] ] = response
;
7662 // Apply the dataFilter if provided
7663 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
7664 response
= s
.dataFilter( response
, s
.dataType
);
7668 current
= dataTypes
.shift();
7672 // There's only work to do if current dataType is non-auto
7673 if ( current
=== "*" ) {
7677 // Convert response if prev dataType is non-auto and differs from current
7678 } else if ( prev
!== "*" && prev
!== current
) {
7680 // Seek a direct converter
7681 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
7683 // If none found, seek a pair
7685 for ( conv2
in converters
) {
7687 // If conv2 outputs current
7688 tmp
= conv2
.split( " " );
7689 if ( tmp
[ 1 ] === current
) {
7691 // If prev can be converted to accepted input
7692 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
7693 converters
[ "* " + tmp
[ 0 ] ];
7695 // Condense equivalence converters
7696 if ( conv
=== true ) {
7697 conv
= converters
[ conv2
];
7699 // Otherwise, insert the intermediate dataType
7700 } else if ( converters
[ conv2
] !== true ) {
7702 dataTypes
.unshift( tmp
[ 1 ] );
7710 // Apply converter (if not an equivalence)
7711 if ( conv
!== true ) {
7713 // Unless errors are allowed to bubble, catch and return them
7714 if ( conv
&& s
[ "throws" ] ) {
7715 response
= conv( response
);
7718 response
= conv( response
);
7720 return { state
: "parsererror", error
: conv
? e
: "No conversion from " + prev
+ " to " + current
};
7728 return { state
: "success", data
: response
};
7733 // Counter for holding the number of active queries
7736 // Last-Modified header cache for next request
7743 isLocal
: rlocalProtocol
.test( ajaxLocParts
[ 1 ] ),
7747 contentType
: "application/x-www-form-urlencoded; charset=UTF-8",
7764 xml
: "application/xml, text/xml",
7765 json
: "application/json, text/javascript"
7776 text
: "responseText",
7777 json
: "responseJSON"
7781 // Keys separate source (or catchall "*") and destination types with a single space
7784 // Convert anything to text
7787 // Text to html (true = no transformation)
7790 // Evaluate text as a json expression
7791 "text json": jQuery
.parseJSON
,
7793 // Parse text as xml
7794 "text xml": jQuery
.parseXML
7797 // For options that shouldn't be deep extended:
7798 // you can add your own custom options here if
7799 // and when you create one that shouldn't be
7800 // deep extended (see ajaxExtend)
7807 // Creates a full fledged settings object into target
7808 // with both ajaxSettings and settings fields.
7809 // If target is omitted, writes into ajaxSettings.
7810 ajaxSetup: function( target
, settings
) {
7813 // Building a settings object
7814 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
7816 // Extending ajaxSettings
7817 ajaxExtend( jQuery
.ajaxSettings
, target
);
7820 ajaxPrefilter
: addToPrefiltersOrTransports( prefilters
),
7821 ajaxTransport
: addToPrefiltersOrTransports( transports
),
7824 ajax: function( url
, options
) {
7826 // If url is an object, simulate pre-1.5 signature
7827 if ( typeof url
=== "object" ) {
7832 // Force options to be an object
7833 options
= options
|| {};
7836 // URL without anti-cache param
7839 responseHeadersString
,
7843 // Cross-domain detection vars
7845 // To know if global events are to be dispatched
7849 // Create the final options object
7850 s
= jQuery
.ajaxSetup( {}, options
),
7851 // Callbacks context
7852 callbackContext
= s
.context
|| s
,
7853 // Context for global events is callbackContext if it is a DOM node or jQuery collection
7854 globalEventContext
= s
.context
&& ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
7855 jQuery( callbackContext
) :
7858 deferred
= jQuery
.Deferred(),
7859 completeDeferred
= jQuery
.Callbacks("once memory"),
7860 // Status-dependent callbacks
7861 statusCode
= s
.statusCode
|| {},
7862 // Headers (they are sent all at once)
7863 requestHeaders
= {},
7864 requestHeadersNames
= {},
7867 // Default abort message
7868 strAbort
= "canceled",
7873 // Builds headers hashtable if needed
7874 getResponseHeader: function( key
) {
7876 if ( state
=== 2 ) {
7877 if ( !responseHeaders
) {
7878 responseHeaders
= {};
7879 while ( (match
= rheaders
.exec( responseHeadersString
)) ) {
7880 responseHeaders
[ match
[1].toLowerCase() ] = match
[ 2 ];
7883 match
= responseHeaders
[ key
.toLowerCase() ];
7885 return match
== null ? null : match
;
7889 getAllResponseHeaders: function() {
7890 return state
=== 2 ? responseHeadersString
: null;
7893 // Caches the header
7894 setRequestHeader: function( name
, value
) {
7895 var lname
= name
.toLowerCase();
7897 name
= requestHeadersNames
[ lname
] = requestHeadersNames
[ lname
] || name
;
7898 requestHeaders
[ name
] = value
;
7903 // Overrides response content-type header
7904 overrideMimeType: function( type
) {
7911 // Status-dependent callbacks
7912 statusCode: function( map
) {
7916 for ( code
in map
) {
7917 // Lazy-add the new callback in a way that preserves old ones
7918 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
7921 // Execute the appropriate callbacks
7922 jqXHR
.always( map
[ jqXHR
.status
] );
7928 // Cancel the request
7929 abort: function( statusText
) {
7930 var finalText
= statusText
|| strAbort
;
7932 transport
.abort( finalText
);
7934 done( 0, finalText
);
7940 deferred
.promise( jqXHR
).complete
= completeDeferred
.add
;
7941 jqXHR
.success
= jqXHR
.done
;
7942 jqXHR
.error
= jqXHR
.fail
;
7944 // Remove hash character (#7531: and string promotion)
7945 // Add protocol if not provided (prefilters might expect it)
7946 // Handle falsy url in the settings object (#10093: consistency with old signature)
7947 // We also use the url parameter if available
7948 s
.url
= ( ( url
|| s
.url
|| ajaxLocation
) + "" ).replace( rhash
, "" )
7949 .replace( rprotocol
, ajaxLocParts
[ 1 ] + "//" );
7951 // Alias method option to type as per ticket #12004
7952 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
7954 // Extract dataTypes list
7955 s
.dataTypes
= jQuery
.trim( s
.dataType
|| "*" ).toLowerCase().match( rnotwhite
) || [ "" ];
7957 // A cross-domain request is in order when we have a protocol:host:port mismatch
7958 if ( s
.crossDomain
== null ) {
7959 parts
= rurl
.exec( s
.url
.toLowerCase() );
7960 s
.crossDomain
= !!( parts
&&
7961 ( parts
[ 1 ] !== ajaxLocParts
[ 1 ] || parts
[ 2 ] !== ajaxLocParts
[ 2 ] ||
7962 ( parts
[ 3 ] || ( parts
[ 1 ] === "http:" ? "80" : "443" ) ) !==
7963 ( ajaxLocParts
[ 3 ] || ( ajaxLocParts
[ 1 ] === "http:" ? "80" : "443" ) ) )
7967 // Convert data if not already a string
7968 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
7969 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
7973 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
7975 // If request was aborted inside a prefilter, stop there
7976 if ( state
=== 2 ) {
7980 // We can fire global events as of now if asked to
7981 fireGlobals
= s
.global
;
7983 // Watch for a new set of requests
7984 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
7985 jQuery
.event
.trigger("ajaxStart");
7988 // Uppercase the type
7989 s
.type
= s
.type
.toUpperCase();
7991 // Determine if request has content
7992 s
.hasContent
= !rnoContent
.test( s
.type
);
7994 // Save the URL in case we're toying with the If-Modified-Since
7995 // and/or If-None-Match header later on
7998 // More options handling for requests with no content
7999 if ( !s
.hasContent
) {
8001 // If data is available, append data to url
8003 cacheURL
= ( s
.url
+= ( rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
);
8004 // #9682: remove data so that it's not used in an eventual retry
8008 // Add anti-cache in url if needed
8009 if ( s
.cache
=== false ) {
8010 s
.url
= rts
.test( cacheURL
) ?
8012 // If there is already a '_' parameter, set its value
8013 cacheURL
.replace( rts
, "$1_=" + nonce
++ ) :
8015 // Otherwise add one to the end
8016 cacheURL
+ ( rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + nonce
++;
8020 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8021 if ( s
.ifModified
) {
8022 if ( jQuery
.lastModified
[ cacheURL
] ) {
8023 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
8025 if ( jQuery
.etag
[ cacheURL
] ) {
8026 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
8030 // Set the correct header, if data is being sent
8031 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
8032 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
8035 // Set the Accepts header for the server, depending on the dataType
8036 jqXHR
.setRequestHeader(
8038 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[0] ] ?
8039 s
.accepts
[ s
.dataTypes
[0] ] + ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
8043 // Check for headers option
8044 for ( i
in s
.headers
) {
8045 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
8048 // Allow custom headers/mimetypes and early abort
8049 if ( s
.beforeSend
&& ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || state
=== 2 ) ) {
8050 // Abort if not done already and return
8051 return jqXHR
.abort();
8054 // aborting is no longer a cancellation
8057 // Install callbacks on deferreds
8058 for ( i
in { success
: 1, error
: 1, complete
: 1 } ) {
8059 jqXHR
[ i
]( s
[ i
] );
8063 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
8065 // If no transport, we auto-abort
8067 done( -1, "No Transport" );
8069 jqXHR
.readyState
= 1;
8071 // Send global event
8072 if ( fireGlobals
) {
8073 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
8076 if ( s
.async
&& s
.timeout
> 0 ) {
8077 timeoutTimer
= setTimeout(function() {
8078 jqXHR
.abort("timeout");
8084 transport
.send( requestHeaders
, done
);
8086 // Propagate exception as error if not done
8089 // Simply rethrow otherwise
8096 // Callback for when everything is done
8097 function done( status
, nativeStatusText
, responses
, headers
) {
8098 var isSuccess
, success
, error
, response
, modified
,
8099 statusText
= nativeStatusText
;
8102 if ( state
=== 2 ) {
8106 // State is "done" now
8109 // Clear timeout if it exists
8110 if ( timeoutTimer
) {
8111 clearTimeout( timeoutTimer
);
8114 // Dereference transport for early garbage collection
8115 // (no matter how long the jqXHR object will be used)
8116 transport
= undefined;
8118 // Cache response headers
8119 responseHeadersString
= headers
|| "";
8122 jqXHR
.readyState
= status
> 0 ? 4 : 0;
8124 // Determine if successful
8125 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
8127 // Get response data
8129 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
8132 // Convert no matter what (that way responseXXX fields are always set)
8133 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
8135 // If successful, handle type chaining
8138 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8139 if ( s
.ifModified
) {
8140 modified
= jqXHR
.getResponseHeader("Last-Modified");
8142 jQuery
.lastModified
[ cacheURL
] = modified
;
8144 modified
= jqXHR
.getResponseHeader("etag");
8146 jQuery
.etag
[ cacheURL
] = modified
;
8151 if ( status
=== 204 || s
.type
=== "HEAD" ) {
8152 statusText
= "nocontent";
8155 } else if ( status
=== 304 ) {
8156 statusText
= "notmodified";
8158 // If we have data, let's convert it
8160 statusText
= response
.state
;
8161 success
= response
.data
;
8162 error
= response
.error
;
8166 // We extract error from statusText
8167 // then normalize statusText and status for non-aborts
8169 if ( status
|| !statusText
) {
8170 statusText
= "error";
8177 // Set data for the fake xhr object
8178 jqXHR
.status
= status
;
8179 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
8183 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
8185 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
8188 // Status-dependent callbacks
8189 jqXHR
.statusCode( statusCode
);
8190 statusCode
= undefined;
8192 if ( fireGlobals
) {
8193 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
8194 [ jqXHR
, s
, isSuccess
? success
: error
] );
8198 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
8200 if ( fireGlobals
) {
8201 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
8202 // Handle the global AJAX counter
8203 if ( !( --jQuery
.active
) ) {
8204 jQuery
.event
.trigger("ajaxStop");
8212 getJSON: function( url
, data
, callback
) {
8213 return jQuery
.get( url
, data
, callback
, "json" );
8216 getScript: function( url
, callback
) {
8217 return jQuery
.get( url
, undefined, callback
, "script" );
8221 jQuery
.each( [ "get", "post" ], function( i
, method
) {
8222 jQuery
[ method
] = function( url
, data
, callback
, type
) {
8223 // shift arguments if data argument was omitted
8224 if ( jQuery
.isFunction( data
) ) {
8225 type
= type
|| callback
;
8230 return jQuery
.ajax({
8240 // Attach a bunch of functions for handling common AJAX events
8241 jQuery
.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i
, type
) {
8242 jQuery
.fn
[ type
] = function( fn
) {
8243 return this.on( type
, fn
);
8248 jQuery
._evalUrl = function( url
) {
8249 return jQuery
.ajax({
8261 wrapAll: function( html
) {
8264 if ( jQuery
.isFunction( html
) ) {
8265 return this.each(function( i
) {
8266 jQuery( this ).wrapAll( html
.call(this, i
) );
8272 // The elements to wrap the target around
8273 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
8275 if ( this[ 0 ].parentNode
) {
8276 wrap
.insertBefore( this[ 0 ] );
8279 wrap
.map(function() {
8282 while ( elem
.firstElementChild
) {
8283 elem
= elem
.firstElementChild
;
8293 wrapInner: function( html
) {
8294 if ( jQuery
.isFunction( html
) ) {
8295 return this.each(function( i
) {
8296 jQuery( this ).wrapInner( html
.call(this, i
) );
8300 return this.each(function() {
8301 var self
= jQuery( this ),
8302 contents
= self
.contents();
8304 if ( contents
.length
) {
8305 contents
.wrapAll( html
);
8308 self
.append( html
);
8313 wrap: function( html
) {
8314 var isFunction
= jQuery
.isFunction( html
);
8316 return this.each(function( i
) {
8317 jQuery( this ).wrapAll( isFunction
? html
.call(this, i
) : html
);
8321 unwrap: function() {
8322 return this.parent().each(function() {
8323 if ( !jQuery
.nodeName( this, "body" ) ) {
8324 jQuery( this ).replaceWith( this.childNodes
);
8331 jQuery
.expr
.filters
.hidden = function( elem
) {
8332 // Support: Opera <= 12.12
8333 // Opera reports offsetWidths and offsetHeights less than zero on some elements
8334 return elem
.offsetWidth
<= 0 && elem
.offsetHeight
<= 0;
8336 jQuery
.expr
.filters
.visible = function( elem
) {
8337 return !jQuery
.expr
.filters
.hidden( elem
);
8346 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
8347 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
8349 function buildParams( prefix
, obj
, traditional
, add
) {
8352 if ( jQuery
.isArray( obj
) ) {
8353 // Serialize array item.
8354 jQuery
.each( obj
, function( i
, v
) {
8355 if ( traditional
|| rbracket
.test( prefix
) ) {
8356 // Treat each array item as a scalar.
8360 // Item is non-scalar (array or object), encode its numeric index.
8361 buildParams( prefix
+ "[" + ( typeof v
=== "object" ? i
: "" ) + "]", v
, traditional
, add
);
8365 } else if ( !traditional
&& jQuery
.type( obj
) === "object" ) {
8366 // Serialize object item.
8367 for ( name
in obj
) {
8368 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
8372 // Serialize scalar item.
8377 // Serialize an array of form elements or a set of
8378 // key/values into a query string
8379 jQuery
.param = function( a
, traditional
) {
8382 add = function( key
, value
) {
8383 // If value is a function, invoke it and return its value
8384 value
= jQuery
.isFunction( value
) ? value() : ( value
== null ? "" : value
);
8385 s
[ s
.length
] = encodeURIComponent( key
) + "=" + encodeURIComponent( value
);
8388 // Set traditional to true for jQuery <= 1.3.2 behavior.
8389 if ( traditional
=== undefined ) {
8390 traditional
= jQuery
.ajaxSettings
&& jQuery
.ajaxSettings
.traditional
;
8393 // If an array was passed in, assume that it is an array of form elements.
8394 if ( jQuery
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
8395 // Serialize the form elements
8396 jQuery
.each( a
, function() {
8397 add( this.name
, this.value
);
8401 // If traditional, encode the "old" way (the way 1.3.2 or older
8402 // did it), otherwise encode params recursively.
8403 for ( prefix
in a
) {
8404 buildParams( prefix
, a
[ prefix
], traditional
, add
);
8408 // Return the resulting serialization
8409 return s
.join( "&" ).replace( r20
, "+" );
8413 serialize: function() {
8414 return jQuery
.param( this.serializeArray() );
8416 serializeArray: function() {
8417 return this.map(function() {
8418 // Can add propHook for "elements" to filter or add form elements
8419 var elements
= jQuery
.prop( this, "elements" );
8420 return elements
? jQuery
.makeArray( elements
) : this;
8422 .filter(function() {
8423 var type
= this.type
;
8425 // Use .is( ":disabled" ) so that fieldset[disabled] works
8426 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
8427 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
8428 ( this.checked
|| !rcheckableType
.test( type
) );
8430 .map(function( i
, elem
) {
8431 var val
= jQuery( this ).val();
8433 return val
== null ?
8435 jQuery
.isArray( val
) ?
8436 jQuery
.map( val
, function( val
) {
8437 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8439 { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
8445 jQuery
.ajaxSettings
.xhr = function() {
8447 return new XMLHttpRequest();
8453 xhrSuccessStatus
= {
8454 // file protocol always yields status code 0, assume 200
8457 // #1450: sometimes IE returns 1223 when it should be 204
8460 xhrSupported
= jQuery
.ajaxSettings
.xhr();
8463 // Open requests must be manually aborted on unload (#5280)
8464 if ( window
.ActiveXObject
) {
8465 jQuery( window
).on( "unload", function() {
8466 for ( var key
in xhrCallbacks
) {
8467 xhrCallbacks
[ key
]();
8472 support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
8473 support
.ajax
= xhrSupported
= !!xhrSupported
;
8475 jQuery
.ajaxTransport(function( options
) {
8478 // Cross domain only allowed if supported through XMLHttpRequest
8479 if ( support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
8481 send: function( headers
, complete
) {
8483 xhr
= options
.xhr(),
8486 xhr
.open( options
.type
, options
.url
, options
.async
, options
.username
, options
.password
);
8488 // Apply custom fields if provided
8489 if ( options
.xhrFields
) {
8490 for ( i
in options
.xhrFields
) {
8491 xhr
[ i
] = options
.xhrFields
[ i
];
8495 // Override mime type if needed
8496 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
8497 xhr
.overrideMimeType( options
.mimeType
);
8500 // X-Requested-With header
8501 // For cross-domain requests, seeing as conditions for a preflight are
8502 // akin to a jigsaw puzzle, we simply never set it to be sure.
8503 // (it can always be set on a per-request basis or even using ajaxSetup)
8504 // For same-domain requests, won't change header if already provided.
8505 if ( !options
.crossDomain
&& !headers
["X-Requested-With"] ) {
8506 headers
["X-Requested-With"] = "XMLHttpRequest";
8510 for ( i
in headers
) {
8511 xhr
.setRequestHeader( i
, headers
[ i
] );
8515 callback = function( type
) {
8518 delete xhrCallbacks
[ id
];
8519 callback
= xhr
.onload
= xhr
.onerror
= null;
8521 if ( type
=== "abort" ) {
8523 } else if ( type
=== "error" ) {
8525 // file: protocol always yields status 0; see #8605, #14207
8531 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
8534 // Accessing binary-data responseText throws an exception
8536 typeof xhr
.responseText
=== "string" ? {
8537 text
: xhr
.responseText
8539 xhr
.getAllResponseHeaders()
8547 xhr
.onload
= callback();
8548 xhr
.onerror
= callback("error");
8550 // Create the abort callback
8551 callback
= xhrCallbacks
[ id
] = callback("abort");
8553 // Do send the request
8554 // This may raise an exception which is actually
8555 // handled in jQuery.ajax (so no try/catch here)
8556 xhr
.send( options
.hasContent
&& options
.data
|| null );
8571 // Install script dataType
8574 script
: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8577 script
: /(?:java|ecma)script/
8580 "text script": function( text
) {
8581 jQuery
.globalEval( text
);
8587 // Handle cache's special case and crossDomain
8588 jQuery
.ajaxPrefilter( "script", function( s
) {
8589 if ( s
.cache
=== undefined ) {
8592 if ( s
.crossDomain
) {
8597 // Bind script tag hack transport
8598 jQuery
.ajaxTransport( "script", function( s
) {
8599 // This transport only deals with cross domain requests
8600 if ( s
.crossDomain
) {
8601 var script
, callback
;
8603 send: function( _
, complete
) {
8604 script
= jQuery("<script>").prop({
8606 charset
: s
.scriptCharset
,
8610 callback = function( evt
) {
8614 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
8618 document
.head
.appendChild( script
[ 0 ] );
8632 var oldCallbacks
= [],
8633 rjsonp
= /(=)\?(?=&|$)|\?\?/;
8635 // Default jsonp settings
8638 jsonpCallback: function() {
8639 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
++ ) );
8640 this[ callback
] = true;
8645 // Detect, normalize options and install callbacks for jsonp requests
8646 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
8648 var callbackName
, overwritten
, responseContainer
,
8649 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
8651 typeof s
.data
=== "string" && !( s
.contentType
|| "" ).indexOf("application/x-www-form-urlencoded") && rjsonp
.test( s
.data
) && "data"
8654 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8655 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
8657 // Get callback name, remembering preexisting value associated with it
8658 callbackName
= s
.jsonpCallback
= jQuery
.isFunction( s
.jsonpCallback
) ?
8662 // Insert callback into url or form data
8664 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
8665 } else if ( s
.jsonp
!== false ) {
8666 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
8669 // Use data converter to retrieve json after script execution
8670 s
.converters
["script json"] = function() {
8671 if ( !responseContainer
) {
8672 jQuery
.error( callbackName
+ " was not called" );
8674 return responseContainer
[ 0 ];
8677 // force json dataType
8678 s
.dataTypes
[ 0 ] = "json";
8681 overwritten
= window
[ callbackName
];
8682 window
[ callbackName
] = function() {
8683 responseContainer
= arguments
;
8686 // Clean-up function (fires after converters)
8687 jqXHR
.always(function() {
8688 // Restore preexisting value
8689 window
[ callbackName
] = overwritten
;
8691 // Save back as free
8692 if ( s
[ callbackName
] ) {
8693 // make sure that re-using the options doesn't screw things around
8694 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
8696 // save the callback name for future use
8697 oldCallbacks
.push( callbackName
);
8700 // Call if it was a function and we have a response
8701 if ( responseContainer
&& jQuery
.isFunction( overwritten
) ) {
8702 overwritten( responseContainer
[ 0 ] );
8705 responseContainer
= overwritten
= undefined;
8708 // Delegate to script
8716 // data: string of html
8717 // context (optional): If specified, the fragment will be created in this context, defaults to document
8718 // keepScripts (optional): If true, will include scripts passed in the html string
8719 jQuery
.parseHTML = function( data
, context
, keepScripts
) {
8720 if ( !data
|| typeof data
!== "string" ) {
8723 if ( typeof context
=== "boolean" ) {
8724 keepScripts
= context
;
8727 context
= context
|| document
;
8729 var parsed
= rsingleTag
.exec( data
),
8730 scripts
= !keepScripts
&& [];
8734 return [ context
.createElement( parsed
[1] ) ];
8737 parsed
= jQuery
.buildFragment( [ data
], context
, scripts
);
8739 if ( scripts
&& scripts
.length
) {
8740 jQuery( scripts
).remove();
8743 return jQuery
.merge( [], parsed
.childNodes
);
8747 // Keep a copy of the old load method
8748 var _load
= jQuery
.fn
.load
;
8751 * Load a url into a page
8753 jQuery
.fn
.load = function( url
, params
, callback
) {
8754 if ( typeof url
!== "string" && _load
) {
8755 return _load
.apply( this, arguments
);
8758 var selector
, type
, response
,
8760 off
= url
.indexOf(" ");
8763 selector
= url
.slice( off
);
8764 url
= url
.slice( 0, off
);
8767 // If it's a function
8768 if ( jQuery
.isFunction( params
) ) {
8770 // We assume that it's the callback
8774 // Otherwise, build a param string
8775 } else if ( params
&& typeof params
=== "object" ) {
8779 // If we have elements to modify, make the request
8780 if ( self
.length
> 0 ) {
8784 // if "type" variable is undefined, then "GET" method will be used
8788 }).done(function( responseText
) {
8790 // Save response for use in complete callback
8791 response
= arguments
;
8793 self
.html( selector
?
8795 // If a selector was specified, locate the right elements in a dummy div
8796 // Exclude scripts to avoid IE 'Permission Denied' errors
8797 jQuery("<div>").append( jQuery
.parseHTML( responseText
) ).find( selector
) :
8799 // Otherwise use the full result
8802 }).complete( callback
&& function( jqXHR
, status
) {
8803 self
.each( callback
, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
8813 jQuery
.expr
.filters
.animated = function( elem
) {
8814 return jQuery
.grep(jQuery
.timers
, function( fn
) {
8815 return elem
=== fn
.elem
;
8822 var docElem
= window
.document
.documentElement
;
8825 * Gets a window from an element
8827 function getWindow( elem
) {
8828 return jQuery
.isWindow( elem
) ? elem
: elem
.nodeType
=== 9 && elem
.defaultView
;
8832 setOffset: function( elem
, options
, i
) {
8833 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
8834 position
= jQuery
.css( elem
, "position" ),
8835 curElem
= jQuery( elem
),
8838 // Set position first, in-case top/left are set even on static elem
8839 if ( position
=== "static" ) {
8840 elem
.style
.position
= "relative";
8843 curOffset
= curElem
.offset();
8844 curCSSTop
= jQuery
.css( elem
, "top" );
8845 curCSSLeft
= jQuery
.css( elem
, "left" );
8846 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) &&
8847 ( curCSSTop
+ curCSSLeft
).indexOf("auto") > -1;
8849 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
8850 if ( calculatePosition
) {
8851 curPosition
= curElem
.position();
8852 curTop
= curPosition
.top
;
8853 curLeft
= curPosition
.left
;
8856 curTop
= parseFloat( curCSSTop
) || 0;
8857 curLeft
= parseFloat( curCSSLeft
) || 0;
8860 if ( jQuery
.isFunction( options
) ) {
8861 options
= options
.call( elem
, i
, curOffset
);
8864 if ( options
.top
!= null ) {
8865 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
8867 if ( options
.left
!= null ) {
8868 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
8871 if ( "using" in options
) {
8872 options
.using
.call( elem
, props
);
8875 curElem
.css( props
);
8881 offset: function( options
) {
8882 if ( arguments
.length
) {
8883 return options
=== undefined ?
8885 this.each(function( i
) {
8886 jQuery
.offset
.setOffset( this, options
, i
);
8892 box
= { top
: 0, left
: 0 },
8893 doc
= elem
&& elem
.ownerDocument
;
8899 docElem
= doc
.documentElement
;
8901 // Make sure it's not a disconnected DOM node
8902 if ( !jQuery
.contains( docElem
, elem
) ) {
8906 // If we don't have gBCR, just use 0,0 rather than error
8907 // BlackBerry 5, iOS 3 (original iPhone)
8908 if ( typeof elem
.getBoundingClientRect
!== strundefined
) {
8909 box
= elem
.getBoundingClientRect();
8911 win
= getWindow( doc
);
8913 top
: box
.top
+ win
.pageYOffset
- docElem
.clientTop
,
8914 left
: box
.left
+ win
.pageXOffset
- docElem
.clientLeft
8918 position: function() {
8923 var offsetParent
, offset
,
8925 parentOffset
= { top
: 0, left
: 0 };
8927 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
8928 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
8929 // We assume that getBoundingClientRect is available when computed position is fixed
8930 offset
= elem
.getBoundingClientRect();
8933 // Get *real* offsetParent
8934 offsetParent
= this.offsetParent();
8936 // Get correct offsets
8937 offset
= this.offset();
8938 if ( !jQuery
.nodeName( offsetParent
[ 0 ], "html" ) ) {
8939 parentOffset
= offsetParent
.offset();
8942 // Add offsetParent borders
8943 parentOffset
.top
+= jQuery
.css( offsetParent
[ 0 ], "borderTopWidth", true );
8944 parentOffset
.left
+= jQuery
.css( offsetParent
[ 0 ], "borderLeftWidth", true );
8947 // Subtract parent offsets and element margins
8949 top
: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
8950 left
: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
8954 offsetParent: function() {
8955 return this.map(function() {
8956 var offsetParent
= this.offsetParent
|| docElem
;
8958 while ( offsetParent
&& ( !jQuery
.nodeName( offsetParent
, "html" ) && jQuery
.css( offsetParent
, "position" ) === "static" ) ) {
8959 offsetParent
= offsetParent
.offsetParent
;
8962 return offsetParent
|| docElem
;
8967 // Create scrollLeft and scrollTop methods
8968 jQuery
.each( { scrollLeft
: "pageXOffset", scrollTop
: "pageYOffset" }, function( method
, prop
) {
8969 var top
= "pageYOffset" === prop
;
8971 jQuery
.fn
[ method
] = function( val
) {
8972 return access( this, function( elem
, method
, val
) {
8973 var win
= getWindow( elem
);
8975 if ( val
=== undefined ) {
8976 return win
? win
[ prop
] : elem
[ method
];
8981 !top
? val
: window
.pageXOffset
,
8982 top
? val
: window
.pageYOffset
8986 elem
[ method
] = val
;
8988 }, method
, val
, arguments
.length
, null );
8992 // Add the top/left cssHooks using jQuery.fn.position
8993 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
8994 // getComputedStyle returns percent when specified for top/left/bottom/right
8995 // rather than make the css module depend on the offset module, we just check for it here
8996 jQuery
.each( [ "top", "left" ], function( i
, prop
) {
8997 jQuery
.cssHooks
[ prop
] = addGetHookIf( support
.pixelPosition
,
8998 function( elem
, computed
) {
9000 computed
= curCSS( elem
, prop
);
9001 // if curCSS returns percentage, fallback to offset
9002 return rnumnonpx
.test( computed
) ?
9003 jQuery( elem
).position()[ prop
] + "px" :
9011 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9012 jQuery
.each( { Height
: "height", Width
: "width" }, function( name
, type
) {
9013 jQuery
.each( { padding
: "inner" + name
, content
: type
, "": "outer" + name
}, function( defaultExtra
, funcName
) {
9014 // margin is only for outerHeight, outerWidth
9015 jQuery
.fn
[ funcName
] = function( margin
, value
) {
9016 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
9017 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
9019 return access( this, function( elem
, type
, value
) {
9022 if ( jQuery
.isWindow( elem
) ) {
9023 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9024 // isn't a whole lot we can do. See pull request at this URL for discussion:
9025 // https://github.com/jquery/jquery/pull/764
9026 return elem
.document
.documentElement
[ "client" + name
];
9029 // Get document width or height
9030 if ( elem
.nodeType
=== 9 ) {
9031 doc
= elem
.documentElement
;
9033 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
9034 // whichever is greatest
9036 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
9037 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
9038 doc
[ "client" + name
]
9042 return value
=== undefined ?
9043 // Get width or height on the element, requesting but not forcing parseFloat
9044 jQuery
.css( elem
, type
, extra
) :
9046 // Set width or height on the element
9047 jQuery
.style( elem
, type
, value
, extra
);
9048 }, type
, chainable
? margin
: undefined, chainable
, null );
9054 // The number of elements contained in the matched element set
9055 jQuery
.fn
.size = function() {
9059 jQuery
.fn
.andSelf
= jQuery
.fn
.addBack
;
9064 // Register as a named AMD module, since jQuery can be concatenated with other
9065 // files that may use define, but not via a proper concatenation script that
9066 // understands anonymous AMD modules. A named AMD is safest and most robust
9067 // way to register. Lowercase jquery is used because AMD module names are
9068 // derived from file names, and jQuery is normally delivered in a lowercase
9069 // file name. Do this after creating the global so that if an AMD module wants
9070 // to call noConflict to hide this version of jQuery, it will work.
9071 if ( typeof define
=== "function" && define
.amd
) {
9072 define( "jquery", [], function() {
9081 // Map over jQuery in case of overwrite
9082 _jQuery
= window
.jQuery
,
9084 // Map over the $ in case of overwrite
9087 jQuery
.noConflict = function( deep
) {
9088 if ( window
.$ === jQuery
) {
9092 if ( deep
&& window
.jQuery
=== jQuery
) {
9093 window
.jQuery
= _jQuery
;
9099 // Expose jQuery and $ identifiers, even in
9100 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
9101 // and CommonJS for browser emulators (#13566)
9102 if ( typeof noGlobal
=== strundefined
) {
9103 window
.jQuery
= window
.$ = jQuery
;