1 /*! jQuery v1.7.1 jquery.com | jquery.org/license */
2 (function( window, undefined ) {
4 // Use the correct document accordingly with window argument (sandbox)
5 var document = window.document,
6 navigator = window.navigator,
7 location = window.location;
8 var jQuery = (function() {
10 // Define a local copy of jQuery
11 var jQuery = function( selector, context ) {
12 // The jQuery object is actually just the init constructor 'enhanced'
13 return new jQuery.fn.init( selector, context, rootjQuery );
16 // Map over jQuery in case of overwrite
17 _jQuery = window.jQuery,
19 // Map over the $ in case of overwrite
22 // A central reference to the root jQuery(document)
25 // A simple way to check for HTML strings or ID strings
26 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
27 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
29 // Check if a string has a non-whitespace character in it
32 // Used for trimming whitespace
36 // Match a standalone tag
37 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
40 rvalidchars = /^[\],:{}\s]*$/,
41 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
42 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
43 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
46 rwebkit = /(webkit)[ \/]([\w.]+)/,
47 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
48 rmsie = /(msie) ([\w.]+)/,
49 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
51 // Matches dashed string for camelizing
52 rdashAlpha = /-([a-z]|[0-9])/ig,
55 // Used by jQuery.camelCase as callback to replace()
56 fcamelCase = function( all, letter ) {
57 return ( letter + "" ).toUpperCase();
60 // Keep a UserAgent string for use with jQuery.browser
61 userAgent = navigator.userAgent,
63 // For matching the engine and version of the browser
66 // The deferred used on DOM ready
69 // The ready event handler
72 // Save a reference to some core methods
73 toString = Object.prototype.toString,
74 hasOwn = Object.prototype.hasOwnProperty,
75 push = Array.prototype.push,
76 slice = Array.prototype.slice,
77 trim = String.prototype.trim,
78 indexOf = Array.prototype.indexOf,
80 // [[Class]] -> type pairs
83 jQuery.fn = jQuery.prototype = {
85 init: function( selector, context, rootjQuery ) {
86 var match, elem, ret, doc;
88 // Handle $(""), $(null), or $(undefined)
93 // Handle $(DOMElement)
94 if ( selector.nodeType ) {
95 this.context = this[0] = selector;
100 // The body element only exists once, optimize finding it
101 if ( selector === "body" && !context && document.body ) {
102 this.context = document;
103 this[0] = document.body;
104 this.selector = selector;
109 // Handle HTML strings
110 if ( typeof selector === "string" ) {
111 // Are we dealing with HTML string or an ID?
112 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
113 // Assume that strings that start and end with <> are HTML and skip the regex check
114 match = [ null, selector, null ];
117 match = quickExpr.exec( selector );
120 // Verify a match, and that no context was specified for #id
121 if ( match && (match[1] || !context) ) {
123 // HANDLE: $(html) -> $(array)
125 context = context instanceof jQuery ? context[0] : context;
126 doc = ( context ? context.ownerDocument || context : document );
128 // If a single string is passed in and it's a single tag
129 // just do a createElement and skip the rest
130 ret = rsingleTag.exec( selector );
133 if ( jQuery.isPlainObject( context ) ) {
134 selector = [ document.createElement( ret[1] ) ];
135 jQuery.fn.attr.call( selector, context, true );
138 selector = [ doc.createElement( ret[1] ) ];
142 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
143 selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
146 return jQuery.merge( this, selector );
150 elem = document.getElementById( match[2] );
152 // Check parentNode to catch when Blackberry 4.6 returns
153 // nodes that are no longer in the document #6963
154 if ( elem && elem.parentNode ) {
155 // Handle the case where IE and Opera return items
156 // by name instead of ID
157 if ( elem.id !== match[2] ) {
158 return rootjQuery.find( selector );
161 // Otherwise, we inject the element directly into the jQuery object
166 this.context = document;
167 this.selector = selector;
171 // HANDLE: $(expr, $(...))
172 } else if ( !context || context.jquery ) {
173 return ( context || rootjQuery ).find( selector );
175 // HANDLE: $(expr, context)
176 // (which is just equivalent to: $(context).find(expr)
178 return this.constructor( context ).find( selector );
181 // HANDLE: $(function)
182 // Shortcut for document ready
183 } else if ( jQuery.isFunction( selector ) ) {
184 return rootjQuery.ready( selector );
187 if ( selector.selector !== undefined ) {
188 this.selector = selector.selector;
189 this.context = selector.context;
192 return jQuery.makeArray( selector, this );
195 // Start with an empty selector
198 // The current version of jQuery being used
201 // The default length of a jQuery object is 0
204 // The number of elements contained in the matched element set
209 toArray: function() {
210 return slice.call( this, 0 );
213 // Get the Nth element in the matched element set OR
214 // Get the whole matched element set as a clean array
215 get: function( num ) {
218 // Return a 'clean' array
221 // Return just the object
222 ( num < 0 ? this[ this.length + num ] : this[ num ] );
225 // Take an array of elements and push it onto the stack
226 // (returning the new matched element set)
227 pushStack: function( elems, name, selector ) {
228 // Build a new jQuery matched element set
229 var ret = this.constructor();
231 if ( jQuery.isArray( elems ) ) {
232 push.apply( ret, elems );
235 jQuery.merge( ret, elems );
238 // Add the old object onto the stack (as a reference)
239 ret.prevObject = this;
241 ret.context = this.context;
243 if ( name === "find" ) {
244 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
246 ret.selector = this.selector + "." + name + "(" + selector + ")";
249 // Return the newly-formed element set
253 // Execute a callback for every element in the matched set.
254 // (You can seed the arguments with an array of args, but this is
255 // only used internally.)
256 each: function( callback, args ) {
257 return jQuery.each( this, callback, args );
260 ready: function( fn ) {
261 // Attach the listeners
274 this.slice( i, i + 1 );
282 return this.eq( -1 );
286 return this.pushStack( slice.apply( this, arguments ),
287 "slice", slice.call(arguments).join(",") );
290 map: function( callback ) {
291 return this.pushStack( jQuery.map(this, function( elem, i ) {
292 return callback.call( elem, i, elem );
297 return this.prevObject || this.constructor(null);
300 // For internal use only.
301 // Behaves like an Array's method, not like a jQuery method.
307 // Give the init function the jQuery prototype for later instantiation
308 jQuery.fn.init.prototype = jQuery.fn;
310 jQuery.extend = jQuery.fn.extend = function() {
311 var options, name, src, copy, copyIsArray, clone,
312 target = arguments[0] || {},
314 length = arguments.length,
317 // Handle a deep copy situation
318 if ( typeof target === "boolean" ) {
320 target = arguments[1] || {};
321 // skip the boolean and the target
325 // Handle case when target is a string or something (possible in deep copy)
326 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
330 // extend jQuery itself if only one argument is passed
331 if ( length === i ) {
336 for ( ; i < length; i++ ) {
337 // Only deal with non-null/undefined values
338 if ( (options = arguments[ i ]) != null ) {
339 // Extend the base object
340 for ( name in options ) {
341 src = target[ name ];
342 copy = options[ name ];
344 // Prevent never-ending loop
345 if ( target === copy ) {
349 // Recurse if we're merging plain objects or arrays
350 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
353 clone = src && jQuery.isArray(src) ? src : [];
356 clone = src && jQuery.isPlainObject(src) ? src : {};
359 // Never move original objects, clone them
360 target[ name ] = jQuery.extend( deep, clone, copy );
362 // Don't bring in undefined values
363 } else if ( copy !== undefined ) {
364 target[ name ] = copy;
370 // Return the modified object
375 noConflict: function( deep ) {
376 if ( window.$ === jQuery ) {
380 if ( deep && window.jQuery === jQuery ) {
381 window.jQuery = _jQuery;
387 // Is the DOM ready to be used? Set to true once it occurs.
390 // A counter to track how many items to wait for before
391 // the ready event fires. See #6781
394 // Hold (or release) the ready event
395 holdReady: function( hold ) {
399 jQuery.ready( true );
403 // Handle when the DOM is ready
404 ready: function( wait ) {
405 // Either a released hold or an DOMready/load event and not yet ready
406 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
407 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
408 if ( !document.body ) {
409 return setTimeout( jQuery.ready, 1 );
412 // Remember that the DOM is ready
413 jQuery.isReady = true;
415 // If a normal DOM Ready event fired, decrement, and wait if need be
416 if ( wait !== true && --jQuery.readyWait > 0 ) {
420 // If there are functions bound, to execute
421 readyList.fireWith( document, [ jQuery ] );
423 // Trigger any bound ready events
424 if ( jQuery.fn.trigger ) {
425 jQuery( document ).trigger( "ready" ).off( "ready" );
430 bindReady: function() {
435 readyList = jQuery.Callbacks( "once memory" );
437 // Catch cases where $(document).ready() is called after the
438 // browser event has already occurred.
439 if ( document.readyState === "complete" ) {
440 // Handle it asynchronously to allow scripts the opportunity to delay ready
441 return setTimeout( jQuery.ready, 1 );
444 // Mozilla, Opera and webkit nightlies currently support this event
445 if ( document.addEventListener ) {
446 // Use the handy event callback
447 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
449 // A fallback to window.onload, that will always work
450 window.addEventListener( "load", jQuery.ready, false );
452 // If IE event model is used
453 } else if ( document.attachEvent ) {
454 // ensure firing before onload,
455 // maybe late but safe also for iframes
456 document.attachEvent( "onreadystatechange", DOMContentLoaded );
458 // A fallback to window.onload, that will always work
459 window.attachEvent( "onload", jQuery.ready );
461 // If IE and not a frame
462 // continually check to see if the document is ready
463 var toplevel = false;
466 toplevel = window.frameElement == null;
469 if ( document.documentElement.doScroll && toplevel ) {
475 // See test/unit/core.js for details concerning isFunction.
476 // Since version 1.3, DOM methods and functions like alert
477 // aren't supported. They return false on IE (#2968).
478 isFunction: function( obj ) {
479 return jQuery.type(obj) === "function";
482 isArray: Array.isArray || function( obj ) {
483 return jQuery.type(obj) === "array";
486 // A crude way of determining if an object is a window
487 isWindow: function( obj ) {
488 return obj && typeof obj === "object" && "setInterval" in obj;
491 isNumeric: function( obj ) {
492 return !isNaN( parseFloat(obj) ) && isFinite( obj );
495 type: function( obj ) {
498 class2type[ toString.call(obj) ] || "object";
501 isPlainObject: function( obj ) {
502 // Must be an Object.
503 // Because of IE, we also have to check the presence of the constructor property.
504 // Make sure that DOM nodes and window objects don't pass through, as well
505 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
510 // Not own constructor property must be Object
511 if ( obj.constructor &&
512 !hasOwn.call(obj, "constructor") &&
513 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
517 // IE8,9 Will throw exceptions on certain host objects #9897
521 // Own properties are enumerated firstly, so to speed up,
522 // if last one is own, then all properties are own.
525 for ( key in obj ) {}
527 return key === undefined || hasOwn.call( obj, key );
530 isEmptyObject: function( obj ) {
531 for ( var name in obj ) {
537 error: function( msg ) {
538 throw new Error( msg );
541 parseJSON: function( data ) {
542 if ( typeof data !== "string" || !data ) {
546 // Make sure leading/trailing whitespace is removed (IE can't handle it)
547 data = jQuery.trim( data );
549 // Attempt to parse using the native JSON parser first
550 if ( window.JSON && window.JSON.parse ) {
551 return window.JSON.parse( data );
554 // Make sure the incoming data is actual JSON
555 // Logic borrowed from http://json.org/json2.js
556 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
557 .replace( rvalidtokens, "]" )
558 .replace( rvalidbraces, "")) ) {
560 return ( new Function( "return " + data ) )();
563 jQuery.error( "Invalid JSON: " + data );
566 // Cross-browser xml parsing
567 parseXML: function( data ) {
570 if ( window.DOMParser ) { // Standard
571 tmp = new DOMParser();
572 xml = tmp.parseFromString( data , "text/xml" );
574 xml = new ActiveXObject( "Microsoft.XMLDOM" );
581 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
582 jQuery.error( "Invalid XML: " + data );
589 // Evaluates a script in a global context
590 // Workarounds based on findings by Jim Driscoll
591 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
592 globalEval: function( data ) {
593 if ( data && rnotwhite.test( data ) ) {
594 // We use execScript on Internet Explorer
595 // We use an anonymous function so that context is window
596 // rather than jQuery in Firefox
597 ( window.execScript || function( data ) {
598 window[ "eval" ].call( window, data );
603 // Convert dashed to camelCase; used by the css and data modules
604 // Microsoft forgot to hump their vendor prefix (#9572)
605 camelCase: function( string ) {
606 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
609 nodeName: function( elem, name ) {
610 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
613 // args is for internal usage only
614 each: function( object, callback, args ) {
616 length = object.length,
617 isObj = length === undefined || jQuery.isFunction( object );
621 for ( name in object ) {
622 if ( callback.apply( object[ name ], args ) === false ) {
627 for ( ; i < length; ) {
628 if ( callback.apply( object[ i++ ], args ) === false ) {
634 // A special, fast, case for the most common use of each
637 for ( name in object ) {
638 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
643 for ( ; i < length; ) {
644 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
654 // Use native String.trim function wherever possible
657 return text == null ?
662 // Otherwise use our own trimming functionality
664 return text == null ?
666 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
669 // results is for internal usage only
670 makeArray: function( array, results ) {
671 var ret = results || [];
673 if ( array != null ) {
674 // The window, strings (and functions) also have 'length'
675 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
676 var type = jQuery.type( array );
678 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
679 push.call( ret, array );
681 jQuery.merge( ret, array );
688 inArray: function( elem, array, i ) {
693 return indexOf.call( array, elem, i );
697 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
699 for ( ; i < len; i++ ) {
700 // Skip accessing in sparse arrays
701 if ( i in array && array[ i ] === elem ) {
710 merge: function( first, second ) {
711 var i = first.length,
714 if ( typeof second.length === "number" ) {
715 for ( var l = second.length; j < l; j++ ) {
716 first[ i++ ] = second[ j ];
720 while ( second[j] !== undefined ) {
721 first[ i++ ] = second[ j++ ];
730 grep: function( elems, callback, inv ) {
731 var ret = [], retVal;
734 // Go through the array, only saving the items
735 // that pass the validator function
736 for ( var i = 0, length = elems.length; i < length; i++ ) {
737 retVal = !!callback( elems[ i ], i );
738 if ( inv !== retVal ) {
739 ret.push( elems[ i ] );
746 // arg is for internal usage only
747 map: function( elems, callback, arg ) {
748 var value, key, ret = [],
750 length = elems.length,
751 // jquery objects are treated as arrays
752 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
754 // Go through the array, translating each of the items to their
756 for ( ; i < length; i++ ) {
757 value = callback( elems[ i ], i, arg );
759 if ( value != null ) {
760 ret[ ret.length ] = value;
764 // Go through every key on the object
766 for ( key in elems ) {
767 value = callback( elems[ key ], key, arg );
769 if ( value != null ) {
770 ret[ ret.length ] = value;
775 // Flatten any nested arrays
776 return ret.concat.apply( [], ret );
779 // A global GUID counter for objects
782 // Bind a function to a context, optionally partially applying any
784 proxy: function( fn, context ) {
785 if ( typeof context === "string" ) {
786 var tmp = fn[ context ];
791 // Quick check to determine if target is callable, in the spec
792 // this throws a TypeError, but we will just return undefined.
793 if ( !jQuery.isFunction( fn ) ) {
798 var args = slice.call( arguments, 2 ),
800 return fn.apply( context, args.concat( slice.call( arguments ) ) );
803 // Set the guid of unique handler to the same of original handler, so it can be removed
804 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
809 // Mutifunctional method to get and set values to a collection
810 // The value/s can optionally be executed if it's a function
811 access: function( elems, key, value, exec, fn, pass ) {
812 var length = elems.length;
814 // Setting many attributes
815 if ( typeof key === "object" ) {
816 for ( var k in key ) {
817 jQuery.access( elems, k, key[k], exec, fn, value );
822 // Setting one attribute
823 if ( value !== undefined ) {
824 // Optionally, function values get executed if exec is true
825 exec = !pass && exec && jQuery.isFunction(value);
827 for ( var i = 0; i < length; i++ ) {
828 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
834 // Getting an attribute
835 return length ? fn( elems[0], key ) : undefined;
839 return ( new Date() ).getTime();
842 // Use of jQuery.browser is frowned upon.
843 // More details: http://docs.jquery.com/Utilities/jQuery.browser
844 uaMatch: function( ua ) {
845 ua = ua.toLowerCase();
847 var match = rwebkit.exec( ua ) ||
850 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
853 return { browser: match[1] || "", version: match[2] || "0" };
857 function jQuerySub( selector, context ) {
858 return new jQuerySub.fn.init( selector, context );
860 jQuery.extend( true, jQuerySub, this );
861 jQuerySub.superclass = this;
862 jQuerySub.fn = jQuerySub.prototype = this();
863 jQuerySub.fn.constructor = jQuerySub;
864 jQuerySub.sub = this.sub;
865 jQuerySub.fn.init = function init( selector, context ) {
866 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
867 context = jQuerySub( context );
870 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
872 jQuerySub.fn.init.prototype = jQuerySub.fn;
873 var rootjQuerySub = jQuerySub(document);
880 // Populate the class2type map
881 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
882 class2type[ "[object " + name + "]" ] = name.toLowerCase();
885 browserMatch = jQuery.uaMatch( userAgent );
886 if ( browserMatch.browser ) {
887 jQuery.browser[ browserMatch.browser ] = true;
888 jQuery.browser.version = browserMatch.version;
891 // Deprecated, use jQuery.browser.webkit instead
892 if ( jQuery.browser.webkit ) {
893 jQuery.browser.safari = true;
896 // IE doesn't match non-breaking spaces with \s
897 if ( rnotwhite.test( "\xA0" ) ) {
898 trimLeft = /^[\s\xA0]+/;
899 trimRight = /[\s\xA0]+$/;
902 // All jQuery objects should point back to these
903 rootjQuery = jQuery(document);
905 // Cleanup functions for the document ready method
906 if ( document.addEventListener ) {
907 DOMContentLoaded = function() {
908 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
912 } else if ( document.attachEvent ) {
913 DOMContentLoaded = function() {
914 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
915 if ( document.readyState === "complete" ) {
916 document.detachEvent( "onreadystatechange", DOMContentLoaded );
922 // The DOM ready check for Internet Explorer
923 function doScrollCheck() {
924 if ( jQuery.isReady ) {
929 // If IE is used, use the trick by Diego Perini
930 // http://javascript.nwbox.com/IEContentLoaded/
931 document.documentElement.doScroll("left");
933 setTimeout( doScrollCheck, 1 );
937 // and execute any waiting functions
946 // String to Object flags format cache
949 // Convert String-formatted flags into Object-formatted ones and store in cache
950 function createFlags( flags ) {
951 var object = flagsCache[ flags ] = {},
953 flags = flags.split( /\s+/ );
954 for ( i = 0, length = flags.length; i < length; i++ ) {
955 object[ flags[i] ] = true;
961 * Create a callback list using the following parameters:
963 * flags: an optional list of space-separated flags that will change how
964 * the callback list behaves
966 * By default a callback list will act like an event callback list and can be
967 * "fired" multiple times.
971 * once: will ensure the callback list can only be fired once (like a Deferred)
973 * memory: will keep track of previous values and will call any callback added
974 * after the list has been fired right away with the latest "memorized"
975 * values (like a Deferred)
977 * unique: will ensure a callback can only be added once (no duplicate in the list)
979 * stopOnFalse: interrupt callings when a callback returns false
982 jQuery.Callbacks = function( flags ) {
984 // Convert flags from String-formatted to Object-formatted
985 // (we check in cache first)
986 flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
988 var // Actual callback list
990 // Stack of fire calls for repeatable lists
992 // Last fire value (for non-forgettable lists)
994 // Flag to know if list is currently firing
996 // First callback to fire (used internally by add and fireWith)
998 // End of the loop when firing
1000 // Index of currently firing callback (modified by remove if needed)
1002 // Add one or several callbacks to the list
1003 add = function( args ) {
1009 for ( i = 0, length = args.length; i < length; i++ ) {
1011 type = jQuery.type( elem );
1012 if ( type === "array" ) {
1013 // Inspect recursively
1015 } else if ( type === "function" ) {
1016 // Add if not in unique mode and callback is not in
1017 if ( !flags.unique || !self.has( elem ) ) {
1024 fire = function( context, args ) {
1026 memory = !flags.memory || [ context, args ];
1028 firingIndex = firingStart || 0;
1030 firingLength = list.length;
1031 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1032 if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
1033 memory = true; // Mark as halted
1039 if ( !flags.once ) {
1040 if ( stack && stack.length ) {
1041 memory = stack.shift();
1042 self.fireWith( memory[ 0 ], memory[ 1 ] );
1044 } else if ( memory === true ) {
1051 // Actual Callbacks object
1053 // Add a callback or a collection of callbacks to the list
1056 var length = list.length;
1058 // Do we need to add the callbacks to the
1059 // current firing batch?
1061 firingLength = list.length;
1062 // With memory, if we're not firing then
1063 // we should call right away, unless previous
1064 // firing was halted (stopOnFalse)
1065 } else if ( memory && memory !== true ) {
1066 firingStart = length;
1067 fire( memory[ 0 ], memory[ 1 ] );
1072 // Remove a callback from the list
1073 remove: function() {
1075 var args = arguments,
1077 argLength = args.length;
1078 for ( ; argIndex < argLength ; argIndex++ ) {
1079 for ( var i = 0; i < list.length; i++ ) {
1080 if ( args[ argIndex ] === list[ i ] ) {
1081 // Handle firingIndex and firingLength
1083 if ( i <= firingLength ) {
1085 if ( i <= firingIndex ) {
1090 // Remove the element
1091 list.splice( i--, 1 );
1092 // If we have some unicity property then
1093 // we only need to do this once
1094 if ( flags.unique ) {
1103 // Control if a given callback is in the list
1104 has: function( fn ) {
1107 length = list.length;
1108 for ( ; i < length; i++ ) {
1109 if ( fn === list[ i ] ) {
1116 // Remove all callbacks from the list
1121 // Have the list do nothing anymore
1122 disable: function() {
1123 list = stack = memory = undefined;
1127 disabled: function() {
1130 // Lock the list in its current state
1133 if ( !memory || memory === true ) {
1139 locked: function() {
1142 // Call all callbacks with the given context and arguments
1143 fireWith: function( context, args ) {
1146 if ( !flags.once ) {
1147 stack.push( [ context, args ] );
1149 } else if ( !( flags.once && memory ) ) {
1150 fire( context, args );
1155 // Call all the callbacks with the given arguments
1157 self.fireWith( this, arguments );
1160 // To know if the callbacks have already been called at least once
1172 var // Static reference to slice
1173 sliceDeferred = [].slice;
1177 Deferred: function( func ) {
1178 var doneList = jQuery.Callbacks( "once memory" ),
1179 failList = jQuery.Callbacks( "once memory" ),
1180 progressList = jQuery.Callbacks( "memory" ),
1185 notify: progressList
1190 progress: progressList.add,
1197 isResolved: doneList.fired,
1198 isRejected: failList.fired,
1200 then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
1201 deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
1204 always: function() {
1205 deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
1208 pipe: function( fnDone, fnFail, fnProgress ) {
1209 return jQuery.Deferred(function( newDefer ) {
1211 done: [ fnDone, "resolve" ],
1212 fail: [ fnFail, "reject" ],
1213 progress: [ fnProgress, "notify" ]
1214 }, function( handler, data ) {
1218 if ( jQuery.isFunction( fn ) ) {
1219 deferred[ handler ](function() {
1220 returned = fn.apply( this, arguments );
1221 if ( returned && jQuery.isFunction( returned.promise ) ) {
1222 returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
1224 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1228 deferred[ handler ]( newDefer[ action ] );
1233 // Get a promise for this deferred
1234 // If obj is provided, the promise aspect is added to the object
1235 promise: function( obj ) {
1236 if ( obj == null ) {
1239 for ( var key in promise ) {
1240 obj[ key ] = promise[ key ];
1246 deferred = promise.promise({}),
1249 for ( key in lists ) {
1250 deferred[ key ] = lists[ key ].fire;
1251 deferred[ key + "With" ] = lists[ key ].fireWith;
1255 deferred.done( function() {
1257 }, failList.disable, progressList.lock ).fail( function() {
1259 }, doneList.disable, progressList.lock );
1261 // Call given func if any
1263 func.call( deferred, deferred );
1271 when: function( firstParam ) {
1272 var args = sliceDeferred.call( arguments, 0 ),
1274 length = args.length,
1275 pValues = new Array( length ),
1278 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1281 promise = deferred.promise();
1282 function resolveFunc( i ) {
1283 return function( value ) {
1284 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1285 if ( !( --count ) ) {
1286 deferred.resolveWith( deferred, args );
1290 function progressFunc( i ) {
1291 return function( value ) {
1292 pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1293 deferred.notifyWith( promise, pValues );
1297 for ( ; i < length; i++ ) {
1298 if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
1299 args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
1305 deferred.resolveWith( deferred, args );
1307 } else if ( deferred !== firstParam ) {
1308 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1317 jQuery.support = (function() {
1332 div = document.createElement( "div" ),
1333 documentElement = document.documentElement;
1335 // Preliminary tests
1336 div.setAttribute("className", "t");
1337 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1339 all = div.getElementsByTagName( "*" );
1340 a = div.getElementsByTagName( "a" )[ 0 ];
1342 // Can't get basic test support
1343 if ( !all || !all.length || !a ) {
1347 // First batch of supports tests
1348 select = document.createElement( "select" );
1349 opt = select.appendChild( document.createElement("option") );
1350 input = div.getElementsByTagName( "input" )[ 0 ];
1353 // IE strips leading whitespace when .innerHTML is used
1354 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1356 // Make sure that tbody elements aren't automatically inserted
1357 // IE will insert them into empty tables
1358 tbody: !div.getElementsByTagName("tbody").length,
1360 // Make sure that link elements get serialized correctly by innerHTML
1361 // This requires a wrapper element in IE
1362 htmlSerialize: !!div.getElementsByTagName("link").length,
1364 // Get the style information from getAttribute
1365 // (IE uses .cssText instead)
1366 style: /top/.test( a.getAttribute("style") ),
1368 // Make sure that URLs aren't manipulated
1369 // (IE normalizes it by default)
1370 hrefNormalized: ( a.getAttribute("href") === "/a" ),
1372 // Make sure that element opacity exists
1373 // (IE uses filter instead)
1374 // Use a regex to work around a WebKit issue. See #5145
1375 opacity: /^0.55/.test( a.style.opacity ),
1377 // Verify style float existence
1378 // (IE uses styleFloat instead of cssFloat)
1379 cssFloat: !!a.style.cssFloat,
1381 // Make sure that if no value is specified for a checkbox
1382 // that it defaults to "on".
1383 // (WebKit defaults to "" instead)
1384 checkOn: ( input.value === "on" ),
1386 // Make sure that a selected-by-default option has a working selected property.
1387 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1388 optSelected: opt.selected,
1390 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1391 getSetAttribute: div.className !== "t",
1393 // Tests for enctype support on a form(#6743)
1394 enctype: !!document.createElement("form").enctype,
1396 // Makes sure cloning an html5 element does not cause problems
1397 // Where outerHTML is undefined, this still works
1398 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1400 // Will be defined later
1401 submitBubbles: true,
1402 changeBubbles: true,
1403 focusinBubbles: false,
1404 deleteExpando: true,
1406 inlineBlockNeedsLayout: false,
1407 shrinkWrapBlocks: false,
1408 reliableMarginRight: true
1411 // Make sure checked status is properly cloned
1412 input.checked = true;
1413 support.noCloneChecked = input.cloneNode( true ).checked;
1415 // Make sure that the options inside disabled selects aren't marked as disabled
1416 // (WebKit marks them as disabled)
1417 select.disabled = true;
1418 support.optDisabled = !opt.disabled;
1420 // Test to see if it's possible to delete an expando from an element
1421 // Fails in Internet Explorer
1425 support.deleteExpando = false;
1428 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1429 div.attachEvent( "onclick", function() {
1430 // Cloning a node shouldn't copy over any
1431 // bound event handlers (IE does this)
1432 support.noCloneEvent = false;
1434 div.cloneNode( true ).fireEvent( "onclick" );
1437 // Check if a radio maintains its value
1438 // after being appended to the DOM
1439 input = document.createElement("input");
1441 input.setAttribute("type", "radio");
1442 support.radioValue = input.value === "t";
1444 input.setAttribute("checked", "checked");
1445 div.appendChild( input );
1446 fragment = document.createDocumentFragment();
1447 fragment.appendChild( div.lastChild );
1449 // WebKit doesn't clone checked state correctly in fragments
1450 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1452 // Check if a disconnected checkbox will retain its checked
1453 // value of true after appended to the DOM (IE6/7)
1454 support.appendChecked = input.checked;
1456 fragment.removeChild( input );
1457 fragment.appendChild( div );
1461 // Check if div with explicit width and no margin-right incorrectly
1462 // gets computed margin-right based on width of container. For more
1463 // info see bug #3333
1464 // Fails in WebKit before Feb 2011 nightlies
1465 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1466 if ( window.getComputedStyle ) {
1467 marginDiv = document.createElement( "div" );
1468 marginDiv.style.width = "0";
1469 marginDiv.style.marginRight = "0";
1470 div.style.width = "2px";
1471 div.appendChild( marginDiv );
1472 support.reliableMarginRight =
1473 ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1476 // Technique from Juriy Zaytsev
1477 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1478 // We only care about the case where non-standard event systems
1479 // are used, namely in IE. Short-circuiting here helps us to
1480 // avoid an eval call (in setAttribute) which can cause CSP
1481 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1482 if ( div.attachEvent ) {
1488 eventName = "on" + i;
1489 isSupported = ( eventName in div );
1490 if ( !isSupported ) {
1491 div.setAttribute( eventName, "return;" );
1492 isSupported = ( typeof div[ eventName ] === "function" );
1494 support[ i + "Bubbles" ] = isSupported;
1498 fragment.removeChild( div );
1500 // Null elements to avoid leaks in IE
1501 fragment = select = opt = marginDiv = div = input = null;
1503 // Run tests that need a body at doc ready
1505 var container, outer, inner, table, td, offsetSupport,
1506 conMarginTop, ptlm, vb, style, html,
1507 body = document.getElementsByTagName("body")[0];
1510 // Return for frameset docs that don't have a body
1515 ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
1516 vb = "visibility:hidden;border:0;";
1517 style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
1518 html = "<div " + style + "><div></div></div>" +
1519 "<table " + style + " cellpadding='0' cellspacing='0'>" +
1520 "<tr><td></td></tr></table>";
1522 container = document.createElement("div");
1523 container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
1524 body.insertBefore( container, body.firstChild );
1526 // Construct the test element
1527 div = document.createElement("div");
1528 container.appendChild( div );
1530 // Check if table cells still have offsetWidth/Height when they are set
1531 // to display:none and there are still other visible table cells in a
1532 // table row; if so, offsetWidth/Height are not reliable for use when
1533 // determining if an element has been hidden directly using
1534 // display:none (it is still safe to use offsets if a parent element is
1535 // hidden; don safety goggles and see bug #4512 for more information).
1536 // (only IE 8 fails this test)
1537 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1538 tds = div.getElementsByTagName( "td" );
1539 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1541 tds[ 0 ].style.display = "";
1542 tds[ 1 ].style.display = "none";
1544 // Check if empty table cells still have offsetWidth/Height
1545 // (IE <= 8 fail this test)
1546 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1548 // Figure out if the W3C box model works as expected
1550 div.style.width = div.style.paddingLeft = "1px";
1551 jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
1553 if ( typeof div.style.zoom !== "undefined" ) {
1554 // Check if natively block-level elements act like inline-block
1555 // elements when setting their display to 'inline' and giving
1557 // (IE < 8 does this)
1558 div.style.display = "inline";
1560 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1562 // Check if elements with layout shrink-wrap their children
1564 div.style.display = "";
1565 div.innerHTML = "<div style='width:4px;'></div>";
1566 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1569 div.style.cssText = ptlm + vb;
1570 div.innerHTML = html;
1572 outer = div.firstChild;
1573 inner = outer.firstChild;
1574 td = outer.nextSibling.firstChild.firstChild;
1577 doesNotAddBorder: ( inner.offsetTop !== 5 ),
1578 doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
1581 inner.style.position = "fixed";
1582 inner.style.top = "20px";
1584 // safari subtracts parent border width here which is 5px
1585 offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
1586 inner.style.position = inner.style.top = "";
1588 outer.style.overflow = "hidden";
1589 outer.style.position = "relative";
1591 offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
1592 offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
1594 body.removeChild( container );
1595 div = container = null;
1597 jQuery.extend( support, offsetSupport );
1606 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1607 rmultiDash = /([A-Z])/g;
1612 // Please use with caution
1615 // Unique for each copy of jQuery on the page
1616 // Non-digits removed to match rinlinejQuery
1617 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1619 // The following elements throw uncatchable exceptions if you
1620 // attempt to add expando properties to them.
1623 // Ban all objects except for Flash (which handle expandos)
1624 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1628 hasData: function( elem ) {
1629 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1630 return !!elem && !isEmptyDataObject( elem );
1633 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1634 if ( !jQuery.acceptData( elem ) ) {
1638 var privateCache, thisCache, ret,
1639 internalKey = jQuery.expando,
1640 getByName = typeof name === "string",
1642 // We have to handle DOM nodes and JS objects differently because IE6-7
1643 // can't GC object references properly across the DOM-JS boundary
1644 isNode = elem.nodeType,
1646 // Only DOM nodes need the global jQuery cache; JS object data is
1647 // attached directly to the object so GC can occur automatically
1648 cache = isNode ? jQuery.cache : elem,
1650 // Only defining an ID for JS objects if its cache already exists allows
1651 // the code to shortcut on the same path as a DOM node with no cache
1652 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
1653 isEvents = name === "events";
1655 // Avoid doing any more work than we need to when trying to get data on an
1656 // object that has no data at all
1657 if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
1662 // Only DOM nodes need a new unique ID for each element since their data
1663 // ends up in the global cache
1665 elem[ internalKey ] = id = ++jQuery.uuid;
1671 if ( !cache[ id ] ) {
1674 // Avoids exposing jQuery metadata on plain JS objects when the object
1675 // is serialized using JSON.stringify
1677 cache[ id ].toJSON = jQuery.noop;
1681 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1682 // shallow copied over onto the existing cache
1683 if ( typeof name === "object" || typeof name === "function" ) {
1685 cache[ id ] = jQuery.extend( cache[ id ], name );
1687 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1691 privateCache = thisCache = cache[ id ];
1693 // jQuery data() is stored in a separate object inside the object's internal data
1694 // cache in order to avoid key collisions between internal data and user-defined
1697 if ( !thisCache.data ) {
1698 thisCache.data = {};
1701 thisCache = thisCache.data;
1704 if ( data !== undefined ) {
1705 thisCache[ jQuery.camelCase( name ) ] = data;
1708 // Users should not attempt to inspect the internal events object using jQuery.data,
1709 // it is undocumented and subject to change. But does anyone listen? No.
1710 if ( isEvents && !thisCache[ name ] ) {
1711 return privateCache.events;
1714 // Check for both converted-to-camel and non-converted data property names
1715 // If a data property was specified
1718 // First Try to find as-is property data
1719 ret = thisCache[ name ];
1721 // Test for null|undefined property data
1722 if ( ret == null ) {
1724 // Try to find the camelCased property
1725 ret = thisCache[ jQuery.camelCase( name ) ];
1734 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1735 if ( !jQuery.acceptData( elem ) ) {
1739 var thisCache, i, l,
1741 // Reference to internal data cache key
1742 internalKey = jQuery.expando,
1744 isNode = elem.nodeType,
1746 // See jQuery.data for more information
1747 cache = isNode ? jQuery.cache : elem,
1749 // See jQuery.data for more information
1750 id = isNode ? elem[ internalKey ] : internalKey;
1752 // If there is already no cache entry for this object, there is no
1753 // purpose in continuing
1754 if ( !cache[ id ] ) {
1760 thisCache = pvt ? cache[ id ] : cache[ id ].data;
1764 // Support array or space separated string names for data keys
1765 if ( !jQuery.isArray( name ) ) {
1767 // try the string as a key before any manipulation
1768 if ( name in thisCache ) {
1772 // split the camel cased version by spaces unless a key with the spaces exists
1773 name = jQuery.camelCase( name );
1774 if ( name in thisCache ) {
1777 name = name.split( " " );
1782 for ( i = 0, l = name.length; i < l; i++ ) {
1783 delete thisCache[ name[i] ];
1786 // If there is no data left in the cache, we want to continue
1787 // and let the cache object itself get destroyed
1788 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1794 // See jQuery.data for more information
1796 delete cache[ id ].data;
1798 // Don't destroy the parent cache unless the internal data object
1799 // had been the only thing left in it
1800 if ( !isEmptyDataObject(cache[ id ]) ) {
1805 // Browsers that fail expando deletion also refuse to delete expandos on
1806 // the window, but it will allow it on all other JS objects; other browsers
1808 // Ensure that `cache` is not a window object #10080
1809 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1815 // We destroyed the cache and need to eliminate the expando on the node to avoid
1816 // false lookups in the cache for entries that no longer exist
1818 // IE does not allow us to delete expando properties from nodes,
1819 // nor does it have a removeAttribute function on Document nodes;
1820 // we must handle all of these cases
1821 if ( jQuery.support.deleteExpando ) {
1822 delete elem[ internalKey ];
1823 } else if ( elem.removeAttribute ) {
1824 elem.removeAttribute( internalKey );
1826 elem[ internalKey ] = null;
1831 // For internal use only.
1832 _data: function( elem, name, data ) {
1833 return jQuery.data( elem, name, data, true );
1836 // A method for determining if a DOM node can handle the data expando
1837 acceptData: function( elem ) {
1838 if ( elem.nodeName ) {
1839 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1842 return !(match === true || elem.getAttribute("classid") !== match);
1851 data: function( key, value ) {
1852 var parts, attr, name,
1855 if ( typeof key === "undefined" ) {
1856 if ( this.length ) {
1857 data = jQuery.data( this[0] );
1859 if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
1860 attr = this[0].attributes;
1861 for ( var i = 0, l = attr.length; i < l; i++ ) {
1862 name = attr[i].name;
1864 if ( name.indexOf( "data-" ) === 0 ) {
1865 name = jQuery.camelCase( name.substring(5) );
1867 dataAttr( this[0], name, data[ name ] );
1870 jQuery._data( this[0], "parsedAttrs", true );
1876 } else if ( typeof key === "object" ) {
1877 return this.each(function() {
1878 jQuery.data( this, key );
1882 parts = key.split(".");
1883 parts[1] = parts[1] ? "." + parts[1] : "";
1885 if ( value === undefined ) {
1886 data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1888 // Try to fetch any internally stored data first
1889 if ( data === undefined && this.length ) {
1890 data = jQuery.data( this[0], key );
1891 data = dataAttr( this[0], key, data );
1894 return data === undefined && parts[1] ?
1895 this.data( parts[0] ) :
1899 return this.each(function() {
1900 var self = jQuery( this ),
1901 args = [ parts[0], value ];
1903 self.triggerHandler( "setData" + parts[1] + "!", args );
1904 jQuery.data( this, key, value );
1905 self.triggerHandler( "changeData" + parts[1] + "!", args );
1910 removeData: function( key ) {
1911 return this.each(function() {
1912 jQuery.removeData( this, key );
1917 function dataAttr( elem, key, data ) {
1918 // If nothing was found internally, try to fetch any
1919 // data from the HTML5 data-* attribute
1920 if ( data === undefined && elem.nodeType === 1 ) {
1922 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1924 data = elem.getAttribute( name );
1926 if ( typeof data === "string" ) {
1928 data = data === "true" ? true :
1929 data === "false" ? false :
1930 data === "null" ? null :
1931 jQuery.isNumeric( data ) ? parseFloat( data ) :
1932 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1936 // Make sure we set the data so it isn't changed later
1937 jQuery.data( elem, key, data );
1947 // checks a cache object for emptiness
1948 function isEmptyDataObject( obj ) {
1949 for ( var name in obj ) {
1951 // if the public data object is empty, the private is still empty
1952 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1955 if ( name !== "toJSON" ) {
1966 function handleQueueMarkDefer( elem, type, src ) {
1967 var deferDataKey = type + "defer",
1968 queueDataKey = type + "queue",
1969 markDataKey = type + "mark",
1970 defer = jQuery._data( elem, deferDataKey );
1972 ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
1973 ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
1974 // Give room for hard-coded callbacks to fire first
1975 // and eventually mark/queue something else on the element
1976 setTimeout( function() {
1977 if ( !jQuery._data( elem, queueDataKey ) &&
1978 !jQuery._data( elem, markDataKey ) ) {
1979 jQuery.removeData( elem, deferDataKey, true );
1988 _mark: function( elem, type ) {
1990 type = ( type || "fx" ) + "mark";
1991 jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
1995 _unmark: function( force, elem, type ) {
1996 if ( force !== true ) {
2002 type = type || "fx";
2003 var key = type + "mark",
2004 count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
2006 jQuery._data( elem, key, count );
2008 jQuery.removeData( elem, key, true );
2009 handleQueueMarkDefer( elem, type, "mark" );
2014 queue: function( elem, type, data ) {
2017 type = ( type || "fx" ) + "queue";
2018 q = jQuery._data( elem, type );
2020 // Speed up dequeue by getting out quickly if this is just a lookup
2022 if ( !q || jQuery.isArray(data) ) {
2023 q = jQuery._data( elem, type, jQuery.makeArray(data) );
2032 dequeue: function( elem, type ) {
2033 type = type || "fx";
2035 var queue = jQuery.queue( elem, type ),
2039 // If the fx queue is dequeued, always remove the progress sentinel
2040 if ( fn === "inprogress" ) {
2045 // Add a progress sentinel to prevent the fx queue from being
2046 // automatically dequeued
2047 if ( type === "fx" ) {
2048 queue.unshift( "inprogress" );
2051 jQuery._data( elem, type + ".run", hooks );
2052 fn.call( elem, function() {
2053 jQuery.dequeue( elem, type );
2057 if ( !queue.length ) {
2058 jQuery.removeData( elem, type + "queue " + type + ".run", true );
2059 handleQueueMarkDefer( elem, type, "queue" );
2065 queue: function( type, data ) {
2066 if ( typeof type !== "string" ) {
2071 if ( data === undefined ) {
2072 return jQuery.queue( this[0], type );
2074 return this.each(function() {
2075 var queue = jQuery.queue( this, type, data );
2077 if ( type === "fx" && queue[0] !== "inprogress" ) {
2078 jQuery.dequeue( this, type );
2082 dequeue: function( type ) {
2083 return this.each(function() {
2084 jQuery.dequeue( this, type );
2087 // Based off of the plugin by Clint Helfers, with permission.
2088 // http://blindsignals.com/index.php/2009/07/jquery-delay/
2089 delay: function( time, type ) {
2090 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
2091 type = type || "fx";
2093 return this.queue( type, function( next, hooks ) {
2094 var timeout = setTimeout( next, time );
2095 hooks.stop = function() {
2096 clearTimeout( timeout );
2100 clearQueue: function( type ) {
2101 return this.queue( type || "fx", [] );
2103 // Get a promise resolved when queues of a certain type
2104 // are emptied (fx is the type by default)
2105 promise: function( type, object ) {
2106 if ( typeof type !== "string" ) {
2110 type = type || "fx";
2111 var defer = jQuery.Deferred(),
2113 i = elements.length,
2115 deferDataKey = type + "defer",
2116 queueDataKey = type + "queue",
2117 markDataKey = type + "mark",
2119 function resolve() {
2120 if ( !( --count ) ) {
2121 defer.resolveWith( elements, [ elements ] );
2125 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
2126 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
2127 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
2128 jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
2134 return defer.promise();
2141 var rclass = /[\n\t\r]/g,
2144 rtype = /^(?:button|input)$/i,
2145 rfocusable = /^(?:button|input|object|select|textarea)$/i,
2146 rclickable = /^a(?:rea)?$/i,
2147 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2148 getSetAttribute = jQuery.support.getSetAttribute,
2149 nodeHook, boolHook, fixSpecified;
2152 attr: function( name, value ) {
2153 return jQuery.access( this, name, value, true, jQuery.attr );
2156 removeAttr: function( name ) {
2157 return this.each(function() {
2158 jQuery.removeAttr( this, name );
2162 prop: function( name, value ) {
2163 return jQuery.access( this, name, value, true, jQuery.prop );
2166 removeProp: function( name ) {
2167 name = jQuery.propFix[ name ] || name;
2168 return this.each(function() {
2169 // try/catch handles cases where IE balks (such as removing a property on window)
2171 this[ name ] = undefined;
2172 delete this[ name ];
2177 addClass: function( value ) {
2178 var classNames, i, l, elem,
2181 if ( jQuery.isFunction( value ) ) {
2182 return this.each(function( j ) {
2183 jQuery( this ).addClass( value.call(this, j, this.className) );
2187 if ( value && typeof value === "string" ) {
2188 classNames = value.split( rspace );
2190 for ( i = 0, l = this.length; i < l; i++ ) {
2193 if ( elem.nodeType === 1 ) {
2194 if ( !elem.className && classNames.length === 1 ) {
2195 elem.className = value;
2198 setClass = " " + elem.className + " ";
2200 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2201 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2202 setClass += classNames[ c ] + " ";
2205 elem.className = jQuery.trim( setClass );
2214 removeClass: function( value ) {
2215 var classNames, i, l, elem, className, c, cl;
2217 if ( jQuery.isFunction( value ) ) {
2218 return this.each(function( j ) {
2219 jQuery( this ).removeClass( value.call(this, j, this.className) );
2223 if ( (value && typeof value === "string") || value === undefined ) {
2224 classNames = ( value || "" ).split( rspace );
2226 for ( i = 0, l = this.length; i < l; i++ ) {
2229 if ( elem.nodeType === 1 && elem.className ) {
2231 className = (" " + elem.className + " ").replace( rclass, " " );
2232 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2233 className = className.replace(" " + classNames[ c ] + " ", " ");
2235 elem.className = jQuery.trim( className );
2238 elem.className = "";
2247 toggleClass: function( value, stateVal ) {
2248 var type = typeof value,
2249 isBool = typeof stateVal === "boolean";
2251 if ( jQuery.isFunction( value ) ) {
2252 return this.each(function( i ) {
2253 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2257 return this.each(function() {
2258 if ( type === "string" ) {
2259 // toggle individual class names
2262 self = jQuery( this ),
2264 classNames = value.split( rspace );
2266 while ( (className = classNames[ i++ ]) ) {
2267 // check each className given, space seperated list
2268 state = isBool ? state : !self.hasClass( className );
2269 self[ state ? "addClass" : "removeClass" ]( className );
2272 } else if ( type === "undefined" || type === "boolean" ) {
2273 if ( this.className ) {
2274 // store className if set
2275 jQuery._data( this, "__className__", this.className );
2278 // toggle whole className
2279 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2284 hasClass: function( selector ) {
2285 var className = " " + selector + " ",
2288 for ( ; i < l; i++ ) {
2289 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2297 val: function( value ) {
2298 var hooks, ret, isFunction,
2301 if ( !arguments.length ) {
2303 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2305 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2311 return typeof ret === "string" ?
2312 // handle most common string cases
2313 ret.replace(rreturn, "") :
2314 // handle cases where value is null/undef or number
2315 ret == null ? "" : ret;
2321 isFunction = jQuery.isFunction( value );
2323 return this.each(function( i ) {
2324 var self = jQuery(this), val;
2326 if ( this.nodeType !== 1 ) {
2331 val = value.call( this, i, self.val() );
2336 // Treat null/undefined as ""; convert numbers to string
2337 if ( val == null ) {
2339 } else if ( typeof val === "number" ) {
2341 } else if ( jQuery.isArray( val ) ) {
2342 val = jQuery.map(val, function ( value ) {
2343 return value == null ? "" : value + "";
2347 hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2349 // If set returns undefined, fall back to normal setting
2350 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2360 get: function( elem ) {
2361 // attributes.value is undefined in Blackberry 4.7 but
2362 // uses .value. See #6932
2363 var val = elem.attributes.value;
2364 return !val || val.specified ? elem.value : elem.text;
2368 get: function( elem ) {
2369 var value, i, max, option,
2370 index = elem.selectedIndex,
2372 options = elem.options,
2373 one = elem.type === "select-one";
2375 // Nothing was selected
2380 // Loop through all the selected options
2381 i = one ? index : 0;
2382 max = one ? index + 1 : options.length;
2383 for ( ; i < max; i++ ) {
2384 option = options[ i ];
2386 // Don't return options that are disabled or in a disabled optgroup
2387 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2388 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2390 // Get the specific value for the option
2391 value = jQuery( option ).val();
2393 // We don't need an array for one selects
2398 // Multi-Selects return an array
2399 values.push( value );
2403 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2404 if ( one && !values.length && options.length ) {
2405 return jQuery( options[ index ] ).val();
2411 set: function( elem, value ) {
2412 var values = jQuery.makeArray( value );
2414 jQuery(elem).find("option").each(function() {
2415 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2418 if ( !values.length ) {
2419 elem.selectedIndex = -1;
2437 attr: function( elem, name, value, pass ) {
2438 var ret, hooks, notxml,
2439 nType = elem.nodeType;
2441 // don't get/set attributes on text, comment and attribute nodes
2442 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2446 if ( pass && name in jQuery.attrFn ) {
2447 return jQuery( elem )[ name ]( value );
2450 // Fallback to prop when attributes are not supported
2451 if ( typeof elem.getAttribute === "undefined" ) {
2452 return jQuery.prop( elem, name, value );
2455 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2457 // All attributes are lowercase
2458 // Grab necessary hook if one is defined
2460 name = name.toLowerCase();
2461 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2464 if ( value !== undefined ) {
2466 if ( value === null ) {
2467 jQuery.removeAttr( elem, name );
2470 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2474 elem.setAttribute( name, "" + value );
2478 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2483 ret = elem.getAttribute( name );
2485 // Non-existent attributes return null, we normalize to undefined
2486 return ret === null ?
2492 removeAttr: function( elem, value ) {
2493 var propName, attrNames, name, l,
2496 if ( value && elem.nodeType === 1 ) {
2497 attrNames = value.toLowerCase().split( rspace );
2498 l = attrNames.length;
2500 for ( ; i < l; i++ ) {
2501 name = attrNames[ i ];
2504 propName = jQuery.propFix[ name ] || name;
2506 // See #9699 for explanation of this approach (setting first, then removal)
2507 jQuery.attr( elem, name, "" );
2508 elem.removeAttribute( getSetAttribute ? name : propName );
2510 // Set corresponding property to false for boolean attributes
2511 if ( rboolean.test( name ) && propName in elem ) {
2512 elem[ propName ] = false;
2521 set: function( elem, value ) {
2522 // We can't allow the type property to be changed (since it causes problems in IE)
2523 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2524 jQuery.error( "type property can't be changed" );
2525 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2526 // Setting the type on a radio button after the value resets the value in IE6-9
2527 // Reset value to it's default in case type is set after value
2528 // This is for element creation
2529 var val = elem.value;
2530 elem.setAttribute( "type", value );
2538 // Use the value property for back compat
2539 // Use the nodeHook for button elements in IE6/7 (#1954)
2541 get: function( elem, name ) {
2542 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2543 return nodeHook.get( elem, name );
2545 return name in elem ?
2549 set: function( elem, value, name ) {
2550 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2551 return nodeHook.set( elem, value, name );
2553 // Does not return so that setAttribute is also used
2560 tabindex: "tabIndex",
2561 readonly: "readOnly",
2563 "class": "className",
2564 maxlength: "maxLength",
2565 cellspacing: "cellSpacing",
2566 cellpadding: "cellPadding",
2570 frameborder: "frameBorder",
2571 contenteditable: "contentEditable"
2574 prop: function( elem, name, value ) {
2575 var ret, hooks, notxml,
2576 nType = elem.nodeType;
2578 // don't get/set properties on text, comment and attribute nodes
2579 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2583 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2586 // Fix name and attach hooks
2587 name = jQuery.propFix[ name ] || name;
2588 hooks = jQuery.propHooks[ name ];
2591 if ( value !== undefined ) {
2592 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2596 return ( elem[ name ] = value );
2600 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2604 return elem[ name ];
2611 get: function( elem ) {
2612 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2613 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2614 var attributeNode = elem.getAttributeNode("tabindex");
2616 return attributeNode && attributeNode.specified ?
2617 parseInt( attributeNode.value, 10 ) :
2618 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2626 // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
2627 jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
2629 // Hook for boolean attributes
2631 get: function( elem, name ) {
2632 // Align boolean attributes with corresponding properties
2633 // Fall back to attribute presence where some booleans are not supported
2635 property = jQuery.prop( elem, name );
2636 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2637 name.toLowerCase() :
2640 set: function( elem, value, name ) {
2642 if ( value === false ) {
2643 // Remove boolean attributes when set to false
2644 jQuery.removeAttr( elem, name );
2646 // value is true since we know at this point it's type boolean and not false
2647 // Set boolean attributes to the same name and set the DOM property
2648 propName = jQuery.propFix[ name ] || name;
2649 if ( propName in elem ) {
2650 // Only set the IDL specifically if it already exists on the element
2651 elem[ propName ] = true;
2654 elem.setAttribute( name, name.toLowerCase() );
2660 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2661 if ( !getSetAttribute ) {
2668 // Use this for any attribute in IE6/7
2669 // This fixes almost every IE6/7 issue
2670 nodeHook = jQuery.valHooks.button = {
2671 get: function( elem, name ) {
2673 ret = elem.getAttributeNode( name );
2674 return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
2678 set: function( elem, value, name ) {
2679 // Set the existing or create a new attribute node
2680 var ret = elem.getAttributeNode( name );
2682 ret = document.createAttribute( name );
2683 elem.setAttributeNode( ret );
2685 return ( ret.nodeValue = value + "" );
2689 // Apply the nodeHook to tabindex
2690 jQuery.attrHooks.tabindex.set = nodeHook.set;
2692 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2693 // This is for removals
2694 jQuery.each([ "width", "height" ], function( i, name ) {
2695 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2696 set: function( elem, value ) {
2697 if ( value === "" ) {
2698 elem.setAttribute( name, "auto" );
2705 // Set contenteditable to false on removals(#10429)
2706 // Setting to empty string throws an error as an invalid value
2707 jQuery.attrHooks.contenteditable = {
2709 set: function( elem, value, name ) {
2710 if ( value === "" ) {
2713 nodeHook.set( elem, value, name );
2719 // Some attributes require a special call on IE
2720 if ( !jQuery.support.hrefNormalized ) {
2721 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2722 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2723 get: function( elem ) {
2724 var ret = elem.getAttribute( name, 2 );
2725 return ret === null ? undefined : ret;
2731 if ( !jQuery.support.style ) {
2732 jQuery.attrHooks.style = {
2733 get: function( elem ) {
2734 // Return undefined in the case of empty string
2735 // Normalize to lowercase since IE uppercases css property names
2736 return elem.style.cssText.toLowerCase() || undefined;
2738 set: function( elem, value ) {
2739 return ( elem.style.cssText = "" + value );
2744 // Safari mis-reports the default selected property of an option
2745 // Accessing the parent's selectedIndex property fixes it
2746 if ( !jQuery.support.optSelected ) {
2747 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2748 get: function( elem ) {
2749 var parent = elem.parentNode;
2752 parent.selectedIndex;
2754 // Make sure that it also works with optgroups, see #5701
2755 if ( parent.parentNode ) {
2756 parent.parentNode.selectedIndex;
2764 // IE6/7 call enctype encoding
2765 if ( !jQuery.support.enctype ) {
2766 jQuery.propFix.enctype = "encoding";
2769 // Radios and checkboxes getter/setter
2770 if ( !jQuery.support.checkOn ) {
2771 jQuery.each([ "radio", "checkbox" ], function() {
2772 jQuery.valHooks[ this ] = {
2773 get: function( elem ) {
2774 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2775 return elem.getAttribute("value") === null ? "on" : elem.value;
2780 jQuery.each([ "radio", "checkbox" ], function() {
2781 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2782 set: function( elem, value ) {
2783 if ( jQuery.isArray( value ) ) {
2784 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2793 var rformElems = /^(?:textarea|input|select)$/i,
2794 rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
2795 rhoverHack = /\bhover(\.\S+)?\b/,
2797 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2798 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2799 rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
2800 quickParse = function( selector ) {
2801 var quick = rquickIs.exec( selector );
2804 // [ _, tag, id, class ]
2805 quick[1] = ( quick[1] || "" ).toLowerCase();
2806 quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
2810 quickIs = function( elem, m ) {
2811 var attrs = elem.attributes || {};
2813 (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
2814 (!m[2] || (attrs.id || {}).value === m[2]) &&
2815 (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
2818 hoverHack = function( events ) {
2819 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2823 * Helper functions for managing events -- not part of the public interface.
2824 * Props to Dean Edwards' addEvent library for many of the ideas.
2828 add: function( elem, types, handler, data, selector ) {
2830 var elemData, eventHandle, events,
2831 t, tns, type, namespaces, handleObj,
2832 handleObjIn, quick, handlers, special;
2834 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2835 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2839 // Caller can pass in an object of custom data in lieu of the handler
2840 if ( handler.handler ) {
2841 handleObjIn = handler;
2842 handler = handleObjIn.handler;
2845 // Make sure that the handler has a unique ID, used to find/remove it later
2846 if ( !handler.guid ) {
2847 handler.guid = jQuery.guid++;
2850 // Init the element's event structure and main handler, if this is the first
2851 events = elemData.events;
2853 elemData.events = events = {};
2855 eventHandle = elemData.handle;
2856 if ( !eventHandle ) {
2857 elemData.handle = eventHandle = function( e ) {
2858 // Discard the second event of a jQuery.event.trigger() and
2859 // when an event is called after a page has unloaded
2860 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2861 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2864 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2865 eventHandle.elem = elem;
2868 // Handle multiple events separated by a space
2869 // jQuery(...).bind("mouseover mouseout", fn);
2870 types = jQuery.trim( hoverHack(types) ).split( " " );
2871 for ( t = 0; t < types.length; t++ ) {
2873 tns = rtypenamespace.exec( types[t] ) || [];
2875 namespaces = ( tns[2] || "" ).split( "." ).sort();
2877 // If event changes its type, use the special event handlers for the changed type
2878 special = jQuery.event.special[ type ] || {};
2880 // If selector defined, determine special event api type, otherwise given type
2881 type = ( selector ? special.delegateType : special.bindType ) || type;
2883 // Update special based on newly reset type
2884 special = jQuery.event.special[ type ] || {};
2886 // handleObj is passed to all event handlers
2887 handleObj = jQuery.extend({
2894 quick: quickParse( selector ),
2895 namespace: namespaces.join(".")
2898 // Init the event handler queue if we're the first
2899 handlers = events[ type ];
2901 handlers = events[ type ] = [];
2902 handlers.delegateCount = 0;
2904 // Only use addEventListener/attachEvent if the special events handler returns false
2905 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2906 // Bind the global event handler to the element
2907 if ( elem.addEventListener ) {
2908 elem.addEventListener( type, eventHandle, false );
2910 } else if ( elem.attachEvent ) {
2911 elem.attachEvent( "on" + type, eventHandle );
2916 if ( special.add ) {
2917 special.add.call( elem, handleObj );
2919 if ( !handleObj.handler.guid ) {
2920 handleObj.handler.guid = handler.guid;
2924 // Add to the element's handler list, delegates in front
2926 handlers.splice( handlers.delegateCount++, 0, handleObj );
2928 handlers.push( handleObj );
2931 // Keep track of which events have ever been used, for event optimization
2932 jQuery.event.global[ type ] = true;
2935 // Nullify elem to prevent memory leaks in IE
2941 // Detach an event or set of events from an element
2942 remove: function( elem, types, handler, selector, mappedTypes ) {
2944 var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2945 t, tns, type, origType, namespaces, origCount,
2946 j, events, special, handle, eventType, handleObj;
2948 if ( !elemData || !(events = elemData.events) ) {
2952 // Once for each type.namespace in types; type may be omitted
2953 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
2954 for ( t = 0; t < types.length; t++ ) {
2955 tns = rtypenamespace.exec( types[t] ) || [];
2956 type = origType = tns[1];
2957 namespaces = tns[2];
2959 // Unbind all events (on this namespace, if provided) for the element
2961 for ( type in events ) {
2962 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2967 special = jQuery.event.special[ type ] || {};
2968 type = ( selector? special.delegateType : special.bindType ) || type;
2969 eventType = events[ type ] || [];
2970 origCount = eventType.length;
2971 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
2973 // Remove matching events
2974 for ( j = 0; j < eventType.length; j++ ) {
2975 handleObj = eventType[ j ];
2977 if ( ( mappedTypes || origType === handleObj.origType ) &&
2978 ( !handler || handler.guid === handleObj.guid ) &&
2979 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
2980 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2981 eventType.splice( j--, 1 );
2983 if ( handleObj.selector ) {
2984 eventType.delegateCount--;
2986 if ( special.remove ) {
2987 special.remove.call( elem, handleObj );
2992 // Remove generic event handler if we removed something and no more handlers exist
2993 // (avoids potential for endless recursion during removal of special event handlers)
2994 if ( eventType.length === 0 && origCount !== eventType.length ) {
2995 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2996 jQuery.removeEvent( elem, type, elemData.handle );
2999 delete events[ type ];
3003 // Remove the expando if it's no longer used
3004 if ( jQuery.isEmptyObject( events ) ) {
3005 handle = elemData.handle;
3010 // removeData also checks for emptiness and clears the expando if empty
3011 // so use it instead of delete
3012 jQuery.removeData( elem, [ "events", "handle" ], true );
3016 // Events that are safe to short-circuit if no handlers are attached.
3017 // Native DOM events should not be added, they may have inline handlers.
3024 trigger: function( event, data, elem, onlyHandlers ) {
3025 // Don't do events on text and comment nodes
3026 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
3030 // Event object or event type
3031 var type = event.type || event,
3033 cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
3035 // focus/blur morphs to focusin/out; ensure we're not firing them right now
3036 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
3040 if ( type.indexOf( "!" ) >= 0 ) {
3041 // Exclusive events trigger only for the exact event (no namespaces)
3042 type = type.slice(0, -1);
3046 if ( type.indexOf( "." ) >= 0 ) {
3047 // Namespaced trigger; create a regexp to match event type in handle()
3048 namespaces = type.split(".");
3049 type = namespaces.shift();
3053 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
3054 // No jQuery handlers for this event type, and it can't have inline handlers
3058 // Caller can pass in an Event, Object, or just an event type string
3059 event = typeof event === "object" ?
3060 // jQuery.Event object
3061 event[ jQuery.expando ] ? event :
3063 new jQuery.Event( type, event ) :
3064 // Just the event type (string)
3065 new jQuery.Event( type );
3068 event.isTrigger = true;
3069 event.exclusive = exclusive;
3070 event.namespace = namespaces.join( "." );
3071 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3072 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
3074 // Handle a global trigger
3077 // TODO: Stop taunting the data cache; remove global events and always attach to document
3078 cache = jQuery.cache;
3079 for ( i in cache ) {
3080 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
3081 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
3087 // Clean up the event in case it is being reused
3088 event.result = undefined;
3089 if ( !event.target ) {
3090 event.target = elem;
3093 // Clone any incoming data and prepend the event, creating the handler arg list
3094 data = data != null ? jQuery.makeArray( data ) : [];
3095 data.unshift( event );
3097 // Allow special events to draw outside the lines
3098 special = jQuery.event.special[ type ] || {};
3099 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
3103 // Determine event propagation path in advance, per W3C events spec (#9951)
3104 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
3105 eventPath = [[ elem, special.bindType || type ]];
3106 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
3108 bubbleType = special.delegateType || type;
3109 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
3111 for ( ; cur; cur = cur.parentNode ) {
3112 eventPath.push([ cur, bubbleType ]);
3116 // Only add window if we got to document (e.g., not plain obj or detached DOM)
3117 if ( old && old === elem.ownerDocument ) {
3118 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
3122 // Fire handlers on the event path
3123 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
3125 cur = eventPath[i][0];
3126 event.type = eventPath[i][1];
3128 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
3130 handle.apply( cur, data );
3132 // Note that this is a bare JS function and not a jQuery handler
3133 handle = ontype && cur[ ontype ];
3134 if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
3135 event.preventDefault();
3140 // If nobody prevented the default action, do it now
3141 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
3143 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
3144 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
3146 // Call a native DOM method on the target with the same name name as the event.
3147 // Can't use an .isFunction() check here because IE6/7 fails that test.
3148 // Don't do default actions on window, that's where global variables be (#6170)
3149 // IE<9 dies on focus/blur to hidden element (#1486)
3150 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
3152 // Don't re-trigger an onFOO event when we call its FOO() method
3153 old = elem[ ontype ];
3156 elem[ ontype ] = null;
3159 // Prevent re-triggering of the same event, since we already bubbled it above
3160 jQuery.event.triggered = type;
3162 jQuery.event.triggered = undefined;
3165 elem[ ontype ] = old;
3171 return event.result;
3174 dispatch: function( event ) {
3176 // Make a writable jQuery.Event from the native event object
3177 event = jQuery.event.fix( event || window.event );
3179 var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
3180 delegateCount = handlers.delegateCount,
3181 args = [].slice.call( arguments, 0 ),
3182 run_all = !event.exclusive && !event.namespace,
3184 i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
3186 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3188 event.delegateTarget = this;
3190 // Determine handlers that should run if there are delegated events
3191 // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
3192 if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
3194 // Pregenerate a single jQuery object for reuse with .is()
3195 jqcur = jQuery(this);
3196 jqcur.context = this.ownerDocument || this;
3198 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3202 for ( i = 0; i < delegateCount; i++ ) {
3203 handleObj = handlers[ i ];
3204 sel = handleObj.selector;
3206 if ( selMatch[ sel ] === undefined ) {
3208 handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
3211 if ( selMatch[ sel ] ) {
3212 matches.push( handleObj );
3215 if ( matches.length ) {
3216 handlerQueue.push({ elem: cur, matches: matches });
3221 // Add the remaining (directly-bound) handlers
3222 if ( handlers.length > delegateCount ) {
3223 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3226 // Run delegates first; they may want to stop propagation beneath us
3227 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3228 matched = handlerQueue[ i ];
3229 event.currentTarget = matched.elem;
3231 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3232 handleObj = matched.matches[ j ];
3234 // Triggered event must either 1) be non-exclusive and have no namespace, or
3235 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3236 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3238 event.data = handleObj.data;
3239 event.handleObj = handleObj;
3241 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3242 .apply( matched.elem, args );
3244 if ( ret !== undefined ) {
3246 if ( ret === false ) {
3247 event.preventDefault();
3248 event.stopPropagation();
3255 return event.result;
3258 // Includes some event props shared by KeyEvent and MouseEvent
3259 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3260 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3265 props: "char charCode key keyCode".split(" "),
3266 filter: function( event, original ) {
3268 // Add which for key events
3269 if ( event.which == null ) {
3270 event.which = original.charCode != null ? original.charCode : original.keyCode;
3278 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3279 filter: function( event, original ) {
3280 var eventDoc, doc, body,
3281 button = original.button,
3282 fromElement = original.fromElement;
3284 // Calculate pageX/Y if missing and clientX/Y available
3285 if ( event.pageX == null && original.clientX != null ) {
3286 eventDoc = event.target.ownerDocument || document;
3287 doc = eventDoc.documentElement;
3288 body = eventDoc.body;
3290 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3291 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3294 // Add relatedTarget, if necessary
3295 if ( !event.relatedTarget && fromElement ) {
3296 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3299 // Add which for click: 1 === left; 2 === middle; 3 === right
3300 // Note: button is not normalized, so don't use it
3301 if ( !event.which && button !== undefined ) {
3302 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3309 fix: function( event ) {
3310 if ( event[ jQuery.expando ] ) {
3314 // Create a writable copy of the event object and normalize some properties
3316 originalEvent = event,
3317 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3318 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3320 event = jQuery.Event( originalEvent );
3322 for ( i = copy.length; i; ) {
3324 event[ prop ] = originalEvent[ prop ];
3327 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3328 if ( !event.target ) {
3329 event.target = originalEvent.srcElement || document;
3332 // Target should not be a text node (#504, Safari)
3333 if ( event.target.nodeType === 3 ) {
3334 event.target = event.target.parentNode;
3337 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
3338 if ( event.metaKey === undefined ) {
3339 event.metaKey = event.ctrlKey;
3342 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3347 // Make sure the ready event is setup
3348 setup: jQuery.bindReady
3352 // Prevent triggered image.load events from bubbling to window.load
3357 delegateType: "focusin"
3360 delegateType: "focusout"
3364 setup: function( data, namespaces, eventHandle ) {
3365 // We only want to do this special case on windows
3366 if ( jQuery.isWindow( this ) ) {
3367 this.onbeforeunload = eventHandle;
3371 teardown: function( namespaces, eventHandle ) {
3372 if ( this.onbeforeunload === eventHandle ) {
3373 this.onbeforeunload = null;
3379 simulate: function( type, elem, event, bubble ) {
3380 // Piggyback on a donor event to simulate a different one.
3381 // Fake originalEvent to avoid donor's stopPropagation, but if the
3382 // simulated event prevents default then we do the same on the donor.
3383 var e = jQuery.extend(
3392 jQuery.event.trigger( e, null, elem );
3394 jQuery.event.dispatch.call( elem, e );
3396 if ( e.isDefaultPrevented() ) {
3397 event.preventDefault();
3402 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3403 // The 1.7 special event interface should provide all the hooks needed now.
3404 jQuery.event.handle = jQuery.event.dispatch;
3406 jQuery.removeEvent = document.removeEventListener ?
3407 function( elem, type, handle ) {
3408 if ( elem.removeEventListener ) {
3409 elem.removeEventListener( type, handle, false );
3412 function( elem, type, handle ) {
3413 if ( elem.detachEvent ) {
3414 elem.detachEvent( "on" + type, handle );
3418 jQuery.Event = function( src, props ) {
3419 // Allow instantiation without the 'new' keyword
3420 if ( !(this instanceof jQuery.Event) ) {
3421 return new jQuery.Event( src, props );
3425 if ( src && src.type ) {
3426 this.originalEvent = src;
3427 this.type = src.type;
3429 // Events bubbling up the document may have been marked as prevented
3430 // by a handler lower down the tree; reflect the correct value.
3431 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3432 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3439 // Put explicitly provided properties onto the event object
3441 jQuery.extend( this, props );
3444 // Create a timestamp if incoming event doesn't have one
3445 this.timeStamp = src && src.timeStamp || jQuery.now();
3448 this[ jQuery.expando ] = true;
3451 function returnFalse() {
3454 function returnTrue() {
3458 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3459 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3460 jQuery.Event.prototype = {
3461 preventDefault: function() {
3462 this.isDefaultPrevented = returnTrue;
3464 var e = this.originalEvent;
3469 // if preventDefault exists run it on the original event
3470 if ( e.preventDefault ) {
3473 // otherwise set the returnValue property of the original event to false (IE)
3475 e.returnValue = false;
3478 stopPropagation: function() {
3479 this.isPropagationStopped = returnTrue;
3481 var e = this.originalEvent;
3485 // if stopPropagation exists run it on the original event
3486 if ( e.stopPropagation ) {
3487 e.stopPropagation();
3489 // otherwise set the cancelBubble property of the original event to true (IE)
3490 e.cancelBubble = true;
3492 stopImmediatePropagation: function() {
3493 this.isImmediatePropagationStopped = returnTrue;
3494 this.stopPropagation();
3496 isDefaultPrevented: returnFalse,
3497 isPropagationStopped: returnFalse,
3498 isImmediatePropagationStopped: returnFalse
3501 // Create mouseenter/leave events using mouseover/out and event-time checks
3503 mouseenter: "mouseover",
3504 mouseleave: "mouseout"
3505 }, function( orig, fix ) {
3506 jQuery.event.special[ orig ] = {
3510 handle: function( event ) {
3512 related = event.relatedTarget,
3513 handleObj = event.handleObj,
3514 selector = handleObj.selector,
3517 // For mousenter/leave call the handler if related is outside the target.
3518 // NB: No relatedTarget if the mouse left/entered the browser window
3519 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3520 event.type = handleObj.origType;
3521 ret = handleObj.handler.apply( this, arguments );
3529 // IE submit delegation
3530 if ( !jQuery.support.submitBubbles ) {
3532 jQuery.event.special.submit = {
3534 // Only need this for delegated form submit events
3535 if ( jQuery.nodeName( this, "form" ) ) {
3539 // Lazy-add a submit handler when a descendant form may potentially be submitted
3540 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3541 // Node name check avoids a VML-related crash in IE (#9807)
3542 var elem = e.target,
3543 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3544 if ( form && !form._submit_attached ) {
3545 jQuery.event.add( form, "submit._submit", function( event ) {
3546 // If form was submitted by the user, bubble the event up the tree
3547 if ( this.parentNode && !event.isTrigger ) {
3548 jQuery.event.simulate( "submit", this.parentNode, event, true );
3551 form._submit_attached = true;
3554 // return undefined since we don't need an event listener
3557 teardown: function() {
3558 // Only need this for delegated form submit events
3559 if ( jQuery.nodeName( this, "form" ) ) {
3563 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3564 jQuery.event.remove( this, "._submit" );
3569 // IE change delegation and checkbox/radio fix
3570 if ( !jQuery.support.changeBubbles ) {
3572 jQuery.event.special.change = {
3576 if ( rformElems.test( this.nodeName ) ) {
3577 // IE doesn't fire change on a check/radio until blur; trigger it on click
3578 // after a propertychange. Eat the blur-change in special.change.handle.
3579 // This still fires onchange a second time for check/radio after blur.
3580 if ( this.type === "checkbox" || this.type === "radio" ) {
3581 jQuery.event.add( this, "propertychange._change", function( event ) {
3582 if ( event.originalEvent.propertyName === "checked" ) {
3583 this._just_changed = true;
3586 jQuery.event.add( this, "click._change", function( event ) {
3587 if ( this._just_changed && !event.isTrigger ) {
3588 this._just_changed = false;
3589 jQuery.event.simulate( "change", this, event, true );
3595 // Delegated event; lazy-add a change handler on descendant inputs
3596 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3597 var elem = e.target;
3599 if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
3600 jQuery.event.add( elem, "change._change", function( event ) {
3601 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3602 jQuery.event.simulate( "change", this.parentNode, event, true );
3605 elem._change_attached = true;
3610 handle: function( event ) {
3611 var elem = event.target;
3613 // Swallow native change events from checkbox/radio, we already triggered them above
3614 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3615 return event.handleObj.handler.apply( this, arguments );
3619 teardown: function() {
3620 jQuery.event.remove( this, "._change" );
3622 return rformElems.test( this.nodeName );
3627 // Create "bubbling" focus and blur events
3628 if ( !jQuery.support.focusinBubbles ) {
3629 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3631 // Attach a single capturing handler while someone wants focusin/focusout
3633 handler = function( event ) {
3634 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3637 jQuery.event.special[ fix ] = {
3639 if ( attaches++ === 0 ) {
3640 document.addEventListener( orig, handler, true );
3643 teardown: function() {
3644 if ( --attaches === 0 ) {
3645 document.removeEventListener( orig, handler, true );
3654 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3657 // Types can be a map of types/handlers
3658 if ( typeof types === "object" ) {
3659 // ( types-Object, selector, data )
3660 if ( typeof selector !== "string" ) {
3661 // ( types-Object, data )
3663 selector = undefined;
3665 for ( type in types ) {
3666 this.on( type, selector, data, types[ type ], one );
3671 if ( data == null && fn == null ) {
3674 data = selector = undefined;
3675 } else if ( fn == null ) {
3676 if ( typeof selector === "string" ) {
3677 // ( types, selector, fn )
3681 // ( types, data, fn )
3684 selector = undefined;
3687 if ( fn === false ) {
3695 fn = function( event ) {
3696 // Can use an empty set, since event contains the info
3697 jQuery().off( event );
3698 return origFn.apply( this, arguments );
3700 // Use same guid so caller can remove using origFn
3701 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3703 return this.each( function() {
3704 jQuery.event.add( this, types, fn, data, selector );
3707 one: function( types, selector, data, fn ) {
3708 return this.on.call( this, types, selector, data, fn, 1 );
3710 off: function( types, selector, fn ) {
3711 if ( types && types.preventDefault && types.handleObj ) {
3712 // ( event ) dispatched jQuery.Event
3713 var handleObj = types.handleObj;
3714 jQuery( types.delegateTarget ).off(
3715 handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
3721 if ( typeof types === "object" ) {
3722 // ( types-object [, selector] )
3723 for ( var type in types ) {
3724 this.off( type, selector, types[ type ] );
3728 if ( selector === false || typeof selector === "function" ) {
3731 selector = undefined;
3733 if ( fn === false ) {
3736 return this.each(function() {
3737 jQuery.event.remove( this, types, fn, selector );
3741 bind: function( types, data, fn ) {
3742 return this.on( types, null, data, fn );
3744 unbind: function( types, fn ) {
3745 return this.off( types, null, fn );
3748 live: function( types, data, fn ) {
3749 jQuery( this.context ).on( types, this.selector, data, fn );
3752 die: function( types, fn ) {
3753 jQuery( this.context ).off( types, this.selector || "**", fn );
3757 delegate: function( selector, types, data, fn ) {
3758 return this.on( types, selector, data, fn );
3760 undelegate: function( selector, types, fn ) {
3761 // ( namespace ) or ( selector, types [, fn] )
3762 return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
3765 trigger: function( type, data ) {
3766 return this.each(function() {
3767 jQuery.event.trigger( type, data, this );
3770 triggerHandler: function( type, data ) {
3772 return jQuery.event.trigger( type, data, this[0], true );
3776 toggle: function( fn ) {
3777 // Save reference to arguments for access in closure
3778 var args = arguments,
3779 guid = fn.guid || jQuery.guid++,
3781 toggler = function( event ) {
3782 // Figure out which function to execute
3783 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3784 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3786 // Make sure that clicks stop
3787 event.preventDefault();
3789 // and execute the function
3790 return args[ lastToggle ].apply( this, arguments ) || false;
3793 // link all the functions, so any of them can unbind this click handler
3794 toggler.guid = guid;
3795 while ( i < args.length ) {
3796 args[ i++ ].guid = guid;
3799 return this.click( toggler );
3802 hover: function( fnOver, fnOut ) {
3803 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3807 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3808 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3809 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3811 // Handle event binding
3812 jQuery.fn[ name ] = function( data, fn ) {
3818 return arguments.length > 0 ?
3819 this.on( name, null, data, fn ) :
3820 this.trigger( name );
3823 if ( jQuery.attrFn ) {
3824 jQuery.attrFn[ name ] = true;
3827 if ( rkeyEvent.test( name ) ) {
3828 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3831 if ( rmouseEvent.test( name ) ) {
3832 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3839 * Sizzle CSS Selector Engine
3840 * Copyright 2012, The Dojo Foundation
3841 * Released under the MIT, BSD, and GPL Licenses.
3842 * More information: http://sizzlejs.com/
3846 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3847 expando = "sizcache" + (Math.random() + '').replace('.', ''),
3849 toString = Object.prototype.toString,
3850 hasDuplicate = false,
3851 baseHasDuplicate = true,
3856 // Here we check if the JavaScript engine is using some sort of
3857 // optimization where it does not always call our comparision
3858 // function. If that is the case, discard the hasDuplicate value.
3859 // Thus far that includes Google Chrome.
3860 [0, 0].sort(function() {
3861 baseHasDuplicate = false;
3865 var Sizzle = function( selector, context, results, seed ) {
3866 results = results || [];
3867 context = context || document;
3869 var origContext = context;
3871 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3875 if ( !selector || typeof selector !== "string" ) {
3879 var m, set, checkSet, extra, ret, cur, pop, i,
3881 contextXML = Sizzle.isXML( context ),
3885 // Reset the position of the chunker regexp (start from head)
3888 m = chunker.exec( soFar );
3902 if ( parts.length > 1 && origPOS.exec( selector ) ) {
3904 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3905 set = posProcess( parts[0] + parts[1], context, seed );
3908 set = Expr.relative[ parts[0] ] ?
3910 Sizzle( parts.shift(), context );
3912 while ( parts.length ) {
3913 selector = parts.shift();
3915 if ( Expr.relative[ selector ] ) {
3916 selector += parts.shift();
3919 set = posProcess( selector, set, seed );
3924 // Take a shortcut and set the context if the root selector is an ID
3925 // (but not if it'll be faster if the inner selector is an ID)
3926 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
3927 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
3929 ret = Sizzle.find( parts.shift(), context, contextXML );
3930 context = ret.expr ?
3931 Sizzle.filter( ret.expr, ret.set )[0] :
3937 { expr: parts.pop(), set: makeArray(seed) } :
3938 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
3941 Sizzle.filter( ret.expr, ret.set ) :
3944 if ( parts.length > 0 ) {
3945 checkSet = makeArray( set );
3951 while ( parts.length ) {
3955 if ( !Expr.relative[ cur ] ) {
3961 if ( pop == null ) {
3965 Expr.relative[ cur ]( checkSet, pop, contextXML );
3969 checkSet = parts = [];
3978 Sizzle.error( cur || selector );
3981 if ( toString.call(checkSet) === "[object Array]" ) {
3983 results.push.apply( results, checkSet );
3985 } else if ( context && context.nodeType === 1 ) {
3986 for ( i = 0; checkSet[i] != null; i++ ) {
3987 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
3988 results.push( set[i] );
3993 for ( i = 0; checkSet[i] != null; i++ ) {
3994 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
3995 results.push( set[i] );
4001 makeArray( checkSet, results );
4005 Sizzle( extra, origContext, results, seed );
4006 Sizzle.uniqueSort( results );
4012 Sizzle.uniqueSort = function( results ) {
4014 hasDuplicate = baseHasDuplicate;
4015 results.sort( sortOrder );
4017 if ( hasDuplicate ) {
4018 for ( var i = 1; i < results.length; i++ ) {
4019 if ( results[i] === results[ i - 1 ] ) {
4020 results.splice( i--, 1 );
4029 Sizzle.matches = function( expr, set ) {
4030 return Sizzle( expr, null, null, set );
4033 Sizzle.matchesSelector = function( node, expr ) {
4034 return Sizzle( expr, null, null, [node] ).length > 0;
4037 Sizzle.find = function( expr, context, isXML ) {
4038 var set, i, len, match, type, left;
4044 for ( i = 0, len = Expr.order.length; i < len; i++ ) {
4045 type = Expr.order[i];
4047 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
4049 match.splice( 1, 1 );
4051 if ( left.substr( left.length - 1 ) !== "\\" ) {
4052 match[1] = (match[1] || "").replace( rBackslash, "" );
4053 set = Expr.find[ type ]( match, context, isXML );
4055 if ( set != null ) {
4056 expr = expr.replace( Expr.match[ type ], "" );
4064 set = typeof context.getElementsByTagName !== "undefined" ?
4065 context.getElementsByTagName( "*" ) :
4069 return { set: set, expr: expr };
4072 Sizzle.filter = function( expr, set, inplace, not ) {
4073 var match, anyFound,
4074 type, found, item, filter, left,
4079 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
4081 while ( expr && set.length ) {
4082 for ( type in Expr.filter ) {
4083 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
4084 filter = Expr.filter[ type ];
4091 if ( left.substr( left.length - 1 ) === "\\" ) {
4095 if ( curLoop === result ) {
4099 if ( Expr.preFilter[ type ] ) {
4100 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
4103 anyFound = found = true;
4105 } else if ( match === true ) {
4111 for ( i = 0; (item = curLoop[i]) != null; i++ ) {
4113 found = filter( item, match, i, curLoop );
4116 if ( inplace && found != null ) {
4124 } else if ( pass ) {
4125 result.push( item );
4132 if ( found !== undefined ) {
4137 expr = expr.replace( Expr.match[ type ], "" );
4148 // Improper expression
4149 if ( expr === old ) {
4150 if ( anyFound == null ) {
4151 Sizzle.error( expr );
4164 Sizzle.error = function( msg ) {
4165 throw new Error( "Syntax error, unrecognized expression: " + msg );
4169 * Utility function for retreiving the text value of an array of DOM nodes
4170 * @param {Array|Element} elem
4172 var getText = Sizzle.getText = function( elem ) {
4174 nodeType = elem.nodeType,
4178 if ( nodeType === 1 || nodeType === 9 ) {
4179 // Use textContent || innerText for elements
4180 if ( typeof elem.textContent === 'string' ) {
4181 return elem.textContent;
4182 } else if ( typeof elem.innerText === 'string' ) {
4183 // Replace IE's carriage returns
4184 return elem.innerText.replace( rReturn, '' );
4186 // Traverse it's children
4187 for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
4188 ret += getText( elem );
4191 } else if ( nodeType === 3 || nodeType === 4 ) {
4192 return elem.nodeValue;
4196 // If no nodeType, this is expected to be an array
4197 for ( i = 0; (node = elem[i]); i++ ) {
4198 // Do not traverse comment nodes
4199 if ( node.nodeType !== 8 ) {
4200 ret += getText( node );
4207 var Expr = Sizzle.selectors = {
4208 order: [ "ID", "NAME", "TAG" ],
4211 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4212 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4213 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4214 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4215 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4216 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4217 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4218 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4224 "class": "className",
4229 href: function( elem ) {
4230 return elem.getAttribute( "href" );
4232 type: function( elem ) {
4233 return elem.getAttribute( "type" );
4238 "+": function(checkSet, part){
4239 var isPartStr = typeof part === "string",
4240 isTag = isPartStr && !rNonWord.test( part ),
4241 isPartStrNotTag = isPartStr && !isTag;
4244 part = part.toLowerCase();
4247 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
4248 if ( (elem = checkSet[i]) ) {
4249 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
4251 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
4257 if ( isPartStrNotTag ) {
4258 Sizzle.filter( part, checkSet, true );
4262 ">": function( checkSet, part ) {
4264 isPartStr = typeof part === "string",
4266 l = checkSet.length;
4268 if ( isPartStr && !rNonWord.test( part ) ) {
4269 part = part.toLowerCase();
4271 for ( ; i < l; i++ ) {
4275 var parent = elem.parentNode;
4276 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
4281 for ( ; i < l; i++ ) {
4285 checkSet[i] = isPartStr ?
4287 elem.parentNode === part;
4292 Sizzle.filter( part, checkSet, true );
4297 "": function(checkSet, part, isXML){
4302 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4303 part = part.toLowerCase();
4305 checkFn = dirNodeCheck;
4308 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
4311 "~": function( checkSet, part, isXML ) {
4316 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4317 part = part.toLowerCase();
4319 checkFn = dirNodeCheck;
4322 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
4327 ID: function( match, context, isXML ) {
4328 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4329 var m = context.getElementById(match[1]);
4330 // Check parentNode to catch when Blackberry 4.6 returns
4331 // nodes that are no longer in the document #6963
4332 return m && m.parentNode ? [m] : [];
4336 NAME: function( match, context ) {
4337 if ( typeof context.getElementsByName !== "undefined" ) {
4339 results = context.getElementsByName( match[1] );
4341 for ( var i = 0, l = results.length; i < l; i++ ) {
4342 if ( results[i].getAttribute("name") === match[1] ) {
4343 ret.push( results[i] );
4347 return ret.length === 0 ? null : ret;
4351 TAG: function( match, context ) {
4352 if ( typeof context.getElementsByTagName !== "undefined" ) {
4353 return context.getElementsByTagName( match[1] );
4358 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
4359 match = " " + match[1].replace( rBackslash, "" ) + " ";
4365 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
4367 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
4369 result.push( elem );
4372 } else if ( inplace ) {
4381 ID: function( match ) {
4382 return match[1].replace( rBackslash, "" );
4385 TAG: function( match, curLoop ) {
4386 return match[1].replace( rBackslash, "" ).toLowerCase();
4389 CHILD: function( match ) {
4390 if ( match[1] === "nth" ) {
4392 Sizzle.error( match[0] );
4395 match[2] = match[2].replace(/^\+|\s*/g, '');
4397 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4398 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4399 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
4400 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
4402 // calculate the numbers (first)n+(last) including if they are negative
4403 match[2] = (test[1] + (test[2] || 1)) - 0;
4404 match[3] = test[3] - 0;
4406 else if ( match[2] ) {
4407 Sizzle.error( match[0] );
4410 // TODO: Move to normal caching system
4416 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
4417 var name = match[1] = match[1].replace( rBackslash, "" );
4419 if ( !isXML && Expr.attrMap[name] ) {
4420 match[1] = Expr.attrMap[name];
4423 // Handle if an un-quoted value was used
4424 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
4426 if ( match[2] === "~=" ) {
4427 match[4] = " " + match[4] + " ";
4433 PSEUDO: function( match, curLoop, inplace, result, not ) {
4434 if ( match[1] === "not" ) {
4435 // If we're dealing with a complex expression, or a simple one
4436 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
4437 match[3] = Sizzle(match[3], null, null, curLoop);
4440 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
4443 result.push.apply( result, ret );
4449 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
4456 POS: function( match ) {
4457 match.unshift( true );
4464 enabled: function( elem ) {
4465 return elem.disabled === false && elem.type !== "hidden";
4468 disabled: function( elem ) {
4469 return elem.disabled === true;
4472 checked: function( elem ) {
4473 return elem.checked === true;
4476 selected: function( elem ) {
4477 // Accessing this property makes selected-by-default
4478 // options in Safari work properly
4479 if ( elem.parentNode ) {
4480 elem.parentNode.selectedIndex;
4483 return elem.selected === true;
4486 parent: function( elem ) {
4487 return !!elem.firstChild;
4490 empty: function( elem ) {
4491 return !elem.firstChild;
4494 has: function( elem, i, match ) {
4495 return !!Sizzle( match[3], elem ).length;
4498 header: function( elem ) {
4499 return (/h\d/i).test( elem.nodeName );
4502 text: function( elem ) {
4503 var attr = elem.getAttribute( "type" ), type = elem.type;
4504 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4505 // use getAttribute instead to test this case
4506 return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
4509 radio: function( elem ) {
4510 return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
4513 checkbox: function( elem ) {
4514 return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
4517 file: function( elem ) {
4518 return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
4521 password: function( elem ) {
4522 return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
4525 submit: function( elem ) {
4526 var name = elem.nodeName.toLowerCase();
4527 return (name === "input" || name === "button") && "submit" === elem.type;
4530 image: function( elem ) {
4531 return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
4534 reset: function( elem ) {
4535 var name = elem.nodeName.toLowerCase();
4536 return (name === "input" || name === "button") && "reset" === elem.type;
4539 button: function( elem ) {
4540 var name = elem.nodeName.toLowerCase();
4541 return name === "input" && "button" === elem.type || name === "button";
4544 input: function( elem ) {
4545 return (/input|select|textarea|button/i).test( elem.nodeName );
4548 focus: function( elem ) {
4549 return elem === elem.ownerDocument.activeElement;
4553 first: function( elem, i ) {
4557 last: function( elem, i, match, array ) {
4558 return i === array.length - 1;
4561 even: function( elem, i ) {
4565 odd: function( elem, i ) {
4569 lt: function( elem, i, match ) {
4570 return i < match[3] - 0;
4573 gt: function( elem, i, match ) {
4574 return i > match[3] - 0;
4577 nth: function( elem, i, match ) {
4578 return match[3] - 0 === i;
4581 eq: function( elem, i, match ) {
4582 return match[3] - 0 === i;
4586 PSEUDO: function( elem, match, i, array ) {
4587 var name = match[1],
4588 filter = Expr.filters[ name ];
4591 return filter( elem, i, match, array );
4593 } else if ( name === "contains" ) {
4594 return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
4596 } else if ( name === "not" ) {
4599 for ( var j = 0, l = not.length; j < l; j++ ) {
4600 if ( not[j] === elem ) {
4608 Sizzle.error( name );
4612 CHILD: function( elem, match ) {
4614 doneName, parent, cache,
4622 while ( (node = node.previousSibling) ) {
4623 if ( node.nodeType === 1 ) {
4628 if ( type === "first" ) {
4635 while ( (node = node.nextSibling) ) {
4636 if ( node.nodeType === 1 ) {
4647 if ( first === 1 && last === 0 ) {
4651 doneName = match[0];
4652 parent = elem.parentNode;
4654 if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
4657 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4658 if ( node.nodeType === 1 ) {
4659 node.nodeIndex = ++count;
4663 parent[ expando ] = doneName;
4666 diff = elem.nodeIndex - last;
4668 if ( first === 0 ) {
4672 return ( diff % first === 0 && diff / first >= 0 );
4677 ID: function( elem, match ) {
4678 return elem.nodeType === 1 && elem.getAttribute("id") === match;
4681 TAG: function( elem, match ) {
4682 return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
4685 CLASS: function( elem, match ) {
4686 return (" " + (elem.className || elem.getAttribute("class")) + " ")
4687 .indexOf( match ) > -1;
4690 ATTR: function( elem, match ) {
4691 var name = match[1],
4692 result = Sizzle.attr ?
4693 Sizzle.attr( elem, name ) :
4694 Expr.attrHandle[ name ] ?
4695 Expr.attrHandle[ name ]( elem ) :
4696 elem[ name ] != null ?
4698 elem.getAttribute( name ),
4699 value = result + "",
4703 return result == null ?
4705 !type && Sizzle.attr ?
4710 value.indexOf(check) >= 0 :
4712 (" " + value + " ").indexOf(check) >= 0 :
4714 value && result !== false :
4718 value.indexOf(check) === 0 :
4720 value.substr(value.length - check.length) === check :
4722 value === check || value.substr(0, check.length + 1) === check + "-" :
4726 POS: function( elem, match, i, array ) {
4727 var name = match[2],
4728 filter = Expr.setFilters[ name ];
4731 return filter( elem, i, match, array );
4737 var origPOS = Expr.match.POS,
4738 fescape = function(all, num){
4739 return "\\" + (num - 0 + 1);
4742 for ( var type in Expr.match ) {
4743 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
4744 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
4747 var makeArray = function( array, results ) {
4748 array = Array.prototype.slice.call( array, 0 );
4751 results.push.apply( results, array );
4758 // Perform a simple check to determine if the browser is capable of
4759 // converting a NodeList to an array using builtin methods.
4760 // Also verifies that the returned array holds DOM nodes
4761 // (which is not the case in the Blackberry browser)
4763 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
4765 // Provide a fallback method if it does not work
4767 makeArray = function( array, results ) {
4769 ret = results || [];
4771 if ( toString.call(array) === "[object Array]" ) {
4772 Array.prototype.push.apply( ret, array );
4775 if ( typeof array.length === "number" ) {
4776 for ( var l = array.length; i < l; i++ ) {
4777 ret.push( array[i] );
4781 for ( ; array[i]; i++ ) {
4782 ret.push( array[i] );
4791 var sortOrder, siblingCheck;
4793 if ( document.documentElement.compareDocumentPosition ) {
4794 sortOrder = function( a, b ) {
4796 hasDuplicate = true;
4800 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4801 return a.compareDocumentPosition ? -1 : 1;
4804 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4808 sortOrder = function( a, b ) {
4809 // The nodes are identical, we can exit early
4811 hasDuplicate = true;
4814 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4815 } else if ( a.sourceIndex && b.sourceIndex ) {
4816 return a.sourceIndex - b.sourceIndex;
4826 // If the nodes are siblings (or identical) we can do a quick check
4827 if ( aup === bup ) {
4828 return siblingCheck( a, b );
4830 // If no parents were found then the nodes are disconnected
4831 } else if ( !aup ) {
4834 } else if ( !bup ) {
4838 // Otherwise they're somewhere else in the tree so we need
4839 // to build up a full list of the parentNodes for comparison
4842 cur = cur.parentNode;
4849 cur = cur.parentNode;
4855 // Start walking down the tree looking for a discrepancy
4856 for ( var i = 0; i < al && i < bl; i++ ) {
4857 if ( ap[i] !== bp[i] ) {
4858 return siblingCheck( ap[i], bp[i] );
4862 // We ended someplace up the tree so do a sibling check
4864 siblingCheck( a, bp[i], -1 ) :
4865 siblingCheck( ap[i], b, 1 );
4868 siblingCheck = function( a, b, ret ) {
4872 var cur = a.nextSibling;
4880 cur = cur.nextSibling;
4887 // Check to see if the browser returns elements by name when
4888 // querying by getElementById (and provide a workaround)
4890 // We're going to inject a fake input element with a specified name
4891 var form = document.createElement("div"),
4892 id = "script" + (new Date()).getTime(),
4893 root = document.documentElement;
4895 form.innerHTML = "<a name='" + id + "'/>";
4897 // Inject it into the root element, check its status, and remove it quickly
4898 root.insertBefore( form, root.firstChild );
4900 // The workaround has to do additional checks after a getElementById
4901 // Which slows things down for other browsers (hence the branching)
4902 if ( document.getElementById( id ) ) {
4903 Expr.find.ID = function( match, context, isXML ) {
4904 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4905 var m = context.getElementById(match[1]);
4908 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
4915 Expr.filter.ID = function( elem, match ) {
4916 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4918 return elem.nodeType === 1 && node && node.nodeValue === match;
4922 root.removeChild( form );
4924 // release memory in IE
4929 // Check to see if the browser returns only elements
4930 // when doing getElementsByTagName("*")
4932 // Create a fake element
4933 var div = document.createElement("div");
4934 div.appendChild( document.createComment("") );
4936 // Make sure no comments are found
4937 if ( div.getElementsByTagName("*").length > 0 ) {
4938 Expr.find.TAG = function( match, context ) {
4939 var results = context.getElementsByTagName( match[1] );
4941 // Filter out possible comments
4942 if ( match[1] === "*" ) {
4945 for ( var i = 0; results[i]; i++ ) {
4946 if ( results[i].nodeType === 1 ) {
4947 tmp.push( results[i] );
4958 // Check to see if an attribute returns normalized href attributes
4959 div.innerHTML = "<a href='#'></a>";
4961 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4962 div.firstChild.getAttribute("href") !== "#" ) {
4964 Expr.attrHandle.href = function( elem ) {
4965 return elem.getAttribute( "href", 2 );
4969 // release memory in IE
4973 if ( document.querySelectorAll ) {
4975 var oldSizzle = Sizzle,
4976 div = document.createElement("div"),
4979 div.innerHTML = "<p class='TEST'></p>";
4981 // Safari can't handle uppercase or unicode characters when
4983 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4987 Sizzle = function( query, context, extra, seed ) {
4988 context = context || document;
4990 // Only use querySelectorAll on non-XML documents
4991 // (ID selectors don't work in non-HTML documents)
4992 if ( !seed && !Sizzle.isXML(context) ) {
4993 // See if we find a selector to speed up
4994 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
4996 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
4997 // Speed-up: Sizzle("TAG")
4999 return makeArray( context.getElementsByTagName( query ), extra );
5001 // Speed-up: Sizzle(".CLASS")
5002 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
5003 return makeArray( context.getElementsByClassName( match[2] ), extra );
5007 if ( context.nodeType === 9 ) {
5008 // Speed-up: Sizzle("body")
5009 // The body element only exists once, optimize finding it
5010 if ( query === "body" && context.body ) {
5011 return makeArray( [ context.body ], extra );
5013 // Speed-up: Sizzle("#ID")
5014 } else if ( match && match[3] ) {
5015 var elem = context.getElementById( match[3] );
5017 // Check parentNode to catch when Blackberry 4.6 returns
5018 // nodes that are no longer in the document #6963
5019 if ( elem && elem.parentNode ) {
5020 // Handle the case where IE and Opera return items
5021 // by name instead of ID
5022 if ( elem.id === match[3] ) {
5023 return makeArray( [ elem ], extra );
5027 return makeArray( [], extra );
5032 return makeArray( context.querySelectorAll(query), extra );
5033 } catch(qsaError) {}
5035 // qSA works strangely on Element-rooted queries
5036 // We can work around this by specifying an extra ID on the root
5037 // and working up from there (Thanks to Andrew Dupont for the technique)
5038 // IE 8 doesn't work on object elements
5039 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5040 var oldContext = context,
5041 old = context.getAttribute( "id" ),
5043 hasParent = context.parentNode,
5044 relativeHierarchySelector = /^\s*[+~]/.test( query );
5047 context.setAttribute( "id", nid );
5049 nid = nid.replace( /'/g, "\\$&" );
5051 if ( relativeHierarchySelector && hasParent ) {
5052 context = context.parentNode;
5056 if ( !relativeHierarchySelector || hasParent ) {
5057 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
5060 } catch(pseudoError) {
5063 oldContext.removeAttribute( "id" );
5069 return oldSizzle(query, context, extra, seed);
5072 for ( var prop in oldSizzle ) {
5073 Sizzle[ prop ] = oldSizzle[ prop ];
5076 // release memory in IE
5082 var html = document.documentElement,
5083 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
5086 // Check to see if it's possible to do matchesSelector
5087 // on a disconnected node (IE 9 fails this)
5088 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
5089 pseudoWorks = false;
5092 // This should fail with an exception
5093 // Gecko does not error, returns false instead
5094 matches.call( document.documentElement, "[test!='']:sizzle" );
5096 } catch( pseudoError ) {
5100 Sizzle.matchesSelector = function( node, expr ) {
5101 // Make sure that attribute selectors are quoted
5102 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5104 if ( !Sizzle.isXML( node ) ) {
5106 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
5107 var ret = matches.call( node, expr );
5109 // IE 9's matchesSelector returns false on disconnected nodes
5110 if ( ret || !disconnectedMatch ||
5111 // As well, disconnected nodes are said to be in a document
5112 // fragment in IE 9, so check for that
5113 node.document && node.document.nodeType !== 11 ) {
5120 return Sizzle(expr, null, null, [node]).length > 0;
5126 var div = document.createElement("div");
5128 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
5130 // Opera can't find a second classname (in 9.6)
5131 // Also, make sure that getElementsByClassName actually exists
5132 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
5136 // Safari caches class attributes, doesn't catch changes (in 3.2)
5137 div.lastChild.className = "e";
5139 if ( div.getElementsByClassName("e").length === 1 ) {
5143 Expr.order.splice(1, 0, "CLASS");
5144 Expr.find.CLASS = function( match, context, isXML ) {
5145 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
5146 return context.getElementsByClassName(match[1]);
5150 // release memory in IE
5154 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5155 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5156 var elem = checkSet[i];
5164 if ( elem[ expando ] === doneName ) {
5165 match = checkSet[elem.sizset];
5169 if ( elem.nodeType === 1 && !isXML ){
5170 elem[ expando ] = doneName;
5174 if ( elem.nodeName.toLowerCase() === cur ) {
5182 checkSet[i] = match;
5187 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5188 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5189 var elem = checkSet[i];
5197 if ( elem[ expando ] === doneName ) {
5198 match = checkSet[elem.sizset];
5202 if ( elem.nodeType === 1 ) {
5204 elem[ expando ] = doneName;
5208 if ( typeof cur !== "string" ) {
5209 if ( elem === cur ) {
5214 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
5223 checkSet[i] = match;
5228 if ( document.documentElement.contains ) {
5229 Sizzle.contains = function( a, b ) {
5230 return a !== b && (a.contains ? a.contains(b) : true);
5233 } else if ( document.documentElement.compareDocumentPosition ) {
5234 Sizzle.contains = function( a, b ) {
5235 return !!(a.compareDocumentPosition(b) & 16);
5239 Sizzle.contains = function() {
5244 Sizzle.isXML = function( elem ) {
5245 // documentElement is verified for cases where it doesn't yet exist
5246 // (such as loading iframes in IE - #4833)
5247 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
5249 return documentElement ? documentElement.nodeName !== "HTML" : false;
5252 var posProcess = function( selector, context, seed ) {
5256 root = context.nodeType ? [context] : context;
5258 // Position selectors must be done after the filter
5259 // And so must :not(positional) so we move all PSEUDOs to the end
5260 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
5262 selector = selector.replace( Expr.match.PSEUDO, "" );
5265 selector = Expr.relative[selector] ? selector + "*" : selector;
5267 for ( var i = 0, l = root.length; i < l; i++ ) {
5268 Sizzle( selector, root[i], tmpSet, seed );
5271 return Sizzle.filter( later, tmpSet );
5275 // Override sizzle attribute retrieval
5276 Sizzle.attr = jQuery.attr;
5277 Sizzle.selectors.attrMap = {};
5278 jQuery.find = Sizzle;
5279 jQuery.expr = Sizzle.selectors;
5280 jQuery.expr[":"] = jQuery.expr.filters;
5281 jQuery.unique = Sizzle.uniqueSort;
5282 jQuery.text = Sizzle.getText;
5283 jQuery.isXMLDoc = Sizzle.isXML;
5284 jQuery.contains = Sizzle.contains;
5290 var runtil = /Until$/,
5291 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
5292 // Note: This RegExp should be improved, or likely pulled from Sizzle
5293 rmultiselector = /,/,
5294 isSimple = /^.[^:#\[\.,]*$/,
5295 slice = Array.prototype.slice,
5296 POS = jQuery.expr.match.POS,
5297 // methods guaranteed to produce a unique set when starting from a unique set
5298 guaranteedUnique = {
5306 find: function( selector ) {
5310 if ( typeof selector !== "string" ) {
5311 return jQuery( selector ).filter(function() {
5312 for ( i = 0, l = self.length; i < l; i++ ) {
5313 if ( jQuery.contains( self[ i ], this ) ) {
5320 var ret = this.pushStack( "", "find", selector ),
5323 for ( i = 0, l = this.length; i < l; i++ ) {
5324 length = ret.length;
5325 jQuery.find( selector, this[i], ret );
5328 // Make sure that the results are unique
5329 for ( n = length; n < ret.length; n++ ) {
5330 for ( r = 0; r < length; r++ ) {
5331 if ( ret[r] === ret[n] ) {
5343 has: function( target ) {
5344 var targets = jQuery( target );
5345 return this.filter(function() {
5346 for ( var i = 0, l = targets.length; i < l; i++ ) {
5347 if ( jQuery.contains( this, targets[i] ) ) {
5354 not: function( selector ) {
5355 return this.pushStack( winnow(this, selector, false), "not", selector);
5358 filter: function( selector ) {
5359 return this.pushStack( winnow(this, selector, true), "filter", selector );
5362 is: function( selector ) {
5363 return !!selector && (
5364 typeof selector === "string" ?
5365 // If this is a positional selector, check membership in the returned set
5366 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5367 POS.test( selector ) ?
5368 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5369 jQuery.filter( selector, this ).length > 0 :
5370 this.filter( selector ).length > 0 );
5373 closest: function( selectors, context ) {
5374 var ret = [], i, l, cur = this[0];
5376 // Array (deprecated as of jQuery 1.7)
5377 if ( jQuery.isArray( selectors ) ) {
5380 while ( cur && cur.ownerDocument && cur !== context ) {
5381 for ( i = 0; i < selectors.length; i++ ) {
5383 if ( jQuery( cur ).is( selectors[ i ] ) ) {
5384 ret.push({ selector: selectors[ i ], elem: cur, level: level });
5388 cur = cur.parentNode;
5396 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
5397 jQuery( selectors, context || this.context ) :
5400 for ( i = 0, l = this.length; i < l; i++ ) {
5404 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5409 cur = cur.parentNode;
5410 if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
5417 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5419 return this.pushStack( ret, "closest", selectors );
5422 // Determine the position of an element within
5423 // the matched set of elements
5424 index: function( elem ) {
5426 // No argument, return index in parent
5428 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5431 // index in selector
5432 if ( typeof elem === "string" ) {
5433 return jQuery.inArray( this[0], jQuery( elem ) );
5436 // Locate the position of the desired element
5437 return jQuery.inArray(
5438 // If it receives a jQuery object, the first element is used
5439 elem.jquery ? elem[0] : elem, this );
5442 add: function( selector, context ) {
5443 var set = typeof selector === "string" ?
5444 jQuery( selector, context ) :
5445 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5446 all = jQuery.merge( this.get(), set );
5448 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5450 jQuery.unique( all ) );
5453 andSelf: function() {
5454 return this.add( this.prevObject );
5458 // A painfully simple check to see if an element is disconnected
5459 // from a document (should be improved, where feasible).
5460 function isDisconnected( node ) {
5461 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5465 parent: function( elem ) {
5466 var parent = elem.parentNode;
5467 return parent && parent.nodeType !== 11 ? parent : null;
5469 parents: function( elem ) {
5470 return jQuery.dir( elem, "parentNode" );
5472 parentsUntil: function( elem, i, until ) {
5473 return jQuery.dir( elem, "parentNode", until );
5475 next: function( elem ) {
5476 return jQuery.nth( elem, 2, "nextSibling" );
5478 prev: function( elem ) {
5479 return jQuery.nth( elem, 2, "previousSibling" );
5481 nextAll: function( elem ) {
5482 return jQuery.dir( elem, "nextSibling" );
5484 prevAll: function( elem ) {
5485 return jQuery.dir( elem, "previousSibling" );
5487 nextUntil: function( elem, i, until ) {
5488 return jQuery.dir( elem, "nextSibling", until );
5490 prevUntil: function( elem, i, until ) {
5491 return jQuery.dir( elem, "previousSibling", until );
5493 siblings: function( elem ) {
5494 return jQuery.sibling( elem.parentNode.firstChild, elem );
5496 children: function( elem ) {
5497 return jQuery.sibling( elem.firstChild );
5499 contents: function( elem ) {
5500 return jQuery.nodeName( elem, "iframe" ) ?
5501 elem.contentDocument || elem.contentWindow.document :
5502 jQuery.makeArray( elem.childNodes );
5504 }, function( name, fn ) {
5505 jQuery.fn[ name ] = function( until, selector ) {
5506 var ret = jQuery.map( this, fn, until );
5508 if ( !runtil.test( name ) ) {
5512 if ( selector && typeof selector === "string" ) {
5513 ret = jQuery.filter( selector, ret );
5516 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5518 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
5519 ret = ret.reverse();
5522 return this.pushStack( ret, name, slice.call( arguments ).join(",") );
5527 filter: function( expr, elems, not ) {
5529 expr = ":not(" + expr + ")";
5532 return elems.length === 1 ?
5533 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5534 jQuery.find.matches(expr, elems);
5537 dir: function( elem, dir, until ) {
5541 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5542 if ( cur.nodeType === 1 ) {
5543 matched.push( cur );
5550 nth: function( cur, result, dir, elem ) {
5551 result = result || 1;
5554 for ( ; cur; cur = cur[dir] ) {
5555 if ( cur.nodeType === 1 && ++num === result ) {
5563 sibling: function( n, elem ) {
5566 for ( ; n; n = n.nextSibling ) {
5567 if ( n.nodeType === 1 && n !== elem ) {
5576 // Implement the identical functionality for filter and not
5577 function winnow( elements, qualifier, keep ) {
5579 // Can't pass null or undefined to indexOf in Firefox 4
5580 // Set to 0 to skip string check
5581 qualifier = qualifier || 0;
5583 if ( jQuery.isFunction( qualifier ) ) {
5584 return jQuery.grep(elements, function( elem, i ) {
5585 var retVal = !!qualifier.call( elem, i, elem );
5586 return retVal === keep;
5589 } else if ( qualifier.nodeType ) {
5590 return jQuery.grep(elements, function( elem, i ) {
5591 return ( elem === qualifier ) === keep;
5594 } else if ( typeof qualifier === "string" ) {
5595 var filtered = jQuery.grep(elements, function( elem ) {
5596 return elem.nodeType === 1;
5599 if ( isSimple.test( qualifier ) ) {
5600 return jQuery.filter(qualifier, filtered, !keep);
5602 qualifier = jQuery.filter( qualifier, filtered );
5606 return jQuery.grep(elements, function( elem, i ) {
5607 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5614 function createSafeFragment( document ) {
5615 var list = nodeNames.split( "|" ),
5616 safeFrag = document.createDocumentFragment();
5618 if ( safeFrag.createElement ) {
5619 while ( list.length ) {
5620 safeFrag.createElement(
5628 var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" +
5629 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5630 rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5631 rleadingWhitespace = /^\s+/,
5632 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5633 rtagName = /<([\w:]+)/,
5635 rhtml = /<|&#?\w+;/,
5636 rnoInnerhtml = /<(?:script|style)/i,
5637 rnocache = /<(?:script|object|embed|option|style)/i,
5638 rnoshimcache = new RegExp("<(?:" + nodeNames + ")", "i"),
5639 // checked="checked" or checked
5640 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5641 rscriptType = /\/(java|ecma)script/i,
5642 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
5644 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5645 legend: [ 1, "<fieldset>", "</fieldset>" ],
5646 thead: [ 1, "<table>", "</table>" ],
5647 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5648 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5649 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5650 area: [ 1, "<map>", "</map>" ],
5651 _default: [ 0, "", "" ]
5653 safeFragment = createSafeFragment( document );
5655 wrapMap.optgroup = wrapMap.option;
5656 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5657 wrapMap.th = wrapMap.td;
5659 // IE can't serialize <link> and <script> tags normally
5660 if ( !jQuery.support.htmlSerialize ) {
5661 wrapMap._default = [ 1, "div<div>", "</div>" ];
5665 text: function( text ) {
5666 if ( jQuery.isFunction(text) ) {
5667 return this.each(function(i) {
5668 var self = jQuery( this );
5670 self.text( text.call(this, i, self.text()) );
5674 if ( typeof text !== "object" && text !== undefined ) {
5675 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
5678 return jQuery.text( this );
5681 wrapAll: function( html ) {
5682 if ( jQuery.isFunction( html ) ) {
5683 return this.each(function(i) {
5684 jQuery(this).wrapAll( html.call(this, i) );
5689 // The elements to wrap the target around
5690 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5692 if ( this[0].parentNode ) {
5693 wrap.insertBefore( this[0] );
5696 wrap.map(function() {
5699 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5700 elem = elem.firstChild;
5710 wrapInner: function( html ) {
5711 if ( jQuery.isFunction( html ) ) {
5712 return this.each(function(i) {
5713 jQuery(this).wrapInner( html.call(this, i) );
5717 return this.each(function() {
5718 var self = jQuery( this ),
5719 contents = self.contents();
5721 if ( contents.length ) {
5722 contents.wrapAll( html );
5725 self.append( html );
5730 wrap: function( html ) {
5731 var isFunction = jQuery.isFunction( html );
5733 return this.each(function(i) {
5734 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5738 unwrap: function() {
5739 return this.parent().each(function() {
5740 if ( !jQuery.nodeName( this, "body" ) ) {
5741 jQuery( this ).replaceWith( this.childNodes );
5746 append: function() {
5747 return this.domManip(arguments, true, function( elem ) {
5748 if ( this.nodeType === 1 ) {
5749 this.appendChild( elem );
5754 prepend: function() {
5755 return this.domManip(arguments, true, function( elem ) {
5756 if ( this.nodeType === 1 ) {
5757 this.insertBefore( elem, this.firstChild );
5762 before: function() {
5763 if ( this[0] && this[0].parentNode ) {
5764 return this.domManip(arguments, false, function( elem ) {
5765 this.parentNode.insertBefore( elem, this );
5767 } else if ( arguments.length ) {
5768 var set = jQuery.clean( arguments );
5769 set.push.apply( set, this.toArray() );
5770 return this.pushStack( set, "before", arguments );
5775 if ( this[0] && this[0].parentNode ) {
5776 return this.domManip(arguments, false, function( elem ) {
5777 this.parentNode.insertBefore( elem, this.nextSibling );
5779 } else if ( arguments.length ) {
5780 var set = this.pushStack( this, "after", arguments );
5781 set.push.apply( set, jQuery.clean(arguments) );
5786 // keepData is for internal use only--do not document
5787 remove: function( selector, keepData ) {
5788 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5789 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5790 if ( !keepData && elem.nodeType === 1 ) {
5791 jQuery.cleanData( elem.getElementsByTagName("*") );
5792 jQuery.cleanData( [ elem ] );
5795 if ( elem.parentNode ) {
5796 elem.parentNode.removeChild( elem );
5805 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5806 // Remove element nodes and prevent memory leaks
5807 if ( elem.nodeType === 1 ) {
5808 jQuery.cleanData( elem.getElementsByTagName("*") );
5811 // Remove any remaining nodes
5812 while ( elem.firstChild ) {
5813 elem.removeChild( elem.firstChild );
5820 clone: function( dataAndEvents, deepDataAndEvents ) {
5821 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5822 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5824 return this.map( function () {
5825 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5829 html: function( value ) {
5830 if ( value === undefined ) {
5831 return this[0] && this[0].nodeType === 1 ?
5832 this[0].innerHTML.replace(rinlinejQuery, "") :
5835 // See if we can take a shortcut and just use innerHTML
5836 } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5837 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5838 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5840 value = value.replace(rxhtmlTag, "<$1></$2>");
5843 for ( var i = 0, l = this.length; i < l; i++ ) {
5844 // Remove element nodes and prevent memory leaks
5845 if ( this[i].nodeType === 1 ) {
5846 jQuery.cleanData( this[i].getElementsByTagName("*") );
5847 this[i].innerHTML = value;
5851 // If using innerHTML throws an exception, use the fallback method
5853 this.empty().append( value );
5856 } else if ( jQuery.isFunction( value ) ) {
5857 this.each(function(i){
5858 var self = jQuery( this );
5860 self.html( value.call(this, i, self.html()) );
5864 this.empty().append( value );
5870 replaceWith: function( value ) {
5871 if ( this[0] && this[0].parentNode ) {
5872 // Make sure that the elements are removed from the DOM before they are inserted
5873 // this can help fix replacing a parent with child elements
5874 if ( jQuery.isFunction( value ) ) {
5875 return this.each(function(i) {
5876 var self = jQuery(this), old = self.html();
5877 self.replaceWith( value.call( this, i, old ) );
5881 if ( typeof value !== "string" ) {
5882 value = jQuery( value ).detach();
5885 return this.each(function() {
5886 var next = this.nextSibling,
5887 parent = this.parentNode;
5889 jQuery( this ).remove();
5892 jQuery(next).before( value );
5894 jQuery(parent).append( value );
5898 return this.length ?
5899 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5904 detach: function( selector ) {
5905 return this.remove( selector, true );
5908 domManip: function( args, table, callback ) {
5909 var results, first, fragment, parent,
5913 // We can't cloneNode fragments that contain checked, in WebKit
5914 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
5915 return this.each(function() {
5916 jQuery(this).domManip( args, table, callback, true );
5920 if ( jQuery.isFunction(value) ) {
5921 return this.each(function(i) {
5922 var self = jQuery(this);
5923 args[0] = value.call(this, i, table ? self.html() : undefined);
5924 self.domManip( args, table, callback );
5929 parent = value && value.parentNode;
5931 // If we're in a fragment, just use that instead of building a new one
5932 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
5933 results = { fragment: parent };
5936 results = jQuery.buildFragment( args, this, scripts );
5939 fragment = results.fragment;
5941 if ( fragment.childNodes.length === 1 ) {
5942 first = fragment = fragment.firstChild;
5944 first = fragment.firstChild;
5948 table = table && jQuery.nodeName( first, "tr" );
5950 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
5953 root(this[i], first) :
5955 // Make sure that we do not leak memory by inadvertently discarding
5956 // the original fragment (which might have attached data) instead of
5957 // using it; in addition, use the original fragment object for the last
5958 // item instead of first because it can end up being emptied incorrectly
5959 // in certain situations (Bug #8070).
5960 // Fragments from the fragment cache must always be cloned and never used
5962 results.cacheable || ( l > 1 && i < lastIndex ) ?
5963 jQuery.clone( fragment, true, true ) :
5969 if ( scripts.length ) {
5970 jQuery.each( scripts, evalScript );
5978 function root( elem, cur ) {
5979 return jQuery.nodeName(elem, "table") ?
5980 (elem.getElementsByTagName("tbody")[0] ||
5981 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
5985 function cloneCopyEvent( src, dest ) {
5987 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5992 oldData = jQuery._data( src ),
5993 curData = jQuery._data( dest, oldData ),
5994 events = oldData.events;
5997 delete curData.handle;
5998 curData.events = {};
6000 for ( type in events ) {
6001 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6002 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
6007 // make the cloned public data object a copy from the original
6008 if ( curData.data ) {
6009 curData.data = jQuery.extend( {}, curData.data );
6013 function cloneFixAttributes( src, dest ) {
6016 // We do not need to do anything for non-Elements
6017 if ( dest.nodeType !== 1 ) {
6021 // clearAttributes removes the attributes, which we don't want,
6022 // but also removes the attachEvent events, which we *do* want
6023 if ( dest.clearAttributes ) {
6024 dest.clearAttributes();
6027 // mergeAttributes, in contrast, only merges back on the
6028 // original attributes, not the events
6029 if ( dest.mergeAttributes ) {
6030 dest.mergeAttributes( src );
6033 nodeName = dest.nodeName.toLowerCase();
6035 // IE6-8 fail to clone children inside object elements that use
6036 // the proprietary classid attribute value (rather than the type
6037 // attribute) to identify the type of content to display
6038 if ( nodeName === "object" ) {
6039 dest.outerHTML = src.outerHTML;
6041 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
6042 // IE6-8 fails to persist the checked state of a cloned checkbox
6043 // or radio button. Worse, IE6-7 fail to give the cloned element
6044 // a checked appearance if the defaultChecked value isn't also set
6045 if ( src.checked ) {
6046 dest.defaultChecked = dest.checked = src.checked;
6049 // IE6-7 get confused and end up setting the value of a cloned
6050 // checkbox/radio button to an empty string instead of "on"
6051 if ( dest.value !== src.value ) {
6052 dest.value = src.value;
6055 // IE6-8 fails to return the selected option to the default selected
6056 // state when cloning options
6057 } else if ( nodeName === "option" ) {
6058 dest.selected = src.defaultSelected;
6060 // IE6-8 fails to set the defaultValue to the correct value when
6061 // cloning other types of input fields
6062 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6063 dest.defaultValue = src.defaultValue;
6066 // Event data gets referenced instead of copied if the expando
6068 dest.removeAttribute( jQuery.expando );
6071 jQuery.buildFragment = function( args, nodes, scripts ) {
6072 var fragment, cacheable, cacheresults, doc,
6075 // nodes may contain either an explicit document object,
6076 // a jQuery collection or context object.
6077 // If nodes[0] contains a valid object to assign to doc
6078 if ( nodes && nodes[0] ) {
6079 doc = nodes[0].ownerDocument || nodes[0];
6082 // Ensure that an attr object doesn't incorrectly stand in as a document object
6083 // Chrome and Firefox seem to allow this to occur and will throw exception
6085 if ( !doc.createDocumentFragment ) {
6089 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6090 // Cloning options loses the selected state, so don't cache them
6091 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6092 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6093 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6094 if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
6095 first.charAt(0) === "<" && !rnocache.test( first ) &&
6096 (jQuery.support.checkClone || !rchecked.test( first )) &&
6097 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
6101 cacheresults = jQuery.fragments[ first ];
6102 if ( cacheresults && cacheresults !== 1 ) {
6103 fragment = cacheresults;
6108 fragment = doc.createDocumentFragment();
6109 jQuery.clean( args, doc, fragment, scripts );
6113 jQuery.fragments[ first ] = cacheresults ? fragment : 1;
6116 return { fragment: fragment, cacheable: cacheable };
6119 jQuery.fragments = {};
6123 prependTo: "prepend",
6124 insertBefore: "before",
6125 insertAfter: "after",
6126 replaceAll: "replaceWith"
6127 }, function( name, original ) {
6128 jQuery.fn[ name ] = function( selector ) {
6130 insert = jQuery( selector ),
6131 parent = this.length === 1 && this[0].parentNode;
6133 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
6134 insert[ original ]( this[0] );
6138 for ( var i = 0, l = insert.length; i < l; i++ ) {
6139 var elems = ( i > 0 ? this.clone(true) : this ).get();
6140 jQuery( insert[i] )[ original ]( elems );
6141 ret = ret.concat( elems );
6144 return this.pushStack( ret, name, insert.selector );
6149 function getAll( elem ) {
6150 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6151 return elem.getElementsByTagName( "*" );
6153 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6154 return elem.querySelectorAll( "*" );
6161 // Used in clean, fixes the defaultChecked property
6162 function fixDefaultChecked( elem ) {
6163 if ( elem.type === "checkbox" || elem.type === "radio" ) {
6164 elem.defaultChecked = elem.checked;
6167 // Finds all inputs and passes them to fixDefaultChecked
6168 function findInputs( elem ) {
6169 var nodeName = ( elem.nodeName || "" ).toLowerCase();
6170 if ( nodeName === "input" ) {
6171 fixDefaultChecked( elem );
6172 // Skip scripts, get other children
6173 } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
6174 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6178 // Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
6179 function shimCloneNode( elem ) {
6180 var div = document.createElement( "div" );
6181 safeFragment.appendChild( div );
6183 div.innerHTML = elem.outerHTML;
6184 return div.firstChild;
6188 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6192 // IE<=8 does not properly clone detached, unknown element nodes
6193 clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ?
6194 elem.cloneNode( true ) :
6195 shimCloneNode( elem );
6197 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6198 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6199 // IE copies events bound via attachEvent when using cloneNode.
6200 // Calling detachEvent on the clone will also remove the events
6201 // from the original. In order to get around this, we use some
6202 // proprietary methods to clear the events. Thanks to MooTools
6203 // guys for this hotness.
6205 cloneFixAttributes( elem, clone );
6207 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6208 srcElements = getAll( elem );
6209 destElements = getAll( clone );
6211 // Weird iteration because IE will replace the length property
6212 // with an element if you are cloning the body and one of the
6213 // elements on the page has a name or id of "length"
6214 for ( i = 0; srcElements[i]; ++i ) {
6215 // Ensure that the destination node is not null; Fixes #9587
6216 if ( destElements[i] ) {
6217 cloneFixAttributes( srcElements[i], destElements[i] );
6222 // Copy the events from the original to the clone
6223 if ( dataAndEvents ) {
6224 cloneCopyEvent( elem, clone );
6226 if ( deepDataAndEvents ) {
6227 srcElements = getAll( elem );
6228 destElements = getAll( clone );
6230 for ( i = 0; srcElements[i]; ++i ) {
6231 cloneCopyEvent( srcElements[i], destElements[i] );
6236 srcElements = destElements = null;
6238 // Return the cloned set
6242 clean: function( elems, context, fragment, scripts ) {
6243 var checkScriptType;
6245 context = context || document;
6247 // !context.createElement fails in IE with an error but returns typeof 'object'
6248 if ( typeof context.createElement === "undefined" ) {
6249 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
6254 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6255 if ( typeof elem === "number" ) {
6263 // Convert html string into DOM nodes
6264 if ( typeof elem === "string" ) {
6265 if ( !rhtml.test( elem ) ) {
6266 elem = context.createTextNode( elem );
6268 // Fix "XHTML"-style tags in all browsers
6269 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6271 // Trim whitespace, otherwise indexOf won't work as expected
6272 var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
6273 wrap = wrapMap[ tag ] || wrapMap._default,
6275 div = context.createElement("div");
6277 // Append wrapper element to unknown element safe doc fragment
6278 if ( context === document ) {
6279 // Use the fragment we've already created for this document
6280 safeFragment.appendChild( div );
6282 // Use a fragment created with the owner document
6283 createSafeFragment( context ).appendChild( div );
6286 // Go to html and back, then peel off extra wrappers
6287 div.innerHTML = wrap[1] + elem + wrap[2];
6289 // Move to the right depth
6291 div = div.lastChild;
6294 // Remove IE's autoinserted <tbody> from table fragments
6295 if ( !jQuery.support.tbody ) {
6297 // String was a <table>, *may* have spurious <tbody>
6298 var hasBody = rtbody.test(elem),
6299 tbody = tag === "table" && !hasBody ?
6300 div.firstChild && div.firstChild.childNodes :
6302 // String was a bare <thead> or <tfoot>
6303 wrap[1] === "<table>" && !hasBody ?
6307 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6308 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6309 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6314 // IE completely kills leading whitespace when innerHTML is used
6315 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6316 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6319 elem = div.childNodes;
6323 // Resets defaultChecked for any radios and checkboxes
6324 // about to be appended to the DOM in IE 6/7 (#8060)
6326 if ( !jQuery.support.appendChecked ) {
6327 if ( elem[0] && typeof (len = elem.length) === "number" ) {
6328 for ( j = 0; j < len; j++ ) {
6329 findInputs( elem[j] );
6336 if ( elem.nodeType ) {
6339 ret = jQuery.merge( ret, elem );
6344 checkScriptType = function( elem ) {
6345 return !elem.type || rscriptType.test( elem.type );
6347 for ( i = 0; ret[i]; i++ ) {
6348 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
6349 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
6352 if ( ret[i].nodeType === 1 ) {
6353 var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
6355 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6357 fragment.appendChild( ret[i] );
6365 cleanData: function( elems ) {
6367 cache = jQuery.cache,
6368 special = jQuery.event.special,
6369 deleteExpando = jQuery.support.deleteExpando;
6371 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6372 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
6376 id = elem[ jQuery.expando ];
6381 if ( data && data.events ) {
6382 for ( var type in data.events ) {
6383 if ( special[ type ] ) {
6384 jQuery.event.remove( elem, type );
6386 // This is a shortcut to avoid jQuery.event.remove's overhead
6388 jQuery.removeEvent( elem, type, data.handle );
6392 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6393 if ( data.handle ) {
6394 data.handle.elem = null;
6398 if ( deleteExpando ) {
6399 delete elem[ jQuery.expando ];
6401 } else if ( elem.removeAttribute ) {
6402 elem.removeAttribute( jQuery.expando );
6411 function evalScript( i, elem ) {
6419 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
6422 if ( elem.parentNode ) {
6423 elem.parentNode.removeChild( elem );
6430 var ralpha = /alpha\([^)]*\)/i,
6431 ropacity = /opacity=([^)]*)/,
6432 // fixed for IE9, see #8346
6433 rupper = /([A-Z]|^ms)/g,
6434 rnumpx = /^-?\d+(?:px)?$/i,
6436 rrelNum = /^([\-+])=([\-+.\de]+)/,
6438 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6439 cssWidth = [ "Left", "Right" ],
6440 cssHeight = [ "Top", "Bottom" ],
6446 jQuery.fn.css = function( name, value ) {
6447 // Setting 'undefined' is a no-op
6448 if ( arguments.length === 2 && value === undefined ) {
6452 return jQuery.access( this, name, value, true, function( elem, name, value ) {
6453 return value !== undefined ?
6454 jQuery.style( elem, name, value ) :
6455 jQuery.css( elem, name );
6460 // Add in style property hooks for overriding the default
6461 // behavior of getting and setting a style property
6464 get: function( elem, computed ) {
6466 // We should always get a number back from opacity
6467 var ret = curCSS( elem, "opacity", "opacity" );
6468 return ret === "" ? "1" : ret;
6471 return elem.style.opacity;
6477 // Exclude the following css properties to add px
6479 "fillOpacity": true,
6489 // Add in properties whose names you wish to fix before
6490 // setting or getting the value
6492 // normalize float css property
6493 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6496 // Get and set the style property on a DOM Node
6497 style: function( elem, name, value, extra ) {
6498 // Don't set styles on text and comment nodes
6499 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6503 // Make sure that we're working with the right name
6504 var ret, type, origName = jQuery.camelCase( name ),
6505 style = elem.style, hooks = jQuery.cssHooks[ origName ];
6507 name = jQuery.cssProps[ origName ] || origName;
6509 // Check if we're setting a value
6510 if ( value !== undefined ) {
6511 type = typeof value;
6513 // convert relative number strings (+= or -=) to relative numbers. #7345
6514 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6515 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
6520 // Make sure that NaN and null values aren't set. See: #7116
6521 if ( value == null || type === "number" && isNaN( value ) ) {
6525 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6526 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6530 // If a hook was provided, use that value, otherwise just set the specified value
6531 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
6532 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6535 style[ name ] = value;
6540 // If a hook was provided get the non-computed value from there
6541 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6545 // Otherwise just get the value from the style object
6546 return style[ name ];
6550 css: function( elem, name, extra ) {
6553 // Make sure that we're working with the right name
6554 name = jQuery.camelCase( name );
6555 hooks = jQuery.cssHooks[ name ];
6556 name = jQuery.cssProps[ name ] || name;
6558 // cssFloat needs a special treatment
6559 if ( name === "cssFloat" ) {
6563 // If a hook was provided get the computed value from there
6564 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
6567 // Otherwise, if a way to get the computed value exists, use that
6568 } else if ( curCSS ) {
6569 return curCSS( elem, name );
6573 // A method for quickly swapping in/out CSS properties to get correct calculations
6574 swap: function( elem, options, callback ) {
6577 // Remember the old values, and insert the new ones
6578 for ( var name in options ) {
6579 old[ name ] = elem.style[ name ];
6580 elem.style[ name ] = options[ name ];
6583 callback.call( elem );
6585 // Revert the old values
6586 for ( name in options ) {
6587 elem.style[ name ] = old[ name ];
6592 // DEPRECATED, Use jQuery.css() instead
6593 jQuery.curCSS = jQuery.css;
6595 jQuery.each(["height", "width"], function( i, name ) {
6596 jQuery.cssHooks[ name ] = {
6597 get: function( elem, computed, extra ) {
6601 if ( elem.offsetWidth !== 0 ) {
6602 return getWH( elem, name, extra );
6604 jQuery.swap( elem, cssShow, function() {
6605 val = getWH( elem, name, extra );
6613 set: function( elem, value ) {
6614 if ( rnumpx.test( value ) ) {
6615 // ignore negative width and height values #1599
6616 value = parseFloat( value );
6619 return value + "px";
6629 if ( !jQuery.support.opacity ) {
6630 jQuery.cssHooks.opacity = {
6631 get: function( elem, computed ) {
6632 // IE uses filters for opacity
6633 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6634 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
6635 computed ? "1" : "";
6638 set: function( elem, value ) {
6639 var style = elem.style,
6640 currentStyle = elem.currentStyle,
6641 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
6642 filter = currentStyle && currentStyle.filter || style.filter || "";
6644 // IE has trouble with opacity if it does not have layout
6645 // Force it by setting the zoom level
6648 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6649 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
6651 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6652 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6653 // style.removeAttribute is IE Only, but so apparently is this code path...
6654 style.removeAttribute( "filter" );
6656 // if there there is no filter style applied in a css rule, we are done
6657 if ( currentStyle && !currentStyle.filter ) {
6662 // otherwise, set new filter values
6663 style.filter = ralpha.test( filter ) ?
6664 filter.replace( ralpha, opacity ) :
6665 filter + " " + opacity;
6671 // This hook cannot be added until DOM ready because the support test
6672 // for it is not run until after DOM ready
6673 if ( !jQuery.support.reliableMarginRight ) {
6674 jQuery.cssHooks.marginRight = {
6675 get: function( elem, computed ) {
6676 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6677 // Work around by temporarily setting element display to inline-block
6679 jQuery.swap( elem, { "display": "inline-block" }, function() {
6681 ret = curCSS( elem, "margin-right", "marginRight" );
6683 ret = elem.style.marginRight;
6692 if ( document.defaultView && document.defaultView.getComputedStyle ) {
6693 getComputedStyle = function( elem, name ) {
6694 var ret, defaultView, computedStyle;
6696 name = name.replace( rupper, "-$1" ).toLowerCase();
6698 if ( (defaultView = elem.ownerDocument.defaultView) &&
6699 (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
6700 ret = computedStyle.getPropertyValue( name );
6701 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6702 ret = jQuery.style( elem, name );
6710 if ( document.documentElement.currentStyle ) {
6711 currentStyle = function( elem, name ) {
6712 var left, rsLeft, uncomputed,
6713 ret = elem.currentStyle && elem.currentStyle[ name ],
6716 // Avoid setting ret to empty string here
6717 // so we don't default to auto
6718 if ( ret === null && style && (uncomputed = style[ name ]) ) {
6722 // From the awesome hack by Dean Edwards
6723 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6725 // If we're not dealing with a regular pixel number
6726 // but a number that has a weird ending, we need to convert it to pixels
6727 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6729 // Remember the original values
6731 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6733 // Put in the new values to get a computed value out
6735 elem.runtimeStyle.left = elem.currentStyle.left;
6737 style.left = name === "fontSize" ? "1em" : ( ret || 0 );
6738 ret = style.pixelLeft + "px";
6740 // Revert the changed values
6743 elem.runtimeStyle.left = rsLeft;
6747 return ret === "" ? "auto" : ret;
6751 curCSS = getComputedStyle || currentStyle;
6753 function getWH( elem, name, extra ) {
6755 // Start with offset property
6756 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6757 which = name === "width" ? cssWidth : cssHeight,
6762 if ( extra !== "border" ) {
6763 for ( ; i < len; i++ ) {
6765 val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
6767 if ( extra === "margin" ) {
6768 val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
6770 val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
6778 // Fall back to computed then uncomputed css if necessary
6779 val = curCSS( elem, name, name );
6780 if ( val < 0 || val == null ) {
6781 val = elem.style[ name ] || 0;
6783 // Normalize "", auto, and prepare for extra
6784 val = parseFloat( val ) || 0;
6786 // Add padding, border, margin
6788 for ( ; i < len; i++ ) {
6789 val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
6790 if ( extra !== "padding" ) {
6791 val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
6793 if ( extra === "margin" ) {
6794 val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
6802 if ( jQuery.expr && jQuery.expr.filters ) {
6803 jQuery.expr.filters.hidden = function( elem ) {
6804 var width = elem.offsetWidth,
6805 height = elem.offsetHeight;
6807 return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
6810 jQuery.expr.filters.visible = function( elem ) {
6811 return !jQuery.expr.filters.hidden( elem );
6822 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
6823 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6824 // #7653, #8125, #8152: local protocol detection
6825 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6826 rnoContent = /^(?:GET|HEAD)$/,
6827 rprotocol = /^\/\//,
6829 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6830 rselectTextarea = /^(?:select|textarea)/i,
6831 rspacesAjax = /\s+/,
6832 rts = /([?&])_=[^&]*/,
6833 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6835 // Keep a copy of the old load method
6836 _load = jQuery.fn.load,
6839 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6840 * 2) These are called:
6841 * - BEFORE asking for a transport
6842 * - AFTER param serialization (s.data is a string if s.processData is true)
6843 * 3) key is the dataType
6844 * 4) the catchall symbol "*" can be used
6845 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6849 /* Transports bindings
6850 * 1) key is the dataType
6851 * 2) the catchall symbol "*" can be used
6852 * 3) selection will start with transport dataType and THEN go to "*" if needed
6856 // Document location
6859 // Document location segments
6862 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6863 allTypes = ["*/"] + ["*"];
6865 // #8138, IE may throw an exception when accessing
6866 // a field from window.location if document.domain has been set
6868 ajaxLocation = location.href;
6870 // Use the href attribute of an A element
6871 // since IE will modify it given document.location
6872 ajaxLocation = document.createElement( "a" );
6873 ajaxLocation.href = "";
6874 ajaxLocation = ajaxLocation.href;
6877 // Segment location into parts
6878 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
6880 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6881 function addToPrefiltersOrTransports( structure ) {
6883 // dataTypeExpression is optional and defaults to "*"
6884 return function( dataTypeExpression, func ) {
6886 if ( typeof dataTypeExpression !== "string" ) {
6887 func = dataTypeExpression;
6888 dataTypeExpression = "*";
6891 if ( jQuery.isFunction( func ) ) {
6892 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
6894 length = dataTypes.length,
6899 // For each dataType in the dataTypeExpression
6900 for ( ; i < length; i++ ) {
6901 dataType = dataTypes[ i ];
6902 // We control if we're asked to add before
6903 // any existing element
6904 placeBefore = /^\+/.test( dataType );
6905 if ( placeBefore ) {
6906 dataType = dataType.substr( 1 ) || "*";
6908 list = structure[ dataType ] = structure[ dataType ] || [];
6909 // then we add to the structure accordingly
6910 list[ placeBefore ? "unshift" : "push" ]( func );
6916 // Base inspection function for prefilters and transports
6917 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6918 dataType /* internal */, inspected /* internal */ ) {
6920 dataType = dataType || options.dataTypes[ 0 ];
6921 inspected = inspected || {};
6923 inspected[ dataType ] = true;
6925 var list = structure[ dataType ],
6927 length = list ? list.length : 0,
6928 executeOnly = ( structure === prefilters ),
6931 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
6932 selection = list[ i ]( options, originalOptions, jqXHR );
6933 // If we got redirected to another dataType
6934 // we try there if executing only and not done already
6935 if ( typeof selection === "string" ) {
6936 if ( !executeOnly || inspected[ selection ] ) {
6937 selection = undefined;
6939 options.dataTypes.unshift( selection );
6940 selection = inspectPrefiltersOrTransports(
6941 structure, options, originalOptions, jqXHR, selection, inspected );
6945 // If we're only executing or nothing was selected
6946 // we try the catchall dataType if not done already
6947 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6948 selection = inspectPrefiltersOrTransports(
6949 structure, options, originalOptions, jqXHR, "*", inspected );
6951 // unnecessary when only executing (prefilters)
6952 // but it'll be ignored by the caller in that case
6956 // A special extend for ajax options
6957 // that takes "flat" options (not to be deep extended)
6959 function ajaxExtend( target, src ) {
6961 flatOptions = jQuery.ajaxSettings.flatOptions || {};
6962 for ( key in src ) {
6963 if ( src[ key ] !== undefined ) {
6964 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
6968 jQuery.extend( true, target, deep );
6973 load: function( url, params, callback ) {
6974 if ( typeof url !== "string" && _load ) {
6975 return _load.apply( this, arguments );
6977 // Don't do a request if no elements are being requested
6978 } else if ( !this.length ) {
6982 var off = url.indexOf( " " );
6984 var selector = url.slice( off, url.length );
6985 url = url.slice( 0, off );
6988 // Default to a GET request
6991 // If the second parameter was provided
6993 // If it's a function
6994 if ( jQuery.isFunction( params ) ) {
6995 // We assume that it's the callback
6999 // Otherwise, build a param string
7000 } else if ( typeof params === "object" ) {
7001 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
7008 // Request the remote document
7014 // Complete callback (responseText is used internally)
7015 complete: function( jqXHR, status, responseText ) {
7016 // Store the response as specified by the jqXHR object
7017 responseText = jqXHR.responseText;
7018 // If successful, inject the HTML into all the matched elements
7019 if ( jqXHR.isResolved() ) {
7020 // #4825: Get the actual response in case
7021 // a dataFilter is present in ajaxSettings
7022 jqXHR.done(function( r ) {
7025 // See if a selector was specified
7026 self.html( selector ?
7027 // Create a dummy div to hold the results
7029 // inject the contents of the document in, removing the scripts
7030 // to avoid any 'Permission Denied' errors in IE
7031 .append(responseText.replace(rscript, ""))
7033 // Locate the specified elements
7036 // If not, just inject the full result
7041 self.each( callback, [ responseText, status, jqXHR ] );
7049 serialize: function() {
7050 return jQuery.param( this.serializeArray() );
7053 serializeArray: function() {
7054 return this.map(function(){
7055 return this.elements ? jQuery.makeArray( this.elements ) : this;
7058 return this.name && !this.disabled &&
7059 ( this.checked || rselectTextarea.test( this.nodeName ) ||
7060 rinput.test( this.type ) );
7062 .map(function( i, elem ){
7063 var val = jQuery( this ).val();
7065 return val == null ?
7067 jQuery.isArray( val ) ?
7068 jQuery.map( val, function( val, i ){
7069 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7071 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7076 // Attach a bunch of functions for handling common AJAX events
7077 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
7078 jQuery.fn[ o ] = function( f ){
7079 return this.on( o, f );
7083 jQuery.each( [ "get", "post" ], function( i, method ) {
7084 jQuery[ method ] = function( url, data, callback, type ) {
7085 // shift arguments if data argument was omitted
7086 if ( jQuery.isFunction( data ) ) {
7087 type = type || callback;
7092 return jQuery.ajax({
7104 getScript: function( url, callback ) {
7105 return jQuery.get( url, undefined, callback, "script" );
7108 getJSON: function( url, data, callback ) {
7109 return jQuery.get( url, data, callback, "json" );
7112 // Creates a full fledged settings object into target
7113 // with both ajaxSettings and settings fields.
7114 // If target is omitted, writes into ajaxSettings.
7115 ajaxSetup: function( target, settings ) {
7117 // Building a settings object
7118 ajaxExtend( target, jQuery.ajaxSettings );
7120 // Extending ajaxSettings
7122 target = jQuery.ajaxSettings;
7124 ajaxExtend( target, settings );
7130 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7133 contentType: "application/x-www-form-urlencoded",
7148 xml: "application/xml, text/xml",
7151 json: "application/json, text/javascript",
7163 text: "responseText"
7166 // List of data converters
7167 // 1) key format is "source_type destination_type" (a single space in-between)
7168 // 2) the catchall symbol "*" can be used for source_type
7171 // Convert anything to text
7172 "* text": window.String,
7174 // Text to html (true = no transformation)
7177 // Evaluate text as a json expression
7178 "text json": jQuery.parseJSON,
7180 // Parse text as xml
7181 "text xml": jQuery.parseXML
7184 // For options that shouldn't be deep extended:
7185 // you can add your own custom options here if
7186 // and when you create one that shouldn't be
7187 // deep extended (see ajaxExtend)
7194 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7195 ajaxTransport: addToPrefiltersOrTransports( transports ),
7198 ajax: function( url, options ) {
7200 // If url is an object, simulate pre-1.5 signature
7201 if ( typeof url === "object" ) {
7206 // Force options to be an object
7207 options = options || {};
7209 var // Create the final options object
7210 s = jQuery.ajaxSetup( {}, options ),
7211 // Callbacks context
7212 callbackContext = s.context || s,
7213 // Context for global events
7214 // It's the callbackContext if one was provided in the options
7215 // and if it's a DOM node or a jQuery collection
7216 globalEventContext = callbackContext !== s &&
7217 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7218 jQuery( callbackContext ) : jQuery.event,
7220 deferred = jQuery.Deferred(),
7221 completeDeferred = jQuery.Callbacks( "once memory" ),
7222 // Status-dependent callbacks
7223 statusCode = s.statusCode || {},
7226 // Headers (they are sent all at once)
7227 requestHeaders = {},
7228 requestHeadersNames = {},
7230 responseHeadersString,
7236 // Cross-domain detection vars
7240 // To know if global events are to be dispatched
7249 // Caches the header
7250 setRequestHeader: function( name, value ) {
7252 var lname = name.toLowerCase();
7253 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7254 requestHeaders[ name ] = value;
7260 getAllResponseHeaders: function() {
7261 return state === 2 ? responseHeadersString : null;
7264 // Builds headers hashtable if needed
7265 getResponseHeader: function( key ) {
7267 if ( state === 2 ) {
7268 if ( !responseHeaders ) {
7269 responseHeaders = {};
7270 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7271 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7274 match = responseHeaders[ key.toLowerCase() ];
7276 return match === undefined ? null : match;
7279 // Overrides response content-type header
7280 overrideMimeType: function( type ) {
7287 // Cancel the request
7288 abort: function( statusText ) {
7289 statusText = statusText || "abort";
7291 transport.abort( statusText );
7293 done( 0, statusText );
7298 // Callback for when everything is done
7299 // It is defined here because jslint complains if it is declared
7300 // at the end of the function (which would be more logical and readable)
7301 function done( status, nativeStatusText, responses, headers ) {
7304 if ( state === 2 ) {
7308 // State is "done" now
7311 // Clear timeout if it exists
7312 if ( timeoutTimer ) {
7313 clearTimeout( timeoutTimer );
7316 // Dereference transport for early garbage collection
7317 // (no matter how long the jqXHR object will be used)
7318 transport = undefined;
7320 // Cache response headers
7321 responseHeadersString = headers || "";
7324 jqXHR.readyState = status > 0 ? 4 : 0;
7329 statusText = nativeStatusText,
7330 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
7334 // If successful, handle type chaining
7335 if ( status >= 200 && status < 300 || status === 304 ) {
7337 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7338 if ( s.ifModified ) {
7340 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
7341 jQuery.lastModified[ ifModifiedKey ] = lastModified;
7343 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
7344 jQuery.etag[ ifModifiedKey ] = etag;
7349 if ( status === 304 ) {
7351 statusText = "notmodified";
7358 success = ajaxConvert( s, response );
7359 statusText = "success";
7362 // We have a parsererror
7363 statusText = "parsererror";
7368 // We extract error from statusText
7369 // then normalize statusText and status for non-aborts
7371 if ( !statusText || status ) {
7372 statusText = "error";
7379 // Set data for the fake xhr object
7380 jqXHR.status = status;
7381 jqXHR.statusText = "" + ( nativeStatusText || statusText );
7385 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7387 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7390 // Status-dependent callbacks
7391 jqXHR.statusCode( statusCode );
7392 statusCode = undefined;
7394 if ( fireGlobals ) {
7395 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7396 [ jqXHR, s, isSuccess ? success : error ] );
7400 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7402 if ( fireGlobals ) {
7403 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7404 // Handle the global AJAX counter
7405 if ( !( --jQuery.active ) ) {
7406 jQuery.event.trigger( "ajaxStop" );
7412 deferred.promise( jqXHR );
7413 jqXHR.success = jqXHR.done;
7414 jqXHR.error = jqXHR.fail;
7415 jqXHR.complete = completeDeferred.add;
7417 // Status-dependent callbacks
7418 jqXHR.statusCode = function( map ) {
7422 for ( tmp in map ) {
7423 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7426 tmp = map[ jqXHR.status ];
7427 jqXHR.then( tmp, tmp );
7433 // Remove hash character (#7531: and string promotion)
7434 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7435 // We also use the url parameter if available
7436 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7438 // Extract dataTypes list
7439 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
7441 // Determine if a cross-domain request is in order
7442 if ( s.crossDomain == null ) {
7443 parts = rurl.exec( s.url.toLowerCase() );
7444 s.crossDomain = !!( parts &&
7445 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7446 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7447 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7451 // Convert data if not already a string
7452 if ( s.data && s.processData && typeof s.data !== "string" ) {
7453 s.data = jQuery.param( s.data, s.traditional );
7457 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7459 // If request was aborted inside a prefiler, stop there
7460 if ( state === 2 ) {
7464 // We can fire global events as of now if asked to
7465 fireGlobals = s.global;
7467 // Uppercase the type
7468 s.type = s.type.toUpperCase();
7470 // Determine if request has content
7471 s.hasContent = !rnoContent.test( s.type );
7473 // Watch for a new set of requests
7474 if ( fireGlobals && jQuery.active++ === 0 ) {
7475 jQuery.event.trigger( "ajaxStart" );
7478 // More options handling for requests with no content
7479 if ( !s.hasContent ) {
7481 // If data is available, append data to url
7483 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7484 // #9682: remove data so that it's not used in an eventual retry
7488 // Get ifModifiedKey before adding the anti-cache parameter
7489 ifModifiedKey = s.url;
7491 // Add anti-cache in url if needed
7492 if ( s.cache === false ) {
7494 var ts = jQuery.now(),
7495 // try replacing _= if it is there
7496 ret = s.url.replace( rts, "$1_=" + ts );
7498 // if nothing was replaced, add timestamp to the end
7499 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7503 // Set the correct header, if data is being sent
7504 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7505 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7508 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7509 if ( s.ifModified ) {
7510 ifModifiedKey = ifModifiedKey || s.url;
7511 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7512 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7514 if ( jQuery.etag[ ifModifiedKey ] ) {
7515 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7519 // Set the Accepts header for the server, depending on the dataType
7520 jqXHR.setRequestHeader(
7522 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7523 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7527 // Check for headers option
7528 for ( i in s.headers ) {
7529 jqXHR.setRequestHeader( i, s.headers[ i ] );
7532 // Allow custom headers/mimetypes and early abort
7533 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7534 // Abort if not done already
7540 // Install callbacks on deferreds
7541 for ( i in { success: 1, error: 1, complete: 1 } ) {
7542 jqXHR[ i ]( s[ i ] );
7546 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7548 // If no transport, we auto-abort
7550 done( -1, "No Transport" );
7552 jqXHR.readyState = 1;
7553 // Send global event
7554 if ( fireGlobals ) {
7555 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7558 if ( s.async && s.timeout > 0 ) {
7559 timeoutTimer = setTimeout( function(){
7560 jqXHR.abort( "timeout" );
7566 transport.send( requestHeaders, done );
7568 // Propagate exception as error if not done
7571 // Simply rethrow otherwise
7581 // Serialize an array of form elements or a set of
7582 // key/values into a query string
7583 param: function( a, traditional ) {
7585 add = function( key, value ) {
7586 // If value is a function, invoke it and return its value
7587 value = jQuery.isFunction( value ) ? value() : value;
7588 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7591 // Set traditional to true for jQuery <= 1.3.2 behavior.
7592 if ( traditional === undefined ) {
7593 traditional = jQuery.ajaxSettings.traditional;
7596 // If an array was passed in, assume that it is an array of form elements.
7597 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7598 // Serialize the form elements
7599 jQuery.each( a, function() {
7600 add( this.name, this.value );
7604 // If traditional, encode the "old" way (the way 1.3.2 or older
7605 // did it), otherwise encode params recursively.
7606 for ( var prefix in a ) {
7607 buildParams( prefix, a[ prefix ], traditional, add );
7611 // Return the resulting serialization
7612 return s.join( "&" ).replace( r20, "+" );
7616 function buildParams( prefix, obj, traditional, add ) {
7617 if ( jQuery.isArray( obj ) ) {
7618 // Serialize array item.
7619 jQuery.each( obj, function( i, v ) {
7620 if ( traditional || rbracket.test( prefix ) ) {
7621 // Treat each array item as a scalar.
7625 // If array item is non-scalar (array or object), encode its
7626 // numeric index to resolve deserialization ambiguity issues.
7627 // Note that rack (as of 1.0.0) can't currently deserialize
7628 // nested arrays properly, and attempting to do so may cause
7629 // a server error. Possible fixes are to modify rack's
7630 // deserialization algorithm or to provide an option or flag
7631 // to force array serialization to be shallow.
7632 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
7636 } else if ( !traditional && obj != null && typeof obj === "object" ) {
7637 // Serialize object item.
7638 for ( var name in obj ) {
7639 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7643 // Serialize scalar item.
7648 // This is still on the jQuery object... for now
7649 // Want to move this to jQuery.ajax some day
7652 // Counter for holding the number of active queries
7655 // Last-Modified header cache for next request
7661 /* Handles responses to an ajax request:
7662 * - sets all responseXXX fields accordingly
7663 * - finds the right dataType (mediates between content-type and expected dataType)
7664 * - returns the corresponding response
7666 function ajaxHandleResponses( s, jqXHR, responses ) {
7668 var contents = s.contents,
7669 dataTypes = s.dataTypes,
7670 responseFields = s.responseFields,
7676 // Fill responseXXX fields
7677 for ( type in responseFields ) {
7678 if ( type in responses ) {
7679 jqXHR[ responseFields[type] ] = responses[ type ];
7683 // Remove auto dataType and get content-type in the process
7684 while( dataTypes[ 0 ] === "*" ) {
7686 if ( ct === undefined ) {
7687 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
7691 // Check if we're dealing with a known content-type
7693 for ( type in contents ) {
7694 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7695 dataTypes.unshift( type );
7701 // Check to see if we have a response for the expected dataType
7702 if ( dataTypes[ 0 ] in responses ) {
7703 finalDataType = dataTypes[ 0 ];
7705 // Try convertible dataTypes
7706 for ( type in responses ) {
7707 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7708 finalDataType = type;
7711 if ( !firstDataType ) {
7712 firstDataType = type;
7715 // Or just use first one
7716 finalDataType = finalDataType || firstDataType;
7719 // If we found a dataType
7720 // We add the dataType to the list if needed
7721 // and return the corresponding response
7722 if ( finalDataType ) {
7723 if ( finalDataType !== dataTypes[ 0 ] ) {
7724 dataTypes.unshift( finalDataType );
7726 return responses[ finalDataType ];
7730 // Chain conversions given the request and the original response
7731 function ajaxConvert( s, response ) {
7733 // Apply the dataFilter if provided
7734 if ( s.dataFilter ) {
7735 response = s.dataFilter( response, s.dataType );
7738 var dataTypes = s.dataTypes,
7742 length = dataTypes.length,
7744 // Current and previous dataTypes
7745 current = dataTypes[ 0 ],
7747 // Conversion expression
7749 // Conversion function
7751 // Conversion functions (transitive conversion)
7755 // For each dataType in the chain
7756 for ( i = 1; i < length; i++ ) {
7758 // Create converters map
7759 // with lowercased keys
7761 for ( key in s.converters ) {
7762 if ( typeof key === "string" ) {
7763 converters[ key.toLowerCase() ] = s.converters[ key ];
7768 // Get the dataTypes
7770 current = dataTypes[ i ];
7772 // If current is auto dataType, update it to prev
7773 if ( current === "*" ) {
7775 // If no auto and dataTypes are actually different
7776 } else if ( prev !== "*" && prev !== current ) {
7778 // Get the converter
7779 conversion = prev + " " + current;
7780 conv = converters[ conversion ] || converters[ "* " + current ];
7782 // If there is no direct converter, search transitively
7785 for ( conv1 in converters ) {
7786 tmp = conv1.split( " " );
7787 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7788 conv2 = converters[ tmp[1] + " " + current ];
7790 conv1 = converters[ conv1 ];
7791 if ( conv1 === true ) {
7793 } else if ( conv2 === true ) {
7801 // If we found no converter, dispatch an error
7802 if ( !( conv || conv2 ) ) {
7803 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
7805 // If found converter is not an equivalence
7806 if ( conv !== true ) {
7807 // Convert with 1 or 2 converters accordingly
7808 response = conv ? conv( response ) : conv2( conv1(response) );
7818 var jsc = jQuery.now(),
7819 jsre = /(\=)\?(&|$)|\?\?/i;
7821 // Default jsonp settings
7824 jsonpCallback: function() {
7825 return jQuery.expando + "_" + ( jsc++ );
7829 // Detect, normalize options and install callbacks for jsonp requests
7830 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
7832 var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
7833 ( typeof s.data === "string" );
7835 if ( s.dataTypes[ 0 ] === "jsonp" ||
7836 s.jsonp !== false && ( jsre.test( s.url ) ||
7837 inspectData && jsre.test( s.data ) ) ) {
7839 var responseContainer,
7840 jsonpCallback = s.jsonpCallback =
7841 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
7842 previous = window[ jsonpCallback ],
7845 replace = "$1" + jsonpCallback + "$2";
7847 if ( s.jsonp !== false ) {
7848 url = url.replace( jsre, replace );
7849 if ( s.url === url ) {
7850 if ( inspectData ) {
7851 data = data.replace( jsre, replace );
7853 if ( s.data === data ) {
7854 // Add callback manually
7855 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
7864 window[ jsonpCallback ] = function( response ) {
7865 responseContainer = [ response ];
7868 // Clean-up function
7869 jqXHR.always(function() {
7870 // Set callback back to previous value
7871 window[ jsonpCallback ] = previous;
7872 // Call if it was a function and we have a response
7873 if ( responseContainer && jQuery.isFunction( previous ) ) {
7874 window[ jsonpCallback ]( responseContainer[ 0 ] );
7878 // Use data converter to retrieve json after script execution
7879 s.converters["script json"] = function() {
7880 if ( !responseContainer ) {
7881 jQuery.error( jsonpCallback + " was not called" );
7883 return responseContainer[ 0 ];
7886 // force json dataType
7887 s.dataTypes[ 0 ] = "json";
7889 // Delegate to script
7897 // Install script dataType
7900 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7903 script: /javascript|ecmascript/
7906 "text script": function( text ) {
7907 jQuery.globalEval( text );
7913 // Handle cache's special case and global
7914 jQuery.ajaxPrefilter( "script", function( s ) {
7915 if ( s.cache === undefined ) {
7918 if ( s.crossDomain ) {
7924 // Bind script tag hack transport
7925 jQuery.ajaxTransport( "script", function(s) {
7927 // This transport only deals with cross domain requests
7928 if ( s.crossDomain ) {
7931 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7935 send: function( _, callback ) {
7937 script = document.createElement( "script" );
7939 script.async = "async";
7941 if ( s.scriptCharset ) {
7942 script.charset = s.scriptCharset;
7947 // Attach handlers for all browsers
7948 script.onload = script.onreadystatechange = function( _, isAbort ) {
7950 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
7952 // Handle memory leak in IE
7953 script.onload = script.onreadystatechange = null;
7955 // Remove the script
7956 if ( head && script.parentNode ) {
7957 head.removeChild( script );
7960 // Dereference the script
7963 // Callback if not abort
7965 callback( 200, "success" );
7969 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
7970 // This arises when a base node is used (#2709 and #4378).
7971 head.insertBefore( script, head.firstChild );
7976 script.onload( 0, 1 );
7986 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
7987 xhrOnUnloadAbort = window.ActiveXObject ? function() {
7988 // Abort all pending requests
7989 for ( var key in xhrCallbacks ) {
7990 xhrCallbacks[ key ]( 0, 1 );
7996 // Functions to create xhrs
7997 function createStandardXHR() {
7999 return new window.XMLHttpRequest();
8003 function createActiveXHR() {
8005 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
8009 // Create the request object
8010 // (This is still attached to ajaxSettings for backward compatibility)
8011 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8012 /* Microsoft failed to properly
8013 * implement the XMLHttpRequest in IE7 (can't request local files),
8014 * so we use the ActiveXObject when it is available
8015 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8016 * we need a fallback.
8019 return !this.isLocal && createStandardXHR() || createActiveXHR();
8021 // For all other browsers, use the standard XMLHttpRequest object
8024 // Determine support properties
8026 jQuery.extend( jQuery.support, {
8028 cors: !!xhr && ( "withCredentials" in xhr )
8030 })( jQuery.ajaxSettings.xhr() );
8032 // Create transport if the browser can provide an xhr
8033 if ( jQuery.support.ajax ) {
8035 jQuery.ajaxTransport(function( s ) {
8036 // Cross domain only allowed if supported through XMLHttpRequest
8037 if ( !s.crossDomain || jQuery.support.cors ) {
8042 send: function( headers, complete ) {
8050 // Passing null username, generates a login popup on Opera (#2865)
8052 xhr.open( s.type, s.url, s.async, s.username, s.password );
8054 xhr.open( s.type, s.url, s.async );
8057 // Apply custom fields if provided
8058 if ( s.xhrFields ) {
8059 for ( i in s.xhrFields ) {
8060 xhr[ i ] = s.xhrFields[ i ];
8064 // Override mime type if needed
8065 if ( s.mimeType && xhr.overrideMimeType ) {
8066 xhr.overrideMimeType( s.mimeType );
8069 // X-Requested-With header
8070 // For cross-domain requests, seeing as conditions for a preflight are
8071 // akin to a jigsaw puzzle, we simply never set it to be sure.
8072 // (it can always be set on a per-request basis or even using ajaxSetup)
8073 // For same-domain requests, won't change header if already provided.
8074 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8075 headers[ "X-Requested-With" ] = "XMLHttpRequest";
8078 // Need an extra try/catch for cross domain requests in Firefox 3
8080 for ( i in headers ) {
8081 xhr.setRequestHeader( i, headers[ i ] );
8085 // Do send the request
8086 // This may raise an exception which is actually
8087 // handled in jQuery.ajax (so no try/catch here)
8088 xhr.send( ( s.hasContent && s.data ) || null );
8091 callback = function( _, isAbort ) {
8099 // Firefox throws exceptions when accessing properties
8100 // of an xhr when a network error occurred
8101 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8104 // Was never called and is aborted or complete
8105 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8108 callback = undefined;
8110 // Do not keep as active anymore
8112 xhr.onreadystatechange = jQuery.noop;
8113 if ( xhrOnUnloadAbort ) {
8114 delete xhrCallbacks[ handle ];
8120 // Abort it manually if needed
8121 if ( xhr.readyState !== 4 ) {
8125 status = xhr.status;
8126 responseHeaders = xhr.getAllResponseHeaders();
8128 xml = xhr.responseXML;
8130 // Construct response list
8131 if ( xml && xml.documentElement /* #4958 */ ) {
8132 responses.xml = xml;
8134 responses.text = xhr.responseText;
8136 // Firefox throws an exception when accessing
8137 // statusText for faulty cross-domain requests
8139 statusText = xhr.statusText;
8141 // We normalize with Webkit giving an empty statusText
8145 // Filter status for non standard behaviors
8147 // If the request is local and we have data: assume a success
8148 // (success with no data won't get notified, that's the best we
8149 // can do given current implementations)
8150 if ( !status && s.isLocal && !s.crossDomain ) {
8151 status = responses.text ? 200 : 404;
8152 // IE - #1450: sometimes returns 1223 when it should be 204
8153 } else if ( status === 1223 ) {
8158 } catch( firefoxAccessException ) {
8160 complete( -1, firefoxAccessException );
8164 // Call complete if needed
8166 complete( status, statusText, responses, responseHeaders );
8170 // if we're in sync mode or it's in cache
8171 // and has been retrieved directly (IE6 & IE7)
8172 // we need to manually fire the callback
8173 if ( !s.async || xhr.readyState === 4 ) {
8177 if ( xhrOnUnloadAbort ) {
8178 // Create the active xhrs callbacks list if needed
8179 // and attach the unload handler
8180 if ( !xhrCallbacks ) {
8182 jQuery( window ).unload( xhrOnUnloadAbort );
8184 // Add to list of active xhrs callbacks
8185 xhrCallbacks[ handle ] = callback;
8187 xhr.onreadystatechange = callback;
8204 var elemdisplay = {},
8206 rfxtypes = /^(?:toggle|show|hide)$/,
8207 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8210 // height animations
8211 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8213 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8214 // opacity animations
8220 show: function( speed, easing, callback ) {
8223 if ( speed || speed === 0 ) {
8224 return this.animate( genFx("show", 3), speed, easing, callback );
8227 for ( var i = 0, j = this.length; i < j; i++ ) {
8231 display = elem.style.display;
8233 // Reset the inline display of this element to learn if it is
8234 // being hidden by cascaded rules or not
8235 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
8236 display = elem.style.display = "";
8239 // Set elements which have been overridden with display: none
8240 // in a stylesheet to whatever the default browser style is
8241 // for such an element
8242 if ( display === "" && jQuery.css(elem, "display") === "none" ) {
8243 jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
8248 // Set the display of most of the elements in a second loop
8249 // to avoid the constant reflow
8250 for ( i = 0; i < j; i++ ) {
8254 display = elem.style.display;
8256 if ( display === "" || display === "none" ) {
8257 elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
8266 hide: function( speed, easing, callback ) {
8267 if ( speed || speed === 0 ) {
8268 return this.animate( genFx("hide", 3), speed, easing, callback);
8275 for ( ; i < j; i++ ) {
8278 display = jQuery.css( elem, "display" );
8280 if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
8281 jQuery._data( elem, "olddisplay", display );
8286 // Set the display of the elements in a second loop
8287 // to avoid the constant reflow
8288 for ( i = 0; i < j; i++ ) {
8289 if ( this[i].style ) {
8290 this[i].style.display = "none";
8298 // Save the old toggle function
8299 _toggle: jQuery.fn.toggle,
8301 toggle: function( fn, fn2, callback ) {
8302 var bool = typeof fn === "boolean";
8304 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
8305 this._toggle.apply( this, arguments );
8307 } else if ( fn == null || bool ) {
8308 this.each(function() {
8309 var state = bool ? fn : jQuery(this).is(":hidden");
8310 jQuery(this)[ state ? "show" : "hide" ]();
8314 this.animate(genFx("toggle", 3), fn, fn2, callback);
8320 fadeTo: function( speed, to, easing, callback ) {
8321 return this.filter(":hidden").css("opacity", 0).show().end()
8322 .animate({opacity: to}, speed, easing, callback);
8325 animate: function( prop, speed, easing, callback ) {
8326 var optall = jQuery.speed( speed, easing, callback );
8328 if ( jQuery.isEmptyObject( prop ) ) {
8329 return this.each( optall.complete, [ false ] );
8332 // Do not change referenced properties as per-property easing will be lost
8333 prop = jQuery.extend( {}, prop );
8335 function doAnimation() {
8336 // XXX 'this' does not always have a nodeName when running the
8339 if ( optall.queue === false ) {
8340 jQuery._mark( this );
8343 var opt = jQuery.extend( {}, optall ),
8344 isElement = this.nodeType === 1,
8345 hidden = isElement && jQuery(this).is(":hidden"),
8347 parts, start, end, unit,
8350 // will store per property easing and be used to determine when an animation is complete
8351 opt.animatedProperties = {};
8355 // property name normalization
8356 name = jQuery.camelCase( p );
8358 prop[ name ] = prop[ p ];
8364 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8365 if ( jQuery.isArray( val ) ) {
8366 opt.animatedProperties[ name ] = val[ 1 ];
8367 val = prop[ name ] = val[ 0 ];
8369 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
8372 if ( val === "hide" && hidden || val === "show" && !hidden ) {
8373 return opt.complete.call( this );
8376 if ( isElement && ( name === "height" || name === "width" ) ) {
8377 // Make sure that nothing sneaks out
8378 // Record all 3 overflow attributes because IE does not
8379 // change the overflow attribute when overflowX and
8380 // overflowY are set to the same value
8381 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
8383 // Set display property to inline-block for height/width
8384 // animations on inline elements that are having width/height animated
8385 if ( jQuery.css( this, "display" ) === "inline" &&
8386 jQuery.css( this, "float" ) === "none" ) {
8388 // inline-level elements accept inline-block;
8389 // block-level elements need to be inline with layout
8390 if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
8391 this.style.display = "inline-block";
8394 this.style.zoom = 1;
8400 if ( opt.overflow != null ) {
8401 this.style.overflow = "hidden";
8405 e = new jQuery.fx( this, opt, p );
8408 if ( rfxtypes.test( val ) ) {
8410 // Tracks whether to show or hide based on private
8411 // data attached to the element
8412 method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
8414 jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
8421 parts = rfxnum.exec( val );
8425 end = parseFloat( parts[2] );
8426 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
8428 // We need to compute starting value
8429 if ( unit !== "px" ) {
8430 jQuery.style( this, p, (end || 1) + unit);
8431 start = ( (end || 1) / e.cur() ) * start;
8432 jQuery.style( this, p, start + unit);
8435 // If a +=/-= token was provided, we're doing a relative animation
8437 end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
8440 e.custom( start, end, unit );
8443 e.custom( start, val, "" );
8448 // For JS strict compliance
8452 return optall.queue === false ?
8453 this.each( doAnimation ) :
8454 this.queue( optall.queue, doAnimation );
8457 stop: function( type, clearQueue, gotoEnd ) {
8458 if ( typeof type !== "string" ) {
8459 gotoEnd = clearQueue;
8463 if ( clearQueue && type !== false ) {
8464 this.queue( type || "fx", [] );
8467 return this.each(function() {
8470 timers = jQuery.timers,
8471 data = jQuery._data( this );
8473 // clear marker counters if we know they won't be
8475 jQuery._unmark( true, this );
8478 function stopQueue( elem, data, index ) {
8479 var hooks = data[ index ];
8480 jQuery.removeData( elem, index, true );
8481 hooks.stop( gotoEnd );
8484 if ( type == null ) {
8485 for ( index in data ) {
8486 if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
8487 stopQueue( this, data, index );
8490 } else if ( data[ index = type + ".run" ] && data[ index ].stop ){
8491 stopQueue( this, data, index );
8494 for ( index = timers.length; index--; ) {
8495 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
8498 // force the next step to be the last
8499 timers[ index ]( true );
8501 timers[ index ].saveState();
8504 timers.splice( index, 1 );
8508 // start the next in the queue if the last step wasn't forced
8509 // timers currently will call their complete callbacks, which will dequeue
8510 // but only if they were gotoEnd
8511 if ( !( gotoEnd && hadTimers ) ) {
8512 jQuery.dequeue( this, type );
8519 // Animations created synchronously will run synchronously
8520 function createFxNow() {
8521 setTimeout( clearFxNow, 0 );
8522 return ( fxNow = jQuery.now() );
8525 function clearFxNow() {
8529 // Generate parameters to create a standard animation
8530 function genFx( type, num ) {
8533 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
8540 // Generate shortcuts for custom animations
8542 slideDown: genFx( "show", 1 ),
8543 slideUp: genFx( "hide", 1 ),
8544 slideToggle: genFx( "toggle", 1 ),
8545 fadeIn: { opacity: "show" },
8546 fadeOut: { opacity: "hide" },
8547 fadeToggle: { opacity: "toggle" }
8548 }, function( name, props ) {
8549 jQuery.fn[ name ] = function( speed, easing, callback ) {
8550 return this.animate( props, speed, easing, callback );
8555 speed: function( speed, easing, fn ) {
8556 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
8557 complete: fn || !fn && easing ||
8558 jQuery.isFunction( speed ) && speed,
8560 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
8563 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8564 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
8566 // normalize opt.queue - true/undefined/null -> "fx"
8567 if ( opt.queue == null || opt.queue === true ) {
8572 opt.old = opt.complete;
8574 opt.complete = function( noUnmark ) {
8575 if ( jQuery.isFunction( opt.old ) ) {
8576 opt.old.call( this );
8580 jQuery.dequeue( this, opt.queue );
8581 } else if ( noUnmark !== false ) {
8582 jQuery._unmark( this );
8590 linear: function( p, n, firstNum, diff ) {
8591 return firstNum + diff * p;
8593 swing: function( p, n, firstNum, diff ) {
8594 return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum;
8600 fx: function( elem, options, prop ) {
8601 this.options = options;
8605 options.orig = options.orig || {};
8610 jQuery.fx.prototype = {
8611 // Simple function for setting a style value
8612 update: function() {
8613 if ( this.options.step ) {
8614 this.options.step.call( this.elem, this.now, this );
8617 ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
8620 // Get the current size
8622 if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
8623 return this.elem[ this.prop ];
8627 r = jQuery.css( this.elem, this.prop );
8628 // Empty strings, null, undefined and "auto" are converted to 0,
8629 // complex values such as "rotate(1rad)" are returned as is,
8630 // simple values such as "10px" are parsed to Float.
8631 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
8634 // Start an animation from one number to another
8635 custom: function( from, to, unit ) {
8639 this.startTime = fxNow || createFxNow();
8641 this.now = this.start = from;
8642 this.pos = this.state = 0;
8643 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8645 function t( gotoEnd ) {
8646 return self.step( gotoEnd );
8649 t.queue = this.options.queue;
8651 t.saveState = function() {
8652 if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
8653 jQuery._data( self.elem, "fxshow" + self.prop, self.start );
8657 if ( t() && jQuery.timers.push(t) && !timerId ) {
8658 timerId = setInterval( fx.tick, fx.interval );
8662 // Simple 'show' function
8664 var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
8666 // Remember where we started, so that we can go back to it later
8667 this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
8668 this.options.show = true;
8670 // Begin the animation
8671 // Make sure that we start at a small width/height to avoid any flash of content
8672 if ( dataShow !== undefined ) {
8673 // This show is picking up where a previous hide or show left off
8674 this.custom( this.cur(), dataShow );
8676 this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
8679 // Start by showing the element
8680 jQuery( this.elem ).show();
8683 // Simple 'hide' function
8685 // Remember where we started, so that we can go back to it later
8686 this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
8687 this.options.hide = true;
8689 // Begin the animation
8690 this.custom( this.cur(), 0 );
8693 // Each step of an animation
8694 step: function( gotoEnd ) {
8696 t = fxNow || createFxNow(),
8699 options = this.options;
8701 if ( gotoEnd || t >= options.duration + this.startTime ) {
8702 this.now = this.end;
8703 this.pos = this.state = 1;
8706 options.animatedProperties[ this.prop ] = true;
8708 for ( p in options.animatedProperties ) {
8709 if ( options.animatedProperties[ p ] !== true ) {
8715 // Reset the overflow
8716 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
8718 jQuery.each( [ "", "X", "Y" ], function( index, value ) {
8719 elem.style[ "overflow" + value ] = options.overflow[ index ];
8723 // Hide the element if the "hide" operation was done
8724 if ( options.hide ) {
8725 jQuery( elem ).hide();
8728 // Reset the properties, if the item has been hidden or shown
8729 if ( options.hide || options.show ) {
8730 for ( p in options.animatedProperties ) {
8731 jQuery.style( elem, p, options.orig[ p ] );
8732 jQuery.removeData( elem, "fxshow" + p, true );
8733 // Toggle data is no longer needed
8734 jQuery.removeData( elem, "toggle" + p, true );
8738 // Execute the complete function
8739 // in the event that the complete function throws an exception
8740 // we must ensure it won't be called twice. #5684
8742 complete = options.complete;
8745 options.complete = false;
8746 complete.call( elem );
8753 // classical easing cannot be used with an Infinity duration
8754 if ( options.duration == Infinity ) {
8757 n = t - this.startTime;
8758 this.state = n / options.duration;
8760 // Perform the easing function, defaults to swing
8761 this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
8762 this.now = this.start + ( (this.end - this.start) * this.pos );
8764 // Perform the next step of the animation
8772 jQuery.extend( jQuery.fx, {
8775 timers = jQuery.timers,
8778 for ( ; i < timers.length; i++ ) {
8779 timer = timers[ i ];
8780 // Checks the timer has not already been removed
8781 if ( !timer() && timers[ i ] === timer ) {
8782 timers.splice( i--, 1 );
8786 if ( !timers.length ) {
8794 clearInterval( timerId );
8806 opacity: function( fx ) {
8807 jQuery.style( fx.elem, "opacity", fx.now );
8810 _default: function( fx ) {
8811 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
8812 fx.elem.style[ fx.prop ] = fx.now + fx.unit;
8814 fx.elem[ fx.prop ] = fx.now;
8820 // Adds width/height step functions
8821 // Do not set anything below 0
8822 jQuery.each([ "width", "height" ], function( i, prop ) {
8823 jQuery.fx.step[ prop ] = function( fx ) {
8824 jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
8828 if ( jQuery.expr && jQuery.expr.filters ) {
8829 jQuery.expr.filters.animated = function( elem ) {
8830 return jQuery.grep(jQuery.timers, function( fn ) {
8831 return elem === fn.elem;
8836 // Try to restore the default display value of an element
8837 function defaultDisplay( nodeName ) {
8839 if ( !elemdisplay[ nodeName ] ) {
8841 var body = document.body,
8842 elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
8843 display = elem.css( "display" );
8846 // If the simple way fails,
8847 // get element's real default display by attaching it to a temp iframe
8848 if ( display === "none" || display === "" ) {
8849 // No iframe to use yet, so create it
8851 iframe = document.createElement( "iframe" );
8852 iframe.frameBorder = iframe.width = iframe.height = 0;
8855 body.appendChild( iframe );
8857 // Create a cacheable copy of the iframe document on first call.
8858 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8859 // document to it; WebKit & Firefox won't allow reusing the iframe document.
8860 if ( !iframeDoc || !iframe.createElement ) {
8861 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
8862 iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8866 elem = iframeDoc.createElement( nodeName );
8868 iframeDoc.body.appendChild( elem );
8870 display = jQuery.css( elem, "display" );
8871 body.removeChild( iframe );
8874 // Store the correct default display
8875 elemdisplay[ nodeName ] = display;
8878 return elemdisplay[ nodeName ];
8884 var rtable = /^t(?:able|d|h)$/i,
8885 rroot = /^(?:body|html)$/i;
8887 if ( "getBoundingClientRect" in document.documentElement ) {
8888 jQuery.fn.offset = function( options ) {
8889 var elem = this[0], box;
8892 return this.each(function( i ) {
8893 jQuery.offset.setOffset( this, options, i );
8897 if ( !elem || !elem.ownerDocument ) {
8901 if ( elem === elem.ownerDocument.body ) {
8902 return jQuery.offset.bodyOffset( elem );
8906 box = elem.getBoundingClientRect();
8909 var doc = elem.ownerDocument,
8910 docElem = doc.documentElement;
8912 // Make sure we're not dealing with a disconnected DOM node
8913 if ( !box || !jQuery.contains( docElem, elem ) ) {
8914 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
8917 var body = doc.body,
8918 win = getWindow(doc),
8919 clientTop = docElem.clientTop || body.clientTop || 0,
8920 clientLeft = docElem.clientLeft || body.clientLeft || 0,
8921 scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
8922 scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
8923 top = box.top + scrollTop - clientTop,
8924 left = box.left + scrollLeft - clientLeft;
8926 return { top: top, left: left };
8930 jQuery.fn.offset = function( options ) {
8934 return this.each(function( i ) {
8935 jQuery.offset.setOffset( this, options, i );
8939 if ( !elem || !elem.ownerDocument ) {
8943 if ( elem === elem.ownerDocument.body ) {
8944 return jQuery.offset.bodyOffset( elem );
8948 offsetParent = elem.offsetParent,
8949 prevOffsetParent = elem,
8950 doc = elem.ownerDocument,
8951 docElem = doc.documentElement,
8953 defaultView = doc.defaultView,
8954 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
8955 top = elem.offsetTop,
8956 left = elem.offsetLeft;
8958 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
8959 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
8963 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
8964 top -= elem.scrollTop;
8965 left -= elem.scrollLeft;
8967 if ( elem === offsetParent ) {
8968 top += elem.offsetTop;
8969 left += elem.offsetLeft;
8971 if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
8972 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8973 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8976 prevOffsetParent = offsetParent;
8977 offsetParent = elem.offsetParent;
8980 if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
8981 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8982 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8985 prevComputedStyle = computedStyle;
8988 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
8989 top += body.offsetTop;
8990 left += body.offsetLeft;
8993 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
8994 top += Math.max( docElem.scrollTop, body.scrollTop );
8995 left += Math.max( docElem.scrollLeft, body.scrollLeft );
8998 return { top: top, left: left };
9004 bodyOffset: function( body ) {
9005 var top = body.offsetTop,
9006 left = body.offsetLeft;
9008 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
9009 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
9010 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
9013 return { top: top, left: left };
9016 setOffset: function( elem, options, i ) {
9017 var position = jQuery.css( elem, "position" );
9019 // set position first, in-case top/left are set even on static elem
9020 if ( position === "static" ) {
9021 elem.style.position = "relative";
9024 var curElem = jQuery( elem ),
9025 curOffset = curElem.offset(),
9026 curCSSTop = jQuery.css( elem, "top" ),
9027 curCSSLeft = jQuery.css( elem, "left" ),
9028 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9029 props = {}, curPosition = {}, curTop, curLeft;
9031 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9032 if ( calculatePosition ) {
9033 curPosition = curElem.position();
9034 curTop = curPosition.top;
9035 curLeft = curPosition.left;
9037 curTop = parseFloat( curCSSTop ) || 0;
9038 curLeft = parseFloat( curCSSLeft ) || 0;
9041 if ( jQuery.isFunction( options ) ) {
9042 options = options.call( elem, i, curOffset );
9045 if ( options.top != null ) {
9046 props.top = ( options.top - curOffset.top ) + curTop;
9048 if ( options.left != null ) {
9049 props.left = ( options.left - curOffset.left ) + curLeft;
9052 if ( "using" in options ) {
9053 options.using.call( elem, props );
9055 curElem.css( props );
9063 position: function() {
9070 // Get *real* offsetParent
9071 offsetParent = this.offsetParent(),
9073 // Get correct offsets
9074 offset = this.offset(),
9075 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
9077 // Subtract element margins
9078 // note: when an element has margin: auto the offsetLeft and marginLeft
9079 // are the same in Safari causing offset.left to incorrectly be 0
9080 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
9081 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
9083 // Add offsetParent borders
9084 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
9085 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
9087 // Subtract the two offsets
9089 top: offset.top - parentOffset.top,
9090 left: offset.left - parentOffset.left
9094 offsetParent: function() {
9095 return this.map(function() {
9096 var offsetParent = this.offsetParent || document.body;
9097 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
9098 offsetParent = offsetParent.offsetParent;
9100 return offsetParent;
9106 // Create scrollLeft and scrollTop methods
9107 jQuery.each( ["Left", "Top"], function( i, name ) {
9108 var method = "scroll" + name;
9110 jQuery.fn[ method ] = function( val ) {
9113 if ( val === undefined ) {
9120 win = getWindow( elem );
9122 // Return the scroll offset
9123 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
9124 jQuery.support.boxModel && win.document.documentElement[ method ] ||
9125 win.document.body[ method ] :
9129 // Set the scroll offset
9130 return this.each(function() {
9131 win = getWindow( this );
9135 !i ? val : jQuery( win ).scrollLeft(),
9136 i ? val : jQuery( win ).scrollTop()
9140 this[ method ] = val;
9146 function getWindow( elem ) {
9147 return jQuery.isWindow( elem ) ?
9149 elem.nodeType === 9 ?
9150 elem.defaultView || elem.parentWindow :
9157 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
9158 jQuery.each([ "Height", "Width" ], function( i, name ) {
9160 var type = name.toLowerCase();
9162 // innerHeight and innerWidth
9163 jQuery.fn[ "inner" + name ] = function() {
9167 parseFloat( jQuery.css( elem, type, "padding" ) ) :
9172 // outerHeight and outerWidth
9173 jQuery.fn[ "outer" + name ] = function( margin ) {
9177 parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
9182 jQuery.fn[ type ] = function( size ) {
9183 // Get window width or height
9186 return size == null ? null : this;
9189 if ( jQuery.isFunction( size ) ) {
9190 return this.each(function( i ) {
9191 var self = jQuery( this );
9192 self[ type ]( size.call( this, i, self[ type ]() ) );
9196 if ( jQuery.isWindow( elem ) ) {
9197 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9198 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9199 var docElemProp = elem.document.documentElement[ "client" + name ],
9200 body = elem.document.body;
9201 return elem.document.compatMode === "CSS1Compat" && docElemProp ||
9202 body && body[ "client" + name ] || docElemProp;
9204 // Get document width or height
9205 } else if ( elem.nodeType === 9 ) {
9206 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9208 elem.documentElement["client" + name],
9209 elem.body["scroll" + name], elem.documentElement["scroll" + name],
9210 elem.body["offset" + name], elem.documentElement["offset" + name]
9213 // Get or set width or height on the element
9214 } else if ( size === undefined ) {
9215 var orig = jQuery.css( elem, type ),
9216 ret = parseFloat( orig );
9218 return jQuery.isNumeric( ret ) ? ret : orig;
9220 // Set the width or height on the element (default to pixels if value is unitless)
9222 return this.css( type, typeof size === "string" ? size : size + "px" );
9231 // Expose jQuery to the global object
9232 window.jQuery = window.$ = jQuery;
9234 // Expose jQuery as an AMD module, but only for AMD loaders that
9235 // understand the issues with loading multiple versions of jQuery
9236 // in a page that all might call define(). The loader will indicate
9237 // they have special allowances for multiple jQuery versions by
9238 // specifying define.amd.jQuery = true. Register as a named module,
9239 // since jQuery can be concatenated with other files that may use define,
9240 // but not use a proper concatenation script that understands anonymous
9241 // AMD modules. A named AMD is safest and most robust way to register.
9242 // Lowercase jquery is used because AMD module names are derived from
9243 // file names, and jQuery is normally delivered in a lowercase file name.
9244 // Do this after creating the global so that if an AMD module wants to call
9245 // noConflict to hide this version of jQuery, it will work.
9246 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
9247 define( "jquery", [], function () { return jQuery; } );