2 * jQuery JavaScript Library v2.0.1
8 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2013-05-24T16:44Z
14 (function( window
, undefined ) {
16 // Can't do this because several apps including ASP.NET trace
17 // the stack via arguments.caller.callee and Firefox dies if
18 // you try to trace through "use strict" call chains. (#13335)
19 // Support: Firefox 18+
22 // A central reference to the root jQuery(document)
25 // The deferred used on DOM ready
29 // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined`
30 core_strundefined
= typeof undefined,
32 // Use the correct document accordingly with window argument (sandbox)
33 location
= window
.location
,
34 document
= window
.document
,
35 docElem
= document
.documentElement
,
37 // Map over jQuery in case of overwrite
38 _jQuery
= window
.jQuery
,
40 // Map over the $ in case of overwrite
43 // [[Class]] -> type pairs
46 // List of deleted data cache ids, so we can reuse them
49 core_version
= "2.0.1",
51 // Save a reference to some core methods
52 core_concat
= core_deletedIds
.concat
,
53 core_push
= core_deletedIds
.push
,
54 core_slice
= core_deletedIds
.slice
,
55 core_indexOf
= core_deletedIds
.indexOf
,
56 core_toString
= class2type
.toString
,
57 core_hasOwn
= class2type
.hasOwnProperty
,
58 core_trim
= core_version
.trim
,
60 // Define a local copy of jQuery
61 jQuery = function( selector
, context
) {
62 // The jQuery object is actually just the init constructor 'enhanced'
63 return new jQuery
.fn
.init( selector
, context
, rootjQuery
);
66 // Used for matching numbers
67 core_pnum
= /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source
,
69 // Used for splitting on whitespace
70 core_rnotwhite
= /\S+/g,
72 // A simple way to check for HTML strings
73 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
74 // Strict HTML recognition (#11290: must start with <)
75 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
77 // Match a standalone tag
78 rsingleTag
= /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
80 // Matches dashed string for camelizing
82 rdashAlpha
= /-([\da-z])/gi,
84 // Used by jQuery.camelCase as callback to replace()
85 fcamelCase = function( all
, letter
) {
86 return letter
.toUpperCase();
89 // The ready event handler and self cleanup method
90 completed = function() {
91 document
.removeEventListener( "DOMContentLoaded", completed
, false );
92 window
.removeEventListener( "load", completed
, false );
96 jQuery
.fn
= jQuery
.prototype = {
97 // The current version of jQuery being used
101 init: function( selector
, context
, rootjQuery
) {
104 // HANDLE: $(""), $(null), $(undefined), $(false)
109 // Handle HTML strings
110 if ( typeof selector
=== "string" ) {
111 if ( selector
.charAt(0) === "<" && selector
.charAt( selector
.length
- 1 ) === ">" && selector
.length
>= 3 ) {
112 // Assume that strings that start and end with <> are HTML and skip the regex check
113 match
= [ null, selector
, null ];
116 match
= rquickExpr
.exec( selector
);
119 // Match html or make sure no context is specified for #id
120 if ( match
&& (match
[1] || !context
) ) {
122 // HANDLE: $(html) -> $(array)
124 context
= context
instanceof jQuery
? context
[0] : context
;
126 // scripts is true for back-compat
127 jQuery
.merge( this, jQuery
.parseHTML(
129 context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
,
133 // HANDLE: $(html, props)
134 if ( rsingleTag
.test( match
[1] ) && jQuery
.isPlainObject( context
) ) {
135 for ( match
in context
) {
136 // Properties of context are called as methods if possible
137 if ( jQuery
.isFunction( this[ match
] ) ) {
138 this[ match
]( context
[ match
] );
140 // ...and otherwise set as attributes
142 this.attr( match
, context
[ match
] );
151 elem
= document
.getElementById( match
[2] );
153 // Check parentNode to catch when Blackberry 4.6 returns
154 // nodes that are no longer in the document #6963
155 if ( elem
&& elem
.parentNode
) {
156 // Inject the element directly into the jQuery object
161 this.context
= document
;
162 this.selector
= selector
;
166 // HANDLE: $(expr, $(...))
167 } else if ( !context
|| context
.jquery
) {
168 return ( context
|| rootjQuery
).find( selector
);
170 // HANDLE: $(expr, context)
171 // (which is just equivalent to: $(context).find(expr)
173 return this.constructor( context
).find( selector
);
176 // HANDLE: $(DOMElement)
177 } else if ( selector
.nodeType
) {
178 this.context
= this[0] = selector
;
182 // HANDLE: $(function)
183 // Shortcut for document ready
184 } else if ( jQuery
.isFunction( selector
) ) {
185 return rootjQuery
.ready( selector
);
188 if ( selector
.selector
!== undefined ) {
189 this.selector
= selector
.selector
;
190 this.context
= selector
.context
;
193 return jQuery
.makeArray( selector
, this );
196 // Start with an empty selector
199 // The default length of a jQuery object is 0
202 toArray: function() {
203 return core_slice
.call( this );
206 // Get the Nth element in the matched element set OR
207 // Get the whole matched element set as a clean array
208 get: function( num
) {
211 // Return a 'clean' array
214 // Return just the object
215 ( num
< 0 ? this[ this.length
+ num
] : this[ num
] );
218 // Take an array of elements and push it onto the stack
219 // (returning the new matched element set)
220 pushStack: function( elems
) {
222 // Build a new jQuery matched element set
223 var ret
= jQuery
.merge( this.constructor(), elems
);
225 // Add the old object onto the stack (as a reference)
226 ret
.prevObject
= this;
227 ret
.context
= this.context
;
229 // Return the newly-formed element set
233 // Execute a callback for every element in the matched set.
234 // (You can seed the arguments with an array of args, but this is
235 // only used internally.)
236 each: function( callback
, args
) {
237 return jQuery
.each( this, callback
, args
);
240 ready: function( fn
) {
242 jQuery
.ready
.promise().done( fn
);
248 return this.pushStack( core_slice
.apply( this, arguments
) );
256 return this.eq( -1 );
260 var len
= this.length
,
261 j
= +i
+ ( i
< 0 ? len
: 0 );
262 return this.pushStack( j
>= 0 && j
< len
? [ this[j
] ] : [] );
265 map: function( callback
) {
266 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
267 return callback
.call( elem
, i
, elem
);
272 return this.prevObject
|| this.constructor(null);
275 // For internal use only.
276 // Behaves like an Array's method, not like a jQuery method.
282 // Give the init function the jQuery prototype for later instantiation
283 jQuery
.fn
.init
.prototype = jQuery
.fn
;
285 jQuery
.extend
= jQuery
.fn
.extend = function() {
286 var options
, name
, src
, copy
, copyIsArray
, clone
,
287 target
= arguments
[0] || {},
289 length
= arguments
.length
,
292 // Handle a deep copy situation
293 if ( typeof target
=== "boolean" ) {
295 target
= arguments
[1] || {};
296 // skip the boolean and the target
300 // Handle case when target is a string or something (possible in deep copy)
301 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
305 // extend jQuery itself if only one argument is passed
306 if ( length
=== i
) {
311 for ( ; i
< length
; i
++ ) {
312 // Only deal with non-null/undefined values
313 if ( (options
= arguments
[ i
]) != null ) {
314 // Extend the base object
315 for ( name
in options
) {
316 src
= target
[ name
];
317 copy
= options
[ name
];
319 // Prevent never-ending loop
320 if ( target
=== copy
) {
324 // Recurse if we're merging plain objects or arrays
325 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || (copyIsArray
= jQuery
.isArray(copy
)) ) ) {
328 clone
= src
&& jQuery
.isArray(src
) ? src
: [];
331 clone
= src
&& jQuery
.isPlainObject(src
) ? src
: {};
334 // Never move original objects, clone them
335 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
337 // Don't bring in undefined values
338 } else if ( copy
!== undefined ) {
339 target
[ name
] = copy
;
345 // Return the modified object
350 // Unique for each copy of jQuery on the page
351 expando
: "jQuery" + ( core_version
+ Math
.random() ).replace( /\D/g, "" ),
353 noConflict: function( deep
) {
354 if ( window
.$ === jQuery
) {
358 if ( deep
&& window
.jQuery
=== jQuery
) {
359 window
.jQuery
= _jQuery
;
365 // Is the DOM ready to be used? Set to true once it occurs.
368 // A counter to track how many items to wait for before
369 // the ready event fires. See #6781
372 // Hold (or release) the ready event
373 holdReady: function( hold
) {
377 jQuery
.ready( true );
381 // Handle when the DOM is ready
382 ready: function( wait
) {
384 // Abort if there are pending holds or we're already ready
385 if ( wait
=== true ? --jQuery
.readyWait
: jQuery
.isReady
) {
389 // Remember that the DOM is ready
390 jQuery
.isReady
= true;
392 // If a normal DOM Ready event fired, decrement, and wait if need be
393 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
397 // If there are functions bound, to execute
398 readyList
.resolveWith( document
, [ jQuery
] );
400 // Trigger any bound ready events
401 if ( jQuery
.fn
.trigger
) {
402 jQuery( document
).trigger("ready").off("ready");
406 // See test/unit/core.js for details concerning isFunction.
407 // Since version 1.3, DOM methods and functions like alert
408 // aren't supported. They return false on IE (#2968).
409 isFunction: function( obj
) {
410 return jQuery
.type(obj
) === "function";
413 isArray
: Array
.isArray
,
415 isWindow: function( obj
) {
416 return obj
!= null && obj
=== obj
.window
;
419 isNumeric: function( obj
) {
420 return !isNaN( parseFloat(obj
) ) && isFinite( obj
);
423 type: function( obj
) {
425 return String( obj
);
427 // Support: Safari <= 5.1 (functionish RegExp)
428 return typeof obj
=== "object" || typeof obj
=== "function" ?
429 class2type
[ core_toString
.call(obj
) ] || "object" :
433 isPlainObject: function( obj
) {
434 // Not plain objects:
435 // - Any object or value whose internal [[Class]] property is not "[object Object]"
438 if ( jQuery
.type( obj
) !== "object" || obj
.nodeType
|| jQuery
.isWindow( obj
) ) {
442 // Support: Firefox <20
443 // The try/catch suppresses exceptions thrown when attempting to access
444 // the "constructor" property of certain host objects, ie. |window.location|
445 // https://bugzilla.mozilla.org/show_bug.cgi?id=814622
447 if ( obj
.constructor &&
448 !core_hasOwn
.call( obj
.constructor.prototype, "isPrototypeOf" ) ) {
455 // If the function hasn't returned already, we're confident that
456 // |obj| is a plain object, created by {} or constructed with new Object
460 isEmptyObject: function( obj
) {
462 for ( name
in obj
) {
468 error: function( msg
) {
469 throw new Error( msg
);
472 // data: string of html
473 // context (optional): If specified, the fragment will be created in this context, defaults to document
474 // keepScripts (optional): If true, will include scripts passed in the html string
475 parseHTML: function( data
, context
, keepScripts
) {
476 if ( !data
|| typeof data
!== "string" ) {
479 if ( typeof context
=== "boolean" ) {
480 keepScripts
= context
;
483 context
= context
|| document
;
485 var parsed
= rsingleTag
.exec( data
),
486 scripts
= !keepScripts
&& [];
490 return [ context
.createElement( parsed
[1] ) ];
493 parsed
= jQuery
.buildFragment( [ data
], context
, scripts
);
496 jQuery( scripts
).remove();
499 return jQuery
.merge( [], parsed
.childNodes
);
502 parseJSON
: JSON
.parse
,
504 // Cross-browser xml parsing
505 parseXML: function( data
) {
507 if ( !data
|| typeof data
!== "string" ) {
513 tmp
= new DOMParser();
514 xml
= tmp
.parseFromString( data
, "text/xml" );
519 if ( !xml
|| xml
.getElementsByTagName( "parsererror" ).length
) {
520 jQuery
.error( "Invalid XML: " + data
);
527 // Evaluates a script in a global context
528 globalEval: function( code
) {
532 code
= jQuery
.trim( code
);
535 // If the code includes a valid, prologue position
536 // strict mode pragma, execute code by injecting a
537 // script tag into the document.
538 if ( code
.indexOf("use strict") === 1 ) {
539 script
= document
.createElement("script");
541 document
.head
.appendChild( script
).parentNode
.removeChild( script
);
543 // Otherwise, avoid the DOM node creation, insertion
544 // and removal by using an indirect global eval
550 // Convert dashed to camelCase; used by the css and data modules
551 // Microsoft forgot to hump their vendor prefix (#9572)
552 camelCase: function( string
) {
553 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
556 nodeName: function( elem
, name
) {
557 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
560 // args is for internal usage only
561 each: function( obj
, callback
, args
) {
565 isArray
= isArraylike( obj
);
569 for ( ; i
< length
; i
++ ) {
570 value
= callback
.apply( obj
[ i
], args
);
572 if ( value
=== false ) {
578 value
= callback
.apply( obj
[ i
], args
);
580 if ( value
=== false ) {
586 // A special, fast, case for the most common use of each
589 for ( ; i
< length
; i
++ ) {
590 value
= callback
.call( obj
[ i
], i
, obj
[ i
] );
592 if ( value
=== false ) {
598 value
= callback
.call( obj
[ i
], i
, obj
[ i
] );
600 if ( value
=== false ) {
610 trim: function( text
) {
611 return text
== null ? "" : core_trim
.call( text
);
614 // results is for internal usage only
615 makeArray: function( arr
, results
) {
616 var ret
= results
|| [];
619 if ( isArraylike( Object(arr
) ) ) {
621 typeof arr
=== "string" ?
625 core_push
.call( ret
, arr
);
632 inArray: function( elem
, arr
, i
) {
633 return arr
== null ? -1 : core_indexOf
.call( arr
, elem
, i
);
636 merge: function( first
, second
) {
637 var l
= second
.length
,
641 if ( typeof l
=== "number" ) {
642 for ( ; j
< l
; j
++ ) {
643 first
[ i
++ ] = second
[ j
];
646 while ( second
[j
] !== undefined ) {
647 first
[ i
++ ] = second
[ j
++ ];
656 grep: function( elems
, callback
, inv
) {
660 length
= elems
.length
;
663 // Go through the array, only saving the items
664 // that pass the validator function
665 for ( ; i
< length
; i
++ ) {
666 retVal
= !!callback( elems
[ i
], i
);
667 if ( inv
!== retVal
) {
668 ret
.push( elems
[ i
] );
675 // arg is for internal usage only
676 map: function( elems
, callback
, arg
) {
679 length
= elems
.length
,
680 isArray
= isArraylike( elems
),
683 // Go through the array, translating each of the items to their
685 for ( ; i
< length
; i
++ ) {
686 value
= callback( elems
[ i
], i
, arg
);
688 if ( value
!= null ) {
689 ret
[ ret
.length
] = value
;
693 // Go through every key on the object,
696 value
= callback( elems
[ i
], i
, arg
);
698 if ( value
!= null ) {
699 ret
[ ret
.length
] = value
;
704 // Flatten any nested arrays
705 return core_concat
.apply( [], ret
);
708 // A global GUID counter for objects
711 // Bind a function to a context, optionally partially applying any
713 proxy: function( fn
, context
) {
714 var tmp
, args
, proxy
;
716 if ( typeof context
=== "string" ) {
722 // Quick check to determine if target is callable, in the spec
723 // this throws a TypeError, but we will just return undefined.
724 if ( !jQuery
.isFunction( fn
) ) {
729 args
= core_slice
.call( arguments
, 2 );
731 return fn
.apply( context
|| this, args
.concat( core_slice
.call( arguments
) ) );
734 // Set the guid of unique handler to the same of original handler, so it can be removed
735 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
740 // Multifunctional method to get and set values of a collection
741 // The value/s can optionally be executed if it's a function
742 access: function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
744 length
= elems
.length
,
748 if ( jQuery
.type( key
) === "object" ) {
751 jQuery
.access( elems
, fn
, i
, key
[i
], true, emptyGet
, raw
);
755 } else if ( value
!== undefined ) {
758 if ( !jQuery
.isFunction( value
) ) {
763 // Bulk operations run against the entire set
765 fn
.call( elems
, value
);
768 // ...except when executing function values
771 fn = function( elem
, key
, value
) {
772 return bulk
.call( jQuery( elem
), value
);
778 for ( ; i
< length
; i
++ ) {
779 fn( elems
[i
], key
, raw
? value
: value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) );
790 length
? fn( elems
[0], key
) : emptyGet
;
795 // A method for quickly swapping in/out CSS properties to get correct calculations.
796 // Note: this method belongs to the css module but it's needed here for the support module.
797 // If support gets modularized, this method should be moved back to the css module.
798 swap: function( elem
, options
, callback
, args
) {
802 // Remember the old values, and insert the new ones
803 for ( name
in options
) {
804 old
[ name
] = elem
.style
[ name
];
805 elem
.style
[ name
] = options
[ name
];
808 ret
= callback
.apply( elem
, args
|| [] );
810 // Revert the old values
811 for ( name
in options
) {
812 elem
.style
[ name
] = old
[ name
];
819 jQuery
.ready
.promise = function( obj
) {
822 readyList
= jQuery
.Deferred();
824 // Catch cases where $(document).ready() is called after the browser event has already occurred.
825 // we once tried to use readyState "interactive" here, but it caused issues like the one
826 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
827 if ( document
.readyState
=== "complete" ) {
828 // Handle it asynchronously to allow scripts the opportunity to delay ready
829 setTimeout( jQuery
.ready
);
833 // Use the handy event callback
834 document
.addEventListener( "DOMContentLoaded", completed
, false );
836 // A fallback to window.onload, that will always work
837 window
.addEventListener( "load", completed
, false );
840 return readyList
.promise( obj
);
843 // Populate the class2type map
844 jQuery
.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i
, name
) {
845 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
848 function isArraylike( obj
) {
849 var length
= obj
.length
,
850 type
= jQuery
.type( obj
);
852 if ( jQuery
.isWindow( obj
) ) {
856 if ( obj
.nodeType
=== 1 && length
) {
860 return type
=== "array" || type
!== "function" &&
862 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
);
865 // All jQuery objects should point back to these
866 rootjQuery
= jQuery(document
);
868 * Sizzle CSS Selector Engine v1.9.4-pre
869 * http://sizzlejs.com/
871 * Copyright 2013 jQuery Foundation, Inc. and other contributors
872 * Released under the MIT license
873 * http://jquery.org/license
877 (function( window
, undefined ) {
889 // Local document vars
899 // Instance-specific data
900 expando
= "sizzle" + -(new Date()),
901 preferredDoc
= window
.document
,
904 classCache
= createCache(),
905 tokenCache
= createCache(),
906 compilerCache
= createCache(),
907 hasDuplicate
= false,
908 sortOrder = function() { return 0; },
910 // General-purpose constants
911 strundefined
= typeof undefined,
912 MAX_NEGATIVE
= 1 << 31,
915 hasOwn
= ({}).hasOwnProperty
,
918 push_native
= arr
.push
,
921 // Use a stripped-down indexOf if we can't use a native one
922 indexOf
= arr
.indexOf
|| function( elem
) {
925 for ( ; i
< len
; i
++ ) {
926 if ( this[i
] === elem
) {
933 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
935 // Regular expressions
937 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
938 whitespace
= "[\\x20\\t\\r\\n\\f]",
939 // http://www.w3.org/TR/css3-syntax/#characters
940 characterEncoding
= "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
942 // Loosely modeled on CSS identifier characters
943 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
944 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
945 identifier
= characterEncoding
.replace( "w", "w#" ),
947 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
948 attributes
= "\\[" + whitespace
+ "*(" + characterEncoding
+ ")" + whitespace
+
949 "*(?:([*^$|!~]?=)" + whitespace
+ "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier
+ ")|)|)" + whitespace
+ "*\\]",
951 // Prefer arguments quoted,
952 // then not containing pseudos/brackets,
953 // then attribute selectors/non-parenthetical expressions,
954 // then anything else
955 // These preferences are here to reduce the number of selectors
956 // needing tokenize in the PSEUDO preFilter
957 pseudos
= ":(" + characterEncoding
+ ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes
.replace( 3, 8 ) + ")*)|.*)\\)|)",
959 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
960 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
962 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
963 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
965 rsibling
= new RegExp( whitespace
+ "*[+~]" ),
966 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*)" + whitespace
+ "*\\]", "g" ),
968 rpseudo
= new RegExp( pseudos
),
969 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
972 "ID": new RegExp( "^#(" + characterEncoding
+ ")" ),
973 "CLASS": new RegExp( "^\\.(" + characterEncoding
+ ")" ),
974 "TAG": new RegExp( "^(" + characterEncoding
.replace( "w", "w*" ) + ")" ),
975 "ATTR": new RegExp( "^" + attributes
),
976 "PSEUDO": new RegExp( "^" + pseudos
),
977 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
978 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
979 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
980 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
981 // For use in libraries implementing .is()
982 // We use this for POS matching in `select`
983 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
984 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
987 rnative
= /^[^{]+\{\s*\[native \w/,
989 // Easily-parseable/retrievable ID or TAG or CLASS selectors
990 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
992 rinputs
= /^(?:input|select|textarea|button)$/i,
997 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
998 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
999 funescape = function( _, escaped, escapedWhitespace ) {
1000 var high = "0x" + escaped - 0x10000;
1001 // NaN means non-codepoint
1003 // Workaround erroneous numeric interpretation of +"0x"
1004 return high !== high || escapedWhitespace ?
1008 String.fromCharCode( high + 0x10000 ) :
1009 // Supplemental Plane codepoint (surrogate pair)
1010 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
1013 // Optimize for push.apply( _, NodeList )
1016 (arr = slice.call( preferredDoc.childNodes )),
1017 preferredDoc.childNodes
1019 // Support: Android<4.0
1020 // Detect silently failing push.apply
1021 arr[ preferredDoc.childNodes.length ].nodeType;
1023 push = { apply: arr.length ?
1025 // Leverage slice if possible
1026 function( target, els ) {
1027 push_native.apply( target, slice.call(els) );
1031 // Otherwise append directly
1032 function( target, els ) {
1033 var j = target.length,
1035 // Can't trust NodeList
.length
1036 while ( (target
[j
++] = els
[i
++]) ) {}
1037 target
.length
= j
- 1;
1042 function Sizzle( selector
, context
, results
, seed
) {
1043 var match
, elem
, m
, nodeType
,
1045 i
, groups
, old
, nid
, newContext
, newSelector
;
1047 if ( ( context
? context
.ownerDocument
|| context
: preferredDoc
) !== document
) {
1048 setDocument( context
);
1051 context
= context
|| document
;
1052 results
= results
|| [];
1054 if ( !selector
|| typeof selector
!== "string" ) {
1058 if ( (nodeType
= context
.nodeType
) !== 1 && nodeType
!== 9 ) {
1062 if ( documentIsHTML
&& !seed
) {
1065 if ( (match
= rquickExpr
.exec( selector
)) ) {
1066 // Speed-up: Sizzle("#ID")
1067 if ( (m
= match
[1]) ) {
1068 if ( nodeType
=== 9 ) {
1069 elem
= context
.getElementById( m
);
1070 // Check parentNode to catch when Blackberry 4.6 returns
1071 // nodes that are no longer in the document #6963
1072 if ( elem
&& elem
.parentNode
) {
1073 // Handle the case where IE, Opera, and Webkit return items
1074 // by name instead of ID
1075 if ( elem
.id
=== m
) {
1076 results
.push( elem
);
1083 // Context is not a document
1084 if ( context
.ownerDocument
&& (elem
= context
.ownerDocument
.getElementById( m
)) &&
1085 contains( context
, elem
) && elem
.id
=== m
) {
1086 results
.push( elem
);
1091 // Speed-up: Sizzle("TAG")
1092 } else if ( match
[2] ) {
1093 push
.apply( results
, context
.getElementsByTagName( selector
) );
1096 // Speed-up: Sizzle(".CLASS")
1097 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&& context
.getElementsByClassName
) {
1098 push
.apply( results
, context
.getElementsByClassName( m
) );
1104 if ( support
.qsa
&& (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
1105 nid
= old
= expando
;
1106 newContext
= context
;
1107 newSelector
= nodeType
=== 9 && selector
;
1109 // qSA works strangely on Element-rooted queries
1110 // We can work around this by specifying an extra ID on the root
1111 // and working up from there (Thanks to Andrew Dupont for the technique)
1112 // IE 8 doesn't work on object elements
1113 if ( nodeType
=== 1 && context
.nodeName
.toLowerCase() !== "object" ) {
1114 groups
= tokenize( selector
);
1116 if ( (old
= context
.getAttribute("id")) ) {
1117 nid
= old
.replace( rescape
, "\\$&" );
1119 context
.setAttribute( "id", nid
);
1121 nid
= "[id='" + nid
+ "'] ";
1125 groups
[i
] = nid
+ toSelector( groups
[i
] );
1127 newContext
= rsibling
.test( selector
) && context
.parentNode
|| context
;
1128 newSelector
= groups
.join(",");
1131 if ( newSelector
) {
1133 push
.apply( results
,
1134 newContext
.querySelectorAll( newSelector
)
1140 context
.removeAttribute("id");
1148 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
1152 * For feature detection
1153 * @param {Function} fn The function to test for native support
1155 function isNative( fn
) {
1156 return rnative
.test( fn
+ "" );
1160 * Create key-value caches of limited size
1161 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
1162 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
1163 * deleting the oldest entry
1165 function createCache() {
1168 function cache( key
, value
) {
1169 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
1170 if ( keys
.push( key
+= " " ) > Expr
.cacheLength
) {
1171 // Only keep the most recent entries
1172 delete cache
[ keys
.shift() ];
1174 return (cache
[ key
] = value
);
1180 * Mark a function for special use by Sizzle
1181 * @param {Function} fn The function to mark
1183 function markFunction( fn
) {
1184 fn
[ expando
] = true;
1189 * Support testing using an element
1190 * @param {Function} fn Passed the created div and expects a boolean result
1192 function assert( fn
) {
1193 var div
= document
.createElement("div");
1200 // Remove from its parent by default
1201 if ( div
.parentNode
) {
1202 div
.parentNode
.removeChild( div
);
1204 // release memory in IE
1210 * Adds the same handler for all of the specified attrs
1211 * @param {String} attrs Pipe-separated list of attributes
1212 * @param {Function} handler The method that will be applied if the test fails
1213 * @param {Boolean} test The result of a test. If true, null will be set as the handler in leiu of the specified handler
1215 function addHandle( attrs
, handler
, test
) {
1216 attrs
= attrs
.split("|");
1219 setHandle
= test
? null : handler
;
1222 // Don't override a user's handler
1223 if ( !(current
= Expr
.attrHandle
[ attrs
[i
] ]) || current
=== handler
) {
1224 Expr
.attrHandle
[ attrs
[i
] ] = setHandle
;
1230 * Fetches boolean attributes by node
1231 * @param {Element} elem
1232 * @param {String} name
1234 function boolHandler( elem
, name
) {
1235 // XML does not need to be checked as this will not be assigned for XML documents
1236 var val
= elem
.getAttributeNode( name
);
1237 return val
&& val
.specified
?
1239 elem
[ name
] === true ? name
.toLowerCase() : null;
1243 * Fetches attributes without interpolation
1244 * http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
1245 * @param {Element} elem
1246 * @param {String} name
1248 function interpolationHandler( elem
, name
) {
1249 // XML does not need to be checked as this will not be assigned for XML documents
1250 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
1254 * Uses defaultValue to retrieve value in IE6/7
1255 * @param {Element} elem
1256 * @param {String} name
1258 function valueHandler( elem
) {
1259 // Ignore the value *property* on inputs by using defaultValue
1260 // Fallback to Sizzle.attr by returning undefined where appropriate
1261 // XML does not need to be checked as this will not be assigned for XML documents
1262 if ( elem
.nodeName
.toLowerCase() === "input" ) {
1263 return elem
.defaultValue
;
1268 * Checks document order of two siblings
1269 * @param {Element} a
1270 * @param {Element} b
1271 * @returns Returns -1 if a precedes b, 1 if a follows b
1273 function siblingCheck( a
, b
) {
1275 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
1276 ( ~b
.sourceIndex
|| MAX_NEGATIVE
) -
1277 ( ~a
.sourceIndex
|| MAX_NEGATIVE
);
1279 // Use IE sourceIndex if available on both nodes
1284 // Check if b follows a
1286 while ( (cur
= cur
.nextSibling
) ) {
1297 * Returns a function to use in pseudos for input types
1298 * @param {String} type
1300 function createInputPseudo( type
) {
1301 return function( elem
) {
1302 var name
= elem
.nodeName
.toLowerCase();
1303 return name
=== "input" && elem
.type
=== type
;
1308 * Returns a function to use in pseudos for buttons
1309 * @param {String} type
1311 function createButtonPseudo( type
) {
1312 return function( elem
) {
1313 var name
= elem
.nodeName
.toLowerCase();
1314 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
1319 * Returns a function to use in pseudos for positionals
1320 * @param {Function} fn
1322 function createPositionalPseudo( fn
) {
1323 return markFunction(function( argument
) {
1324 argument
= +argument
;
1325 return markFunction(function( seed
, matches
) {
1327 matchIndexes
= fn( [], seed
.length
, argument
),
1328 i
= matchIndexes
.length
;
1330 // Match elements found at the specified indexes
1332 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
1333 seed
[j
] = !(matches
[j
] = seed
[j
]);
1342 * @param {Element|Object} elem An element or a document
1344 isXML
= Sizzle
.isXML = function( elem
) {
1345 // documentElement is verified for cases where it doesn't yet exist
1346 // (such as loading iframes in IE - #4833)
1347 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
1348 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1351 // Expose support vars for convenience
1352 support
= Sizzle
.support
= {};
1355 * Sets document-related variables once based on the current document
1356 * @param {Element|Object} [doc] An element or document object to use to set the document
1357 * @returns {Object} Returns the current document
1359 setDocument
= Sizzle
.setDocument = function( node
) {
1360 var doc
= node
? node
.ownerDocument
|| node
: preferredDoc
;
1362 // If no document and documentElement is available, return
1363 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1369 docElem
= doc
.documentElement
;
1372 documentIsHTML
= !isXML( doc
);
1375 ---------------------------------------------------------------------- */
1378 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1379 support
.attributes
= assert(function( div
) {
1382 // Prevent attribute/property "interpolation"
1383 div
.innerHTML
= "<a href='#'></a>";
1384 addHandle( "type|href|height|width", interpolationHandler
, div
.firstChild
.getAttribute("href") === "#" );
1387 // Use getAttributeNode to fetch booleans when getAttribute lies
1388 addHandle( booleans
, boolHandler
, div
.getAttribute("disabled") == null );
1390 div
.className
= "i";
1391 return !div
.getAttribute("className");
1395 // Retrieving value should defer to defaultValue
1396 support
.input
= assert(function( div
) {
1397 div
.innerHTML
= "<input>";
1398 div
.firstChild
.setAttribute( "value", "" );
1399 return div
.firstChild
.getAttribute( "value" ) === "";
1402 // IE6/7 still return empty string for value,
1403 // but are actually retrieving the property
1404 addHandle( "value", valueHandler
, support
.attributes
&& support
.input
);
1407 ---------------------------------------------------------------------- */
1409 // Check if getElementsByTagName("*") returns only elements
1410 support
.getElementsByTagName
= assert(function( div
) {
1411 div
.appendChild( doc
.createComment("") );
1412 return !div
.getElementsByTagName("*").length
;
1415 // Check if getElementsByClassName can be trusted
1416 support
.getElementsByClassName
= assert(function( div
) {
1417 div
.innerHTML
= "<div class='a'></div><div class='a i'></div>";
1419 // Support: Safari<4
1420 // Catch class over-caching
1421 div
.firstChild
.className
= "i";
1422 // Support: Opera<10
1423 // Catch gEBCN failure to find non-leading classes
1424 return div
.getElementsByClassName("i").length
=== 2;
1428 // Check if getElementById returns elements by name
1429 // The broken getElementById methods don't pick up programatically-set names,
1430 // so use a roundabout getElementsByName test
1431 support
.getById
= assert(function( div
) {
1432 docElem
.appendChild( div
).id
= expando
;
1433 return !doc
.getElementsByName
|| !doc
.getElementsByName( expando
).length
;
1436 // ID find and filter
1437 if ( support
.getById
) {
1438 Expr
.find
["ID"] = function( id
, context
) {
1439 if ( typeof context
.getElementById
!== strundefined
&& documentIsHTML
) {
1440 var m
= context
.getElementById( id
);
1441 // Check parentNode to catch when Blackberry 4.6 returns
1442 // nodes that are no longer in the document #6963
1443 return m
&& m
.parentNode
? [m
] : [];
1446 Expr
.filter
["ID"] = function( id
) {
1447 var attrId
= id
.replace( runescape
, funescape
);
1448 return function( elem
) {
1449 return elem
.getAttribute("id") === attrId
;
1454 // getElementById is not reliable as a find shortcut
1455 delete Expr
.find
["ID"];
1457 Expr
.filter
["ID"] = function( id
) {
1458 var attrId
= id
.replace( runescape
, funescape
);
1459 return function( elem
) {
1460 var node
= typeof elem
.getAttributeNode
!== strundefined
&& elem
.getAttributeNode("id");
1461 return node
&& node
.value
=== attrId
;
1467 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1468 function( tag
, context
) {
1469 if ( typeof context
.getElementsByTagName
!== strundefined
) {
1470 return context
.getElementsByTagName( tag
);
1473 function( tag
, context
) {
1477 results
= context
.getElementsByTagName( tag
);
1479 // Filter out possible comments
1480 if ( tag
=== "*" ) {
1481 while ( (elem
= results
[i
++]) ) {
1482 if ( elem
.nodeType
=== 1 ) {
1493 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1494 if ( typeof context
.getElementsByClassName
!== strundefined
&& documentIsHTML
) {
1495 return context
.getElementsByClassName( className
);
1499 /* QSA/matchesSelector
1500 ---------------------------------------------------------------------- */
1502 // QSA and matchesSelector support
1504 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1507 // qSa(:focus) reports false when true (Chrome 21)
1508 // We allow this because of a bug in IE8/9 that throws an error
1509 // whenever `document.activeElement` is accessed on an iframe
1510 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1511 // See http://bugs.jquery.com/ticket/13378
1514 if ( (support
.qsa
= isNative(doc
.querySelectorAll
)) ) {
1516 // Regex strategy adopted from Diego Perini
1517 assert(function( div
) {
1518 // Select is set to empty string on purpose
1519 // This is to test IE's treatment of not explicitly
1520 // setting a boolean content attribute,
1521 // since its presence should be enough
1522 // http://bugs.jquery.com/ticket/12359
1523 div
.innerHTML
= "<select><option selected=''></option></select>";
1526 // Boolean attributes and "value" are not treated correctly
1527 if ( !div
.querySelectorAll("[selected]").length
) {
1528 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1531 // Webkit/Opera - :checked should return selected option elements
1532 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1533 // IE8 throws error here and will not see later tests
1534 if ( !div
.querySelectorAll(":checked").length
) {
1535 rbuggyQSA
.push(":checked");
1539 assert(function( div
) {
1541 // Support: Opera 10-12/IE8
1542 // ^= $= *= and empty values
1543 // Should not select anything
1544 // Support: Windows 8 Native Apps
1545 // The type attribute is restricted during .innerHTML assignment
1546 var input
= doc
.createElement("input");
1547 input
.setAttribute( "type", "hidden" );
1548 div
.appendChild( input
).setAttribute( "t", "" );
1550 if ( div
.querySelectorAll("[t^='']").length
) {
1551 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1554 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1555 // IE8 throws error here and will not see later tests
1556 if ( !div
.querySelectorAll(":enabled").length
) {
1557 rbuggyQSA
.push( ":enabled", ":disabled" );
1560 // Opera 10-11 does not throw on post-comma invalid pseudos
1561 div
.querySelectorAll("*,:x");
1562 rbuggyQSA
.push(",.*:");
1566 if ( (support
.matchesSelector
= isNative( (matches
= docElem
.webkitMatchesSelector
||
1567 docElem
.mozMatchesSelector
||
1568 docElem
.oMatchesSelector
||
1569 docElem
.msMatchesSelector
) )) ) {
1571 assert(function( div
) {
1572 // Check to see if it's possible to do matchesSelector
1573 // on a disconnected node (IE 9)
1574 support
.disconnectedMatch
= matches
.call( div
, "div" );
1576 // This should fail with an exception
1577 // Gecko does not error, returns false instead
1578 matches
.call( div
, "[s!='']:x" );
1579 rbuggyMatches
.push( "!=", pseudos
);
1583 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1584 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1587 ---------------------------------------------------------------------- */
1589 // Element contains another
1590 // Purposefully does not implement inclusive descendent
1591 // As in, an element does not contain itself
1592 contains
= isNative(docElem
.contains
) || docElem
.compareDocumentPosition
?
1594 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
1595 bup
= b
&& b
.parentNode
;
1596 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1598 adown
.contains( bup
) :
1599 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1604 while ( (b
= b
.parentNode
) ) {
1614 ---------------------------------------------------------------------- */
1616 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
1617 // Detached nodes confoundingly follow *each other*
1618 support
.sortDetached
= assert(function( div1
) {
1619 // Should return 1, but returns 4 (following)
1620 return div1
.compareDocumentPosition( doc
.createElement("div") ) & 1;
1623 // Document order sorting
1624 sortOrder
= docElem
.compareDocumentPosition
?
1627 // Flag for duplicate removal
1629 hasDuplicate
= true;
1633 var compare
= b
.compareDocumentPosition
&& a
.compareDocumentPosition
&& a
.compareDocumentPosition( b
);
1636 // Disconnected nodes
1638 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1640 // Choose the first element that is related to our preferred document
1641 if ( a
=== doc
|| contains(preferredDoc
, a
) ) {
1644 if ( b
=== doc
|| contains(preferredDoc
, b
) ) {
1648 // Maintain original order
1650 ( indexOf
.call( sortInput
, a
) - indexOf
.call( sortInput
, b
) ) :
1654 return compare
& 4 ? -1 : 1;
1657 // Not directly comparable, sort on existence of method
1658 return a
.compareDocumentPosition
? -1 : 1;
1668 // Exit early if the nodes are identical
1670 hasDuplicate
= true;
1673 // Parentless nodes are either documents or disconnected
1674 } else if ( !aup
|| !bup
) {
1675 return a
=== doc
? -1 :
1680 ( indexOf
.call( sortInput
, a
) - indexOf
.call( sortInput
, b
) ) :
1683 // If the nodes are siblings, we can do a quick check
1684 } else if ( aup
=== bup
) {
1685 return siblingCheck( a
, b
);
1688 // Otherwise we need full lists of their ancestors for comparison
1690 while ( (cur
= cur
.parentNode
) ) {
1694 while ( (cur
= cur
.parentNode
) ) {
1698 // Walk down the tree looking for a discrepancy
1699 while ( ap
[i
] === bp
[i
] ) {
1704 // Do a sibling check if the nodes have a common ancestor
1705 siblingCheck( ap
[i
], bp
[i
] ) :
1707 // Otherwise nodes in our document sort first
1708 ap
[i
] === preferredDoc
? -1 :
1709 bp
[i
] === preferredDoc
? 1 :
1716 Sizzle
.matches = function( expr
, elements
) {
1717 return Sizzle( expr
, null, null, elements
);
1720 Sizzle
.matchesSelector = function( elem
, expr
) {
1721 // Set document vars if needed
1722 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1723 setDocument( elem
);
1726 // Make sure that attribute selectors are quoted
1727 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1729 if ( support
.matchesSelector
&& documentIsHTML
&&
1730 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1731 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1734 var ret
= matches
.call( elem
, expr
);
1736 // IE 9's matchesSelector returns false on disconnected nodes
1737 if ( ret
|| support
.disconnectedMatch
||
1738 // As well, disconnected nodes are said to be in a document
1740 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1746 return Sizzle( expr
, document
, null, [elem
] ).length
> 0;
1749 Sizzle
.contains = function( context
, elem
) {
1750 // Set document vars if needed
1751 if ( ( context
.ownerDocument
|| context
) !== document
) {
1752 setDocument( context
);
1754 return contains( context
, elem
);
1757 Sizzle
.attr = function( elem
, name
) {
1758 // Set document vars if needed
1759 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1760 setDocument( elem
);
1763 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1764 // Don't get fooled by Object.prototype properties (jQuery #13807)
1765 val
= ( fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1766 fn( elem
, name
, !documentIsHTML
) :
1769 return val
=== undefined ?
1770 support
.attributes
|| !documentIsHTML
?
1771 elem
.getAttribute( name
) :
1772 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1778 Sizzle
.error = function( msg
) {
1779 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1783 * Document sorting and removing duplicates
1784 * @param {ArrayLike} results
1786 Sizzle
.uniqueSort = function( results
) {
1792 // Unless we *know* we can detect duplicates, assume their presence
1793 hasDuplicate
= !support
.detectDuplicates
;
1794 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1795 results
.sort( sortOrder
);
1797 if ( hasDuplicate
) {
1798 while ( (elem
= results
[i
++]) ) {
1799 if ( elem
=== results
[ i
] ) {
1800 j
= duplicates
.push( i
);
1804 results
.splice( duplicates
[ j
], 1 );
1812 * Utility function for retrieving the text value of an array of DOM nodes
1813 * @param {Array|Element} elem
1815 getText
= Sizzle
.getText = function( elem
) {
1819 nodeType
= elem
.nodeType
;
1822 // If no nodeType, this is expected to be an array
1823 for ( ; (node
= elem
[i
]); i
++ ) {
1824 // Do not traverse comment nodes
1825 ret
+= getText( node
);
1827 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1828 // Use textContent for elements
1829 // innerText usage removed for consistency of new lines (see #11153)
1830 if ( typeof elem
.textContent
=== "string" ) {
1831 return elem
.textContent
;
1833 // Traverse its children
1834 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1835 ret
+= getText( elem
);
1838 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1839 return elem
.nodeValue
;
1841 // Do not include comment or processing instruction nodes
1846 Expr
= Sizzle
.selectors
= {
1848 // Can be adjusted by the user
1851 createPseudo
: markFunction
,
1860 ">": { dir
: "parentNode", first
: true },
1861 " ": { dir
: "parentNode" },
1862 "+": { dir
: "previousSibling", first
: true },
1863 "~": { dir
: "previousSibling" }
1867 "ATTR": function( match
) {
1868 match
[1] = match
[1].replace( runescape
, funescape
);
1870 // Move the given value to match[3] whether quoted or unquoted
1871 match
[3] = ( match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1873 if ( match
[2] === "~=" ) {
1874 match
[3] = " " + match
[3] + " ";
1877 return match
.slice( 0, 4 );
1880 "CHILD": function( match
) {
1881 /* matches from matchExpr["CHILD"]
1882 1 type (only|nth|...)
1883 2 what (child|of-type)
1884 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1885 4 xn-component of xn+y argument ([+-]?\d*n|)
1886 5 sign of xn-component
1888 7 sign of y-component
1891 match
[1] = match
[1].toLowerCase();
1893 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1894 // nth-* requires argument
1896 Sizzle
.error( match
[0] );
1899 // numeric x and y parameters for Expr.filter.CHILD
1900 // remember that false/true cast respectively to 0/1
1901 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1902 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1904 // other types prohibit arguments
1905 } else if ( match
[3] ) {
1906 Sizzle
.error( match
[0] );
1912 "PSEUDO": function( match
) {
1914 unquoted
= !match
[5] && match
[2];
1916 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1920 // Accept quoted arguments as-is
1921 if ( match
[3] && match
[4] !== undefined ) {
1922 match
[2] = match
[4];
1924 // Strip excess characters from unquoted arguments
1925 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1926 // Get excess from tokenize (recursively)
1927 (excess
= tokenize( unquoted
, true )) &&
1928 // advance to the next closing parenthesis
1929 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1931 // excess is a negative index
1932 match
[0] = match
[0].slice( 0, excess
);
1933 match
[2] = unquoted
.slice( 0, excess
);
1936 // Return only captures needed by the pseudo filter method (type and argument)
1937 return match
.slice( 0, 3 );
1943 "TAG": function( nodeNameSelector
) {
1944 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1945 return nodeNameSelector
=== "*" ?
1946 function() { return true; } :
1948 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1952 "CLASS": function( className
) {
1953 var pattern
= classCache
[ className
+ " " ];
1956 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1957 classCache( className
, function( elem
) {
1958 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== strundefined
&& elem
.getAttribute("class") || "" );
1962 "ATTR": function( name
, operator
, check
) {
1963 return function( elem
) {
1964 var result
= Sizzle
.attr( elem
, name
);
1966 if ( result
== null ) {
1967 return operator
=== "!=";
1975 return operator
=== "=" ? result
=== check
:
1976 operator
=== "!=" ? result
!== check
:
1977 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1978 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1979 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check
:
1980 operator
=== "~=" ? ( " " + result
+ " " ).indexOf( check
) > -1 :
1981 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1986 "CHILD": function( type
, what
, argument
, first
, last
) {
1987 var simple
= type
.slice( 0, 3 ) !== "nth",
1988 forward
= type
.slice( -4 ) !== "last",
1989 ofType
= what
=== "of-type";
1991 return first
=== 1 && last
=== 0 ?
1993 // Shortcut for :nth-*(n)
1995 return !!elem
.parentNode
;
1998 function( elem
, context
, xml
) {
1999 var cache
, outerCache
, node
, diff
, nodeIndex
, start
,
2000 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
2001 parent
= elem
.parentNode
,
2002 name
= ofType
&& elem
.nodeName
.toLowerCase(),
2003 useCache
= !xml
&& !ofType
;
2007 // :(first|last|only)-(child|of-type)
2011 while ( (node
= node
[ dir
]) ) {
2012 if ( ofType
? node
.nodeName
.toLowerCase() === name
: node
.nodeType
=== 1 ) {
2016 // Reverse direction for :only-* (if we haven't yet done so)
2017 start
= dir
= type
=== "only" && !start
&& "nextSibling";
2022 start
= [ forward
? parent
.firstChild
: parent
.lastChild
];
2024 // non-xml :nth-child(...) stores cache data on `parent`
2025 if ( forward
&& useCache
) {
2026 // Seek `elem` from a previously-cached index
2027 outerCache
= parent
[ expando
] || (parent
[ expando
] = {});
2028 cache
= outerCache
[ type
] || [];
2029 nodeIndex
= cache
[0] === dirruns
&& cache
[1];
2030 diff
= cache
[0] === dirruns
&& cache
[2];
2031 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
2033 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
2035 // Fallback to seeking `elem` from the start
2036 (diff
= nodeIndex
= 0) || start
.pop()) ) {
2038 // When found, cache indexes on `parent` and break
2039 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
2040 outerCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
2045 // Use previously-cached element index if available
2046 } else if ( useCache
&& (cache
= (elem
[ expando
] || (elem
[ expando
] = {}))[ type
]) && cache
[0] === dirruns
) {
2049 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
2051 // Use the same loop as above to seek `elem` from the start
2052 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
2053 (diff
= nodeIndex
= 0) || start
.pop()) ) {
2055 if ( ( ofType
? node
.nodeName
.toLowerCase() === name
: node
.nodeType
=== 1 ) && ++diff
) {
2056 // Cache the index of each encountered element
2058 (node
[ expando
] || (node
[ expando
] = {}))[ type
] = [ dirruns
, diff
];
2061 if ( node
=== elem
) {
2068 // Incorporate the offset, then check against cycle size
2070 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
2075 "PSEUDO": function( pseudo
, argument
) {
2076 // pseudo-class names are case-insensitive
2077 // http://www.w3.org/TR/selectors/#pseudo-classes
2078 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
2079 // Remember that setFilters inherits from pseudos
2081 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
2082 Sizzle
.error( "unsupported pseudo: " + pseudo
);
2084 // The user may use createPseudo to indicate that
2085 // arguments are needed to create the filter function
2086 // just as Sizzle does
2087 if ( fn
[ expando
] ) {
2088 return fn( argument
);
2091 // But maintain support for old signatures
2092 if ( fn
.length
> 1 ) {
2093 args
= [ pseudo
, pseudo
, "", argument
];
2094 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
2095 markFunction(function( seed
, matches
) {
2097 matched
= fn( seed
, argument
),
2100 idx
= indexOf
.call( seed
, matched
[i
] );
2101 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
2105 return fn( elem
, 0, args
);
2114 // Potentially complex pseudos
2115 "not": markFunction(function( selector
) {
2116 // Trim the selector passed to compile
2117 // to avoid treating leading and trailing
2118 // spaces as combinators
2121 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
2123 return matcher
[ expando
] ?
2124 markFunction(function( seed
, matches
, context
, xml
) {
2126 unmatched
= matcher( seed
, null, xml
, [] ),
2129 // Match elements unmatched by `matcher`
2131 if ( (elem
= unmatched
[i
]) ) {
2132 seed
[i
] = !(matches
[i
] = elem
);
2136 function( elem
, context
, xml
) {
2138 matcher( input
, null, xml
, results
);
2139 return !results
.pop();
2143 "has": markFunction(function( selector
) {
2144 return function( elem
) {
2145 return Sizzle( selector
, elem
).length
> 0;
2149 "contains": markFunction(function( text
) {
2150 return function( elem
) {
2151 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
2155 // "Whether an element is represented by a :lang() selector
2156 // is based solely on the element's language value
2157 // being equal to the identifier C,
2158 // or beginning with the identifier C immediately followed by "-".
2159 // The matching of C against the element's language value is performed case-insensitively.
2160 // The identifier C does not have to be a valid language name."
2161 // http://www.w3.org/TR/selectors/#lang-pseudo
2162 "lang": markFunction( function( lang
) {
2163 // lang value must be a valid identifier
2164 if ( !ridentifier
.test(lang
|| "") ) {
2165 Sizzle
.error( "unsupported lang: " + lang
);
2167 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
2168 return function( elem
) {
2171 if ( (elemLang
= documentIsHTML
?
2173 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
2175 elemLang
= elemLang
.toLowerCase();
2176 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
2178 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
2184 "target": function( elem
) {
2185 var hash
= window
.location
&& window
.location
.hash
;
2186 return hash
&& hash
.slice( 1 ) === elem
.id
;
2189 "root": function( elem
) {
2190 return elem
=== docElem
;
2193 "focus": function( elem
) {
2194 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
2197 // Boolean properties
2198 "enabled": function( elem
) {
2199 return elem
.disabled
=== false;
2202 "disabled": function( elem
) {
2203 return elem
.disabled
=== true;
2206 "checked": function( elem
) {
2207 // In CSS3, :checked should return both checked and selected elements
2208 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2209 var nodeName
= elem
.nodeName
.toLowerCase();
2210 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
2213 "selected": function( elem
) {
2214 // Accessing this property makes selected-by-default
2215 // options in Safari work properly
2216 if ( elem
.parentNode
) {
2217 elem
.parentNode
.selectedIndex
;
2220 return elem
.selected
=== true;
2224 "empty": function( elem
) {
2225 // http://www.w3.org/TR/selectors/#empty-pseudo
2226 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
2227 // not comment, processing instructions, or others
2228 // Thanks to Diego Perini for the nodeName shortcut
2229 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
2230 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
2231 if ( elem
.nodeName
> "@" || elem
.nodeType
=== 3 || elem
.nodeType
=== 4 ) {
2238 "parent": function( elem
) {
2239 return !Expr
.pseudos
["empty"]( elem
);
2242 // Element/input types
2243 "header": function( elem
) {
2244 return rheader
.test( elem
.nodeName
);
2247 "input": function( elem
) {
2248 return rinputs
.test( elem
.nodeName
);
2251 "button": function( elem
) {
2252 var name
= elem
.nodeName
.toLowerCase();
2253 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
2256 "text": function( elem
) {
2258 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
2259 // use getAttribute instead to test this case
2260 return elem
.nodeName
.toLowerCase() === "input" &&
2261 elem
.type
=== "text" &&
2262 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === elem
.type
);
2265 // Position-in-collection
2266 "first": createPositionalPseudo(function() {
2270 "last": createPositionalPseudo(function( matchIndexes
, length
) {
2271 return [ length
- 1 ];
2274 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2275 return [ argument
< 0 ? argument
+ length
: argument
];
2278 "even": createPositionalPseudo(function( matchIndexes
, length
) {
2280 for ( ; i
< length
; i
+= 2 ) {
2281 matchIndexes
.push( i
);
2283 return matchIndexes
;
2286 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
2288 for ( ; i
< length
; i
+= 2 ) {
2289 matchIndexes
.push( i
);
2291 return matchIndexes
;
2294 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2295 var i
= argument
< 0 ? argument
+ length
: argument
;
2296 for ( ; --i
>= 0; ) {
2297 matchIndexes
.push( i
);
2299 return matchIndexes
;
2302 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2303 var i
= argument
< 0 ? argument
+ length
: argument
;
2304 for ( ; ++i
< length
; ) {
2305 matchIndexes
.push( i
);
2307 return matchIndexes
;
2312 // Add button/input type pseudos
2313 for ( i
in { radio
: true, checkbox
: true, file
: true, password
: true, image
: true } ) {
2314 Expr
.pseudos
[ i
] = createInputPseudo( i
);
2316 for ( i
in { submit
: true, reset
: true } ) {
2317 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
2320 function tokenize( selector
, parseOnly
) {
2321 var matched
, match
, tokens
, type
,
2322 soFar
, groups
, preFilters
,
2323 cached
= tokenCache
[ selector
+ " " ];
2326 return parseOnly
? 0 : cached
.slice( 0 );
2331 preFilters
= Expr
.preFilter
;
2335 // Comma and first run
2336 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
2338 // Don't consume trailing commas as valid
2339 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2341 groups
.push( tokens
= [] );
2347 if ( (match
= rcombinators
.exec( soFar
)) ) {
2348 matched
= match
.shift();
2351 // Cast descendant combinators to space
2352 type
: match
[0].replace( rtrim
, " " )
2354 soFar
= soFar
.slice( matched
.length
);
2358 for ( type
in Expr
.filter
) {
2359 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2360 (match
= preFilters
[ type
]( match
))) ) {
2361 matched
= match
.shift();
2367 soFar
= soFar
.slice( matched
.length
);
2376 // Return the length of the invalid excess
2377 // if we're just parsing
2378 // Otherwise, throw an error or return tokens
2382 Sizzle
.error( selector
) :
2384 tokenCache( selector
, groups
).slice( 0 );
2387 function toSelector( tokens
) {
2389 len
= tokens
.length
,
2391 for ( ; i
< len
; i
++ ) {
2392 selector
+= tokens
[i
].value
;
2397 function addCombinator( matcher
, combinator
, base
) {
2398 var dir
= combinator
.dir
,
2399 checkNonElements
= base
&& dir
=== "parentNode",
2402 return combinator
.first
?
2403 // Check against closest ancestor/preceding element
2404 function( elem
, context
, xml
) {
2405 while ( (elem
= elem
[ dir
]) ) {
2406 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2407 return matcher( elem
, context
, xml
);
2412 // Check against all ancestor/preceding elements
2413 function( elem
, context
, xml
) {
2414 var data
, cache
, outerCache
,
2415 dirkey
= dirruns
+ " " + doneName
;
2417 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2419 while ( (elem
= elem
[ dir
]) ) {
2420 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2421 if ( matcher( elem
, context
, xml
) ) {
2427 while ( (elem
= elem
[ dir
]) ) {
2428 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2429 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2430 if ( (cache
= outerCache
[ dir
]) && cache
[0] === dirkey
) {
2431 if ( (data
= cache
[1]) === true || data
=== cachedruns
) {
2432 return data
=== true;
2435 cache
= outerCache
[ dir
] = [ dirkey
];
2436 cache
[1] = matcher( elem
, context
, xml
) || cachedruns
;
2437 if ( cache
[1] === true ) {
2447 function elementMatcher( matchers
) {
2448 return matchers
.length
> 1 ?
2449 function( elem
, context
, xml
) {
2450 var i
= matchers
.length
;
2452 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2461 function condense( unmatched
, map
, filter
, context
, xml
) {
2465 len
= unmatched
.length
,
2466 mapped
= map
!= null;
2468 for ( ; i
< len
; i
++ ) {
2469 if ( (elem
= unmatched
[i
]) ) {
2470 if ( !filter
|| filter( elem
, context
, xml
) ) {
2471 newUnmatched
.push( elem
);
2479 return newUnmatched
;
2482 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2483 if ( postFilter
&& !postFilter
[ expando
] ) {
2484 postFilter
= setMatcher( postFilter
);
2486 if ( postFinder
&& !postFinder
[ expando
] ) {
2487 postFinder
= setMatcher( postFinder
, postSelector
);
2489 return markFunction(function( seed
, results
, context
, xml
) {
2493 preexisting
= results
.length
,
2495 // Get initial elements from seed or context
2496 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2498 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2499 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2500 condense( elems
, preMap
, preFilter
, context
, xml
) :
2503 matcherOut
= matcher
?
2504 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2505 postFinder
|| ( seed
? preFilter
: preexisting
|| postFilter
) ?
2507 // ...intermediate processing is necessary
2510 // ...otherwise use results directly
2514 // Find primary matches
2516 matcher( matcherIn
, matcherOut
, context
, xml
);
2521 temp
= condense( matcherOut
, postMap
);
2522 postFilter( temp
, [], context
, xml
);
2524 // Un-match failing elements by moving them back to matcherIn
2527 if ( (elem
= temp
[i
]) ) {
2528 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2534 if ( postFinder
|| preFilter
) {
2536 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2538 i
= matcherOut
.length
;
2540 if ( (elem
= matcherOut
[i
]) ) {
2541 // Restore matcherIn since elem is not yet a final match
2542 temp
.push( (matcherIn
[i
] = elem
) );
2545 postFinder( null, (matcherOut
= []), temp
, xml
);
2548 // Move matched elements from seed to results to keep them synchronized
2549 i
= matcherOut
.length
;
2551 if ( (elem
= matcherOut
[i
]) &&
2552 (temp
= postFinder
? indexOf
.call( seed
, elem
) : preMap
[i
]) > -1 ) {
2554 seed
[temp
] = !(results
[temp
] = elem
);
2559 // Add elements to results, through postFinder if defined
2561 matcherOut
= condense(
2562 matcherOut
=== results
?
2563 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2567 postFinder( null, results
, matcherOut
, xml
);
2569 push
.apply( results
, matcherOut
);
2575 function matcherFromTokens( tokens
) {
2576 var checkContext
, matcher
, j
,
2577 len
= tokens
.length
,
2578 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2579 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2580 i
= leadingRelative
? 1 : 0,
2582 // The foundational matcher ensures that elements are reachable from top-level context(s)
2583 matchContext
= addCombinator( function( elem
) {
2584 return elem
=== checkContext
;
2585 }, implicitRelative
, true ),
2586 matchAnyContext
= addCombinator( function( elem
) {
2587 return indexOf
.call( checkContext
, elem
) > -1;
2588 }, implicitRelative
, true ),
2589 matchers
= [ function( elem
, context
, xml
) {
2590 return ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2591 (checkContext
= context
).nodeType
?
2592 matchContext( elem
, context
, xml
) :
2593 matchAnyContext( elem
, context
, xml
) );
2596 for ( ; i
< len
; i
++ ) {
2597 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2598 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2600 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2602 // Return special upon seeing a positional matcher
2603 if ( matcher
[ expando
] ) {
2604 // Find the next relative operator (if any) for proper handling
2606 for ( ; j
< len
; j
++ ) {
2607 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2612 i
> 1 && elementMatcher( matchers
),
2613 i
> 1 && toSelector(
2614 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2615 tokens
.slice( 0, i
- 1 ).concat({ value
: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2616 ).replace( rtrim
, "$1" ),
2618 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2619 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2620 j
< len
&& toSelector( tokens
)
2623 matchers
.push( matcher
);
2627 return elementMatcher( matchers
);
2630 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2631 // A counter to specify which element is currently being matched
2632 var matcherCachedRuns
= 0,
2633 bySet
= setMatchers
.length
> 0,
2634 byElement
= elementMatchers
.length
> 0,
2635 superMatcher = function( seed
, context
, xml
, results
, expandContext
) {
2636 var elem
, j
, matcher
,
2640 unmatched
= seed
&& [],
2641 outermost
= expandContext
!= null,
2642 contextBackup
= outermostContext
,
2643 // We must always have either seed elements or context
2644 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", expandContext
&& context
.parentNode
|| context
),
2645 // Use integer dirruns iff this is the outermost matcher
2646 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1);
2649 outermostContext
= context
!== document
&& context
;
2650 cachedruns
= matcherCachedRuns
;
2653 // Add elements passing elementMatchers directly to results
2654 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2655 for ( ; (elem
= elems
[i
]) != null; i
++ ) {
2656 if ( byElement
&& elem
) {
2658 while ( (matcher
= elementMatchers
[j
++]) ) {
2659 if ( matcher( elem
, context
, xml
) ) {
2660 results
.push( elem
);
2665 dirruns
= dirrunsUnique
;
2666 cachedruns
= ++matcherCachedRuns
;
2670 // Track unmatched elements for set filters
2672 // They will have gone through all possible matchers
2673 if ( (elem
= !matcher
&& elem
) ) {
2677 // Lengthen the array for every element, matched or not
2679 unmatched
.push( elem
);
2684 // Apply set filters to unmatched elements
2686 if ( bySet
&& i
!== matchedCount
) {
2688 while ( (matcher
= setMatchers
[j
++]) ) {
2689 matcher( unmatched
, setMatched
, context
, xml
);
2693 // Reintegrate element matches to eliminate the need for sorting
2694 if ( matchedCount
> 0 ) {
2696 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2697 setMatched
[i
] = pop
.call( results
);
2702 // Discard index placeholder values to get only actual matches
2703 setMatched
= condense( setMatched
);
2706 // Add matches to results
2707 push
.apply( results
, setMatched
);
2709 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2710 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2711 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2713 Sizzle
.uniqueSort( results
);
2717 // Override manipulation of globals by nested matchers
2719 dirruns
= dirrunsUnique
;
2720 outermostContext
= contextBackup
;
2727 markFunction( superMatcher
) :
2731 compile
= Sizzle
.compile = function( selector
, group
/* Internal Use Only */ ) {
2734 elementMatchers
= [],
2735 cached
= compilerCache
[ selector
+ " " ];
2738 // Generate a function of recursive functions that can be used to check each element
2740 group
= tokenize( selector
);
2744 cached
= matcherFromTokens( group
[i
] );
2745 if ( cached
[ expando
] ) {
2746 setMatchers
.push( cached
);
2748 elementMatchers
.push( cached
);
2752 // Cache the compiled function
2753 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2758 function multipleContexts( selector
, contexts
, results
) {
2760 len
= contexts
.length
;
2761 for ( ; i
< len
; i
++ ) {
2762 Sizzle( selector
, contexts
[i
], results
);
2767 function select( selector
, context
, results
, seed
) {
2768 var i
, tokens
, token
, type
, find
,
2769 match
= tokenize( selector
);
2772 // Try to minimize operations if there is only one group
2773 if ( match
.length
=== 1 ) {
2775 // Take a shortcut and set the context if the root selector is an ID
2776 tokens
= match
[0] = match
[0].slice( 0 );
2777 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2778 support
.getById
&& context
.nodeType
=== 9 && documentIsHTML
&&
2779 Expr
.relative
[ tokens
[1].type
] ) {
2781 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2785 selector
= selector
.slice( tokens
.shift().value
.length
);
2788 // Fetch a seed set for right-to-left matching
2789 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2793 // Abort if we hit a combinator
2794 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2797 if ( (find
= Expr
.find
[ type
]) ) {
2798 // Search, expanding context for leading sibling combinators
2800 token
.matches
[0].replace( runescape
, funescape
),
2801 rsibling
.test( tokens
[0].type
) && context
.parentNode
|| context
2804 // If seed is empty or no tokens remain, we can return early
2805 tokens
.splice( i
, 1 );
2806 selector
= seed
.length
&& toSelector( tokens
);
2808 push
.apply( results
, seed
);
2819 // Compile and execute a filtering function
2820 // Provide `match` to avoid retokenization if we modified the selector above
2821 compile( selector
, match
)(
2826 rsibling
.test( selector
)
2832 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
2834 // Easy API for creating new setFilters
2835 function setFilters() {}
2836 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
2837 Expr
.setFilters
= new setFilters();
2839 // One-time assignments
2842 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2844 // Initialize against the default document
2847 // Support: Chrome<<14
2848 // Always assume duplicates if they aren't passed to the comparison function
2849 [0, 0].sort( sortOrder
);
2850 support
.detectDuplicates
= hasDuplicate
;
2852 jQuery
.find
= Sizzle
;
2853 jQuery
.expr
= Sizzle
.selectors
;
2854 jQuery
.expr
[":"] = jQuery
.expr
.pseudos
;
2855 jQuery
.unique
= Sizzle
.uniqueSort
;
2856 jQuery
.text
= Sizzle
.getText
;
2857 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2858 jQuery
.contains
= Sizzle
.contains
;
2862 // String to Object options format cache
2863 var optionsCache
= {};
2865 // Convert String-formatted options into Object-formatted ones and store in cache
2866 function createOptions( options
) {
2867 var object
= optionsCache
[ options
] = {};
2868 jQuery
.each( options
.match( core_rnotwhite
) || [], function( _
, flag
) {
2869 object
[ flag
] = true;
2875 * Create a callback list using the following parameters:
2877 * options: an optional list of space-separated options that will change how
2878 * the callback list behaves or a more traditional option object
2880 * By default a callback list will act like an event callback list and can be
2881 * "fired" multiple times.
2885 * once: will ensure the callback list can only be fired once (like a Deferred)
2887 * memory: will keep track of previous values and will call any callback added
2888 * after the list has been fired right away with the latest "memorized"
2889 * values (like a Deferred)
2891 * unique: will ensure a callback can only be added once (no duplicate in the list)
2893 * stopOnFalse: interrupt callings when a callback returns false
2896 jQuery
.Callbacks = function( options
) {
2898 // Convert options from String-formatted to Object-formatted if needed
2899 // (we check in cache first)
2900 options
= typeof options
=== "string" ?
2901 ( optionsCache
[ options
] || createOptions( options
) ) :
2902 jQuery
.extend( {}, options
);
2904 var // Last fire value (for non-forgettable lists)
2906 // Flag to know if list was already fired
2908 // Flag to know if list is currently firing
2910 // First callback to fire (used internally by add and fireWith)
2912 // End of the loop when firing
2914 // Index of currently firing callback (modified by remove if needed)
2916 // Actual callback list
2918 // Stack of fire calls for repeatable lists
2919 stack
= !options
.once
&& [],
2921 fire = function( data
) {
2922 memory
= options
.memory
&& data
;
2924 firingIndex
= firingStart
|| 0;
2926 firingLength
= list
.length
;
2928 for ( ; list
&& firingIndex
< firingLength
; firingIndex
++ ) {
2929 if ( list
[ firingIndex
].apply( data
[ 0 ], data
[ 1 ] ) === false && options
.stopOnFalse
) {
2930 memory
= false; // To prevent further calls using add
2937 if ( stack
.length
) {
2938 fire( stack
.shift() );
2940 } else if ( memory
) {
2947 // Actual Callbacks object
2949 // Add a callback or a collection of callbacks to the list
2952 // First, we save the current length
2953 var start
= list
.length
;
2954 (function add( args
) {
2955 jQuery
.each( args
, function( _
, arg
) {
2956 var type
= jQuery
.type( arg
);
2957 if ( type
=== "function" ) {
2958 if ( !options
.unique
|| !self
.has( arg
) ) {
2961 } else if ( arg
&& arg
.length
&& type
!== "string" ) {
2962 // Inspect recursively
2967 // Do we need to add the callbacks to the
2968 // current firing batch?
2970 firingLength
= list
.length
;
2971 // With memory, if we're not firing then
2972 // we should call right away
2973 } else if ( memory
) {
2974 firingStart
= start
;
2980 // Remove a callback from the list
2981 remove: function() {
2983 jQuery
.each( arguments
, function( _
, arg
) {
2985 while( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
2986 list
.splice( index
, 1 );
2987 // Handle firing indexes
2989 if ( index
<= firingLength
) {
2992 if ( index
<= firingIndex
) {
3001 // Check if a given callback is in the list.
3002 // If no argument is given, return whether or not list has callbacks attached.
3003 has: function( fn
) {
3004 return fn
? jQuery
.inArray( fn
, list
) > -1 : !!( list
&& list
.length
);
3006 // Remove all callbacks from the list
3012 // Have the list do nothing anymore
3013 disable: function() {
3014 list
= stack
= memory
= undefined;
3018 disabled: function() {
3021 // Lock the list in its current state
3030 locked: function() {
3033 // Call all callbacks with the given context and arguments
3034 fireWith: function( context
, args
) {
3036 args
= [ context
, args
.slice
? args
.slice() : args
];
3037 if ( list
&& ( !fired
|| stack
) ) {
3046 // Call all the callbacks with the given arguments
3048 self
.fireWith( this, arguments
);
3051 // To know if the callbacks have already been called at least once
3061 Deferred: function( func
) {
3063 // action, add listener, listener list, final state
3064 [ "resolve", "done", jQuery
.Callbacks("once memory"), "resolved" ],
3065 [ "reject", "fail", jQuery
.Callbacks("once memory"), "rejected" ],
3066 [ "notify", "progress", jQuery
.Callbacks("memory") ]
3073 always: function() {
3074 deferred
.done( arguments
).fail( arguments
);
3077 then: function( /* fnDone, fnFail, fnProgress */ ) {
3078 var fns
= arguments
;
3079 return jQuery
.Deferred(function( newDefer
) {
3080 jQuery
.each( tuples
, function( i
, tuple
) {
3081 var action
= tuple
[ 0 ],
3082 fn
= jQuery
.isFunction( fns
[ i
] ) && fns
[ i
];
3083 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3084 deferred
[ tuple
[1] ](function() {
3085 var returned
= fn
&& fn
.apply( this, arguments
);
3086 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
3088 .done( newDefer
.resolve
)
3089 .fail( newDefer
.reject
)
3090 .progress( newDefer
.notify
);
3092 newDefer
[ action
+ "With" ]( this === promise
? newDefer
.promise() : this, fn
? [ returned
] : arguments
);
3099 // Get a promise for this deferred
3100 // If obj is provided, the promise aspect is added to the object
3101 promise: function( obj
) {
3102 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3107 // Keep pipe for back-compat
3108 promise
.pipe
= promise
.then
;
3110 // Add list-specific methods
3111 jQuery
.each( tuples
, function( i
, tuple
) {
3112 var list
= tuple
[ 2 ],
3113 stateString
= tuple
[ 3 ];
3115 // promise[ done | fail | progress ] = list.add
3116 promise
[ tuple
[1] ] = list
.add
;
3119 if ( stateString
) {
3120 list
.add(function() {
3121 // state = [ resolved | rejected ]
3122 state
= stateString
;
3124 // [ reject_list | resolve_list ].disable; progress_list.lock
3125 }, tuples
[ i
^ 1 ][ 2 ].disable
, tuples
[ 2 ][ 2 ].lock
);
3128 // deferred[ resolve | reject | notify ]
3129 deferred
[ tuple
[0] ] = function() {
3130 deferred
[ tuple
[0] + "With" ]( this === deferred
? promise
: this, arguments
);
3133 deferred
[ tuple
[0] + "With" ] = list
.fireWith
;
3136 // Make the deferred a promise
3137 promise
.promise( deferred
);
3139 // Call given func if any
3141 func
.call( deferred
, deferred
);
3149 when: function( subordinate
/* , ..., subordinateN */ ) {
3151 resolveValues
= core_slice
.call( arguments
),
3152 length
= resolveValues
.length
,
3154 // the count of uncompleted subordinates
3155 remaining
= length
!== 1 || ( subordinate
&& jQuery
.isFunction( subordinate
.promise
) ) ? length
: 0,
3157 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3158 deferred
= remaining
=== 1 ? subordinate
: jQuery
.Deferred(),
3160 // Update function for both resolve and progress values
3161 updateFunc = function( i
, contexts
, values
) {
3162 return function( value
) {
3163 contexts
[ i
] = this;
3164 values
[ i
] = arguments
.length
> 1 ? core_slice
.call( arguments
) : value
;
3165 if( values
=== progressValues
) {
3166 deferred
.notifyWith( contexts
, values
);
3167 } else if ( !( --remaining
) ) {
3168 deferred
.resolveWith( contexts
, values
);
3173 progressValues
, progressContexts
, resolveContexts
;
3175 // add listeners to Deferred subordinates; treat others as resolved
3177 progressValues
= new Array( length
);
3178 progressContexts
= new Array( length
);
3179 resolveContexts
= new Array( length
);
3180 for ( ; i
< length
; i
++ ) {
3181 if ( resolveValues
[ i
] && jQuery
.isFunction( resolveValues
[ i
].promise
) ) {
3182 resolveValues
[ i
].promise()
3183 .done( updateFunc( i
, resolveContexts
, resolveValues
) )
3184 .fail( deferred
.reject
)
3185 .progress( updateFunc( i
, progressContexts
, progressValues
) );
3192 // if we're not waiting on anything, resolve the master
3194 deferred
.resolveWith( resolveContexts
, resolveValues
);
3197 return deferred
.promise();
3200 jQuery
.support
= (function( support
) {
3201 var input
= document
.createElement("input"),
3202 fragment
= document
.createDocumentFragment(),
3203 div
= document
.createElement("div"),
3204 select
= document
.createElement("select"),
3205 opt
= select
.appendChild( document
.createElement("option") );
3207 // Finish early in limited environments
3208 if ( !input
.type
) {
3212 input
.type
= "checkbox";
3214 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
3215 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
3216 support
.checkOn
= input
.value
!== "";
3218 // Must access the parent to make an option select properly
3219 // Support: IE9, IE10
3220 support
.optSelected
= opt
.selected
;
3222 // Will be defined later
3223 support
.reliableMarginRight
= true;
3224 support
.boxSizingReliable
= true;
3225 support
.pixelPosition
= false;
3227 // Make sure checked status is properly cloned
3228 // Support: IE9, IE10
3229 input
.checked
= true;
3230 support
.noCloneChecked
= input
.cloneNode( true ).checked
;
3232 // Make sure that the options inside disabled selects aren't marked as disabled
3233 // (WebKit marks them as disabled)
3234 select
.disabled
= true;
3235 support
.optDisabled
= !opt
.disabled
;
3237 // Check if an input maintains its value after becoming a radio
3238 // Support: IE9, IE10
3239 input
= document
.createElement("input");
3241 input
.type
= "radio";
3242 support
.radioValue
= input
.value
=== "t";
3244 // #11217 - WebKit loses check when the name is after the checked attribute
3245 input
.setAttribute( "checked", "t" );
3246 input
.setAttribute( "name", "t" );
3248 fragment
.appendChild( input
);
3250 // Support: Safari 5.1, Android 4.x, Android 2.3
3251 // old WebKit doesn't clone checked state correctly in fragments
3252 support
.checkClone
= fragment
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
3254 // Support: Firefox, Chrome, Safari
3255 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
3256 support
.focusinBubbles
= "onfocusin" in window
;
3258 div
.style
.backgroundClip
= "content-box";
3259 div
.cloneNode( true ).style
.backgroundClip
= "";
3260 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
3262 // Run tests that need a body at doc ready
3264 var container
, marginDiv
,
3265 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
3266 divReset
= "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",
3267 body
= document
.getElementsByTagName("body")[ 0 ];
3270 // Return for frameset docs that don't have a body
3274 container
= document
.createElement("div");
3275 container
.style
.cssText
= "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
3277 // Check box-sizing and margin behavior.
3278 body
.appendChild( container
).appendChild( div
);
3280 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
3281 div
.style
.cssText
= "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%";
3283 // Workaround failing boxSizing test due to offsetWidth returning wrong value
3284 // with some non-1 values of body zoom, ticket #13543
3285 jQuery
.swap( body
, body
.style
.zoom
!= null ? { zoom
: 1 } : {}, function() {
3286 support
.boxSizing
= div
.offsetWidth
=== 4;
3289 // Use window.getComputedStyle because jsdom on node.js will break without it.
3290 if ( window
.getComputedStyle
) {
3291 support
.pixelPosition
= ( window
.getComputedStyle( div
, null ) || {} ).top
!== "1%";
3292 support
.boxSizingReliable
= ( window
.getComputedStyle( div
, null ) || { width
: "4px" } ).width
=== "4px";
3294 // Support: Android 2.3
3295 // Check if div with explicit width and no margin-right incorrectly
3296 // gets computed margin-right based on width of container. (#3333)
3297 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
3298 marginDiv
= div
.appendChild( document
.createElement("div") );
3299 marginDiv
.style
.cssText
= div
.style
.cssText
= divReset
;
3300 marginDiv
.style
.marginRight
= marginDiv
.style
.width
= "0";
3301 div
.style
.width
= "1px";
3303 support
.reliableMarginRight
=
3304 !parseFloat( ( window
.getComputedStyle( marginDiv
, null ) || {} ).marginRight
);
3307 body
.removeChild( container
);
3314 Implementation Summary
3316 1. Enforce API surface and semantic compatibility with 1.9.x branch
3317 2. Improve the module's maintainability by reducing the storage
3318 paths to a single mechanism.
3319 3. Use the same single mechanism to support "private" and "user" data.
3320 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
3321 5. Avoid exposing implementation details on user objects (eg. expando properties)
3322 6. Provide a clear path for implementation upgrade to WeakMap in 2014
3324 var data_user
, data_priv
,
3325 rbrace
= /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
3326 rmultiDash
= /([A-Z])/g;
3329 // Support: Android < 4,
3330 // Old WebKit does not have Object.preventExtensions/freeze method,
3331 // return new empty object instead with no [[set]] accessor
3332 Object
.defineProperty( this.cache
= {}, 0, {
3338 this.expando
= jQuery
.expando
+ Math
.random();
3343 Data
.accepts = function( owner
) {
3346 // - Node.ELEMENT_NODE
3347 // - Node.DOCUMENT_NODE
3350 return owner
.nodeType
?
3351 owner
.nodeType
=== 1 || owner
.nodeType
=== 9 : true;
3355 key: function( owner
) {
3356 // We can accept data for non-element nodes in modern browsers,
3357 // but we should not, see #8335.
3358 // Always return the key for a frozen object.
3359 if ( !Data
.accepts( owner
) ) {
3363 var descriptor
= {},
3364 // Check if the owner object already has a cache key
3365 unlock
= owner
[ this.expando
];
3367 // If not, create one
3369 unlock
= Data
.uid
++;
3371 // Secure it in a non-enumerable, non-writable property
3373 descriptor
[ this.expando
] = { value
: unlock
};
3374 Object
.defineProperties( owner
, descriptor
);
3376 // Support: Android < 4
3377 // Fallback to a less secure definition
3379 descriptor
[ this.expando
] = unlock
;
3380 jQuery
.extend( owner
, descriptor
);
3384 // Ensure the cache object
3385 if ( !this.cache
[ unlock
] ) {
3386 this.cache
[ unlock
] = {};
3391 set: function( owner
, data
, value
) {
3393 // There may be an unlock assigned to this node,
3394 // if there is no entry for this "owner", create one inline
3395 // and set the unlock as though an owner entry had always existed
3396 unlock
= this.key( owner
),
3397 cache
= this.cache
[ unlock
];
3399 // Handle: [ owner, key, value ] args
3400 if ( typeof data
=== "string" ) {
3401 cache
[ data
] = value
;
3403 // Handle: [ owner, { properties } ] args
3405 // Fresh assignments by object are shallow copied
3406 if ( jQuery
.isEmptyObject( cache
) ) {
3407 jQuery
.extend( this.cache
[ unlock
], data
);
3408 // Otherwise, copy the properties one-by-one to the cache object
3410 for ( prop
in data
) {
3411 cache
[ prop
] = data
[ prop
];
3417 get: function( owner
, key
) {
3418 // Either a valid cache is found, or will be created.
3419 // New caches will be created and the unlock returned,
3420 // allowing direct access to the newly created
3421 // empty data object. A valid owner object must be provided.
3422 var cache
= this.cache
[ this.key( owner
) ];
3424 return key
=== undefined ?
3425 cache
: cache
[ key
];
3427 access: function( owner
, key
, value
) {
3428 // In cases where either:
3430 // 1. No key was specified
3431 // 2. A string key was specified, but no value provided
3433 // Take the "read" path and allow the get method to determine
3434 // which value to return, respectively either:
3436 // 1. The entire cache object
3437 // 2. The data stored at the key
3439 if ( key
=== undefined ||
3440 ((key
&& typeof key
=== "string") && value
=== undefined) ) {
3441 return this.get( owner
, key
);
3444 // [*]When the key is not a string, or both a key and value
3445 // are specified, set or extend (existing objects) with either:
3447 // 1. An object of properties
3448 // 2. A key and value
3450 this.set( owner
, key
, value
);
3452 // Since the "set" path can have two possible entry points
3453 // return the expected data based on which path was taken[*]
3454 return value
!== undefined ? value
: key
;
3456 remove: function( owner
, key
) {
3458 unlock
= this.key( owner
),
3459 cache
= this.cache
[ unlock
];
3461 if ( key
=== undefined ) {
3462 this.cache
[ unlock
] = {};
3465 // Support array or space separated string of keys
3466 if ( jQuery
.isArray( key
) ) {
3467 // If "name" is an array of keys...
3468 // When data is initially created, via ("key", "val") signature,
3469 // keys will be converted to camelCase.
3470 // Since there is no way to tell _how_ a key was added, remove
3471 // both plain key and camelCase key. #12786
3472 // This will only penalize the array argument path.
3473 name
= key
.concat( key
.map( jQuery
.camelCase
) );
3475 camel
= jQuery
.camelCase( key
);
3476 // Try the string as a key before any manipulation
3477 if ( key
in cache
) {
3478 name
= [ key
, camel
];
3480 // If a key with the spaces exists, use it.
3481 // Otherwise, create an array by matching non-whitespace
3483 name
= name
in cache
?
3484 [ name
] : ( name
.match( core_rnotwhite
) || [] );
3490 delete cache
[ name
[ i
] ];
3494 hasData: function( owner
) {
3495 return !jQuery
.isEmptyObject(
3496 this.cache
[ owner
[ this.expando
] ] || {}
3499 discard: function( owner
) {
3500 if ( owner
[ this.expando
] ) {
3501 delete this.cache
[ owner
[ this.expando
] ];
3506 // These may be used throughout the jQuery core codebase
3507 data_user
= new Data();
3508 data_priv
= new Data();
3512 acceptData
: Data
.accepts
,
3514 hasData: function( elem
) {
3515 return data_user
.hasData( elem
) || data_priv
.hasData( elem
);
3518 data: function( elem
, name
, data
) {
3519 return data_user
.access( elem
, name
, data
);
3522 removeData: function( elem
, name
) {
3523 data_user
.remove( elem
, name
);
3526 // TODO: Now that all calls to _data and _removeData have been replaced
3527 // with direct calls to data_priv methods, these can be deprecated.
3528 _data: function( elem
, name
, data
) {
3529 return data_priv
.access( elem
, name
, data
);
3532 _removeData: function( elem
, name
) {
3533 data_priv
.remove( elem
, name
);
3538 data: function( key
, value
) {
3545 if ( key
=== undefined ) {
3546 if ( this.length
) {
3547 data
= data_user
.get( elem
);
3549 if ( elem
.nodeType
=== 1 && !data_priv
.get( elem
, "hasDataAttrs" ) ) {
3550 attrs
= elem
.attributes
;
3551 for ( ; i
< attrs
.length
; i
++ ) {
3552 name
= attrs
[ i
].name
;
3554 if ( name
.indexOf( "data-" ) === 0 ) {
3555 name
= jQuery
.camelCase( name
.slice(5) );
3556 dataAttr( elem
, name
, data
[ name
] );
3559 data_priv
.set( elem
, "hasDataAttrs", true );
3566 // Sets multiple values
3567 if ( typeof key
=== "object" ) {
3568 return this.each(function() {
3569 data_user
.set( this, key
);
3573 return jQuery
.access( this, function( value
) {
3575 camelKey
= jQuery
.camelCase( key
);
3577 // The calling jQuery object (element matches) is not empty
3578 // (and therefore has an element appears at this[ 0 ]) and the
3579 // `value` parameter was not undefined. An empty jQuery object
3580 // will result in `undefined` for elem = this[ 0 ] which will
3581 // throw an exception if an attempt to read a data cache is made.
3582 if ( elem
&& value
=== undefined ) {
3583 // Attempt to get data from the cache
3584 // with the key as-is
3585 data
= data_user
.get( elem
, key
);
3586 if ( data
!== undefined ) {
3590 // Attempt to get data from the cache
3591 // with the key camelized
3592 data
= data_user
.get( elem
, camelKey
);
3593 if ( data
!== undefined ) {
3597 // Attempt to "discover" the data in
3598 // HTML5 custom data-* attrs
3599 data
= dataAttr( elem
, camelKey
, undefined );
3600 if ( data
!== undefined ) {
3604 // We tried really hard, but the data doesn't exist.
3609 this.each(function() {
3610 // First, attempt to store a copy or reference of any
3611 // data that might've been store with a camelCased key.
3612 var data
= data_user
.get( this, camelKey
);
3614 // For HTML5 data-* attribute interop, we have to
3615 // store property names with dashes in a camelCase form.
3616 // This might not apply to all properties...*
3617 data_user
.set( this, camelKey
, value
);
3619 // *... In the case of properties that might _actually_
3620 // have dashes, we need to also store a copy of that
3621 // unchanged property.
3622 if ( key
.indexOf("-") !== -1 && data
!== undefined ) {
3623 data_user
.set( this, key
, value
);
3626 }, null, value
, arguments
.length
> 1, null, true );
3629 removeData: function( key
) {
3630 return this.each(function() {
3631 data_user
.remove( this, key
);
3636 function dataAttr( elem
, key
, data
) {
3639 // If nothing was found internally, try to fetch any
3640 // data from the HTML5 data-* attribute
3641 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
3642 name
= "data-" + key
.replace( rmultiDash
, "-$1" ).toLowerCase();
3643 data
= elem
.getAttribute( name
);
3645 if ( typeof data
=== "string" ) {
3647 data
= data
=== "true" ? true :
3648 data
=== "false" ? false :
3649 data
=== "null" ? null :
3650 // Only convert to a number if it doesn't change the string
3651 +data
+ "" === data
? +data
:
3652 rbrace
.test( data
) ? JSON
.parse( data
) :
3656 // Make sure we set the data so it isn't changed later
3657 data_user
.set( elem
, key
, data
);
3665 queue: function( elem
, type
, data
) {
3669 type
= ( type
|| "fx" ) + "queue";
3670 queue
= data_priv
.get( elem
, type
);
3672 // Speed up dequeue by getting out quickly if this is just a lookup
3674 if ( !queue
|| jQuery
.isArray( data
) ) {
3675 queue
= data_priv
.access( elem
, type
, jQuery
.makeArray(data
) );
3684 dequeue: function( elem
, type
) {
3685 type
= type
|| "fx";
3687 var queue
= jQuery
.queue( elem
, type
),
3688 startLength
= queue
.length
,
3690 hooks
= jQuery
._queueHooks( elem
, type
),
3692 jQuery
.dequeue( elem
, type
);
3695 // If the fx queue is dequeued, always remove the progress sentinel
3696 if ( fn
=== "inprogress" ) {
3704 // Add a progress sentinel to prevent the fx queue from being
3705 // automatically dequeued
3706 if ( type
=== "fx" ) {
3707 queue
.unshift( "inprogress" );
3710 // clear up the last queue stop function
3712 fn
.call( elem
, next
, hooks
);
3715 if ( !startLength
&& hooks
) {
3720 // not intended for public consumption - generates a queueHooks object, or returns the current one
3721 _queueHooks: function( elem
, type
) {
3722 var key
= type
+ "queueHooks";
3723 return data_priv
.get( elem
, key
) || data_priv
.access( elem
, key
, {
3724 empty
: jQuery
.Callbacks("once memory").add(function() {
3725 data_priv
.remove( elem
, [ type
+ "queue", key
] );
3732 queue: function( type
, data
) {
3735 if ( typeof type
!== "string" ) {
3741 if ( arguments
.length
< setter
) {
3742 return jQuery
.queue( this[0], type
);
3745 return data
=== undefined ?
3747 this.each(function() {
3748 var queue
= jQuery
.queue( this, type
, data
);
3750 // ensure a hooks for this queue
3751 jQuery
._queueHooks( this, type
);
3753 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
3754 jQuery
.dequeue( this, type
);
3758 dequeue: function( type
) {
3759 return this.each(function() {
3760 jQuery
.dequeue( this, type
);
3763 // Based off of the plugin by Clint Helfers, with permission.
3764 // http://blindsignals.com/index.php/2009/07/jquery-delay/
3765 delay: function( time
, type
) {
3766 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
3767 type
= type
|| "fx";
3769 return this.queue( type
, function( next
, hooks
) {
3770 var timeout
= setTimeout( next
, time
);
3771 hooks
.stop = function() {
3772 clearTimeout( timeout
);
3776 clearQueue: function( type
) {
3777 return this.queue( type
|| "fx", [] );
3779 // Get a promise resolved when queues of a certain type
3780 // are emptied (fx is the type by default)
3781 promise: function( type
, obj
) {
3784 defer
= jQuery
.Deferred(),
3787 resolve = function() {
3788 if ( !( --count
) ) {
3789 defer
.resolveWith( elements
, [ elements
] );
3793 if ( typeof type
!== "string" ) {
3797 type
= type
|| "fx";
3800 tmp
= data_priv
.get( elements
[ i
], type
+ "queueHooks" );
3801 if ( tmp
&& tmp
.empty
) {
3803 tmp
.empty
.add( resolve
);
3807 return defer
.promise( obj
);
3810 var nodeHook
, boolHook
,
3811 rclass
= /[\t\r\n\f]/g,
3813 rfocusable
= /^(?:input|select|textarea|button)$/i;
3816 attr: function( name
, value
) {
3817 return jQuery
.access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
3820 removeAttr: function( name
) {
3821 return this.each(function() {
3822 jQuery
.removeAttr( this, name
);
3826 prop: function( name
, value
) {
3827 return jQuery
.access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
3830 removeProp: function( name
) {
3831 return this.each(function() {
3832 delete this[ jQuery
.propFix
[ name
] || name
];
3836 addClass: function( value
) {
3837 var classes
, elem
, cur
, clazz
, j
,
3840 proceed
= typeof value
=== "string" && value
;
3842 if ( jQuery
.isFunction( value
) ) {
3843 return this.each(function( j
) {
3844 jQuery( this ).addClass( value
.call( this, j
, this.className
) );
3849 // The disjunction here is for better compressibility (see removeClass)
3850 classes
= ( value
|| "" ).match( core_rnotwhite
) || [];
3852 for ( ; i
< len
; i
++ ) {
3854 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
3855 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
3861 while ( (clazz
= classes
[j
++]) ) {
3862 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
3866 elem
.className
= jQuery
.trim( cur
);
3875 removeClass: function( value
) {
3876 var classes
, elem
, cur
, clazz
, j
,
3879 proceed
= arguments
.length
=== 0 || typeof value
=== "string" && value
;
3881 if ( jQuery
.isFunction( value
) ) {
3882 return this.each(function( j
) {
3883 jQuery( this ).removeClass( value
.call( this, j
, this.className
) );
3887 classes
= ( value
|| "" ).match( core_rnotwhite
) || [];
3889 for ( ; i
< len
; i
++ ) {
3891 // This expression is here for better compressibility (see addClass)
3892 cur
= elem
.nodeType
=== 1 && ( elem
.className
?
3893 ( " " + elem
.className
+ " " ).replace( rclass
, " " ) :
3899 while ( (clazz
= classes
[j
++]) ) {
3900 // Remove *all* instances
3901 while ( cur
.indexOf( " " + clazz
+ " " ) >= 0 ) {
3902 cur
= cur
.replace( " " + clazz
+ " ", " " );
3905 elem
.className
= value
? jQuery
.trim( cur
) : "";
3913 toggleClass: function( value
, stateVal
) {
3914 var type
= typeof value
,
3915 isBool
= typeof stateVal
=== "boolean";
3917 if ( jQuery
.isFunction( value
) ) {
3918 return this.each(function( i
) {
3919 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
3923 return this.each(function() {
3924 if ( type
=== "string" ) {
3925 // toggle individual class names
3928 self
= jQuery( this ),
3930 classNames
= value
.match( core_rnotwhite
) || [];
3932 while ( (className
= classNames
[ i
++ ]) ) {
3933 // check each className given, space separated list
3934 state
= isBool
? state
: !self
.hasClass( className
);
3935 self
[ state
? "addClass" : "removeClass" ]( className
);
3938 // Toggle whole class name
3939 } else if ( type
=== core_strundefined
|| type
=== "boolean" ) {
3940 if ( this.className
) {
3941 // store className if set
3942 data_priv
.set( this, "__className__", this.className
);
3945 // If the element has a class name or if we're passed "false",
3946 // then remove the whole classname (if there was one, the above saved it).
3947 // Otherwise bring back whatever was previously saved (if anything),
3948 // falling back to the empty string if nothing was stored.
3949 this.className
= this.className
|| value
=== false ? "" : data_priv
.get( this, "__className__" ) || "";
3954 hasClass: function( selector
) {
3955 var className
= " " + selector
+ " ",
3958 for ( ; i
< l
; i
++ ) {
3959 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) >= 0 ) {
3967 val: function( value
) {
3968 var hooks
, ret
, isFunction
,
3971 if ( !arguments
.length
) {
3973 hooks
= jQuery
.valHooks
[ elem
.type
] || jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
3975 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, "value" )) !== undefined ) {
3981 return typeof ret
=== "string" ?
3982 // handle most common string cases
3983 ret
.replace(rreturn
, "") :
3984 // handle cases where value is null/undef or number
3985 ret
== null ? "" : ret
;
3991 isFunction
= jQuery
.isFunction( value
);
3993 return this.each(function( i
) {
3996 if ( this.nodeType
!== 1 ) {
4001 val
= value
.call( this, i
, jQuery( this ).val() );
4006 // Treat null/undefined as ""; convert numbers to string
4007 if ( val
== null ) {
4009 } else if ( typeof val
=== "number" ) {
4011 } else if ( jQuery
.isArray( val
) ) {
4012 val
= jQuery
.map(val
, function ( value
) {
4013 return value
== null ? "" : value
+ "";
4017 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
4019 // If set returns undefined, fall back to normal setting
4020 if ( !hooks
|| !("set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
4030 get: function( elem
) {
4031 // attributes.value is undefined in Blackberry 4.7 but
4032 // uses .value. See #6932
4033 var val
= elem
.attributes
.value
;
4034 return !val
|| val
.specified
? elem
.value
: elem
.text
;
4038 get: function( elem
) {
4040 options
= elem
.options
,
4041 index
= elem
.selectedIndex
,
4042 one
= elem
.type
=== "select-one" || index
< 0,
4043 values
= one
? null : [],
4044 max
= one
? index
+ 1 : options
.length
,
4049 // Loop through all the selected options
4050 for ( ; i
< max
; i
++ ) {
4051 option
= options
[ i
];
4053 // IE6-9 doesn't update selected after form reset (#2551)
4054 if ( ( option
.selected
|| i
=== index
) &&
4055 // Don't return options that are disabled or in a disabled optgroup
4056 ( jQuery
.support
.optDisabled
? !option
.disabled
: option
.getAttribute("disabled") === null ) &&
4057 ( !option
.parentNode
.disabled
|| !jQuery
.nodeName( option
.parentNode
, "optgroup" ) ) ) {
4059 // Get the specific value for the option
4060 value
= jQuery( option
).val();
4062 // We don't need an array for one selects
4067 // Multi-Selects return an array
4068 values
.push( value
);
4075 set: function( elem
, value
) {
4076 var optionSet
, option
,
4077 options
= elem
.options
,
4078 values
= jQuery
.makeArray( value
),
4082 option
= options
[ i
];
4083 if ( (option
.selected
= jQuery
.inArray( jQuery(option
).val(), values
) >= 0) ) {
4088 // force browsers to behave consistently when non-matching value is set
4090 elem
.selectedIndex
= -1;
4097 attr: function( elem
, name
, value
) {
4099 nType
= elem
.nodeType
;
4101 // don't get/set attributes on text, comment and attribute nodes
4102 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
4106 // Fallback to prop when attributes are not supported
4107 if ( typeof elem
.getAttribute
=== core_strundefined
) {
4108 return jQuery
.prop( elem
, name
, value
);
4111 // All attributes are lowercase
4112 // Grab necessary hook if one is defined
4113 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
4114 name
= name
.toLowerCase();
4115 hooks
= jQuery
.attrHooks
[ name
] ||
4116 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook
: nodeHook
);
4119 if ( value
!== undefined ) {
4121 if ( value
=== null ) {
4122 jQuery
.removeAttr( elem
, name
);
4124 } else if ( hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
4128 elem
.setAttribute( name
, value
+ "" );
4132 } else if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
4136 ret
= jQuery
.find
.attr( elem
, name
);
4138 // Non-existent attributes return null, we normalize to undefined
4139 return ret
== null ?
4145 removeAttr: function( elem
, value
) {
4148 attrNames
= value
&& value
.match( core_rnotwhite
);
4150 if ( attrNames
&& elem
.nodeType
=== 1 ) {
4151 while ( (name
= attrNames
[i
++]) ) {
4152 propName
= jQuery
.propFix
[ name
] || name
;
4154 // Boolean attributes get special treatment (#10870)
4155 if ( jQuery
.expr
.match
.bool
.test( name
) ) {
4156 // Set corresponding property to false
4157 elem
[ propName
] = false;
4160 elem
.removeAttribute( name
);
4167 set: function( elem
, value
) {
4168 if ( !jQuery
.support
.radioValue
&& value
=== "radio" && jQuery
.nodeName(elem
, "input") ) {
4169 // Setting the type on a radio button after the value resets the value in IE6-9
4170 // Reset value to default in case type is set after value during creation
4171 var val
= elem
.value
;
4172 elem
.setAttribute( "type", value
);
4184 "class": "className"
4187 prop: function( elem
, name
, value
) {
4188 var ret
, hooks
, notxml
,
4189 nType
= elem
.nodeType
;
4191 // don't get/set properties on text, comment and attribute nodes
4192 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
4196 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
4199 // Fix name and attach hooks
4200 name
= jQuery
.propFix
[ name
] || name
;
4201 hooks
= jQuery
.propHooks
[ name
];
4204 if ( value
!== undefined ) {
4205 return hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ?
4207 ( elem
[ name
] = value
);
4210 return hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ?
4218 get: function( elem
) {
4219 return elem
.hasAttribute( "tabindex" ) || rfocusable
.test( elem
.nodeName
) || elem
.href
?
4227 // Hooks for boolean attributes
4229 set: function( elem
, value
, name
) {
4230 if ( value
=== false ) {
4231 // Remove boolean attributes when set to false
4232 jQuery
.removeAttr( elem
, name
);
4234 elem
.setAttribute( name
, name
);
4239 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( i
, name
) {
4240 var getter
= jQuery
.expr
.attrHandle
[ name
] || jQuery
.find
.attr
;
4242 jQuery
.expr
.attrHandle
[ name
] = function( elem
, name
, isXML
) {
4243 var fn
= jQuery
.expr
.attrHandle
[ name
],
4246 /* jshint eqeqeq: false */
4247 // Temporarily disable this handler to check existence
4248 (jQuery
.expr
.attrHandle
[ name
] = undefined) !=
4249 getter( elem
, name
, isXML
) ?
4251 name
.toLowerCase() :
4255 jQuery
.expr
.attrHandle
[ name
] = fn
;
4262 // Selectedness for an option in an optgroup can be inaccurate
4263 if ( !jQuery
.support
.optSelected
) {
4264 jQuery
.propHooks
.selected
= {
4265 get: function( elem
) {
4266 var parent
= elem
.parentNode
;
4267 if ( parent
&& parent
.parentNode
) {
4268 parent
.parentNode
.selectedIndex
;
4287 jQuery
.propFix
[ this.toLowerCase() ] = this;
4290 // Radios and checkboxes getter/setter
4291 jQuery
.each([ "radio", "checkbox" ], function() {
4292 jQuery
.valHooks
[ this ] = {
4293 set: function( elem
, value
) {
4294 if ( jQuery
.isArray( value
) ) {
4295 return ( elem
.checked
= jQuery
.inArray( jQuery(elem
).val(), value
) >= 0 );
4299 if ( !jQuery
.support
.checkOn
) {
4300 jQuery
.valHooks
[ this ].get = function( elem
) {
4302 // "" is returned instead of "on" if a value isn't specified
4303 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
4307 var rkeyEvent
= /^key/,
4308 rmouseEvent
= /^(?:mouse|contextmenu)|click/,
4309 rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
4310 rtypenamespace
= /^([^.]*)(?:\.(.+)|)$/;
4312 function returnTrue() {
4316 function returnFalse() {
4320 function safeActiveElement() {
4322 return document
.activeElement
;
4327 * Helper functions for managing events -- not part of the public interface.
4328 * Props to Dean Edwards' addEvent library for many of the ideas.
4334 add: function( elem
, types
, handler
, data
, selector
) {
4336 var handleObjIn
, eventHandle
, tmp
,
4337 events
, t
, handleObj
,
4338 special
, handlers
, type
, namespaces
, origType
,
4339 elemData
= data_priv
.get( elem
);
4341 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4346 // Caller can pass in an object of custom data in lieu of the handler
4347 if ( handler
.handler
) {
4348 handleObjIn
= handler
;
4349 handler
= handleObjIn
.handler
;
4350 selector
= handleObjIn
.selector
;
4353 // Make sure that the handler has a unique ID, used to find/remove it later
4354 if ( !handler
.guid
) {
4355 handler
.guid
= jQuery
.guid
++;
4358 // Init the element's event structure and main handler, if this is the first
4359 if ( !(events
= elemData
.events
) ) {
4360 events
= elemData
.events
= {};
4362 if ( !(eventHandle
= elemData
.handle
) ) {
4363 eventHandle
= elemData
.handle = function( e
) {
4364 // Discard the second event of a jQuery.event.trigger() and
4365 // when an event is called after a page has unloaded
4366 return typeof jQuery
!== core_strundefined
&& (!e
|| jQuery
.event
.triggered
!== e
.type
) ?
4367 jQuery
.event
.dispatch
.apply( eventHandle
.elem
, arguments
) :
4370 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
4371 eventHandle
.elem
= elem
;
4374 // Handle multiple events separated by a space
4375 types
= ( types
|| "" ).match( core_rnotwhite
) || [""];
4378 tmp
= rtypenamespace
.exec( types
[t
] ) || [];
4379 type
= origType
= tmp
[1];
4380 namespaces
= ( tmp
[2] || "" ).split( "." ).sort();
4382 // There *must* be a type, no attaching namespace-only handlers
4387 // If event changes its type, use the special event handlers for the changed type
4388 special
= jQuery
.event
.special
[ type
] || {};
4390 // If selector defined, determine special event api type, otherwise given type
4391 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
4393 // Update special based on newly reset type
4394 special
= jQuery
.event
.special
[ type
] || {};
4396 // handleObj is passed to all event handlers
4397 handleObj
= jQuery
.extend({
4404 needsContext
: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
4405 namespace: namespaces
.join(".")
4408 // Init the event handler queue if we're the first
4409 if ( !(handlers
= events
[ type
]) ) {
4410 handlers
= events
[ type
] = [];
4411 handlers
.delegateCount
= 0;
4413 // Only use addEventListener if the special events handler returns false
4414 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
4415 if ( elem
.addEventListener
) {
4416 elem
.addEventListener( type
, eventHandle
, false );
4421 if ( special
.add
) {
4422 special
.add
.call( elem
, handleObj
);
4424 if ( !handleObj
.handler
.guid
) {
4425 handleObj
.handler
.guid
= handler
.guid
;
4429 // Add to the element's handler list, delegates in front
4431 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
4433 handlers
.push( handleObj
);
4436 // Keep track of which events have ever been used, for event optimization
4437 jQuery
.event
.global
[ type
] = true;
4440 // Nullify elem to prevent memory leaks in IE
4444 // Detach an event or set of events from an element
4445 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
4447 var j
, origCount
, tmp
,
4448 events
, t
, handleObj
,
4449 special
, handlers
, type
, namespaces
, origType
,
4450 elemData
= data_priv
.hasData( elem
) && data_priv
.get( elem
);
4452 if ( !elemData
|| !(events
= elemData
.events
) ) {
4456 // Once for each type.namespace in types; type may be omitted
4457 types
= ( types
|| "" ).match( core_rnotwhite
) || [""];
4460 tmp
= rtypenamespace
.exec( types
[t
] ) || [];
4461 type
= origType
= tmp
[1];
4462 namespaces
= ( tmp
[2] || "" ).split( "." ).sort();
4464 // Unbind all events (on this namespace, if provided) for the element
4466 for ( type
in events
) {
4467 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
4472 special
= jQuery
.event
.special
[ type
] || {};
4473 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
4474 handlers
= events
[ type
] || [];
4475 tmp
= tmp
[2] && new RegExp( "(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4477 // Remove matching events
4478 origCount
= j
= handlers
.length
;
4480 handleObj
= handlers
[ j
];
4482 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
4483 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
4484 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
4485 ( !selector
|| selector
=== handleObj
.selector
|| selector
=== "**" && handleObj
.selector
) ) {
4486 handlers
.splice( j
, 1 );
4488 if ( handleObj
.selector
) {
4489 handlers
.delegateCount
--;
4491 if ( special
.remove
) {
4492 special
.remove
.call( elem
, handleObj
);
4497 // Remove generic event handler if we removed something and no more handlers exist
4498 // (avoids potential for endless recursion during removal of special event handlers)
4499 if ( origCount
&& !handlers
.length
) {
4500 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
4501 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
4504 delete events
[ type
];
4508 // Remove the expando if it's no longer used
4509 if ( jQuery
.isEmptyObject( events
) ) {
4510 delete elemData
.handle
;
4511 data_priv
.remove( elem
, "events" );
4515 trigger: function( event
, data
, elem
, onlyHandlers
) {
4517 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
,
4518 eventPath
= [ elem
|| document
],
4519 type
= core_hasOwn
.call( event
, "type" ) ? event
.type
: event
,
4520 namespaces
= core_hasOwn
.call( event
, "namespace" ) ? event
.namespace.split(".") : [];
4522 cur
= tmp
= elem
= elem
|| document
;
4524 // Don't do events on text and comment nodes
4525 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
4529 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4530 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
4534 if ( type
.indexOf(".") >= 0 ) {
4535 // Namespaced trigger; create a regexp to match event type in handle()
4536 namespaces
= type
.split(".");
4537 type
= namespaces
.shift();
4540 ontype
= type
.indexOf(":") < 0 && "on" + type
;
4542 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4543 event
= event
[ jQuery
.expando
] ?
4545 new jQuery
.Event( type
, typeof event
=== "object" && event
);
4547 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4548 event
.isTrigger
= onlyHandlers
? 2 : 3;
4549 event
.namespace = namespaces
.join(".");
4550 event
.namespace_re
= event
.namespace ?
4551 new RegExp( "(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4554 // Clean up the event in case it is being reused
4555 event
.result
= undefined;
4556 if ( !event
.target
) {
4557 event
.target
= elem
;
4560 // Clone any incoming data and prepend the event, creating the handler arg list
4561 data
= data
== null ?
4563 jQuery
.makeArray( data
, [ event
] );
4565 // Allow special events to draw outside the lines
4566 special
= jQuery
.event
.special
[ type
] || {};
4567 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
4571 // Determine event propagation path in advance, per W3C events spec (#9951)
4572 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4573 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
4575 bubbleType
= special
.delegateType
|| type
;
4576 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
4577 cur
= cur
.parentNode
;
4579 for ( ; cur
; cur
= cur
.parentNode
) {
4580 eventPath
.push( cur
);
4584 // Only add window if we got to document (e.g., not plain obj or detached DOM)
4585 if ( tmp
=== (elem
.ownerDocument
|| document
) ) {
4586 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
4590 // Fire handlers on the event path
4592 while ( (cur
= eventPath
[i
++]) && !event
.isPropagationStopped() ) {
4594 event
.type
= i
> 1 ?
4596 special
.bindType
|| type
;
4599 handle
= ( data_priv
.get( cur
, "events" ) || {} )[ event
.type
] && data_priv
.get( cur
, "handle" );
4601 handle
.apply( cur
, data
);
4605 handle
= ontype
&& cur
[ ontype
];
4606 if ( handle
&& jQuery
.acceptData( cur
) && handle
.apply
&& handle
.apply( cur
, data
) === false ) {
4607 event
.preventDefault();
4612 // If nobody prevented the default action, do it now
4613 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
4615 if ( (!special
._default
|| special
._default
.apply( eventPath
.pop(), data
) === false) &&
4616 jQuery
.acceptData( elem
) ) {
4618 // Call a native DOM method on the target with the same name name as the event.
4619 // Don't do default actions on window, that's where global variables be (#6170)
4620 if ( ontype
&& jQuery
.isFunction( elem
[ type
] ) && !jQuery
.isWindow( elem
) ) {
4622 // Don't re-trigger an onFOO event when we call its FOO() method
4623 tmp
= elem
[ ontype
];
4626 elem
[ ontype
] = null;
4629 // Prevent re-triggering of the same event, since we already bubbled it above
4630 jQuery
.event
.triggered
= type
;
4632 jQuery
.event
.triggered
= undefined;
4635 elem
[ ontype
] = tmp
;
4641 return event
.result
;
4644 dispatch: function( event
) {
4646 // Make a writable jQuery.Event from the native event object
4647 event
= jQuery
.event
.fix( event
);
4649 var i
, j
, ret
, matched
, handleObj
,
4651 args
= core_slice
.call( arguments
),
4652 handlers
= ( data_priv
.get( this, "events" ) || {} )[ event
.type
] || [],
4653 special
= jQuery
.event
.special
[ event
.type
] || {};
4655 // Use the fix-ed jQuery.Event rather than the (read-only) native event
4657 event
.delegateTarget
= this;
4659 // Call the preDispatch hook for the mapped type, and let it bail if desired
4660 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
4664 // Determine handlers
4665 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
4667 // Run delegates first; they may want to stop propagation beneath us
4669 while ( (matched
= handlerQueue
[ i
++ ]) && !event
.isPropagationStopped() ) {
4670 event
.currentTarget
= matched
.elem
;
4673 while ( (handleObj
= matched
.handlers
[ j
++ ]) && !event
.isImmediatePropagationStopped() ) {
4675 // Triggered event must either 1) have no namespace, or
4676 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
4677 if ( !event
.namespace_re
|| event
.namespace_re
.test( handleObj
.namespace ) ) {
4679 event
.handleObj
= handleObj
;
4680 event
.data
= handleObj
.data
;
4682 ret
= ( (jQuery
.event
.special
[ handleObj
.origType
] || {}).handle
|| handleObj
.handler
)
4683 .apply( matched
.elem
, args
);
4685 if ( ret
!== undefined ) {
4686 if ( (event
.result
= ret
) === false ) {
4687 event
.preventDefault();
4688 event
.stopPropagation();
4695 // Call the postDispatch hook for the mapped type
4696 if ( special
.postDispatch
) {
4697 special
.postDispatch
.call( this, event
);
4700 return event
.result
;
4703 handlers: function( event
, handlers
) {
4704 var i
, matches
, sel
, handleObj
,
4706 delegateCount
= handlers
.delegateCount
,
4709 // Find delegate handlers
4710 // Black-hole SVG <use> instance trees (#13180)
4711 // Avoid non-left-click bubbling in Firefox (#3861)
4712 if ( delegateCount
&& cur
.nodeType
&& (!event
.button
|| event
.type
!== "click") ) {
4714 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
4716 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
4717 if ( cur
.disabled
!== true || event
.type
!== "click" ) {
4719 for ( i
= 0; i
< delegateCount
; i
++ ) {
4720 handleObj
= handlers
[ i
];
4722 // Don't conflict with Object.prototype properties (#13203)
4723 sel
= handleObj
.selector
+ " ";
4725 if ( matches
[ sel
] === undefined ) {
4726 matches
[ sel
] = handleObj
.needsContext
?
4727 jQuery( sel
, this ).index( cur
) >= 0 :
4728 jQuery
.find( sel
, this, null, [ cur
] ).length
;
4730 if ( matches
[ sel
] ) {
4731 matches
.push( handleObj
);
4734 if ( matches
.length
) {
4735 handlerQueue
.push({ elem
: cur
, handlers
: matches
});
4741 // Add the remaining (directly-bound) handlers
4742 if ( delegateCount
< handlers
.length
) {
4743 handlerQueue
.push({ elem
: this, handlers
: handlers
.slice( delegateCount
) });
4746 return handlerQueue
;
4749 // Includes some event props shared by KeyEvent and MouseEvent
4750 props
: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
4755 props
: "char charCode key keyCode".split(" "),
4756 filter: function( event
, original
) {
4758 // Add which for key events
4759 if ( event
.which
== null ) {
4760 event
.which
= original
.charCode
!= null ? original
.charCode
: original
.keyCode
;
4768 props
: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
4769 filter: function( event
, original
) {
4770 var eventDoc
, doc
, body
,
4771 button
= original
.button
;
4773 // Calculate pageX/Y if missing and clientX/Y available
4774 if ( event
.pageX
== null && original
.clientX
!= null ) {
4775 eventDoc
= event
.target
.ownerDocument
|| document
;
4776 doc
= eventDoc
.documentElement
;
4777 body
= eventDoc
.body
;
4779 event
.pageX
= original
.clientX
+ ( doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0 ) - ( doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0 );
4780 event
.pageY
= original
.clientY
+ ( doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0 ) - ( doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0 );
4783 // Add which for click: 1 === left; 2 === middle; 3 === right
4784 // Note: button is not normalized, so don't use it
4785 if ( !event
.which
&& button
!== undefined ) {
4786 event
.which
= ( button
& 1 ? 1 : ( button
& 2 ? 3 : ( button
& 4 ? 2 : 0 ) ) );
4793 fix: function( event
) {
4794 if ( event
[ jQuery
.expando
] ) {
4798 // Create a writable copy of the event object and normalize some properties
4801 originalEvent
= event
,
4802 fixHook
= this.fixHooks
[ type
];
4805 this.fixHooks
[ type
] = fixHook
=
4806 rmouseEvent
.test( type
) ? this.mouseHooks
:
4807 rkeyEvent
.test( type
) ? this.keyHooks
:
4810 copy
= fixHook
.props
? this.props
.concat( fixHook
.props
) : this.props
;
4812 event
= new jQuery
.Event( originalEvent
);
4817 event
[ prop
] = originalEvent
[ prop
];
4820 // Support: Cordova 2.5 (WebKit) (#13255)
4821 // All events should have a target; Cordova deviceready doesn't
4822 if ( !event
.target
) {
4823 event
.target
= document
;
4826 // Support: Safari 6.0+, Chrome < 28
4827 // Target should not be a text node (#504, #13143)
4828 if ( event
.target
.nodeType
=== 3 ) {
4829 event
.target
= event
.target
.parentNode
;
4832 return fixHook
.filter
? fixHook
.filter( event
, originalEvent
) : event
;
4837 // Prevent triggered image.load events from bubbling to window.load
4841 // Fire native event if possible so blur/focus sequence is correct
4842 trigger: function() {
4843 if ( this !== safeActiveElement() && this.focus
) {
4848 delegateType
: "focusin"
4851 trigger: function() {
4852 if ( this === safeActiveElement() && this.blur
) {
4857 delegateType
: "focusout"
4860 // For checkbox, fire native event so checked state will be right
4861 trigger: function() {
4862 if ( this.type
=== "checkbox" && this.click
&& jQuery
.nodeName( this, "input" ) ) {
4868 // For cross-browser consistency, don't fire native .click() on links
4869 _default: function( event
) {
4870 return jQuery
.nodeName( event
.target
, "a" );
4875 postDispatch: function( event
) {
4877 // Support: Firefox 20+
4878 // Firefox doesn't alert if the returnValue field is not set.
4879 if ( event
.result
!== undefined ) {
4880 event
.originalEvent
.returnValue
= event
.result
;
4886 simulate: function( type
, elem
, event
, bubble
) {
4887 // Piggyback on a donor event to simulate a different one.
4888 // Fake originalEvent to avoid donor's stopPropagation, but if the
4889 // simulated event prevents default then we do the same on the donor.
4890 var e
= jQuery
.extend(
4900 jQuery
.event
.trigger( e
, null, elem
);
4902 jQuery
.event
.dispatch
.call( elem
, e
);
4904 if ( e
.isDefaultPrevented() ) {
4905 event
.preventDefault();
4910 jQuery
.removeEvent = function( elem
, type
, handle
) {
4911 if ( elem
.removeEventListener
) {
4912 elem
.removeEventListener( type
, handle
, false );
4916 jQuery
.Event = function( src
, props
) {
4917 // Allow instantiation without the 'new' keyword
4918 if ( !(this instanceof jQuery
.Event
) ) {
4919 return new jQuery
.Event( src
, props
);
4923 if ( src
&& src
.type
) {
4924 this.originalEvent
= src
;
4925 this.type
= src
.type
;
4927 // Events bubbling up the document may have been marked as prevented
4928 // by a handler lower down the tree; reflect the correct value.
4929 this.isDefaultPrevented
= ( src
.defaultPrevented
||
4930 src
.getPreventDefault
&& src
.getPreventDefault() ) ? returnTrue
: returnFalse
;
4937 // Put explicitly provided properties onto the event object
4939 jQuery
.extend( this, props
);
4942 // Create a timestamp if incoming event doesn't have one
4943 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
4946 this[ jQuery
.expando
] = true;
4949 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
4950 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
4951 jQuery
.Event
.prototype = {
4952 isDefaultPrevented
: returnFalse
,
4953 isPropagationStopped
: returnFalse
,
4954 isImmediatePropagationStopped
: returnFalse
,
4956 preventDefault: function() {
4957 var e
= this.originalEvent
;
4959 this.isDefaultPrevented
= returnTrue
;
4961 if ( e
&& e
.preventDefault
) {
4965 stopPropagation: function() {
4966 var e
= this.originalEvent
;
4968 this.isPropagationStopped
= returnTrue
;
4970 if ( e
&& e
.stopPropagation
) {
4971 e
.stopPropagation();
4974 stopImmediatePropagation: function() {
4975 this.isImmediatePropagationStopped
= returnTrue
;
4976 this.stopPropagation();
4980 // Create mouseenter/leave events using mouseover/out and event-time checks
4981 // Support: Chrome 15+
4983 mouseenter
: "mouseover",
4984 mouseleave
: "mouseout"
4985 }, function( orig
, fix
) {
4986 jQuery
.event
.special
[ orig
] = {
4990 handle: function( event
) {
4993 related
= event
.relatedTarget
,
4994 handleObj
= event
.handleObj
;
4996 // For mousenter/leave call the handler if related is outside the target.
4997 // NB: No relatedTarget if the mouse left/entered the browser window
4998 if ( !related
|| (related
!== target
&& !jQuery
.contains( target
, related
)) ) {
4999 event
.type
= handleObj
.origType
;
5000 ret
= handleObj
.handler
.apply( this, arguments
);
5008 // Create "bubbling" focus and blur events
5009 // Support: Firefox, Chrome, Safari
5010 if ( !jQuery
.support
.focusinBubbles
) {
5011 jQuery
.each({ focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
5013 // Attach a single capturing handler while someone wants focusin/focusout
5015 handler = function( event
) {
5016 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
), true );
5019 jQuery
.event
.special
[ fix
] = {
5021 if ( attaches
++ === 0 ) {
5022 document
.addEventListener( orig
, handler
, true );
5025 teardown: function() {
5026 if ( --attaches
=== 0 ) {
5027 document
.removeEventListener( orig
, handler
, true );
5036 on: function( types
, selector
, data
, fn
, /*INTERNAL*/ one
) {
5039 // Types can be a map of types/handlers
5040 if ( typeof types
=== "object" ) {
5041 // ( types-Object, selector, data )
5042 if ( typeof selector
!== "string" ) {
5043 // ( types-Object, data )
5044 data
= data
|| selector
;
5045 selector
= undefined;
5047 for ( type
in types
) {
5048 this.on( type
, selector
, data
, types
[ type
], one
);
5053 if ( data
== null && fn
== null ) {
5056 data
= selector
= undefined;
5057 } else if ( fn
== null ) {
5058 if ( typeof selector
=== "string" ) {
5059 // ( types, selector, fn )
5063 // ( types, data, fn )
5066 selector
= undefined;
5069 if ( fn
=== false ) {
5077 fn = function( event
) {
5078 // Can use an empty set, since event contains the info
5079 jQuery().off( event
);
5080 return origFn
.apply( this, arguments
);
5082 // Use same guid so caller can remove using origFn
5083 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
5085 return this.each( function() {
5086 jQuery
.event
.add( this, types
, fn
, data
, selector
);
5089 one: function( types
, selector
, data
, fn
) {
5090 return this.on( types
, selector
, data
, fn
, 1 );
5092 off: function( types
, selector
, fn
) {
5093 var handleObj
, type
;
5094 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
5095 // ( event ) dispatched jQuery.Event
5096 handleObj
= types
.handleObj
;
5097 jQuery( types
.delegateTarget
).off(
5098 handleObj
.namespace ? handleObj
.origType
+ "." + handleObj
.namespace : handleObj
.origType
,
5104 if ( typeof types
=== "object" ) {
5105 // ( types-object [, selector] )
5106 for ( type
in types
) {
5107 this.off( type
, selector
, types
[ type
] );
5111 if ( selector
=== false || typeof selector
=== "function" ) {
5114 selector
= undefined;
5116 if ( fn
=== false ) {
5119 return this.each(function() {
5120 jQuery
.event
.remove( this, types
, fn
, selector
);
5124 trigger: function( type
, data
) {
5125 return this.each(function() {
5126 jQuery
.event
.trigger( type
, data
, this );
5129 triggerHandler: function( type
, data
) {
5132 return jQuery
.event
.trigger( type
, data
, elem
, true );
5136 var isSimple
= /^.[^:#\[\.,]*$/,
5137 rparentsprev
= /^(?:parents|prev(?:Until|All))/,
5138 rneedsContext
= jQuery
.expr
.match
.needsContext
,
5139 // methods guaranteed to produce a unique set when starting from a unique set
5140 guaranteedUnique
= {
5148 find: function( selector
) {
5154 if ( typeof selector
!== "string" ) {
5155 return this.pushStack( jQuery( selector
).filter(function() {
5156 for ( i
= 0; i
< len
; i
++ ) {
5157 if ( jQuery
.contains( self
[ i
], this ) ) {
5164 for ( i
= 0; i
< len
; i
++ ) {
5165 jQuery
.find( selector
, self
[ i
], ret
);
5168 // Needed because $( selector, context ) becomes $( context ).find( selector )
5169 ret
= this.pushStack( len
> 1 ? jQuery
.unique( ret
) : ret
);
5170 ret
.selector
= this.selector
? this.selector
+ " " + selector
: selector
;
5174 has: function( target
) {
5175 var targets
= jQuery( target
, this ),
5178 return this.filter(function() {
5180 for ( ; i
< l
; i
++ ) {
5181 if ( jQuery
.contains( this, targets
[i
] ) ) {
5188 not: function( selector
) {
5189 return this.pushStack( winnow(this, selector
|| [], true) );
5192 filter: function( selector
) {
5193 return this.pushStack( winnow(this, selector
|| [], false) );
5196 is: function( selector
) {
5200 // If this is a positional/relative selector, check membership in the returned set
5201 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5202 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
5203 jQuery( selector
) :
5209 closest: function( selectors
, context
) {
5214 pos
= ( rneedsContext
.test( selectors
) || typeof selectors
!== "string" ) ?
5215 jQuery( selectors
, context
|| this.context
) :
5218 for ( ; i
< l
; i
++ ) {
5219 for ( cur
= this[i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
5220 // Always skip document fragments
5221 if ( cur
.nodeType
< 11 && (pos
?
5222 pos
.index(cur
) > -1 :
5224 // Don't pass non-elements to Sizzle
5225 cur
.nodeType
=== 1 &&
5226 jQuery
.find
.matchesSelector(cur
, selectors
)) ) {
5228 cur
= matched
.push( cur
);
5234 return this.pushStack( matched
.length
> 1 ? jQuery
.unique( matched
) : matched
);
5237 // Determine the position of an element within
5238 // the matched set of elements
5239 index: function( elem
) {
5241 // No argument, return index in parent
5243 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length
: -1;
5246 // index in selector
5247 if ( typeof elem
=== "string" ) {
5248 return core_indexOf
.call( jQuery( elem
), this[ 0 ] );
5251 // Locate the position of the desired element
5252 return core_indexOf
.call( this,
5254 // If it receives a jQuery object, the first element is used
5255 elem
.jquery
? elem
[ 0 ] : elem
5259 add: function( selector
, context
) {
5260 var set = typeof selector
=== "string" ?
5261 jQuery( selector
, context
) :
5262 jQuery
.makeArray( selector
&& selector
.nodeType
? [ selector
] : selector
),
5263 all
= jQuery
.merge( this.get(), set );
5265 return this.pushStack( jQuery
.unique(all
) );
5268 addBack: function( selector
) {
5269 return this.add( selector
== null ?
5270 this.prevObject
: this.prevObject
.filter(selector
)
5275 function sibling( cur
, dir
) {
5276 while ( (cur
= cur
[dir
]) && cur
.nodeType
!== 1 ) {}
5282 parent: function( elem
) {
5283 var parent
= elem
.parentNode
;
5284 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
5286 parents: function( elem
) {
5287 return jQuery
.dir( elem
, "parentNode" );
5289 parentsUntil: function( elem
, i
, until
) {
5290 return jQuery
.dir( elem
, "parentNode", until
);
5292 next: function( elem
) {
5293 return sibling( elem
, "nextSibling" );
5295 prev: function( elem
) {
5296 return sibling( elem
, "previousSibling" );
5298 nextAll: function( elem
) {
5299 return jQuery
.dir( elem
, "nextSibling" );
5301 prevAll: function( elem
) {
5302 return jQuery
.dir( elem
, "previousSibling" );
5304 nextUntil: function( elem
, i
, until
) {
5305 return jQuery
.dir( elem
, "nextSibling", until
);
5307 prevUntil: function( elem
, i
, until
) {
5308 return jQuery
.dir( elem
, "previousSibling", until
);
5310 siblings: function( elem
) {
5311 return jQuery
.sibling( ( elem
.parentNode
|| {} ).firstChild
, elem
);
5313 children: function( elem
) {
5314 return jQuery
.sibling( elem
.firstChild
);
5316 contents: function( elem
) {
5317 return jQuery
.nodeName( elem
, "iframe" ) ?
5318 elem
.contentDocument
|| elem
.contentWindow
.document
:
5319 jQuery
.merge( [], elem
.childNodes
);
5321 }, function( name
, fn
) {
5322 jQuery
.fn
[ name
] = function( until
, selector
) {
5323 var matched
= jQuery
.map( this, fn
, until
);
5325 if ( name
.slice( -5 ) !== "Until" ) {
5329 if ( selector
&& typeof selector
=== "string" ) {
5330 matched
= jQuery
.filter( selector
, matched
);
5333 if ( this.length
> 1 ) {
5334 // Remove duplicates
5335 if ( !guaranteedUnique
[ name
] ) {
5336 jQuery
.unique( matched
);
5339 // Reverse order for parents* and prev-derivatives
5340 if ( rparentsprev
.test( name
) ) {
5345 return this.pushStack( matched
);
5350 filter: function( expr
, elems
, not
) {
5351 var elem
= elems
[ 0 ];
5354 expr
= ":not(" + expr
+ ")";
5357 return elems
.length
=== 1 && elem
.nodeType
=== 1 ?
5358 jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [] :
5359 jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
5360 return elem
.nodeType
=== 1;
5364 dir: function( elem
, dir
, until
) {
5366 truncate
= until
!== undefined;
5368 while ( (elem
= elem
[ dir
]) && elem
.nodeType
!== 9 ) {
5369 if ( elem
.nodeType
=== 1 ) {
5370 if ( truncate
&& jQuery( elem
).is( until
) ) {
5373 matched
.push( elem
);
5379 sibling: function( n
, elem
) {
5382 for ( ; n
; n
= n
.nextSibling
) {
5383 if ( n
.nodeType
=== 1 && n
!== elem
) {
5392 // Implement the identical functionality for filter and not
5393 function winnow( elements
, qualifier
, not
) {
5394 if ( jQuery
.isFunction( qualifier
) ) {
5395 return jQuery
.grep( elements
, function( elem
, i
) {
5397 return !!qualifier
.call( elem
, i
, elem
) !== not
;
5402 if ( qualifier
.nodeType
) {
5403 return jQuery
.grep( elements
, function( elem
) {
5404 return ( elem
=== qualifier
) !== not
;
5409 if ( typeof qualifier
=== "string" ) {
5410 if ( isSimple
.test( qualifier
) ) {
5411 return jQuery
.filter( qualifier
, elements
, not
);
5414 qualifier
= jQuery
.filter( qualifier
, elements
);
5417 return jQuery
.grep( elements
, function( elem
) {
5418 return ( core_indexOf
.call( qualifier
, elem
) >= 0 ) !== not
;
5421 var rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5422 rtagName
= /<([\w:]+)/,
5423 rhtml
= /<|&#?\w+;/,
5424 rnoInnerhtml
= /<(?:script|style|link)/i,
5425 manipulation_rcheckableType
= /^(?:checkbox|radio)$/i,
5426 // checked="checked" or checked
5427 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5428 rscriptType
= /^$|\/(?:java|ecma)script/i,
5429 rscriptTypeMasked
= /^true\/(.*)/,
5430 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
5432 // We have to close these tags to support XHTML (#13200)
5436 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
5438 thead
: [ 1, "<table>", "</table>" ],
5439 col
: [ 2, "<table><colgroup>", "</colgroup></table>" ],
5440 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
5441 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5443 _default
: [ 0, "", "" ]
5447 wrapMap
.optgroup
= wrapMap
.option
;
5449 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
5450 wrapMap
.th
= wrapMap
.td
;
5453 text: function( value
) {
5454 return jQuery
.access( this, function( value
) {
5455 return value
=== undefined ?
5456 jQuery
.text( this ) :
5457 this.empty().append( ( this[ 0 ] && this[ 0 ].ownerDocument
|| document
).createTextNode( value
) );
5458 }, null, value
, arguments
.length
);
5461 append: function() {
5462 return this.domManip( arguments
, function( elem
) {
5463 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5464 var target
= manipulationTarget( this, elem
);
5465 target
.appendChild( elem
);
5470 prepend: function() {
5471 return this.domManip( arguments
, function( elem
) {
5472 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
5473 var target
= manipulationTarget( this, elem
);
5474 target
.insertBefore( elem
, target
.firstChild
);
5479 before: function() {
5480 return this.domManip( arguments
, function( elem
) {
5481 if ( this.parentNode
) {
5482 this.parentNode
.insertBefore( elem
, this );
5488 return this.domManip( arguments
, function( elem
) {
5489 if ( this.parentNode
) {
5490 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5495 // keepData is for internal use only--do not document
5496 remove: function( selector
, keepData
) {
5498 elems
= selector
? jQuery
.filter( selector
, this ) : this,
5501 for ( ; (elem
= elems
[i
]) != null; i
++ ) {
5502 if ( !keepData
&& elem
.nodeType
=== 1 ) {
5503 jQuery
.cleanData( getAll( elem
) );
5506 if ( elem
.parentNode
) {
5507 if ( keepData
&& jQuery
.contains( elem
.ownerDocument
, elem
) ) {
5508 setGlobalEval( getAll( elem
, "script" ) );
5510 elem
.parentNode
.removeChild( elem
);
5521 for ( ; (elem
= this[i
]) != null; i
++ ) {
5522 if ( elem
.nodeType
=== 1 ) {
5524 // Prevent memory leaks
5525 jQuery
.cleanData( getAll( elem
, false ) );
5527 // Remove any remaining nodes
5528 elem
.textContent
= "";
5535 clone: function( dataAndEvents
, deepDataAndEvents
) {
5536 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5537 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents
: deepDataAndEvents
;
5539 return this.map( function () {
5540 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5544 html: function( value
) {
5545 return jQuery
.access( this, function( value
) {
5546 var elem
= this[ 0 ] || {},
5550 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
5551 return elem
.innerHTML
;
5554 // See if we can take a shortcut and just use innerHTML
5555 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5556 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
5558 value
= value
.replace( rxhtmlTag
, "<$1></$2>" );
5561 for ( ; i
< l
; i
++ ) {
5562 elem
= this[ i
] || {};
5564 // Remove element nodes and prevent memory leaks
5565 if ( elem
.nodeType
=== 1 ) {
5566 jQuery
.cleanData( getAll( elem
, false ) );
5567 elem
.innerHTML
= value
;
5573 // If using innerHTML throws an exception, use the fallback method
5578 this.empty().append( value
);
5580 }, null, value
, arguments
.length
);
5583 replaceWith: function() {
5585 // Snapshot the DOM in case .domManip sweeps something relevant into its fragment
5586 args
= jQuery
.map( this, function( elem
) {
5587 return [ elem
.nextSibling
, elem
.parentNode
];
5591 // Make the changes, replacing each context element with the new content
5592 this.domManip( arguments
, function( elem
) {
5593 var next
= args
[ i
++ ],
5594 parent
= args
[ i
++ ];
5597 // Don't use the snapshot next if it has moved (#13810)
5598 if ( next
&& next
.parentNode
!== parent
) {
5599 next
= this.nextSibling
;
5601 jQuery( this ).remove();
5602 parent
.insertBefore( elem
, next
);
5604 // Allow new content to include elements from the context set
5607 // Force removal if there was no new content (e.g., from empty arguments)
5608 return i
? this : this.remove();
5611 detach: function( selector
) {
5612 return this.remove( selector
, true );
5615 domManip: function( args
, callback
, allowIntersection
) {
5617 // Flatten any nested arrays
5618 args
= core_concat
.apply( [], args
);
5620 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
5626 isFunction
= jQuery
.isFunction( value
);
5628 // We can't cloneNode fragments that contain checked, in WebKit
5629 if ( isFunction
|| !( l
<= 1 || typeof value
!== "string" || jQuery
.support
.checkClone
|| !rchecked
.test( value
) ) ) {
5630 return this.each(function( index
) {
5631 var self
= set.eq( index
);
5633 args
[ 0 ] = value
.call( this, index
, self
.html() );
5635 self
.domManip( args
, callback
, allowIntersection
);
5640 fragment
= jQuery
.buildFragment( args
, this[ 0 ].ownerDocument
, false, !allowIntersection
&& this );
5641 first
= fragment
.firstChild
;
5643 if ( fragment
.childNodes
.length
=== 1 ) {
5648 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
5649 hasScripts
= scripts
.length
;
5651 // Use the original fragment for the last item instead of the first because it can end up
5652 // being emptied incorrectly in certain situations (#8070).
5653 for ( ; i
< l
; i
++ ) {
5656 if ( i
!== iNoClone
) {
5657 node
= jQuery
.clone( node
, true, true );
5659 // Keep references to cloned scripts for later restoration
5661 // Support: QtWebKit
5662 // jQuery.merge because core_push.apply(_, arraylike) throws
5663 jQuery
.merge( scripts
, getAll( node
, "script" ) );
5667 callback
.call( this[ i
], node
, i
);
5671 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
5674 jQuery
.map( scripts
, restoreScript
);
5676 // Evaluate executable scripts on first document insertion
5677 for ( i
= 0; i
< hasScripts
; i
++ ) {
5678 node
= scripts
[ i
];
5679 if ( rscriptType
.test( node
.type
|| "" ) &&
5680 !data_priv
.access( node
, "globalEval" ) && jQuery
.contains( doc
, node
) ) {
5683 // Hope ajax is available...
5684 jQuery
._evalUrl( node
.src
);
5686 jQuery
.globalEval( node
.textContent
.replace( rcleanScript
, "" ) );
5700 prependTo
: "prepend",
5701 insertBefore
: "before",
5702 insertAfter
: "after",
5703 replaceAll
: "replaceWith"
5704 }, function( name
, original
) {
5705 jQuery
.fn
[ name
] = function( selector
) {
5708 insert
= jQuery( selector
),
5709 last
= insert
.length
- 1,
5712 for ( ; i
<= last
; i
++ ) {
5713 elems
= i
=== last
? this : this.clone( true );
5714 jQuery( insert
[ i
] )[ original
]( elems
);
5716 // Support: QtWebKit
5717 // .get() because core_push.apply(_, arraylike) throws
5718 core_push
.apply( ret
, elems
.get() );
5721 return this.pushStack( ret
);
5726 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
5727 var i
, l
, srcElements
, destElements
,
5728 clone
= elem
.cloneNode( true ),
5729 inPage
= jQuery
.contains( elem
.ownerDocument
, elem
);
5732 // Fix Cloning issues
5733 if ( !jQuery
.support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) && !jQuery
.isXMLDoc( elem
) ) {
5735 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
5736 destElements
= getAll( clone
);
5737 srcElements
= getAll( elem
);
5739 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5740 fixInput( srcElements
[ i
], destElements
[ i
] );
5744 // Copy the events from the original to the clone
5745 if ( dataAndEvents
) {
5746 if ( deepDataAndEvents
) {
5747 srcElements
= srcElements
|| getAll( elem
);
5748 destElements
= destElements
|| getAll( clone
);
5750 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
5751 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
5754 cloneCopyEvent( elem
, clone
);
5758 // Preserve script evaluation history
5759 destElements
= getAll( clone
, "script" );
5760 if ( destElements
.length
> 0 ) {
5761 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
5764 // Return the cloned set
5768 buildFragment: function( elems
, context
, scripts
, selection
) {
5769 var elem
, tmp
, tag
, wrap
, contains
, j
,
5772 fragment
= context
.createDocumentFragment(),
5775 for ( ; i
< l
; i
++ ) {
5778 if ( elem
|| elem
=== 0 ) {
5780 // Add nodes directly
5781 if ( jQuery
.type( elem
) === "object" ) {
5782 // Support: QtWebKit
5783 // jQuery.merge because core_push.apply(_, arraylike) throws
5784 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
5786 // Convert non-html into a text node
5787 } else if ( !rhtml
.test( elem
) ) {
5788 nodes
.push( context
.createTextNode( elem
) );
5790 // Convert html into DOM nodes
5792 tmp
= tmp
|| fragment
.appendChild( context
.createElement("div") );
5794 // Deserialize a standard representation
5795 tag
= ( rtagName
.exec( elem
) || ["", ""] )[ 1 ].toLowerCase();
5796 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
5797 tmp
.innerHTML
= wrap
[ 1 ] + elem
.replace( rxhtmlTag
, "<$1></$2>" ) + wrap
[ 2 ];
5799 // Descend through wrappers to the right content
5802 tmp
= tmp
.firstChild
;
5805 // Support: QtWebKit
5806 // jQuery.merge because core_push.apply(_, arraylike) throws
5807 jQuery
.merge( nodes
, tmp
.childNodes
);
5809 // Remember the top-level container
5810 tmp
= fragment
.firstChild
;
5813 // Support: Webkit, IE
5814 tmp
.textContent
= "";
5819 // Remove wrapper from fragment
5820 fragment
.textContent
= "";
5823 while ( (elem
= nodes
[ i
++ ]) ) {
5825 // #4087 - If origin and destination elements are the same, and this is
5826 // that element, do not do anything
5827 if ( selection
&& jQuery
.inArray( elem
, selection
) !== -1 ) {
5831 contains
= jQuery
.contains( elem
.ownerDocument
, elem
);
5833 // Append to fragment
5834 tmp
= getAll( fragment
.appendChild( elem
), "script" );
5836 // Preserve script evaluation history
5838 setGlobalEval( tmp
);
5841 // Capture executables
5844 while ( (elem
= tmp
[ j
++ ]) ) {
5845 if ( rscriptType
.test( elem
.type
|| "" ) ) {
5846 scripts
.push( elem
);
5855 cleanData: function( elems
) {
5856 var data
, elem
, events
, type
, key
, j
,
5857 special
= jQuery
.event
.special
,
5860 for ( ; (elem
= elems
[ i
]) !== undefined; i
++ ) {
5861 if ( Data
.accepts( elem
) ) {
5862 key
= elem
[ data_priv
.expando
];
5864 if ( key
&& (data
= data_priv
.cache
[ key
]) ) {
5865 events
= Object
.keys( data
.events
|| {} );
5866 if ( events
.length
) {
5867 for ( j
= 0; (type
= events
[j
]) !== undefined; j
++ ) {
5868 if ( special
[ type
] ) {
5869 jQuery
.event
.remove( elem
, type
);
5871 // This is a shortcut to avoid jQuery.event.remove's overhead
5873 jQuery
.removeEvent( elem
, type
, data
.handle
);
5877 if ( data_priv
.cache
[ key
] ) {
5878 // Discard any remaining `private` data
5879 delete data_priv
.cache
[ key
];
5883 // Discard any remaining `user` data
5884 delete data_user
.cache
[ elem
[ data_user
.expando
] ];
5888 _evalUrl: function( url
) {
5889 return jQuery
.ajax({
5900 // Support: 1.x compatibility
5901 // Manipulating tables requires a tbody
5902 function manipulationTarget( elem
, content
) {
5903 return jQuery
.nodeName( elem
, "table" ) &&
5904 jQuery
.nodeName( content
.nodeType
=== 1 ? content
: content
.firstChild
, "tr" ) ?
5906 elem
.getElementsByTagName("tbody")[0] ||
5907 elem
.appendChild( elem
.ownerDocument
.createElement("tbody") ) :
5911 // Replace/restore the type attribute of script elements for safe DOM manipulation
5912 function disableScript( elem
) {
5913 elem
.type
= (elem
.getAttribute("type") !== null) + "/" + elem
.type
;
5916 function restoreScript( elem
) {
5917 var match
= rscriptTypeMasked
.exec( elem
.type
);
5920 elem
.type
= match
[ 1 ];
5922 elem
.removeAttribute("type");
5928 // Mark scripts as having already been evaluated
5929 function setGlobalEval( elems
, refElements
) {
5930 var l
= elems
.length
,
5933 for ( ; i
< l
; i
++ ) {
5935 elems
[ i
], "globalEval", !refElements
|| data_priv
.get( refElements
[ i
], "globalEval" )
5940 function cloneCopyEvent( src
, dest
) {
5941 var i
, l
, type
, pdataOld
, pdataCur
, udataOld
, udataCur
, events
;
5943 if ( dest
.nodeType
!== 1 ) {
5947 // 1. Copy private data: events, handlers, etc.
5948 if ( data_priv
.hasData( src
) ) {
5949 pdataOld
= data_priv
.access( src
);
5950 pdataCur
= data_priv
.set( dest
, pdataOld
);
5951 events
= pdataOld
.events
;
5954 delete pdataCur
.handle
;
5955 pdataCur
.events
= {};
5957 for ( type
in events
) {
5958 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
5959 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
5965 // 2. Copy user data
5966 if ( data_user
.hasData( src
) ) {
5967 udataOld
= data_user
.access( src
);
5968 udataCur
= jQuery
.extend( {}, udataOld
);
5970 data_user
.set( dest
, udataCur
);
5975 function getAll( context
, tag
) {
5976 var ret
= context
.getElementsByTagName
? context
.getElementsByTagName( tag
|| "*" ) :
5977 context
.querySelectorAll
? context
.querySelectorAll( tag
|| "*" ) :
5980 return tag
=== undefined || tag
&& jQuery
.nodeName( context
, tag
) ?
5981 jQuery
.merge( [ context
], ret
) :
5986 function fixInput( src
, dest
) {
5987 var nodeName
= dest
.nodeName
.toLowerCase();
5989 // Fails to persist the checked state of a cloned checkbox or radio button.
5990 if ( nodeName
=== "input" && manipulation_rcheckableType
.test( src
.type
) ) {
5991 dest
.checked
= src
.checked
;
5993 // Fails to return the selected option to the default selected state when cloning options
5994 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
5995 dest
.defaultValue
= src
.defaultValue
;
5999 wrapAll: function( html
) {
6002 if ( jQuery
.isFunction( html
) ) {
6003 return this.each(function( i
) {
6004 jQuery( this ).wrapAll( html
.call(this, i
) );
6010 // The elements to wrap the target around
6011 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
6013 if ( this[ 0 ].parentNode
) {
6014 wrap
.insertBefore( this[ 0 ] );
6017 wrap
.map(function() {
6020 while ( elem
.firstElementChild
) {
6021 elem
= elem
.firstElementChild
;
6031 wrapInner: function( html
) {
6032 if ( jQuery
.isFunction( html
) ) {
6033 return this.each(function( i
) {
6034 jQuery( this ).wrapInner( html
.call(this, i
) );
6038 return this.each(function() {
6039 var self
= jQuery( this ),
6040 contents
= self
.contents();
6042 if ( contents
.length
) {
6043 contents
.wrapAll( html
);
6046 self
.append( html
);
6051 wrap: function( html
) {
6052 var isFunction
= jQuery
.isFunction( html
);
6054 return this.each(function( i
) {
6055 jQuery( this ).wrapAll( isFunction
? html
.call(this, i
) : html
);
6059 unwrap: function() {
6060 return this.parent().each(function() {
6061 if ( !jQuery
.nodeName( this, "body" ) ) {
6062 jQuery( this ).replaceWith( this.childNodes
);
6068 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6069 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6070 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
6071 rmargin
= /^margin/,
6072 rnumsplit
= new RegExp( "^(" + core_pnum
+ ")(.*)$", "i" ),
6073 rnumnonpx
= new RegExp( "^(" + core_pnum
+ ")(?!px)[a-z%]+$", "i" ),
6074 rrelNum
= new RegExp( "^([+-])=(" + core_pnum
+ ")", "i" ),
6075 elemdisplay
= { BODY
: "block" },
6077 cssShow
= { position
: "absolute", visibility
: "hidden", display
: "block" },
6078 cssNormalTransform
= {
6083 cssExpand
= [ "Top", "Right", "Bottom", "Left" ],
6084 cssPrefixes
= [ "Webkit", "O", "Moz", "ms" ];
6086 // return a css property mapped to a potentially vendor prefixed property
6087 function vendorPropName( style
, name
) {
6089 // shortcut for names that are not vendor prefixed
6090 if ( name
in style
) {
6094 // check for vendor prefixed names
6095 var capName
= name
.charAt(0).toUpperCase() + name
.slice(1),
6097 i
= cssPrefixes
.length
;
6100 name
= cssPrefixes
[ i
] + capName
;
6101 if ( name
in style
) {
6109 function isHidden( elem
, el
) {
6110 // isHidden might be called from jQuery#filter function;
6111 // in that case, element will be second argument
6113 return jQuery
.css( elem
, "display" ) === "none" || !jQuery
.contains( elem
.ownerDocument
, elem
);
6116 // NOTE: we've included the "window" in window.getComputedStyle
6117 // because jsdom on node.js will break without it.
6118 function getStyles( elem
) {
6119 return window
.getComputedStyle( elem
, null );
6122 function showHide( elements
, show
) {
6123 var display
, elem
, hidden
,
6126 length
= elements
.length
;
6128 for ( ; index
< length
; index
++ ) {
6129 elem
= elements
[ index
];
6130 if ( !elem
.style
) {
6134 values
[ index
] = data_priv
.get( elem
, "olddisplay" );
6135 display
= elem
.style
.display
;
6137 // Reset the inline display of this element to learn if it is
6138 // being hidden by cascaded rules or not
6139 if ( !values
[ index
] && display
=== "none" ) {
6140 elem
.style
.display
= "";
6143 // Set elements which have been overridden with display: none
6144 // in a stylesheet to whatever the default browser style is
6145 // for such an element
6146 if ( elem
.style
.display
=== "" && isHidden( elem
) ) {
6147 values
[ index
] = data_priv
.access( elem
, "olddisplay", css_defaultDisplay(elem
.nodeName
) );
6151 if ( !values
[ index
] ) {
6152 hidden
= isHidden( elem
);
6154 if ( display
&& display
!== "none" || !hidden
) {
6155 data_priv
.set( elem
, "olddisplay", hidden
? display
: jQuery
.css(elem
, "display") );
6161 // Set the display of most of the elements in a second loop
6162 // to avoid the constant reflow
6163 for ( index
= 0; index
< length
; index
++ ) {
6164 elem
= elements
[ index
];
6165 if ( !elem
.style
) {
6168 if ( !show
|| elem
.style
.display
=== "none" || elem
.style
.display
=== "" ) {
6169 elem
.style
.display
= show
? values
[ index
] || "" : "none";
6177 css: function( name
, value
) {
6178 return jQuery
.access( this, function( elem
, name
, value
) {
6183 if ( jQuery
.isArray( name
) ) {
6184 styles
= getStyles( elem
);
6187 for ( ; i
< len
; i
++ ) {
6188 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
6194 return value
!== undefined ?
6195 jQuery
.style( elem
, name
, value
) :
6196 jQuery
.css( elem
, name
);
6197 }, name
, value
, arguments
.length
> 1 );
6200 return showHide( this, true );
6203 return showHide( this );
6205 toggle: function( state
) {
6206 var bool
= typeof state
=== "boolean";
6208 return this.each(function() {
6209 if ( bool
? state
: isHidden( this ) ) {
6210 jQuery( this ).show();
6212 jQuery( this ).hide();
6219 // Add in style property hooks for overriding the default
6220 // behavior of getting and setting a style property
6223 get: function( elem
, computed
) {
6225 // We should always get a number back from opacity
6226 var ret
= curCSS( elem
, "opacity" );
6227 return ret
=== "" ? "1" : ret
;
6233 // Don't automatically add "px" to these possibly-unitless properties
6235 "columnCount": true,
6236 "fillOpacity": true,
6246 // Add in properties whose names you wish to fix before
6247 // setting or getting the value
6249 // normalize float css property
6253 // Get and set the style property on a DOM Node
6254 style: function( elem
, name
, value
, extra
) {
6255 // Don't set styles on text and comment nodes
6256 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6260 // Make sure that we're working with the right name
6261 var ret
, type
, hooks
,
6262 origName
= jQuery
.camelCase( name
),
6265 name
= jQuery
.cssProps
[ origName
] || ( jQuery
.cssProps
[ origName
] = vendorPropName( style
, origName
) );
6267 // gets hook for the prefixed version
6268 // followed by the unprefixed version
6269 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6271 // Check if we're setting a value
6272 if ( value
!== undefined ) {
6273 type
= typeof value
;
6275 // convert relative number strings (+= or -=) to relative numbers. #7345
6276 if ( type
=== "string" && (ret
= rrelNum
.exec( value
)) ) {
6277 value
= ( ret
[1] + 1 ) * ret
[2] + parseFloat( jQuery
.css( elem
, name
) );
6282 // Make sure that NaN and null values aren't set. See: #7116
6283 if ( value
== null || type
=== "number" && isNaN( value
) ) {
6287 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6288 if ( type
=== "number" && !jQuery
.cssNumber
[ origName
] ) {
6292 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
6293 // but it would mean to define eight (for every problematic property) identical functions
6294 if ( !jQuery
.support
.clearCloneStyle
&& value
=== "" && name
.indexOf("background") === 0 ) {
6295 style
[ name
] = "inherit";
6298 // If a hook was provided, use that value, otherwise just set the specified value
6299 if ( !hooks
|| !("set" in hooks
) || (value
= hooks
.set( elem
, value
, extra
)) !== undefined ) {
6300 style
[ name
] = value
;
6304 // If a hook was provided get the non-computed value from there
6305 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, false, extra
)) !== undefined ) {
6309 // Otherwise just get the value from the style object
6310 return style
[ name
];
6314 css: function( elem
, name
, extra
, styles
) {
6315 var val
, num
, hooks
,
6316 origName
= jQuery
.camelCase( name
);
6318 // Make sure that we're working with the right name
6319 name
= jQuery
.cssProps
[ origName
] || ( jQuery
.cssProps
[ origName
] = vendorPropName( elem
.style
, origName
) );
6321 // gets hook for the prefixed version
6322 // followed by the unprefixed version
6323 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6325 // If a hook was provided get the computed value from there
6326 if ( hooks
&& "get" in hooks
) {
6327 val
= hooks
.get( elem
, true, extra
);
6330 // Otherwise, if a way to get the computed value exists, use that
6331 if ( val
=== undefined ) {
6332 val
= curCSS( elem
, name
, styles
);
6335 //convert "normal" to computed value
6336 if ( val
=== "normal" && name
in cssNormalTransform
) {
6337 val
= cssNormalTransform
[ name
];
6340 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6341 if ( extra
=== "" || extra
) {
6342 num
= parseFloat( val
);
6343 return extra
=== true || jQuery
.isNumeric( num
) ? num
|| 0 : val
;
6349 curCSS = function( elem
, name
, _computed
) {
6350 var width
, minWidth
, maxWidth
,
6351 computed
= _computed
|| getStyles( elem
),
6354 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6355 ret
= computed
? computed
.getPropertyValue( name
) || computed
[ name
] : undefined,
6360 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
, elem
) ) {
6361 ret
= jQuery
.style( elem
, name
);
6364 // Support: Safari 5.1
6365 // A tribute to the "awesome hack by Dean Edwards"
6366 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6367 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6368 if ( rnumnonpx
.test( ret
) && rmargin
.test( name
) ) {
6370 // Remember the original values
6371 width
= style
.width
;
6372 minWidth
= style
.minWidth
;
6373 maxWidth
= style
.maxWidth
;
6375 // Put in the new values to get a computed value out
6376 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
6377 ret
= computed
.width
;
6379 // Revert the changed values
6380 style
.width
= width
;
6381 style
.minWidth
= minWidth
;
6382 style
.maxWidth
= maxWidth
;
6390 function setPositiveNumber( elem
, value
, subtract
) {
6391 var matches
= rnumsplit
.exec( value
);
6393 // Guard against undefined "subtract", e.g., when used as in cssHooks
6394 Math
.max( 0, matches
[ 1 ] - ( subtract
|| 0 ) ) + ( matches
[ 2 ] || "px" ) :
6398 function augmentWidthOrHeight( elem
, name
, extra
, isBorderBox
, styles
) {
6399 var i
= extra
=== ( isBorderBox
? "border" : "content" ) ?
6400 // If we already have the right measurement, avoid augmentation
6402 // Otherwise initialize for horizontal or vertical properties
6403 name
=== "width" ? 1 : 0,
6407 for ( ; i
< 4; i
+= 2 ) {
6408 // both box models exclude margin, so add it if we want it
6409 if ( extra
=== "margin" ) {
6410 val
+= jQuery
.css( elem
, extra
+ cssExpand
[ i
], true, styles
);
6413 if ( isBorderBox
) {
6414 // border-box includes padding, so remove it if we want content
6415 if ( extra
=== "content" ) {
6416 val
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6419 // at this point, extra isn't border nor margin, so remove border
6420 if ( extra
!== "margin" ) {
6421 val
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6424 // at this point, extra isn't content, so add padding
6425 val
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6427 // at this point, extra isn't content nor padding, so add border
6428 if ( extra
!== "padding" ) {
6429 val
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6437 function getWidthOrHeight( elem
, name
, extra
) {
6439 // Start with offset property, which is equivalent to the border-box value
6440 var valueIsBorderBox
= true,
6441 val
= name
=== "width" ? elem
.offsetWidth
: elem
.offsetHeight
,
6442 styles
= getStyles( elem
),
6443 isBorderBox
= jQuery
.support
.boxSizing
&& jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box";
6445 // some non-html elements return undefined for offsetWidth, so check for null/undefined
6446 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6447 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6448 if ( val
<= 0 || val
== null ) {
6449 // Fall back to computed then uncomputed css if necessary
6450 val
= curCSS( elem
, name
, styles
);
6451 if ( val
< 0 || val
== null ) {
6452 val
= elem
.style
[ name
];
6455 // Computed unit is not pixels. Stop here and return.
6456 if ( rnumnonpx
.test(val
) ) {
6460 // we need the check for style in case a browser which returns unreliable values
6461 // for getComputedStyle silently falls back to the reliable elem.style
6462 valueIsBorderBox
= isBorderBox
&& ( jQuery
.support
.boxSizingReliable
|| val
=== elem
.style
[ name
] );
6464 // Normalize "", auto, and prepare for extra
6465 val
= parseFloat( val
) || 0;
6468 // use the active box-sizing model to add/subtract irrelevant styles
6470 augmentWidthOrHeight(
6473 extra
|| ( isBorderBox
? "border" : "content" ),
6480 // Try to determine the default display value of an element
6481 function css_defaultDisplay( nodeName
) {
6483 display
= elemdisplay
[ nodeName
];
6486 display
= actualDisplay( nodeName
, doc
);
6488 // If the simple way fails, read from inside an iframe
6489 if ( display
=== "none" || !display
) {
6490 // Use the already-created iframe if possible
6491 iframe
= ( iframe
||
6492 jQuery("<iframe frameborder='0' width='0' height='0'/>")
6493 .css( "cssText", "display:block !important" )
6494 ).appendTo( doc
.documentElement
);
6496 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
6497 doc
= ( iframe
[0].contentWindow
|| iframe
[0].contentDocument
).document
;
6498 doc
.write("<!doctype html><html><body>");
6501 display
= actualDisplay( nodeName
, doc
);
6505 // Store the correct default display
6506 elemdisplay
[ nodeName
] = display
;
6512 // Called ONLY from within css_defaultDisplay
6513 function actualDisplay( name
, doc
) {
6514 var elem
= jQuery( doc
.createElement( name
) ).appendTo( doc
.body
),
6515 display
= jQuery
.css( elem
[0], "display" );
6520 jQuery
.each([ "height", "width" ], function( i
, name
) {
6521 jQuery
.cssHooks
[ name
] = {
6522 get: function( elem
, computed
, extra
) {
6524 // certain elements can have dimension info if we invisibly show them
6525 // however, it must have a current display style that would benefit from this
6526 return elem
.offsetWidth
=== 0 && rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) ?
6527 jQuery
.swap( elem
, cssShow
, function() {
6528 return getWidthOrHeight( elem
, name
, extra
);
6530 getWidthOrHeight( elem
, name
, extra
);
6534 set: function( elem
, value
, extra
) {
6535 var styles
= extra
&& getStyles( elem
);
6536 return setPositiveNumber( elem
, value
, extra
?
6537 augmentWidthOrHeight(
6541 jQuery
.support
.boxSizing
&& jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6549 // These hooks cannot be added until DOM ready because the support test
6550 // for it is not run until after DOM ready
6552 // Support: Android 2.3
6553 if ( !jQuery
.support
.reliableMarginRight
) {
6554 jQuery
.cssHooks
.marginRight
= {
6555 get: function( elem
, computed
) {
6557 // Support: Android 2.3
6558 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6559 // Work around by temporarily setting element display to inline-block
6560 return jQuery
.swap( elem
, { "display": "inline-block" },
6561 curCSS
, [ elem
, "marginRight" ] );
6567 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
6568 // getComputedStyle returns percent when specified for top/left/bottom/right
6569 // rather than make the css module depend on the offset module, we just check for it here
6570 if ( !jQuery
.support
.pixelPosition
&& jQuery
.fn
.position
) {
6571 jQuery
.each( [ "top", "left" ], function( i
, prop
) {
6572 jQuery
.cssHooks
[ prop
] = {
6573 get: function( elem
, computed
) {
6575 computed
= curCSS( elem
, prop
);
6576 // if curCSS returns percentage, fallback to offset
6577 return rnumnonpx
.test( computed
) ?
6578 jQuery( elem
).position()[ prop
] + "px" :
6588 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
6589 jQuery
.expr
.filters
.hidden = function( elem
) {
6590 // Support: Opera <= 12.12
6591 // Opera reports offsetWidths and offsetHeights less than zero on some elements
6592 return elem
.offsetWidth
<= 0 && elem
.offsetHeight
<= 0;
6595 jQuery
.expr
.filters
.visible = function( elem
) {
6596 return !jQuery
.expr
.filters
.hidden( elem
);
6600 // These hooks are used by animate to expand properties
6605 }, function( prefix
, suffix
) {
6606 jQuery
.cssHooks
[ prefix
+ suffix
] = {
6607 expand: function( value
) {
6611 // assumes a single number if not a string
6612 parts
= typeof value
=== "string" ? value
.split(" ") : [ value
];
6614 for ( ; i
< 4; i
++ ) {
6615 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
6616 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
6623 if ( !rmargin
.test( prefix
) ) {
6624 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
6630 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
6631 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
6634 serialize: function() {
6635 return jQuery
.param( this.serializeArray() );
6637 serializeArray: function() {
6638 return this.map(function(){
6639 // Can add propHook for "elements" to filter or add form elements
6640 var elements
= jQuery
.prop( this, "elements" );
6641 return elements
? jQuery
.makeArray( elements
) : this;
6644 var type
= this.type
;
6645 // Use .is(":disabled") so that fieldset[disabled] works
6646 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
6647 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
6648 ( this.checked
|| !manipulation_rcheckableType
.test( type
) );
6650 .map(function( i
, elem
){
6651 var val
= jQuery( this ).val();
6653 return val
== null ?
6655 jQuery
.isArray( val
) ?
6656 jQuery
.map( val
, function( val
){
6657 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
6659 { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
6664 //Serialize an array of form elements or a set of
6665 //key/values into a query string
6666 jQuery
.param = function( a
, traditional
) {
6669 add = function( key
, value
) {
6670 // If value is a function, invoke it and return its value
6671 value
= jQuery
.isFunction( value
) ? value() : ( value
== null ? "" : value
);
6672 s
[ s
.length
] = encodeURIComponent( key
) + "=" + encodeURIComponent( value
);
6675 // Set traditional to true for jQuery <= 1.3.2 behavior.
6676 if ( traditional
=== undefined ) {
6677 traditional
= jQuery
.ajaxSettings
&& jQuery
.ajaxSettings
.traditional
;
6680 // If an array was passed in, assume that it is an array of form elements.
6681 if ( jQuery
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
6682 // Serialize the form elements
6683 jQuery
.each( a
, function() {
6684 add( this.name
, this.value
);
6688 // If traditional, encode the "old" way (the way 1.3.2 or older
6689 // did it), otherwise encode params recursively.
6690 for ( prefix
in a
) {
6691 buildParams( prefix
, a
[ prefix
], traditional
, add
);
6695 // Return the resulting serialization
6696 return s
.join( "&" ).replace( r20
, "+" );
6699 function buildParams( prefix
, obj
, traditional
, add
) {
6702 if ( jQuery
.isArray( obj
) ) {
6703 // Serialize array item.
6704 jQuery
.each( obj
, function( i
, v
) {
6705 if ( traditional
|| rbracket
.test( prefix
) ) {
6706 // Treat each array item as a scalar.
6710 // Item is non-scalar (array or object), encode its numeric index.
6711 buildParams( prefix
+ "[" + ( typeof v
=== "object" ? i
: "" ) + "]", v
, traditional
, add
);
6715 } else if ( !traditional
&& jQuery
.type( obj
) === "object" ) {
6716 // Serialize object item.
6717 for ( name
in obj
) {
6718 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
6722 // Serialize scalar item.
6726 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
6727 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
6728 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i
, name
) {
6730 // Handle event binding
6731 jQuery
.fn
[ name
] = function( data
, fn
) {
6732 return arguments
.length
> 0 ?
6733 this.on( name
, null, data
, fn
) :
6734 this.trigger( name
);
6739 hover: function( fnOver
, fnOut
) {
6740 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
6743 bind: function( types
, data
, fn
) {
6744 return this.on( types
, null, data
, fn
);
6746 unbind: function( types
, fn
) {
6747 return this.off( types
, null, fn
);
6750 delegate: function( selector
, types
, data
, fn
) {
6751 return this.on( types
, selector
, data
, fn
);
6753 undelegate: function( selector
, types
, fn
) {
6754 // ( namespace ) or ( selector, types [, fn] )
6755 return arguments
.length
=== 1 ? this.off( selector
, "**" ) : this.off( types
, selector
|| "**", fn
);
6759 // Document location
6763 ajax_nonce
= jQuery
.now(),
6767 rts
= /([?&])_=[^&]*/,
6768 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg,
6769 // #7653, #8125, #8152: local protocol detection
6770 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
6771 rnoContent
= /^(?:GET|HEAD)$/,
6772 rprotocol
= /^\/\//,
6773 rurl
= /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
6775 // Keep a copy of the old load method
6776 _load
= jQuery
.fn
.load
,
6779 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6780 * 2) These are called:
6781 * - BEFORE asking for a transport
6782 * - AFTER param serialization (s.data is a string if s.processData is true)
6783 * 3) key is the dataType
6784 * 4) the catchall symbol "*" can be used
6785 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6789 /* Transports bindings
6790 * 1) key is the dataType
6791 * 2) the catchall symbol "*" can be used
6792 * 3) selection will start with transport dataType and THEN go to "*" if needed
6796 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6797 allTypes
= "*/".concat("*");
6799 // #8138, IE may throw an exception when accessing
6800 // a field from window.location if document.domain has been set
6802 ajaxLocation
= location
.href
;
6804 // Use the href attribute of an A element
6805 // since IE will modify it given document.location
6806 ajaxLocation
= document
.createElement( "a" );
6807 ajaxLocation
.href
= "";
6808 ajaxLocation
= ajaxLocation
.href
;
6811 // Segment location into parts
6812 ajaxLocParts
= rurl
.exec( ajaxLocation
.toLowerCase() ) || [];
6814 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6815 function addToPrefiltersOrTransports( structure
) {
6817 // dataTypeExpression is optional and defaults to "*"
6818 return function( dataTypeExpression
, func
) {
6820 if ( typeof dataTypeExpression
!== "string" ) {
6821 func
= dataTypeExpression
;
6822 dataTypeExpression
= "*";
6827 dataTypes
= dataTypeExpression
.toLowerCase().match( core_rnotwhite
) || [];
6829 if ( jQuery
.isFunction( func
) ) {
6830 // For each dataType in the dataTypeExpression
6831 while ( (dataType
= dataTypes
[i
++]) ) {
6832 // Prepend if requested
6833 if ( dataType
[0] === "+" ) {
6834 dataType
= dataType
.slice( 1 ) || "*";
6835 (structure
[ dataType
] = structure
[ dataType
] || []).unshift( func
);
6839 (structure
[ dataType
] = structure
[ dataType
] || []).push( func
);
6846 // Base inspection function for prefilters and transports
6847 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
6850 seekingTransport
= ( structure
=== transports
);
6852 function inspect( dataType
) {
6854 inspected
[ dataType
] = true;
6855 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
6856 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
6857 if( typeof dataTypeOrTransport
=== "string" && !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
6858 options
.dataTypes
.unshift( dataTypeOrTransport
);
6859 inspect( dataTypeOrTransport
);
6861 } else if ( seekingTransport
) {
6862 return !( selected
= dataTypeOrTransport
);
6868 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
6871 // A special extend for ajax options
6872 // that takes "flat" options (not to be deep extended)
6874 function ajaxExtend( target
, src
) {
6876 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
6878 for ( key
in src
) {
6879 if ( src
[ key
] !== undefined ) {
6880 ( flatOptions
[ key
] ? target
: ( deep
|| (deep
= {}) ) )[ key
] = src
[ key
];
6884 jQuery
.extend( true, target
, deep
);
6890 jQuery
.fn
.load = function( url
, params
, callback
) {
6891 if ( typeof url
!== "string" && _load
) {
6892 return _load
.apply( this, arguments
);
6895 var selector
, type
, response
,
6897 off
= url
.indexOf(" ");
6900 selector
= url
.slice( off
);
6901 url
= url
.slice( 0, off
);
6904 // If it's a function
6905 if ( jQuery
.isFunction( params
) ) {
6907 // We assume that it's the callback
6911 // Otherwise, build a param string
6912 } else if ( params
&& typeof params
=== "object" ) {
6916 // If we have elements to modify, make the request
6917 if ( self
.length
> 0 ) {
6921 // if "type" variable is undefined, then "GET" method will be used
6925 }).done(function( responseText
) {
6927 // Save response for use in complete callback
6928 response
= arguments
;
6930 self
.html( selector
?
6932 // If a selector was specified, locate the right elements in a dummy div
6933 // Exclude scripts to avoid IE 'Permission Denied' errors
6934 jQuery("<div>").append( jQuery
.parseHTML( responseText
) ).find( selector
) :
6936 // Otherwise use the full result
6939 }).complete( callback
&& function( jqXHR
, status
) {
6940 self
.each( callback
, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
6947 // Attach a bunch of functions for handling common AJAX events
6948 jQuery
.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i
, type
){
6949 jQuery
.fn
[ type
] = function( fn
){
6950 return this.on( type
, fn
);
6956 // Counter for holding the number of active queries
6959 // Last-Modified header cache for next request
6966 isLocal
: rlocalProtocol
.test( ajaxLocParts
[ 1 ] ),
6970 contentType
: "application/x-www-form-urlencoded; charset=UTF-8",
6987 xml
: "application/xml, text/xml",
6988 json
: "application/json, text/javascript"
6999 text
: "responseText",
7000 json
: "responseJSON"
7004 // Keys separate source (or catchall "*") and destination types with a single space
7007 // Convert anything to text
7010 // Text to html (true = no transformation)
7013 // Evaluate text as a json expression
7014 "text json": jQuery
.parseJSON
,
7016 // Parse text as xml
7017 "text xml": jQuery
.parseXML
7020 // For options that shouldn't be deep extended:
7021 // you can add your own custom options here if
7022 // and when you create one that shouldn't be
7023 // deep extended (see ajaxExtend)
7030 // Creates a full fledged settings object into target
7031 // with both ajaxSettings and settings fields.
7032 // If target is omitted, writes into ajaxSettings.
7033 ajaxSetup: function( target
, settings
) {
7036 // Building a settings object
7037 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
7039 // Extending ajaxSettings
7040 ajaxExtend( jQuery
.ajaxSettings
, target
);
7043 ajaxPrefilter
: addToPrefiltersOrTransports( prefilters
),
7044 ajaxTransport
: addToPrefiltersOrTransports( transports
),
7047 ajax: function( url
, options
) {
7049 // If url is an object, simulate pre-1.5 signature
7050 if ( typeof url
=== "object" ) {
7055 // Force options to be an object
7056 options
= options
|| {};
7059 // URL without anti-cache param
7062 responseHeadersString
,
7066 // Cross-domain detection vars
7068 // To know if global events are to be dispatched
7072 // Create the final options object
7073 s
= jQuery
.ajaxSetup( {}, options
),
7074 // Callbacks context
7075 callbackContext
= s
.context
|| s
,
7076 // Context for global events is callbackContext if it is a DOM node or jQuery collection
7077 globalEventContext
= s
.context
&& ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
7078 jQuery( callbackContext
) :
7081 deferred
= jQuery
.Deferred(),
7082 completeDeferred
= jQuery
.Callbacks("once memory"),
7083 // Status-dependent callbacks
7084 statusCode
= s
.statusCode
|| {},
7085 // Headers (they are sent all at once)
7086 requestHeaders
= {},
7087 requestHeadersNames
= {},
7090 // Default abort message
7091 strAbort
= "canceled",
7096 // Builds headers hashtable if needed
7097 getResponseHeader: function( key
) {
7099 if ( state
=== 2 ) {
7100 if ( !responseHeaders
) {
7101 responseHeaders
= {};
7102 while ( (match
= rheaders
.exec( responseHeadersString
)) ) {
7103 responseHeaders
[ match
[1].toLowerCase() ] = match
[ 2 ];
7106 match
= responseHeaders
[ key
.toLowerCase() ];
7108 return match
== null ? null : match
;
7112 getAllResponseHeaders: function() {
7113 return state
=== 2 ? responseHeadersString
: null;
7116 // Caches the header
7117 setRequestHeader: function( name
, value
) {
7118 var lname
= name
.toLowerCase();
7120 name
= requestHeadersNames
[ lname
] = requestHeadersNames
[ lname
] || name
;
7121 requestHeaders
[ name
] = value
;
7126 // Overrides response content-type header
7127 overrideMimeType: function( type
) {
7134 // Status-dependent callbacks
7135 statusCode: function( map
) {
7139 for ( code
in map
) {
7140 // Lazy-add the new callback in a way that preserves old ones
7141 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
7144 // Execute the appropriate callbacks
7145 jqXHR
.always( map
[ jqXHR
.status
] );
7151 // Cancel the request
7152 abort: function( statusText
) {
7153 var finalText
= statusText
|| strAbort
;
7155 transport
.abort( finalText
);
7157 done( 0, finalText
);
7163 deferred
.promise( jqXHR
).complete
= completeDeferred
.add
;
7164 jqXHR
.success
= jqXHR
.done
;
7165 jqXHR
.error
= jqXHR
.fail
;
7167 // Remove hash character (#7531: and string promotion)
7168 // Add protocol if not provided (prefilters might expect it)
7169 // Handle falsy url in the settings object (#10093: consistency with old signature)
7170 // We also use the url parameter if available
7171 s
.url
= ( ( url
|| s
.url
|| ajaxLocation
) + "" ).replace( rhash
, "" )
7172 .replace( rprotocol
, ajaxLocParts
[ 1 ] + "//" );
7174 // Alias method option to type as per ticket #12004
7175 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
7177 // Extract dataTypes list
7178 s
.dataTypes
= jQuery
.trim( s
.dataType
|| "*" ).toLowerCase().match( core_rnotwhite
) || [""];
7180 // A cross-domain request is in order when we have a protocol:host:port mismatch
7181 if ( s
.crossDomain
== null ) {
7182 parts
= rurl
.exec( s
.url
.toLowerCase() );
7183 s
.crossDomain
= !!( parts
&&
7184 ( parts
[ 1 ] !== ajaxLocParts
[ 1 ] || parts
[ 2 ] !== ajaxLocParts
[ 2 ] ||
7185 ( parts
[ 3 ] || ( parts
[ 1 ] === "http:" ? "80" : "443" ) ) !==
7186 ( ajaxLocParts
[ 3 ] || ( ajaxLocParts
[ 1 ] === "http:" ? "80" : "443" ) ) )
7190 // Convert data if not already a string
7191 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
7192 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
7196 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
7198 // If request was aborted inside a prefilter, stop there
7199 if ( state
=== 2 ) {
7203 // We can fire global events as of now if asked to
7204 fireGlobals
= s
.global
;
7206 // Watch for a new set of requests
7207 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
7208 jQuery
.event
.trigger("ajaxStart");
7211 // Uppercase the type
7212 s
.type
= s
.type
.toUpperCase();
7214 // Determine if request has content
7215 s
.hasContent
= !rnoContent
.test( s
.type
);
7217 // Save the URL in case we're toying with the If-Modified-Since
7218 // and/or If-None-Match header later on
7221 // More options handling for requests with no content
7222 if ( !s
.hasContent
) {
7224 // If data is available, append data to url
7226 cacheURL
= ( s
.url
+= ( ajax_rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
);
7227 // #9682: remove data so that it's not used in an eventual retry
7231 // Add anti-cache in url if needed
7232 if ( s
.cache
=== false ) {
7233 s
.url
= rts
.test( cacheURL
) ?
7235 // If there is already a '_' parameter, set its value
7236 cacheURL
.replace( rts
, "$1_=" + ajax_nonce
++ ) :
7238 // Otherwise add one to the end
7239 cacheURL
+ ( ajax_rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + ajax_nonce
++;
7243 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7244 if ( s
.ifModified
) {
7245 if ( jQuery
.lastModified
[ cacheURL
] ) {
7246 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
7248 if ( jQuery
.etag
[ cacheURL
] ) {
7249 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
7253 // Set the correct header, if data is being sent
7254 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
7255 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
7258 // Set the Accepts header for the server, depending on the dataType
7259 jqXHR
.setRequestHeader(
7261 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[0] ] ?
7262 s
.accepts
[ s
.dataTypes
[0] ] + ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
7266 // Check for headers option
7267 for ( i
in s
.headers
) {
7268 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
7271 // Allow custom headers/mimetypes and early abort
7272 if ( s
.beforeSend
&& ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || state
=== 2 ) ) {
7273 // Abort if not done already and return
7274 return jqXHR
.abort();
7277 // aborting is no longer a cancellation
7280 // Install callbacks on deferreds
7281 for ( i
in { success
: 1, error
: 1, complete
: 1 } ) {
7282 jqXHR
[ i
]( s
[ i
] );
7286 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
7288 // If no transport, we auto-abort
7290 done( -1, "No Transport" );
7292 jqXHR
.readyState
= 1;
7294 // Send global event
7295 if ( fireGlobals
) {
7296 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
7299 if ( s
.async
&& s
.timeout
> 0 ) {
7300 timeoutTimer
= setTimeout(function() {
7301 jqXHR
.abort("timeout");
7307 transport
.send( requestHeaders
, done
);
7309 // Propagate exception as error if not done
7312 // Simply rethrow otherwise
7319 // Callback for when everything is done
7320 function done( status
, nativeStatusText
, responses
, headers
) {
7321 var isSuccess
, success
, error
, response
, modified
,
7322 statusText
= nativeStatusText
;
7325 if ( state
=== 2 ) {
7329 // State is "done" now
7332 // Clear timeout if it exists
7333 if ( timeoutTimer
) {
7334 clearTimeout( timeoutTimer
);
7337 // Dereference transport for early garbage collection
7338 // (no matter how long the jqXHR object will be used)
7339 transport
= undefined;
7341 // Cache response headers
7342 responseHeadersString
= headers
|| "";
7345 jqXHR
.readyState
= status
> 0 ? 4 : 0;
7347 // Determine if successful
7348 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
7350 // Get response data
7352 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
7355 // Convert no matter what (that way responseXXX fields are always set)
7356 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
7358 // If successful, handle type chaining
7361 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7362 if ( s
.ifModified
) {
7363 modified
= jqXHR
.getResponseHeader("Last-Modified");
7365 jQuery
.lastModified
[ cacheURL
] = modified
;
7367 modified
= jqXHR
.getResponseHeader("etag");
7369 jQuery
.etag
[ cacheURL
] = modified
;
7374 if ( status
=== 204 || s
.type
=== "HEAD" ) {
7375 statusText
= "nocontent";
7378 } else if ( status
=== 304 ) {
7379 statusText
= "notmodified";
7381 // If we have data, let's convert it
7383 statusText
= response
.state
;
7384 success
= response
.data
;
7385 error
= response
.error
;
7389 // We extract error from statusText
7390 // then normalize statusText and status for non-aborts
7392 if ( status
|| !statusText
) {
7393 statusText
= "error";
7400 // Set data for the fake xhr object
7401 jqXHR
.status
= status
;
7402 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
7406 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
7408 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
7411 // Status-dependent callbacks
7412 jqXHR
.statusCode( statusCode
);
7413 statusCode
= undefined;
7415 if ( fireGlobals
) {
7416 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
7417 [ jqXHR
, s
, isSuccess
? success
: error
] );
7421 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
7423 if ( fireGlobals
) {
7424 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
7425 // Handle the global AJAX counter
7426 if ( !( --jQuery
.active
) ) {
7427 jQuery
.event
.trigger("ajaxStop");
7435 getJSON: function( url
, data
, callback
) {
7436 return jQuery
.get( url
, data
, callback
, "json" );
7439 getScript: function( url
, callback
) {
7440 return jQuery
.get( url
, undefined, callback
, "script" );
7444 jQuery
.each( [ "get", "post" ], function( i
, method
) {
7445 jQuery
[ method
] = function( url
, data
, callback
, type
) {
7446 // shift arguments if data argument was omitted
7447 if ( jQuery
.isFunction( data
) ) {
7448 type
= type
|| callback
;
7453 return jQuery
.ajax({
7463 /* Handles responses to an ajax request:
7464 * - finds the right dataType (mediates between content-type and expected dataType)
7465 * - returns the corresponding response
7467 function ajaxHandleResponses( s
, jqXHR
, responses
) {
7469 var ct
, type
, finalDataType
, firstDataType
,
7470 contents
= s
.contents
,
7471 dataTypes
= s
.dataTypes
;
7473 // Remove auto dataType and get content-type in the process
7474 while( dataTypes
[ 0 ] === "*" ) {
7476 if ( ct
=== undefined ) {
7477 ct
= s
.mimeType
|| jqXHR
.getResponseHeader("Content-Type");
7481 // Check if we're dealing with a known content-type
7483 for ( type
in contents
) {
7484 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
7485 dataTypes
.unshift( type
);
7491 // Check to see if we have a response for the expected dataType
7492 if ( dataTypes
[ 0 ] in responses
) {
7493 finalDataType
= dataTypes
[ 0 ];
7495 // Try convertible dataTypes
7496 for ( type
in responses
) {
7497 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[0] ] ) {
7498 finalDataType
= type
;
7501 if ( !firstDataType
) {
7502 firstDataType
= type
;
7505 // Or just use first one
7506 finalDataType
= finalDataType
|| firstDataType
;
7509 // If we found a dataType
7510 // We add the dataType to the list if needed
7511 // and return the corresponding response
7512 if ( finalDataType
) {
7513 if ( finalDataType
!== dataTypes
[ 0 ] ) {
7514 dataTypes
.unshift( finalDataType
);
7516 return responses
[ finalDataType
];
7520 /* Chain conversions given the request and the original response
7521 * Also sets the responseXXX fields on the jqXHR instance
7523 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
7524 var conv2
, current
, conv
, tmp
, prev
,
7526 // Work with a copy of dataTypes in case we need to modify it for conversion
7527 dataTypes
= s
.dataTypes
.slice();
7529 // Create converters map with lowercased keys
7530 if ( dataTypes
[ 1 ] ) {
7531 for ( conv
in s
.converters
) {
7532 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
7536 current
= dataTypes
.shift();
7538 // Convert to each sequential dataType
7541 if ( s
.responseFields
[ current
] ) {
7542 jqXHR
[ s
.responseFields
[ current
] ] = response
;
7545 // Apply the dataFilter if provided
7546 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
7547 response
= s
.dataFilter( response
, s
.dataType
);
7551 current
= dataTypes
.shift();
7555 // There's only work to do if current dataType is non-auto
7556 if ( current
=== "*" ) {
7560 // Convert response if prev dataType is non-auto and differs from current
7561 } else if ( prev
!== "*" && prev
!== current
) {
7563 // Seek a direct converter
7564 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
7566 // If none found, seek a pair
7568 for ( conv2
in converters
) {
7570 // If conv2 outputs current
7571 tmp
= conv2
.split( " " );
7572 if ( tmp
[ 1 ] === current
) {
7574 // If prev can be converted to accepted input
7575 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
7576 converters
[ "* " + tmp
[ 0 ] ];
7578 // Condense equivalence converters
7579 if ( conv
=== true ) {
7580 conv
= converters
[ conv2
];
7582 // Otherwise, insert the intermediate dataType
7583 } else if ( converters
[ conv2
] !== true ) {
7585 dataTypes
.unshift( tmp
[ 1 ] );
7593 // Apply converter (if not an equivalence)
7594 if ( conv
!== true ) {
7596 // Unless errors are allowed to bubble, catch and return them
7597 if ( conv
&& s
[ "throws" ] ) {
7598 response
= conv( response
);
7601 response
= conv( response
);
7603 return { state
: "parsererror", error
: conv
? e
: "No conversion from " + prev
+ " to " + current
};
7611 return { state
: "success", data
: response
};
7613 // Install script dataType
7616 script
: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7619 script
: /(?:java|ecma)script/
7622 "text script": function( text
) {
7623 jQuery
.globalEval( text
);
7629 // Handle cache's special case and crossDomain
7630 jQuery
.ajaxPrefilter( "script", function( s
) {
7631 if ( s
.cache
=== undefined ) {
7634 if ( s
.crossDomain
) {
7639 // Bind script tag hack transport
7640 jQuery
.ajaxTransport( "script", function( s
) {
7641 // This transport only deals with cross domain requests
7642 if ( s
.crossDomain
) {
7643 var script
, callback
;
7645 send: function( _
, complete
) {
7646 script
= jQuery("<script>").prop({
7648 charset
: s
.scriptCharset
,
7652 callback = function( evt
) {
7656 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
7660 document
.head
.appendChild( script
[ 0 ] );
7670 var oldCallbacks
= [],
7671 rjsonp
= /(=)\?(?=&|$)|\?\?/;
7673 // Default jsonp settings
7676 jsonpCallback: function() {
7677 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( ajax_nonce
++ ) );
7678 this[ callback
] = true;
7683 // Detect, normalize options and install callbacks for jsonp requests
7684 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
7686 var callbackName
, overwritten
, responseContainer
,
7687 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
7689 typeof s
.data
=== "string" && !( s
.contentType
|| "" ).indexOf("application/x-www-form-urlencoded") && rjsonp
.test( s
.data
) && "data"
7692 // Handle iff the expected data type is "jsonp" or we have a parameter to set
7693 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
7695 // Get callback name, remembering preexisting value associated with it
7696 callbackName
= s
.jsonpCallback
= jQuery
.isFunction( s
.jsonpCallback
) ?
7700 // Insert callback into url or form data
7702 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
7703 } else if ( s
.jsonp
!== false ) {
7704 s
.url
+= ( ajax_rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
7707 // Use data converter to retrieve json after script execution
7708 s
.converters
["script json"] = function() {
7709 if ( !responseContainer
) {
7710 jQuery
.error( callbackName
+ " was not called" );
7712 return responseContainer
[ 0 ];
7715 // force json dataType
7716 s
.dataTypes
[ 0 ] = "json";
7719 overwritten
= window
[ callbackName
];
7720 window
[ callbackName
] = function() {
7721 responseContainer
= arguments
;
7724 // Clean-up function (fires after converters)
7725 jqXHR
.always(function() {
7726 // Restore preexisting value
7727 window
[ callbackName
] = overwritten
;
7729 // Save back as free
7730 if ( s
[ callbackName
] ) {
7731 // make sure that re-using the options doesn't screw things around
7732 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
7734 // save the callback name for future use
7735 oldCallbacks
.push( callbackName
);
7738 // Call if it was a function and we have a response
7739 if ( responseContainer
&& jQuery
.isFunction( overwritten
) ) {
7740 overwritten( responseContainer
[ 0 ] );
7743 responseContainer
= overwritten
= undefined;
7746 // Delegate to script
7750 jQuery
.ajaxSettings
.xhr = function() {
7752 return new XMLHttpRequest();
7756 var xhrSupported
= jQuery
.ajaxSettings
.xhr(),
7757 xhrSuccessStatus
= {
7758 // file protocol always yields status code 0, assume 200
7761 // #1450: sometimes IE returns 1223 when it should be 204
7765 // We need to keep track of outbound xhr and abort them manually
7766 // because IE is not smart enough to do it all by itself
7770 if ( window
.ActiveXObject
) {
7771 jQuery( window
).on( "unload", function() {
7772 for( var key
in xhrCallbacks
) {
7773 xhrCallbacks
[ key
]();
7775 xhrCallbacks
= undefined;
7779 jQuery
.support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
7780 jQuery
.support
.ajax
= xhrSupported
= !!xhrSupported
;
7782 jQuery
.ajaxTransport(function( options
) {
7784 // Cross domain only allowed if supported through XMLHttpRequest
7785 if ( jQuery
.support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
7787 send: function( headers
, complete
) {
7789 xhr
= options
.xhr();
7790 xhr
.open( options
.type
, options
.url
, options
.async
, options
.username
, options
.password
);
7791 // Apply custom fields if provided
7792 if ( options
.xhrFields
) {
7793 for ( i
in options
.xhrFields
) {
7794 xhr
[ i
] = options
.xhrFields
[ i
];
7797 // Override mime type if needed
7798 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
7799 xhr
.overrideMimeType( options
.mimeType
);
7801 // X-Requested-With header
7802 // For cross-domain requests, seeing as conditions for a preflight are
7803 // akin to a jigsaw puzzle, we simply never set it to be sure.
7804 // (it can always be set on a per-request basis or even using ajaxSetup)
7805 // For same-domain requests, won't change header if already provided.
7806 if ( !options
.crossDomain
&& !headers
["X-Requested-With"] ) {
7807 headers
["X-Requested-With"] = "XMLHttpRequest";
7810 for ( i
in headers
) {
7811 xhr
.setRequestHeader( i
, headers
[ i
] );
7814 callback = function( type
) {
7817 delete xhrCallbacks
[ id
];
7818 callback
= xhr
.onload
= xhr
.onerror
= null;
7819 if ( type
=== "abort" ) {
7821 } else if ( type
=== "error" ) {
7823 // file protocol always yields status 0, assume 404
7829 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
7832 // #11426: When requesting binary data, IE9 will throw an exception
7833 // on any attempt to access responseText
7834 typeof xhr
.responseText
=== "string" ? {
7835 text
: xhr
.responseText
7837 xhr
.getAllResponseHeaders()
7844 xhr
.onload
= callback();
7845 xhr
.onerror
= callback("error");
7846 // Create the abort callback
7847 callback
= xhrCallbacks
[( id
= xhrId
++ )] = callback("abort");
7848 // Do send the request
7849 // This may raise an exception which is actually
7850 // handled in jQuery.ajax (so no try/catch here)
7851 xhr
.send( options
.hasContent
&& options
.data
|| null );
7862 rfxtypes
= /^(?:toggle|show|hide)$/,
7863 rfxnum
= new RegExp( "^(?:([+-])=|)(" + core_pnum
+ ")([a-z%]*)$", "i" ),
7864 rrun
= /queueHooks$/,
7865 animationPrefilters
= [ defaultPrefilter
],
7867 "*": [function( prop
, value
) {
7868 var tween
= this.createTween( prop
, value
),
7869 target
= tween
.cur(),
7870 parts
= rfxnum
.exec( value
),
7871 unit
= parts
&& parts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
7873 // Starting value computation is required for potential unit mismatches
7874 start
= ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +target
) &&
7875 rfxnum
.exec( jQuery
.css( tween
.elem
, prop
) ),
7879 if ( start
&& start
[ 3 ] !== unit
) {
7880 // Trust units reported by jQuery.css
7881 unit
= unit
|| start
[ 3 ];
7883 // Make sure we update the tween properties later on
7884 parts
= parts
|| [];
7886 // Iteratively approximate from a nonzero starting point
7887 start
= +target
|| 1;
7890 // If previous iteration zeroed out, double until we get *something*
7891 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
7892 scale
= scale
|| ".5";
7895 start
= start
/ scale
;
7896 jQuery
.style( tween
.elem
, prop
, start
+ unit
);
7898 // Update scale, tolerating zero or NaN from tween.cur()
7899 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
7900 } while ( scale
!== (scale
= tween
.cur() / target
) && scale
!== 1 && --maxIterations
);
7903 // Update tween properties
7906 tween
.start
= +start
|| +target
|| 0;
7907 // If a +=/-= token was provided, we're doing a relative animation
7908 tween
.end
= parts
[ 1 ] ?
7909 start
+ ( parts
[ 1 ] + 1 ) * parts
[ 2 ] :
7917 // Animations created synchronously will run synchronously
7918 function createFxNow() {
7919 setTimeout(function() {
7922 return ( fxNow
= jQuery
.now() );
7925 function createTween( value
, prop
, animation
) {
7927 collection
= ( tweeners
[ prop
] || [] ).concat( tweeners
[ "*" ] ),
7929 length
= collection
.length
;
7930 for ( ; index
< length
; index
++ ) {
7931 if ( (tween
= collection
[ index
].call( animation
, prop
, value
)) ) {
7933 // we're done with this property
7939 function Animation( elem
, properties
, options
) {
7943 length
= animationPrefilters
.length
,
7944 deferred
= jQuery
.Deferred().always( function() {
7945 // don't match elem in the :animated selector
7952 var currentTime
= fxNow
|| createFxNow(),
7953 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
7954 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
7955 temp
= remaining
/ animation
.duration
|| 0,
7958 length
= animation
.tweens
.length
;
7960 for ( ; index
< length
; index
++ ) {
7961 animation
.tweens
[ index
].run( percent
);
7964 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
]);
7966 if ( percent
< 1 && length
) {
7969 deferred
.resolveWith( elem
, [ animation
] );
7973 animation
= deferred
.promise({
7975 props
: jQuery
.extend( {}, properties
),
7976 opts
: jQuery
.extend( true, { specialEasing
: {} }, options
),
7977 originalProperties
: properties
,
7978 originalOptions
: options
,
7979 startTime
: fxNow
|| createFxNow(),
7980 duration
: options
.duration
,
7982 createTween: function( prop
, end
) {
7983 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
7984 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
7985 animation
.tweens
.push( tween
);
7988 stop: function( gotoEnd
) {
7990 // if we are going to the end, we want to run all the tweens
7991 // otherwise we skip this part
7992 length
= gotoEnd
? animation
.tweens
.length
: 0;
7997 for ( ; index
< length
; index
++ ) {
7998 animation
.tweens
[ index
].run( 1 );
8001 // resolve when we played the last frame
8002 // otherwise, reject
8004 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
8006 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
8011 props
= animation
.props
;
8013 propFilter( props
, animation
.opts
.specialEasing
);
8015 for ( ; index
< length
; index
++ ) {
8016 result
= animationPrefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
8022 jQuery
.map( props
, createTween
, animation
);
8024 if ( jQuery
.isFunction( animation
.opts
.start
) ) {
8025 animation
.opts
.start
.call( elem
, animation
);
8029 jQuery
.extend( tick
, {
8032 queue
: animation
.opts
.queue
8036 // attach callbacks from options
8037 return animation
.progress( animation
.opts
.progress
)
8038 .done( animation
.opts
.done
, animation
.opts
.complete
)
8039 .fail( animation
.opts
.fail
)
8040 .always( animation
.opts
.always
);
8043 function propFilter( props
, specialEasing
) {
8044 var index
, name
, easing
, value
, hooks
;
8046 // camelCase, specialEasing and expand cssHook pass
8047 for ( index
in props
) {
8048 name
= jQuery
.camelCase( index
);
8049 easing
= specialEasing
[ name
];
8050 value
= props
[ index
];
8051 if ( jQuery
.isArray( value
) ) {
8052 easing
= value
[ 1 ];
8053 value
= props
[ index
] = value
[ 0 ];
8056 if ( index
!== name
) {
8057 props
[ name
] = value
;
8058 delete props
[ index
];
8061 hooks
= jQuery
.cssHooks
[ name
];
8062 if ( hooks
&& "expand" in hooks
) {
8063 value
= hooks
.expand( value
);
8064 delete props
[ name
];
8066 // not quite $.extend, this wont overwrite keys already present.
8067 // also - reusing 'index' from above because we have the correct "name"
8068 for ( index
in value
) {
8069 if ( !( index
in props
) ) {
8070 props
[ index
] = value
[ index
];
8071 specialEasing
[ index
] = easing
;
8075 specialEasing
[ name
] = easing
;
8080 jQuery
.Animation
= jQuery
.extend( Animation
, {
8082 tweener: function( props
, callback
) {
8083 if ( jQuery
.isFunction( props
) ) {
8087 props
= props
.split(" ");
8092 length
= props
.length
;
8094 for ( ; index
< length
; index
++ ) {
8095 prop
= props
[ index
];
8096 tweeners
[ prop
] = tweeners
[ prop
] || [];
8097 tweeners
[ prop
].unshift( callback
);
8101 prefilter: function( callback
, prepend
) {
8103 animationPrefilters
.unshift( callback
);
8105 animationPrefilters
.push( callback
);
8110 function defaultPrefilter( elem
, props
, opts
) {
8111 /* jshint validthis: true */
8112 var prop
, value
, toggle
, tween
, hooks
, oldfire
,
8116 hidden
= elem
.nodeType
&& isHidden( elem
),
8117 dataShow
= data_priv
.get( elem
, "fxshow" );
8119 // handle queue: false promises
8120 if ( !opts
.queue
) {
8121 hooks
= jQuery
._queueHooks( elem
, "fx" );
8122 if ( hooks
.unqueued
== null ) {
8124 oldfire
= hooks
.empty
.fire
;
8125 hooks
.empty
.fire = function() {
8126 if ( !hooks
.unqueued
) {
8133 anim
.always(function() {
8134 // doing this makes sure that the complete handler will be called
8135 // before this completes
8136 anim
.always(function() {
8138 if ( !jQuery
.queue( elem
, "fx" ).length
) {
8145 // height/width overflow pass
8146 if ( elem
.nodeType
=== 1 && ( "height" in props
|| "width" in props
) ) {
8147 // Make sure that nothing sneaks out
8148 // Record all 3 overflow attributes because IE9-10 do not
8149 // change the overflow attribute when overflowX and
8150 // overflowY are set to the same value
8151 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
8153 // Set display property to inline-block for height/width
8154 // animations on inline elements that are having width/height animated
8155 if ( jQuery
.css( elem
, "display" ) === "inline" &&
8156 jQuery
.css( elem
, "float" ) === "none" ) {
8158 style
.display
= "inline-block";
8162 if ( opts
.overflow
) {
8163 style
.overflow
= "hidden";
8164 anim
.always(function() {
8165 style
.overflow
= opts
.overflow
[ 0 ];
8166 style
.overflowX
= opts
.overflow
[ 1 ];
8167 style
.overflowY
= opts
.overflow
[ 2 ];
8173 for ( prop
in props
) {
8174 value
= props
[ prop
];
8175 if ( rfxtypes
.exec( value
) ) {
8176 delete props
[ prop
];
8177 toggle
= toggle
|| value
=== "toggle";
8178 if ( value
=== ( hidden
? "hide" : "show" ) ) {
8180 // 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
8181 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
8187 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
8191 if ( !jQuery
.isEmptyObject( orig
) ) {
8193 if ( "hidden" in dataShow
) {
8194 hidden
= dataShow
.hidden
;
8197 dataShow
= data_priv
.access( elem
, "fxshow", {} );
8200 // store state if its toggle - enables .stop().toggle() to "reverse"
8202 dataShow
.hidden
= !hidden
;
8205 jQuery( elem
).show();
8207 anim
.done(function() {
8208 jQuery( elem
).hide();
8211 anim
.done(function() {
8214 data_priv
.remove( elem
, "fxshow" );
8215 for ( prop
in orig
) {
8216 jQuery
.style( elem
, prop
, orig
[ prop
] );
8219 for ( prop
in orig
) {
8220 tween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
8222 if ( !( prop
in dataShow
) ) {
8223 dataShow
[ prop
] = tween
.start
;
8225 tween
.end
= tween
.start
;
8226 tween
.start
= prop
=== "width" || prop
=== "height" ? 1 : 0;
8233 function Tween( elem
, options
, prop
, end
, easing
) {
8234 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
8236 jQuery
.Tween
= Tween
;
8240 init: function( elem
, options
, prop
, end
, easing
, unit
) {
8243 this.easing
= easing
|| "swing";
8244 this.options
= options
;
8245 this.start
= this.now
= this.cur();
8247 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
8250 var hooks
= Tween
.propHooks
[ this.prop
];
8252 return hooks
&& hooks
.get ?
8254 Tween
.propHooks
._default
.get( this );
8256 run: function( percent
) {
8258 hooks
= Tween
.propHooks
[ this.prop
];
8260 if ( this.options
.duration
) {
8261 this.pos
= eased
= jQuery
.easing
[ this.easing
](
8262 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
8265 this.pos
= eased
= percent
;
8267 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
8269 if ( this.options
.step
) {
8270 this.options
.step
.call( this.elem
, this.now
, this );
8273 if ( hooks
&& hooks
.set ) {
8276 Tween
.propHooks
._default
.set( this );
8282 Tween
.prototype.init
.prototype = Tween
.prototype;
8286 get: function( tween
) {
8289 if ( tween
.elem
[ tween
.prop
] != null &&
8290 (!tween
.elem
.style
|| tween
.elem
.style
[ tween
.prop
] == null) ) {
8291 return tween
.elem
[ tween
.prop
];
8294 // passing an empty string as a 3rd parameter to .css will automatically
8295 // attempt a parseFloat and fallback to a string if the parse fails
8296 // so, simple values such as "10px" are parsed to Float.
8297 // complex values such as "rotate(1rad)" are returned as is.
8298 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
8299 // Empty strings, null, undefined and "auto" are converted to 0.
8300 return !result
|| result
=== "auto" ? 0 : result
;
8302 set: function( tween
) {
8303 // use step hook for back compat - use cssHook if its there - use .style if its
8304 // available and use plain properties where available
8305 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
8306 jQuery
.fx
.step
[ tween
.prop
]( tween
);
8307 } else if ( tween
.elem
.style
&& ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null || jQuery
.cssHooks
[ tween
.prop
] ) ) {
8308 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
8310 tween
.elem
[ tween
.prop
] = tween
.now
;
8317 // Panic based approach to setting things on disconnected nodes
8319 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
8320 set: function( tween
) {
8321 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
8322 tween
.elem
[ tween
.prop
] = tween
.now
;
8327 jQuery
.each([ "toggle", "show", "hide" ], function( i
, name
) {
8328 var cssFn
= jQuery
.fn
[ name
];
8329 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
8330 return speed
== null || typeof speed
=== "boolean" ?
8331 cssFn
.apply( this, arguments
) :
8332 this.animate( genFx( name
, true ), speed
, easing
, callback
);
8337 fadeTo: function( speed
, to
, easing
, callback
) {
8339 // show any hidden elements after setting opacity to 0
8340 return this.filter( isHidden
).css( "opacity", 0 ).show()
8342 // animate to the value specified
8343 .end().animate({ opacity
: to
}, speed
, easing
, callback
);
8345 animate: function( prop
, speed
, easing
, callback
) {
8346 var empty
= jQuery
.isEmptyObject( prop
),
8347 optall
= jQuery
.speed( speed
, easing
, callback
),
8348 doAnimation = function() {
8349 // Operate on a copy of prop so per-property easing won't be lost
8350 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
8351 doAnimation
.finish = function() {
8354 // Empty animations, or finishing resolves immediately
8355 if ( empty
|| data_priv
.get( this, "finish" ) ) {
8359 doAnimation
.finish
= doAnimation
;
8361 return empty
|| optall
.queue
=== false ?
8362 this.each( doAnimation
) :
8363 this.queue( optall
.queue
, doAnimation
);
8365 stop: function( type
, clearQueue
, gotoEnd
) {
8366 var stopQueue = function( hooks
) {
8367 var stop
= hooks
.stop
;
8372 if ( typeof type
!== "string" ) {
8373 gotoEnd
= clearQueue
;
8377 if ( clearQueue
&& type
!== false ) {
8378 this.queue( type
|| "fx", [] );
8381 return this.each(function() {
8383 index
= type
!= null && type
+ "queueHooks",
8384 timers
= jQuery
.timers
,
8385 data
= data_priv
.get( this );
8388 if ( data
[ index
] && data
[ index
].stop
) {
8389 stopQueue( data
[ index
] );
8392 for ( index
in data
) {
8393 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
8394 stopQueue( data
[ index
] );
8399 for ( index
= timers
.length
; index
--; ) {
8400 if ( timers
[ index
].elem
=== this && (type
== null || timers
[ index
].queue
=== type
) ) {
8401 timers
[ index
].anim
.stop( gotoEnd
);
8403 timers
.splice( index
, 1 );
8407 // start the next in the queue if the last step wasn't forced
8408 // timers currently will call their complete callbacks, which will dequeue
8409 // but only if they were gotoEnd
8410 if ( dequeue
|| !gotoEnd
) {
8411 jQuery
.dequeue( this, type
);
8415 finish: function( type
) {
8416 if ( type
!== false ) {
8417 type
= type
|| "fx";
8419 return this.each(function() {
8421 data
= data_priv
.get( this ),
8422 queue
= data
[ type
+ "queue" ],
8423 hooks
= data
[ type
+ "queueHooks" ],
8424 timers
= jQuery
.timers
,
8425 length
= queue
? queue
.length
: 0;
8427 // enable finishing flag on private data
8430 // empty the queue first
8431 jQuery
.queue( this, type
, [] );
8433 if ( hooks
&& hooks
.cur
&& hooks
.cur
.finish
) {
8434 hooks
.cur
.finish
.call( this );
8437 // look for any active animations, and finish them
8438 for ( index
= timers
.length
; index
--; ) {
8439 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
8440 timers
[ index
].anim
.stop( true );
8441 timers
.splice( index
, 1 );
8445 // look for any animations in the old queue and finish them
8446 for ( index
= 0; index
< length
; index
++ ) {
8447 if ( queue
[ index
] && queue
[ index
].finish
) {
8448 queue
[ index
].finish
.call( this );
8452 // turn off finishing flag
8458 // Generate parameters to create a standard animation
8459 function genFx( type
, includeWidth
) {
8461 attrs
= { height
: type
},
8464 // if we include width, step value is 1 to do all cssExpand values,
8465 // if we don't include width, step value is 2 to skip over Left and Right
8466 includeWidth
= includeWidth
? 1 : 0;
8467 for( ; i
< 4 ; i
+= 2 - includeWidth
) {
8468 which
= cssExpand
[ i
];
8469 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
8472 if ( includeWidth
) {
8473 attrs
.opacity
= attrs
.width
= type
;
8479 // Generate shortcuts for custom animations
8481 slideDown
: genFx("show"),
8482 slideUp
: genFx("hide"),
8483 slideToggle
: genFx("toggle"),
8484 fadeIn
: { opacity
: "show" },
8485 fadeOut
: { opacity
: "hide" },
8486 fadeToggle
: { opacity
: "toggle" }
8487 }, function( name
, props
) {
8488 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
8489 return this.animate( props
, speed
, easing
, callback
);
8493 jQuery
.speed = function( speed
, easing
, fn
) {
8494 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
8495 complete
: fn
|| !fn
&& easing
||
8496 jQuery
.isFunction( speed
) && speed
,
8498 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
8501 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration
:
8502 opt
.duration
in jQuery
.fx
.speeds
? jQuery
.fx
.speeds
[ opt
.duration
] : jQuery
.fx
.speeds
._default
;
8504 // normalize opt.queue - true/undefined/null -> "fx"
8505 if ( opt
.queue
== null || opt
.queue
=== true ) {
8510 opt
.old
= opt
.complete
;
8512 opt
.complete = function() {
8513 if ( jQuery
.isFunction( opt
.old
) ) {
8514 opt
.old
.call( this );
8518 jQuery
.dequeue( this, opt
.queue
);
8526 linear: function( p
) {
8529 swing: function( p
) {
8530 return 0.5 - Math
.cos( p
*Math
.PI
) / 2;
8535 jQuery
.fx
= Tween
.prototype.init
;
8536 jQuery
.fx
.tick = function() {
8538 timers
= jQuery
.timers
,
8541 fxNow
= jQuery
.now();
8543 for ( ; i
< timers
.length
; i
++ ) {
8544 timer
= timers
[ i
];
8545 // Checks the timer has not already been removed
8546 if ( !timer() && timers
[ i
] === timer
) {
8547 timers
.splice( i
--, 1 );
8551 if ( !timers
.length
) {
8557 jQuery
.fx
.timer = function( timer
) {
8558 if ( timer() && jQuery
.timers
.push( timer
) ) {
8563 jQuery
.fx
.interval
= 13;
8565 jQuery
.fx
.start = function() {
8567 timerId
= setInterval( jQuery
.fx
.tick
, jQuery
.fx
.interval
);
8571 jQuery
.fx
.stop = function() {
8572 clearInterval( timerId
);
8576 jQuery
.fx
.speeds
= {
8583 // Back Compat <1.8 extension point
8584 jQuery
.fx
.step
= {};
8586 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
8587 jQuery
.expr
.filters
.animated = function( elem
) {
8588 return jQuery
.grep(jQuery
.timers
, function( fn
) {
8589 return elem
=== fn
.elem
;
8593 jQuery
.fn
.offset = function( options
) {
8594 if ( arguments
.length
) {
8595 return options
=== undefined ?
8597 this.each(function( i
) {
8598 jQuery
.offset
.setOffset( this, options
, i
);
8604 box
= { top
: 0, left
: 0 },
8605 doc
= elem
&& elem
.ownerDocument
;
8611 docElem
= doc
.documentElement
;
8613 // Make sure it's not a disconnected DOM node
8614 if ( !jQuery
.contains( docElem
, elem
) ) {
8618 // If we don't have gBCR, just use 0,0 rather than error
8619 // BlackBerry 5, iOS 3 (original iPhone)
8620 if ( typeof elem
.getBoundingClientRect
!== core_strundefined
) {
8621 box
= elem
.getBoundingClientRect();
8623 win
= getWindow( doc
);
8625 top
: box
.top
+ win
.pageYOffset
- docElem
.clientTop
,
8626 left
: box
.left
+ win
.pageXOffset
- docElem
.clientLeft
8632 setOffset: function( elem
, options
, i
) {
8633 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
8634 position
= jQuery
.css( elem
, "position" ),
8635 curElem
= jQuery( elem
),
8638 // Set position first, in-case top/left are set even on static elem
8639 if ( position
=== "static" ) {
8640 elem
.style
.position
= "relative";
8643 curOffset
= curElem
.offset();
8644 curCSSTop
= jQuery
.css( elem
, "top" );
8645 curCSSLeft
= jQuery
.css( elem
, "left" );
8646 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) && ( curCSSTop
+ curCSSLeft
).indexOf("auto") > -1;
8648 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
8649 if ( calculatePosition
) {
8650 curPosition
= curElem
.position();
8651 curTop
= curPosition
.top
;
8652 curLeft
= curPosition
.left
;
8655 curTop
= parseFloat( curCSSTop
) || 0;
8656 curLeft
= parseFloat( curCSSLeft
) || 0;
8659 if ( jQuery
.isFunction( options
) ) {
8660 options
= options
.call( elem
, i
, curOffset
);
8663 if ( options
.top
!= null ) {
8664 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
8666 if ( options
.left
!= null ) {
8667 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
8670 if ( "using" in options
) {
8671 options
.using
.call( elem
, props
);
8674 curElem
.css( props
);
8682 position: function() {
8687 var offsetParent
, offset
,
8689 parentOffset
= { top
: 0, left
: 0 };
8691 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
8692 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
8693 // We assume that getBoundingClientRect is available when computed position is fixed
8694 offset
= elem
.getBoundingClientRect();
8697 // Get *real* offsetParent
8698 offsetParent
= this.offsetParent();
8700 // Get correct offsets
8701 offset
= this.offset();
8702 if ( !jQuery
.nodeName( offsetParent
[ 0 ], "html" ) ) {
8703 parentOffset
= offsetParent
.offset();
8706 // Add offsetParent borders
8707 parentOffset
.top
+= jQuery
.css( offsetParent
[ 0 ], "borderTopWidth", true );
8708 parentOffset
.left
+= jQuery
.css( offsetParent
[ 0 ], "borderLeftWidth", true );
8711 // Subtract parent offsets and element margins
8713 top
: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
8714 left
: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
8718 offsetParent: function() {
8719 return this.map(function() {
8720 var offsetParent
= this.offsetParent
|| docElem
;
8722 while ( offsetParent
&& ( !jQuery
.nodeName( offsetParent
, "html" ) && jQuery
.css( offsetParent
, "position") === "static" ) ) {
8723 offsetParent
= offsetParent
.offsetParent
;
8726 return offsetParent
|| docElem
;
8732 // Create scrollLeft and scrollTop methods
8733 jQuery
.each( {scrollLeft
: "pageXOffset", scrollTop
: "pageYOffset"}, function( method
, prop
) {
8734 var top
= "pageYOffset" === prop
;
8736 jQuery
.fn
[ method
] = function( val
) {
8737 return jQuery
.access( this, function( elem
, method
, val
) {
8738 var win
= getWindow( elem
);
8740 if ( val
=== undefined ) {
8741 return win
? win
[ prop
] : elem
[ method
];
8746 !top
? val
: window
.pageXOffset
,
8747 top
? val
: window
.pageYOffset
8751 elem
[ method
] = val
;
8753 }, method
, val
, arguments
.length
, null );
8757 function getWindow( elem
) {
8758 return jQuery
.isWindow( elem
) ? elem
: elem
.nodeType
=== 9 && elem
.defaultView
;
8760 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
8761 jQuery
.each( { Height
: "height", Width
: "width" }, function( name
, type
) {
8762 jQuery
.each( { padding
: "inner" + name
, content
: type
, "": "outer" + name
}, function( defaultExtra
, funcName
) {
8763 // margin is only for outerHeight, outerWidth
8764 jQuery
.fn
[ funcName
] = function( margin
, value
) {
8765 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
8766 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
8768 return jQuery
.access( this, function( elem
, type
, value
) {
8771 if ( jQuery
.isWindow( elem
) ) {
8772 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
8773 // isn't a whole lot we can do. See pull request at this URL for discussion:
8774 // https://github.com/jquery/jquery/pull/764
8775 return elem
.document
.documentElement
[ "client" + name
];
8778 // Get document width or height
8779 if ( elem
.nodeType
=== 9 ) {
8780 doc
= elem
.documentElement
;
8782 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
8783 // whichever is greatest
8785 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
8786 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
8787 doc
[ "client" + name
]
8791 return value
=== undefined ?
8792 // Get width or height on the element, requesting but not forcing parseFloat
8793 jQuery
.css( elem
, type
, extra
) :
8795 // Set width or height on the element
8796 jQuery
.style( elem
, type
, value
, extra
);
8797 }, type
, chainable
? margin
: undefined, chainable
, null );
8801 // Limit scope pollution from any deprecated API
8804 // The number of elements contained in the matched element set
8805 jQuery
.fn
.size = function() {
8809 jQuery
.fn
.andSelf
= jQuery
.fn
.addBack
;
8812 if ( typeof module
=== "object" && module
&& typeof module
.exports
=== "object" ) {
8813 // Expose jQuery as module.exports in loaders that implement the Node
8814 // module pattern (including browserify). Do not create the global, since
8815 // the user will be storing it themselves locally, and globals are frowned
8816 // upon in the Node module world.
8817 module
.exports
= jQuery
;
8819 // Register as a named AMD module, since jQuery can be concatenated with other
8820 // files that may use define, but not via a proper concatenation script that
8821 // understands anonymous AMD modules. A named AMD is safest and most robust
8822 // way to register. Lowercase jquery is used because AMD module names are
8823 // derived from file names, and jQuery is normally delivered in a lowercase
8824 // file name. Do this after creating the global so that if an AMD module wants
8825 // to call noConflict to hide this version of jQuery, it will work.
8826 if ( typeof define
=== "function" && define
.amd
) {
8827 define( "jquery", [], function () { return jQuery
; } );
8831 // If there is a window object, that at least has a document property,
8832 // define jQuery and $ identifiers
8833 if ( typeof window
=== "object" && typeof window
.document
=== "object" ) {
8834 window
.jQuery
= window
.$ = jQuery
;