2 * jQuery JavaScript Library v1.8.1
8 * Copyright 2012 jQuery Foundation and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: Thu Aug 30 2012 17:17:22 GMT-0400 (Eastern Daylight Time)
14 (function( window
, undefined ) {
16 // A central reference to the root jQuery(document)
19 // The deferred used on DOM ready
22 // Use the correct document accordingly with window argument (sandbox)
23 document
= window
.document
,
24 location
= window
.location
,
25 navigator
= window
.navigator
,
27 // Map over jQuery in case of overwrite
28 _jQuery
= window
.jQuery
,
30 // Map over the $ in case of overwrite
33 // Save a reference to some core methods
34 core_push
= Array
.prototype.push
,
35 core_slice
= Array
.prototype.slice
,
36 core_indexOf
= Array
.prototype.indexOf
,
37 core_toString
= Object
.prototype.toString
,
38 core_hasOwn
= Object
.prototype.hasOwnProperty
,
39 core_trim
= String
.prototype.trim
,
41 // Define a local copy of jQuery
42 jQuery = function( selector
, context
) {
43 // The jQuery object is actually just the init constructor 'enhanced'
44 return new jQuery
.fn
.init( selector
, context
, rootjQuery
);
47 // Used for matching numbers
48 core_pnum
= /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source
,
50 // Used for detecting and trimming whitespace
51 core_rnotwhite
= /\S/,
54 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
55 rtrim
= /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
57 // A simple way to check for HTML strings
58 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
59 rquickExpr
= /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
61 // Match a standalone tag
62 rsingleTag
= /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
65 rvalidchars
= /^[\],:{}\s]*$/,
66 rvalidbraces
= /(?:^|:|,)(?:\s*\[)+/g,
67 rvalidescape
= /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
68 rvalidtokens
= /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
70 // Matches dashed string for camelizing
72 rdashAlpha
= /-([\da-z])/gi,
74 // Used by jQuery.camelCase as callback to replace()
75 fcamelCase = function( all
, letter
) {
76 return ( letter
+ "" ).toUpperCase();
79 // The ready event handler and self cleanup method
80 DOMContentLoaded = function() {
81 if ( document
.addEventListener
) {
82 document
.removeEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
84 } else if ( document
.readyState
=== "complete" ) {
85 // we're here because readyState === "complete" in oldIE
86 // which is good enough for us to call the dom ready!
87 document
.detachEvent( "onreadystatechange", DOMContentLoaded
);
92 // [[Class]] -> type pairs
95 jQuery
.fn
= jQuery
.prototype = {
97 init: function( selector
, context
, rootjQuery
) {
98 var match
, elem
, ret
, doc
;
100 // Handle $(""), $(null), $(undefined), $(false)
105 // Handle $(DOMElement)
106 if ( selector
.nodeType
) {
107 this.context
= this[0] = selector
;
112 // Handle HTML strings
113 if ( typeof selector
=== "string" ) {
114 if ( selector
.charAt(0) === "<" && selector
.charAt( selector
.length
- 1 ) === ">" && selector
.length
>= 3 ) {
115 // Assume that strings that start and end with <> are HTML and skip the regex check
116 match
= [ null, selector
, null ];
119 match
= rquickExpr
.exec( selector
);
122 // Match html or make sure no context is specified for #id
123 if ( match
&& (match
[1] || !context
) ) {
125 // HANDLE: $(html) -> $(array)
127 context
= context
instanceof jQuery
? context
[0] : context
;
128 doc
= ( context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
);
130 // scripts is true for back-compat
131 selector
= jQuery
.parseHTML( match
[1], doc
, true );
132 if ( rsingleTag
.test( match
[1] ) && jQuery
.isPlainObject( context
) ) {
133 this.attr
.call( selector
, context
, true );
136 return jQuery
.merge( this, selector
);
140 elem
= document
.getElementById( match
[2] );
142 // Check parentNode to catch when Blackberry 4.6 returns
143 // nodes that are no longer in the document #6963
144 if ( elem
&& elem
.parentNode
) {
145 // Handle the case where IE and Opera return items
146 // by name instead of ID
147 if ( elem
.id
!== match
[2] ) {
148 return rootjQuery
.find( selector
);
151 // Otherwise, we inject the element directly into the jQuery object
156 this.context
= document
;
157 this.selector
= selector
;
161 // HANDLE: $(expr, $(...))
162 } else if ( !context
|| context
.jquery
) {
163 return ( context
|| rootjQuery
).find( selector
);
165 // HANDLE: $(expr, context)
166 // (which is just equivalent to: $(context).find(expr)
168 return this.constructor( context
).find( selector
);
171 // HANDLE: $(function)
172 // Shortcut for document ready
173 } else if ( jQuery
.isFunction( selector
) ) {
174 return rootjQuery
.ready( selector
);
177 if ( selector
.selector
!== undefined ) {
178 this.selector
= selector
.selector
;
179 this.context
= selector
.context
;
182 return jQuery
.makeArray( selector
, this );
185 // Start with an empty selector
188 // The current version of jQuery being used
191 // The default length of a jQuery object is 0
194 // The number of elements contained in the matched element set
199 toArray: function() {
200 return core_slice
.call( this );
203 // Get the Nth element in the matched element set OR
204 // Get the whole matched element set as a clean array
205 get: function( num
) {
208 // Return a 'clean' array
211 // Return just the object
212 ( num
< 0 ? this[ this.length
+ num
] : this[ num
] );
215 // Take an array of elements and push it onto the stack
216 // (returning the new matched element set)
217 pushStack: function( elems
, name
, selector
) {
219 // Build a new jQuery matched element set
220 var ret
= jQuery
.merge( this.constructor(), elems
);
222 // Add the old object onto the stack (as a reference)
223 ret
.prevObject
= this;
225 ret
.context
= this.context
;
227 if ( name
=== "find" ) {
228 ret
.selector
= this.selector
+ ( this.selector
? " " : "" ) + selector
;
230 ret
.selector
= this.selector
+ "." + name
+ "(" + selector
+ ")";
233 // Return the newly-formed element set
237 // Execute a callback for every element in the matched set.
238 // (You can seed the arguments with an array of args, but this is
239 // only used internally.)
240 each: function( callback
, args
) {
241 return jQuery
.each( this, callback
, args
);
244 ready: function( fn
) {
246 jQuery
.ready
.promise().done( fn
);
255 this.slice( i
, i
+ 1 );
263 return this.eq( -1 );
267 return this.pushStack( core_slice
.apply( this, arguments
),
268 "slice", core_slice
.call(arguments
).join(",") );
271 map: function( callback
) {
272 return this.pushStack( jQuery
.map(this, function( elem
, i
) {
273 return callback
.call( elem
, i
, elem
);
278 return this.prevObject
|| this.constructor(null);
281 // For internal use only.
282 // Behaves like an Array's method, not like a jQuery method.
288 // Give the init function the jQuery prototype for later instantiation
289 jQuery
.fn
.init
.prototype = jQuery
.fn
;
291 jQuery
.extend
= jQuery
.fn
.extend = function() {
292 var options
, name
, src
, copy
, copyIsArray
, clone
,
293 target
= arguments
[0] || {},
295 length
= arguments
.length
,
298 // Handle a deep copy situation
299 if ( typeof target
=== "boolean" ) {
301 target
= arguments
[1] || {};
302 // skip the boolean and the target
306 // Handle case when target is a string or something (possible in deep copy)
307 if ( typeof target
!== "object" && !jQuery
.isFunction(target
) ) {
311 // extend jQuery itself if only one argument is passed
312 if ( length
=== i
) {
317 for ( ; i
< length
; i
++ ) {
318 // Only deal with non-null/undefined values
319 if ( (options
= arguments
[ i
]) != null ) {
320 // Extend the base object
321 for ( name
in options
) {
322 src
= target
[ name
];
323 copy
= options
[ name
];
325 // Prevent never-ending loop
326 if ( target
=== copy
) {
330 // Recurse if we're merging plain objects or arrays
331 if ( deep
&& copy
&& ( jQuery
.isPlainObject(copy
) || (copyIsArray
= jQuery
.isArray(copy
)) ) ) {
334 clone
= src
&& jQuery
.isArray(src
) ? src
: [];
337 clone
= src
&& jQuery
.isPlainObject(src
) ? src
: {};
340 // Never move original objects, clone them
341 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
343 // Don't bring in undefined values
344 } else if ( copy
!== undefined ) {
345 target
[ name
] = copy
;
351 // Return the modified object
356 noConflict: function( deep
) {
357 if ( window
.$ === jQuery
) {
361 if ( deep
&& window
.jQuery
=== jQuery
) {
362 window
.jQuery
= _jQuery
;
368 // Is the DOM ready to be used? Set to true once it occurs.
371 // A counter to track how many items to wait for before
372 // the ready event fires. See #6781
375 // Hold (or release) the ready event
376 holdReady: function( hold
) {
380 jQuery
.ready( true );
384 // Handle when the DOM is ready
385 ready: function( wait
) {
387 // Abort if there are pending holds or we're already ready
388 if ( wait
=== true ? --jQuery
.readyWait
: jQuery
.isReady
) {
392 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
393 if ( !document
.body
) {
394 return setTimeout( jQuery
.ready
, 1 );
397 // Remember that the DOM is ready
398 jQuery
.isReady
= true;
400 // If a normal DOM Ready event fired, decrement, and wait if need be
401 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
405 // If there are functions bound, to execute
406 readyList
.resolveWith( document
, [ jQuery
] );
408 // Trigger any bound ready events
409 if ( jQuery
.fn
.trigger
) {
410 jQuery( document
).trigger("ready").off("ready");
414 // See test/unit/core.js for details concerning isFunction.
415 // Since version 1.3, DOM methods and functions like alert
416 // aren't supported. They return false on IE (#2968).
417 isFunction: function( obj
) {
418 return jQuery
.type(obj
) === "function";
421 isArray
: Array
.isArray
|| function( obj
) {
422 return jQuery
.type(obj
) === "array";
425 isWindow: function( obj
) {
426 return obj
!= null && obj
== obj
.window
;
429 isNumeric: function( obj
) {
430 return !isNaN( parseFloat(obj
) ) && isFinite( obj
);
433 type: function( obj
) {
436 class2type
[ core_toString
.call(obj
) ] || "object";
439 isPlainObject: function( obj
) {
440 // Must be an Object.
441 // Because of IE, we also have to check the presence of the constructor property.
442 // Make sure that DOM nodes and window objects don't pass through, as well
443 if ( !obj
|| jQuery
.type(obj
) !== "object" || obj
.nodeType
|| jQuery
.isWindow( obj
) ) {
448 // Not own constructor property must be Object
449 if ( obj
.constructor &&
450 !core_hasOwn
.call(obj
, "constructor") &&
451 !core_hasOwn
.call(obj
.constructor.prototype, "isPrototypeOf") ) {
455 // IE8,9 Will throw exceptions on certain host objects #9897
459 // Own properties are enumerated firstly, so to speed up,
460 // if last one is own, then all properties are own.
463 for ( key
in obj
) {}
465 return key
=== undefined || core_hasOwn
.call( obj
, key
);
468 isEmptyObject: function( obj
) {
470 for ( name
in obj
) {
476 error: function( msg
) {
477 throw new Error( msg
);
480 // data: string of html
481 // context (optional): If specified, the fragment will be created in this context, defaults to document
482 // scripts (optional): If true, will include scripts passed in the html string
483 parseHTML: function( data
, context
, scripts
) {
485 if ( !data
|| typeof data
!== "string" ) {
488 if ( typeof context
=== "boolean" ) {
492 context
= context
|| document
;
495 if ( (parsed
= rsingleTag
.exec( data
)) ) {
496 return [ context
.createElement( parsed
[1] ) ];
499 parsed
= jQuery
.buildFragment( [ data
], context
, scripts
? null : [] );
500 return jQuery
.merge( [],
501 (parsed
.cacheable
? jQuery
.clone( parsed
.fragment
) : parsed
.fragment
).childNodes
);
504 parseJSON: function( data
) {
505 if ( !data
|| typeof data
!== "string") {
509 // Make sure leading/trailing whitespace is removed (IE can't handle it)
510 data
= jQuery
.trim( data
);
512 // Attempt to parse using the native JSON parser first
513 if ( window
.JSON
&& window
.JSON
.parse
) {
514 return window
.JSON
.parse( data
);
517 // Make sure the incoming data is actual JSON
518 // Logic borrowed from http://json.org/json2.js
519 if ( rvalidchars
.test( data
.replace( rvalidescape
, "@" )
520 .replace( rvalidtokens
, "]" )
521 .replace( rvalidbraces
, "")) ) {
523 return ( new Function( "return " + data
) )();
526 jQuery
.error( "Invalid JSON: " + data
);
529 // Cross-browser xml parsing
530 parseXML: function( data
) {
532 if ( !data
|| typeof data
!== "string" ) {
536 if ( window
.DOMParser
) { // Standard
537 tmp
= new DOMParser();
538 xml
= tmp
.parseFromString( data
, "text/xml" );
540 xml
= new ActiveXObject( "Microsoft.XMLDOM" );
547 if ( !xml
|| !xml
.documentElement
|| xml
.getElementsByTagName( "parsererror" ).length
) {
548 jQuery
.error( "Invalid XML: " + data
);
555 // Evaluates a script in a global context
556 // Workarounds based on findings by Jim Driscoll
557 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
558 globalEval: function( data
) {
559 if ( data
&& core_rnotwhite
.test( data
) ) {
560 // We use execScript on Internet Explorer
561 // We use an anonymous function so that context is window
562 // rather than jQuery in Firefox
563 ( window
.execScript
|| function( data
) {
564 window
[ "eval" ].call( window
, data
);
569 // Convert dashed to camelCase; used by the css and data modules
570 // Microsoft forgot to hump their vendor prefix (#9572)
571 camelCase: function( string
) {
572 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
575 nodeName: function( elem
, name
) {
576 return elem
.nodeName
&& elem
.nodeName
.toUpperCase() === name
.toUpperCase();
579 // args is for internal usage only
580 each: function( obj
, callback
, args
) {
584 isObj
= length
=== undefined || jQuery
.isFunction( obj
);
588 for ( name
in obj
) {
589 if ( callback
.apply( obj
[ name
], args
) === false ) {
594 for ( ; i
< length
; ) {
595 if ( callback
.apply( obj
[ i
++ ], args
) === false ) {
601 // A special, fast, case for the most common use of each
604 for ( name
in obj
) {
605 if ( callback
.call( obj
[ name
], name
, obj
[ name
] ) === false ) {
610 for ( ; i
< length
; ) {
611 if ( callback
.call( obj
[ i
], i
, obj
[ i
++ ] ) === false ) {
621 // Use native String.trim function wherever possible
622 trim
: core_trim
&& !core_trim
.call("\uFEFF\xA0") ?
624 return text
== null ?
626 core_trim
.call( text
);
629 // Otherwise use our own trimming functionality
631 return text
== null ?
633 text
.toString().replace( rtrim
, "" );
636 // results is for internal usage only
637 makeArray: function( arr
, results
) {
642 // The window, strings (and functions) also have 'length'
643 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
644 type
= jQuery
.type( arr
);
646 if ( arr
.length
== null || type
=== "string" || type
=== "function" || type
=== "regexp" || jQuery
.isWindow( arr
) ) {
647 core_push
.call( ret
, arr
);
649 jQuery
.merge( ret
, arr
);
656 inArray: function( elem
, arr
, i
) {
660 if ( core_indexOf
) {
661 return core_indexOf
.call( arr
, elem
, i
);
665 i
= i
? i
< 0 ? Math
.max( 0, len
+ i
) : i
: 0;
667 for ( ; i
< len
; i
++ ) {
668 // Skip accessing in sparse arrays
669 if ( i
in arr
&& arr
[ i
] === elem
) {
678 merge: function( first
, second
) {
679 var l
= second
.length
,
683 if ( typeof l
=== "number" ) {
684 for ( ; j
< l
; j
++ ) {
685 first
[ i
++ ] = second
[ j
];
689 while ( second
[j
] !== undefined ) {
690 first
[ i
++ ] = second
[ j
++ ];
699 grep: function( elems
, callback
, inv
) {
703 length
= elems
.length
;
706 // Go through the array, only saving the items
707 // that pass the validator function
708 for ( ; i
< length
; i
++ ) {
709 retVal
= !!callback( elems
[ i
], i
);
710 if ( inv
!== retVal
) {
711 ret
.push( elems
[ i
] );
718 // arg is for internal usage only
719 map: function( elems
, callback
, arg
) {
723 length
= elems
.length
,
724 // jquery objects are treated as arrays
725 isArray
= elems
instanceof jQuery
|| length
!== undefined && typeof length
=== "number" && ( ( length
> 0 && elems
[ 0 ] && elems
[ length
-1 ] ) || length
=== 0 || jQuery
.isArray( elems
) ) ;
727 // Go through the array, translating each of the items to their
729 for ( ; i
< length
; i
++ ) {
730 value
= callback( elems
[ i
], i
, arg
);
732 if ( value
!= null ) {
733 ret
[ ret
.length
] = value
;
737 // Go through every key on the object,
739 for ( key
in elems
) {
740 value
= callback( elems
[ key
], key
, arg
);
742 if ( value
!= null ) {
743 ret
[ ret
.length
] = value
;
748 // Flatten any nested arrays
749 return ret
.concat
.apply( [], ret
);
752 // A global GUID counter for objects
755 // Bind a function to a context, optionally partially applying any
757 proxy: function( fn
, context
) {
758 var tmp
, args
, proxy
;
760 if ( typeof context
=== "string" ) {
766 // Quick check to determine if target is callable, in the spec
767 // this throws a TypeError, but we will just return undefined.
768 if ( !jQuery
.isFunction( fn
) ) {
773 args
= core_slice
.call( arguments
, 2 );
775 return fn
.apply( context
, args
.concat( core_slice
.call( arguments
) ) );
778 // Set the guid of unique handler to the same of original handler, so it can be removed
779 proxy
.guid
= fn
.guid
= fn
.guid
|| proxy
.guid
|| jQuery
.guid
++;
784 // Multifunctional method to get and set values of a collection
785 // The value/s can optionally be executed if it's a function
786 access: function( elems
, fn
, key
, value
, chainable
, emptyGet
, pass
) {
790 length
= elems
.length
;
793 if ( key
&& typeof key
=== "object" ) {
795 jQuery
.access( elems
, fn
, i
, key
[i
], 1, emptyGet
, value
);
800 } else if ( value
!== undefined ) {
801 // Optionally, function values get executed if exec is true
802 exec
= pass
=== undefined && jQuery
.isFunction( value
);
805 // Bulk operations only iterate when executing function values
808 fn = function( elem
, key
, value
) {
809 return exec
.call( jQuery( elem
), value
);
812 // Otherwise they run against the entire set
814 fn
.call( elems
, value
);
820 for (; i
< length
; i
++ ) {
821 fn( elems
[i
], key
, exec
? value
.call( elems
[i
], i
, fn( elems
[i
], key
) ) : value
, pass
);
834 length
? fn( elems
[0], key
) : emptyGet
;
838 return ( new Date() ).getTime();
842 jQuery
.ready
.promise = function( obj
) {
845 readyList
= jQuery
.Deferred();
847 // Catch cases where $(document).ready() is called after the browser event has already occurred.
848 // we once tried to use readyState "interactive" here, but it caused issues like the one
849 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
850 if ( document
.readyState
=== "complete" ) {
851 // Handle it asynchronously to allow scripts the opportunity to delay ready
852 setTimeout( jQuery
.ready
, 1 );
854 // Standards-based browsers support DOMContentLoaded
855 } else if ( document
.addEventListener
) {
856 // Use the handy event callback
857 document
.addEventListener( "DOMContentLoaded", DOMContentLoaded
, false );
859 // A fallback to window.onload, that will always work
860 window
.addEventListener( "load", jQuery
.ready
, false );
862 // If IE event model is used
864 // Ensure firing before onload, maybe late but safe also for iframes
865 document
.attachEvent( "onreadystatechange", DOMContentLoaded
);
867 // A fallback to window.onload, that will always work
868 window
.attachEvent( "onload", jQuery
.ready
);
870 // If IE and not a frame
871 // continually check to see if the document is ready
875 top
= window
.frameElement
== null && document
.documentElement
;
878 if ( top
&& top
.doScroll
) {
879 (function doScrollCheck() {
880 if ( !jQuery
.isReady
) {
883 // Use the trick by Diego Perini
884 // http://javascript.nwbox.com/IEContentLoaded/
885 top
.doScroll("left");
887 return setTimeout( doScrollCheck
, 50 );
890 // and execute any waiting functions
897 return readyList
.promise( obj
);
900 // Populate the class2type map
901 jQuery
.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i
, name
) {
902 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
905 // All jQuery objects should point back to these
906 rootjQuery
= jQuery(document
);
907 // String to Object options format cache
908 var optionsCache
= {};
910 // Convert String-formatted options into Object-formatted ones and store in cache
911 function createOptions( options
) {
912 var object
= optionsCache
[ options
] = {};
913 jQuery
.each( options
.split( core_rspace
), function( _
, flag
) {
914 object
[ flag
] = true;
920 * Create a callback list using the following parameters:
922 * options: an optional list of space-separated options that will change how
923 * the callback list behaves or a more traditional option object
925 * By default a callback list will act like an event callback list and can be
926 * "fired" multiple times.
930 * once: will ensure the callback list can only be fired once (like a Deferred)
932 * memory: will keep track of previous values and will call any callback added
933 * after the list has been fired right away with the latest "memorized"
934 * values (like a Deferred)
936 * unique: will ensure a callback can only be added once (no duplicate in the list)
938 * stopOnFalse: interrupt callings when a callback returns false
941 jQuery
.Callbacks = function( options
) {
943 // Convert options from String-formatted to Object-formatted if needed
944 // (we check in cache first)
945 options
= typeof options
=== "string" ?
946 ( optionsCache
[ options
] || createOptions( options
) ) :
947 jQuery
.extend( {}, options
);
949 var // Last fire value (for non-forgettable lists)
951 // Flag to know if list was already fired
953 // Flag to know if list is currently firing
955 // First callback to fire (used internally by add and fireWith)
957 // End of the loop when firing
959 // Index of currently firing callback (modified by remove if needed)
961 // Actual callback list
963 // Stack of fire calls for repeatable lists
964 stack
= !options
.once
&& [],
966 fire = function( data
) {
967 memory
= options
.memory
&& data
;
969 firingIndex
= firingStart
|| 0;
971 firingLength
= list
.length
;
973 for ( ; list
&& firingIndex
< firingLength
; firingIndex
++ ) {
974 if ( list
[ firingIndex
].apply( data
[ 0 ], data
[ 1 ] ) === false && options
.stopOnFalse
) {
975 memory
= false; // To prevent further calls using add
982 if ( stack
.length
) {
983 fire( stack
.shift() );
985 } else if ( memory
) {
992 // Actual Callbacks object
994 // Add a callback or a collection of callbacks to the list
997 // First, we save the current length
998 var start
= list
.length
;
999 (function add( args
) {
1000 jQuery
.each( args
, function( _
, arg
) {
1001 var type
= jQuery
.type( arg
);
1002 if ( type
=== "function" && ( !options
.unique
|| !self
.has( arg
) ) ) {
1004 } else if ( arg
&& arg
.length
&& type
!== "string" ) {
1005 // Inspect recursively
1010 // Do we need to add the callbacks to the
1011 // current firing batch?
1013 firingLength
= list
.length
;
1014 // With memory, if we're not firing then
1015 // we should call right away
1016 } else if ( memory
) {
1017 firingStart
= start
;
1023 // Remove a callback from the list
1024 remove: function() {
1026 jQuery
.each( arguments
, function( _
, arg
) {
1028 while( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
1029 list
.splice( index
, 1 );
1030 // Handle firing indexes
1032 if ( index
<= firingLength
) {
1035 if ( index
<= firingIndex
) {
1044 // Control if a given callback is in the list
1045 has: function( fn
) {
1046 return jQuery
.inArray( fn
, list
) > -1;
1048 // Remove all callbacks from the list
1053 // Have the list do nothing anymore
1054 disable: function() {
1055 list
= stack
= memory
= undefined;
1059 disabled: function() {
1062 // Lock the list in its current state
1071 locked: function() {
1074 // Call all callbacks with the given context and arguments
1075 fireWith: function( context
, args
) {
1077 args
= [ context
, args
.slice
? args
.slice() : args
];
1078 if ( list
&& ( !fired
|| stack
) ) {
1087 // Call all the callbacks with the given arguments
1089 self
.fireWith( this, arguments
);
1092 // To know if the callbacks have already been called at least once
1102 Deferred: function( func
) {
1104 // action, add listener, listener list, final state
1105 [ "resolve", "done", jQuery
.Callbacks("once memory"), "resolved" ],
1106 [ "reject", "fail", jQuery
.Callbacks("once memory"), "rejected" ],
1107 [ "notify", "progress", jQuery
.Callbacks("memory") ]
1114 always: function() {
1115 deferred
.done( arguments
).fail( arguments
);
1118 then: function( /* fnDone, fnFail, fnProgress */ ) {
1119 var fns
= arguments
;
1120 return jQuery
.Deferred(function( newDefer
) {
1121 jQuery
.each( tuples
, function( i
, tuple
) {
1122 var action
= tuple
[ 0 ],
1124 // deferred[ done | fail | progress ] for forwarding actions to newDefer
1125 deferred
[ tuple
[1] ]( jQuery
.isFunction( fn
) ?
1127 var returned
= fn
.apply( this, arguments
);
1128 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
1130 .done( newDefer
.resolve
)
1131 .fail( newDefer
.reject
)
1132 .progress( newDefer
.notify
);
1134 newDefer
[ action
+ "With" ]( this === deferred
? newDefer
: this, [ returned
] );
1143 // Get a promise for this deferred
1144 // If obj is provided, the promise aspect is added to the object
1145 promise: function( obj
) {
1146 return typeof obj
=== "object" ? jQuery
.extend( obj
, promise
) : promise
;
1151 // Keep pipe for back-compat
1152 promise
.pipe
= promise
.then
;
1154 // Add list-specific methods
1155 jQuery
.each( tuples
, function( i
, tuple
) {
1156 var list
= tuple
[ 2 ],
1157 stateString
= tuple
[ 3 ];
1159 // promise[ done | fail | progress ] = list.add
1160 promise
[ tuple
[1] ] = list
.add
;
1163 if ( stateString
) {
1164 list
.add(function() {
1165 // state = [ resolved | rejected ]
1166 state
= stateString
;
1168 // [ reject_list | resolve_list ].disable; progress_list.lock
1169 }, tuples
[ i
^ 1 ][ 2 ].disable
, tuples
[ 2 ][ 2 ].lock
);
1172 // deferred[ resolve | reject | notify ] = list.fire
1173 deferred
[ tuple
[0] ] = list
.fire
;
1174 deferred
[ tuple
[0] + "With" ] = list
.fireWith
;
1177 // Make the deferred a promise
1178 promise
.promise( deferred
);
1180 // Call given func if any
1182 func
.call( deferred
, deferred
);
1190 when: function( subordinate
/* , ..., subordinateN */ ) {
1192 resolveValues
= core_slice
.call( arguments
),
1193 length
= resolveValues
.length
,
1195 // the count of uncompleted subordinates
1196 remaining
= length
!== 1 || ( subordinate
&& jQuery
.isFunction( subordinate
.promise
) ) ? length
: 0,
1198 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1199 deferred
= remaining
=== 1 ? subordinate
: jQuery
.Deferred(),
1201 // Update function for both resolve and progress values
1202 updateFunc = function( i
, contexts
, values
) {
1203 return function( value
) {
1204 contexts
[ i
] = this;
1205 values
[ i
] = arguments
.length
> 1 ? core_slice
.call( arguments
) : value
;
1206 if( values
=== progressValues
) {
1207 deferred
.notifyWith( contexts
, values
);
1208 } else if ( !( --remaining
) ) {
1209 deferred
.resolveWith( contexts
, values
);
1214 progressValues
, progressContexts
, resolveContexts
;
1216 // add listeners to Deferred subordinates; treat others as resolved
1218 progressValues
= new Array( length
);
1219 progressContexts
= new Array( length
);
1220 resolveContexts
= new Array( length
);
1221 for ( ; i
< length
; i
++ ) {
1222 if ( resolveValues
[ i
] && jQuery
.isFunction( resolveValues
[ i
].promise
) ) {
1223 resolveValues
[ i
].promise()
1224 .done( updateFunc( i
, resolveContexts
, resolveValues
) )
1225 .fail( deferred
.reject
)
1226 .progress( updateFunc( i
, progressContexts
, progressValues
) );
1233 // if we're not waiting on anything, resolve the master
1235 deferred
.resolveWith( resolveContexts
, resolveValues
);
1238 return deferred
.promise();
1241 jQuery
.support
= (function() {
1254 div
= document
.createElement("div");
1256 // Preliminary tests
1257 div
.setAttribute( "className", "t" );
1258 div
.innerHTML
= " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1260 all
= div
.getElementsByTagName("*");
1261 a
= div
.getElementsByTagName("a")[ 0 ];
1262 a
.style
.cssText
= "top:1px;float:left;opacity:.5";
1264 // Can't get basic test support
1265 if ( !all
|| !all
.length
|| !a
) {
1269 // First batch of supports tests
1270 select
= document
.createElement("select");
1271 opt
= select
.appendChild( document
.createElement("option") );
1272 input
= div
.getElementsByTagName("input")[ 0 ];
1275 // IE strips leading whitespace when .innerHTML is used
1276 leadingWhitespace
: ( div
.firstChild
.nodeType
=== 3 ),
1278 // Make sure that tbody elements aren't automatically inserted
1279 // IE will insert them into empty tables
1280 tbody
: !div
.getElementsByTagName("tbody").length
,
1282 // Make sure that link elements get serialized correctly by innerHTML
1283 // This requires a wrapper element in IE
1284 htmlSerialize
: !!div
.getElementsByTagName("link").length
,
1286 // Get the style information from getAttribute
1287 // (IE uses .cssText instead)
1288 style
: /top/.test( a
.getAttribute("style") ),
1290 // Make sure that URLs aren't manipulated
1291 // (IE normalizes it by default)
1292 hrefNormalized
: ( a
.getAttribute("href") === "/a" ),
1294 // Make sure that element opacity exists
1295 // (IE uses filter instead)
1296 // Use a regex to work around a WebKit issue. See #5145
1297 opacity
: /^0.5/.test( a
.style
.opacity
),
1299 // Verify style float existence
1300 // (IE uses styleFloat instead of cssFloat)
1301 cssFloat
: !!a
.style
.cssFloat
,
1303 // Make sure that if no value is specified for a checkbox
1304 // that it defaults to "on".
1305 // (WebKit defaults to "" instead)
1306 checkOn
: ( input
.value
=== "on" ),
1308 // Make sure that a selected-by-default option has a working selected property.
1309 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1310 optSelected
: opt
.selected
,
1312 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1313 getSetAttribute
: div
.className
!== "t",
1315 // Tests for enctype support on a form(#6743)
1316 enctype
: !!document
.createElement("form").enctype
,
1318 // Makes sure cloning an html5 element does not cause problems
1319 // Where outerHTML is undefined, this still works
1320 html5Clone
: document
.createElement("nav").cloneNode( true ).outerHTML
!== "<:nav></:nav>",
1322 // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1323 boxModel
: ( document
.compatMode
=== "CSS1Compat" ),
1325 // Will be defined later
1326 submitBubbles
: true,
1327 changeBubbles
: true,
1328 focusinBubbles
: false,
1329 deleteExpando
: true,
1331 inlineBlockNeedsLayout
: false,
1332 shrinkWrapBlocks
: false,
1333 reliableMarginRight
: true,
1334 boxSizingReliable
: true,
1335 pixelPosition
: false
1338 // Make sure checked status is properly cloned
1339 input
.checked
= true;
1340 support
.noCloneChecked
= input
.cloneNode( true ).checked
;
1342 // Make sure that the options inside disabled selects aren't marked as disabled
1343 // (WebKit marks them as disabled)
1344 select
.disabled
= true;
1345 support
.optDisabled
= !opt
.disabled
;
1347 // Test to see if it's possible to delete an expando from an element
1348 // Fails in Internet Explorer
1352 support
.deleteExpando
= false;
1355 if ( !div
.addEventListener
&& div
.attachEvent
&& div
.fireEvent
) {
1356 div
.attachEvent( "onclick", clickFn = function() {
1357 // Cloning a node shouldn't copy over any
1358 // bound event handlers (IE does this)
1359 support
.noCloneEvent
= false;
1361 div
.cloneNode( true ).fireEvent("onclick");
1362 div
.detachEvent( "onclick", clickFn
);
1365 // Check if a radio maintains its value
1366 // after being appended to the DOM
1367 input
= document
.createElement("input");
1369 input
.setAttribute( "type", "radio" );
1370 support
.radioValue
= input
.value
=== "t";
1372 input
.setAttribute( "checked", "checked" );
1374 // #11217 - WebKit loses check when the name is after the checked attribute
1375 input
.setAttribute( "name", "t" );
1377 div
.appendChild( input
);
1378 fragment
= document
.createDocumentFragment();
1379 fragment
.appendChild( div
.lastChild
);
1381 // WebKit doesn't clone checked state correctly in fragments
1382 support
.checkClone
= fragment
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
1384 // Check if a disconnected checkbox will retain its checked
1385 // value of true after appended to the DOM (IE6/7)
1386 support
.appendChecked
= input
.checked
;
1388 fragment
.removeChild( input
);
1389 fragment
.appendChild( div
);
1391 // Technique from Juriy Zaytsev
1392 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1393 // We only care about the case where non-standard event systems
1394 // are used, namely in IE. Short-circuiting here helps us to
1395 // avoid an eval call (in setAttribute) which can cause CSP
1396 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1397 if ( div
.attachEvent
) {
1403 eventName
= "on" + i
;
1404 isSupported
= ( eventName
in div
);
1405 if ( !isSupported
) {
1406 div
.setAttribute( eventName
, "return;" );
1407 isSupported
= ( typeof div
[ eventName
] === "function" );
1409 support
[ i
+ "Bubbles" ] = isSupported
;
1413 // Run tests that need a body at doc ready
1415 var container
, div
, tds
, marginDiv
,
1416 divReset
= "padding:0;margin:0;border:0;display:block;overflow:hidden;",
1417 body
= document
.getElementsByTagName("body")[0];
1420 // Return for frameset docs that don't have a body
1424 container
= document
.createElement("div");
1425 container
.style
.cssText
= "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
1426 body
.insertBefore( container
, body
.firstChild
);
1428 // Construct the test element
1429 div
= document
.createElement("div");
1430 container
.appendChild( div
);
1432 // Check if table cells still have offsetWidth/Height when they are set
1433 // to display:none and there are still other visible table cells in a
1434 // table row; if so, offsetWidth/Height are not reliable for use when
1435 // determining if an element has been hidden directly using
1436 // display:none (it is still safe to use offsets if a parent element is
1437 // hidden; don safety goggles and see bug #4512 for more information).
1438 // (only IE 8 fails this test)
1439 div
.innerHTML
= "<table><tr><td></td><td>t</td></tr></table>";
1440 tds
= div
.getElementsByTagName("td");
1441 tds
[ 0 ].style
.cssText
= "padding:0;margin:0;border:0;display:none";
1442 isSupported
= ( tds
[ 0 ].offsetHeight
=== 0 );
1444 tds
[ 0 ].style
.display
= "";
1445 tds
[ 1 ].style
.display
= "none";
1447 // Check if empty table cells still have offsetWidth/Height
1448 // (IE <= 8 fail this test)
1449 support
.reliableHiddenOffsets
= isSupported
&& ( tds
[ 0 ].offsetHeight
=== 0 );
1451 // Check box-sizing and margin behavior
1453 div
.style
.cssText
= "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
1454 support
.boxSizing
= ( div
.offsetWidth
=== 4 );
1455 support
.doesNotIncludeMarginInBodyOffset
= ( body
.offsetTop
!== 1 );
1457 // NOTE: To any future maintainer, we've window.getComputedStyle
1458 // because jsdom on node.js will break without it.
1459 if ( window
.getComputedStyle
) {
1460 support
.pixelPosition
= ( window
.getComputedStyle( div
, null ) || {} ).top
!== "1%";
1461 support
.boxSizingReliable
= ( window
.getComputedStyle( div
, null ) || { width
: "4px" } ).width
=== "4px";
1463 // Check if div with explicit width and no margin-right incorrectly
1464 // gets computed margin-right based on width of container. For more
1465 // info see bug #3333
1466 // Fails in WebKit before Feb 2011 nightlies
1467 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1468 marginDiv
= document
.createElement("div");
1469 marginDiv
.style
.cssText
= div
.style
.cssText
= divReset
;
1470 marginDiv
.style
.marginRight
= marginDiv
.style
.width
= "0";
1471 div
.style
.width
= "1px";
1472 div
.appendChild( marginDiv
);
1473 support
.reliableMarginRight
=
1474 !parseFloat( ( window
.getComputedStyle( marginDiv
, null ) || {} ).marginRight
);
1477 if ( typeof div
.style
.zoom
!== "undefined" ) {
1478 // Check if natively block-level elements act like inline-block
1479 // elements when setting their display to 'inline' and giving
1481 // (IE < 8 does this)
1483 div
.style
.cssText
= divReset
+ "width:1px;padding:1px;display:inline;zoom:1";
1484 support
.inlineBlockNeedsLayout
= ( div
.offsetWidth
=== 3 );
1486 // Check if elements with layout shrink-wrap their children
1488 div
.style
.display
= "block";
1489 div
.style
.overflow
= "visible";
1490 div
.innerHTML
= "<div></div>";
1491 div
.firstChild
.style
.width
= "5px";
1492 support
.shrinkWrapBlocks
= ( div
.offsetWidth
!== 3 );
1494 container
.style
.zoom
= 1;
1497 // Null elements to avoid leaks in IE
1498 body
.removeChild( container
);
1499 container
= div
= tds
= marginDiv
= null;
1502 // Null elements to avoid leaks in IE
1503 fragment
.removeChild( div
);
1504 all
= a
= select
= opt
= input
= fragment
= div
= null;
1508 var rbrace
= /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
1509 rmultiDash
= /([A-Z])/g;
1516 // Please use with caution
1519 // Unique for each copy of jQuery on the page
1520 // Non-digits removed to match rinlinejQuery
1521 expando
: "jQuery" + ( jQuery
.fn
.jquery
+ Math
.random() ).replace( /\D/g, "" ),
1523 // The following elements throw uncatchable exceptions if you
1524 // attempt to add expando properties to them.
1527 // Ban all objects except for Flash (which handle expandos)
1528 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1532 hasData: function( elem
) {
1533 elem
= elem
.nodeType
? jQuery
.cache
[ elem
[jQuery
.expando
] ] : elem
[ jQuery
.expando
];
1534 return !!elem
&& !isEmptyDataObject( elem
);
1537 data: function( elem
, name
, data
, pvt
/* Internal Use Only */ ) {
1538 if ( !jQuery
.acceptData( elem
) ) {
1543 internalKey
= jQuery
.expando
,
1544 getByName
= typeof name
=== "string",
1546 // We have to handle DOM nodes and JS objects differently because IE6-7
1547 // can't GC object references properly across the DOM-JS boundary
1548 isNode
= elem
.nodeType
,
1550 // Only DOM nodes need the global jQuery cache; JS object data is
1551 // attached directly to the object so GC can occur automatically
1552 cache
= isNode
? jQuery
.cache
: elem
,
1554 // Only defining an ID for JS objects if its cache already exists allows
1555 // the code to shortcut on the same path as a DOM node with no cache
1556 id
= isNode
? elem
[ internalKey
] : elem
[ internalKey
] && internalKey
;
1558 // Avoid doing any more work than we need to when trying to get data on an
1559 // object that has no data at all
1560 if ( (!id
|| !cache
[id
] || (!pvt
&& !cache
[id
].data
)) && getByName
&& data
=== undefined ) {
1565 // Only DOM nodes need a new unique ID for each element since their data
1566 // ends up in the global cache
1568 elem
[ internalKey
] = id
= jQuery
.deletedIds
.pop() || ++jQuery
.uuid
;
1574 if ( !cache
[ id
] ) {
1577 // Avoids exposing jQuery metadata on plain JS objects when the object
1578 // is serialized using JSON.stringify
1580 cache
[ id
].toJSON
= jQuery
.noop
;
1584 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1585 // shallow copied over onto the existing cache
1586 if ( typeof name
=== "object" || typeof name
=== "function" ) {
1588 cache
[ id
] = jQuery
.extend( cache
[ id
], name
);
1590 cache
[ id
].data
= jQuery
.extend( cache
[ id
].data
, name
);
1594 thisCache
= cache
[ id
];
1596 // jQuery data() is stored in a separate object inside the object's internal data
1597 // cache in order to avoid key collisions between internal data and user-defined
1600 if ( !thisCache
.data
) {
1601 thisCache
.data
= {};
1604 thisCache
= thisCache
.data
;
1607 if ( data
!== undefined ) {
1608 thisCache
[ jQuery
.camelCase( name
) ] = data
;
1611 // Check for both converted-to-camel and non-converted data property names
1612 // If a data property was specified
1615 // First Try to find as-is property data
1616 ret
= thisCache
[ name
];
1618 // Test for null|undefined property data
1619 if ( ret
== null ) {
1621 // Try to find the camelCased property
1622 ret
= thisCache
[ jQuery
.camelCase( name
) ];
1631 removeData: function( elem
, name
, pvt
/* Internal Use Only */ ) {
1632 if ( !jQuery
.acceptData( elem
) ) {
1636 var thisCache
, i
, l
,
1638 isNode
= elem
.nodeType
,
1640 // See jQuery.data for more information
1641 cache
= isNode
? jQuery
.cache
: elem
,
1642 id
= isNode
? elem
[ jQuery
.expando
] : jQuery
.expando
;
1644 // If there is already no cache entry for this object, there is no
1645 // purpose in continuing
1646 if ( !cache
[ id
] ) {
1652 thisCache
= pvt
? cache
[ id
] : cache
[ id
].data
;
1656 // Support array or space separated string names for data keys
1657 if ( !jQuery
.isArray( name
) ) {
1659 // try the string as a key before any manipulation
1660 if ( name
in thisCache
) {
1664 // split the camel cased version by spaces unless a key with the spaces exists
1665 name
= jQuery
.camelCase( name
);
1666 if ( name
in thisCache
) {
1669 name
= name
.split(" ");
1674 for ( i
= 0, l
= name
.length
; i
< l
; i
++ ) {
1675 delete thisCache
[ name
[i
] ];
1678 // If there is no data left in the cache, we want to continue
1679 // and let the cache object itself get destroyed
1680 if ( !( pvt
? isEmptyDataObject
: jQuery
.isEmptyObject
)( thisCache
) ) {
1686 // See jQuery.data for more information
1688 delete cache
[ id
].data
;
1690 // Don't destroy the parent cache unless the internal data object
1691 // had been the only thing left in it
1692 if ( !isEmptyDataObject( cache
[ id
] ) ) {
1697 // Destroy the cache
1699 jQuery
.cleanData( [ elem
], true );
1701 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
1702 } else if ( jQuery
.support
.deleteExpando
|| cache
!= cache
.window
) {
1705 // When all else fails, null
1711 // For internal use only.
1712 _data: function( elem
, name
, data
) {
1713 return jQuery
.data( elem
, name
, data
, true );
1716 // A method for determining if a DOM node can handle the data expando
1717 acceptData: function( elem
) {
1718 var noData
= elem
.nodeName
&& jQuery
.noData
[ elem
.nodeName
.toLowerCase() ];
1720 // nodes accept data unless otherwise specified; rejection can be conditional
1721 return !noData
|| noData
!== true && elem
.getAttribute("classid") === noData
;
1726 data: function( key
, value
) {
1727 var parts
, part
, attr
, name
, l
,
1733 if ( key
=== undefined ) {
1734 if ( this.length
) {
1735 data
= jQuery
.data( elem
);
1737 if ( elem
.nodeType
=== 1 && !jQuery
._data( elem
, "parsedAttrs" ) ) {
1738 attr
= elem
.attributes
;
1739 for ( l
= attr
.length
; i
< l
; i
++ ) {
1740 name
= attr
[i
].name
;
1742 if ( name
.indexOf( "data-" ) === 0 ) {
1743 name
= jQuery
.camelCase( name
.substring(5) );
1745 dataAttr( elem
, name
, data
[ name
] );
1748 jQuery
._data( elem
, "parsedAttrs", true );
1755 // Sets multiple values
1756 if ( typeof key
=== "object" ) {
1757 return this.each(function() {
1758 jQuery
.data( this, key
);
1762 parts
= key
.split( ".", 2 );
1763 parts
[1] = parts
[1] ? "." + parts
[1] : "";
1764 part
= parts
[1] + "!";
1766 return jQuery
.access( this, function( value
) {
1768 if ( value
=== undefined ) {
1769 data
= this.triggerHandler( "getData" + part
, [ parts
[0] ] );
1771 // Try to fetch any internally stored data first
1772 if ( data
=== undefined && elem
) {
1773 data
= jQuery
.data( elem
, key
);
1774 data
= dataAttr( elem
, key
, data
);
1777 return data
=== undefined && parts
[1] ?
1778 this.data( parts
[0] ) :
1783 this.each(function() {
1784 var self
= jQuery( this );
1786 self
.triggerHandler( "setData" + part
, parts
);
1787 jQuery
.data( this, key
, value
);
1788 self
.triggerHandler( "changeData" + part
, parts
);
1790 }, null, value
, arguments
.length
> 1, null, false );
1793 removeData: function( key
) {
1794 return this.each(function() {
1795 jQuery
.removeData( this, key
);
1800 function dataAttr( elem
, key
, data
) {
1801 // If nothing was found internally, try to fetch any
1802 // data from the HTML5 data-* attribute
1803 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
1805 var name
= "data-" + key
.replace( rmultiDash
, "-$1" ).toLowerCase();
1807 data
= elem
.getAttribute( name
);
1809 if ( typeof data
=== "string" ) {
1811 data
= data
=== "true" ? true :
1812 data
=== "false" ? false :
1813 data
=== "null" ? null :
1814 // Only convert to a number if it doesn't change the string
1815 +data
+ "" === data
? +data
:
1816 rbrace
.test( data
) ? jQuery
.parseJSON( data
) :
1820 // Make sure we set the data so it isn't changed later
1821 jQuery
.data( elem
, key
, data
);
1831 // checks a cache object for emptiness
1832 function isEmptyDataObject( obj
) {
1834 for ( name
in obj
) {
1836 // if the public data object is empty, the private is still empty
1837 if ( name
=== "data" && jQuery
.isEmptyObject( obj
[name
] ) ) {
1840 if ( name
!== "toJSON" ) {
1848 queue: function( elem
, type
, data
) {
1852 type
= ( type
|| "fx" ) + "queue";
1853 queue
= jQuery
._data( elem
, type
);
1855 // Speed up dequeue by getting out quickly if this is just a lookup
1857 if ( !queue
|| jQuery
.isArray(data
) ) {
1858 queue
= jQuery
._data( elem
, type
, jQuery
.makeArray(data
) );
1867 dequeue: function( elem
, type
) {
1868 type
= type
|| "fx";
1870 var queue
= jQuery
.queue( elem
, type
),
1871 startLength
= queue
.length
,
1873 hooks
= jQuery
._queueHooks( elem
, type
),
1875 jQuery
.dequeue( elem
, type
);
1878 // If the fx queue is dequeued, always remove the progress sentinel
1879 if ( fn
=== "inprogress" ) {
1886 // Add a progress sentinel to prevent the fx queue from being
1887 // automatically dequeued
1888 if ( type
=== "fx" ) {
1889 queue
.unshift( "inprogress" );
1892 // clear up the last queue stop function
1894 fn
.call( elem
, next
, hooks
);
1897 if ( !startLength
&& hooks
) {
1902 // not intended for public consumption - generates a queueHooks object, or returns the current one
1903 _queueHooks: function( elem
, type
) {
1904 var key
= type
+ "queueHooks";
1905 return jQuery
._data( elem
, key
) || jQuery
._data( elem
, key
, {
1906 empty
: jQuery
.Callbacks("once memory").add(function() {
1907 jQuery
.removeData( elem
, type
+ "queue", true );
1908 jQuery
.removeData( elem
, key
, true );
1915 queue: function( type
, data
) {
1918 if ( typeof type
!== "string" ) {
1924 if ( arguments
.length
< setter
) {
1925 return jQuery
.queue( this[0], type
);
1928 return data
=== undefined ?
1930 this.each(function() {
1931 var queue
= jQuery
.queue( this, type
, data
);
1933 // ensure a hooks for this queue
1934 jQuery
._queueHooks( this, type
);
1936 if ( type
=== "fx" && queue
[0] !== "inprogress" ) {
1937 jQuery
.dequeue( this, type
);
1941 dequeue: function( type
) {
1942 return this.each(function() {
1943 jQuery
.dequeue( this, type
);
1946 // Based off of the plugin by Clint Helfers, with permission.
1947 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1948 delay: function( time
, type
) {
1949 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time
: time
;
1950 type
= type
|| "fx";
1952 return this.queue( type
, function( next
, hooks
) {
1953 var timeout
= setTimeout( next
, time
);
1954 hooks
.stop = function() {
1955 clearTimeout( timeout
);
1959 clearQueue: function( type
) {
1960 return this.queue( type
|| "fx", [] );
1962 // Get a promise resolved when queues of a certain type
1963 // are emptied (fx is the type by default)
1964 promise: function( type
, obj
) {
1967 defer
= jQuery
.Deferred(),
1970 resolve = function() {
1971 if ( !( --count
) ) {
1972 defer
.resolveWith( elements
, [ elements
] );
1976 if ( typeof type
!== "string" ) {
1980 type
= type
|| "fx";
1983 tmp
= jQuery
._data( elements
[ i
], type
+ "queueHooks" );
1984 if ( tmp
&& tmp
.empty
) {
1986 tmp
.empty
.add( resolve
);
1990 return defer
.promise( obj
);
1993 var nodeHook
, boolHook
, fixSpecified
,
1994 rclass
= /[\t\r\n]/g,
1996 rtype
= /^(?:button|input)$/i,
1997 rfocusable
= /^(?:button|input|object|select|textarea)$/i,
1998 rclickable
= /^a(?:rea|)$/i,
1999 rboolean
= /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2000 getSetAttribute
= jQuery
.support
.getSetAttribute
;
2003 attr: function( name
, value
) {
2004 return jQuery
.access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
2007 removeAttr: function( name
) {
2008 return this.each(function() {
2009 jQuery
.removeAttr( this, name
);
2013 prop: function( name
, value
) {
2014 return jQuery
.access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
2017 removeProp: function( name
) {
2018 name
= jQuery
.propFix
[ name
] || name
;
2019 return this.each(function() {
2020 // try/catch handles cases where IE balks (such as removing a property on window)
2022 this[ name
] = undefined;
2023 delete this[ name
];
2028 addClass: function( value
) {
2029 var classNames
, i
, l
, elem
,
2032 if ( jQuery
.isFunction( value
) ) {
2033 return this.each(function( j
) {
2034 jQuery( this ).addClass( value
.call(this, j
, this.className
) );
2038 if ( value
&& typeof value
=== "string" ) {
2039 classNames
= value
.split( core_rspace
);
2041 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
2044 if ( elem
.nodeType
=== 1 ) {
2045 if ( !elem
.className
&& classNames
.length
=== 1 ) {
2046 elem
.className
= value
;
2049 setClass
= " " + elem
.className
+ " ";
2051 for ( c
= 0, cl
= classNames
.length
; c
< cl
; c
++ ) {
2052 if ( !~setClass
.indexOf( " " + classNames
[ c
] + " " ) ) {
2053 setClass
+= classNames
[ c
] + " ";
2056 elem
.className
= jQuery
.trim( setClass
);
2065 removeClass: function( value
) {
2066 var removes
, className
, elem
, c
, cl
, i
, l
;
2068 if ( jQuery
.isFunction( value
) ) {
2069 return this.each(function( j
) {
2070 jQuery( this ).removeClass( value
.call(this, j
, this.className
) );
2073 if ( (value
&& typeof value
=== "string") || value
=== undefined ) {
2074 removes
= ( value
|| "" ).split( core_rspace
);
2076 for ( i
= 0, l
= this.length
; i
< l
; i
++ ) {
2078 if ( elem
.nodeType
=== 1 && elem
.className
) {
2080 className
= (" " + elem
.className
+ " ").replace( rclass
, " " );
2082 // loop over each item in the removal list
2083 for ( c
= 0, cl
= removes
.length
; c
< cl
; c
++ ) {
2084 // Remove until there is nothing to remove,
2085 while ( className
.indexOf(" " + removes
[ c
] + " ") > -1 ) {
2086 className
= className
.replace( " " + removes
[ c
] + " " , " " );
2089 elem
.className
= value
? jQuery
.trim( className
) : "";
2097 toggleClass: function( value
, stateVal
) {
2098 var type
= typeof value
,
2099 isBool
= typeof stateVal
=== "boolean";
2101 if ( jQuery
.isFunction( value
) ) {
2102 return this.each(function( i
) {
2103 jQuery( this ).toggleClass( value
.call(this, i
, this.className
, stateVal
), stateVal
);
2107 return this.each(function() {
2108 if ( type
=== "string" ) {
2109 // toggle individual class names
2112 self
= jQuery( this ),
2114 classNames
= value
.split( core_rspace
);
2116 while ( (className
= classNames
[ i
++ ]) ) {
2117 // check each className given, space separated list
2118 state
= isBool
? state
: !self
.hasClass( className
);
2119 self
[ state
? "addClass" : "removeClass" ]( className
);
2122 } else if ( type
=== "undefined" || type
=== "boolean" ) {
2123 if ( this.className
) {
2124 // store className if set
2125 jQuery
._data( this, "__className__", this.className
);
2128 // toggle whole className
2129 this.className
= this.className
|| value
=== false ? "" : jQuery
._data( this, "__className__" ) || "";
2134 hasClass: function( selector
) {
2135 var className
= " " + selector
+ " ",
2138 for ( ; i
< l
; i
++ ) {
2139 if ( this[i
].nodeType
=== 1 && (" " + this[i
].className
+ " ").replace(rclass
, " ").indexOf( className
) > -1 ) {
2147 val: function( value
) {
2148 var hooks
, ret
, isFunction
,
2151 if ( !arguments
.length
) {
2153 hooks
= jQuery
.valHooks
[ elem
.type
] || jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
2155 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, "value" )) !== undefined ) {
2161 return typeof ret
=== "string" ?
2162 // handle most common string cases
2163 ret
.replace(rreturn
, "") :
2164 // handle cases where value is null/undef or number
2165 ret
== null ? "" : ret
;
2171 isFunction
= jQuery
.isFunction( value
);
2173 return this.each(function( i
) {
2175 self
= jQuery(this);
2177 if ( this.nodeType
!== 1 ) {
2182 val
= value
.call( this, i
, self
.val() );
2187 // Treat null/undefined as ""; convert numbers to string
2188 if ( val
== null ) {
2190 } else if ( typeof val
=== "number" ) {
2192 } else if ( jQuery
.isArray( val
) ) {
2193 val
= jQuery
.map(val
, function ( value
) {
2194 return value
== null ? "" : value
+ "";
2198 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
2200 // If set returns undefined, fall back to normal setting
2201 if ( !hooks
|| !("set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
2211 get: function( elem
) {
2212 // attributes.value is undefined in Blackberry 4.7 but
2213 // uses .value. See #6932
2214 var val
= elem
.attributes
.value
;
2215 return !val
|| val
.specified
? elem
.value
: elem
.text
;
2219 get: function( elem
) {
2220 var value
, i
, max
, option
,
2221 index
= elem
.selectedIndex
,
2223 options
= elem
.options
,
2224 one
= elem
.type
=== "select-one";
2226 // Nothing was selected
2231 // Loop through all the selected options
2232 i
= one
? index
: 0;
2233 max
= one
? index
+ 1 : options
.length
;
2234 for ( ; i
< max
; i
++ ) {
2235 option
= options
[ i
];
2237 // Don't return options that are disabled or in a disabled optgroup
2238 if ( option
.selected
&& (jQuery
.support
.optDisabled
? !option
.disabled
: option
.getAttribute("disabled") === null) &&
2239 (!option
.parentNode
.disabled
|| !jQuery
.nodeName( option
.parentNode
, "optgroup" )) ) {
2241 // Get the specific value for the option
2242 value
= jQuery( option
).val();
2244 // We don't need an array for one selects
2249 // Multi-Selects return an array
2250 values
.push( value
);
2254 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2255 if ( one
&& !values
.length
&& options
.length
) {
2256 return jQuery( options
[ index
] ).val();
2262 set: function( elem
, value
) {
2263 var values
= jQuery
.makeArray( value
);
2265 jQuery(elem
).find("option").each(function() {
2266 this.selected
= jQuery
.inArray( jQuery(this).val(), values
) >= 0;
2269 if ( !values
.length
) {
2270 elem
.selectedIndex
= -1;
2277 // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
2280 attr: function( elem
, name
, value
, pass
) {
2281 var ret
, hooks
, notxml
,
2282 nType
= elem
.nodeType
;
2284 // don't get/set attributes on text, comment and attribute nodes
2285 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
2289 if ( pass
&& jQuery
.isFunction( jQuery
.fn
[ name
] ) ) {
2290 return jQuery( elem
)[ name
]( value
);
2293 // Fallback to prop when attributes are not supported
2294 if ( typeof elem
.getAttribute
=== "undefined" ) {
2295 return jQuery
.prop( elem
, name
, value
);
2298 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
2300 // All attributes are lowercase
2301 // Grab necessary hook if one is defined
2303 name
= name
.toLowerCase();
2304 hooks
= jQuery
.attrHooks
[ name
] || ( rboolean
.test( name
) ? boolHook
: nodeHook
);
2307 if ( value
!== undefined ) {
2309 if ( value
=== null ) {
2310 jQuery
.removeAttr( elem
, name
);
2313 } else if ( hooks
&& "set" in hooks
&& notxml
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
2317 elem
.setAttribute( name
, "" + value
);
2321 } else if ( hooks
&& "get" in hooks
&& notxml
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
2326 ret
= elem
.getAttribute( name
);
2328 // Non-existent attributes return null, we normalize to undefined
2329 return ret
=== null ?
2335 removeAttr: function( elem
, value
) {
2336 var propName
, attrNames
, name
, isBool
,
2339 if ( value
&& elem
.nodeType
=== 1 ) {
2341 attrNames
= value
.split( core_rspace
);
2343 for ( ; i
< attrNames
.length
; i
++ ) {
2344 name
= attrNames
[ i
];
2347 propName
= jQuery
.propFix
[ name
] || name
;
2348 isBool
= rboolean
.test( name
);
2350 // See #9699 for explanation of this approach (setting first, then removal)
2351 // Do not do this for boolean attributes (see #10870)
2353 jQuery
.attr( elem
, name
, "" );
2355 elem
.removeAttribute( getSetAttribute
? name
: propName
);
2357 // Set corresponding property to false for boolean attributes
2358 if ( isBool
&& propName
in elem
) {
2359 elem
[ propName
] = false;
2368 set: function( elem
, value
) {
2369 // We can't allow the type property to be changed (since it causes problems in IE)
2370 if ( rtype
.test( elem
.nodeName
) && elem
.parentNode
) {
2371 jQuery
.error( "type property can't be changed" );
2372 } else if ( !jQuery
.support
.radioValue
&& value
=== "radio" && jQuery
.nodeName(elem
, "input") ) {
2373 // Setting the type on a radio button after the value resets the value in IE6-9
2374 // Reset value to it's default in case type is set after value
2375 // This is for element creation
2376 var val
= elem
.value
;
2377 elem
.setAttribute( "type", value
);
2385 // Use the value property for back compat
2386 // Use the nodeHook for button elements in IE6/7 (#1954)
2388 get: function( elem
, name
) {
2389 if ( nodeHook
&& jQuery
.nodeName( elem
, "button" ) ) {
2390 return nodeHook
.get( elem
, name
);
2392 return name
in elem
?
2396 set: function( elem
, value
, name
) {
2397 if ( nodeHook
&& jQuery
.nodeName( elem
, "button" ) ) {
2398 return nodeHook
.set( elem
, value
, name
);
2400 // Does not return so that setAttribute is also used
2407 tabindex
: "tabIndex",
2408 readonly
: "readOnly",
2410 "class": "className",
2411 maxlength
: "maxLength",
2412 cellspacing
: "cellSpacing",
2413 cellpadding
: "cellPadding",
2417 frameborder
: "frameBorder",
2418 contenteditable
: "contentEditable"
2421 prop: function( elem
, name
, value
) {
2422 var ret
, hooks
, notxml
,
2423 nType
= elem
.nodeType
;
2425 // don't get/set properties on text, comment and attribute nodes
2426 if ( !elem
|| nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
2430 notxml
= nType
!== 1 || !jQuery
.isXMLDoc( elem
);
2433 // Fix name and attach hooks
2434 name
= jQuery
.propFix
[ name
] || name
;
2435 hooks
= jQuery
.propHooks
[ name
];
2438 if ( value
!== undefined ) {
2439 if ( hooks
&& "set" in hooks
&& (ret
= hooks
.set( elem
, value
, name
)) !== undefined ) {
2443 return ( elem
[ name
] = value
);
2447 if ( hooks
&& "get" in hooks
&& (ret
= hooks
.get( elem
, name
)) !== null ) {
2451 return elem
[ name
];
2458 get: function( elem
) {
2459 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2460 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2461 var attributeNode
= elem
.getAttributeNode("tabindex");
2463 return attributeNode
&& attributeNode
.specified
?
2464 parseInt( attributeNode
.value
, 10 ) :
2465 rfocusable
.test( elem
.nodeName
) || rclickable
.test( elem
.nodeName
) && elem
.href
?
2473 // Hook for boolean attributes
2475 get: function( elem
, name
) {
2476 // Align boolean attributes with corresponding properties
2477 // Fall back to attribute presence where some booleans are not supported
2479 property
= jQuery
.prop( elem
, name
);
2480 return property
=== true || typeof property
!== "boolean" && ( attrNode
= elem
.getAttributeNode(name
) ) && attrNode
.nodeValue
!== false ?
2481 name
.toLowerCase() :
2484 set: function( elem
, value
, name
) {
2486 if ( value
=== false ) {
2487 // Remove boolean attributes when set to false
2488 jQuery
.removeAttr( elem
, name
);
2490 // value is true since we know at this point it's type boolean and not false
2491 // Set boolean attributes to the same name and set the DOM property
2492 propName
= jQuery
.propFix
[ name
] || name
;
2493 if ( propName
in elem
) {
2494 // Only set the IDL specifically if it already exists on the element
2495 elem
[ propName
] = true;
2498 elem
.setAttribute( name
, name
.toLowerCase() );
2504 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2505 if ( !getSetAttribute
) {
2513 // Use this for any attribute in IE6/7
2514 // This fixes almost every IE6/7 issue
2515 nodeHook
= jQuery
.valHooks
.button
= {
2516 get: function( elem
, name
) {
2518 ret
= elem
.getAttributeNode( name
);
2519 return ret
&& ( fixSpecified
[ name
] ? ret
.value
!== "" : ret
.specified
) ?
2523 set: function( elem
, value
, name
) {
2524 // Set the existing or create a new attribute node
2525 var ret
= elem
.getAttributeNode( name
);
2527 ret
= document
.createAttribute( name
);
2528 elem
.setAttributeNode( ret
);
2530 return ( ret
.value
= value
+ "" );
2534 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2535 // This is for removals
2536 jQuery
.each([ "width", "height" ], function( i
, name
) {
2537 jQuery
.attrHooks
[ name
] = jQuery
.extend( jQuery
.attrHooks
[ name
], {
2538 set: function( elem
, value
) {
2539 if ( value
=== "" ) {
2540 elem
.setAttribute( name
, "auto" );
2547 // Set contenteditable to false on removals(#10429)
2548 // Setting to empty string throws an error as an invalid value
2549 jQuery
.attrHooks
.contenteditable
= {
2551 set: function( elem
, value
, name
) {
2552 if ( value
=== "" ) {
2555 nodeHook
.set( elem
, value
, name
);
2561 // Some attributes require a special call on IE
2562 if ( !jQuery
.support
.hrefNormalized
) {
2563 jQuery
.each([ "href", "src", "width", "height" ], function( i
, name
) {
2564 jQuery
.attrHooks
[ name
] = jQuery
.extend( jQuery
.attrHooks
[ name
], {
2565 get: function( elem
) {
2566 var ret
= elem
.getAttribute( name
, 2 );
2567 return ret
=== null ? undefined : ret
;
2573 if ( !jQuery
.support
.style
) {
2574 jQuery
.attrHooks
.style
= {
2575 get: function( elem
) {
2576 // Return undefined in the case of empty string
2577 // Normalize to lowercase since IE uppercases css property names
2578 return elem
.style
.cssText
.toLowerCase() || undefined;
2580 set: function( elem
, value
) {
2581 return ( elem
.style
.cssText
= "" + value
);
2586 // Safari mis-reports the default selected property of an option
2587 // Accessing the parent's selectedIndex property fixes it
2588 if ( !jQuery
.support
.optSelected
) {
2589 jQuery
.propHooks
.selected
= jQuery
.extend( jQuery
.propHooks
.selected
, {
2590 get: function( elem
) {
2591 var parent
= elem
.parentNode
;
2594 parent
.selectedIndex
;
2596 // Make sure that it also works with optgroups, see #5701
2597 if ( parent
.parentNode
) {
2598 parent
.parentNode
.selectedIndex
;
2606 // IE6/7 call enctype encoding
2607 if ( !jQuery
.support
.enctype
) {
2608 jQuery
.propFix
.enctype
= "encoding";
2611 // Radios and checkboxes getter/setter
2612 if ( !jQuery
.support
.checkOn
) {
2613 jQuery
.each([ "radio", "checkbox" ], function() {
2614 jQuery
.valHooks
[ this ] = {
2615 get: function( elem
) {
2616 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2617 return elem
.getAttribute("value") === null ? "on" : elem
.value
;
2622 jQuery
.each([ "radio", "checkbox" ], function() {
2623 jQuery
.valHooks
[ this ] = jQuery
.extend( jQuery
.valHooks
[ this ], {
2624 set: function( elem
, value
) {
2625 if ( jQuery
.isArray( value
) ) {
2626 return ( elem
.checked
= jQuery
.inArray( jQuery(elem
).val(), value
) >= 0 );
2631 var rformElems
= /^(?:textarea|input|select)$/i,
2632 rtypenamespace
= /^([^\.]*|)(?:\.(.+)|)$/,
2633 rhoverHack
= /(?:^|\s)hover(\.\S+|)\b/,
2635 rmouseEvent
= /^(?:mouse|contextmenu)|click/,
2636 rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
2637 hoverHack = function( events
) {
2638 return jQuery
.event
.special
.hover
? events
: events
.replace( rhoverHack
, "mouseenter$1 mouseleave$1" );
2642 * Helper functions for managing events -- not part of the public interface.
2643 * Props to Dean Edwards' addEvent library for many of the ideas.
2647 add: function( elem
, types
, handler
, data
, selector
) {
2649 var elemData
, eventHandle
, events
,
2650 t
, tns
, type
, namespaces
, handleObj
,
2651 handleObjIn
, handlers
, special
;
2653 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2654 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !types
|| !handler
|| !(elemData
= jQuery
._data( elem
)) ) {
2658 // Caller can pass in an object of custom data in lieu of the handler
2659 if ( handler
.handler
) {
2660 handleObjIn
= handler
;
2661 handler
= handleObjIn
.handler
;
2662 selector
= handleObjIn
.selector
;
2665 // Make sure that the handler has a unique ID, used to find/remove it later
2666 if ( !handler
.guid
) {
2667 handler
.guid
= jQuery
.guid
++;
2670 // Init the element's event structure and main handler, if this is the first
2671 events
= elemData
.events
;
2673 elemData
.events
= events
= {};
2675 eventHandle
= elemData
.handle
;
2676 if ( !eventHandle
) {
2677 elemData
.handle
= eventHandle = function( e
) {
2678 // Discard the second event of a jQuery.event.trigger() and
2679 // when an event is called after a page has unloaded
2680 return typeof jQuery
!== "undefined" && (!e
|| jQuery
.event
.triggered
!== e
.type
) ?
2681 jQuery
.event
.dispatch
.apply( eventHandle
.elem
, arguments
) :
2684 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2685 eventHandle
.elem
= elem
;
2688 // Handle multiple events separated by a space
2689 // jQuery(...).bind("mouseover mouseout", fn);
2690 types
= jQuery
.trim( hoverHack(types
) ).split( " " );
2691 for ( t
= 0; t
< types
.length
; t
++ ) {
2693 tns
= rtypenamespace
.exec( types
[t
] ) || [];
2695 namespaces
= ( tns
[2] || "" ).split( "." ).sort();
2697 // If event changes its type, use the special event handlers for the changed type
2698 special
= jQuery
.event
.special
[ type
] || {};
2700 // If selector defined, determine special event api type, otherwise given type
2701 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
2703 // Update special based on newly reset type
2704 special
= jQuery
.event
.special
[ type
] || {};
2706 // handleObj is passed to all event handlers
2707 handleObj
= jQuery
.extend({
2714 namespace: namespaces
.join(".")
2717 // Init the event handler queue if we're the first
2718 handlers
= events
[ type
];
2720 handlers
= events
[ type
] = [];
2721 handlers
.delegateCount
= 0;
2723 // Only use addEventListener/attachEvent if the special events handler returns false
2724 if ( !special
.setup
|| special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
2725 // Bind the global event handler to the element
2726 if ( elem
.addEventListener
) {
2727 elem
.addEventListener( type
, eventHandle
, false );
2729 } else if ( elem
.attachEvent
) {
2730 elem
.attachEvent( "on" + type
, eventHandle
);
2735 if ( special
.add
) {
2736 special
.add
.call( elem
, handleObj
);
2738 if ( !handleObj
.handler
.guid
) {
2739 handleObj
.handler
.guid
= handler
.guid
;
2743 // Add to the element's handler list, delegates in front
2745 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
2747 handlers
.push( handleObj
);
2750 // Keep track of which events have ever been used, for event optimization
2751 jQuery
.event
.global
[ type
] = true;
2754 // Nullify elem to prevent memory leaks in IE
2760 // Detach an event or set of events from an element
2761 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
2763 var t
, tns
, type
, origType
, namespaces
, origCount
,
2764 j
, events
, special
, eventType
, handleObj
,
2765 elemData
= jQuery
.hasData( elem
) && jQuery
._data( elem
);
2767 if ( !elemData
|| !(events
= elemData
.events
) ) {
2771 // Once for each type.namespace in types; type may be omitted
2772 types
= jQuery
.trim( hoverHack( types
|| "" ) ).split(" ");
2773 for ( t
= 0; t
< types
.length
; t
++ ) {
2774 tns
= rtypenamespace
.exec( types
[t
] ) || [];
2775 type
= origType
= tns
[1];
2776 namespaces
= tns
[2];
2778 // Unbind all events (on this namespace, if provided) for the element
2780 for ( type
in events
) {
2781 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
2786 special
= jQuery
.event
.special
[ type
] || {};
2787 type
= ( selector
? special
.delegateType
: special
.bindType
) || type
;
2788 eventType
= events
[ type
] || [];
2789 origCount
= eventType
.length
;
2790 namespaces
= namespaces
? new RegExp("(^|\\.)" + namespaces
.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2792 // Remove matching events
2793 for ( j
= 0; j
< eventType
.length
; j
++ ) {
2794 handleObj
= eventType
[ j
];
2796 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
2797 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
2798 ( !namespaces
|| namespaces
.test( handleObj
.namespace ) ) &&
2799 ( !selector
|| selector
=== handleObj
.selector
|| selector
=== "**" && handleObj
.selector
) ) {
2800 eventType
.splice( j
--, 1 );
2802 if ( handleObj
.selector
) {
2803 eventType
.delegateCount
--;
2805 if ( special
.remove
) {
2806 special
.remove
.call( elem
, handleObj
);
2811 // Remove generic event handler if we removed something and no more handlers exist
2812 // (avoids potential for endless recursion during removal of special event handlers)
2813 if ( eventType
.length
=== 0 && origCount
!== eventType
.length
) {
2814 if ( !special
.teardown
|| special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
2815 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
2818 delete events
[ type
];
2822 // Remove the expando if it's no longer used
2823 if ( jQuery
.isEmptyObject( events
) ) {
2824 delete elemData
.handle
;
2826 // removeData also checks for emptiness and clears the expando if empty
2827 // so use it instead of delete
2828 jQuery
.removeData( elem
, "events", true );
2832 // Events that are safe to short-circuit if no handlers are attached.
2833 // Native DOM events should not be added, they may have inline handlers.
2840 trigger: function( event
, data
, elem
, onlyHandlers
) {
2841 // Don't do events on text and comment nodes
2842 if ( elem
&& (elem
.nodeType
=== 3 || elem
.nodeType
=== 8) ) {
2846 // Event object or event type
2847 var cache
, exclusive
, i
, cur
, old
, ontype
, special
, handle
, eventPath
, bubbleType
,
2848 type
= event
.type
|| event
,
2851 // focus/blur morphs to focusin/out; ensure we're not firing them right now
2852 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
2856 if ( type
.indexOf( "!" ) >= 0 ) {
2857 // Exclusive events trigger only for the exact event (no namespaces)
2858 type
= type
.slice(0, -1);
2862 if ( type
.indexOf( "." ) >= 0 ) {
2863 // Namespaced trigger; create a regexp to match event type in handle()
2864 namespaces
= type
.split(".");
2865 type
= namespaces
.shift();
2869 if ( (!elem
|| jQuery
.event
.customEvent
[ type
]) && !jQuery
.event
.global
[ type
] ) {
2870 // No jQuery handlers for this event type, and it can't have inline handlers
2874 // Caller can pass in an Event, Object, or just an event type string
2875 event
= typeof event
=== "object" ?
2876 // jQuery.Event object
2877 event
[ jQuery
.expando
] ? event
:
2879 new jQuery
.Event( type
, event
) :
2880 // Just the event type (string)
2881 new jQuery
.Event( type
);
2884 event
.isTrigger
= true;
2885 event
.exclusive
= exclusive
;
2886 event
.namespace = namespaces
.join( "." );
2887 event
.namespace_re
= event
.namespace? new RegExp("(^|\\.)" + namespaces
.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2888 ontype
= type
.indexOf( ":" ) < 0 ? "on" + type
: "";
2890 // Handle a global trigger
2893 // TODO: Stop taunting the data cache; remove global events and always attach to document
2894 cache
= jQuery
.cache
;
2895 for ( i
in cache
) {
2896 if ( cache
[ i
].events
&& cache
[ i
].events
[ type
] ) {
2897 jQuery
.event
.trigger( event
, data
, cache
[ i
].handle
.elem
, true );
2903 // Clean up the event in case it is being reused
2904 event
.result
= undefined;
2905 if ( !event
.target
) {
2906 event
.target
= elem
;
2909 // Clone any incoming data and prepend the event, creating the handler arg list
2910 data
= data
!= null ? jQuery
.makeArray( data
) : [];
2911 data
.unshift( event
);
2913 // Allow special events to draw outside the lines
2914 special
= jQuery
.event
.special
[ type
] || {};
2915 if ( special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
2919 // Determine event propagation path in advance, per W3C events spec (#9951)
2920 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2921 eventPath
= [[ elem
, special
.bindType
|| type
]];
2922 if ( !onlyHandlers
&& !special
.noBubble
&& !jQuery
.isWindow( elem
) ) {
2924 bubbleType
= special
.delegateType
|| type
;
2925 cur
= rfocusMorph
.test( bubbleType
+ type
) ? elem
: elem
.parentNode
;
2926 for ( old
= elem
; cur
; cur
= cur
.parentNode
) {
2927 eventPath
.push([ cur
, bubbleType
]);
2931 // Only add window if we got to document (e.g., not plain obj or detached DOM)
2932 if ( old
=== (elem
.ownerDocument
|| document
) ) {
2933 eventPath
.push([ old
.defaultView
|| old
.parentWindow
|| window
, bubbleType
]);
2937 // Fire handlers on the event path
2938 for ( i
= 0; i
< eventPath
.length
&& !event
.isPropagationStopped(); i
++ ) {
2940 cur
= eventPath
[i
][0];
2941 event
.type
= eventPath
[i
][1];
2943 handle
= ( jQuery
._data( cur
, "events" ) || {} )[ event
.type
] && jQuery
._data( cur
, "handle" );
2945 handle
.apply( cur
, data
);
2947 // Note that this is a bare JS function and not a jQuery handler
2948 handle
= ontype
&& cur
[ ontype
];
2949 if ( handle
&& jQuery
.acceptData( cur
) && handle
.apply( cur
, data
) === false ) {
2950 event
.preventDefault();
2955 // If nobody prevented the default action, do it now
2956 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
2958 if ( (!special
._default
|| special
._default
.apply( elem
.ownerDocument
, data
) === false) &&
2959 !(type
=== "click" && jQuery
.nodeName( elem
, "a" )) && jQuery
.acceptData( elem
) ) {
2961 // Call a native DOM method on the target with the same name name as the event.
2962 // Can't use an .isFunction() check here because IE6/7 fails that test.
2963 // Don't do default actions on window, that's where global variables be (#6170)
2964 // IE<9 dies on focus/blur to hidden element (#1486)
2965 if ( ontype
&& elem
[ type
] && ((type
!== "focus" && type
!== "blur") || event
.target
.offsetWidth
!== 0) && !jQuery
.isWindow( elem
) ) {
2967 // Don't re-trigger an onFOO event when we call its FOO() method
2968 old
= elem
[ ontype
];
2971 elem
[ ontype
] = null;
2974 // Prevent re-triggering of the same event, since we already bubbled it above
2975 jQuery
.event
.triggered
= type
;
2977 jQuery
.event
.triggered
= undefined;
2980 elem
[ ontype
] = old
;
2986 return event
.result
;
2989 dispatch: function( event
) {
2991 // Make a writable jQuery.Event from the native event object
2992 event
= jQuery
.event
.fix( event
|| window
.event
);
2994 var i
, j
, cur
, ret
, selMatch
, matched
, matches
, handleObj
, sel
, related
,
2995 handlers
= ( (jQuery
._data( this, "events" ) || {} )[ event
.type
] || []),
2996 delegateCount
= handlers
.delegateCount
,
2997 args
= [].slice
.call( arguments
),
2998 run_all
= !event
.exclusive
&& !event
.namespace,
2999 special
= jQuery
.event
.special
[ event
.type
] || {},
3002 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3004 event
.delegateTarget
= this;
3006 // Call the preDispatch hook for the mapped type, and let it bail if desired
3007 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
3011 // Determine handlers that should run if there are delegated events
3012 // Avoid non-left-click bubbling in Firefox (#3861)
3013 if ( delegateCount
&& !(event
.button
&& event
.type
=== "click") ) {
3015 for ( cur
= event
.target
; cur
!= this; cur
= cur
.parentNode
|| this ) {
3017 // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
3018 if ( cur
.disabled
!== true || event
.type
!== "click" ) {
3021 for ( i
= 0; i
< delegateCount
; i
++ ) {
3022 handleObj
= handlers
[ i
];
3023 sel
= handleObj
.selector
;
3025 if ( selMatch
[ sel
] === undefined ) {
3026 selMatch
[ sel
] = jQuery( sel
, this ).index( cur
) >= 0;
3028 if ( selMatch
[ sel
] ) {
3029 matches
.push( handleObj
);
3032 if ( matches
.length
) {
3033 handlerQueue
.push({ elem
: cur
, matches
: matches
});
3039 // Add the remaining (directly-bound) handlers
3040 if ( handlers
.length
> delegateCount
) {
3041 handlerQueue
.push({ elem
: this, matches
: handlers
.slice( delegateCount
) });
3044 // Run delegates first; they may want to stop propagation beneath us
3045 for ( i
= 0; i
< handlerQueue
.length
&& !event
.isPropagationStopped(); i
++ ) {
3046 matched
= handlerQueue
[ i
];
3047 event
.currentTarget
= matched
.elem
;
3049 for ( j
= 0; j
< matched
.matches
.length
&& !event
.isImmediatePropagationStopped(); j
++ ) {
3050 handleObj
= matched
.matches
[ j
];
3052 // Triggered event must either 1) be non-exclusive and have no namespace, or
3053 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3054 if ( run_all
|| (!event
.namespace && !handleObj
.namespace) || event
.namespace_re
&& event
.namespace_re
.test( handleObj
.namespace ) ) {
3056 event
.data
= handleObj
.data
;
3057 event
.handleObj
= handleObj
;
3059 ret
= ( (jQuery
.event
.special
[ handleObj
.origType
] || {}).handle
|| handleObj
.handler
)
3060 .apply( matched
.elem
, args
);
3062 if ( ret
!== undefined ) {
3064 if ( ret
=== false ) {
3065 event
.preventDefault();
3066 event
.stopPropagation();
3073 // Call the postDispatch hook for the mapped type
3074 if ( special
.postDispatch
) {
3075 special
.postDispatch
.call( this, event
);
3078 return event
.result
;
3081 // Includes some event props shared by KeyEvent and MouseEvent
3082 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3083 props
: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3088 props
: "char charCode key keyCode".split(" "),
3089 filter: function( event
, original
) {
3091 // Add which for key events
3092 if ( event
.which
== null ) {
3093 event
.which
= original
.charCode
!= null ? original
.charCode
: original
.keyCode
;
3101 props
: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3102 filter: function( event
, original
) {
3103 var eventDoc
, doc
, body
,
3104 button
= original
.button
,
3105 fromElement
= original
.fromElement
;
3107 // Calculate pageX/Y if missing and clientX/Y available
3108 if ( event
.pageX
== null && original
.clientX
!= null ) {
3109 eventDoc
= event
.target
.ownerDocument
|| document
;
3110 doc
= eventDoc
.documentElement
;
3111 body
= eventDoc
.body
;
3113 event
.pageX
= original
.clientX
+ ( doc
&& doc
.scrollLeft
|| body
&& body
.scrollLeft
|| 0 ) - ( doc
&& doc
.clientLeft
|| body
&& body
.clientLeft
|| 0 );
3114 event
.pageY
= original
.clientY
+ ( doc
&& doc
.scrollTop
|| body
&& body
.scrollTop
|| 0 ) - ( doc
&& doc
.clientTop
|| body
&& body
.clientTop
|| 0 );
3117 // Add relatedTarget, if necessary
3118 if ( !event
.relatedTarget
&& fromElement
) {
3119 event
.relatedTarget
= fromElement
=== event
.target
? original
.toElement
: fromElement
;
3122 // Add which for click: 1 === left; 2 === middle; 3 === right
3123 // Note: button is not normalized, so don't use it
3124 if ( !event
.which
&& button
!== undefined ) {
3125 event
.which
= ( button
& 1 ? 1 : ( button
& 2 ? 3 : ( button
& 4 ? 2 : 0 ) ) );
3132 fix: function( event
) {
3133 if ( event
[ jQuery
.expando
] ) {
3137 // Create a writable copy of the event object and normalize some properties
3139 originalEvent
= event
,
3140 fixHook
= jQuery
.event
.fixHooks
[ event
.type
] || {},
3141 copy
= fixHook
.props
? this.props
.concat( fixHook
.props
) : this.props
;
3143 event
= jQuery
.Event( originalEvent
);
3145 for ( i
= copy
.length
; i
; ) {
3147 event
[ prop
] = originalEvent
[ prop
];
3150 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3151 if ( !event
.target
) {
3152 event
.target
= originalEvent
.srcElement
|| document
;
3155 // Target should not be a text node (#504, Safari)
3156 if ( event
.target
.nodeType
=== 3 ) {
3157 event
.target
= event
.target
.parentNode
;
3160 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
3161 event
.metaKey
= !!event
.metaKey
;
3163 return fixHook
.filter
? fixHook
.filter( event
, originalEvent
) : event
;
3168 // Prevent triggered image.load events from bubbling to window.load
3173 delegateType
: "focusin"
3176 delegateType
: "focusout"
3180 setup: function( data
, namespaces
, eventHandle
) {
3181 // We only want to do this special case on windows
3182 if ( jQuery
.isWindow( this ) ) {
3183 this.onbeforeunload
= eventHandle
;
3187 teardown: function( namespaces
, eventHandle
) {
3188 if ( this.onbeforeunload
=== eventHandle
) {
3189 this.onbeforeunload
= null;
3195 simulate: function( type
, elem
, event
, bubble
) {
3196 // Piggyback on a donor event to simulate a different one.
3197 // Fake originalEvent to avoid donor's stopPropagation, but if the
3198 // simulated event prevents default then we do the same on the donor.
3199 var e
= jQuery
.extend(
3208 jQuery
.event
.trigger( e
, null, elem
);
3210 jQuery
.event
.dispatch
.call( elem
, e
);
3212 if ( e
.isDefaultPrevented() ) {
3213 event
.preventDefault();
3218 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3219 // The 1.7 special event interface should provide all the hooks needed now.
3220 jQuery
.event
.handle
= jQuery
.event
.dispatch
;
3222 jQuery
.removeEvent
= document
.removeEventListener
?
3223 function( elem
, type
, handle
) {
3224 if ( elem
.removeEventListener
) {
3225 elem
.removeEventListener( type
, handle
, false );
3228 function( elem
, type
, handle
) {
3229 var name
= "on" + type
;
3231 if ( elem
.detachEvent
) {
3233 // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
3234 // detachEvent needed property on element, by name of that event, to properly expose it to GC
3235 if ( typeof elem
[ name
] === "undefined" ) {
3236 elem
[ name
] = null;
3239 elem
.detachEvent( name
, handle
);
3243 jQuery
.Event = function( src
, props
) {
3244 // Allow instantiation without the 'new' keyword
3245 if ( !(this instanceof jQuery
.Event
) ) {
3246 return new jQuery
.Event( src
, props
);
3250 if ( src
&& src
.type
) {
3251 this.originalEvent
= src
;
3252 this.type
= src
.type
;
3254 // Events bubbling up the document may have been marked as prevented
3255 // by a handler lower down the tree; reflect the correct value.
3256 this.isDefaultPrevented
= ( src
.defaultPrevented
|| src
.returnValue
=== false ||
3257 src
.getPreventDefault
&& src
.getPreventDefault() ) ? returnTrue
: returnFalse
;
3264 // Put explicitly provided properties onto the event object
3266 jQuery
.extend( this, props
);
3269 // Create a timestamp if incoming event doesn't have one
3270 this.timeStamp
= src
&& src
.timeStamp
|| jQuery
.now();
3273 this[ jQuery
.expando
] = true;
3276 function returnFalse() {
3279 function returnTrue() {
3283 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3284 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3285 jQuery
.Event
.prototype = {
3286 preventDefault: function() {
3287 this.isDefaultPrevented
= returnTrue
;
3289 var e
= this.originalEvent
;
3294 // if preventDefault exists run it on the original event
3295 if ( e
.preventDefault
) {
3298 // otherwise set the returnValue property of the original event to false (IE)
3300 e
.returnValue
= false;
3303 stopPropagation: function() {
3304 this.isPropagationStopped
= returnTrue
;
3306 var e
= this.originalEvent
;
3310 // if stopPropagation exists run it on the original event
3311 if ( e
.stopPropagation
) {
3312 e
.stopPropagation();
3314 // otherwise set the cancelBubble property of the original event to true (IE)
3315 e
.cancelBubble
= true;
3317 stopImmediatePropagation: function() {
3318 this.isImmediatePropagationStopped
= returnTrue
;
3319 this.stopPropagation();
3321 isDefaultPrevented
: returnFalse
,
3322 isPropagationStopped
: returnFalse
,
3323 isImmediatePropagationStopped
: returnFalse
3326 // Create mouseenter/leave events using mouseover/out and event-time checks
3328 mouseenter
: "mouseover",
3329 mouseleave
: "mouseout"
3330 }, function( orig
, fix
) {
3331 jQuery
.event
.special
[ orig
] = {
3335 handle: function( event
) {
3338 related
= event
.relatedTarget
,
3339 handleObj
= event
.handleObj
,
3340 selector
= handleObj
.selector
;
3342 // For mousenter/leave call the handler if related is outside the target.
3343 // NB: No relatedTarget if the mouse left/entered the browser window
3344 if ( !related
|| (related
!== target
&& !jQuery
.contains( target
, related
)) ) {
3345 event
.type
= handleObj
.origType
;
3346 ret
= handleObj
.handler
.apply( this, arguments
);
3354 // IE submit delegation
3355 if ( !jQuery
.support
.submitBubbles
) {
3357 jQuery
.event
.special
.submit
= {
3359 // Only need this for delegated form submit events
3360 if ( jQuery
.nodeName( this, "form" ) ) {
3364 // Lazy-add a submit handler when a descendant form may potentially be submitted
3365 jQuery
.event
.add( this, "click._submit keypress._submit", function( e
) {
3366 // Node name check avoids a VML-related crash in IE (#9807)
3367 var elem
= e
.target
,
3368 form
= jQuery
.nodeName( elem
, "input" ) || jQuery
.nodeName( elem
, "button" ) ? elem
.form
: undefined;
3369 if ( form
&& !jQuery
._data( form
, "_submit_attached" ) ) {
3370 jQuery
.event
.add( form
, "submit._submit", function( event
) {
3371 event
._submit_bubble
= true;
3373 jQuery
._data( form
, "_submit_attached", true );
3376 // return undefined since we don't need an event listener
3379 postDispatch: function( event
) {
3380 // If form was submitted by the user, bubble the event up the tree
3381 if ( event
._submit_bubble
) {
3382 delete event
._submit_bubble
;
3383 if ( this.parentNode
&& !event
.isTrigger
) {
3384 jQuery
.event
.simulate( "submit", this.parentNode
, event
, true );
3389 teardown: function() {
3390 // Only need this for delegated form submit events
3391 if ( jQuery
.nodeName( this, "form" ) ) {
3395 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3396 jQuery
.event
.remove( this, "._submit" );
3401 // IE change delegation and checkbox/radio fix
3402 if ( !jQuery
.support
.changeBubbles
) {
3404 jQuery
.event
.special
.change
= {
3408 if ( rformElems
.test( this.nodeName
) ) {
3409 // IE doesn't fire change on a check/radio until blur; trigger it on click
3410 // after a propertychange. Eat the blur-change in special.change.handle.
3411 // This still fires onchange a second time for check/radio after blur.
3412 if ( this.type
=== "checkbox" || this.type
=== "radio" ) {
3413 jQuery
.event
.add( this, "propertychange._change", function( event
) {
3414 if ( event
.originalEvent
.propertyName
=== "checked" ) {
3415 this._just_changed
= true;
3418 jQuery
.event
.add( this, "click._change", function( event
) {
3419 if ( this._just_changed
&& !event
.isTrigger
) {
3420 this._just_changed
= false;
3422 // Allow triggered, simulated change events (#11500)
3423 jQuery
.event
.simulate( "change", this, event
, true );
3428 // Delegated event; lazy-add a change handler on descendant inputs
3429 jQuery
.event
.add( this, "beforeactivate._change", function( e
) {
3430 var elem
= e
.target
;
3432 if ( rformElems
.test( elem
.nodeName
) && !jQuery
._data( elem
, "_change_attached" ) ) {
3433 jQuery
.event
.add( elem
, "change._change", function( event
) {
3434 if ( this.parentNode
&& !event
.isSimulated
&& !event
.isTrigger
) {
3435 jQuery
.event
.simulate( "change", this.parentNode
, event
, true );
3438 jQuery
._data( elem
, "_change_attached", true );
3443 handle: function( event
) {
3444 var elem
= event
.target
;
3446 // Swallow native change events from checkbox/radio, we already triggered them above
3447 if ( this !== elem
|| event
.isSimulated
|| event
.isTrigger
|| (elem
.type
!== "radio" && elem
.type
!== "checkbox") ) {
3448 return event
.handleObj
.handler
.apply( this, arguments
);
3452 teardown: function() {
3453 jQuery
.event
.remove( this, "._change" );
3455 return !rformElems
.test( this.nodeName
);
3460 // Create "bubbling" focus and blur events
3461 if ( !jQuery
.support
.focusinBubbles
) {
3462 jQuery
.each({ focus
: "focusin", blur
: "focusout" }, function( orig
, fix
) {
3464 // Attach a single capturing handler while someone wants focusin/focusout
3466 handler = function( event
) {
3467 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
), true );
3470 jQuery
.event
.special
[ fix
] = {
3472 if ( attaches
++ === 0 ) {
3473 document
.addEventListener( orig
, handler
, true );
3476 teardown: function() {
3477 if ( --attaches
=== 0 ) {
3478 document
.removeEventListener( orig
, handler
, true );
3487 on: function( types
, selector
, data
, fn
, /*INTERNAL*/ one
) {
3490 // Types can be a map of types/handlers
3491 if ( typeof types
=== "object" ) {
3492 // ( types-Object, selector, data )
3493 if ( typeof selector
!== "string" ) { // && selector != null
3494 // ( types-Object, data )
3495 data
= data
|| selector
;
3496 selector
= undefined;
3498 for ( type
in types
) {
3499 this.on( type
, selector
, data
, types
[ type
], one
);
3504 if ( data
== null && fn
== null ) {
3507 data
= selector
= undefined;
3508 } else if ( fn
== null ) {
3509 if ( typeof selector
=== "string" ) {
3510 // ( types, selector, fn )
3514 // ( types, data, fn )
3517 selector
= undefined;
3520 if ( fn
=== false ) {
3528 fn = function( event
) {
3529 // Can use an empty set, since event contains the info
3530 jQuery().off( event
);
3531 return origFn
.apply( this, arguments
);
3533 // Use same guid so caller can remove using origFn
3534 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
3536 return this.each( function() {
3537 jQuery
.event
.add( this, types
, fn
, data
, selector
);
3540 one: function( types
, selector
, data
, fn
) {
3541 return this.on( types
, selector
, data
, fn
, 1 );
3543 off: function( types
, selector
, fn
) {
3544 var handleObj
, type
;
3545 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
3546 // ( event ) dispatched jQuery.Event
3547 handleObj
= types
.handleObj
;
3548 jQuery( types
.delegateTarget
).off(
3549 handleObj
.namespace ? handleObj
.origType
+ "." + handleObj
.namespace : handleObj
.origType
,
3555 if ( typeof types
=== "object" ) {
3556 // ( types-object [, selector] )
3557 for ( type
in types
) {
3558 this.off( type
, selector
, types
[ type
] );
3562 if ( selector
=== false || typeof selector
=== "function" ) {
3565 selector
= undefined;
3567 if ( fn
=== false ) {
3570 return this.each(function() {
3571 jQuery
.event
.remove( this, types
, fn
, selector
);
3575 bind: function( types
, data
, fn
) {
3576 return this.on( types
, null, data
, fn
);
3578 unbind: function( types
, fn
) {
3579 return this.off( types
, null, fn
);
3582 live: function( types
, data
, fn
) {
3583 jQuery( this.context
).on( types
, this.selector
, data
, fn
);
3586 die: function( types
, fn
) {
3587 jQuery( this.context
).off( types
, this.selector
|| "**", fn
);
3591 delegate: function( selector
, types
, data
, fn
) {
3592 return this.on( types
, selector
, data
, fn
);
3594 undelegate: function( selector
, types
, fn
) {
3595 // ( namespace ) or ( selector, types [, fn] )
3596 return arguments
.length
== 1? this.off( selector
, "**" ) : this.off( types
, selector
|| "**", fn
);
3599 trigger: function( type
, data
) {
3600 return this.each(function() {
3601 jQuery
.event
.trigger( type
, data
, this );
3604 triggerHandler: function( type
, data
) {
3606 return jQuery
.event
.trigger( type
, data
, this[0], true );
3610 toggle: function( fn
) {
3611 // Save reference to arguments for access in closure
3612 var args
= arguments
,
3613 guid
= fn
.guid
|| jQuery
.guid
++,
3615 toggler = function( event
) {
3616 // Figure out which function to execute
3617 var lastToggle
= ( jQuery
._data( this, "lastToggle" + fn
.guid
) || 0 ) % i
;
3618 jQuery
._data( this, "lastToggle" + fn
.guid
, lastToggle
+ 1 );
3620 // Make sure that clicks stop
3621 event
.preventDefault();
3623 // and execute the function
3624 return args
[ lastToggle
].apply( this, arguments
) || false;
3627 // link all the functions, so any of them can unbind this click handler
3628 toggler
.guid
= guid
;
3629 while ( i
< args
.length
) {
3630 args
[ i
++ ].guid
= guid
;
3633 return this.click( toggler
);
3636 hover: function( fnOver
, fnOut
) {
3637 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
3641 jQuery
.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3642 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3643 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i
, name
) {
3645 // Handle event binding
3646 jQuery
.fn
[ name
] = function( data
, fn
) {
3652 return arguments
.length
> 0 ?
3653 this.on( name
, null, data
, fn
) :
3654 this.trigger( name
);
3657 if ( rkeyEvent
.test( name
) ) {
3658 jQuery
.event
.fixHooks
[ name
] = jQuery
.event
.keyHooks
;
3661 if ( rmouseEvent
.test( name
) ) {
3662 jQuery
.event
.fixHooks
[ name
] = jQuery
.event
.mouseHooks
;
3666 * Sizzle CSS Selector Engine
3667 * Copyright 2012 jQuery Foundation and other contributors
3668 * Released under the MIT license
3669 * http://sizzlejs.com/
3671 (function( window
, undefined ) {
3684 baseHasDuplicate
= true,
3685 strundefined
= "undefined",
3687 expando
= ( "sizcache" + Math
.random() ).replace( ".", "" ),
3689 document
= window
.document
,
3690 docElem
= document
.documentElement
,
3695 // Augment a function for special use by Sizzle
3696 markFunction = function( fn
, value
) {
3697 fn
[ expando
] = value
|| true;
3701 createCache = function() {
3705 return markFunction(function( key
, value
) {
3706 // Only keep the most recent entries
3707 if ( keys
.push( key
) > Expr
.cacheLength
) {
3708 delete cache
[ keys
.shift() ];
3711 return (cache
[ key
] = value
);
3715 classCache
= createCache(),
3716 tokenCache
= createCache(),
3717 compilerCache
= createCache(),
3721 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
3722 whitespace
= "[\\x20\\t\\r\\n\\f]",
3723 // http://www.w3.org/TR/css3-syntax/#characters
3724 characterEncoding
= "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
3726 // Loosely modeled on CSS identifier characters
3727 // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
3728 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
3729 identifier
= characterEncoding
.replace( "w", "w#" ),
3731 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
3732 operators
= "([*^$|!~]?=)",
3733 attributes
= "\\[" + whitespace
+ "*(" + characterEncoding
+ ")" + whitespace
+
3734 "*(?:" + operators
+ whitespace
+ "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier
+ ")|)|)" + whitespace
+ "*\\]",
3736 // Prefer arguments not in parens/brackets,
3737 // then attribute selectors and non-pseudos (denoted by :),
3738 // then anything else
3739 // These preferences are here to reduce the number of selectors
3740 // needing tokenize in the PSEUDO preFilter
3741 pseudos
= ":(" + characterEncoding
+ ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes
+ ")|[^:]|\\\\.)*|.*))\\)|)",
3743 // For matchExpr.POS and matchExpr.needsContext
3744 pos
= ":(nth|eq|gt|lt|first|last|even|odd)(?:\\(((?:-\\d)?\\d*)\\)|)(?=[^-]|$)",
3746 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3747 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
3749 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
3750 rcombinators
= new RegExp( "^" + whitespace
+ "*([\\x20\\t\\r\\n\\f>+~])" + whitespace
+ "*" ),
3751 rpseudo
= new RegExp( pseudos
),
3753 // Easily-parseable/retrievable ID or TAG or CLASS selectors
3754 rquickExpr
= /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
3757 rsibling
= /[\x20\t\r\n\f]*[+~]/,
3758 rendsWithNot
= /:not\($/,
3761 rinputs
= /input|select|textarea|button/i,
3763 rbackslash
= /\\(?!\\)/g,
3766 "ID": new RegExp( "^#(" + characterEncoding
+ ")" ),
3767 "CLASS": new RegExp( "^\\.(" + characterEncoding
+ ")" ),
3768 "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding
+ ")['\"]?\\]" ),
3769 "TAG": new RegExp( "^(" + characterEncoding
.replace( "w", "w*" ) + ")" ),
3770 "ATTR": new RegExp( "^" + attributes
),
3771 "PSEUDO": new RegExp( "^" + pseudos
),
3772 "CHILD": new RegExp( "^:(only|nth|last|first)-child(?:\\(" + whitespace
+
3773 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
3774 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
3775 "POS": new RegExp( pos
, "ig" ),
3776 // For use in libraries implementing .is()
3777 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|" + pos
, "i" )
3782 // Used for testing something on an element
3783 assert = function( fn
) {
3784 var div
= document
.createElement("div");
3791 // release memory in IE
3796 // Check if getElementsByTagName("*") returns only elements
3797 assertTagNameNoComments
= assert(function( div
) {
3798 div
.appendChild( document
.createComment("") );
3799 return !div
.getElementsByTagName("*").length
;
3802 // Check if getAttribute returns normalized href attributes
3803 assertHrefNotNormalized
= assert(function( div
) {
3804 div
.innerHTML
= "<a href='#'></a>";
3805 return div
.firstChild
&& typeof div
.firstChild
.getAttribute
!== strundefined
&&
3806 div
.firstChild
.getAttribute("href") === "#";
3809 // Check if attributes should be retrieved by attribute nodes
3810 assertAttributes
= assert(function( div
) {
3811 div
.innerHTML
= "<select></select>";
3812 var type
= typeof div
.lastChild
.getAttribute("multiple");
3813 // IE8 returns a string for some attributes even when not present
3814 return type
!== "boolean" && type
!== "string";
3817 // Check if getElementsByClassName can be trusted
3818 assertUsableClassName
= assert(function( div
) {
3819 // Opera can't find a second classname (in 9.6)
3820 div
.innerHTML
= "<div class='hidden e'></div><div class='hidden'></div>";
3821 if ( !div
.getElementsByClassName
|| !div
.getElementsByClassName("e").length
) {
3825 // Safari 3.2 caches class attributes and doesn't catch changes
3826 div
.lastChild
.className
= "e";
3827 return div
.getElementsByClassName("e").length
=== 2;
3830 // Check if getElementById returns elements by name
3831 // Check if getElementsByName privileges form controls or returns elements by ID
3832 assertUsableName
= assert(function( div
) {
3834 div
.id
= expando
+ 0;
3835 div
.innerHTML
= "<a name='" + expando
+ "'></a><div name='" + expando
+ "'></div>";
3836 docElem
.insertBefore( div
, docElem
.firstChild
);
3839 var pass
= document
.getElementsByName
&&
3840 // buggy browsers will return fewer than the correct 2
3841 document
.getElementsByName( expando
).length
=== 2 +
3842 // buggy browsers will return more than the correct 0
3843 document
.getElementsByName( expando
+ 0 ).length
;
3844 assertGetIdNotName
= !document
.getElementById( expando
);
3847 docElem
.removeChild( div
);
3852 // If slice is not available, provide a backup
3854 slice
.call( docElem
.childNodes
, 0 )[0].nodeType
;
3856 slice = function( i
) {
3857 var elem
, results
= [];
3858 for ( ; (elem
= this[i
]); i
++ ) {
3859 results
.push( elem
);
3865 function Sizzle( selector
, context
, results
, seed
) {
3866 results
= results
|| [];
3867 context
= context
|| document
;
3868 var match
, elem
, xml
, m
,
3869 nodeType
= context
.nodeType
;
3871 if ( nodeType
!== 1 && nodeType
!== 9 ) {
3875 if ( !selector
|| typeof selector
!== "string" ) {
3879 xml
= isXML( context
);
3881 if ( !xml
&& !seed
) {
3882 if ( (match
= rquickExpr
.exec( selector
)) ) {
3883 // Speed-up: Sizzle("#ID")
3884 if ( (m
= match
[1]) ) {
3885 if ( nodeType
=== 9 ) {
3886 elem
= context
.getElementById( m
);
3887 // Check parentNode to catch when Blackberry 4.6 returns
3888 // nodes that are no longer in the document #6963
3889 if ( elem
&& elem
.parentNode
) {
3890 // Handle the case where IE, Opera, and Webkit return items
3891 // by name instead of ID
3892 if ( elem
.id
=== m
) {
3893 results
.push( elem
);
3900 // Context is not a document
3901 if ( context
.ownerDocument
&& (elem
= context
.ownerDocument
.getElementById( m
)) &&
3902 contains( context
, elem
) && elem
.id
=== m
) {
3903 results
.push( elem
);
3908 // Speed-up: Sizzle("TAG")
3909 } else if ( match
[2] ) {
3910 push
.apply( results
, slice
.call(context
.getElementsByTagName( selector
), 0) );
3913 // Speed-up: Sizzle(".CLASS")
3914 } else if ( (m
= match
[3]) && assertUsableClassName
&& context
.getElementsByClassName
) {
3915 push
.apply( results
, slice
.call(context
.getElementsByClassName( m
), 0) );
3922 return select( selector
, context
, results
, seed
, xml
);
3925 Sizzle
.matches = function( expr
, elements
) {
3926 return Sizzle( expr
, null, null, elements
);
3929 Sizzle
.matchesSelector = function( elem
, expr
) {
3930 return Sizzle( expr
, null, null, [ elem
] ).length
> 0;
3933 // Returns a function to use in pseudos for input types
3934 function createInputPseudo( type
) {
3935 return function( elem
) {
3936 var name
= elem
.nodeName
.toLowerCase();
3937 return name
=== "input" && elem
.type
=== type
;
3941 // Returns a function to use in pseudos for buttons
3942 function createButtonPseudo( type
) {
3943 return function( elem
) {
3944 var name
= elem
.nodeName
.toLowerCase();
3945 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
3950 * Utility function for retrieving the text value of an array of DOM nodes
3951 * @param {Array|Element} elem
3953 getText
= Sizzle
.getText = function( elem
) {
3957 nodeType
= elem
.nodeType
;
3960 if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
3961 // Use textContent for elements
3962 // innerText usage removed for consistency of new lines (see #11153)
3963 if ( typeof elem
.textContent
=== "string" ) {
3964 return elem
.textContent
;
3966 // Traverse its children
3967 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
3968 ret
+= getText( elem
);
3971 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
3972 return elem
.nodeValue
;
3974 // Do not include comment or processing instruction nodes
3977 // If no nodeType, this is expected to be an array
3978 for ( ; (node
= elem
[i
]); i
++ ) {
3979 // Do not traverse comment nodes
3980 ret
+= getText( node
);
3986 isXML
= Sizzle
.isXML
= function isXML( elem
) {
3987 // documentElement is verified for cases where it doesn't yet exist
3988 // (such as loading iframes in IE - #4833)
3989 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
3990 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
3993 // Element contains another
3994 contains
= Sizzle
.contains
= docElem
.contains
?
3996 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
3997 bup
= b
&& b
.parentNode
;
3998 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && adown
.contains
&& adown
.contains(bup
) );
4000 docElem
.compareDocumentPosition
?
4002 return b
&& !!( a
.compareDocumentPosition( b
) & 16 );
4005 while ( (b
= b
.parentNode
) ) {
4013 Sizzle
.attr = function( elem
, name
) {
4015 xml
= isXML( elem
);
4018 name
= name
.toLowerCase();
4020 if ( Expr
.attrHandle
[ name
] ) {
4021 return Expr
.attrHandle
[ name
]( elem
);
4023 if ( assertAttributes
|| xml
) {
4024 return elem
.getAttribute( name
);
4026 attr
= elem
.getAttributeNode( name
);
4028 typeof elem
[ name
] === "boolean" ?
4029 elem
[ name
] ? name
: null :
4030 attr
.specified
? attr
.value
: null :
4034 Expr
= Sizzle
.selectors
= {
4036 // Can be adjusted by the user
4039 createPseudo
: markFunction
,
4043 order
: new RegExp( "ID|TAG" +
4044 (assertUsableName
? "|NAME" : "") +
4045 (assertUsableClassName
? "|CLASS" : "")
4048 // IE6/7 return a modified href
4049 attrHandle
: assertHrefNotNormalized
?
4052 "href": function( elem
) {
4053 return elem
.getAttribute( "href", 2 );
4055 "type": function( elem
) {
4056 return elem
.getAttribute("type");
4061 "ID": assertGetIdNotName
?
4062 function( id
, context
, xml
) {
4063 if ( typeof context
.getElementById
!== strundefined
&& !xml
) {
4064 var m
= context
.getElementById( id
);
4065 // Check parentNode to catch when Blackberry 4.6 returns
4066 // nodes that are no longer in the document #6963
4067 return m
&& m
.parentNode
? [m
] : [];
4070 function( id
, context
, xml
) {
4071 if ( typeof context
.getElementById
!== strundefined
&& !xml
) {
4072 var m
= context
.getElementById( id
);
4075 m
.id
=== id
|| typeof m
.getAttributeNode
!== strundefined
&& m
.getAttributeNode("id").value
=== id
?
4082 "TAG": assertTagNameNoComments
?
4083 function( tag
, context
) {
4084 if ( typeof context
.getElementsByTagName
!== strundefined
) {
4085 return context
.getElementsByTagName( tag
);
4088 function( tag
, context
) {
4089 var results
= context
.getElementsByTagName( tag
);
4091 // Filter out possible comments
4092 if ( tag
=== "*" ) {
4097 for ( ; (elem
= results
[i
]); i
++ ) {
4098 if ( elem
.nodeType
=== 1 ) {
4108 "NAME": function( tag
, context
) {
4109 if ( typeof context
.getElementsByName
!== strundefined
) {
4110 return context
.getElementsByName( name
);
4114 "CLASS": function( className
, context
, xml
) {
4115 if ( typeof context
.getElementsByClassName
!== strundefined
&& !xml
) {
4116 return context
.getElementsByClassName( className
);
4122 ">": { dir
: "parentNode", first
: true },
4123 " ": { dir
: "parentNode" },
4124 "+": { dir
: "previousSibling", first
: true },
4125 "~": { dir
: "previousSibling" }
4129 "ATTR": function( match
) {
4130 match
[1] = match
[1].replace( rbackslash
, "" );
4132 // Move the given value to match[3] whether quoted or unquoted
4133 match
[3] = ( match
[4] || match
[5] || "" ).replace( rbackslash
, "" );
4135 if ( match
[2] === "~=" ) {
4136 match
[3] = " " + match
[3] + " ";
4139 return match
.slice( 0, 4 );
4142 "CHILD": function( match
) {
4143 /* matches from matchExpr.CHILD
4144 1 type (only|nth|...)
4145 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4146 3 xn-component of xn+y argument ([+-]?\d*n|)
4147 4 sign of xn-component
4149 6 sign of y-component
4152 match
[1] = match
[1].toLowerCase();
4154 if ( match
[1] === "nth" ) {
4155 // nth-child requires argument
4157 Sizzle
.error( match
[0] );
4160 // numeric x and y parameters for Expr.filter.CHILD
4161 // remember that false/true cast respectively to 0/1
4162 match
[3] = +( match
[3] ? match
[4] + (match
[5] || 1) : 2 * ( match
[2] === "even" || match
[2] === "odd" ) );
4163 match
[4] = +( ( match
[6] + match
[7] ) || match
[2] === "odd" );
4165 // other types prohibit arguments
4166 } else if ( match
[2] ) {
4167 Sizzle
.error( match
[0] );
4173 "PSEUDO": function( match
, context
, xml
) {
4174 var unquoted
, excess
;
4175 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
4180 match
[2] = match
[3];
4181 } else if ( (unquoted
= match
[4]) ) {
4182 // Only check arguments that contain a pseudo
4183 if ( rpseudo
.test(unquoted
) &&
4184 // Get excess from tokenize (recursively)
4185 (excess
= tokenize( unquoted
, context
, xml
, true )) &&
4186 // advance to the next closing parenthesis
4187 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
4189 // excess is a negative index
4190 unquoted
= unquoted
.slice( 0, excess
);
4191 match
[0] = match
[0].slice( 0, excess
);
4193 match
[2] = unquoted
;
4196 // Return only captures needed by the pseudo filter method (type and argument)
4197 return match
.slice( 0, 3 );
4202 "ID": assertGetIdNotName
?
4204 id
= id
.replace( rbackslash
, "" );
4205 return function( elem
) {
4206 return elem
.getAttribute("id") === id
;
4210 id
= id
.replace( rbackslash
, "" );
4211 return function( elem
) {
4212 var node
= typeof elem
.getAttributeNode
!== strundefined
&& elem
.getAttributeNode("id");
4213 return node
&& node
.value
=== id
;
4217 "TAG": function( nodeName
) {
4218 if ( nodeName
=== "*" ) {
4219 return function() { return true; };
4221 nodeName
= nodeName
.replace( rbackslash
, "" ).toLowerCase();
4223 return function( elem
) {
4224 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
4228 "CLASS": function( className
) {
4229 var pattern
= classCache
[ expando
][ className
];
4231 pattern
= classCache( className
, new RegExp("(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)") );
4233 return function( elem
) {
4234 return pattern
.test( elem
.className
|| (typeof elem
.getAttribute
!== strundefined
&& elem
.getAttribute("class")) || "" );
4238 "ATTR": function( name
, operator
, check
) {
4240 return function( elem
) {
4241 return Sizzle
.attr( elem
, name
) != null;
4245 return function( elem
) {
4246 var result
= Sizzle
.attr( elem
, name
),
4247 value
= result
+ "";
4249 if ( result
== null ) {
4250 return operator
=== "!=";
4253 switch ( operator
) {
4255 return value
=== check
;
4257 return value
!== check
;
4259 return check
&& value
.indexOf( check
) === 0;
4261 return check
&& value
.indexOf( check
) > -1;
4263 return check
&& value
.substr( value
.length
- check
.length
) === check
;
4265 return ( " " + value
+ " " ).indexOf( check
) > -1;
4267 return value
=== check
|| value
.substr( 0, check
.length
+ 1 ) === check
+ "-";
4272 "CHILD": function( type
, argument
, first
, last
) {
4274 if ( type
=== "nth" ) {
4275 var doneName
= done
++;
4277 return function( elem
) {
4282 if ( first
=== 1 && last
=== 0 ) {
4286 parent
= elem
.parentNode
;
4288 if ( parent
&& (parent
[ expando
] !== doneName
|| !elem
.sizset
) ) {
4289 for ( node
= parent
.firstChild
; node
; node
= node
.nextSibling
) {
4290 if ( node
.nodeType
=== 1 ) {
4291 node
.sizset
= ++count
;
4292 if ( node
=== elem
) {
4298 parent
[ expando
] = doneName
;
4301 diff
= elem
.sizset
- last
;
4303 if ( first
=== 0 ) {
4307 return ( diff
% first
=== 0 && diff
/ first
>= 0 );
4312 return function( elem
) {
4318 while ( (node
= node
.previousSibling
) ) {
4319 if ( node
.nodeType
=== 1 ) {
4324 if ( type
=== "first" ) {
4332 while ( (node
= node
.nextSibling
) ) {
4333 if ( node
.nodeType
=== 1 ) {
4343 "PSEUDO": function( pseudo
, argument
, context
, xml
) {
4344 // pseudo-class names are case-insensitive
4345 // http://www.w3.org/TR/selectors/#pseudo-classes
4346 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4348 fn
= Expr
.pseudos
[ pseudo
] || Expr
.pseudos
[ pseudo
.toLowerCase() ];
4351 Sizzle
.error( "unsupported pseudo: " + pseudo
);
4354 // The user may use createPseudo to indicate that
4355 // arguments are needed to create the filter function
4356 // just as Sizzle does
4357 if ( !fn
[ expando
] ) {
4358 if ( fn
.length
> 1 ) {
4359 args
= [ pseudo
, pseudo
, "", argument
];
4360 return function( elem
) {
4361 return fn( elem
, 0, args
);
4367 return fn( argument
, context
, xml
);
4372 "not": markFunction(function( selector
, context
, xml
) {
4373 // Trim the selector passed to compile
4374 // to avoid treating leading and trailing
4375 // spaces as combinators
4376 var matcher
= compile( selector
.replace( rtrim
, "$1" ), context
, xml
);
4377 return function( elem
) {
4378 return !matcher( elem
);
4382 "enabled": function( elem
) {
4383 return elem
.disabled
=== false;
4386 "disabled": function( elem
) {
4387 return elem
.disabled
=== true;
4390 "checked": function( elem
) {
4391 // In CSS3, :checked should return both checked and selected elements
4392 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4393 var nodeName
= elem
.nodeName
.toLowerCase();
4394 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
4397 "selected": function( elem
) {
4398 // Accessing this property makes selected-by-default
4399 // options in Safari work properly
4400 if ( elem
.parentNode
) {
4401 elem
.parentNode
.selectedIndex
;
4404 return elem
.selected
=== true;
4407 "parent": function( elem
) {
4408 return !Expr
.pseudos
["empty"]( elem
);
4411 "empty": function( elem
) {
4412 // http://www.w3.org/TR/selectors/#empty-pseudo
4413 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
4414 // not comment, processing instructions, or others
4415 // Thanks to Diego Perini for the nodeName shortcut
4416 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
4418 elem
= elem
.firstChild
;
4420 if ( elem
.nodeName
> "@" || (nodeType
= elem
.nodeType
) === 3 || nodeType
=== 4 ) {
4423 elem
= elem
.nextSibling
;
4428 "contains": markFunction(function( text
) {
4429 return function( elem
) {
4430 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
4434 "has": markFunction(function( selector
) {
4435 return function( elem
) {
4436 return Sizzle( selector
, elem
).length
> 0;
4440 "header": function( elem
) {
4441 return rheader
.test( elem
.nodeName
);
4444 "text": function( elem
) {
4446 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4447 // use getAttribute instead to test this case
4448 return elem
.nodeName
.toLowerCase() === "input" &&
4449 (type
= elem
.type
) === "text" &&
4450 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === type
);
4454 "radio": createInputPseudo("radio"),
4455 "checkbox": createInputPseudo("checkbox"),
4456 "file": createInputPseudo("file"),
4457 "password": createInputPseudo("password"),
4458 "image": createInputPseudo("image"),
4460 "submit": createButtonPseudo("submit"),
4461 "reset": createButtonPseudo("reset"),
4463 "button": function( elem
) {
4464 var name
= elem
.nodeName
.toLowerCase();
4465 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
4468 "input": function( elem
) {
4469 return rinputs
.test( elem
.nodeName
);
4472 "focus": function( elem
) {
4473 var doc
= elem
.ownerDocument
;
4474 return elem
=== doc
.activeElement
&& (!doc
.hasFocus
|| doc
.hasFocus()) && !!(elem
.type
|| elem
.href
);
4477 "active": function( elem
) {
4478 return elem
=== elem
.ownerDocument
.activeElement
;
4483 "first": function( elements
, argument
, not
) {
4484 return not
? elements
.slice( 1 ) : [ elements
[0] ];
4487 "last": function( elements
, argument
, not
) {
4488 var elem
= elements
.pop();
4489 return not
? elements
: [ elem
];
4492 "even": function( elements
, argument
, not
) {
4495 len
= elements
.length
;
4496 for ( ; i
< len
; i
= i
+ 2 ) {
4497 results
.push( elements
[i
] );
4502 "odd": function( elements
, argument
, not
) {
4505 len
= elements
.length
;
4506 for ( ; i
< len
; i
= i
+ 2 ) {
4507 results
.push( elements
[i
] );
4512 "lt": function( elements
, argument
, not
) {
4513 return not
? elements
.slice( +argument
) : elements
.slice( 0, +argument
);
4516 "gt": function( elements
, argument
, not
) {
4517 return not
? elements
.slice( 0, +argument
+ 1 ) : elements
.slice( +argument
+ 1 );
4520 "eq": function( elements
, argument
, not
) {
4521 var elem
= elements
.splice( +argument
, 1 );
4522 return not
? elements
: elem
;
4527 function siblingCheck( a
, b
, ret
) {
4532 var cur
= a
.nextSibling
;
4539 cur
= cur
.nextSibling
;
4545 sortOrder
= docElem
.compareDocumentPosition
?
4548 hasDuplicate
= true;
4552 return ( !a
.compareDocumentPosition
|| !b
.compareDocumentPosition
?
4553 a
.compareDocumentPosition
:
4554 a
.compareDocumentPosition(b
) & 4
4558 // The nodes are identical, we can exit early
4560 hasDuplicate
= true;
4563 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4564 } else if ( a
.sourceIndex
&& b
.sourceIndex
) {
4565 return a
.sourceIndex
- b
.sourceIndex
;
4575 // If the nodes are siblings (or identical) we can do a quick check
4576 if ( aup
=== bup
) {
4577 return siblingCheck( a
, b
);
4579 // If no parents were found then the nodes are disconnected
4580 } else if ( !aup
) {
4583 } else if ( !bup
) {
4587 // Otherwise they're somewhere else in the tree so we need
4588 // to build up a full list of the parentNodes for comparison
4591 cur
= cur
.parentNode
;
4598 cur
= cur
.parentNode
;
4604 // Start walking down the tree looking for a discrepancy
4605 for ( var i
= 0; i
< al
&& i
< bl
; i
++ ) {
4606 if ( ap
[i
] !== bp
[i
] ) {
4607 return siblingCheck( ap
[i
], bp
[i
] );
4611 // We ended someplace up the tree so do a sibling check
4613 siblingCheck( a
, bp
[i
], -1 ) :
4614 siblingCheck( ap
[i
], b
, 1 );
4617 // Always assume the presence of duplicates if sort doesn't
4618 // pass them to our comparison function (as in Google Chrome).
4619 [0, 0].sort( sortOrder
);
4620 baseHasDuplicate
= !hasDuplicate
;
4622 // Document sorting and removing duplicates
4623 Sizzle
.uniqueSort = function( results
) {
4627 hasDuplicate
= baseHasDuplicate
;
4628 results
.sort( sortOrder
);
4630 if ( hasDuplicate
) {
4631 for ( ; (elem
= results
[i
]); i
++ ) {
4632 if ( elem
=== results
[ i
- 1 ] ) {
4633 results
.splice( i
--, 1 );
4641 Sizzle
.error = function( msg
) {
4642 throw new Error( "Syntax error, unrecognized expression: " + msg
);
4645 function tokenize( selector
, context
, xml
, parseOnly
) {
4646 var matched
, match
, tokens
, type
,
4647 soFar
, groups
, group
, i
,
4648 preFilters
, filters
,
4649 checkContext
= !xml
&& context
!== document
,
4650 // Token cache should maintain spaces
4651 key
= ( checkContext
? "<s>" : "" ) + selector
.replace( rtrim
, "$1<s>" ),
4652 cached
= tokenCache
[ expando
][ key
];
4655 return parseOnly
? 0 : slice
.call( cached
, 0 );
4661 preFilters
= Expr
.preFilter
;
4662 filters
= Expr
.filter
;
4666 // Comma and first run
4667 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
4669 soFar
= soFar
.slice( match
[0].length
);
4670 tokens
.selector
= group
;
4672 groups
.push( tokens
= [] );
4675 // Need to make sure we're within a narrower context if necessary
4676 // Adding a descendant combinator will generate what is needed
4677 if ( checkContext
) {
4678 soFar
= " " + soFar
;
4685 if ( (match
= rcombinators
.exec( soFar
)) ) {
4687 soFar
= soFar
.slice( match
[0].length
);
4689 // Cast descendant combinators to space
4690 matched
= tokens
.push({
4691 part
: match
.pop().replace( rtrim
, " " ),
4698 for ( type
in filters
) {
4699 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
4700 ( match
= preFilters
[ type
](match
, context
, xml
) )) ) {
4703 soFar
= soFar
.slice( match
[0].length
);
4704 matched
= tokens
.push({
4706 string
: match
.shift(),
4717 // Attach the full group as a selector
4719 tokens
.selector
= group
;
4722 // Return the length of the invalid excess
4723 // if we're just parsing
4724 // Otherwise, throw an error or return tokens
4728 Sizzle
.error( selector
) :
4730 slice
.call( tokenCache(key
, groups
), 0 );
4733 function addCombinator( matcher
, combinator
, context
, xml
) {
4734 var dir
= combinator
.dir
,
4738 // If there is no matcher to check, check against the context
4739 matcher = function( elem
) {
4740 return elem
=== context
;
4743 return combinator
.first
?
4745 while ( (elem
= elem
[ dir
]) ) {
4746 if ( elem
.nodeType
=== 1 ) {
4747 return matcher( elem
) && elem
;
4753 while ( (elem
= elem
[ dir
]) ) {
4754 if ( elem
.nodeType
=== 1 ) {
4755 if ( matcher( elem
) ) {
4763 dirkey
= doneName
+ "." + dirruns
,
4764 cachedkey
= dirkey
+ "." + cachedruns
;
4765 while ( (elem
= elem
[ dir
]) ) {
4766 if ( elem
.nodeType
=== 1 ) {
4767 if ( (cache
= elem
[ expando
]) === cachedkey
) {
4769 } else if ( typeof cache
=== "string" && cache
.indexOf(dirkey
) === 0 ) {
4770 if ( elem
.sizset
) {
4774 elem
[ expando
] = cachedkey
;
4775 if ( matcher( elem
) ) {
4779 elem
.sizset
= false;
4786 function addMatcher( higher
, deeper
) {
4789 var result
= deeper( elem
);
4790 return result
&& higher( result
=== true ? elem
: result
);
4795 // ["TAG", ">", "ID", " ", "CLASS"]
4796 function matcherFromTokens( tokens
, context
, xml
) {
4800 for ( ; (token
= tokens
[i
]); i
++ ) {
4801 if ( Expr
.relative
[ token
.part
] ) {
4802 matcher
= addCombinator( matcher
, Expr
.relative
[ token
.part
], context
, xml
);
4804 matcher
= addMatcher( matcher
, Expr
.filter
[ token
.part
].apply(null, token
.captures
.concat( context
, xml
)) );
4811 function matcherFromGroupMatchers( matchers
) {
4812 return function( elem
) {
4815 for ( ; (matcher
= matchers
[j
]); j
++ ) {
4816 if ( matcher(elem
) ) {
4824 compile
= Sizzle
.compile = function( selector
, context
, xml
) {
4826 cached
= compilerCache
[ expando
][ selector
];
4828 // Return a cached group function if already generated (context dependent)
4829 if ( cached
&& cached
.context
=== context
) {
4833 // Generate a function of recursive functions that can be used to check each element
4834 group
= tokenize( selector
, context
, xml
);
4835 for ( i
= 0, len
= group
.length
; i
< len
; i
++ ) {
4836 group
[i
] = matcherFromTokens(group
[i
], context
, xml
);
4839 // Cache the compiled function
4840 cached
= compilerCache( selector
, matcherFromGroupMatchers(group
) );
4841 cached
.context
= context
;
4842 cached
.runs
= cached
.dirruns
= 0;
4846 function multipleContexts( selector
, contexts
, results
, seed
) {
4848 len
= contexts
.length
;
4849 for ( ; i
< len
; i
++ ) {
4850 Sizzle( selector
, contexts
[i
], results
, seed
);
4854 function handlePOSGroup( selector
, posfilter
, argument
, contexts
, seed
, not
) {
4856 fn
= Expr
.setFilters
[ posfilter
.toLowerCase() ];
4859 Sizzle
.error( posfilter
);
4862 if ( selector
|| !(results
= seed
) ) {
4863 multipleContexts( selector
|| "*", contexts
, (results
= []), seed
);
4866 return results
.length
> 0 ? fn( results
, argument
, not
) : [];
4869 function handlePOS( groups
, context
, results
, seed
) {
4870 var group
, part
, j
, groupLen
, token
, selector
,
4871 anchor
, elements
, match
, matched
,
4872 lastIndex
, currentContexts
, not
,
4874 len
= groups
.length
,
4875 rpos
= matchExpr
["POS"],
4876 // This is generated here in case matchExpr["POS"] is extended
4877 rposgroups
= new RegExp( "^" + rpos
.source
+ "(?!" + whitespace
+ ")", "i" ),
4878 // This is for making sure non-participating
4879 // matching groups are represented cross-browser (IE6-8)
4880 setUndefined = function() {
4882 len
= arguments
.length
- 2;
4883 for ( ; i
< len
; i
++ ) {
4884 if ( arguments
[i
] === undefined ) {
4885 match
[i
] = undefined;
4890 for ( ; i
< len
; i
++ ) {
4894 for ( j
= 0, groupLen
= group
.length
; j
< groupLen
; j
++ ) {
4896 selector
= token
.string
;
4897 if ( token
.part
=== "PSEUDO" ) {
4898 // Reset regex index to 0
4901 while ( (match
= rpos
.exec( selector
)) ) {
4903 lastIndex
= rpos
.lastIndex
= match
.index
+ match
[0].length
;
4904 if ( lastIndex
> anchor
) {
4905 part
+= selector
.slice( anchor
, match
.index
);
4907 currentContexts
= [ context
];
4909 if ( rcombinators
.test(part
) ) {
4911 currentContexts
= elements
;
4916 if ( (not
= rendsWithNot
.test( part
)) ) {
4917 part
= part
.slice( 0, -5 ).replace( rcombinators
, "$&*" );
4921 if ( match
.length
> 1 ) {
4922 match
[0].replace( rposgroups
, setUndefined
);
4924 elements
= handlePOSGroup( part
, match
[1], match
[2], currentContexts
, elements
, not
);
4938 if ( rcombinators
.test(part
) ) {
4939 multipleContexts( part
, elements
|| [ context
], results
, seed
);
4941 Sizzle( part
, context
, results
, seed
? seed
.concat(elements
) : elements
);
4944 push
.apply( results
, elements
);
4948 // Do not sort if this is a single filter
4949 return len
=== 1 ? results
: Sizzle
.uniqueSort( results
);
4952 function select( selector
, context
, results
, seed
, xml
) {
4953 // Remove excessive whitespace
4954 selector
= selector
.replace( rtrim
, "$1" );
4955 var elements
, matcher
, cached
, elem
,
4956 i
, tokens
, token
, lastToken
, findContext
, type
,
4957 match
= tokenize( selector
, context
, xml
),
4958 contextNodeType
= context
.nodeType
;
4961 if ( matchExpr
["POS"].test(selector
) ) {
4962 return handlePOS( match
, context
, results
, seed
);
4966 elements
= slice
.call( seed
, 0 );
4968 // To maintain document order, only narrow the
4969 // set if there is one group
4970 } else if ( match
.length
=== 1 ) {
4972 // Take a shortcut and set the context if the root selector is an ID
4973 if ( (tokens
= slice
.call( match
[0], 0 )).length
> 2 &&
4974 (token
= tokens
[0]).part
=== "ID" &&
4975 contextNodeType
=== 9 && !xml
&&
4976 Expr
.relative
[ tokens
[1].part
] ) {
4978 context
= Expr
.find
["ID"]( token
.captures
[0].replace( rbackslash
, "" ), context
, xml
)[0];
4983 selector
= selector
.slice( tokens
.shift().string
.length
);
4986 findContext
= ( (match
= rsibling
.exec( tokens
[0].string
)) && !match
.index
&& context
.parentNode
) || context
;
4988 // Reduce the set if possible
4990 for ( i
= tokens
.length
- 1; i
>= 0; i
-- ) {
4993 lastToken
= token
.string
+ lastToken
;
4994 if ( Expr
.relative
[ type
] ) {
4997 if ( Expr
.order
.test(type
) ) {
4998 elements
= Expr
.find
[ type
]( token
.captures
[0].replace( rbackslash
, "" ), findContext
, xml
);
4999 if ( elements
== null ) {
5002 selector
= selector
.slice( 0, selector
.length
- lastToken
.length
) +
5003 lastToken
.replace( matchExpr
[ type
], "" );
5006 push
.apply( results
, slice
.call(elements
, 0) );
5015 // Only loop over the given elements once
5017 matcher
= compile( selector
, context
, xml
);
5018 dirruns
= matcher
.dirruns
++;
5019 if ( elements
== null ) {
5020 elements
= Expr
.find
["TAG"]( "*", (rsibling
.test( selector
) && context
.parentNode
) || context
);
5023 for ( i
= 0; (elem
= elements
[i
]); i
++ ) {
5024 cachedruns
= matcher
.runs
++;
5025 if ( matcher(elem
) ) {
5026 results
.push( elem
);
5034 if ( document
.querySelectorAll
) {
5036 var disconnectedMatch
,
5039 rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
5041 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
5042 // A support test would require too much code (would include document ready)
5043 // just skip matchesSelector for :active
5044 rbuggyMatches = [":active
"],
5045 matches = docElem.matchesSelector ||
5046 docElem.mozMatchesSelector ||
5047 docElem.webkitMatchesSelector ||
5048 docElem.oMatchesSelector ||
5049 docElem.msMatchesSelector;
5052 // Regex strategy adopted from Diego Perini
5053 assert(function( div ) {
5054 // Select is set to empty string on purpose
5055 // This is to test IE's treatment of not explictly
5056 // setting a boolean content attribute,
5057 // since its presence should be enough
5058 // http://bugs.jquery.com/ticket/12359
5059 div.innerHTML = "<select
><option selected
=''></option></select>";
5061 // IE8 - Some boolean attributes are not treated correctly
5062 if ( !div.querySelectorAll("[selected
]").length ) {
5063 rbuggyQSA.push( "\\[" + whitespace + "*(?:checked
|disabled
|ismap
|multiple
|readonly
|selected
|value
)" );
5066 // Webkit/Opera - :checked should return selected option elements
5067 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
5068 // IE8 throws error here (do not put tests after this one)
5069 if ( !div.querySelectorAll(":checked
").length ) {
5070 rbuggyQSA.push(":checked
");
5074 assert(function( div ) {
5076 // Opera 10-12/IE9 - ^= $= *= and empty values
5077 // Should not select anything
5078 div.innerHTML = "<p test
=''></p
>";
5079 if ( div.querySelectorAll("[test
^='']").length ) {
5080 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
5083 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
5084 // IE8 throws error here (do not put tests after this one)
5085 div.innerHTML = "<input type
='hidden'/>";
5086 if ( !div.querySelectorAll(":enabled
").length ) {
5087 rbuggyQSA.push(":enabled
", ":disabled
");
5091 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
5093 select = function( selector, context, results, seed, xml ) {
5094 // Only use querySelectorAll when not filtering,
5095 // when this is not xml,
5096 // and when no QSA bugs apply
5097 if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
5098 if ( context.nodeType === 9 ) {
5100 push.apply( results, slice.call(context.querySelectorAll( selector ), 0) );
5102 } catch(qsaError) {}
5103 // qSA works strangely on Element-rooted queries
5104 // We can work around this by specifying an extra ID on the root
5105 // and working up from there (Thanks to Andrew Dupont for the technique)
5106 // IE 8 doesn't work on object elements
5107 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object
" ) {
5109 old = context.getAttribute("id
"),
5110 nid = old || expando,
5111 newContext = rsibling.test( selector ) && context.parentNode || context;
5114 nid = nid.replace( rescape, "\\$&" );
5116 context.setAttribute( "id
", nid );
5119 groups = tokenize(selector, context, xml);
5120 // Trailing space is unnecessary
5121 // There is always a context check
5122 nid = "[id
='" + nid + "']";
5123 for ( i = 0, len = groups.length; i < len; i++ ) {
5124 groups[i] = nid + groups[i].selector;
5127 push.apply( results, slice.call( newContext.querySelectorAll(
5134 context.removeAttribute("id
");
5140 return oldSelect( selector, context, results, seed, xml );
5144 assert(function( div ) {
5145 // Check to see if it's possible to do matchesSelector
5146 // on a disconnected node (IE 9)
5147 disconnectedMatch = matches.call( div, "div
" );
5149 // This should fail with an exception
5150 // Gecko does not error, returns false instead
5152 matches.call( div, "[test
!='']:sizzle
" );
5153 rbuggyMatches.push( matchExpr["PSEUDO
"].source, matchExpr["POS
"].source, "!=" );
5157 // rbuggyMatches always contains :active, so no need for a length check
5158 rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
5160 Sizzle.matchesSelector = function( elem, expr ) {
5161 // Make sure that attribute selectors are quoted
5162 expr = expr.replace( rattributeQuotes, "='$1']" );
5164 // rbuggyMatches always contains :active, so no need for an existence check
5165 if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
5167 var ret = matches.call( elem, expr );
5169 // IE 9's matchesSelector returns false on disconnected nodes
5170 if ( ret || disconnectedMatch ||
5171 // As well, disconnected nodes are said to be in a document
5173 elem.document && elem.document.nodeType !== 11 ) {
5179 return Sizzle( expr, null, null, [ elem ] ).length > 0;
5186 Expr.setFilters["nth
"] = Expr.setFilters["eq
"];
5189 Expr.filters = Expr.pseudos;
5191 // Override sizzle attribute retrieval
5192 Sizzle.attr = jQuery.attr;
5193 jQuery.find = Sizzle;
5194 jQuery.expr = Sizzle.selectors;
5195 jQuery.expr[":"] = jQuery.expr.pseudos;
5196 jQuery.unique = Sizzle.uniqueSort;
5197 jQuery.text = Sizzle.getText;
5198 jQuery.isXMLDoc = Sizzle.isXML;
5199 jQuery.contains = Sizzle.contains;
5203 var runtil = /Until$/,
5204 rparentsprev = /^(?:parents|prev(?:Until|All))/,
5205 isSimple = /^.[^:#\[\.,]*$/,
5206 rneedsContext = jQuery.expr.match.needsContext,
5207 // methods guaranteed to produce a unique set when starting from a unique set
5208 guaranteedUnique = {
5216 find: function( selector ) {
5217 var i, l, length, n, r, ret,
5220 if ( typeof selector !== "string
" ) {
5221 return jQuery( selector ).filter(function() {
5222 for ( i = 0, l = self.length; i < l; i++ ) {
5223 if ( jQuery.contains( self[ i ], this ) ) {
5230 ret = this.pushStack( "", "find
", selector );
5232 for ( i = 0, l = this.length; i < l; i++ ) {
5233 length = ret.length;
5234 jQuery.find( selector, this[i], ret );
5237 // Make sure that the results are unique
5238 for ( n = length; n < ret.length; n++ ) {
5239 for ( r = 0; r < length; r++ ) {
5240 if ( ret[r] === ret[n] ) {
5252 has: function( target ) {
5254 targets = jQuery( target, this ),
5255 len = targets.length;
5257 return this.filter(function() {
5258 for ( i = 0; i < len; i++ ) {
5259 if ( jQuery.contains( this, targets[i] ) ) {
5266 not: function( selector ) {
5267 return this.pushStack( winnow(this, selector, false), "not
", selector);
5270 filter: function( selector ) {
5271 return this.pushStack( winnow(this, selector, true), "filter
", selector );
5274 is: function( selector ) {
5275 return !!selector && (
5276 typeof selector === "string
" ?
5277 // If this is a positional/relative selector, check membership in the returned set
5278 // so $("p
:first
").is("p
:last
") won't return true for a doc with two "p
".
5279 rneedsContext.test( selector ) ?
5280 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5281 jQuery.filter( selector, this ).length > 0 :
5282 this.filter( selector ).length > 0 );
5285 closest: function( selectors, context ) {
5290 pos = rneedsContext.test( selectors ) || typeof selectors !== "string
" ?
5291 jQuery( selectors, context || this.context ) :
5294 for ( ; i < l; i++ ) {
5297 while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5298 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5302 cur = cur.parentNode;
5306 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5308 return this.pushStack( ret, "closest
", selectors );
5311 // Determine the position of an element within
5312 // the matched set of elements
5313 index: function( elem ) {
5315 // No argument, return index in parent
5317 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5320 // index in selector
5321 if ( typeof elem === "string
" ) {
5322 return jQuery.inArray( this[0], jQuery( elem ) );
5325 // Locate the position of the desired element
5326 return jQuery.inArray(
5327 // If it receives a jQuery object, the first element is used
5328 elem.jquery ? elem[0] : elem, this );
5331 add: function( selector, context ) {
5332 var set = typeof selector === "string
" ?
5333 jQuery( selector, context ) :
5334 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5335 all = jQuery.merge( this.get(), set );
5337 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5339 jQuery.unique( all ) );
5342 addBack: function( selector ) {
5343 return this.add( selector == null ?
5344 this.prevObject : this.prevObject.filter(selector)
5349 jQuery.fn.andSelf = jQuery.fn.addBack;
5351 // A painfully simple check to see if an element is disconnected
5352 // from a document (should be improved, where feasible).
5353 function isDisconnected( node ) {
5354 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5357 function sibling( cur, dir ) {
5360 } while ( cur && cur.nodeType !== 1 );
5366 parent: function( elem ) {
5367 var parent = elem.parentNode;
5368 return parent && parent.nodeType !== 11 ? parent : null;
5370 parents: function( elem ) {
5371 return jQuery.dir( elem, "parentNode
" );
5373 parentsUntil: function( elem, i, until ) {
5374 return jQuery.dir( elem, "parentNode
", until );
5376 next: function( elem ) {
5377 return sibling( elem, "nextSibling
" );
5379 prev: function( elem ) {
5380 return sibling( elem, "previousSibling
" );
5382 nextAll: function( elem ) {
5383 return jQuery.dir( elem, "nextSibling
" );
5385 prevAll: function( elem ) {
5386 return jQuery.dir( elem, "previousSibling
" );
5388 nextUntil: function( elem, i, until ) {
5389 return jQuery.dir( elem, "nextSibling
", until );
5391 prevUntil: function( elem, i, until ) {
5392 return jQuery.dir( elem, "previousSibling
", until );
5394 siblings: function( elem ) {
5395 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5397 children: function( elem ) {
5398 return jQuery.sibling( elem.firstChild );
5400 contents: function( elem ) {
5401 return jQuery.nodeName( elem, "iframe
" ) ?
5402 elem.contentDocument || elem.contentWindow.document :
5403 jQuery.merge( [], elem.childNodes );
5405 }, function( name, fn ) {
5406 jQuery.fn[ name ] = function( until, selector ) {
5407 var ret = jQuery.map( this, fn, until );
5409 if ( !runtil.test( name ) ) {
5413 if ( selector && typeof selector === "string
" ) {
5414 ret = jQuery.filter( selector, ret );
5417 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5419 if ( this.length > 1 && rparentsprev.test( name ) ) {
5420 ret = ret.reverse();
5423 return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
5428 filter: function( expr, elems, not ) {
5430 expr = ":not(" + expr + ")";
5433 return elems.length === 1 ?
5434 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5435 jQuery.find.matches(expr, elems);
5438 dir: function( elem, dir, until ) {
5442 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5443 if ( cur.nodeType === 1 ) {
5444 matched.push( cur );
5451 sibling: function( n, elem ) {
5454 for ( ; n; n = n.nextSibling ) {
5455 if ( n.nodeType === 1 && n !== elem ) {
5464 // Implement the identical functionality for filter and not
5465 function winnow( elements, qualifier, keep ) {
5467 // Can't pass null or undefined to indexOf in Firefox 4
5468 // Set to 0 to skip string check
5469 qualifier = qualifier || 0;
5471 if ( jQuery.isFunction( qualifier ) ) {
5472 return jQuery.grep(elements, function( elem, i ) {
5473 var retVal = !!qualifier.call( elem, i, elem );
5474 return retVal === keep;
5477 } else if ( qualifier.nodeType ) {
5478 return jQuery.grep(elements, function( elem, i ) {
5479 return ( elem === qualifier ) === keep;
5482 } else if ( typeof qualifier === "string
" ) {
5483 var filtered = jQuery.grep(elements, function( elem ) {
5484 return elem.nodeType === 1;
5487 if ( isSimple.test( qualifier ) ) {
5488 return jQuery.filter(qualifier, filtered, !keep);
5490 qualifier = jQuery.filter( qualifier, filtered );
5494 return jQuery.grep(elements, function( elem, i ) {
5495 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5498 function createSafeFragment( document ) {
5499 var list = nodeNames.split( "|" ),
5500 safeFrag = document.createDocumentFragment();
5502 if ( safeFrag.createElement ) {
5503 while ( list.length ) {
5504 safeFrag.createElement(
5512 var nodeNames = "abbr
|article
|aside
|audio
|bdi
|canvas
|data
|datalist
|details
|figcaption
|figure
|footer
|" +
5513 "header
|hgroup
|mark
|meter
|nav
|output
|progress
|section
|summary
|time
|video
",
5514 rinlinejQuery = / jQuery\d+="(?:null|\d
+)"/g,
5515 rleadingWhitespace = /^\s+/,
5516 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5517 rtagName = /<([\w:]+)/,
5519 rhtml = /<|&#?\w+;/,
5520 rnoInnerhtml = /<(?:script|style|link)/i,
5521 rnocache = /<(?:script|object|embed|option|style)/i,
5522 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s
/>]", "i
"),
5523 rcheckableType = /^(?:checkbox|radio)$/,
5524 // checked="checked
" or checked
5525 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5526 rscriptType = /\/(java|ecma)script/i,
5527 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
5529 option: [ 1, "<select multiple
='multiple'>", "</select
>" ],
5530 legend: [ 1, "<fieldset
>", "</fieldset
>" ],
5531 thead: [ 1, "<table
>", "</table
>" ],
5532 tr: [ 2, "<table
><tbody
>", "</tbody></table
>" ],
5533 td: [ 3, "<table
><tbody
><tr
>", "</tr></tbody
></table
>" ],
5534 col: [ 2, "<table
><tbody
></tbody><colgroup>", "</colgroup></table
>" ],
5535 area: [ 1, "<map
>", "</map
>" ],
5536 _default: [ 0, "", "" ]
5538 safeFragment = createSafeFragment( document ),
5539 fragmentDiv = safeFragment.appendChild( document.createElement("div
") );
5541 wrapMap.optgroup = wrapMap.option;
5542 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5543 wrapMap.th = wrapMap.td;
5545 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5546 // unless wrapped in a div with non-breaking characters in front of it.
5547 if ( !jQuery.support.htmlSerialize ) {
5548 wrapMap._default = [ 1, "X
<div
>", "</div
>" ];
5552 text: function( value ) {
5553 return jQuery.access( this, function( value ) {
5554 return value === undefined ?
5555 jQuery.text( this ) :
5556 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5557 }, null, value, arguments.length );
5560 wrapAll: function( html ) {
5561 if ( jQuery.isFunction( html ) ) {
5562 return this.each(function(i) {
5563 jQuery(this).wrapAll( html.call(this, i) );
5568 // The elements to wrap the target around
5569 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5571 if ( this[0].parentNode ) {
5572 wrap.insertBefore( this[0] );
5575 wrap.map(function() {
5578 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5579 elem = elem.firstChild;
5589 wrapInner: function( html ) {
5590 if ( jQuery.isFunction( html ) ) {
5591 return this.each(function(i) {
5592 jQuery(this).wrapInner( html.call(this, i) );
5596 return this.each(function() {
5597 var self = jQuery( this ),
5598 contents = self.contents();
5600 if ( contents.length ) {
5601 contents.wrapAll( html );
5604 self.append( html );
5609 wrap: function( html ) {
5610 var isFunction = jQuery.isFunction( html );
5612 return this.each(function(i) {
5613 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5617 unwrap: function() {
5618 return this.parent().each(function() {
5619 if ( !jQuery.nodeName( this, "body
" ) ) {
5620 jQuery( this ).replaceWith( this.childNodes );
5625 append: function() {
5626 return this.domManip(arguments, true, function( elem ) {
5627 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5628 this.appendChild( elem );
5633 prepend: function() {
5634 return this.domManip(arguments, true, function( elem ) {
5635 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5636 this.insertBefore( elem, this.firstChild );
5641 before: function() {
5642 if ( !isDisconnected( this[0] ) ) {
5643 return this.domManip(arguments, false, function( elem ) {
5644 this.parentNode.insertBefore( elem, this );
5648 if ( arguments.length ) {
5649 var set = jQuery.clean( arguments );
5650 return this.pushStack( jQuery.merge( set, this ), "before
", this.selector );
5655 if ( !isDisconnected( this[0] ) ) {
5656 return this.domManip(arguments, false, function( elem ) {
5657 this.parentNode.insertBefore( elem, this.nextSibling );
5661 if ( arguments.length ) {
5662 var set = jQuery.clean( arguments );
5663 return this.pushStack( jQuery.merge( this, set ), "after
", this.selector );
5667 // keepData is for internal use only--do not document
5668 remove: function( selector, keepData ) {
5672 for ( ; (elem = this[i]) != null; i++ ) {
5673 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5674 if ( !keepData && elem.nodeType === 1 ) {
5675 jQuery.cleanData( elem.getElementsByTagName("*") );
5676 jQuery.cleanData( [ elem ] );
5679 if ( elem.parentNode ) {
5680 elem.parentNode.removeChild( elem );
5692 for ( ; (elem = this[i]) != null; i++ ) {
5693 // Remove element nodes and prevent memory leaks
5694 if ( elem.nodeType === 1 ) {
5695 jQuery.cleanData( elem.getElementsByTagName("*") );
5698 // Remove any remaining nodes
5699 while ( elem.firstChild ) {
5700 elem.removeChild( elem.firstChild );
5707 clone: function( dataAndEvents, deepDataAndEvents ) {
5708 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5709 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5711 return this.map( function () {
5712 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5716 html: function( value ) {
5717 return jQuery.access( this, function( value ) {
5718 var elem = this[0] || {},
5722 if ( value === undefined ) {
5723 return elem.nodeType === 1 ?
5724 elem.innerHTML.replace( rinlinejQuery, "" ) :
5728 // See if we can take a shortcut and just use innerHTML
5729 if ( typeof value === "string
" && !rnoInnerhtml.test( value ) &&
5730 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5731 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5732 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
5734 value = value.replace( rxhtmlTag, "<$1></$2>" );
5737 for (; i < l; i++ ) {
5738 // Remove element nodes and prevent memory leaks
5739 elem = this[i] || {};
5740 if ( elem.nodeType === 1 ) {
5741 jQuery.cleanData( elem.getElementsByTagName( "*" ) );
5742 elem.innerHTML = value;
5748 // If using innerHTML throws an exception, use the fallback method
5753 this.empty().append( value );
5755 }, null, value, arguments.length );
5758 replaceWith: function( value ) {
5759 if ( !isDisconnected( this[0] ) ) {
5760 // Make sure that the elements are removed from the DOM before they are inserted
5761 // this can help fix replacing a parent with child elements
5762 if ( jQuery.isFunction( value ) ) {
5763 return this.each(function(i) {
5764 var self = jQuery(this), old = self.html();
5765 self.replaceWith( value.call( this, i, old ) );
5769 if ( typeof value !== "string
" ) {
5770 value = jQuery( value ).detach();
5773 return this.each(function() {
5774 var next = this.nextSibling,
5775 parent = this.parentNode;
5777 jQuery( this ).remove();
5780 jQuery(next).before( value );
5782 jQuery(parent).append( value );
5787 return this.length ?
5788 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith
", value ) :
5792 detach: function( selector ) {
5793 return this.remove( selector, true );
5796 domManip: function( args, table, callback ) {
5798 // Flatten any nested arrays
5799 args = [].concat.apply( [], args );
5801 var results, first, fragment, iNoClone,
5807 // We can't cloneNode fragments that contain checked, in WebKit
5808 if ( !jQuery.support.checkClone && l > 1 && typeof value === "string
" && rchecked.test( value ) ) {
5809 return this.each(function() {
5810 jQuery(this).domManip( args, table, callback );
5814 if ( jQuery.isFunction(value) ) {
5815 return this.each(function(i) {
5816 var self = jQuery(this);
5817 args[0] = value.call( this, i, table ? self.html() : undefined );
5818 self.domManip( args, table, callback );
5823 results = jQuery.buildFragment( args, this, scripts );
5824 fragment = results.fragment;
5825 first = fragment.firstChild;
5827 if ( fragment.childNodes.length === 1 ) {
5832 table = table && jQuery.nodeName( first, "tr
" );
5834 // Use the original fragment for the last item instead of the first because it can end up
5835 // being emptied incorrectly in certain situations (#8070).
5836 // Fragments from the fragment cache must always be cloned and never used in place.
5837 for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
5839 table && jQuery.nodeName( this[i], "table
" ) ?
5840 findOrAppend( this[i], "tbody
" ) :
5844 jQuery.clone( fragment, true, true )
5849 // Fix #11809: Avoid leaking memory
5850 fragment = first = null;
5852 if ( scripts.length ) {
5853 jQuery.each( scripts, function( i, elem ) {
5855 if ( jQuery.ajax ) {
5865 jQuery.error("no ajax
");
5868 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
5871 if ( elem.parentNode ) {
5872 elem.parentNode.removeChild( elem );
5882 function findOrAppend( elem, tag ) {
5883 return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
5886 function cloneCopyEvent( src, dest ) {
5888 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5893 oldData = jQuery._data( src ),
5894 curData = jQuery._data( dest, oldData ),
5895 events = oldData.events;
5898 delete curData.handle;
5899 curData.events = {};
5901 for ( type in events ) {
5902 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5903 jQuery.event.add( dest, type, events[ type ][ i ] );
5908 // make the cloned public data object a copy from the original
5909 if ( curData.data ) {
5910 curData.data = jQuery.extend( {}, curData.data );
5914 function cloneFixAttributes( src, dest ) {
5917 // We do not need to do anything for non-Elements
5918 if ( dest.nodeType !== 1 ) {
5922 // clearAttributes removes the attributes, which we don't want,
5923 // but also removes the attachEvent events, which we *do* want
5924 if ( dest.clearAttributes ) {
5925 dest.clearAttributes();
5928 // mergeAttributes, in contrast, only merges back on the
5929 // original attributes, not the events
5930 if ( dest.mergeAttributes ) {
5931 dest.mergeAttributes( src );
5934 nodeName = dest.nodeName.toLowerCase();
5936 if ( nodeName === "object
" ) {
5937 // IE6-10 improperly clones children of object elements using classid.
5938 // IE10 throws NoModificationAllowedError if parent is null, #12132.
5939 if ( dest.parentNode ) {
5940 dest.outerHTML = src.outerHTML;
5943 // This path appears unavoidable for IE9. When cloning an object
5944 // element in IE9, the outerHTML strategy above is not sufficient.
5945 // If the src has innerHTML and the destination does not,
5946 // copy the src.innerHTML into the dest.innerHTML. #10324
5947 if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
5948 dest.innerHTML = src.innerHTML;
5951 } else if ( nodeName === "input
" && rcheckableType.test( src.type ) ) {
5952 // IE6-8 fails to persist the checked state of a cloned checkbox
5953 // or radio button. Worse, IE6-7 fail to give the cloned element
5954 // a checked appearance if the defaultChecked value isn't also set
5956 dest.defaultChecked = dest.checked = src.checked;
5958 // IE6-7 get confused and end up setting the value of a cloned
5959 // checkbox/radio button to an empty string instead of "on
"
5960 if ( dest.value !== src.value ) {
5961 dest.value = src.value;
5964 // IE6-8 fails to return the selected option to the default selected
5965 // state when cloning options
5966 } else if ( nodeName === "option
" ) {
5967 dest.selected = src.defaultSelected;
5969 // IE6-8 fails to set the defaultValue to the correct value when
5970 // cloning other types of input fields
5971 } else if ( nodeName === "input
" || nodeName === "textarea
" ) {
5972 dest.defaultValue = src.defaultValue;
5974 // IE blanks contents when cloning scripts
5975 } else if ( nodeName === "script
" && dest.text !== src.text ) {
5976 dest.text = src.text;
5979 // Event data gets referenced instead of copied if the expando
5981 dest.removeAttribute( jQuery.expando );
5984 jQuery.buildFragment = function( args, context, scripts ) {
5985 var fragment, cacheable, cachehit,
5988 // Set context from what may come in as undefined or a jQuery collection or a node
5989 // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
5990 // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
5991 context = context || document;
5992 context = !context.nodeType && context[0] || context;
5993 context = context.ownerDocument || context;
5995 // Only cache "small
" (1/2 KB) HTML strings that are associated with the main document
5996 // Cloning options loses the selected state, so don't cache them
5997 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
5998 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
5999 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6000 if ( args.length === 1 && typeof first === "string
" && first.length < 512 && context === document &&
6001 first.charAt(0) === "<" && !rnocache.test( first ) &&
6002 (jQuery.support.checkClone || !rchecked.test( first )) &&
6003 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
6005 // Mark cacheable and look for a hit
6007 fragment = jQuery.fragments[ first ];
6008 cachehit = fragment !== undefined;
6012 fragment = context.createDocumentFragment();
6013 jQuery.clean( args, context, fragment, scripts );
6015 // Update the cache, but only store false
6016 // unless this is a second parsing of the same content
6018 jQuery.fragments[ first ] = cachehit && fragment;
6022 return { fragment: fragment, cacheable: cacheable };
6025 jQuery.fragments = {};
6029 prependTo: "prepend
",
6030 insertBefore: "before
",
6031 insertAfter: "after
",
6032 replaceAll: "replaceWith
"
6033 }, function( name, original ) {
6034 jQuery.fn[ name ] = function( selector ) {
6038 insert = jQuery( selector ),
6040 parent = this.length === 1 && this[0].parentNode;
6042 if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
6043 insert[ original ]( this[0] );
6046 for ( ; i < l; i++ ) {
6047 elems = ( i > 0 ? this.clone(true) : this ).get();
6048 jQuery( insert[i] )[ original ]( elems );
6049 ret = ret.concat( elems );
6052 return this.pushStack( ret, name, insert.selector );
6057 function getAll( elem ) {
6058 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6059 return elem.getElementsByTagName( "*" );
6061 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6062 return elem.querySelectorAll( "*" );
6069 // Used in clean, fixes the defaultChecked property
6070 function fixDefaultChecked( elem ) {
6071 if ( rcheckableType.test( elem.type ) ) {
6072 elem.defaultChecked = elem.checked;
6077 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6083 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6084 clone = elem.cloneNode( true );
6086 // IE<=8 does not properly clone detached, unknown element nodes
6088 fragmentDiv.innerHTML = elem.outerHTML;
6089 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6092 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6093 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6094 // IE copies events bound via attachEvent when using cloneNode.
6095 // Calling detachEvent on the clone will also remove the events
6096 // from the original. In order to get around this, we use some
6097 // proprietary methods to clear the events. Thanks to MooTools
6098 // guys for this hotness.
6100 cloneFixAttributes( elem, clone );
6102 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6103 srcElements = getAll( elem );
6104 destElements = getAll( clone );
6106 // Weird iteration because IE will replace the length property
6107 // with an element if you are cloning the body and one of the
6108 // elements on the page has a name or id of "length
"
6109 for ( i = 0; srcElements[i]; ++i ) {
6110 // Ensure that the destination node is not null; Fixes #9587
6111 if ( destElements[i] ) {
6112 cloneFixAttributes( srcElements[i], destElements[i] );
6117 // Copy the events from the original to the clone
6118 if ( dataAndEvents ) {
6119 cloneCopyEvent( elem, clone );
6121 if ( deepDataAndEvents ) {
6122 srcElements = getAll( elem );
6123 destElements = getAll( clone );
6125 for ( i = 0; srcElements[i]; ++i ) {
6126 cloneCopyEvent( srcElements[i], destElements[i] );
6131 srcElements = destElements = null;
6133 // Return the cloned set
6137 clean: function( elems, context, fragment, scripts ) {
6138 var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6139 safe = context === document && safeFragment,
6142 // Ensure that context is a document
6143 if ( !context || typeof context.createDocumentFragment === "undefined" ) {
6147 // Use the already-created safe fragment if context permits
6148 for ( i = 0; (elem = elems[i]) != null; i++ ) {
6149 if ( typeof elem === "number
" ) {
6157 // Convert html string into DOM nodes
6158 if ( typeof elem === "string
" ) {
6159 if ( !rhtml.test( elem ) ) {
6160 elem = context.createTextNode( elem );
6162 // Ensure a safe container in which to render the html
6163 safe = safe || createSafeFragment( context );
6164 div = context.createElement("div
");
6165 safe.appendChild( div );
6167 // Fix "XHTML
"-style tags in all browsers
6168 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6170 // Go to html and back, then peel off extra wrappers
6171 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6172 wrap = wrapMap[ tag ] || wrapMap._default;
6174 div.innerHTML = wrap[1] + elem + wrap[2];
6176 // Move to the right depth
6178 div = div.lastChild;
6181 // Remove IE's autoinserted <tbody> from table fragments
6182 if ( !jQuery.support.tbody ) {
6184 // String was a <table>, *may* have spurious <tbody>
6185 hasBody = rtbody.test(elem);
6186 tbody = tag === "table
" && !hasBody ?
6187 div.firstChild && div.firstChild.childNodes :
6189 // String was a bare <thead> or <tfoot>
6190 wrap[1] === "<table
>" && !hasBody ?
6194 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6195 if ( jQuery.nodeName( tbody[ j ], "tbody
" ) && !tbody[ j ].childNodes.length ) {
6196 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6201 // IE completely kills leading whitespace when innerHTML is used
6202 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6203 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6206 elem = div.childNodes;
6208 // Take out of fragment container (we need a fresh div each time)
6209 div.parentNode.removeChild( div );
6213 if ( elem.nodeType ) {
6216 jQuery.merge( ret, elem );
6220 // Fix #11356: Clear elements from safeFragment
6222 elem = div = safe = null;
6225 // Reset defaultChecked for any radios and checkboxes
6226 // about to be appended to the DOM in IE 6/7 (#8060)
6227 if ( !jQuery.support.appendChecked ) {
6228 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6229 if ( jQuery.nodeName( elem, "input
" ) ) {
6230 fixDefaultChecked( elem );
6231 } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
6232 jQuery.grep( elem.getElementsByTagName("input
"), fixDefaultChecked );
6237 // Append elements to a provided document fragment
6239 // Special handling of each script element
6240 handleScript = function( elem ) {
6241 // Check if we consider it executable
6242 if ( !elem.type || rscriptType.test( elem.type ) ) {
6243 // Detach the script and store it in the scripts array (if provided) or the fragment
6244 // Return truthy to indicate that it has been handled
6246 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
6247 fragment.appendChild( elem );
6251 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6252 // Check if we're done after handling an executable script
6253 if ( !( jQuery.nodeName( elem, "script
" ) && handleScript( elem ) ) ) {
6254 // Append to fragment and handle embedded scripts
6255 fragment.appendChild( elem );
6256 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6257 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
6258 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script
") ), handleScript );
6260 // Splice the scripts into ret after their former ancestor and advance our index beyond them
6261 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6271 cleanData: function( elems, /* internal */ acceptData ) {
6272 var data, id, elem, type,
6274 internalKey = jQuery.expando,
6275 cache = jQuery.cache,
6276 deleteExpando = jQuery.support.deleteExpando,
6277 special = jQuery.event.special;
6279 for ( ; (elem = elems[i]) != null; i++ ) {
6281 if ( acceptData || jQuery.acceptData( elem ) ) {
6283 id = elem[ internalKey ];
6284 data = id && cache[ id ];
6287 if ( data.events ) {
6288 for ( type in data.events ) {
6289 if ( special[ type ] ) {
6290 jQuery.event.remove( elem, type );
6292 // This is a shortcut to avoid jQuery.event.remove's overhead
6294 jQuery.removeEvent( elem, type, data.handle );
6299 // Remove cache only if it was not already removed by jQuery.event.remove
6300 if ( cache[ id ] ) {
6304 // IE does not allow us to delete expando properties from nodes,
6305 // nor does it have a removeAttribute function on Document nodes;
6306 // we must handle all of these cases
6307 if ( deleteExpando ) {
6308 delete elem[ internalKey ];
6310 } else if ( elem.removeAttribute ) {
6311 elem.removeAttribute( internalKey );
6314 elem[ internalKey ] = null;
6317 jQuery.deletedIds.push( id );
6324 // Limit scope pollution from any deprecated API
6327 var matched, browser;
6329 // Use of jQuery.browser is frowned upon.
6330 // More details: http://api.jquery.com/jQuery.browser
6331 // jQuery.uaMatch maintained for back-compat
6332 jQuery.uaMatch = function( ua ) {
6333 ua = ua.toLowerCase();
6335 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
6336 /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
6337 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
6338 /(msie) ([\w.]+)/.exec( ua ) ||
6339 ua.indexOf("compatible
") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
6343 browser: match[ 1 ] || "",
6344 version: match[ 2 ] || "0"
6348 matched = jQuery.uaMatch( navigator.userAgent );
6351 if ( matched.browser ) {
6352 browser[ matched.browser ] = true;
6353 browser.version = matched.version;
6356 // Chrome is Webkit, but Webkit is also Safari.
6357 if ( browser.chrome ) {
6358 browser.webkit = true;
6359 } else if ( browser.webkit ) {
6360 browser.safari = true;
6363 jQuery.browser = browser;
6365 jQuery.sub = function() {
6366 function jQuerySub( selector, context ) {
6367 return new jQuerySub.fn.init( selector, context );
6369 jQuery.extend( true, jQuerySub, this );
6370 jQuerySub.superclass = this;
6371 jQuerySub.fn = jQuerySub.prototype = this();
6372 jQuerySub.fn.constructor = jQuerySub;
6373 jQuerySub.sub = this.sub;
6374 jQuerySub.fn.init = function init( selector, context ) {
6375 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
6376 context = jQuerySub( context );
6379 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
6381 jQuerySub.fn.init.prototype = jQuerySub.fn;
6382 var rootjQuerySub = jQuerySub(document);
6387 var curCSS, iframe, iframeDoc,
6388 ralpha = /alpha\([^)]*\)/i,
6389 ropacity = /opacity=([^)]*)/,
6390 rposition = /^(top|right|bottom|left)$/,
6391 // swappable if display is none or starts with table except "table
", "table
-cell
", or "table
-caption
"
6392 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6393 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6394 rmargin = /^margin/,
6395 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i
" ),
6396 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px
)[a
-z
%]+$", "i
" ),
6397 rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i
" ),
6400 cssShow = { position: "absolute
", visibility: "hidden
", display: "block
" },
6401 cssNormalTransform = {
6406 cssExpand = [ "Top
", "Right
", "Bottom
", "Left
" ],
6407 cssPrefixes = [ "Webkit
", "O
", "Moz
", "ms
" ],
6409 eventsToggle = jQuery.fn.toggle;
6411 // return a css property mapped to a potentially vendor prefixed property
6412 function vendorPropName( style, name ) {
6414 // shortcut for names that are not vendor prefixed
6415 if ( name in style ) {
6419 // check for vendor prefixed names
6420 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6422 i = cssPrefixes.length;
6425 name = cssPrefixes[ i ] + capName;
6426 if ( name in style ) {
6434 function isHidden( elem, el ) {
6436 return jQuery.css( elem, "display
" ) === "none
" || !jQuery.contains( elem.ownerDocument, elem );
6439 function showHide( elements, show ) {
6443 length = elements.length;
6445 for ( ; index < length; index++ ) {
6446 elem = elements[ index ];
6447 if ( !elem.style ) {
6450 values[ index ] = jQuery._data( elem, "olddisplay
" );
6452 // Reset the inline display of this element to learn if it is
6453 // being hidden by cascaded rules or not
6454 if ( !values[ index ] && elem.style.display === "none
" ) {
6455 elem.style.display = "";
6458 // Set elements which have been overridden with display: none
6459 // in a stylesheet to whatever the default browser style is
6460 // for such an element
6461 if ( elem.style.display === "" && isHidden( elem ) ) {
6462 values[ index ] = jQuery._data( elem, "olddisplay
", css_defaultDisplay(elem.nodeName) );
6465 display = curCSS( elem, "display
" );
6467 if ( !values[ index ] && display !== "none
" ) {
6468 jQuery._data( elem, "olddisplay
", display );
6473 // Set the display of most of the elements in a second loop
6474 // to avoid the constant reflow
6475 for ( index = 0; index < length; index++ ) {
6476 elem = elements[ index ];
6477 if ( !elem.style ) {
6480 if ( !show || elem.style.display === "none
" || elem.style.display === "" ) {
6481 elem.style.display = show ? values[ index ] || "" : "none
";
6489 css: function( name, value ) {
6490 return jQuery.access( this, function( elem, name, value ) {
6491 return value !== undefined ?
6492 jQuery.style( elem, name, value ) :
6493 jQuery.css( elem, name );
6494 }, name, value, arguments.length > 1 );
6497 return showHide( this, true );
6500 return showHide( this );
6502 toggle: function( state, fn2 ) {
6503 var bool = typeof state === "boolean";
6505 if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
6506 return eventsToggle.apply( this, arguments );
6509 return this.each(function() {
6510 if ( bool ? state : isHidden( this ) ) {
6511 jQuery( this ).show();
6513 jQuery( this ).hide();
6520 // Add in style property hooks for overriding the default
6521 // behavior of getting and setting a style property
6524 get: function( elem, computed ) {
6526 // We should always get a number back from opacity
6527 var ret = curCSS( elem, "opacity
" );
6528 return ret === "" ? "1" : ret;
6535 // Exclude the following css properties to add px
6537 "fillOpacity
": true,
6547 // Add in properties whose names you wish to fix before
6548 // setting or getting the value
6550 // normalize float css property
6551 "float": jQuery.support.cssFloat ? "cssFloat
" : "styleFloat
"
6554 // Get and set the style property on a DOM Node
6555 style: function( elem, name, value, extra ) {
6556 // Don't set styles on text and comment nodes
6557 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6561 // Make sure that we're working with the right name
6562 var ret, type, hooks,
6563 origName = jQuery.camelCase( name ),
6566 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6568 // gets hook for the prefixed version
6569 // followed by the unprefixed version
6570 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6572 // Check if we're setting a value
6573 if ( value !== undefined ) {
6574 type = typeof value;
6576 // convert relative number strings (+= or -=) to relative numbers. #7345
6577 if ( type === "string
" && (ret = rrelNum.exec( value )) ) {
6578 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6583 // Make sure that NaN and null values aren't set. See: #7116
6584 if ( value == null || type === "number
" && isNaN( value ) ) {
6588 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6589 if ( type === "number
" && !jQuery.cssNumber[ origName ] ) {
6593 // If a hook was provided, use that value, otherwise just set the specified value
6594 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6595 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6598 style[ name ] = value;
6603 // If a hook was provided get the non-computed value from there
6604 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6608 // Otherwise just get the value from the style object
6609 return style[ name ];
6613 css: function( elem, name, numeric, extra ) {
6614 var val, num, hooks,
6615 origName = jQuery.camelCase( name );
6617 // Make sure that we're working with the right name
6618 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6620 // gets hook for the prefixed version
6621 // followed by the unprefixed version
6622 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6624 // If a hook was provided get the computed value from there
6625 if ( hooks && "get" in hooks ) {
6626 val = hooks.get( elem, true, extra );
6629 // Otherwise, if a way to get the computed value exists, use that
6630 if ( val === undefined ) {
6631 val = curCSS( elem, name );
6634 //convert "normal
" to computed value
6635 if ( val === "normal
" && name in cssNormalTransform ) {
6636 val = cssNormalTransform[ name ];
6639 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6640 if ( numeric || extra !== undefined ) {
6641 num = parseFloat( val );
6642 return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
6647 // A method for quickly swapping in/out CSS properties to get correct calculations
6648 swap: function( elem, options, callback ) {
6652 // Remember the old values, and insert the new ones
6653 for ( name in options ) {
6654 old[ name ] = elem.style[ name ];
6655 elem.style[ name ] = options[ name ];
6658 ret = callback.call( elem );
6660 // Revert the old values
6661 for ( name in options ) {
6662 elem.style[ name ] = old[ name ];
6669 // NOTE: To any future maintainer, we've window.getComputedStyle
6670 // because jsdom on node.js will break without it.
6671 if ( window.getComputedStyle ) {
6672 curCSS = function( elem, name ) {
6673 var ret, width, minWidth, maxWidth,
6674 computed = window.getComputedStyle( elem, null ),
6679 ret = computed[ name ];
6680 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6681 ret = jQuery.style( elem, name );
6684 // A tribute to the "awesome hack by Dean Edwards
"
6685 // Chrome < 17 and Safari 5.0 uses "computed value
" instead of "used value
" for margin-right
6686 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6687 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6688 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6689 width = style.width;
6690 minWidth = style.minWidth;
6691 maxWidth = style.maxWidth;
6693 style.minWidth = style.maxWidth = style.width = ret;
6694 ret = computed.width;
6696 style.width = width;
6697 style.minWidth = minWidth;
6698 style.maxWidth = maxWidth;
6704 } else if ( document.documentElement.currentStyle ) {
6705 curCSS = function( elem, name ) {
6707 ret = elem.currentStyle && elem.currentStyle[ name ],
6710 // Avoid setting ret to empty string here
6711 // so we don't default to auto
6712 if ( ret == null && style && style[ name ] ) {
6713 ret = style[ name ];
6716 // From the awesome hack by Dean Edwards
6717 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6719 // If we're not dealing with a regular pixel number
6720 // but a number that has a weird ending, we need to convert it to pixels
6721 // but not position css attributes, as those are proportional to the parent element instead
6722 // and we can't measure the parent instead because it might trigger a "stacking dolls
" problem
6723 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6725 // Remember the original values
6727 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6729 // Put in the new values to get a computed value out
6731 elem.runtimeStyle.left = elem.currentStyle.left;
6733 style.left = name === "fontSize
" ? "1em
" : ret;
6734 ret = style.pixelLeft + "px
";
6736 // Revert the changed values
6739 elem.runtimeStyle.left = rsLeft;
6743 return ret === "" ? "auto
" : ret;
6747 function setPositiveNumber( elem, value, subtract ) {
6748 var matches = rnumsplit.exec( value );
6750 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px
" ) :
6754 function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
6755 var i = extra === ( isBorderBox ? "border
" : "content
" ) ?
6756 // If we already have the right measurement, avoid augmentation
6758 // Otherwise initialize for horizontal or vertical properties
6759 name === "width
" ? 1 : 0,
6763 for ( ; i < 4; i += 2 ) {
6764 // both box models exclude margin, so add it if we want it
6765 if ( extra === "margin
" ) {
6766 // we use jQuery.css instead of curCSS here
6767 // because of the reliableMarginRight CSS hook!
6768 val += jQuery.css( elem, extra + cssExpand[ i ], true );
6771 // From this point on we use curCSS for maximum performance (relevant in animations)
6772 if ( isBorderBox ) {
6773 // border-box includes padding, so remove it if we want content
6774 if ( extra === "content
" ) {
6775 val -= parseFloat( curCSS( elem, "padding
" + cssExpand[ i ] ) ) || 0;
6778 // at this point, extra isn't border nor margin, so remove border
6779 if ( extra !== "margin
" ) {
6780 val -= parseFloat( curCSS( elem, "border
" + cssExpand[ i ] + "Width
" ) ) || 0;
6783 // at this point, extra isn't content, so add padding
6784 val += parseFloat( curCSS( elem, "padding
" + cssExpand[ i ] ) ) || 0;
6786 // at this point, extra isn't content nor padding, so add border
6787 if ( extra !== "padding
" ) {
6788 val += parseFloat( curCSS( elem, "border
" + cssExpand[ i ] + "Width
" ) ) || 0;
6796 function getWidthOrHeight( elem, name, extra ) {
6798 // Start with offset property, which is equivalent to the border-box value
6799 var val = name === "width
" ? elem.offsetWidth : elem.offsetHeight,
6800 valueIsBorderBox = true,
6801 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing
" ) === "border
-box
";
6803 // some non-html elements return undefined for offsetWidth, so check for null/undefined
6804 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6805 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6806 if ( val <= 0 || val == null ) {
6807 // Fall back to computed then uncomputed css if necessary
6808 val = curCSS( elem, name );
6809 if ( val < 0 || val == null ) {
6810 val = elem.style[ name ];
6813 // Computed unit is not pixels. Stop here and return.
6814 if ( rnumnonpx.test(val) ) {
6818 // we need the check for style in case a browser which returns unreliable values
6819 // for getComputedStyle silently falls back to the reliable elem.style
6820 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
6822 // Normalize "", auto, and prepare for extra
6823 val = parseFloat( val ) || 0;
6826 // use the active box-sizing model to add/subtract irrelevant styles
6828 augmentWidthOrHeight(
6831 extra || ( isBorderBox ? "border
" : "content
" ),
6838 // Try to determine the default display value of an element
6839 function css_defaultDisplay( nodeName ) {
6840 if ( elemdisplay[ nodeName ] ) {
6841 return elemdisplay[ nodeName ];
6844 var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
6845 display = elem.css("display
");
6848 // If the simple way fails,
6849 // get element's real default display by attaching it to a temp iframe
6850 if ( display === "none
" || display === "" ) {
6851 // Use the already-created iframe if possible
6852 iframe = document.body.appendChild(
6853 iframe || jQuery.extend( document.createElement("iframe
"), {
6860 // Create a cacheable copy of the iframe document on first call.
6861 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
6862 // document to it; WebKit & Firefox won't allow reusing the iframe document.
6863 if ( !iframeDoc || !iframe.createElement ) {
6864 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
6865 iframeDoc.write("<!doctype html
><html
><body
>");
6869 elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
6871 display = curCSS( elem, "display
" );
6872 document.body.removeChild( iframe );
6875 // Store the correct default display
6876 elemdisplay[ nodeName ] = display;
6881 jQuery.each([ "height
", "width
" ], function( i, name ) {
6882 jQuery.cssHooks[ name ] = {
6883 get: function( elem, computed, extra ) {
6885 // certain elements can have dimension info if we invisibly show them
6886 // however, it must have a current display style that would benefit from this
6887 if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display
" ) ) ) {
6888 return jQuery.swap( elem, cssShow, function() {
6889 return getWidthOrHeight( elem, name, extra );
6892 return getWidthOrHeight( elem, name, extra );
6897 set: function( elem, value, extra ) {
6898 return setPositiveNumber( elem, value, extra ?
6899 augmentWidthOrHeight(
6903 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing
" ) === "border
-box
"
6910 if ( !jQuery.support.opacity ) {
6911 jQuery.cssHooks.opacity = {
6912 get: function( elem, computed ) {
6913 // IE uses filters for opacity
6914 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6915 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
6916 computed ? "1" : "";
6919 set: function( elem, value ) {
6920 var style = elem.style,
6921 currentStyle = elem.currentStyle,
6922 opacity = jQuery.isNumeric( value ) ? "alpha(opacity
=" + value * 100 + ")" : "",
6923 filter = currentStyle && currentStyle.filter || style.filter || "";
6925 // IE has trouble with opacity if it does not have layout
6926 // Force it by setting the zoom level
6929 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6930 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
6931 style.removeAttribute ) {
6933 // Setting style.filter to null, "" & " " still leave "filter
:" in the cssText
6934 // if "filter
:" is present at all, clearType is disabled, we want to avoid this
6935 // style.removeAttribute is IE Only, but so apparently is this code path...
6936 style.removeAttribute( "filter
" );
6938 // if there there is no filter style applied in a css rule, we are done
6939 if ( currentStyle && !currentStyle.filter ) {
6944 // otherwise, set new filter values
6945 style.filter = ralpha.test( filter ) ?
6946 filter.replace( ralpha, opacity ) :
6947 filter + " " + opacity;
6952 // These hooks cannot be added until DOM ready because the support test
6953 // for it is not run until after DOM ready
6955 if ( !jQuery.support.reliableMarginRight ) {
6956 jQuery.cssHooks.marginRight = {
6957 get: function( elem, computed ) {
6958 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6959 // Work around by temporarily setting element display to inline-block
6960 return jQuery.swap( elem, { "display
": "inline
-block
" }, function() {
6962 return curCSS( elem, "marginRight
" );
6969 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
6970 // getComputedStyle returns percent when specified for top/left/bottom/right
6971 // rather than make the css module depend on the offset module, we just check for it here
6972 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
6973 jQuery.each( [ "top
", "left
" ], function( i, prop ) {
6974 jQuery.cssHooks[ prop ] = {
6975 get: function( elem, computed ) {
6977 var ret = curCSS( elem, prop );
6978 // if curCSS returns percentage, fallback to offset
6979 return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px
" : ret;
6988 if ( jQuery.expr && jQuery.expr.filters ) {
6989 jQuery.expr.filters.hidden = function( elem ) {
6990 return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display
" )) === "none
");
6993 jQuery.expr.filters.visible = function( elem ) {
6994 return !jQuery.expr.filters.hidden( elem );
6998 // These hooks are used by animate to expand properties
7003 }, function( prefix, suffix ) {
7004 jQuery.cssHooks[ prefix + suffix ] = {
7005 expand: function( value ) {
7008 // assumes a single number if not a string
7009 parts = typeof value === "string
" ? value.split(" ") : [ value ],
7012 for ( i = 0; i < 4; i++ ) {
7013 expanded[ prefix + cssExpand[ i ] + suffix ] =
7014 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7021 if ( !rmargin.test( prefix ) ) {
7022 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7028 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
7029 rselectTextarea = /^(?:select|textarea)/i;
7032 serialize: function() {
7033 return jQuery.param( this.serializeArray() );
7035 serializeArray: function() {
7036 return this.map(function(){
7037 return this.elements ? jQuery.makeArray( this.elements ) : this;
7040 return this.name && !this.disabled &&
7041 ( this.checked || rselectTextarea.test( this.nodeName ) ||
7042 rinput.test( this.type ) );
7044 .map(function( i, elem ){
7045 var val = jQuery( this ).val();
7047 return val == null ?
7049 jQuery.isArray( val ) ?
7050 jQuery.map( val, function( val, i ){
7051 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7053 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7058 //Serialize an array of form elements or a set of
7059 //key/values into a query string
7060 jQuery.param = function( a, traditional ) {
7063 add = function( key, value ) {
7064 // If value is a function, invoke it and return its value
7065 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7066 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7069 // Set traditional to true for jQuery <= 1.3.2 behavior.
7070 if ( traditional === undefined ) {
7071 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7074 // If an array was passed in, assume that it is an array of form elements.
7075 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7076 // Serialize the form elements
7077 jQuery.each( a, function() {
7078 add( this.name, this.value );
7082 // If traditional, encode the "old
" way (the way 1.3.2 or older
7083 // did it), otherwise encode params recursively.
7084 for ( prefix in a ) {
7085 buildParams( prefix, a[ prefix ], traditional, add );
7089 // Return the resulting serialization
7090 return s.join( "&" ).replace( r20, "+" );
7093 function buildParams( prefix, obj, traditional, add ) {
7096 if ( jQuery.isArray( obj ) ) {
7097 // Serialize array item.
7098 jQuery.each( obj, function( i, v ) {
7099 if ( traditional || rbracket.test( prefix ) ) {
7100 // Treat each array item as a scalar.
7104 // If array item is non-scalar (array or object), encode its
7105 // numeric index to resolve deserialization ambiguity issues.
7106 // Note that rack (as of 1.0.0) can't currently deserialize
7107 // nested arrays properly, and attempting to do so may cause
7108 // a server error. Possible fixes are to modify rack's
7109 // deserialization algorithm or to provide an option or flag
7110 // to force array serialization to be shallow.
7111 buildParams( prefix + "[" + ( typeof v === "object
" ? i : "" ) + "]", v, traditional, add );
7115 } else if ( !traditional && jQuery.type( obj ) === "object
" ) {
7116 // Serialize object item.
7117 for ( name in obj ) {
7118 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7122 // Serialize scalar item.
7126 var // Document location
7128 // Document location segments
7132 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7133 // #7653, #8125, #8152: local protocol detection
7134 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
7135 rnoContent = /^(?:GET|HEAD)$/,
7136 rprotocol = /^\/\//,
7138 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
7139 rts = /([?&])_=[^&]*/,
7140 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7142 // Keep a copy of the old load method
7143 _load = jQuery.fn.load,
7146 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7147 * 2) These are called:
7148 * - BEFORE asking for a transport
7149 * - AFTER param serialization (s.data is a string if s.processData is true)
7150 * 3) key is the dataType
7151 * 4) the catchall symbol "*" can be used
7152 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7156 /* Transports bindings
7157 * 1) key is the dataType
7158 * 2) the catchall symbol "*" can be used
7159 * 3) selection will start with transport dataType and THEN go to "*" if needed
7163 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7164 allTypes = ["*/
"] + ["*"];
7166 // #8138, IE may throw an exception when accessing
7167 // a field from window.location if document.domain has been set
7169 ajaxLocation = location.href;
7171 // Use the href attribute of an A element
7172 // since IE will modify it given document.location
7173 ajaxLocation = document.createElement( "a
" );
7174 ajaxLocation.href = "";
7175 ajaxLocation = ajaxLocation.href;
7178 // Segment location into parts
7179 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7181 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7182 function addToPrefiltersOrTransports( structure ) {
7184 // dataTypeExpression is optional and defaults to "*"
7185 return function( dataTypeExpression, func ) {
7187 if ( typeof dataTypeExpression !== "string
" ) {
7188 func = dataTypeExpression;
7189 dataTypeExpression = "*";
7192 var dataType, list, placeBefore,
7193 dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
7195 length = dataTypes.length;
7197 if ( jQuery.isFunction( func ) ) {
7198 // For each dataType in the dataTypeExpression
7199 for ( ; i < length; i++ ) {
7200 dataType = dataTypes[ i ];
7201 // We control if we're asked to add before
7202 // any existing element
7203 placeBefore = /^\+/.test( dataType );
7204 if ( placeBefore ) {
7205 dataType = dataType.substr( 1 ) || "*";
7207 list = structure[ dataType ] = structure[ dataType ] || [];
7208 // then we add to the structure accordingly
7209 list[ placeBefore ? "unshift
" : "push
" ]( func );
7215 // Base inspection function for prefilters and transports
7216 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
7217 dataType /* internal */, inspected /* internal */ ) {
7219 dataType = dataType || options.dataTypes[ 0 ];
7220 inspected = inspected || {};
7222 inspected[ dataType ] = true;
7225 list = structure[ dataType ],
7227 length = list ? list.length : 0,
7228 executeOnly = ( structure === prefilters );
7230 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
7231 selection = list[ i ]( options, originalOptions, jqXHR );
7232 // If we got redirected to another dataType
7233 // we try there if executing only and not done already
7234 if ( typeof selection === "string
" ) {
7235 if ( !executeOnly || inspected[ selection ] ) {
7236 selection = undefined;
7238 options.dataTypes.unshift( selection );
7239 selection = inspectPrefiltersOrTransports(
7240 structure, options, originalOptions, jqXHR, selection, inspected );
7244 // If we're only executing or nothing was selected
7245 // we try the catchall dataType if not done already
7246 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
7247 selection = inspectPrefiltersOrTransports(
7248 structure, options, originalOptions, jqXHR, "*", inspected );
7250 // unnecessary when only executing (prefilters)
7251 // but it'll be ignored by the caller in that case
7255 // A special extend for ajax options
7256 // that takes "flat
" options (not to be deep extended)
7258 function ajaxExtend( target, src ) {
7260 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7261 for ( key in src ) {
7262 if ( src[ key ] !== undefined ) {
7263 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
7267 jQuery.extend( true, target, deep );
7271 jQuery.fn.load = function( url, params, callback ) {
7272 if ( typeof url !== "string
" && _load ) {
7273 return _load.apply( this, arguments );
7276 // Don't do a request if no elements are being requested
7277 if ( !this.length ) {
7281 var selector, type, response,
7283 off = url.indexOf(" ");
7286 selector = url.slice( off, url.length );
7287 url = url.slice( 0, off );
7290 // If it's a function
7291 if ( jQuery.isFunction( params ) ) {
7293 // We assume that it's the callback
7297 // Otherwise, build a param string
7298 } else if ( params && typeof params === "object
" ) {
7302 // Request the remote document
7306 // if "type
" variable is undefined, then "GET
" method will be used
7310 complete: function( jqXHR, status ) {
7312 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7315 }).done(function( responseText ) {
7317 // Save response for use in complete callback
7318 response = arguments;
7320 // See if a selector was specified
7321 self.html( selector ?
7323 // Create a dummy div to hold the results
7326 // inject the contents of the document in, removing the scripts
7327 // to avoid any 'Permission Denied' errors in IE
7328 .append( responseText.replace( rscript, "" ) )
7330 // Locate the specified elements
7333 // If not, just inject the full result
7341 // Attach a bunch of functions for handling common AJAX events
7342 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend
".split( " " ), function( i, o ){
7343 jQuery.fn[ o ] = function( f ){
7344 return this.on( o, f );
7348 jQuery.each( [ "get", "post
" ], function( i, method ) {
7349 jQuery[ method ] = function( url, data, callback, type ) {
7350 // shift arguments if data argument was omitted
7351 if ( jQuery.isFunction( data ) ) {
7352 type = type || callback;
7357 return jQuery.ajax({
7369 getScript: function( url, callback ) {
7370 return jQuery.get( url, undefined, callback, "script
" );
7373 getJSON: function( url, data, callback ) {
7374 return jQuery.get( url, data, callback, "json
" );
7377 // Creates a full fledged settings object into target
7378 // with both ajaxSettings and settings fields.
7379 // If target is omitted, writes into ajaxSettings.
7380 ajaxSetup: function( target, settings ) {
7382 // Building a settings object
7383 ajaxExtend( target, jQuery.ajaxSettings );
7385 // Extending ajaxSettings
7387 target = jQuery.ajaxSettings;
7389 ajaxExtend( target, settings );
7395 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7398 contentType: "application
/x
-www
-form
-urlencoded
; charset
=UTF
-8",
7414 xml: "application
/xml, text/xml",
7417 json: "application
/json, text/javascript
",
7429 text: "responseText
"
7432 // List of data converters
7433 // 1) key format is "source_type destination_type
" (a single space in-between)
7434 // 2) the catchall symbol "*" can be used for source_type
7437 // Convert anything to text
7438 "* text
": window.String,
7440 // Text to html (true = no transformation)
7443 // Evaluate text as a json expression
7444 "text json
": jQuery.parseJSON,
7446 // Parse text as xml
7447 "text xml
": jQuery.parseXML
7450 // For options that shouldn't be deep extended:
7451 // you can add your own custom options here if
7452 // and when you create one that shouldn't be
7453 // deep extended (see ajaxExtend)
7460 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7461 ajaxTransport: addToPrefiltersOrTransports( transports ),
7464 ajax: function( url, options ) {
7466 // If url is an object, simulate pre-1.5 signature
7467 if ( typeof url === "object
" ) {
7472 // Force options to be an object
7473 options = options || {};
7475 var // ifModified key
7478 responseHeadersString,
7484 // Cross-domain detection vars
7486 // To know if global events are to be dispatched
7490 // Create the final options object
7491 s = jQuery.ajaxSetup( {}, options ),
7492 // Callbacks context
7493 callbackContext = s.context || s,
7494 // Context for global events
7495 // It's the callbackContext if one was provided in the options
7496 // and if it's a DOM node or a jQuery collection
7497 globalEventContext = callbackContext !== s &&
7498 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7499 jQuery( callbackContext ) : jQuery.event,
7501 deferred = jQuery.Deferred(),
7502 completeDeferred = jQuery.Callbacks( "once memory
" ),
7503 // Status-dependent callbacks
7504 statusCode = s.statusCode || {},
7505 // Headers (they are sent all at once)
7506 requestHeaders = {},
7507 requestHeadersNames = {},
7510 // Default abort message
7511 strAbort = "canceled
",
7517 // Caches the header
7518 setRequestHeader: function( name, value ) {
7520 var lname = name.toLowerCase();
7521 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7522 requestHeaders[ name ] = value;
7528 getAllResponseHeaders: function() {
7529 return state === 2 ? responseHeadersString : null;
7532 // Builds headers hashtable if needed
7533 getResponseHeader: function( key ) {
7535 if ( state === 2 ) {
7536 if ( !responseHeaders ) {
7537 responseHeaders = {};
7538 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7539 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7542 match = responseHeaders[ key.toLowerCase() ];
7544 return match === undefined ? null : match;
7547 // Overrides response content-type header
7548 overrideMimeType: function( type ) {
7555 // Cancel the request
7556 abort: function( statusText ) {
7557 statusText = statusText || strAbort;
7559 transport.abort( statusText );
7561 done( 0, statusText );
7566 // Callback for when everything is done
7567 // It is defined here because jslint complains if it is declared
7568 // at the end of the function (which would be more logical and readable)
7569 function done( status, nativeStatusText, responses, headers ) {
7570 var isSuccess, success, error, response, modified,
7571 statusText = nativeStatusText;
7574 if ( state === 2 ) {
7578 // State is "done
" now
7581 // Clear timeout if it exists
7582 if ( timeoutTimer ) {
7583 clearTimeout( timeoutTimer );
7586 // Dereference transport for early garbage collection
7587 // (no matter how long the jqXHR object will be used)
7588 transport = undefined;
7590 // Cache response headers
7591 responseHeadersString = headers || "";
7594 jqXHR.readyState = status > 0 ? 4 : 0;
7596 // Get response data
7598 response = ajaxHandleResponses( s, jqXHR, responses );
7601 // If successful, handle type chaining
7602 if ( status >= 200 && status < 300 || status === 304 ) {
7604 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7605 if ( s.ifModified ) {
7607 modified = jqXHR.getResponseHeader("Last
-Modified
");
7609 jQuery.lastModified[ ifModifiedKey ] = modified;
7611 modified = jqXHR.getResponseHeader("Etag
");
7613 jQuery.etag[ ifModifiedKey ] = modified;
7618 if ( status === 304 ) {
7620 statusText = "notmodified
";
7626 isSuccess = ajaxConvert( s, response );
7627 statusText = isSuccess.state;
7628 success = isSuccess.data;
7629 error = isSuccess.error;
7633 // We extract error from statusText
7634 // then normalize statusText and status for non-aborts
7636 if ( !statusText || status ) {
7637 statusText = "error
";
7644 // Set data for the fake xhr object
7645 jqXHR.status = status;
7646 jqXHR.statusText = "" + ( nativeStatusText || statusText );
7650 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7652 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7655 // Status-dependent callbacks
7656 jqXHR.statusCode( statusCode );
7657 statusCode = undefined;
7659 if ( fireGlobals ) {
7660 globalEventContext.trigger( "ajax
" + ( isSuccess ? "Success
" : "Error
" ),
7661 [ jqXHR, s, isSuccess ? success : error ] );
7665 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7667 if ( fireGlobals ) {
7668 globalEventContext.trigger( "ajaxComplete
", [ jqXHR, s ] );
7669 // Handle the global AJAX counter
7670 if ( !( --jQuery.active ) ) {
7671 jQuery.event.trigger( "ajaxStop
" );
7677 deferred.promise( jqXHR );
7678 jqXHR.success = jqXHR.done;
7679 jqXHR.error = jqXHR.fail;
7680 jqXHR.complete = completeDeferred.add;
7682 // Status-dependent callbacks
7683 jqXHR.statusCode = function( map ) {
7687 for ( tmp in map ) {
7688 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7691 tmp = map[ jqXHR.status ];
7692 jqXHR.always( tmp );
7698 // Remove hash character (#7531: and string promotion)
7699 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7700 // We also use the url parameter if available
7701 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7703 // Extract dataTypes list
7704 s
.dataTypes
= jQuery
.trim( s
.dataType
|| "*" ).toLowerCase().split( core_rspace
);
7706 // Determine if a cross-domain request is in order
7707 if ( s
.crossDomain
== null ) {
7708 parts
= rurl
.exec( s
.url
.toLowerCase() );
7709 s
.crossDomain
= !!( parts
&&
7710 ( parts
[ 1 ] != ajaxLocParts
[ 1 ] || parts
[ 2 ] != ajaxLocParts
[ 2 ] ||
7711 ( parts
[ 3 ] || ( parts
[ 1 ] === "http:" ? 80 : 443 ) ) !=
7712 ( ajaxLocParts
[ 3 ] || ( ajaxLocParts
[ 1 ] === "http:" ? 80 : 443 ) ) )
7716 // Convert data if not already a string
7717 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
7718 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
7722 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
7724 // If request was aborted inside a prefilter, stop there
7725 if ( state
=== 2 ) {
7729 // We can fire global events as of now if asked to
7730 fireGlobals
= s
.global
;
7732 // Uppercase the type
7733 s
.type
= s
.type
.toUpperCase();
7735 // Determine if request has content
7736 s
.hasContent
= !rnoContent
.test( s
.type
);
7738 // Watch for a new set of requests
7739 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
7740 jQuery
.event
.trigger( "ajaxStart" );
7743 // More options handling for requests with no content
7744 if ( !s
.hasContent
) {
7746 // If data is available, append data to url
7748 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.data
;
7749 // #9682: remove data so that it's not used in an eventual retry
7753 // Get ifModifiedKey before adding the anti-cache parameter
7754 ifModifiedKey
= s
.url
;
7756 // Add anti-cache in url if needed
7757 if ( s
.cache
=== false ) {
7759 var ts
= jQuery
.now(),
7760 // try replacing _= if it is there
7761 ret
= s
.url
.replace( rts
, "$1_=" + ts
);
7763 // if nothing was replaced, add timestamp to the end
7764 s
.url
= ret
+ ( ( ret
=== s
.url
) ? ( rquery
.test( s
.url
) ? "&" : "?" ) + "_=" + ts
: "" );
7768 // Set the correct header, if data is being sent
7769 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
7770 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
7773 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7774 if ( s
.ifModified
) {
7775 ifModifiedKey
= ifModifiedKey
|| s
.url
;
7776 if ( jQuery
.lastModified
[ ifModifiedKey
] ) {
7777 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ ifModifiedKey
] );
7779 if ( jQuery
.etag
[ ifModifiedKey
] ) {
7780 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ ifModifiedKey
] );
7784 // Set the Accepts header for the server, depending on the dataType
7785 jqXHR
.setRequestHeader(
7787 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[0] ] ?
7788 s
.accepts
[ s
.dataTypes
[0] ] + ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
7792 // Check for headers option
7793 for ( i
in s
.headers
) {
7794 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
7797 // Allow custom headers/mimetypes and early abort
7798 if ( s
.beforeSend
&& ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || state
=== 2 ) ) {
7799 // Abort if not done already and return
7800 return jqXHR
.abort();
7804 // aborting is no longer a cancellation
7807 // Install callbacks on deferreds
7808 for ( i
in { success
: 1, error
: 1, complete
: 1 } ) {
7809 jqXHR
[ i
]( s
[ i
] );
7813 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
7815 // If no transport, we auto-abort
7817 done( -1, "No Transport" );
7819 jqXHR
.readyState
= 1;
7820 // Send global event
7821 if ( fireGlobals
) {
7822 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
7825 if ( s
.async
&& s
.timeout
> 0 ) {
7826 timeoutTimer
= setTimeout( function(){
7827 jqXHR
.abort( "timeout" );
7833 transport
.send( requestHeaders
, done
);
7835 // Propagate exception as error if not done
7838 // Simply rethrow otherwise
7848 // Counter for holding the number of active queries
7851 // Last-Modified header cache for next request
7857 /* Handles responses to an ajax request:
7858 * - sets all responseXXX fields accordingly
7859 * - finds the right dataType (mediates between content-type and expected dataType)
7860 * - returns the corresponding response
7862 function ajaxHandleResponses( s
, jqXHR
, responses
) {
7864 var ct
, type
, finalDataType
, firstDataType
,
7865 contents
= s
.contents
,
7866 dataTypes
= s
.dataTypes
,
7867 responseFields
= s
.responseFields
;
7869 // Fill responseXXX fields
7870 for ( type
in responseFields
) {
7871 if ( type
in responses
) {
7872 jqXHR
[ responseFields
[type
] ] = responses
[ type
];
7876 // Remove auto dataType and get content-type in the process
7877 while( dataTypes
[ 0 ] === "*" ) {
7879 if ( ct
=== undefined ) {
7880 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "content-type" );
7884 // Check if we're dealing with a known content-type
7886 for ( type
in contents
) {
7887 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
7888 dataTypes
.unshift( type
);
7894 // Check to see if we have a response for the expected dataType
7895 if ( dataTypes
[ 0 ] in responses
) {
7896 finalDataType
= dataTypes
[ 0 ];
7898 // Try convertible dataTypes
7899 for ( type
in responses
) {
7900 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[0] ] ) {
7901 finalDataType
= type
;
7904 if ( !firstDataType
) {
7905 firstDataType
= type
;
7908 // Or just use first one
7909 finalDataType
= finalDataType
|| firstDataType
;
7912 // If we found a dataType
7913 // We add the dataType to the list if needed
7914 // and return the corresponding response
7915 if ( finalDataType
) {
7916 if ( finalDataType
!== dataTypes
[ 0 ] ) {
7917 dataTypes
.unshift( finalDataType
);
7919 return responses
[ finalDataType
];
7923 // Chain conversions given the request and the original response
7924 function ajaxConvert( s
, response
) {
7926 var conv
, conv2
, current
, tmp
,
7927 // Work with a copy of dataTypes in case we need to modify it for conversion
7928 dataTypes
= s
.dataTypes
.slice(),
7929 prev
= dataTypes
[ 0 ],
7933 // Apply the dataFilter if provided
7934 if ( s
.dataFilter
) {
7935 response
= s
.dataFilter( response
, s
.dataType
);
7938 // Create converters map with lowercased keys
7939 if ( dataTypes
[ 1 ] ) {
7940 for ( conv
in s
.converters
) {
7941 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
7945 // Convert to each sequential dataType, tolerating list modification
7946 for ( ; (current
= dataTypes
[++i
]); ) {
7948 // There's only work to do if current dataType is non-auto
7949 if ( current
!== "*" ) {
7951 // Convert response if prev dataType is non-auto and differs from current
7952 if ( prev
!== "*" && prev
!== current
) {
7954 // Seek a direct converter
7955 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
7957 // If none found, seek a pair
7959 for ( conv2
in converters
) {
7961 // If conv2 outputs current
7962 tmp
= conv2
.split(" ");
7963 if ( tmp
[ 1 ] === current
) {
7965 // If prev can be converted to accepted input
7966 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
7967 converters
[ "* " + tmp
[ 0 ] ];
7969 // Condense equivalence converters
7970 if ( conv
=== true ) {
7971 conv
= converters
[ conv2
];
7973 // Otherwise, insert the intermediate dataType
7974 } else if ( converters
[ conv2
] !== true ) {
7976 dataTypes
.splice( i
--, 0, current
);
7985 // Apply converter (if not an equivalence)
7986 if ( conv
!== true ) {
7988 // Unless errors are allowed to bubble, catch and return them
7989 if ( conv
&& s
["throws"] ) {
7990 response
= conv( response
);
7993 response
= conv( response
);
7995 return { state
: "parsererror", error
: conv
? e
: "No conversion from " + prev
+ " to " + current
};
8001 // Update prev for next iteration
8006 return { state
: "success", data
: response
};
8008 var oldCallbacks
= [],
8010 rjsonp
= /(=)\?(?=&|$)|\?\?/,
8011 nonce
= jQuery
.now();
8013 // Default jsonp settings
8016 jsonpCallback: function() {
8017 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
++ ) );
8018 this[ callback
] = true;
8023 // Detect, normalize options and install callbacks for jsonp requests
8024 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
8026 var callbackName
, overwritten
, responseContainer
,
8029 hasCallback
= s
.jsonp
!== false,
8030 replaceInUrl
= hasCallback
&& rjsonp
.test( url
),
8031 replaceInData
= hasCallback
&& !replaceInUrl
&& typeof data
=== "string" &&
8032 !( s
.contentType
|| "" ).indexOf("application/x-www-form-urlencoded") &&
8033 rjsonp
.test( data
);
8035 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8036 if ( s
.dataTypes
[ 0 ] === "jsonp" || replaceInUrl
|| replaceInData
) {
8038 // Get callback name, remembering preexisting value associated with it
8039 callbackName
= s
.jsonpCallback
= jQuery
.isFunction( s
.jsonpCallback
) ?
8042 overwritten
= window
[ callbackName
];
8044 // Insert callback into url or form data
8045 if ( replaceInUrl
) {
8046 s
.url
= url
.replace( rjsonp
, "$1" + callbackName
);
8047 } else if ( replaceInData
) {
8048 s
.data
= data
.replace( rjsonp
, "$1" + callbackName
);
8049 } else if ( hasCallback
) {
8050 s
.url
+= ( rquestion
.test( url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
8053 // Use data converter to retrieve json after script execution
8054 s
.converters
["script json"] = function() {
8055 if ( !responseContainer
) {
8056 jQuery
.error( callbackName
+ " was not called" );
8058 return responseContainer
[ 0 ];
8061 // force json dataType
8062 s
.dataTypes
[ 0 ] = "json";
8065 window
[ callbackName
] = function() {
8066 responseContainer
= arguments
;
8069 // Clean-up function (fires after converters)
8070 jqXHR
.always(function() {
8071 // Restore preexisting value
8072 window
[ callbackName
] = overwritten
;
8074 // Save back as free
8075 if ( s
[ callbackName
] ) {
8076 // make sure that re-using the options doesn't screw things around
8077 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
8079 // save the callback name for future use
8080 oldCallbacks
.push( callbackName
);
8083 // Call if it was a function and we have a response
8084 if ( responseContainer
&& jQuery
.isFunction( overwritten
) ) {
8085 overwritten( responseContainer
[ 0 ] );
8088 responseContainer
= overwritten
= undefined;
8091 // Delegate to script
8095 // Install script dataType
8098 script
: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8101 script
: /javascript|ecmascript/
8104 "text script": function( text
) {
8105 jQuery
.globalEval( text
);
8111 // Handle cache's special case and global
8112 jQuery
.ajaxPrefilter( "script", function( s
) {
8113 if ( s
.cache
=== undefined ) {
8116 if ( s
.crossDomain
) {
8122 // Bind script tag hack transport
8123 jQuery
.ajaxTransport( "script", function(s
) {
8125 // This transport only deals with cross domain requests
8126 if ( s
.crossDomain
) {
8129 head
= document
.head
|| document
.getElementsByTagName( "head" )[0] || document
.documentElement
;
8133 send: function( _
, callback
) {
8135 script
= document
.createElement( "script" );
8137 script
.async
= "async";
8139 if ( s
.scriptCharset
) {
8140 script
.charset
= s
.scriptCharset
;
8145 // Attach handlers for all browsers
8146 script
.onload
= script
.onreadystatechange = function( _
, isAbort
) {
8148 if ( isAbort
|| !script
.readyState
|| /loaded|complete/.test( script
.readyState
) ) {
8150 // Handle memory leak in IE
8151 script
.onload
= script
.onreadystatechange
= null;
8153 // Remove the script
8154 if ( head
&& script
.parentNode
) {
8155 head
.removeChild( script
);
8158 // Dereference the script
8161 // Callback if not abort
8163 callback( 200, "success" );
8167 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
8168 // This arises when a base node is used (#2709 and #4378).
8169 head
.insertBefore( script
, head
.firstChild
);
8174 script
.onload( 0, 1 );
8181 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8182 xhrOnUnloadAbort
= window
.ActiveXObject
? function() {
8183 // Abort all pending requests
8184 for ( var key
in xhrCallbacks
) {
8185 xhrCallbacks
[ key
]( 0, 1 );
8190 // Functions to create xhrs
8191 function createStandardXHR() {
8193 return new window
.XMLHttpRequest();
8197 function createActiveXHR() {
8199 return new window
.ActiveXObject( "Microsoft.XMLHTTP" );
8203 // Create the request object
8204 // (This is still attached to ajaxSettings for backward compatibility)
8205 jQuery
.ajaxSettings
.xhr
= window
.ActiveXObject
?
8206 /* Microsoft failed to properly
8207 * implement the XMLHttpRequest in IE7 (can't request local files),
8208 * so we use the ActiveXObject when it is available
8209 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8210 * we need a fallback.
8213 return !this.isLocal
&& createStandardXHR() || createActiveXHR();
8215 // For all other browsers, use the standard XMLHttpRequest object
8218 // Determine support properties
8220 jQuery
.extend( jQuery
.support
, {
8222 cors
: !!xhr
&& ( "withCredentials" in xhr
)
8224 })( jQuery
.ajaxSettings
.xhr() );
8226 // Create transport if the browser can provide an xhr
8227 if ( jQuery
.support
.ajax
) {
8229 jQuery
.ajaxTransport(function( s
) {
8230 // Cross domain only allowed if supported through XMLHttpRequest
8231 if ( !s
.crossDomain
|| jQuery
.support
.cors
) {
8236 send: function( headers
, complete
) {
8243 // Passing null username, generates a login popup on Opera (#2865)
8245 xhr
.open( s
.type
, s
.url
, s
.async
, s
.username
, s
.password
);
8247 xhr
.open( s
.type
, s
.url
, s
.async
);
8250 // Apply custom fields if provided
8251 if ( s
.xhrFields
) {
8252 for ( i
in s
.xhrFields
) {
8253 xhr
[ i
] = s
.xhrFields
[ i
];
8257 // Override mime type if needed
8258 if ( s
.mimeType
&& xhr
.overrideMimeType
) {
8259 xhr
.overrideMimeType( s
.mimeType
);
8262 // X-Requested-With header
8263 // For cross-domain requests, seeing as conditions for a preflight are
8264 // akin to a jigsaw puzzle, we simply never set it to be sure.
8265 // (it can always be set on a per-request basis or even using ajaxSetup)
8266 // For same-domain requests, won't change header if already provided.
8267 if ( !s
.crossDomain
&& !headers
["X-Requested-With"] ) {
8268 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
8271 // Need an extra try/catch for cross domain requests in Firefox 3
8273 for ( i
in headers
) {
8274 xhr
.setRequestHeader( i
, headers
[ i
] );
8278 // Do send the request
8279 // This may raise an exception which is actually
8280 // handled in jQuery.ajax (so no try/catch here)
8281 xhr
.send( ( s
.hasContent
&& s
.data
) || null );
8284 callback = function( _
, isAbort
) {
8292 // Firefox throws exceptions when accessing properties
8293 // of an xhr when a network error occurred
8294 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8297 // Was never called and is aborted or complete
8298 if ( callback
&& ( isAbort
|| xhr
.readyState
=== 4 ) ) {
8301 callback
= undefined;
8303 // Do not keep as active anymore
8305 xhr
.onreadystatechange
= jQuery
.noop
;
8306 if ( xhrOnUnloadAbort
) {
8307 delete xhrCallbacks
[ handle
];
8313 // Abort it manually if needed
8314 if ( xhr
.readyState
!== 4 ) {
8318 status
= xhr
.status
;
8319 responseHeaders
= xhr
.getAllResponseHeaders();
8321 xml
= xhr
.responseXML
;
8323 // Construct response list
8324 if ( xml
&& xml
.documentElement
/* #4958 */ ) {
8325 responses
.xml
= xml
;
8328 // When requesting binary data, IE6-9 will throw an exception
8329 // on any attempt to access responseText (#11426)
8331 responses
.text
= xhr
.responseText
;
8335 // Firefox throws an exception when accessing
8336 // statusText for faulty cross-domain requests
8338 statusText
= xhr
.statusText
;
8340 // We normalize with Webkit giving an empty statusText
8344 // Filter status for non standard behaviors
8346 // If the request is local and we have data: assume a success
8347 // (success with no data won't get notified, that's the best we
8348 // can do given current implementations)
8349 if ( !status
&& s
.isLocal
&& !s
.crossDomain
) {
8350 status
= responses
.text
? 200 : 404;
8351 // IE - #1450: sometimes returns 1223 when it should be 204
8352 } else if ( status
=== 1223 ) {
8357 } catch( firefoxAccessException
) {
8359 complete( -1, firefoxAccessException
);
8363 // Call complete if needed
8365 complete( status
, statusText
, responses
, responseHeaders
);
8370 // if we're in sync mode we fire the callback
8372 } else if ( xhr
.readyState
=== 4 ) {
8373 // (IE6 & IE7) if it's in cache and has been
8374 // retrieved directly we need to fire the callback
8375 setTimeout( callback
, 0 );
8378 if ( xhrOnUnloadAbort
) {
8379 // Create the active xhrs callbacks list if needed
8380 // and attach the unload handler
8381 if ( !xhrCallbacks
) {
8383 jQuery( window
).unload( xhrOnUnloadAbort
);
8385 // Add to list of active xhrs callbacks
8386 xhrCallbacks
[ handle
] = callback
;
8388 xhr
.onreadystatechange
= callback
;
8402 rfxtypes
= /^(?:toggle|show|hide)$/,
8403 rfxnum
= new RegExp( "^(?:([-+])=|)(" + core_pnum
+ ")([a-z%]*)$", "i" ),
8404 rrun
= /queueHooks$/,
8405 animationPrefilters
= [ defaultPrefilter
],
8407 "*": [function( prop
, value
) {
8408 var end
, unit
, prevScale
,
8409 tween
= this.createTween( prop
, value
),
8410 parts
= rfxnum
.exec( value
),
8411 target
= tween
.cur(),
8412 start
= +target
|| 0,
8417 unit
= parts
[3] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
8419 // We need to compute starting value
8420 if ( unit
!== "px" && start
) {
8421 // Iteratively approximate from a nonzero starting point
8422 // Prefer the current property, because this process will be trivial if it uses the same units
8423 // Fallback to end or a simple constant
8424 start
= jQuery
.css( tween
.elem
, prop
, true ) || end
|| 1;
8427 // If previous iteration zeroed out, double until we get *something*
8428 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8429 prevScale
= scale
= scale
|| ".5";
8432 start
= start
/ scale
;
8433 jQuery
.style( tween
.elem
, prop
, start
+ unit
);
8435 // Update scale, tolerating zeroes from tween.cur()
8436 scale
= tween
.cur() / target
;
8438 // Stop looping if we've hit the mark or scale is unchanged
8439 } while ( scale
!== 1 && scale
!== prevScale
);
8443 tween
.start
= start
;
8444 // If a +=/-= token was provided, we're doing a relative animation
8445 tween
.end
= parts
[1] ? start
+ ( parts
[1] + 1 ) * end
: end
;
8451 // Animations created synchronously will run synchronously
8452 function createFxNow() {
8453 setTimeout(function() {
8456 return ( fxNow
= jQuery
.now() );
8459 function createTweens( animation
, props
) {
8460 jQuery
.each( props
, function( prop
, value
) {
8461 var collection
= ( tweeners
[ prop
] || [] ).concat( tweeners
[ "*" ] ),
8463 length
= collection
.length
;
8464 for ( ; index
< length
; index
++ ) {
8465 if ( collection
[ index
].call( animation
, prop
, value
) ) {
8467 // we're done with this property
8474 function Animation( elem
, properties
, options
) {
8478 length
= animationPrefilters
.length
,
8479 deferred
= jQuery
.Deferred().always( function() {
8480 // don't match elem in the :animated selector
8484 var currentTime
= fxNow
|| createFxNow(),
8485 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
8486 percent
= 1 - ( remaining
/ animation
.duration
|| 0 ),
8488 length
= animation
.tweens
.length
;
8490 for ( ; index
< length
; index
++ ) {
8491 animation
.tweens
[ index
].run( percent
);
8494 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
]);
8496 if ( percent
< 1 && length
) {
8499 deferred
.resolveWith( elem
, [ animation
] );
8503 animation
= deferred
.promise({
8505 props
: jQuery
.extend( {}, properties
),
8506 opts
: jQuery
.extend( true, { specialEasing
: {} }, options
),
8507 originalProperties
: properties
,
8508 originalOptions
: options
,
8509 startTime
: fxNow
|| createFxNow(),
8510 duration
: options
.duration
,
8512 createTween: function( prop
, end
, easing
) {
8513 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
8514 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
8515 animation
.tweens
.push( tween
);
8518 stop: function( gotoEnd
) {
8520 // if we are going to the end, we want to run all the tweens
8521 // otherwise we skip this part
8522 length
= gotoEnd
? animation
.tweens
.length
: 0;
8524 for ( ; index
< length
; index
++ ) {
8525 animation
.tweens
[ index
].run( 1 );
8528 // resolve when we played the last frame
8529 // otherwise, reject
8531 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
8533 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
8538 props
= animation
.props
;
8540 propFilter( props
, animation
.opts
.specialEasing
);
8542 for ( ; index
< length
; index
++ ) {
8543 result
= animationPrefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
8549 createTweens( animation
, props
);
8551 if ( jQuery
.isFunction( animation
.opts
.start
) ) {
8552 animation
.opts
.start
.call( elem
, animation
);
8556 jQuery
.extend( tick
, {
8558 queue
: animation
.opts
.queue
,
8563 // attach callbacks from options
8564 return animation
.progress( animation
.opts
.progress
)
8565 .done( animation
.opts
.done
, animation
.opts
.complete
)
8566 .fail( animation
.opts
.fail
)
8567 .always( animation
.opts
.always
);
8570 function propFilter( props
, specialEasing
) {
8571 var index
, name
, easing
, value
, hooks
;
8573 // camelCase, specialEasing and expand cssHook pass
8574 for ( index
in props
) {
8575 name
= jQuery
.camelCase( index
);
8576 easing
= specialEasing
[ name
];
8577 value
= props
[ index
];
8578 if ( jQuery
.isArray( value
) ) {
8579 easing
= value
[ 1 ];
8580 value
= props
[ index
] = value
[ 0 ];
8583 if ( index
!== name
) {
8584 props
[ name
] = value
;
8585 delete props
[ index
];
8588 hooks
= jQuery
.cssHooks
[ name
];
8589 if ( hooks
&& "expand" in hooks
) {
8590 value
= hooks
.expand( value
);
8591 delete props
[ name
];
8593 // not quite $.extend, this wont overwrite keys already present.
8594 // also - reusing 'index' from above because we have the correct "name"
8595 for ( index
in value
) {
8596 if ( !( index
in props
) ) {
8597 props
[ index
] = value
[ index
];
8598 specialEasing
[ index
] = easing
;
8602 specialEasing
[ name
] = easing
;
8607 jQuery
.Animation
= jQuery
.extend( Animation
, {
8609 tweener: function( props
, callback
) {
8610 if ( jQuery
.isFunction( props
) ) {
8614 props
= props
.split(" ");
8619 length
= props
.length
;
8621 for ( ; index
< length
; index
++ ) {
8622 prop
= props
[ index
];
8623 tweeners
[ prop
] = tweeners
[ prop
] || [];
8624 tweeners
[ prop
].unshift( callback
);
8628 prefilter: function( callback
, prepend
) {
8630 animationPrefilters
.unshift( callback
);
8632 animationPrefilters
.push( callback
);
8637 function defaultPrefilter( elem
, props
, opts
) {
8638 var index
, prop
, value
, length
, dataShow
, tween
, hooks
, oldfire
,
8643 hidden
= elem
.nodeType
&& isHidden( elem
);
8645 // handle queue: false promises
8646 if ( !opts
.queue
) {
8647 hooks
= jQuery
._queueHooks( elem
, "fx" );
8648 if ( hooks
.unqueued
== null ) {
8650 oldfire
= hooks
.empty
.fire
;
8651 hooks
.empty
.fire = function() {
8652 if ( !hooks
.unqueued
) {
8659 anim
.always(function() {
8660 // doing this makes sure that the complete handler will be called
8661 // before this completes
8662 anim
.always(function() {
8664 if ( !jQuery
.queue( elem
, "fx" ).length
) {
8671 // height/width overflow pass
8672 if ( elem
.nodeType
=== 1 && ( "height" in props
|| "width" in props
) ) {
8673 // Make sure that nothing sneaks out
8674 // Record all 3 overflow attributes because IE does not
8675 // change the overflow attribute when overflowX and
8676 // overflowY are set to the same value
8677 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
8679 // Set display property to inline-block for height/width
8680 // animations on inline elements that are having width/height animated
8681 if ( jQuery
.css( elem
, "display" ) === "inline" &&
8682 jQuery
.css( elem
, "float" ) === "none" ) {
8684 // inline-level elements accept inline-block;
8685 // block-level elements need to be inline with layout
8686 if ( !jQuery
.support
.inlineBlockNeedsLayout
|| css_defaultDisplay( elem
.nodeName
) === "inline" ) {
8687 style
.display
= "inline-block";
8695 if ( opts
.overflow
) {
8696 style
.overflow
= "hidden";
8697 if ( !jQuery
.support
.shrinkWrapBlocks
) {
8698 anim
.done(function() {
8699 style
.overflow
= opts
.overflow
[ 0 ];
8700 style
.overflowX
= opts
.overflow
[ 1 ];
8701 style
.overflowY
= opts
.overflow
[ 2 ];
8708 for ( index
in props
) {
8709 value
= props
[ index
];
8710 if ( rfxtypes
.exec( value
) ) {
8711 delete props
[ index
];
8712 if ( value
=== ( hidden
? "hide" : "show" ) ) {
8715 handled
.push( index
);
8719 length
= handled
.length
;
8721 dataShow
= jQuery
._data( elem
, "fxshow" ) || jQuery
._data( elem
, "fxshow", {} );
8723 jQuery( elem
).show();
8725 anim
.done(function() {
8726 jQuery( elem
).hide();
8729 anim
.done(function() {
8731 jQuery
.removeData( elem
, "fxshow", true );
8732 for ( prop
in orig
) {
8733 jQuery
.style( elem
, prop
, orig
[ prop
] );
8736 for ( index
= 0 ; index
< length
; index
++ ) {
8737 prop
= handled
[ index
];
8738 tween
= anim
.createTween( prop
, hidden
? dataShow
[ prop
] : 0 );
8739 orig
[ prop
] = dataShow
[ prop
] || jQuery
.style( elem
, prop
);
8741 if ( !( prop
in dataShow
) ) {
8742 dataShow
[ prop
] = tween
.start
;
8744 tween
.end
= tween
.start
;
8745 tween
.start
= prop
=== "width" || prop
=== "height" ? 1 : 0;
8752 function Tween( elem
, options
, prop
, end
, easing
) {
8753 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
8755 jQuery
.Tween
= Tween
;
8759 init: function( elem
, options
, prop
, end
, easing
, unit
) {
8762 this.easing
= easing
|| "swing";
8763 this.options
= options
;
8764 this.start
= this.now
= this.cur();
8766 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
8769 var hooks
= Tween
.propHooks
[ this.prop
];
8771 return hooks
&& hooks
.get ?
8773 Tween
.propHooks
._default
.get( this );
8775 run: function( percent
) {
8777 hooks
= Tween
.propHooks
[ this.prop
];
8779 if ( this.options
.duration
) {
8780 this.pos
= eased
= jQuery
.easing
[ this.easing
](
8781 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
8784 this.pos
= eased
= percent
;
8786 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
8788 if ( this.options
.step
) {
8789 this.options
.step
.call( this.elem
, this.now
, this );
8792 if ( hooks
&& hooks
.set ) {
8795 Tween
.propHooks
._default
.set( this );
8801 Tween
.prototype.init
.prototype = Tween
.prototype;
8805 get: function( tween
) {
8808 if ( tween
.elem
[ tween
.prop
] != null &&
8809 (!tween
.elem
.style
|| tween
.elem
.style
[ tween
.prop
] == null) ) {
8810 return tween
.elem
[ tween
.prop
];
8813 // passing any value as a 4th parameter to .css will automatically
8814 // attempt a parseFloat and fallback to a string if the parse fails
8815 // so, simple values such as "10px" are parsed to Float.
8816 // complex values such as "rotate(1rad)" are returned as is.
8817 result
= jQuery
.css( tween
.elem
, tween
.prop
, false, "" );
8818 // Empty strings, null, undefined and "auto" are converted to 0.
8819 return !result
|| result
=== "auto" ? 0 : result
;
8821 set: function( tween
) {
8822 // use step hook for back compat - use cssHook if its there - use .style if its
8823 // available and use plain properties where available
8824 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
8825 jQuery
.fx
.step
[ tween
.prop
]( tween
);
8826 } else if ( tween
.elem
.style
&& ( tween
.elem
.style
[ jQuery
.cssProps
[ tween
.prop
] ] != null || jQuery
.cssHooks
[ tween
.prop
] ) ) {
8827 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
8829 tween
.elem
[ tween
.prop
] = tween
.now
;
8835 // Remove in 2.0 - this supports IE8's panic based approach
8836 // to setting things on disconnected nodes
8838 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
8839 set: function( tween
) {
8840 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
8841 tween
.elem
[ tween
.prop
] = tween
.now
;
8846 jQuery
.each([ "toggle", "show", "hide" ], function( i
, name
) {
8847 var cssFn
= jQuery
.fn
[ name
];
8848 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
8849 return speed
== null || typeof speed
=== "boolean" ||
8850 // special check for .toggle( handler, handler, ... )
8851 ( !i
&& jQuery
.isFunction( speed
) && jQuery
.isFunction( easing
) ) ?
8852 cssFn
.apply( this, arguments
) :
8853 this.animate( genFx( name
, true ), speed
, easing
, callback
);
8858 fadeTo: function( speed
, to
, easing
, callback
) {
8860 // show any hidden elements after setting opacity to 0
8861 return this.filter( isHidden
).css( "opacity", 0 ).show()
8863 // animate to the value specified
8864 .end().animate({ opacity
: to
}, speed
, easing
, callback
);
8866 animate: function( prop
, speed
, easing
, callback
) {
8867 var empty
= jQuery
.isEmptyObject( prop
),
8868 optall
= jQuery
.speed( speed
, easing
, callback
),
8869 doAnimation = function() {
8870 // Operate on a copy of prop so per-property easing won't be lost
8871 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
8873 // Empty animations resolve immediately
8879 return empty
|| optall
.queue
=== false ?
8880 this.each( doAnimation
) :
8881 this.queue( optall
.queue
, doAnimation
);
8883 stop: function( type
, clearQueue
, gotoEnd
) {
8884 var stopQueue = function( hooks
) {
8885 var stop
= hooks
.stop
;
8890 if ( typeof type
!== "string" ) {
8891 gotoEnd
= clearQueue
;
8895 if ( clearQueue
&& type
!== false ) {
8896 this.queue( type
|| "fx", [] );
8899 return this.each(function() {
8901 index
= type
!= null && type
+ "queueHooks",
8902 timers
= jQuery
.timers
,
8903 data
= jQuery
._data( this );
8906 if ( data
[ index
] && data
[ index
].stop
) {
8907 stopQueue( data
[ index
] );
8910 for ( index
in data
) {
8911 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
8912 stopQueue( data
[ index
] );
8917 for ( index
= timers
.length
; index
--; ) {
8918 if ( timers
[ index
].elem
=== this && (type
== null || timers
[ index
].queue
=== type
) ) {
8919 timers
[ index
].anim
.stop( gotoEnd
);
8921 timers
.splice( index
, 1 );
8925 // start the next in the queue if the last step wasn't forced
8926 // timers currently will call their complete callbacks, which will dequeue
8927 // but only if they were gotoEnd
8928 if ( dequeue
|| !gotoEnd
) {
8929 jQuery
.dequeue( this, type
);
8935 // Generate parameters to create a standard animation
8936 function genFx( type
, includeWidth
) {
8938 attrs
= { height
: type
},
8941 // if we include width, step value is 1 to do all cssExpand values,
8942 // if we don't include width, step value is 2 to skip over Left and Right
8943 includeWidth
= includeWidth
? 1 : 0;
8944 for( ; i
< 4 ; i
+= 2 - includeWidth
) {
8945 which
= cssExpand
[ i
];
8946 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
8949 if ( includeWidth
) {
8950 attrs
.opacity
= attrs
.width
= type
;
8956 // Generate shortcuts for custom animations
8958 slideDown
: genFx("show"),
8959 slideUp
: genFx("hide"),
8960 slideToggle
: genFx("toggle"),
8961 fadeIn
: { opacity
: "show" },
8962 fadeOut
: { opacity
: "hide" },
8963 fadeToggle
: { opacity
: "toggle" }
8964 }, function( name
, props
) {
8965 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
8966 return this.animate( props
, speed
, easing
, callback
);
8970 jQuery
.speed = function( speed
, easing
, fn
) {
8971 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
8972 complete
: fn
|| !fn
&& easing
||
8973 jQuery
.isFunction( speed
) && speed
,
8975 easing
: fn
&& easing
|| easing
&& !jQuery
.isFunction( easing
) && easing
8978 opt
.duration
= jQuery
.fx
.off
? 0 : typeof opt
.duration
=== "number" ? opt
.duration
:
8979 opt
.duration
in jQuery
.fx
.speeds
? jQuery
.fx
.speeds
[ opt
.duration
] : jQuery
.fx
.speeds
._default
;
8981 // normalize opt.queue - true/undefined/null -> "fx"
8982 if ( opt
.queue
== null || opt
.queue
=== true ) {
8987 opt
.old
= opt
.complete
;
8989 opt
.complete = function() {
8990 if ( jQuery
.isFunction( opt
.old
) ) {
8991 opt
.old
.call( this );
8995 jQuery
.dequeue( this, opt
.queue
);
9003 linear: function( p
) {
9006 swing: function( p
) {
9007 return 0.5 - Math
.cos( p
*Math
.PI
) / 2;
9012 jQuery
.fx
= Tween
.prototype.init
;
9013 jQuery
.fx
.tick = function() {
9015 timers
= jQuery
.timers
,
9018 for ( ; i
< timers
.length
; i
++ ) {
9019 timer
= timers
[ i
];
9020 // Checks the timer has not already been removed
9021 if ( !timer() && timers
[ i
] === timer
) {
9022 timers
.splice( i
--, 1 );
9026 if ( !timers
.length
) {
9031 jQuery
.fx
.timer = function( timer
) {
9032 if ( timer() && jQuery
.timers
.push( timer
) && !timerId
) {
9033 timerId
= setInterval( jQuery
.fx
.tick
, jQuery
.fx
.interval
);
9037 jQuery
.fx
.interval
= 13;
9039 jQuery
.fx
.stop = function() {
9040 clearInterval( timerId
);
9044 jQuery
.fx
.speeds
= {
9051 // Back Compat <1.8 extension point
9052 jQuery
.fx
.step
= {};
9054 if ( jQuery
.expr
&& jQuery
.expr
.filters
) {
9055 jQuery
.expr
.filters
.animated = function( elem
) {
9056 return jQuery
.grep(jQuery
.timers
, function( fn
) {
9057 return elem
=== fn
.elem
;
9061 var rroot
= /^(?:body|html)$/i;
9063 jQuery
.fn
.offset = function( options
) {
9064 if ( arguments
.length
) {
9065 return options
=== undefined ?
9067 this.each(function( i
) {
9068 jQuery
.offset
.setOffset( this, options
, i
);
9072 var box
, docElem
, body
, win
, clientTop
, clientLeft
, scrollTop
, scrollLeft
, top
, left
,
9074 doc
= elem
&& elem
.ownerDocument
;
9080 if ( (body
= doc
.body
) === elem
) {
9081 return jQuery
.offset
.bodyOffset( elem
);
9084 docElem
= doc
.documentElement
;
9086 // Make sure we're not dealing with a disconnected DOM node
9087 if ( !jQuery
.contains( docElem
, elem
) ) {
9088 return { top
: 0, left
: 0 };
9091 box
= elem
.getBoundingClientRect();
9092 win
= getWindow( doc
);
9093 clientTop
= docElem
.clientTop
|| body
.clientTop
|| 0;
9094 clientLeft
= docElem
.clientLeft
|| body
.clientLeft
|| 0;
9095 scrollTop
= win
.pageYOffset
|| docElem
.scrollTop
;
9096 scrollLeft
= win
.pageXOffset
|| docElem
.scrollLeft
;
9097 top
= box
.top
+ scrollTop
- clientTop
;
9098 left
= box
.left
+ scrollLeft
- clientLeft
;
9100 return { top
: top
, left
: left
};
9105 bodyOffset: function( body
) {
9106 var top
= body
.offsetTop
,
9107 left
= body
.offsetLeft
;
9109 if ( jQuery
.support
.doesNotIncludeMarginInBodyOffset
) {
9110 top
+= parseFloat( jQuery
.css(body
, "marginTop") ) || 0;
9111 left
+= parseFloat( jQuery
.css(body
, "marginLeft") ) || 0;
9114 return { top
: top
, left
: left
};
9117 setOffset: function( elem
, options
, i
) {
9118 var position
= jQuery
.css( elem
, "position" );
9120 // set position first, in-case top/left are set even on static elem
9121 if ( position
=== "static" ) {
9122 elem
.style
.position
= "relative";
9125 var curElem
= jQuery( elem
),
9126 curOffset
= curElem
.offset(),
9127 curCSSTop
= jQuery
.css( elem
, "top" ),
9128 curCSSLeft
= jQuery
.css( elem
, "left" ),
9129 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) && jQuery
.inArray("auto", [curCSSTop
, curCSSLeft
]) > -1,
9130 props
= {}, curPosition
= {}, curTop
, curLeft
;
9132 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9133 if ( calculatePosition
) {
9134 curPosition
= curElem
.position();
9135 curTop
= curPosition
.top
;
9136 curLeft
= curPosition
.left
;
9138 curTop
= parseFloat( curCSSTop
) || 0;
9139 curLeft
= parseFloat( curCSSLeft
) || 0;
9142 if ( jQuery
.isFunction( options
) ) {
9143 options
= options
.call( elem
, i
, curOffset
);
9146 if ( options
.top
!= null ) {
9147 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
9149 if ( options
.left
!= null ) {
9150 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
9153 if ( "using" in options
) {
9154 options
.using
.call( elem
, props
);
9156 curElem
.css( props
);
9164 position: function() {
9171 // Get *real* offsetParent
9172 offsetParent
= this.offsetParent(),
9174 // Get correct offsets
9175 offset
= this.offset(),
9176 parentOffset
= rroot
.test(offsetParent
[0].nodeName
) ? { top
: 0, left
: 0 } : offsetParent
.offset();
9178 // Subtract element margins
9179 // note: when an element has margin: auto the offsetLeft and marginLeft
9180 // are the same in Safari causing offset.left to incorrectly be 0
9181 offset
.top
-= parseFloat( jQuery
.css(elem
, "marginTop") ) || 0;
9182 offset
.left
-= parseFloat( jQuery
.css(elem
, "marginLeft") ) || 0;
9184 // Add offsetParent borders
9185 parentOffset
.top
+= parseFloat( jQuery
.css(offsetParent
[0], "borderTopWidth") ) || 0;
9186 parentOffset
.left
+= parseFloat( jQuery
.css(offsetParent
[0], "borderLeftWidth") ) || 0;
9188 // Subtract the two offsets
9190 top
: offset
.top
- parentOffset
.top
,
9191 left
: offset
.left
- parentOffset
.left
9195 offsetParent: function() {
9196 return this.map(function() {
9197 var offsetParent
= this.offsetParent
|| document
.body
;
9198 while ( offsetParent
&& (!rroot
.test(offsetParent
.nodeName
) && jQuery
.css(offsetParent
, "position") === "static") ) {
9199 offsetParent
= offsetParent
.offsetParent
;
9201 return offsetParent
|| document
.body
;
9207 // Create scrollLeft and scrollTop methods
9208 jQuery
.each( {scrollLeft
: "pageXOffset", scrollTop
: "pageYOffset"}, function( method
, prop
) {
9209 var top
= /Y
/.test( prop
);
9211 jQuery
.fn
[ method
] = function( val
) {
9212 return jQuery
.access( this, function( elem
, method
, val
) {
9213 var win
= getWindow( elem
);
9215 if ( val
=== undefined ) {
9216 return win
? (prop
in win
) ? win
[ prop
] :
9217 win
.document
.documentElement
[ method
] :
9223 !top
? val
: jQuery( win
).scrollLeft(),
9224 top
? val
: jQuery( win
).scrollTop()
9228 elem
[ method
] = val
;
9230 }, method
, val
, arguments
.length
, null );
9234 function getWindow( elem
) {
9235 return jQuery
.isWindow( elem
) ?
9237 elem
.nodeType
=== 9 ?
9238 elem
.defaultView
|| elem
.parentWindow
:
9241 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9242 jQuery
.each( { Height
: "height", Width
: "width" }, function( name
, type
) {
9243 jQuery
.each( { padding
: "inner" + name
, content
: type
, "": "outer" + name
}, function( defaultExtra
, funcName
) {
9244 // margin is only for outerHeight, outerWidth
9245 jQuery
.fn
[ funcName
] = function( margin
, value
) {
9246 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
9247 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
9249 return jQuery
.access( this, function( elem
, type
, value
) {
9252 if ( jQuery
.isWindow( elem
) ) {
9253 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9254 // isn't a whole lot we can do. See pull request at this URL for discussion:
9255 // https://github.com/jquery/jquery/pull/764
9256 return elem
.document
.documentElement
[ "client" + name
];
9259 // Get document width or height
9260 if ( elem
.nodeType
=== 9 ) {
9261 doc
= elem
.documentElement
;
9263 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9264 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9266 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
9267 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
9268 doc
[ "client" + name
]
9272 return value
=== undefined ?
9273 // Get width or height on the element, requesting but not forcing parseFloat
9274 jQuery
.css( elem
, type
, value
, extra
) :
9276 // Set width or height on the element
9277 jQuery
.style( elem
, type
, value
, extra
);
9278 }, type
, chainable
? margin
: undefined, chainable
, null );
9282 // Expose jQuery to the global object
9283 window
.jQuery
= window
.$ = jQuery
;
9285 // Expose jQuery as an AMD module, but only for AMD loaders that
9286 // understand the issues with loading multiple versions of jQuery
9287 // in a page that all might call define(). The loader will indicate
9288 // they have special allowances for multiple jQuery versions by
9289 // specifying define.amd.jQuery = true. Register as a named module,
9290 // since jQuery can be concatenated with other files that may use define,
9291 // but not use a proper concatenation script that understands anonymous
9292 // AMD modules. A named AMD is safest and most robust way to register.
9293 // Lowercase jquery is used because AMD module names are derived from
9294 // file names, and jQuery is normally delivered in a lowercase file name.
9295 // Do this after creating the global so that if an AMD module wants to call
9296 // noConflict to hide this version of jQuery, it will work.
9297 if ( typeof define
=== "function" && define
.amd
&& define
.amd
.jQuery
) {
9298 define( "jquery", [], function () { return jQuery
; } );