2 * jQuery JavaScript Library v1.9.0
8 * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
14 (function( window, undefined ) {
17 // A central reference to the root jQuery(document)
20 // The deferred used on DOM ready
23 // Use the correct document accordingly with window argument (sandbox)
24 document = window.document,
25 location = window.location,
27 // Map over jQuery in case of overwrite
28 _jQuery = window.jQuery,
30 // Map over the $ in case of overwrite
33 // [[Class]] -> type pairs
36 // List of deleted data cache ids, so we can reuse them
39 core_version = "1.9.0",
41 // Save a reference to some core methods
42 core_concat = core_deletedIds.concat,
43 core_push = core_deletedIds.push,
44 core_slice = core_deletedIds.slice,
45 core_indexOf = core_deletedIds.indexOf,
46 core_toString = class2type.toString,
47 core_hasOwn = class2type.hasOwnProperty,
48 core_trim = core_version.trim,
50 // Define a local copy of jQuery
51 jQuery = function( selector, context ) {
52 // The jQuery object is actually just the init constructor 'enhanced'
53 return new jQuery.fn.init( selector, context, rootjQuery );
56 // Used for matching numbers
57 core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
59 // Used for splitting on whitespace
60 core_rnotwhite = /\S+/g,
62 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
63 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
65 // A simple way to check for HTML strings
66 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
67 // Strict HTML recognition (#11290: must start with <)
68 rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
70 // Match a standalone tag
71 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
74 rvalidchars = /^[\],:{}\s]*$/,
75 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
76 rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
77 rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
79 // Matches dashed string for camelizing
81 rdashAlpha = /-([\da-z])/gi,
83 // Used by jQuery.camelCase as callback to replace()
84 fcamelCase = function( all, letter ) {
85 return letter.toUpperCase();
88 // The ready event handler and self cleanup method
89 DOMContentLoaded = function() {
90 if ( document.addEventListener ) {
91 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
93 } else if ( document.readyState === "complete" ) {
94 // we're here because readyState === "complete" in oldIE
95 // which is good enough for us to call the dom ready!
96 document.detachEvent( "onreadystatechange", DOMContentLoaded );
101 jQuery.fn = jQuery.prototype = {
102 // The current version of jQuery being used
103 jquery: core_version,
106 init: function( selector, context, rootjQuery ) {
109 // HANDLE: $(""), $(null), $(undefined), $(false)
114 // Handle HTML strings
115 if ( typeof selector === "string" ) {
116 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
117 // Assume that strings that start and end with <> are HTML and skip the regex check
118 match = [ null, selector, null ];
121 match = rquickExpr.exec( selector );
124 // Match html or make sure no context is specified for #id
125 if ( match && (match[1] || !context) ) {
127 // HANDLE: $(html) -> $(array)
129 context = context instanceof jQuery ? context[0] : context;
131 // scripts is true for back-compat
132 jQuery.merge( this, jQuery.parseHTML(
134 context && context.nodeType ? context.ownerDocument || context : document,
138 // HANDLE: $(html, props)
139 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
140 for ( match in context ) {
141 // Properties of context are called as methods if possible
142 if ( jQuery.isFunction( this[ match ] ) ) {
143 this[ match ]( context[ match ] );
145 // ...and otherwise set as attributes
147 this.attr( match, context[ match ] );
156 elem = document.getElementById( match[2] );
158 // Check parentNode to catch when Blackberry 4.6 returns
159 // nodes that are no longer in the document #6963
160 if ( elem && elem.parentNode ) {
161 // Handle the case where IE and Opera return items
162 // by name instead of ID
163 if ( elem.id !== match[2] ) {
164 return rootjQuery.find( selector );
167 // Otherwise, we inject the element directly into the jQuery object
172 this.context = document;
173 this.selector = selector;
177 // HANDLE: $(expr, $(...))
178 } else if ( !context || context.jquery ) {
179 return ( context || rootjQuery ).find( selector );
181 // HANDLE: $(expr, context)
182 // (which is just equivalent to: $(context).find(expr)
184 return this.constructor( context ).find( selector );
187 // HANDLE: $(DOMElement)
188 } else if ( selector.nodeType ) {
189 this.context = this[0] = selector;
193 // HANDLE: $(function)
194 // Shortcut for document ready
195 } else if ( jQuery.isFunction( selector ) ) {
196 return rootjQuery.ready( selector );
199 if ( selector.selector !== undefined ) {
200 this.selector = selector.selector;
201 this.context = selector.context;
204 return jQuery.makeArray( selector, this );
207 // Start with an empty selector
210 // The default length of a jQuery object is 0
213 // The number of elements contained in the matched element set
218 toArray: function() {
219 return core_slice.call( this );
222 // Get the Nth element in the matched element set OR
223 // Get the whole matched element set as a clean array
224 get: function( num ) {
227 // Return a 'clean' array
230 // Return just the object
231 ( num < 0 ? this[ this.length + num ] : this[ num ] );
234 // Take an array of elements and push it onto the stack
235 // (returning the new matched element set)
236 pushStack: function( elems ) {
238 // Build a new jQuery matched element set
239 var ret = jQuery.merge( this.constructor(), elems );
241 // Add the old object onto the stack (as a reference)
242 ret.prevObject = this;
243 ret.context = this.context;
245 // Return the newly-formed element set
249 // Execute a callback for every element in the matched set.
250 // (You can seed the arguments with an array of args, but this is
251 // only used internally.)
252 each: function( callback, args ) {
253 return jQuery.each( this, callback, args );
256 ready: function( fn ) {
258 jQuery.ready.promise().done( fn );
264 return this.pushStack( core_slice.apply( this, arguments ) );
272 return this.eq( -1 );
276 var len = this.length,
277 j = +i + ( i < 0 ? len : 0 );
278 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
281 map: function( callback ) {
282 return this.pushStack( jQuery.map(this, function( elem, i ) {
283 return callback.call( elem, i, elem );
288 return this.prevObject || this.constructor(null);
291 // For internal use only.
292 // Behaves like an Array's method, not like a jQuery method.
298 // Give the init function the jQuery prototype for later instantiation
299 jQuery.fn.init.prototype = jQuery.fn;
301 jQuery.extend = jQuery.fn.extend = function() {
302 var options, name, src, copy, copyIsArray, clone,
303 target = arguments[0] || {},
305 length = arguments.length,
308 // Handle a deep copy situation
309 if ( typeof target === "boolean" ) {
311 target = arguments[1] || {};
312 // skip the boolean and the target
316 // Handle case when target is a string or something (possible in deep copy)
317 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
321 // extend jQuery itself if only one argument is passed
322 if ( length === i ) {
327 for ( ; i < length; i++ ) {
328 // Only deal with non-null/undefined values
329 if ( (options = arguments[ i ]) != null ) {
330 // Extend the base object
331 for ( name in options ) {
332 src = target[ name ];
333 copy = options[ name ];
335 // Prevent never-ending loop
336 if ( target === copy ) {
340 // Recurse if we're merging plain objects or arrays
341 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
344 clone = src && jQuery.isArray(src) ? src : [];
347 clone = src && jQuery.isPlainObject(src) ? src : {};
350 // Never move original objects, clone them
351 target[ name ] = jQuery.extend( deep, clone, copy );
353 // Don't bring in undefined values
354 } else if ( copy !== undefined ) {
355 target[ name ] = copy;
361 // Return the modified object
366 noConflict: function( deep ) {
367 if ( window.$ === jQuery ) {
371 if ( deep && window.jQuery === jQuery ) {
372 window.jQuery = _jQuery;
378 // Is the DOM ready to be used? Set to true once it occurs.
381 // A counter to track how many items to wait for before
382 // the ready event fires. See #6781
385 // Hold (or release) the ready event
386 holdReady: function( hold ) {
390 jQuery.ready( true );
394 // Handle when the DOM is ready
395 ready: function( wait ) {
397 // Abort if there are pending holds or we're already ready
398 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
402 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
403 if ( !document.body ) {
404 return setTimeout( jQuery.ready );
407 // Remember that the DOM is ready
408 jQuery.isReady = true;
410 // If a normal DOM Ready event fired, decrement, and wait if need be
411 if ( wait !== true && --jQuery.readyWait > 0 ) {
415 // If there are functions bound, to execute
416 readyList.resolveWith( document, [ jQuery ] );
418 // Trigger any bound ready events
419 if ( jQuery.fn.trigger ) {
420 jQuery( document ).trigger("ready").off("ready");
424 // See test/unit/core.js for details concerning isFunction.
425 // Since version 1.3, DOM methods and functions like alert
426 // aren't supported. They return false on IE (#2968).
427 isFunction: function( obj ) {
428 return jQuery.type(obj) === "function";
431 isArray: Array.isArray || function( obj ) {
432 return jQuery.type(obj) === "array";
435 isWindow: function( obj ) {
436 return obj != null && obj == obj.window;
439 isNumeric: function( obj ) {
440 return !isNaN( parseFloat(obj) ) && isFinite( obj );
443 type: function( obj ) {
445 return String( obj );
447 return typeof obj === "object" || typeof obj === "function" ?
448 class2type[ core_toString.call(obj) ] || "object" :
452 isPlainObject: function( obj ) {
453 // Must be an Object.
454 // Because of IE, we also have to check the presence of the constructor property.
455 // Make sure that DOM nodes and window objects don't pass through, as well
456 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
461 // Not own constructor property must be Object
462 if ( obj.constructor &&
463 !core_hasOwn.call(obj, "constructor") &&
464 !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
468 // IE8,9 Will throw exceptions on certain host objects #9897
472 // Own properties are enumerated firstly, so to speed up,
473 // if last one is own, then all properties are own.
476 for ( key in obj ) {}
478 return key === undefined || core_hasOwn.call( obj, key );
481 isEmptyObject: function( obj ) {
483 for ( name in obj ) {
489 error: function( msg ) {
490 throw new Error( msg );
493 // data: string of html
494 // context (optional): If specified, the fragment will be created in this context, defaults to document
495 // keepScripts (optional): If true, will include scripts passed in the html string
496 parseHTML: function( data, context, keepScripts ) {
497 if ( !data || typeof data !== "string" ) {
500 if ( typeof context === "boolean" ) {
501 keepScripts = context;
504 context = context || document;
506 var parsed = rsingleTag.exec( data ),
507 scripts = !keepScripts && [];
511 return [ context.createElement( parsed[1] ) ];
514 parsed = jQuery.buildFragment( [ data ], context, scripts );
516 jQuery( scripts ).remove();
518 return jQuery.merge( [], parsed.childNodes );
521 parseJSON: function( data ) {
522 // Attempt to parse using the native JSON parser first
523 if ( window.JSON && window.JSON.parse ) {
524 return window.JSON.parse( data );
527 if ( data === null ) {
531 if ( typeof data === "string" ) {
533 // Make sure leading/trailing whitespace is removed (IE can't handle it)
534 data = jQuery.trim( data );
537 // Make sure the incoming data is actual JSON
538 // Logic borrowed from http://json.org/json2.js
539 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
540 .replace( rvalidtokens, "]" )
541 .replace( rvalidbraces, "")) ) {
543 return ( new Function( "return " + data ) )();
548 jQuery.error( "Invalid JSON: " + data );
551 // Cross-browser xml parsing
552 parseXML: function( data ) {
554 if ( !data || typeof data !== "string" ) {
558 if ( window.DOMParser ) { // Standard
559 tmp = new DOMParser();
560 xml = tmp.parseFromString( data , "text/xml" );
562 xml = new ActiveXObject( "Microsoft.XMLDOM" );
569 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
570 jQuery.error( "Invalid XML: " + data );
577 // Evaluates a script in a global context
578 // Workarounds based on findings by Jim Driscoll
579 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
580 globalEval: function( data ) {
581 if ( data && jQuery.trim( data ) ) {
582 // We use execScript on Internet Explorer
583 // We use an anonymous function so that context is window
584 // rather than jQuery in Firefox
585 ( window.execScript || function( data ) {
586 window[ "eval" ].call( window, data );
591 // Convert dashed to camelCase; used by the css and data modules
592 // Microsoft forgot to hump their vendor prefix (#9572)
593 camelCase: function( string ) {
594 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
597 nodeName: function( elem, name ) {
598 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
601 // args is for internal usage only
602 each: function( obj, callback, args ) {
606 isArray = isArraylike( obj );
610 for ( ; i < length; i++ ) {
611 value = callback.apply( obj[ i ], args );
613 if ( value === false ) {
619 value = callback.apply( obj[ i ], args );
621 if ( value === false ) {
627 // A special, fast, case for the most common use of each
630 for ( ; i < length; i++ ) {
631 value = callback.call( obj[ i ], i, obj[ i ] );
633 if ( value === false ) {
639 value = callback.call( obj[ i ], i, obj[ i ] );
641 if ( value === false ) {
651 // Use native String.trim function wherever possible
652 trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
654 return text == null ?
656 core_trim.call( text );
659 // Otherwise use our own trimming functionality
661 return text == null ?
663 ( text + "" ).replace( rtrim, "" );
666 // results is for internal usage only
667 makeArray: function( arr, results ) {
668 var ret = results || [];
671 if ( isArraylike( Object(arr) ) ) {
673 typeof arr === "string" ?
677 core_push.call( ret, arr );
684 inArray: function( elem, arr, i ) {
688 if ( core_indexOf ) {
689 return core_indexOf.call( arr, elem, i );
693 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
695 for ( ; i < len; i++ ) {
696 // Skip accessing in sparse arrays
697 if ( i in arr && arr[ i ] === elem ) {
706 merge: function( first, second ) {
707 var l = second.length,
711 if ( typeof l === "number" ) {
712 for ( ; j < l; j++ ) {
713 first[ i++ ] = second[ j ];
716 while ( second[j] !== undefined ) {
717 first[ i++ ] = second[ j++ ];
726 grep: function( elems, callback, inv ) {
730 length = elems.length;
733 // Go through the array, only saving the items
734 // that pass the validator function
735 for ( ; i < length; i++ ) {
736 retVal = !!callback( elems[ i ], i );
737 if ( inv !== retVal ) {
738 ret.push( elems[ i ] );
745 // arg is for internal usage only
746 map: function( elems, callback, arg ) {
749 length = elems.length,
750 isArray = isArraylike( elems ),
753 // Go through the array, translating each of the items to their
755 for ( ; i < length; i++ ) {
756 value = callback( elems[ i ], i, arg );
758 if ( value != null ) {
759 ret[ ret.length ] = value;
763 // Go through every key on the object,
766 value = callback( elems[ i ], i, arg );
768 if ( value != null ) {
769 ret[ ret.length ] = value;
774 // Flatten any nested arrays
775 return core_concat.apply( [], ret );
778 // A global GUID counter for objects
781 // Bind a function to a context, optionally partially applying any
783 proxy: function( fn, context ) {
784 var tmp, args, proxy;
786 if ( typeof context === "string" ) {
792 // Quick check to determine if target is callable, in the spec
793 // this throws a TypeError, but we will just return undefined.
794 if ( !jQuery.isFunction( fn ) ) {
799 args = core_slice.call( arguments, 2 );
801 return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
804 // Set the guid of unique handler to the same of original handler, so it can be removed
805 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
810 // Multifunctional method to get and set values of a collection
811 // The value/s can optionally be executed if it's a function
812 access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
814 length = elems.length,
818 if ( jQuery.type( key ) === "object" ) {
821 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
825 } else if ( value !== undefined ) {
828 if ( !jQuery.isFunction( value ) ) {
833 // Bulk operations run against the entire set
835 fn.call( elems, value );
838 // ...except when executing function values
841 fn = function( elem, key, value ) {
842 return bulk.call( jQuery( elem ), value );
848 for ( ; i < length; i++ ) {
849 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
860 length ? fn( elems[0], key ) : emptyGet;
864 return ( new Date() ).getTime();
868 jQuery.ready.promise = function( obj ) {
871 readyList = jQuery.Deferred();
873 // Catch cases where $(document).ready() is called after the browser event has already occurred.
874 // we once tried to use readyState "interactive" here, but it caused issues like the one
875 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
876 if ( document.readyState === "complete" ) {
877 // Handle it asynchronously to allow scripts the opportunity to delay ready
878 setTimeout( jQuery.ready );
880 // Standards-based browsers support DOMContentLoaded
881 } else if ( document.addEventListener ) {
882 // Use the handy event callback
883 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
885 // A fallback to window.onload, that will always work
886 window.addEventListener( "load", jQuery.ready, false );
888 // If IE event model is used
890 // Ensure firing before onload, maybe late but safe also for iframes
891 document.attachEvent( "onreadystatechange", DOMContentLoaded );
893 // A fallback to window.onload, that will always work
894 window.attachEvent( "onload", jQuery.ready );
896 // If IE and not a frame
897 // continually check to see if the document is ready
901 top = window.frameElement == null && document.documentElement;
904 if ( top && top.doScroll ) {
905 (function doScrollCheck() {
906 if ( !jQuery.isReady ) {
909 // Use the trick by Diego Perini
910 // http://javascript.nwbox.com/IEContentLoaded/
911 top.doScroll("left");
913 return setTimeout( doScrollCheck, 50 );
916 // and execute any waiting functions
923 return readyList.promise( obj );
926 // Populate the class2type map
927 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
928 class2type[ "[object " + name + "]" ] = name.toLowerCase();
931 function isArraylike( obj ) {
932 var length = obj.length,
933 type = jQuery.type( obj );
935 if ( jQuery.isWindow( obj ) ) {
939 if ( obj.nodeType === 1 && length ) {
943 return type === "array" || type !== "function" &&
945 typeof length === "number" && length > 0 && ( length - 1 ) in obj );
948 // All jQuery objects should point back to these
949 rootjQuery = jQuery(document);
950 // String to Object options format cache
951 var optionsCache = {};
953 // Convert String-formatted options into Object-formatted ones and store in cache
954 function createOptions( options ) {
955 var object = optionsCache[ options ] = {};
956 jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
957 object[ flag ] = true;
963 * Create a callback list using the following parameters:
965 * options: an optional list of space-separated options that will change how
966 * the callback list behaves or a more traditional option object
968 * By default a callback list will act like an event callback list and can be
969 * "fired" multiple times.
973 * once: will ensure the callback list can only be fired once (like a Deferred)
975 * memory: will keep track of previous values and will call any callback added
976 * after the list has been fired right away with the latest "memorized"
977 * values (like a Deferred)
979 * unique: will ensure a callback can only be added once (no duplicate in the list)
981 * stopOnFalse: interrupt callings when a callback returns false
984 jQuery.Callbacks = function( options ) {
986 // Convert options from String-formatted to Object-formatted if needed
987 // (we check in cache first)
988 options = typeof options === "string" ?
989 ( optionsCache[ options ] || createOptions( options ) ) :
990 jQuery.extend( {}, options );
992 var // Last fire value (for non-forgettable lists)
994 // Flag to know if list was already fired
996 // Flag to know if list is currently firing
998 // First callback to fire (used internally by add and fireWith)
1000 // End of the loop when firing
1002 // Index of currently firing callback (modified by remove if needed)
1004 // Actual callback list
1006 // Stack of fire calls for repeatable lists
1007 stack = !options.once && [],
1009 fire = function( data ) {
1010 memory = options.memory && data;
1012 firingIndex = firingStart || 0;
1014 firingLength = list.length;
1016 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1017 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
1018 memory = false; // To prevent further calls using add
1025 if ( stack.length ) {
1026 fire( stack.shift() );
1028 } else if ( memory ) {
1035 // Actual Callbacks object
1037 // Add a callback or a collection of callbacks to the list
1040 // First, we save the current length
1041 var start = list.length;
1042 (function add( args ) {
1043 jQuery.each( args, function( _, arg ) {
1044 var type = jQuery.type( arg );
1045 if ( type === "function" ) {
1046 if ( !options.unique || !self.has( arg ) ) {
1049 } else if ( arg && arg.length && type !== "string" ) {
1050 // Inspect recursively
1055 // Do we need to add the callbacks to the
1056 // current firing batch?
1058 firingLength = list.length;
1059 // With memory, if we're not firing then
1060 // we should call right away
1061 } else if ( memory ) {
1062 firingStart = start;
1068 // Remove a callback from the list
1069 remove: function() {
1071 jQuery.each( arguments, function( _, arg ) {
1073 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1074 list.splice( index, 1 );
1075 // Handle firing indexes
1077 if ( index <= firingLength ) {
1080 if ( index <= firingIndex ) {
1089 // Control if a given callback is in the list
1090 has: function( fn ) {
1091 return jQuery.inArray( fn, list ) > -1;
1093 // Remove all callbacks from the list
1098 // Have the list do nothing anymore
1099 disable: function() {
1100 list = stack = memory = undefined;
1104 disabled: function() {
1107 // Lock the list in its current state
1116 locked: function() {
1119 // Call all callbacks with the given context and arguments
1120 fireWith: function( context, args ) {
1122 args = [ context, args.slice ? args.slice() : args ];
1123 if ( list && ( !fired || stack ) ) {
1132 // Call all the callbacks with the given arguments
1134 self.fireWith( this, arguments );
1137 // To know if the callbacks have already been called at least once
1147 Deferred: function( func ) {
1149 // action, add listener, listener list, final state
1150 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1151 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1152 [ "notify", "progress", jQuery.Callbacks("memory") ]
1159 always: function() {
1160 deferred.done( arguments ).fail( arguments );
1163 then: function( /* fnDone, fnFail, fnProgress */ ) {
1164 var fns = arguments;
1165 return jQuery.Deferred(function( newDefer ) {
1166 jQuery.each( tuples, function( i, tuple ) {
1167 var action = tuple[ 0 ],
1168 fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
1169 // deferred[ done | fail | progress ] for forwarding actions to newDefer
1170 deferred[ tuple[1] ](function() {
1171 var returned = fn && fn.apply( this, arguments );
1172 if ( returned && jQuery.isFunction( returned.promise ) ) {
1174 .done( newDefer.resolve )
1175 .fail( newDefer.reject )
1176 .progress( newDefer.notify );
1178 newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
1185 // Get a promise for this deferred
1186 // If obj is provided, the promise aspect is added to the object
1187 promise: function( obj ) {
1188 return obj != null ? jQuery.extend( obj, promise ) : promise;
1193 // Keep pipe for back-compat
1194 promise.pipe = promise.then;
1196 // Add list-specific methods
1197 jQuery.each( tuples, function( i, tuple ) {
1198 var list = tuple[ 2 ],
1199 stateString = tuple[ 3 ];
1201 // promise[ done | fail | progress ] = list.add
1202 promise[ tuple[1] ] = list.add;
1205 if ( stateString ) {
1206 list.add(function() {
1207 // state = [ resolved | rejected ]
1208 state = stateString;
1210 // [ reject_list | resolve_list ].disable; progress_list.lock
1211 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1214 // deferred[ resolve | reject | notify ]
1215 deferred[ tuple[0] ] = function() {
1216 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
1219 deferred[ tuple[0] + "With" ] = list.fireWith;
1222 // Make the deferred a promise
1223 promise.promise( deferred );
1225 // Call given func if any
1227 func.call( deferred, deferred );
1235 when: function( subordinate /* , ..., subordinateN */ ) {
1237 resolveValues = core_slice.call( arguments ),
1238 length = resolveValues.length,
1240 // the count of uncompleted subordinates
1241 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1243 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1244 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1246 // Update function for both resolve and progress values
1247 updateFunc = function( i, contexts, values ) {
1248 return function( value ) {
1249 contexts[ i ] = this;
1250 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
1251 if( values === progressValues ) {
1252 deferred.notifyWith( contexts, values );
1253 } else if ( !( --remaining ) ) {
1254 deferred.resolveWith( contexts, values );
1259 progressValues, progressContexts, resolveContexts;
1261 // add listeners to Deferred subordinates; treat others as resolved
1263 progressValues = new Array( length );
1264 progressContexts = new Array( length );
1265 resolveContexts = new Array( length );
1266 for ( ; i < length; i++ ) {
1267 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1268 resolveValues[ i ].promise()
1269 .done( updateFunc( i, resolveContexts, resolveValues ) )
1270 .fail( deferred.reject )
1271 .progress( updateFunc( i, progressContexts, progressValues ) );
1278 // if we're not waiting on anything, resolve the master
1280 deferred.resolveWith( resolveContexts, resolveValues );
1283 return deferred.promise();
1286 jQuery.support = (function() {
1288 var support, all, a, select, opt, input, fragment, eventName, isSupported, i,
1289 div = document.createElement("div");
1292 div.setAttribute( "className", "t" );
1293 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1295 // Support tests won't run in some limited or non-browser environments
1296 all = div.getElementsByTagName("*");
1297 a = div.getElementsByTagName("a")[ 0 ];
1298 if ( !all || !a || !all.length ) {
1302 // First batch of tests
1303 select = document.createElement("select");
1304 opt = select.appendChild( document.createElement("option") );
1305 input = div.getElementsByTagName("input")[ 0 ];
1307 a.style.cssText = "top:1px;float:left;opacity:.5";
1309 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1310 getSetAttribute: div.className !== "t",
1312 // IE strips leading whitespace when .innerHTML is used
1313 leadingWhitespace: div.firstChild.nodeType === 3,
1315 // Make sure that tbody elements aren't automatically inserted
1316 // IE will insert them into empty tables
1317 tbody: !div.getElementsByTagName("tbody").length,
1319 // Make sure that link elements get serialized correctly by innerHTML
1320 // This requires a wrapper element in IE
1321 htmlSerialize: !!div.getElementsByTagName("link").length,
1323 // Get the style information from getAttribute
1324 // (IE uses .cssText instead)
1325 style: /top/.test( a.getAttribute("style") ),
1327 // Make sure that URLs aren't manipulated
1328 // (IE normalizes it by default)
1329 hrefNormalized: a.getAttribute("href") === "/a",
1331 // Make sure that element opacity exists
1332 // (IE uses filter instead)
1333 // Use a regex to work around a WebKit issue. See #5145
1334 opacity: /^0.5/.test( a.style.opacity ),
1336 // Verify style float existence
1337 // (IE uses styleFloat instead of cssFloat)
1338 cssFloat: !!a.style.cssFloat,
1340 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
1341 checkOn: !!input.value,
1343 // Make sure that a selected-by-default option has a working selected property.
1344 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1345 optSelected: opt.selected,
1347 // Tests for enctype support on a form (#6743)
1348 enctype: !!document.createElement("form").enctype,
1350 // Makes sure cloning an html5 element does not cause problems
1351 // Where outerHTML is undefined, this still works
1352 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1354 // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1355 boxModel: document.compatMode === "CSS1Compat",
1357 // Will be defined later
1358 deleteExpando: true,
1360 inlineBlockNeedsLayout: false,
1361 shrinkWrapBlocks: false,
1362 reliableMarginRight: true,
1363 boxSizingReliable: true,
1364 pixelPosition: false
1367 // Make sure checked status is properly cloned
1368 input.checked = true;
1369 support.noCloneChecked = input.cloneNode( true ).checked;
1371 // Make sure that the options inside disabled selects aren't marked as disabled
1372 // (WebKit marks them as disabled)
1373 select.disabled = true;
1374 support.optDisabled = !opt.disabled;
1380 support.deleteExpando = false;
1383 // Check if we can trust getAttribute("value")
1384 input = document.createElement("input");
1385 input.setAttribute( "value", "" );
1386 support.input = input.getAttribute( "value" ) === "";
1388 // Check if an input maintains its value after becoming a radio
1390 input.setAttribute( "type", "radio" );
1391 support.radioValue = input.value === "t";
1393 // #11217 - WebKit loses check when the name is after the checked attribute
1394 input.setAttribute( "checked", "t" );
1395 input.setAttribute( "name", "t" );
1397 fragment = document.createDocumentFragment();
1398 fragment.appendChild( input );
1400 // Check if a disconnected checkbox will retain its checked
1401 // value of true after appended to the DOM (IE6/7)
1402 support.appendChecked = input.checked;
1404 // WebKit doesn't clone checked state correctly in fragments
1405 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1408 // Opera does not clone events (and typeof div.attachEvent === undefined).
1409 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
1410 if ( div.attachEvent ) {
1411 div.attachEvent( "onclick", function() {
1412 support.noCloneEvent = false;
1415 div.cloneNode( true ).click();
1418 // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
1419 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php
1420 for ( i in { submit: true, change: true, focusin: true }) {
1421 div.setAttribute( eventName = "on" + i, "t" );
1423 support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
1426 div.style.backgroundClip = "content-box";
1427 div.cloneNode( true ).style.backgroundClip = "";
1428 support.clearCloneStyle = div.style.backgroundClip === "content-box";
1430 // Run tests that need a body at doc ready
1432 var container, marginDiv, tds,
1433 divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
1434 body = document.getElementsByTagName("body")[0];
1437 // Return for frameset docs that don't have a body
1441 container = document.createElement("div");
1442 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
1444 body.appendChild( container ).appendChild( div );
1447 // Check if table cells still have offsetWidth/Height when they are set
1448 // to display:none and there are still other visible table cells in a
1449 // table row; if so, offsetWidth/Height are not reliable for use when
1450 // determining if an element has been hidden directly using
1451 // display:none (it is still safe to use offsets if a parent element is
1452 // hidden; don safety goggles and see bug #4512 for more information).
1453 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
1454 tds = div.getElementsByTagName("td");
1455 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
1456 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1458 tds[ 0 ].style.display = "";
1459 tds[ 1 ].style.display = "none";
1462 // Check if empty table cells still have offsetWidth/Height
1463 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1465 // Check box-sizing and margin behavior
1467 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%;";
1468 support.boxSizing = ( div.offsetWidth === 4 );
1469 support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1471 // Use window.getComputedStyle because jsdom on node.js will break without it.
1472 if ( window.getComputedStyle ) {
1473 support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
1474 support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
1476 // Check if div with explicit width and no margin-right incorrectly
1477 // gets computed margin-right based on width of container. (#3333)
1478 // Fails in WebKit before Feb 2011 nightlies
1479 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1480 marginDiv = div.appendChild( document.createElement("div") );
1481 marginDiv.style.cssText = div.style.cssText = divReset;
1482 marginDiv.style.marginRight = marginDiv.style.width = "0";
1483 div.style.width = "1px";
1485 support.reliableMarginRight =
1486 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
1489 if ( typeof div.style.zoom !== "undefined" ) {
1491 // Check if natively block-level elements act like inline-block
1492 // elements when setting their display to 'inline' and giving
1495 div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
1496 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
1499 // Check if elements with layout shrink-wrap their children
1500 div.style.display = "block";
1501 div.innerHTML = "<div></div>";
1502 div.firstChild.style.width = "5px";
1503 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
1505 // Prevent IE 6 from affecting layout for positioned elements #11048
1506 // Prevent IE from shrinking the body in IE 7 mode #12869
1507 body.style.zoom = 1;
1510 body.removeChild( container );
1512 // Null elements to avoid leaks in IE
1513 container = div = tds = marginDiv = null;
1516 // Null elements to avoid leaks in IE
1517 all = select = fragment = opt = a = input = null;
1522 var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
1523 rmultiDash = /([A-Z])/g;
1525 function internalData( elem, name, data, pvt /* Internal Use Only */ ){
1526 if ( !jQuery.acceptData( elem ) ) {
1531 internalKey = jQuery.expando,
1532 getByName = typeof name === "string",
1534 // We have to handle DOM nodes and JS objects differently because IE6-7
1535 // can't GC object references properly across the DOM-JS boundary
1536 isNode = elem.nodeType,
1538 // Only DOM nodes need the global jQuery cache; JS object data is
1539 // attached directly to the object so GC can occur automatically
1540 cache = isNode ? jQuery.cache : elem,
1542 // Only defining an ID for JS objects if its cache already exists allows
1543 // the code to shortcut on the same path as a DOM node with no cache
1544 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
1546 // Avoid doing any more work than we need to when trying to get data on an
1547 // object that has no data at all
1548 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
1553 // Only DOM nodes need a new unique ID for each element since their data
1554 // ends up in the global cache
1556 elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++;
1562 if ( !cache[ id ] ) {
1565 // Avoids exposing jQuery metadata on plain JS objects when the object
1566 // is serialized using JSON.stringify
1568 cache[ id ].toJSON = jQuery.noop;
1572 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1573 // shallow copied over onto the existing cache
1574 if ( typeof name === "object" || typeof name === "function" ) {
1576 cache[ id ] = jQuery.extend( cache[ id ], name );
1578 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1582 thisCache = cache[ id ];
1584 // jQuery data() is stored in a separate object inside the object's internal data
1585 // cache in order to avoid key collisions between internal data and user-defined
1588 if ( !thisCache.data ) {
1589 thisCache.data = {};
1592 thisCache = thisCache.data;
1595 if ( data !== undefined ) {
1596 thisCache[ jQuery.camelCase( name ) ] = data;
1599 // Check for both converted-to-camel and non-converted data property names
1600 // If a data property was specified
1603 // First Try to find as-is property data
1604 ret = thisCache[ name ];
1606 // Test for null|undefined property data
1607 if ( ret == null ) {
1609 // Try to find the camelCased property
1610 ret = thisCache[ jQuery.camelCase( name ) ];
1619 function internalRemoveData( elem, name, pvt /* For internal use only */ ){
1620 if ( !jQuery.acceptData( elem ) ) {
1624 var thisCache, i, l,
1626 isNode = elem.nodeType,
1628 // See jQuery.data for more information
1629 cache = isNode ? jQuery.cache : elem,
1630 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1632 // If there is already no cache entry for this object, there is no
1633 // purpose in continuing
1634 if ( !cache[ id ] ) {
1640 thisCache = pvt ? cache[ id ] : cache[ id ].data;
1644 // Support array or space separated string names for data keys
1645 if ( !jQuery.isArray( name ) ) {
1647 // try the string as a key before any manipulation
1648 if ( name in thisCache ) {
1652 // split the camel cased version by spaces unless a key with the spaces exists
1653 name = jQuery.camelCase( name );
1654 if ( name in thisCache ) {
1657 name = name.split(" ");
1661 // If "name" is an array of keys...
1662 // When data is initially created, via ("key", "val") signature,
1663 // keys will be converted to camelCase.
1664 // Since there is no way to tell _how_ a key was added, remove
1665 // both plain key and camelCase key. #12786
1666 // This will only penalize the array argument path.
1667 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
1670 for ( i = 0, l = name.length; i < l; i++ ) {
1671 delete thisCache[ name[i] ];
1674 // If there is no data left in the cache, we want to continue
1675 // and let the cache object itself get destroyed
1676 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1682 // See jQuery.data for more information
1684 delete cache[ id ].data;
1686 // Don't destroy the parent cache unless the internal data object
1687 // had been the only thing left in it
1688 if ( !isEmptyDataObject( cache[ id ] ) ) {
1693 // Destroy the cache
1695 jQuery.cleanData( [ elem ], true );
1697 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
1698 } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
1701 // When all else fails, null
1710 // Unique for each copy of jQuery on the page
1711 // Non-digits removed to match rinlinejQuery
1712 expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
1714 // The following elements throw uncatchable exceptions if you
1715 // attempt to add expando properties to them.
1718 // Ban all objects except for Flash (which handle expandos)
1719 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1723 hasData: function( elem ) {
1724 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1725 return !!elem && !isEmptyDataObject( elem );
1728 data: function( elem, name, data ) {
1729 return internalData( elem, name, data, false );
1732 removeData: function( elem, name ) {
1733 return internalRemoveData( elem, name, false );
1736 // For internal use only.
1737 _data: function( elem, name, data ) {
1738 return internalData( elem, name, data, true );
1741 _removeData: function( elem, name ) {
1742 return internalRemoveData( elem, name, true );
1745 // A method for determining if a DOM node can handle the data expando
1746 acceptData: function( elem ) {
1747 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
1749 // nodes accept data unless otherwise specified; rejection can be conditional
1750 return !noData || noData !== true && elem.getAttribute("classid") === noData;
1755 data: function( key, value ) {
1762 if ( key === undefined ) {
1763 if ( this.length ) {
1764 data = jQuery.data( elem );
1766 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
1767 attrs = elem.attributes;
1768 for ( ; i < attrs.length; i++ ) {
1769 name = attrs[i].name;
1771 if ( !name.indexOf( "data-" ) ) {
1772 name = jQuery.camelCase( name.substring(5) );
1774 dataAttr( elem, name, data[ name ] );
1777 jQuery._data( elem, "parsedAttrs", true );
1784 // Sets multiple values
1785 if ( typeof key === "object" ) {
1786 return this.each(function() {
1787 jQuery.data( this, key );
1791 return jQuery.access( this, function( value ) {
1793 if ( value === undefined ) {
1794 // Try to fetch any internally stored data first
1795 return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
1798 this.each(function() {
1799 jQuery.data( this, key, value );
1801 }, null, value, arguments.length > 1, null, true );
1804 removeData: function( key ) {
1805 return this.each(function() {
1806 jQuery.removeData( this, key );
1811 function dataAttr( elem, key, data ) {
1812 // If nothing was found internally, try to fetch any
1813 // data from the HTML5 data-* attribute
1814 if ( data === undefined && elem.nodeType === 1 ) {
1816 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1818 data = elem.getAttribute( name );
1820 if ( typeof data === "string" ) {
1822 data = data === "true" ? true :
1823 data === "false" ? false :
1824 data === "null" ? null :
1825 // Only convert to a number if it doesn't change the string
1826 +data + "" === data ? +data :
1827 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1831 // Make sure we set the data so it isn't changed later
1832 jQuery.data( elem, key, data );
1842 // checks a cache object for emptiness
1843 function isEmptyDataObject( obj ) {
1845 for ( name in obj ) {
1847 // if the public data object is empty, the private is still empty
1848 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1851 if ( name !== "toJSON" ) {
1859 queue: function( elem, type, data ) {
1863 type = ( type || "fx" ) + "queue";
1864 queue = jQuery._data( elem, type );
1866 // Speed up dequeue by getting out quickly if this is just a lookup
1868 if ( !queue || jQuery.isArray(data) ) {
1869 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
1878 dequeue: function( elem, type ) {
1879 type = type || "fx";
1881 var queue = jQuery.queue( elem, type ),
1882 startLength = queue.length,
1884 hooks = jQuery._queueHooks( elem, type ),
1886 jQuery.dequeue( elem, type );
1889 // If the fx queue is dequeued, always remove the progress sentinel
1890 if ( fn === "inprogress" ) {
1898 // Add a progress sentinel to prevent the fx queue from being
1899 // automatically dequeued
1900 if ( type === "fx" ) {
1901 queue.unshift( "inprogress" );
1904 // clear up the last queue stop function
1906 fn.call( elem, next, hooks );
1909 if ( !startLength && hooks ) {
1914 // not intended for public consumption - generates a queueHooks object, or returns the current one
1915 _queueHooks: function( elem, type ) {
1916 var key = type + "queueHooks";
1917 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
1918 empty: jQuery.Callbacks("once memory").add(function() {
1919 jQuery._removeData( elem, type + "queue" );
1920 jQuery._removeData( elem, key );
1927 queue: function( type, data ) {
1930 if ( typeof type !== "string" ) {
1936 if ( arguments.length < setter ) {
1937 return jQuery.queue( this[0], type );
1940 return data === undefined ?
1942 this.each(function() {
1943 var queue = jQuery.queue( this, type, data );
1945 // ensure a hooks for this queue
1946 jQuery._queueHooks( this, type );
1948 if ( type === "fx" && queue[0] !== "inprogress" ) {
1949 jQuery.dequeue( this, type );
1953 dequeue: function( type ) {
1954 return this.each(function() {
1955 jQuery.dequeue( this, type );
1958 // Based off of the plugin by Clint Helfers, with permission.
1959 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1960 delay: function( time, type ) {
1961 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1962 type = type || "fx";
1964 return this.queue( type, function( next, hooks ) {
1965 var timeout = setTimeout( next, time );
1966 hooks.stop = function() {
1967 clearTimeout( timeout );
1971 clearQueue: function( type ) {
1972 return this.queue( type || "fx", [] );
1974 // Get a promise resolved when queues of a certain type
1975 // are emptied (fx is the type by default)
1976 promise: function( type, obj ) {
1979 defer = jQuery.Deferred(),
1982 resolve = function() {
1983 if ( !( --count ) ) {
1984 defer.resolveWith( elements, [ elements ] );
1988 if ( typeof type !== "string" ) {
1992 type = type || "fx";
1995 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
1996 if ( tmp && tmp.empty ) {
1998 tmp.empty.add( resolve );
2002 return defer.promise( obj );
2005 var nodeHook, boolHook,
2006 rclass = /[\t\r\n]/g,
2008 rfocusable = /^(?:input|select|textarea|button|object)$/i,
2009 rclickable = /^(?:a|area)$/i,
2010 rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,
2011 ruseDefault = /^(?:checked|selected)$/i,
2012 getSetAttribute = jQuery.support.getSetAttribute,
2013 getSetInput = jQuery.support.input;
2016 attr: function( name, value ) {
2017 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2020 removeAttr: function( name ) {
2021 return this.each(function() {
2022 jQuery.removeAttr( this, name );
2026 prop: function( name, value ) {
2027 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2030 removeProp: function( name ) {
2031 name = jQuery.propFix[ name ] || name;
2032 return this.each(function() {
2033 // try/catch handles cases where IE balks (such as removing a property on window)
2035 this[ name ] = undefined;
2036 delete this[ name ];
2041 addClass: function( value ) {
2042 var classes, elem, cur, clazz, j,
2045 proceed = typeof value === "string" && value;
2047 if ( jQuery.isFunction( value ) ) {
2048 return this.each(function( j ) {
2049 jQuery( this ).addClass( value.call( this, j, this.className ) );
2054 // The disjunction here is for better compressibility (see removeClass)
2055 classes = ( value || "" ).match( core_rnotwhite ) || [];
2057 for ( ; i < len; i++ ) {
2059 cur = elem.nodeType === 1 && ( elem.className ?
2060 ( " " + elem.className + " " ).replace( rclass, " " ) :
2066 while ( (clazz = classes[j++]) ) {
2067 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
2071 elem.className = jQuery.trim( cur );
2080 removeClass: function( value ) {
2081 var classes, elem, cur, clazz, j,
2084 proceed = arguments.length === 0 || typeof value === "string" && value;
2086 if ( jQuery.isFunction( value ) ) {
2087 return this.each(function( j ) {
2088 jQuery( this ).removeClass( value.call( this, j, this.className ) );
2092 classes = ( value || "" ).match( core_rnotwhite ) || [];
2094 for ( ; i < len; i++ ) {
2096 // This expression is here for better compressibility (see addClass)
2097 cur = elem.nodeType === 1 && ( elem.className ?
2098 ( " " + elem.className + " " ).replace( rclass, " " ) :
2104 while ( (clazz = classes[j++]) ) {
2105 // Remove *all* instances
2106 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
2107 cur = cur.replace( " " + clazz + " ", " " );
2110 elem.className = value ? jQuery.trim( cur ) : "";
2118 toggleClass: function( value, stateVal ) {
2119 var type = typeof value,
2120 isBool = typeof stateVal === "boolean";
2122 if ( jQuery.isFunction( value ) ) {
2123 return this.each(function( i ) {
2124 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2128 return this.each(function() {
2129 if ( type === "string" ) {
2130 // toggle individual class names
2133 self = jQuery( this ),
2135 classNames = value.match( core_rnotwhite ) || [];
2137 while ( (className = classNames[ i++ ]) ) {
2138 // check each className given, space separated list
2139 state = isBool ? state : !self.hasClass( className );
2140 self[ state ? "addClass" : "removeClass" ]( className );
2143 // Toggle whole class name
2144 } else if ( type === "undefined" || type === "boolean" ) {
2145 if ( this.className ) {
2146 // store className if set
2147 jQuery._data( this, "__className__", this.className );
2150 // If the element has a class name or if we're passed "false",
2151 // then remove the whole classname (if there was one, the above saved it).
2152 // Otherwise bring back whatever was previously saved (if anything),
2153 // falling back to the empty string if nothing was stored.
2154 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2159 hasClass: function( selector ) {
2160 var className = " " + selector + " ",
2163 for ( ; i < l; i++ ) {
2164 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
2172 val: function( value ) {
2173 var hooks, ret, isFunction,
2176 if ( !arguments.length ) {
2178 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2180 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2186 return typeof ret === "string" ?
2187 // handle most common string cases
2188 ret.replace(rreturn, "") :
2189 // handle cases where value is null/undef or number
2190 ret == null ? "" : ret;
2196 isFunction = jQuery.isFunction( value );
2198 return this.each(function( i ) {
2200 self = jQuery(this);
2202 if ( this.nodeType !== 1 ) {
2207 val = value.call( this, i, self.val() );
2212 // Treat null/undefined as ""; convert numbers to string
2213 if ( val == null ) {
2215 } else if ( typeof val === "number" ) {
2217 } else if ( jQuery.isArray( val ) ) {
2218 val = jQuery.map(val, function ( value ) {
2219 return value == null ? "" : value + "";
2223 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2225 // If set returns undefined, fall back to normal setting
2226 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2236 get: function( elem ) {
2237 // attributes.value is undefined in Blackberry 4.7 but
2238 // uses .value. See #6932
2239 var val = elem.attributes.value;
2240 return !val || val.specified ? elem.value : elem.text;
2244 get: function( elem ) {
2246 options = elem.options,
2247 index = elem.selectedIndex,
2248 one = elem.type === "select-one" || index < 0,
2249 values = one ? null : [],
2250 max = one ? index + 1 : options.length,
2255 // Loop through all the selected options
2256 for ( ; i < max; i++ ) {
2257 option = options[ i ];
2259 // oldIE doesn't update selected after form reset (#2551)
2260 if ( ( option.selected || i === index ) &&
2261 // Don't return options that are disabled or in a disabled optgroup
2262 ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
2263 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
2265 // Get the specific value for the option
2266 value = jQuery( option ).val();
2268 // We don't need an array for one selects
2273 // Multi-Selects return an array
2274 values.push( value );
2281 set: function( elem, value ) {
2282 var values = jQuery.makeArray( value );
2284 jQuery(elem).find("option").each(function() {
2285 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2288 if ( !values.length ) {
2289 elem.selectedIndex = -1;
2296 attr: function( elem, name, value ) {
2297 var ret, hooks, notxml,
2298 nType = elem.nodeType;
2300 // don't get/set attributes on text, comment and attribute nodes
2301 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2305 // Fallback to prop when attributes are not supported
2306 if ( typeof elem.getAttribute === "undefined" ) {
2307 return jQuery.prop( elem, name, value );
2310 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2312 // All attributes are lowercase
2313 // Grab necessary hook if one is defined
2315 name = name.toLowerCase();
2316 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2319 if ( value !== undefined ) {
2321 if ( value === null ) {
2322 jQuery.removeAttr( elem, name );
2324 } else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2328 elem.setAttribute( name, value + "" );
2332 } else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2337 // In IE9+, Flash objects don't have .getAttribute (#12945)
2339 if ( typeof elem.getAttribute !== "undefined" ) {
2340 ret = elem.getAttribute( name );
2343 // Non-existent attributes return null, we normalize to undefined
2344 return ret == null ?
2350 removeAttr: function( elem, value ) {
2353 attrNames = value && value.match( core_rnotwhite );
2355 if ( attrNames && elem.nodeType === 1 ) {
2356 while ( (name = attrNames[i++]) ) {
2357 propName = jQuery.propFix[ name ] || name;
2359 // Boolean attributes get special treatment (#10870)
2360 if ( rboolean.test( name ) ) {
2361 // Set corresponding property to false for boolean attributes
2362 // Also clear defaultChecked/defaultSelected (if appropriate) for IE<8
2363 if ( !getSetAttribute && ruseDefault.test( name ) ) {
2364 elem[ jQuery.camelCase( "default-" + name ) ] =
2365 elem[ propName ] = false;
2367 elem[ propName ] = false;
2370 // See #9699 for explanation of this approach (setting first, then removal)
2372 jQuery.attr( elem, name, "" );
2375 elem.removeAttribute( getSetAttribute ? name : propName );
2382 set: function( elem, value ) {
2383 if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2384 // Setting the type on a radio button after the value resets the value in IE6-9
2385 // Reset value to default in case type is set after value during creation
2386 var val = elem.value;
2387 elem.setAttribute( "type", value );
2398 tabindex: "tabIndex",
2399 readonly: "readOnly",
2401 "class": "className",
2402 maxlength: "maxLength",
2403 cellspacing: "cellSpacing",
2404 cellpadding: "cellPadding",
2408 frameborder: "frameBorder",
2409 contenteditable: "contentEditable"
2412 prop: function( elem, name, value ) {
2413 var ret, hooks, notxml,
2414 nType = elem.nodeType;
2416 // don't get/set properties on text, comment and attribute nodes
2417 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2421 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2424 // Fix name and attach hooks
2425 name = jQuery.propFix[ name ] || name;
2426 hooks = jQuery.propHooks[ name ];
2429 if ( value !== undefined ) {
2430 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2434 return ( elem[ name ] = value );
2438 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2442 return elem[ name ];
2449 get: function( elem ) {
2450 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2451 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2452 var attributeNode = elem.getAttributeNode("tabindex");
2454 return attributeNode && attributeNode.specified ?
2455 parseInt( attributeNode.value, 10 ) :
2456 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2464 // Hook for boolean attributes
2466 get: function( elem, name ) {
2468 // Use .prop to determine if this attribute is understood as boolean
2469 prop = jQuery.prop( elem, name ),
2471 // Fetch it accordingly
2472 attr = typeof prop === "boolean" && elem.getAttribute( name ),
2473 detail = typeof prop === "boolean" ?
2475 getSetInput && getSetAttribute ?
2477 // oldIE fabricates an empty string for missing boolean attributes
2478 // and conflates checked/selected into attroperties
2479 ruseDefault.test( name ) ?
2480 elem[ jQuery.camelCase( "default-" + name ) ] :
2483 // fetch an attribute node for properties not recognized as boolean
2484 elem.getAttributeNode( name );
2486 return detail && detail.value !== false ?
2487 name.toLowerCase() :
2490 set: function( elem, value, name ) {
2491 if ( value === false ) {
2492 // Remove boolean attributes when set to false
2493 jQuery.removeAttr( elem, name );
2494 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
2495 // IE<8 needs the *property* name
2496 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
2498 // Use defaultChecked and defaultSelected for oldIE
2500 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
2507 // fix oldIE value attroperty
2508 if ( !getSetInput || !getSetAttribute ) {
2509 jQuery.attrHooks.value = {
2510 get: function( elem, name ) {
2511 var ret = elem.getAttributeNode( name );
2512 return jQuery.nodeName( elem, "input" ) ?
2514 // Ignore the value *property* by using defaultValue
2517 ret && ret.specified ? ret.value : undefined;
2519 set: function( elem, value, name ) {
2520 if ( jQuery.nodeName( elem, "input" ) ) {
2521 // Does not return so that setAttribute is also used
2522 elem.defaultValue = value;
2524 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
2525 return nodeHook && nodeHook.set( elem, value, name );
2531 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2532 if ( !getSetAttribute ) {
2534 // Use this for any attribute in IE6/7
2535 // This fixes almost every IE6/7 issue
2536 nodeHook = jQuery.valHooks.button = {
2537 get: function( elem, name ) {
2538 var ret = elem.getAttributeNode( name );
2539 return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ?
2543 set: function( elem, value, name ) {
2544 // Set the existing or create a new attribute node
2545 var ret = elem.getAttributeNode( name );
2547 elem.setAttributeNode(
2548 (ret = elem.ownerDocument.createAttribute( name ))
2552 ret.value = value += "";
2554 // Break association with cloned elements by also using setAttribute (#9646)
2555 return name === "value" || value === elem.getAttribute( name ) ?
2561 // Set contenteditable to false on removals(#10429)
2562 // Setting to empty string throws an error as an invalid value
2563 jQuery.attrHooks.contenteditable = {
2565 set: function( elem, value, name ) {
2566 nodeHook.set( elem, value === "" ? false : value, name );
2570 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2571 // This is for removals
2572 jQuery.each([ "width", "height" ], function( i, name ) {
2573 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2574 set: function( elem, value ) {
2575 if ( value === "" ) {
2576 elem.setAttribute( name, "auto" );
2585 // Some attributes require a special call on IE
2586 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2587 if ( !jQuery.support.hrefNormalized ) {
2588 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2589 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2590 get: function( elem ) {
2591 var ret = elem.getAttribute( name, 2 );
2592 return ret == null ? undefined : ret;
2597 // href/src property should get the full normalized URL (#10299/#12915)
2598 jQuery.each([ "href", "src" ], function( i, name ) {
2599 jQuery.propHooks[ name ] = {
2600 get: function( elem ) {
2601 return elem.getAttribute( name, 4 );
2607 if ( !jQuery.support.style ) {
2608 jQuery.attrHooks.style = {
2609 get: function( elem ) {
2610 // Return undefined in the case of empty string
2611 // Note: IE uppercases css property names, but if we were to .toLowerCase()
2612 // .cssText, that would destroy case senstitivity in URL's, like in "background"
2613 return elem.style.cssText || undefined;
2615 set: function( elem, value ) {
2616 return ( elem.style.cssText = value + "" );
2621 // Safari mis-reports the default selected property of an option
2622 // Accessing the parent's selectedIndex property fixes it
2623 if ( !jQuery.support.optSelected ) {
2624 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2625 get: function( elem ) {
2626 var parent = elem.parentNode;
2629 parent.selectedIndex;
2631 // Make sure that it also works with optgroups, see #5701
2632 if ( parent.parentNode ) {
2633 parent.parentNode.selectedIndex;
2641 // IE6/7 call enctype encoding
2642 if ( !jQuery.support.enctype ) {
2643 jQuery.propFix.enctype = "encoding";
2646 // Radios and checkboxes getter/setter
2647 if ( !jQuery.support.checkOn ) {
2648 jQuery.each([ "radio", "checkbox" ], function() {
2649 jQuery.valHooks[ this ] = {
2650 get: function( elem ) {
2651 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2652 return elem.getAttribute("value") === null ? "on" : elem.value;
2657 jQuery.each([ "radio", "checkbox" ], function() {
2658 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2659 set: function( elem, value ) {
2660 if ( jQuery.isArray( value ) ) {
2661 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2666 var rformElems = /^(?:input|select|textarea)$/i,
2668 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2669 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2670 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
2672 function returnTrue() {
2676 function returnFalse() {
2681 * Helper functions for managing events -- not part of the public interface.
2682 * Props to Dean Edwards' addEvent library for many of the ideas.
2688 add: function( elem, types, handler, data, selector ) {
2690 var handleObjIn, eventHandle, tmp,
2691 events, t, handleObj,
2692 special, handlers, type, namespaces, origType,
2693 // Don't attach events to noData or text/comment nodes (but allow plain objects)
2694 elemData = elem.nodeType !== 3 && elem.nodeType !== 8 && jQuery._data( elem );
2700 // Caller can pass in an object of custom data in lieu of the handler
2701 if ( handler.handler ) {
2702 handleObjIn = handler;
2703 handler = handleObjIn.handler;
2704 selector = handleObjIn.selector;
2707 // Make sure that the handler has a unique ID, used to find/remove it later
2708 if ( !handler.guid ) {
2709 handler.guid = jQuery.guid++;
2712 // Init the element's event structure and main handler, if this is the first
2713 if ( !(events = elemData.events) ) {
2714 events = elemData.events = {};
2716 if ( !(eventHandle = elemData.handle) ) {
2717 eventHandle = elemData.handle = function( e ) {
2718 // Discard the second event of a jQuery.event.trigger() and
2719 // when an event is called after a page has unloaded
2720 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2721 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2724 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2725 eventHandle.elem = elem;
2728 // Handle multiple events separated by a space
2729 // jQuery(...).bind("mouseover mouseout", fn);
2730 types = ( types || "" ).match( core_rnotwhite ) || [""];
2733 tmp = rtypenamespace.exec( types[t] ) || [];
2734 type = origType = tmp[1];
2735 namespaces = ( tmp[2] || "" ).split( "." ).sort();
2737 // If event changes its type, use the special event handlers for the changed type
2738 special = jQuery.event.special[ type ] || {};
2740 // If selector defined, determine special event api type, otherwise given type
2741 type = ( selector ? special.delegateType : special.bindType ) || type;
2743 // Update special based on newly reset type
2744 special = jQuery.event.special[ type ] || {};
2746 // handleObj is passed to all event handlers
2747 handleObj = jQuery.extend({
2754 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2755 namespace: namespaces.join(".")
2758 // Init the event handler queue if we're the first
2759 if ( !(handlers = events[ type ]) ) {
2760 handlers = events[ type ] = [];
2761 handlers.delegateCount = 0;
2763 // Only use addEventListener/attachEvent if the special events handler returns false
2764 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2765 // Bind the global event handler to the element
2766 if ( elem.addEventListener ) {
2767 elem.addEventListener( type, eventHandle, false );
2769 } else if ( elem.attachEvent ) {
2770 elem.attachEvent( "on" + type, eventHandle );
2775 if ( special.add ) {
2776 special.add.call( elem, handleObj );
2778 if ( !handleObj.handler.guid ) {
2779 handleObj.handler.guid = handler.guid;
2783 // Add to the element's handler list, delegates in front
2785 handlers.splice( handlers.delegateCount++, 0, handleObj );
2787 handlers.push( handleObj );
2790 // Keep track of which events have ever been used, for event optimization
2791 jQuery.event.global[ type ] = true;
2794 // Nullify elem to prevent memory leaks in IE
2798 // Detach an event or set of events from an element
2799 remove: function( elem, types, handler, selector, mappedTypes ) {
2801 var j, origCount, tmp,
2802 events, t, handleObj,
2803 special, handlers, type, namespaces, origType,
2804 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
2806 if ( !elemData || !(events = elemData.events) ) {
2810 // Once for each type.namespace in types; type may be omitted
2811 types = ( types || "" ).match( core_rnotwhite ) || [""];
2814 tmp = rtypenamespace.exec( types[t] ) || [];
2815 type = origType = tmp[1];
2816 namespaces = ( tmp[2] || "" ).split( "." ).sort();
2818 // Unbind all events (on this namespace, if provided) for the element
2820 for ( type in events ) {
2821 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2826 special = jQuery.event.special[ type ] || {};
2827 type = ( selector ? special.delegateType : special.bindType ) || type;
2828 handlers = events[ type ] || [];
2829 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
2831 // Remove matching events
2832 origCount = j = handlers.length;
2834 handleObj = handlers[ j ];
2836 if ( ( mappedTypes || origType === handleObj.origType ) &&
2837 ( !handler || handler.guid === handleObj.guid ) &&
2838 ( !tmp || tmp.test( handleObj.namespace ) ) &&
2839 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2840 handlers.splice( j, 1 );
2842 if ( handleObj.selector ) {
2843 handlers.delegateCount--;
2845 if ( special.remove ) {
2846 special.remove.call( elem, handleObj );
2851 // Remove generic event handler if we removed something and no more handlers exist
2852 // (avoids potential for endless recursion during removal of special event handlers)
2853 if ( origCount && !handlers.length ) {
2854 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2855 jQuery.removeEvent( elem, type, elemData.handle );
2858 delete events[ type ];
2862 // Remove the expando if it's no longer used
2863 if ( jQuery.isEmptyObject( events ) ) {
2864 delete elemData.handle;
2866 // removeData also checks for emptiness and clears the expando if empty
2867 // so use it instead of delete
2868 jQuery._removeData( elem, "events" );
2872 trigger: function( event, data, elem, onlyHandlers ) {
2874 var i, cur, tmp, bubbleType, ontype, handle, special,
2875 eventPath = [ elem || document ],
2876 type = event.type || event,
2877 namespaces = event.namespace ? event.namespace.split(".") : [];
2879 cur = tmp = elem = elem || document;
2881 // Don't do events on text and comment nodes
2882 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2886 // focus/blur morphs to focusin/out; ensure we're not firing them right now
2887 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2891 if ( type.indexOf(".") >= 0 ) {
2892 // Namespaced trigger; create a regexp to match event type in handle()
2893 namespaces = type.split(".");
2894 type = namespaces.shift();
2897 ontype = type.indexOf(":") < 0 && "on" + type;
2899 // Caller can pass in a jQuery.Event object, Object, or just an event type string
2900 event = event[ jQuery.expando ] ?
2902 new jQuery.Event( type, typeof event === "object" && event );
2904 event.isTrigger = true;
2905 event.namespace = namespaces.join(".");
2906 event.namespace_re = event.namespace ?
2907 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
2910 // Clean up the event in case it is being reused
2911 event.result = undefined;
2912 if ( !event.target ) {
2913 event.target = elem;
2916 // Clone any incoming data and prepend the event, creating the handler arg list
2917 data = data == null ?
2919 jQuery.makeArray( data, [ event ] );
2921 // Allow special events to draw outside the lines
2922 special = jQuery.event.special[ type ] || {};
2923 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
2927 // Determine event propagation path in advance, per W3C events spec (#9951)
2928 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2929 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2931 bubbleType = special.delegateType || type;
2932 if ( !rfocusMorph.test( bubbleType + type ) ) {
2933 cur = cur.parentNode;
2935 for ( ; cur; cur = cur.parentNode ) {
2936 eventPath.push( cur );
2940 // Only add window if we got to document (e.g., not plain obj or detached DOM)
2941 if ( tmp === (elem.ownerDocument || document) ) {
2942 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
2946 // Fire handlers on the event path
2948 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
2950 event.type = i > 1 ?
2952 special.bindType || type;
2955 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2957 handle.apply( cur, data );
2961 handle = ontype && cur[ ontype ];
2962 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2963 event.preventDefault();
2968 // If nobody prevented the default action, do it now
2969 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
2971 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
2972 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2974 // Call a native DOM method on the target with the same name name as the event.
2975 // Can't use an .isFunction() check here because IE6/7 fails that test.
2976 // Don't do default actions on window, that's where global variables be (#6170)
2977 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
2979 // Don't re-trigger an onFOO event when we call its FOO() method
2980 tmp = elem[ ontype ];
2983 elem[ ontype ] = null;
2986 // Prevent re-triggering of the same event, since we already bubbled it above
2987 jQuery.event.triggered = type;
2991 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
2992 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
2994 jQuery.event.triggered = undefined;
2997 elem[ ontype ] = tmp;
3003 return event.result;
3006 dispatch: function( event ) {
3008 // Make a writable jQuery.Event from the native event object
3009 event = jQuery.event.fix( event );
3011 var i, j, ret, matched, handleObj,
3013 args = core_slice.call( arguments ),
3014 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
3015 special = jQuery.event.special[ event.type ] || {};
3017 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3019 event.delegateTarget = this;
3021 // Call the preDispatch hook for the mapped type, and let it bail if desired
3022 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3026 // Determine handlers
3027 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
3029 // Run delegates first; they may want to stop propagation beneath us
3031 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
3032 event.currentTarget = matched.elem;
3035 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
3037 // Triggered event must either 1) have no namespace, or
3038 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3039 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
3041 event.handleObj = handleObj;
3042 event.data = handleObj.data;
3044 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3045 .apply( matched.elem, args );
3047 if ( ret !== undefined ) {
3048 if ( (event.result = ret) === false ) {
3049 event.preventDefault();
3050 event.stopPropagation();
3057 // Call the postDispatch hook for the mapped type
3058 if ( special.postDispatch ) {
3059 special.postDispatch.call( this, event );
3062 return event.result;
3065 handlers: function( event, handlers ) {
3066 var i, matches, sel, handleObj,
3068 delegateCount = handlers.delegateCount,
3071 // Find delegate handlers
3072 // Black-hole SVG <use> instance trees (#13180)
3073 // Avoid non-left-click bubbling in Firefox (#3861)
3074 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
3076 for ( ; cur != this; cur = cur.parentNode || this ) {
3078 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
3079 if ( cur.disabled !== true || event.type !== "click" ) {
3081 for ( i = 0; i < delegateCount; i++ ) {
3082 handleObj = handlers[ i ];
3084 // Don't conflict with Object.prototype properties (#13203)
3085 sel = handleObj.selector + " ";
3087 if ( matches[ sel ] === undefined ) {
3088 matches[ sel ] = handleObj.needsContext ?
3089 jQuery( sel, this ).index( cur ) >= 0 :
3090 jQuery.find( sel, this, null, [ cur ] ).length;
3092 if ( matches[ sel ] ) {
3093 matches.push( handleObj );
3096 if ( matches.length ) {
3097 handlerQueue.push({ elem: cur, handlers: matches });
3103 // Add the remaining (directly-bound) handlers
3104 if ( delegateCount < handlers.length ) {
3105 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
3108 return handlerQueue;
3111 fix: function( event ) {
3112 if ( event[ jQuery.expando ] ) {
3116 // Create a writable copy of the event object and normalize some properties
3118 originalEvent = event,
3119 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3120 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3122 event = new jQuery.Event( originalEvent );
3127 event[ prop ] = originalEvent[ prop ];
3131 // Fix target property (#1925)
3132 if ( !event.target ) {
3133 event.target = originalEvent.srcElement || document;
3136 // Support: Chrome 23+, Safari?
3137 // Target should not be a text node (#504, #13143)
3138 if ( event.target.nodeType === 3 ) {
3139 event.target = event.target.parentNode;
3143 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
3144 event.metaKey = !!event.metaKey;
3146 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
3149 // Includes some event props shared by KeyEvent and MouseEvent
3150 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3155 props: "char charCode key keyCode".split(" "),
3156 filter: function( event, original ) {
3158 // Add which for key events
3159 if ( event.which == null ) {
3160 event.which = original.charCode != null ? original.charCode : original.keyCode;
3168 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3169 filter: function( event, original ) {
3170 var eventDoc, doc, body,
3171 button = original.button,
3172 fromElement = original.fromElement;
3174 // Calculate pageX/Y if missing and clientX/Y available
3175 if ( event.pageX == null && original.clientX != null ) {
3176 eventDoc = event.target.ownerDocument || document;
3177 doc = eventDoc.documentElement;
3178 body = eventDoc.body;
3180 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3181 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3184 // Add relatedTarget, if necessary
3185 if ( !event.relatedTarget && fromElement ) {
3186 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3189 // Add which for click: 1 === left; 2 === middle; 3 === right
3190 // Note: button is not normalized, so don't use it
3191 if ( !event.which && button !== undefined ) {
3192 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3201 // Prevent triggered image.load events from bubbling to window.load
3205 // For checkbox, fire native event so checked state will be right
3206 trigger: function() {
3207 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
3214 // Fire native event if possible so blur/focus sequence is correct
3215 trigger: function() {
3216 if ( this !== document.activeElement && this.focus ) {
3222 // If we error on focus to hidden element (#1486, #12518),
3223 // let .trigger() run the handlers
3227 delegateType: "focusin"
3230 trigger: function() {
3231 if ( this === document.activeElement && this.blur ) {
3236 delegateType: "focusout"
3240 postDispatch: function( event ) {
3242 // Even when returnValue equals to undefined Firefox will still show alert
3243 if ( event.result !== undefined ) {
3244 event.originalEvent.returnValue = event.result;
3250 simulate: function( type, elem, event, bubble ) {
3251 // Piggyback on a donor event to simulate a different one.
3252 // Fake originalEvent to avoid donor's stopPropagation, but if the
3253 // simulated event prevents default then we do the same on the donor.
3254 var e = jQuery.extend(
3263 jQuery.event.trigger( e, null, elem );
3265 jQuery.event.dispatch.call( elem, e );
3267 if ( e.isDefaultPrevented() ) {
3268 event.preventDefault();
3273 jQuery.removeEvent = document.removeEventListener ?
3274 function( elem, type, handle ) {
3275 if ( elem.removeEventListener ) {
3276 elem.removeEventListener( type, handle, false );
3279 function( elem, type, handle ) {
3280 var name = "on" + type;
3282 if ( elem.detachEvent ) {
3284 // #8545, #7054, preventing memory leaks for custom events in IE6-8
3285 // detachEvent needed property on element, by name of that event, to properly expose it to GC
3286 if ( typeof elem[ name ] === "undefined" ) {
3287 elem[ name ] = null;
3290 elem.detachEvent( name, handle );
3294 jQuery.Event = function( src, props ) {
3295 // Allow instantiation without the 'new' keyword
3296 if ( !(this instanceof jQuery.Event) ) {
3297 return new jQuery.Event( src, props );
3301 if ( src && src.type ) {
3302 this.originalEvent = src;
3303 this.type = src.type;
3305 // Events bubbling up the document may have been marked as prevented
3306 // by a handler lower down the tree; reflect the correct value.
3307 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3308 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3315 // Put explicitly provided properties onto the event object
3317 jQuery.extend( this, props );
3320 // Create a timestamp if incoming event doesn't have one
3321 this.timeStamp = src && src.timeStamp || jQuery.now();
3324 this[ jQuery.expando ] = true;
3327 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3328 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3329 jQuery.Event.prototype = {
3330 isDefaultPrevented: returnFalse,
3331 isPropagationStopped: returnFalse,
3332 isImmediatePropagationStopped: returnFalse,
3334 preventDefault: function() {
3335 var e = this.originalEvent;
3337 this.isDefaultPrevented = returnTrue;
3342 // If preventDefault exists, run it on the original event
3343 if ( e.preventDefault ) {
3347 // Otherwise set the returnValue property of the original event to false
3349 e.returnValue = false;
3352 stopPropagation: function() {
3353 var e = this.originalEvent;
3355 this.isPropagationStopped = returnTrue;
3359 // If stopPropagation exists, run it on the original event
3360 if ( e.stopPropagation ) {
3361 e.stopPropagation();
3365 // Set the cancelBubble property of the original event to true
3366 e.cancelBubble = true;
3368 stopImmediatePropagation: function() {
3369 this.isImmediatePropagationStopped = returnTrue;
3370 this.stopPropagation();
3374 // Create mouseenter/leave events using mouseover/out and event-time checks
3376 mouseenter: "mouseover",
3377 mouseleave: "mouseout"
3378 }, function( orig, fix ) {
3379 jQuery.event.special[ orig ] = {
3383 handle: function( event ) {
3386 related = event.relatedTarget,
3387 handleObj = event.handleObj;
3389 // For mousenter/leave call the handler if related is outside the target.
3390 // NB: No relatedTarget if the mouse left/entered the browser window
3391 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3392 event.type = handleObj.origType;
3393 ret = handleObj.handler.apply( this, arguments );
3401 // IE submit delegation
3402 if ( !jQuery.support.submitBubbles ) {
3404 jQuery.event.special.submit = {
3406 // Only need this for delegated form submit events
3407 if ( jQuery.nodeName( this, "form" ) ) {
3411 // Lazy-add a submit handler when a descendant form may potentially be submitted
3412 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3413 // Node name check avoids a VML-related crash in IE (#9807)
3414 var elem = e.target,
3415 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3416 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
3417 jQuery.event.add( form, "submit._submit", function( event ) {
3418 event._submit_bubble = true;
3420 jQuery._data( form, "submitBubbles", true );
3423 // return undefined since we don't need an event listener
3426 postDispatch: function( event ) {
3427 // If form was submitted by the user, bubble the event up the tree
3428 if ( event._submit_bubble ) {
3429 delete event._submit_bubble;
3430 if ( this.parentNode && !event.isTrigger ) {
3431 jQuery.event.simulate( "submit", this.parentNode, event, true );
3436 teardown: function() {
3437 // Only need this for delegated form submit events
3438 if ( jQuery.nodeName( this, "form" ) ) {
3442 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3443 jQuery.event.remove( this, "._submit" );
3448 // IE change delegation and checkbox/radio fix
3449 if ( !jQuery.support.changeBubbles ) {
3451 jQuery.event.special.change = {
3455 if ( rformElems.test( this.nodeName ) ) {
3456 // IE doesn't fire change on a check/radio until blur; trigger it on click
3457 // after a propertychange. Eat the blur-change in special.change.handle.
3458 // This still fires onchange a second time for check/radio after blur.
3459 if ( this.type === "checkbox" || this.type === "radio" ) {
3460 jQuery.event.add( this, "propertychange._change", function( event ) {
3461 if ( event.originalEvent.propertyName === "checked" ) {
3462 this._just_changed = true;
3465 jQuery.event.add( this, "click._change", function( event ) {
3466 if ( this._just_changed && !event.isTrigger ) {
3467 this._just_changed = false;
3469 // Allow triggered, simulated change events (#11500)
3470 jQuery.event.simulate( "change", this, event, true );
3475 // Delegated event; lazy-add a change handler on descendant inputs
3476 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3477 var elem = e.target;
3479 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
3480 jQuery.event.add( elem, "change._change", function( event ) {
3481 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3482 jQuery.event.simulate( "change", this.parentNode, event, true );
3485 jQuery._data( elem, "changeBubbles", true );
3490 handle: function( event ) {
3491 var elem = event.target;
3493 // Swallow native change events from checkbox/radio, we already triggered them above
3494 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3495 return event.handleObj.handler.apply( this, arguments );
3499 teardown: function() {
3500 jQuery.event.remove( this, "._change" );
3502 return !rformElems.test( this.nodeName );
3507 // Create "bubbling" focus and blur events
3508 if ( !jQuery.support.focusinBubbles ) {
3509 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3511 // Attach a single capturing handler while someone wants focusin/focusout
3513 handler = function( event ) {
3514 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3517 jQuery.event.special[ fix ] = {
3519 if ( attaches++ === 0 ) {
3520 document.addEventListener( orig, handler, true );
3523 teardown: function() {
3524 if ( --attaches === 0 ) {
3525 document.removeEventListener( orig, handler, true );
3534 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3537 // Types can be a map of types/handlers
3538 if ( typeof types === "object" ) {
3539 // ( types-Object, selector, data )
3540 if ( typeof selector !== "string" ) {
3541 // ( types-Object, data )
3542 data = data || selector;
3543 selector = undefined;
3545 for ( type in types ) {
3546 this.on( type, selector, data, types[ type ], one );
3551 if ( data == null && fn == null ) {
3554 data = selector = undefined;
3555 } else if ( fn == null ) {
3556 if ( typeof selector === "string" ) {
3557 // ( types, selector, fn )
3561 // ( types, data, fn )
3564 selector = undefined;
3567 if ( fn === false ) {
3575 fn = function( event ) {
3576 // Can use an empty set, since event contains the info
3577 jQuery().off( event );
3578 return origFn.apply( this, arguments );
3580 // Use same guid so caller can remove using origFn
3581 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3583 return this.each( function() {
3584 jQuery.event.add( this, types, fn, data, selector );
3587 one: function( types, selector, data, fn ) {
3588 return this.on( types, selector, data, fn, 1 );
3590 off: function( types, selector, fn ) {
3591 var handleObj, type;
3592 if ( types && types.preventDefault && types.handleObj ) {
3593 // ( event ) dispatched jQuery.Event
3594 handleObj = types.handleObj;
3595 jQuery( types.delegateTarget ).off(
3596 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3602 if ( typeof types === "object" ) {
3603 // ( types-object [, selector] )
3604 for ( type in types ) {
3605 this.off( type, selector, types[ type ] );
3609 if ( selector === false || typeof selector === "function" ) {
3612 selector = undefined;
3614 if ( fn === false ) {
3617 return this.each(function() {
3618 jQuery.event.remove( this, types, fn, selector );
3622 bind: function( types, data, fn ) {
3623 return this.on( types, null, data, fn );
3625 unbind: function( types, fn ) {
3626 return this.off( types, null, fn );
3629 delegate: function( selector, types, data, fn ) {
3630 return this.on( types, selector, data, fn );
3632 undelegate: function( selector, types, fn ) {
3633 // ( namespace ) or ( selector, types [, fn] )
3634 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3637 trigger: function( type, data ) {
3638 return this.each(function() {
3639 jQuery.event.trigger( type, data, this );
3642 triggerHandler: function( type, data ) {
3645 return jQuery.event.trigger( type, data, elem, true );
3649 hover: function( fnOver, fnOut ) {
3650 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3654 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3655 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3656 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3658 // Handle event binding
3659 jQuery.fn[ name ] = function( data, fn ) {
3660 return arguments.length > 0 ?
3661 this.on( name, null, data, fn ) :
3662 this.trigger( name );
3665 if ( rkeyEvent.test( name ) ) {
3666 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3669 if ( rmouseEvent.test( name ) ) {
3670 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3674 * Sizzle CSS Selector Engine
3675 * Copyright 2012 jQuery Foundation and other contributors
3676 * Released under the MIT license
3677 * http://sizzlejs.com/
3679 (function( window, undefined ) {
3690 // Local document vars
3701 // Instance-specific data
3702 expando = "sizzle" + -(new Date()),
3703 preferredDoc = window.document,
3707 classCache = createCache(),
3708 tokenCache = createCache(),
3709 compilerCache = createCache(),
3711 // General-purpose constants
3712 strundefined = typeof undefined,
3713 MAX_NEGATIVE = 1 << 31,
3720 // Use a stripped-down indexOf if we can't use a native one
3721 indexOf = arr.indexOf || function( elem ) {
3724 for ( ; i < len; i++ ) {
3725 if ( this[i] === elem ) {
3733 // Regular expressions
3735 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
3736 whitespace = "[\\x20\\t\\r\\n\\f]",
3737 // http://www.w3.org/TR/css3-syntax/#characters
3738 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
3740 // Loosely modeled on CSS identifier characters
3741 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
3742 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
3743 identifier = characterEncoding.replace( "w", "w#" ),
3745 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
3746 operators = "([*^$|!~]?=)",
3747 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
3748 "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
3750 // Prefer arguments quoted,
3751 // then not containing pseudos/brackets,
3752 // then attribute selectors/non-parenthetical expressions,
3753 // then anything else
3754 // These preferences are here to reduce the number of selectors
3755 // needing tokenize in the PSEUDO preFilter
3756 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
3758 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3759 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3761 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
3762 rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
3763 rpseudo = new RegExp( pseudos ),
3764 ridentifier = new RegExp( "^" + identifier + "$" ),
3767 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
3768 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
3769 "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
3770 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
3771 "ATTR": new RegExp( "^" + attributes ),
3772 "PSEUDO": new RegExp( "^" + pseudos ),
3773 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
3774 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3775 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3776 // For use in libraries implementing .is()
3777 // We use this for POS matching in `select`
3778 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
3779 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
3782 rsibling = /[\x20\t\r\n\f]*[+~]/,
3784 rnative = /\{\s*\[native code\]\s*\}/,
3786 // Easily-parseable/retrievable ID or TAG or CLASS selectors
3787 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
3789 rinputs = /^(?:input|select|textarea|button)$/i,
3793 rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
3795 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
3796 runescape = /\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,
3797 funescape = function( _, escaped ) {
3798 var high = "0x" + escaped - 0x10000;
3799 // NaN means non-codepoint
3800 return high !== high ?
3804 String.fromCharCode( high + 0x10000 ) :
3805 // Supplemental Plane codepoint (surrogate pair)
3806 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
3809 // Use a stripped-down slice if we can't use a native one
3811 slice.call( docElem.childNodes, 0 )[0].nodeType;
3813 slice = function( i ) {
3816 for ( ; (elem = this[i]); i++ ) {
3817 results.push( elem );
3824 * For feature detection
3825 * @param {Function} fn The function to test for native support
3827 function isNative( fn ) {
3828 return rnative.test( fn + "" );
3832 * Create key-value caches of limited size
3833 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
3834 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
3835 * deleting the oldest entry
3837 function createCache() {
3841 return (cache = function( key, value ) {
3842 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
3843 if ( keys.push( key += " " ) > Expr.cacheLength ) {
3844 // Only keep the most recent entries
3845 delete cache[ keys.shift() ];
3847 return (cache[ key ] = value);
3852 * Mark a function for special use by Sizzle
3853 * @param {Function} fn The function to mark
3855 function markFunction( fn ) {
3856 fn[ expando ] = true;
3861 * Support testing using an element
3862 * @param {Function} fn Passed the created div and expects a boolean result
3864 function assert( fn ) {
3865 var div = document.createElement("div");
3872 // release memory in IE
3877 function Sizzle( selector, context, results, seed ) {
3878 var match, elem, m, nodeType,
3880 i, groups, old, nid, newContext, newSelector;
3882 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
3883 setDocument( context );
3886 context = context || document;
3887 results = results || [];
3889 if ( !selector || typeof selector !== "string" ) {
3893 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
3897 if ( !documentIsXML && !seed ) {
3900 if ( (match = rquickExpr.exec( selector )) ) {
3901 // Speed-up: Sizzle("#ID")
3902 if ( (m = match[1]) ) {
3903 if ( nodeType === 9 ) {
3904 elem = context.getElementById( m );
3905 // Check parentNode to catch when Blackberry 4.6 returns
3906 // nodes that are no longer in the document #6963
3907 if ( elem && elem.parentNode ) {
3908 // Handle the case where IE, Opera, and Webkit return items
3909 // by name instead of ID
3910 if ( elem.id === m ) {
3911 results.push( elem );
3918 // Context is not a document
3919 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
3920 contains( context, elem ) && elem.id === m ) {
3921 results.push( elem );
3926 // Speed-up: Sizzle("TAG")
3927 } else if ( match[2] ) {
3928 push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
3931 // Speed-up: Sizzle(".CLASS")
3932 } else if ( (m = match[3]) && support.getByClassName && context.getElementsByClassName ) {
3933 push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
3939 if ( support.qsa && !rbuggyQSA.test(selector) ) {
3942 newContext = context;
3943 newSelector = nodeType === 9 && selector;
3945 // qSA works strangely on Element-rooted queries
3946 // We can work around this by specifying an extra ID on the root
3947 // and working up from there (Thanks to Andrew Dupont for the technique)
3948 // IE 8 doesn't work on object elements
3949 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
3950 groups = tokenize( selector );
3952 if ( (old = context.getAttribute("id")) ) {
3953 nid = old.replace( rescape, "\\$&" );
3955 context.setAttribute( "id", nid );
3957 nid = "[id='" + nid + "'] ";
3961 groups[i] = nid + toSelector( groups[i] );
3963 newContext = rsibling.test( selector ) && context.parentNode || context;
3964 newSelector = groups.join(",");
3967 if ( newSelector ) {
3969 push.apply( results, slice.call( newContext.querySelectorAll(
3976 context.removeAttribute("id");
3984 return select( selector.replace( rtrim, "$1" ), context, results, seed );
3989 * @param {Element|Object} elem An element or a document
3991 isXML = Sizzle.isXML = function( elem ) {
3992 // documentElement is verified for cases where it doesn't yet exist
3993 // (such as loading iframes in IE - #4833)
3994 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
3995 return documentElement ? documentElement.nodeName !== "HTML" : false;
3999 * Sets document-related variables once based on the current document
4000 * @param {Element|Object} [doc] An element or document object to use to set the document
4001 * @returns {Object} Returns the current document
4003 setDocument = Sizzle.setDocument = function( node ) {
4004 var doc = node ? node.ownerDocument || node : preferredDoc;
4006 // If no document and documentElement is available, return
4007 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
4013 docElem = doc.documentElement;
4016 documentIsXML = isXML( doc );
4018 // Check if getElementsByTagName("*") returns only elements
4019 support.tagNameNoComments = assert(function( div ) {
4020 div.appendChild( doc.createComment("") );
4021 return !div.getElementsByTagName("*").length;
4024 // Check if attributes should be retrieved by attribute nodes
4025 support.attributes = assert(function( div ) {
4026 div.innerHTML = "<select></select>";
4027 var type = typeof div.lastChild.getAttribute("multiple");
4028 // IE8 returns a string for some attributes even when not present
4029 return type !== "boolean" && type !== "string";
4032 // Check if getElementsByClassName can be trusted
4033 support.getByClassName = assert(function( div ) {
4034 // Opera can't find a second classname (in 9.6)
4035 div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
4036 if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
4040 // Safari 3.2 caches class attributes and doesn't catch changes
4041 div.lastChild.className = "e";
4042 return div.getElementsByClassName("e").length === 2;
4045 // Check if getElementById returns elements by name
4046 // Check if getElementsByName privileges form controls or returns elements by ID
4047 support.getByName = assert(function( div ) {
4049 div.id = expando + 0;
4050 div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
4051 docElem.insertBefore( div, docElem.firstChild );
4054 var pass = doc.getElementsByName &&
4055 // buggy browsers will return fewer than the correct 2
4056 doc.getElementsByName( expando ).length === 2 +
4057 // buggy browsers will return more than the correct 0
4058 doc.getElementsByName( expando + 0 ).length;
4059 support.getIdNotName = !doc.getElementById( expando );
4062 docElem.removeChild( div );
4067 // IE6/7 return modified attributes
4068 Expr.attrHandle = assert(function( div ) {
4069 div.innerHTML = "<a href='#'></a>";
4070 return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
4071 div.firstChild.getAttribute("href") === "#";
4075 "href": function( elem ) {
4076 return elem.getAttribute( "href", 2 );
4078 "type": function( elem ) {
4079 return elem.getAttribute("type");
4083 // ID find and filter
4084 if ( support.getIdNotName ) {
4085 Expr.find["ID"] = function( id, context ) {
4086 if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
4087 var m = context.getElementById( id );
4088 // Check parentNode to catch when Blackberry 4.6 returns
4089 // nodes that are no longer in the document #6963
4090 return m && m.parentNode ? [m] : [];
4093 Expr.filter["ID"] = function( id ) {
4094 var attrId = id.replace( runescape, funescape );
4095 return function( elem ) {
4096 return elem.getAttribute("id") === attrId;
4100 Expr.find["ID"] = function( id, context ) {
4101 if ( typeof context.getElementById !== strundefined && !documentIsXML ) {
4102 var m = context.getElementById( id );
4105 m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
4111 Expr.filter["ID"] = function( id ) {
4112 var attrId = id.replace( runescape, funescape );
4113 return function( elem ) {
4114 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
4115 return node && node.value === attrId;
4121 Expr.find["TAG"] = support.tagNameNoComments ?
4122 function( tag, context ) {
4123 if ( typeof context.getElementsByTagName !== strundefined ) {
4124 return context.getElementsByTagName( tag );
4127 function( tag, context ) {
4131 results = context.getElementsByTagName( tag );
4133 // Filter out possible comments
4134 if ( tag === "*" ) {
4135 for ( ; (elem = results[i]); i++ ) {
4136 if ( elem.nodeType === 1 ) {
4147 Expr.find["NAME"] = support.getByName && function( tag, context ) {
4148 if ( typeof context.getElementsByName !== strundefined ) {
4149 return context.getElementsByName( name );
4154 Expr.find["CLASS"] = support.getByClassName && function( className, context ) {
4155 if ( typeof context.getElementsByClassName !== strundefined && !documentIsXML ) {
4156 return context.getElementsByClassName( className );
4160 // QSA and matchesSelector support
4162 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
4165 // qSa(:focus) reports false when true (Chrome 21),
4166 // no need to also add to buggyMatches since matches checks buggyQSA
4167 // A support test would require too much code (would include document ready)
4168 rbuggyQSA = [ ":focus" ];
4170 if ( (support.qsa = isNative(doc.querySelectorAll)) ) {
4172 // Regex strategy adopted from Diego Perini
4173 assert(function( div ) {
4174 // Select is set to empty string on purpose
4175 // This is to test IE's treatment of not explictly
4176 // setting a boolean content attribute,
4177 // since its presence should be enough
4178 // http://bugs.jquery.com/ticket/12359
4179 div.innerHTML = "<select><option selected=''></option></select>";
4181 // IE8 - Some boolean attributes are not treated correctly
4182 if ( !div.querySelectorAll("[selected]").length ) {
4183 rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
4186 // Webkit/Opera - :checked should return selected option elements
4187 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4188 // IE8 throws error here and will not see later tests
4189 if ( !div.querySelectorAll(":checked").length ) {
4190 rbuggyQSA.push(":checked");
4194 assert(function( div ) {
4196 // Opera 10-12/IE8 - ^= $= *= and empty values
4197 // Should not select anything
4198 div.innerHTML = "<input type='hidden' i=''/>";
4199 if ( div.querySelectorAll("[i^='']").length ) {
4200 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
4203 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
4204 // IE8 throws error here and will not see later tests
4205 if ( !div.querySelectorAll(":enabled").length ) {
4206 rbuggyQSA.push( ":enabled", ":disabled" );
4209 // Opera 10-11 does not throw on post-comma invalid pseudos
4210 div.querySelectorAll("*,:x");
4211 rbuggyQSA.push(",.*:");
4215 if ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector ||
4216 docElem.mozMatchesSelector ||
4217 docElem.webkitMatchesSelector ||
4218 docElem.oMatchesSelector ||
4219 docElem.msMatchesSelector) )) ) {
4221 assert(function( div ) {
4222 // Check to see if it's possible to do matchesSelector
4223 // on a disconnected node (IE 9)
4224 support.disconnectedMatch = matches.call( div, "div" );
4226 // This should fail with an exception
4227 // Gecko does not error, returns false instead
4228 matches.call( div, "[s!='']:x" );
4229 rbuggyMatches.push( "!=", pseudos );
4233 rbuggyQSA = new RegExp( rbuggyQSA.join("|") );
4234 rbuggyMatches = new RegExp( rbuggyMatches.join("|") );
4236 // Element contains another
4237 // Purposefully does not implement inclusive descendent
4238 // As in, an element does not contain itself
4239 contains = isNative(docElem.contains) || docElem.compareDocumentPosition ?
4241 var adown = a.nodeType === 9 ? a.documentElement : a,
4242 bup = b && b.parentNode;
4243 return a === bup || !!( bup && bup.nodeType === 1 && (
4245 adown.contains( bup ) :
4246 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
4251 while ( (b = b.parentNode) ) {
4260 // Document order sorting
4261 sortOrder = docElem.compareDocumentPosition ?
4266 hasDuplicate = true;
4270 if ( (compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b )) ) {
4271 if ( compare & 1 || a.parentNode && a.parentNode.nodeType === 11 ) {
4272 if ( a === doc || contains( preferredDoc, a ) ) {
4275 if ( b === doc || contains( preferredDoc, b ) ) {
4280 return compare & 4 ? -1 : 1;
4283 return a.compareDocumentPosition ? -1 : 1;
4293 // The nodes are identical, we can exit early
4295 hasDuplicate = true;
4298 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4299 } else if ( a.sourceIndex && b.sourceIndex ) {
4300 return ( ~b.sourceIndex || MAX_NEGATIVE ) - ( contains( preferredDoc, a ) && ~a.sourceIndex || MAX_NEGATIVE );
4302 // Parentless nodes are either documents or disconnected
4303 } else if ( !aup || !bup ) {
4304 return a === doc ? -1 :
4310 // If the nodes are siblings, we can do a quick check
4311 } else if ( aup === bup ) {
4312 return siblingCheck( a, b );
4315 // Otherwise we need full lists of their ancestors for comparison
4317 while ( (cur = cur.parentNode) ) {
4321 while ( (cur = cur.parentNode) ) {
4325 // Walk down the tree looking for a discrepancy
4326 while ( ap[i] === bp[i] ) {
4331 // Do a sibling check if the nodes have a common ancestor
4332 siblingCheck( ap[i], bp[i] ) :
4334 // Otherwise nodes in our document sort first
4335 ap[i] === preferredDoc ? -1 :
4336 bp[i] === preferredDoc ? 1 :
4340 // Always assume the presence of duplicates if sort doesn't
4341 // pass them to our comparison function (as in Google Chrome).
4342 hasDuplicate = false;
4343 [0, 0].sort( sortOrder );
4344 support.detectDuplicates = hasDuplicate;
4349 Sizzle.matches = function( expr, elements ) {
4350 return Sizzle( expr, null, null, elements );
4353 Sizzle.matchesSelector = function( elem, expr ) {
4354 // Set document vars if needed
4355 if ( ( elem.ownerDocument || elem ) !== document ) {
4356 setDocument( elem );
4359 // Make sure that attribute selectors are quoted
4360 expr = expr.replace( rattributeQuotes, "='$1']" );
4362 // rbuggyQSA always contains :focus, so no need for an existence check
4363 if ( support.matchesSelector && !documentIsXML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) {
4365 var ret = matches.call( elem, expr );
4367 // IE 9's matchesSelector returns false on disconnected nodes
4368 if ( ret || support.disconnectedMatch ||
4369 // As well, disconnected nodes are said to be in a document
4371 elem.document && elem.document.nodeType !== 11 ) {
4377 return Sizzle( expr, document, null, [elem] ).length > 0;
4380 Sizzle.contains = function( context, elem ) {
4381 // Set document vars if needed
4382 if ( ( context.ownerDocument || context ) !== document ) {
4383 setDocument( context );
4385 return contains( context, elem );
4388 Sizzle.attr = function( elem, name ) {
4391 // Set document vars if needed
4392 if ( ( elem.ownerDocument || elem ) !== document ) {
4393 setDocument( elem );
4396 if ( !documentIsXML ) {
4397 name = name.toLowerCase();
4399 if ( (val = Expr.attrHandle[ name ]) ) {
4402 if ( documentIsXML || support.attributes ) {
4403 return elem.getAttribute( name );
4405 return ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ?
4407 val && val.specified ? val.value : null;
4410 Sizzle.error = function( msg ) {
4411 throw new Error( "Syntax error, unrecognized expression: " + msg );
4414 // Document sorting and removing duplicates
4415 Sizzle.uniqueSort = function( results ) {
4421 // Unless we *know* we can detect duplicates, assume their presence
4422 hasDuplicate = !support.detectDuplicates;
4423 results.sort( sortOrder );
4425 if ( hasDuplicate ) {
4426 for ( ; (elem = results[i]); i++ ) {
4427 if ( elem === results[ i - 1 ] ) {
4428 j = duplicates.push( i );
4432 results.splice( duplicates[ j ], 1 );
4439 function siblingCheck( a, b ) {
4440 var cur = a && b && a.nextSibling;
4442 for ( ; cur; cur = cur.nextSibling ) {
4451 // Returns a function to use in pseudos for input types
4452 function createInputPseudo( type ) {
4453 return function( elem ) {
4454 var name = elem.nodeName.toLowerCase();
4455 return name === "input" && elem.type === type;
4459 // Returns a function to use in pseudos for buttons
4460 function createButtonPseudo( type ) {
4461 return function( elem ) {
4462 var name = elem.nodeName.toLowerCase();
4463 return (name === "input" || name === "button") && elem.type === type;
4467 // Returns a function to use in pseudos for positionals
4468 function createPositionalPseudo( fn ) {
4469 return markFunction(function( argument ) {
4470 argument = +argument;
4471 return markFunction(function( seed, matches ) {
4473 matchIndexes = fn( [], seed.length, argument ),
4474 i = matchIndexes.length;
4476 // Match elements found at the specified indexes
4478 if ( seed[ (j = matchIndexes[i]) ] ) {
4479 seed[j] = !(matches[j] = seed[j]);
4487 * Utility function for retrieving the text value of an array of DOM nodes
4488 * @param {Array|Element} elem
4490 getText = Sizzle.getText = function( elem ) {
4494 nodeType = elem.nodeType;
4497 // If no nodeType, this is expected to be an array
4498 for ( ; (node = elem[i]); i++ ) {
4499 // Do not traverse comment nodes
4500 ret += getText( node );
4502 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
4503 // Use textContent for elements
4504 // innerText usage removed for consistency of new lines (see #11153)
4505 if ( typeof elem.textContent === "string" ) {
4506 return elem.textContent;
4508 // Traverse its children
4509 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4510 ret += getText( elem );
4513 } else if ( nodeType === 3 || nodeType === 4 ) {
4514 return elem.nodeValue;
4516 // Do not include comment or processing instruction nodes
4521 Expr = Sizzle.selectors = {
4523 // Can be adjusted by the user
4526 createPseudo: markFunction,
4533 ">": { dir: "parentNode", first: true },
4534 " ": { dir: "parentNode" },
4535 "+": { dir: "previousSibling", first: true },
4536 "~": { dir: "previousSibling" }
4540 "ATTR": function( match ) {
4541 match[1] = match[1].replace( runescape, funescape );
4543 // Move the given value to match[3] whether quoted or unquoted
4544 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
4546 if ( match[2] === "~=" ) {
4547 match[3] = " " + match[3] + " ";
4550 return match.slice( 0, 4 );
4553 "CHILD": function( match ) {
4554 /* matches from matchExpr["CHILD"]
4555 1 type (only|nth|...)
4556 2 what (child|of-type)
4557 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4558 4 xn-component of xn+y argument ([+-]?\d*n|)
4559 5 sign of xn-component
4561 7 sign of y-component
4564 match[1] = match[1].toLowerCase();
4566 if ( match[1].slice( 0, 3 ) === "nth" ) {
4567 // nth-* requires argument
4569 Sizzle.error( match[0] );
4572 // numeric x and y parameters for Expr.filter.CHILD
4573 // remember that false/true cast respectively to 0/1
4574 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
4575 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
4577 // other types prohibit arguments
4578 } else if ( match[3] ) {
4579 Sizzle.error( match[0] );
4585 "PSEUDO": function( match ) {
4587 unquoted = !match[5] && match[2];
4589 if ( matchExpr["CHILD"].test( match[0] ) ) {
4593 // Accept quoted arguments as-is
4595 match[2] = match[4];
4597 // Strip excess characters from unquoted arguments
4598 } else if ( unquoted && rpseudo.test( unquoted ) &&
4599 // Get excess from tokenize (recursively)
4600 (excess = tokenize( unquoted, true )) &&
4601 // advance to the next closing parenthesis
4602 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
4604 // excess is a negative index
4605 match[0] = match[0].slice( 0, excess );
4606 match[2] = unquoted.slice( 0, excess );
4609 // Return only captures needed by the pseudo filter method (type and argument)
4610 return match.slice( 0, 3 );
4616 "TAG": function( nodeName ) {
4617 if ( nodeName === "*" ) {
4618 return function() { return true; };
4621 nodeName = nodeName.replace( runescape, funescape ).toLowerCase();
4622 return function( elem ) {
4623 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
4627 "CLASS": function( className ) {
4628 var pattern = classCache[ className + " " ];
4631 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
4632 classCache( className, function( elem ) {
4633 return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4637 "ATTR": function( name, operator, check ) {
4638 return function( elem ) {
4639 var result = Sizzle.attr( elem, name );
4641 if ( result == null ) {
4642 return operator === "!=";
4650 return operator === "=" ? result === check :
4651 operator === "!=" ? result !== check :
4652 operator === "^=" ? check && result.indexOf( check ) === 0 :
4653 operator === "*=" ? check && result.indexOf( check ) > -1 :
4654 operator === "$=" ? check && result.substr( result.length - check.length ) === check :
4655 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
4656 operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
4661 "CHILD": function( type, what, argument, first, last ) {
4662 var simple = type.slice( 0, 3 ) !== "nth",
4663 forward = type.slice( -4 ) !== "last",
4664 ofType = what === "of-type";
4666 return first === 1 && last === 0 ?
4668 // Shortcut for :nth-*(n)
4670 return !!elem.parentNode;
4673 function( elem, context, xml ) {
4674 var cache, outerCache, node, diff, nodeIndex, start,
4675 dir = simple !== forward ? "nextSibling" : "previousSibling",
4676 parent = elem.parentNode,
4677 name = ofType && elem.nodeName.toLowerCase(),
4678 useCache = !xml && !ofType;
4682 // :(first|last|only)-(child|of-type)
4686 while ( (node = node[ dir ]) ) {
4687 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
4691 // Reverse direction for :only-* (if we haven't yet done so)
4692 start = dir = type === "only" && !start && "nextSibling";
4697 start = [ forward ? parent.firstChild : parent.lastChild ];
4699 // non-xml :nth-child(...) stores cache data on `parent`
4700 if ( forward && useCache ) {
4701 // Seek `elem` from a previously-cached index
4702 outerCache = parent[ expando ] || (parent[ expando ] = {});
4703 cache = outerCache[ type ] || [];
4704 nodeIndex = cache[0] === dirruns && cache[1];
4705 diff = cache[0] === dirruns && cache[2];
4706 node = nodeIndex && parent.childNodes[ nodeIndex ];
4708 while ( (node = ++nodeIndex && node && node[ dir ] ||
4710 // Fallback to seeking `elem` from the start
4711 (diff = nodeIndex = 0) || start.pop()) ) {
4713 // When found, cache indexes on `parent` and break
4714 if ( node.nodeType === 1 && ++diff && node === elem ) {
4715 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
4720 // Use previously-cached element index if available
4721 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
4724 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
4726 // Use the same loop as above to seek `elem` from the start
4727 while ( (node = ++nodeIndex && node && node[ dir ] ||
4728 (diff = nodeIndex = 0) || start.pop()) ) {
4730 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
4731 // Cache the index of each encountered element
4733 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
4736 if ( node === elem ) {
4743 // Incorporate the offset, then check against cycle size
4745 return diff === first || ( diff % first === 0 && diff / first >= 0 );
4750 "PSEUDO": function( pseudo, argument ) {
4751 // pseudo-class names are case-insensitive
4752 // http://www.w3.org/TR/selectors/#pseudo-classes
4753 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4754 // Remember that setFilters inherits from pseudos
4756 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
4757 Sizzle.error( "unsupported pseudo: " + pseudo );
4759 // The user may use createPseudo to indicate that
4760 // arguments are needed to create the filter function
4761 // just as Sizzle does
4762 if ( fn[ expando ] ) {
4763 return fn( argument );
4766 // But maintain support for old signatures
4767 if ( fn.length > 1 ) {
4768 args = [ pseudo, pseudo, "", argument ];
4769 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
4770 markFunction(function( seed, matches ) {
4772 matched = fn( seed, argument ),
4775 idx = indexOf.call( seed, matched[i] );
4776 seed[ idx ] = !( matches[ idx ] = matched[i] );
4780 return fn( elem, 0, args );
4789 // Potentially complex pseudos
4790 "not": markFunction(function( selector ) {
4791 // Trim the selector passed to compile
4792 // to avoid treating leading and trailing
4793 // spaces as combinators
4796 matcher = compile( selector.replace( rtrim, "$1" ) );
4798 return matcher[ expando ] ?
4799 markFunction(function( seed, matches, context, xml ) {
4801 unmatched = matcher( seed, null, xml, [] ),
4804 // Match elements unmatched by `matcher`
4806 if ( (elem = unmatched[i]) ) {
4807 seed[i] = !(matches[i] = elem);
4811 function( elem, context, xml ) {
4813 matcher( input, null, xml, results );
4814 return !results.pop();
4818 "has": markFunction(function( selector ) {
4819 return function( elem ) {
4820 return Sizzle( selector, elem ).length > 0;
4824 "contains": markFunction(function( text ) {
4825 return function( elem ) {
4826 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4830 // "Whether an element is represented by a :lang() selector
4831 // is based solely on the element's language value
4832 // being equal to the identifier C,
4833 // or beginning with the identifier C immediately followed by "-".
4834 // The matching of C against the element's language value is performed case-insensitively.
4835 // The identifier C does not have to be a valid language name."
4836 // http://www.w3.org/TR/selectors/#lang-pseudo
4837 "lang": markFunction( function( lang ) {
4838 // lang value must be a valid identifider
4839 if ( !ridentifier.test(lang || "") ) {
4840 Sizzle.error( "unsupported lang: " + lang );
4842 lang = lang.replace( runescape, funescape ).toLowerCase();
4843 return function( elem ) {
4846 if ( (elemLang = documentIsXML ?
4847 elem.getAttribute("xml:lang") || elem.getAttribute("lang") :
4850 elemLang = elemLang.toLowerCase();
4851 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
4853 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
4859 "target": function( elem ) {
4860 var hash = window.location && window.location.hash;
4861 return hash && hash.slice( 1 ) === elem.id;
4864 "root": function( elem ) {
4865 return elem === docElem;
4868 "focus": function( elem ) {
4869 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
4872 // Boolean properties
4873 "enabled": function( elem ) {
4874 return elem.disabled === false;
4877 "disabled": function( elem ) {
4878 return elem.disabled === true;
4881 "checked": function( elem ) {
4882 // In CSS3, :checked should return both checked and selected elements
4883 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4884 var nodeName = elem.nodeName.toLowerCase();
4885 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
4888 "selected": function( elem ) {
4889 // Accessing this property makes selected-by-default
4890 // options in Safari work properly
4891 if ( elem.parentNode ) {
4892 elem.parentNode.selectedIndex;
4895 return elem.selected === true;
4899 "empty": function( elem ) {
4900 // http://www.w3.org/TR/selectors/#empty-pseudo
4901 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
4902 // not comment, processing instructions, or others
4903 // Thanks to Diego Perini for the nodeName shortcut
4904 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
4905 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4906 if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
4913 "parent": function( elem ) {
4914 return !Expr.pseudos["empty"]( elem );
4917 // Element/input types
4918 "header": function( elem ) {
4919 return rheader.test( elem.nodeName );
4922 "input": function( elem ) {
4923 return rinputs.test( elem.nodeName );
4926 "button": function( elem ) {
4927 var name = elem.nodeName.toLowerCase();
4928 return name === "input" && elem.type === "button" || name === "button";
4931 "text": function( elem ) {
4933 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4934 // use getAttribute instead to test this case
4935 return elem.nodeName.toLowerCase() === "input" &&
4936 elem.type === "text" &&
4937 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
4940 // Position-in-collection
4941 "first": createPositionalPseudo(function() {
4945 "last": createPositionalPseudo(function( matchIndexes, length ) {
4946 return [ length - 1 ];
4949 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
4950 return [ argument < 0 ? argument + length : argument ];
4953 "even": createPositionalPseudo(function( matchIndexes, length ) {
4955 for ( ; i < length; i += 2 ) {
4956 matchIndexes.push( i );
4958 return matchIndexes;
4961 "odd": createPositionalPseudo(function( matchIndexes, length ) {
4963 for ( ; i < length; i += 2 ) {
4964 matchIndexes.push( i );
4966 return matchIndexes;
4969 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4970 var i = argument < 0 ? argument + length : argument;
4971 for ( ; --i >= 0; ) {
4972 matchIndexes.push( i );
4974 return matchIndexes;
4977 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4978 var i = argument < 0 ? argument + length : argument;
4979 for ( ; ++i < length; ) {
4980 matchIndexes.push( i );
4982 return matchIndexes;
4987 // Add button/input type pseudos
4988 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
4989 Expr.pseudos[ i ] = createInputPseudo( i );
4991 for ( i in { submit: true, reset: true } ) {
4992 Expr.pseudos[ i ] = createButtonPseudo( i );
4995 function tokenize( selector, parseOnly ) {
4996 var matched, match, tokens, type,
4997 soFar, groups, preFilters,
4998 cached = tokenCache[ selector + " " ];
5001 return parseOnly ? 0 : cached.slice( 0 );
5006 preFilters = Expr.preFilter;
5010 // Comma and first run
5011 if ( !matched || (match = rcomma.exec( soFar )) ) {
5013 // Don't consume trailing commas as valid
5014 soFar = soFar.slice( match[0].length ) || soFar;
5016 groups.push( tokens = [] );
5022 if ( (match = rcombinators.exec( soFar )) ) {
5023 matched = match.shift();
5026 // Cast descendant combinators to space
5027 type: match[0].replace( rtrim, " " )
5029 soFar = soFar.slice( matched.length );
5033 for ( type in Expr.filter ) {
5034 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
5035 (match = preFilters[ type ]( match ))) ) {
5036 matched = match.shift();
5042 soFar = soFar.slice( matched.length );
5051 // Return the length of the invalid excess
5052 // if we're just parsing
5053 // Otherwise, throw an error or return tokens
5057 Sizzle.error( selector ) :
5059 tokenCache( selector, groups ).slice( 0 );
5062 function toSelector( tokens ) {
5064 len = tokens.length,
5066 for ( ; i < len; i++ ) {
5067 selector += tokens[i].value;
5072 function addCombinator( matcher, combinator, base ) {
5073 var dir = combinator.dir,
5074 checkNonElements = base && combinator.dir === "parentNode",
5077 return combinator.first ?
5078 // Check against closest ancestor/preceding element
5079 function( elem, context, xml ) {
5080 while ( (elem = elem[ dir ]) ) {
5081 if ( elem.nodeType === 1 || checkNonElements ) {
5082 return matcher( elem, context, xml );
5087 // Check against all ancestor/preceding elements
5088 function( elem, context, xml ) {
5089 var data, cache, outerCache,
5090 dirkey = dirruns + " " + doneName;
5092 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
5094 while ( (elem = elem[ dir ]) ) {
5095 if ( elem.nodeType === 1 || checkNonElements ) {
5096 if ( matcher( elem, context, xml ) ) {
5102 while ( (elem = elem[ dir ]) ) {
5103 if ( elem.nodeType === 1 || checkNonElements ) {
5104 outerCache = elem[ expando ] || (elem[ expando ] = {});
5105 if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
5106 if ( (data = cache[1]) === true || data === cachedruns ) {
5107 return data === true;
5110 cache = outerCache[ dir ] = [ dirkey ];
5111 cache[1] = matcher( elem, context, xml ) || cachedruns;
5112 if ( cache[1] === true ) {
5122 function elementMatcher( matchers ) {
5123 return matchers.length > 1 ?
5124 function( elem, context, xml ) {
5125 var i = matchers.length;
5127 if ( !matchers[i]( elem, context, xml ) ) {
5136 function condense( unmatched, map, filter, context, xml ) {
5140 len = unmatched.length,
5141 mapped = map != null;
5143 for ( ; i < len; i++ ) {
5144 if ( (elem = unmatched[i]) ) {
5145 if ( !filter || filter( elem, context, xml ) ) {
5146 newUnmatched.push( elem );
5154 return newUnmatched;
5157 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
5158 if ( postFilter && !postFilter[ expando ] ) {
5159 postFilter = setMatcher( postFilter );
5161 if ( postFinder && !postFinder[ expando ] ) {
5162 postFinder = setMatcher( postFinder, postSelector );
5164 return markFunction(function( seed, results, context, xml ) {
5168 preexisting = results.length,
5170 // Get initial elements from seed or context
5171 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
5173 // Prefilter to get matcher input, preserving a map for seed-results synchronization
5174 matcherIn = preFilter && ( seed || !selector ) ?
5175 condense( elems, preMap, preFilter, context, xml ) :
5178 matcherOut = matcher ?
5179 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
5180 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
5182 // ...intermediate processing is necessary
5185 // ...otherwise use results directly
5189 // Find primary matches
5191 matcher( matcherIn, matcherOut, context, xml );
5196 temp = condense( matcherOut, postMap );
5197 postFilter( temp, [], context, xml );
5199 // Un-match failing elements by moving them back to matcherIn
5202 if ( (elem = temp[i]) ) {
5203 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
5209 if ( postFinder || preFilter ) {
5211 // Get the final matcherOut by condensing this intermediate into postFinder contexts
5213 i = matcherOut.length;
5215 if ( (elem = matcherOut[i]) ) {
5216 // Restore matcherIn since elem is not yet a final match
5217 temp.push( (matcherIn[i] = elem) );
5220 postFinder( null, (matcherOut = []), temp, xml );
5223 // Move matched elements from seed to results to keep them synchronized
5224 i = matcherOut.length;
5226 if ( (elem = matcherOut[i]) &&
5227 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
5229 seed[temp] = !(results[temp] = elem);
5234 // Add elements to results, through postFinder if defined
5236 matcherOut = condense(
5237 matcherOut === results ?
5238 matcherOut.splice( preexisting, matcherOut.length ) :
5242 postFinder( null, results, matcherOut, xml );
5244 push.apply( results, matcherOut );
5250 function matcherFromTokens( tokens ) {
5251 var checkContext, matcher, j,
5252 len = tokens.length,
5253 leadingRelative = Expr.relative[ tokens[0].type ],
5254 implicitRelative = leadingRelative || Expr.relative[" "],
5255 i = leadingRelative ? 1 : 0,
5257 // The foundational matcher ensures that elements are reachable from top-level context(s)
5258 matchContext = addCombinator( function( elem ) {
5259 return elem === checkContext;
5260 }, implicitRelative, true ),
5261 matchAnyContext = addCombinator( function( elem ) {
5262 return indexOf.call( checkContext, elem ) > -1;
5263 }, implicitRelative, true ),
5264 matchers = [ function( elem, context, xml ) {
5265 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
5266 (checkContext = context).nodeType ?
5267 matchContext( elem, context, xml ) :
5268 matchAnyContext( elem, context, xml ) );
5271 for ( ; i < len; i++ ) {
5272 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
5273 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
5275 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
5277 // Return special upon seeing a positional matcher
5278 if ( matcher[ expando ] ) {
5279 // Find the next relative operator (if any) for proper handling
5281 for ( ; j < len; j++ ) {
5282 if ( Expr.relative[ tokens[j].type ] ) {
5287 i > 1 && elementMatcher( matchers ),
5288 i > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, "$1" ),
5290 i < j && matcherFromTokens( tokens.slice( i, j ) ),
5291 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
5292 j < len && toSelector( tokens )
5295 matchers.push( matcher );
5299 return elementMatcher( matchers );
5302 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
5303 // A counter to specify which element is currently being matched
5304 var matcherCachedRuns = 0,
5305 bySet = setMatchers.length > 0,
5306 byElement = elementMatchers.length > 0,
5307 superMatcher = function( seed, context, xml, results, expandContext ) {
5308 var elem, j, matcher,
5312 unmatched = seed && [],
5313 outermost = expandContext != null,
5314 contextBackup = outermostContext,
5315 // We must always have either seed elements or context
5316 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
5317 // Nested matchers should use non-integer dirruns
5318 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
5321 outermostContext = context !== document && context;
5322 cachedruns = matcherCachedRuns;
5325 // Add elements passing elementMatchers directly to results
5326 for ( ; (elem = elems[i]) != null; i++ ) {
5327 if ( byElement && elem ) {
5328 for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
5329 if ( matcher( elem, context, xml ) ) {
5330 results.push( elem );
5335 dirruns = dirrunsUnique;
5336 cachedruns = ++matcherCachedRuns;
5340 // Track unmatched elements for set filters
5342 // They will have gone through all possible matchers
5343 if ( (elem = !matcher && elem) ) {
5347 // Lengthen the array for every element, matched or not
5349 unmatched.push( elem );
5354 // Apply set filters to unmatched elements
5355 // `i` starts as a string, so matchedCount would equal "00" if there are no elements
5357 if ( bySet && i !== matchedCount ) {
5358 for ( j = 0; (matcher = setMatchers[j]); j++ ) {
5359 matcher( unmatched, setMatched, context, xml );
5363 // Reintegrate element matches to eliminate the need for sorting
5364 if ( matchedCount > 0 ) {
5366 if ( !(unmatched[i] || setMatched[i]) ) {
5367 setMatched[i] = pop.call( results );
5372 // Discard index placeholder values to get only actual matches
5373 setMatched = condense( setMatched );
5376 // Add matches to results
5377 push.apply( results, setMatched );
5379 // Seedless set matches succeeding multiple successful matchers stipulate sorting
5380 if ( outermost && !seed && setMatched.length > 0 &&
5381 ( matchedCount + setMatchers.length ) > 1 ) {
5383 Sizzle.uniqueSort( results );
5387 // Override manipulation of globals by nested matchers
5389 dirruns = dirrunsUnique;
5390 outermostContext = contextBackup;
5397 markFunction( superMatcher ) :
5401 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
5404 elementMatchers = [],
5405 cached = compilerCache[ selector + " " ];
5408 // Generate a function of recursive functions that can be used to check each element
5410 group = tokenize( selector );
5414 cached = matcherFromTokens( group[i] );
5415 if ( cached[ expando ] ) {
5416 setMatchers.push( cached );
5418 elementMatchers.push( cached );
5422 // Cache the compiled function
5423 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
5428 function multipleContexts( selector, contexts, results ) {
5430 len = contexts.length;
5431 for ( ; i < len; i++ ) {
5432 Sizzle( selector, contexts[i], results );
5437 function select( selector, context, results, seed ) {
5438 var i, tokens, token, type, find,
5439 match = tokenize( selector );
5442 // Try to minimize operations if there is only one group
5443 if ( match.length === 1 ) {
5445 // Take a shortcut and set the context if the root selector is an ID
5446 tokens = match[0] = match[0].slice( 0 );
5447 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
5448 context.nodeType === 9 && !documentIsXML &&
5449 Expr.relative[ tokens[1].type ] ) {
5451 context = Expr.find["ID"]( token.matches[0].replace( runescape, funescape ), context )[0];
5456 selector = selector.slice( tokens.shift().value.length );
5459 // Fetch a seed set for right-to-left matching
5460 for ( i = matchExpr["needsContext"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
5463 // Abort if we hit a combinator
5464 if ( Expr.relative[ (type = token.type) ] ) {
5467 if ( (find = Expr.find[ type ]) ) {
5468 // Search, expanding context for leading sibling combinators
5470 token.matches[0].replace( runescape, funescape ),
5471 rsibling.test( tokens[0].type ) && context.parentNode || context
5474 // If seed is empty or no tokens remain, we can return early
5475 tokens.splice( i, 1 );
5476 selector = seed.length && toSelector( tokens );
5478 push.apply( results, slice.call( seed, 0 ) );
5489 // Compile and execute a filtering function
5490 // Provide `match` to avoid retokenization if we modified the selector above
5491 compile( selector, match )(
5496 rsibling.test( selector )
5502 Expr.pseudos["nth"] = Expr.pseudos["eq"];
5504 // Easy API for creating new setFilters
5505 function setFilters() {}
5506 Expr.filters = setFilters.prototype = Expr.pseudos;
5507 Expr.setFilters = new setFilters();
5509 // Initialize with the default document
5512 // Override sizzle attribute retrieval
5513 Sizzle.attr = jQuery.attr;
5514 jQuery.find = Sizzle;
5515 jQuery.expr = Sizzle.selectors;
5516 jQuery.expr[":"] = jQuery.expr.pseudos;
5517 jQuery.unique = Sizzle.uniqueSort;
5518 jQuery.text = Sizzle.getText;
5519 jQuery.isXMLDoc = Sizzle.isXML;
5520 jQuery.contains = Sizzle.contains;
5524 var runtil = /Until$/,
5525 rparentsprev = /^(?:parents|prev(?:Until|All))/,
5526 isSimple = /^.[^:#\[\.,]*$/,
5527 rneedsContext = jQuery.expr.match.needsContext,
5528 // methods guaranteed to produce a unique set when starting from a unique set
5529 guaranteedUnique = {
5537 find: function( selector ) {
5540 if ( typeof selector !== "string" ) {
5542 return this.pushStack( jQuery( selector ).filter(function() {
5543 for ( i = 0; i < self.length; i++ ) {
5544 if ( jQuery.contains( self[ i ], this ) ) {
5552 for ( i = 0; i < this.length; i++ ) {
5553 jQuery.find( selector, this[ i ], ret );
5556 // Needed because $( selector, context ) becomes $( context ).find( selector )
5557 ret = this.pushStack( jQuery.unique( ret ) );
5558 ret.selector = ( this.selector ? this.selector + " " : "" ) + selector;
5562 has: function( target ) {
5564 targets = jQuery( target, this ),
5565 len = targets.length;
5567 return this.filter(function() {
5568 for ( i = 0; i < len; i++ ) {
5569 if ( jQuery.contains( this, targets[i] ) ) {
5576 not: function( selector ) {
5577 return this.pushStack( winnow(this, selector, false) );
5580 filter: function( selector ) {
5581 return this.pushStack( winnow(this, selector, true) );
5584 is: function( selector ) {
5585 return !!selector && (
5586 typeof selector === "string" ?
5587 // If this is a positional/relative selector, check membership in the returned set
5588 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5589 rneedsContext.test( selector ) ?
5590 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5591 jQuery.filter( selector, this ).length > 0 :
5592 this.filter( selector ).length > 0 );
5595 closest: function( selectors, context ) {
5600 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5601 jQuery( selectors, context || this.context ) :
5604 for ( ; i < l; i++ ) {
5607 while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5608 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5612 cur = cur.parentNode;
5616 return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
5619 // Determine the position of an element within
5620 // the matched set of elements
5621 index: function( elem ) {
5623 // No argument, return index in parent
5625 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
5628 // index in selector
5629 if ( typeof elem === "string" ) {
5630 return jQuery.inArray( this[0], jQuery( elem ) );
5633 // Locate the position of the desired element
5634 return jQuery.inArray(
5635 // If it receives a jQuery object, the first element is used
5636 elem.jquery ? elem[0] : elem, this );
5639 add: function( selector, context ) {
5640 var set = typeof selector === "string" ?
5641 jQuery( selector, context ) :
5642 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5643 all = jQuery.merge( this.get(), set );
5645 return this.pushStack( jQuery.unique(all) );
5648 addBack: function( selector ) {
5649 return this.add( selector == null ?
5650 this.prevObject : this.prevObject.filter(selector)
5655 jQuery.fn.andSelf = jQuery.fn.addBack;
5657 function sibling( cur, dir ) {
5660 } while ( cur && cur.nodeType !== 1 );
5666 parent: function( elem ) {
5667 var parent = elem.parentNode;
5668 return parent && parent.nodeType !== 11 ? parent : null;
5670 parents: function( elem ) {
5671 return jQuery.dir( elem, "parentNode" );
5673 parentsUntil: function( elem, i, until ) {
5674 return jQuery.dir( elem, "parentNode", until );
5676 next: function( elem ) {
5677 return sibling( elem, "nextSibling" );
5679 prev: function( elem ) {
5680 return sibling( elem, "previousSibling" );
5682 nextAll: function( elem ) {
5683 return jQuery.dir( elem, "nextSibling" );
5685 prevAll: function( elem ) {
5686 return jQuery.dir( elem, "previousSibling" );
5688 nextUntil: function( elem, i, until ) {
5689 return jQuery.dir( elem, "nextSibling", until );
5691 prevUntil: function( elem, i, until ) {
5692 return jQuery.dir( elem, "previousSibling", until );
5694 siblings: function( elem ) {
5695 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5697 children: function( elem ) {
5698 return jQuery.sibling( elem.firstChild );
5700 contents: function( elem ) {
5701 return jQuery.nodeName( elem, "iframe" ) ?
5702 elem.contentDocument || elem.contentWindow.document :
5703 jQuery.merge( [], elem.childNodes );
5705 }, function( name, fn ) {
5706 jQuery.fn[ name ] = function( until, selector ) {
5707 var ret = jQuery.map( this, fn, until );
5709 if ( !runtil.test( name ) ) {
5713 if ( selector && typeof selector === "string" ) {
5714 ret = jQuery.filter( selector, ret );
5717 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5719 if ( this.length > 1 && rparentsprev.test( name ) ) {
5720 ret = ret.reverse();
5723 return this.pushStack( ret );
5728 filter: function( expr, elems, not ) {
5730 expr = ":not(" + expr + ")";
5733 return elems.length === 1 ?
5734 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5735 jQuery.find.matches(expr, elems);
5738 dir: function( elem, dir, until ) {
5742 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5743 if ( cur.nodeType === 1 ) {
5744 matched.push( cur );
5751 sibling: function( n, elem ) {
5754 for ( ; n; n = n.nextSibling ) {
5755 if ( n.nodeType === 1 && n !== elem ) {
5764 // Implement the identical functionality for filter and not
5765 function winnow( elements, qualifier, keep ) {
5767 // Can't pass null or undefined to indexOf in Firefox 4
5768 // Set to 0 to skip string check
5769 qualifier = qualifier || 0;
5771 if ( jQuery.isFunction( qualifier ) ) {
5772 return jQuery.grep(elements, function( elem, i ) {
5773 var retVal = !!qualifier.call( elem, i, elem );
5774 return retVal === keep;
5777 } else if ( qualifier.nodeType ) {
5778 return jQuery.grep(elements, function( elem ) {
5779 return ( elem === qualifier ) === keep;
5782 } else if ( typeof qualifier === "string" ) {
5783 var filtered = jQuery.grep(elements, function( elem ) {
5784 return elem.nodeType === 1;
5787 if ( isSimple.test( qualifier ) ) {
5788 return jQuery.filter(qualifier, filtered, !keep);
5790 qualifier = jQuery.filter( qualifier, filtered );
5794 return jQuery.grep(elements, function( elem ) {
5795 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5798 function createSafeFragment( document ) {
5799 var list = nodeNames.split( "|" ),
5800 safeFrag = document.createDocumentFragment();
5802 if ( safeFrag.createElement ) {
5803 while ( list.length ) {
5804 safeFrag.createElement(
5812 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5813 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5814 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5815 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5816 rleadingWhitespace = /^\s+/,
5817 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5818 rtagName = /<([\w:]+)/,
5820 rhtml = /<|&#?\w+;/,
5821 rnoInnerhtml = /<(?:script|style|link)/i,
5822 manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
5823 // checked="checked" or checked
5824 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5825 rscriptType = /^$|\/(?:java|ecma)script/i,
5826 rscriptTypeMasked = /^true\/(.*)/,
5827 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
5829 // We have to close these tags to support XHTML (#13200)
5831 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5832 legend: [ 1, "<fieldset>", "</fieldset>" ],
5833 area: [ 1, "<map>", "</map>" ],
5834 param: [ 1, "<object>", "</object>" ],
5835 thead: [ 1, "<table>", "</table>" ],
5836 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5837 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5838 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5840 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5841 // unless wrapped in a div with non-breaking characters in front of it.
5842 _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
5844 safeFragment = createSafeFragment( document ),
5845 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5847 wrapMap.optgroup = wrapMap.option;
5848 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5849 wrapMap.th = wrapMap.td;
5852 text: function( value ) {
5853 return jQuery.access( this, function( value ) {
5854 return value === undefined ?
5855 jQuery.text( this ) :
5856 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5857 }, null, value, arguments.length );
5860 wrapAll: function( html ) {
5861 if ( jQuery.isFunction( html ) ) {
5862 return this.each(function(i) {
5863 jQuery(this).wrapAll( html.call(this, i) );
5868 // The elements to wrap the target around
5869 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5871 if ( this[0].parentNode ) {
5872 wrap.insertBefore( this[0] );
5875 wrap.map(function() {
5878 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5879 elem = elem.firstChild;
5889 wrapInner: function( html ) {
5890 if ( jQuery.isFunction( html ) ) {
5891 return this.each(function(i) {
5892 jQuery(this).wrapInner( html.call(this, i) );
5896 return this.each(function() {
5897 var self = jQuery( this ),
5898 contents = self.contents();
5900 if ( contents.length ) {
5901 contents.wrapAll( html );
5904 self.append( html );
5909 wrap: function( html ) {
5910 var isFunction = jQuery.isFunction( html );
5912 return this.each(function(i) {
5913 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5917 unwrap: function() {
5918 return this.parent().each(function() {
5919 if ( !jQuery.nodeName( this, "body" ) ) {
5920 jQuery( this ).replaceWith( this.childNodes );
5925 append: function() {
5926 return this.domManip(arguments, true, function( elem ) {
5927 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5928 this.appendChild( elem );
5933 prepend: function() {
5934 return this.domManip(arguments, true, function( elem ) {
5935 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
5936 this.insertBefore( elem, this.firstChild );
5941 before: function() {
5942 return this.domManip( arguments, false, function( elem ) {
5943 if ( this.parentNode ) {
5944 this.parentNode.insertBefore( elem, this );
5950 return this.domManip( arguments, false, function( elem ) {
5951 if ( this.parentNode ) {
5952 this.parentNode.insertBefore( elem, this.nextSibling );
5957 // keepData is for internal use only--do not document
5958 remove: function( selector, keepData ) {
5962 for ( ; (elem = this[i]) != null; i++ ) {
5963 if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) {
5964 if ( !keepData && elem.nodeType === 1 ) {
5965 jQuery.cleanData( getAll( elem ) );
5968 if ( elem.parentNode ) {
5969 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
5970 setGlobalEval( getAll( elem, "script" ) );
5972 elem.parentNode.removeChild( elem );
5984 for ( ; (elem = this[i]) != null; i++ ) {
5985 // Remove element nodes and prevent memory leaks
5986 if ( elem.nodeType === 1 ) {
5987 jQuery.cleanData( getAll( elem, false ) );
5990 // Remove any remaining nodes
5991 while ( elem.firstChild ) {
5992 elem.removeChild( elem.firstChild );
5995 // If this is a select, ensure that it displays empty (#12336)
5997 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
5998 elem.options.length = 0;
6005 clone: function( dataAndEvents, deepDataAndEvents ) {
6006 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6007 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6009 return this.map( function () {
6010 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6014 html: function( value ) {
6015 return jQuery.access( this, function( value ) {
6016 var elem = this[0] || {},
6020 if ( value === undefined ) {
6021 return elem.nodeType === 1 ?
6022 elem.innerHTML.replace( rinlinejQuery, "" ) :
6026 // See if we can take a shortcut and just use innerHTML
6027 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6028 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
6029 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
6030 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
6032 value = value.replace( rxhtmlTag, "<$1></$2>" );
6035 for (; i < l; i++ ) {
6036 // Remove element nodes and prevent memory leaks
6037 elem = this[i] || {};
6038 if ( elem.nodeType === 1 ) {
6039 jQuery.cleanData( getAll( elem, false ) );
6040 elem.innerHTML = value;
6046 // If using innerHTML throws an exception, use the fallback method
6051 this.empty().append( value );
6053 }, null, value, arguments.length );
6056 replaceWith: function( value ) {
6057 var isFunc = jQuery.isFunction( value );
6059 // Make sure that the elements are removed from the DOM before they are inserted
6060 // this can help fix replacing a parent with child elements
6061 if ( !isFunc && typeof value !== "string" ) {
6062 value = jQuery( value ).not( this ).detach();
6065 return this.domManip( [ value ], true, function( elem ) {
6066 var next = this.nextSibling,
6067 parent = this.parentNode;
6069 if ( parent && this.nodeType === 1 || this.nodeType === 11 ) {
6071 jQuery( this ).remove();
6074 next.parentNode.insertBefore( elem, next );
6076 parent.appendChild( elem );
6082 detach: function( selector ) {
6083 return this.remove( selector, true );
6086 domManip: function( args, table, callback ) {
6088 // Flatten any nested arrays
6089 args = core_concat.apply( [], args );
6091 var fragment, first, scripts, hasScripts, node, doc,
6097 isFunction = jQuery.isFunction( value );
6099 // We can't cloneNode fragments that contain checked, in WebKit
6100 if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
6101 return this.each(function( index ) {
6102 var self = set.eq( index );
6104 args[0] = value.call( this, index, table ? self.html() : undefined );
6106 self.domManip( args, table, callback );
6111 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
6112 first = fragment.firstChild;
6114 if ( fragment.childNodes.length === 1 ) {
6119 table = table && jQuery.nodeName( first, "tr" );
6120 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6121 hasScripts = scripts.length;
6123 // Use the original fragment for the last item instead of the first because it can end up
6124 // being emptied incorrectly in certain situations (#8070).
6125 for ( ; i < l; i++ ) {
6128 if ( i !== iNoClone ) {
6129 node = jQuery.clone( node, true, true );
6131 // Keep references to cloned scripts for later restoration
6133 jQuery.merge( scripts, getAll( node, "script" ) );
6138 table && jQuery.nodeName( this[i], "table" ) ?
6139 findOrAppend( this[i], "tbody" ) :
6147 doc = scripts[ scripts.length - 1 ].ownerDocument;
6150 jQuery.map( scripts, restoreScript );
6152 // Evaluate executable scripts on first document insertion
6153 for ( i = 0; i < hasScripts; i++ ) {
6154 node = scripts[ i ];
6155 if ( rscriptType.test( node.type || "" ) &&
6156 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
6159 // Hope ajax is available...
6169 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
6175 // Fix #11809: Avoid leaking memory
6176 fragment = first = null;
6184 function findOrAppend( elem, tag ) {
6185 return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
6188 // Replace/restore the type attribute of script elements for safe DOM manipulation
6189 function disableScript( elem ) {
6190 var attr = elem.getAttributeNode("type");
6191 elem.type = ( attr && attr.specified ) + "/" + elem.type;
6194 function restoreScript( elem ) {
6195 var match = rscriptTypeMasked.exec( elem.type );
6197 elem.type = match[1];
6199 elem.removeAttribute("type");
6204 // Mark scripts as having already been evaluated
6205 function setGlobalEval( elems, refElements ) {
6208 for ( ; (elem = elems[i]) != null; i++ ) {
6209 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
6213 function cloneCopyEvent( src, dest ) {
6215 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6220 oldData = jQuery._data( src ),
6221 curData = jQuery._data( dest, oldData ),
6222 events = oldData.events;
6225 delete curData.handle;
6226 curData.events = {};
6228 for ( type in events ) {
6229 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6230 jQuery.event.add( dest, type, events[ type ][ i ] );
6235 // make the cloned public data object a copy from the original
6236 if ( curData.data ) {
6237 curData.data = jQuery.extend( {}, curData.data );
6241 function fixCloneNodeIssues( src, dest ) {
6242 var nodeName, data, e;
6244 // We do not need to do anything for non-Elements
6245 if ( dest.nodeType !== 1 ) {
6249 nodeName = dest.nodeName.toLowerCase();
6251 // IE6-8 copies events bound via attachEvent when using cloneNode.
6252 if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
6253 data = jQuery._data( dest );
6255 for ( e in data.events ) {
6256 jQuery.removeEvent( dest, e, data.handle );
6259 // Event data gets referenced instead of copied if the expando gets copied too
6260 dest.removeAttribute( jQuery.expando );
6263 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
6264 if ( nodeName === "script" && dest.text !== src.text ) {
6265 disableScript( dest ).text = src.text;
6266 restoreScript( dest );
6268 // IE6-10 improperly clones children of object elements using classid.
6269 // IE10 throws NoModificationAllowedError if parent is null, #12132.
6270 } else if ( nodeName === "object" ) {
6271 if ( dest.parentNode ) {
6272 dest.outerHTML = src.outerHTML;
6275 // This path appears unavoidable for IE9. When cloning an object
6276 // element in IE9, the outerHTML strategy above is not sufficient.
6277 // If the src has innerHTML and the destination does not,
6278 // copy the src.innerHTML into the dest.innerHTML. #10324
6279 if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
6280 dest.innerHTML = src.innerHTML;
6283 } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
6284 // IE6-8 fails to persist the checked state of a cloned checkbox
6285 // or radio button. Worse, IE6-7 fail to give the cloned element
6286 // a checked appearance if the defaultChecked value isn't also set
6288 dest.defaultChecked = dest.checked = src.checked;
6290 // IE6-7 get confused and end up setting the value of a cloned
6291 // checkbox/radio button to an empty string instead of "on"
6292 if ( dest.value !== src.value ) {
6293 dest.value = src.value;
6296 // IE6-8 fails to return the selected option to the default selected
6297 // state when cloning options
6298 } else if ( nodeName === "option" ) {
6299 dest.defaultSelected = dest.selected = src.defaultSelected;
6301 // IE6-8 fails to set the defaultValue to the correct value when
6302 // cloning other types of input fields
6303 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6304 dest.defaultValue = src.defaultValue;
6310 prependTo: "prepend",
6311 insertBefore: "before",
6312 insertAfter: "after",
6313 replaceAll: "replaceWith"
6314 }, function( name, original ) {
6315 jQuery.fn[ name ] = function( selector ) {
6319 insert = jQuery( selector ),
6320 last = insert.length - 1;
6322 for ( ; i <= last; i++ ) {
6323 elems = i === last ? this : this.clone(true);
6324 jQuery( insert[i] )[ original ]( elems );
6326 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
6327 core_push.apply( ret, elems.get() );
6330 return this.pushStack( ret );
6334 function getAll( context, tag ) {
6337 found = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) :
6338 typeof context.querySelectorAll !== "undefined" ? context.querySelectorAll( tag || "*" ) :
6342 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
6343 if ( !tag || jQuery.nodeName( elem, tag ) ) {
6346 jQuery.merge( found, getAll( elem, tag ) );
6351 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
6352 jQuery.merge( [ context ], found ) :
6356 // Used in buildFragment, fixes the defaultChecked property
6357 function fixDefaultChecked( elem ) {
6358 if ( manipulation_rcheckableType.test( elem.type ) ) {
6359 elem.defaultChecked = elem.checked;
6364 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6365 var destElements, srcElements, node, i, clone,
6366 inPage = jQuery.contains( elem.ownerDocument, elem );
6368 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6369 clone = elem.cloneNode( true );
6371 // IE<=8 does not properly clone detached, unknown element nodes
6373 fragmentDiv.innerHTML = elem.outerHTML;
6374 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6377 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6378 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6380 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
6381 destElements = getAll( clone );
6382 srcElements = getAll( elem );
6384 // Fix all IE cloning issues
6385 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
6386 // Ensure that the destination node is not null; Fixes #9587
6387 if ( destElements[i] ) {
6388 fixCloneNodeIssues( node, destElements[i] );
6393 // Copy the events from the original to the clone
6394 if ( dataAndEvents ) {
6395 if ( deepDataAndEvents ) {
6396 srcElements = srcElements || getAll( elem );
6397 destElements = destElements || getAll( clone );
6399 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
6400 cloneCopyEvent( node, destElements[i] );
6403 cloneCopyEvent( elem, clone );
6407 // Preserve script evaluation history
6408 destElements = getAll( clone, "script" );
6409 if ( destElements.length > 0 ) {
6410 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6413 destElements = srcElements = node = null;
6415 // Return the cloned set
6419 buildFragment: function( elems, context, scripts, selection ) {
6420 var contains, elem, tag, tmp, wrap, tbody, j,
6423 // Ensure a safe fragment
6424 safe = createSafeFragment( context ),
6429 for ( ; i < l; i++ ) {
6432 if ( elem || elem === 0 ) {
6434 // Add nodes directly
6435 if ( jQuery.type( elem ) === "object" ) {
6436 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
6438 // Convert non-html into a text node
6439 } else if ( !rhtml.test( elem ) ) {
6440 nodes.push( context.createTextNode( elem ) );
6442 // Convert html into DOM nodes
6444 tmp = tmp || safe.appendChild( context.createElement("div") );
6446 // Deserialize a standard representation
6447 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6448 wrap = wrapMap[ tag ] || wrapMap._default;
6450 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
6452 // Descend through wrappers to the right content
6455 tmp = tmp.lastChild;
6458 // Manually add leading whitespace removed by IE
6459 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6460 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
6463 // Remove IE's autoinserted <tbody> from table fragments
6464 if ( !jQuery.support.tbody ) {
6466 // String was a <table>, *may* have spurious <tbody>
6467 elem = tag === "table" && !rtbody.test( elem ) ?
6470 // String was a bare <thead> or <tfoot>
6471 wrap[1] === "<table>" && !rtbody.test( elem ) ?
6475 j = elem && elem.childNodes.length;
6477 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
6478 elem.removeChild( tbody );
6483 jQuery.merge( nodes, tmp.childNodes );
6485 // Fix #12392 for WebKit and IE > 9
6486 tmp.textContent = "";
6488 // Fix #12392 for oldIE
6489 while ( tmp.firstChild ) {
6490 tmp.removeChild( tmp.firstChild );
6493 // Remember the top-level container for proper cleanup
6494 tmp = safe.lastChild;
6499 // Fix #11356: Clear elements from fragment
6501 safe.removeChild( tmp );
6504 // Reset defaultChecked for any radios and checkboxes
6505 // about to be appended to the DOM in IE 6/7 (#8060)
6506 if ( !jQuery.support.appendChecked ) {
6507 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
6511 while ( (elem = nodes[ i++ ]) ) {
6513 // #4087 - If origin and destination elements are the same, and this is
6514 // that element, do not do anything
6515 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
6519 contains = jQuery.contains( elem.ownerDocument, elem );
6521 // Append to fragment
6522 tmp = getAll( safe.appendChild( elem ), "script" );
6524 // Preserve script evaluation history
6526 setGlobalEval( tmp );
6529 // Capture executables
6532 while ( (elem = tmp[ j++ ]) ) {
6533 if ( rscriptType.test( elem.type || "" ) ) {
6534 scripts.push( elem );
6545 cleanData: function( elems, /* internal */ acceptData ) {
6546 var data, id, elem, type,
6548 internalKey = jQuery.expando,
6549 cache = jQuery.cache,
6550 deleteExpando = jQuery.support.deleteExpando,
6551 special = jQuery.event.special;
6553 for ( ; (elem = elems[i]) != null; i++ ) {
6555 if ( acceptData || jQuery.acceptData( elem ) ) {
6557 id = elem[ internalKey ];
6558 data = id && cache[ id ];
6561 if ( data.events ) {
6562 for ( type in data.events ) {
6563 if ( special[ type ] ) {
6564 jQuery.event.remove( elem, type );
6566 // This is a shortcut to avoid jQuery.event.remove's overhead
6568 jQuery.removeEvent( elem, type, data.handle );
6573 // Remove cache only if it was not already removed by jQuery.event.remove
6574 if ( cache[ id ] ) {
6578 // IE does not allow us to delete expando properties from nodes,
6579 // nor does it have a removeAttribute function on Document nodes;
6580 // we must handle all of these cases
6581 if ( deleteExpando ) {
6582 delete elem[ internalKey ];
6584 } else if ( typeof elem.removeAttribute !== "undefined" ) {
6585 elem.removeAttribute( internalKey );
6588 elem[ internalKey ] = null;
6591 core_deletedIds.push( id );
6598 var curCSS, getStyles, iframe,
6599 ralpha = /alpha\([^)]*\)/i,
6600 ropacity = /opacity\s*=\s*([^)]*)/,
6601 rposition = /^(top|right|bottom|left)$/,
6602 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6603 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6604 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6605 rmargin = /^margin/,
6606 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6607 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6608 rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
6609 elemdisplay = { BODY: "block" },
6611 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6612 cssNormalTransform = {
6617 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6618 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
6620 // return a css property mapped to a potentially vendor prefixed property
6621 function vendorPropName( style, name ) {
6623 // shortcut for names that are not vendor prefixed
6624 if ( name in style ) {
6628 // check for vendor prefixed names
6629 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6631 i = cssPrefixes.length;
6634 name = cssPrefixes[ i ] + capName;
6635 if ( name in style ) {
6643 function isHidden( elem, el ) {
6644 // isHidden might be called from jQuery#filter function;
6645 // in that case, element will be second argument
6647 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6650 function showHide( elements, show ) {
6654 length = elements.length;
6656 for ( ; index < length; index++ ) {
6657 elem = elements[ index ];
6658 if ( !elem.style ) {
6661 values[ index ] = jQuery._data( elem, "olddisplay" );
6663 // Reset the inline display of this element to learn if it is
6664 // being hidden by cascaded rules or not
6665 if ( !values[ index ] && elem.style.display === "none" ) {
6666 elem.style.display = "";
6669 // Set elements which have been overridden with display: none
6670 // in a stylesheet to whatever the default browser style is
6671 // for such an element
6672 if ( elem.style.display === "" && isHidden( elem ) ) {
6673 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6675 } else if ( !values[ index ] && !isHidden( elem ) ) {
6676 jQuery._data( elem, "olddisplay", jQuery.css( elem, "display" ) );
6680 // Set the display of most of the elements in a second loop
6681 // to avoid the constant reflow
6682 for ( index = 0; index < length; index++ ) {
6683 elem = elements[ index ];
6684 if ( !elem.style ) {
6687 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6688 elem.style.display = show ? values[ index ] || "" : "none";
6696 css: function( name, value ) {
6697 return jQuery.access( this, function( elem, name, value ) {
6702 if ( jQuery.isArray( name ) ) {
6703 styles = getStyles( elem );
6706 for ( ; i < len; i++ ) {
6707 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6713 return value !== undefined ?
6714 jQuery.style( elem, name, value ) :
6715 jQuery.css( elem, name );
6716 }, name, value, arguments.length > 1 );
6719 return showHide( this, true );
6722 return showHide( this );
6724 toggle: function( state ) {
6725 var bool = typeof state === "boolean";
6727 return this.each(function() {
6728 if ( bool ? state : isHidden( this ) ) {
6729 jQuery( this ).show();
6731 jQuery( this ).hide();
6738 // Add in style property hooks for overriding the default
6739 // behavior of getting and setting a style property
6742 get: function( elem, computed ) {
6744 // We should always get a number back from opacity
6745 var ret = curCSS( elem, "opacity" );
6746 return ret === "" ? "1" : ret;
6752 // Exclude the following css properties to add px
6754 "columnCount": true,
6755 "fillOpacity": true,
6765 // Add in properties whose names you wish to fix before
6766 // setting or getting the value
6768 // normalize float css property
6769 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6772 // Get and set the style property on a DOM Node
6773 style: function( elem, name, value, extra ) {
6774 // Don't set styles on text and comment nodes
6775 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6779 // Make sure that we're working with the right name
6780 var ret, type, hooks,
6781 origName = jQuery.camelCase( name ),
6784 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6786 // gets hook for the prefixed version
6787 // followed by the unprefixed version
6788 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6790 // Check if we're setting a value
6791 if ( value !== undefined ) {
6792 type = typeof value;
6794 // convert relative number strings (+= or -=) to relative numbers. #7345
6795 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6796 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6801 // Make sure that NaN and null values aren't set. See: #7116
6802 if ( value == null || type === "number" && isNaN( value ) ) {
6806 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6807 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6811 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
6812 // but it would mean to define eight (for every problematic property) identical functions
6813 if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
6814 style[ name ] = "inherit";
6817 // If a hook was provided, use that value, otherwise just set the specified value
6818 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6820 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6823 style[ name ] = value;
6828 // If a hook was provided get the non-computed value from there
6829 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6833 // Otherwise just get the value from the style object
6834 return style[ name ];
6838 css: function( elem, name, extra, styles ) {
6839 var val, num, hooks,
6840 origName = jQuery.camelCase( name );
6842 // Make sure that we're working with the right name
6843 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6845 // gets hook for the prefixed version
6846 // followed by the unprefixed version
6847 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6849 // If a hook was provided get the computed value from there
6850 if ( hooks && "get" in hooks ) {
6851 val = hooks.get( elem, true, extra );
6854 // Otherwise, if a way to get the computed value exists, use that
6855 if ( val === undefined ) {
6856 val = curCSS( elem, name, styles );
6859 //convert "normal" to computed value
6860 if ( val === "normal" && name in cssNormalTransform ) {
6861 val = cssNormalTransform[ name ];
6864 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6866 num = parseFloat( val );
6867 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
6872 // A method for quickly swapping in/out CSS properties to get correct calculations
6873 swap: function( elem, options, callback, args ) {
6877 // Remember the old values, and insert the new ones
6878 for ( name in options ) {
6879 old[ name ] = elem.style[ name ];
6880 elem.style[ name ] = options[ name ];
6883 ret = callback.apply( elem, args || [] );
6885 // Revert the old values
6886 for ( name in options ) {
6887 elem.style[ name ] = old[ name ];
6894 // NOTE: we've included the "window" in window.getComputedStyle
6895 // because jsdom on node.js will break without it.
6896 if ( window.getComputedStyle ) {
6897 getStyles = function( elem ) {
6898 return window.getComputedStyle( elem, null );
6901 curCSS = function( elem, name, _computed ) {
6902 var width, minWidth, maxWidth,
6903 computed = _computed || getStyles( elem ),
6905 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
6906 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
6911 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6912 ret = jQuery.style( elem, name );
6915 // A tribute to the "awesome hack by Dean Edwards"
6916 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6917 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6918 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6919 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6921 // Remember the original values
6922 width = style.width;
6923 minWidth = style.minWidth;
6924 maxWidth = style.maxWidth;
6926 // Put in the new values to get a computed value out
6927 style.minWidth = style.maxWidth = style.width = ret;
6928 ret = computed.width;
6930 // Revert the changed values
6931 style.width = width;
6932 style.minWidth = minWidth;
6933 style.maxWidth = maxWidth;
6939 } else if ( document.documentElement.currentStyle ) {
6940 getStyles = function( elem ) {
6941 return elem.currentStyle;
6944 curCSS = function( elem, name, _computed ) {
6945 var left, rs, rsLeft,
6946 computed = _computed || getStyles( elem ),
6947 ret = computed ? computed[ name ] : undefined,
6950 // Avoid setting ret to empty string here
6951 // so we don't default to auto
6952 if ( ret == null && style && style[ name ] ) {
6953 ret = style[ name ];
6956 // From the awesome hack by Dean Edwards
6957 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6959 // If we're not dealing with a regular pixel number
6960 // but a number that has a weird ending, we need to convert it to pixels
6961 // but not position css attributes, as those are proportional to the parent element instead
6962 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6963 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6965 // Remember the original values
6967 rs = elem.runtimeStyle;
6968 rsLeft = rs && rs.left;
6970 // Put in the new values to get a computed value out
6972 rs.left = elem.currentStyle.left;
6974 style.left = name === "fontSize" ? "1em" : ret;
6975 ret = style.pixelLeft + "px";
6977 // Revert the changed values
6984 return ret === "" ? "auto" : ret;
6988 function setPositiveNumber( elem, value, subtract ) {
6989 var matches = rnumsplit.exec( value );
6991 // Guard against undefined "subtract", e.g., when used as in cssHooks
6992 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6996 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
6997 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6998 // If we already have the right measurement, avoid augmentation
7000 // Otherwise initialize for horizontal or vertical properties
7001 name === "width" ? 1 : 0,
7005 for ( ; i < 4; i += 2 ) {
7006 // both box models exclude margin, so add it if we want it
7007 if ( extra === "margin" ) {
7008 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
7011 if ( isBorderBox ) {
7012 // border-box includes padding, so remove it if we want content
7013 if ( extra === "content" ) {
7014 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7017 // at this point, extra isn't border nor margin, so remove border
7018 if ( extra !== "margin" ) {
7019 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7022 // at this point, extra isn't content, so add padding
7023 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7025 // at this point, extra isn't content nor padding, so add border
7026 if ( extra !== "padding" ) {
7027 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7035 function getWidthOrHeight( elem, name, extra ) {
7037 // Start with offset property, which is equivalent to the border-box value
7038 var valueIsBorderBox = true,
7039 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
7040 styles = getStyles( elem ),
7041 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
7043 // some non-html elements return undefined for offsetWidth, so check for null/undefined
7044 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
7045 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
7046 if ( val <= 0 || val == null ) {
7047 // Fall back to computed then uncomputed css if necessary
7048 val = curCSS( elem, name, styles );
7049 if ( val < 0 || val == null ) {
7050 val = elem.style[ name ];
7053 // Computed unit is not pixels. Stop here and return.
7054 if ( rnumnonpx.test(val) ) {
7058 // we need the check for style in case a browser which returns unreliable values
7059 // for getComputedStyle silently falls back to the reliable elem.style
7060 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
7062 // Normalize "", auto, and prepare for extra
7063 val = parseFloat( val ) || 0;
7066 // use the active box-sizing model to add/subtract irrelevant styles
7068 augmentWidthOrHeight(
7071 extra || ( isBorderBox ? "border" : "content" ),
7078 // Try to determine the default display value of an element
7079 function css_defaultDisplay( nodeName ) {
7081 display = elemdisplay[ nodeName ];
7084 display = actualDisplay( nodeName, doc );
7086 // If the simple way fails, read from inside an iframe
7087 if ( display === "none" || !display ) {
7088 // Use the already-created iframe if possible
7089 iframe = ( iframe ||
7090 jQuery("<iframe frameborder='0' width='0' height='0'/>")
7091 .css( "cssText", "display:block !important" )
7092 ).appendTo( doc.documentElement );
7094 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
7095 doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
7096 doc.write("<!doctype html><html><body>");
7099 display = actualDisplay( nodeName, doc );
7103 // Store the correct default display
7104 elemdisplay[ nodeName ] = display;
7110 // Called ONLY from within css_defaultDisplay
7111 function actualDisplay( name, doc ) {
7112 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
7113 display = jQuery.css( elem[0], "display" );
7118 jQuery.each([ "height", "width" ], function( i, name ) {
7119 jQuery.cssHooks[ name ] = {
7120 get: function( elem, computed, extra ) {
7122 // certain elements can have dimension info if we invisibly show them
7123 // however, it must have a current display style that would benefit from this
7124 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
7125 jQuery.swap( elem, cssShow, function() {
7126 return getWidthOrHeight( elem, name, extra );
7128 getWidthOrHeight( elem, name, extra );
7132 set: function( elem, value, extra ) {
7133 var styles = extra && getStyles( elem );
7134 return setPositiveNumber( elem, value, extra ?
7135 augmentWidthOrHeight(
7139 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
7147 if ( !jQuery.support.opacity ) {
7148 jQuery.cssHooks.opacity = {
7149 get: function( elem, computed ) {
7150 // IE uses filters for opacity
7151 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
7152 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7153 computed ? "1" : "";
7156 set: function( elem, value ) {
7157 var style = elem.style,
7158 currentStyle = elem.currentStyle,
7159 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7160 filter = currentStyle && currentStyle.filter || style.filter || "";
7162 // IE has trouble with opacity if it does not have layout
7163 // Force it by setting the zoom level
7166 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
7167 // if value === "", then remove inline opacity #12685
7168 if ( ( value >= 1 || value === "" ) &&
7169 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7170 style.removeAttribute ) {
7172 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7173 // if "filter:" is present at all, clearType is disabled, we want to avoid this
7174 // style.removeAttribute is IE Only, but so apparently is this code path...
7175 style.removeAttribute( "filter" );
7177 // if there is no filter style applied in a css rule or unset inline opacity, we are done
7178 if ( value === "" || currentStyle && !currentStyle.filter ) {
7183 // otherwise, set new filter values
7184 style.filter = ralpha.test( filter ) ?
7185 filter.replace( ralpha, opacity ) :
7186 filter + " " + opacity;
7191 // These hooks cannot be added until DOM ready because the support test
7192 // for it is not run until after DOM ready
7194 if ( !jQuery.support.reliableMarginRight ) {
7195 jQuery.cssHooks.marginRight = {
7196 get: function( elem, computed ) {
7198 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7199 // Work around by temporarily setting element display to inline-block
7200 return jQuery.swap( elem, { "display": "inline-block" },
7201 curCSS, [ elem, "marginRight" ] );
7207 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7208 // getComputedStyle returns percent when specified for top/left/bottom/right
7209 // rather than make the css module depend on the offset module, we just check for it here
7210 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
7211 jQuery.each( [ "top", "left" ], function( i, prop ) {
7212 jQuery.cssHooks[ prop ] = {
7213 get: function( elem, computed ) {
7215 computed = curCSS( elem, prop );
7216 // if curCSS returns percentage, fallback to offset
7217 return rnumnonpx.test( computed ) ?
7218 jQuery( elem ).position()[ prop ] + "px" :
7228 if ( jQuery.expr && jQuery.expr.filters ) {
7229 jQuery.expr.filters.hidden = function( elem ) {
7230 return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
7233 jQuery.expr.filters.visible = function( elem ) {
7234 return !jQuery.expr.filters.hidden( elem );
7238 // These hooks are used by animate to expand properties
7243 }, function( prefix, suffix ) {
7244 jQuery.cssHooks[ prefix + suffix ] = {
7245 expand: function( value ) {
7249 // assumes a single number if not a string
7250 parts = typeof value === "string" ? value.split(" ") : [ value ];
7252 for ( ; i < 4; i++ ) {
7253 expanded[ prefix + cssExpand[ i ] + suffix ] =
7254 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7261 if ( !rmargin.test( prefix ) ) {
7262 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7268 rsubmitterTypes = /^(?:submit|button|image|reset)$/i,
7269 rsubmittable = /^(?:input|select|textarea|keygen)/i;
7272 serialize: function() {
7273 return jQuery.param( this.serializeArray() );
7275 serializeArray: function() {
7276 return this.map(function(){
7277 // Can add propHook for "elements" to filter or add form elements
7278 var elements = jQuery.prop( this, "elements" );
7279 return elements ? jQuery.makeArray( elements ) : this;
7282 var type = this.type;
7283 // Use .is(":disabled") so that fieldset[disabled] works
7284 return this.name && !jQuery( this ).is( ":disabled" ) &&
7285 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
7286 ( this.checked || !manipulation_rcheckableType.test( type ) );
7288 .map(function( i, elem ){
7289 var val = jQuery( this ).val();
7291 return val == null ?
7293 jQuery.isArray( val ) ?
7294 jQuery.map( val, function( val ){
7295 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7297 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7302 //Serialize an array of form elements or a set of
7303 //key/values into a query string
7304 jQuery.param = function( a, traditional ) {
7307 add = function( key, value ) {
7308 // If value is a function, invoke it and return its value
7309 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7310 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7313 // Set traditional to true for jQuery <= 1.3.2 behavior.
7314 if ( traditional === undefined ) {
7315 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7318 // If an array was passed in, assume that it is an array of form elements.
7319 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7320 // Serialize the form elements
7321 jQuery.each( a, function() {
7322 add( this.name, this.value );
7326 // If traditional, encode the "old" way (the way 1.3.2 or older
7327 // did it), otherwise encode params recursively.
7328 for ( prefix in a ) {
7329 buildParams( prefix, a[ prefix ], traditional, add );
7333 // Return the resulting serialization
7334 return s.join( "&" ).replace( r20, "+" );
7337 function buildParams( prefix, obj, traditional, add ) {
7340 if ( jQuery.isArray( obj ) ) {
7341 // Serialize array item.
7342 jQuery.each( obj, function( i, v ) {
7343 if ( traditional || rbracket.test( prefix ) ) {
7344 // Treat each array item as a scalar.
7348 // Item is non-scalar (array or object), encode its numeric index.
7349 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7353 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
7354 // Serialize object item.
7355 for ( name in obj ) {
7356 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7360 // Serialize scalar item.
7365 // Document location
7369 ajax_nonce = jQuery.now(),
7373 rts = /([?&])_=[^&]*/,
7374 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7375 // #7653, #8125, #8152: local protocol detection
7376 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7377 rnoContent = /^(?:GET|HEAD)$/,
7378 rprotocol = /^\/\//,
7379 rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7381 // Keep a copy of the old load method
7382 _load = jQuery.fn.load,
7385 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7386 * 2) These are called:
7387 * - BEFORE asking for a transport
7388 * - AFTER param serialization (s.data is a string if s.processData is true)
7389 * 3) key is the dataType
7390 * 4) the catchall symbol "*" can be used
7391 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7395 /* Transports bindings
7396 * 1) key is the dataType
7397 * 2) the catchall symbol "*" can be used
7398 * 3) selection will start with transport dataType and THEN go to "*" if needed
7402 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7403 allTypes = "*/".concat("*");
7405 // #8138, IE may throw an exception when accessing
7406 // a field from window.location if document.domain has been set
7408 ajaxLocation = location.href;
7410 // Use the href attribute of an A element
7411 // since IE will modify it given document.location
7412 ajaxLocation = document.createElement( "a" );
7413 ajaxLocation.href = "";
7414 ajaxLocation = ajaxLocation.href;
7417 // Segment location into parts
7418 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7420 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7421 function addToPrefiltersOrTransports( structure ) {
7423 // dataTypeExpression is optional and defaults to "*"
7424 return function( dataTypeExpression, func ) {
7426 if ( typeof dataTypeExpression !== "string" ) {
7427 func = dataTypeExpression;
7428 dataTypeExpression = "*";
7433 dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
7435 if ( jQuery.isFunction( func ) ) {
7436 // For each dataType in the dataTypeExpression
7437 while ( (dataType = dataTypes[i++]) ) {
7438 // Prepend if requested
7439 if ( dataType[0] === "+" ) {
7440 dataType = dataType.slice( 1 ) || "*";
7441 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
7445 (structure[ dataType ] = structure[ dataType ] || []).push( func );
7452 // Base inspection function for prefilters and transports
7453 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
7456 seekingTransport = ( structure === transports );
7458 function inspect( dataType ) {
7460 inspected[ dataType ] = true;
7461 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
7462 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
7463 if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
7464 options.dataTypes.unshift( dataTypeOrTransport );
7465 inspect( dataTypeOrTransport );
7467 } else if ( seekingTransport ) {
7468 return !( selected = dataTypeOrTransport );
7474 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
7477 // A special extend for ajax options
7478 // that takes "flat" options (not to be deep extended)
7480 function ajaxExtend( target, src ) {
7482 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7484 for ( key in src ) {
7485 if ( src[ key ] !== undefined ) {
7486 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
7490 jQuery.extend( true, target, deep );
7496 jQuery.fn.load = function( url, params, callback ) {
7497 if ( typeof url !== "string" && _load ) {
7498 return _load.apply( this, arguments );
7501 var selector, type, response,
7503 off = url.indexOf(" ");
7506 selector = url.slice( off, url.length );
7507 url = url.slice( 0, off );
7510 // If it's a function
7511 if ( jQuery.isFunction( params ) ) {
7513 // We assume that it's the callback
7517 // Otherwise, build a param string
7518 } else if ( params && typeof params === "object" ) {
7522 // If we have elements to modify, make the request
7523 if ( self.length > 0 ) {
7527 // if "type" variable is undefined, then "GET" method will be used
7531 }).done(function( responseText ) {
7533 // Save response for use in complete callback
7534 response = arguments;
7536 self.html( selector ?
7538 // If a selector was specified, locate the right elements in a dummy div
7539 // Exclude scripts to avoid IE 'Permission Denied' errors
7540 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
7542 // Otherwise use the full result
7545 }).complete( callback && function( jqXHR, status ) {
7546 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7553 // Attach a bunch of functions for handling common AJAX events
7554 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
7555 jQuery.fn[ type ] = function( fn ){
7556 return this.on( type, fn );
7560 jQuery.each( [ "get", "post" ], function( i, method ) {
7561 jQuery[ method ] = function( url, data, callback, type ) {
7562 // shift arguments if data argument was omitted
7563 if ( jQuery.isFunction( data ) ) {
7564 type = type || callback;
7569 return jQuery.ajax({
7581 // Counter for holding the number of active queries
7584 // Last-Modified header cache for next request
7591 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7595 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7612 xml: "application/xml, text/xml",
7613 json: "application/json, text/javascript"
7624 text: "responseText"
7628 // Keys separate source (or catchall "*") and destination types with a single space
7631 // Convert anything to text
7632 "* text": window.String,
7634 // Text to html (true = no transformation)
7637 // Evaluate text as a json expression
7638 "text json": jQuery.parseJSON,
7640 // Parse text as xml
7641 "text xml": jQuery.parseXML
7644 // For options that shouldn't be deep extended:
7645 // you can add your own custom options here if
7646 // and when you create one that shouldn't be
7647 // deep extended (see ajaxExtend)
7654 // Creates a full fledged settings object into target
7655 // with both ajaxSettings and settings fields.
7656 // If target is omitted, writes into ajaxSettings.
7657 ajaxSetup: function( target, settings ) {
7660 // Building a settings object
7661 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
7663 // Extending ajaxSettings
7664 ajaxExtend( jQuery.ajaxSettings, target );
7667 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7668 ajaxTransport: addToPrefiltersOrTransports( transports ),
7671 ajax: function( url, options ) {
7673 // If url is an object, simulate pre-1.5 signature
7674 if ( typeof url === "object" ) {
7679 // Force options to be an object
7680 options = options || {};
7683 // URL without anti-cache param
7686 responseHeadersString,
7690 // Cross-domain detection vars
7692 // To know if global events are to be dispatched
7696 // Create the final options object
7697 s = jQuery.ajaxSetup( {}, options ),
7698 // Callbacks context
7699 callbackContext = s.context || s,
7700 // Context for global events is callbackContext if it is a DOM node or jQuery collection
7701 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
7702 jQuery( callbackContext ) :
7705 deferred = jQuery.Deferred(),
7706 completeDeferred = jQuery.Callbacks("once memory"),
7707 // Status-dependent callbacks
7708 statusCode = s.statusCode || {},
7709 // Headers (they are sent all at once)
7710 requestHeaders = {},
7711 requestHeadersNames = {},
7714 // Default abort message
7715 strAbort = "canceled",
7720 // Builds headers hashtable if needed
7721 getResponseHeader: function( key ) {
7723 if ( state === 2 ) {
7724 if ( !responseHeaders ) {
7725 responseHeaders = {};
7726 while ( (match = rheaders.exec( responseHeadersString )) ) {
7727 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7730 match = responseHeaders[ key.toLowerCase() ];
7732 return match == null ? null : match;
7736 getAllResponseHeaders: function() {
7737 return state === 2 ? responseHeadersString : null;
7740 // Caches the header
7741 setRequestHeader: function( name, value ) {
7742 var lname = name.toLowerCase();
7744 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7745 requestHeaders[ name ] = value;
7750 // Overrides response content-type header
7751 overrideMimeType: function( type ) {
7758 // Status-dependent callbacks
7759 statusCode: function( map ) {
7763 for ( code in map ) {
7764 // Lazy-add the new callback in a way that preserves old ones
7765 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
7768 // Execute the appropriate callbacks
7769 jqXHR.always( map[ jqXHR.status ] );
7775 // Cancel the request
7776 abort: function( statusText ) {
7777 var finalText = statusText || strAbort;
7779 transport.abort( finalText );
7781 done( 0, finalText );
7787 deferred.promise( jqXHR ).complete = completeDeferred.add;
7788 jqXHR.success = jqXHR.done;
7789 jqXHR.error = jqXHR.fail;
7791 // Remove hash character (#7531: and string promotion)
7792 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7793 // Handle falsy url in the settings object (#10093: consistency with old signature)
7794 // We also use the url parameter if available
7795 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7797 // Alias method option to type as per ticket #12004
7798 s.type = options.method || options.type || s.method || s.type;
7800 // Extract dataTypes list
7801 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
7803 // A cross-domain request is in order when we have a protocol:host:port mismatch
7804 if ( s.crossDomain == null ) {
7805 parts = rurl.exec( s.url.toLowerCase() );
7806 s.crossDomain = !!( parts &&
7807 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
7808 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7809 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7813 // Convert data if not already a string
7814 if ( s.data && s.processData && typeof s.data !== "string" ) {
7815 s.data = jQuery.param( s.data, s.traditional );
7819 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7821 // If request was aborted inside a prefilter, stop there
7822 if ( state === 2 ) {
7826 // We can fire global events as of now if asked to
7827 fireGlobals = s.global;
7829 // Watch for a new set of requests
7830 if ( fireGlobals && jQuery.active++ === 0 ) {
7831 jQuery.event.trigger("ajaxStart");
7834 // Uppercase the type
7835 s.type = s.type.toUpperCase();
7837 // Determine if request has content
7838 s.hasContent = !rnoContent.test( s.type );
7840 // Save the URL in case we're toying with the If-Modified-Since
7841 // and/or If-None-Match header later on
7844 // More options handling for requests with no content
7845 if ( !s.hasContent ) {
7847 // If data is available, append data to url
7849 cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
7850 // #9682: remove data so that it's not used in an eventual retry
7854 // Add anti-cache in url if needed
7855 if ( s.cache === false ) {
7856 s.url = rts.test( cacheURL ) ?
7858 // If there is already a '_' parameter, set its value
7859 cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
7861 // Otherwise add one to the end
7862 cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
7866 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7867 if ( s.ifModified ) {
7868 if ( jQuery.lastModified[ cacheURL ] ) {
7869 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
7871 if ( jQuery.etag[ cacheURL ] ) {
7872 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
7876 // Set the correct header, if data is being sent
7877 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7878 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7881 // Set the Accepts header for the server, depending on the dataType
7882 jqXHR.setRequestHeader(
7884 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7885 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7889 // Check for headers option
7890 for ( i in s.headers ) {
7891 jqXHR.setRequestHeader( i, s.headers[ i ] );
7894 // Allow custom headers/mimetypes and early abort
7895 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7896 // Abort if not done already and return
7897 return jqXHR.abort();
7900 // aborting is no longer a cancellation
7903 // Install callbacks on deferreds
7904 for ( i in { success: 1, error: 1, complete: 1 } ) {
7905 jqXHR[ i ]( s[ i ] );
7909 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7911 // If no transport, we auto-abort
7913 done( -1, "No Transport" );
7915 jqXHR.readyState = 1;
7917 // Send global event
7918 if ( fireGlobals ) {
7919 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7922 if ( s.async && s.timeout > 0 ) {
7923 timeoutTimer = setTimeout(function() {
7924 jqXHR.abort("timeout");
7930 transport.send( requestHeaders, done );
7932 // Propagate exception as error if not done
7935 // Simply rethrow otherwise
7942 // Callback for when everything is done
7943 function done( status, nativeStatusText, responses, headers ) {
7944 var isSuccess, success, error, response, modified,
7945 statusText = nativeStatusText;
7948 if ( state === 2 ) {
7952 // State is "done" now
7955 // Clear timeout if it exists
7956 if ( timeoutTimer ) {
7957 clearTimeout( timeoutTimer );
7960 // Dereference transport for early garbage collection
7961 // (no matter how long the jqXHR object will be used)
7962 transport = undefined;
7964 // Cache response headers
7965 responseHeadersString = headers || "";
7968 jqXHR.readyState = status > 0 ? 4 : 0;
7970 // Get response data
7972 response = ajaxHandleResponses( s, jqXHR, responses );
7975 // If successful, handle type chaining
7976 if ( status >= 200 && status < 300 || status === 304 ) {
7978 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7979 if ( s.ifModified ) {
7980 modified = jqXHR.getResponseHeader("Last-Modified");
7982 jQuery.lastModified[ cacheURL ] = modified;
7984 modified = jqXHR.getResponseHeader("etag");
7986 jQuery.etag[ cacheURL ] = modified;
7991 if ( status === 304 ) {
7993 statusText = "notmodified";
7997 isSuccess = ajaxConvert( s, response );
7998 statusText = isSuccess.state;
7999 success = isSuccess.data;
8000 error = isSuccess.error;
8004 // We extract error from statusText
8005 // then normalize statusText and status for non-aborts
8007 if ( status || !statusText ) {
8008 statusText = "error";
8015 // Set data for the fake xhr object
8016 jqXHR.status = status;
8017 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
8021 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
8023 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
8026 // Status-dependent callbacks
8027 jqXHR.statusCode( statusCode );
8028 statusCode = undefined;
8030 if ( fireGlobals ) {
8031 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
8032 [ jqXHR, s, isSuccess ? success : error ] );
8036 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
8038 if ( fireGlobals ) {
8039 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
8040 // Handle the global AJAX counter
8041 if ( !( --jQuery.active ) ) {
8042 jQuery.event.trigger("ajaxStop");
8050 getScript: function( url, callback ) {
8051 return jQuery.get( url, undefined, callback, "script" );
8054 getJSON: function( url, data, callback ) {
8055 return jQuery.get( url, data, callback, "json" );
8059 /* Handles responses to an ajax request:
8060 * - sets all responseXXX fields accordingly
8061 * - finds the right dataType (mediates between content-type and expected dataType)
8062 * - returns the corresponding response
8064 function ajaxHandleResponses( s, jqXHR, responses ) {
8066 var ct, type, finalDataType, firstDataType,
8067 contents = s.contents,
8068 dataTypes = s.dataTypes,
8069 responseFields = s.responseFields;
8071 // Fill responseXXX fields
8072 for ( type in responseFields ) {
8073 if ( type in responses ) {
8074 jqXHR[ responseFields[type] ] = responses[ type ];
8078 // Remove auto dataType and get content-type in the process
8079 while( dataTypes[ 0 ] === "*" ) {
8081 if ( ct === undefined ) {
8082 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
8086 // Check if we're dealing with a known content-type
8088 for ( type in contents ) {
8089 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8090 dataTypes.unshift( type );
8096 // Check to see if we have a response for the expected dataType
8097 if ( dataTypes[ 0 ] in responses ) {
8098 finalDataType = dataTypes[ 0 ];
8100 // Try convertible dataTypes
8101 for ( type in responses ) {
8102 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8103 finalDataType = type;
8106 if ( !firstDataType ) {
8107 firstDataType = type;
8110 // Or just use first one
8111 finalDataType = finalDataType || firstDataType;
8114 // If we found a dataType
8115 // We add the dataType to the list if needed
8116 // and return the corresponding response
8117 if ( finalDataType ) {
8118 if ( finalDataType !== dataTypes[ 0 ] ) {
8119 dataTypes.unshift( finalDataType );
8121 return responses[ finalDataType ];
8125 // Chain conversions given the request and the original response
8126 function ajaxConvert( s, response ) {
8128 var conv, conv2, current, tmp,
8131 // Work with a copy of dataTypes in case we need to modify it for conversion
8132 dataTypes = s.dataTypes.slice(),
8133 prev = dataTypes[ 0 ];
8135 // Apply the dataFilter if provided
8136 if ( s.dataFilter ) {
8137 response = s.dataFilter( response, s.dataType );
8140 // Create converters map with lowercased keys
8141 if ( dataTypes[ 1 ] ) {
8142 for ( conv in s.converters ) {
8143 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8147 // Convert to each sequential dataType, tolerating list modification
8148 for ( ; (current = dataTypes[++i]); ) {
8150 // There's only work to do if current dataType is non-auto
8151 if ( current !== "*" ) {
8153 // Convert response if prev dataType is non-auto and differs from current
8154 if ( prev !== "*" && prev !== current ) {
8156 // Seek a direct converter
8157 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8159 // If none found, seek a pair
8161 for ( conv2 in converters ) {
8163 // If conv2 outputs current
8164 tmp = conv2.split(" ");
8165 if ( tmp[ 1 ] === current ) {
8167 // If prev can be converted to accepted input
8168 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8169 converters[ "* " + tmp[ 0 ] ];
8171 // Condense equivalence converters
8172 if ( conv === true ) {
8173 conv = converters[ conv2 ];
8175 // Otherwise, insert the intermediate dataType
8176 } else if ( converters[ conv2 ] !== true ) {
8178 dataTypes.splice( i--, 0, current );
8187 // Apply converter (if not an equivalence)
8188 if ( conv !== true ) {
8190 // Unless errors are allowed to bubble, catch and return them
8191 if ( conv && s["throws"] ) {
8192 response = conv( response );
8195 response = conv( response );
8197 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8203 // Update prev for next iteration
8208 return { state: "success", data: response };
8210 // Install script dataType
8213 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8216 script: /(?:java|ecma)script/
8219 "text script": function( text ) {
8220 jQuery.globalEval( text );
8226 // Handle cache's special case and global
8227 jQuery.ajaxPrefilter( "script", function( s ) {
8228 if ( s.cache === undefined ) {
8231 if ( s.crossDomain ) {
8237 // Bind script tag hack transport
8238 jQuery.ajaxTransport( "script", function(s) {
8240 // This transport only deals with cross domain requests
8241 if ( s.crossDomain ) {
8244 head = document.head || jQuery("head")[0] || document.documentElement;
8248 send: function( _, callback ) {
8250 script = document.createElement("script");
8252 script.async = true;
8254 if ( s.scriptCharset ) {
8255 script.charset = s.scriptCharset;
8260 // Attach handlers for all browsers
8261 script.onload = script.onreadystatechange = function( _, isAbort ) {
8263 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8265 // Handle memory leak in IE
8266 script.onload = script.onreadystatechange = null;
8268 // Remove the script
8269 if ( script.parentNode ) {
8270 script.parentNode.removeChild( script );
8273 // Dereference the script
8276 // Callback if not abort
8278 callback( 200, "success" );
8283 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
8284 // Use native DOM manipulation to avoid our domManip AJAX trickery
8285 head.insertBefore( script, head.firstChild );
8290 script.onload( undefined, true );
8296 var oldCallbacks = [],
8297 rjsonp = /(=)\?(?=&|$)|\?\?/;
8299 // Default jsonp settings
8302 jsonpCallback: function() {
8303 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
8304 this[ callback ] = true;
8309 // Detect, normalize options and install callbacks for jsonp requests
8310 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8312 var callbackName, overwritten, responseContainer,
8313 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
8315 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
8318 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8319 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
8321 // Get callback name, remembering preexisting value associated with it
8322 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8326 // Insert callback into url or form data
8328 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
8329 } else if ( s.jsonp !== false ) {
8330 s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8333 // Use data converter to retrieve json after script execution
8334 s.converters["script json"] = function() {
8335 if ( !responseContainer ) {
8336 jQuery.error( callbackName + " was not called" );
8338 return responseContainer[ 0 ];
8341 // force json dataType
8342 s.dataTypes[ 0 ] = "json";
8345 overwritten = window[ callbackName ];
8346 window[ callbackName ] = function() {
8347 responseContainer = arguments;
8350 // Clean-up function (fires after converters)
8351 jqXHR.always(function() {
8352 // Restore preexisting value
8353 window[ callbackName ] = overwritten;
8355 // Save back as free
8356 if ( s[ callbackName ] ) {
8357 // make sure that re-using the options doesn't screw things around
8358 s.jsonpCallback = originalSettings.jsonpCallback;
8360 // save the callback name for future use
8361 oldCallbacks.push( callbackName );
8364 // Call if it was a function and we have a response
8365 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8366 overwritten( responseContainer[ 0 ] );
8369 responseContainer = overwritten = undefined;
8372 // Delegate to script
8376 var xhrCallbacks, xhrSupported,
8378 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8379 xhrOnUnloadAbort = window.ActiveXObject && function() {
8380 // Abort all pending requests
8382 for ( key in xhrCallbacks ) {
8383 xhrCallbacks[ key ]( undefined, true );
8387 // Functions to create xhrs
8388 function createStandardXHR() {
8390 return new window.XMLHttpRequest();
8394 function createActiveXHR() {
8396 return new window.ActiveXObject("Microsoft.XMLHTTP");
8400 // Create the request object
8401 // (This is still attached to ajaxSettings for backward compatibility)
8402 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8403 /* Microsoft failed to properly
8404 * implement the XMLHttpRequest in IE7 (can't request local files),
8405 * so we use the ActiveXObject when it is available
8406 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8407 * we need a fallback.
8410 return !this.isLocal && createStandardXHR() || createActiveXHR();
8412 // For all other browsers, use the standard XMLHttpRequest object
8415 // Determine support properties
8416 xhrSupported = jQuery.ajaxSettings.xhr();
8417 jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
8418 xhrSupported = jQuery.support.ajax = !!xhrSupported;
8420 // Create transport if the browser can provide an xhr
8421 if ( xhrSupported ) {
8423 jQuery.ajaxTransport(function( s ) {
8424 // Cross domain only allowed if supported through XMLHttpRequest
8425 if ( !s.crossDomain || jQuery.support.cors ) {
8430 send: function( headers, complete ) {
8437 // Passing null username, generates a login popup on Opera (#2865)
8439 xhr.open( s.type, s.url, s.async, s.username, s.password );
8441 xhr.open( s.type, s.url, s.async );
8444 // Apply custom fields if provided
8445 if ( s.xhrFields ) {
8446 for ( i in s.xhrFields ) {
8447 xhr[ i ] = s.xhrFields[ i ];
8451 // Override mime type if needed
8452 if ( s.mimeType && xhr.overrideMimeType ) {
8453 xhr.overrideMimeType( s.mimeType );
8456 // X-Requested-With header
8457 // For cross-domain requests, seeing as conditions for a preflight are
8458 // akin to a jigsaw puzzle, we simply never set it to be sure.
8459 // (it can always be set on a per-request basis or even using ajaxSetup)
8460 // For same-domain requests, won't change header if already provided.
8461 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8462 headers["X-Requested-With"] = "XMLHttpRequest";
8465 // Need an extra try/catch for cross domain requests in Firefox 3
8467 for ( i in headers ) {
8468 xhr.setRequestHeader( i, headers[ i ] );
8472 // Do send the request
8473 // This may raise an exception which is actually
8474 // handled in jQuery.ajax (so no try/catch here)
8475 xhr.send( ( s.hasContent && s.data ) || null );
8478 callback = function( _, isAbort ) {
8486 // Firefox throws exceptions when accessing properties
8487 // of an xhr when a network error occurred
8488 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8491 // Was never called and is aborted or complete
8492 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8495 callback = undefined;
8497 // Do not keep as active anymore
8499 xhr.onreadystatechange = jQuery.noop;
8500 if ( xhrOnUnloadAbort ) {
8501 delete xhrCallbacks[ handle ];
8507 // Abort it manually if needed
8508 if ( xhr.readyState !== 4 ) {
8513 status = xhr.status;
8514 xml = xhr.responseXML;
8515 responseHeaders = xhr.getAllResponseHeaders();
8517 // Construct response list
8518 if ( xml && xml.documentElement /* #4958 */ ) {
8519 responses.xml = xml;
8522 // When requesting binary data, IE6-9 will throw an exception
8523 // on any attempt to access responseText (#11426)
8524 if ( typeof xhr.responseText === "string" ) {
8525 responses.text = xhr.responseText;
8528 // Firefox throws an exception when accessing
8529 // statusText for faulty cross-domain requests
8531 statusText = xhr.statusText;
8533 // We normalize with Webkit giving an empty statusText
8537 // Filter status for non standard behaviors
8539 // If the request is local and we have data: assume a success
8540 // (success with no data won't get notified, that's the best we
8541 // can do given current implementations)
8542 if ( !status && s.isLocal && !s.crossDomain ) {
8543 status = responses.text ? 200 : 404;
8544 // IE - #1450: sometimes returns 1223 when it should be 204
8545 } else if ( status === 1223 ) {
8550 } catch( firefoxAccessException ) {
8552 complete( -1, firefoxAccessException );
8556 // Call complete if needed
8558 complete( status, statusText, responses, responseHeaders );
8563 // if we're in sync mode we fire the callback
8565 } else if ( xhr.readyState === 4 ) {
8566 // (IE6 & IE7) if it's in cache and has been
8567 // retrieved directly we need to fire the callback
8568 setTimeout( callback );
8571 if ( xhrOnUnloadAbort ) {
8572 // Create the active xhrs callbacks list if needed
8573 // and attach the unload handler
8574 if ( !xhrCallbacks ) {
8576 jQuery( window ).unload( xhrOnUnloadAbort );
8578 // Add to list of active xhrs callbacks
8579 xhrCallbacks[ handle ] = callback;
8581 xhr.onreadystatechange = callback;
8587 callback( undefined, true );
8595 rfxtypes = /^(?:toggle|show|hide)$/,
8596 rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8597 rrun = /queueHooks$/,
8598 animationPrefilters = [ defaultPrefilter ],
8600 "*": [function( prop, value ) {
8602 tween = this.createTween( prop, value ),
8603 parts = rfxnum.exec( value ),
8604 target = tween.cur(),
8605 start = +target || 0,
8611 unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8613 // We need to compute starting value
8614 if ( unit !== "px" && start ) {
8615 // Iteratively approximate from a nonzero starting point
8616 // Prefer the current property, because this process will be trivial if it uses the same units
8617 // Fallback to end or a simple constant
8618 start = jQuery.css( tween.elem, prop, true ) || end || 1;
8621 // If previous iteration zeroed out, double until we get *something*
8622 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8623 scale = scale || ".5";
8626 start = start / scale;
8627 jQuery.style( tween.elem, prop, start + unit );
8629 // Update scale, tolerating zero or NaN from tween.cur()
8630 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8631 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8635 tween.start = start;
8636 // If a +=/-= token was provided, we're doing a relative animation
8637 tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
8643 // Animations created synchronously will run synchronously
8644 function createFxNow() {
8645 setTimeout(function() {
8648 return ( fxNow = jQuery.now() );
8651 function createTweens( animation, props ) {
8652 jQuery.each( props, function( prop, value ) {
8653 var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8655 length = collection.length;
8656 for ( ; index < length; index++ ) {
8657 if ( collection[ index ].call( animation, prop, value ) ) {
8659 // we're done with this property
8666 function Animation( elem, properties, options ) {
8670 length = animationPrefilters.length,
8671 deferred = jQuery.Deferred().always( function() {
8672 // don't match elem in the :animated selector
8679 var currentTime = fxNow || createFxNow(),
8680 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8681 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
8682 temp = remaining / animation.duration || 0,
8685 length = animation.tweens.length;
8687 for ( ; index < length ; index++ ) {
8688 animation.tweens[ index ].run( percent );
8691 deferred.notifyWith( elem, [ animation, percent, remaining ]);
8693 if ( percent < 1 && length ) {
8696 deferred.resolveWith( elem, [ animation ] );
8700 animation = deferred.promise({
8702 props: jQuery.extend( {}, properties ),
8703 opts: jQuery.extend( true, { specialEasing: {} }, options ),
8704 originalProperties: properties,
8705 originalOptions: options,
8706 startTime: fxNow || createFxNow(),
8707 duration: options.duration,
8709 createTween: function( prop, end ) {
8710 var tween = jQuery.Tween( elem, animation.opts, prop, end,
8711 animation.opts.specialEasing[ prop ] || animation.opts.easing );
8712 animation.tweens.push( tween );
8715 stop: function( gotoEnd ) {
8717 // if we are going to the end, we want to run all the tweens
8718 // otherwise we skip this part
8719 length = gotoEnd ? animation.tweens.length : 0;
8724 for ( ; index < length ; index++ ) {
8725 animation.tweens[ index ].run( 1 );
8728 // resolve when we played the last frame
8729 // otherwise, reject
8731 deferred.resolveWith( elem, [ animation, gotoEnd ] );
8733 deferred.rejectWith( elem, [ animation, gotoEnd ] );
8738 props = animation.props;
8740 propFilter( props, animation.opts.specialEasing );
8742 for ( ; index < length ; index++ ) {
8743 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8749 createTweens( animation, props );
8751 if ( jQuery.isFunction( animation.opts.start ) ) {
8752 animation.opts.start.call( elem, animation );
8756 jQuery.extend( tick, {
8759 queue: animation.opts.queue
8763 // attach callbacks from options
8764 return animation.progress( animation.opts.progress )
8765 .done( animation.opts.done, animation.opts.complete )
8766 .fail( animation.opts.fail )
8767 .always( animation.opts.always );
8770 function propFilter( props, specialEasing ) {
8771 var index, name, easing, value, hooks;
8773 // camelCase, specialEasing and expand cssHook pass
8774 for ( index in props ) {
8775 name = jQuery.camelCase( index );
8776 easing = specialEasing[ name ];
8777 value = props[ index ];
8778 if ( jQuery.isArray( value ) ) {
8779 easing = value[ 1 ];
8780 value = props[ index ] = value[ 0 ];
8783 if ( index !== name ) {
8784 props[ name ] = value;
8785 delete props[ index ];
8788 hooks = jQuery.cssHooks[ name ];
8789 if ( hooks && "expand" in hooks ) {
8790 value = hooks.expand( value );
8791 delete props[ name ];
8793 // not quite $.extend, this wont overwrite keys already present.
8794 // also - reusing 'index' from above because we have the correct "name"
8795 for ( index in value ) {
8796 if ( !( index in props ) ) {
8797 props[ index ] = value[ index ];
8798 specialEasing[ index ] = easing;
8802 specialEasing[ name ] = easing;
8807 jQuery.Animation = jQuery.extend( Animation, {
8809 tweener: function( props, callback ) {
8810 if ( jQuery.isFunction( props ) ) {
8814 props = props.split(" ");
8819 length = props.length;
8821 for ( ; index < length ; index++ ) {
8822 prop = props[ index ];
8823 tweeners[ prop ] = tweeners[ prop ] || [];
8824 tweeners[ prop ].unshift( callback );
8828 prefilter: function( callback, prepend ) {
8830 animationPrefilters.unshift( callback );
8832 animationPrefilters.push( callback );
8837 function defaultPrefilter( elem, props, opts ) {
8838 /*jshint validthis:true */
8839 var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
8844 hidden = elem.nodeType && isHidden( elem );
8846 // handle queue: false promises
8847 if ( !opts.queue ) {
8848 hooks = jQuery._queueHooks( elem, "fx" );
8849 if ( hooks.unqueued == null ) {
8851 oldfire = hooks.empty.fire;
8852 hooks.empty.fire = function() {
8853 if ( !hooks.unqueued ) {
8860 anim.always(function() {
8861 // doing this makes sure that the complete handler will be called
8862 // before this completes
8863 anim.always(function() {
8865 if ( !jQuery.queue( elem, "fx" ).length ) {
8872 // height/width overflow pass
8873 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8874 // Make sure that nothing sneaks out
8875 // Record all 3 overflow attributes because IE does not
8876 // change the overflow attribute when overflowX and
8877 // overflowY are set to the same value
8878 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8880 // Set display property to inline-block for height/width
8881 // animations on inline elements that are having width/height animated
8882 if ( jQuery.css( elem, "display" ) === "inline" &&
8883 jQuery.css( elem, "float" ) === "none" ) {
8885 // inline-level elements accept inline-block;
8886 // block-level elements need to be inline with layout
8887 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
8888 style.display = "inline-block";
8896 if ( opts.overflow ) {
8897 style.overflow = "hidden";
8898 if ( !jQuery.support.shrinkWrapBlocks ) {
8899 anim.done(function() {
8900 style.overflow = opts.overflow[ 0 ];
8901 style.overflowX = opts.overflow[ 1 ];
8902 style.overflowY = opts.overflow[ 2 ];
8909 for ( index in props ) {
8910 value = props[ index ];
8911 if ( rfxtypes.exec( value ) ) {
8912 delete props[ index ];
8913 toggle = toggle || value === "toggle";
8914 if ( value === ( hidden ? "hide" : "show" ) ) {
8917 handled.push( index );
8921 length = handled.length;
8923 dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8924 if ( "hidden" in dataShow ) {
8925 hidden = dataShow.hidden;
8928 // store state if its toggle - enables .stop().toggle() to "reverse"
8930 dataShow.hidden = !hidden;
8933 jQuery( elem ).show();
8935 anim.done(function() {
8936 jQuery( elem ).hide();
8939 anim.done(function() {
8941 jQuery._removeData( elem, "fxshow" );
8942 for ( prop in orig ) {
8943 jQuery.style( elem, prop, orig[ prop ] );
8946 for ( index = 0 ; index < length ; index++ ) {
8947 prop = handled[ index ];
8948 tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
8949 orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
8951 if ( !( prop in dataShow ) ) {
8952 dataShow[ prop ] = tween.start;
8954 tween.end = tween.start;
8955 tween.start = prop === "width" || prop === "height" ? 1 : 0;
8962 function Tween( elem, options, prop, end, easing ) {
8963 return new Tween.prototype.init( elem, options, prop, end, easing );
8965 jQuery.Tween = Tween;
8969 init: function( elem, options, prop, end, easing, unit ) {
8972 this.easing = easing || "swing";
8973 this.options = options;
8974 this.start = this.now = this.cur();
8976 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8979 var hooks = Tween.propHooks[ this.prop ];
8981 return hooks && hooks.get ?
8983 Tween.propHooks._default.get( this );
8985 run: function( percent ) {
8987 hooks = Tween.propHooks[ this.prop ];
8989 if ( this.options.duration ) {
8990 this.pos = eased = jQuery.easing[ this.easing ](
8991 percent, this.options.duration * percent, 0, 1, this.options.duration
8994 this.pos = eased = percent;
8996 this.now = ( this.end - this.start ) * eased + this.start;
8998 if ( this.options.step ) {
8999 this.options.step.call( this.elem, this.now, this );
9002 if ( hooks && hooks.set ) {
9005 Tween.propHooks._default.set( this );
9011 Tween.prototype.init.prototype = Tween.prototype;
9015 get: function( tween ) {
9018 if ( tween.elem[ tween.prop ] != null &&
9019 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
9020 return tween.elem[ tween.prop ];
9023 // passing a non empty string as a 3rd parameter to .css will automatically
9024 // attempt a parseFloat and fallback to a string if the parse fails
9025 // so, simple values such as "10px" are parsed to Float.
9026 // complex values such as "rotate(1rad)" are returned as is.
9027 result = jQuery.css( tween.elem, tween.prop, "auto" );
9028 // Empty strings, null, undefined and "auto" are converted to 0.
9029 return !result || result === "auto" ? 0 : result;
9031 set: function( tween ) {
9032 // use step hook for back compat - use cssHook if its there - use .style if its
9033 // available and use plain properties where available
9034 if ( jQuery.fx.step[ tween.prop ] ) {
9035 jQuery.fx.step[ tween.prop ]( tween );
9036 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
9037 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
9039 tween.elem[ tween.prop ] = tween.now;
9045 // Remove in 2.0 - this supports IE8's panic based approach
9046 // to setting things on disconnected nodes
9048 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
9049 set: function( tween ) {
9050 if ( tween.elem.nodeType && tween.elem.parentNode ) {
9051 tween.elem[ tween.prop ] = tween.now;
9056 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
9057 var cssFn = jQuery.fn[ name ];
9058 jQuery.fn[ name ] = function( speed, easing, callback ) {
9059 return speed == null || typeof speed === "boolean" ?
9060 cssFn.apply( this, arguments ) :
9061 this.animate( genFx( name, true ), speed, easing, callback );
9066 fadeTo: function( speed, to, easing, callback ) {
9068 // show any hidden elements after setting opacity to 0
9069 return this.filter( isHidden ).css( "opacity", 0 ).show()
9071 // animate to the value specified
9072 .end().animate({ opacity: to }, speed, easing, callback );
9074 animate: function( prop, speed, easing, callback ) {
9075 var empty = jQuery.isEmptyObject( prop ),
9076 optall = jQuery.speed( speed, easing, callback ),
9077 doAnimation = function() {
9078 // Operate on a copy of prop so per-property easing won't be lost
9079 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
9080 doAnimation.finish = function() {
9083 // Empty animations, or finishing resolves immediately
9084 if ( empty || jQuery._data( this, "finish" ) ) {
9088 doAnimation.finish = doAnimation;
9090 return empty || optall.queue === false ?
9091 this.each( doAnimation ) :
9092 this.queue( optall.queue, doAnimation );
9094 stop: function( type, clearQueue, gotoEnd ) {
9095 var stopQueue = function( hooks ) {
9096 var stop = hooks.stop;
9101 if ( typeof type !== "string" ) {
9102 gotoEnd = clearQueue;
9106 if ( clearQueue && type !== false ) {
9107 this.queue( type || "fx", [] );
9110 return this.each(function() {
9112 index = type != null && type + "queueHooks",
9113 timers = jQuery.timers,
9114 data = jQuery._data( this );
9117 if ( data[ index ] && data[ index ].stop ) {
9118 stopQueue( data[ index ] );
9121 for ( index in data ) {
9122 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
9123 stopQueue( data[ index ] );
9128 for ( index = timers.length; index--; ) {
9129 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
9130 timers[ index ].anim.stop( gotoEnd );
9132 timers.splice( index, 1 );
9136 // start the next in the queue if the last step wasn't forced
9137 // timers currently will call their complete callbacks, which will dequeue
9138 // but only if they were gotoEnd
9139 if ( dequeue || !gotoEnd ) {
9140 jQuery.dequeue( this, type );
9144 finish: function( type ) {
9145 if ( type !== false ) {
9146 type = type || "fx";
9148 return this.each(function() {
9150 data = jQuery._data( this ),
9151 queue = data[ type + "queue" ],
9152 hooks = data[ type + "queueHooks" ],
9153 timers = jQuery.timers,
9154 length = queue ? queue.length : 0;
9156 // enable finishing flag on private data
9159 // empty the queue first
9160 jQuery.queue( this, type, [] );
9162 if ( hooks && hooks.cur && hooks.cur.finish ) {
9163 hooks.cur.finish.call( this );
9166 // look for any active animations, and finish them
9167 for ( index = timers.length; index--; ) {
9168 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
9169 timers[ index ].anim.stop( true );
9170 timers.splice( index, 1 );
9174 // look for any animations in the old queue and finish them
9175 for ( index = 0; index < length; index++ ) {
9176 if ( queue[ index ] && queue[ index ].finish ) {
9177 queue[ index ].finish.call( this );
9181 // turn off finishing flag
9187 // Generate parameters to create a standard animation
9188 function genFx( type, includeWidth ) {
9190 attrs = { height: type },
9193 // if we include width, step value is 1 to do all cssExpand values,
9194 // if we don't include width, step value is 2 to skip over Left and Right
9195 includeWidth = includeWidth? 1 : 0;
9196 for( ; i < 4 ; i += 2 - includeWidth ) {
9197 which = cssExpand[ i ];
9198 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
9201 if ( includeWidth ) {
9202 attrs.opacity = attrs.width = type;
9208 // Generate shortcuts for custom animations
9210 slideDown: genFx("show"),
9211 slideUp: genFx("hide"),
9212 slideToggle: genFx("toggle"),
9213 fadeIn: { opacity: "show" },
9214 fadeOut: { opacity: "hide" },
9215 fadeToggle: { opacity: "toggle" }
9216 }, function( name, props ) {
9217 jQuery.fn[ name ] = function( speed, easing, callback ) {
9218 return this.animate( props, speed, easing, callback );
9222 jQuery.speed = function( speed, easing, fn ) {
9223 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
9224 complete: fn || !fn && easing ||
9225 jQuery.isFunction( speed ) && speed,
9227 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
9230 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
9231 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
9233 // normalize opt.queue - true/undefined/null -> "fx"
9234 if ( opt.queue == null || opt.queue === true ) {
9239 opt.old = opt.complete;
9241 opt.complete = function() {
9242 if ( jQuery.isFunction( opt.old ) ) {
9243 opt.old.call( this );
9247 jQuery.dequeue( this, opt.queue );
9255 linear: function( p ) {
9258 swing: function( p ) {
9259 return 0.5 - Math.cos( p*Math.PI ) / 2;
9264 jQuery.fx = Tween.prototype.init;
9265 jQuery.fx.tick = function() {
9267 timers = jQuery.timers,
9270 fxNow = jQuery.now();
9272 for ( ; i < timers.length; i++ ) {
9273 timer = timers[ i ];
9274 // Checks the timer has not already been removed
9275 if ( !timer() && timers[ i ] === timer ) {
9276 timers.splice( i--, 1 );
9280 if ( !timers.length ) {
9286 jQuery.fx.timer = function( timer ) {
9287 if ( timer() && jQuery.timers.push( timer ) ) {
9292 jQuery.fx.interval = 13;
9294 jQuery.fx.start = function() {
9296 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
9300 jQuery.fx.stop = function() {
9301 clearInterval( timerId );
9305 jQuery.fx.speeds = {
9312 // Back Compat <1.8 extension point
9313 jQuery.fx.step = {};
9315 if ( jQuery.expr && jQuery.expr.filters ) {
9316 jQuery.expr.filters.animated = function( elem ) {
9317 return jQuery.grep(jQuery.timers, function( fn ) {
9318 return elem === fn.elem;
9322 jQuery.fn.offset = function( options ) {
9323 if ( arguments.length ) {
9324 return options === undefined ?
9326 this.each(function( i ) {
9327 jQuery.offset.setOffset( this, options, i );
9332 box = { top: 0, left: 0 },
9334 doc = elem && elem.ownerDocument;
9340 docElem = doc.documentElement;
9342 // Make sure it's not a disconnected DOM node
9343 if ( !jQuery.contains( docElem, elem ) ) {
9347 // If we don't have gBCR, just use 0,0 rather than error
9348 // BlackBerry 5, iOS 3 (original iPhone)
9349 if ( typeof elem.getBoundingClientRect !== "undefined" ) {
9350 box = elem.getBoundingClientRect();
9352 win = getWindow( doc );
9354 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
9355 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
9361 setOffset: function( elem, options, i ) {
9362 var position = jQuery.css( elem, "position" );
9364 // set position first, in-case top/left are set even on static elem
9365 if ( position === "static" ) {
9366 elem.style.position = "relative";
9369 var curElem = jQuery( elem ),
9370 curOffset = curElem.offset(),
9371 curCSSTop = jQuery.css( elem, "top" ),
9372 curCSSLeft = jQuery.css( elem, "left" ),
9373 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9374 props = {}, curPosition = {}, curTop, curLeft;
9376 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9377 if ( calculatePosition ) {
9378 curPosition = curElem.position();
9379 curTop = curPosition.top;
9380 curLeft = curPosition.left;
9382 curTop = parseFloat( curCSSTop ) || 0;
9383 curLeft = parseFloat( curCSSLeft ) || 0;
9386 if ( jQuery.isFunction( options ) ) {
9387 options = options.call( elem, i, curOffset );
9390 if ( options.top != null ) {
9391 props.top = ( options.top - curOffset.top ) + curTop;
9393 if ( options.left != null ) {
9394 props.left = ( options.left - curOffset.left ) + curLeft;
9397 if ( "using" in options ) {
9398 options.using.call( elem, props );
9400 curElem.css( props );
9408 position: function() {
9413 var offsetParent, offset,
9414 parentOffset = { top: 0, left: 0 },
9417 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
9418 if ( jQuery.css( elem, "position" ) === "fixed" ) {
9419 // we assume that getBoundingClientRect is available when computed position is fixed
9420 offset = elem.getBoundingClientRect();
9422 // Get *real* offsetParent
9423 offsetParent = this.offsetParent();
9425 // Get correct offsets
9426 offset = this.offset();
9427 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
9428 parentOffset = offsetParent.offset();
9431 // Add offsetParent borders
9432 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
9433 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
9436 // Subtract parent offsets and element margins
9437 // note: when an element has margin: auto the offsetLeft and marginLeft
9438 // are the same in Safari causing offset.left to incorrectly be 0
9440 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
9441 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
9445 offsetParent: function() {
9446 return this.map(function() {
9447 var offsetParent = this.offsetParent || document.documentElement;
9448 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
9449 offsetParent = offsetParent.offsetParent;
9451 return offsetParent || document.documentElement;
9457 // Create scrollLeft and scrollTop methods
9458 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
9459 var top = /Y/.test( prop );
9461 jQuery.fn[ method ] = function( val ) {
9462 return jQuery.access( this, function( elem, method, val ) {
9463 var win = getWindow( elem );
9465 if ( val === undefined ) {
9466 return win ? (prop in win) ? win[ prop ] :
9467 win.document.documentElement[ method ] :
9473 !top ? val : jQuery( win ).scrollLeft(),
9474 top ? val : jQuery( win ).scrollTop()
9478 elem[ method ] = val;
9480 }, method, val, arguments.length, null );
9484 function getWindow( elem ) {
9485 return jQuery.isWindow( elem ) ?
9487 elem.nodeType === 9 ?
9488 elem.defaultView || elem.parentWindow :
9491 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9492 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9493 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9494 // margin is only for outerHeight, outerWidth
9495 jQuery.fn[ funcName ] = function( margin, value ) {
9496 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9497 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9499 return jQuery.access( this, function( elem, type, value ) {
9502 if ( jQuery.isWindow( elem ) ) {
9503 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9504 // isn't a whole lot we can do. See pull request at this URL for discussion:
9505 // https://github.com/jquery/jquery/pull/764
9506 return elem.document.documentElement[ "client" + name ];
9509 // Get document width or height
9510 if ( elem.nodeType === 9 ) {
9511 doc = elem.documentElement;
9513 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9514 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9516 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9517 elem.body[ "offset" + name ], doc[ "offset" + name ],
9518 doc[ "client" + name ]
9522 return value === undefined ?
9523 // Get width or height on the element, requesting but not forcing parseFloat
9524 jQuery.css( elem, type, extra ) :
9526 // Set width or height on the element
9527 jQuery.style( elem, type, value, extra );
9528 }, type, chainable ? margin : undefined, chainable, null );
9532 // Limit scope pollution from any deprecated API
9536 // Expose jQuery to the global object
9537 window.jQuery = window.$ = jQuery;
9539 // Expose jQuery as an AMD module, but only for AMD loaders that
9540 // understand the issues with loading multiple versions of jQuery
9541 // in a page that all might call define(). The loader will indicate
9542 // they have special allowances for multiple jQuery versions by
9543 // specifying define.amd.jQuery = true. Register as a named module,
9544 // since jQuery can be concatenated with other files that may use define,
9545 // but not use a proper concatenation script that understands anonymous
9546 // AMD modules. A named AMD is safest and most robust way to register.
9547 // Lowercase jquery is used because AMD module names are derived from
9548 // file names, and jQuery is normally delivered in a lowercase file name.
9549 // Do this after creating the global so that if an AMD module wants to call
9550 // noConflict to hide this version of jQuery, it will work.
9551 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
9552 define( "jquery", [], function () { return jQuery; } );