2 * jQuery JavaScript Library v1.7
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: Thu Nov 3 16:18:21 2011 -0400
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
53 // Match a standalone tag
54 rsingleTag
= /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
57 rvalidchars
= /^[\],:{}\s]*$/,
58 rvalidescape
= /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
59 rvalidtokens
= /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
60 rvalidbraces
= /(?:^|:|,)(?:\s*\[)+/g,
63 rwebkit
= /(webkit)[ \/]([\w.]+)/,
64 ropera
= /(opera)(?:.*version)?[ \/]([\w.]+)/,
65 rmsie
= /(msie) ([\w.]+)/,
66 rmozilla
= /(mozilla)(?:.*? rv:([\w.]+))?/,
68 // Matches dashed string for camelizing
69 rdashAlpha
= /-([a-z]|[0-9])/ig,
72 // Used by jQuery.camelCase as callback to replace()
73 fcamelCase = function( all
, letter
) {
74 return ( letter
+ "" ).toUpperCase();
77 // Keep a UserAgent string for use with jQuery.browser
78 userAgent
= navigator
.userAgent
,
80 // For matching the engine and version of the browser
83 // The deferred used on DOM ready
86 // The ready event handler
89 // Save a reference to some core methods
90 toString
= Object
.prototype.toString
,
91 hasOwn
= Object
.prototype.hasOwnProperty
,
92 push
= Array
.prototype.push
,
93 slice
= Array
.prototype.slice
,
94 trim
= String
.prototype.trim
,
95 indexOf
= Array
.prototype.indexOf
,
97 // [[Class]] -> type pairs
100 jQuery
.fn
= jQuery
.prototype = {
102 init: function( selector
, context
, rootjQuery
) {
103 var match
, elem
, ret
, doc
;
105 // Handle $(""), $(null), or $(undefined)
110 // Handle $(DOMElement)
111 if ( selector
.nodeType
) {
112 this.context
= this[0] = selector
;
117 // The body element only exists once, optimize finding it
118 if ( selector
=== "body" && !context
&& document
.body
) {
119 this.context
= document
;
120 this[0] = document
.body
;
121 this.selector
= selector
;
126 // Handle HTML strings
127 if ( typeof selector
=== "string" ) {
128 // Are we dealing with HTML string or an ID?
129 if ( selector
.charAt(0) === "<" && selector
.charAt( selector
.length
- 1 ) === ">" && selector
.length
>= 3 ) {
130 // Assume that strings that start and end with <> are HTML and skip the regex check
131 match
= [ null, selector
, null ];
134 match
= quickExpr
.exec( selector
);
137 // Verify a match, and that no context was specified for #id
138 if ( match
&& (match
[1] || !context
) ) {
140 // HANDLE: $(html) -> $(array)
142 context
= context
instanceof jQuery
? context
[0] : context
;
143 doc
= ( context
? context
.ownerDocument
|| context
: document
);
145 // If a single string is passed in and it's a single tag
146 // just do a createElement and skip the rest
147 ret
= rsingleTag
.exec( selector
);
150 if ( jQuery
.isPlainObject( context
) ) {
151 selector
= [ document
.createElement( ret
[1] ) ];
152 jQuery
.fn
.attr
.call( selector
, context
, true );
155 selector
= [ doc
.createElement( ret
[1] ) ];
159 ret
= jQuery
.buildFragment( [ match
[1] ], [ doc
] );
160 selector
= ( ret
.cacheable
? jQuery
.clone(ret
.fragment
) : ret
.fragment
).childNodes
;
163 return jQuery
.merge( this, selector
);
167 elem
= document
.getElementById( match
[2] );
169 // Check parentNode to catch when Blackberry 4.6 returns
170 // nodes that are no longer in the document #6963
171 if ( elem
&& elem
.parentNode
) {
172 // Handle the case where IE and Opera return items
173 // by name instead of ID
174 if ( elem
.id
!== match
[2] ) {
175 return rootjQuery
.find( selector
);
178 // Otherwise, we inject the element directly into the jQuery object
183 this.context
= document
;
184 this.selector
= selector
;
188 // HANDLE: $(expr, $(...))
189 } else if ( !context
|| context
.jquery
) {
190 return ( context
|| rootjQuery
).find( selector
);
192 // HANDLE: $(expr, context)
193 // (which is just equivalent to: $(context).find(expr)
195 return this.constructor( context
).find( selector
);
198 // HANDLE: $(function)
199 // Shortcut for document ready
200 } else if ( jQuery
.isFunction( selector
) ) {
201 return rootjQuery
.ready( selector
);
204 if ( selector
.selector
!== undefined ) {
205 this.selector
= selector
.selector
;
206 this.context
= selector
.context
;
209 return jQuery
.makeArray( selector
, this );
212 // Start with an empty selector
215 // The current version of jQuery being used
218 // The default length of a jQuery object is 0
221 // The number of elements contained in the matched element set
226 toArray: function() {
227 return slice
.call( this, 0 );
230 // Get the Nth element in the matched element set OR
231 // Get the whole matched element set as a clean array
232 get: function( num
) {
235 // Return a 'clean' array
238 // Return just the object
239 ( num
< 0 ? this[ this.length
+ num
] : this[ num
] );
242 // Take an array of elements and push it onto the stack
243 // (returning the new matched element set)
244 pushStack: function( elems
, name
, selector
) {
245 // Build a new jQuery matched element set
246 var ret
= this.constructor();
248 if ( jQuery
.isArray( elems
) ) {
249 push
.apply( ret
, elems
);
252 jQuery
.merge( ret
, elems
);
255 // Add the old object onto the stack (as a reference)
256 ret
.prevObject
= this;
258 ret
.context
= this.context
;
260 if ( name
=== "find" ) {
261 ret
.selector
= this.selector
+ ( this.selector
? " " : "" ) + selector
;
263 ret
.selector
= this.selector
+ "." + name
+ "(" + selector
+ ")";
266 // Return the newly-formed element set
270 // Execute a callback for every element in the matched set.
271 // (You can seed the arguments with an array of args, but this is
272 // only used internally.)
273 each: function( callback
, args
) {
274 return jQuery
.each( this, callback
, args
);
277 ready: function( fn
) {
278 // Attach the listeners
290 this.slice( i
, +i
+ 1 );
298 return this.eq( -1 );
302 return this.pushStack( slice
.apply( this, arguments
),
303 "slice", slice
.call(arguments
).join(",") );
306 map: function( callback
) {
307 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
308 return callback
.call( elem
, i
, elem
);
313 return this.prevObject
|| this.constructor(null);
316 // For internal use only.
317 // Behaves like an Array's method, not like a jQuery method.
323 // Give the init function the jQuery prototype for later instantiation
324 jQuery
.fn
.init
.prototype = jQuery
.fn
;
326 jQuery
.extend
= jQuery
.fn
.extend = function() {
327 var options
, name
, src
, copy
, copyIsArray
, clone
,
328 target
= arguments
[0] || {},
330 length
= arguments
.length
,
333 // Handle a deep copy situation
334 if ( typeof target
=== "boolean" ) {
336 target
= arguments
[1] || {};
337 // skip the boolean and the target
341 // Handle case when target is a string or something (possible in deep copy)
342 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
346 // extend jQuery itself if only one argument is passed
347 if ( length
=== i
) {
352 for ( ; i
< length
; i
++ ) {
353 // Only deal with non-null/undefined values
354 if ( (options
= arguments
[ i
]) != null ) {
355 // Extend the base object
356 for ( name
in options
) {
357 src
= target
[ name
];
358 copy
= options
[ name
];
360 // Prevent never-ending loop
361 if ( target
=== copy
) {
365 // Recurse if we're merging plain objects or arrays
366 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || (copyIsArray
= jQuery
.isArray(copy
)) ) ) {
369 clone
= src
&& jQuery
.isArray(src
) ? src
: [];
372 clone
= src
&& jQuery
.isPlainObject(src
) ? src
: {};
375 // Never move original objects, clone them
376 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
378 // Don't bring in undefined values
379 } else if ( copy
!== undefined ) {
380 target
[ name
] = copy
;
386 // Return the modified object
391 noConflict: function( deep
) {
392 if ( window
.$ === jQuery
) {
396 if ( deep
&& window
.jQuery
=== jQuery
) {
397 window
.jQuery
= _jQuery
;
403 // Is the DOM ready to be used? Set to true once it occurs.
406 // A counter to track how many items to wait for before
407 // the ready event fires. See #6781
410 // Hold (or release) the ready event
411 holdReady: function( hold
) {
415 jQuery
.ready( true );
419 // Handle when the DOM is ready
420 ready: function( wait
) {
421 // Either a released hold or an DOMready/load event and not yet ready
422 if ( (wait
=== true && !--jQuery
.readyWait
) || (wait
!== true && !jQuery
.isReady
) ) {
423 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
424 if ( !document
.body
) {
425 return setTimeout( jQuery
.ready
, 1 );
428 // Remember that the DOM is ready
429 jQuery
.isReady
= true;
431 // If a normal DOM Ready event fired, decrement, and wait if need be
432 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
436 // If there are functions bound, to execute
437 readyList
.fireWith( document
, [ jQuery
] );
439 // Trigger any bound ready events
440 if ( jQuery
.fn
.trigger
) {
441 jQuery( document
).trigger( "ready" ).unbind( "ready" );
446 bindReady: function() {
451 readyList
= jQuery
.Callbacks( "once memory" );
453 // Catch cases where $(document).ready() is called after the
454 // browser event has already occurred.
455 if ( document
.readyState
=== "complete" ) {
456 // Handle it asynchronously to allow scripts the opportunity to delay ready
457 return setTimeout( jQuery
.ready
, 1 );
460 // Mozilla, Opera and webkit nightlies currently support this event
461 if ( document
.addEventListener
) {
462 // Use the handy event callback
463 document
.addEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
465 // A fallback to window.onload, that will always work
466 window
.addEventListener( "load", jQuery
.ready
, false );
468 // If IE event model is used
469 } else if ( document
.attachEvent
) {
470 // ensure firing before onload,
471 // maybe late but safe also for iframes
472 document
.attachEvent( "onreadystatechange", DOMContentLoaded
);
474 // A fallback to window.onload, that will always work
475 window
.attachEvent( "onload", jQuery
.ready
);
477 // If IE and not a frame
478 // continually check to see if the document is ready
479 var toplevel
= false;
482 toplevel
= window
.frameElement
== null;
485 if ( document
.documentElement
.doScroll
&& toplevel
) {
491 // See test/unit/core.js for details concerning isFunction.
492 // Since version 1.3, DOM methods and functions like alert
493 // aren't supported. They return false on IE (#2968).
494 isFunction: function( obj
) {
495 return jQuery
.type(obj
) === "function";
498 isArray
: Array
.isArray
|| function( obj
) {
499 return jQuery
.type(obj
) === "array";
502 // A crude way of determining if an object is a window
503 isWindow: function( obj
) {
504 return obj
&& typeof obj
=== "object" && "setInterval" in obj
;
507 isNumeric: function( obj
) {
508 return obj
!= null && rdigit
.test( obj
) && !isNaN( obj
);
511 type: function( obj
) {
514 class2type
[ toString
.call(obj
) ] || "object";
517 isPlainObject: function( obj
) {
518 // Must be an Object.
519 // Because of IE, we also have to check the presence of the constructor property.
520 // Make sure that DOM nodes and window objects don't pass through, as well
521 if ( !obj
|| jQuery
.type(obj
) !== "object" || obj
.nodeType
|| jQuery
.isWindow( obj
) ) {
526 // Not own constructor property must be Object
527 if ( obj
.constructor &&
528 !hasOwn
.call(obj
, "constructor") &&
529 !hasOwn
.call(obj
.constructor.prototype, "isPrototypeOf") ) {
533 // IE8,9 Will throw exceptions on certain host objects #9897
537 // Own properties are enumerated firstly, so to speed up,
538 // if last one is own, then all properties are own.
541 for ( key
in obj
) {}
543 return key
=== undefined || hasOwn
.call( obj
, key
);
546 isEmptyObject: function( obj
) {
547 for ( var name
in obj
) {
553 error: function( msg
) {
557 parseJSON: function( data
) {
558 if ( typeof data
!== "string" || !data
) {
562 // Make sure leading/trailing whitespace is removed (IE can't handle it)
563 data
= jQuery
.trim( data
);
565 // Attempt to parse using the native JSON parser first
566 if ( window
.JSON
&& window
.JSON
.parse
) {
567 return window
.JSON
.parse( data
);
570 // Make sure the incoming data is actual JSON
571 // Logic borrowed from http://json.org/json2.js
572 if ( rvalidchars
.test( data
.replace( rvalidescape
, "@" )
573 .replace( rvalidtokens
, "]" )
574 .replace( rvalidbraces
, "")) ) {
576 return ( new Function( "return " + data
) )();
579 jQuery
.error( "Invalid JSON: " + data
);
582 // Cross-browser xml parsing
583 parseXML: function( data
) {
586 if ( window
.DOMParser
) { // Standard
587 tmp
= new DOMParser();
588 xml
= tmp
.parseFromString( data
, "text/xml" );
590 xml
= new ActiveXObject( "Microsoft.XMLDOM" );
597 if ( !xml
|| !xml
.documentElement
|| xml
.getElementsByTagName( "parsererror" ).length
) {
598 jQuery
.error( "Invalid XML: " + data
);
605 // Evaluates a script in a global context
606 // Workarounds based on findings by Jim Driscoll
607 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
608 globalEval: function( data
) {
609 if ( data
&& rnotwhite
.test( data
) ) {
610 // We use execScript on Internet Explorer
611 // We use an anonymous function so that context is window
612 // rather than jQuery in Firefox
613 ( window
.execScript
|| function( data
) {
614 window
[ "eval" ].call( window
, data
);
619 // Convert dashed to camelCase; used by the css and data modules
620 // Microsoft forgot to hump their vendor prefix (#9572)
621 camelCase: function( string
) {
622 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
625 nodeName: function( elem
, name
) {
626 return elem
.nodeName
&& elem
.nodeName
.toUpperCase() === name
.toUpperCase();
629 // args is for internal usage only
630 each: function( object
, callback
, args
) {
632 length
= object
.length
,
633 isObj
= length
=== undefined || jQuery
.isFunction( object
);
637 for ( name
in object
) {
638 if ( callback
.apply( object
[ name
], args
) === false ) {
643 for ( ; i
< length
; ) {
644 if ( callback
.apply( object
[ i
++ ], args
) === false ) {
650 // A special, fast, case for the most common use of each
653 for ( name
in object
) {
654 if ( callback
.call( object
[ name
], name
, object
[ name
] ) === false ) {
659 for ( ; i
< length
; ) {
660 if ( callback
.call( object
[ i
], i
, object
[ i
++ ] ) === false ) {
670 // Use native String.trim function wherever possible
673 return text
== null ?
678 // Otherwise use our own trimming functionality
680 return text
== null ?
682 text
.toString().replace( trimLeft
, "" ).replace( trimRight
, "" );
685 // results is for internal usage only
686 makeArray: function( array
, results
) {
687 var ret
= results
|| [];
689 if ( array
!= null ) {
690 // The window, strings (and functions) also have 'length'
691 // The extra typeof function check is to prevent crashes
692 // in Safari 2 (See: #3039)
693 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
694 var type
= jQuery
.type( array
);
696 if ( array
.length
== null || type
=== "string" || type
=== "function" || type
=== "regexp" || jQuery
.isWindow( array
) ) {
697 push
.call( ret
, array
);
699 jQuery
.merge( ret
, array
);
706 inArray: function( elem
, array
, i
) {
711 return indexOf
.call( array
, elem
, i
);
715 i
= i
? i
< 0 ? Math
.max( 0, len
+ i
) : i
: 0;
717 for ( ; i
< len
; i
++ ) {
718 // Skip accessing in sparse arrays
719 if ( i
in array
&& array
[ i
] === elem
) {
728 merge: function( first
, second
) {
729 var i
= first
.length
,
732 if ( typeof second
.length
=== "number" ) {
733 for ( var l
= second
.length
; j
< l
; j
++ ) {
734 first
[ i
++ ] = second
[ j
];
738 while ( second
[j
] !== undefined ) {
739 first
[ i
++ ] = second
[ j
++ ];
748 grep: function( elems
, callback
, inv
) {
749 var ret
= [], retVal
;
752 // Go through the array, only saving the items
753 // that pass the validator function
754 for ( var i
= 0, length
= elems
.length
; i
< length
; i
++ ) {
755 retVal
= !!callback( elems
[ i
], i
);
756 if ( inv
!== retVal
) {
757 ret
.push( elems
[ i
] );
764 // arg is for internal usage only
765 map: function( elems
, callback
, arg
) {
766 var value
, key
, ret
= [],
768 length
= elems
.length
,
769 // jquery objects are treated as arrays
770 isArray
= elems
instanceof jQuery
|| length
!== undefined && typeof length
=== "number" && ( ( length
> 0 && elems
[ 0 ] && elems
[ length
-1 ] ) || length
=== 0 || jQuery
.isArray( elems
) ) ;
772 // Go through the array, translating each of the items to their
774 for ( ; i
< length
; i
++ ) {
775 value
= callback( elems
[ i
], i
, arg
);
777 if ( value
!= null ) {
778 ret
[ ret
.length
] = value
;
782 // Go through every key on the object,
784 for ( key
in elems
) {
785 value
= callback( elems
[ key
], key
, arg
);
787 if ( value
!= null ) {
788 ret
[ ret
.length
] = value
;
793 // Flatten any nested arrays
794 return ret
.concat
.apply( [], ret
);
797 // A global GUID counter for objects
800 // Bind a function to a context, optionally partially applying any
802 proxy: function( fn
, context
) {
803 if ( typeof context
=== "string" ) {
804 var tmp
= fn
[ context
];
809 // Quick check to determine if target is callable, in the spec
810 // this throws a TypeError, but we will just return undefined.
811 if ( !jQuery
.isFunction( fn
) ) {
816 var args
= slice
.call( arguments
, 2 ),
818 return fn
.apply( context
, args
.concat( slice
.call( arguments
) ) );
821 // Set the guid of unique handler to the same of original handler, so it can be removed
822 proxy
.guid
= fn
.guid
= fn
.guid
|| proxy
.guid
|| jQuery
.guid
++;
827 // Mutifunctional method to get and set values to a collection
828 // The value/s can optionally be executed if it's a function
829 access: function( elems
, key
, value
, exec
, fn
, pass
) {
830 var length
= elems
.length
;
832 // Setting many attributes
833 if ( typeof key
=== "object" ) {
834 for ( var k
in key
) {
835 jQuery
.access( elems
, k
, key
[k
], exec
, fn
, value
);
840 // Setting one attribute
841 if ( value
!== undefined ) {
842 // Optionally, function values get executed if exec is true
843 exec
= !pass
&& exec
&& jQuery
.isFunction(value
);
845 for ( var i
= 0; i
< length
; i
++ ) {
846 fn( elems
[i
], key
, exec
? value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) : value
, pass
);
852 // Getting an attribute
853 return length
? fn( elems
[0], key
) : undefined;
857 return ( new Date() ).getTime();
860 // Use of jQuery.browser is frowned upon.
861 // More details: http://docs.jquery.com/Utilities/jQuery.browser
862 uaMatch: function( ua
) {
863 ua
= ua
.toLowerCase();
865 var match
= rwebkit
.exec( ua
) ||
868 ua
.indexOf("compatible") < 0 && rmozilla
.exec( ua
) ||
871 return { browser
: match
[1] || "", version
: match
[2] || "0" };
875 function jQuerySub( selector
, context
) {
876 return new jQuerySub
.fn
.init( selector
, context
);
878 jQuery
.extend( true, jQuerySub
, this );
879 jQuerySub
.superclass
= this;
880 jQuerySub
.fn
= jQuerySub
.prototype = this();
881 jQuerySub
.fn
.constructor = jQuerySub
;
882 jQuerySub
.sub
= this.sub
;
883 jQuerySub
.fn
.init
= function init( selector
, context
) {
884 if ( context
&& context
instanceof jQuery
&& !(context
instanceof jQuerySub
) ) {
885 context
= jQuerySub( context
);
888 return jQuery
.fn
.init
.call( this, selector
, context
, rootjQuerySub
);
890 jQuerySub
.fn
.init
.prototype = jQuerySub
.fn
;
891 var rootjQuerySub
= jQuerySub(document
);
898 // Populate the class2type map
899 jQuery
.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i
, name
) {
900 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
903 browserMatch
= jQuery
.uaMatch( userAgent
);
904 if ( browserMatch
.browser
) {
905 jQuery
.browser
[ browserMatch
.browser
] = true;
906 jQuery
.browser
.version
= browserMatch
.version
;
909 // Deprecated, use jQuery.browser.webkit instead
910 if ( jQuery
.browser
.webkit
) {
911 jQuery
.browser
.safari
= true;
914 // IE doesn't match non-breaking spaces with \s
915 if ( rnotwhite
.test( "\xA0" ) ) {
916 trimLeft
= /^[\s\xA0]+/;
917 trimRight
= /[\s\xA0]+$/;
920 // All jQuery objects should point back to these
921 rootjQuery
= jQuery(document
);
923 // Cleanup functions for the document ready method
924 if ( document
.addEventListener
) {
925 DOMContentLoaded = function() {
926 document
.removeEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
930 } else if ( document
.attachEvent
) {
931 DOMContentLoaded = function() {
932 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
933 if ( document
.readyState
=== "complete" ) {
934 document
.detachEvent( "onreadystatechange", DOMContentLoaded
);
940 // The DOM ready check for Internet Explorer
941 function doScrollCheck() {
942 if ( jQuery
.isReady
) {
947 // If IE is used, use the trick by Diego Perini
948 // http://javascript.nwbox.com/IEContentLoaded/
949 document
.documentElement
.doScroll("left");
951 setTimeout( doScrollCheck
, 1 );
955 // and execute any waiting functions
959 // Expose jQuery as an AMD module, but only for AMD loaders that
960 // understand the issues with loading multiple versions of jQuery
961 // in a page that all might call define(). The loader will indicate
962 // they have special allowances for multiple jQuery versions by
963 // specifying define.amd.jQuery = true. Register as a named module,
964 // since jQuery can be concatenated with other files that may use define,
965 // but not use a proper concatenation script that understands anonymous
966 // AMD modules. A named AMD is safest and most robust way to register.
967 // Lowercase jquery is used because AMD module names are derived from
968 // file names, and jQuery is normally delivered in a lowercase file name.
969 if ( typeof define
=== "function" && define
.amd
&& define
.amd
.jQuery
) {
970 define( "jquery", [], function () { return jQuery
; } );
978 // String to Object flags format cache
981 // Convert String-formatted flags into Object-formatted ones and store in cache
982 function createFlags( flags
) {
983 var object
= flagsCache
[ flags
] = {},
985 flags
= flags
.split( /\s+/ );
986 for ( i
= 0, length
= flags
.length
; i
< length
; i
++ ) {
987 object
[ flags
[i
] ] = true;
993 * Create a callback list using the following parameters:
995 * flags: an optional list of space-separated flags that will change how
996 * the callback list behaves
998 * By default a callback list will act like an event callback list and can be
999 * "fired" multiple times.
1003 * once: will ensure the callback list can only be fired once (like a Deferred)
1005 * memory: will keep track of previous values and will call any callback added
1006 * after the list has been fired right away with the latest "memorized"
1007 * values (like a Deferred)
1009 * unique: will ensure a callback can only be added once (no duplicate in the list)
1011 * stopOnFalse: interrupt callings when a callback returns false
1014 jQuery
.Callbacks = function( flags
) {
1016 // Convert flags from String-formatted to Object-formatted
1017 // (we check in cache first)
1018 flags
= flags
? ( flagsCache
[ flags
] || createFlags( flags
) ) : {};
1020 var // Actual callback list
1022 // Stack of fire calls for repeatable lists
1024 // Last fire value (for non-forgettable lists)
1026 // Flag to know if list is currently firing
1028 // First callback to fire (used internally by add and fireWith)
1030 // End of the loop when firing
1032 // Index of currently firing callback (modified by remove if needed)
1034 // Add one or several callbacks to the list
1035 add = function( args
) {
1041 for ( i
= 0, length
= args
.length
; i
< length
; i
++ ) {
1043 type
= jQuery
.type( elem
);
1044 if ( type
=== "array" ) {
1045 // Inspect recursively
1047 } else if ( type
=== "function" ) {
1048 // Add if not in unique mode and callback is not in
1049 if ( !flags
.unique
|| !self
.has( elem
) ) {
1056 fire = function( context
, args
) {
1058 memory
= !flags
.memory
|| [ context
, args
];
1060 firingIndex
= firingStart
|| 0;
1062 firingLength
= list
.length
;
1063 for ( ; list
&& firingIndex
< firingLength
; firingIndex
++ ) {
1064 if ( list
[ firingIndex
].apply( context
, args
) === false && flags
.stopOnFalse
) {
1065 memory
= true; // Mark as halted
1071 if ( !flags
.once
) {
1072 if ( stack
&& stack
.length
) {
1073 memory
= stack
.shift();
1074 self
.fireWith( memory
[ 0 ], memory
[ 1 ] );
1076 } else if ( memory
=== true ) {
1083 // Actual Callbacks object
1085 // Add a callback or a collection of callbacks to the list
1088 var length
= list
.length
;
1090 // Do we need to add the callbacks to the
1091 // current firing batch?
1093 firingLength
= list
.length
;
1094 // With memory, if we're not firing then
1095 // we should call right away, unless previous
1096 // firing was halted (stopOnFalse)
1097 } else if ( memory
&& memory
!== true ) {
1098 firingStart
= length
;
1099 fire( memory
[ 0 ], memory
[ 1 ] );
1104 // Remove a callback from the list
1105 remove: function() {
1107 var args
= arguments
,
1109 argLength
= args
.length
;
1110 for ( ; argIndex
< argLength
; argIndex
++ ) {
1111 for ( var i
= 0; i
< list
.length
; i
++ ) {
1112 if ( args
[ argIndex
] === list
[ i
] ) {
1113 // Handle firingIndex and firingLength
1115 if ( i
<= firingLength
) {
1117 if ( i
<= firingIndex
) {
1122 // Remove the element
1123 list
.splice( i
--, 1 );
1124 // If we have some unicity property then
1125 // we only need to do this once
1126 if ( flags
.unique
) {
1135 // Control if a given callback is in the list
1136 has: function( fn
) {
1139 length
= list
.length
;
1140 for ( ; i
< length
; i
++ ) {
1141 if ( fn
=== list
[ i
] ) {
1148 // Remove all callbacks from the list
1153 // Have the list do nothing anymore
1154 disable: function() {
1155 list
= stack
= memory
= undefined;
1159 disabled: function() {
1162 // Lock the list in its current state
1165 if ( !memory
|| memory
=== true ) {
1171 locked: function() {
1174 // Call all callbacks with the given context and arguments
1175 fireWith: function( context
, args
) {
1178 if ( !flags
.once
) {
1179 stack
.push( [ context
, args
] );
1181 } else if ( !( flags
.once
&& memory
) ) {
1182 fire( context
, args
);
1187 // Call all the callbacks with the given arguments
1189 self
.fireWith( this, arguments
);
1192 // To know if the callbacks have already been called at least once
1204 var // Static reference to slice
1205 sliceDeferred
= [].slice
;
1209 Deferred: function( func
) {
1210 var doneList
= jQuery
.Callbacks( "once memory" ),
1211 failList
= jQuery
.Callbacks( "once memory" ),
1212 progressList
= jQuery
.Callbacks( "memory" ),
1217 notify
: progressList
1222 progress
: progressList
.add
,
1229 isResolved
: doneList
.fired
,
1230 isRejected
: failList
.fired
,
1232 then: function( doneCallbacks
, failCallbacks
, progressCallbacks
) {
1233 deferred
.done( doneCallbacks
).fail( failCallbacks
).progress( progressCallbacks
);
1236 always: function() {
1237 return deferred
.done
.apply( deferred
, arguments
).fail
.apply( deferred
, arguments
);
1239 pipe: function( fnDone
, fnFail
, fnProgress
) {
1240 return jQuery
.Deferred(function( newDefer
) {
1242 done
: [ fnDone
, "resolve" ],
1243 fail
: [ fnFail
, "reject" ],
1244 progress
: [ fnProgress
, "notify" ]
1245 }, function( handler
, data
) {
1249 if ( jQuery
.isFunction( fn
) ) {
1250 deferred
[ handler
](function() {
1251 returned
= fn
.apply( this, arguments
);
1252 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
1253 returned
.promise().then( newDefer
.resolve
, newDefer
.reject
, newDefer
.notify
);
1255 newDefer
[ action
+ "With" ]( this === deferred
? newDefer
: this, [ returned
] );
1259 deferred
[ handler
]( newDefer
[ action
] );
1264 // Get a promise for this deferred
1265 // If obj is provided, the promise aspect is added to the object
1266 promise: function( obj
) {
1267 if ( obj
== null ) {
1270 for ( var key
in promise
) {
1271 obj
[ key
] = promise
[ key
];
1277 deferred
= promise
.promise({}),
1280 for ( key
in lists
) {
1281 deferred
[ key
] = lists
[ key
].fire
;
1282 deferred
[ key
+ "With" ] = lists
[ key
].fireWith
;
1286 deferred
.done( function() {
1288 }, failList
.disable
, progressList
.lock
).fail( function() {
1290 }, doneList
.disable
, progressList
.lock
);
1292 // Call given func if any
1294 func
.call( deferred
, deferred
);
1302 when: function( firstParam
) {
1303 var args
= sliceDeferred
.call( arguments
, 0 ),
1305 length
= args
.length
,
1306 pValues
= new Array( length
),
1309 deferred
= length
<= 1 && firstParam
&& jQuery
.isFunction( firstParam
.promise
) ?
1312 promise
= deferred
.promise();
1313 function resolveFunc( i
) {
1314 return function( value
) {
1315 args
[ i
] = arguments
.length
> 1 ? sliceDeferred
.call( arguments
, 0 ) : value
;
1316 if ( !( --count
) ) {
1317 deferred
.resolveWith( deferred
, args
);
1321 function progressFunc( i
) {
1322 return function( value
) {
1323 pValues
[ i
] = arguments
.length
> 1 ? sliceDeferred
.call( arguments
, 0 ) : value
;
1324 deferred
.notifyWith( promise
, pValues
);
1328 for ( ; i
< length
; i
++ ) {
1329 if ( args
[ i
] && args
[ i
].promise
&& jQuery
.isFunction( args
[ i
].promise
) ) {
1330 args
[ i
].promise().then( resolveFunc(i
), deferred
.reject
, progressFunc(i
) );
1336 deferred
.resolveWith( deferred
, args
);
1338 } else if ( deferred
!== firstParam
) {
1339 deferred
.resolveWith( deferred
, length
? [ firstParam
] : [] );
1348 jQuery
.support
= (function() {
1350 var div
= document
.createElement( "div" ),
1351 documentElement
= document
.documentElement
,
1370 // Preliminary tests
1371 div
.setAttribute("className", "t");
1372 div
.innerHTML
= " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/><nav></nav>";
1375 all
= div
.getElementsByTagName( "*" );
1376 a
= div
.getElementsByTagName( "a" )[ 0 ];
1378 // Can't get basic test support
1379 if ( !all
|| !all
.length
|| !a
) {
1383 // First batch of supports tests
1384 select
= document
.createElement( "select" );
1385 opt
= select
.appendChild( document
.createElement("option") );
1386 input
= div
.getElementsByTagName( "input" )[ 0 ];
1389 // IE strips leading whitespace when .innerHTML is used
1390 leadingWhitespace
: ( div
.firstChild
.nodeType
=== 3 ),
1392 // Make sure that tbody elements aren't automatically inserted
1393 // IE will insert them into empty tables
1394 tbody
: !div
.getElementsByTagName( "tbody" ).length
,
1396 // Make sure that link elements get serialized correctly by innerHTML
1397 // This requires a wrapper element in IE
1398 htmlSerialize
: !!div
.getElementsByTagName( "link" ).length
,
1400 // Get the style information from getAttribute
1401 // (IE uses .cssText instead)
1402 style
: /top/.test( a
.getAttribute("style") ),
1404 // Make sure that URLs aren't manipulated
1405 // (IE normalizes it by default)
1406 hrefNormalized
: ( a
.getAttribute( "href" ) === "/a" ),
1408 // Make sure that element opacity exists
1409 // (IE uses filter instead)
1410 // Use a regex to work around a WebKit issue. See #5145
1411 opacity
: /^0.55/.test( a
.style
.opacity
),
1413 // Verify style float existence
1414 // (IE uses styleFloat instead of cssFloat)
1415 cssFloat
: !!a
.style
.cssFloat
,
1417 // Make sure unknown elements (like HTML5 elems) are handled appropriately
1418 unknownElems
: !!div
.getElementsByTagName( "nav" ).length
,
1420 // Make sure that if no value is specified for a checkbox
1421 // that it defaults to "on".
1422 // (WebKit defaults to "" instead)
1423 checkOn
: ( input
.value
=== "on" ),
1425 // Make sure that a selected-by-default option has a working selected property.
1426 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1427 optSelected
: opt
.selected
,
1429 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1430 getSetAttribute
: div
.className
!== "t",
1432 // Tests for enctype support on a form(#6743)
1433 enctype
: !!document
.createElement("form").enctype
,
1435 // Will be defined later
1436 submitBubbles
: true,
1437 changeBubbles
: true,
1438 focusinBubbles
: false,
1439 deleteExpando
: true,
1441 inlineBlockNeedsLayout
: false,
1442 shrinkWrapBlocks
: false,
1443 reliableMarginRight
: true
1446 // Make sure checked status is properly cloned
1447 input
.checked
= true;
1448 support
.noCloneChecked
= input
.cloneNode( true ).checked
;
1450 // Make sure that the options inside disabled selects aren't marked as disabled
1451 // (WebKit marks them as disabled)
1452 select
.disabled
= true;
1453 support
.optDisabled
= !opt
.disabled
;
1455 // Test to see if it's possible to delete an expando from an element
1456 // Fails in Internet Explorer
1460 support
.deleteExpando
= false;
1463 if ( !div
.addEventListener
&& div
.attachEvent
&& div
.fireEvent
) {
1464 div
.attachEvent( "onclick", function() {
1465 // Cloning a node shouldn't copy over any
1466 // bound event handlers (IE does this)
1467 support
.noCloneEvent
= false;
1469 div
.cloneNode( true ).fireEvent( "onclick" );
1472 // Check if a radio maintains its value
1473 // after being appended to the DOM
1474 input
= document
.createElement("input");
1476 input
.setAttribute("type", "radio");
1477 support
.radioValue
= input
.value
=== "t";
1479 input
.setAttribute("checked", "checked");
1480 div
.appendChild( input
);
1481 fragment
= document
.createDocumentFragment();
1482 fragment
.appendChild( div
.lastChild
);
1484 // WebKit doesn't clone checked state correctly in fragments
1485 support
.checkClone
= fragment
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
1489 // Figure out if the W3C box model works as expected
1490 div
.style
.width
= div
.style
.paddingLeft
= "1px";
1492 // We don't want to do body-related feature tests on frameset
1493 // documents, which lack a body. So we use
1494 // document.getElementsByTagName("body")[0], which is undefined in
1495 // frameset documents, while document.body isn’t. (7398)
1496 body
= document
.getElementsByTagName("body")[ 0 ];
1497 // We use our own, invisible, body unless the body is already present
1498 // in which case we use a div (#9239)
1499 testElement
= document
.createElement( body
? "div" : "body" );
1500 testElementStyle
= {
1501 visibility
: "hidden",
1509 jQuery
.extend( testElementStyle
, {
1510 position
: "absolute",
1515 for ( i
in testElementStyle
) {
1516 testElement
.style
[ i
] = testElementStyle
[ i
];
1518 testElement
.appendChild( div
);
1519 testElementParent
= body
|| documentElement
;
1520 testElementParent
.insertBefore( testElement
, testElementParent
.firstChild
);
1522 // Check if a disconnected checkbox will retain its checked
1523 // value of true after appended to the DOM (IE6/7)
1524 support
.appendChecked
= input
.checked
;
1526 support
.boxModel
= div
.offsetWidth
=== 2;
1528 if ( "zoom" in div
.style
) {
1529 // Check if natively block-level elements act like inline-block
1530 // elements when setting their display to 'inline' and giving
1532 // (IE < 8 does this)
1533 div
.style
.display
= "inline";
1535 support
.inlineBlockNeedsLayout
= ( div
.offsetWidth
=== 2 );
1537 // Check if elements with layout shrink-wrap their children
1539 div
.style
.display
= "";
1540 div
.innerHTML
= "<div style='width:4px;'></div>";
1541 support
.shrinkWrapBlocks
= ( div
.offsetWidth
!== 2 );
1544 div
.innerHTML
= "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1545 tds
= div
.getElementsByTagName( "td" );
1547 // Check if table cells still have offsetWidth/Height when they are set
1548 // to display:none and there are still other visible table cells in a
1549 // table row; if so, offsetWidth/Height are not reliable for use when
1550 // determining if an element has been hidden directly using
1551 // display:none (it is still safe to use offsets if a parent element is
1552 // hidden; don safety goggles and see bug #4512 for more information).
1553 // (only IE 8 fails this test)
1554 isSupported
= ( tds
[ 0 ].offsetHeight
=== 0 );
1556 tds
[ 0 ].style
.display
= "";
1557 tds
[ 1 ].style
.display
= "none";
1559 // Check if empty table cells still have offsetWidth/Height
1560 // (IE < 8 fail this test)
1561 support
.reliableHiddenOffsets
= isSupported
&& ( tds
[ 0 ].offsetHeight
=== 0 );
1564 // Check if div with explicit width and no margin-right incorrectly
1565 // gets computed margin-right based on width of container. For more
1566 // info see bug #3333
1567 // Fails in WebKit before Feb 2011 nightlies
1568 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1569 if ( document
.defaultView
&& document
.defaultView
.getComputedStyle
) {
1570 marginDiv
= document
.createElement( "div" );
1571 marginDiv
.style
.width
= "0";
1572 marginDiv
.style
.marginRight
= "0";
1573 div
.appendChild( marginDiv
);
1574 support
.reliableMarginRight
=
1575 ( parseInt( ( document
.defaultView
.getComputedStyle( marginDiv
, null ) || { marginRight
: 0 } ).marginRight
, 10 ) || 0 ) === 0;
1578 // Technique from Juriy Zaytsev
1579 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1580 // We only care about the case where non-standard event systems
1581 // are used, namely in IE. Short-circuiting here helps us to
1582 // avoid an eval call (in setAttribute) which can cause CSP
1583 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1584 if ( div
.attachEvent
) {
1590 eventName
= "on" + i
;
1591 isSupported
= ( eventName
in div
);
1592 if ( !isSupported
) {
1593 div
.setAttribute( eventName
, "return;" );
1594 isSupported
= ( typeof div
[ eventName
] === "function" );
1596 support
[ i
+ "Bubbles" ] = isSupported
;
1600 // Run fixed position tests at doc ready to avoid a crash
1601 // related to the invisible body in IE8
1603 var container
, outer
, inner
, table
, td
, offsetSupport
,
1605 ptlm
= "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",
1606 vb
= "visibility:hidden;border:0;",
1607 style
= "style='" + ptlm
+ "border:5px solid #000;padding:0;'",
1608 html
= "<div " + style
+ "><div></div></div>" +
1609 "<table " + style
+ " cellpadding='0' cellspacing='0'>" +
1610 "<tr><td></td></tr></table>";
1612 // Reconstruct a container
1613 body
= document
.getElementsByTagName("body")[0];
1615 // Return for frameset docs that don't have a body
1616 // These tests cannot be done
1620 container
= document
.createElement("div");
1621 container
.style
.cssText
= vb
+ "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop
+ "px";
1622 body
.insertBefore( container
, body
.firstChild
);
1624 // Construct a test element
1625 testElement
= document
.createElement("div");
1626 testElement
.style
.cssText
= ptlm
+ vb
;
1628 testElement
.innerHTML
= html
;
1629 container
.appendChild( testElement
);
1630 outer
= testElement
.firstChild
;
1631 inner
= outer
.firstChild
;
1632 td
= outer
.nextSibling
.firstChild
.firstChild
;
1635 doesNotAddBorder
: ( inner
.offsetTop
!== 5 ),
1636 doesAddBorderForTableAndCells
: ( td
.offsetTop
=== 5 )
1639 inner
.style
.position
= "fixed";
1640 inner
.style
.top
= "20px";
1642 // safari subtracts parent border width here which is 5px
1643 offsetSupport
.fixedPosition
= ( inner
.offsetTop
=== 20 || inner
.offsetTop
=== 15 );
1644 inner
.style
.position
= inner
.style
.top
= "";
1646 outer
.style
.overflow
= "hidden";
1647 outer
.style
.position
= "relative";
1649 offsetSupport
.subtractsBorderForOverflowNotVisible
= ( inner
.offsetTop
=== -5 );
1650 offsetSupport
.doesNotIncludeMarginInBodyOffset
= ( body
.offsetTop
!== conMarginTop
);
1652 body
.removeChild( container
);
1653 testElement
= container
= null;
1655 jQuery
.extend( support
, offsetSupport
);
1658 testElement
.innerHTML
= "";
1659 testElementParent
.removeChild( testElement
);
1661 // Null connected elements to avoid leaks in IE
1662 testElement
= fragment
= select
= opt
= body
= marginDiv
= div
= input
= null;
1667 // Keep track of boxModel
1668 jQuery
.boxModel
= jQuery
.support
.boxModel
;
1673 var rbrace
= /^(?:\{.*\}|\[.*\])$/,
1674 rmultiDash
= /([A-Z])/g;
1679 // Please use with caution
1682 // Unique for each copy of jQuery on the page
1683 // Non-digits removed to match rinlinejQuery
1684 expando
: "jQuery" + ( jQuery
.fn
.jquery
+ Math
.random() ).replace( /\D/g, "" ),
1686 // The following elements throw uncatchable exceptions if you
1687 // attempt to add expando properties to them.
1690 // Ban all objects except for Flash (which handle expandos)
1691 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1695 hasData: function( elem
) {
1696 elem
= elem
.nodeType
? jQuery
.cache
[ elem
[jQuery
.expando
] ] : elem
[ jQuery
.expando
];
1697 return !!elem
&& !isEmptyDataObject( elem
);
1700 data: function( elem
, name
, data
, pvt
/* Internal Use Only */ ) {
1701 if ( !jQuery
.acceptData( elem
) ) {
1705 var privateCache
, thisCache
, ret
,
1706 internalKey
= jQuery
.expando
,
1707 getByName
= typeof name
=== "string",
1709 // We have to handle DOM nodes and JS objects differently because IE6-7
1710 // can't GC object references properly across the DOM-JS boundary
1711 isNode
= elem
.nodeType
,
1713 // Only DOM nodes need the global jQuery cache; JS object data is
1714 // attached directly to the object so GC can occur automatically
1715 cache
= isNode
? jQuery
.cache
: elem
,
1717 // Only defining an ID for JS objects if its cache already exists allows
1718 // the code to shortcut on the same path as a DOM node with no cache
1719 id
= isNode
? elem
[ jQuery
.expando
] : elem
[ jQuery
.expando
] && jQuery
.expando
,
1720 isEvents
= name
=== "events";
1722 // Avoid doing any more work than we need to when trying to get data on an
1723 // object that has no data at all
1724 if ( (!id
|| !cache
[id
] || (!isEvents
&& !pvt
&& !cache
[id
].data
)) && getByName
&& data
=== undefined ) {
1729 // Only DOM nodes need a new unique ID for each element since their data
1730 // ends up in the global cache
1732 elem
[ jQuery
.expando
] = id
= ++jQuery
.uuid
;
1734 id
= jQuery
.expando
;
1738 if ( !cache
[ id
] ) {
1741 // Avoids exposing jQuery metadata on plain JS objects when the object
1742 // is serialized using JSON.stringify
1744 cache
[ id
].toJSON
= jQuery
.noop
;
1748 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1749 // shallow copied over onto the existing cache
1750 if ( typeof name
=== "object" || typeof name
=== "function" ) {
1752 cache
[ id
] = jQuery
.extend( cache
[ id
], name
);
1754 cache
[ id
].data
= jQuery
.extend( cache
[ id
].data
, name
);
1758 privateCache
= thisCache
= cache
[ id
];
1760 // jQuery data() is stored in a separate object inside the object's internal data
1761 // cache in order to avoid key collisions between internal data and user-defined
1764 if ( !thisCache
.data
) {
1765 thisCache
.data
= {};
1768 thisCache
= thisCache
.data
;
1771 if ( data
!== undefined ) {
1772 thisCache
[ jQuery
.camelCase( name
) ] = data
;
1775 // Users should not attempt to inspect the internal events object using jQuery.data,
1776 // it is undocumented and subject to change. But does anyone listen? No.
1777 if ( isEvents
&& !thisCache
[ name
] ) {
1778 return privateCache
.events
;
1781 // Check for both converted-to-camel and non-converted data property names
1782 // If a data property was specified
1785 // First Try to find as-is property data
1786 ret
= thisCache
[ name
];
1788 // Test for null|undefined property data
1789 if ( ret
== null ) {
1791 // Try to find the camelCased property
1792 ret
= thisCache
[ jQuery
.camelCase( name
) ];
1801 removeData: function( elem
, name
, pvt
/* Internal Use Only */ ) {
1802 if ( !jQuery
.acceptData( elem
) ) {
1806 var thisCache
, i
, l
,
1808 // Reference to internal data cache key
1809 internalKey
= jQuery
.expando
,
1811 isNode
= elem
.nodeType
,
1813 // See jQuery.data for more information
1814 cache
= isNode
? jQuery
.cache
: elem
,
1816 // See jQuery.data for more information
1817 id
= isNode
? elem
[ jQuery
.expando
] : jQuery
.expando
;
1819 // If there is already no cache entry for this object, there is no
1820 // purpose in continuing
1821 if ( !cache
[ id
] ) {
1827 thisCache
= pvt
? cache
[ id
] : cache
[ id
].data
;
1831 // Support space separated names
1832 if ( jQuery
.isArray( name
) ) {
1834 } else if ( name
in thisCache
) {
1838 // split the camel cased version by spaces
1839 name
= jQuery
.camelCase( name
);
1840 if ( name
in thisCache
) {
1843 name
= name
.split( " " );
1847 for ( i
= 0, l
= name
.length
; i
< l
; i
++ ) {
1848 delete thisCache
[ name
[i
] ];
1851 // If there is no data left in the cache, we want to continue
1852 // and let the cache object itself get destroyed
1853 if ( !( pvt
? isEmptyDataObject
: jQuery
.isEmptyObject
)( thisCache
) ) {
1859 // See jQuery.data for more information
1861 delete cache
[ id
].data
;
1863 // Don't destroy the parent cache unless the internal data object
1864 // had been the only thing left in it
1865 if ( !isEmptyDataObject(cache
[ id
]) ) {
1870 // Browsers that fail expando deletion also refuse to delete expandos on
1871 // the window, but it will allow it on all other JS objects; other browsers
1873 // Ensure that `cache` is not a window object #10080
1874 if ( jQuery
.support
.deleteExpando
|| !cache
.setInterval
) {
1880 // We destroyed the cache and need to eliminate the expando on the node to avoid
1881 // false lookups in the cache for entries that no longer exist
1883 // IE does not allow us to delete expando properties from nodes,
1884 // nor does it have a removeAttribute function on Document nodes;
1885 // we must handle all of these cases
1886 if ( jQuery
.support
.deleteExpando
) {
1887 delete elem
[ jQuery
.expando
];
1888 } else if ( elem
.removeAttribute
) {
1889 elem
.removeAttribute( jQuery
.expando
);
1891 elem
[ jQuery
.expando
] = null;
1896 // For internal use only.
1897 _data: function( elem
, name
, data
) {
1898 return jQuery
.data( elem
, name
, data
, true );
1901 // A method for determining if a DOM node can handle the data expando
1902 acceptData: function( elem
) {
1903 if ( elem
.nodeName
) {
1904 var match
= jQuery
.noData
[ elem
.nodeName
.toLowerCase() ];
1907 return !(match
=== true || elem
.getAttribute("classid") !== match
);
1916 data: function( key
, value
) {
1917 var parts
, attr
, name
,
1920 if ( typeof key
=== "undefined" ) {
1921 if ( this.length
) {
1922 data
= jQuery
.data( this[0] );
1924 if ( this[0].nodeType
=== 1 && !jQuery
._data( this[0], "parsedAttrs" ) ) {
1925 attr
= this[0].attributes
;
1926 for ( var i
= 0, l
= attr
.length
; i
< l
; i
++ ) {
1927 name
= attr
[i
].name
;
1929 if ( name
.indexOf( "data-" ) === 0 ) {
1930 name
= jQuery
.camelCase( name
.substring(5) );
1932 dataAttr( this[0], name
, data
[ name
] );
1935 jQuery
._data( this[0], "parsedAttrs", true );
1941 } else if ( typeof key
=== "object" ) {
1942 return this.each(function() {
1943 jQuery
.data( this, key
);
1947 parts
= key
.split(".");
1948 parts
[1] = parts
[1] ? "." + parts
[1] : "";
1950 if ( value
=== undefined ) {
1951 data
= this.triggerHandler("getData" + parts
[1] + "!", [parts
[0]]);
1953 // Try to fetch any internally stored data first
1954 if ( data
=== undefined && this.length
) {
1955 data
= jQuery
.data( this[0], key
);
1956 data
= dataAttr( this[0], key
, data
);
1959 return data
=== undefined && parts
[1] ?
1960 this.data( parts
[0] ) :
1964 return this.each(function() {
1965 var $this = jQuery( this ),
1966 args
= [ parts
[0], value
];
1968 $this.triggerHandler( "setData" + parts
[1] + "!", args
);
1969 jQuery
.data( this, key
, value
);
1970 $this.triggerHandler( "changeData" + parts
[1] + "!", args
);
1975 removeData: function( key
) {
1976 return this.each(function() {
1977 jQuery
.removeData( this, key
);
1982 function dataAttr( elem
, key
, data
) {
1983 // If nothing was found internally, try to fetch any
1984 // data from the HTML5 data-* attribute
1985 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
1987 var name
= "data-" + key
.replace( rmultiDash
, "-$1" ).toLowerCase();
1989 data
= elem
.getAttribute( name
);
1991 if ( typeof data
=== "string" ) {
1993 data
= data
=== "true" ? true :
1994 data
=== "false" ? false :
1995 data
=== "null" ? null :
1996 jQuery
.isNumeric( data
) ? parseFloat( data
) :
1997 rbrace
.test( data
) ? jQuery
.parseJSON( data
) :
2001 // Make sure we set the data so it isn't changed later
2002 jQuery
.data( elem
, key
, data
);
2012 // checks a cache object for emptiness
2013 function isEmptyDataObject( obj
) {
2014 for ( var name
in obj
) {
2016 // if the public data object is empty, the private is still empty
2017 if ( name
=== "data" && jQuery
.isEmptyObject( obj
[name
] ) ) {
2020 if ( name
!== "toJSON" ) {
2031 function handleQueueMarkDefer( elem
, type
, src
) {
2032 var deferDataKey
= type
+ "defer",
2033 queueDataKey
= type
+ "queue",
2034 markDataKey
= type
+ "mark",
2035 defer
= jQuery
._data( elem
, deferDataKey
);
2037 ( src
=== "queue" || !jQuery
._data(elem
, queueDataKey
) ) &&
2038 ( src
=== "mark" || !jQuery
._data(elem
, markDataKey
) ) ) {
2039 // Give room for hard-coded callbacks to fire first
2040 // and eventually mark/queue something else on the element
2041 setTimeout( function() {
2042 if ( !jQuery
._data( elem
, queueDataKey
) &&
2043 !jQuery
._data( elem
, markDataKey
) ) {
2044 jQuery
.removeData( elem
, deferDataKey
, true );
2053 _mark: function( elem
, type
) {
2055 type
= ( type
|| "fx" ) + "mark";
2056 jQuery
._data( elem
, type
, (jQuery
._data( elem
, type
) || 0) + 1 );
2060 _unmark: function( force
, elem
, type
) {
2061 if ( force
!== true ) {
2067 type
= type
|| "fx";
2068 var key
= type
+ "mark",
2069 count
= force
? 0 : ( (jQuery
._data( elem
, key
) || 1) - 1 );
2071 jQuery
._data( elem
, key
, count
);
2073 jQuery
.removeData( elem
, key
, true );
2074 handleQueueMarkDefer( elem
, type
, "mark" );
2079 queue: function( elem
, type
, data
) {
2082 type
= ( type
|| "fx" ) + "queue";
2083 q
= jQuery
._data( elem
, type
);
2085 // Speed up dequeue by getting out quickly if this is just a lookup
2087 if ( !q
|| jQuery
.isArray(data
) ) {
2088 q
= jQuery
._data( elem
, type
, jQuery
.makeArray(data
) );
2097 dequeue: function( elem
, type
) {
2098 type
= type
|| "fx";
2100 var queue
= jQuery
.queue( elem
, type
),
2104 // If the fx queue is dequeued, always remove the progress sentinel
2105 if ( fn
=== "inprogress" ) {
2110 // Add a progress sentinel to prevent the fx queue from being
2111 // automatically dequeued
2112 if ( type
=== "fx" ) {
2113 queue
.unshift( "inprogress" );
2116 jQuery
._data( elem
, type
+ ".run", hooks
);
2117 fn
.call( elem
, function() {
2118 jQuery
.dequeue( elem
, type
);
2122 if ( !queue
.length
) {
2123 jQuery
.removeData( elem
, type
+ "queue " + type
+ ".run", true );
2124 handleQueueMarkDefer( elem
, type
, "queue" );
2130 queue: function( type
, data
) {
2131 if ( typeof type
!== "string" ) {
2136 if ( data
=== undefined ) {
2137 return jQuery
.queue( this[0], type
);
2139 return this.each(function() {
2140 var queue
= jQuery
.queue( this, type
, data
);
2142 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
2143 jQuery
.dequeue( this, type
);
2147 dequeue: function( type
) {
2148 return this.each(function() {
2149 jQuery
.dequeue( this, type
);
2152 // Based off of the plugin by Clint Helfers, with permission.
2153 // http://blindsignals.com/index.php/2009/07/jquery-delay/
2154 delay: function( time
, type
) {
2155 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
2156 type
= type
|| "fx";
2158 return this.queue( type
, function( next
, hooks
) {
2159 var timeout
= setTimeout( next
, time
);
2160 hooks
.stop = function() {
2161 clearTimeout( timeout
);
2165 clearQueue: function( type
) {
2166 return this.queue( type
|| "fx", [] );
2168 // Get a promise resolved when queues of a certain type
2169 // are emptied (fx is the type by default)
2170 promise: function( type
, object
) {
2171 if ( typeof type
!== "string" ) {
2175 type
= type
|| "fx";
2176 var defer
= jQuery
.Deferred(),
2178 i
= elements
.length
,
2180 deferDataKey
= type
+ "defer",
2181 queueDataKey
= type
+ "queue",
2182 markDataKey
= type
+ "mark",
2184 function resolve() {
2185 if ( !( --count
) ) {
2186 defer
.resolveWith( elements
, [ elements
] );
2190 if (( tmp
= jQuery
.data( elements
[ i
], deferDataKey
, undefined, true ) ||
2191 ( jQuery
.data( elements
[ i
], queueDataKey
, undefined, true ) ||
2192 jQuery
.data( elements
[ i
], markDataKey
, undefined, true ) ) &&
2193 jQuery
.data( elements
[ i
], deferDataKey
, jQuery
.Callbacks( "once memory" ), true ) )) {
2199 return defer
.promise();
2206 var rclass
= /[\n\t\r]/g,
2209 rtype
= /^(?:button|input)$/i,
2210 rfocusable
= /^(?:button|input|object|select|textarea)$/i,
2211 rclickable
= /^a(?:rea)?$/i,
2212 rboolean
= /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2213 getSetAttribute
= jQuery
.support
.getSetAttribute
,
2214 nodeHook
, boolHook
, fixSpecified
;
2217 attr: function( name
, value
) {
2218 return jQuery
.access( this, name
, value
, true, jQuery
.attr
);
2221 removeAttr: function( name
) {
2222 return this.each(function() {
2223 jQuery
.removeAttr( this, name
);
2227 prop: function( name
, value
) {
2228 return jQuery
.access( this, name
, value
, true, jQuery
.prop
);
2231 removeProp: function( name
) {
2232 name
= jQuery
.propFix
[ name
] || name
;
2233 return this.each(function() {
2234 // try/catch handles cases where IE balks (such as removing a property on window)
2236 this[ name
] = undefined;
2237 delete this[ name
];
2242 addClass: function( value
) {
2243 var classNames
, i
, l
, elem
,
2246 if ( jQuery
.isFunction( value
) ) {
2247 return this.each(function( j
) {
2248 jQuery( this ).addClass( value
.call(this, j
, this.className
) );
2252 if ( value
&& typeof value
=== "string" ) {
2253 classNames
= value
.split( rspace
);
2255 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
2258 if ( elem
.nodeType
=== 1 ) {
2259 if ( !elem
.className
&& classNames
.length
=== 1 ) {
2260 elem
.className
= value
;
2263 setClass
= " " + elem
.className
+ " ";
2265 for ( c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
2266 if ( !~setClass
.indexOf( " " + classNames
[ c
] + " " ) ) {
2267 setClass
+= classNames
[ c
] + " ";
2270 elem
.className
= jQuery
.trim( setClass
);
2279 removeClass: function( value
) {
2280 var classNames
, i
, l
, elem
, className
, c
, cl
;
2282 if ( jQuery
.isFunction( value
) ) {
2283 return this.each(function( j
) {
2284 jQuery( this ).removeClass( value
.call(this, j
, this.className
) );
2288 if ( (value
&& typeof value
=== "string") || value
=== undefined ) {
2289 classNames
= ( value
|| "" ).split( rspace
);
2291 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
2294 if ( elem
.nodeType
=== 1 && elem
.className
) {
2296 className
= (" " + elem
.className
+ " ").replace( rclass
, " " );
2297 for ( c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
2298 className
= className
.replace(" " + classNames
[ c
] + " ", " ");
2300 elem
.className
= jQuery
.trim( className
);
2303 elem
.className
= "";
2312 toggleClass: function( value
, stateVal
) {
2313 var type
= typeof value
,
2314 isBool
= typeof stateVal
=== "boolean";
2316 if ( jQuery
.isFunction( value
) ) {
2317 return this.each(function( i
) {
2318 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
2322 return this.each(function() {
2323 if ( type
=== "string" ) {
2324 // toggle individual class names
2327 self
= jQuery( this ),
2329 classNames
= value
.split( rspace
);
2331 while ( (className
= classNames
[ i
++ ]) ) {
2332 // check each className given, space seperated list
2333 state
= isBool
? state
: !self
.hasClass( className
);
2334 self
[ state
? "addClass" : "removeClass" ]( className
);
2337 } else if ( type
=== "undefined" || type
=== "boolean" ) {
2338 if ( this.className
) {
2339 // store className if set
2340 jQuery
._data( this, "__className__", this.className
);
2343 // toggle whole className
2344 this.className
= this.className
|| value
=== false ? "" : jQuery
._data( this, "__className__" ) || "";
2349 hasClass: function( selector
) {
2350 var className
= " " + selector
+ " ",
2353 for ( ; i
< l
; i
++ ) {
2354 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) > -1 ) {
2362 val: function( value
) {
2363 var hooks
, ret
, isFunction
,
2366 if ( !arguments
.length
) {
2368 hooks
= jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ] || jQuery
.valHooks
[ elem
.type
];
2370 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, "value" )) !== undefined ) {
2376 return typeof ret
=== "string" ?
2377 // handle most common string cases
2378 ret
.replace(rreturn
, "") :
2379 // handle cases where value is null/undef or number
2380 ret
== null ? "" : ret
;
2386 isFunction
= jQuery
.isFunction( value
);
2388 return this.each(function( i
) {
2389 var self
= jQuery(this), val
;
2391 if ( this.nodeType
!== 1 ) {
2396 val
= value
.call( this, i
, self
.val() );
2401 // Treat null/undefined as ""; convert numbers to string
2402 if ( val
== null ) {
2404 } else if ( typeof val
=== "number" ) {
2406 } else if ( jQuery
.isArray( val
) ) {
2407 val
= jQuery
.map(val
, function ( value
) {
2408 return value
== null ? "" : value
+ "";
2412 hooks
= jQuery
.valHooks
[ this.nodeName
.toLowerCase() ] || jQuery
.valHooks
[ this.type
];
2414 // If set returns undefined, fall back to normal setting
2415 if ( !hooks
|| !("set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
2425 get: function( elem
) {
2426 // attributes.value is undefined in Blackberry 4.7 but
2427 // uses .value. See #6932
2428 var val
= elem
.attributes
.value
;
2429 return !val
|| val
.specified
? elem
.value
: elem
.text
;
2433 get: function( elem
) {
2434 var value
, i
, max
, option
,
2435 index
= elem
.selectedIndex
,
2437 options
= elem
.options
,
2438 one
= elem
.type
=== "select-one";
2440 // Nothing was selected
2445 // Loop through all the selected options
2446 i
= one
? index
: 0;
2447 max
= one
? index
+ 1 : options
.length
;
2448 for ( ; i
< max
; i
++ ) {
2449 option
= options
[ i
];
2451 // Don't return options that are disabled or in a disabled optgroup
2452 if ( option
.selected
&& (jQuery
.support
.optDisabled
? !option
.disabled
: option
.getAttribute("disabled") === null) &&
2453 (!option
.parentNode
.disabled
|| !jQuery
.nodeName( option
.parentNode
, "optgroup" )) ) {
2455 // Get the specific value for the option
2456 value
= jQuery( option
).val();
2458 // We don't need an array for one selects
2463 // Multi-Selects return an array
2464 values
.push( value
);
2468 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2469 if ( one
&& !values
.length
&& options
.length
) {
2470 return jQuery( options
[ index
] ).val();
2476 set: function( elem
, value
) {
2477 var values
= jQuery
.makeArray( value
);
2479 jQuery(elem
).find("option").each(function() {
2480 this.selected
= jQuery
.inArray( jQuery(this).val(), values
) >= 0;
2483 if ( !values
.length
) {
2484 elem
.selectedIndex
= -1;
2502 attr: function( elem
, name
, value
, pass
) {
2503 var ret
, hooks
, notxml
,
2504 nType
= elem
.nodeType
;
2506 // don't get/set attributes on text, comment and attribute nodes
2507 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
2511 if ( pass
&& name
in jQuery
.attrFn
) {
2512 return jQuery( elem
)[ name
]( value
);
2515 // Fallback to prop when attributes are not supported
2516 if ( !("getAttribute" in elem
) ) {
2517 return jQuery
.prop( elem
, name
, value
);
2520 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
2522 // All attributes are lowercase
2523 // Grab necessary hook if one is defined
2525 name
= name
.toLowerCase();
2526 hooks
= jQuery
.attrHooks
[ name
] || ( rboolean
.test( name
) ? boolHook
: nodeHook
);
2529 if ( value
!== undefined ) {
2531 if ( value
=== null ) {
2532 jQuery
.removeAttr( elem
, name
);
2535 } else if ( hooks
&& "set" in hooks
&& notxml
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
2539 elem
.setAttribute( name
, "" + value
);
2543 } else if ( hooks
&& "get" in hooks
&& notxml
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
2548 ret
= elem
.getAttribute( name
);
2550 // Non-existent attributes return null, we normalize to undefined
2551 return ret
=== null ?
2557 removeAttr: function( elem
, value
) {
2558 var propName
, attrNames
, name
, l
,
2561 if ( elem
.nodeType
=== 1 ) {
2562 attrNames
= ( value
|| "" ).split( rspace
);
2563 l
= attrNames
.length
;
2565 for ( ; i
< l
; i
++ ) {
2566 name
= attrNames
[ i
].toLowerCase();
2567 propName
= jQuery
.propFix
[ name
] || name
;
2569 // See #9699 for explanation of this approach (setting first, then removal)
2570 jQuery
.attr( elem
, name
, "" );
2571 elem
.removeAttribute( getSetAttribute
? name
: propName
);
2573 // Set corresponding property to false for boolean attributes
2574 if ( rboolean
.test( name
) && propName
in elem
) {
2575 elem
[ propName
] = false;
2583 set: function( elem
, value
) {
2584 // We can't allow the type property to be changed (since it causes problems in IE)
2585 if ( rtype
.test( elem
.nodeName
) && elem
.parentNode
) {
2586 jQuery
.error( "type property can't be changed" );
2587 } else if ( !jQuery
.support
.radioValue
&& value
=== "radio" && jQuery
.nodeName(elem
, "input") ) {
2588 // Setting the type on a radio button after the value resets the value in IE6-9
2589 // Reset value to it's default in case type is set after value
2590 // This is for element creation
2591 var val
= elem
.value
;
2592 elem
.setAttribute( "type", value
);
2600 // Use the value property for back compat
2601 // Use the nodeHook for button elements in IE6/7 (#1954)
2603 get: function( elem
, name
) {
2604 if ( nodeHook
&& jQuery
.nodeName( elem
, "button" ) ) {
2605 return nodeHook
.get( elem
, name
);
2607 return name
in elem
?
2611 set: function( elem
, value
, name
) {
2612 if ( nodeHook
&& jQuery
.nodeName( elem
, "button" ) ) {
2613 return nodeHook
.set( elem
, value
, name
);
2615 // Does not return so that setAttribute is also used
2622 tabindex
: "tabIndex",
2623 readonly
: "readOnly",
2625 "class": "className",
2626 maxlength
: "maxLength",
2627 cellspacing
: "cellSpacing",
2628 cellpadding
: "cellPadding",
2632 frameborder
: "frameBorder",
2633 contenteditable
: "contentEditable"
2636 prop: function( elem
, name
, value
) {
2637 var ret
, hooks
, notxml
,
2638 nType
= elem
.nodeType
;
2640 // don't get/set properties on text, comment and attribute nodes
2641 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
2645 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
2648 // Fix name and attach hooks
2649 name
= jQuery
.propFix
[ name
] || name
;
2650 hooks
= jQuery
.propHooks
[ name
];
2653 if ( value
!== undefined ) {
2654 if ( hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
2658 return ( elem
[ name
] = value
);
2662 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
2666 return elem
[ name
];
2673 get: function( elem
) {
2674 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2675 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2676 var attributeNode
= elem
.getAttributeNode("tabindex");
2678 return attributeNode
&& attributeNode
.specified
?
2679 parseInt( attributeNode
.value
, 10 ) :
2680 rfocusable
.test( elem
.nodeName
) || rclickable
.test( elem
.nodeName
) && elem
.href
?
2688 // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
2689 jQuery
.attrHooks
.tabindex
= jQuery
.propHooks
.tabIndex
;
2691 // Hook for boolean attributes
2693 get: function( elem
, name
) {
2694 // Align boolean attributes with corresponding properties
2695 // Fall back to attribute presence where some booleans are not supported
2697 property
= jQuery
.prop( elem
, name
);
2698 return property
=== true || typeof property
!== "boolean" && ( attrNode
= elem
.getAttributeNode(name
) ) && attrNode
.nodeValue
!== false ?
2699 name
.toLowerCase() :
2702 set: function( elem
, value
, name
) {
2704 if ( value
=== false ) {
2705 // Remove boolean attributes when set to false
2706 jQuery
.removeAttr( elem
, name
);
2708 // value is true since we know at this point it's type boolean and not false
2709 // Set boolean attributes to the same name and set the DOM property
2710 propName
= jQuery
.propFix
[ name
] || name
;
2711 if ( propName
in elem
) {
2712 // Only set the IDL specifically if it already exists on the element
2713 elem
[ propName
] = true;
2716 elem
.setAttribute( name
, name
.toLowerCase() );
2722 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2723 if ( !getSetAttribute
) {
2730 // Use this for any attribute in IE6/7
2731 // This fixes almost every IE6/7 issue
2732 nodeHook
= jQuery
.valHooks
.button
= {
2733 get: function( elem
, name
) {
2735 ret
= elem
.getAttributeNode( name
);
2736 return ret
&& ( fixSpecified
[ name
] ? ret
.nodeValue
!== "" : ret
.specified
) ?
2740 set: function( elem
, value
, name
) {
2741 // Set the existing or create a new attribute node
2742 var ret
= elem
.getAttributeNode( name
);
2744 ret
= document
.createAttribute( name
);
2745 elem
.setAttributeNode( ret
);
2747 return ( ret
.nodeValue
= value
+ "" );
2751 // Apply the nodeHook to tabindex
2752 jQuery
.attrHooks
.tabindex
.set = nodeHook
.set;
2754 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2755 // This is for removals
2756 jQuery
.each([ "width", "height" ], function( i
, name
) {
2757 jQuery
.attrHooks
[ name
] = jQuery
.extend( jQuery
.attrHooks
[ name
], {
2758 set: function( elem
, value
) {
2759 if ( value
=== "" ) {
2760 elem
.setAttribute( name
, "auto" );
2767 // Set contenteditable to false on removals(#10429)
2768 // Setting to empty string throws an error as an invalid value
2769 jQuery
.attrHooks
.contenteditable
= {
2771 set: function( elem
, value
, name
) {
2772 if ( value
=== "" ) {
2775 nodeHook
.set( elem
, value
, name
);
2781 // Some attributes require a special call on IE
2782 if ( !jQuery
.support
.hrefNormalized
) {
2783 jQuery
.each([ "href", "src", "width", "height" ], function( i
, name
) {
2784 jQuery
.attrHooks
[ name
] = jQuery
.extend( jQuery
.attrHooks
[ name
], {
2785 get: function( elem
) {
2786 var ret
= elem
.getAttribute( name
, 2 );
2787 return ret
=== null ? undefined : ret
;
2793 if ( !jQuery
.support
.style
) {
2794 jQuery
.attrHooks
.style
= {
2795 get: function( elem
) {
2796 // Return undefined in the case of empty string
2797 // Normalize to lowercase since IE uppercases css property names
2798 return elem
.style
.cssText
.toLowerCase() || undefined;
2800 set: function( elem
, value
) {
2801 return ( elem
.style
.cssText
= "" + value
);
2806 // Safari mis-reports the default selected property of an option
2807 // Accessing the parent's selectedIndex property fixes it
2808 if ( !jQuery
.support
.optSelected
) {
2809 jQuery
.propHooks
.selected
= jQuery
.extend( jQuery
.propHooks
.selected
, {
2810 get: function( elem
) {
2811 var parent
= elem
.parentNode
;
2814 parent
.selectedIndex
;
2816 // Make sure that it also works with optgroups, see #5701
2817 if ( parent
.parentNode
) {
2818 parent
.parentNode
.selectedIndex
;
2826 // IE6/7 call enctype encoding
2827 if ( !jQuery
.support
.enctype
) {
2828 jQuery
.propFix
.enctype
= "encoding";
2831 // Radios and checkboxes getter/setter
2832 if ( !jQuery
.support
.checkOn
) {
2833 jQuery
.each([ "radio", "checkbox" ], function() {
2834 jQuery
.valHooks
[ this ] = {
2835 get: function( elem
) {
2836 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2837 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
2842 jQuery
.each([ "radio", "checkbox" ], function() {
2843 jQuery
.valHooks
[ this ] = jQuery
.extend( jQuery
.valHooks
[ this ], {
2844 set: function( elem
, value
) {
2845 if ( jQuery
.isArray( value
) ) {
2846 return ( elem
.checked
= jQuery
.inArray( jQuery(elem
).val(), value
) >= 0 );
2855 var rnamespaces
= /\.(.*)$/,
2856 rformElems
= /^(?:textarea|input|select)$/i,
2859 rescape
= /[^\w\s.|`]/g,
2860 rtypenamespace
= /^([^\.]*)?(?:\.(.+))?$/,
2861 rhoverHack
= /\bhover(\.\S+)?/,
2863 rmouseEvent
= /^(?:mouse|contextmenu)|click/,
2864 rquickIs
= /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
2865 quickParse = function( selector
) {
2866 var quick
= rquickIs
.exec( selector
);
2869 // [ _, tag, id, class ]
2870 quick
[1] = ( quick
[1] || "" ).toLowerCase();
2871 quick
[3] = quick
[3] && new RegExp( "(?:^|\\s)" + quick
[3] + "(?:\\s|$)" );
2875 quickIs = function( elem
, m
) {
2877 (!m
[1] || elem
.nodeName
.toLowerCase() === m
[1]) &&
2878 (!m
[2] || elem
.id
=== m
[2]) &&
2879 (!m
[3] || m
[3].test( elem
.className
))
2882 hoverHack = function( events
) {
2883 return jQuery
.event
.special
.hover
? events
: events
.replace( rhoverHack
, "mouseenter$1 mouseleave$1" );
2887 * Helper functions for managing events -- not part of the public interface.
2888 * Props to Dean Edwards' addEvent library for many of the ideas.
2892 add: function( elem
, types
, handler
, data
, selector
) {
2894 var elemData
, eventHandle
, events
,
2895 t
, tns
, type
, namespaces
, handleObj
,
2896 handleObjIn
, quick
, handlers
, special
;
2898 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2899 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !types
|| !handler
|| !(elemData
= jQuery
._data( elem
)) ) {
2903 // Caller can pass in an object of custom data in lieu of the handler
2904 if ( handler
.handler
) {
2905 handleObjIn
= handler
;
2906 handler
= handleObjIn
.handler
;
2909 // Make sure that the handler has a unique ID, used to find/remove it later
2910 if ( !handler
.guid
) {
2911 handler
.guid
= jQuery
.guid
++;
2914 // Init the element's event structure and main handler, if this is the first
2915 events
= elemData
.events
;
2917 elemData
.events
= events
= {};
2919 eventHandle
= elemData
.handle
;
2920 if ( !eventHandle
) {
2921 elemData
.handle
= eventHandle = function( e
) {
2922 // Discard the second event of a jQuery.event.trigger() and
2923 // when an event is called after a page has unloaded
2924 return typeof jQuery
!== "undefined" && (!e
|| jQuery
.event
.triggered
!== e
.type
) ?
2925 jQuery
.event
.dispatch
.apply( eventHandle
.elem
, arguments
) :
2928 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2929 eventHandle
.elem
= elem
;
2932 // Handle multiple events separated by a space
2933 // jQuery(...).bind("mouseover mouseout", fn);
2934 types
= hoverHack(types
).split( " " );
2935 for ( t
= 0; t
< types
.length
; t
++ ) {
2937 tns
= rtypenamespace
.exec( types
[t
] ) || [];
2939 namespaces
= ( tns
[2] || "" ).split( "." ).sort();
2941 // If event changes its type, use the special event handlers for the changed type
2942 special
= jQuery
.event
.special
[ type
] || {};
2944 // If selector defined, determine special event api type, otherwise given type
2945 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
2947 // Update special based on newly reset type
2948 special
= jQuery
.event
.special
[ type
] || {};
2950 // handleObj is passed to all event handlers
2951 handleObj
= jQuery
.extend({
2958 namespace: namespaces
.join(".")
2961 // Delegated event; pre-analyze selector so it's processed quickly on event dispatch
2963 handleObj
.quick
= quickParse( selector
);
2964 if ( !handleObj
.quick
&& jQuery
.expr
.match
.POS
.test( selector
) ) {
2965 handleObj
.isPositional
= true;
2969 // Init the event handler queue if we're the first
2970 handlers
= events
[ type
];
2972 handlers
= events
[ type
] = [];
2973 handlers
.delegateCount
= 0;
2975 // Only use addEventListener/attachEvent if the special events handler returns false
2976 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
2977 // Bind the global event handler to the element
2978 if ( elem
.addEventListener
) {
2979 elem
.addEventListener( type
, eventHandle
, false );
2981 } else if ( elem
.attachEvent
) {
2982 elem
.attachEvent( "on" + type
, eventHandle
);
2987 if ( special
.add
) {
2988 special
.add
.call( elem
, handleObj
);
2990 if ( !handleObj
.handler
.guid
) {
2991 handleObj
.handler
.guid
= handler
.guid
;
2995 // Add to the element's handler list, delegates in front
2997 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
2999 handlers
.push( handleObj
);
3002 // Keep track of which events have ever been used, for event optimization
3003 jQuery
.event
.global
[ type
] = true;
3006 // Nullify elem to prevent memory leaks in IE
3012 // Detach an event or set of events from an element
3013 remove: function( elem
, types
, handler
, selector
) {
3015 var elemData
= jQuery
.hasData( elem
) && jQuery
._data( elem
),
3016 t
, tns
, type
, namespaces
, origCount
,
3017 j
, events
, special
, handle
, eventType
, handleObj
;
3019 if ( !elemData
|| !(events
= elemData
.events
) ) {
3023 // Once for each type.namespace in types; type may be omitted
3024 types
= hoverHack( types
|| "" ).split(" ");
3025 for ( t
= 0; t
< types
.length
; t
++ ) {
3026 tns
= rtypenamespace
.exec( types
[t
] ) || [];
3028 namespaces
= tns
[2];
3030 // Unbind all events (on this namespace, if provided) for the element
3032 namespaces
= namespaces
? "." + namespaces
: "";
3033 for ( j
in events
) {
3034 jQuery
.event
.remove( elem
, j
+ namespaces
, handler
, selector
);
3039 special
= jQuery
.event
.special
[ type
] || {};
3040 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
3041 eventType
= events
[ type
] || [];
3042 origCount
= eventType
.length
;
3043 namespaces
= namespaces
? new RegExp("(^|\\.)" + namespaces
.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3045 // Only need to loop for special events or selective removal
3046 if ( handler
|| namespaces
|| selector
|| special
.remove
) {
3047 for ( j
= 0; j
< eventType
.length
; j
++ ) {
3048 handleObj
= eventType
[ j
];
3050 if ( !handler
|| handler
.guid
=== handleObj
.guid
) {
3051 if ( !namespaces
|| namespaces
.test( handleObj
.namespace ) ) {
3052 if ( !selector
|| selector
=== handleObj
.selector
|| selector
=== "**" && handleObj
.selector
) {
3053 eventType
.splice( j
--, 1 );
3055 if ( handleObj
.selector
) {
3056 eventType
.delegateCount
--;
3058 if ( special
.remove
) {
3059 special
.remove
.call( elem
, handleObj
);
3066 // Removing all events
3067 eventType
.length
= 0;
3070 // Remove generic event handler if we removed something and no more handlers exist
3071 // (avoids potential for endless recursion during removal of special event handlers)
3072 if ( eventType
.length
=== 0 && origCount
!== eventType
.length
) {
3073 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
) === false ) {
3074 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
3077 delete events
[ type
];
3081 // Remove the expando if it's no longer used
3082 if ( jQuery
.isEmptyObject( events
) ) {
3083 handle
= elemData
.handle
;
3088 // removeData also checks for emptiness and clears the expando if empty
3089 // so use it instead of delete
3090 jQuery
.removeData( elem
, [ "events", "handle" ], true );
3094 // Events that are safe to short-circuit if no handlers are attached.
3095 // Native DOM events should not be added, they may have inline handlers.
3102 trigger: function( event
, data
, elem
, onlyHandlers
) {
3103 // Don't do events on text and comment nodes
3104 if ( elem
&& (elem
.nodeType
=== 3 || elem
.nodeType
=== 8) ) {
3108 // Event object or event type
3109 var type
= event
.type
|| event
,
3111 cache
, exclusive
, i
, cur
, old
, ontype
, special
, handle
, eventPath
, bubbleType
;
3113 if ( type
.indexOf( "!" ) >= 0 ) {
3114 // Exclusive events trigger only for the exact event (no namespaces)
3115 type
= type
.slice(0, -1);
3119 if ( type
.indexOf( "." ) >= 0 ) {
3120 // Namespaced trigger; create a regexp to match event type in handle()
3121 namespaces
= type
.split(".");
3122 type
= namespaces
.shift();
3126 if ( (!elem
|| jQuery
.event
.customEvent
[ type
]) && !jQuery
.event
.global
[ type
] ) {
3127 // No jQuery handlers for this event type, and it can't have inline handlers
3131 // Caller can pass in an Event, Object, or just an event type string
3132 event
= typeof event
=== "object" ?
3133 // jQuery.Event object
3134 event
[ jQuery
.expando
] ? event
:
3136 new jQuery
.Event( type
, event
) :
3137 // Just the event type (string)
3138 new jQuery
.Event( type
);
3141 event
.isTrigger
= true;
3142 event
.exclusive
= exclusive
;
3143 event
.namespace = namespaces
.join( "." );
3144 event
.namespace_re
= event
.namespace? new RegExp("(^|\\.)" + namespaces
.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3145 ontype
= type
.indexOf( ":" ) < 0 ? "on" + type
: "";
3147 // triggerHandler() and global events don't bubble or run the default action
3148 if ( onlyHandlers
|| !elem
) {
3149 event
.preventDefault();
3152 // Handle a global trigger
3155 // TODO: Stop taunting the data cache; remove global events and always attach to document
3156 cache
= jQuery
.cache
;
3157 for ( i
in cache
) {
3158 if ( cache
[ i
].events
&& cache
[ i
].events
[ type
] ) {
3159 jQuery
.event
.trigger( event
, data
, cache
[ i
].handle
.elem
, true );
3165 // Clean up the event in case it is being reused
3166 event
.result
= undefined;
3167 if ( !event
.target
) {
3168 event
.target
= elem
;
3171 // Clone any incoming data and prepend the event, creating the handler arg list
3172 data
= data
!= null ? jQuery
.makeArray( data
) : [];
3173 data
.unshift( event
);
3175 // Allow special events to draw outside the lines
3176 special
= jQuery
.event
.special
[ type
] || {};
3177 if ( special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
3181 // Determine event propagation path in advance, per W3C events spec (#9951)
3182 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
3183 eventPath
= [[ elem
, special
.bindType
|| type
]];
3184 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
3186 bubbleType
= special
.delegateType
|| type
;
3188 for ( cur
= elem
.parentNode
; cur
; cur
= cur
.parentNode
) {
3189 eventPath
.push([ cur
, bubbleType
]);
3193 // Only add window if we got to document (e.g., not plain obj or detached DOM)
3194 if ( old
&& old
=== elem
.ownerDocument
) {
3195 eventPath
.push([ old
.defaultView
|| old
.parentWindow
|| window
, bubbleType
]);
3199 // Fire handlers on the event path
3200 for ( i
= 0; i
< eventPath
.length
; i
++ ) {
3202 cur
= eventPath
[i
][0];
3203 event
.type
= eventPath
[i
][1];
3205 handle
= ( jQuery
._data( cur
, "events" ) || {} )[ event
.type
] && jQuery
._data( cur
, "handle" );
3207 handle
.apply( cur
, data
);
3209 handle
= ontype
&& cur
[ ontype
];
3210 if ( handle
&& jQuery
.acceptData( cur
) ) {
3211 handle
.apply( cur
, data
);
3214 if ( event
.isPropagationStopped() ) {
3220 // If nobody prevented the default action, do it now
3221 if ( !event
.isDefaultPrevented() ) {
3223 if ( (!special
._default
|| special
._default
.apply( elem
.ownerDocument
, data
) === false) &&
3224 !(type
=== "click" && jQuery
.nodeName( elem
, "a" )) && jQuery
.acceptData( elem
) ) {
3226 // Call a native DOM method on the target with the same name name as the event.
3227 // Can't use an .isFunction() check here because IE6/7 fails that test.
3228 // Don't do default actions on window, that's where global variables be (#6170)
3229 // IE<9 dies on focus/blur to hidden element (#1486)
3230 if ( ontype
&& elem
[ type
] && ((type
!== "focus" && type
!== "blur") || event
.target
.offsetWidth
!== 0) && !jQuery
.isWindow( elem
) ) {
3232 // Don't re-trigger an onFOO event when we call its FOO() method
3233 old
= elem
[ ontype
];
3236 elem
[ ontype
] = null;
3239 // Prevent re-triggering of the same event, since we already bubbled it above
3240 jQuery
.event
.triggered
= type
;
3242 jQuery
.event
.triggered
= undefined;
3245 elem
[ ontype
] = old
;
3251 return event
.result
;
3254 dispatch: function( event
) {
3256 // Make a writable jQuery.Event from the native event object
3257 event
= jQuery
.event
.fix( event
|| window
.event
);
3259 var handlers
= ( (jQuery
._data( this, "events" ) || {} )[ event
.type
] || []),
3260 delegateCount
= handlers
.delegateCount
,
3261 args
= [].slice
.call( arguments
, 0 ),
3262 run_all
= !event
.exclusive
&& !event
.namespace,
3263 specialHandle
= ( jQuery
.event
.special
[ event
.type
] || {} ).handle
,
3265 i
, j
, cur
, ret
, selMatch
, matched
, matches
, handleObj
, sel
, hit
, related
;
3267 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3269 event
.delegateTarget
= this;
3271 // Determine handlers that should run if there are delegated events
3272 // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
3273 if ( delegateCount
&& !event
.target
.disabled
&& !(event
.button
&& event
.type
=== "click") ) {
3275 for ( cur
= event
.target
; cur
!= this; cur
= cur
.parentNode
|| this ) {
3278 for ( i
= 0; i
< delegateCount
; i
++ ) {
3279 handleObj
= handlers
[ i
];
3280 sel
= handleObj
.selector
;
3281 hit
= selMatch
[ sel
];
3283 if ( handleObj
.isPositional
) {
3284 // Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/
3285 hit
= ( hit
|| (selMatch
[ sel
] = jQuery( sel
)) ).index( cur
) >= 0;
3286 } else if ( hit
=== undefined ) {
3287 hit
= selMatch
[ sel
] = ( handleObj
.quick
? quickIs( cur
, handleObj
.quick
) : jQuery( cur
).is( sel
) );
3290 matches
.push( handleObj
);
3293 if ( matches
.length
) {
3294 handlerQueue
.push({ elem
: cur
, matches
: matches
});
3299 // Add the remaining (directly-bound) handlers
3300 if ( handlers
.length
> delegateCount
) {
3301 handlerQueue
.push({ elem
: this, matches
: handlers
.slice( delegateCount
) });
3304 // Run delegates first; they may want to stop propagation beneath us
3305 for ( i
= 0; i
< handlerQueue
.length
&& !event
.isPropagationStopped(); i
++ ) {
3306 matched
= handlerQueue
[ i
];
3307 event
.currentTarget
= matched
.elem
;
3309 for ( j
= 0; j
< matched
.matches
.length
&& !event
.isImmediatePropagationStopped(); j
++ ) {
3310 handleObj
= matched
.matches
[ j
];
3312 // Triggered event must either 1) be non-exclusive and have no namespace, or
3313 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3314 if ( run_all
|| (!event
.namespace && !handleObj
.namespace) || event
.namespace_re
&& event
.namespace_re
.test( handleObj
.namespace ) ) {
3316 event
.data
= handleObj
.data
;
3317 event
.handleObj
= handleObj
;
3319 ret
= ( specialHandle
|| handleObj
.handler
).apply( matched
.elem
, args
);
3321 if ( ret
!== undefined ) {
3323 if ( ret
=== false ) {
3324 event
.preventDefault();
3325 event
.stopPropagation();
3332 return event
.result
;
3335 // Includes some event props shared by KeyEvent and MouseEvent
3336 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3337 props
: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3342 props
: "char charCode key keyCode".split(" "),
3343 filter: function( event
, original
) {
3345 // Add which for key events
3346 if ( event
.which
== null ) {
3347 event
.which
= original
.charCode
!= null ? original
.charCode
: original
.keyCode
;
3355 props
: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement wheelDelta".split(" "),
3356 filter: function( event
, original
) {
3357 var eventDoc
, doc
, body
,
3358 button
= original
.button
,
3359 fromElement
= original
.fromElement
;
3361 // Calculate pageX/Y if missing and clientX/Y available
3362 if ( event
.pageX
== null && original
.clientX
!= null ) {
3363 eventDoc
= event
.target
.ownerDocument
|| document
;
3364 doc
= eventDoc
.documentElement
;
3365 body
= eventDoc
.body
;
3367 event
.pageX
= original
.clientX
+ ( doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0 ) - ( doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0 );
3368 event
.pageY
= original
.clientY
+ ( doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0 ) - ( doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0 );
3371 // Add relatedTarget, if necessary
3372 if ( !event
.relatedTarget
&& fromElement
) {
3373 event
.relatedTarget
= fromElement
=== event
.target
? original
.toElement
: fromElement
;
3376 // Add which for click: 1 === left; 2 === middle; 3 === right
3377 // Note: button is not normalized, so don't use it
3378 if ( !event
.which
&& button
!== undefined ) {
3379 event
.which
= ( button
& 1 ? 1 : ( button
& 2 ? 3 : ( button
& 4 ? 2 : 0 ) ) );
3386 fix: function( event
) {
3387 if ( event
[ jQuery
.expando
] ) {
3391 // Create a writable copy of the event object and normalize some properties
3393 originalEvent
= event
,
3394 fixHook
= jQuery
.event
.fixHooks
[ event
.type
] || {},
3395 copy
= fixHook
.props
? this.props
.concat( fixHook
.props
) : this.props
;
3397 event
= jQuery
.Event( originalEvent
);
3399 for ( i
= copy
.length
; i
; ) {
3401 event
[ prop
] = originalEvent
[ prop
];
3404 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3405 if ( !event
.target
) {
3406 event
.target
= originalEvent
.srcElement
|| document
;
3409 // Target should not be a text node (#504, Safari)
3410 if ( event
.target
.nodeType
=== 3 ) {
3411 event
.target
= event
.target
.parentNode
;
3414 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
3415 if ( event
.metaKey
=== undefined ) {
3416 event
.metaKey
= event
.ctrlKey
;
3419 return fixHook
.filter
? fixHook
.filter( event
, originalEvent
) : event
;
3424 // Make sure the ready event is setup
3425 setup
: jQuery
.bindReady
3429 delegateType
: "focusin",
3433 delegateType
: "focusout",
3438 setup: function( data
, namespaces
, eventHandle
) {
3439 // We only want to do this special case on windows
3440 if ( jQuery
.isWindow( this ) ) {
3441 this.onbeforeunload
= eventHandle
;
3445 teardown: function( namespaces
, eventHandle
) {
3446 if ( this.onbeforeunload
=== eventHandle
) {
3447 this.onbeforeunload
= null;
3453 simulate: function( type
, elem
, event
, bubble
) {
3454 // Piggyback on a donor event to simulate a different one.
3455 // Fake originalEvent to avoid donor's stopPropagation, but if the
3456 // simulated event prevents default then we do the same on the donor.
3457 var e
= jQuery
.extend(
3466 jQuery
.event
.trigger( e
, null, elem
);
3468 jQuery
.event
.dispatch
.call( elem
, e
);
3470 if ( e
.isDefaultPrevented() ) {
3471 event
.preventDefault();
3476 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3477 // The 1.7 special event interface should provide all the hooks needed now.
3478 jQuery
.event
.handle
= jQuery
.event
.dispatch
;
3480 jQuery
.removeEvent
= document
.removeEventListener
?
3481 function( elem
, type
, handle
) {
3482 if ( elem
.removeEventListener
) {
3483 elem
.removeEventListener( type
, handle
, false );
3486 function( elem
, type
, handle
) {
3487 if ( elem
.detachEvent
) {
3488 elem
.detachEvent( "on" + type
, handle
);
3492 jQuery
.Event = function( src
, props
) {
3493 // Allow instantiation without the 'new' keyword
3494 if ( !(this instanceof jQuery
.Event
) ) {
3495 return new jQuery
.Event( src
, props
);
3499 if ( src
&& src
.type
) {
3500 this.originalEvent
= src
;
3501 this.type
= src
.type
;
3503 // Events bubbling up the document may have been marked as prevented
3504 // by a handler lower down the tree; reflect the correct value.
3505 this.isDefaultPrevented
= ( src
.defaultPrevented
|| src
.returnValue
=== false ||
3506 src
.getPreventDefault
&& src
.getPreventDefault() ) ? returnTrue
: returnFalse
;
3513 // Put explicitly provided properties onto the event object
3515 jQuery
.extend( this, props
);
3518 // Create a timestamp if incoming event doesn't have one
3519 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
3522 this[ jQuery
.expando
] = true;
3525 function returnFalse() {
3528 function returnTrue() {
3532 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3533 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3534 jQuery
.Event
.prototype = {
3535 preventDefault: function() {
3536 this.isDefaultPrevented
= returnTrue
;
3538 var e
= this.originalEvent
;
3543 // if preventDefault exists run it on the original event
3544 if ( e
.preventDefault
) {
3547 // otherwise set the returnValue property of the original event to false (IE)
3549 e
.returnValue
= false;
3552 stopPropagation: function() {
3553 this.isPropagationStopped
= returnTrue
;
3555 var e
= this.originalEvent
;
3559 // if stopPropagation exists run it on the original event
3560 if ( e
.stopPropagation
) {
3561 e
.stopPropagation();
3563 // otherwise set the cancelBubble property of the original event to true (IE)
3564 e
.cancelBubble
= true;
3566 stopImmediatePropagation: function() {
3567 this.isImmediatePropagationStopped
= returnTrue
;
3568 this.stopPropagation();
3570 isDefaultPrevented
: returnFalse
,
3571 isPropagationStopped
: returnFalse
,
3572 isImmediatePropagationStopped
: returnFalse
3575 // Create mouseenter/leave events using mouseover/out and event-time checks
3577 mouseenter
: "mouseover",
3578 mouseleave
: "mouseout"
3579 }, function( orig
, fix
) {
3580 jQuery
.event
.special
[ orig
] = jQuery
.event
.special
[ fix
] = {
3584 handle: function( event
) {
3586 related
= event
.relatedTarget
,
3587 handleObj
= event
.handleObj
,
3588 selector
= handleObj
.selector
,
3591 // For a real mouseover/out, always call the handler; for
3592 // mousenter/leave call the handler if related is outside the target.
3593 // NB: No relatedTarget if the mouse left/entered the browser window
3594 if ( !related
|| handleObj
.origType
=== event
.type
|| (related
!== target
&& !jQuery
.contains( target
, related
)) ) {
3595 oldType
= event
.type
;
3596 event
.type
= handleObj
.origType
;
3597 ret
= handleObj
.handler
.apply( this, arguments
);
3598 event
.type
= oldType
;
3605 // IE submit delegation
3606 if ( !jQuery
.support
.submitBubbles
) {
3608 jQuery
.event
.special
.submit
= {
3610 // Only need this for delegated form submit events
3611 if ( jQuery
.nodeName( this, "form" ) ) {
3615 // Lazy-add a submit handler when a descendant form may potentially be submitted
3616 jQuery
.event
.add( this, "click._submit keypress._submit", function( e
) {
3617 // Node name check avoids a VML-related crash in IE (#9807)
3618 var elem
= e
.target
,
3619 form
= jQuery
.nodeName( elem
, "input" ) || jQuery
.nodeName( elem
, "button" ) ? elem
.form
: undefined;
3620 if ( form
&& !form
._submit_attached
) {
3621 jQuery
.event
.add( form
, "submit._submit", function( event
) {
3622 // Form was submitted, bubble the event up the tree
3623 if ( this.parentNode
) {
3624 jQuery
.event
.simulate( "submit", this.parentNode
, event
, true );
3627 form
._submit_attached
= true;
3630 // return undefined since we don't need an event listener
3633 teardown: function() {
3634 // Only need this for delegated form submit events
3635 if ( jQuery
.nodeName( this, "form" ) ) {
3639 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3640 jQuery
.event
.remove( this, "._submit" );
3645 // IE change delegation and checkbox/radio fix
3646 if ( !jQuery
.support
.changeBubbles
) {
3648 jQuery
.event
.special
.change
= {
3652 if ( rformElems
.test( this.nodeName
) ) {
3653 // IE doesn't fire change on a check/radio until blur; trigger it on click
3654 // after a propertychange. Eat the blur-change in special.change.handle.
3655 // This still fires onchange a second time for check/radio after blur.
3656 if ( this.type
=== "checkbox" || this.type
=== "radio" ) {
3657 jQuery
.event
.add( this, "propertychange._change", function( event
) {
3658 if ( event
.originalEvent
.propertyName
=== "checked" ) {
3659 this._just_changed
= true;
3662 jQuery
.event
.add( this, "click._change", function( event
) {
3663 if ( this._just_changed
) {
3664 this._just_changed
= false;
3665 jQuery
.event
.simulate( "change", this, event
, true );
3671 // Delegated event; lazy-add a change handler on descendant inputs
3672 jQuery
.event
.add( this, "beforeactivate._change", function( e
) {
3673 var elem
= e
.target
;
3675 if ( rformElems
.test( elem
.nodeName
) && !elem
._change_attached
) {
3676 jQuery
.event
.add( elem
, "change._change", function( event
) {
3677 if ( this.parentNode
&& !event
.isSimulated
) {
3678 jQuery
.event
.simulate( "change", this.parentNode
, event
, true );
3681 elem
._change_attached
= true;
3686 handle: function( event
) {
3687 var elem
= event
.target
;
3689 // Swallow native change events from checkbox/radio, we already triggered them above
3690 if ( this !== elem
|| event
.isSimulated
|| event
.isTrigger
|| (elem
.type
!== "radio" && elem
.type
!== "checkbox") ) {
3691 return event
.handleObj
.handler
.apply( this, arguments
);
3695 teardown: function() {
3696 jQuery
.event
.remove( this, "._change" );
3698 return rformElems
.test( this.nodeName
);
3703 // Create "bubbling" focus and blur events
3704 if ( !jQuery
.support
.focusinBubbles
) {
3705 jQuery
.each({ focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
3707 // Attach a single capturing handler while someone wants focusin/focusout
3709 handler = function( event
) {
3710 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
), true );
3713 jQuery
.event
.special
[ fix
] = {
3715 if ( attaches
++ === 0 ) {
3716 document
.addEventListener( orig
, handler
, true );
3719 teardown: function() {
3720 if ( --attaches
=== 0 ) {
3721 document
.removeEventListener( orig
, handler
, true );
3730 on: function( types
, selector
, data
, fn
, /*INTERNAL*/ one
) {
3733 // Types can be a map of types/handlers
3734 if ( typeof types
=== "object" ) {
3735 // ( types-Object, selector, data )
3736 if ( typeof selector
!== "string" ) {
3737 // ( types-Object, data )
3739 selector
= undefined;
3741 for ( type
in types
) {
3742 this.on( type
, selector
, data
, types
[ type
], one
);
3747 if ( data
== null && fn
== null ) {
3750 data
= selector
= undefined;
3751 } else if ( fn
== null ) {
3752 if ( typeof selector
=== "string" ) {
3753 // ( types, selector, fn )
3757 // ( types, data, fn )
3760 selector
= undefined;
3763 if ( fn
=== false ) {
3771 fn = function( event
) {
3772 // Can use an empty set, since event contains the info
3773 jQuery().off( event
);
3774 return origFn
.apply( this, arguments
);
3776 // Use same guid so caller can remove using origFn
3777 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
3779 return this.each( function() {
3780 jQuery
.event
.add( this, types
, fn
, data
, selector
);
3783 one: function( types
, selector
, data
, fn
) {
3784 return this.on
.call( this, types
, selector
, data
, fn
, 1 );
3786 off: function( types
, selector
, fn
) {
3787 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
3788 // ( event ) dispatched jQuery.Event
3789 var handleObj
= types
.handleObj
;
3790 jQuery( types
.delegateTarget
).off(
3791 handleObj
.namespace? handleObj
.type
+ "." + handleObj
.namespace : handleObj
.type
,
3797 if ( typeof types
=== "object" ) {
3798 // ( types-object [, selector] )
3799 for ( var type
in types
) {
3800 this.off( type
, selector
, types
[ type
] );
3804 if ( selector
=== false || typeof selector
=== "function" ) {
3807 selector
= undefined;
3809 if ( fn
=== false ) {
3812 return this.each(function() {
3813 jQuery
.event
.remove( this, types
, fn
, selector
);
3817 bind: function( types
, data
, fn
) {
3818 return this.on( types
, null, data
, fn
);
3820 unbind: function( types
, fn
) {
3821 return this.off( types
, null, fn
);
3824 live: function( types
, data
, fn
) {
3825 jQuery( this.context
).on( types
, this.selector
, data
, fn
);
3828 die: function( types
, fn
) {
3829 jQuery( this.context
).off( types
, this.selector
|| "**", fn
);
3833 delegate: function( selector
, types
, data
, fn
) {
3834 return this.on( types
, selector
, data
, fn
);
3836 undelegate: function( selector
, types
, fn
) {
3837 // ( namespace ) or ( selector, types [, fn] )
3838 return arguments
.length
== 1? this.off( selector
, "**" ) : this.off( types
, selector
, fn
);
3841 trigger: function( type
, data
) {
3842 return this.each(function() {
3843 jQuery
.event
.trigger( type
, data
, this );
3846 triggerHandler: function( type
, data
) {
3848 return jQuery
.event
.trigger( type
, data
, this[0], true );
3852 toggle: function( fn
) {
3853 // Save reference to arguments for access in closure
3854 var args
= arguments
,
3855 guid
= fn
.guid
|| jQuery
.guid
++,
3857 toggler = function( event
) {
3858 // Figure out which function to execute
3859 var lastToggle
= ( jQuery
._data( this, "lastToggle" + fn
.guid
) || 0 ) % i
;
3860 jQuery
._data( this, "lastToggle" + fn
.guid
, lastToggle
+ 1 );
3862 // Make sure that clicks stop
3863 event
.preventDefault();
3865 // and execute the function
3866 return args
[ lastToggle
].apply( this, arguments
) || false;
3869 // link all the functions, so any of them can unbind this click handler
3870 toggler
.guid
= guid
;
3871 while ( i
< args
.length
) {
3872 args
[ i
++ ].guid
= guid
;
3875 return this.click( toggler
);
3878 hover: function( fnOver
, fnOut
) {
3879 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
3883 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3884 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3885 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i
, name
) {
3887 // Handle event binding
3888 jQuery
.fn
[ name
] = function( data
, fn
) {
3894 return arguments
.length
> 0 ?
3895 this.bind( name
, data
, fn
) :
3896 this.trigger( name
);
3899 if ( jQuery
.attrFn
) {
3900 jQuery
.attrFn
[ name
] = true;
3903 if ( rkeyEvent
.test( name
) ) {
3904 jQuery
.event
.fixHooks
[ name
] = jQuery
.event
.keyHooks
;
3907 if ( rmouseEvent
.test( name
) ) {
3908 jQuery
.event
.fixHooks
[ name
] = jQuery
.event
.mouseHooks
;
3915 * Sizzle CSS Selector Engine
3916 * Copyright 2011, The Dojo Foundation
3917 * Released under the MIT, BSD, and GPL Licenses.
3918 * More information: http://sizzlejs.com/
3922 var chunker
= /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3923 expando
= "sizcache" + (Math
.random() + '').replace('.', ''),
3925 toString
= Object
.prototype.toString
,
3926 hasDuplicate
= false,
3927 baseHasDuplicate
= true,
3932 // Here we check if the JavaScript engine is using some sort of
3933 // optimization where it does not always call our comparision
3934 // function. If that is the case, discard the hasDuplicate value.
3935 // Thus far that includes Google Chrome.
3936 [0, 0].sort(function() {
3937 baseHasDuplicate
= false;
3941 var Sizzle = function( selector
, context
, results
, seed
) {
3942 results
= results
|| [];
3943 context
= context
|| document
;
3945 var origContext
= context
;
3947 if ( context
.nodeType
!== 1 && context
.nodeType
!== 9 ) {
3951 if ( !selector
|| typeof selector
!== "string" ) {
3955 var m
, set, checkSet
, extra
, ret
, cur
, pop
, i
,
3957 contextXML
= Sizzle
.isXML( context
),
3961 // Reset the position of the chunker regexp (start from head)
3964 m
= chunker
.exec( soFar
);
3978 if ( parts
.length
> 1 && origPOS
.exec( selector
) ) {
3980 if ( parts
.length
=== 2 && Expr
.relative
[ parts
[0] ] ) {
3981 set = posProcess( parts
[0] + parts
[1], context
, seed
);
3984 set = Expr
.relative
[ parts
[0] ] ?
3986 Sizzle( parts
.shift(), context
);
3988 while ( parts
.length
) {
3989 selector
= parts
.shift();
3991 if ( Expr
.relative
[ selector
] ) {
3992 selector
+= parts
.shift();
3995 set = posProcess( selector
, set, seed
);
4000 // Take a shortcut and set the context if the root selector is an ID
4001 // (but not if it'll be faster if the inner selector is an ID)
4002 if ( !seed
&& parts
.length
> 1 && context
.nodeType
=== 9 && !contextXML
&&
4003 Expr
.match
.ID
.test(parts
[0]) && !Expr
.match
.ID
.test(parts
[parts
.length
- 1]) ) {
4005 ret
= Sizzle
.find( parts
.shift(), context
, contextXML
);
4006 context
= ret
.expr
?
4007 Sizzle
.filter( ret
.expr
, ret
.set )[0] :
4013 { expr
: parts
.pop(), set: makeArray(seed
) } :
4014 Sizzle
.find( parts
.pop(), parts
.length
=== 1 && (parts
[0] === "~" || parts
[0] === "+") && context
.parentNode
? context
.parentNode
: context
, contextXML
);
4017 Sizzle
.filter( ret
.expr
, ret
.set ) :
4020 if ( parts
.length
> 0 ) {
4021 checkSet
= makeArray( set );
4027 while ( parts
.length
) {
4031 if ( !Expr
.relative
[ cur
] ) {
4037 if ( pop
== null ) {
4041 Expr
.relative
[ cur
]( checkSet
, pop
, contextXML
);
4045 checkSet
= parts
= [];
4054 Sizzle
.error( cur
|| selector
);
4057 if ( toString
.call(checkSet
) === "[object Array]" ) {
4059 results
.push
.apply( results
, checkSet
);
4061 } else if ( context
&& context
.nodeType
=== 1 ) {
4062 for ( i
= 0; checkSet
[i
] != null; i
++ ) {
4063 if ( checkSet
[i
] && (checkSet
[i
] === true || checkSet
[i
].nodeType
=== 1 && Sizzle
.contains(context
, checkSet
[i
])) ) {
4064 results
.push( set[i
] );
4069 for ( i
= 0; checkSet
[i
] != null; i
++ ) {
4070 if ( checkSet
[i
] && checkSet
[i
].nodeType
=== 1 ) {
4071 results
.push( set[i
] );
4077 makeArray( checkSet
, results
);
4081 Sizzle( extra
, origContext
, results
, seed
);
4082 Sizzle
.uniqueSort( results
);
4088 Sizzle
.uniqueSort = function( results
) {
4090 hasDuplicate
= baseHasDuplicate
;
4091 results
.sort( sortOrder
);
4093 if ( hasDuplicate
) {
4094 for ( var i
= 1; i
< results
.length
; i
++ ) {
4095 if ( results
[i
] === results
[ i
- 1 ] ) {
4096 results
.splice( i
--, 1 );
4105 Sizzle
.matches = function( expr
, set ) {
4106 return Sizzle( expr
, null, null, set );
4109 Sizzle
.matchesSelector = function( node
, expr
) {
4110 return Sizzle( expr
, null, null, [node
] ).length
> 0;
4113 Sizzle
.find = function( expr
, context
, isXML
) {
4114 var set, i
, len
, match
, type
, left
;
4120 for ( i
= 0, len
= Expr
.order
.length
; i
< len
; i
++ ) {
4121 type
= Expr
.order
[i
];
4123 if ( (match
= Expr
.leftMatch
[ type
].exec( expr
)) ) {
4125 match
.splice( 1, 1 );
4127 if ( left
.substr( left
.length
- 1 ) !== "\\" ) {
4128 match
[1] = (match
[1] || "").replace( rBackslash
, "" );
4129 set = Expr
.find
[ type
]( match
, context
, isXML
);
4131 if ( set != null ) {
4132 expr
= expr
.replace( Expr
.match
[ type
], "" );
4140 set = typeof context
.getElementsByTagName
!== "undefined" ?
4141 context
.getElementsByTagName( "*" ) :
4145 return { set: set, expr
: expr
};
4148 Sizzle
.filter = function( expr
, set, inplace
, not
) {
4149 var match
, anyFound
,
4150 type
, found
, item
, filter
, left
,
4155 isXMLFilter
= set && set[0] && Sizzle
.isXML( set[0] );
4157 while ( expr
&& set.length
) {
4158 for ( type
in Expr
.filter
) {
4159 if ( (match
= Expr
.leftMatch
[ type
].exec( expr
)) != null && match
[2] ) {
4160 filter
= Expr
.filter
[ type
];
4167 if ( left
.substr( left
.length
- 1 ) === "\\" ) {
4171 if ( curLoop
=== result
) {
4175 if ( Expr
.preFilter
[ type
] ) {
4176 match
= Expr
.preFilter
[ type
]( match
, curLoop
, inplace
, result
, not
, isXMLFilter
);
4179 anyFound
= found
= true;
4181 } else if ( match
=== true ) {
4187 for ( i
= 0; (item
= curLoop
[i
]) != null; i
++ ) {
4189 found
= filter( item
, match
, i
, curLoop
);
4192 if ( inplace
&& found
!= null ) {
4200 } else if ( pass
) {
4201 result
.push( item
);
4208 if ( found
!== undefined ) {
4213 expr
= expr
.replace( Expr
.match
[ type
], "" );
4224 // Improper expression
4225 if ( expr
=== old
) {
4226 if ( anyFound
== null ) {
4227 Sizzle
.error( expr
);
4240 Sizzle
.error = function( msg
) {
4241 throw "Syntax error, unrecognized expression: " + msg
;
4245 * Utility function for retreiving the text value of an array of DOM nodes
4246 * @param {Array|Element} elem
4248 var getText
= Sizzle
.getText = function( elem
) {
4250 nodeType
= elem
.nodeType
,
4254 if ( nodeType
=== 1 ) {
4255 // Use textContent || innerText for elements
4256 if ( typeof elem
.textContent
=== 'string' ) {
4257 return elem
.textContent
;
4258 } else if ( typeof elem
.innerText
=== 'string' ) {
4259 // Replace IE's carriage returns
4260 return elem
.innerText
.replace( rReturn
, '' );
4262 // Traverse it's children
4263 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
4264 ret
+= getText( elem
);
4267 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
4268 return elem
.nodeValue
;
4272 // If no nodeType, this is expected to be an array
4273 for ( i
= 0; (node
= elem
[i
]); i
++ ) {
4274 // Do not traverse comment nodes
4275 if ( node
.nodeType
!== 8 ) {
4276 ret
+= getText( node
);
4283 var Expr
= Sizzle
.selectors
= {
4284 order
: [ "ID", "NAME", "TAG" ],
4287 ID
: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4288 CLASS
: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4289 NAME
: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4290 ATTR
: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4291 TAG
: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4292 CHILD
: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4293 POS
: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4294 PSEUDO
: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4300 "class": "className",
4305 href: function( elem
) {
4306 return elem
.getAttribute( "href" );
4308 type: function( elem
) {
4309 return elem
.getAttribute( "type" );
4314 "+": function(checkSet
, part
){
4315 var isPartStr
= typeof part
=== "string",
4316 isTag
= isPartStr
&& !rNonWord
.test( part
),
4317 isPartStrNotTag
= isPartStr
&& !isTag
;
4320 part
= part
.toLowerCase();
4323 for ( var i
= 0, l
= checkSet
.length
, elem
; i
< l
; i
++ ) {
4324 if ( (elem
= checkSet
[i
]) ) {
4325 while ( (elem
= elem
.previousSibling
) && elem
.nodeType
!== 1 ) {}
4327 checkSet
[i
] = isPartStrNotTag
|| elem
&& elem
.nodeName
.toLowerCase() === part
?
4333 if ( isPartStrNotTag
) {
4334 Sizzle
.filter( part
, checkSet
, true );
4338 ">": function( checkSet
, part
) {
4340 isPartStr
= typeof part
=== "string",
4342 l
= checkSet
.length
;
4344 if ( isPartStr
&& !rNonWord
.test( part
) ) {
4345 part
= part
.toLowerCase();
4347 for ( ; i
< l
; i
++ ) {
4351 var parent
= elem
.parentNode
;
4352 checkSet
[i
] = parent
.nodeName
.toLowerCase() === part
? parent
: false;
4357 for ( ; i
< l
; i
++ ) {
4361 checkSet
[i
] = isPartStr
?
4363 elem
.parentNode
=== part
;
4368 Sizzle
.filter( part
, checkSet
, true );
4373 "": function(checkSet
, part
, isXML
){
4378 if ( typeof part
=== "string" && !rNonWord
.test( part
) ) {
4379 part
= part
.toLowerCase();
4381 checkFn
= dirNodeCheck
;
4384 checkFn( "parentNode", part
, doneName
, checkSet
, nodeCheck
, isXML
);
4387 "~": function( checkSet
, part
, isXML
) {
4392 if ( typeof part
=== "string" && !rNonWord
.test( part
) ) {
4393 part
= part
.toLowerCase();
4395 checkFn
= dirNodeCheck
;
4398 checkFn( "previousSibling", part
, doneName
, checkSet
, nodeCheck
, isXML
);
4403 ID: function( match
, context
, isXML
) {
4404 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
4405 var m
= context
.getElementById(match
[1]);
4406 // Check parentNode to catch when Blackberry 4.6 returns
4407 // nodes that are no longer in the document #6963
4408 return m
&& m
.parentNode
? [m
] : [];
4412 NAME: function( match
, context
) {
4413 if ( typeof context
.getElementsByName
!== "undefined" ) {
4415 results
= context
.getElementsByName( match
[1] );
4417 for ( var i
= 0, l
= results
.length
; i
< l
; i
++ ) {
4418 if ( results
[i
].getAttribute("name") === match
[1] ) {
4419 ret
.push( results
[i
] );
4423 return ret
.length
=== 0 ? null : ret
;
4427 TAG: function( match
, context
) {
4428 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
4429 return context
.getElementsByTagName( match
[1] );
4434 CLASS: function( match
, curLoop
, inplace
, result
, not
, isXML
) {
4435 match
= " " + match
[1].replace( rBackslash
, "" ) + " ";
4441 for ( var i
= 0, elem
; (elem
= curLoop
[i
]) != null; i
++ ) {
4443 if ( not
^ (elem
.className
&& (" " + elem
.className
+ " ").replace(/[\t\n\r]/g, " ").indexOf(match
) >= 0) ) {
4445 result
.push( elem
);
4448 } else if ( inplace
) {
4457 ID: function( match
) {
4458 return match
[1].replace( rBackslash
, "" );
4461 TAG: function( match
, curLoop
) {
4462 return match
[1].replace( rBackslash
, "" ).toLowerCase();
4465 CHILD: function( match
) {
4466 if ( match
[1] === "nth" ) {
4468 Sizzle
.error( match
[0] );
4471 match
[2] = match
[2].replace(/^\+|\s*/g, '');
4473 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4474 var test
= /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4475 match
[2] === "even" && "2n" || match
[2] === "odd" && "2n+1" ||
4476 !/\D/.test( match
[2] ) && "0n+" + match
[2] || match
[2]);
4478 // calculate the numbers (first)n+(last) including if they are negative
4479 match
[2] = (test
[1] + (test
[2] || 1)) - 0;
4480 match
[3] = test
[3] - 0;
4482 else if ( match
[2] ) {
4483 Sizzle
.error( match
[0] );
4486 // TODO: Move to normal caching system
4492 ATTR: function( match
, curLoop
, inplace
, result
, not
, isXML
) {
4493 var name
= match
[1] = match
[1].replace( rBackslash
, "" );
4495 if ( !isXML
&& Expr
.attrMap
[name
] ) {
4496 match
[1] = Expr
.attrMap
[name
];
4499 // Handle if an un-quoted value was used
4500 match
[4] = ( match
[4] || match
[5] || "" ).replace( rBackslash
, "" );
4502 if ( match
[2] === "~=" ) {
4503 match
[4] = " " + match
[4] + " ";
4509 PSEUDO: function( match
, curLoop
, inplace
, result
, not
) {
4510 if ( match
[1] === "not" ) {
4511 // If we're dealing with a complex expression, or a simple one
4512 if ( ( chunker
.exec(match
[3]) || "" ).length
> 1 || /^\w/.test(match
[3]) ) {
4513 match
[3] = Sizzle(match
[3], null, null, curLoop
);
4516 var ret
= Sizzle
.filter(match
[3], curLoop
, inplace
, true ^ not
);
4519 result
.push
.apply( result
, ret
);
4525 } else if ( Expr
.match
.POS
.test( match
[0] ) || Expr
.match
.CHILD
.test( match
[0] ) ) {
4532 POS: function( match
) {
4533 match
.unshift( true );
4540 enabled: function( elem
) {
4541 return elem
.disabled
=== false && elem
.type
!== "hidden";
4544 disabled: function( elem
) {
4545 return elem
.disabled
=== true;
4548 checked: function( elem
) {
4549 return elem
.checked
=== true;
4552 selected: function( elem
) {
4553 // Accessing this property makes selected-by-default
4554 // options in Safari work properly
4555 if ( elem
.parentNode
) {
4556 elem
.parentNode
.selectedIndex
;
4559 return elem
.selected
=== true;
4562 parent: function( elem
) {
4563 return !!elem
.firstChild
;
4566 empty: function( elem
) {
4567 return !elem
.firstChild
;
4570 has: function( elem
, i
, match
) {
4571 return !!Sizzle( match
[3], elem
).length
;
4574 header: function( elem
) {
4575 return (/h\d/i).test( elem
.nodeName
);
4578 text: function( elem
) {
4579 var attr
= elem
.getAttribute( "type" ), type
= elem
.type
;
4580 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4581 // use getAttribute instead to test this case
4582 return elem
.nodeName
.toLowerCase() === "input" && "text" === type
&& ( attr
=== type
|| attr
=== null );
4585 radio: function( elem
) {
4586 return elem
.nodeName
.toLowerCase() === "input" && "radio" === elem
.type
;
4589 checkbox: function( elem
) {
4590 return elem
.nodeName
.toLowerCase() === "input" && "checkbox" === elem
.type
;
4593 file: function( elem
) {
4594 return elem
.nodeName
.toLowerCase() === "input" && "file" === elem
.type
;
4597 password: function( elem
) {
4598 return elem
.nodeName
.toLowerCase() === "input" && "password" === elem
.type
;
4601 submit: function( elem
) {
4602 var name
= elem
.nodeName
.toLowerCase();
4603 return (name
=== "input" || name
=== "button") && "submit" === elem
.type
;
4606 image: function( elem
) {
4607 return elem
.nodeName
.toLowerCase() === "input" && "image" === elem
.type
;
4610 reset: function( elem
) {
4611 var name
= elem
.nodeName
.toLowerCase();
4612 return (name
=== "input" || name
=== "button") && "reset" === elem
.type
;
4615 button: function( elem
) {
4616 var name
= elem
.nodeName
.toLowerCase();
4617 return name
=== "input" && "button" === elem
.type
|| name
=== "button";
4620 input: function( elem
) {
4621 return (/input|select|textarea|button/i).test( elem
.nodeName
);
4624 focus: function( elem
) {
4625 return elem
=== elem
.ownerDocument
.activeElement
;
4629 first: function( elem
, i
) {
4633 last: function( elem
, i
, match
, array
) {
4634 return i
=== array
.length
- 1;
4637 even: function( elem
, i
) {
4641 odd: function( elem
, i
) {
4645 lt: function( elem
, i
, match
) {
4646 return i
< match
[3] - 0;
4649 gt: function( elem
, i
, match
) {
4650 return i
> match
[3] - 0;
4653 nth: function( elem
, i
, match
) {
4654 return match
[3] - 0 === i
;
4657 eq: function( elem
, i
, match
) {
4658 return match
[3] - 0 === i
;
4662 PSEUDO: function( elem
, match
, i
, array
) {
4663 var name
= match
[1],
4664 filter
= Expr
.filters
[ name
];
4667 return filter( elem
, i
, match
, array
);
4669 } else if ( name
=== "contains" ) {
4670 return (elem
.textContent
|| elem
.innerText
|| getText([ elem
]) || "").indexOf(match
[3]) >= 0;
4672 } else if ( name
=== "not" ) {
4675 for ( var j
= 0, l
= not
.length
; j
< l
; j
++ ) {
4676 if ( not
[j
] === elem
) {
4684 Sizzle
.error( name
);
4688 CHILD: function( elem
, match
) {
4690 doneName
, parent
, cache
,
4698 while ( (node
= node
.previousSibling
) ) {
4699 if ( node
.nodeType
=== 1 ) {
4704 if ( type
=== "first" ) {
4711 while ( (node
= node
.nextSibling
) ) {
4712 if ( node
.nodeType
=== 1 ) {
4723 if ( first
=== 1 && last
=== 0 ) {
4727 doneName
= match
[0];
4728 parent
= elem
.parentNode
;
4730 if ( parent
&& (parent
[ expando
] !== doneName
|| !elem
.nodeIndex
) ) {
4733 for ( node
= parent
.firstChild
; node
; node
= node
.nextSibling
) {
4734 if ( node
.nodeType
=== 1 ) {
4735 node
.nodeIndex
= ++count
;
4739 parent
[ expando
] = doneName
;
4742 diff
= elem
.nodeIndex
- last
;
4744 if ( first
=== 0 ) {
4748 return ( diff
% first
=== 0 && diff
/ first
>= 0 );
4753 ID: function( elem
, match
) {
4754 return elem
.nodeType
=== 1 && elem
.getAttribute("id") === match
;
4757 TAG: function( elem
, match
) {
4758 return (match
=== "*" && elem
.nodeType
=== 1) || !!elem
.nodeName
&& elem
.nodeName
.toLowerCase() === match
;
4761 CLASS: function( elem
, match
) {
4762 return (" " + (elem
.className
|| elem
.getAttribute("class")) + " ")
4763 .indexOf( match
) > -1;
4766 ATTR: function( elem
, match
) {
4767 var name
= match
[1],
4768 result
= Sizzle
.attr
?
4769 Sizzle
.attr( elem
, name
) :
4770 Expr
.attrHandle
[ name
] ?
4771 Expr
.attrHandle
[ name
]( elem
) :
4772 elem
[ name
] != null ?
4774 elem
.getAttribute( name
),
4775 value
= result
+ "",
4779 return result
== null ?
4781 !type
&& Sizzle
.attr
?
4786 value
.indexOf(check
) >= 0 :
4788 (" " + value
+ " ").indexOf(check
) >= 0 :
4790 value
&& result
!== false :
4794 value
.indexOf(check
) === 0 :
4796 value
.substr(value
.length
- check
.length
) === check
:
4798 value
=== check
|| value
.substr(0, check
.length
+ 1) === check
+ "-" :
4802 POS: function( elem
, match
, i
, array
) {
4803 var name
= match
[2],
4804 filter
= Expr
.setFilters
[ name
];
4807 return filter( elem
, i
, match
, array
);
4813 var origPOS
= Expr
.match
.POS
,
4814 fescape = function(all
, num
){
4815 return "\\" + (num
- 0 + 1);
4818 for ( var type
in Expr
.match
) {
4819 Expr
.match
[ type
] = new RegExp( Expr
.match
[ type
].source
+ (/(?![^\[]*\])(?![^\(]*\))/.source
) );
4820 Expr
.leftMatch
[ type
] = new RegExp( /(^(?:.|\r|\n)*?)/.source
+ Expr
.match
[ type
].source
.replace(/\\(\d+)/g, fescape
) );
4823 var makeArray = function( array
, results
) {
4824 array
= Array
.prototype.slice
.call( array
, 0 );
4827 results
.push
.apply( results
, array
);
4834 // Perform a simple check to determine if the browser is capable of
4835 // converting a NodeList to an array using builtin methods.
4836 // Also verifies that the returned array holds DOM nodes
4837 // (which is not the case in the Blackberry browser)
4839 Array
.prototype.slice
.call( document
.documentElement
.childNodes
, 0 )[0].nodeType
;
4841 // Provide a fallback method if it does not work
4843 makeArray = function( array
, results
) {
4845 ret
= results
|| [];
4847 if ( toString
.call(array
) === "[object Array]" ) {
4848 Array
.prototype.push
.apply( ret
, array
);
4851 if ( typeof array
.length
=== "number" ) {
4852 for ( var l
= array
.length
; i
< l
; i
++ ) {
4853 ret
.push( array
[i
] );
4857 for ( ; array
[i
]; i
++ ) {
4858 ret
.push( array
[i
] );
4867 var sortOrder
, siblingCheck
;
4869 if ( document
.documentElement
.compareDocumentPosition
) {
4870 sortOrder = function( a
, b
) {
4872 hasDuplicate
= true;
4876 if ( !a
.compareDocumentPosition
|| !b
.compareDocumentPosition
) {
4877 return a
.compareDocumentPosition
? -1 : 1;
4880 return a
.compareDocumentPosition(b
) & 4 ? -1 : 1;
4884 sortOrder = function( a
, b
) {
4885 // The nodes are identical, we can exit early
4887 hasDuplicate
= true;
4890 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4891 } else if ( a
.sourceIndex
&& b
.sourceIndex
) {
4892 return a
.sourceIndex
- b
.sourceIndex
;
4902 // If the nodes are siblings (or identical) we can do a quick check
4903 if ( aup
=== bup
) {
4904 return siblingCheck( a
, b
);
4906 // If no parents were found then the nodes are disconnected
4907 } else if ( !aup
) {
4910 } else if ( !bup
) {
4914 // Otherwise they're somewhere else in the tree so we need
4915 // to build up a full list of the parentNodes for comparison
4918 cur
= cur
.parentNode
;
4925 cur
= cur
.parentNode
;
4931 // Start walking down the tree looking for a discrepancy
4932 for ( var i
= 0; i
< al
&& i
< bl
; i
++ ) {
4933 if ( ap
[i
] !== bp
[i
] ) {
4934 return siblingCheck( ap
[i
], bp
[i
] );
4938 // We ended someplace up the tree so do a sibling check
4940 siblingCheck( a
, bp
[i
], -1 ) :
4941 siblingCheck( ap
[i
], b
, 1 );
4944 siblingCheck = function( a
, b
, ret
) {
4949 var cur
= a
.nextSibling
;
4956 cur
= cur
.nextSibling
;
4963 // Check to see if the browser returns elements by name when
4964 // querying by getElementById (and provide a workaround)
4966 // We're going to inject a fake input element with a specified name
4967 var form
= document
.createElement("div"),
4968 id
= "script" + (new Date()).getTime(),
4969 root
= document
.documentElement
;
4971 form
.innerHTML
= "<a name='" + id
+ "'/>";
4973 // Inject it into the root element, check its status, and remove it quickly
4974 root
.insertBefore( form
, root
.firstChild
);
4976 // The workaround has to do additional checks after a getElementById
4977 // Which slows things down for other browsers (hence the branching)
4978 if ( document
.getElementById( id
) ) {
4979 Expr
.find
.ID = function( match
, context
, isXML
) {
4980 if ( typeof context
.getElementById
!== "undefined" && !isXML
) {
4981 var m
= context
.getElementById(match
[1]);
4984 m
.id
=== match
[1] || typeof m
.getAttributeNode
!== "undefined" && m
.getAttributeNode("id").nodeValue
=== match
[1] ?
4991 Expr
.filter
.ID = function( elem
, match
) {
4992 var node
= typeof elem
.getAttributeNode
!== "undefined" && elem
.getAttributeNode("id");
4994 return elem
.nodeType
=== 1 && node
&& node
.nodeValue
=== match
;
4998 root
.removeChild( form
);
5000 // release memory in IE
5005 // Check to see if the browser returns only elements
5006 // when doing getElementsByTagName("*")
5008 // Create a fake element
5009 var div
= document
.createElement("div");
5010 div
.appendChild( document
.createComment("") );
5012 // Make sure no comments are found
5013 if ( div
.getElementsByTagName("*").length
> 0 ) {
5014 Expr
.find
.TAG = function( match
, context
) {
5015 var results
= context
.getElementsByTagName( match
[1] );
5017 // Filter out possible comments
5018 if ( match
[1] === "*" ) {
5021 for ( var i
= 0; results
[i
]; i
++ ) {
5022 if ( results
[i
].nodeType
=== 1 ) {
5023 tmp
.push( results
[i
] );
5034 // Check to see if an attribute returns normalized href attributes
5035 div
.innerHTML
= "<a href='#'></a>";
5037 if ( div
.firstChild
&& typeof div
.firstChild
.getAttribute
!== "undefined" &&
5038 div
.firstChild
.getAttribute("href") !== "#" ) {
5040 Expr
.attrHandle
.href = function( elem
) {
5041 return elem
.getAttribute( "href", 2 );
5045 // release memory in IE
5049 if ( document
.querySelectorAll
) {
5051 var oldSizzle
= Sizzle
,
5052 div
= document
.createElement("div"),
5055 div
.innerHTML
= "<p class='TEST'></p>";
5057 // Safari can't handle uppercase or unicode characters when
5059 if ( div
.querySelectorAll
&& div
.querySelectorAll(".TEST").length
=== 0 ) {
5063 Sizzle = function( query
, context
, extra
, seed
) {
5064 context
= context
|| document
;
5066 // Only use querySelectorAll on non-XML documents
5067 // (ID selectors don't work in non-HTML documents)
5068 if ( !seed
&& !Sizzle
.isXML(context
) ) {
5069 // See if we find a selector to speed up
5070 var match
= /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query
);
5072 if ( match
&& (context
.nodeType
=== 1 || context
.nodeType
=== 9) ) {
5073 // Speed-up: Sizzle("TAG")
5075 return makeArray( context
.getElementsByTagName( query
), extra
);
5077 // Speed-up: Sizzle(".CLASS")
5078 } else if ( match
[2] && Expr
.find
.CLASS
&& context
.getElementsByClassName
) {
5079 return makeArray( context
.getElementsByClassName( match
[2] ), extra
);
5083 if ( context
.nodeType
=== 9 ) {
5084 // Speed-up: Sizzle("body")
5085 // The body element only exists once, optimize finding it
5086 if ( query
=== "body" && context
.body
) {
5087 return makeArray( [ context
.body
], extra
);
5089 // Speed-up: Sizzle("#ID")
5090 } else if ( match
&& match
[3] ) {
5091 var elem
= context
.getElementById( match
[3] );
5093 // Check parentNode to catch when Blackberry 4.6 returns
5094 // nodes that are no longer in the document #6963
5095 if ( elem
&& elem
.parentNode
) {
5096 // Handle the case where IE and Opera return items
5097 // by name instead of ID
5098 if ( elem
.id
=== match
[3] ) {
5099 return makeArray( [ elem
], extra
);
5103 return makeArray( [], extra
);
5108 return makeArray( context
.querySelectorAll(query
), extra
);
5109 } catch(qsaError
) {}
5111 // qSA works strangely on Element-rooted queries
5112 // We can work around this by specifying an extra ID on the root
5113 // and working up from there (Thanks to Andrew Dupont for the technique)
5114 // IE 8 doesn't work on object elements
5115 } else if ( context
.nodeType
=== 1 && context
.nodeName
.toLowerCase() !== "object" ) {
5116 var oldContext
= context
,
5117 old
= context
.getAttribute( "id" ),
5119 hasParent
= context
.parentNode
,
5120 relativeHierarchySelector
= /^\s*[+~]/.test( query
);
5123 context
.setAttribute( "id", nid
);
5125 nid
= nid
.replace( /'/g, "\\$&" );
5127 if ( relativeHierarchySelector && hasParent ) {
5128 context = context.parentNode;
5132 if ( !relativeHierarchySelector || hasParent ) {
5133 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
5136 } catch(pseudoError) {
5139 oldContext.removeAttribute( "id" );
5145 return oldSizzle(query, context, extra, seed);
5148 for ( var prop in oldSizzle ) {
5149 Sizzle[ prop ] = oldSizzle[ prop ];
5152 // release memory in IE
5158 var html = document.documentElement,
5159 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
5162 // Check to see if it's possible to
do matchesSelector
5163 // on a disconnected node (IE 9 fails this)
5164 var disconnectedMatch
= !matches
.call( document
.createElement( "div" ), "div" ),
5165 pseudoWorks
= false;
5168 // This should fail with an exception
5169 // Gecko does not error, returns false instead
5170 matches
.call( document
.documentElement
, "[test!='']:sizzle" );
5172 } catch( pseudoError
) {
5176 Sizzle
.matchesSelector = function( node
, expr
) {
5177 // Make sure that attribute selectors are quoted
5178 expr
= expr
.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5180 if ( !Sizzle
.isXML( node
) ) {
5182 if ( pseudoWorks
|| !Expr
.match
.PSEUDO
.test( expr
) && !/!=/.test( expr
) ) {
5183 var ret
= matches
.call( node
, expr
);
5185 // IE 9's matchesSelector returns false on disconnected nodes
5186 if ( ret
|| !disconnectedMatch
||
5187 // As well, disconnected nodes are said to be in a document
5188 // fragment in IE 9, so check for that
5189 node
.document
&& node
.document
.nodeType
!== 11 ) {
5196 return Sizzle(expr
, null, null, [node
]).length
> 0;
5202 var div
= document
.createElement("div");
5204 div
.innerHTML
= "<div class='test e'></div><div class='test'></div>";
5206 // Opera can't find a second classname (in 9.6)
5207 // Also, make sure that getElementsByClassName actually exists
5208 if ( !div
.getElementsByClassName
|| div
.getElementsByClassName("e").length
=== 0 ) {
5212 // Safari caches class attributes, doesn't catch changes (in 3.2)
5213 div
.lastChild
.className
= "e";
5215 if ( div
.getElementsByClassName("e").length
=== 1 ) {
5219 Expr
.order
.splice(1, 0, "CLASS");
5220 Expr
.find
.CLASS = function( match
, context
, isXML
) {
5221 if ( typeof context
.getElementsByClassName
!== "undefined" && !isXML
) {
5222 return context
.getElementsByClassName(match
[1]);
5226 // release memory in IE
5230 function dirNodeCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
5231 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
5232 var elem
= checkSet
[i
];
5240 if ( elem
[ expando
] === doneName
) {
5241 match
= checkSet
[elem
.sizset
];
5245 if ( elem
.nodeType
=== 1 && !isXML
){
5246 elem
[ expando
] = doneName
;
5250 if ( elem
.nodeName
.toLowerCase() === cur
) {
5258 checkSet
[i
] = match
;
5263 function dirCheck( dir
, cur
, doneName
, checkSet
, nodeCheck
, isXML
) {
5264 for ( var i
= 0, l
= checkSet
.length
; i
< l
; i
++ ) {
5265 var elem
= checkSet
[i
];
5273 if ( elem
[ expando
] === doneName
) {
5274 match
= checkSet
[elem
.sizset
];
5278 if ( elem
.nodeType
=== 1 ) {
5280 elem
[ expando
] = doneName
;
5284 if ( typeof cur
!== "string" ) {
5285 if ( elem
=== cur
) {
5290 } else if ( Sizzle
.filter( cur
, [elem
] ).length
> 0 ) {
5299 checkSet
[i
] = match
;
5304 if ( document
.documentElement
.contains
) {
5305 Sizzle
.contains = function( a
, b
) {
5306 return a
!== b
&& (a
.contains
? a
.contains(b
) : true);
5309 } else if ( document
.documentElement
.compareDocumentPosition
) {
5310 Sizzle
.contains = function( a
, b
) {
5311 return !!(a
.compareDocumentPosition(b
) & 16);
5315 Sizzle
.contains = function() {
5320 Sizzle
.isXML = function( elem
) {
5321 // documentElement is verified for cases where it doesn't yet exist
5322 // (such as loading iframes in IE - #4833)
5323 var documentElement
= (elem
? elem
.ownerDocument
|| elem
: 0).documentElement
;
5325 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
5328 var posProcess = function( selector
, context
, seed
) {
5332 root
= context
.nodeType
? [context
] : context
;
5334 // Position selectors must be done after the filter
5335 // And so must :not(positional) so we move all PSEUDOs to the end
5336 while ( (match
= Expr
.match
.PSEUDO
.exec( selector
)) ) {
5338 selector
= selector
.replace( Expr
.match
.PSEUDO
, "" );
5341 selector
= Expr
.relative
[selector
] ? selector
+ "*" : selector
;
5343 for ( var i
= 0, l
= root
.length
; i
< l
; i
++ ) {
5344 Sizzle( selector
, root
[i
], tmpSet
, seed
);
5347 return Sizzle
.filter( later
, tmpSet
);
5351 // Override sizzle attribute retrieval
5352 Sizzle
.attr
= jQuery
.attr
;
5353 Sizzle
.selectors
.attrMap
= {};
5354 jQuery
.find
= Sizzle
;
5355 jQuery
.expr
= Sizzle
.selectors
;
5356 jQuery
.expr
[":"] = jQuery
.expr
.filters
;
5357 jQuery
.unique
= Sizzle
.uniqueSort
;
5358 jQuery
.text
= Sizzle
.getText
;
5359 jQuery
.isXMLDoc
= Sizzle
.isXML
;
5360 jQuery
.contains
= Sizzle
.contains
;
5366 var runtil
= /Until$/,
5367 rparentsprev
= /^(?:parents|prevUntil|prevAll)/,
5368 // Note: This RegExp should be improved, or likely pulled from Sizzle
5369 rmultiselector
= /,/,
5370 isSimple
= /^.[^:#\[\.,]*$/,
5371 slice
= Array
.prototype.slice
,
5372 POS
= jQuery
.expr
.match
.POS
,
5373 // methods guaranteed to produce a unique set when starting from a unique set
5374 guaranteedUnique
= {
5382 find: function( selector
) {
5386 if ( typeof selector
!== "string" ) {
5387 return jQuery( selector
).filter(function() {
5388 for ( i
= 0, l
= self
.length
; i
< l
; i
++ ) {
5389 if ( jQuery
.contains( self
[ i
], this ) ) {
5396 var ret
= this.pushStack( "", "find", selector
),
5399 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
5400 length
= ret
.length
;
5401 jQuery
.find( selector
, this[i
], ret
);
5404 // Make sure that the results are unique
5405 for ( n
= length
; n
< ret
.length
; n
++ ) {
5406 for ( r
= 0; r
< length
; r
++ ) {
5407 if ( ret
[r
] === ret
[n
] ) {
5419 has: function( target
) {
5420 var targets
= jQuery( target
);
5421 return this.filter(function() {
5422 for ( var i
= 0, l
= targets
.length
; i
< l
; i
++ ) {
5423 if ( jQuery
.contains( this, targets
[i
] ) ) {
5430 not: function( selector
) {
5431 return this.pushStack( winnow(this, selector
, false), "not", selector
);
5434 filter: function( selector
) {
5435 return this.pushStack( winnow(this, selector
, true), "filter", selector
);
5438 is: function( selector
) {
5439 return !!selector
&& (
5440 typeof selector
=== "string" ?
5441 // If this is a positional selector, check membership in the returned set
5442 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5443 POS
.test( selector
) ?
5444 jQuery( selector
, this.context
).index( this[0] ) >= 0 :
5445 jQuery
.filter( selector
, this ).length
> 0 :
5446 this.filter( selector
).length
> 0 );
5449 closest: function( selectors
, context
) {
5450 var ret
= [], i
, l
, cur
= this[0];
5452 // Array (deprecated as of jQuery 1.7)
5453 if ( jQuery
.isArray( selectors
) ) {
5456 while ( cur
&& cur
.ownerDocument
&& cur
!== context
) {
5457 for ( i
= 0; i
< selectors
.length
; i
++ ) {
5459 if ( jQuery( cur
).is( selectors
[ i
] ) ) {
5460 ret
.push({ selector
: selectors
[ i
], elem
: cur
, level
: level
});
5464 cur
= cur
.parentNode
;
5472 var pos
= POS
.test( selectors
) || typeof selectors
!== "string" ?
5473 jQuery( selectors
, context
|| this.context
) :
5476 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
5480 if ( pos
? pos
.index(cur
) > -1 : jQuery
.find
.matchesSelector(cur
, selectors
) ) {
5485 cur
= cur
.parentNode
;
5486 if ( !cur
|| !cur
.ownerDocument
|| cur
=== context
|| cur
.nodeType
=== 11 ) {
5493 ret
= ret
.length
> 1 ? jQuery
.unique( ret
) : ret
;
5495 return this.pushStack( ret
, "closest", selectors
);
5498 // Determine the position of an element within
5499 // the matched set of elements
5500 index: function( elem
) {
5502 // No argument, return index in parent
5504 return ( this[0] && this[0].parentNode
) ? this.prevAll().length
: -1;
5507 // index in selector
5508 if ( typeof elem
=== "string" ) {
5509 return jQuery
.inArray( this[0], jQuery( elem
) );
5512 // Locate the position of the desired element
5513 return jQuery
.inArray(
5514 // If it receives a jQuery object, the first element is used
5515 elem
.jquery
? elem
[0] : elem
, this );
5518 add: function( selector
, context
) {
5519 var set = typeof selector
=== "string" ?
5520 jQuery( selector
, context
) :
5521 jQuery
.makeArray( selector
&& selector
.nodeType
? [ selector
] : selector
),
5522 all
= jQuery
.merge( this.get(), set );
5524 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all
[0] ) ?
5526 jQuery
.unique( all
) );
5529 andSelf: function() {
5530 return this.add( this.prevObject
);
5534 // A painfully simple check to see if an element is disconnected
5535 // from a document (should be improved, where feasible).
5536 function isDisconnected( node
) {
5537 return !node
|| !node
.parentNode
|| node
.parentNode
.nodeType
=== 11;
5541 parent: function( elem
) {
5542 var parent
= elem
.parentNode
;
5543 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
5545 parents: function( elem
) {
5546 return jQuery
.dir( elem
, "parentNode" );
5548 parentsUntil: function( elem
, i
, until
) {
5549 return jQuery
.dir( elem
, "parentNode", until
);
5551 next: function( elem
) {
5552 return jQuery
.nth( elem
, 2, "nextSibling" );
5554 prev: function( elem
) {
5555 return jQuery
.nth( elem
, 2, "previousSibling" );
5557 nextAll: function( elem
) {
5558 return jQuery
.dir( elem
, "nextSibling" );
5560 prevAll: function( elem
) {
5561 return jQuery
.dir( elem
, "previousSibling" );
5563 nextUntil: function( elem
, i
, until
) {
5564 return jQuery
.dir( elem
, "nextSibling", until
);
5566 prevUntil: function( elem
, i
, until
) {
5567 return jQuery
.dir( elem
, "previousSibling", until
);
5569 siblings: function( elem
) {
5570 return jQuery
.sibling( elem
.parentNode
.firstChild
, elem
);
5572 children: function( elem
) {
5573 return jQuery
.sibling( elem
.firstChild
);
5575 contents: function( elem
) {
5576 return jQuery
.nodeName( elem
, "iframe" ) ?
5577 elem
.contentDocument
|| elem
.contentWindow
.document
:
5578 jQuery
.makeArray( elem
.childNodes
);
5580 }, function( name
, fn
) {
5581 jQuery
.fn
[ name
] = function( until
, selector
) {
5582 var ret
= jQuery
.map( this, fn
, until
),
5583 // The variable 'args' was introduced in
5584 // https://github.com/jquery/jquery/commit/52a0238
5585 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
5586 // http://code.google.com/p/v8/issues/detail?id=1050
5587 args
= slice
.call(arguments
);
5589 if ( !runtil
.test( name
) ) {
5593 if ( selector
&& typeof selector
=== "string" ) {
5594 ret
= jQuery
.filter( selector
, ret
);
5597 ret
= this.length
> 1 && !guaranteedUnique
[ name
] ? jQuery
.unique( ret
) : ret
;
5599 if ( (this.length
> 1 || rmultiselector
.test( selector
)) && rparentsprev
.test( name
) ) {
5600 ret
= ret
.reverse();
5603 return this.pushStack( ret
, name
, args
.join(",") );
5608 filter: function( expr
, elems
, not
) {
5610 expr
= ":not(" + expr
+ ")";
5613 return elems
.length
=== 1 ?
5614 jQuery
.find
.matchesSelector(elems
[0], expr
) ? [ elems
[0] ] : [] :
5615 jQuery
.find
.matches(expr
, elems
);
5618 dir: function( elem
, dir
, until
) {
5622 while ( cur
&& cur
.nodeType
!== 9 && (until
=== undefined || cur
.nodeType
!== 1 || !jQuery( cur
).is( until
)) ) {
5623 if ( cur
.nodeType
=== 1 ) {
5624 matched
.push( cur
);
5631 nth: function( cur
, result
, dir
, elem
) {
5632 result
= result
|| 1;
5635 for ( ; cur
; cur
= cur
[dir
] ) {
5636 if ( cur
.nodeType
=== 1 && ++num
=== result
) {
5644 sibling: function( n
, elem
) {
5647 for ( ; n
; n
= n
.nextSibling
) {
5648 if ( n
.nodeType
=== 1 && n
!== elem
) {
5657 // Implement the identical functionality for filter and not
5658 function winnow( elements
, qualifier
, keep
) {
5660 // Can't pass null or undefined to indexOf in Firefox 4
5661 // Set to 0 to skip string check
5662 qualifier
= qualifier
|| 0;
5664 if ( jQuery
.isFunction( qualifier
) ) {
5665 return jQuery
.grep(elements
, function( elem
, i
) {
5666 var retVal
= !!qualifier
.call( elem
, i
, elem
);
5667 return retVal
=== keep
;
5670 } else if ( qualifier
.nodeType
) {
5671 return jQuery
.grep(elements
, function( elem
, i
) {
5672 return ( elem
=== qualifier
) === keep
;
5675 } else if ( typeof qualifier
=== "string" ) {
5676 var filtered
= jQuery
.grep(elements
, function( elem
) {
5677 return elem
.nodeType
=== 1;
5680 if ( isSimple
.test( qualifier
) ) {
5681 return jQuery
.filter(qualifier
, filtered
, !keep
);
5683 qualifier
= jQuery
.filter( qualifier
, filtered
);
5687 return jQuery
.grep(elements
, function( elem
, i
) {
5688 return ( jQuery
.inArray( elem
, qualifier
) >= 0 ) === keep
;
5695 function createSafeFragment( document
) {
5696 var list
= nodeNames
.split( " " ),
5697 safeFrag
= document
.createDocumentFragment();
5699 if ( safeFrag
.createElement
) {
5700 while ( list
.length
) {
5701 safeFrag
.createElement(
5709 var nodeNames
= "abbr article aside audio canvas datalist details figcaption figure footer " +
5710 "header hgroup mark meter nav output progress section summary time video",
5711 rinlinejQuery
= / jQuery
\d
+="(?:\d+|null)"/g
,
5712 rleadingWhitespace
= /^\s+/,
5713 rxhtmlTag
= /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5714 rtagName
= /<([\w:]+)/,
5716 rhtml
= /<|&#?\w+;/,
5717 rnoInnerhtml
= /<(?:script|style)/i,
5718 rnocache
= /<(?:script|object|embed|option|style)/i,
5719 rnoshimcache
= new RegExp("<(?:" + nodeNames
.replace(" ", "|") + ")", "i"),
5720 // checked="checked" or checked
5721 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5722 rscriptType
= /\/(java|ecma)script/i,
5723 rcleanScript
= /^\s*<!(?:\[CDATA\[|\-\-)/,
5725 option
: [ 1, "<select multiple='multiple'>", "</select>" ],
5726 legend
: [ 1, "<fieldset>", "</fieldset>" ],
5727 thead
: [ 1, "<table>", "</table>" ],
5728 tr
: [ 2, "<table><tbody>", "</tbody></table>" ],
5729 td
: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5730 col
: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5731 area
: [ 1, "<map>", "</map>" ],
5732 _default
: [ 0, "", "" ]
5734 safeFragment
= createSafeFragment( document
);
5736 wrapMap
.optgroup
= wrapMap
.option
;
5737 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
5738 wrapMap
.th
= wrapMap
.td
;
5740 // IE can't serialize <link> and <script> tags normally
5741 if ( !jQuery
.support
.htmlSerialize
) {
5742 wrapMap
._default
= [ 1, "div<div>", "</div>" ];
5746 text: function( text
) {
5747 if ( jQuery
.isFunction(text
) ) {
5748 return this.each(function(i
) {
5749 var self
= jQuery( this );
5751 self
.text( text
.call(this, i
, self
.text()) );
5755 if ( typeof text
!== "object" && text
!== undefined ) {
5756 return this.empty().append( (this[0] && this[0].ownerDocument
|| document
).createTextNode( text
) );
5759 return jQuery
.text( this );
5762 wrapAll: function( html
) {
5763 if ( jQuery
.isFunction( html
) ) {
5764 return this.each(function(i
) {
5765 jQuery(this).wrapAll( html
.call(this, i
) );
5770 // The elements to wrap the target around
5771 var wrap
= jQuery( html
, this[0].ownerDocument
).eq(0).clone(true);
5773 if ( this[0].parentNode
) {
5774 wrap
.insertBefore( this[0] );
5777 wrap
.map(function() {
5780 while ( elem
.firstChild
&& elem
.firstChild
.nodeType
=== 1 ) {
5781 elem
= elem
.firstChild
;
5791 wrapInner: function( html
) {
5792 if ( jQuery
.isFunction( html
) ) {
5793 return this.each(function(i
) {
5794 jQuery(this).wrapInner( html
.call(this, i
) );
5798 return this.each(function() {
5799 var self
= jQuery( this ),
5800 contents
= self
.contents();
5802 if ( contents
.length
) {
5803 contents
.wrapAll( html
);
5806 self
.append( html
);
5811 wrap: function( html
) {
5812 return this.each(function() {
5813 jQuery( this ).wrapAll( html
);
5817 unwrap: function() {
5818 return this.parent().each(function() {
5819 if ( !jQuery
.nodeName( this, "body" ) ) {
5820 jQuery( this ).replaceWith( this.childNodes
);
5825 append: function() {
5826 return this.domManip(arguments
, true, function( elem
) {
5827 if ( this.nodeType
=== 1 ) {
5828 this.appendChild( elem
);
5833 prepend: function() {
5834 return this.domManip(arguments
, true, function( elem
) {
5835 if ( this.nodeType
=== 1 ) {
5836 this.insertBefore( elem
, this.firstChild
);
5841 before: function() {
5842 if ( this[0] && this[0].parentNode
) {
5843 return this.domManip(arguments
, false, function( elem
) {
5844 this.parentNode
.insertBefore( elem
, this );
5846 } else if ( arguments
.length
) {
5847 var set = jQuery(arguments
[0]);
5848 set.push
.apply( set, this.toArray() );
5849 return this.pushStack( set, "before", arguments
);
5854 if ( this[0] && this[0].parentNode
) {
5855 return this.domManip(arguments
, false, function( elem
) {
5856 this.parentNode
.insertBefore( elem
, this.nextSibling
);
5858 } else if ( arguments
.length
) {
5859 var set = this.pushStack( this, "after", arguments
);
5860 set.push
.apply( set, jQuery(arguments
[0]).toArray() );
5865 // keepData is for internal use only--do not document
5866 remove: function( selector
, keepData
) {
5867 for ( var i
= 0, elem
; (elem
= this[i
]) != null; i
++ ) {
5868 if ( !selector
|| jQuery
.filter( selector
, [ elem
] ).length
) {
5869 if ( !keepData
&& elem
.nodeType
=== 1 ) {
5870 jQuery
.cleanData( elem
.getElementsByTagName("*") );
5871 jQuery
.cleanData( [ elem
] );
5874 if ( elem
.parentNode
) {
5875 elem
.parentNode
.removeChild( elem
);
5884 for ( var i
= 0, elem
; (elem
= this[i
]) != null; i
++ ) {
5885 // Remove element nodes and prevent memory leaks
5886 if ( elem
.nodeType
=== 1 ) {
5887 jQuery
.cleanData( elem
.getElementsByTagName("*") );
5890 // Remove any remaining nodes
5891 while ( elem
.firstChild
) {
5892 elem
.removeChild( elem
.firstChild
);
5899 clone: function( dataAndEvents
, deepDataAndEvents
) {
5900 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
5901 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents
: deepDataAndEvents
;
5903 return this.map( function () {
5904 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
5908 html: function( value
) {
5909 if ( value
=== undefined ) {
5910 return this[0] && this[0].nodeType
=== 1 ?
5911 this[0].innerHTML
.replace(rinlinejQuery
, "") :
5914 // See if we can take a shortcut and just use innerHTML
5915 } else if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
5916 (jQuery
.support
.leadingWhitespace
|| !rleadingWhitespace
.test( value
)) &&
5917 !wrapMap
[ (rtagName
.exec( value
) || ["", ""])[1].toLowerCase() ] ) {
5919 value
= value
.replace(rxhtmlTag
, "<$1></$2>");
5922 for ( var i
= 0, l
= this.length
; i
< l
; i
++ ) {
5923 // Remove element nodes and prevent memory leaks
5924 if ( this[i
].nodeType
=== 1 ) {
5925 jQuery
.cleanData( this[i
].getElementsByTagName("*") );
5926 this[i
].innerHTML
= value
;
5930 // If using innerHTML throws an exception, use the fallback method
5932 this.empty().append( value
);
5935 } else if ( jQuery
.isFunction( value
) ) {
5936 this.each(function(i
){
5937 var self
= jQuery( this );
5939 self
.html( value
.call(this, i
, self
.html()) );
5943 this.empty().append( value
);
5949 replaceWith: function( value
) {
5950 if ( this[0] && this[0].parentNode
) {
5951 // Make sure that the elements are removed from the DOM before they are inserted
5952 // this can help fix replacing a parent with child elements
5953 if ( jQuery
.isFunction( value
) ) {
5954 return this.each(function(i
) {
5955 var self
= jQuery(this), old
= self
.html();
5956 self
.replaceWith( value
.call( this, i
, old
) );
5960 if ( typeof value
!== "string" ) {
5961 value
= jQuery( value
).detach();
5964 return this.each(function() {
5965 var next
= this.nextSibling
,
5966 parent
= this.parentNode
;
5968 jQuery( this ).remove();
5971 jQuery(next
).before( value
);
5973 jQuery(parent
).append( value
);
5977 return this.length
?
5978 this.pushStack( jQuery(jQuery
.isFunction(value
) ? value() : value
), "replaceWith", value
) :
5983 detach: function( selector
) {
5984 return this.remove( selector
, true );
5987 domManip: function( args
, table
, callback
) {
5988 var results
, first
, fragment
, parent
,
5992 // We can't cloneNode fragments that contain checked, in WebKit
5993 if ( !jQuery
.support
.checkClone
&& arguments
.length
=== 3 && typeof value
=== "string" && rchecked
.test( value
) ) {
5994 return this.each(function() {
5995 jQuery(this).domManip( args
, table
, callback
, true );
5999 if ( jQuery
.isFunction(value
) ) {
6000 return this.each(function(i
) {
6001 var self
= jQuery(this);
6002 args
[0] = value
.call(this, i
, table
? self
.html() : undefined);
6003 self
.domManip( args
, table
, callback
);
6008 parent
= value
&& value
.parentNode
;
6010 // If we're in a fragment, just use that instead of building a new one
6011 if ( jQuery
.support
.parentNode
&& parent
&& parent
.nodeType
=== 11 && parent
.childNodes
.length
=== this.length
) {
6012 results
= { fragment
: parent
};
6015 results
= jQuery
.buildFragment( args
, this, scripts
);
6018 fragment
= results
.fragment
;
6020 if ( fragment
.childNodes
.length
=== 1 ) {
6021 first
= fragment
= fragment
.firstChild
;
6023 first
= fragment
.firstChild
;
6027 table
= table
&& jQuery
.nodeName( first
, "tr" );
6029 for ( var i
= 0, l
= this.length
, lastIndex
= l
- 1; i
< l
; i
++ ) {
6032 root(this[i
], first
) :
6034 // Make sure that we do not leak memory by inadvertently discarding
6035 // the original fragment (which might have attached data) instead of
6036 // using it; in addition, use the original fragment object for the last
6037 // item instead of first because it can end up being emptied incorrectly
6038 // in certain situations (Bug #8070).
6039 // Fragments from the fragment cache must always be cloned and never used
6041 results
.cacheable
|| ( l
> 1 && i
< lastIndex
) ?
6042 jQuery
.clone( fragment
, true, true ) :
6048 if ( scripts
.length
) {
6049 jQuery
.each( scripts
, evalScript
);
6057 function root( elem
, cur
) {
6058 return jQuery
.nodeName(elem
, "table") ?
6059 (elem
.getElementsByTagName("tbody")[0] ||
6060 elem
.appendChild(elem
.ownerDocument
.createElement("tbody"))) :
6064 function cloneCopyEvent( src
, dest
) {
6066 if ( dest
.nodeType
!== 1 || !jQuery
.hasData( src
) ) {
6071 oldData
= jQuery
._data( src
),
6072 curData
= jQuery
._data( dest
, oldData
),
6073 events
= oldData
.events
;
6076 delete curData
.handle
;
6077 curData
.events
= {};
6079 for ( type
in events
) {
6080 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
6081 jQuery
.event
.add( dest
, type
+ ( events
[ type
][ i
].namespace ? "." : "" ) + events
[ type
][ i
].namespace, events
[ type
][ i
], events
[ type
][ i
].data
);
6086 // make the cloned public data object a copy from the original
6087 if ( curData
.data
) {
6088 curData
.data
= jQuery
.extend( {}, curData
.data
);
6092 function cloneFixAttributes( src
, dest
) {
6095 // We do not need to do anything for non-Elements
6096 if ( dest
.nodeType
!== 1 ) {
6100 // clearAttributes removes the attributes, which we don't want,
6101 // but also removes the attachEvent events, which we *do* want
6102 if ( dest
.clearAttributes
) {
6103 dest
.clearAttributes();
6106 // mergeAttributes, in contrast, only merges back on the
6107 // original attributes, not the events
6108 if ( dest
.mergeAttributes
) {
6109 dest
.mergeAttributes( src
);
6112 nodeName
= dest
.nodeName
.toLowerCase();
6114 // IE6-8 fail to clone children inside object elements that use
6115 // the proprietary classid attribute value (rather than the type
6116 // attribute) to identify the type of content to display
6117 if ( nodeName
=== "object" ) {
6118 dest
.outerHTML
= src
.outerHTML
;
6120 } else if ( nodeName
=== "input" && (src
.type
=== "checkbox" || src
.type
=== "radio") ) {
6121 // IE6-8 fails to persist the checked state of a cloned checkbox
6122 // or radio button. Worse, IE6-7 fail to give the cloned element
6123 // a checked appearance if the defaultChecked value isn't also set
6124 if ( src
.checked
) {
6125 dest
.defaultChecked
= dest
.checked
= src
.checked
;
6128 // IE6-7 get confused and end up setting the value of a cloned
6129 // checkbox/radio button to an empty string instead of "on"
6130 if ( dest
.value
!== src
.value
) {
6131 dest
.value
= src
.value
;
6134 // IE6-8 fails to return the selected option to the default selected
6135 // state when cloning options
6136 } else if ( nodeName
=== "option" ) {
6137 dest
.selected
= src
.defaultSelected
;
6139 // IE6-8 fails to set the defaultValue to the correct value when
6140 // cloning other types of input fields
6141 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
6142 dest
.defaultValue
= src
.defaultValue
;
6145 // Event data gets referenced instead of copied if the expando
6147 dest
.removeAttribute( jQuery
.expando
);
6150 jQuery
.buildFragment = function( args
, nodes
, scripts
) {
6151 var fragment
, cacheable
, cacheresults
, doc
,
6154 // nodes may contain either an explicit document object,
6155 // a jQuery collection or context object.
6156 // If nodes[0] contains a valid object to assign to doc
6157 if ( nodes
&& nodes
[0] ) {
6158 doc
= nodes
[0].ownerDocument
|| nodes
[0];
6161 // Ensure that an attr object doesn't incorrectly stand in as a document object
6162 // Chrome and Firefox seem to allow this to occur and will throw exception
6164 if ( !doc
.createDocumentFragment
) {
6168 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6169 // Cloning options loses the selected state, so don't cache them
6170 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6171 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6172 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6173 if ( args
.length
=== 1 && typeof first
=== "string" && first
.length
< 512 && doc
=== document
&&
6174 first
.charAt(0) === "<" && !rnocache
.test( first
) &&
6175 (jQuery
.support
.checkClone
|| !rchecked
.test( first
)) &&
6176 (!jQuery
.support
.unknownElems
&& rnoshimcache
.test( first
)) ) {
6180 cacheresults
= jQuery
.fragments
[ first
];
6181 if ( cacheresults
&& cacheresults
!== 1 ) {
6182 fragment
= cacheresults
;
6187 fragment
= doc
.createDocumentFragment();
6188 jQuery
.clean( args
, doc
, fragment
, scripts
);
6192 jQuery
.fragments
[ first
] = cacheresults
? fragment
: 1;
6195 return { fragment
: fragment
, cacheable
: cacheable
};
6198 jQuery
.fragments
= {};
6202 prependTo
: "prepend",
6203 insertBefore
: "before",
6204 insertAfter
: "after",
6205 replaceAll
: "replaceWith"
6206 }, function( name
, original
) {
6207 jQuery
.fn
[ name
] = function( selector
) {
6209 insert
= jQuery( selector
),
6210 parent
= this.length
=== 1 && this[0].parentNode
;
6212 if ( parent
&& parent
.nodeType
=== 11 && parent
.childNodes
.length
=== 1 && insert
.length
=== 1 ) {
6213 insert
[ original
]( this[0] );
6217 for ( var i
= 0, l
= insert
.length
; i
< l
; i
++ ) {
6218 var elems
= ( i
> 0 ? this.clone(true) : this ).get();
6219 jQuery( insert
[i
] )[ original
]( elems
);
6220 ret
= ret
.concat( elems
);
6223 return this.pushStack( ret
, name
, insert
.selector
);
6228 function getAll( elem
) {
6229 if ( typeof elem
.getElementsByTagName
!== "undefined" ) {
6230 return elem
.getElementsByTagName( "*" );
6232 } else if ( typeof elem
.querySelectorAll
!== "undefined" ) {
6233 return elem
.querySelectorAll( "*" );
6240 // Used in clean, fixes the defaultChecked property
6241 function fixDefaultChecked( elem
) {
6242 if ( elem
.type
=== "checkbox" || elem
.type
=== "radio" ) {
6243 elem
.defaultChecked
= elem
.checked
;
6246 // Finds all inputs and passes them to fixDefaultChecked
6247 function findInputs( elem
) {
6248 var nodeName
= ( elem
.nodeName
|| "" ).toLowerCase();
6249 if ( nodeName
=== "input" ) {
6250 fixDefaultChecked( elem
);
6251 // Skip scripts, get other children
6252 } else if ( nodeName
!== "script" && typeof elem
.getElementsByTagName
!== "undefined" ) {
6253 jQuery
.grep( elem
.getElementsByTagName("input"), fixDefaultChecked
);
6258 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
6259 var clone
= elem
.cloneNode(true),
6264 if ( (!jQuery
.support
.noCloneEvent
|| !jQuery
.support
.noCloneChecked
) &&
6265 (elem
.nodeType
=== 1 || elem
.nodeType
=== 11) && !jQuery
.isXMLDoc(elem
) ) {
6266 // IE copies events bound via attachEvent when using cloneNode.
6267 // Calling detachEvent on the clone will also remove the events
6268 // from the original. In order to get around this, we use some
6269 // proprietary methods to clear the events. Thanks to MooTools
6270 // guys for this hotness.
6272 cloneFixAttributes( elem
, clone
);
6274 // Using Sizzle here is crazy slow, so we use getElementsByTagName
6276 srcElements
= getAll( elem
);
6277 destElements
= getAll( clone
);
6279 // Weird iteration because IE will replace the length property
6280 // with an element if you are cloning the body and one of the
6281 // elements on the page has a name or id of "length"
6282 for ( i
= 0; srcElements
[i
]; ++i
) {
6283 // Ensure that the destination node is not null; Fixes #9587
6284 if ( destElements
[i
] ) {
6285 cloneFixAttributes( srcElements
[i
], destElements
[i
] );
6290 // Copy the events from the original to the clone
6291 if ( dataAndEvents
) {
6292 cloneCopyEvent( elem
, clone
);
6294 if ( deepDataAndEvents
) {
6295 srcElements
= getAll( elem
);
6296 destElements
= getAll( clone
);
6298 for ( i
= 0; srcElements
[i
]; ++i
) {
6299 cloneCopyEvent( srcElements
[i
], destElements
[i
] );
6304 srcElements
= destElements
= null;
6306 // Return the cloned set
6310 clean: function( elems
, context
, fragment
, scripts
) {
6311 var checkScriptType
;
6313 context
= context
|| document
;
6315 // !context.createElement fails in IE with an error but returns typeof 'object'
6316 if ( typeof context
.createElement
=== "undefined" ) {
6317 context
= context
.ownerDocument
|| context
[0] && context
[0].ownerDocument
|| document
;
6322 for ( var i
= 0, elem
; (elem
= elems
[i
]) != null; i
++ ) {
6323 if ( typeof elem
=== "number" ) {
6331 // Convert html string into DOM nodes
6332 if ( typeof elem
=== "string" ) {
6333 if ( !rhtml
.test( elem
) ) {
6334 elem
= context
.createTextNode( elem
);
6336 // Fix "XHTML"-style tags in all browsers
6337 elem
= elem
.replace(rxhtmlTag
, "<$1></$2>");
6339 // Trim whitespace, otherwise indexOf won't work as expected
6340 var tag
= ( rtagName
.exec( elem
) || ["", ""] )[1].toLowerCase(),
6341 wrap
= wrapMap
[ tag
] || wrapMap
._default
,
6343 div
= context
.createElement("div");
6345 // Append wrapper element to unknown element safe doc fragment
6346 if ( context
=== document
) {
6347 // Use the fragment we've already created for this document
6348 safeFragment
.appendChild( div
);
6350 // Use a fragment created with the owner document
6351 createSafeFragment( context
).appendChild( div
);
6354 // Go to html and back, then peel off extra wrappers
6355 div
.innerHTML
= wrap
[1] + elem
+ wrap
[2];
6357 // Move to the right depth
6359 div
= div
.lastChild
;
6362 // Remove IE's autoinserted <tbody> from table fragments
6363 if ( !jQuery
.support
.tbody
) {
6365 // String was a <table>, *may* have spurious <tbody>
6366 var hasBody
= rtbody
.test(elem
),
6367 tbody
= tag
=== "table" && !hasBody
?
6368 div
.firstChild
&& div
.firstChild
.childNodes
:
6370 // String was a bare <thead> or <tfoot>
6371 wrap
[1] === "<table>" && !hasBody
?
6375 for ( j
= tbody
.length
- 1; j
>= 0 ; --j
) {
6376 if ( jQuery
.nodeName( tbody
[ j
], "tbody" ) && !tbody
[ j
].childNodes
.length
) {
6377 tbody
[ j
].parentNode
.removeChild( tbody
[ j
] );
6382 // IE completely kills leading whitespace when innerHTML is used
6383 if ( !jQuery
.support
.leadingWhitespace
&& rleadingWhitespace
.test( elem
) ) {
6384 div
.insertBefore( context
.createTextNode( rleadingWhitespace
.exec(elem
)[0] ), div
.firstChild
);
6387 elem
= div
.childNodes
;
6391 // Resets defaultChecked for any radios and checkboxes
6392 // about to be appended to the DOM in IE 6/7 (#8060)
6394 if ( !jQuery
.support
.appendChecked
) {
6395 if ( elem
[0] && typeof (len
= elem
.length
) === "number" ) {
6396 for ( j
= 0; j
< len
; j
++ ) {
6397 findInputs( elem
[j
] );
6404 if ( elem
.nodeType
) {
6407 ret
= jQuery
.merge( ret
, elem
);
6412 checkScriptType = function( elem
) {
6413 return !elem
.type
|| rscriptType
.test( elem
.type
);
6415 for ( i
= 0; ret
[i
]; i
++ ) {
6416 if ( scripts
&& jQuery
.nodeName( ret
[i
], "script" ) && (!ret
[i
].type
|| ret
[i
].type
.toLowerCase() === "text/javascript") ) {
6417 scripts
.push( ret
[i
].parentNode
? ret
[i
].parentNode
.removeChild( ret
[i
] ) : ret
[i
] );
6420 if ( ret
[i
].nodeType
=== 1 ) {
6421 var jsTags
= jQuery
.grep( ret
[i
].getElementsByTagName( "script" ), checkScriptType
);
6423 ret
.splice
.apply( ret
, [i
+ 1, 0].concat( jsTags
) );
6425 fragment
.appendChild( ret
[i
] );
6433 cleanData: function( elems
) {
6435 cache
= jQuery
.cache
,
6436 special
= jQuery
.event
.special
,
6437 deleteExpando
= jQuery
.support
.deleteExpando
;
6439 for ( var i
= 0, elem
; (elem
= elems
[i
]) != null; i
++ ) {
6440 if ( elem
.nodeName
&& jQuery
.noData
[elem
.nodeName
.toLowerCase()] ) {
6444 id
= elem
[ jQuery
.expando
];
6449 if ( data
&& data
.events
) {
6450 for ( var type
in data
.events
) {
6451 if ( special
[ type
] ) {
6452 jQuery
.event
.remove( elem
, type
);
6454 // This is a shortcut to avoid jQuery.event.remove's overhead
6456 jQuery
.removeEvent( elem
, type
, data
.handle
);
6460 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6461 if ( data
.handle
) {
6462 data
.handle
.elem
= null;
6466 if ( deleteExpando
) {
6467 delete elem
[ jQuery
.expando
];
6469 } else if ( elem
.removeAttribute
) {
6470 elem
.removeAttribute( jQuery
.expando
);
6479 function evalScript( i
, elem
) {
6487 jQuery
.globalEval( ( elem
.text
|| elem
.textContent
|| elem
.innerHTML
|| "" ).replace( rcleanScript
, "/*$0*/" ) );
6490 if ( elem
.parentNode
) {
6491 elem
.parentNode
.removeChild( elem
);
6498 var ralpha
= /alpha\([^)]*\)/i,
6499 ropacity
= /opacity=([^)]*)/,
6500 // fixed for IE9, see #8346
6501 rupper
= /([A-Z]|^ms)/g,
6502 rnumpx
= /^-?\d+(?:px)?$/i,
6504 rrelNum
= /^([\-+])=([\-+.\de]+)/,
6506 cssShow
= { position
: "absolute", visibility
: "hidden", display
: "block" },
6507 cssWidth
= [ "Left", "Right" ],
6508 cssHeight
= [ "Top", "Bottom" ],
6514 jQuery
.fn
.css = function( name
, value
) {
6515 // Setting 'undefined' is a no-op
6516 if ( arguments
.length
=== 2 && value
=== undefined ) {
6520 return jQuery
.access( this, name
, value
, true, function( elem
, name
, value
) {
6521 return value
!== undefined ?
6522 jQuery
.style( elem
, name
, value
) :
6523 jQuery
.css( elem
, name
);
6528 // Add in style property hooks for overriding the default
6529 // behavior of getting and setting a style property
6532 get: function( elem
, computed
) {
6534 // We should always get a number back from opacity
6535 var ret
= curCSS( elem
, "opacity", "opacity" );
6536 return ret
=== "" ? "1" : ret
;
6539 return elem
.style
.opacity
;
6545 // Exclude the following css properties to add px
6547 "fillOpacity": true,
6557 // Add in properties whose names you wish to fix before
6558 // setting or getting the value
6560 // normalize float css property
6561 "float": jQuery
.support
.cssFloat
? "cssFloat" : "styleFloat"
6564 // Get and set the style property on a DOM Node
6565 style: function( elem
, name
, value
, extra
) {
6566 // Don't set styles on text and comment nodes
6567 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6571 // Make sure that we're working with the right name
6572 var ret
, type
, origName
= jQuery
.camelCase( name
),
6573 style
= elem
.style
, hooks
= jQuery
.cssHooks
[ origName
];
6575 name
= jQuery
.cssProps
[ origName
] || origName
;
6577 // Check if we're setting a value
6578 if ( value
!== undefined ) {
6579 type
= typeof value
;
6581 // convert relative number strings (+= or -=) to relative numbers. #7345
6582 if ( type
=== "string" && (ret
= rrelNum
.exec( value
)) ) {
6583 value
= ( +( ret
[1] + 1) * +ret
[2] ) + parseFloat( jQuery
.css( elem
, name
) );
6588 // Make sure that NaN and null values aren't set. See: #7116
6589 if ( value
== null || type
=== "number" && isNaN( value
) ) {
6593 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6594 if ( type
=== "number" && !jQuery
.cssNumber
[ origName
] ) {
6598 // If a hook was provided, use that value, otherwise just set the specified value
6599 if ( !hooks
|| !("set" in hooks
) || (value
= hooks
.set( elem
, value
)) !== undefined ) {
6600 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6603 style
[ name
] = value
;
6608 // If a hook was provided get the non-computed value from there
6609 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, false, extra
)) !== undefined ) {
6613 // Otherwise just get the value from the style object
6614 return style
[ name
];
6618 css: function( elem
, name
, extra
) {
6621 // Make sure that we're working with the right name
6622 name
= jQuery
.camelCase( name
);
6623 hooks
= jQuery
.cssHooks
[ name
];
6624 name
= jQuery
.cssProps
[ name
] || name
;
6626 // cssFloat needs a special treatment
6627 if ( name
=== "cssFloat" ) {
6631 // If a hook was provided get the computed value from there
6632 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, true, extra
)) !== undefined ) {
6635 // Otherwise, if a way to get the computed value exists, use that
6636 } else if ( curCSS
) {
6637 return curCSS( elem
, name
);
6641 // A method for quickly swapping in/out CSS properties to get correct calculations
6642 swap: function( elem
, options
, callback
) {
6645 // Remember the old values, and insert the new ones
6646 for ( var name
in options
) {
6647 old
[ name
] = elem
.style
[ name
];
6648 elem
.style
[ name
] = options
[ name
];
6651 callback
.call( elem
);
6653 // Revert the old values
6654 for ( name
in options
) {
6655 elem
.style
[ name
] = old
[ name
];
6660 // DEPRECATED, Use jQuery.css() instead
6661 jQuery
.curCSS
= jQuery
.css
;
6663 jQuery
.each(["height", "width"], function( i
, name
) {
6664 jQuery
.cssHooks
[ name
] = {
6665 get: function( elem
, computed
, extra
) {
6669 if ( elem
.offsetWidth
!== 0 ) {
6670 return getWH( elem
, name
, extra
);
6672 jQuery
.swap( elem
, cssShow
, function() {
6673 val
= getWH( elem
, name
, extra
);
6681 set: function( elem
, value
) {
6682 if ( rnumpx
.test( value
) ) {
6683 // ignore negative width and height values #1599
6684 value
= parseFloat( value
);
6687 return value
+ "px";
6697 if ( !jQuery
.support
.opacity
) {
6698 jQuery
.cssHooks
.opacity
= {
6699 get: function( elem
, computed
) {
6700 // IE uses filters for opacity
6701 return ropacity
.test( (computed
&& elem
.currentStyle
? elem
.currentStyle
.filter
: elem
.style
.filter
) || "" ) ?
6702 ( parseFloat( RegExp
.$1 ) / 100 ) + "" :
6703 computed
? "1" : "";
6706 set: function( elem
, value
) {
6707 var style
= elem
.style
,
6708 currentStyle
= elem
.currentStyle
,
6709 opacity
= jQuery
.isNumeric( value
) ? "alpha(opacity=" + value
* 100 + ")" : "",
6710 filter
= currentStyle
&& currentStyle
.filter
|| style
.filter
|| "";
6712 // IE has trouble with opacity if it does not have layout
6713 // Force it by setting the zoom level
6716 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6717 if ( value
>= 1 && jQuery
.trim( filter
.replace( ralpha
, "" ) ) === "" ) {
6719 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6720 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6721 // style.removeAttribute is IE Only, but so apparently is this code path...
6722 style
.removeAttribute( "filter" );
6724 // if there there is no filter style applied in a css rule, we are done
6725 if ( currentStyle
&& !currentStyle
.filter
) {
6730 // otherwise, set new filter values
6731 style
.filter
= ralpha
.test( filter
) ?
6732 filter
.replace( ralpha
, opacity
) :
6733 filter
+ " " + opacity
;
6739 // This hook cannot be added until DOM ready because the support test
6740 // for it is not run until after DOM ready
6741 if ( !jQuery
.support
.reliableMarginRight
) {
6742 jQuery
.cssHooks
.marginRight
= {
6743 get: function( elem
, computed
) {
6744 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6745 // Work around by temporarily setting element display to inline-block
6747 jQuery
.swap( elem
, { "display": "inline-block" }, function() {
6749 ret
= curCSS( elem
, "margin-right", "marginRight" );
6751 ret
= elem
.style
.marginRight
;
6760 if ( document
.defaultView
&& document
.defaultView
.getComputedStyle
) {
6761 getComputedStyle = function( elem
, name
) {
6762 var ret
, defaultView
, computedStyle
;
6764 name
= name
.replace( rupper
, "-$1" ).toLowerCase();
6766 if ( !(defaultView
= elem
.ownerDocument
.defaultView
) ) {
6770 if ( (computedStyle
= defaultView
.getComputedStyle( elem
, null )) ) {
6771 ret
= computedStyle
.getPropertyValue( name
);
6772 if ( ret
=== "" && !jQuery
.contains( elem
.ownerDocument
.documentElement
, elem
) ) {
6773 ret
= jQuery
.style( elem
, name
);
6781 if ( document
.documentElement
.currentStyle
) {
6782 currentStyle = function( elem
, name
) {
6783 var left
, rsLeft
, uncomputed
,
6784 ret
= elem
.currentStyle
&& elem
.currentStyle
[ name
],
6787 // Avoid setting ret to empty string here
6788 // so we don't default to auto
6789 if ( ret
=== null && style
&& (uncomputed
= style
[ name
]) ) {
6793 // From the awesome hack by Dean Edwards
6794 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6796 // If we're not dealing with a regular pixel number
6797 // but a number that has a weird ending, we need to convert it to pixels
6798 if ( !rnumpx
.test( ret
) && rnum
.test( ret
) ) {
6800 // Remember the original values
6802 rsLeft
= elem
.runtimeStyle
&& elem
.runtimeStyle
.left
;
6804 // Put in the new values to get a computed value out
6806 elem
.runtimeStyle
.left
= elem
.currentStyle
.left
;
6808 style
.left
= name
=== "fontSize" ? "1em" : ( ret
|| 0 );
6809 ret
= style
.pixelLeft
+ "px";
6811 // Revert the changed values
6814 elem
.runtimeStyle
.left
= rsLeft
;
6818 return ret
=== "" ? "auto" : ret
;
6822 curCSS
= getComputedStyle
|| currentStyle
;
6824 function getWH( elem
, name
, extra
) {
6826 // Start with offset property
6827 var val
= name
=== "width" ? elem
.offsetWidth
: elem
.offsetHeight
,
6828 which
= name
=== "width" ? cssWidth
: cssHeight
;
6831 if ( extra
!== "border" ) {
6832 jQuery
.each( which
, function() {
6834 val
-= parseFloat( jQuery
.css( elem
, "padding" + this ) ) || 0;
6836 if ( extra
=== "margin" ) {
6837 val
+= parseFloat( jQuery
.css( elem
, extra
+ this ) ) || 0;
6839 val
-= parseFloat( jQuery
.css( elem
, "border" + this + "Width" ) ) || 0;
6847 // Fall back to computed then uncomputed css if necessary
6848 val
= curCSS( elem
, name
, name
);
6849 if ( val
< 0 || val
== null ) {
6850 val
= elem
.style
[ name
] || 0;
6852 // Normalize "", auto, and prepare for extra
6853 val
= parseFloat( val
) || 0;
6855 // Add padding, border, margin
6857 jQuery
.each( which
, function() {
6858 val
+= parseFloat( jQuery
.css( elem
, "padding" + this ) ) || 0;
6859 if ( extra
!== "padding" ) {
6860 val
+= parseFloat( jQuery
.css( elem
, "border" + this + "Width" ) ) || 0;
6862 if ( extra
=== "margin" ) {
6863 val
+= parseFloat( jQuery
.css( elem
, extra
+ this ) ) || 0;
6871 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
6872 jQuery
.expr
.filters
.hidden = function( elem
) {
6873 var width
= elem
.offsetWidth
,
6874 height
= elem
.offsetHeight
;
6876 return ( width
=== 0 && height
=== 0 ) || (!jQuery
.support
.reliableHiddenOffsets
&& ((elem
.style
&& elem
.style
.display
) || jQuery
.css( elem
, "display" )) === "none");
6879 jQuery
.expr
.filters
.visible = function( elem
) {
6880 return !jQuery
.expr
.filters
.hidden( elem
);
6891 rheaders
= /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
6892 rinput
= /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6893 // #7653, #8125, #8152: local protocol detection
6894 rlocalProtocol
= /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6895 rnoContent
= /^(?:GET|HEAD)$/,
6896 rprotocol
= /^\/\//,
6898 rscript
= /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6899 rselectTextarea
= /^(?:select|textarea)/i,
6900 rspacesAjax
= /\s+/,
6901 rts
= /([?&])_=[^&]*/,
6902 rurl
= /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6904 // Keep a copy of the old load method
6905 _load
= jQuery
.fn
.load
,
6908 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6909 * 2) These are called:
6910 * - BEFORE asking for a transport
6911 * - AFTER param serialization (s.data is a string if s.processData is true)
6912 * 3) key is the dataType
6913 * 4) the catchall symbol "*" can be used
6914 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6918 /* Transports bindings
6919 * 1) key is the dataType
6920 * 2) the catchall symbol "*" can be used
6921 * 3) selection will start with transport dataType and THEN go to "*" if needed
6925 // Document location
6928 // Document location segments
6931 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6932 allTypes
= ["*/"] + ["*"];
6934 // #8138, IE may throw an exception when accessing
6935 // a field from window.location if document.domain has been set
6937 ajaxLocation
= location
.href
;
6939 // Use the href attribute of an A element
6940 // since IE will modify it given document.location
6941 ajaxLocation
= document
.createElement( "a" );
6942 ajaxLocation
.href
= "";
6943 ajaxLocation
= ajaxLocation
.href
;
6946 // Segment location into parts
6947 ajaxLocParts
= rurl
.exec( ajaxLocation
.toLowerCase() ) || [];
6949 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6950 function addToPrefiltersOrTransports( structure
) {
6952 // dataTypeExpression is optional and defaults to "*"
6953 return function( dataTypeExpression
, func
) {
6955 if ( typeof dataTypeExpression
!== "string" ) {
6956 func
= dataTypeExpression
;
6957 dataTypeExpression
= "*";
6960 if ( jQuery
.isFunction( func
) ) {
6961 var dataTypes
= dataTypeExpression
.toLowerCase().split( rspacesAjax
),
6963 length
= dataTypes
.length
,
6968 // For each dataType in the dataTypeExpression
6969 for ( ; i
< length
; i
++ ) {
6970 dataType
= dataTypes
[ i
];
6971 // We control if we're asked to add before
6972 // any existing element
6973 placeBefore
= /^\+/.test( dataType
);
6974 if ( placeBefore
) {
6975 dataType
= dataType
.substr( 1 ) || "*";
6977 list
= structure
[ dataType
] = structure
[ dataType
] || [];
6978 // then we add to the structure accordingly
6979 list
[ placeBefore
? "unshift" : "push" ]( func
);
6985 // Base inspection function for prefilters and transports
6986 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
,
6987 dataType
/* internal */, inspected
/* internal */ ) {
6989 dataType
= dataType
|| options
.dataTypes
[ 0 ];
6990 inspected
= inspected
|| {};
6992 inspected
[ dataType
] = true;
6994 var list
= structure
[ dataType
],
6996 length
= list
? list
.length
: 0,
6997 executeOnly
= ( structure
=== prefilters
),
7000 for ( ; i
< length
&& ( executeOnly
|| !selection
); i
++ ) {
7001 selection
= list
[ i
]( options
, originalOptions
, jqXHR
);
7002 // If we got redirected to another dataType
7003 // we try there if executing only and not done already
7004 if ( typeof selection
=== "string" ) {
7005 if ( !executeOnly
|| inspected
[ selection
] ) {
7006 selection
= undefined;
7008 options
.dataTypes
.unshift( selection
);
7009 selection
= inspectPrefiltersOrTransports(
7010 structure
, options
, originalOptions
, jqXHR
, selection
, inspected
);
7014 // If we're only executing or nothing was selected
7015 // we try the catchall dataType if not done already
7016 if ( ( executeOnly
|| !selection
) && !inspected
[ "*" ] ) {
7017 selection
= inspectPrefiltersOrTransports(
7018 structure
, options
, originalOptions
, jqXHR
, "*", inspected
);
7020 // unnecessary when only executing (prefilters)
7021 // but it'll be ignored by the caller in that case
7025 // A special extend for ajax options
7026 // that takes "flat" options (not to be deep extended)
7028 function ajaxExtend( target
, src
) {
7030 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
7031 for ( key
in src
) {
7032 if ( src
[ key
] !== undefined ) {
7033 ( flatOptions
[ key
] ? target
: ( deep
|| ( deep
= {} ) ) )[ key
] = src
[ key
];
7037 jQuery
.extend( true, target
, deep
);
7042 load: function( url
, params
, callback
) {
7043 if ( typeof url
!== "string" && _load
) {
7044 return _load
.apply( this, arguments
);
7046 // Don't do a request if no elements are being requested
7047 } else if ( !this.length
) {
7051 var off
= url
.indexOf( " " );
7053 var selector
= url
.slice( off
, url
.length
);
7054 url
= url
.slice( 0, off
);
7057 // Default to a GET request
7060 // If the second parameter was provided
7062 // If it's a function
7063 if ( jQuery
.isFunction( params
) ) {
7064 // We assume that it's the callback
7068 // Otherwise, build a param string
7069 } else if ( typeof params
=== "object" ) {
7070 params
= jQuery
.param( params
, jQuery
.ajaxSettings
.traditional
);
7077 // Request the remote document
7083 // Complete callback (responseText is used internally)
7084 complete: function( jqXHR
, status
, responseText
) {
7085 // Store the response as specified by the jqXHR object
7086 responseText
= jqXHR
.responseText
;
7087 // If successful, inject the HTML into all the matched elements
7088 if ( jqXHR
.isResolved() ) {
7089 // #4825: Get the actual response in case
7090 // a dataFilter is present in ajaxSettings
7091 jqXHR
.done(function( r
) {
7094 // See if a selector was specified
7095 self
.html( selector
?
7096 // Create a dummy div to hold the results
7098 // inject the contents of the document in, removing the scripts
7099 // to avoid any 'Permission Denied' errors in IE
7100 .append(responseText
.replace(rscript
, ""))
7102 // Locate the specified elements
7105 // If not, just inject the full result
7110 self
.each( callback
, [ responseText
, status
, jqXHR
] );
7118 serialize: function() {
7119 return jQuery
.param( this.serializeArray() );
7122 serializeArray: function() {
7123 return this.map(function(){
7124 return this.elements
? jQuery
.makeArray( this.elements
) : this;
7127 return this.name
&& !this.disabled
&&
7128 ( this.checked
|| rselectTextarea
.test( this.nodeName
) ||
7129 rinput
.test( this.type
) );
7131 .map(function( i
, elem
){
7132 var val
= jQuery( this ).val();
7134 return val
== null ?
7136 jQuery
.isArray( val
) ?
7137 jQuery
.map( val
, function( val
, i
){
7138 return { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
7140 { name
: elem
.name
, value
: val
.replace( rCRLF
, "\r\n" ) };
7145 // Attach a bunch of functions for handling common AJAX events
7146 jQuery
.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i
, o
){
7147 jQuery
.fn
[ o
] = function( f
){
7148 return this.bind( o
, f
);
7152 jQuery
.each( [ "get", "post" ], function( i
, method
) {
7153 jQuery
[ method
] = function( url
, data
, callback
, type
) {
7154 // shift arguments if data argument was omitted
7155 if ( jQuery
.isFunction( data
) ) {
7156 type
= type
|| callback
;
7161 return jQuery
.ajax({
7173 getScript: function( url
, callback
) {
7174 return jQuery
.get( url
, undefined, callback
, "script" );
7177 getJSON: function( url
, data
, callback
) {
7178 return jQuery
.get( url
, data
, callback
, "json" );
7181 // Creates a full fledged settings object into target
7182 // with both ajaxSettings and settings fields.
7183 // If target is omitted, writes into ajaxSettings.
7184 ajaxSetup: function( target
, settings
) {
7186 // Building a settings object
7187 ajaxExtend( target
, jQuery
.ajaxSettings
);
7189 // Extending ajaxSettings
7191 target
= jQuery
.ajaxSettings
;
7193 ajaxExtend( target
, settings
);
7199 isLocal
: rlocalProtocol
.test( ajaxLocParts
[ 1 ] ),
7202 contentType
: "application/x-www-form-urlencoded",
7217 xml
: "application/xml, text/xml",
7220 json
: "application/json, text/javascript",
7232 text
: "responseText"
7235 // List of data converters
7236 // 1) key format is "source_type destination_type" (a single space in-between)
7237 // 2) the catchall symbol "*" can be used for source_type
7240 // Convert anything to text
7241 "* text": window
.String
,
7243 // Text to html (true = no transformation)
7246 // Evaluate text as a json expression
7247 "text json": jQuery
.parseJSON
,
7249 // Parse text as xml
7250 "text xml": jQuery
.parseXML
7253 // For options that shouldn't be deep extended:
7254 // you can add your own custom options here if
7255 // and when you create one that shouldn't be
7256 // deep extended (see ajaxExtend)
7263 ajaxPrefilter
: addToPrefiltersOrTransports( prefilters
),
7264 ajaxTransport
: addToPrefiltersOrTransports( transports
),
7267 ajax: function( url
, options
) {
7269 // If url is an object, simulate pre-1.5 signature
7270 if ( typeof url
=== "object" ) {
7275 // Force options to be an object
7276 options
= options
|| {};
7278 var // Create the final options object
7279 s
= jQuery
.ajaxSetup( {}, options
),
7280 // Callbacks context
7281 callbackContext
= s
.context
|| s
,
7282 // Context for global events
7283 // It's the callbackContext if one was provided in the options
7284 // and if it's a DOM node or a jQuery collection
7285 globalEventContext
= callbackContext
!== s
&&
7286 ( callbackContext
.nodeType
|| callbackContext
instanceof jQuery
) ?
7287 jQuery( callbackContext
) : jQuery
.event
,
7289 deferred
= jQuery
.Deferred(),
7290 completeDeferred
= jQuery
.Callbacks( "once memory" ),
7291 // Status-dependent callbacks
7292 statusCode
= s
.statusCode
|| {},
7295 // Headers (they are sent all at once)
7296 requestHeaders
= {},
7297 requestHeadersNames
= {},
7299 responseHeadersString
,
7305 // Cross-domain detection vars
7309 // To know if global events are to be dispatched
7318 // Caches the header
7319 setRequestHeader: function( name
, value
) {
7321 var lname
= name
.toLowerCase();
7322 name
= requestHeadersNames
[ lname
] = requestHeadersNames
[ lname
] || name
;
7323 requestHeaders
[ name
] = value
;
7329 getAllResponseHeaders: function() {
7330 return state
=== 2 ? responseHeadersString
: null;
7333 // Builds headers hashtable if needed
7334 getResponseHeader: function( key
) {
7336 if ( state
=== 2 ) {
7337 if ( !responseHeaders
) {
7338 responseHeaders
= {};
7339 while( ( match
= rheaders
.exec( responseHeadersString
) ) ) {
7340 responseHeaders
[ match
[1].toLowerCase() ] = match
[ 2 ];
7343 match
= responseHeaders
[ key
.toLowerCase() ];
7345 return match
=== undefined ? null : match
;
7348 // Overrides response content-type header
7349 overrideMimeType: function( type
) {
7356 // Cancel the request
7357 abort: function( statusText
) {
7358 statusText
= statusText
|| "abort";
7360 transport
.abort( statusText
);
7362 done( 0, statusText
);
7367 // Callback for when everything is done
7368 // It is defined here because jslint complains if it is declared
7369 // at the end of the function (which would be more logical and readable)
7370 function done( status
, nativeStatusText
, responses
, headers
) {
7373 if ( state
=== 2 ) {
7377 // State is "done" now
7380 // Clear timeout if it exists
7381 if ( timeoutTimer
) {
7382 clearTimeout( timeoutTimer
);
7385 // Dereference transport for early garbage collection
7386 // (no matter how long the jqXHR object will be used)
7387 transport
= undefined;
7389 // Cache response headers
7390 responseHeadersString
= headers
|| "";
7393 jqXHR
.readyState
= status
> 0 ? 4 : 0;
7398 statusText
= nativeStatusText
,
7399 response
= responses
? ajaxHandleResponses( s
, jqXHR
, responses
) : undefined,
7403 // If successful, handle type chaining
7404 if ( status
>= 200 && status
< 300 || status
=== 304 ) {
7406 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7407 if ( s
.ifModified
) {
7409 if ( ( lastModified
= jqXHR
.getResponseHeader( "Last-Modified" ) ) ) {
7410 jQuery
.lastModified
[ ifModifiedKey
] = lastModified
;
7412 if ( ( etag
= jqXHR
.getResponseHeader( "Etag" ) ) ) {
7413 jQuery
.etag
[ ifModifiedKey
] = etag
;
7418 if ( status
=== 304 ) {
7420 statusText
= "notmodified";
7427 success
= ajaxConvert( s
, response
);
7428 statusText
= "success";
7431 // We have a parsererror
7432 statusText
= "parsererror";
7437 // We extract error from statusText
7438 // then normalize statusText and status for non-aborts
7440 if ( !statusText
|| status
) {
7441 statusText
= "error";
7448 // Set data for the fake xhr object
7449 jqXHR
.status
= status
;
7450 jqXHR
.statusText
= "" + ( nativeStatusText
|| statusText
);
7454 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
7456 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
7459 // Status-dependent callbacks
7460 jqXHR
.statusCode( statusCode
);
7461 statusCode
= undefined;
7463 if ( fireGlobals
) {
7464 globalEventContext
.trigger( "ajax" + ( isSuccess
? "Success" : "Error" ),
7465 [ jqXHR
, s
, isSuccess
? success
: error
] );
7469 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
7471 if ( fireGlobals
) {
7472 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
7473 // Handle the global AJAX counter
7474 if ( !( --jQuery
.active
) ) {
7475 jQuery
.event
.trigger( "ajaxStop" );
7481 deferred
.promise( jqXHR
);
7482 jqXHR
.success
= jqXHR
.done
;
7483 jqXHR
.error
= jqXHR
.fail
;
7484 jqXHR
.complete
= completeDeferred
.add
;
7486 // Status-dependent callbacks
7487 jqXHR
.statusCode = function( map
) {
7491 for ( tmp
in map
) {
7492 statusCode
[ tmp
] = [ statusCode
[tmp
], map
[tmp
] ];
7495 tmp
= map
[ jqXHR
.status
];
7496 jqXHR
.then( tmp
, tmp
);
7502 // Remove hash character (#7531: and string promotion)
7503 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7504 // We also use the url parameter if available
7505 s
.url
= ( ( url
|| s
.url
) + "" ).replace( rhash
, "" ).replace( rprotocol
, ajaxLocParts
[ 1 ] + "//" );
7507 // Extract dataTypes list
7508 s
.dataTypes
= jQuery
.trim( s
.dataType
|| "*" ).toLowerCase().split( rspacesAjax
);
7510 // Determine if a cross-domain request is in order
7511 if ( s
.crossDomain
== null ) {
7512 parts
= rurl
.exec( s
.url
.toLowerCase() );
7513 s
.crossDomain
= !!( parts
&&
7514 ( parts
[ 1 ] != ajaxLocParts
[ 1 ] || parts
[ 2 ] != ajaxLocParts
[ 2 ] ||
7515 ( parts
[ 3 ] || ( parts
[ 1 ] === "http:" ? 80 : 443 ) ) !=
7516 ( ajaxLocParts
[ 3 ] || ( ajaxLocParts
[ 1 ] === "http:" ? 80 : 443 ) ) )
7520 // Convert data if not already a string
7521 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
7522 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
7526 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
7528 // If request was aborted inside a prefiler, stop there
7529 if ( state
=== 2 ) {
7533 // We can fire global events as of now if asked to
7534 fireGlobals
= s
.global
;
7536 // Uppercase the type
7537 s
.type
= s
.type
.toUpperCase();
7539 // Determine if request has content
7540 s
.hasContent
= !rnoContent
.test( s
.type
);
7542 // Watch for a new set of requests
7543 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
7544 jQuery
.event
.trigger( "ajaxStart" );
7547 // More options handling for requests with no content
7548 if ( !s
.hasContent
) {
7550 // If data is available, append data to url
7552 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.data
;
7553 // #9682: remove data so that it's not used in an eventual retry
7557 // Get ifModifiedKey before adding the anti-cache parameter
7558 ifModifiedKey
= s
.url
;
7560 // Add anti-cache in url if needed
7561 if ( s
.cache
=== false ) {
7563 var ts
= jQuery
.now(),
7564 // try replacing _= if it is there
7565 ret
= s
.url
.replace( rts
, "$1_=" + ts
);
7567 // if nothing was replaced, add timestamp to the end
7568 s
.url
= ret
+ ( ( ret
=== s
.url
) ? ( rquery
.test( s
.url
) ? "&" : "?" ) + "_=" + ts
: "" );
7572 // Set the correct header, if data is being sent
7573 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
7574 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
7577 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7578 if ( s
.ifModified
) {
7579 ifModifiedKey
= ifModifiedKey
|| s
.url
;
7580 if ( jQuery
.lastModified
[ ifModifiedKey
] ) {
7581 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ ifModifiedKey
] );
7583 if ( jQuery
.etag
[ ifModifiedKey
] ) {
7584 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ ifModifiedKey
] );
7588 // Set the Accepts header for the server, depending on the dataType
7589 jqXHR
.setRequestHeader(
7591 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[0] ] ?
7592 s
.accepts
[ s
.dataTypes
[0] ] + ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
7596 // Check for headers option
7597 for ( i
in s
.headers
) {
7598 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
7601 // Allow custom headers/mimetypes and early abort
7602 if ( s
.beforeSend
&& ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || state
=== 2 ) ) {
7603 // Abort if not done already
7609 // Install callbacks on deferreds
7610 for ( i
in { success
: 1, error
: 1, complete
: 1 } ) {
7611 jqXHR
[ i
]( s
[ i
] );
7615 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
7617 // If no transport, we auto-abort
7619 done( -1, "No Transport" );
7621 jqXHR
.readyState
= 1;
7622 // Send global event
7623 if ( fireGlobals
) {
7624 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
7627 if ( s
.async
&& s
.timeout
> 0 ) {
7628 timeoutTimer
= setTimeout( function(){
7629 jqXHR
.abort( "timeout" );
7635 transport
.send( requestHeaders
, done
);
7637 // Propagate exception as error if not done
7640 // Simply rethrow otherwise
7650 // Serialize an array of form elements or a set of
7651 // key/values into a query string
7652 param: function( a
, traditional
) {
7654 add = function( key
, value
) {
7655 // If value is a function, invoke it and return its value
7656 value
= jQuery
.isFunction( value
) ? value() : value
;
7657 s
[ s
.length
] = encodeURIComponent( key
) + "=" + encodeURIComponent( value
);
7660 // Set traditional to true for jQuery <= 1.3.2 behavior.
7661 if ( traditional
=== undefined ) {
7662 traditional
= jQuery
.ajaxSettings
.traditional
;
7665 // If an array was passed in, assume that it is an array of form elements.
7666 if ( jQuery
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
7667 // Serialize the form elements
7668 jQuery
.each( a
, function() {
7669 add( this.name
, this.value
);
7673 // If traditional, encode the "old" way (the way 1.3.2 or older
7674 // did it), otherwise encode params recursively.
7675 for ( var prefix
in a
) {
7676 buildParams( prefix
, a
[ prefix
], traditional
, add
);
7680 // Return the resulting serialization
7681 return s
.join( "&" ).replace( r20
, "+" );
7685 function buildParams( prefix
, obj
, traditional
, add
) {
7686 if ( jQuery
.isArray( obj
) ) {
7687 // Serialize array item.
7688 jQuery
.each( obj
, function( i
, v
) {
7689 if ( traditional
|| rbracket
.test( prefix
) ) {
7690 // Treat each array item as a scalar.
7694 // If array item is non-scalar (array or object), encode its
7695 // numeric index to resolve deserialization ambiguity issues.
7696 // Note that rack (as of 1.0.0) can't currently deserialize
7697 // nested arrays properly, and attempting to do so may cause
7698 // a server error. Possible fixes are to modify rack's
7699 // deserialization algorithm or to provide an option or flag
7700 // to force array serialization to be shallow.
7701 buildParams( prefix
+ "[" + ( typeof v
=== "object" || jQuery
.isArray(v
) ? i
: "" ) + "]", v
, traditional
, add
);
7705 } else if ( !traditional
&& obj
!= null && typeof obj
=== "object" ) {
7706 // Serialize object item.
7707 for ( var name
in obj
) {
7708 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
7712 // Serialize scalar item.
7717 // This is still on the jQuery object... for now
7718 // Want to move this to jQuery.ajax some day
7721 // Counter for holding the number of active queries
7724 // Last-Modified header cache for next request
7730 /* Handles responses to an ajax request:
7731 * - sets all responseXXX fields accordingly
7732 * - finds the right dataType (mediates between content-type and expected dataType)
7733 * - returns the corresponding response
7735 function ajaxHandleResponses( s
, jqXHR
, responses
) {
7737 var contents
= s
.contents
,
7738 dataTypes
= s
.dataTypes
,
7739 responseFields
= s
.responseFields
,
7745 // Fill responseXXX fields
7746 for ( type
in responseFields
) {
7747 if ( type
in responses
) {
7748 jqXHR
[ responseFields
[type
] ] = responses
[ type
];
7752 // Remove auto dataType and get content-type in the process
7753 while( dataTypes
[ 0 ] === "*" ) {
7755 if ( ct
=== undefined ) {
7756 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "content-type" );
7760 // Check if we're dealing with a known content-type
7762 for ( type
in contents
) {
7763 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
7764 dataTypes
.unshift( type
);
7770 // Check to see if we have a response for the expected dataType
7771 if ( dataTypes
[ 0 ] in responses
) {
7772 finalDataType
= dataTypes
[ 0 ];
7774 // Try convertible dataTypes
7775 for ( type
in responses
) {
7776 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[0] ] ) {
7777 finalDataType
= type
;
7780 if ( !firstDataType
) {
7781 firstDataType
= type
;
7784 // Or just use first one
7785 finalDataType
= finalDataType
|| firstDataType
;
7788 // If we found a dataType
7789 // We add the dataType to the list if needed
7790 // and return the corresponding response
7791 if ( finalDataType
) {
7792 if ( finalDataType
!== dataTypes
[ 0 ] ) {
7793 dataTypes
.unshift( finalDataType
);
7795 return responses
[ finalDataType
];
7799 // Chain conversions given the request and the original response
7800 function ajaxConvert( s
, response
) {
7802 // Apply the dataFilter if provided
7803 if ( s
.dataFilter
) {
7804 response
= s
.dataFilter( response
, s
.dataType
);
7807 var dataTypes
= s
.dataTypes
,
7811 length
= dataTypes
.length
,
7813 // Current and previous dataTypes
7814 current
= dataTypes
[ 0 ],
7816 // Conversion expression
7818 // Conversion function
7820 // Conversion functions (transitive conversion)
7824 // For each dataType in the chain
7825 for ( i
= 1; i
< length
; i
++ ) {
7827 // Create converters map
7828 // with lowercased keys
7830 for ( key
in s
.converters
) {
7831 if ( typeof key
=== "string" ) {
7832 converters
[ key
.toLowerCase() ] = s
.converters
[ key
];
7837 // Get the dataTypes
7839 current
= dataTypes
[ i
];
7841 // If current is auto dataType, update it to prev
7842 if ( current
=== "*" ) {
7844 // If no auto and dataTypes are actually different
7845 } else if ( prev
!== "*" && prev
!== current
) {
7847 // Get the converter
7848 conversion
= prev
+ " " + current
;
7849 conv
= converters
[ conversion
] || converters
[ "* " + current
];
7851 // If there is no direct converter, search transitively
7854 for ( conv1
in converters
) {
7855 tmp
= conv1
.split( " " );
7856 if ( tmp
[ 0 ] === prev
|| tmp
[ 0 ] === "*" ) {
7857 conv2
= converters
[ tmp
[1] + " " + current
];
7859 conv1
= converters
[ conv1
];
7860 if ( conv1
=== true ) {
7862 } else if ( conv2
=== true ) {
7870 // If we found no converter, dispatch an error
7871 if ( !( conv
|| conv2
) ) {
7872 jQuery
.error( "No conversion from " + conversion
.replace(" "," to ") );
7874 // If found converter is not an equivalence
7875 if ( conv
!== true ) {
7876 // Convert with 1 or 2 converters accordingly
7877 response
= conv
? conv( response
) : conv2( conv1(response
) );
7887 var jsc
= jQuery
.now(),
7888 jsre
= /(\=)\?(&|$)|\?\?/i;
7890 // Default jsonp settings
7893 jsonpCallback: function() {
7894 return jQuery
.expando
+ "_" + ( jsc
++ );
7898 // Detect, normalize options and install callbacks for jsonp requests
7899 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
7901 var inspectData
= s
.contentType
=== "application/x-www-form-urlencoded" &&
7902 ( typeof s
.data
=== "string" );
7904 if ( s
.dataTypes
[ 0 ] === "jsonp" ||
7905 s
.jsonp
!== false && ( jsre
.test( s
.url
) ||
7906 inspectData
&& jsre
.test( s
.data
) ) ) {
7908 var responseContainer
,
7909 jsonpCallback
= s
.jsonpCallback
=
7910 jQuery
.isFunction( s
.jsonpCallback
) ? s
.jsonpCallback() : s
.jsonpCallback
,
7911 previous
= window
[ jsonpCallback
],
7914 replace
= "$1" + jsonpCallback
+ "$2";
7916 if ( s
.jsonp
!== false ) {
7917 url
= url
.replace( jsre
, replace
);
7918 if ( s
.url
=== url
) {
7919 if ( inspectData
) {
7920 data
= data
.replace( jsre
, replace
);
7922 if ( s
.data
=== data
) {
7923 // Add callback manually
7924 url
+= (/\?/.test( url
) ? "&" : "?") + s
.jsonp
+ "=" + jsonpCallback
;
7933 window
[ jsonpCallback
] = function( response
) {
7934 responseContainer
= [ response
];
7937 // Clean-up function
7938 jqXHR
.always(function() {
7939 // Set callback back to previous value
7940 window
[ jsonpCallback
] = previous
;
7941 // Call if it was a function and we have a response
7942 if ( responseContainer
&& jQuery
.isFunction( previous
) ) {
7943 window
[ jsonpCallback
]( responseContainer
[ 0 ] );
7947 // Use data converter to retrieve json after script execution
7948 s
.converters
["script json"] = function() {
7949 if ( !responseContainer
) {
7950 jQuery
.error( jsonpCallback
+ " was not called" );
7952 return responseContainer
[ 0 ];
7955 // force json dataType
7956 s
.dataTypes
[ 0 ] = "json";
7958 // Delegate to script
7966 // Install script dataType
7969 script
: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7972 script
: /javascript|ecmascript/
7975 "text script": function( text
) {
7976 jQuery
.globalEval( text
);
7982 // Handle cache's special case and global
7983 jQuery
.ajaxPrefilter( "script", function( s
) {
7984 if ( s
.cache
=== undefined ) {
7987 if ( s
.crossDomain
) {
7993 // Bind script tag hack transport
7994 jQuery
.ajaxTransport( "script", function(s
) {
7996 // This transport only deals with cross domain requests
7997 if ( s
.crossDomain
) {
8000 head
= document
.head
|| document
.getElementsByTagName( "head" )[0] || document
.documentElement
;
8004 send: function( _
, callback
) {
8006 script
= document
.createElement( "script" );
8008 script
.async
= "async";
8010 if ( s
.scriptCharset
) {
8011 script
.charset
= s
.scriptCharset
;
8016 // Attach handlers for all browsers
8017 script
.onload
= script
.onreadystatechange = function( _
, isAbort
) {
8019 if ( isAbort
|| !script
.readyState
|| /loaded|complete/.test( script
.readyState
) ) {
8021 // Handle memory leak in IE
8022 script
.onload
= script
.onreadystatechange
= null;
8024 // Remove the script
8025 if ( head
&& script
.parentNode
) {
8026 head
.removeChild( script
);
8029 // Dereference the script
8032 // Callback if not abort
8034 callback( 200, "success" );
8038 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
8039 // This arises when a base node is used (#2709 and #4378).
8040 head
.insertBefore( script
, head
.firstChild
);
8045 script
.onload( 0, 1 );
8055 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8056 xhrOnUnloadAbort
= window
.ActiveXObject
? function() {
8057 // Abort all pending requests
8058 for ( var key
in xhrCallbacks
) {
8059 xhrCallbacks
[ key
]( 0, 1 );
8065 // Functions to create xhrs
8066 function createStandardXHR() {
8068 return new window
.XMLHttpRequest();
8072 function createActiveXHR() {
8074 return new window
.ActiveXObject( "Microsoft.XMLHTTP" );
8078 // Create the request object
8079 // (This is still attached to ajaxSettings for backward compatibility)
8080 jQuery
.ajaxSettings
.xhr
= window
.ActiveXObject
?
8081 /* Microsoft failed to properly
8082 * implement the XMLHttpRequest in IE7 (can't request local files),
8083 * so we use the ActiveXObject when it is available
8084 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8085 * we need a fallback.
8088 return !this.isLocal
&& createStandardXHR() || createActiveXHR();
8090 // For all other browsers, use the standard XMLHttpRequest object
8093 // Determine support properties
8095 jQuery
.extend( jQuery
.support
, {
8097 cors
: !!xhr
&& ( "withCredentials" in xhr
)
8099 })( jQuery
.ajaxSettings
.xhr() );
8101 // Create transport if the browser can provide an xhr
8102 if ( jQuery
.support
.ajax
) {
8104 jQuery
.ajaxTransport(function( s
) {
8105 // Cross domain only allowed if supported through XMLHttpRequest
8106 if ( !s
.crossDomain
|| jQuery
.support
.cors
) {
8111 send: function( headers
, complete
) {
8119 // Passing null username, generates a login popup on Opera (#2865)
8121 xhr
.open( s
.type
, s
.url
, s
.async
, s
.username
, s
.password
);
8123 xhr
.open( s
.type
, s
.url
, s
.async
);
8126 // Apply custom fields if provided
8127 if ( s
.xhrFields
) {
8128 for ( i
in s
.xhrFields
) {
8129 xhr
[ i
] = s
.xhrFields
[ i
];
8133 // Override mime type if needed
8134 if ( s
.mimeType
&& xhr
.overrideMimeType
) {
8135 xhr
.overrideMimeType( s
.mimeType
);
8138 // X-Requested-With header
8139 // For cross-domain requests, seeing as conditions for a preflight are
8140 // akin to a jigsaw puzzle, we simply never set it to be sure.
8141 // (it can always be set on a per-request basis or even using ajaxSetup)
8142 // For same-domain requests, won't change header if already provided.
8143 if ( !s
.crossDomain
&& !headers
["X-Requested-With"] ) {
8144 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
8147 // Need an extra try/catch for cross domain requests in Firefox 3
8149 for ( i
in headers
) {
8150 xhr
.setRequestHeader( i
, headers
[ i
] );
8154 // Do send the request
8155 // This may raise an exception which is actually
8156 // handled in jQuery.ajax (so no try/catch here)
8157 xhr
.send( ( s
.hasContent
&& s
.data
) || null );
8160 callback = function( _
, isAbort
) {
8168 // Firefox throws exceptions when accessing properties
8169 // of an xhr when a network error occured
8170 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8173 // Was never called and is aborted or complete
8174 if ( callback
&& ( isAbort
|| xhr
.readyState
=== 4 ) ) {
8177 callback
= undefined;
8179 // Do not keep as active anymore
8181 xhr
.onreadystatechange
= jQuery
.noop
;
8182 if ( xhrOnUnloadAbort
) {
8183 delete xhrCallbacks
[ handle
];
8189 // Abort it manually if needed
8190 if ( xhr
.readyState
!== 4 ) {
8194 status
= xhr
.status
;
8195 responseHeaders
= xhr
.getAllResponseHeaders();
8197 xml
= xhr
.responseXML
;
8199 // Construct response list
8200 if ( xml
&& xml
.documentElement
/* #4958 */ ) {
8201 responses
.xml
= xml
;
8203 responses
.text
= xhr
.responseText
;
8205 // Firefox throws an exception when accessing
8206 // statusText for faulty cross-domain requests
8208 statusText
= xhr
.statusText
;
8210 // We normalize with Webkit giving an empty statusText
8214 // Filter status for non standard behaviors
8216 // If the request is local and we have data: assume a success
8217 // (success with no data won't get notified, that's the best we
8218 // can do given current implementations)
8219 if ( !status
&& s
.isLocal
&& !s
.crossDomain
) {
8220 status
= responses
.text
? 200 : 404;
8221 // IE - #1450: sometimes returns 1223 when it should be 204
8222 } else if ( status
=== 1223 ) {
8227 } catch( firefoxAccessException
) {
8229 complete( -1, firefoxAccessException
);
8233 // Call complete if needed
8235 complete( status
, statusText
, responses
, responseHeaders
);
8239 // if we're in sync mode or it's in cache
8240 // and has been retrieved directly (IE6 & IE7)
8241 // we need to manually fire the callback
8242 if ( !s
.async
|| xhr
.readyState
=== 4 ) {
8246 if ( xhrOnUnloadAbort
) {
8247 // Create the active xhrs callbacks list if needed
8248 // and attach the unload handler
8249 if ( !xhrCallbacks
) {
8251 jQuery( window
).unload( xhrOnUnloadAbort
);
8253 // Add to list of active xhrs callbacks
8254 xhrCallbacks
[ handle
] = callback
;
8256 xhr
.onreadystatechange
= callback
;
8273 var elemdisplay
= {},
8275 rfxtypes
= /^(?:toggle|show|hide)$/,
8276 rfxnum
= /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8279 // height animations
8280 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8282 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8283 // opacity animations
8289 show: function( speed
, easing
, callback
) {
8292 if ( speed
|| speed
=== 0 ) {
8293 return this.animate( genFx("show", 3), speed
, easing
, callback
);
8296 for ( var i
= 0, j
= this.length
; i
< j
; i
++ ) {
8300 display
= elem
.style
.display
;
8302 // Reset the inline display of this element to learn if it is
8303 // being hidden by cascaded rules or not
8304 if ( !jQuery
._data(elem
, "olddisplay") && display
=== "none" ) {
8305 display
= elem
.style
.display
= "";
8308 // Set elements which have been overridden with display: none
8309 // in a stylesheet to whatever the default browser style is
8310 // for such an element
8311 if ( display
=== "" && jQuery
.css(elem
, "display") === "none" ) {
8312 jQuery
._data( elem
, "olddisplay", defaultDisplay(elem
.nodeName
) );
8317 // Set the display of most of the elements in a second loop
8318 // to avoid the constant reflow
8319 for ( i
= 0; i
< j
; i
++ ) {
8323 display
= elem
.style
.display
;
8325 if ( display
=== "" || display
=== "none" ) {
8326 elem
.style
.display
= jQuery
._data( elem
, "olddisplay" ) || "";
8335 hide: function( speed
, easing
, callback
) {
8336 if ( speed
|| speed
=== 0 ) {
8337 return this.animate( genFx("hide", 3), speed
, easing
, callback
);
8344 for ( ; i
< j
; i
++ ) {
8347 display
= jQuery
.css( elem
, "display" );
8349 if ( display
!== "none" && !jQuery
._data( elem
, "olddisplay" ) ) {
8350 jQuery
._data( elem
, "olddisplay", display
);
8355 // Set the display of the elements in a second loop
8356 // to avoid the constant reflow
8357 for ( i
= 0; i
< j
; i
++ ) {
8358 if ( this[i
].style
) {
8359 this[i
].style
.display
= "none";
8367 // Save the old toggle function
8368 _toggle
: jQuery
.fn
.toggle
,
8370 toggle: function( fn
, fn2
, callback
) {
8371 var bool
= typeof fn
=== "boolean";
8373 if ( jQuery
.isFunction(fn
) && jQuery
.isFunction(fn2
) ) {
8374 this._toggle
.apply( this, arguments
);
8376 } else if ( fn
== null || bool
) {
8377 this.each(function() {
8378 var state
= bool
? fn
: jQuery(this).is(":hidden");
8379 jQuery(this)[ state
? "show" : "hide" ]();
8383 this.animate(genFx("toggle", 3), fn
, fn2
, callback
);
8389 fadeTo: function( speed
, to
, easing
, callback
) {
8390 return this.filter(":hidden").css("opacity", 0).show().end()
8391 .animate({opacity
: to
}, speed
, easing
, callback
);
8394 animate: function( prop
, speed
, easing
, callback
) {
8395 var optall
= jQuery
.speed( speed
, easing
, callback
);
8397 if ( jQuery
.isEmptyObject( prop
) ) {
8398 return this.each( optall
.complete
, [ false ] );
8401 // Do not change referenced properties as per-property easing will be lost
8402 prop
= jQuery
.extend( {}, prop
);
8404 function doAnimation() {
8405 // XXX 'this' does not always have a nodeName when running the
8408 if ( optall
.queue
=== false ) {
8409 jQuery
._mark( this );
8412 var opt
= jQuery
.extend( {}, optall
),
8413 isElement
= this.nodeType
=== 1,
8414 hidden
= isElement
&& jQuery(this).is(":hidden"),
8416 parts
, start
, end
, unit
,
8419 // will store per property easing and be used to determine when an animation is complete
8420 opt
.animatedProperties
= {};
8424 // property name normalization
8425 name
= jQuery
.camelCase( p
);
8427 prop
[ name
] = prop
[ p
];
8433 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8434 if ( jQuery
.isArray( val
) ) {
8435 opt
.animatedProperties
[ name
] = val
[ 1 ];
8436 val
= prop
[ name
] = val
[ 0 ];
8438 opt
.animatedProperties
[ name
] = opt
.specialEasing
&& opt
.specialEasing
[ name
] || opt
.easing
|| 'swing';
8441 if ( val
=== "hide" && hidden
|| val
=== "show" && !hidden
) {
8442 return opt
.complete
.call( this );
8445 if ( isElement
&& ( name
=== "height" || name
=== "width" ) ) {
8446 // Make sure that nothing sneaks out
8447 // Record all 3 overflow attributes because IE does not
8448 // change the overflow attribute when overflowX and
8449 // overflowY are set to the same value
8450 opt
.overflow
= [ this.style
.overflow
, this.style
.overflowX
, this.style
.overflowY
];
8452 // Set display property to inline-block for height/width
8453 // animations on inline elements that are having width/height animated
8454 if ( jQuery
.css( this, "display" ) === "inline" &&
8455 jQuery
.css( this, "float" ) === "none" ) {
8457 // inline-level elements accept inline-block;
8458 // block-level elements need to be inline with layout
8459 if ( !jQuery
.support
.inlineBlockNeedsLayout
|| defaultDisplay( this.nodeName
) === "inline" ) {
8460 this.style
.display
= "inline-block";
8463 this.style
.zoom
= 1;
8469 if ( opt
.overflow
!= null ) {
8470 this.style
.overflow
= "hidden";
8474 e
= new jQuery
.fx( this, opt
, p
);
8477 if ( rfxtypes
.test( val
) ) {
8479 // Tracks whether to show or hide based on private
8480 // data attached to the element
8481 method
= jQuery
._data( this, "toggle" + p
) || ( val
=== "toggle" ? hidden
? "show" : "hide" : 0 );
8483 jQuery
._data( this, "toggle" + p
, method
=== "show" ? "hide" : "show" );
8490 parts
= rfxnum
.exec( val
);
8494 end
= parseFloat( parts
[2] );
8495 unit
= parts
[3] || ( jQuery
.cssNumber
[ p
] ? "" : "px" );
8497 // We need to compute starting value
8498 if ( unit
!== "px" ) {
8499 jQuery
.style( this, p
, (end
|| 1) + unit
);
8500 start
= ( (end
|| 1) / e
.cur() ) * start
;
8501 jQuery
.style( this, p
, start
+ unit
);
8504 // If a +=/-= token was provided, we're doing a relative animation
8506 end
= ( (parts
[ 1 ] === "-=" ? -1 : 1) * end
) + start
;
8509 e
.custom( start
, end
, unit
);
8512 e
.custom( start
, val
, "" );
8517 // For JS strict compliance
8521 return optall
.queue
=== false ?
8522 this.each( doAnimation
) :
8523 this.queue( optall
.queue
, doAnimation
);
8526 stop: function( type
, clearQueue
, gotoEnd
) {
8527 if ( typeof type
!== "string" ) {
8528 gotoEnd
= clearQueue
;
8532 if ( clearQueue
&& type
!== false ) {
8533 this.queue( type
|| "fx", [] );
8536 return this.each(function() {
8539 timers
= jQuery
.timers
,
8540 data
= jQuery
._data( this );
8542 // clear marker counters if we know they won't be
8544 jQuery
._unmark( true, this );
8547 function stopQueue( elem
, data
, i
) {
8548 var hooks
= data
[ i
];
8549 jQuery
.removeData( elem
, i
, true );
8550 hooks
.stop( gotoEnd
);
8553 if ( type
== null ) {
8555 if ( data
[ i
].stop
&& i
.indexOf(".run") === i
.length
- 4 ) {
8556 stopQueue( this, data
, i
);
8559 } else if ( data
[ i
= type
+ ".run" ] && data
[ i
].stop
){
8560 stopQueue( this, data
, i
);
8563 for ( i
= timers
.length
; i
--; ) {
8564 if ( timers
[ i
].elem
=== this && (type
== null || timers
[ i
].queue
=== type
) ) {
8567 // force the next step to be the last
8568 timers
[ i
]( true );
8570 timers
[ i
].saveState();
8573 timers
.splice( i
, 1 );
8577 // start the next in the queue if the last step wasn't forced
8578 // timers currently will call their complete callbacks, which will dequeue
8579 // but only if they were gotoEnd
8580 if ( !( gotoEnd
&& hadTimers
) ) {
8581 jQuery
.dequeue( this, type
);
8588 // Animations created synchronously will run synchronously
8589 function createFxNow() {
8590 setTimeout( clearFxNow
, 0 );
8591 return ( fxNow
= jQuery
.now() );
8594 function clearFxNow() {
8598 // Generate parameters to create a standard animation
8599 function genFx( type
, num
) {
8602 jQuery
.each( fxAttrs
.concat
.apply([], fxAttrs
.slice( 0, num
)), function() {
8609 // Generate shortcuts for custom animations
8611 slideDown
: genFx( "show", 1 ),
8612 slideUp
: genFx( "hide", 1 ),
8613 slideToggle
: genFx( "toggle", 1 ),
8614 fadeIn
: { opacity
: "show" },
8615 fadeOut
: { opacity
: "hide" },
8616 fadeToggle
: { opacity
: "toggle" }
8617 }, function( name
, props
) {
8618 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
8619 return this.animate( props
, speed
, easing
, callback
);
8624 speed: function( speed
, easing
, fn
) {
8625 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
8626 complete
: fn
|| !fn
&& easing
||
8627 jQuery
.isFunction( speed
) && speed
,
8629 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
8632 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration
:
8633 opt
.duration
in jQuery
.fx
.speeds
? jQuery
.fx
.speeds
[ opt
.duration
] : jQuery
.fx
.speeds
._default
;
8635 // normalize opt.queue - true/undefined/null -> "fx"
8636 if ( opt
.queue
== null || opt
.queue
=== true ) {
8641 opt
.old
= opt
.complete
;
8643 opt
.complete = function( noUnmark
) {
8644 if ( jQuery
.isFunction( opt
.old
) ) {
8645 opt
.old
.call( this );
8649 jQuery
.dequeue( this, opt
.queue
);
8650 } else if ( noUnmark
!== false ) {
8651 jQuery
._unmark( this );
8659 linear: function( p
, n
, firstNum
, diff
) {
8660 return firstNum
+ diff
* p
;
8662 swing: function( p
, n
, firstNum
, diff
) {
8663 return ( ( -Math
.cos( p
*Math
.PI
) / 2 ) + 0.5 ) * diff
+ firstNum
;
8669 fx: function( elem
, options
, prop
) {
8670 this.options
= options
;
8674 options
.orig
= options
.orig
|| {};
8679 jQuery
.fx
.prototype = {
8680 // Simple function for setting a style value
8681 update: function() {
8682 if ( this.options
.step
) {
8683 this.options
.step
.call( this.elem
, this.now
, this );
8686 ( jQuery
.fx
.step
[ this.prop
] || jQuery
.fx
.step
._default
)( this );
8689 // Get the current size
8691 if ( this.elem
[ this.prop
] != null && (!this.elem
.style
|| this.elem
.style
[ this.prop
] == null) ) {
8692 return this.elem
[ this.prop
];
8696 r
= jQuery
.css( this.elem
, this.prop
);
8697 // Empty strings, null, undefined and "auto" are converted to 0,
8698 // complex values such as "rotate(1rad)" are returned as is,
8699 // simple values such as "10px" are parsed to Float.
8700 return isNaN( parsed
= parseFloat( r
) ) ? !r
|| r
=== "auto" ? 0 : r
: parsed
;
8703 // Start an animation from one number to another
8704 custom: function( from, to
, unit
) {
8708 this.startTime
= fxNow
|| createFxNow();
8710 this.now
= this.start
= from;
8711 this.pos
= this.state
= 0;
8712 this.unit
= unit
|| this.unit
|| ( jQuery
.cssNumber
[ this.prop
] ? "" : "px" );
8714 function t( gotoEnd
) {
8715 return self
.step( gotoEnd
);
8718 t
.queue
= this.options
.queue
;
8720 t
.saveState = function() {
8721 if ( self
.options
.hide
&& jQuery
._data( self
.elem
, "fxshow" + self
.prop
) === undefined ) {
8722 jQuery
._data( self
.elem
, "fxshow" + self
.prop
, self
.start
);
8726 if ( t() && jQuery
.timers
.push(t
) && !timerId
) {
8727 timerId
= setInterval( fx
.tick
, fx
.interval
);
8731 // Simple 'show' function
8733 var dataShow
= jQuery
._data( this.elem
, "fxshow" + this.prop
);
8735 // Remember where we started, so that we can go back to it later
8736 this.options
.orig
[ this.prop
] = dataShow
|| jQuery
.style( this.elem
, this.prop
);
8737 this.options
.show
= true;
8739 // Begin the animation
8740 // Make sure that we start at a small width/height to avoid any flash of content
8741 if ( dataShow
!== undefined ) {
8742 // This show is picking up where a previous hide or show left off
8743 this.custom( this.cur(), dataShow
);
8745 this.custom( this.prop
=== "width" || this.prop
=== "height" ? 1 : 0, this.cur() );
8748 // Start by showing the element
8749 jQuery( this.elem
).show();
8752 // Simple 'hide' function
8754 // Remember where we started, so that we can go back to it later
8755 this.options
.orig
[ this.prop
] = jQuery
._data( this.elem
, "fxshow" + this.prop
) || jQuery
.style( this.elem
, this.prop
);
8756 this.options
.hide
= true;
8758 // Begin the animation
8759 this.custom( this.cur(), 0 );
8762 // Each step of an animation
8763 step: function( gotoEnd
) {
8765 t
= fxNow
|| createFxNow(),
8768 options
= this.options
;
8770 if ( gotoEnd
|| t
>= options
.duration
+ this.startTime
) {
8771 this.now
= this.end
;
8772 this.pos
= this.state
= 1;
8775 options
.animatedProperties
[ this.prop
] = true;
8777 for ( p
in options
.animatedProperties
) {
8778 if ( options
.animatedProperties
[ p
] !== true ) {
8784 // Reset the overflow
8785 if ( options
.overflow
!= null && !jQuery
.support
.shrinkWrapBlocks
) {
8787 jQuery
.each( [ "", "X", "Y" ], function( index
, value
) {
8788 elem
.style
[ "overflow" + value
] = options
.overflow
[ index
];
8792 // Hide the element if the "hide" operation was done
8793 if ( options
.hide
) {
8794 jQuery( elem
).hide();
8797 // Reset the properties, if the item has been hidden or shown
8798 if ( options
.hide
|| options
.show
) {
8799 for ( p
in options
.animatedProperties
) {
8800 jQuery
.style( elem
, p
, options
.orig
[ p
] );
8801 jQuery
.removeData( elem
, "fxshow" + p
, true );
8802 // Toggle data is no longer needed
8803 jQuery
.removeData( elem
, "toggle" + p
, true );
8807 // Execute the complete function
8808 // in the event that the complete function throws an exception
8809 // we must ensure it won't be called twice. #5684
8811 complete
= options
.complete
;
8814 options
.complete
= false;
8815 complete
.call( elem
);
8822 // classical easing cannot be used with an Infinity duration
8823 if ( options
.duration
== Infinity
) {
8826 n
= t
- this.startTime
;
8827 this.state
= n
/ options
.duration
;
8829 // Perform the easing function, defaults to swing
8830 this.pos
= jQuery
.easing
[ options
.animatedProperties
[this.prop
] ]( this.state
, n
, 0, 1, options
.duration
);
8831 this.now
= this.start
+ ( (this.end
- this.start
) * this.pos
);
8833 // Perform the next step of the animation
8841 jQuery
.extend( jQuery
.fx
, {
8844 timers
= jQuery
.timers
,
8847 for ( ; i
< timers
.length
; i
++ ) {
8848 timer
= timers
[ i
];
8849 // Checks the timer has not already been removed
8850 if ( !timer() && timers
[ i
] === timer
) {
8851 timers
.splice( i
--, 1 );
8855 if ( !timers
.length
) {
8863 clearInterval( timerId
);
8875 opacity: function( fx
) {
8876 jQuery
.style( fx
.elem
, "opacity", fx
.now
);
8879 _default: function( fx
) {
8880 if ( fx
.elem
.style
&& fx
.elem
.style
[ fx
.prop
] != null ) {
8881 fx
.elem
.style
[ fx
.prop
] = fx
.now
+ fx
.unit
;
8883 fx
.elem
[ fx
.prop
] = fx
.now
;
8889 // Adds width/height step functions
8890 // Do not set anything below 0
8891 jQuery
.each([ "width", "height" ], function( i
, prop
) {
8892 jQuery
.fx
.step
[ prop
] = function( fx
) {
8893 jQuery
.style( fx
.elem
, prop
, Math
.max(0, fx
.now
) );
8897 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
8898 jQuery
.expr
.filters
.animated = function( elem
) {
8899 return jQuery
.grep(jQuery
.timers
, function( fn
) {
8900 return elem
=== fn
.elem
;
8905 // Try to restore the default display value of an element
8906 function defaultDisplay( nodeName
) {
8908 if ( !elemdisplay
[ nodeName
] ) {
8910 var body
= document
.body
,
8911 elem
= jQuery( "<" + nodeName
+ ">" ).appendTo( body
),
8912 display
= elem
.css( "display" );
8915 // If the simple way fails,
8916 // get element's real default display by attaching it to a temp iframe
8917 if ( display
=== "none" || display
=== "" ) {
8918 // No iframe to use yet, so create it
8920 iframe
= document
.createElement( "iframe" );
8921 iframe
.frameBorder
= iframe
.width
= iframe
.height
= 0;
8924 body
.appendChild( iframe
);
8926 // Create a cacheable copy of the iframe document on first call.
8927 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8928 // document to it; WebKit & Firefox won't allow reusing the iframe document.
8929 if ( !iframeDoc
|| !iframe
.createElement
) {
8930 iframeDoc
= ( iframe
.contentWindow
|| iframe
.contentDocument
).document
;
8931 iframeDoc
.write( ( document
.compatMode
=== "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8935 elem
= iframeDoc
.createElement( nodeName
);
8937 iframeDoc
.body
.appendChild( elem
);
8939 display
= jQuery
.css( elem
, "display" );
8940 body
.removeChild( iframe
);
8943 // Store the correct default display
8944 elemdisplay
[ nodeName
] = display
;
8947 return elemdisplay
[ nodeName
];
8953 var rtable
= /^t(?:able|d|h)$/i,
8954 rroot
= /^(?:body|html)$/i;
8956 if ( "getBoundingClientRect" in document
.documentElement
) {
8957 jQuery
.fn
.offset = function( options
) {
8958 var elem
= this[0], box
;
8961 return this.each(function( i
) {
8962 jQuery
.offset
.setOffset( this, options
, i
);
8966 if ( !elem
|| !elem
.ownerDocument
) {
8970 if ( elem
=== elem
.ownerDocument
.body
) {
8971 return jQuery
.offset
.bodyOffset( elem
);
8975 box
= elem
.getBoundingClientRect();
8978 var doc
= elem
.ownerDocument
,
8979 docElem
= doc
.documentElement
;
8981 // Make sure we're not dealing with a disconnected DOM node
8982 if ( !box
|| !jQuery
.contains( docElem
, elem
) ) {
8983 return box
? { top
: box
.top
, left
: box
.left
} : { top
: 0, left
: 0 };
8986 var body
= doc
.body
,
8987 win
= getWindow(doc
),
8988 clientTop
= docElem
.clientTop
|| body
.clientTop
|| 0,
8989 clientLeft
= docElem
.clientLeft
|| body
.clientLeft
|| 0,
8990 scrollTop
= win
.pageYOffset
|| jQuery
.support
.boxModel
&& docElem
.scrollTop
|| body
.scrollTop
,
8991 scrollLeft
= win
.pageXOffset
|| jQuery
.support
.boxModel
&& docElem
.scrollLeft
|| body
.scrollLeft
,
8992 top
= box
.top
+ scrollTop
- clientTop
,
8993 left
= box
.left
+ scrollLeft
- clientLeft
;
8995 return { top
: top
, left
: left
};
8999 jQuery
.fn
.offset = function( options
) {
9003 return this.each(function( i
) {
9004 jQuery
.offset
.setOffset( this, options
, i
);
9008 if ( !elem
|| !elem
.ownerDocument
) {
9012 if ( elem
=== elem
.ownerDocument
.body
) {
9013 return jQuery
.offset
.bodyOffset( elem
);
9017 offsetParent
= elem
.offsetParent
,
9018 prevOffsetParent
= elem
,
9019 doc
= elem
.ownerDocument
,
9020 docElem
= doc
.documentElement
,
9022 defaultView
= doc
.defaultView
,
9023 prevComputedStyle
= defaultView
? defaultView
.getComputedStyle( elem
, null ) : elem
.currentStyle
,
9024 top
= elem
.offsetTop
,
9025 left
= elem
.offsetLeft
;
9027 while ( (elem
= elem
.parentNode
) && elem
!== body
&& elem
!== docElem
) {
9028 if ( jQuery
.support
.fixedPosition
&& prevComputedStyle
.position
=== "fixed" ) {
9032 computedStyle
= defaultView
? defaultView
.getComputedStyle(elem
, null) : elem
.currentStyle
;
9033 top
-= elem
.scrollTop
;
9034 left
-= elem
.scrollLeft
;
9036 if ( elem
=== offsetParent
) {
9037 top
+= elem
.offsetTop
;
9038 left
+= elem
.offsetLeft
;
9040 if ( jQuery
.support
.doesNotAddBorder
&& !(jQuery
.support
.doesAddBorderForTableAndCells
&& rtable
.test(elem
.nodeName
)) ) {
9041 top
+= parseFloat( computedStyle
.borderTopWidth
) || 0;
9042 left
+= parseFloat( computedStyle
.borderLeftWidth
) || 0;
9045 prevOffsetParent
= offsetParent
;
9046 offsetParent
= elem
.offsetParent
;
9049 if ( jQuery
.support
.subtractsBorderForOverflowNotVisible
&& computedStyle
.overflow
!== "visible" ) {
9050 top
+= parseFloat( computedStyle
.borderTopWidth
) || 0;
9051 left
+= parseFloat( computedStyle
.borderLeftWidth
) || 0;
9054 prevComputedStyle
= computedStyle
;
9057 if ( prevComputedStyle
.position
=== "relative" || prevComputedStyle
.position
=== "static" ) {
9058 top
+= body
.offsetTop
;
9059 left
+= body
.offsetLeft
;
9062 if ( jQuery
.support
.fixedPosition
&& prevComputedStyle
.position
=== "fixed" ) {
9063 top
+= Math
.max( docElem
.scrollTop
, body
.scrollTop
);
9064 left
+= Math
.max( docElem
.scrollLeft
, body
.scrollLeft
);
9067 return { top
: top
, left
: left
};
9073 bodyOffset: function( body
) {
9074 var top
= body
.offsetTop
,
9075 left
= body
.offsetLeft
;
9077 if ( jQuery
.support
.doesNotIncludeMarginInBodyOffset
) {
9078 top
+= parseFloat( jQuery
.css(body
, "marginTop") ) || 0;
9079 left
+= parseFloat( jQuery
.css(body
, "marginLeft") ) || 0;
9082 return { top
: top
, left
: left
};
9085 setOffset: function( elem
, options
, i
) {
9086 var position
= jQuery
.css( elem
, "position" );
9088 // set position first, in-case top/left are set even on static elem
9089 if ( position
=== "static" ) {
9090 elem
.style
.position
= "relative";
9093 var curElem
= jQuery( elem
),
9094 curOffset
= curElem
.offset(),
9095 curCSSTop
= jQuery
.css( elem
, "top" ),
9096 curCSSLeft
= jQuery
.css( elem
, "left" ),
9097 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) && jQuery
.inArray("auto", [curCSSTop
, curCSSLeft
]) > -1,
9098 props
= {}, curPosition
= {}, curTop
, curLeft
;
9100 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9101 if ( calculatePosition
) {
9102 curPosition
= curElem
.position();
9103 curTop
= curPosition
.top
;
9104 curLeft
= curPosition
.left
;
9106 curTop
= parseFloat( curCSSTop
) || 0;
9107 curLeft
= parseFloat( curCSSLeft
) || 0;
9110 if ( jQuery
.isFunction( options
) ) {
9111 options
= options
.call( elem
, i
, curOffset
);
9114 if ( options
.top
!= null ) {
9115 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
9117 if ( options
.left
!= null ) {
9118 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
9121 if ( "using" in options
) {
9122 options
.using
.call( elem
, props
);
9124 curElem
.css( props
);
9132 position: function() {
9139 // Get *real* offsetParent
9140 offsetParent
= this.offsetParent(),
9142 // Get correct offsets
9143 offset
= this.offset(),
9144 parentOffset
= rroot
.test(offsetParent
[0].nodeName
) ? { top
: 0, left
: 0 } : offsetParent
.offset();
9146 // Subtract element margins
9147 // note: when an element has margin: auto the offsetLeft and marginLeft
9148 // are the same in Safari causing offset.left to incorrectly be 0
9149 offset
.top
-= parseFloat( jQuery
.css(elem
, "marginTop") ) || 0;
9150 offset
.left
-= parseFloat( jQuery
.css(elem
, "marginLeft") ) || 0;
9152 // Add offsetParent borders
9153 parentOffset
.top
+= parseFloat( jQuery
.css(offsetParent
[0], "borderTopWidth") ) || 0;
9154 parentOffset
.left
+= parseFloat( jQuery
.css(offsetParent
[0], "borderLeftWidth") ) || 0;
9156 // Subtract the two offsets
9158 top
: offset
.top
- parentOffset
.top
,
9159 left
: offset
.left
- parentOffset
.left
9163 offsetParent: function() {
9164 return this.map(function() {
9165 var offsetParent
= this.offsetParent
|| document
.body
;
9166 while ( offsetParent
&& (!rroot
.test(offsetParent
.nodeName
) && jQuery
.css(offsetParent
, "position") === "static") ) {
9167 offsetParent
= offsetParent
.offsetParent
;
9169 return offsetParent
;
9175 // Create scrollLeft and scrollTop methods
9176 jQuery
.each( ["Left", "Top"], function( i
, name
) {
9177 var method
= "scroll" + name
;
9179 jQuery
.fn
[ method
] = function( val
) {
9182 if ( val
=== undefined ) {
9189 win
= getWindow( elem
);
9191 // Return the scroll offset
9192 return win
? ("pageXOffset" in win
) ? win
[ i
? "pageYOffset" : "pageXOffset" ] :
9193 jQuery
.support
.boxModel
&& win
.document
.documentElement
[ method
] ||
9194 win
.document
.body
[ method
] :
9198 // Set the scroll offset
9199 return this.each(function() {
9200 win
= getWindow( this );
9204 !i
? val
: jQuery( win
).scrollLeft(),
9205 i
? val
: jQuery( win
).scrollTop()
9209 this[ method
] = val
;
9215 function getWindow( elem
) {
9216 return jQuery
.isWindow( elem
) ?
9218 elem
.nodeType
=== 9 ?
9219 elem
.defaultView
|| elem
.parentWindow
:
9226 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
9227 jQuery
.each([ "Height", "Width" ], function( i
, name
) {
9229 var type
= name
.toLowerCase();
9231 // innerHeight and innerWidth
9232 jQuery
.fn
[ "inner" + name
] = function() {
9236 parseFloat( jQuery
.css( elem
, type
, "padding" ) ) :
9241 // outerHeight and outerWidth
9242 jQuery
.fn
[ "outer" + name
] = function( margin
) {
9246 parseFloat( jQuery
.css( elem
, type
, margin
? "margin" : "border" ) ) :
9251 jQuery
.fn
[ type
] = function( size
) {
9252 // Get window width or height
9255 return size
== null ? null : this;
9258 if ( jQuery
.isFunction( size
) ) {
9259 return this.each(function( i
) {
9260 var self
= jQuery( this );
9261 self
[ type
]( size
.call( this, i
, self
[ type
]() ) );
9265 if ( jQuery
.isWindow( elem
) ) {
9266 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9267 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9268 var docElemProp
= elem
.document
.documentElement
[ "client" + name
],
9269 body
= elem
.document
.body
;
9270 return elem
.document
.compatMode
=== "CSS1Compat" && docElemProp
||
9271 body
&& body
[ "client" + name
] || docElemProp
;
9273 // Get document width or height
9274 } else if ( elem
.nodeType
=== 9 ) {
9275 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9277 elem
.documentElement
["client" + name
],
9278 elem
.body
["scroll" + name
], elem
.documentElement
["scroll" + name
],
9279 elem
.body
["offset" + name
], elem
.documentElement
["offset" + name
]
9282 // Get or set width or height on the element
9283 } else if ( size
=== undefined ) {
9284 var orig
= jQuery
.css( elem
, type
),
9285 ret
= parseFloat( orig
);
9287 return jQuery
.isNumeric( ret
) ? ret
: orig
;
9289 // Set the width or height on the element (default to pixels if value is unitless)
9291 return this.css( type
, typeof size
=== "string" ? size
: size
+ "px" );
9298 // Expose jQuery to the global object
9299 window
.jQuery
= window
.$ = jQuery
;