2 * jQuery JavaScript Library v1.7.1
5 * Copyright 2011, John Resig
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://jquery.org/license
10 * http://sizzlejs.com/
11 * Copyright 2011, The Dojo Foundation
12 * Released under the MIT, BSD, and GPL Licenses.
14 * Date: Mon Nov 21 21:11:03 2011 -0500
16 (function( window
, undefined ) {
18 // Use the correct document accordingly with window argument (sandbox)
19 var document
= window
.document
,
20 navigator
= window
.navigator
,
21 location
= window
.location
;
22 var jQuery
= (function() {
24 // Define a local copy of jQuery
25 var jQuery = function( selector
, context
) {
26 // The jQuery object is actually just the init constructor 'enhanced'
27 return new jQuery
.fn
.init( selector
, context
, rootjQuery
);
30 // Map over jQuery in case of overwrite
31 _jQuery
= window
.jQuery
,
33 // Map over the $ in case of overwrite
36 // A central reference to the root jQuery(document)
39 // A simple way to check for HTML strings or ID strings
40 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
41 quickExpr
= /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
43 // Check if a string has a non-whitespace character in it
46 // Used for trimming whitespace
50 // Match a standalone tag
51 rsingleTag
= /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
54 rvalidchars
= /^[\],:{}\s]*$/,
55 rvalidescape
= /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
56 rvalidtokens
= /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
57 rvalidbraces
= /(?:^|:|,)(?:\s*\[)+/g,
60 rwebkit
= /(webkit
)[ \/]([\w.]+)/,
61 ropera
= /(opera
)(?:.*version
)?[ \/]([\w.]+)/,
62 rmsie
= /(msie
) ([\w
.]+)/,
63 rmozilla
= /(mozilla
)(?:.*? rv:([\w
.]+))?/,
65 // Matches dashed string for camelizing
66 rdashAlpha
= /-([a-z]|[0-9])/ig,
69 // Used by jQuery.camelCase as callback to replace()
70 fcamelCase = function( all
, letter
) {
71 return ( letter
+ "" ).toUpperCase();
74 // Keep a UserAgent string for use with jQuery.browser
75 userAgent
= navigator
.userAgent
,
77 // For matching the engine and version of the browser
80 // The deferred used on DOM ready
83 // The ready event handler
86 // Save a reference to some core methods
87 toString
= Object
.prototype.toString
,
88 hasOwn
= Object
.prototype.hasOwnProperty
,
89 push
= Array
.prototype.push
,
90 slice
= Array
.prototype.slice
,
91 trim
= String
.prototype.trim
,
92 indexOf
= Array
.prototype.indexOf
,
94 // [[Class]] -> type pairs
97 jQuery
.fn
= jQuery
.prototype = {
99 init: function( selector
, context
, rootjQuery
) {
100 var match
, elem
, ret
, doc
;
102 // Handle $(""), $(null), or $(undefined)
107 // Handle $(DOMElement)
108 if ( selector
.nodeType
) {
109 this.context
= this[0] = selector
;
114 // The body element only exists once, optimize finding it
115 if ( selector
=== "body" && !context
&& document
.body
) {
116 this.context
= document
;
117 this[0] = document
.body
;
118 this.selector
= selector
;
123 // Handle HTML strings
124 if ( typeof selector
=== "string" ) {
125 // Are we dealing with HTML string or an ID?
126 if ( selector
.charAt(0) === "<" && selector
.charAt( selector
.length
- 1 ) === ">" && selector
.length
>= 3 ) {
127 // Assume that strings that start and end with <> are HTML and skip the regex check
128 match
= [ null, selector
, null ];
131 match
= quickExpr
.exec( selector
);
134 // Verify a match, and that no context was specified for #id
135 if ( match
&& (match
[1] || !context
) ) {
137 // HANDLE: $(html) -> $(array)
139 context
= context
instanceof jQuery
? context
[0] : context
;
140 doc
= ( context
? context
.ownerDocument
|| context : document
);
142 // If a single string is passed in and it's a single tag
143 // just do a createElement and skip the rest
144 ret
= rsingleTag
.exec( selector
);
147 if ( jQuery
.isPlainObject( context
) ) {
148 selector
= [ document
.createElement( ret
[1] ) ];
149 jQuery
.fn
.attr
.call( selector
, context
, true );
152 selector
= [ doc
.createElement( ret
[1] ) ];
156 ret
= jQuery
.buildFragment( [ match
[1] ], [ doc
] );
157 selector
= ( ret
.cacheable
? jQuery
.clone(ret
.fragment
) : ret
.fragment
).childNodes
;
160 return jQuery
.merge( this, selector
);
164 elem
= document
.getElementById( match
[2] );
166 // Check parentNode to catch when Blackberry 4.6 returns
167 // nodes that are no longer in the document #6963
168 if ( elem
&& elem
.parentNode
) {
169 // Handle the case where IE and Opera return items
170 // by name instead of ID
171 if ( elem
.id
!== match
[2] ) {
172 return rootjQuery
.find( selector
);
175 // Otherwise, we inject the element directly into the jQuery object
180 this.context
= document
;
181 this.selector
= selector
;
185 // HANDLE: $(expr, $(...))
186 } else if ( !context
|| context
.jquery
) {
187 return ( context
|| rootjQuery
).find( selector
);
189 // HANDLE: $(expr, context)
190 // (which is just equivalent to: $(context).find(expr)
192 return this.constructor( context
).find( selector
);
195 // HANDLE: $(function)
196 // Shortcut for document ready
197 } else if ( jQuery
.isFunction( selector
) ) {
198 return rootjQuery
.ready( selector
);
201 if ( selector
.selector
!== undefined ) {
202 this.selector
= selector
.selector
;
203 this.context
= selector
.context
;
206 return jQuery
.makeArray( selector
, this );
209 // Start with an empty selector
212 // The current version of jQuery being used
215 // The default length of a jQuery object is 0
218 // The number of elements contained in the matched element set
223 toArray: function() {
224 return slice
.call( this, 0 );
227 // Get the Nth element in the matched element set OR
228 // Get the whole matched element set as a clean array
229 get: function( num
) {
232 // Return a 'clean' array
235 // Return just the object
236 ( num
< 0 ? this[ this.length
+ num
] : this[ num
] );
239 // Take an array of elements and push it onto the stack
240 // (returning the new matched element set)
241 pushStack: function( elems
, name
, selector
) {
242 // Build a new jQuery matched element set
243 var ret
= this.constructor();
245 if ( jQuery
.isArray( elems
) ) {
246 push
.apply( ret
, elems
);
249 jQuery
.merge( ret
, elems
);
252 // Add the old object onto the stack (as a reference)
253 ret
.prevObject
= this;
255 ret
.context
= this.context
;
257 if ( name
=== "find" ) {
258 ret
.selector
= this.selector
+ ( this.selector
? " " : "" ) + selector
;
260 ret
.selector
= this.selector
+ "." + name
+ "(" + selector
+ ")";
263 // Return the newly-formed element set
267 // Execute a callback for every element in the matched set.
268 // (You can seed the arguments with an array of args, but this is
269 // only used internally.)
270 each: function( callback
, args
) {
271 return jQuery
.each( this, callback
, args
);
274 ready: function( fn
) {
275 // Attach the listeners
288 this.slice( i
, i
+ 1 );
296 return this.eq( -1 );
300 return this.pushStack( slice
.apply( this, arguments
),
301 "slice", slice
.call(arguments
).join(",") );
304 map: function( callback
) {
305 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
306 return callback
.call( elem
, i
, elem
);
311 return this.prevObject
|| this.constructor(null);
314 // For internal use only.
315 // Behaves like an Array's method, not like a jQuery method.
321 // Give the init function the jQuery prototype for later instantiation
322 jQuery
.fn
.init
.prototype = jQuery
.fn
;
324 jQuery
.extend
= jQuery
.fn
.extend = function() {
325 var options
, name
, src
, copy
, copyIsArray
, clone
,
326 target
= arguments
[0] || {},
328 length
= arguments
.length
,
331 // Handle a deep copy situation
332 if ( typeof target
=== "boolean" ) {
334 target
= arguments
[1] || {};
335 // skip the boolean and the target
339 // Handle case when target is a string or something (possible in deep copy)
340 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
344 // extend jQuery itself if only one argument is passed
345 if ( length
=== i
) {
350 for ( ; i
< length
; i
++ ) {
351 // Only deal with non-null/undefined values
352 if ( (options
= arguments
[ i
]) != null ) {
353 // Extend the base object
354 for ( name
in options
) {
355 src
= target
[ name
];
356 copy
= options
[ name
];
358 // Prevent never-ending loop
359 if ( target
=== copy
) {
363 // Recurse if we're merging plain objects or arrays
364 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || (copyIsArray
= jQuery
.isArray(copy
)) ) ) {
367 clone
= src
&& jQuery
.isArray(src
) ? src : [];
370 clone
= src
&& jQuery
.isPlainObject(src
) ? src : {};
373 // Never move original objects, clone them
374 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
376 // Don't bring in undefined values
377 } else if ( copy
!== undefined ) {
378 target
[ name
] = copy
;
384 // Return the modified object
389 noConflict: function( deep
) {
390 if ( window
.$ === jQuery
) {
394 if ( deep
&& window
.jQuery
=== jQuery
) {
395 window
.jQuery
= _jQuery
;
401 // Is the DOM ready to be used? Set to true once it occurs.
404 // A counter to track how many items to wait for before
405 // the ready event fires. See #6781
408 // Hold (or release) the ready event
409 holdReady: function( hold
) {
413 jQuery
.ready( true );
417 // Handle when the DOM is ready
418 ready: function( wait
) {
419 // Either a released hold or an DOMready/load event and not yet ready
420 if ( (wait
=== true && !--jQuery
.readyWait
) || (wait
!== true && !jQuery
.isReady
) ) {
421 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
422 if ( !document
.body
) {
423 return setTimeout( jQuery
.ready
, 1 );
426 // Remember that the DOM is ready
427 jQuery
.isReady
= true;
429 // If a normal DOM Ready event fired, decrement, and wait if need be
430 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
434 // If there are functions bound, to execute
435 readyList
.fireWith( document
, [ jQuery
] );
437 // Trigger any bound ready events
438 if ( jQuery
.fn
.trigger
) {
439 jQuery( document
).trigger( "ready" ).off( "ready" );
444 bindReady: function() {
449 readyList
= jQuery
.Callbacks( "once memory" );
451 // Catch cases where $(document).ready() is called after the
452 // browser event has already occurred.
453 if ( document
.readyState
=== "complete" ) {
454 // Handle it asynchronously to allow scripts the opportunity to delay ready
455 return setTimeout( jQuery
.ready
, 1 );
458 // Mozilla, Opera and webkit nightlies currently support this event
459 if ( document
.addEventListener
) {
460 // Use the handy event callback
461 document
.addEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
463 // A fallback to window.onload, that will always work
464 window
.addEventListener( "load", jQuery
.ready
, false );
466 // If IE event model is used
467 } else if ( document
.attachEvent
) {
468 // ensure firing before onload,
469 // maybe late but safe also for iframes
470 document
.attachEvent( "onreadystatechange", DOMContentLoaded
);
472 // A fallback to window.onload, that will always work
473 window
.attachEvent( "onload", jQuery
.ready
);
475 // If IE and not a frame
476 // continually check to see if the document is ready
477 var toplevel
= false;
480 toplevel
= window
.frameElement
== null;
483 if ( document
.documentElement
.doScroll
&& toplevel
) {
489 // See test/unit/core.js for details concerning isFunction.
490 // Since version 1.3, DOM methods and functions like alert
491 // aren't supported. They return false on IE (#2968).
492 isFunction: function( obj
) {
493 return jQuery
.type(obj
) === "function";
496 isArray: Array
.isArray
|| function( obj
) {
497 return jQuery
.type(obj
) === "array";
500 // A crude way of determining if an object is a window
501 isWindow: function( obj
) {
502 return obj
&& typeof obj
=== "object" && "setInterval" in obj
;
505 isNumeric: function( obj
) {
506 return !isNaN( parseFloat(obj
) ) && isFinite( obj
);
509 type: function( obj
) {
512 class2type
[ toString
.call(obj
) ] || "object";
515 isPlainObject: function( obj
) {
516 // Must be an Object.
517 // Because of IE, we also have to check the presence of the constructor property.
518 // Make sure that DOM nodes and window objects don't pass through, as well
519 if ( !obj
|| jQuery
.type(obj
) !== "object" || obj
.nodeType
|| jQuery
.isWindow( obj
) ) {
524 // Not own constructor property must be Object
525 if ( obj
.constructor &&
526 !hasOwn
.call(obj
, "constructor") &&
527 !hasOwn
.call(obj
.constructor.prototype, "isPrototypeOf") ) {
531 // IE8,9 Will throw exceptions on certain host objects #9897
535 // Own properties are enumerated firstly, so to speed up,
536 // if last one is own, then all properties are own.
539 for ( key
in obj
) {}
541 return key
=== undefined || hasOwn
.call( obj
, key
);
544 isEmptyObject: function( obj
) {
545 for ( var name
in obj
) {
551 error: function( msg
) {
552 throw new Error( msg
);
555 parseJSON: function( data
) {
556 if ( typeof data
!== "string" || !data
) {
560 // Make sure leading/trailing whitespace is removed (IE can't handle it)
561 data
= jQuery
.trim( data
);
563 // Attempt to parse using the native JSON parser first
564 if ( window
.JSON
&& window
.JSON
.parse
) {
565 return window
.JSON
.parse( data
);
568 // Make sure the incoming data is actual JSON
569 // Logic borrowed from http://json.org/json2.js
570 if ( rvalidchars
.test( data
.replace( rvalidescape
, "@" )
571 .replace( rvalidtokens
, "]" )
572 .replace( rvalidbraces
, "")) ) {
574 return ( new Function( "return " + data
) )();
577 jQuery
.error( "Invalid JSON: " + data
);
580 // Cross-browser xml parsing
581 parseXML: function( data
) {
584 if ( window
.DOMParser
) { // Standard
585 tmp
= new DOMParser();
586 xml
= tmp
.parseFromString( data
, "text/xml" );
588 xml
= new ActiveXObject( "Microsoft.XMLDOM" );
595 if ( !xml
|| !xml
.documentElement
|| xml
.getElementsByTagName( "parsererror" ).length
) {
596 jQuery
.error( "Invalid XML: " + data
);
603 // Evaluates a script in a global context
604 // Workarounds based on findings by Jim Driscoll
605 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
606 globalEval: function( data
) {
607 if ( data
&& rnotwhite
.test( data
) ) {
608 // We use execScript on Internet Explorer
609 // We use an anonymous function so that context is window
610 // rather than jQuery in Firefox
611 ( window
.execScript
|| function( data
) {
612 window
[ "eval" ].call( window
, data
);
617 // Convert dashed to camelCase; used by the css and data modules
618 // Microsoft forgot to hump their vendor prefix (#9572)
619 camelCase: function( string
) {
620 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
623 nodeName: function( elem
, name
) {
624 return elem
.nodeName
&& elem
.nodeName
.toUpperCase() === name
.toUpperCase();
627 // args is for internal usage only
628 each: function( object
, callback
, args
) {
630 length
= object
.length
,
631 isObj
= length
=== undefined || jQuery
.isFunction( object
);
635 for ( name
in object
) {
636 if ( callback
.apply( object
[ name
], args
) === false ) {
641 for ( ; i
< length
; ) {
642 if ( callback
.apply( object
[ i
++ ], args
) === false ) {
648 // A special, fast, case for the most common use of each
651 for ( name
in object
) {
652 if ( callback
.call( object
[ name
], name
, object
[ name
] ) === false ) {
657 for ( ; i
< length
; ) {
658 if ( callback
.call( object
[ i
], i
, object
[ i
++ ] ) === false ) {
668 // Use native String.trim function wherever possible
671 return text
== null ?
676 // Otherwise use our own trimming functionality
678 return text
== null ?
680 text
.toString().replace( trimLeft
, "" ).replace( trimRight
, "" );
683 // results is for internal usage only
684 makeArray: function( array
, results
) {
685 var ret
= results
|| [];
687 if ( array
!= null ) {
688 // The window, strings (and functions) also have 'length'
689 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
690 var type
= jQuery
.type( array
);
692 if ( array
.length
== null || type
=== "string" || type
=== "function" || type
=== "regexp" || jQuery
.isWindow( array
) ) {
693 push
.call( ret
, array
);
695 jQuery
.merge( ret
, array
);
702 inArray: function( elem
, array
, i
) {
707 return indexOf
.call( array
, elem
, i
);
711 i
= i
? i
< 0 ? Math
.max( 0, len
+ i
) : i : 0;
713 for ( ; i
< len
; i
++ ) {
714 // Skip accessing in sparse arrays
715 if ( i
in array
&& array
[ i
] === elem
) {
724 merge: function( first
, second
) {
725 var i
= first
.length
,
728 if ( typeof second
.length
=== "number" ) {
729 for ( var l
= second
.length
; j
< l
; j
++ ) {
730 first
[ i
++ ] = second
[ j
];
734 while ( second
[j
] !== undefined ) {
735 first
[ i
++ ] = second
[ j
++ ];
744 grep: function( elems
, callback
, inv
) {
745 var ret
= [], retVal
;
748 // Go through the array, only saving the items
749 // that pass the validator function
750 for ( var i
= 0, length
= elems
.length
; i
< length
; i
++ ) {
751 retVal
= !!callback( elems
[ i
], i
);
752 if ( inv
!== retVal
) {
753 ret
.push( elems
[ i
] );
760 // arg is for internal usage only
761 map: function( elems
, callback
, arg
) {
762 var value
, key
, ret
= [],
764 length
= elems
.length
,
765 // jquery objects are treated as arrays
766 isArray
= elems
instanceof jQuery
|| length
!== undefined && typeof length
=== "number" && ( ( length
> 0 && elems
[ 0 ] && elems
[ length
-1 ] ) || length
=== 0 || jQuery
.isArray( elems
) ) ;
768 // Go through the array, translating each of the items to their
770 for ( ; i
< length
; i
++ ) {
771 value
= callback( elems
[ i
], i
, arg
);
773 if ( value
!= null ) {
774 ret
[ ret
.length
] = value
;
778 // Go through every key on the object,
780 for ( key
in elems
) {
781 value
= callback( elems
[ key
], key
, arg
);
783 if ( value
!= null ) {
784 ret
[ ret
.length
] = value
;
789 // Flatten any nested arrays
790 return ret
.concat
.apply( [], ret
);
793 // A global GUID counter for objects
796 // Bind a function to a context, optionally partially applying any
798 proxy: function( fn
, context
) {
799 if ( typeof context
=== "string" ) {
800 var tmp
= fn
[ context
];
805 // Quick check to determine if target is callable, in the spec
806 // this throws a TypeError, but we will just return undefined.
807 if ( !jQuery
.isFunction( fn
) ) {
812 var args
= slice
.call( arguments
, 2 ),
814 return fn
.apply( context
, args
.concat( slice
.call( arguments
) ) );
817 // Set the guid of unique handler to the same of original handler, so it can be removed
818 proxy
.guid
= fn
.guid
= fn
.guid
|| proxy
.guid
|| jQuery
.guid
++;
823 // Mutifunctional method to get and set values to a collection
824 // The value/s can optionally be executed if it's a function
825 access: function( elems
, key
, value
, exec
, fn
, pass
) {
826 var length
= elems
.length
;
828 // Setting many attributes
829 if ( typeof key
=== "object" ) {
830 for ( var k
in key
) {
831 jQuery
.access( elems
, k
, key
[k
], exec
, fn
, value
);
836 // Setting one attribute
837 if ( value
!== undefined ) {
838 // Optionally, function values get executed if exec is true
839 exec
= !pass
&& exec
&& jQuery
.isFunction(value
);
841 for ( var i
= 0; i
< length
; i
++ ) {
842 fn( elems
[i
], key
, exec
? value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) : value
, pass
);
848 // Getting an attribute
849 return length
? fn( elems
[0], key
) : undefined;
853 return ( new Date() ).getTime();
856 // Use of jQuery.browser is frowned upon.
857 // More details: http://docs.jquery.com/Utilities/jQuery.browser
858 uaMatch: function( ua
) {
859 ua
= ua
.toLowerCase();
861 var match
= rwebkit
.exec( ua
) ||
864 ua
.indexOf("compatible") < 0 && rmozilla
.exec( ua
) ||
867 return { browser: match
[1] || "", version: match
[2] || "0" };
871 function jQuerySub( selector
, context
) {
872 return new jQuerySub
.fn
.init( selector
, context
);
874 jQuery
.extend( true, jQuerySub
, this );
875 jQuerySub
.superclass
= this;
876 jQuerySub
.fn
= jQuerySub
.prototype = this();
877 jQuerySub
.fn
.constructor = jQuerySub
;
878 jQuerySub
.sub
= this.sub
;
879 jQuerySub
.fn
.init
= function init( selector
, context
) {
880 if ( context
&& context
instanceof jQuery
&& !(context
instanceof jQuerySub
) ) {
881 context
= jQuerySub( context
);
884 return jQuery
.fn
.init
.call( this, selector
, context
, rootjQuerySub
);
886 jQuerySub
.fn
.init
.prototype = jQuerySub
.fn
;
887 var rootjQuerySub
= jQuerySub(document
);
894 // Populate the class2type map
895 jQuery
.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i
, name
) {
896 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
899 browserMatch
= jQuery
.uaMatch( userAgent
);
900 if ( browserMatch
.browser
) {
901 jQuery
.browser
[ browserMatch
.browser
] = true;
902 jQuery
.browser
.version
= browserMatch
.version
;
905 // Deprecated, use jQuery.browser.webkit instead
906 if ( jQuery
.browser
.webkit
) {
907 jQuery
.browser
.safari
= true;
910 // IE doesn't match non-breaking spaces with \s
911 if ( rnotwhite
.test( "\xA0" ) ) {
912 trimLeft
= /^[\s\xA0]+/;
913 trimRight
= /[\s\xA0]+$/;
916 // All jQuery objects should point back to these
917 rootjQuery
= jQuery(document
);
919 // Cleanup functions for the document ready method
920 if ( document
.addEventListener
) {
921 DOMContentLoaded = function() {
922 document
.removeEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
926 } else if ( document
.attachEvent
) {
927 DOMContentLoaded = function() {
928 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
929 if ( document
.readyState
=== "complete" ) {
930 document
.detachEvent( "onreadystatechange", DOMContentLoaded
);
936 // The DOM ready check for Internet Explorer
937 function doScrollCheck() {
938 if ( jQuery
.isReady
) {
943 // If IE is used, use the trick by Diego Perini
944 // http://javascript.nwbox.com/IEContentLoaded/
945 document
.documentElement
.doScroll("left");
947 setTimeout( doScrollCheck
, 1 );
951 // and execute any waiting functions
960 // String to Object flags format cache
963 // Convert String-formatted flags into Object-formatted ones and store in cache
964 function createFlags( flags
) {
965 var object
= flagsCache
[ flags
] = {},
967 flags
= flags
.split( /\s+/ );
968 for ( i
= 0, length
= flags
.length
; i
< length
; i
++ ) {
969 object
[ flags
[i
] ] = true;
975 * Create a callback list using the following parameters:
977 * flags: an optional list of space-separated flags that will change how
978 * the callback list behaves
980 * By default a callback list will act like an event callback list and can be
981 * "fired" multiple times.
985 * once: will ensure the callback list can only be fired once (like a Deferred)
987 * memory: will keep track of previous values and will call any callback added
988 * after the list has been fired right away with the latest "memorized"
989 * values (like a Deferred)
991 * unique: will ensure a callback can only be added once (no duplicate in the list)
993 * stopOnFalse: interrupt callings when a callback returns false
996 jQuery
.Callbacks = function( flags
) {
998 // Convert flags from String-formatted to Object-formatted
999 // (we check in cache first)
1000 flags
= flags
? ( flagsCache
[ flags
] || createFlags( flags
) ) : {};
1002 var // Actual callback list
1004 // Stack of fire calls for repeatable lists
1006 // Last fire value (for non-forgettable lists)
1008 // Flag to know if list is currently firing
1010 // First callback to fire (used internally by add and fireWith)
1012 // End of the loop when firing
1014 // Index of currently firing callback (modified by remove if needed)
1016 // Add one or several callbacks to the list
1017 add = function( args
) {
1023 for ( i
= 0, length
= args
.length
; i
< length
; i
++ ) {
1025 type
= jQuery
.type( elem
);
1026 if ( type
=== "array" ) {
1027 // Inspect recursively
1029 } else if ( type
=== "function" ) {
1030 // Add if not in unique mode and callback is not in
1031 if ( !flags
.unique
|| !self
.has( elem
) ) {
1038 fire = function( context
, args
) {
1040 memory
= !flags
.memory
|| [ context
, args
];
1042 firingIndex
= firingStart
|| 0;
1044 firingLength
= list
.length
;
1045 for ( ; list
&& firingIndex
< firingLength
; firingIndex
++ ) {
1046 if ( list
[ firingIndex
].apply( context
, args
) === false && flags
.stopOnFalse
) {
1047 memory
= true; // Mark as halted
1053 if ( !flags
.once
) {
1054 if ( stack
&& stack
.length
) {
1055 memory
= stack
.shift();
1056 self
.fireWith( memory
[ 0 ], memory
[ 1 ] );
1058 } else if ( memory
=== true ) {
1065 // Actual Callbacks object
1067 // Add a callback or a collection of callbacks to the list
1070 var length
= list
.length
;
1072 // Do we need to add the callbacks to the
1073 // current firing batch?
1075 firingLength
= list
.length
;
1076 // With memory, if we're not firing then
1077 // we should call right away, unless previous
1078 // firing was halted (stopOnFalse)
1079 } else if ( memory
&& memory
!== true ) {
1080 firingStart
= length
;
1081 fire( memory
[ 0 ], memory
[ 1 ] );
1086 // Remove a callback from the list
1087 remove: function() {
1089 var args
= arguments
,
1091 argLength
= args
.length
;
1092 for ( ; argIndex
< argLength
; argIndex
++ ) {
1093 for ( var i
= 0; i
< list
.length
; i
++ ) {
1094 if ( args
[ argIndex
] === list
[ i
] ) {
1095 // Handle firingIndex and firingLength
1097 if ( i
<= firingLength
) {
1099 if ( i
<= firingIndex
) {
1104 // Remove the element
1105 list
.splice( i
--, 1 );
1106 // If we have some unicity property then
1107 // we only need to do this once
1108 if ( flags
.unique
) {
1117 // Control if a given callback is in the list
1118 has: function( fn
) {
1121 length
= list
.length
;
1122 for ( ; i
< length
; i
++ ) {
1123 if ( fn
=== list
[ i
] ) {
1130 // Remove all callbacks from the list
1135 // Have the list do nothing anymore
1136 disable: function() {
1137 list
= stack
= memory
= undefined;
1141 disabled: function() {
1144 // Lock the list in its current state
1147 if ( !memory
|| memory
=== true ) {
1153 locked: function() {
1156 // Call all callbacks with the given context and arguments
1157 fireWith: function( context
, args
) {
1160 if ( !flags
.once
) {
1161 stack
.push( [ context
, args
] );
1163 } else if ( !( flags
.once
&& memory
) ) {
1164 fire( context
, args
);
1169 // Call all the callbacks with the given arguments
1171 self
.fireWith( this, arguments
);
1174 // To know if the callbacks have already been called at least once
1186 var // Static reference to slice
1187 sliceDeferred
= [].slice
;
1191 Deferred: function( func
) {
1192 var doneList
= jQuery
.Callbacks( "once memory" ),
1193 failList
= jQuery
.Callbacks( "once memory" ),
1194 progressList
= jQuery
.Callbacks( "memory" ),
1199 notify: progressList
1204 progress: progressList
.add
,
1211 isResolved: doneList
.fired
,
1212 isRejected: failList
.fired
,
1214 then: function( doneCallbacks
, failCallbacks
, progressCallbacks
) {
1215 deferred
.done( doneCallbacks
).fail( failCallbacks
).progress( progressCallbacks
);
1218 always: function() {
1219 deferred
.done
.apply( deferred
, arguments
).fail
.apply( deferred
, arguments
);
1222 pipe: function( fnDone
, fnFail
, fnProgress
) {
1223 return jQuery
.Deferred(function( newDefer
) {
1225 done: [ fnDone
, "resolve" ],
1226 fail: [ fnFail
, "reject" ],
1227 progress: [ fnProgress
, "notify" ]
1228 }, function( handler
, data
) {
1232 if ( jQuery
.isFunction( fn
) ) {
1233 deferred
[ handler
](function() {
1234 returned
= fn
.apply( this, arguments
);
1235 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
1236 returned
.promise().then( newDefer
.resolve
, newDefer
.reject
, newDefer
.notify
);
1238 newDefer
[ action
+ "With" ]( this === deferred
? newDefer : this, [ returned
] );
1242 deferred
[ handler
]( newDefer
[ action
] );
1247 // Get a promise for this deferred
1248 // If obj is provided, the promise aspect is added to the object
1249 promise: function( obj
) {
1250 if ( obj
== null ) {
1253 for ( var key
in promise
) {
1254 obj
[ key
] = promise
[ key
];
1260 deferred
= promise
.promise({}),
1263 for ( key
in lists
) {
1264 deferred
[ key
] = lists
[ key
].fire
;
1265 deferred
[ key
+ "With" ] = lists
[ key
].fireWith
;
1269 deferred
.done( function() {
1271 }, failList
.disable
, progressList
.lock
).fail( function() {
1273 }, doneList
.disable
, progressList
.lock
);
1275 // Call given func if any
1277 func
.call( deferred
, deferred
);
1285 when: function( firstParam
) {
1286 var args
= sliceDeferred
.call( arguments
, 0 ),
1288 length
= args
.length
,
1289 pValues
= new Array( length
),
1292 deferred
= length
<= 1 && firstParam
&& jQuery
.isFunction( firstParam
.promise
) ?
1295 promise
= deferred
.promise();
1296 function resolveFunc( i
) {
1297 return function( value
) {
1298 args
[ i
] = arguments
.length
> 1 ? sliceDeferred
.call( arguments
, 0 ) : value
;
1299 if ( !( --count
) ) {
1300 deferred
.resolveWith( deferred
, args
);
1304 function progressFunc( i
) {
1305 return function( value
) {
1306 pValues
[ i
] = arguments
.length
> 1 ? sliceDeferred
.call( arguments
, 0 ) : value
;
1307 deferred
.notifyWith( promise
, pValues
);
1311 for ( ; i
< length
; i
++ ) {
1312 if ( args
[ i
] && args
[ i
].promise
&& jQuery
.isFunction( args
[ i
].promise
) ) {
1313 args
[ i
].promise().then( resolveFunc(i
), deferred
.reject
, progressFunc(i
) );
1319 deferred
.resolveWith( deferred
, args
);
1321 } else if ( deferred
!== firstParam
) {
1322 deferred
.resolveWith( deferred
, length
? [ firstParam
] : [] );
1331 jQuery
.support
= (function() {
1346 div
= document
.createElement( "div" ),
1347 documentElement
= document
.documentElement
;
1349 // Preliminary tests
1350 div
.setAttribute("className", "t");
1351 div
.innerHTML
= " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1353 all
= div
.getElementsByTagName( "*" );
1354 a
= div
.getElementsByTagName( "a" )[ 0 ];
1356 // Can't get basic test support
1357 if ( !all
|| !all
.length
|| !a
) {
1361 // First batch of supports tests
1362 select
= document
.createElement( "select" );
1363 opt
= select
.appendChild( document
.createElement("option") );
1364 input
= div
.getElementsByTagName( "input" )[ 0 ];
1367 // IE strips leading whitespace when .innerHTML is used
1368 leadingWhitespace: ( div
.firstChild
.nodeType
=== 3 ),
1370 // Make sure that tbody elements aren't automatically inserted
1371 // IE will insert them into empty tables
1372 tbody: !div
.getElementsByTagName("tbody").length
,
1374 // Make sure that link elements get serialized correctly by innerHTML
1375 // This requires a wrapper element in IE
1376 htmlSerialize: !!div
.getElementsByTagName("link").length
,
1378 // Get the style information from getAttribute
1379 // (IE uses .cssText instead)
1380 style: /top/.test( a
.getAttribute("style") ),
1382 // Make sure that URLs aren't manipulated
1383 // (IE normalizes it by default)
1384 hrefNormalized: ( a
.getAttribute("href") === "/a" ),
1386 // Make sure that element opacity exists
1387 // (IE uses filter instead)
1388 // Use a regex to work around a WebKit issue. See #5145
1389 opacity: /^0.55/.test( a
.style
.opacity
),
1391 // Verify style float existence
1392 // (IE uses styleFloat instead of cssFloat)
1393 cssFloat: !!a
.style
.cssFloat
,
1395 // Make sure that if no value is specified for a checkbox
1396 // that it defaults to "on".
1397 // (WebKit defaults to "" instead)
1398 checkOn: ( input
.value
=== "on" ),
1400 // Make sure that a selected-by-default option has a working selected property.
1401 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1402 optSelected: opt
.selected
,
1404 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1405 getSetAttribute: div
.className
!== "t",
1407 // Tests for enctype support on a form(#6743)
1408 enctype: !!document
.createElement("form").enctype
,
1410 // Makes sure cloning an html5 element does not cause problems
1411 // Where outerHTML is undefined, this still works
1412 html5Clone: document
.createElement("nav").cloneNode( true ).outerHTML
!== "<:nav></:nav>",
1414 // Will be defined later
1415 submitBubbles: true,
1416 changeBubbles: true,
1417 focusinBubbles: false,
1418 deleteExpando: true,
1420 inlineBlockNeedsLayout: false,
1421 shrinkWrapBlocks: false,
1422 reliableMarginRight: true
1425 // Make sure checked status is properly cloned
1426 input
.checked
= true;
1427 support
.noCloneChecked
= input
.cloneNode( true ).checked
;
1429 // Make sure that the options inside disabled selects aren't marked as disabled
1430 // (WebKit marks them as disabled)
1431 select
.disabled
= true;
1432 support
.optDisabled
= !opt
.disabled
;
1434 // Test to see if it's possible to delete an expando from an element
1435 // Fails in Internet Explorer
1439 support
.deleteExpando
= false;
1442 if ( !div
.addEventListener
&& div
.attachEvent
&& div
.fireEvent
) {
1443 div
.attachEvent( "onclick", function() {
1444 // Cloning a node shouldn't copy over any
1445 // bound event handlers (IE does this)
1446 support
.noCloneEvent
= false;
1448 div
.cloneNode( true ).fireEvent( "onclick" );
1451 // Check if a radio maintains its value
1452 // after being appended to the DOM
1453 input
= document
.createElement("input");
1455 input
.setAttribute("type", "radio");
1456 support
.radioValue
= input
.value
=== "t";
1458 input
.setAttribute("checked", "checked");
1459 div
.appendChild( input
);
1460 fragment
= document
.createDocumentFragment();
1461 fragment
.appendChild( div
.lastChild
);
1463 // WebKit doesn't clone checked state correctly in fragments
1464 support
.checkClone
= fragment
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
1466 // Check if a disconnected checkbox will retain its checked
1467 // value of true after appended to the DOM (IE6/7)
1468 support
.appendChecked
= input
.checked
;
1470 fragment
.removeChild( input
);
1471 fragment
.appendChild( div
);
1475 // Check if div with explicit width and no margin-right incorrectly
1476 // gets computed margin-right based on width of container. For more
1477 // info see bug #3333
1478 // Fails in WebKit before Feb 2011 nightlies
1479 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1480 if ( window
.getComputedStyle
) {
1481 marginDiv
= document
.createElement( "div" );
1482 marginDiv
.style
.width
= "0";
1483 marginDiv
.style
.marginRight
= "0";
1484 div
.style
.width
= "2px";
1485 div
.appendChild( marginDiv
);
1486 support
.reliableMarginRight
=
1487 ( parseInt( ( window
.getComputedStyle( marginDiv
, null ) || { marginRight: 0 } ).marginRight
, 10 ) || 0 ) === 0;
1490 // Technique from Juriy Zaytsev
1491 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1492 // We only care about the case where non-standard event systems
1493 // are used, namely in IE. Short-circuiting here helps us to
1494 // avoid an eval call (in setAttribute) which can cause CSP
1495 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1496 if ( div
.attachEvent
) {
1502 eventName
= "on" + i
;
1503 isSupported
= ( eventName
in div
);
1504 if ( !isSupported
) {
1505 div
.setAttribute( eventName
, "return;" );
1506 isSupported
= ( typeof div
[ eventName
] === "function" );
1508 support
[ i
+ "Bubbles" ] = isSupported
;
1512 fragment
.removeChild( div
);
1514 // Null elements to avoid leaks in IE
1515 fragment
= select
= opt
= marginDiv
= div
= input
= null;
1517 // Run tests that need a body at doc ready
1519 var container
, outer
, inner
, table
, td
, offsetSupport
,
1520 conMarginTop
, ptlm
, vb
, style
, html
,
1521 body
= document
.getElementsByTagName("body")[0];
1524 // Return for frameset docs that don't have a body
1529 ptlm
= "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
1530 vb
= "visibility:hidden;border:0;";
1531 style
= "style='" + ptlm
+ "border:5px solid #000;padding:0;'";
1532 html
= "<div " + style
+ "><div></div></div>" +
1533 "<table " + style
+ " cellpadding='0' cellspacing='0'>" +
1534 "<tr><td></td></tr></table>";
1536 container
= document
.createElement("div");
1537 container
.style
.cssText
= vb
+ "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop
+ "px";
1538 body
.insertBefore( container
, body
.firstChild
);
1540 // Construct the test element
1541 div
= document
.createElement("div");
1542 container
.appendChild( div
);
1544 // Check if table cells still have offsetWidth/Height when they are set
1545 // to display:none and there are still other visible table cells in a
1546 // table row; if so, offsetWidth/Height are not reliable for use when
1547 // determining if an element has been hidden directly using
1548 // display:none (it is still safe to use offsets if a parent element is
1549 // hidden; don safety goggles and see bug #4512 for more information).
1550 // (only IE 8 fails this test)
1551 div
.innerHTML
= "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1552 tds
= div
.getElementsByTagName( "td" );
1553 isSupported
= ( tds
[ 0 ].offsetHeight
=== 0 );
1555 tds
[ 0 ].style
.display
= "";
1556 tds
[ 1 ].style
.display
= "none";
1558 // Check if empty table cells still have offsetWidth/Height
1559 // (IE <= 8 fail this test)
1560 support
.reliableHiddenOffsets
= isSupported
&& ( tds
[ 0 ].offsetHeight
=== 0 );
1562 // Figure out if the W3C box model works as expected
1564 div
.style
.width
= div
.style
.paddingLeft
= "1px";
1565 jQuery
.boxModel
= support
.boxModel
= div
.offsetWidth
=== 2;
1567 if ( typeof div
.style
.zoom
!== "undefined" ) {
1568 // Check if natively block-level elements act like inline-block
1569 // elements when setting their display to 'inline' and giving
1571 // (IE < 8 does this)
1572 div
.style
.display
= "inline";
1574 support
.inlineBlockNeedsLayout
= ( div
.offsetWidth
=== 2 );
1576 // Check if elements with layout shrink-wrap their children
1578 div
.style
.display
= "";
1579 div
.innerHTML
= "<div style='width:4px;'></div>";
1580 support
.shrinkWrapBlocks
= ( div
.offsetWidth
!== 2 );
1583 div
.style
.cssText
= ptlm
+ vb
;
1584 div
.innerHTML
= html
;
1586 outer
= div
.firstChild
;
1587 inner
= outer
.firstChild
;
1588 td
= outer
.nextSibling
.firstChild
.firstChild
;
1591 doesNotAddBorder: ( inner
.offsetTop
!== 5 ),
1592 doesAddBorderForTableAndCells: ( td
.offsetTop
=== 5 )
1595 inner
.style
.position
= "fixed";
1596 inner
.style
.top
= "20px";
1598 // safari subtracts parent border width here which is 5px
1599 offsetSupport
.fixedPosition
= ( inner
.offsetTop
=== 20 || inner
.offsetTop
=== 15 );
1600 inner
.style
.position
= inner
.style
.top
= "";
1602 outer
.style
.overflow
= "hidden";
1603 outer
.style
.position
= "relative";
1605 offsetSupport
.subtractsBorderForOverflowNotVisible
= ( inner
.offsetTop
=== -5 );
1606 offsetSupport
.doesNotIncludeMarginInBodyOffset
= ( body
.offsetTop
!== conMarginTop
);
1608 body
.removeChild( container
);
1609 div
= container
= null;
1611 jQuery
.extend( support
, offsetSupport
);
1620 var rbrace
= /^(?:\{.*\}|\[.*\])$/,
1621 rmultiDash
= /([A-Z])/g;
1626 // Please use with caution
1629 // Unique for each copy of jQuery on the page
1630 // Non-digits removed to match rinlinejQuery
1631 expando: "jQuery" + ( jQuery
.fn
.jquery
+ Math
.random() ).replace( /\D/g, "" ),
1633 // The following elements throw uncatchable exceptions if you
1634 // attempt to add expando properties to them.
1637 // Ban all objects except for Flash (which handle expandos)
1638 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1642 hasData: function( elem
) {
1643 elem
= elem
.nodeType
? jQuery
.cache
[ elem
[jQuery
.expando
] ] : elem
[ jQuery
.expando
];
1644 return !!elem
&& !isEmptyDataObject( elem
);
1647 data: function( elem
, name
, data
, pvt
/* Internal Use Only */ ) {
1648 if ( !jQuery
.acceptData( elem
) ) {
1652 var privateCache
, thisCache
, ret
,
1653 internalKey
= jQuery
.expando
,
1654 getByName
= typeof name
=== "string",
1656 // We have to handle DOM nodes and JS objects differently because IE6-7
1657 // can't GC object references properly across the DOM-JS boundary
1658 isNode
= elem
.nodeType
,
1660 // Only DOM nodes need the global jQuery cache; JS object data is
1661 // attached directly to the object so GC can occur automatically
1662 cache
= isNode
? jQuery
.cache : elem
,
1664 // Only defining an ID for JS objects if its cache already exists allows
1665 // the code to shortcut on the same path as a DOM node with no cache
1666 id
= isNode
? elem
[ internalKey
] : elem
[ internalKey
] && internalKey
,
1667 isEvents
= name
=== "events";
1669 // Avoid doing any more work than we need to when trying to get data on an
1670 // object that has no data at all
1671 if ( (!id
|| !cache
[id
] || (!isEvents
&& !pvt
&& !cache
[id
].data
)) && getByName
&& data
=== undefined ) {
1676 // Only DOM nodes need a new unique ID for each element since their data
1677 // ends up in the global cache
1679 elem
[ internalKey
] = id
= ++jQuery
.uuid
;
1685 if ( !cache
[ id
] ) {
1688 // Avoids exposing jQuery metadata on plain JS objects when the object
1689 // is serialized using JSON.stringify
1691 cache
[ id
].toJSON
= jQuery
.noop
;
1695 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1696 // shallow copied over onto the existing cache
1697 if ( typeof name
=== "object" || typeof name
=== "function" ) {
1699 cache
[ id
] = jQuery
.extend( cache
[ id
], name
);
1701 cache
[ id
].data
= jQuery
.extend( cache
[ id
].data
, name
);
1705 privateCache
= thisCache
= cache
[ id
];
1707 // jQuery data() is stored in a separate object inside the object's internal data
1708 // cache in order to avoid key collisions between internal data and user-defined
1711 if ( !thisCache
.data
) {
1712 thisCache
.data
= {};
1715 thisCache
= thisCache
.data
;
1718 if ( data
!== undefined ) {
1719 thisCache
[ jQuery
.camelCase( name
) ] = data
;
1722 // Users should not attempt to inspect the internal events object using jQuery.data,
1723 // it is undocumented and subject to change. But does anyone listen? No.
1724 if ( isEvents
&& !thisCache
[ name
] ) {
1725 return privateCache
.events
;
1728 // Check for both converted-to-camel and non-converted data property names
1729 // If a data property was specified
1732 // First Try to find as-is property data
1733 ret
= thisCache
[ name
];
1735 // Test for null|undefined property data
1736 if ( ret
== null ) {
1738 // Try to find the camelCased property
1739 ret
= thisCache
[ jQuery
.camelCase( name
) ];
1748 removeData: function( elem
, name
, pvt
/* Internal Use Only */ ) {
1749 if ( !jQuery
.acceptData( elem
) ) {
1753 var thisCache
, i
, l
,
1755 // Reference to internal data cache key
1756 internalKey
= jQuery
.expando
,
1758 isNode
= elem
.nodeType
,
1760 // See jQuery.data for more information
1761 cache
= isNode
? jQuery
.cache : elem
,
1763 // See jQuery.data for more information
1764 id
= isNode
? elem
[ internalKey
] : internalKey
;
1766 // If there is already no cache entry for this object, there is no
1767 // purpose in continuing
1768 if ( !cache
[ id
] ) {
1774 thisCache
= pvt
? cache
[ id
] : cache
[ id
].data
;
1778 // Support array or space separated string names for data keys
1779 if ( !jQuery
.isArray( name
) ) {
1781 // try the string as a key before any manipulation
1782 if ( name
in thisCache
) {
1786 // split the camel cased version by spaces unless a key with the spaces exists
1787 name
= jQuery
.camelCase( name
);
1788 if ( name
in thisCache
) {
1791 name
= name
.split( " " );
1796 for ( i
= 0, l
= name
.length
; i
< l
; i
++ ) {
1797 delete thisCache
[ name
[i
] ];
1800 // If there is no data left in the cache, we want to continue
1801 // and let the cache object itself get destroyed
1802 if ( !( pvt
? isEmptyDataObject : jQuery
.isEmptyObject
)( thisCache
) ) {
1808 // See jQuery.data for more information
1810 delete cache
[ id
].data
;
1812 // Don't destroy the parent cache unless the internal data object
1813 // had been the only thing left in it
1814 if ( !isEmptyDataObject(cache
[ id
]) ) {
1819 // Browsers that fail expando deletion also refuse to delete expandos on
1820 // the window, but it will allow it on all other JS objects; other browsers
1822 // Ensure that `cache` is not a window object #10080
1823 if ( jQuery
.support
.deleteExpando
|| !cache
.setInterval
) {
1829 // We destroyed the cache and need to eliminate the expando on the node to avoid
1830 // false lookups in the cache for entries that no longer exist
1832 // IE does not allow us to delete expando properties from nodes,
1833 // nor does it have a removeAttribute function on Document nodes;
1834 // we must handle all of these cases
1835 if ( jQuery
.support
.deleteExpando
) {
1836 delete elem
[ internalKey
];
1837 } else if ( elem
.removeAttribute
) {
1838 elem
.removeAttribute( internalKey
);
1840 elem
[ internalKey
] = null;
1845 // For internal use only.
1846 _data: function( elem
, name
, data
) {
1847 return jQuery
.data( elem
, name
, data
, true );
1850 // A method for determining if a DOM node can handle the data expando
1851 acceptData: function( elem
) {
1852 if ( elem
.nodeName
) {
1853 var match
= jQuery
.noData
[ elem
.nodeName
.toLowerCase() ];
1856 return !(match
=== true || elem
.getAttribute("classid") !== match
);
1865 data: function( key
, value
) {
1866 var parts
, attr
, name
,
1869 if ( typeof key
=== "undefined" ) {
1870 if ( this.length
) {
1871 data
= jQuery
.data( this[0] );
1873 if ( this[0].nodeType
=== 1 && !jQuery
._data( this[0], "parsedAttrs" ) ) {
1874 attr
= this[0].attributes
;
1875 for ( var i
= 0, l
= attr
.length
; i
< l
; i
++ ) {
1876 name
= attr
[i
].name
;
1878 if ( name
.indexOf( "data-" ) === 0 ) {
1879 name
= jQuery
.camelCase( name
.substring(5) );
1881 dataAttr( this[0], name
, data
[ name
] );
1884 jQuery
._data( this[0], "parsedAttrs", true );
1890 } else if ( typeof key
=== "object" ) {
1891 return this.each(function() {
1892 jQuery
.data( this, key
);
1896 parts
= key
.split(".");
1897 parts
[1] = parts
[1] ? "." + parts
[1] : "";
1899 if ( value
=== undefined ) {
1900 data
= this.triggerHandler("getData" + parts
[1] + "!", [parts
[0]]);
1902 // Try to fetch any internally stored data first
1903 if ( data
=== undefined && this.length
) {
1904 data
= jQuery
.data( this[0], key
);
1905 data
= dataAttr( this[0], key
, data
);
1908 return data
=== undefined && parts
[1] ?
1909 this.data( parts
[0] ) :
1913 return this.each(function() {
1914 var self
= jQuery( this ),
1915 args
= [ parts
[0], value
];
1917 self
.triggerHandler( "setData" + parts
[1] + "!", args
);
1918 jQuery
.data( this, key
, value
);
1919 self
.triggerHandler( "changeData" + parts
[1] + "!", args
);
1924 removeData: function( key
) {
1925 return this.each(function() {
1926 jQuery
.removeData( this, key
);
1931 function dataAttr( elem
, key
, data
) {
1932 // If nothing was found internally, try to fetch any
1933 // data from the HTML5 data-* attribute
1934 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
1936 var name
= "data-" + key
.replace( rmultiDash
, "-$1" ).toLowerCase();
1938 data
= elem
.getAttribute( name
);
1940 if ( typeof data
=== "string" ) {
1942 data
= data
=== "true" ? true :
1943 data
=== "false" ? false :
1944 data
=== "null" ? null :
1945 jQuery
.isNumeric( data
) ? parseFloat( data
) :
1946 rbrace
.test( data
) ? jQuery
.parseJSON( data
) :
1950 // Make sure we set the data so it isn't changed later
1951 jQuery
.data( elem
, key
, data
);
1961 // checks a cache object for emptiness
1962 function isEmptyDataObject( obj
) {
1963 for ( var name
in obj
) {
1965 // if the public data object is empty, the private is still empty
1966 if ( name
=== "data" && jQuery
.isEmptyObject( obj
[name
] ) ) {
1969 if ( name
!== "toJSON" ) {
1980 function handleQueueMarkDefer( elem
, type
, src
) {
1981 var deferDataKey
= type
+ "defer",
1982 queueDataKey
= type
+ "queue",
1983 markDataKey
= type
+ "mark",
1984 defer
= jQuery
._data( elem
, deferDataKey
);
1986 ( src
=== "queue" || !jQuery
._data(elem
, queueDataKey
) ) &&
1987 ( src
=== "mark" || !jQuery
._data(elem
, markDataKey
) ) ) {
1988 // Give room for hard-coded callbacks to fire first
1989 // and eventually mark/queue something else on the element
1990 setTimeout( function() {
1991 if ( !jQuery
._data( elem
, queueDataKey
) &&
1992 !jQuery
._data( elem
, markDataKey
) ) {
1993 jQuery
.removeData( elem
, deferDataKey
, true );
2002 _mark: function( elem
, type
) {
2004 type
= ( type
|| "fx" ) + "mark";
2005 jQuery
._data( elem
, type
, (jQuery
._data( elem
, type
) || 0) + 1 );
2009 _unmark: function( force
, elem
, type
) {
2010 if ( force
!== true ) {
2016 type
= type
|| "fx";
2017 var key
= type
+ "mark",
2018 count
= force
? 0 : ( (jQuery
._data( elem
, key
) || 1) - 1 );
2020 jQuery
._data( elem
, key
, count
);
2022 jQuery
.removeData( elem
, key
, true );
2023 handleQueueMarkDefer( elem
, type
, "mark" );
2028 queue: function( elem
, type
, data
) {
2031 type
= ( type
|| "fx" ) + "queue";
2032 q
= jQuery
._data( elem
, type
);
2034 // Speed up dequeue by getting out quickly if this is just a lookup
2036 if ( !q
|| jQuery
.isArray(data
) ) {
2037 q
= jQuery
._data( elem
, type
, jQuery
.makeArray(data
) );
2046 dequeue: function( elem
, type
) {
2047 type
= type
|| "fx";
2049 var queue
= jQuery
.queue( elem
, type
),
2053 // If the fx queue is dequeued, always remove the progress sentinel
2054 if ( fn
=== "inprogress" ) {
2059 // Add a progress sentinel to prevent the fx queue from being
2060 // automatically dequeued
2061 if ( type
=== "fx" ) {
2062 queue
.unshift( "inprogress" );
2065 jQuery
._data( elem
, type
+ ".run", hooks
);
2066 fn
.call( elem
, function() {
2067 jQuery
.dequeue( elem
, type
);
2071 if ( !queue
.length
) {
2072 jQuery
.removeData( elem
, type
+ "queue " + type
+ ".run", true );
2073 handleQueueMarkDefer( elem
, type
, "queue" );
2079 queue: function( type
, data
) {
2080 if ( typeof type
!== "string" ) {
2085 if ( data
=== undefined ) {
2086 return jQuery
.queue( this[0], type
);
2088 return this.each(function() {
2089 var queue
= jQuery
.queue( this, type
, data
);
2091 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
2092 jQuery
.dequeue( this, type
);
2096 dequeue: function( type
) {
2097 return this.each(function() {
2098 jQuery
.dequeue( this, type
);
2101 // Based off of the plugin by Clint Helfers, with permission.
2102 // http://blindsignals.com/index.php/2009/07/jquery-delay/
2103 delay: function( time
, type
) {
2104 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time : time
;
2105 type
= type
|| "fx";
2107 return this.queue( type
, function( next
, hooks
) {
2108 var timeout
= setTimeout( next
, time
);
2109 hooks
.stop = function() {
2110 clearTimeout( timeout
);
2114 clearQueue: function( type
) {
2115 return this.queue( type
|| "fx", [] );
2117 // Get a promise resolved when queues of a certain type
2118 // are emptied (fx is the type by default)
2119 promise: function( type
, object
) {
2120 if ( typeof type
!== "string" ) {
2124 type
= type
|| "fx";
2125 var defer
= jQuery
.Deferred(),
2127 i
= elements
.length
,
2129 deferDataKey
= type
+ "defer",
2130 queueDataKey
= type
+ "queue",
2131 markDataKey
= type
+ "mark",
2133 function resolve() {
2134 if ( !( --count
) ) {
2135 defer
.resolveWith( elements
, [ elements
] );
2139 if (( tmp
= jQuery
.data( elements
[ i
], deferDataKey
, undefined, true ) ||
2140 ( jQuery
.data( elements
[ i
], queueDataKey
, undefined, true ) ||
2141 jQuery
.data( elements
[ i
], markDataKey
, undefined, true ) ) &&
2142 jQuery
.data( elements
[ i
], deferDataKey
, jQuery
.Callbacks( "once memory" ), true ) )) {
2148 return defer
.promise();
2155 var rclass
= /[\n\t\r]/g,
2158 rtype
= /^(?:button|input)$/i,
2159 rfocusable
= /^(?:button|input|object|select|textarea)$/i,
2160 rclickable
= /^a(?:rea)?$/i,
2161 rboolean
= /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2162 getSetAttribute
= jQuery
.support
.getSetAttribute
,
2163 nodeHook
, boolHook
, fixSpecified
;
2166 attr: function( name
, value
) {
2167 return jQuery
.access( this, name
, value
, true, jQuery
.attr
);
2170 removeAttr: function( name
) {
2171 return this.each(function() {
2172 jQuery
.removeAttr( this, name
);
2176 prop: function( name
, value
) {
2177 return jQuery
.access( this, name
, value
, true, jQuery
.prop
);
2180 removeProp: function( name
) {
2181 name
= jQuery
.propFix
[ name
] || name
;
2182 return this.each(function() {
2183 // try/catch handles cases where IE balks (such as removing a property on window)
2185 this[ name
] = undefined;
2186 delete this[ name
];
2191 addClass: function( value
) {
2192 var classNames
, i
, l
, elem
,
2195 if ( jQuery
.isFunction( value
) ) {
2196 return this.each(function( j
) {
2197 jQuery( this ).addClass( value
.call(this, j
, this.className
) );
2201 if ( value
&& typeof value
=== "string" ) {
2202 classNames
= value
.split( rspace
);
2204 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
2207 if ( elem
.nodeType
=== 1 ) {
2208 if ( !elem
.className
&& classNames
.length
=== 1 ) {
2209 elem
.className
= value
;
2212 setClass
= " " + elem
.className
+ " ";
2214 for ( c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
2215 if ( !~setClass
.indexOf( " " + classNames
[ c
] + " " ) ) {
2216 setClass
+= classNames
[ c
] + " ";
2219 elem
.className
= jQuery
.trim( setClass
);
2228 removeClass: function( value
) {
2229 var classNames
, i
, l
, elem
, className
, c
, cl
;
2231 if ( jQuery
.isFunction( value
) ) {
2232 return this.each(function( j
) {
2233 jQuery( this ).removeClass( value
.call(this, j
, this.className
) );
2237 if ( (value
&& typeof value
=== "string") || value
=== undefined ) {
2238 classNames
= ( value
|| "" ).split( rspace
);
2240 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
2243 if ( elem
.nodeType
=== 1 && elem
.className
) {
2245 className
= (" " + elem
.className
+ " ").replace( rclass
, " " );
2246 for ( c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
2247 className
= className
.replace(" " + classNames
[ c
] + " ", " ");
2249 elem
.className
= jQuery
.trim( className
);
2252 elem
.className
= "";
2261 toggleClass: function( value
, stateVal
) {
2262 var type
= typeof value
,
2263 isBool
= typeof stateVal
=== "boolean";
2265 if ( jQuery
.isFunction( value
) ) {
2266 return this.each(function( i
) {
2267 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
2271 return this.each(function() {
2272 if ( type
=== "string" ) {
2273 // toggle individual class names
2276 self
= jQuery( this ),
2278 classNames
= value
.split( rspace
);
2280 while ( (className
= classNames
[ i
++ ]) ) {
2281 // check each className given, space seperated list
2282 state
= isBool
? state : !self
.hasClass( className
);
2283 self
[ state
? "addClass" : "removeClass" ]( className
);
2286 } else if ( type
=== "undefined" || type
=== "boolean" ) {
2287 if ( this.className
) {
2288 // store className if set
2289 jQuery
._data( this, "__className__", this.className
);
2292 // toggle whole className
2293 this.className
= this.className
|| value
=== false ? "" : jQuery
._data( this, "__className__" ) || "";
2298 hasClass: function( selector
) {
2299 var className
= " " + selector
+ " ",
2302 for ( ; i
< l
; i
++ ) {
2303 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) > -1 ) {
2311 val: function( value
) {
2312 var hooks
, ret
, isFunction
,
2315 if ( !arguments
.length
) {
2317 hooks
= jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ] || jQuery
.valHooks
[ elem
.type
];
2319 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, "value" )) !== undefined ) {
2325 return typeof ret
=== "string" ?
2326 // handle most common string cases
2327 ret
.replace(rreturn
, "") :
2328 // handle cases where value is null/undef or number
2329 ret
== null ? "" : ret
;
2335 isFunction
= jQuery
.isFunction( value
);
2337 return this.each(function( i
) {
2338 var self
= jQuery(this), val
;
2340 if ( this.nodeType
!== 1 ) {
2345 val
= value
.call( this, i
, self
.val() );
2350 // Treat null/undefined as ""; convert numbers to string
2351 if ( val
== null ) {
2353 } else if ( typeof val
=== "number" ) {
2355 } else if ( jQuery
.isArray( val
) ) {
2356 val
= jQuery
.map(val
, function ( value
) {
2357 return value
== null ? "" : value
+ "";
2361 hooks
= jQuery
.valHooks
[ this.nodeName
.toLowerCase() ] || jQuery
.valHooks
[ this.type
];
2363 // If set returns undefined, fall back to normal setting
2364 if ( !hooks
|| !("set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
2374 get: function( elem
) {
2375 // attributes.value is undefined in Blackberry 4.7 but
2376 // uses .value. See #6932
2377 var val
= elem
.attributes
.value
;
2378 return !val
|| val
.specified
? elem
.value : elem
.text
;
2382 get: function( elem
) {
2383 var value
, i
, max
, option
,
2384 index
= elem
.selectedIndex
,
2386 options
= elem
.options
,
2387 one
= elem
.type
=== "select-one";
2389 // Nothing was selected
2394 // Loop through all the selected options
2395 i
= one
? index : 0;
2396 max
= one
? index
+ 1 : options
.length
;
2397 for ( ; i
< max
; i
++ ) {
2398 option
= options
[ i
];
2400 // Don't return options that are disabled or in a disabled optgroup
2401 if ( option
.selected
&& (jQuery
.support
.optDisabled
? !option
.disabled : option
.getAttribute("disabled") === null) &&
2402 (!option
.parentNode
.disabled
|| !jQuery
.nodeName( option
.parentNode
, "optgroup" )) ) {
2404 // Get the specific value for the option
2405 value
= jQuery( option
).val();
2407 // We don't need an array for one selects
2412 // Multi-Selects return an array
2413 values
.push( value
);
2417 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2418 if ( one
&& !values
.length
&& options
.length
) {
2419 return jQuery( options
[ index
] ).val();
2425 set: function( elem
, value
) {
2426 var values
= jQuery
.makeArray( value
);
2428 jQuery(elem
).find("option").each(function() {
2429 this.selected
= jQuery
.inArray( jQuery(this).val(), values
) >= 0;
2432 if ( !values
.length
) {
2433 elem
.selectedIndex
= -1;
2451 attr: function( elem
, name
, value
, pass
) {
2452 var ret
, hooks
, notxml
,
2453 nType
= elem
.nodeType
;
2455 // don't get/set attributes on text, comment and attribute nodes
2456 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
2460 if ( pass
&& name
in jQuery
.attrFn
) {
2461 return jQuery( elem
)[ name
]( value
);
2464 // Fallback to prop when attributes are not supported
2465 if ( typeof elem
.getAttribute
=== "undefined" ) {
2466 return jQuery
.prop( elem
, name
, value
);
2469 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
2471 // All attributes are lowercase
2472 // Grab necessary hook if one is defined
2474 name
= name
.toLowerCase();
2475 hooks
= jQuery
.attrHooks
[ name
] || ( rboolean
.test( name
) ? boolHook : nodeHook
);
2478 if ( value
!== undefined ) {
2480 if ( value
=== null ) {
2481 jQuery
.removeAttr( elem
, name
);
2484 } else if ( hooks
&& "set" in hooks
&& notxml
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
2488 elem
.setAttribute( name
, "" + value
);
2492 } else if ( hooks
&& "get" in hooks
&& notxml
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
2497 ret
= elem
.getAttribute( name
);
2499 // Non-existent attributes return null, we normalize to undefined
2500 return ret
=== null ?
2506 removeAttr: function( elem
, value
) {
2507 var propName
, attrNames
, name
, l
,
2510 if ( value
&& elem
.nodeType
=== 1 ) {
2511 attrNames
= value
.toLowerCase().split( rspace
);
2512 l
= attrNames
.length
;
2514 for ( ; i
< l
; i
++ ) {
2515 name
= attrNames
[ i
];
2518 propName
= jQuery
.propFix
[ name
] || name
;
2520 // See #9699 for explanation of this approach (setting first, then removal)
2521 jQuery
.attr( elem
, name
, "" );
2522 elem
.removeAttribute( getSetAttribute
? name : propName
);
2524 // Set corresponding property to false for boolean attributes
2525 if ( rboolean
.test( name
) && propName
in elem
) {
2526 elem
[ propName
] = false;
2535 set: function( elem
, value
) {
2536 // We can't allow the type property to be changed (since it causes problems in IE)
2537 if ( rtype
.test( elem
.nodeName
) && elem
.parentNode
) {
2538 jQuery
.error( "type property can't be changed" );
2539 } else if ( !jQuery
.support
.radioValue
&& value
=== "radio" && jQuery
.nodeName(elem
, "input") ) {
2540 // Setting the type on a radio button after the value resets the value in IE6-9
2541 // Reset value to it's default in case type is set after value
2542 // This is for element creation
2543 var val
= elem
.value
;
2544 elem
.setAttribute( "type", value
);
2552 // Use the value property for back compat
2553 // Use the nodeHook for button elements in IE6/7 (#1954)
2555 get: function( elem
, name
) {
2556 if ( nodeHook
&& jQuery
.nodeName( elem
, "button" ) ) {
2557 return nodeHook
.get( elem
, name
);
2559 return name
in elem
?
2563 set: function( elem
, value
, name
) {
2564 if ( nodeHook
&& jQuery
.nodeName( elem
, "button" ) ) {
2565 return nodeHook
.set( elem
, value
, name
);
2567 // Does not return so that setAttribute is also used
2574 tabindex: "tabIndex",
2575 readonly: "readOnly",
2577 "class": "className",
2578 maxlength: "maxLength",
2579 cellspacing: "cellSpacing",
2580 cellpadding: "cellPadding",
2584 frameborder: "frameBorder",
2585 contenteditable: "contentEditable"
2588 prop: function( elem
, name
, value
) {
2589 var ret
, hooks
, notxml
,
2590 nType
= elem
.nodeType
;
2592 // don't get/set properties on text, comment and attribute nodes
2593 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
2597 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
2600 // Fix name and attach hooks
2601 name
= jQuery
.propFix
[ name
] || name
;
2602 hooks
= jQuery
.propHooks
[ name
];
2605 if ( value
!== undefined ) {
2606 if ( hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
2610 return ( elem
[ name
] = value
);
2614 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
2618 return elem
[ name
];
2625 get: function( elem
) {
2626 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2627 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2628 var attributeNode
= elem
.getAttributeNode("tabindex");
2630 return attributeNode
&& attributeNode
.specified
?
2631 parseInt( attributeNode
.value
, 10 ) :
2632 rfocusable
.test( elem
.nodeName
) || rclickable
.test( elem
.nodeName
) && elem
.href
?
2640 // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
2641 jQuery
.attrHooks
.tabindex
= jQuery
.propHooks
.tabIndex
;
2643 // Hook for boolean attributes
2645 get: function( elem
, name
) {
2646 // Align boolean attributes with corresponding properties
2647 // Fall back to attribute presence where some booleans are not supported
2649 property
= jQuery
.prop( elem
, name
);
2650 return property
=== true || typeof property
!== "boolean" && ( attrNode
= elem
.getAttributeNode(name
) ) && attrNode
.nodeValue
!== false ?
2651 name
.toLowerCase() :
2654 set: function( elem
, value
, name
) {
2656 if ( value
=== false ) {
2657 // Remove boolean attributes when set to false
2658 jQuery
.removeAttr( elem
, name
);
2660 // value is true since we know at this point it's type boolean and not false
2661 // Set boolean attributes to the same name and set the DOM property
2662 propName
= jQuery
.propFix
[ name
] || name
;
2663 if ( propName
in elem
) {
2664 // Only set the IDL specifically if it already exists on the element
2665 elem
[ propName
] = true;
2668 elem
.setAttribute( name
, name
.toLowerCase() );
2674 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2675 if ( !getSetAttribute
) {
2682 // Use this for any attribute in IE6/7
2683 // This fixes almost every IE6/7 issue
2684 nodeHook
= jQuery
.valHooks
.button
= {
2685 get: function( elem
, name
) {
2687 ret
= elem
.getAttributeNode( name
);
2688 return ret
&& ( fixSpecified
[ name
] ? ret
.nodeValue
!== "" : ret
.specified
) ?
2692 set: function( elem
, value
, name
) {
2693 // Set the existing or create a new attribute node
2694 var ret
= elem
.getAttributeNode( name
);
2696 ret
= document
.createAttribute( name
);
2697 elem
.setAttributeNode( ret
);
2699 return ( ret
.nodeValue
= value
+ "" );
2703 // Apply the nodeHook to tabindex
2704 jQuery
.attrHooks
.tabindex
.set = nodeHook
.set;
2706 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2707 // This is for removals
2708 jQuery
.each([ "width", "height" ], function( i
, name
) {
2709 jQuery
.attrHooks
[ name
] = jQuery
.extend( jQuery
.attrHooks
[ name
], {
2710 set: function( elem
, value
) {
2711 if ( value
=== "" ) {
2712 elem
.setAttribute( name
, "auto" );
2719 // Set contenteditable to false on removals(#10429)
2720 // Setting to empty string throws an error as an invalid value
2721 jQuery
.attrHooks
.contenteditable
= {
2723 set: function( elem
, value
, name
) {
2724 if ( value
=== "" ) {
2727 nodeHook
.set( elem
, value
, name
);
2733 // Some attributes require a special call on IE
2734 if ( !jQuery
.support
.hrefNormalized
) {
2735 jQuery
.each([ "href", "src", "width", "height" ], function( i
, name
) {
2736 jQuery
.attrHooks
[ name
] = jQuery
.extend( jQuery
.attrHooks
[ name
], {
2737 get: function( elem
) {
2738 var ret
= elem
.getAttribute( name
, 2 );
2739 return ret
=== null ? undefined : ret
;
2745 if ( !jQuery
.support
.style
) {
2746 jQuery
.attrHooks
.style
= {
2747 get: function( elem
) {
2748 // Return undefined in the case of empty string
2749 // Normalize to lowercase since IE uppercases css property names
2750 return elem
.style
.cssText
.toLowerCase() || undefined;
2752 set: function( elem
, value
) {
2753 return ( elem
.style
.cssText
= "" + value
);
2758 // Safari mis-reports the default selected property of an option
2759 // Accessing the parent's selectedIndex property fixes it
2760 if ( !jQuery
.support
.optSelected
) {
2761 jQuery
.propHooks
.selected
= jQuery
.extend( jQuery
.propHooks
.selected
, {
2762 get: function( elem
) {
2763 var parent
= elem
.parentNode
;
2766 parent
.selectedIndex
;
2768 // Make sure that it also works with optgroups, see #5701
2769 if ( parent
.parentNode
) {
2770 parent
.parentNode
.selectedIndex
;
2778 // IE6/7 call enctype encoding
2779 if ( !jQuery
.support
.enctype
) {
2780 jQuery
.propFix
.enctype
= "encoding";
2783 // Radios and checkboxes getter/setter
2784 if ( !jQuery
.support
.checkOn
) {
2785 jQuery
.each([ "radio", "checkbox" ], function() {
2786 jQuery
.valHooks
[ this ] = {
2787 get: function( elem
) {
2788 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2789 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
2794 jQuery
.each([ "radio", "checkbox" ], function() {
2795 jQuery
.valHooks
[ this ] = jQuery
.extend( jQuery
.valHooks
[ this ], {
2796 set: function( elem
, value
) {
2797 if ( jQuery
.isArray( value
) ) {
2798 return ( elem
.checked
= jQuery
.inArray( jQuery(elem
).val(), value
) >= 0 );
2807 var rformElems
= /^(?:textarea|input|select)$/i,
2808 rtypenamespace
= /^([^\.]*)?(?:\.(.+))?$/,
2809 rhoverHack
= /\bhover(\.\S+)?\b/,
2811 rmouseEvent
= /^(?:mouse|contextmenu)|click/,
2812 rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
2813 rquickIs
= /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
2814 quickParse = function( selector
) {
2815 var quick
= rquickIs
.exec( selector
);
2818 // [ _, tag, id, class ]
2819 quick
[1] = ( quick
[1] || "" ).toLowerCase();
2820 quick
[3] = quick
[3] && new RegExp( "(?:^|\\s)" + quick
[3] + "(?:\\s|$)" );
2824 quickIs = function( elem
, m
) {
2825 var attrs
= elem
.attributes
|| {};
2827 (!m
[1] || elem
.nodeName
.toLowerCase() === m
[1]) &&
2828 (!m
[2] || (attrs
.id
|| {}).value
=== m
[2]) &&
2829 (!m
[3] || m
[3].test( (attrs
[ "class" ] || {}).value
))
2832 hoverHack = function( events
) {
2833 return jQuery
.event
.special
.hover
? events : events
.replace( rhoverHack
, "mouseenter$1 mouseleave$1" );
2837 * Helper functions for managing events -- not part of the public interface.
2838 * Props to Dean Edwards' addEvent library for many of the ideas.
2842 add: function( elem
, types
, handler
, data
, selector
) {
2844 var elemData
, eventHandle
, events
,
2845 t
, tns
, type
, namespaces
, handleObj
,
2846 handleObjIn
, quick
, handlers
, special
;
2848 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2849 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !types
|| !handler
|| !(elemData
= jQuery
._data( elem
)) ) {
2853 // Caller can pass in an object of custom data in lieu of the handler
2854 if ( handler
.handler
) {
2855 handleObjIn
= handler
;
2856 handler
= handleObjIn
.handler
;
2859 // Make sure that the handler has a unique ID, used to find/remove it later
2860 if ( !handler
.guid
) {
2861 handler
.guid
= jQuery
.guid
++;
2864 // Init the element's event structure and main handler, if this is the first
2865 events
= elemData
.events
;
2867 elemData
.events
= events
= {};
2869 eventHandle
= elemData
.handle
;
2870 if ( !eventHandle
) {
2871 elemData
.handle
= eventHandle = function( e
) {
2872 // Discard the second event of a jQuery.event.trigger() and
2873 // when an event is called after a page has unloaded
2874 return typeof jQuery
!== "undefined" && (!e
|| jQuery
.event
.triggered
!== e
.type
) ?
2875 jQuery
.event
.dispatch
.apply( eventHandle
.elem
, arguments
) :
2878 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2879 eventHandle
.elem
= elem
;
2882 // Handle multiple events separated by a space
2883 // jQuery(...).bind("mouseover mouseout", fn);
2884 types
= jQuery
.trim( hoverHack(types
) ).split( " " );
2885 for ( t
= 0; t
< types
.length
; t
++ ) {
2887 tns
= rtypenamespace
.exec( types
[t
] ) || [];
2889 namespaces
= ( tns
[2] || "" ).split( "." ).sort();
2891 // If event changes its type, use the special event handlers for the changed type
2892 special
= jQuery
.event
.special
[ type
] || {};
2894 // If selector defined, determine special event api type, otherwise given type
2895 type
= ( selector
? special
.delegateType : special
.bindType
) || type
;
2897 // Update special based on newly reset type
2898 special
= jQuery
.event
.special
[ type
] || {};
2900 // handleObj is passed to all event handlers
2901 handleObj
= jQuery
.extend({
2908 quick: quickParse( selector
),
2909 namespace: namespaces
.join(".")
2912 // Init the event handler queue if we're the first
2913 handlers
= events
[ type
];
2915 handlers
= events
[ type
] = [];
2916 handlers
.delegateCount
= 0;
2918 // Only use addEventListener/attachEvent if the special events handler returns false
2919 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
2920 // Bind the global event handler to the element
2921 if ( elem
.addEventListener
) {
2922 elem
.addEventListener( type
, eventHandle
, false );
2924 } else if ( elem
.attachEvent
) {
2925 elem
.attachEvent( "on" + type
, eventHandle
);
2930 if ( special
.add
) {
2931 special
.add
.call( elem
, handleObj
);
2933 if ( !handleObj
.handler
.guid
) {
2934 handleObj
.handler
.guid
= handler
.guid
;
2938 // Add to the element's handler list, delegates in front
2940 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
2942 handlers
.push( handleObj
);
2945 // Keep track of which events have ever been used, for event optimization
2946 jQuery
.event
.global
[ type
] = true;
2949 // Nullify elem to prevent memory leaks in IE
2955 // Detach an event or set of events from an element
2956 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
2958 var elemData
= jQuery
.hasData( elem
) && jQuery
._data( elem
),
2959 t
, tns
, type
, origType
, namespaces
, origCount
,
2960 j
, events
, special
, handle
, eventType
, handleObj
;
2962 if ( !elemData
|| !(events
= elemData
.events
) ) {
2966 // Once for each type.namespace in types; type may be omitted
2967 types
= jQuery
.trim( hoverHack( types
|| "" ) ).split(" ");
2968 for ( t
= 0; t
< types
.length
; t
++ ) {
2969 tns
= rtypenamespace
.exec( types
[t
] ) || [];
2970 type
= origType
= tns
[1];
2971 namespaces
= tns
[2];
2973 // Unbind all events (on this namespace, if provided) for the element
2975 for ( type
in events
) {
2976 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
2981 special
= jQuery
.event
.special
[ type
] || {};
2982 type
= ( selector
? special
.delegateType : special
.bindType
) || type
;
2983 eventType
= events
[ type
] || [];
2984 origCount
= eventType
.length
;
2985 namespaces
= namespaces
? new RegExp("(^|\\.)" + namespaces
.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
2987 // Remove matching events
2988 for ( j
= 0; j
< eventType
.length
; j
++ ) {
2989 handleObj
= eventType
[ j
];
2991 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
2992 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
2993 ( !namespaces
|| namespaces
.test( handleObj
.namespace ) ) &&
2994 ( !selector
|| selector
=== handleObj
.selector
|| selector
=== "**" && handleObj
.selector
) ) {
2995 eventType
.splice( j
--, 1 );
2997 if ( handleObj
.selector
) {
2998 eventType
.delegateCount
--;
3000 if ( special
.remove
) {
3001 special
.remove
.call( elem
, handleObj
);
3006 // Remove generic event handler if we removed something and no more handlers exist
3007 // (avoids potential for endless recursion during removal of special event handlers)
3008 if ( eventType
.length
=== 0 && origCount
!== eventType
.length
) {
3009 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
) === false ) {
3010 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
3013 delete events
[ type
];
3017 // Remove the expando if it's no longer used
3018 if ( jQuery
.isEmptyObject( events
) ) {
3019 handle
= elemData
.handle
;
3024 // removeData also checks for emptiness and clears the expando if empty
3025 // so use it instead of delete
3026 jQuery
.removeData( elem
, [ "events", "handle" ], true );
3030 // Events that are safe to short-circuit if no handlers are attached.
3031 // Native DOM events should not be added, they may have inline handlers.
3038 trigger: function( event
, data
, elem
, onlyHandlers
) {
3039 // Don't do events on text and comment nodes
3040 if ( elem
&& (elem
.nodeType
=== 3 || elem
.nodeType
=== 8) ) {
3044 // Event object or event type
3045 var type
= event
.type
|| event
,
3047 cache
, exclusive
, i
, cur
, old
, ontype
, special
, handle
, eventPath
, bubbleType
;
3049 // focus/blur morphs to focusin/out; ensure we're not firing them right now
3050 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
3054 if ( type
.indexOf( "!" ) >= 0 ) {
3055 // Exclusive events trigger only for the exact event (no namespaces)
3056 type
= type
.slice(0, -1);
3060 if ( type
.indexOf( "." ) >= 0 ) {
3061 // Namespaced trigger; create a regexp to match event type in handle()
3062 namespaces
= type
.split(".");
3063 type
= namespaces
.shift();
3067 if ( (!elem
|| jQuery
.event
.customEvent
[ type
]) && !jQuery
.event
.global
[ type
] ) {
3068 // No jQuery handlers for this event type, and it can't have inline handlers
3072 // Caller can pass in an Event, Object, or just an event type string
3073 event
= typeof event
=== "object" ?
3074 // jQuery.Event object
3075 event
[ jQuery
.expando
] ? event :
3077 new jQuery
.Event( type
, event
) :
3078 // Just the event type (string)
3079 new jQuery
.Event( type
);
3082 event
.isTrigger
= true;
3083 event
.exclusive
= exclusive
;
3084 event
.namespace = namespaces
.join( "." );
3085 event
.namespace_re
= event
.namespace? new RegExp("(^|\\.)" + namespaces
.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3086 ontype
= type
.indexOf( ":" ) < 0 ? "on" + type : "";
3088 // Handle a global trigger
3091 // TODO: Stop taunting the data cache; remove global events and always attach to document
3092 cache
= jQuery
.cache
;
3093 for ( i
in cache
) {
3094 if ( cache
[ i
].events
&& cache
[ i
].events
[ type
] ) {
3095 jQuery
.event
.trigger( event
, data
, cache
[ i
].handle
.elem
, true );
3101 // Clean up the event in case it is being reused
3102 event
.result
= undefined;
3103 if ( !event
.target
) {
3104 event
.target
= elem
;
3107 // Clone any incoming data and prepend the event, creating the handler arg list
3108 data
= data
!= null ? jQuery
.makeArray( data
) : [];
3109 data
.unshift( event
);
3111 // Allow special events to draw outside the lines
3112 special
= jQuery
.event
.special
[ type
] || {};
3113 if ( special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
3117 // Determine event propagation path in advance, per W3C events spec (#9951)
3118 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
3119 eventPath
= [[ elem
, special
.bindType
|| type
]];
3120 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
3122 bubbleType
= special
.delegateType
|| type
;
3123 cur
= rfocusMorph
.test( bubbleType
+ type
) ? elem : elem
.parentNode
;
3125 for ( ; cur
; cur
= cur
.parentNode
) {
3126 eventPath
.push([ cur
, bubbleType
]);
3130 // Only add window if we got to document (e.g., not plain obj or detached DOM)
3131 if ( old
&& old
=== elem
.ownerDocument
) {
3132 eventPath
.push([ old
.defaultView
|| old
.parentWindow
|| window
, bubbleType
]);
3136 // Fire handlers on the event path
3137 for ( i
= 0; i
< eventPath
.length
&& !event
.isPropagationStopped(); i
++ ) {
3139 cur
= eventPath
[i
][0];
3140 event
.type
= eventPath
[i
][1];
3142 handle
= ( jQuery
._data( cur
, "events" ) || {} )[ event
.type
] && jQuery
._data( cur
, "handle" );
3144 handle
.apply( cur
, data
);
3146 // Note that this is a bare JS function and not a jQuery handler
3147 handle
= ontype
&& cur
[ ontype
];
3148 if ( handle
&& jQuery
.acceptData( cur
) && handle
.apply( cur
, data
) === false ) {
3149 event
.preventDefault();
3154 // If nobody prevented the default action, do it now
3155 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
3157 if ( (!special
._default
|| special
._default
.apply( elem
.ownerDocument
, data
) === false) &&
3158 !(type
=== "click" && jQuery
.nodeName( elem
, "a" )) && jQuery
.acceptData( elem
) ) {
3160 // Call a native DOM method on the target with the same name name as the event.
3161 // Can't use an .isFunction() check here because IE6/7 fails that test.
3162 // Don't do default actions on window, that's where global variables be (#6170)
3163 // IE<9 dies on focus/blur to hidden element (#1486)
3164 if ( ontype
&& elem
[ type
] && ((type
!== "focus" && type
!== "blur") || event
.target
.offsetWidth
!== 0) && !jQuery
.isWindow( elem
) ) {
3166 // Don't re-trigger an onFOO event when we call its FOO() method
3167 old
= elem
[ ontype
];
3170 elem
[ ontype
] = null;
3173 // Prevent re-triggering of the same event, since we already bubbled it above
3174 jQuery
.event
.triggered
= type
;
3176 jQuery
.event
.triggered
= undefined;
3179 elem
[ ontype
] = old
;
3185 return event
.result
;
3188 dispatch: function( event
) {
3190 // Make a writable jQuery.Event from the native event object
3191 event
= jQuery
.event
.fix( event
|| window
.event
);
3193 var handlers
= ( (jQuery
._data( this, "events" ) || {} )[ event
.type
] || []),
3194 delegateCount
= handlers
.delegateCount
,
3195 args
= [].slice
.call( arguments
, 0 ),
3196 run_all
= !event
.exclusive
&& !event
.namespace,
3198 i
, j
, cur
, jqcur
, ret
, selMatch
, matched
, matches
, handleObj
, sel
, related
;
3200 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3202 event
.delegateTarget
= this;
3204 // Determine handlers that should run if there are delegated events
3205 // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
3206 if ( delegateCount
&& !event
.target
.disabled
&& !(event
.button
&& event
.type
=== "click") ) {
3208 // Pregenerate a single jQuery object for reuse with .is()
3209 jqcur
= jQuery(this);
3210 jqcur
.context
= this.ownerDocument
|| this;
3212 for ( cur
= event
.target
; cur
!= this; cur
= cur
.parentNode
|| this ) {
3216 for ( i
= 0; i
< delegateCount
; i
++ ) {
3217 handleObj
= handlers
[ i
];
3218 sel
= handleObj
.selector
;
3220 if ( selMatch
[ sel
] === undefined ) {
3222 handleObj
.quick
? quickIs( cur
, handleObj
.quick
) : jqcur
.is( sel
)
3225 if ( selMatch
[ sel
] ) {
3226 matches
.push( handleObj
);
3229 if ( matches
.length
) {
3230 handlerQueue
.push({ elem: cur
, matches: matches
});
3235 // Add the remaining (directly-bound) handlers
3236 if ( handlers
.length
> delegateCount
) {
3237 handlerQueue
.push({ elem: this, matches: handlers
.slice( delegateCount
) });
3240 // Run delegates first; they may want to stop propagation beneath us
3241 for ( i
= 0; i
< handlerQueue
.length
&& !event
.isPropagationStopped(); i
++ ) {
3242 matched
= handlerQueue
[ i
];
3243 event
.currentTarget
= matched
.elem
;
3245 for ( j
= 0; j
< matched
.matches
.length
&& !event
.isImmediatePropagationStopped(); j
++ ) {
3246 handleObj
= matched
.matches
[ j
];
3248 // Triggered event must either 1) be non-exclusive and have no namespace, or
3249 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3250 if ( run_all
|| (!event
.namespace && !handleObj
.namespace) || event
.namespace_re
&& event
.namespace_re
.test( handleObj
.namespace ) ) {
3252 event
.data
= handleObj
.data
;
3253 event
.handleObj
= handleObj
;
3255 ret
= ( (jQuery
.event
.special
[ handleObj
.origType
] || {}).handle
|| handleObj
.handler
)
3256 .apply( matched
.elem
, args
);
3258 if ( ret
!== undefined ) {
3260 if ( ret
=== false ) {
3261 event
.preventDefault();
3262 event
.stopPropagation();
3269 return event
.result
;
3272 // Includes some event props shared by KeyEvent and MouseEvent
3273 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3274 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3279 props: "char charCode key keyCode".split(" "),
3280 filter: function( event
, original
) {
3282 // Add which for key events
3283 if ( event
.which
== null ) {
3284 event
.which
= original
.charCode
!= null ? original
.charCode : original
.keyCode
;
3292 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3293 filter: function( event
, original
) {
3294 var eventDoc
, doc
, body
,
3295 button
= original
.button
,
3296 fromElement
= original
.fromElement
;
3298 // Calculate pageX/Y if missing and clientX/Y available
3299 if ( event
.pageX
== null && original
.clientX
!= null ) {
3300 eventDoc
= event
.target
.ownerDocument
|| document
;
3301 doc
= eventDoc
.documentElement
;
3302 body
= eventDoc
.body
;
3304 event
.pageX
= original
.clientX
+ ( doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0 ) - ( doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0 );
3305 event
.pageY
= original
.clientY
+ ( doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0 ) - ( doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0 );
3308 // Add relatedTarget, if necessary
3309 if ( !event
.relatedTarget
&& fromElement
) {
3310 event
.relatedTarget
= fromElement
=== event
.target
? original
.toElement : fromElement
;
3313 // Add which for click: 1 === left; 2 === middle; 3 === right
3314 // Note: button is not normalized, so don't use it
3315 if ( !event
.which
&& button
!== undefined ) {
3316 event
.which
= ( button
& 1 ? 1 : ( button
& 2 ? 3 : ( button
& 4 ? 2 : 0 ) ) );
3323 fix: function( event
) {
3324 if ( event
[ jQuery
.expando
] ) {
3328 // Create a writable copy of the event object and normalize some properties
3330 originalEvent
= event
,
3331 fixHook
= jQuery
.event
.fixHooks
[ event
.type
] || {},
3332 copy
= fixHook
.props
? this.props
.concat( fixHook
.props
) : this.props
;
3334 event
= jQuery
.Event( originalEvent
);
3336 for ( i
= copy
.length
; i
; ) {
3338 event
[ prop
] = originalEvent
[ prop
];
3341 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3342 if ( !event
.target
) {
3343 event
.target
= originalEvent
.srcElement
|| document
;
3346 // Target should not be a text node (#504, Safari)
3347 if ( event
.target
.nodeType
=== 3 ) {
3348 event
.target
= event
.target
.parentNode
;
3351 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
3352 if ( event
.metaKey
=== undefined ) {
3353 event
.metaKey
= event
.ctrlKey
;
3356 return fixHook
.filter
? fixHook
.filter( event
, originalEvent
) : event
;
3361 // Make sure the ready event is setup
3362 setup: jQuery
.bindReady
3366 // Prevent triggered image.load events from bubbling to window.load
3371 delegateType: "focusin"
3374 delegateType: "focusout"
3378 setup: function( data
, namespaces
, eventHandle
) {
3379 // We only want to do this special case on windows
3380 if ( jQuery
.isWindow( this ) ) {
3381 this.onbeforeunload
= eventHandle
;
3385 teardown: function( namespaces
, eventHandle
) {
3386 if ( this.onbeforeunload
=== eventHandle
) {
3387 this.onbeforeunload
= null;
3393 simulate: function( type
, elem
, event
, bubble
) {
3394 // Piggyback on a donor event to simulate a different one.
3395 // Fake originalEvent to avoid donor's stopPropagation, but if the
3396 // simulated event prevents default then we do the same on the donor.
3397 var e
= jQuery
.extend(
3406 jQuery
.event
.trigger( e
, null, elem
);
3408 jQuery
.event
.dispatch
.call( elem
, e
);
3410 if ( e
.isDefaultPrevented() ) {
3411 event
.preventDefault();
3416 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3417 // The 1.7 special event interface should provide all the hooks needed now.
3418 jQuery
.event
.handle
= jQuery
.event
.dispatch
;
3420 jQuery
.removeEvent
= document
.removeEventListener
?
3421 function( elem
, type
, handle
) {
3422 if ( elem
.removeEventListener
) {
3423 elem
.removeEventListener( type
, handle
, false );
3426 function( elem
, type
, handle
) {
3427 if ( elem
.detachEvent
) {
3428 elem
.detachEvent( "on" + type
, handle
);
3432 jQuery
.Event = function( src
, props
) {
3433 // Allow instantiation without the 'new' keyword
3434 if ( !(this instanceof jQuery
.Event
) ) {
3435 return new jQuery
.Event( src
, props
);
3439 if ( src
&& src
.type
) {
3440 this.originalEvent
= src
;
3441 this.type
= src
.type
;
3443 // Events bubbling up the document may have been marked as prevented
3444 // by a handler lower down the tree; reflect the correct value.
3445 this.isDefaultPrevented
= ( src
.defaultPrevented
|| src
.returnValue
=== false ||
3446 src
.getPreventDefault
&& src
.getPreventDefault() ) ? returnTrue : returnFalse
;
3453 // Put explicitly provided properties onto the event object
3455 jQuery
.extend( this, props
);
3458 // Create a timestamp if incoming event doesn't have one
3459 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
3462 this[ jQuery
.expando
] = true;
3465 function returnFalse() {
3468 function returnTrue() {
3472 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3473 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3474 jQuery
.Event
.prototype = {
3475 preventDefault: function() {
3476 this.isDefaultPrevented
= returnTrue
;
3478 var e
= this.originalEvent
;
3483 // if preventDefault exists run it on the original event
3484 if ( e
.preventDefault
) {
3487 // otherwise set the returnValue property of the original event to false (IE)
3489 e
.returnValue
= false;
3492 stopPropagation: function() {
3493 this.isPropagationStopped
= returnTrue
;
3495 var e
= this.originalEvent
;
3499 // if stopPropagation exists run it on the original event
3500 if ( e
.stopPropagation
) {
3501 e
.stopPropagation();
3503 // otherwise set the cancelBubble property of the original event to true (IE)
3504 e
.cancelBubble
= true;
3506 stopImmediatePropagation: function() {
3507 this.isImmediatePropagationStopped
= returnTrue
;
3508 this.stopPropagation();
3510 isDefaultPrevented: returnFalse
,
3511 isPropagationStopped: returnFalse
,
3512 isImmediatePropagationStopped: returnFalse
3515 // Create mouseenter/leave events using mouseover/out and event-time checks
3517 mouseenter: "mouseover",
3518 mouseleave: "mouseout"
3519 }, function( orig
, fix
) {
3520 jQuery
.event
.special
[ orig
] = {
3524 handle: function( event
) {
3526 related
= event
.relatedTarget
,
3527 handleObj
= event
.handleObj
,
3528 selector
= handleObj
.selector
,
3531 // For mousenter/leave call the handler if related is outside the target.
3532 // NB: No relatedTarget if the mouse left/entered the browser window
3533 if ( !related
|| (related
!== target
&& !jQuery
.contains( target
, related
)) ) {
3534 event
.type
= handleObj
.origType
;
3535 ret
= handleObj
.handler
.apply( this, arguments
);
3543 // IE submit delegation
3544 if ( !jQuery
.support
.submitBubbles
) {
3546 jQuery
.event
.special
.submit
= {
3548 // Only need this for delegated form submit events
3549 if ( jQuery
.nodeName( this, "form" ) ) {
3553 // Lazy-add a submit handler when a descendant form may potentially be submitted
3554 jQuery
.event
.add( this, "click._submit keypress._submit", function( e
) {
3555 // Node name check avoids a VML-related crash in IE (#9807)
3556 var elem
= e
.target
,
3557 form
= jQuery
.nodeName( elem
, "input" ) || jQuery
.nodeName( elem
, "button" ) ? elem
.form : undefined;
3558 if ( form
&& !form
._submit_attached
) {
3559 jQuery
.event
.add( form
, "submit._submit", function( event
) {
3560 // If form was submitted by the user, bubble the event up the tree
3561 if ( this.parentNode
&& !event
.isTrigger
) {
3562 jQuery
.event
.simulate( "submit", this.parentNode
, event
, true );
3565 form
._submit_attached
= true;
3568 // return undefined since we don't need an event listener
3571 teardown: function() {
3572 // Only need this for delegated form submit events
3573 if ( jQuery
.nodeName( this, "form" ) ) {
3577 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3578 jQuery
.event
.remove( this, "._submit" );
3583 // IE change delegation and checkbox/radio fix
3584 if ( !jQuery
.support
.changeBubbles
) {
3586 jQuery
.event
.special
.change
= {
3590 if ( rformElems
.test( this.nodeName
) ) {
3591 // IE doesn't fire change on a check/radio until blur; trigger it on click
3592 // after a propertychange. Eat the blur-change in special.change.handle.
3593 // This still fires onchange a second time for check/radio after blur.
3594 if ( this.type
=== "checkbox" || this.type
=== "radio" ) {
3595 jQuery
.event
.add( this, "propertychange._change", function( event
) {
3596 if ( event
.originalEvent
.propertyName
=== "checked" ) {
3597 this._just_changed
= true;
3600 jQuery
.event
.add( this, "click._change", function( event
) {
3601 if ( this._just_changed
&& !event
.isTrigger
) {
3602 this._just_changed
= false;
3603 jQuery
.event
.simulate( "change", this, event
, true );
3609 // Delegated event; lazy-add a change handler on descendant inputs
3610 jQuery
.event
.add( this, "beforeactivate._change", function( e
) {
3611 var elem
= e
.target
;
3613 if ( rformElems
.test( elem
.nodeName
) && !elem
._change_attached
) {
3614 jQuery
.event
.add( elem
, "change._change", function( event
) {
3615 if ( this.parentNode
&& !event
.isSimulated
&& !event
.isTrigger
) {
3616 jQuery
.event
.simulate( "change", this.parentNode
, event
, true );
3619 elem
._change_attached
= true;
3624 handle: function( event
) {
3625 var elem
= event
.target
;
3627 // Swallow native change events from checkbox/radio, we already triggered them above
3628 if ( this !== elem
|| event
.isSimulated
|| event
.isTrigger
|| (elem
.type
!== "radio" && elem
.type
!== "checkbox") ) {
3629 return event
.handleObj
.handler
.apply( this, arguments
);
3633 teardown: function() {
3634 jQuery
.event
.remove( this, "._change" );
3636 return rformElems
.test( this.nodeName
);
3641 // Create "bubbling" focus and blur events
3642 if ( !jQuery
.support
.focusinBubbles
) {
3643 jQuery
.each({ focus: "focusin", blur: "focusout" }, function( orig
, fix
) {
3645 // Attach a single capturing handler while someone wants focusin/focusout
3647 handler = function( event
) {
3648 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
), true );
3651 jQuery
.event
.special
[ fix
] = {
3653 if ( attaches
++ === 0 ) {
3654 document
.addEventListener( orig
, handler
, true );
3657 teardown: function() {
3658 if ( --attaches
=== 0 ) {
3659 document
.removeEventListener( orig
, handler
, true );
3668 on: function( types
, selector
, data
, fn
, /*INTERNAL*/ one
) {
3671 // Types can be a map of types/handlers
3672 if ( typeof types
=== "object" ) {
3673 // ( types-Object, selector, data )
3674 if ( typeof selector
!== "string" ) {
3675 // ( types-Object, data )
3677 selector
= undefined;
3679 for ( type
in types
) {
3680 this.on( type
, selector
, data
, types
[ type
], one
);
3685 if ( data
== null && fn
== null ) {
3688 data
= selector
= undefined;
3689 } else if ( fn
== null ) {
3690 if ( typeof selector
=== "string" ) {
3691 // ( types, selector, fn )
3695 // ( types, data, fn )
3698 selector
= undefined;
3701 if ( fn
=== false ) {
3709 fn = function( event
) {
3710 // Can use an empty set, since event contains the info
3711 jQuery().off( event
);
3712 return origFn
.apply( this, arguments
);
3714 // Use same guid so caller can remove using origFn
3715 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
3717 return this.each( function() {
3718 jQuery
.event
.add( this, types
, fn
, data
, selector
);
3721 one: function( types
, selector
, data
, fn
) {
3722 return this.on
.call( this, types
, selector
, data
, fn
, 1 );
3724 off: function( types
, selector
, fn
) {
3725 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
3726 // ( event ) dispatched jQuery.Event
3727 var handleObj
= types
.handleObj
;
3728 jQuery( types
.delegateTarget
).off(
3729 handleObj
.namespace? handleObj
.type
+ "." + handleObj
.namespace : handleObj
.type
,
3735 if ( typeof types
=== "object" ) {
3736 // ( types-object [, selector] )
3737 for ( var type
in types
) {
3738 this.off( type
, selector
, types
[ type
] );
3742 if ( selector
=== false || typeof selector
=== "function" ) {
3745 selector
= undefined;
3747 if ( fn
=== false ) {
3750 return this.each(function() {
3751 jQuery
.event
.remove( this, types
, fn
, selector
);
3755 bind: function( types
, data
, fn
) {
3756 return this.on( types
, null, data
, fn
);
3758 unbind: function( types
, fn
) {
3759 return this.off( types
, null, fn
);
3762 live: function( types
, data
, fn
) {
3763 jQuery( this.context
).on( types
, this.selector
, data
, fn
);
3766 die: function( types
, fn
) {
3767 jQuery( this.context
).off( types
, this.selector
|| "**", fn
);
3771 delegate: function( selector
, types
, data
, fn
) {
3772 return this.on( types
, selector
, data
, fn
);
3774 undelegate: function( selector
, types
, fn
) {
3775 // ( namespace ) or ( selector, types [, fn] )
3776 return arguments
.length
== 1? this.off( selector
, "**" ) : this.off( types
, selector
, fn
);
3779 trigger: function( type
, data
) {
3780 return this.each(function() {
3781 jQuery
.event
.trigger( type
, data
, this );
3784 triggerHandler: function( type
, data
) {
3786 return jQuery
.event
.trigger( type
, data
, this[0], true );
3790 toggle: function( fn
) {
3791 // Save reference to arguments for access in closure
3792 var args
= arguments
,
3793 guid
= fn
.guid
|| jQuery
.guid
++,
3795 toggler = function( event
) {
3796 // Figure out which function to execute
3797 var lastToggle
= ( jQuery
._data( this, "lastToggle" + fn
.guid
) || 0 ) % i
;
3798 jQuery
._data( this, "lastToggle" + fn
.guid
, lastToggle
+ 1 );
3800 // Make sure that clicks stop
3801 event
.preventDefault();
3803 // and execute the function
3804 return args
[ lastToggle
].apply( this, arguments
) || false;
3807 // link all the functions, so any of them can unbind this click handler
3808 toggler
.guid
= guid
;
3809 while ( i
< args
.length
) {
3810 args
[ i
++ ].guid
= guid
;
3813 return this.click( toggler
);
3816 hover: function( fnOver
, fnOut
) {
3817 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
3821 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3822 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3823 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i
, name
) {
3825 // Handle event binding
3826 jQuery
.fn
[ name
] = function( data
, fn
) {
3832 return arguments
.length
> 0 ?
3833 this.on( name
, null, data
, fn
) :
3834 this.trigger( name
);
3837 if ( jQuery
.attrFn
) {
3838 jQuery
.attrFn
[ name
] = true;
3841 if ( rkeyEvent
.test( name
) ) {
3842 jQuery
.event
.fixHooks
[ name
] = jQuery
.event
.keyHooks
;
3845 if ( rmouseEvent
.test( name
) ) {
3846 jQuery
.event
.fixHooks
[ name
] = jQuery
.event
.mouseHooks
;
3853 * Sizzle CSS Selector Engine
3854 * Copyright 2011, The Dojo Foundation
3855 * Released under the MIT, BSD, and GPL Licenses.
3856 * More information: http://sizzlejs.com/
3860 var chunker
= /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3861 expando = "sizcache" + (Math.random() + '').replace('.', ''),
3863 toString = Object.prototype.toString,
3864 hasDuplicate = false,
3865 baseHasDuplicate = true,
3870 // Here we check if the JavaScript engine is using some sort of
3871 // optimization where it does not always call our comparision
3872 // function. If that is the case, discard the hasDuplicate value.
3873 // Thus far that includes Google Chrome.
3874 [0, 0].sort(function() {
3875 baseHasDuplicate = false;
3879 var Sizzle = function( selector, context, results, seed ) {
3880 results = results || [];
3881 context = context || document;
3883 var origContext = context;
3885 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3889 if ( !selector || typeof selector !== "string" ) {
3893 var m, set, checkSet, extra, ret, cur, pop, i,
3895 contextXML = Sizzle.isXML( context ),
3899 // Reset the position of the chunker regexp (start from head)
3902 m = chunker.exec( soFar );
3916 if ( parts.length > 1 && origPOS.exec( selector ) ) {
3918 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3919 set = posProcess( parts[0] + parts[1], context, seed );
3922 set = Expr.relative[ parts[0] ] ?
3924 Sizzle( parts.shift(), context );
3926 while ( parts.length ) {
3927 selector = parts.shift();
3929 if ( Expr.relative[ selector ] ) {
3930 selector += parts.shift();
3933 set = posProcess( selector, set, seed );
3938 // Take a shortcut and set the context if the root selector is an ID
3939 // (but not if it'll be faster
if the inner selector is an ID
)
3940 if ( !seed
&& parts
.length
> 1 && context
.nodeType
=== 9 && !contextXML
&&
3941 Expr
.match
.ID
.test(parts
[0]) && !Expr
.match
.ID
.test(parts
[parts
.length
- 1]) ) {
3943 ret
= Sizzle
.find( parts
.shift(), context
, contextXML
);
3944 context
= ret
.expr
?
3945 Sizzle
.filter( ret
.expr
, ret
.set )[0] :
3951 { expr: parts
.pop(), set: makeArray(seed
) } :
3952 Sizzle
.find( parts
.pop(), parts
.length
=== 1 && (parts
[0] === "~" || parts
[0] === "+") && context
.parentNode
? context
.parentNode : context
, contextXML
);
3955 Sizzle
.filter( ret
.expr
, ret
.set ) :
3958 if ( parts
.length
> 0 ) {
3959 checkSet
= makeArray( set );
3965 while ( parts
.length
) {
3969 if ( !Expr
.relative
[ cur
] ) {
3975 if ( pop
== null ) {
3979 Expr
.relative
[ cur
]( checkSet
, pop
, contextXML
);
3983 checkSet
= parts
= [];
3992 Sizzle
.error( cur
|| selector
);
3995 if ( toString
.call(checkSet
) === "[object Array]" ) {
3997 results
.push
.apply( results
, checkSet
);
3999 } else if ( context
&& context
.nodeType
=== 1 ) {
4000 for ( i
= 0; checkSet
[i
] != null; i
++ ) {
4001 if ( checkSet
[i
] && (checkSet
[i
] === true || checkSet
[i
].nodeType
=== 1 && Sizzle
.contains(context
, checkSet
[i
])) ) {
4002 results
.push( set[i
] );
4007 for ( i
= 0; checkSet
[i
] != null; i
++ ) {
4008 if ( checkSet
[i
] && checkSet
[i
].nodeType
=== 1 ) {
4009 results
.push( set[i
] );
4015 makeArray( checkSet
, results
);
4019 Sizzle( extra
, origContext
, results
, seed
);
4020 Sizzle
.uniqueSort( results
);
4026 Sizzle
.uniqueSort = function( results
) {
4028 hasDuplicate
= baseHasDuplicate
;
4029 results
.sort( sortOrder
);
4031 if ( hasDuplicate
) {
4032 for ( var i
= 1; i
< results
.length
; i
++ ) {
4033 if ( results
[i
] === results
[ i
- 1 ] ) {
4034 results
.splice( i
--, 1 );
4043 Sizzle
.matches = function( expr
, set ) {
4044 return Sizzle( expr
, null, null, set );
4047 Sizzle
.matchesSelector = function( node
, expr
) {
4048 return Sizzle( expr
, null, null, [node
] ).length
> 0;
4051 Sizzle
.find = function( expr
, context
, isXML
) {
4052 var set, i
, len
, match
, type
, left
;
4058 for ( i
= 0, len
= Expr
.order
.length
; i
< len
; i
++ ) {
4059 type
= Expr
.order
[i
];
4061 if ( (match
= Expr
.leftMatch
[ type
].exec( expr
)) ) {
4063 match
.splice( 1, 1 );
4065 if ( left
.substr( left
.length
- 1 ) !== "\\" ) {
4066 match
[1] = (match
[1] || "").replace( rBackslash
, "" );
4067 set = Expr
.find
[ type
]( match
, context
, isXML
);
4069 if ( set != null ) {
4070 expr
= expr
.replace( Expr
.match
[ type
], "" );
4078 set = typeof context
.getElementsByTagName
!== "undefined" ?
4079 context
.getElementsByTagName( "*" ) :
4083 return { set: set, expr: expr
};
4086 Sizzle
.filter = function( expr
, set, inplace
, not
) {
4087 var match
, anyFound
,
4088 type
, found
, item
, filter
, left
,
4093 isXMLFilter
= set && set[0] && Sizzle
.isXML( set[0] );
4095 while ( expr
&& set.length
) {
4096 for ( type
in Expr
.filter
) {
4097 if ( (match
= Expr
.leftMatch
[ type
].exec( expr
)) != null && match
[2] ) {
4098 filter
= Expr
.filter
[ type
];
4105 if ( left
.substr( left
.length
- 1 ) === "\\" ) {
4109 if ( curLoop
=== result
) {
4113 if ( Expr
.preFilter
[ type
] ) {
4114 match
= Expr
.preFilter
[ type
]( match
, curLoop
, inplace
, result
, not
, isXMLFilter
);
4117 anyFound
= found
= true;
4119 } else if ( match
=== true ) {
4125 for ( i
= 0; (item
= curLoop
[i
]) != null; i
++ ) {
4127 found
= filter( item
, match
, i
, curLoop
);
4130 if ( inplace
&& found
!= null ) {
4138 } else if ( pass
) {
4139 result
.push( item
);
4146 if ( found
!== undefined ) {
4151 expr
= expr
.replace( Expr
.match
[ type
], "" );
4162 // Improper expression
4163 if ( expr
=== old
) {
4164 if ( anyFound
== null ) {
4165 Sizzle
.error( expr
);
4178 Sizzle
.error = function( msg
) {
4179 throw new Error( "Syntax error, unrecognized expression: " + msg
);
4183 * Utility function for retreiving the text value of an array of DOM nodes
4184 * @param {Array|Element} elem
4186 var getText
= Sizzle
.getText = function( elem
) {
4188 nodeType
= elem
.nodeType
,
4192 if ( nodeType
=== 1 || nodeType
=== 9 ) {
4193 // Use textContent || innerText for elements
4194 if ( typeof elem
.textContent
=== 'string' ) {
4195 return elem
.textContent
;
4196 } else if ( typeof elem
.innerText
=== 'string' ) {
4197 // Replace IE's carriage returns
4198 return elem
.innerText
.replace( rReturn
, '' );
4200 // Traverse it's children
4201 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
4202 ret
+= getText( elem
);
4205 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
4206 return elem
.nodeValue
;
4210 // If no nodeType, this is expected to be an array
4211 for ( i
= 0; (node
= elem
[i
]); i
++ ) {
4212 // Do not traverse comment nodes
4213 if ( node
.nodeType
!== 8 ) {
4214 ret
+= getText( node
);
4221 var Expr
= Sizzle
.selectors
= {
4222 order: [ "ID", "NAME", "TAG" ],
4225 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4226 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4227 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4228 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4229 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4230 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4231 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4232 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4238 "class": "className",
4243 href: function( elem
) {
4244 return elem
.getAttribute( "href" );
4246 type: function( elem
) {
4247 return elem
.getAttribute( "type" );
4252 "+": function(checkSet
, part
){
4253 var isPartStr
= typeof part
=== "string",
4254 isTag
= isPartStr
&& !rNonWord
.test( part
),
4255 isPartStrNotTag
= isPartStr
&& !isTag
;
4258 part
= part
.toLowerCase();
4261 for ( var i
= 0, l
= checkSet
.length
, elem
; i
< l
; i
++ ) {
4262 if ( (elem
= checkSet
[i
]) ) {
4263 while ( (elem
= elem
.previousSibling
) && elem
.nodeType
!== 1 ) {}
4265 checkSet
[i
] = isPartStrNotTag
|| elem
&& elem
.nodeName
.toLowerCase() === part
?
4271 if ( isPartStrNotTag
) {
4272 Sizzle
.filter( part
, checkSet
, true );
4276 ">": function( checkSet
, part
) {
4278 isPartStr
= typeof part
=== "string",
4280 l
= checkSet
.length
;
4282 if ( isPartStr
&& !rNonWord
.test( part
) ) {
4283 part
= part
.toLowerCase();
4285 for ( ; i
< l
; i
++ ) {
4289 var parent
= elem
.parentNode
;
4290 checkSet
[i
] = parent
.nodeName
.toLowerCase() === part
? parent : false;
4295 for ( ; i
< l
; i
++ ) {
4299 checkSet
[i
] = isPartStr
?
4301 elem
.parentNode
=== part
;
4306 Sizzle
.filter( part
, checkSet
, true );
4311 "": function(checkSet
, part
, isXML
){
4316 if ( typeof part
=== "string" && !rNonWord
.test( part
) ) {
4317 part
= part
.toLowerCase();
4319 checkFn
= dirNodeCheck
;
4322 checkFn( "parentNode", part
, doneName
, checkSet
, nodeCheck
, isXML
);
4325 "~": function( checkSet
, part
, isXML
) {
4330 if ( typeof part
=== "string" && !rNonWord
.test( part
) ) {
4331 part
= part
.toLowerCase();
4333 checkFn
= dirNodeCheck
;
4336 checkFn( "previousSibling", part
, doneName
, checkSet
, nodeCheck
, isXML
);
4341 ID: function( match
, context
, isXML
) {
4342 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
4343 var m
= context
.getElementById(match
[1]);
4344 // Check parentNode to catch when Blackberry 4.6 returns
4345 // nodes that are no longer in the document #6963
4346 return m
&& m
.parentNode
? [m
] : [];
4350 NAME: function( match
, context
) {
4351 if ( typeof context
.getElementsByName
!== "undefined" ) {
4353 results
= context
.getElementsByName( match
[1] );
4355 for ( var i
= 0, l
= results
.length
; i
< l
; i
++ ) {
4356 if ( results
[i
].getAttribute("name") === match
[1] ) {
4357 ret
.push( results
[i
] );
4361 return ret
.length
=== 0 ? null : ret
;
4365 TAG: function( match
, context
) {
4366 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
4367 return context
.getElementsByTagName( match
[1] );
4372 CLASS: function( match
, curLoop
, inplace
, result
, not
, isXML
) {
4373 match
= " " + match
[1].replace( rBackslash
, "" ) + " ";
4379 for ( var i
= 0, elem
; (elem
= curLoop
[i
]) != null; i
++ ) {
4381 if ( not
^ (elem
.className
&& (" " + elem
.className
+ " ").replace(/[\t\n\r]/g, " ").indexOf(match
) >= 0) ) {
4383 result
.push( elem
);
4386 } else if ( inplace
) {
4395 ID: function( match
) {
4396 return match
[1].replace( rBackslash
, "" );
4399 TAG: function( match
, curLoop
) {
4400 return match
[1].replace( rBackslash
, "" ).toLowerCase();
4403 CHILD: function( match
) {
4404 if ( match
[1] === "nth" ) {
4406 Sizzle
.error( match
[0] );
4409 match
[2] = match
[2].replace(/^\+|\s*/g, '');
4411 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4412 var test
= /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4413 match
[2] === "even" && "2n" || match
[2] === "odd" && "2n+1" ||
4414 !/\D/.test( match
[2] ) && "0n+" + match
[2] || match
[2]);
4416 // calculate the numbers (first)n+(last) including if they are negative
4417 match
[2] = (test
[1] + (test
[2] || 1)) - 0;
4418 match
[3] = test
[3] - 0;
4420 else if ( match
[2] ) {
4421 Sizzle
.error( match
[0] );
4424 // TODO: Move to normal caching system
4430 ATTR: function( match
, curLoop
, inplace
, result
, not
, isXML
) {
4431 var name
= match
[1] = match
[1].replace( rBackslash
, "" );
4433 if ( !isXML
&& Expr
.attrMap
[name
] ) {
4434 match
[1] = Expr
.attrMap
[name
];
4437 // Handle if an un-quoted value was used
4438 match
[4] = ( match
[4] || match
[5] || "" ).replace( rBackslash
, "" );
4440 if ( match
[2] === "~=" ) {
4441 match
[4] = " " + match
[4] + " ";
4447 PSEUDO: function( match
, curLoop
, inplace
, result
, not
) {
4448 if ( match
[1] === "not" ) {
4449 // If we're dealing with a complex expression, or a simple one
4450 if ( ( chunker
.exec(match
[3]) || "" ).length
> 1 || /^\w/.test(match
[3]) ) {
4451 match
[3] = Sizzle(match
[3], null, null, curLoop
);
4454 var ret
= Sizzle
.filter(match
[3], curLoop
, inplace
, true ^ not
);
4457 result
.push
.apply( result
, ret
);
4463 } else if ( Expr
.match
.POS
.test( match
[0] ) || Expr
.match
.CHILD
.test( match
[0] ) ) {
4470 POS: function( match
) {
4471 match
.unshift( true );
4478 enabled: function( elem
) {
4479 return elem
.disabled
=== false && elem
.type
!== "hidden";
4482 disabled: function( elem
) {
4483 return elem
.disabled
=== true;
4486 checked: function( elem
) {
4487 return elem
.checked
=== true;
4490 selected: function( elem
) {
4491 // Accessing this property makes selected-by-default
4492 // options in Safari work properly
4493 if ( elem
.parentNode
) {
4494 elem
.parentNode
.selectedIndex
;
4497 return elem
.selected
=== true;
4500 parent: function( elem
) {
4501 return !!elem
.firstChild
;
4504 empty: function( elem
) {
4505 return !elem
.firstChild
;
4508 has: function( elem
, i
, match
) {
4509 return !!Sizzle( match
[3], elem
).length
;
4512 header: function( elem
) {
4513 return (/h\d/i).test( elem
.nodeName
);
4516 text: function( elem
) {
4517 var attr
= elem
.getAttribute( "type" ), type
= elem
.type
;
4518 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4519 // use getAttribute instead to test this case
4520 return elem
.nodeName
.toLowerCase() === "input" && "text" === type
&& ( attr
=== type
|| attr
=== null );
4523 radio: function( elem
) {
4524 return elem
.nodeName
.toLowerCase() === "input" && "radio" === elem
.type
;
4527 checkbox: function( elem
) {
4528 return elem
.nodeName
.toLowerCase() === "input" && "checkbox" === elem
.type
;
4531 file: function( elem
) {
4532 return elem
.nodeName
.toLowerCase() === "input" && "file" === elem
.type
;
4535 password: function( elem
) {
4536 return elem
.nodeName
.toLowerCase() === "input" && "password" === elem
.type
;
4539 submit: function( elem
) {
4540 var name
= elem
.nodeName
.toLowerCase();
4541 return (name
=== "input" || name
=== "button") && "submit" === elem
.type
;
4544 image: function( elem
) {
4545 return elem
.nodeName
.toLowerCase() === "input" && "image" === elem
.type
;
4548 reset: function( elem
) {
4549 var name
= elem
.nodeName
.toLowerCase();
4550 return (name
=== "input" || name
=== "button") && "reset" === elem
.type
;
4553 button: function( elem
) {
4554 var name
= elem
.nodeName
.toLowerCase();
4555 return name
=== "input" && "button" === elem
.type
|| name
=== "button";
4558 input: function( elem
) {
4559 return (/input|select|textarea|button/i).test( elem
.nodeName
);
4562 focus: function( elem
) {
4563 return elem
=== elem
.ownerDocument
.activeElement
;
4567 first: function( elem
, i
) {
4571 last: function( elem
, i
, match
, array
) {
4572 return i
=== array
.length
- 1;
4575 even: function( elem
, i
) {
4579 odd: function( elem
, i
) {
4583 lt: function( elem
, i
, match
) {
4584 return i
< match
[3] - 0;
4587 gt: function( elem
, i
, match
) {
4588 return i
> match
[3] - 0;
4591 nth: function( elem
, i
, match
) {
4592 return match
[3] - 0 === i
;
4595 eq: function( elem
, i
, match
) {
4596 return match
[3] - 0 === i
;
4600 PSEUDO: function( elem
, match
, i
, array
) {
4601 var name
= match
[1],
4602 filter
= Expr
.filters
[ name
];
4605 return filter( elem
, i
, match
, array
);
4607 } else if ( name
=== "contains" ) {
4608 return (elem
.textContent
|| elem
.innerText
|| getText([ elem
]) || "").indexOf(match
[3]) >= 0;
4610 } else if ( name
=== "not" ) {
4613 for ( var j
= 0, l
= not
.length
; j
< l
; j
++ ) {
4614 if ( not
[j
] === elem
) {
4622 Sizzle
.error( name
);
4626 CHILD: function( elem
, match
) {
4628 doneName
, parent
, cache
,
4636 while ( (node
= node
.previousSibling
) ) {
4637 if ( node
.nodeType
=== 1 ) {
4642 if ( type
=== "first" ) {
4649 while ( (node
= node
.nextSibling
) ) {
4650 if ( node
.nodeType
=== 1 ) {
4661 if ( first
=== 1 && last
=== 0 ) {
4665 doneName
= match
[0];
4666 parent
= elem
.parentNode
;
4668 if ( parent
&& (parent
[ expando
] !== doneName
|| !elem
.nodeIndex
) ) {
4671 for ( node
= parent
.firstChild
; node
; node
= node
.nextSibling
) {
4672 if ( node
.nodeType
=== 1 ) {
4673 node
.nodeIndex
= ++count
;
4677 parent
[ expando
] = doneName
;
4680 diff
= elem
.nodeIndex
- last
;
4682 if ( first
=== 0 ) {
4686 return ( diff
% first
=== 0 && diff
/ first
>= 0 );
4691 ID: function( elem
, match
) {
4692 return elem
.nodeType
=== 1 && elem
.getAttribute("id") === match
;
4695 TAG: function( elem
, match
) {
4696 return (match
=== "*" && elem
.nodeType
=== 1) || !!elem
.nodeName
&& elem
.nodeName
.toLowerCase() === match
;
4699 CLASS: function( elem
, match
) {
4700 return (" " + (elem
.className
|| elem
.getAttribute("class")) + " ")
4701 .indexOf( match
) > -1;
4704 ATTR: function( elem
, match
) {
4705 var name
= match
[1],
4706 result
= Sizzle
.attr
?
4707 Sizzle
.attr( elem
, name
) :
4708 Expr
.attrHandle
[ name
] ?
4709 Expr
.attrHandle
[ name
]( elem
) :
4710 elem
[ name
] != null ?
4712 elem
.getAttribute( name
),
4713 value
= result
+ "",
4717 return result
== null ?
4719 !type
&& Sizzle
.attr
?
4724 value
.indexOf(check
) >= 0 :
4726 (" " + value
+ " ").indexOf(check
) >= 0 :
4728 value
&& result
!== false :
4732 value
.indexOf(check
) === 0 :
4734 value
.substr(value
.length
- check
.length
) === check :
4736 value
=== check
|| value
.substr(0, check
.length
+ 1) === check
+ "-" :
4740 POS: function( elem
, match
, i
, array
) {
4741 var name
= match
[2],
4742 filter
= Expr
.setFilters
[ name
];
4745 return filter( elem
, i
, match
, array
);
4751 var origPOS
= Expr
.match
.POS
,
4752 fescape = function(all
, num
){
4753 return "\\" + (num
- 0 + 1);
4756 for ( var type
in Expr
.match
) {
4757 Expr
.match
[ type
] = new RegExp( Expr
.match
[ type
].source
+ (/(?![^\[]*\])(?![^\(]*\))/.source
) );
4758 Expr
.leftMatch
[ type
] = new RegExp( /(^(?:.|\r|\n)*?)/.source
+ Expr
.match
[ type
].source
.replace(/\\(\d+)/g, fescape
) );
4761 var makeArray = function( array
, results
) {
4762 array
= Array
.prototype.slice
.call( array
, 0 );
4765 results
.push
.apply( results
, array
);
4772 // Perform a simple check to determine if the browser is capable of
4773 // converting a NodeList to an array using builtin methods.
4774 // Also verifies that the returned array holds DOM nodes
4775 // (which is not the case in the Blackberry browser)
4777 Array
.prototype.slice
.call( document
.documentElement
.childNodes
, 0 )[0].nodeType
;
4779 // Provide a fallback method if it does not work
4781 makeArray = function( array
, results
) {
4783 ret
= results
|| [];
4785 if ( toString
.call(array
) === "[object Array]" ) {
4786 Array
.prototype.push
.apply( ret
, array
);
4789 if ( typeof array
.length
=== "number" ) {
4790 for ( var l
= array
.length
; i
< l
; i
++ ) {
4791 ret
.push( array
[i
] );
4795 for ( ; array
[i
]; i
++ ) {
4796 ret
.push( array
[i
] );
4805 var sortOrder
, siblingCheck
;
4807 if ( document
.documentElement
.compareDocumentPosition
) {
4808 sortOrder = function( a
, b
) {
4810 hasDuplicate
= true;
4814 if ( !a
.compareDocumentPosition
|| !b
.compareDocumentPosition
) {
4815 return a
.compareDocumentPosition
? -1 : 1;
4818 return a
.compareDocumentPosition(b
) & 4 ? -1 : 1;
4822 sortOrder = function( a
, b
) {
4823 // The nodes are identical, we can exit early
4825 hasDuplicate
= true;
4828 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4829 } else if ( a
.sourceIndex
&& b
.sourceIndex
) {
4830 return a
.sourceIndex
- b
.sourceIndex
;
4840 // If the nodes are siblings (or identical) we can do a quick check
4841 if ( aup
=== bup
) {
4842 return siblingCheck( a
, b
);
4844 // If no parents were found then the nodes are disconnected
4845 } else if ( !aup
) {
4848 } else if ( !bup
) {
4852 // Otherwise they're somewhere else in the tree so we need
4853 // to build up a full list of the parentNodes for comparison
4856 cur
= cur
.parentNode
;
4863 cur
= cur
.parentNode
;
4869 // Start walking down the tree looking for a discrepancy
4870 for ( var i
= 0; i
< al
&& i
< bl
; i
++ ) {
4871 if ( ap
[i
] !== bp
[i
] ) {
4872 return siblingCheck( ap
[i
], bp
[i
] );
4876 // We ended someplace up the tree so do a sibling check
4878 siblingCheck( a
, bp
[i
], -1 ) :
4879 siblingCheck( ap
[i
], b
, 1 );
4882 siblingCheck = function( a
, b
, ret
) {
4887 var cur
= a
.nextSibling
;
4894 cur
= cur
.nextSibling
;
4901 // Check to see if the browser returns elements by name when
4902 // querying by getElementById (and provide a workaround)
4904 // We're going to inject a fake input element with a specified name
4905 var form
= document
.createElement("div"),
4906 id
= "script" + (new Date()).getTime(),
4907 root
= document
.documentElement
;
4909 form
.innerHTML
= "<a name='" + id
+ "'/>";
4911 // Inject it into the root element, check its status, and remove it quickly
4912 root
.insertBefore( form
, root
.firstChild
);
4914 // The workaround has to do additional checks after a getElementById
4915 // Which slows things down for other browsers (hence the branching)
4916 if ( document
.getElementById( id
) ) {
4917 Expr
.find
.ID = function( match
, context
, isXML
) {
4918 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
4919 var m
= context
.getElementById(match
[1]);
4922 m
.id
=== match
[1] || typeof m
.getAttributeNode
!== "undefined" && m
.getAttributeNode("id").nodeValue
=== match
[1] ?
4929 Expr
.filter
.ID = function( elem
, match
) {
4930 var node
= typeof elem
.getAttributeNode
!== "undefined" && elem
.getAttributeNode("id");
4932 return elem
.nodeType
=== 1 && node
&& node
.nodeValue
=== match
;
4936 root
.removeChild( form
);
4938 // release memory in IE
4943 // Check to see if the browser returns only elements
4944 // when doing getElementsByTagName("*")
4946 // Create a fake element
4947 var div
= document
.createElement("div");
4948 div
.appendChild( document
.createComment("") );
4950 // Make sure no comments are found
4951 if ( div
.getElementsByTagName("*").length
> 0 ) {
4952 Expr
.find
.TAG = function( match
, context
) {
4953 var results
= context
.getElementsByTagName( match
[1] );
4955 // Filter out possible comments
4956 if ( match
[1] === "*" ) {
4959 for ( var i
= 0; results
[i
]; i
++ ) {
4960 if ( results
[i
].nodeType
=== 1 ) {
4961 tmp
.push( results
[i
] );
4972 // Check to see if an attribute returns normalized href attributes
4973 div
.innerHTML
= "<a href='#'></a>";
4975 if ( div
.firstChild
&& typeof div
.firstChild
.getAttribute
!== "undefined" &&
4976 div
.firstChild
.getAttribute("href") !== "#" ) {
4978 Expr
.attrHandle
.href = function( elem
) {
4979 return elem
.getAttribute( "href", 2 );
4983 // release memory in IE
4987 if ( document
.querySelectorAll
) {
4989 var oldSizzle
= Sizzle
,
4990 div
= document
.createElement("div"),
4993 div
.innerHTML
= "<p class='TEST'></p>";
4995 // Safari can't handle uppercase or unicode characters when
4997 if ( div
.querySelectorAll
&& div
.querySelectorAll(".TEST").length
=== 0 ) {
5001 Sizzle = function( query
, context
, extra
, seed
) {
5002 context
= context
|| document
;
5004 // Only use querySelectorAll on non-XML documents
5005 // (ID selectors don't work in non-HTML documents)
5006 if ( !seed
&& !Sizzle
.isXML(context
) ) {
5007 // See if we find a selector to speed up
5008 var match
= /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query
);
5010 if ( match
&& (context
.nodeType
=== 1 || context
.nodeType
=== 9) ) {
5011 // Speed-up: Sizzle("TAG")
5013 return makeArray( context
.getElementsByTagName( query
), extra
);
5015 // Speed-up: Sizzle(".CLASS")
5016 } else if ( match
[2] && Expr
.find
.CLASS
&& context
.getElementsByClassName
) {
5017 return makeArray( context
.getElementsByClassName( match
[2] ), extra
);
5021 if ( context
.nodeType
=== 9 ) {
5022 // Speed-up: Sizzle("body")
5023 // The body element only exists once, optimize finding it
5024 if ( query
=== "body" && context
.body
) {
5025 return makeArray( [ context
.body
], extra
);
5027 // Speed-up: Sizzle("#ID")
5028 } else if ( match
&& match
[3] ) {
5029 var elem
= context
.getElementById( match
[3] );
5031 // Check parentNode to catch when Blackberry 4.6 returns
5032 // nodes that are no longer in the document #6963
5033 if ( elem
&& elem
.parentNode
) {
5034 // Handle the case where IE and Opera return items
5035 // by name instead of ID
5036 if ( elem
.id
=== match
[3] ) {
5037 return makeArray( [ elem
], extra
);
5041 return makeArray( [], extra
);
5046 return makeArray( context
.querySelectorAll(query
), extra
);
5047 } catch(qsaError
) {}
5049 // qSA works strangely on Element-rooted queries
5050 // We can work around this by specifying an extra ID on the root
5051 // and working up from there (Thanks to Andrew Dupont for the technique)
5052 // IE 8 doesn't work on object elements
5053 } else if ( context
.nodeType
=== 1 && context
.nodeName
.toLowerCase() !== "object" ) {
5054 var oldContext
= context
,
5055 old
= context
.getAttribute( "id" ),
5057 hasParent
= context
.parentNode
,
5058 relativeHierarchySelector
= /^\s*[+~]/.test( query
);
5061 context
.setAttribute( "id", nid
);
5063 nid
= nid
.replace( /'/g, "\\$&" );
5065 if ( relativeHierarchySelector && hasParent ) {
5066 context = context.parentNode;
5070 if ( !relativeHierarchySelector || hasParent ) {
5071 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
5074 } catch(pseudoError) {
5077 oldContext.removeAttribute( "id" );
5083 return oldSizzle(query, context, extra, seed);
5086 for ( var prop in oldSizzle ) {
5087 Sizzle[ prop ] = oldSizzle[ prop ];
5090 // release memory in IE
5096 var html = document.documentElement,
5097 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
5100 // Check to see if it's possible to
do matchesSelector
5101 // on a disconnected node (IE 9 fails this)
5102 var disconnectedMatch
= !matches
.call( document
.createElement( "div" ), "div" ),
5103 pseudoWorks
= false;
5106 // This should fail with an exception
5107 // Gecko does not error, returns false instead
5108 matches
.call( document
.documentElement
, "[test!='']:sizzle" );
5110 } catch( pseudoError
) {
5114 Sizzle
.matchesSelector = function( node
, expr
) {
5115 // Make sure that attribute selectors are quoted
5116 expr
= expr
.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5118 if ( !Sizzle
.isXML( node
) ) {
5120 if ( pseudoWorks
|| !Expr
.match
.PSEUDO
.test( expr
) && !/!=/.test( expr
) ) {
5121 var ret
= matches
.call( node
, expr
);
5123 // IE 9's matchesSelector returns false on disconnected nodes
5124 if ( ret
|| !disconnectedMatch
||
5125 // As well, disconnected nodes are said to be in a document
5126 // fragment in IE 9, so check for that
5127 node
.document
&& node
.document
.nodeType
!== 11 ) {
5134 return Sizzle(expr
, null, null, [node
]).length
> 0;
5140 var div
= document
.createElement("div");
5142 div
.innerHTML
= "<div class='test e'></div><div class='test'></div>";
5144 // Opera can't find a second classname (in 9.6)
5145 // Also, make sure that getElementsByClassName actually exists
5146 if ( !div
.getElementsByClassName
|| div
.getElementsByClassName("e").length
=== 0 ) {
5150 // Safari caches class attributes, doesn't catch changes (in 3.2)
5151 div
.lastChild
.className
= "e";
5153 if ( div
.getElementsByClassName("e").length
=== 1 ) {
5157 Expr
.order
.splice(1, 0, "CLASS");
5158 Expr
.find
.CLASS = function( match
, context
, isXML
) {
5159 if ( typeof context
.getElementsByClassName
!== "undefined" && !isXML
) {
5160 return context
.getElementsByClassName(match
[1]);
5164 // release memory in IE
5168 function dirNodeCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
5169 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
5170 var elem
= checkSet
[i
];
5178 if ( elem
[ expando
] === doneName
) {
5179 match
= checkSet
[elem
.sizset
];
5183 if ( elem
.nodeType
=== 1 && !isXML
){
5184 elem
[ expando
] = doneName
;
5188 if ( elem
.nodeName
.toLowerCase() === cur
) {
5196 checkSet
[i
] = match
;
5201 function dirCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
5202 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
5203 var elem
= checkSet
[i
];
5211 if ( elem
[ expando
] === doneName
) {
5212 match
= checkSet
[elem
.sizset
];
5216 if ( elem
.nodeType
=== 1 ) {
5218 elem
[ expando
] = doneName
;
5222 if ( typeof cur
!== "string" ) {
5223 if ( elem
=== cur
) {
5228 } else if ( Sizzle
.filter( cur
, [elem
] ).length
> 0 ) {
5237 checkSet
[i
] = match
;
5242 if ( document
.documentElement
.contains
) {
5243 Sizzle
.contains = function( a
, b
) {
5244 return a
!== b
&& (a
.contains
? a
.contains(b
) : true);
5247 } else if ( document
.documentElement
.compareDocumentPosition
) {
5248 Sizzle
.contains = function( a
, b
) {
5249 return !!(a
.compareDocumentPosition(b
) & 16);
5253 Sizzle
.contains = function() {
5258 Sizzle
.isXML = function( elem
) {
5259 // documentElement is verified for cases where it doesn't yet exist
5260 // (such as loading iframes in IE - #4833)
5261 var documentElement
= (elem
? elem
.ownerDocument
|| elem : 0).documentElement
;
5263 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
5266 var posProcess = function( selector
, context
, seed
) {
5270 root
= context
.nodeType
? [context
] : context
;
5272 // Position selectors must be done after the filter
5273 // And so must :not(positional) so we move all PSEUDOs to the end
5274 while ( (match
= Expr
.match
.PSEUDO
.exec( selector
)) ) {
5276 selector
= selector
.replace( Expr
.match
.PSEUDO
, "" );
5279 selector
= Expr
.relative
[selector
] ? selector
+ "*" : selector
;
5281 for ( var i
= 0, l
= root
.length
; i
< l
; i
++ ) {
5282 Sizzle( selector
, root
[i
], tmpSet
, seed
);
5285 return Sizzle
.filter( later
, tmpSet
);
5289 // Override sizzle attribute retrieval
5290 Sizzle
.attr
= jQuery
.attr
;
5291 Sizzle
.selectors
.attrMap
= {};
5292 jQuery
.find
= Sizzle
;
5293 jQuery
.expr
= Sizzle
.selectors
;
5294 jQuery
.expr
[":"] = jQuery
.expr
.filters
;
5295 jQuery
.unique
= Sizzle
.uniqueSort
;
5296 jQuery
.text
= Sizzle
.getText
;
5297 jQuery
.isXMLDoc
= Sizzle
.isXML
;
5298 jQuery
.contains
= Sizzle
.contains
;
5304 var runtil
= /Until$/,
5305 rparentsprev
= /^(?:parents|prevUntil|prevAll)/,
5306 // Note: This RegExp should be improved, or likely pulled from Sizzle
5307 rmultiselector
= /,/,
5308 isSimple
= /^.[^:#\[\.,]*$/,
5309 slice
= Array
.prototype.slice
,
5310 POS
= jQuery
.expr
.match
.POS
,
5311 // methods guaranteed to produce a unique set when starting from a unique set
5312 guaranteedUnique
= {
5320 find: function( selector
) {
5324 if ( typeof selector
!== "string" ) {
5325 return jQuery( selector
).filter(function() {
5326 for ( i
= 0, l
= self
.length
; i
< l
; i
++ ) {
5327 if ( jQuery
.contains( self
[ i
], this ) ) {
5334 var ret
= this.pushStack( "", "find", selector
),
5337 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
5338 length
= ret
.length
;
5339 jQuery
.find( selector
, this[i
], ret
);
5342 // Make sure that the results are unique
5343 for ( n
= length
; n
< ret
.length
; n
++ ) {
5344 for ( r
= 0; r
< length
; r
++ ) {
5345 if ( ret
[r
] === ret
[n
] ) {
5357 has: function( target
) {
5358 var targets
= jQuery( target
);
5359 return this.filter(function() {
5360 for ( var i
= 0, l
= targets
.length
; i
< l
; i
++ ) {
5361 if ( jQuery
.contains( this, targets
[i
] ) ) {
5368 not: function( selector
) {
5369 return this.pushStack( winnow(this, selector
, false), "not", selector
);
5372 filter: function( selector
) {
5373 return this.pushStack( winnow(this, selector
, true), "filter", selector
);
5376 is: function( selector
) {
5377 return !!selector
&& (
5378 typeof selector
=== "string" ?
5379 // If this is a positional selector, check membership in the returned set
5380 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5381 POS
.test( selector
) ?
5382 jQuery( selector
, this.context
).index( this[0] ) >= 0 :
5383 jQuery
.filter( selector
, this ).length
> 0 :
5384 this.filter( selector
).length
> 0 );
5387 closest: function( selectors
, context
) {
5388 var ret
= [], i
, l
, cur
= this[0];
5390 // Array (deprecated as of jQuery 1.7)
5391 if ( jQuery
.isArray( selectors
) ) {
5394 while ( cur
&& cur
.ownerDocument
&& cur
!== context
) {
5395 for ( i
= 0; i
< selectors
.length
; i
++ ) {
5397 if ( jQuery( cur
).is( selectors
[ i
] ) ) {
5398 ret
.push({ selector: selectors
[ i
], elem: cur
, level: level
});
5402 cur
= cur
.parentNode
;
5410 var pos
= POS
.test( selectors
) || typeof selectors
!== "string" ?
5411 jQuery( selectors
, context
|| this.context
) :
5414 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
5418 if ( pos
? pos
.index(cur
) > -1 : jQuery
.find
.matchesSelector(cur
, selectors
) ) {
5423 cur
= cur
.parentNode
;
5424 if ( !cur
|| !cur
.ownerDocument
|| cur
=== context
|| cur
.nodeType
=== 11 ) {
5431 ret
= ret
.length
> 1 ? jQuery
.unique( ret
) : ret
;
5433 return this.pushStack( ret
, "closest", selectors
);
5436 // Determine the position of an element within
5437 // the matched set of elements
5438 index: function( elem
) {
5440 // No argument, return index in parent
5442 return ( this[0] && this[0].parentNode
) ? this.prevAll().length : -1;
5445 // index in selector
5446 if ( typeof elem
=== "string" ) {
5447 return jQuery
.inArray( this[0], jQuery( elem
) );
5450 // Locate the position of the desired element
5451 return jQuery
.inArray(
5452 // If it receives a jQuery object, the first element is used
5453 elem
.jquery
? elem
[0] : elem
, this );
5456 add: function( selector
, context
) {
5457 var set = typeof selector
=== "string" ?
5458 jQuery( selector
, context
) :
5459 jQuery
.makeArray( selector
&& selector
.nodeType
? [ selector
] : selector
),
5460 all
= jQuery
.merge( this.get(), set );
5462 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all
[0] ) ?
5464 jQuery
.unique( all
) );
5467 andSelf: function() {
5468 return this.add( this.prevObject
);
5472 // A painfully simple check to see if an element is disconnected
5473 // from a document (should be improved, where feasible).
5474 function isDisconnected( node
) {
5475 return !node
|| !node
.parentNode
|| node
.parentNode
.nodeType
=== 11;
5479 parent: function( elem
) {
5480 var parent
= elem
.parentNode
;
5481 return parent
&& parent
.nodeType
!== 11 ? parent : null;
5483 parents: function( elem
) {
5484 return jQuery
.dir( elem
, "parentNode" );
5486 parentsUntil: function( elem
, i
, until
) {
5487 return jQuery
.dir( elem
, "parentNode", until
);
5489 next: function( elem
) {
5490 return jQuery
.nth( elem
, 2, "nextSibling" );
5492 prev: function( elem
) {
5493 return jQuery
.nth( elem
, 2, "previousSibling" );
5495 nextAll: function( elem
) {
5496 return jQuery
.dir( elem
, "nextSibling" );
5498 prevAll: function( elem
) {
5499 return jQuery
.dir( elem
, "previousSibling" );
5501 nextUntil: function( elem
, i
, until
) {
5502 return jQuery
.dir( elem
, "nextSibling", until
);
5504 prevUntil: function( elem
, i
, until
) {
5505 return jQuery
.dir( elem
, "previousSibling", until
);
5507 siblings: function( elem
) {
5508 return jQuery
.sibling( elem
.parentNode
.firstChild
, elem
);
5510 children: function( elem
) {
5511 return jQuery
.sibling( elem
.firstChild
);
5513 contents: function( elem
) {
5514 return jQuery
.nodeName( elem
, "iframe" ) ?
5515 elem
.contentDocument
|| elem
.contentWindow
.document :
5516 jQuery
.makeArray( elem
.childNodes
);
5518 }, function( name
, fn
) {
5519 jQuery
.fn
[ name
] = function( until
, selector
) {
5520 var ret
= jQuery
.map( this, fn
, until
);
5522 if ( !runtil
.test( name
) ) {
5526 if ( selector
&& typeof selector
=== "string" ) {
5527 ret
= jQuery
.filter( selector
, ret
);
5530 ret
= this.length
> 1 && !guaranteedUnique
[ name
] ? jQuery
.unique( ret
) : ret
;
5532 if ( (this.length
> 1 || rmultiselector
.test( selector
)) && rparentsprev
.test( name
) ) {
5533 ret
= ret
.reverse();
5536 return this.pushStack( ret
, name
, slice
.call( arguments
).join(",") );
5541 filter: function( expr
, elems
, not
) {
5543 expr
= ":not(" + expr
+ ")";
5546 return elems
.length
=== 1 ?
5547 jQuery
.find
.matchesSelector(elems
[0], expr
) ? [ elems
[0] ] : [] :
5548 jQuery
.find
.matches(expr
, elems
);
5551 dir: function( elem
, dir
, until
) {
5555 while ( cur
&& cur
.nodeType
!== 9 && (until
=== undefined || cur
.nodeType
!== 1 || !jQuery( cur
).is( until
)) ) {
5556 if ( cur
.nodeType
=== 1 ) {
5557 matched
.push( cur
);
5564 nth: function( cur
, result
, dir
, elem
) {
5565 result
= result
|| 1;
5568 for ( ; cur
; cur
= cur
[dir
] ) {
5569 if ( cur
.nodeType
=== 1 && ++num
=== result
) {
5577 sibling: function( n
, elem
) {
5580 for ( ; n
; n
= n
.nextSibling
) {
5581 if ( n
.nodeType
=== 1 && n
!== elem
) {
5590 // Implement the identical functionality for filter and not
5591 function winnow( elements
, qualifier
, keep
) {
5593 // Can't pass null or undefined to indexOf in Firefox 4
5594 // Set to 0 to skip string check
5595 qualifier
= qualifier
|| 0;
5597 if ( jQuery
.isFunction( qualifier
) ) {
5598 return jQuery
.grep(elements
, function( elem
, i
) {
5599 var retVal
= !!qualifier
.call( elem
, i
, elem
);
5600 return retVal
=== keep
;
5603 } else if ( qualifier
.nodeType
) {
5604 return jQuery
.grep(elements
, function( elem
, i
) {
5605 return ( elem
=== qualifier
) === keep
;
5608 } else if ( typeof qualifier
=== "string" ) {
5609 var filtered
= jQuery
.grep(elements
, function( elem
) {
5610 return elem
.nodeType
=== 1;
5613 if ( isSimple
.test( qualifier
) ) {
5614 return jQuery
.filter(qualifier
, filtered
, !keep
);
5616 qualifier
= jQuery
.filter( qualifier
, filtered
);
5620 return jQuery
.grep(elements
, function( elem
, i
) {
5621 return ( jQuery
.inArray( elem
, qualifier
) >= 0 ) === keep
;
5628 function createSafeFragment( document
) {
5629 var list
= nodeNames
.split( "|" ),
5630 safeFrag
= document
.createDocumentFragment();
5632 if ( safeFrag
.createElement
) {
5633 while ( list
.length
) {
5634 safeFrag
.createElement(
5642 var nodeNames
= "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" +
5643 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5644 rinlinejQuery
= / jQuery
\d
+="(?:\d+|null)"/g
,
5645 rleadingWhitespace
= /^\s+/,
5646 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5647 rtagName
= /<([\w:]+)/,
5649 rhtml
= /<|&#?\w+;/,
5650 rnoInnerhtml
= /<(?:script|style)/i,
5651 rnocache
= /<(?:script|object|embed|option|style)/i,
5652 rnoshimcache
= new RegExp("<(?:" + nodeNames
+ ")", "i"),
5653 // checked="checked" or checked
5654 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5655 rscriptType
= /\/(java|ecma)script/i,
5656 rcleanScript
= /^\s*<!(?:\[CDATA\[|\-\-)/,
5658 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5659 legend: [ 1, "<fieldset>", "</fieldset>" ],
5660 thead: [ 1, "<table>", "</table>" ],
5661 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5662 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5663 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5664 area: [ 1, "<map>", "</map>" ],
5665 _default: [ 0, "", "" ]
5667 safeFragment
= createSafeFragment( document
);
5669 wrapMap
.optgroup
= wrapMap
.option
;
5670 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
5671 wrapMap
.th
= wrapMap
.td
;
5673 // IE can't serialize <link> and <script> tags normally
5674 if ( !jQuery
.support
.htmlSerialize
) {
5675 wrapMap
._default
= [ 1, "div<div>", "</div>" ];
5679 text: function( text
) {
5680 if ( jQuery
.isFunction(text
) ) {
5681 return this.each(function(i
) {
5682 var self
= jQuery( this );
5684 self
.text( text
.call(this, i
, self
.text()) );
5688 if ( typeof text
!== "object" && text
!== undefined ) {
5689 return this.empty().append( (this[0] && this[0].ownerDocument
|| document
).createTextNode( text
) );
5692 return jQuery
.text( this );
5695 wrapAll: function( html
) {
5696 if ( jQuery
.isFunction( html
) ) {
5697 return this.each(function(i
) {
5698 jQuery(this).wrapAll( html
.call(this, i
) );
5703 // The elements to wrap the target around
5704 var wrap
= jQuery( html
, this[0].ownerDocument
).eq(0).clone(true);
5706 if ( this[0].parentNode
) {
5707 wrap
.insertBefore( this[0] );
5710 wrap
.map(function() {
5713 while ( elem
.firstChild
&& elem
.firstChild
.nodeType
=== 1 ) {
5714 elem
= elem
.firstChild
;
5724 wrapInner: function( html
) {
5725 if ( jQuery
.isFunction( html
) ) {
5726 return this.each(function(i
) {
5727 jQuery(this).wrapInner( html
.call(this, i
) );
5731 return this.each(function() {
5732 var self
= jQuery( this ),
5733 contents
= self
.contents();
5735 if ( contents
.length
) {
5736 contents
.wrapAll( html
);
5739 self
.append( html
);
5744 wrap: function( html
) {
5745 var isFunction
= jQuery
.isFunction( html
);
5747 return this.each(function(i
) {
5748 jQuery( this ).wrapAll( isFunction
? html
.call(this, i
) : html
);
5752 unwrap: function() {
5753 return this.parent().each(function() {
5754 if ( !jQuery
.nodeName( this, "body" ) ) {
5755 jQuery( this ).replaceWith( this.childNodes
);
5760 append: function() {
5761 return this.domManip(arguments
, true, function( elem
) {
5762 if ( this.nodeType
=== 1 ) {
5763 this.appendChild( elem
);
5768 prepend: function() {
5769 return this.domManip(arguments
, true, function( elem
) {
5770 if ( this.nodeType
=== 1 ) {
5771 this.insertBefore( elem
, this.firstChild
);
5776 before: function() {
5777 if ( this[0] && this[0].parentNode
) {
5778 return this.domManip(arguments
, false, function( elem
) {
5779 this.parentNode
.insertBefore( elem
, this );
5781 } else if ( arguments
.length
) {
5782 var set = jQuery
.clean( arguments
);
5783 set.push
.apply( set, this.toArray() );
5784 return this.pushStack( set, "before", arguments
);
5789 if ( this[0] && this[0].parentNode
) {
5790 return this.domManip(arguments
, false, function( elem
) {
5791 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5793 } else if ( arguments
.length
) {
5794 var set = this.pushStack( this, "after", arguments
);
5795 set.push
.apply( set, jQuery
.clean(arguments
) );
5800 // keepData is for internal use only--do not document
5801 remove: function( selector
, keepData
) {
5802 for ( var i
= 0, elem
; (elem
= this[i
]) != null; i
++ ) {
5803 if ( !selector
|| jQuery
.filter( selector
, [ elem
] ).length
) {
5804 if ( !keepData
&& elem
.nodeType
=== 1 ) {
5805 jQuery
.cleanData( elem
.getElementsByTagName("*") );
5806 jQuery
.cleanData( [ elem
] );
5809 if ( elem
.parentNode
) {
5810 elem
.parentNode
.removeChild( elem
);
5819 for ( var i
= 0, elem
; (elem
= this[i
]) != null; i
++ ) {
5820 // Remove element nodes and prevent memory leaks
5821 if ( elem
.nodeType
=== 1 ) {
5822 jQuery
.cleanData( elem
.getElementsByTagName("*") );
5825 // Remove any remaining nodes
5826 while ( elem
.firstChild
) {
5827 elem
.removeChild( elem
.firstChild
);
5834 clone: function( dataAndEvents
, deepDataAndEvents
) {
5835 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5836 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents : deepDataAndEvents
;
5838 return this.map( function () {
5839 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5843 html: function( value
) {
5844 if ( value
=== undefined ) {
5845 return this[0] && this[0].nodeType
=== 1 ?
5846 this[0].innerHTML
.replace(rinlinejQuery
, "") :
5849 // See if we can take a shortcut and just use innerHTML
5850 } else if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5851 (jQuery
.support
.leadingWhitespace
|| !rleadingWhitespace
.test( value
)) &&
5852 !wrapMap
[ (rtagName
.exec( value
) || ["", ""])[1].toLowerCase() ] ) {
5854 value
= value
.replace(rxhtmlTag
, "<$1></$2>");
5857 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
5858 // Remove element nodes and prevent memory leaks
5859 if ( this[i
].nodeType
=== 1 ) {
5860 jQuery
.cleanData( this[i
].getElementsByTagName("*") );
5861 this[i
].innerHTML
= value
;
5865 // If using innerHTML throws an exception, use the fallback method
5867 this.empty().append( value
);
5870 } else if ( jQuery
.isFunction( value
) ) {
5871 this.each(function(i
){
5872 var self
= jQuery( this );
5874 self
.html( value
.call(this, i
, self
.html()) );
5878 this.empty().append( value
);
5884 replaceWith: function( value
) {
5885 if ( this[0] && this[0].parentNode
) {
5886 // Make sure that the elements are removed from the DOM before they are inserted
5887 // this can help fix replacing a parent with child elements
5888 if ( jQuery
.isFunction( value
) ) {
5889 return this.each(function(i
) {
5890 var self
= jQuery(this), old
= self
.html();
5891 self
.replaceWith( value
.call( this, i
, old
) );
5895 if ( typeof value
!== "string" ) {
5896 value
= jQuery( value
).detach();
5899 return this.each(function() {
5900 var next
= this.nextSibling
,
5901 parent
= this.parentNode
;
5903 jQuery( this ).remove();
5906 jQuery(next
).before( value
);
5908 jQuery(parent
).append( value
);
5912 return this.length
?
5913 this.pushStack( jQuery(jQuery
.isFunction(value
) ? value() : value
), "replaceWith", value
) :
5918 detach: function( selector
) {
5919 return this.remove( selector
, true );
5922 domManip: function( args
, table
, callback
) {
5923 var results
, first
, fragment
, parent
,
5927 // We can't cloneNode fragments that contain checked, in WebKit
5928 if ( !jQuery
.support
.checkClone
&& arguments
.length
=== 3 && typeof value
=== "string" && rchecked
.test( value
) ) {
5929 return this.each(function() {
5930 jQuery(this).domManip( args
, table
, callback
, true );
5934 if ( jQuery
.isFunction(value
) ) {
5935 return this.each(function(i
) {
5936 var self
= jQuery(this);
5937 args
[0] = value
.call(this, i
, table
? self
.html() : undefined);
5938 self
.domManip( args
, table
, callback
);
5943 parent
= value
&& value
.parentNode
;
5945 // If we're in a fragment, just use that instead of building a new one
5946 if ( jQuery
.support
.parentNode
&& parent
&& parent
.nodeType
=== 11 && parent
.childNodes
.length
=== this.length
) {
5947 results
= { fragment: parent
};
5950 results
= jQuery
.buildFragment( args
, this, scripts
);
5953 fragment
= results
.fragment
;
5955 if ( fragment
.childNodes
.length
=== 1 ) {
5956 first
= fragment
= fragment
.firstChild
;
5958 first
= fragment
.firstChild
;
5962 table
= table
&& jQuery
.nodeName( first
, "tr" );
5964 for ( var i
= 0, l
= this.length
, lastIndex
= l
- 1; i
< l
; i
++ ) {
5967 root(this[i
], first
) :
5969 // Make sure that we do not leak memory by inadvertently discarding
5970 // the original fragment (which might have attached data) instead of
5971 // using it; in addition, use the original fragment object for the last
5972 // item instead of first because it can end up being emptied incorrectly
5973 // in certain situations (Bug #8070).
5974 // Fragments from the fragment cache must always be cloned and never used
5976 results
.cacheable
|| ( l
> 1 && i
< lastIndex
) ?
5977 jQuery
.clone( fragment
, true, true ) :
5983 if ( scripts
.length
) {
5984 jQuery
.each( scripts
, evalScript
);
5992 function root( elem
, cur
) {
5993 return jQuery
.nodeName(elem
, "table") ?
5994 (elem
.getElementsByTagName("tbody")[0] ||
5995 elem
.appendChild(elem
.ownerDocument
.createElement("tbody"))) :
5999 function cloneCopyEvent( src
, dest
) {
6001 if ( dest
.nodeType
!== 1 || !jQuery
.hasData( src
) ) {
6006 oldData
= jQuery
._data( src
),
6007 curData
= jQuery
._data( dest
, oldData
),
6008 events
= oldData
.events
;
6011 delete curData
.handle
;
6012 curData
.events
= {};
6014 for ( type
in events
) {
6015 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
6016 jQuery
.event
.add( dest
, type
+ ( events
[ type
][ i
].namespace ? "." : "" ) + events
[ type
][ i
].namespace, events
[ type
][ i
], events
[ type
][ i
].data
);
6021 // make the cloned public data object a copy from the original
6022 if ( curData
.data
) {
6023 curData
.data
= jQuery
.extend( {}, curData
.data
);
6027 function cloneFixAttributes( src
, dest
) {
6030 // We do not need to do anything for non-Elements
6031 if ( dest
.nodeType
!== 1 ) {
6035 // clearAttributes removes the attributes, which we don't want,
6036 // but also removes the attachEvent events, which we *do* want
6037 if ( dest
.clearAttributes
) {
6038 dest
.clearAttributes();
6041 // mergeAttributes, in contrast, only merges back on the
6042 // original attributes, not the events
6043 if ( dest
.mergeAttributes
) {
6044 dest
.mergeAttributes( src
);
6047 nodeName
= dest
.nodeName
.toLowerCase();
6049 // IE6-8 fail to clone children inside object elements that use
6050 // the proprietary classid attribute value (rather than the type
6051 // attribute) to identify the type of content to display
6052 if ( nodeName
=== "object" ) {
6053 dest
.outerHTML
= src
.outerHTML
;
6055 } else if ( nodeName
=== "input" && (src
.type
=== "checkbox" || src
.type
=== "radio") ) {
6056 // IE6-8 fails to persist the checked state of a cloned checkbox
6057 // or radio button. Worse, IE6-7 fail to give the cloned element
6058 // a checked appearance if the defaultChecked value isn't also set
6059 if ( src
.checked
) {
6060 dest
.defaultChecked
= dest
.checked
= src
.checked
;
6063 // IE6-7 get confused and end up setting the value of a cloned
6064 // checkbox/radio button to an empty string instead of "on"
6065 if ( dest
.value
!== src
.value
) {
6066 dest
.value
= src
.value
;
6069 // IE6-8 fails to return the selected option to the default selected
6070 // state when cloning options
6071 } else if ( nodeName
=== "option" ) {
6072 dest
.selected
= src
.defaultSelected
;
6074 // IE6-8 fails to set the defaultValue to the correct value when
6075 // cloning other types of input fields
6076 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
6077 dest
.defaultValue
= src
.defaultValue
;
6080 // Event data gets referenced instead of copied if the expando
6082 dest
.removeAttribute( jQuery
.expando
);
6085 jQuery
.buildFragment = function( args
, nodes
, scripts
) {
6086 var fragment
, cacheable
, cacheresults
, doc
,
6089 // nodes may contain either an explicit document object,
6090 // a jQuery collection or context object.
6091 // If nodes[0] contains a valid object to assign to doc
6092 if ( nodes
&& nodes
[0] ) {
6093 doc
= nodes
[0].ownerDocument
|| nodes
[0];
6096 // Ensure that an attr object doesn't incorrectly stand in as a document object
6097 // Chrome and Firefox seem to allow this to occur and will throw exception
6099 if ( !doc
.createDocumentFragment
) {
6103 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6104 // Cloning options loses the selected state, so don't cache them
6105 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6106 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6107 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6108 if ( args
.length
=== 1 && typeof first
=== "string" && first
.length
< 512 && doc
=== document
&&
6109 first
.charAt(0) === "<" && !rnocache
.test( first
) &&
6110 (jQuery
.support
.checkClone
|| !rchecked
.test( first
)) &&
6111 (jQuery
.support
.html5Clone
|| !rnoshimcache
.test( first
)) ) {
6115 cacheresults
= jQuery
.fragments
[ first
];
6116 if ( cacheresults
&& cacheresults
!== 1 ) {
6117 fragment
= cacheresults
;
6122 fragment
= doc
.createDocumentFragment();
6123 jQuery
.clean( args
, doc
, fragment
, scripts
);
6127 jQuery
.fragments
[ first
] = cacheresults
? fragment : 1;
6130 return { fragment: fragment
, cacheable: cacheable
};
6133 jQuery
.fragments
= {};
6137 prependTo: "prepend",
6138 insertBefore: "before",
6139 insertAfter: "after",
6140 replaceAll: "replaceWith"
6141 }, function( name
, original
) {
6142 jQuery
.fn
[ name
] = function( selector
) {
6144 insert
= jQuery( selector
),
6145 parent
= this.length
=== 1 && this[0].parentNode
;
6147 if ( parent
&& parent
.nodeType
=== 11 && parent
.childNodes
.length
=== 1 && insert
.length
=== 1 ) {
6148 insert
[ original
]( this[0] );
6152 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
6153 var elems
= ( i
> 0 ? this.clone(true) : this ).get();
6154 jQuery( insert
[i
] )[ original
]( elems
);
6155 ret
= ret
.concat( elems
);
6158 return this.pushStack( ret
, name
, insert
.selector
);
6163 function getAll( elem
) {
6164 if ( typeof elem
.getElementsByTagName
!== "undefined" ) {
6165 return elem
.getElementsByTagName( "*" );
6167 } else if ( typeof elem
.querySelectorAll
!== "undefined" ) {
6168 return elem
.querySelectorAll( "*" );
6175 // Used in clean, fixes the defaultChecked property
6176 function fixDefaultChecked( elem
) {
6177 if ( elem
.type
=== "checkbox" || elem
.type
=== "radio" ) {
6178 elem
.defaultChecked
= elem
.checked
;
6181 // Finds all inputs and passes them to fixDefaultChecked
6182 function findInputs( elem
) {
6183 var nodeName
= ( elem
.nodeName
|| "" ).toLowerCase();
6184 if ( nodeName
=== "input" ) {
6185 fixDefaultChecked( elem
);
6186 // Skip scripts, get other children
6187 } else if ( nodeName
!== "script" && typeof elem
.getElementsByTagName
!== "undefined" ) {
6188 jQuery
.grep( elem
.getElementsByTagName("input"), fixDefaultChecked
);
6192 // Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
6193 function shimCloneNode( elem
) {
6194 var div
= document
.createElement( "div" );
6195 safeFragment
.appendChild( div
);
6197 div
.innerHTML
= elem
.outerHTML
;
6198 return div
.firstChild
;
6202 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
6206 // IE<=8 does not properly clone detached, unknown element nodes
6207 clone
= jQuery
.support
.html5Clone
|| !rnoshimcache
.test( "<" + elem
.nodeName
) ?
6208 elem
.cloneNode( true ) :
6209 shimCloneNode( elem
);
6211 if ( (!jQuery
.support
.noCloneEvent
|| !jQuery
.support
.noCloneChecked
) &&
6212 (elem
.nodeType
=== 1 || elem
.nodeType
=== 11) && !jQuery
.isXMLDoc(elem
) ) {
6213 // IE copies events bound via attachEvent when using cloneNode.
6214 // Calling detachEvent on the clone will also remove the events
6215 // from the original. In order to get around this, we use some
6216 // proprietary methods to clear the events. Thanks to MooTools
6217 // guys for this hotness.
6219 cloneFixAttributes( elem
, clone
);
6221 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6222 srcElements
= getAll( elem
);
6223 destElements
= getAll( clone
);
6225 // Weird iteration because IE will replace the length property
6226 // with an element if you are cloning the body and one of the
6227 // elements on the page has a name or id of "length"
6228 for ( i
= 0; srcElements
[i
]; ++i
) {
6229 // Ensure that the destination node is not null; Fixes #9587
6230 if ( destElements
[i
] ) {
6231 cloneFixAttributes( srcElements
[i
], destElements
[i
] );
6236 // Copy the events from the original to the clone
6237 if ( dataAndEvents
) {
6238 cloneCopyEvent( elem
, clone
);
6240 if ( deepDataAndEvents
) {
6241 srcElements
= getAll( elem
);
6242 destElements
= getAll( clone
);
6244 for ( i
= 0; srcElements
[i
]; ++i
) {
6245 cloneCopyEvent( srcElements
[i
], destElements
[i
] );
6250 srcElements
= destElements
= null;
6252 // Return the cloned set
6256 clean: function( elems
, context
, fragment
, scripts
) {
6257 var checkScriptType
;
6259 context
= context
|| document
;
6261 // !context.createElement fails in IE with an error but returns typeof 'object'
6262 if ( typeof context
.createElement
=== "undefined" ) {
6263 context
= context
.ownerDocument
|| context
[0] && context
[0].ownerDocument
|| document
;
6268 for ( var i
= 0, elem
; (elem
= elems
[i
]) != null; i
++ ) {
6269 if ( typeof elem
=== "number" ) {
6277 // Convert html string into DOM nodes
6278 if ( typeof elem
=== "string" ) {
6279 if ( !rhtml
.test( elem
) ) {
6280 elem
= context
.createTextNode( elem
);
6282 // Fix "XHTML"-style tags in all browsers
6283 elem
= elem
.replace(rxhtmlTag
, "<$1></$2>");
6285 // Trim whitespace, otherwise indexOf won't work as expected
6286 var tag
= ( rtagName
.exec( elem
) || ["", ""] )[1].toLowerCase(),
6287 wrap
= wrapMap
[ tag
] || wrapMap
._default
,
6289 div
= context
.createElement("div");
6291 // Append wrapper element to unknown element safe doc fragment
6292 if ( context
=== document
) {
6293 // Use the fragment we've already created for this document
6294 safeFragment
.appendChild( div
);
6296 // Use a fragment created with the owner document
6297 createSafeFragment( context
).appendChild( div
);
6300 // Go to html and back, then peel off extra wrappers
6301 div
.innerHTML
= wrap
[1] + elem
+ wrap
[2];
6303 // Move to the right depth
6305 div
= div
.lastChild
;
6308 // Remove IE's autoinserted <tbody> from table fragments
6309 if ( !jQuery
.support
.tbody
) {
6311 // String was a <table>, *may* have spurious <tbody>
6312 var hasBody
= rtbody
.test(elem
),
6313 tbody
= tag
=== "table" && !hasBody
?
6314 div
.firstChild
&& div
.firstChild
.childNodes :
6316 // String was a bare <thead> or <tfoot>
6317 wrap
[1] === "<table>" && !hasBody
?
6321 for ( j
= tbody
.length
- 1; j
>= 0 ; --j
) {
6322 if ( jQuery
.nodeName( tbody
[ j
], "tbody" ) && !tbody
[ j
].childNodes
.length
) {
6323 tbody
[ j
].parentNode
.removeChild( tbody
[ j
] );
6328 // IE completely kills leading whitespace when innerHTML is used
6329 if ( !jQuery
.support
.leadingWhitespace
&& rleadingWhitespace
.test( elem
) ) {
6330 div
.insertBefore( context
.createTextNode( rleadingWhitespace
.exec(elem
)[0] ), div
.firstChild
);
6333 elem
= div
.childNodes
;
6337 // Resets defaultChecked for any radios and checkboxes
6338 // about to be appended to the DOM in IE 6/7 (#8060)
6340 if ( !jQuery
.support
.appendChecked
) {
6341 if ( elem
[0] && typeof (len
= elem
.length
) === "number" ) {
6342 for ( j
= 0; j
< len
; j
++ ) {
6343 findInputs( elem
[j
] );
6350 if ( elem
.nodeType
) {
6353 ret
= jQuery
.merge( ret
, elem
);
6358 checkScriptType = function( elem
) {
6359 return !elem
.type
|| rscriptType
.test( elem
.type
);
6361 for ( i
= 0; ret
[i
]; i
++ ) {
6362 if ( scripts
&& jQuery
.nodeName( ret
[i
], "script" ) && (!ret
[i
].type
|| ret
[i
].type
.toLowerCase() === "text/javascript") ) {
6363 scripts
.push( ret
[i
].parentNode
? ret
[i
].parentNode
.removeChild( ret
[i
] ) : ret
[i
] );
6366 if ( ret
[i
].nodeType
=== 1 ) {
6367 var jsTags
= jQuery
.grep( ret
[i
].getElementsByTagName( "script" ), checkScriptType
);
6369 ret
.splice
.apply( ret
, [i
+ 1, 0].concat( jsTags
) );
6371 fragment
.appendChild( ret
[i
] );
6379 cleanData: function( elems
) {
6381 cache
= jQuery
.cache
,
6382 special
= jQuery
.event
.special
,
6383 deleteExpando
= jQuery
.support
.deleteExpando
;
6385 for ( var i
= 0, elem
; (elem
= elems
[i
]) != null; i
++ ) {
6386 if ( elem
.nodeName
&& jQuery
.noData
[elem
.nodeName
.toLowerCase()] ) {
6390 id
= elem
[ jQuery
.expando
];
6395 if ( data
&& data
.events
) {
6396 for ( var type
in data
.events
) {
6397 if ( special
[ type
] ) {
6398 jQuery
.event
.remove( elem
, type
);
6400 // This is a shortcut to avoid jQuery.event.remove's overhead
6402 jQuery
.removeEvent( elem
, type
, data
.handle
);
6406 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6407 if ( data
.handle
) {
6408 data
.handle
.elem
= null;
6412 if ( deleteExpando
) {
6413 delete elem
[ jQuery
.expando
];
6415 } else if ( elem
.removeAttribute
) {
6416 elem
.removeAttribute( jQuery
.expando
);
6425 function evalScript( i
, elem
) {
6433 jQuery
.globalEval( ( elem
.text
|| elem
.textContent
|| elem
.innerHTML
|| "" ).replace( rcleanScript
, "/*$0*/" ) );
6436 if ( elem
.parentNode
) {
6437 elem
.parentNode
.removeChild( elem
);
6444 var ralpha
= /alpha\([^)]*\)/i,
6445 ropacity
= /opacity=([^)]*)/,
6446 // fixed for IE9, see #8346
6447 rupper
= /([A-Z]|^ms)/g,
6448 rnumpx
= /^-?\d+(?:px)?$/i,
6450 rrelNum
= /^([\-+])=([\-+.\de]+)/,
6452 cssShow
= { position: "absolute", visibility: "hidden", display: "block" },
6453 cssWidth
= [ "Left", "Right" ],
6454 cssHeight
= [ "Top", "Bottom" ],
6460 jQuery
.fn
.css = function( name
, value
) {
6461 // Setting 'undefined' is a no-op
6462 if ( arguments
.length
=== 2 && value
=== undefined ) {
6466 return jQuery
.access( this, name
, value
, true, function( elem
, name
, value
) {
6467 return value
!== undefined ?
6468 jQuery
.style( elem
, name
, value
) :
6469 jQuery
.css( elem
, name
);
6474 // Add in style property hooks for overriding the default
6475 // behavior of getting and setting a style property
6478 get: function( elem
, computed
) {
6480 // We should always get a number back from opacity
6481 var ret
= curCSS( elem
, "opacity", "opacity" );
6482 return ret
=== "" ? "1" : ret
;
6485 return elem
.style
.opacity
;
6491 // Exclude the following css properties to add px
6493 "fillOpacity": true,
6503 // Add in properties whose names you wish to fix before
6504 // setting or getting the value
6506 // normalize float css property
6507 "float": jQuery
.support
.cssFloat
? "cssFloat" : "styleFloat"
6510 // Get and set the style property on a DOM Node
6511 style: function( elem
, name
, value
, extra
) {
6512 // Don't set styles on text and comment nodes
6513 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6517 // Make sure that we're working with the right name
6518 var ret
, type
, origName
= jQuery
.camelCase( name
),
6519 style
= elem
.style
, hooks
= jQuery
.cssHooks
[ origName
];
6521 name
= jQuery
.cssProps
[ origName
] || origName
;
6523 // Check if we're setting a value
6524 if ( value
!== undefined ) {
6525 type
= typeof value
;
6527 // convert relative number strings (+= or -=) to relative numbers. #7345
6528 if ( type
=== "string" && (ret
= rrelNum
.exec( value
)) ) {
6529 value
= ( +( ret
[1] + 1) * +ret
[2] ) + parseFloat( jQuery
.css( elem
, name
) );
6534 // Make sure that NaN and null values aren't set. See: #7116
6535 if ( value
== null || type
=== "number" && isNaN( value
) ) {
6539 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6540 if ( type
=== "number" && !jQuery
.cssNumber
[ origName
] ) {
6544 // If a hook was provided, use that value, otherwise just set the specified value
6545 if ( !hooks
|| !("set" in hooks
) || (value
= hooks
.set( elem
, value
)) !== undefined ) {
6546 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6549 style
[ name
] = value
;
6554 // If a hook was provided get the non-computed value from there
6555 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, false, extra
)) !== undefined ) {
6559 // Otherwise just get the value from the style object
6560 return style
[ name
];
6564 css: function( elem
, name
, extra
) {
6567 // Make sure that we're working with the right name
6568 name
= jQuery
.camelCase( name
);
6569 hooks
= jQuery
.cssHooks
[ name
];
6570 name
= jQuery
.cssProps
[ name
] || name
;
6572 // cssFloat needs a special treatment
6573 if ( name
=== "cssFloat" ) {
6577 // If a hook was provided get the computed value from there
6578 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, true, extra
)) !== undefined ) {
6581 // Otherwise, if a way to get the computed value exists, use that
6582 } else if ( curCSS
) {
6583 return curCSS( elem
, name
);
6587 // A method for quickly swapping in/out CSS properties to get correct calculations
6588 swap: function( elem
, options
, callback
) {
6591 // Remember the old values, and insert the new ones
6592 for ( var name
in options
) {
6593 old
[ name
] = elem
.style
[ name
];
6594 elem
.style
[ name
] = options
[ name
];
6597 callback
.call( elem
);
6599 // Revert the old values
6600 for ( name
in options
) {
6601 elem
.style
[ name
] = old
[ name
];
6606 // DEPRECATED, Use jQuery.css() instead
6607 jQuery
.curCSS
= jQuery
.css
;
6609 jQuery
.each(["height", "width"], function( i
, name
) {
6610 jQuery
.cssHooks
[ name
] = {
6611 get: function( elem
, computed
, extra
) {
6615 if ( elem
.offsetWidth
!== 0 ) {
6616 return getWH( elem
, name
, extra
);
6618 jQuery
.swap( elem
, cssShow
, function() {
6619 val
= getWH( elem
, name
, extra
);
6627 set: function( elem
, value
) {
6628 if ( rnumpx
.test( value
) ) {
6629 // ignore negative width and height values #1599
6630 value
= parseFloat( value
);
6633 return value
+ "px";
6643 if ( !jQuery
.support
.opacity
) {
6644 jQuery
.cssHooks
.opacity
= {
6645 get: function( elem
, computed
) {
6646 // IE uses filters for opacity
6647 return ropacity
.test( (computed
&& elem
.currentStyle
? elem
.currentStyle
.filter : elem
.style
.filter
) || "" ) ?
6648 ( parseFloat( RegExp
.$1 ) / 100 ) + "" :
6649 computed
? "1" : "";
6652 set: function( elem
, value
) {
6653 var style
= elem
.style
,
6654 currentStyle
= elem
.currentStyle
,
6655 opacity
= jQuery
.isNumeric( value
) ? "alpha(opacity=" + value
* 100 + ")" : "",
6656 filter
= currentStyle
&& currentStyle
.filter
|| style
.filter
|| "";
6658 // IE has trouble with opacity if it does not have layout
6659 // Force it by setting the zoom level
6662 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6663 if ( value
>= 1 && jQuery
.trim( filter
.replace( ralpha
, "" ) ) === "" ) {
6665 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6666 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6667 // style.removeAttribute is IE Only, but so apparently is this code path...
6668 style
.removeAttribute( "filter" );
6670 // if there there is no filter style applied in a css rule, we are done
6671 if ( currentStyle
&& !currentStyle
.filter
) {
6676 // otherwise, set new filter values
6677 style
.filter
= ralpha
.test( filter
) ?
6678 filter
.replace( ralpha
, opacity
) :
6679 filter
+ " " + opacity
;
6685 // This hook cannot be added until DOM ready because the support test
6686 // for it is not run until after DOM ready
6687 if ( !jQuery
.support
.reliableMarginRight
) {
6688 jQuery
.cssHooks
.marginRight
= {
6689 get: function( elem
, computed
) {
6690 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6691 // Work around by temporarily setting element display to inline-block
6693 jQuery
.swap( elem
, { "display": "inline-block" }, function() {
6695 ret
= curCSS( elem
, "margin-right", "marginRight" );
6697 ret
= elem
.style
.marginRight
;
6706 if ( document
.defaultView
&& document
.defaultView
.getComputedStyle
) {
6707 getComputedStyle = function( elem
, name
) {
6708 var ret
, defaultView
, computedStyle
;
6710 name
= name
.replace( rupper
, "-$1" ).toLowerCase();
6712 if ( (defaultView
= elem
.ownerDocument
.defaultView
) &&
6713 (computedStyle
= defaultView
.getComputedStyle( elem
, null )) ) {
6714 ret
= computedStyle
.getPropertyValue( name
);
6715 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
.documentElement
, elem
) ) {
6716 ret
= jQuery
.style( elem
, name
);
6724 if ( document
.documentElement
.currentStyle
) {
6725 currentStyle = function( elem
, name
) {
6726 var left
, rsLeft
, uncomputed
,
6727 ret
= elem
.currentStyle
&& elem
.currentStyle
[ name
],
6730 // Avoid setting ret to empty string here
6731 // so we don't default to auto
6732 if ( ret
=== null && style
&& (uncomputed
= style
[ name
]) ) {
6736 // From the awesome hack by Dean Edwards
6737 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6739 // If we're not dealing with a regular pixel number
6740 // but a number that has a weird ending, we need to convert it to pixels
6741 if ( !rnumpx
.test( ret
) && rnum
.test( ret
) ) {
6743 // Remember the original values
6745 rsLeft
= elem
.runtimeStyle
&& elem
.runtimeStyle
.left
;
6747 // Put in the new values to get a computed value out
6749 elem
.runtimeStyle
.left
= elem
.currentStyle
.left
;
6751 style
.left
= name
=== "fontSize" ? "1em" : ( ret
|| 0 );
6752 ret
= style
.pixelLeft
+ "px";
6754 // Revert the changed values
6757 elem
.runtimeStyle
.left
= rsLeft
;
6761 return ret
=== "" ? "auto" : ret
;
6765 curCSS
= getComputedStyle
|| currentStyle
;
6767 function getWH( elem
, name
, extra
) {
6769 // Start with offset property
6770 var val
= name
=== "width" ? elem
.offsetWidth : elem
.offsetHeight
,
6771 which
= name
=== "width" ? cssWidth : cssHeight
,
6776 if ( extra
!== "border" ) {
6777 for ( ; i
< len
; i
++ ) {
6779 val
-= parseFloat( jQuery
.css( elem
, "padding" + which
[ i
] ) ) || 0;
6781 if ( extra
=== "margin" ) {
6782 val
+= parseFloat( jQuery
.css( elem
, extra
+ which
[ i
] ) ) || 0;
6784 val
-= parseFloat( jQuery
.css( elem
, "border" + which
[ i
] + "Width" ) ) || 0;
6792 // Fall back to computed then uncomputed css if necessary
6793 val
= curCSS( elem
, name
, name
);
6794 if ( val
< 0 || val
== null ) {
6795 val
= elem
.style
[ name
] || 0;
6797 // Normalize "", auto, and prepare for extra
6798 val
= parseFloat( val
) || 0;
6800 // Add padding, border, margin
6802 for ( ; i
< len
; i
++ ) {
6803 val
+= parseFloat( jQuery
.css( elem
, "padding" + which
[ i
] ) ) || 0;
6804 if ( extra
!== "padding" ) {
6805 val
+= parseFloat( jQuery
.css( elem
, "border" + which
[ i
] + "Width" ) ) || 0;
6807 if ( extra
=== "margin" ) {
6808 val
+= parseFloat( jQuery
.css( elem
, extra
+ which
[ i
] ) ) || 0;
6816 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
6817 jQuery
.expr
.filters
.hidden = function( elem
) {
6818 var width
= elem
.offsetWidth
,
6819 height
= elem
.offsetHeight
;
6821 return ( width
=== 0 && height
=== 0 ) || (!jQuery
.support
.reliableHiddenOffsets
&& ((elem
.style
&& elem
.style
.display
) || jQuery
.css( elem
, "display" )) === "none");
6824 jQuery
.expr
.filters
.visible = function( elem
) {
6825 return !jQuery
.expr
.filters
.hidden( elem
);
6836 rheaders
= /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an
\r character at EOL
6837 rinput
= /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6838 // #7653, #8125, #8152: local protocol detection
6839 rlocalProtocol
= /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6840 rnoContent
= /^(?:GET|HEAD)$/,
6841 rprotocol
= /^\/\//,
6843 rscript
= /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6844 rselectTextarea
= /^(?:select|textarea)/i,
6845 rspacesAjax
= /\s+/,
6846 rts
= /([?&])_=[^&]*/,
6847 rurl
= /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6849 // Keep a copy of the old load method
6850 _load
= jQuery
.fn
.load
,
6853 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6854 * 2) These are called:
6855 * - BEFORE asking for a transport
6856 * - AFTER param serialization (s.data is a string if s.processData is true)
6857 * 3) key is the dataType
6858 * 4) the catchall symbol "*" can be used
6859 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6863 /* Transports bindings
6864 * 1) key is the dataType
6865 * 2) the catchall symbol "*" can be used
6866 * 3) selection will start with transport dataType and THEN go to "*" if needed
6870 // Document location
6873 // Document location segments
6876 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6877 allTypes
= ["*/"] + ["*"];
6879 // #8138, IE may throw an exception when accessing
6880 // a field from window.location if document.domain has been set
6882 ajaxLocation
= location
.href
;
6884 // Use the href attribute of an A element
6885 // since IE will modify it given document.location
6886 ajaxLocation
= document
.createElement( "a" );
6887 ajaxLocation
.href
= "";
6888 ajaxLocation
= ajaxLocation
.href
;
6891 // Segment location into parts
6892 ajaxLocParts
= rurl
.exec( ajaxLocation
.toLowerCase() ) || [];
6894 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6895 function addToPrefiltersOrTransports( structure
) {
6897 // dataTypeExpression is optional and defaults to "*"
6898 return function( dataTypeExpression
, func
) {
6900 if ( typeof dataTypeExpression
!== "string" ) {
6901 func
= dataTypeExpression
;
6902 dataTypeExpression
= "*";
6905 if ( jQuery
.isFunction( func
) ) {
6906 var dataTypes
= dataTypeExpression
.toLowerCase().split( rspacesAjax
),
6908 length
= dataTypes
.length
,
6913 // For each dataType in the dataTypeExpression
6914 for ( ; i
< length
; i
++ ) {
6915 dataType
= dataTypes
[ i
];
6916 // We control if we're asked to add before
6917 // any existing element
6918 placeBefore
= /^\+/.test( dataType
);
6919 if ( placeBefore
) {
6920 dataType
= dataType
.substr( 1 ) || "*";
6922 list
= structure
[ dataType
] = structure
[ dataType
] || [];
6923 // then we add to the structure accordingly
6924 list
[ placeBefore
? "unshift" : "push" ]( func
);
6930 // Base inspection function for prefilters and transports
6931 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
,
6932 dataType
/* internal */, inspected
/* internal */ ) {
6934 dataType
= dataType
|| options
.dataTypes
[ 0 ];
6935 inspected
= inspected
|| {};
6937 inspected
[ dataType
] = true;
6939 var list
= structure
[ dataType
],
6941 length
= list
? list
.length : 0,
6942 executeOnly
= ( structure
=== prefilters
),
6945 for ( ; i
< length
&& ( executeOnly
|| !selection
); i
++ ) {
6946 selection
= list
[ i
]( options
, originalOptions
, jqXHR
);
6947 // If we got redirected to another dataType
6948 // we try there if executing only and not done already
6949 if ( typeof selection
=== "string" ) {
6950 if ( !executeOnly
|| inspected
[ selection
] ) {
6951 selection
= undefined;
6953 options
.dataTypes
.unshift( selection
);
6954 selection
= inspectPrefiltersOrTransports(
6955 structure
, options
, originalOptions
, jqXHR
, selection
, inspected
);
6959 // If we're only executing or nothing was selected
6960 // we try the catchall dataType if not done already
6961 if ( ( executeOnly
|| !selection
) && !inspected
[ "*" ] ) {
6962 selection
= inspectPrefiltersOrTransports(
6963 structure
, options
, originalOptions
, jqXHR
, "*", inspected
);
6965 // unnecessary when only executing (prefilters)
6966 // but it'll be ignored by the caller in that case
6970 // A special extend for ajax options
6971 // that takes "flat" options (not to be deep extended)
6973 function ajaxExtend( target
, src
) {
6975 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
6976 for ( key
in src
) {
6977 if ( src
[ key
] !== undefined ) {
6978 ( flatOptions
[ key
] ? target : ( deep
|| ( deep
= {} ) ) )[ key
] = src
[ key
];
6982 jQuery
.extend( true, target
, deep
);
6987 load: function( url
, params
, callback
) {
6988 if ( typeof url
!== "string" && _load
) {
6989 return _load
.apply( this, arguments
);
6991 // Don't do a request if no elements are being requested
6992 } else if ( !this.length
) {
6996 var off
= url
.indexOf( " " );
6998 var selector
= url
.slice( off
, url
.length
);
6999 url
= url
.slice( 0, off
);
7002 // Default to a GET request
7005 // If the second parameter was provided
7007 // If it's a function
7008 if ( jQuery
.isFunction( params
) ) {
7009 // We assume that it's the callback
7013 // Otherwise, build a param string
7014 } else if ( typeof params
=== "object" ) {
7015 params
= jQuery
.param( params
, jQuery
.ajaxSettings
.traditional
);
7022 // Request the remote document
7028 // Complete callback (responseText is used internally)
7029 complete: function( jqXHR
, status
, responseText
) {
7030 // Store the response as specified by the jqXHR object
7031 responseText
= jqXHR
.responseText
;
7032 // If successful, inject the HTML into all the matched elements
7033 if ( jqXHR
.isResolved() ) {
7034 // #4825: Get the actual response in case
7035 // a dataFilter is present in ajaxSettings
7036 jqXHR
.done(function( r
) {
7039 // See if a selector was specified
7040 self
.html( selector
?
7041 // Create a dummy div to hold the results
7043 // inject the contents of the document in, removing the scripts
7044 // to avoid any 'Permission Denied' errors in IE
7045 .append(responseText
.replace(rscript
, ""))
7047 // Locate the specified elements
7050 // If not, just inject the full result
7055 self
.each( callback
, [ responseText
, status
, jqXHR
] );
7063 serialize: function() {
7064 return jQuery
.param( this.serializeArray() );
7067 serializeArray: function() {
7068 return this.map(function(){
7069 return this.elements
? jQuery
.makeArray( this.elements
) : this;
7072 return this.name
&& !this.disabled
&&
7073 ( this.checked
|| rselectTextarea
.test( this.nodeName
) ||
7074 rinput
.test( this.type
) );
7076 .map(function( i
, elem
){
7077 var val
= jQuery( this ).val();
7079 return val
== null ?
7081 jQuery
.isArray( val
) ?
7082 jQuery
.map( val
, function( val
, i
){
7083 return { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
7085 { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
7090 // Attach a bunch of functions for handling common AJAX events
7091 jQuery
.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i
, o
){
7092 jQuery
.fn
[ o
] = function( f
){
7093 return this.on( o
, f
);
7097 jQuery
.each( [ "get", "post" ], function( i
, method
) {
7098 jQuery
[ method
] = function( url
, data
, callback
, type
) {
7099 // shift arguments if data argument was omitted
7100 if ( jQuery
.isFunction( data
) ) {
7101 type
= type
|| callback
;
7106 return jQuery
.ajax({
7118 getScript: function( url
, callback
) {
7119 return jQuery
.get( url
, undefined, callback
, "script" );
7122 getJSON: function( url
, data
, callback
) {
7123 return jQuery
.get( url
, data
, callback
, "json" );
7126 // Creates a full fledged settings object into target
7127 // with both ajaxSettings and settings fields.
7128 // If target is omitted, writes into ajaxSettings.
7129 ajaxSetup: function( target
, settings
) {
7131 // Building a settings object
7132 ajaxExtend( target
, jQuery
.ajaxSettings
);
7134 // Extending ajaxSettings
7136 target
= jQuery
.ajaxSettings
;
7138 ajaxExtend( target
, settings
);
7144 isLocal: rlocalProtocol
.test( ajaxLocParts
[ 1 ] ),
7147 contentType: "application/x-www-form-urlencoded",
7162 xml: "application/xml, text/xml",
7165 json: "application/json, text/javascript",
7177 text: "responseText"
7180 // List of data converters
7181 // 1) key format is "source_type destination_type" (a single space in-between)
7182 // 2) the catchall symbol "*" can be used for source_type
7185 // Convert anything to text
7186 "* text": window
.String
,
7188 // Text to html (true = no transformation)
7191 // Evaluate text as a json expression
7192 "text json": jQuery
.parseJSON
,
7194 // Parse text as xml
7195 "text xml": jQuery
.parseXML
7198 // For options that shouldn't be deep extended:
7199 // you can add your own custom options here if
7200 // and when you create one that shouldn't be
7201 // deep extended (see ajaxExtend)
7208 ajaxPrefilter: addToPrefiltersOrTransports( prefilters
),
7209 ajaxTransport: addToPrefiltersOrTransports( transports
),
7212 ajax: function( url
, options
) {
7214 // If url is an object, simulate pre-1.5 signature
7215 if ( typeof url
=== "object" ) {
7220 // Force options to be an object
7221 options
= options
|| {};
7223 var // Create the final options object
7224 s
= jQuery
.ajaxSetup( {}, options
),
7225 // Callbacks context
7226 callbackContext
= s
.context
|| s
,
7227 // Context for global events
7228 // It's the callbackContext if one was provided in the options
7229 // and if it's a DOM node or a jQuery collection
7230 globalEventContext
= callbackContext
!== s
&&
7231 ( callbackContext
.nodeType
|| callbackContext
instanceof jQuery
) ?
7232 jQuery( callbackContext
) : jQuery
.event
,
7234 deferred
= jQuery
.Deferred(),
7235 completeDeferred
= jQuery
.Callbacks( "once memory" ),
7236 // Status-dependent callbacks
7237 statusCode
= s
.statusCode
|| {},
7240 // Headers (they are sent all at once)
7241 requestHeaders
= {},
7242 requestHeadersNames
= {},
7244 responseHeadersString
,
7250 // Cross-domain detection vars
7254 // To know if global events are to be dispatched
7263 // Caches the header
7264 setRequestHeader: function( name
, value
) {
7266 var lname
= name
.toLowerCase();
7267 name
= requestHeadersNames
[ lname
] = requestHeadersNames
[ lname
] || name
;
7268 requestHeaders
[ name
] = value
;
7274 getAllResponseHeaders: function() {
7275 return state
=== 2 ? responseHeadersString : null;
7278 // Builds headers hashtable if needed
7279 getResponseHeader: function( key
) {
7281 if ( state
=== 2 ) {
7282 if ( !responseHeaders
) {
7283 responseHeaders
= {};
7284 while( ( match
= rheaders
.exec( responseHeadersString
) ) ) {
7285 responseHeaders
[ match
[1].toLowerCase() ] = match
[ 2 ];
7288 match
= responseHeaders
[ key
.toLowerCase() ];
7290 return match
=== undefined ? null : match
;
7293 // Overrides response content-type header
7294 overrideMimeType: function( type
) {
7301 // Cancel the request
7302 abort: function( statusText
) {
7303 statusText
= statusText
|| "abort";
7305 transport
.abort( statusText
);
7307 done( 0, statusText
);
7312 // Callback for when everything is done
7313 // It is defined here because jslint complains if it is declared
7314 // at the end of the function (which would be more logical and readable)
7315 function done( status
, nativeStatusText
, responses
, headers
) {
7318 if ( state
=== 2 ) {
7322 // State is "done" now
7325 // Clear timeout if it exists
7326 if ( timeoutTimer
) {
7327 clearTimeout( timeoutTimer
);
7330 // Dereference transport for early garbage collection
7331 // (no matter how long the jqXHR object will be used)
7332 transport
= undefined;
7334 // Cache response headers
7335 responseHeadersString
= headers
|| "";
7338 jqXHR
.readyState
= status
> 0 ? 4 : 0;
7343 statusText
= nativeStatusText
,
7344 response
= responses
? ajaxHandleResponses( s
, jqXHR
, responses
) : undefined,
7348 // If successful, handle type chaining
7349 if ( status
>= 200 && status
< 300 || status
=== 304 ) {
7351 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7352 if ( s
.ifModified
) {
7354 if ( ( lastModified
= jqXHR
.getResponseHeader( "Last-Modified" ) ) ) {
7355 jQuery
.lastModified
[ ifModifiedKey
] = lastModified
;
7357 if ( ( etag
= jqXHR
.getResponseHeader( "Etag" ) ) ) {
7358 jQuery
.etag
[ ifModifiedKey
] = etag
;
7363 if ( status
=== 304 ) {
7365 statusText
= "notmodified";
7372 success
= ajaxConvert( s
, response
);
7373 statusText
= "success";
7376 // We have a parsererror
7377 statusText
= "parsererror";
7382 // We extract error from statusText
7383 // then normalize statusText and status for non-aborts
7385 if ( !statusText
|| status
) {
7386 statusText
= "error";
7393 // Set data for the fake xhr object
7394 jqXHR
.status
= status
;
7395 jqXHR
.statusText
= "" + ( nativeStatusText
|| statusText
);
7399 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
7401 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
7404 // Status-dependent callbacks
7405 jqXHR
.statusCode( statusCode
);
7406 statusCode
= undefined;
7408 if ( fireGlobals
) {
7409 globalEventContext
.trigger( "ajax" + ( isSuccess
? "Success" : "Error" ),
7410 [ jqXHR
, s
, isSuccess
? success : error
] );
7414 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
7416 if ( fireGlobals
) {
7417 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
7418 // Handle the global AJAX counter
7419 if ( !( --jQuery
.active
) ) {
7420 jQuery
.event
.trigger( "ajaxStop" );
7426 deferred
.promise( jqXHR
);
7427 jqXHR
.success
= jqXHR
.done
;
7428 jqXHR
.error
= jqXHR
.fail
;
7429 jqXHR
.complete
= completeDeferred
.add
;
7431 // Status-dependent callbacks
7432 jqXHR
.statusCode = function( map
) {
7436 for ( tmp
in map
) {
7437 statusCode
[ tmp
] = [ statusCode
[tmp
], map
[tmp
] ];
7440 tmp
= map
[ jqXHR
.status
];
7441 jqXHR
.then( tmp
, tmp
);
7447 // Remove hash character (#7531: and string promotion)
7448 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7449 // We also use the url parameter if available
7450 s
.url
= ( ( url
|| s
.url
) + "" ).replace( rhash
, "" ).replace( rprotocol
, ajaxLocParts
[ 1 ] + "//" );
7452 // Extract dataTypes list
7453 s
.dataTypes
= jQuery
.trim( s
.dataType
|| "*" ).toLowerCase().split( rspacesAjax
);
7455 // Determine if a cross-domain request is in order
7456 if ( s
.crossDomain
== null ) {
7457 parts
= rurl
.exec( s
.url
.toLowerCase() );
7458 s
.crossDomain
= !!( parts
&&
7459 ( parts
[ 1 ] != ajaxLocParts
[ 1 ] || parts
[ 2 ] != ajaxLocParts
[ 2 ] ||
7460 ( parts
[ 3 ] || ( parts
[ 1 ] === "http:" ? 80 : 443 ) ) !=
7461 ( ajaxLocParts
[ 3 ] || ( ajaxLocParts
[ 1 ] === "http:" ? 80 : 443 ) ) )
7465 // Convert data if not already a string
7466 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
7467 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
7471 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
7473 // If request was aborted inside a prefiler, stop there
7474 if ( state
=== 2 ) {
7478 // We can fire global events as of now if asked to
7479 fireGlobals
= s
.global
;
7481 // Uppercase the type
7482 s
.type
= s
.type
.toUpperCase();
7484 // Determine if request has content
7485 s
.hasContent
= !rnoContent
.test( s
.type
);
7487 // Watch for a new set of requests
7488 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
7489 jQuery
.event
.trigger( "ajaxStart" );
7492 // More options handling for requests with no content
7493 if ( !s
.hasContent
) {
7495 // If data is available, append data to url
7497 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.data
;
7498 // #9682: remove data so that it's not used in an eventual retry
7502 // Get ifModifiedKey before adding the anti-cache parameter
7503 ifModifiedKey
= s
.url
;
7505 // Add anti-cache in url if needed
7506 if ( s
.cache
=== false ) {
7508 var ts
= jQuery
.now(),
7509 // try replacing _= if it is there
7510 ret
= s
.url
.replace( rts
, "$1_=" + ts
);
7512 // if nothing was replaced, add timestamp to the end
7513 s
.url
= ret
+ ( ( ret
=== s
.url
) ? ( rquery
.test( s
.url
) ? "&" : "?" ) + "_=" + ts : "" );
7517 // Set the correct header, if data is being sent
7518 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
7519 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
7522 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7523 if ( s
.ifModified
) {
7524 ifModifiedKey
= ifModifiedKey
|| s
.url
;
7525 if ( jQuery
.lastModified
[ ifModifiedKey
] ) {
7526 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ ifModifiedKey
] );
7528 if ( jQuery
.etag
[ ifModifiedKey
] ) {
7529 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ ifModifiedKey
] );
7533 // Set the Accepts header for the server, depending on the dataType
7534 jqXHR
.setRequestHeader(
7536 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[0] ] ?
7537 s
.accepts
[ s
.dataTypes
[0] ] + ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
7541 // Check for headers option
7542 for ( i
in s
.headers
) {
7543 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
7546 // Allow custom headers/mimetypes and early abort
7547 if ( s
.beforeSend
&& ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || state
=== 2 ) ) {
7548 // Abort if not done already
7554 // Install callbacks on deferreds
7555 for ( i
in { success: 1, error: 1, complete: 1 } ) {
7556 jqXHR
[ i
]( s
[ i
] );
7560 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
7562 // If no transport, we auto-abort
7564 done( -1, "No Transport" );
7566 jqXHR
.readyState
= 1;
7567 // Send global event
7568 if ( fireGlobals
) {
7569 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
7572 if ( s
.async
&& s
.timeout
> 0 ) {
7573 timeoutTimer
= setTimeout( function(){
7574 jqXHR
.abort( "timeout" );
7580 transport
.send( requestHeaders
, done
);
7582 // Propagate exception as error if not done
7585 // Simply rethrow otherwise
7595 // Serialize an array of form elements or a set of
7596 // key/values into a query string
7597 param: function( a
, traditional
) {
7599 add = function( key
, value
) {
7600 // If value is a function, invoke it and return its value
7601 value
= jQuery
.isFunction( value
) ? value() : value
;
7602 s
[ s
.length
] = encodeURIComponent( key
) + "=" + encodeURIComponent( value
);
7605 // Set traditional to true for jQuery <= 1.3.2 behavior.
7606 if ( traditional
=== undefined ) {
7607 traditional
= jQuery
.ajaxSettings
.traditional
;
7610 // If an array was passed in, assume that it is an array of form elements.
7611 if ( jQuery
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
7612 // Serialize the form elements
7613 jQuery
.each( a
, function() {
7614 add( this.name
, this.value
);
7618 // If traditional, encode the "old" way (the way 1.3.2 or older
7619 // did it), otherwise encode params recursively.
7620 for ( var prefix
in a
) {
7621 buildParams( prefix
, a
[ prefix
], traditional
, add
);
7625 // Return the resulting serialization
7626 return s
.join( "&" ).replace( r20
, "+" );
7630 function buildParams( prefix
, obj
, traditional
, add
) {
7631 if ( jQuery
.isArray( obj
) ) {
7632 // Serialize array item.
7633 jQuery
.each( obj
, function( i
, v
) {
7634 if ( traditional
|| rbracket
.test( prefix
) ) {
7635 // Treat each array item as a scalar.
7639 // If array item is non-scalar (array or object), encode its
7640 // numeric index to resolve deserialization ambiguity issues.
7641 // Note that rack (as of 1.0.0) can't currently deserialize
7642 // nested arrays properly, and attempting to do so may cause
7643 // a server error. Possible fixes are to modify rack's
7644 // deserialization algorithm or to provide an option or flag
7645 // to force array serialization to be shallow.
7646 buildParams( prefix
+ "[" + ( typeof v
=== "object" || jQuery
.isArray(v
) ? i : "" ) + "]", v
, traditional
, add
);
7650 } else if ( !traditional
&& obj
!= null && typeof obj
=== "object" ) {
7651 // Serialize object item.
7652 for ( var name
in obj
) {
7653 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
7657 // Serialize scalar item.
7662 // This is still on the jQuery object... for now
7663 // Want to move this to jQuery.ajax some day
7666 // Counter for holding the number of active queries
7669 // Last-Modified header cache for next request
7675 /* Handles responses to an ajax request:
7676 * - sets all responseXXX fields accordingly
7677 * - finds the right dataType (mediates between content-type and expected dataType)
7678 * - returns the corresponding response
7680 function ajaxHandleResponses( s
, jqXHR
, responses
) {
7682 var contents
= s
.contents
,
7683 dataTypes
= s
.dataTypes
,
7684 responseFields
= s
.responseFields
,
7690 // Fill responseXXX fields
7691 for ( type
in responseFields
) {
7692 if ( type
in responses
) {
7693 jqXHR
[ responseFields
[type
] ] = responses
[ type
];
7697 // Remove auto dataType and get content-type in the process
7698 while( dataTypes
[ 0 ] === "*" ) {
7700 if ( ct
=== undefined ) {
7701 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "content-type" );
7705 // Check if we're dealing with a known content-type
7707 for ( type
in contents
) {
7708 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
7709 dataTypes
.unshift( type
);
7715 // Check to see if we have a response for the expected dataType
7716 if ( dataTypes
[ 0 ] in responses
) {
7717 finalDataType
= dataTypes
[ 0 ];
7719 // Try convertible dataTypes
7720 for ( type
in responses
) {
7721 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[0] ] ) {
7722 finalDataType
= type
;
7725 if ( !firstDataType
) {
7726 firstDataType
= type
;
7729 // Or just use first one
7730 finalDataType
= finalDataType
|| firstDataType
;
7733 // If we found a dataType
7734 // We add the dataType to the list if needed
7735 // and return the corresponding response
7736 if ( finalDataType
) {
7737 if ( finalDataType
!== dataTypes
[ 0 ] ) {
7738 dataTypes
.unshift( finalDataType
);
7740 return responses
[ finalDataType
];
7744 // Chain conversions given the request and the original response
7745 function ajaxConvert( s
, response
) {
7747 // Apply the dataFilter if provided
7748 if ( s
.dataFilter
) {
7749 response
= s
.dataFilter( response
, s
.dataType
);
7752 var dataTypes
= s
.dataTypes
,
7756 length
= dataTypes
.length
,
7758 // Current and previous dataTypes
7759 current
= dataTypes
[ 0 ],
7761 // Conversion expression
7763 // Conversion function
7765 // Conversion functions (transitive conversion)
7769 // For each dataType in the chain
7770 for ( i
= 1; i
< length
; i
++ ) {
7772 // Create converters map
7773 // with lowercased keys
7775 for ( key
in s
.converters
) {
7776 if ( typeof key
=== "string" ) {
7777 converters
[ key
.toLowerCase() ] = s
.converters
[ key
];
7782 // Get the dataTypes
7784 current
= dataTypes
[ i
];
7786 // If current is auto dataType, update it to prev
7787 if ( current
=== "*" ) {
7789 // If no auto and dataTypes are actually different
7790 } else if ( prev
!== "*" && prev
!== current
) {
7792 // Get the converter
7793 conversion
= prev
+ " " + current
;
7794 conv
= converters
[ conversion
] || converters
[ "* " + current
];
7796 // If there is no direct converter, search transitively
7799 for ( conv1
in converters
) {
7800 tmp
= conv1
.split( " " );
7801 if ( tmp
[ 0 ] === prev
|| tmp
[ 0 ] === "*" ) {
7802 conv2
= converters
[ tmp
[1] + " " + current
];
7804 conv1
= converters
[ conv1
];
7805 if ( conv1
=== true ) {
7807 } else if ( conv2
=== true ) {
7815 // If we found no converter, dispatch an error
7816 if ( !( conv
|| conv2
) ) {
7817 jQuery
.error( "No conversion from " + conversion
.replace(" "," to ") );
7819 // If found converter is not an equivalence
7820 if ( conv
!== true ) {
7821 // Convert with 1 or 2 converters accordingly
7822 response
= conv
? conv( response
) : conv2( conv1(response
) );
7832 var jsc
= jQuery
.now(),
7833 jsre
= /(\=)\?(&|$)|\?\?/i;
7835 // Default jsonp settings
7838 jsonpCallback: function() {
7839 return jQuery
.expando
+ "_" + ( jsc
++ );
7843 // Detect, normalize options and install callbacks for jsonp requests
7844 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
7846 var inspectData
= s
.contentType
=== "application/x-www-form-urlencoded" &&
7847 ( typeof s
.data
=== "string" );
7849 if ( s
.dataTypes
[ 0 ] === "jsonp" ||
7850 s
.jsonp
!== false && ( jsre
.test( s
.url
) ||
7851 inspectData
&& jsre
.test( s
.data
) ) ) {
7853 var responseContainer
,
7854 jsonpCallback
= s
.jsonpCallback
=
7855 jQuery
.isFunction( s
.jsonpCallback
) ? s
.jsonpCallback() : s
.jsonpCallback
,
7856 previous
= window
[ jsonpCallback
],
7859 replace
= "$1" + jsonpCallback
+ "$2";
7861 if ( s
.jsonp
!== false ) {
7862 url
= url
.replace( jsre
, replace
);
7863 if ( s
.url
=== url
) {
7864 if ( inspectData
) {
7865 data
= data
.replace( jsre
, replace
);
7867 if ( s
.data
=== data
) {
7868 // Add callback manually
7869 url
+= (/\?/.test( url
) ? "&" : "?") + s
.jsonp
+ "=" + jsonpCallback
;
7878 window
[ jsonpCallback
] = function( response
) {
7879 responseContainer
= [ response
];
7882 // Clean-up function
7883 jqXHR
.always(function() {
7884 // Set callback back to previous value
7885 window
[ jsonpCallback
] = previous
;
7886 // Call if it was a function and we have a response
7887 if ( responseContainer
&& jQuery
.isFunction( previous
) ) {
7888 window
[ jsonpCallback
]( responseContainer
[ 0 ] );
7892 // Use data converter to retrieve json after script execution
7893 s
.converters
["script json"] = function() {
7894 if ( !responseContainer
) {
7895 jQuery
.error( jsonpCallback
+ " was not called" );
7897 return responseContainer
[ 0 ];
7900 // force json dataType
7901 s
.dataTypes
[ 0 ] = "json";
7903 // Delegate to script
7911 // Install script dataType
7914 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7917 script: /javascript|ecmascript/
7920 "text script": function( text
) {
7921 jQuery
.globalEval( text
);
7927 // Handle cache's special case and global
7928 jQuery
.ajaxPrefilter( "script", function( s
) {
7929 if ( s
.cache
=== undefined ) {
7932 if ( s
.crossDomain
) {
7938 // Bind script tag hack transport
7939 jQuery
.ajaxTransport( "script", function(s
) {
7941 // This transport only deals with cross domain requests
7942 if ( s
.crossDomain
) {
7945 head
= document
.head
|| document
.getElementsByTagName( "head" )[0] || document
.documentElement
;
7949 send: function( _
, callback
) {
7951 script
= document
.createElement( "script" );
7953 script
.async
= "async";
7955 if ( s
.scriptCharset
) {
7956 script
.charset
= s
.scriptCharset
;
7961 // Attach handlers for all browsers
7962 script
.onload
= script
.onreadystatechange = function( _
, isAbort
) {
7964 if ( isAbort
|| !script
.readyState
|| /loaded|complete/.test( script
.readyState
) ) {
7966 // Handle memory leak in IE
7967 script
.onload
= script
.onreadystatechange
= null;
7969 // Remove the script
7970 if ( head
&& script
.parentNode
) {
7971 head
.removeChild( script
);
7974 // Dereference the script
7977 // Callback if not abort
7979 callback( 200, "success" );
7983 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
7984 // This arises when a base node is used (#2709 and #4378).
7985 head
.insertBefore( script
, head
.firstChild
);
7990 script
.onload( 0, 1 );
8000 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8001 xhrOnUnloadAbort
= window
.ActiveXObject
? function() {
8002 // Abort all pending requests
8003 for ( var key
in xhrCallbacks
) {
8004 xhrCallbacks
[ key
]( 0, 1 );
8010 // Functions to create xhrs
8011 function createStandardXHR() {
8013 return new window
.XMLHttpRequest();
8017 function createActiveXHR() {
8019 return new window
.ActiveXObject( "Microsoft.XMLHTTP" );
8023 // Create the request object
8024 // (This is still attached to ajaxSettings for backward compatibility)
8025 jQuery
.ajaxSettings
.xhr
= window
.ActiveXObject
?
8026 /* Microsoft failed to properly
8027 * implement the XMLHttpRequest in IE7 (can't request local files),
8028 * so we use the ActiveXObject when it is available
8029 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8030 * we need a fallback.
8033 return !this.isLocal
&& createStandardXHR() || createActiveXHR();
8035 // For all other browsers, use the standard XMLHttpRequest object
8038 // Determine support properties
8040 jQuery
.extend( jQuery
.support
, {
8042 cors: !!xhr
&& ( "withCredentials" in xhr
)
8044 })( jQuery
.ajaxSettings
.xhr() );
8046 // Create transport if the browser can provide an xhr
8047 if ( jQuery
.support
.ajax
) {
8049 jQuery
.ajaxTransport(function( s
) {
8050 // Cross domain only allowed if supported through XMLHttpRequest
8051 if ( !s
.crossDomain
|| jQuery
.support
.cors
) {
8056 send: function( headers
, complete
) {
8064 // Passing null username, generates a login popup on Opera (#2865)
8066 xhr
.open( s
.type
, s
.url
, s
.async
, s
.username
, s
.password
);
8068 xhr
.open( s
.type
, s
.url
, s
.async
);
8071 // Apply custom fields if provided
8072 if ( s
.xhrFields
) {
8073 for ( i
in s
.xhrFields
) {
8074 xhr
[ i
] = s
.xhrFields
[ i
];
8078 // Override mime type if needed
8079 if ( s
.mimeType
&& xhr
.overrideMimeType
) {
8080 xhr
.overrideMimeType( s
.mimeType
);
8083 // X-Requested-With header
8084 // For cross-domain requests, seeing as conditions for a preflight are
8085 // akin to a jigsaw puzzle, we simply never set it to be sure.
8086 // (it can always be set on a per-request basis or even using ajaxSetup)
8087 // For same-domain requests, won't change header if already provided.
8088 if ( !s
.crossDomain
&& !headers
["X-Requested-With"] ) {
8089 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
8092 // Need an extra try/catch for cross domain requests in Firefox 3
8094 for ( i
in headers
) {
8095 xhr
.setRequestHeader( i
, headers
[ i
] );
8099 // Do send the request
8100 // This may raise an exception which is actually
8101 // handled in jQuery.ajax (so no try/catch here)
8102 xhr
.send( ( s
.hasContent
&& s
.data
) || null );
8105 callback = function( _
, isAbort
) {
8113 // Firefox throws exceptions when accessing properties
8114 // of an xhr when a network error occured
8115 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8118 // Was never called and is aborted or complete
8119 if ( callback
&& ( isAbort
|| xhr
.readyState
=== 4 ) ) {
8122 callback
= undefined;
8124 // Do not keep as active anymore
8126 xhr
.onreadystatechange
= jQuery
.noop
;
8127 if ( xhrOnUnloadAbort
) {
8128 delete xhrCallbacks
[ handle
];
8134 // Abort it manually if needed
8135 if ( xhr
.readyState
!== 4 ) {
8139 status
= xhr
.status
;
8140 responseHeaders
= xhr
.getAllResponseHeaders();
8142 xml
= xhr
.responseXML
;
8144 // Construct response list
8145 if ( xml
&& xml
.documentElement
/* #4958 */ ) {
8146 responses
.xml
= xml
;
8148 responses
.text
= xhr
.responseText
;
8150 // Firefox throws an exception when accessing
8151 // statusText for faulty cross-domain requests
8153 statusText
= xhr
.statusText
;
8155 // We normalize with Webkit giving an empty statusText
8159 // Filter status for non standard behaviors
8161 // If the request is local and we have data: assume a success
8162 // (success with no data won't get notified, that's the best we
8163 // can do given current implementations)
8164 if ( !status
&& s
.isLocal
&& !s
.crossDomain
) {
8165 status
= responses
.text
? 200 : 404;
8166 // IE - #1450: sometimes returns 1223 when it should be 204
8167 } else if ( status
=== 1223 ) {
8172 } catch( firefoxAccessException
) {
8174 complete( -1, firefoxAccessException
);
8178 // Call complete if needed
8180 complete( status
, statusText
, responses
, responseHeaders
);
8184 // if we're in sync mode or it's in cache
8185 // and has been retrieved directly (IE6 & IE7)
8186 // we need to manually fire the callback
8187 if ( !s
.async
|| xhr
.readyState
=== 4 ) {
8191 if ( xhrOnUnloadAbort
) {
8192 // Create the active xhrs callbacks list if needed
8193 // and attach the unload handler
8194 if ( !xhrCallbacks
) {
8196 jQuery( window
).unload( xhrOnUnloadAbort
);
8198 // Add to list of active xhrs callbacks
8199 xhrCallbacks
[ handle
] = callback
;
8201 xhr
.onreadystatechange
= callback
;
8218 var elemdisplay
= {},
8220 rfxtypes
= /^(?:toggle|show|hide)$/,
8221 rfxnum
= /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8224 // height animations
8225 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8227 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8228 // opacity animations
8234 show: function( speed
, easing
, callback
) {
8237 if ( speed
|| speed
=== 0 ) {
8238 return this.animate( genFx("show", 3), speed
, easing
, callback
);
8241 for ( var i
= 0, j
= this.length
; i
< j
; i
++ ) {
8245 display
= elem
.style
.display
;
8247 // Reset the inline display of this element to learn if it is
8248 // being hidden by cascaded rules or not
8249 if ( !jQuery
._data(elem
, "olddisplay") && display
=== "none" ) {
8250 display
= elem
.style
.display
= "";
8253 // Set elements which have been overridden with display: none
8254 // in a stylesheet to whatever the default browser style is
8255 // for such an element
8256 if ( display
=== "" && jQuery
.css(elem
, "display") === "none" ) {
8257 jQuery
._data( elem
, "olddisplay", defaultDisplay(elem
.nodeName
) );
8262 // Set the display of most of the elements in a second loop
8263 // to avoid the constant reflow
8264 for ( i
= 0; i
< j
; i
++ ) {
8268 display
= elem
.style
.display
;
8270 if ( display
=== "" || display
=== "none" ) {
8271 elem
.style
.display
= jQuery
._data( elem
, "olddisplay" ) || "";
8280 hide: function( speed
, easing
, callback
) {
8281 if ( speed
|| speed
=== 0 ) {
8282 return this.animate( genFx("hide", 3), speed
, easing
, callback
);
8289 for ( ; i
< j
; i
++ ) {
8292 display
= jQuery
.css( elem
, "display" );
8294 if ( display
!== "none" && !jQuery
._data( elem
, "olddisplay" ) ) {
8295 jQuery
._data( elem
, "olddisplay", display
);
8300 // Set the display of the elements in a second loop
8301 // to avoid the constant reflow
8302 for ( i
= 0; i
< j
; i
++ ) {
8303 if ( this[i
].style
) {
8304 this[i
].style
.display
= "none";
8312 // Save the old toggle function
8313 _toggle: jQuery
.fn
.toggle
,
8315 toggle: function( fn
, fn2
, callback
) {
8316 var bool
= typeof fn
=== "boolean";
8318 if ( jQuery
.isFunction(fn
) && jQuery
.isFunction(fn2
) ) {
8319 this._toggle
.apply( this, arguments
);
8321 } else if ( fn
== null || bool
) {
8322 this.each(function() {
8323 var state
= bool
? fn : jQuery(this).is(":hidden");
8324 jQuery(this)[ state
? "show" : "hide" ]();
8328 this.animate(genFx("toggle", 3), fn
, fn2
, callback
);
8334 fadeTo: function( speed
, to
, easing
, callback
) {
8335 return this.filter(":hidden").css("opacity", 0).show().end()
8336 .animate({opacity: to
}, speed
, easing
, callback
);
8339 animate: function( prop
, speed
, easing
, callback
) {
8340 var optall
= jQuery
.speed( speed
, easing
, callback
);
8342 if ( jQuery
.isEmptyObject( prop
) ) {
8343 return this.each( optall
.complete
, [ false ] );
8346 // Do not change referenced properties as per-property easing will be lost
8347 prop
= jQuery
.extend( {}, prop
);
8349 function doAnimation() {
8350 // XXX 'this' does not always have a nodeName when running the
8353 if ( optall
.queue
=== false ) {
8354 jQuery
._mark( this );
8357 var opt
= jQuery
.extend( {}, optall
),
8358 isElement
= this.nodeType
=== 1,
8359 hidden
= isElement
&& jQuery(this).is(":hidden"),
8361 parts
, start
, end
, unit
,
8364 // will store per property easing and be used to determine when an animation is complete
8365 opt
.animatedProperties
= {};
8369 // property name normalization
8370 name
= jQuery
.camelCase( p
);
8372 prop
[ name
] = prop
[ p
];
8378 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8379 if ( jQuery
.isArray( val
) ) {
8380 opt
.animatedProperties
[ name
] = val
[ 1 ];
8381 val
= prop
[ name
] = val
[ 0 ];
8383 opt
.animatedProperties
[ name
] = opt
.specialEasing
&& opt
.specialEasing
[ name
] || opt
.easing
|| 'swing';
8386 if ( val
=== "hide" && hidden
|| val
=== "show" && !hidden
) {
8387 return opt
.complete
.call( this );
8390 if ( isElement
&& ( name
=== "height" || name
=== "width" ) ) {
8391 // Make sure that nothing sneaks out
8392 // Record all 3 overflow attributes because IE does not
8393 // change the overflow attribute when overflowX and
8394 // overflowY are set to the same value
8395 opt
.overflow
= [ this.style
.overflow
, this.style
.overflowX
, this.style
.overflowY
];
8397 // Set display property to inline-block for height/width
8398 // animations on inline elements that are having width/height animated
8399 if ( jQuery
.css( this, "display" ) === "inline" &&
8400 jQuery
.css( this, "float" ) === "none" ) {
8402 // inline-level elements accept inline-block;
8403 // block-level elements need to be inline with layout
8404 if ( !jQuery
.support
.inlineBlockNeedsLayout
|| defaultDisplay( this.nodeName
) === "inline" ) {
8405 this.style
.display
= "inline-block";
8408 this.style
.zoom
= 1;
8414 if ( opt
.overflow
!= null ) {
8415 this.style
.overflow
= "hidden";
8419 e
= new jQuery
.fx( this, opt
, p
);
8422 if ( rfxtypes
.test( val
) ) {
8424 // Tracks whether to show or hide based on private
8425 // data attached to the element
8426 method
= jQuery
._data( this, "toggle" + p
) || ( val
=== "toggle" ? hidden
? "show" : "hide" : 0 );
8428 jQuery
._data( this, "toggle" + p
, method
=== "show" ? "hide" : "show" );
8435 parts
= rfxnum
.exec( val
);
8439 end
= parseFloat( parts
[2] );
8440 unit
= parts
[3] || ( jQuery
.cssNumber
[ p
] ? "" : "px" );
8442 // We need to compute starting value
8443 if ( unit
!== "px" ) {
8444 jQuery
.style( this, p
, (end
|| 1) + unit
);
8445 start
= ( (end
|| 1) / e
.cur() ) * start
;
8446 jQuery
.style( this, p
, start
+ unit
);
8449 // If a +=/-= token was provided, we're doing a relative animation
8451 end
= ( (parts
[ 1 ] === "-=" ? -1 : 1) * end
) + start
;
8454 e
.custom( start
, end
, unit
);
8457 e
.custom( start
, val
, "" );
8462 // For JS strict compliance
8466 return optall
.queue
=== false ?
8467 this.each( doAnimation
) :
8468 this.queue( optall
.queue
, doAnimation
);
8471 stop: function( type
, clearQueue
, gotoEnd
) {
8472 if ( typeof type
!== "string" ) {
8473 gotoEnd
= clearQueue
;
8477 if ( clearQueue
&& type
!== false ) {
8478 this.queue( type
|| "fx", [] );
8481 return this.each(function() {
8484 timers
= jQuery
.timers
,
8485 data
= jQuery
._data( this );
8487 // clear marker counters if we know they won't be
8489 jQuery
._unmark( true, this );
8492 function stopQueue( elem
, data
, index
) {
8493 var hooks
= data
[ index
];
8494 jQuery
.removeData( elem
, index
, true );
8495 hooks
.stop( gotoEnd
);
8498 if ( type
== null ) {
8499 for ( index
in data
) {
8500 if ( data
[ index
] && data
[ index
].stop
&& index
.indexOf(".run") === index
.length
- 4 ) {
8501 stopQueue( this, data
, index
);
8504 } else if ( data
[ index
= type
+ ".run" ] && data
[ index
].stop
){
8505 stopQueue( this, data
, index
);
8508 for ( index
= timers
.length
; index
--; ) {
8509 if ( timers
[ index
].elem
=== this && (type
== null || timers
[ index
].queue
=== type
) ) {
8512 // force the next step to be the last
8513 timers
[ index
]( true );
8515 timers
[ index
].saveState();
8518 timers
.splice( index
, 1 );
8522 // start the next in the queue if the last step wasn't forced
8523 // timers currently will call their complete callbacks, which will dequeue
8524 // but only if they were gotoEnd
8525 if ( !( gotoEnd
&& hadTimers
) ) {
8526 jQuery
.dequeue( this, type
);
8533 // Animations created synchronously will run synchronously
8534 function createFxNow() {
8535 setTimeout( clearFxNow
, 0 );
8536 return ( fxNow
= jQuery
.now() );
8539 function clearFxNow() {
8543 // Generate parameters to create a standard animation
8544 function genFx( type
, num
) {
8547 jQuery
.each( fxAttrs
.concat
.apply([], fxAttrs
.slice( 0, num
)), function() {
8554 // Generate shortcuts for custom animations
8556 slideDown: genFx( "show", 1 ),
8557 slideUp: genFx( "hide", 1 ),
8558 slideToggle: genFx( "toggle", 1 ),
8559 fadeIn: { opacity: "show" },
8560 fadeOut: { opacity: "hide" },
8561 fadeToggle: { opacity: "toggle" }
8562 }, function( name
, props
) {
8563 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
8564 return this.animate( props
, speed
, easing
, callback
);
8569 speed: function( speed
, easing
, fn
) {
8570 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
8571 complete: fn
|| !fn
&& easing
||
8572 jQuery
.isFunction( speed
) && speed
,
8574 easing: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
8577 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration :
8578 opt
.duration
in jQuery
.fx
.speeds
? jQuery
.fx
.speeds
[ opt
.duration
] : jQuery
.fx
.speeds
._default
;
8580 // normalize opt.queue - true/undefined/null -> "fx"
8581 if ( opt
.queue
== null || opt
.queue
=== true ) {
8586 opt
.old
= opt
.complete
;
8588 opt
.complete = function( noUnmark
) {
8589 if ( jQuery
.isFunction( opt
.old
) ) {
8590 opt
.old
.call( this );
8594 jQuery
.dequeue( this, opt
.queue
);
8595 } else if ( noUnmark
!== false ) {
8596 jQuery
._unmark( this );
8604 linear: function( p
, n
, firstNum
, diff
) {
8605 return firstNum
+ diff
* p
;
8607 swing: function( p
, n
, firstNum
, diff
) {
8608 return ( ( -Math
.cos( p
*Math
.PI
) / 2 ) + 0.5 ) * diff
+ firstNum
;
8614 fx: function( elem
, options
, prop
) {
8615 this.options
= options
;
8619 options
.orig
= options
.orig
|| {};
8624 jQuery
.fx
.prototype = {
8625 // Simple function for setting a style value
8626 update: function() {
8627 if ( this.options
.step
) {
8628 this.options
.step
.call( this.elem
, this.now
, this );
8631 ( jQuery
.fx
.step
[ this.prop
] || jQuery
.fx
.step
._default
)( this );
8634 // Get the current size
8636 if ( this.elem
[ this.prop
] != null && (!this.elem
.style
|| this.elem
.style
[ this.prop
] == null) ) {
8637 return this.elem
[ this.prop
];
8641 r
= jQuery
.css( this.elem
, this.prop
);
8642 // Empty strings, null, undefined and "auto" are converted to 0,
8643 // complex values such as "rotate(1rad)" are returned as is,
8644 // simple values such as "10px" are parsed to Float.
8645 return isNaN( parsed
= parseFloat( r
) ) ? !r
|| r
=== "auto" ? 0 : r : parsed
;
8648 // Start an animation from one number to another
8649 custom: function( from, to
, unit
) {
8653 this.startTime
= fxNow
|| createFxNow();
8655 this.now
= this.start
= from;
8656 this.pos
= this.state
= 0;
8657 this.unit
= unit
|| this.unit
|| ( jQuery
.cssNumber
[ this.prop
] ? "" : "px" );
8659 function t( gotoEnd
) {
8660 return self
.step( gotoEnd
);
8663 t
.queue
= this.options
.queue
;
8665 t
.saveState = function() {
8666 if ( self
.options
.hide
&& jQuery
._data( self
.elem
, "fxshow" + self
.prop
) === undefined ) {
8667 jQuery
._data( self
.elem
, "fxshow" + self
.prop
, self
.start
);
8671 if ( t() && jQuery
.timers
.push(t
) && !timerId
) {
8672 timerId
= setInterval( fx
.tick
, fx
.interval
);
8676 // Simple 'show' function
8678 var dataShow
= jQuery
._data( this.elem
, "fxshow" + this.prop
);
8680 // Remember where we started, so that we can go back to it later
8681 this.options
.orig
[ this.prop
] = dataShow
|| jQuery
.style( this.elem
, this.prop
);
8682 this.options
.show
= true;
8684 // Begin the animation
8685 // Make sure that we start at a small width/height to avoid any flash of content
8686 if ( dataShow
!== undefined ) {
8687 // This show is picking up where a previous hide or show left off
8688 this.custom( this.cur(), dataShow
);
8690 this.custom( this.prop
=== "width" || this.prop
=== "height" ? 1 : 0, this.cur() );
8693 // Start by showing the element
8694 jQuery( this.elem
).show();
8697 // Simple 'hide' function
8699 // Remember where we started, so that we can go back to it later
8700 this.options
.orig
[ this.prop
] = jQuery
._data( this.elem
, "fxshow" + this.prop
) || jQuery
.style( this.elem
, this.prop
);
8701 this.options
.hide
= true;
8703 // Begin the animation
8704 this.custom( this.cur(), 0 );
8707 // Each step of an animation
8708 step: function( gotoEnd
) {
8710 t
= fxNow
|| createFxNow(),
8713 options
= this.options
;
8715 if ( gotoEnd
|| t
>= options
.duration
+ this.startTime
) {
8716 this.now
= this.end
;
8717 this.pos
= this.state
= 1;
8720 options
.animatedProperties
[ this.prop
] = true;
8722 for ( p
in options
.animatedProperties
) {
8723 if ( options
.animatedProperties
[ p
] !== true ) {
8729 // Reset the overflow
8730 if ( options
.overflow
!= null && !jQuery
.support
.shrinkWrapBlocks
) {
8732 jQuery
.each( [ "", "X", "Y" ], function( index
, value
) {
8733 elem
.style
[ "overflow" + value
] = options
.overflow
[ index
];
8737 // Hide the element if the "hide" operation was done
8738 if ( options
.hide
) {
8739 jQuery( elem
).hide();
8742 // Reset the properties, if the item has been hidden or shown
8743 if ( options
.hide
|| options
.show
) {
8744 for ( p
in options
.animatedProperties
) {
8745 jQuery
.style( elem
, p
, options
.orig
[ p
] );
8746 jQuery
.removeData( elem
, "fxshow" + p
, true );
8747 // Toggle data is no longer needed
8748 jQuery
.removeData( elem
, "toggle" + p
, true );
8752 // Execute the complete function
8753 // in the event that the complete function throws an exception
8754 // we must ensure it won't be called twice. #5684
8756 complete
= options
.complete
;
8759 options
.complete
= false;
8760 complete
.call( elem
);
8767 // classical easing cannot be used with an Infinity duration
8768 if ( options
.duration
== Infinity
) {
8771 n
= t
- this.startTime
;
8772 this.state
= n
/ options
.duration
;
8774 // Perform the easing function, defaults to swing
8775 this.pos
= jQuery
.easing
[ options
.animatedProperties
[this.prop
] ]( this.state
, n
, 0, 1, options
.duration
);
8776 this.now
= this.start
+ ( (this.end
- this.start
) * this.pos
);
8778 // Perform the next step of the animation
8786 jQuery
.extend( jQuery
.fx
, {
8789 timers
= jQuery
.timers
,
8792 for ( ; i
< timers
.length
; i
++ ) {
8793 timer
= timers
[ i
];
8794 // Checks the timer has not already been removed
8795 if ( !timer() && timers
[ i
] === timer
) {
8796 timers
.splice( i
--, 1 );
8800 if ( !timers
.length
) {
8808 clearInterval( timerId
);
8820 opacity: function( fx
) {
8821 jQuery
.style( fx
.elem
, "opacity", fx
.now
);
8824 _default: function( fx
) {
8825 if ( fx
.elem
.style
&& fx
.elem
.style
[ fx
.prop
] != null ) {
8826 fx
.elem
.style
[ fx
.prop
] = fx
.now
+ fx
.unit
;
8828 fx
.elem
[ fx
.prop
] = fx
.now
;
8834 // Adds width/height step functions
8835 // Do not set anything below 0
8836 jQuery
.each([ "width", "height" ], function( i
, prop
) {
8837 jQuery
.fx
.step
[ prop
] = function( fx
) {
8838 jQuery
.style( fx
.elem
, prop
, Math
.max(0, fx
.now
) + fx
.unit
);
8842 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
8843 jQuery
.expr
.filters
.animated = function( elem
) {
8844 return jQuery
.grep(jQuery
.timers
, function( fn
) {
8845 return elem
=== fn
.elem
;
8850 // Try to restore the default display value of an element
8851 function defaultDisplay( nodeName
) {
8853 if ( !elemdisplay
[ nodeName
] ) {
8855 var body
= document
.body
,
8856 elem
= jQuery( "<" + nodeName
+ ">" ).appendTo( body
),
8857 display
= elem
.css( "display" );
8860 // If the simple way fails,
8861 // get element's real default display by attaching it to a temp iframe
8862 if ( display
=== "none" || display
=== "" ) {
8863 // No iframe to use yet, so create it
8865 iframe
= document
.createElement( "iframe" );
8866 iframe
.frameBorder
= iframe
.width
= iframe
.height
= 0;
8869 body
.appendChild( iframe
);
8871 // Create a cacheable copy of the iframe document on first call.
8872 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8873 // document to it; WebKit & Firefox won't allow reusing the iframe document.
8874 if ( !iframeDoc
|| !iframe
.createElement
) {
8875 iframeDoc
= ( iframe
.contentWindow
|| iframe
.contentDocument
).document
;
8876 iframeDoc
.write( ( document
.compatMode
=== "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8880 elem
= iframeDoc
.createElement( nodeName
);
8882 iframeDoc
.body
.appendChild( elem
);
8884 display
= jQuery
.css( elem
, "display" );
8885 body
.removeChild( iframe
);
8888 // Store the correct default display
8889 elemdisplay
[ nodeName
] = display
;
8892 return elemdisplay
[ nodeName
];
8898 var rtable
= /^t(?:able|d|h)$/i,
8899 rroot
= /^(?:body|html)$/i;
8901 if ( "getBoundingClientRect" in document
.documentElement
) {
8902 jQuery
.fn
.offset = function( options
) {
8903 var elem
= this[0], box
;
8906 return this.each(function( i
) {
8907 jQuery
.offset
.setOffset( this, options
, i
);
8911 if ( !elem
|| !elem
.ownerDocument
) {
8915 if ( elem
=== elem
.ownerDocument
.body
) {
8916 return jQuery
.offset
.bodyOffset( elem
);
8920 box
= elem
.getBoundingClientRect();
8923 var doc
= elem
.ownerDocument
,
8924 docElem
= doc
.documentElement
;
8926 // Make sure we're not dealing with a disconnected DOM node
8927 if ( !box
|| !jQuery
.contains( docElem
, elem
) ) {
8928 return box
? { top: box
.top
, left: box
.left
} : { top: 0, left: 0 };
8931 var body
= doc
.body
,
8932 win
= getWindow(doc
),
8933 clientTop
= docElem
.clientTop
|| body
.clientTop
|| 0,
8934 clientLeft
= docElem
.clientLeft
|| body
.clientLeft
|| 0,
8935 scrollTop
= win
.pageYOffset
|| jQuery
.support
.boxModel
&& docElem
.scrollTop
|| body
.scrollTop
,
8936 scrollLeft
= win
.pageXOffset
|| jQuery
.support
.boxModel
&& docElem
.scrollLeft
|| body
.scrollLeft
,
8937 top
= box
.top
+ scrollTop
- clientTop
,
8938 left
= box
.left
+ scrollLeft
- clientLeft
;
8940 return { top: top
, left: left
};
8944 jQuery
.fn
.offset = function( options
) {
8948 return this.each(function( i
) {
8949 jQuery
.offset
.setOffset( this, options
, i
);
8953 if ( !elem
|| !elem
.ownerDocument
) {
8957 if ( elem
=== elem
.ownerDocument
.body
) {
8958 return jQuery
.offset
.bodyOffset( elem
);
8962 offsetParent
= elem
.offsetParent
,
8963 prevOffsetParent
= elem
,
8964 doc
= elem
.ownerDocument
,
8965 docElem
= doc
.documentElement
,
8967 defaultView
= doc
.defaultView
,
8968 prevComputedStyle
= defaultView
? defaultView
.getComputedStyle( elem
, null ) : elem
.currentStyle
,
8969 top
= elem
.offsetTop
,
8970 left
= elem
.offsetLeft
;
8972 while ( (elem
= elem
.parentNode
) && elem
!== body
&& elem
!== docElem
) {
8973 if ( jQuery
.support
.fixedPosition
&& prevComputedStyle
.position
=== "fixed" ) {
8977 computedStyle
= defaultView
? defaultView
.getComputedStyle(elem
, null) : elem
.currentStyle
;
8978 top
-= elem
.scrollTop
;
8979 left
-= elem
.scrollLeft
;
8981 if ( elem
=== offsetParent
) {
8982 top
+= elem
.offsetTop
;
8983 left
+= elem
.offsetLeft
;
8985 if ( jQuery
.support
.doesNotAddBorder
&& !(jQuery
.support
.doesAddBorderForTableAndCells
&& rtable
.test(elem
.nodeName
)) ) {
8986 top
+= parseFloat( computedStyle
.borderTopWidth
) || 0;
8987 left
+= parseFloat( computedStyle
.borderLeftWidth
) || 0;
8990 prevOffsetParent
= offsetParent
;
8991 offsetParent
= elem
.offsetParent
;
8994 if ( jQuery
.support
.subtractsBorderForOverflowNotVisible
&& computedStyle
.overflow
!== "visible" ) {
8995 top
+= parseFloat( computedStyle
.borderTopWidth
) || 0;
8996 left
+= parseFloat( computedStyle
.borderLeftWidth
) || 0;
8999 prevComputedStyle
= computedStyle
;
9002 if ( prevComputedStyle
.position
=== "relative" || prevComputedStyle
.position
=== "static" ) {
9003 top
+= body
.offsetTop
;
9004 left
+= body
.offsetLeft
;
9007 if ( jQuery
.support
.fixedPosition
&& prevComputedStyle
.position
=== "fixed" ) {
9008 top
+= Math
.max( docElem
.scrollTop
, body
.scrollTop
);
9009 left
+= Math
.max( docElem
.scrollLeft
, body
.scrollLeft
);
9012 return { top: top
, left: left
};
9018 bodyOffset: function( body
) {
9019 var top
= body
.offsetTop
,
9020 left
= body
.offsetLeft
;
9022 if ( jQuery
.support
.doesNotIncludeMarginInBodyOffset
) {
9023 top
+= parseFloat( jQuery
.css(body
, "marginTop") ) || 0;
9024 left
+= parseFloat( jQuery
.css(body
, "marginLeft") ) || 0;
9027 return { top: top
, left: left
};
9030 setOffset: function( elem
, options
, i
) {
9031 var position
= jQuery
.css( elem
, "position" );
9033 // set position first, in-case top/left are set even on static elem
9034 if ( position
=== "static" ) {
9035 elem
.style
.position
= "relative";
9038 var curElem
= jQuery( elem
),
9039 curOffset
= curElem
.offset(),
9040 curCSSTop
= jQuery
.css( elem
, "top" ),
9041 curCSSLeft
= jQuery
.css( elem
, "left" ),
9042 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) && jQuery
.inArray("auto", [curCSSTop
, curCSSLeft
]) > -1,
9043 props
= {}, curPosition
= {}, curTop
, curLeft
;
9045 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9046 if ( calculatePosition
) {
9047 curPosition
= curElem
.position();
9048 curTop
= curPosition
.top
;
9049 curLeft
= curPosition
.left
;
9051 curTop
= parseFloat( curCSSTop
) || 0;
9052 curLeft
= parseFloat( curCSSLeft
) || 0;
9055 if ( jQuery
.isFunction( options
) ) {
9056 options
= options
.call( elem
, i
, curOffset
);
9059 if ( options
.top
!= null ) {
9060 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
9062 if ( options
.left
!= null ) {
9063 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
9066 if ( "using" in options
) {
9067 options
.using
.call( elem
, props
);
9069 curElem
.css( props
);
9077 position: function() {
9084 // Get *real* offsetParent
9085 offsetParent
= this.offsetParent(),
9087 // Get correct offsets
9088 offset
= this.offset(),
9089 parentOffset
= rroot
.test(offsetParent
[0].nodeName
) ? { top: 0, left: 0 } : offsetParent
.offset();
9091 // Subtract element margins
9092 // note: when an element has margin: auto the offsetLeft and marginLeft
9093 // are the same in Safari causing offset.left to incorrectly be 0
9094 offset
.top
-= parseFloat( jQuery
.css(elem
, "marginTop") ) || 0;
9095 offset
.left
-= parseFloat( jQuery
.css(elem
, "marginLeft") ) || 0;
9097 // Add offsetParent borders
9098 parentOffset
.top
+= parseFloat( jQuery
.css(offsetParent
[0], "borderTopWidth") ) || 0;
9099 parentOffset
.left
+= parseFloat( jQuery
.css(offsetParent
[0], "borderLeftWidth") ) || 0;
9101 // Subtract the two offsets
9103 top: offset
.top
- parentOffset
.top
,
9104 left: offset
.left
- parentOffset
.left
9108 offsetParent: function() {
9109 return this.map(function() {
9110 var offsetParent
= this.offsetParent
|| document
.body
;
9111 while ( offsetParent
&& (!rroot
.test(offsetParent
.nodeName
) && jQuery
.css(offsetParent
, "position") === "static") ) {
9112 offsetParent
= offsetParent
.offsetParent
;
9114 return offsetParent
;
9120 // Create scrollLeft and scrollTop methods
9121 jQuery
.each( ["Left", "Top"], function( i
, name
) {
9122 var method
= "scroll" + name
;
9124 jQuery
.fn
[ method
] = function( val
) {
9127 if ( val
=== undefined ) {
9134 win
= getWindow( elem
);
9136 // Return the scroll offset
9137 return win
? ("pageXOffset" in win
) ? win
[ i
? "pageYOffset" : "pageXOffset" ] :
9138 jQuery
.support
.boxModel
&& win
.document
.documentElement
[ method
] ||
9139 win
.document
.body
[ method
] :
9143 // Set the scroll offset
9144 return this.each(function() {
9145 win
= getWindow( this );
9149 !i
? val : jQuery( win
).scrollLeft(),
9150 i
? val : jQuery( win
).scrollTop()
9154 this[ method
] = val
;
9160 function getWindow( elem
) {
9161 return jQuery
.isWindow( elem
) ?
9163 elem
.nodeType
=== 9 ?
9164 elem
.defaultView
|| elem
.parentWindow :
9171 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
9172 jQuery
.each([ "Height", "Width" ], function( i
, name
) {
9174 var type
= name
.toLowerCase();
9176 // innerHeight and innerWidth
9177 jQuery
.fn
[ "inner" + name
] = function() {
9181 parseFloat( jQuery
.css( elem
, type
, "padding" ) ) :
9186 // outerHeight and outerWidth
9187 jQuery
.fn
[ "outer" + name
] = function( margin
) {
9191 parseFloat( jQuery
.css( elem
, type
, margin
? "margin" : "border" ) ) :
9196 jQuery
.fn
[ type
] = function( size
) {
9197 // Get window width or height
9200 return size
== null ? null : this;
9203 if ( jQuery
.isFunction( size
) ) {
9204 return this.each(function( i
) {
9205 var self
= jQuery( this );
9206 self
[ type
]( size
.call( this, i
, self
[ type
]() ) );
9210 if ( jQuery
.isWindow( elem
) ) {
9211 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9212 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9213 var docElemProp
= elem
.document
.documentElement
[ "client" + name
],
9214 body
= elem
.document
.body
;
9215 return elem
.document
.compatMode
=== "CSS1Compat" && docElemProp
||
9216 body
&& body
[ "client" + name
] || docElemProp
;
9218 // Get document width or height
9219 } else if ( elem
.nodeType
=== 9 ) {
9220 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9222 elem
.documentElement
["client" + name
],
9223 elem
.body
["scroll" + name
], elem
.documentElement
["scroll" + name
],
9224 elem
.body
["offset" + name
], elem
.documentElement
["offset" + name
]
9227 // Get or set width or height on the element
9228 } else if ( size
=== undefined ) {
9229 var orig
= jQuery
.css( elem
, type
),
9230 ret
= parseFloat( orig
);
9232 return jQuery
.isNumeric( ret
) ? ret : orig
;
9234 // Set the width or height on the element (default to pixels if value is unitless)
9236 return this.css( type
, typeof size
=== "string" ? size : size
+ "px" );
9245 // Expose jQuery to the global object
9246 window
.jQuery
= window
.$ = jQuery
;
9248 // Expose jQuery as an AMD module, but only for AMD loaders that
9249 // understand the issues with loading multiple versions of jQuery
9250 // in a page that all might call define(). The loader will indicate
9251 // they have special allowances for multiple jQuery versions by
9252 // specifying define.amd.jQuery = true. Register as a named module,
9253 // since jQuery can be concatenated with other files that may use define,
9254 // but not use a proper concatenation script that understands anonymous
9255 // AMD modules. A named AMD is safest and most robust way to register.
9256 // Lowercase jquery is used because AMD module names are derived from
9257 // file names, and jQuery is normally delivered in a lowercase file name.
9258 // Do this after creating the global so that if an AMD module wants to call
9259 // noConflict to hide this version of jQuery, it will work.
9260 if ( typeof define
=== "function" && define
.amd
&& define
.amd
.jQuery
) {
9261 define( "jquery", [], function () { return jQuery
; } );