1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: jQuery 1.7.1 core library
4 //>>excludeEnd("jqmBuildExclude");
8 * jQuery JavaScript Library v1.7.1
11 * Copyright 2011, John Resig
12 * Dual licensed under the MIT or GPL Version 2 licenses.
13 * http://jquery.org/license
16 * http://sizzlejs.com/
17 * Copyright 2011, The Dojo Foundation
18 * Released under the MIT, BSD, and GPL Licenses.
20 * Date: Mon Nov 21 21:11:03 2011 -0500
22 (function( window, undefined ) {
24 // Use the correct document accordingly with window argument (sandbox)
25 var document = window.document,
26 navigator = window.navigator,
27 location = window.location;
28 var jQuery = (function() {
30 // Define a local copy of jQuery
31 var jQuery = function( selector, context ) {
32 // The jQuery object is actually just the init constructor 'enhanced'
33 return new jQuery.fn.init( selector, context, rootjQuery );
36 // Map over jQuery in case of overwrite
37 _jQuery = window.jQuery,
39 // Map over the $ in case of overwrite
42 // A central reference to the root jQuery(document)
45 // A simple way to check for HTML strings or ID strings
46 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
47 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
49 // Check if a string has a non-whitespace character in it
52 // Used for trimming whitespace
56 // Match a standalone tag
57 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
60 rvalidchars = /^[\],:{}\s]*$/,
61 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
62 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
63 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
66 rwebkit = /(webkit)[ \/]([\w.]+)/,
67 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
68 rmsie = /(msie) ([\w.]+)/,
69 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
71 // Matches dashed string for camelizing
72 rdashAlpha = /-([a-z]|[0-9])/ig,
75 // Used by jQuery.camelCase as callback to replace()
76 fcamelCase = function( all, letter ) {
77 return ( letter + "" ).toUpperCase();
80 // Keep a UserAgent string for use with jQuery.browser
81 userAgent = navigator.userAgent,
83 // For matching the engine and version of the browser
86 // The deferred used on DOM ready
89 // The ready event handler
92 // Save a reference to some core methods
93 toString = Object.prototype.toString,
94 hasOwn = Object.prototype.hasOwnProperty,
95 push = Array.prototype.push,
96 slice = Array.prototype.slice,
97 trim = String.prototype.trim,
98 indexOf = Array.prototype.indexOf,
100 // [[Class]] -> type pairs
103 jQuery.fn = jQuery.prototype = {
105 init: function( selector, context, rootjQuery ) {
106 var match, elem, ret, doc;
108 // Handle $(""), $(null), or $(undefined)
113 // Handle $(DOMElement)
114 if ( selector.nodeType ) {
115 this.context = this[0] = selector;
120 // The body element only exists once, optimize finding it
121 if ( selector === "body" && !context && document.body ) {
122 this.context = document;
123 this[0] = document.body;
124 this.selector = selector;
129 // Handle HTML strings
130 if ( typeof selector === "string" ) {
131 // Are we dealing with HTML string or an ID?
132 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
133 // Assume that strings that start and end with <> are HTML and skip the regex check
134 match = [ null, selector, null ];
137 match = quickExpr.exec( selector );
140 // Verify a match, and that no context was specified for #id
141 if ( match && (match[1] || !context) ) {
143 // HANDLE: $(html) -> $(array)
145 context = context instanceof jQuery ? context[0] : context;
146 doc = ( context ? context.ownerDocument || context : document );
148 // If a single string is passed in and it's a single tag
149 // just do a createElement and skip the rest
150 ret = rsingleTag.exec( selector );
153 if ( jQuery.isPlainObject( context ) ) {
154 selector = [ document.createElement( ret[1] ) ];
155 jQuery.fn.attr.call( selector, context, true );
158 selector = [ doc.createElement( ret[1] ) ];
162 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
163 selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
166 return jQuery.merge( this, selector );
170 elem = document.getElementById( match[2] );
172 // Check parentNode to catch when Blackberry 4.6 returns
173 // nodes that are no longer in the document #6963
174 if ( elem && elem.parentNode ) {
175 // Handle the case where IE and Opera return items
176 // by name instead of ID
177 if ( elem.id !== match[2] ) {
178 return rootjQuery.find( selector );
181 // Otherwise, we inject the element directly into the jQuery object
186 this.context = document;
187 this.selector = selector;
191 // HANDLE: $(expr, $(...))
192 } else if ( !context || context.jquery ) {
193 return ( context || rootjQuery ).find( selector );
195 // HANDLE: $(expr, context)
196 // (which is just equivalent to: $(context).find(expr)
198 return this.constructor( context ).find( selector );
201 // HANDLE: $(function)
202 // Shortcut for document ready
203 } else if ( jQuery.isFunction( selector ) ) {
204 return rootjQuery.ready( selector );
207 if ( selector.selector !== undefined ) {
208 this.selector = selector.selector;
209 this.context = selector.context;
212 return jQuery.makeArray( selector, this );
215 // Start with an empty selector
218 // The current version of jQuery being used
221 // The default length of a jQuery object is 0
224 // The number of elements contained in the matched element set
229 toArray: function() {
230 return slice.call( this, 0 );
233 // Get the Nth element in the matched element set OR
234 // Get the whole matched element set as a clean array
235 get: function( num ) {
238 // Return a 'clean' array
241 // Return just the object
242 ( num < 0 ? this[ this.length + num ] : this[ num ] );
245 // Take an array of elements and push it onto the stack
246 // (returning the new matched element set)
247 pushStack: function( elems, name, selector ) {
248 // Build a new jQuery matched element set
249 var ret = this.constructor();
251 if ( jQuery.isArray( elems ) ) {
252 push.apply( ret, elems );
255 jQuery.merge( ret, elems );
258 // Add the old object onto the stack (as a reference)
259 ret.prevObject = this;
261 ret.context = this.context;
263 if ( name === "find" ) {
264 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
266 ret.selector = this.selector + "." + name + "(" + selector + ")";
269 // Return the newly-formed element set
273 // Execute a callback for every element in the matched set.
274 // (You can seed the arguments with an array of args, but this is
275 // only used internally.)
276 each: function( callback, args ) {
277 return jQuery.each( this, callback, args );
280 ready: function( fn ) {
281 // Attach the listeners
294 this.slice( i, i + 1 );
302 return this.eq( -1 );
306 return this.pushStack( slice.apply( this, arguments ),
307 "slice", slice.call(arguments).join(",") );
310 map: function( callback ) {
311 return this.pushStack( jQuery.map(this, function( elem, i ) {
312 return callback.call( elem, i, elem );
317 return this.prevObject || this.constructor(null);
320 // For internal use only.
321 // Behaves like an Array's method, not like a jQuery method.
327 // Give the init function the jQuery prototype for later instantiation
328 jQuery.fn.init.prototype = jQuery.fn;
330 jQuery.extend = jQuery.fn.extend = function() {
331 var options, name, src, copy, copyIsArray, clone,
332 target = arguments[0] || {},
334 length = arguments.length,
337 // Handle a deep copy situation
338 if ( typeof target === "boolean" ) {
340 target = arguments[1] || {};
341 // skip the boolean and the target
345 // Handle case when target is a string or something (possible in deep copy)
346 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
350 // extend jQuery itself if only one argument is passed
351 if ( length === i ) {
356 for ( ; i < length; i++ ) {
357 // Only deal with non-null/undefined values
358 if ( (options = arguments[ i ]) != null ) {
359 // Extend the base object
360 for ( name in options ) {
361 src = target[ name ];
362 copy = options[ name ];
364 // Prevent never-ending loop
365 if ( target === copy ) {
369 // Recurse if we're merging plain objects or arrays
370 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
373 clone = src && jQuery.isArray(src) ? src : [];
376 clone = src && jQuery.isPlainObject(src) ? src : {};
379 // Never move original objects, clone them
380 target[ name ] = jQuery.extend( deep, clone, copy );
382 // Don't bring in undefined values
383 } else if ( copy !== undefined ) {
384 target[ name ] = copy;
390 // Return the modified object
395 noConflict: function( deep ) {
396 if ( window.$ === jQuery ) {
400 if ( deep && window.jQuery === jQuery ) {
401 window.jQuery = _jQuery;
407 // Is the DOM ready to be used? Set to true once it occurs.
410 // A counter to track how many items to wait for before
411 // the ready event fires. See #6781
414 // Hold (or release) the ready event
415 holdReady: function( hold ) {
419 jQuery.ready( true );
423 // Handle when the DOM is ready
424 ready: function( wait ) {
425 // Either a released hold or an DOMready/load event and not yet ready
426 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
427 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
428 if ( !document.body ) {
429 return setTimeout( jQuery.ready, 1 );
432 // Remember that the DOM is ready
433 jQuery.isReady = true;
435 // If a normal DOM Ready event fired, decrement, and wait if need be
436 if ( wait !== true && --jQuery.readyWait > 0 ) {
440 // If there are functions bound, to execute
441 readyList.fireWith( document, [ jQuery ] );
443 // Trigger any bound ready events
444 if ( jQuery.fn.trigger ) {
445 jQuery( document ).trigger( "ready" ).off( "ready" );
450 bindReady: function() {
455 readyList = jQuery.Callbacks( "once memory" );
457 // Catch cases where $(document).ready() is called after the
458 // browser event has already occurred.
459 if ( document.readyState === "complete" ) {
460 // Handle it asynchronously to allow scripts the opportunity to delay ready
461 return setTimeout( jQuery.ready, 1 );
464 // Mozilla, Opera and webkit nightlies currently support this event
465 if ( document.addEventListener ) {
466 // Use the handy event callback
467 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
469 // A fallback to window.onload, that will always work
470 window.addEventListener( "load", jQuery.ready, false );
472 // If IE event model is used
473 } else if ( document.attachEvent ) {
474 // ensure firing before onload,
475 // maybe late but safe also for iframes
476 document.attachEvent( "onreadystatechange", DOMContentLoaded );
478 // A fallback to window.onload, that will always work
479 window.attachEvent( "onload", jQuery.ready );
481 // If IE and not a frame
482 // continually check to see if the document is ready
483 var toplevel = false;
486 toplevel = window.frameElement == null;
489 if ( document.documentElement.doScroll && toplevel ) {
495 // See test/unit/core.js for details concerning isFunction.
496 // Since version 1.3, DOM methods and functions like alert
497 // aren't supported. They return false on IE (#2968).
498 isFunction: function( obj ) {
499 return jQuery.type(obj) === "function";
502 isArray: Array.isArray || function( obj ) {
503 return jQuery.type(obj) === "array";
506 // A crude way of determining if an object is a window
507 isWindow: function( obj ) {
508 return obj && typeof obj === "object" && "setInterval" in obj;
511 isNumeric: function( obj ) {
512 return !isNaN( parseFloat(obj) ) && isFinite( obj );
515 type: function( obj ) {
518 class2type[ toString.call(obj) ] || "object";
521 isPlainObject: function( obj ) {
522 // Must be an Object.
523 // Because of IE, we also have to check the presence of the constructor property.
524 // Make sure that DOM nodes and window objects don't pass through, as well
525 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
530 // Not own constructor property must be Object
531 if ( obj.constructor &&
532 !hasOwn.call(obj, "constructor") &&
533 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
537 // IE8,9 Will throw exceptions on certain host objects #9897
541 // Own properties are enumerated firstly, so to speed up,
542 // if last one is own, then all properties are own.
545 for ( key in obj ) {}
547 return key === undefined || hasOwn.call( obj, key );
550 isEmptyObject: function( obj ) {
551 for ( var name in obj ) {
557 error: function( msg ) {
558 throw new Error( msg );
561 parseJSON: function( data ) {
562 if ( typeof data !== "string" || !data ) {
566 // Make sure leading/trailing whitespace is removed (IE can't handle it)
567 data = jQuery.trim( data );
569 // Attempt to parse using the native JSON parser first
570 if ( window.JSON && window.JSON.parse ) {
571 return window.JSON.parse( data );
574 // Make sure the incoming data is actual JSON
575 // Logic borrowed from http://json.org/json2.js
576 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
577 .replace( rvalidtokens, "]" )
578 .replace( rvalidbraces, "")) ) {
580 return ( new Function( "return " + data ) )();
583 jQuery.error( "Invalid JSON: " + data );
586 // Cross-browser xml parsing
587 parseXML: function( data ) {
590 if ( window.DOMParser ) { // Standard
591 tmp = new DOMParser();
592 xml = tmp.parseFromString( data , "text/xml" );
594 xml = new ActiveXObject( "Microsoft.XMLDOM" );
601 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
602 jQuery.error( "Invalid XML: " + data );
609 // Evaluates a script in a global context
610 // Workarounds based on findings by Jim Driscoll
611 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
612 globalEval: function( data ) {
613 if ( data && rnotwhite.test( data ) ) {
614 // We use execScript on Internet Explorer
615 // We use an anonymous function so that context is window
616 // rather than jQuery in Firefox
617 ( window.execScript || function( data ) {
618 window[ "eval" ].call( window, data );
623 // Convert dashed to camelCase; used by the css and data modules
624 // Microsoft forgot to hump their vendor prefix (#9572)
625 camelCase: function( string ) {
626 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
629 nodeName: function( elem, name ) {
630 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
633 // args is for internal usage only
634 each: function( object, callback, args ) {
636 length = object.length,
637 isObj = length === undefined || jQuery.isFunction( object );
641 for ( name in object ) {
642 if ( callback.apply( object[ name ], args ) === false ) {
647 for ( ; i < length; ) {
648 if ( callback.apply( object[ i++ ], args ) === false ) {
654 // A special, fast, case for the most common use of each
657 for ( name in object ) {
658 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
663 for ( ; i < length; ) {
664 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
674 // Use native String.trim function wherever possible
677 return text == null ?
682 // Otherwise use our own trimming functionality
684 return text == null ?
686 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
689 // results is for internal usage only
690 makeArray: function( array, results ) {
691 var ret = results || [];
693 if ( array != null ) {
694 // The window, strings (and functions) also have 'length'
695 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
696 var type = jQuery.type( array );
698 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
699 push.call( ret, array );
701 jQuery.merge( ret, array );
708 inArray: function( elem, array, i ) {
713 return indexOf.call( array, elem, i );
717 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
719 for ( ; i < len; i++ ) {
720 // Skip accessing in sparse arrays
721 if ( i in array && array[ i ] === elem ) {
730 merge: function( first, second ) {
731 var i = first.length,
734 if ( typeof second.length === "number" ) {
735 for ( var l = second.length; j < l; j++ ) {
736 first[ i++ ] = second[ j ];
740 while ( second[j] !== undefined ) {
741 first[ i++ ] = second[ j++ ];
750 grep: function( elems, callback, inv ) {
751 var ret = [], retVal;
754 // Go through the array, only saving the items
755 // that pass the validator function
756 for ( var i = 0, length = elems.length; i < length; i++ ) {
757 retVal = !!callback( elems[ i ], i );
758 if ( inv !== retVal ) {
759 ret.push( elems[ i ] );
766 // arg is for internal usage only
767 map: function( elems, callback, arg ) {
768 var value, key, ret = [],
770 length = elems.length,
771 // jquery objects are treated as arrays
772 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
774 // Go through the array, translating each of the items to their
776 for ( ; i < length; i++ ) {
777 value = callback( elems[ i ], i, arg );
779 if ( value != null ) {
780 ret[ ret.length ] = value;
784 // Go through every key on the object,
786 for ( key in elems ) {
787 value = callback( elems[ key ], key, arg );
789 if ( value != null ) {
790 ret[ ret.length ] = value;
795 // Flatten any nested arrays
796 return ret.concat.apply( [], ret );
799 // A global GUID counter for objects
802 // Bind a function to a context, optionally partially applying any
804 proxy: function( fn, context ) {
805 if ( typeof context === "string" ) {
806 var tmp = fn[ context ];
811 // Quick check to determine if target is callable, in the spec
812 // this throws a TypeError, but we will just return undefined.
813 if ( !jQuery.isFunction( fn ) ) {
818 var args = slice.call( arguments, 2 ),
820 return fn.apply( context, args.concat( slice.call( arguments ) ) );
823 // Set the guid of unique handler to the same of original handler, so it can be removed
824 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
829 // Mutifunctional method to get and set values to a collection
830 // The value/s can optionally be executed if it's a function
831 access: function( elems, key, value, exec, fn, pass ) {
832 var length = elems.length;
834 // Setting many attributes
835 if ( typeof key === "object" ) {
836 for ( var k in key ) {
837 jQuery.access( elems, k, key[k], exec, fn, value );
842 // Setting one attribute
843 if ( value !== undefined ) {
844 // Optionally, function values get executed if exec is true
845 exec = !pass && exec && jQuery.isFunction(value);
847 for ( var i = 0; i < length; i++ ) {
848 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
854 // Getting an attribute
855 return length ? fn( elems[0], key ) : undefined;
859 return ( new Date() ).getTime();
862 // Use of jQuery.browser is frowned upon.
863 // More details: http://docs.jquery.com/Utilities/jQuery.browser
864 uaMatch: function( ua ) {
865 ua = ua.toLowerCase();
867 var match = rwebkit.exec( ua ) ||
870 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
873 return { browser: match[1] || "", version: match[2] || "0" };
877 function jQuerySub( selector, context ) {
878 return new jQuerySub.fn.init( selector, context );
880 jQuery.extend( true, jQuerySub, this );
881 jQuerySub.superclass = this;
882 jQuerySub.fn = jQuerySub.prototype = this();
883 jQuerySub.fn.constructor = jQuerySub;
884 jQuerySub.sub = this.sub;
885 jQuerySub.fn.init = function init( selector, context ) {
886 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
887 context = jQuerySub( context );
890 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
892 jQuerySub.fn.init.prototype = jQuerySub.fn;
893 var rootjQuerySub = jQuerySub(document);
900 // Populate the class2type map
901 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
902 class2type[ "[object " + name + "]" ] = name.toLowerCase();
905 browserMatch = jQuery.uaMatch( userAgent );
906 if ( browserMatch.browser ) {
907 jQuery.browser[ browserMatch.browser ] = true;
908 jQuery.browser.version = browserMatch.version;
911 // Deprecated, use jQuery.browser.webkit instead
912 if ( jQuery.browser.webkit ) {
913 jQuery.browser.safari = true;
916 // IE doesn't match non-breaking spaces with \s
917 if ( rnotwhite.test( "\xA0" ) ) {
918 trimLeft = /^[\s\xA0]+/;
919 trimRight = /[\s\xA0]+$/;
922 // All jQuery objects should point back to these
923 rootjQuery = jQuery(document);
925 // Cleanup functions for the document ready method
926 if ( document.addEventListener ) {
927 DOMContentLoaded = function() {
928 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
932 } else if ( document.attachEvent ) {
933 DOMContentLoaded = function() {
934 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
935 if ( document.readyState === "complete" ) {
936 document.detachEvent( "onreadystatechange", DOMContentLoaded );
942 // The DOM ready check for Internet Explorer
943 function doScrollCheck() {
944 if ( jQuery.isReady ) {
949 // If IE is used, use the trick by Diego Perini
950 // http://javascript.nwbox.com/IEContentLoaded/
951 document.documentElement.doScroll("left");
953 setTimeout( doScrollCheck, 1 );
957 // and execute any waiting functions
966 // String to Object flags format cache
969 // Convert String-formatted flags into Object-formatted ones and store in cache
970 function createFlags( flags ) {
971 var object = flagsCache[ flags ] = {},
973 flags = flags.split( /\s+/ );
974 for ( i = 0, length = flags.length; i < length; i++ ) {
975 object[ flags[i] ] = true;
981 * Create a callback list using the following parameters:
983 * flags: an optional list of space-separated flags that will change how
984 * the callback list behaves
986 * By default a callback list will act like an event callback list and can be
987 * "fired" multiple times.
991 * once: will ensure the callback list can only be fired once (like a Deferred)
993 * memory: will keep track of previous values and will call any callback added
994 * after the list has been fired right away with the latest "memorized"
995 * values (like a Deferred)
997 * unique: will ensure a callback can only be added once (no duplicate in the list)
999 * stopOnFalse: interrupt callings when a callback returns false
1002 jQuery.Callbacks = function( flags ) {
1004 // Convert flags from String-formatted to Object-formatted
1005 // (we check in cache first)
1006 flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {};
1008 var // Actual callback list
1010 // Stack of fire calls for repeatable lists
1012 // Last fire value (for non-forgettable lists)
1014 // Flag to know if list is currently firing
1016 // First callback to fire (used internally by add and fireWith)
1018 // End of the loop when firing
1020 // Index of currently firing callback (modified by remove if needed)
1022 // Add one or several callbacks to the list
1023 add = function( args ) {
1029 for ( i = 0, length = args.length; i < length; i++ ) {
1031 type = jQuery.type( elem );
1032 if ( type === "array" ) {
1033 // Inspect recursively
1035 } else if ( type === "function" ) {
1036 // Add if not in unique mode and callback is not in
1037 if ( !flags.unique || !self.has( elem ) ) {
1044 fire = function( context, args ) {
1046 memory = !flags.memory || [ context, args ];
1048 firingIndex = firingStart || 0;
1050 firingLength = list.length;
1051 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1052 if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) {
1053 memory = true; // Mark as halted
1059 if ( !flags.once ) {
1060 if ( stack && stack.length ) {
1061 memory = stack.shift();
1062 self.fireWith( memory[ 0 ], memory[ 1 ] );
1064 } else if ( memory === true ) {
1071 // Actual Callbacks object
1073 // Add a callback or a collection of callbacks to the list
1076 var length = list.length;
1078 // Do we need to add the callbacks to the
1079 // current firing batch?
1081 firingLength = list.length;
1082 // With memory, if we're not firing then
1083 // we should call right away, unless previous
1084 // firing was halted (stopOnFalse)
1085 } else if ( memory && memory !== true ) {
1086 firingStart = length;
1087 fire( memory[ 0 ], memory[ 1 ] );
1092 // Remove a callback from the list
1093 remove: function() {
1095 var args = arguments,
1097 argLength = args.length;
1098 for ( ; argIndex < argLength ; argIndex++ ) {
1099 for ( var i = 0; i < list.length; i++ ) {
1100 if ( args[ argIndex ] === list[ i ] ) {
1101 // Handle firingIndex and firingLength
1103 if ( i <= firingLength ) {
1105 if ( i <= firingIndex ) {
1110 // Remove the element
1111 list.splice( i--, 1 );
1112 // If we have some unicity property then
1113 // we only need to do this once
1114 if ( flags.unique ) {
1123 // Control if a given callback is in the list
1124 has: function( fn ) {
1127 length = list.length;
1128 for ( ; i < length; i++ ) {
1129 if ( fn === list[ i ] ) {
1136 // Remove all callbacks from the list
1141 // Have the list do nothing anymore
1142 disable: function() {
1143 list = stack = memory = undefined;
1147 disabled: function() {
1150 // Lock the list in its current state
1153 if ( !memory || memory === true ) {
1159 locked: function() {
1162 // Call all callbacks with the given context and arguments
1163 fireWith: function( context, args ) {
1166 if ( !flags.once ) {
1167 stack.push( [ context, args ] );
1169 } else if ( !( flags.once && memory ) ) {
1170 fire( context, args );
1175 // Call all the callbacks with the given arguments
1177 self.fireWith( this, arguments );
1180 // To know if the callbacks have already been called at least once
1192 var // Static reference to slice
1193 sliceDeferred = [].slice;
1197 Deferred: function( func ) {
1198 var doneList = jQuery.Callbacks( "once memory" ),
1199 failList = jQuery.Callbacks( "once memory" ),
1200 progressList = jQuery.Callbacks( "memory" ),
1205 notify: progressList
1210 progress: progressList.add,
1217 isResolved: doneList.fired,
1218 isRejected: failList.fired,
1220 then: function( doneCallbacks, failCallbacks, progressCallbacks ) {
1221 deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks );
1224 always: function() {
1225 deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments );
1228 pipe: function( fnDone, fnFail, fnProgress ) {
1229 return jQuery.Deferred(function( newDefer ) {
1231 done: [ fnDone, "resolve" ],
1232 fail: [ fnFail, "reject" ],
1233 progress: [ fnProgress, "notify" ]
1234 }, function( handler, data ) {
1238 if ( jQuery.isFunction( fn ) ) {
1239 deferred[ handler ](function() {
1240 returned = fn.apply( this, arguments );
1241 if ( returned && jQuery.isFunction( returned.promise ) ) {
1242 returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify );
1244 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1248 deferred[ handler ]( newDefer[ action ] );
1253 // Get a promise for this deferred
1254 // If obj is provided, the promise aspect is added to the object
1255 promise: function( obj ) {
1256 if ( obj == null ) {
1259 for ( var key in promise ) {
1260 obj[ key ] = promise[ key ];
1266 deferred = promise.promise({}),
1269 for ( key in lists ) {
1270 deferred[ key ] = lists[ key ].fire;
1271 deferred[ key + "With" ] = lists[ key ].fireWith;
1275 deferred.done( function() {
1277 }, failList.disable, progressList.lock ).fail( function() {
1279 }, doneList.disable, progressList.lock );
1281 // Call given func if any
1283 func.call( deferred, deferred );
1291 when: function( firstParam ) {
1292 var args = sliceDeferred.call( arguments, 0 ),
1294 length = args.length,
1295 pValues = new Array( length ),
1298 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1301 promise = deferred.promise();
1302 function resolveFunc( i ) {
1303 return function( value ) {
1304 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1305 if ( !( --count ) ) {
1306 deferred.resolveWith( deferred, args );
1310 function progressFunc( i ) {
1311 return function( value ) {
1312 pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1313 deferred.notifyWith( promise, pValues );
1317 for ( ; i < length; i++ ) {
1318 if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) {
1319 args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) );
1325 deferred.resolveWith( deferred, args );
1327 } else if ( deferred !== firstParam ) {
1328 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1337 jQuery.support = (function() {
1352 div = document.createElement( "div" ),
1353 documentElement = document.documentElement;
1355 // Preliminary tests
1356 div.setAttribute("className", "t");
1357 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1359 all = div.getElementsByTagName( "*" );
1360 a = div.getElementsByTagName( "a" )[ 0 ];
1362 // Can't get basic test support
1363 if ( !all || !all.length || !a ) {
1367 // First batch of supports tests
1368 select = document.createElement( "select" );
1369 opt = select.appendChild( document.createElement("option") );
1370 input = div.getElementsByTagName( "input" )[ 0 ];
1373 // IE strips leading whitespace when .innerHTML is used
1374 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1376 // Make sure that tbody elements aren't automatically inserted
1377 // IE will insert them into empty tables
1378 tbody: !div.getElementsByTagName("tbody").length,
1380 // Make sure that link elements get serialized correctly by innerHTML
1381 // This requires a wrapper element in IE
1382 htmlSerialize: !!div.getElementsByTagName("link").length,
1384 // Get the style information from getAttribute
1385 // (IE uses .cssText instead)
1386 style: /top/.test( a.getAttribute("style") ),
1388 // Make sure that URLs aren't manipulated
1389 // (IE normalizes it by default)
1390 hrefNormalized: ( a.getAttribute("href") === "/a" ),
1392 // Make sure that element opacity exists
1393 // (IE uses filter instead)
1394 // Use a regex to work around a WebKit issue. See #5145
1395 opacity: /^0.55/.test( a.style.opacity ),
1397 // Verify style float existence
1398 // (IE uses styleFloat instead of cssFloat)
1399 cssFloat: !!a.style.cssFloat,
1401 // Make sure that if no value is specified for a checkbox
1402 // that it defaults to "on".
1403 // (WebKit defaults to "" instead)
1404 checkOn: ( input.value === "on" ),
1406 // Make sure that a selected-by-default option has a working selected property.
1407 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1408 optSelected: opt.selected,
1410 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1411 getSetAttribute: div.className !== "t",
1413 // Tests for enctype support on a form(#6743)
1414 enctype: !!document.createElement("form").enctype,
1416 // Makes sure cloning an html5 element does not cause problems
1417 // Where outerHTML is undefined, this still works
1418 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1420 // Will be defined later
1421 submitBubbles: true,
1422 changeBubbles: true,
1423 focusinBubbles: false,
1424 deleteExpando: true,
1426 inlineBlockNeedsLayout: false,
1427 shrinkWrapBlocks: false,
1428 reliableMarginRight: true
1431 // Make sure checked status is properly cloned
1432 input.checked = true;
1433 support.noCloneChecked = input.cloneNode( true ).checked;
1435 // Make sure that the options inside disabled selects aren't marked as disabled
1436 // (WebKit marks them as disabled)
1437 select.disabled = true;
1438 support.optDisabled = !opt.disabled;
1440 // Test to see if it's possible to delete an expando from an element
1441 // Fails in Internet Explorer
1445 support.deleteExpando = false;
1448 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1449 div.attachEvent( "onclick", function() {
1450 // Cloning a node shouldn't copy over any
1451 // bound event handlers (IE does this)
1452 support.noCloneEvent = false;
1454 div.cloneNode( true ).fireEvent( "onclick" );
1457 // Check if a radio maintains its value
1458 // after being appended to the DOM
1459 input = document.createElement("input");
1461 input.setAttribute("type", "radio");
1462 support.radioValue = input.value === "t";
1464 input.setAttribute("checked", "checked");
1465 div.appendChild( input );
1466 fragment = document.createDocumentFragment();
1467 fragment.appendChild( div.lastChild );
1469 // WebKit doesn't clone checked state correctly in fragments
1470 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1472 // Check if a disconnected checkbox will retain its checked
1473 // value of true after appended to the DOM (IE6/7)
1474 support.appendChecked = input.checked;
1476 fragment.removeChild( input );
1477 fragment.appendChild( div );
1481 // Check if div with explicit width and no margin-right incorrectly
1482 // gets computed margin-right based on width of container. For more
1483 // info see bug #3333
1484 // Fails in WebKit before Feb 2011 nightlies
1485 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1486 if ( window.getComputedStyle ) {
1487 marginDiv = document.createElement( "div" );
1488 marginDiv.style.width = "0";
1489 marginDiv.style.marginRight = "0";
1490 div.style.width = "2px";
1491 div.appendChild( marginDiv );
1492 support.reliableMarginRight =
1493 ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1496 // Technique from Juriy Zaytsev
1497 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1498 // We only care about the case where non-standard event systems
1499 // are used, namely in IE. Short-circuiting here helps us to
1500 // avoid an eval call (in setAttribute) which can cause CSP
1501 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1502 if ( div.attachEvent ) {
1508 eventName = "on" + i;
1509 isSupported = ( eventName in div );
1510 if ( !isSupported ) {
1511 div.setAttribute( eventName, "return;" );
1512 isSupported = ( typeof div[ eventName ] === "function" );
1514 support[ i + "Bubbles" ] = isSupported;
1518 fragment.removeChild( div );
1520 // Null elements to avoid leaks in IE
1521 fragment = select = opt = marginDiv = div = input = null;
1523 // Run tests that need a body at doc ready
1525 var container, outer, inner, table, td, offsetSupport,
1526 conMarginTop, ptlm, vb, style, html,
1527 body = document.getElementsByTagName("body")[0];
1530 // Return for frameset docs that don't have a body
1535 ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
1536 vb = "visibility:hidden;border:0;";
1537 style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
1538 html = "<div " + style + "><div></div></div>" +
1539 "<table " + style + " cellpadding='0' cellspacing='0'>" +
1540 "<tr><td></td></tr></table>";
1542 container = document.createElement("div");
1543 container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
1544 body.insertBefore( container, body.firstChild );
1546 // Construct the test element
1547 div = document.createElement("div");
1548 container.appendChild( div );
1550 // Check if table cells still have offsetWidth/Height when they are set
1551 // to display:none and there are still other visible table cells in a
1552 // table row; if so, offsetWidth/Height are not reliable for use when
1553 // determining if an element has been hidden directly using
1554 // display:none (it is still safe to use offsets if a parent element is
1555 // hidden; don safety goggles and see bug #4512 for more information).
1556 // (only IE 8 fails this test)
1557 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1558 tds = div.getElementsByTagName( "td" );
1559 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1561 tds[ 0 ].style.display = "";
1562 tds[ 1 ].style.display = "none";
1564 // Check if empty table cells still have offsetWidth/Height
1565 // (IE <= 8 fail this test)
1566 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1568 // Figure out if the W3C box model works as expected
1570 div.style.width = div.style.paddingLeft = "1px";
1571 jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
1573 if ( typeof div.style.zoom !== "undefined" ) {
1574 // Check if natively block-level elements act like inline-block
1575 // elements when setting their display to 'inline' and giving
1577 // (IE < 8 does this)
1578 div.style.display = "inline";
1580 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1582 // Check if elements with layout shrink-wrap their children
1584 div.style.display = "";
1585 div.innerHTML = "<div style='width:4px;'></div>";
1586 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1589 div.style.cssText = ptlm + vb;
1590 div.innerHTML = html;
1592 outer = div.firstChild;
1593 inner = outer.firstChild;
1594 td = outer.nextSibling.firstChild.firstChild;
1597 doesNotAddBorder: ( inner.offsetTop !== 5 ),
1598 doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
1601 inner.style.position = "fixed";
1602 inner.style.top = "20px";
1604 // safari subtracts parent border width here which is 5px
1605 offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
1606 inner.style.position = inner.style.top = "";
1608 outer.style.overflow = "hidden";
1609 outer.style.position = "relative";
1611 offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
1612 offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
1614 body.removeChild( container );
1615 div = container = null;
1617 jQuery.extend( support, offsetSupport );
1626 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1627 rmultiDash = /([A-Z])/g;
1632 // Please use with caution
1635 // Unique for each copy of jQuery on the page
1636 // Non-digits removed to match rinlinejQuery
1637 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1639 // The following elements throw uncatchable exceptions if you
1640 // attempt to add expando properties to them.
1643 // Ban all objects except for Flash (which handle expandos)
1644 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1648 hasData: function( elem ) {
1649 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1650 return !!elem && !isEmptyDataObject( elem );
1653 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1654 if ( !jQuery.acceptData( elem ) ) {
1658 var privateCache, thisCache, ret,
1659 internalKey = jQuery.expando,
1660 getByName = typeof name === "string",
1662 // We have to handle DOM nodes and JS objects differently because IE6-7
1663 // can't GC object references properly across the DOM-JS boundary
1664 isNode = elem.nodeType,
1666 // Only DOM nodes need the global jQuery cache; JS object data is
1667 // attached directly to the object so GC can occur automatically
1668 cache = isNode ? jQuery.cache : elem,
1670 // Only defining an ID for JS objects if its cache already exists allows
1671 // the code to shortcut on the same path as a DOM node with no cache
1672 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey,
1673 isEvents = name === "events";
1675 // Avoid doing any more work than we need to when trying to get data on an
1676 // object that has no data at all
1677 if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) {
1682 // Only DOM nodes need a new unique ID for each element since their data
1683 // ends up in the global cache
1685 elem[ internalKey ] = id = ++jQuery.uuid;
1691 if ( !cache[ id ] ) {
1694 // Avoids exposing jQuery metadata on plain JS objects when the object
1695 // is serialized using JSON.stringify
1697 cache[ id ].toJSON = jQuery.noop;
1701 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1702 // shallow copied over onto the existing cache
1703 if ( typeof name === "object" || typeof name === "function" ) {
1705 cache[ id ] = jQuery.extend( cache[ id ], name );
1707 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1711 privateCache = thisCache = cache[ id ];
1713 // jQuery data() is stored in a separate object inside the object's internal data
1714 // cache in order to avoid key collisions between internal data and user-defined
1717 if ( !thisCache.data ) {
1718 thisCache.data = {};
1721 thisCache = thisCache.data;
1724 if ( data !== undefined ) {
1725 thisCache[ jQuery.camelCase( name ) ] = data;
1728 // Users should not attempt to inspect the internal events object using jQuery.data,
1729 // it is undocumented and subject to change. But does anyone listen? No.
1730 if ( isEvents && !thisCache[ name ] ) {
1731 return privateCache.events;
1734 // Check for both converted-to-camel and non-converted data property names
1735 // If a data property was specified
1738 // First Try to find as-is property data
1739 ret = thisCache[ name ];
1741 // Test for null|undefined property data
1742 if ( ret == null ) {
1744 // Try to find the camelCased property
1745 ret = thisCache[ jQuery.camelCase( name ) ];
1754 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1755 if ( !jQuery.acceptData( elem ) ) {
1759 var thisCache, i, l,
1761 // Reference to internal data cache key
1762 internalKey = jQuery.expando,
1764 isNode = elem.nodeType,
1766 // See jQuery.data for more information
1767 cache = isNode ? jQuery.cache : elem,
1769 // See jQuery.data for more information
1770 id = isNode ? elem[ internalKey ] : internalKey;
1772 // If there is already no cache entry for this object, there is no
1773 // purpose in continuing
1774 if ( !cache[ id ] ) {
1780 thisCache = pvt ? cache[ id ] : cache[ id ].data;
1784 // Support array or space separated string names for data keys
1785 if ( !jQuery.isArray( name ) ) {
1787 // try the string as a key before any manipulation
1788 if ( name in thisCache ) {
1792 // split the camel cased version by spaces unless a key with the spaces exists
1793 name = jQuery.camelCase( name );
1794 if ( name in thisCache ) {
1797 name = name.split( " " );
1802 for ( i = 0, l = name.length; i < l; i++ ) {
1803 delete thisCache[ name[i] ];
1806 // If there is no data left in the cache, we want to continue
1807 // and let the cache object itself get destroyed
1808 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1814 // See jQuery.data for more information
1816 delete cache[ id ].data;
1818 // Don't destroy the parent cache unless the internal data object
1819 // had been the only thing left in it
1820 if ( !isEmptyDataObject(cache[ id ]) ) {
1825 // Browsers that fail expando deletion also refuse to delete expandos on
1826 // the window, but it will allow it on all other JS objects; other browsers
1828 // Ensure that `cache` is not a window object #10080
1829 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1835 // We destroyed the cache and need to eliminate the expando on the node to avoid
1836 // false lookups in the cache for entries that no longer exist
1838 // IE does not allow us to delete expando properties from nodes,
1839 // nor does it have a removeAttribute function on Document nodes;
1840 // we must handle all of these cases
1841 if ( jQuery.support.deleteExpando ) {
1842 delete elem[ internalKey ];
1843 } else if ( elem.removeAttribute ) {
1844 elem.removeAttribute( internalKey );
1846 elem[ internalKey ] = null;
1851 // For internal use only.
1852 _data: function( elem, name, data ) {
1853 return jQuery.data( elem, name, data, true );
1856 // A method for determining if a DOM node can handle the data expando
1857 acceptData: function( elem ) {
1858 if ( elem.nodeName ) {
1859 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1862 return !(match === true || elem.getAttribute("classid") !== match);
1871 data: function( key, value ) {
1872 var parts, attr, name,
1875 if ( typeof key === "undefined" ) {
1876 if ( this.length ) {
1877 data = jQuery.data( this[0] );
1879 if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
1880 attr = this[0].attributes;
1881 for ( var i = 0, l = attr.length; i < l; i++ ) {
1882 name = attr[i].name;
1884 if ( name.indexOf( "data-" ) === 0 ) {
1885 name = jQuery.camelCase( name.substring(5) );
1887 dataAttr( this[0], name, data[ name ] );
1890 jQuery._data( this[0], "parsedAttrs", true );
1896 } else if ( typeof key === "object" ) {
1897 return this.each(function() {
1898 jQuery.data( this, key );
1902 parts = key.split(".");
1903 parts[1] = parts[1] ? "." + parts[1] : "";
1905 if ( value === undefined ) {
1906 data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1908 // Try to fetch any internally stored data first
1909 if ( data === undefined && this.length ) {
1910 data = jQuery.data( this[0], key );
1911 data = dataAttr( this[0], key, data );
1914 return data === undefined && parts[1] ?
1915 this.data( parts[0] ) :
1919 return this.each(function() {
1920 var self = jQuery( this ),
1921 args = [ parts[0], value ];
1923 self.triggerHandler( "setData" + parts[1] + "!", args );
1924 jQuery.data( this, key, value );
1925 self.triggerHandler( "changeData" + parts[1] + "!", args );
1930 removeData: function( key ) {
1931 return this.each(function() {
1932 jQuery.removeData( this, key );
1937 function dataAttr( elem, key, data ) {
1938 // If nothing was found internally, try to fetch any
1939 // data from the HTML5 data-* attribute
1940 if ( data === undefined && elem.nodeType === 1 ) {
1942 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1944 data = elem.getAttribute( name );
1946 if ( typeof data === "string" ) {
1948 data = data === "true" ? true :
1949 data === "false" ? false :
1950 data === "null" ? null :
1951 jQuery.isNumeric( data ) ? parseFloat( data ) :
1952 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1956 // Make sure we set the data so it isn't changed later
1957 jQuery.data( elem, key, data );
1967 // checks a cache object for emptiness
1968 function isEmptyDataObject( obj ) {
1969 for ( var name in obj ) {
1971 // if the public data object is empty, the private is still empty
1972 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1975 if ( name !== "toJSON" ) {
1986 function handleQueueMarkDefer( elem, type, src ) {
1987 var deferDataKey = type + "defer",
1988 queueDataKey = type + "queue",
1989 markDataKey = type + "mark",
1990 defer = jQuery._data( elem, deferDataKey );
1992 ( src === "queue" || !jQuery._data(elem, queueDataKey) ) &&
1993 ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) {
1994 // Give room for hard-coded callbacks to fire first
1995 // and eventually mark/queue something else on the element
1996 setTimeout( function() {
1997 if ( !jQuery._data( elem, queueDataKey ) &&
1998 !jQuery._data( elem, markDataKey ) ) {
1999 jQuery.removeData( elem, deferDataKey, true );
2008 _mark: function( elem, type ) {
2010 type = ( type || "fx" ) + "mark";
2011 jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
2015 _unmark: function( force, elem, type ) {
2016 if ( force !== true ) {
2022 type = type || "fx";
2023 var key = type + "mark",
2024 count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
2026 jQuery._data( elem, key, count );
2028 jQuery.removeData( elem, key, true );
2029 handleQueueMarkDefer( elem, type, "mark" );
2034 queue: function( elem, type, data ) {
2037 type = ( type || "fx" ) + "queue";
2038 q = jQuery._data( elem, type );
2040 // Speed up dequeue by getting out quickly if this is just a lookup
2042 if ( !q || jQuery.isArray(data) ) {
2043 q = jQuery._data( elem, type, jQuery.makeArray(data) );
2052 dequeue: function( elem, type ) {
2053 type = type || "fx";
2055 var queue = jQuery.queue( elem, type ),
2059 // If the fx queue is dequeued, always remove the progress sentinel
2060 if ( fn === "inprogress" ) {
2065 // Add a progress sentinel to prevent the fx queue from being
2066 // automatically dequeued
2067 if ( type === "fx" ) {
2068 queue.unshift( "inprogress" );
2071 jQuery._data( elem, type + ".run", hooks );
2072 fn.call( elem, function() {
2073 jQuery.dequeue( elem, type );
2077 if ( !queue.length ) {
2078 jQuery.removeData( elem, type + "queue " + type + ".run", true );
2079 handleQueueMarkDefer( elem, type, "queue" );
2085 queue: function( type, data ) {
2086 if ( typeof type !== "string" ) {
2091 if ( data === undefined ) {
2092 return jQuery.queue( this[0], type );
2094 return this.each(function() {
2095 var queue = jQuery.queue( this, type, data );
2097 if ( type === "fx" && queue[0] !== "inprogress" ) {
2098 jQuery.dequeue( this, type );
2102 dequeue: function( type ) {
2103 return this.each(function() {
2104 jQuery.dequeue( this, type );
2107 // Based off of the plugin by Clint Helfers, with permission.
2108 // http://blindsignals.com/index.php/2009/07/jquery-delay/
2109 delay: function( time, type ) {
2110 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
2111 type = type || "fx";
2113 return this.queue( type, function( next, hooks ) {
2114 var timeout = setTimeout( next, time );
2115 hooks.stop = function() {
2116 clearTimeout( timeout );
2120 clearQueue: function( type ) {
2121 return this.queue( type || "fx", [] );
2123 // Get a promise resolved when queues of a certain type
2124 // are emptied (fx is the type by default)
2125 promise: function( type, object ) {
2126 if ( typeof type !== "string" ) {
2130 type = type || "fx";
2131 var defer = jQuery.Deferred(),
2133 i = elements.length,
2135 deferDataKey = type + "defer",
2136 queueDataKey = type + "queue",
2137 markDataKey = type + "mark",
2139 function resolve() {
2140 if ( !( --count ) ) {
2141 defer.resolveWith( elements, [ elements ] );
2145 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
2146 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
2147 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
2148 jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
2154 return defer.promise();
2161 var rclass = /[\n\t\r]/g,
2164 rtype = /^(?:button|input)$/i,
2165 rfocusable = /^(?:button|input|object|select|textarea)$/i,
2166 rclickable = /^a(?:rea)?$/i,
2167 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2168 getSetAttribute = jQuery.support.getSetAttribute,
2169 nodeHook, boolHook, fixSpecified;
2172 attr: function( name, value ) {
2173 return jQuery.access( this, name, value, true, jQuery.attr );
2176 removeAttr: function( name ) {
2177 return this.each(function() {
2178 jQuery.removeAttr( this, name );
2182 prop: function( name, value ) {
2183 return jQuery.access( this, name, value, true, jQuery.prop );
2186 removeProp: function( name ) {
2187 name = jQuery.propFix[ name ] || name;
2188 return this.each(function() {
2189 // try/catch handles cases where IE balks (such as removing a property on window)
2191 this[ name ] = undefined;
2192 delete this[ name ];
2197 addClass: function( value ) {
2198 var classNames, i, l, elem,
2201 if ( jQuery.isFunction( value ) ) {
2202 return this.each(function( j ) {
2203 jQuery( this ).addClass( value.call(this, j, this.className) );
2207 if ( value && typeof value === "string" ) {
2208 classNames = value.split( rspace );
2210 for ( i = 0, l = this.length; i < l; i++ ) {
2213 if ( elem.nodeType === 1 ) {
2214 if ( !elem.className && classNames.length === 1 ) {
2215 elem.className = value;
2218 setClass = " " + elem.className + " ";
2220 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2221 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2222 setClass += classNames[ c ] + " ";
2225 elem.className = jQuery.trim( setClass );
2234 removeClass: function( value ) {
2235 var classNames, i, l, elem, className, c, cl;
2237 if ( jQuery.isFunction( value ) ) {
2238 return this.each(function( j ) {
2239 jQuery( this ).removeClass( value.call(this, j, this.className) );
2243 if ( (value && typeof value === "string") || value === undefined ) {
2244 classNames = ( value || "" ).split( rspace );
2246 for ( i = 0, l = this.length; i < l; i++ ) {
2249 if ( elem.nodeType === 1 && elem.className ) {
2251 className = (" " + elem.className + " ").replace( rclass, " " );
2252 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2253 className = className.replace(" " + classNames[ c ] + " ", " ");
2255 elem.className = jQuery.trim( className );
2258 elem.className = "";
2267 toggleClass: function( value, stateVal ) {
2268 var type = typeof value,
2269 isBool = typeof stateVal === "boolean";
2271 if ( jQuery.isFunction( value ) ) {
2272 return this.each(function( i ) {
2273 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2277 return this.each(function() {
2278 if ( type === "string" ) {
2279 // toggle individual class names
2282 self = jQuery( this ),
2284 classNames = value.split( rspace );
2286 while ( (className = classNames[ i++ ]) ) {
2287 // check each className given, space seperated list
2288 state = isBool ? state : !self.hasClass( className );
2289 self[ state ? "addClass" : "removeClass" ]( className );
2292 } else if ( type === "undefined" || type === "boolean" ) {
2293 if ( this.className ) {
2294 // store className if set
2295 jQuery._data( this, "__className__", this.className );
2298 // toggle whole className
2299 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2304 hasClass: function( selector ) {
2305 var className = " " + selector + " ",
2308 for ( ; i < l; i++ ) {
2309 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2317 val: function( value ) {
2318 var hooks, ret, isFunction,
2321 if ( !arguments.length ) {
2323 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2325 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2331 return typeof ret === "string" ?
2332 // handle most common string cases
2333 ret.replace(rreturn, "") :
2334 // handle cases where value is null/undef or number
2335 ret == null ? "" : ret;
2341 isFunction = jQuery.isFunction( value );
2343 return this.each(function( i ) {
2344 var self = jQuery(this), val;
2346 if ( this.nodeType !== 1 ) {
2351 val = value.call( this, i, self.val() );
2356 // Treat null/undefined as ""; convert numbers to string
2357 if ( val == null ) {
2359 } else if ( typeof val === "number" ) {
2361 } else if ( jQuery.isArray( val ) ) {
2362 val = jQuery.map(val, function ( value ) {
2363 return value == null ? "" : value + "";
2367 hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2369 // If set returns undefined, fall back to normal setting
2370 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2380 get: function( elem ) {
2381 // attributes.value is undefined in Blackberry 4.7 but
2382 // uses .value. See #6932
2383 var val = elem.attributes.value;
2384 return !val || val.specified ? elem.value : elem.text;
2388 get: function( elem ) {
2389 var value, i, max, option,
2390 index = elem.selectedIndex,
2392 options = elem.options,
2393 one = elem.type === "select-one";
2395 // Nothing was selected
2400 // Loop through all the selected options
2401 i = one ? index : 0;
2402 max = one ? index + 1 : options.length;
2403 for ( ; i < max; i++ ) {
2404 option = options[ i ];
2406 // Don't return options that are disabled or in a disabled optgroup
2407 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2408 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2410 // Get the specific value for the option
2411 value = jQuery( option ).val();
2413 // We don't need an array for one selects
2418 // Multi-Selects return an array
2419 values.push( value );
2423 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2424 if ( one && !values.length && options.length ) {
2425 return jQuery( options[ index ] ).val();
2431 set: function( elem, value ) {
2432 var values = jQuery.makeArray( value );
2434 jQuery(elem).find("option").each(function() {
2435 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2438 if ( !values.length ) {
2439 elem.selectedIndex = -1;
2457 attr: function( elem, name, value, pass ) {
2458 var ret, hooks, notxml,
2459 nType = elem.nodeType;
2461 // don't get/set attributes on text, comment and attribute nodes
2462 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2466 if ( pass && name in jQuery.attrFn ) {
2467 return jQuery( elem )[ name ]( value );
2470 // Fallback to prop when attributes are not supported
2471 if ( typeof elem.getAttribute === "undefined" ) {
2472 return jQuery.prop( elem, name, value );
2475 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2477 // All attributes are lowercase
2478 // Grab necessary hook if one is defined
2480 name = name.toLowerCase();
2481 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2484 if ( value !== undefined ) {
2486 if ( value === null ) {
2487 jQuery.removeAttr( elem, name );
2490 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2494 elem.setAttribute( name, "" + value );
2498 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2503 ret = elem.getAttribute( name );
2505 // Non-existent attributes return null, we normalize to undefined
2506 return ret === null ?
2512 removeAttr: function( elem, value ) {
2513 var propName, attrNames, name, l,
2516 if ( value && elem.nodeType === 1 ) {
2517 attrNames = value.toLowerCase().split( rspace );
2518 l = attrNames.length;
2520 for ( ; i < l; i++ ) {
2521 name = attrNames[ i ];
2524 propName = jQuery.propFix[ name ] || name;
2526 // See #9699 for explanation of this approach (setting first, then removal)
2527 jQuery.attr( elem, name, "" );
2528 elem.removeAttribute( getSetAttribute ? name : propName );
2530 // Set corresponding property to false for boolean attributes
2531 if ( rboolean.test( name ) && propName in elem ) {
2532 elem[ propName ] = false;
2541 set: function( elem, value ) {
2542 // We can't allow the type property to be changed (since it causes problems in IE)
2543 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2544 jQuery.error( "type property can't be changed" );
2545 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2546 // Setting the type on a radio button after the value resets the value in IE6-9
2547 // Reset value to it's default in case type is set after value
2548 // This is for element creation
2549 var val = elem.value;
2550 elem.setAttribute( "type", value );
2558 // Use the value property for back compat
2559 // Use the nodeHook for button elements in IE6/7 (#1954)
2561 get: function( elem, name ) {
2562 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2563 return nodeHook.get( elem, name );
2565 return name in elem ?
2569 set: function( elem, value, name ) {
2570 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2571 return nodeHook.set( elem, value, name );
2573 // Does not return so that setAttribute is also used
2580 tabindex: "tabIndex",
2581 readonly: "readOnly",
2583 "class": "className",
2584 maxlength: "maxLength",
2585 cellspacing: "cellSpacing",
2586 cellpadding: "cellPadding",
2590 frameborder: "frameBorder",
2591 contenteditable: "contentEditable"
2594 prop: function( elem, name, value ) {
2595 var ret, hooks, notxml,
2596 nType = elem.nodeType;
2598 // don't get/set properties on text, comment and attribute nodes
2599 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2603 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2606 // Fix name and attach hooks
2607 name = jQuery.propFix[ name ] || name;
2608 hooks = jQuery.propHooks[ name ];
2611 if ( value !== undefined ) {
2612 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2616 return ( elem[ name ] = value );
2620 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2624 return elem[ name ];
2631 get: function( elem ) {
2632 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2633 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2634 var attributeNode = elem.getAttributeNode("tabindex");
2636 return attributeNode && attributeNode.specified ?
2637 parseInt( attributeNode.value, 10 ) :
2638 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2646 // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
2647 jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
2649 // Hook for boolean attributes
2651 get: function( elem, name ) {
2652 // Align boolean attributes with corresponding properties
2653 // Fall back to attribute presence where some booleans are not supported
2655 property = jQuery.prop( elem, name );
2656 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2657 name.toLowerCase() :
2660 set: function( elem, value, name ) {
2662 if ( value === false ) {
2663 // Remove boolean attributes when set to false
2664 jQuery.removeAttr( elem, name );
2666 // value is true since we know at this point it's type boolean and not false
2667 // Set boolean attributes to the same name and set the DOM property
2668 propName = jQuery.propFix[ name ] || name;
2669 if ( propName in elem ) {
2670 // Only set the IDL specifically if it already exists on the element
2671 elem[ propName ] = true;
2674 elem.setAttribute( name, name.toLowerCase() );
2680 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2681 if ( !getSetAttribute ) {
2688 // Use this for any attribute in IE6/7
2689 // This fixes almost every IE6/7 issue
2690 nodeHook = jQuery.valHooks.button = {
2691 get: function( elem, name ) {
2693 ret = elem.getAttributeNode( name );
2694 return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
2698 set: function( elem, value, name ) {
2699 // Set the existing or create a new attribute node
2700 var ret = elem.getAttributeNode( name );
2702 ret = document.createAttribute( name );
2703 elem.setAttributeNode( ret );
2705 return ( ret.nodeValue = value + "" );
2709 // Apply the nodeHook to tabindex
2710 jQuery.attrHooks.tabindex.set = nodeHook.set;
2712 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2713 // This is for removals
2714 jQuery.each([ "width", "height" ], function( i, name ) {
2715 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2716 set: function( elem, value ) {
2717 if ( value === "" ) {
2718 elem.setAttribute( name, "auto" );
2725 // Set contenteditable to false on removals(#10429)
2726 // Setting to empty string throws an error as an invalid value
2727 jQuery.attrHooks.contenteditable = {
2729 set: function( elem, value, name ) {
2730 if ( value === "" ) {
2733 nodeHook.set( elem, value, name );
2739 // Some attributes require a special call on IE
2740 if ( !jQuery.support.hrefNormalized ) {
2741 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2742 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2743 get: function( elem ) {
2744 var ret = elem.getAttribute( name, 2 );
2745 return ret === null ? undefined : ret;
2751 if ( !jQuery.support.style ) {
2752 jQuery.attrHooks.style = {
2753 get: function( elem ) {
2754 // Return undefined in the case of empty string
2755 // Normalize to lowercase since IE uppercases css property names
2756 return elem.style.cssText.toLowerCase() || undefined;
2758 set: function( elem, value ) {
2759 return ( elem.style.cssText = "" + value );
2764 // Safari mis-reports the default selected property of an option
2765 // Accessing the parent's selectedIndex property fixes it
2766 if ( !jQuery.support.optSelected ) {
2767 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2768 get: function( elem ) {
2769 var parent = elem.parentNode;
2772 parent.selectedIndex;
2774 // Make sure that it also works with optgroups, see #5701
2775 if ( parent.parentNode ) {
2776 parent.parentNode.selectedIndex;
2784 // IE6/7 call enctype encoding
2785 if ( !jQuery.support.enctype ) {
2786 jQuery.propFix.enctype = "encoding";
2789 // Radios and checkboxes getter/setter
2790 if ( !jQuery.support.checkOn ) {
2791 jQuery.each([ "radio", "checkbox" ], function() {
2792 jQuery.valHooks[ this ] = {
2793 get: function( elem ) {
2794 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2795 return elem.getAttribute("value") === null ? "on" : elem.value;
2800 jQuery.each([ "radio", "checkbox" ], function() {
2801 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2802 set: function( elem, value ) {
2803 if ( jQuery.isArray( value ) ) {
2804 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2813 var rformElems = /^(?:textarea|input|select)$/i,
2814 rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
2815 rhoverHack = /\bhover(\.\S+)?\b/,
2817 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2818 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2819 rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
2820 quickParse = function( selector ) {
2821 var quick = rquickIs.exec( selector );
2824 // [ _, tag, id, class ]
2825 quick[1] = ( quick[1] || "" ).toLowerCase();
2826 quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
2830 quickIs = function( elem, m ) {
2831 var attrs = elem.attributes || {};
2833 (!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
2834 (!m[2] || (attrs.id || {}).value === m[2]) &&
2835 (!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
2838 hoverHack = function( events ) {
2839 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2843 * Helper functions for managing events -- not part of the public interface.
2844 * Props to Dean Edwards' addEvent library for many of the ideas.
2848 add: function( elem, types, handler, data, selector ) {
2850 var elemData, eventHandle, events,
2851 t, tns, type, namespaces, handleObj,
2852 handleObjIn, quick, handlers, special;
2854 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2855 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2859 // Caller can pass in an object of custom data in lieu of the handler
2860 if ( handler.handler ) {
2861 handleObjIn = handler;
2862 handler = handleObjIn.handler;
2865 // Make sure that the handler has a unique ID, used to find/remove it later
2866 if ( !handler.guid ) {
2867 handler.guid = jQuery.guid++;
2870 // Init the element's event structure and main handler, if this is the first
2871 events = elemData.events;
2873 elemData.events = events = {};
2875 eventHandle = elemData.handle;
2876 if ( !eventHandle ) {
2877 elemData.handle = eventHandle = function( e ) {
2878 // Discard the second event of a jQuery.event.trigger() and
2879 // when an event is called after a page has unloaded
2880 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2881 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2884 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2885 eventHandle.elem = elem;
2888 // Handle multiple events separated by a space
2889 // jQuery(...).bind("mouseover mouseout", fn);
2890 types = jQuery.trim( hoverHack(types) ).split( " " );
2891 for ( t = 0; t < types.length; t++ ) {
2893 tns = rtypenamespace.exec( types[t] ) || [];
2895 namespaces = ( tns[2] || "" ).split( "." ).sort();
2897 // If event changes its type, use the special event handlers for the changed type
2898 special = jQuery.event.special[ type ] || {};
2900 // If selector defined, determine special event api type, otherwise given type
2901 type = ( selector ? special.delegateType : special.bindType ) || type;
2903 // Update special based on newly reset type
2904 special = jQuery.event.special[ type ] || {};
2906 // handleObj is passed to all event handlers
2907 handleObj = jQuery.extend({
2914 quick: quickParse( selector ),
2915 namespace: namespaces.join(".")
2918 // Init the event handler queue if we're the first
2919 handlers = events[ type ];
2921 handlers = events[ type ] = [];
2922 handlers.delegateCount = 0;
2924 // Only use addEventListener/attachEvent if the special events handler returns false
2925 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2926 // Bind the global event handler to the element
2927 if ( elem.addEventListener ) {
2928 elem.addEventListener( type, eventHandle, false );
2930 } else if ( elem.attachEvent ) {
2931 elem.attachEvent( "on" + type, eventHandle );
2936 if ( special.add ) {
2937 special.add.call( elem, handleObj );
2939 if ( !handleObj.handler.guid ) {
2940 handleObj.handler.guid = handler.guid;
2944 // Add to the element's handler list, delegates in front
2946 handlers.splice( handlers.delegateCount++, 0, handleObj );
2948 handlers.push( handleObj );
2951 // Keep track of which events have ever been used, for event optimization
2952 jQuery.event.global[ type ] = true;
2955 // Nullify elem to prevent memory leaks in IE
2961 // Detach an event or set of events from an element
2962 remove: function( elem, types, handler, selector, mappedTypes ) {
2964 var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2965 t, tns, type, origType, namespaces, origCount,
2966 j, events, special, handle, eventType, handleObj;
2968 if ( !elemData || !(events = elemData.events) ) {
2972 // Once for each type.namespace in types; type may be omitted
2973 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
2974 for ( t = 0; t < types.length; t++ ) {
2975 tns = rtypenamespace.exec( types[t] ) || [];
2976 type = origType = tns[1];
2977 namespaces = tns[2];
2979 // Unbind all events (on this namespace, if provided) for the element
2981 for ( type in events ) {
2982 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2987 special = jQuery.event.special[ type ] || {};
2988 type = ( selector? special.delegateType : special.bindType ) || type;
2989 eventType = events[ type ] || [];
2990 origCount = eventType.length;
2991 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
2993 // Remove matching events
2994 for ( j = 0; j < eventType.length; j++ ) {
2995 handleObj = eventType[ j ];
2997 if ( ( mappedTypes || origType === handleObj.origType ) &&
2998 ( !handler || handler.guid === handleObj.guid ) &&
2999 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
3000 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
3001 eventType.splice( j--, 1 );
3003 if ( handleObj.selector ) {
3004 eventType.delegateCount--;
3006 if ( special.remove ) {
3007 special.remove.call( elem, handleObj );
3012 // Remove generic event handler if we removed something and no more handlers exist
3013 // (avoids potential for endless recursion during removal of special event handlers)
3014 if ( eventType.length === 0 && origCount !== eventType.length ) {
3015 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
3016 jQuery.removeEvent( elem, type, elemData.handle );
3019 delete events[ type ];
3023 // Remove the expando if it's no longer used
3024 if ( jQuery.isEmptyObject( events ) ) {
3025 handle = elemData.handle;
3030 // removeData also checks for emptiness and clears the expando if empty
3031 // so use it instead of delete
3032 jQuery.removeData( elem, [ "events", "handle" ], true );
3036 // Events that are safe to short-circuit if no handlers are attached.
3037 // Native DOM events should not be added, they may have inline handlers.
3044 trigger: function( event, data, elem, onlyHandlers ) {
3045 // Don't do events on text and comment nodes
3046 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
3050 // Event object or event type
3051 var type = event.type || event,
3053 cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType;
3055 // focus/blur morphs to focusin/out; ensure we're not firing them right now
3056 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
3060 if ( type.indexOf( "!" ) >= 0 ) {
3061 // Exclusive events trigger only for the exact event (no namespaces)
3062 type = type.slice(0, -1);
3066 if ( type.indexOf( "." ) >= 0 ) {
3067 // Namespaced trigger; create a regexp to match event type in handle()
3068 namespaces = type.split(".");
3069 type = namespaces.shift();
3073 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
3074 // No jQuery handlers for this event type, and it can't have inline handlers
3078 // Caller can pass in an Event, Object, or just an event type string
3079 event = typeof event === "object" ?
3080 // jQuery.Event object
3081 event[ jQuery.expando ] ? event :
3083 new jQuery.Event( type, event ) :
3084 // Just the event type (string)
3085 new jQuery.Event( type );
3088 event.isTrigger = true;
3089 event.exclusive = exclusive;
3090 event.namespace = namespaces.join( "." );
3091 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
3092 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
3094 // Handle a global trigger
3097 // TODO: Stop taunting the data cache; remove global events and always attach to document
3098 cache = jQuery.cache;
3099 for ( i in cache ) {
3100 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
3101 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
3107 // Clean up the event in case it is being reused
3108 event.result = undefined;
3109 if ( !event.target ) {
3110 event.target = elem;
3113 // Clone any incoming data and prepend the event, creating the handler arg list
3114 data = data != null ? jQuery.makeArray( data ) : [];
3115 data.unshift( event );
3117 // Allow special events to draw outside the lines
3118 special = jQuery.event.special[ type ] || {};
3119 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
3123 // Determine event propagation path in advance, per W3C events spec (#9951)
3124 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
3125 eventPath = [[ elem, special.bindType || type ]];
3126 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
3128 bubbleType = special.delegateType || type;
3129 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
3131 for ( ; cur; cur = cur.parentNode ) {
3132 eventPath.push([ cur, bubbleType ]);
3136 // Only add window if we got to document (e.g., not plain obj or detached DOM)
3137 if ( old && old === elem.ownerDocument ) {
3138 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
3142 // Fire handlers on the event path
3143 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
3145 cur = eventPath[i][0];
3146 event.type = eventPath[i][1];
3148 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
3150 handle.apply( cur, data );
3152 // Note that this is a bare JS function and not a jQuery handler
3153 handle = ontype && cur[ ontype ];
3154 if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
3155 event.preventDefault();
3160 // If nobody prevented the default action, do it now
3161 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
3163 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
3164 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
3166 // Call a native DOM method on the target with the same name name as the event.
3167 // Can't use an .isFunction() check here because IE6/7 fails that test.
3168 // Don't do default actions on window, that's where global variables be (#6170)
3169 // IE<9 dies on focus/blur to hidden element (#1486)
3170 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
3172 // Don't re-trigger an onFOO event when we call its FOO() method
3173 old = elem[ ontype ];
3176 elem[ ontype ] = null;
3179 // Prevent re-triggering of the same event, since we already bubbled it above
3180 jQuery.event.triggered = type;
3182 jQuery.event.triggered = undefined;
3185 elem[ ontype ] = old;
3191 return event.result;
3194 dispatch: function( event ) {
3196 // Make a writable jQuery.Event from the native event object
3197 event = jQuery.event.fix( event || window.event );
3199 var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
3200 delegateCount = handlers.delegateCount,
3201 args = [].slice.call( arguments, 0 ),
3202 run_all = !event.exclusive && !event.namespace,
3204 i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
3206 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3208 event.delegateTarget = this;
3210 // Determine handlers that should run if there are delegated events
3211 // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
3212 if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
3214 // Pregenerate a single jQuery object for reuse with .is()
3215 jqcur = jQuery(this);
3216 jqcur.context = this.ownerDocument || this;
3218 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3222 for ( i = 0; i < delegateCount; i++ ) {
3223 handleObj = handlers[ i ];
3224 sel = handleObj.selector;
3226 if ( selMatch[ sel ] === undefined ) {
3228 handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
3231 if ( selMatch[ sel ] ) {
3232 matches.push( handleObj );
3235 if ( matches.length ) {
3236 handlerQueue.push({ elem: cur, matches: matches });
3241 // Add the remaining (directly-bound) handlers
3242 if ( handlers.length > delegateCount ) {
3243 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3246 // Run delegates first; they may want to stop propagation beneath us
3247 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3248 matched = handlerQueue[ i ];
3249 event.currentTarget = matched.elem;
3251 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3252 handleObj = matched.matches[ j ];
3254 // Triggered event must either 1) be non-exclusive and have no namespace, or
3255 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3256 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3258 event.data = handleObj.data;
3259 event.handleObj = handleObj;
3261 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3262 .apply( matched.elem, args );
3264 if ( ret !== undefined ) {
3266 if ( ret === false ) {
3267 event.preventDefault();
3268 event.stopPropagation();
3275 return event.result;
3278 // Includes some event props shared by KeyEvent and MouseEvent
3279 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3280 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3285 props: "char charCode key keyCode".split(" "),
3286 filter: function( event, original ) {
3288 // Add which for key events
3289 if ( event.which == null ) {
3290 event.which = original.charCode != null ? original.charCode : original.keyCode;
3298 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3299 filter: function( event, original ) {
3300 var eventDoc, doc, body,
3301 button = original.button,
3302 fromElement = original.fromElement;
3304 // Calculate pageX/Y if missing and clientX/Y available
3305 if ( event.pageX == null && original.clientX != null ) {
3306 eventDoc = event.target.ownerDocument || document;
3307 doc = eventDoc.documentElement;
3308 body = eventDoc.body;
3310 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3311 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3314 // Add relatedTarget, if necessary
3315 if ( !event.relatedTarget && fromElement ) {
3316 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3319 // Add which for click: 1 === left; 2 === middle; 3 === right
3320 // Note: button is not normalized, so don't use it
3321 if ( !event.which && button !== undefined ) {
3322 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3329 fix: function( event ) {
3330 if ( event[ jQuery.expando ] ) {
3334 // Create a writable copy of the event object and normalize some properties
3336 originalEvent = event,
3337 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3338 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3340 event = jQuery.Event( originalEvent );
3342 for ( i = copy.length; i; ) {
3344 event[ prop ] = originalEvent[ prop ];
3347 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3348 if ( !event.target ) {
3349 event.target = originalEvent.srcElement || document;
3352 // Target should not be a text node (#504, Safari)
3353 if ( event.target.nodeType === 3 ) {
3354 event.target = event.target.parentNode;
3357 // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8)
3358 if ( event.metaKey === undefined ) {
3359 event.metaKey = event.ctrlKey;
3362 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3367 // Make sure the ready event is setup
3368 setup: jQuery.bindReady
3372 // Prevent triggered image.load events from bubbling to window.load
3377 delegateType: "focusin"
3380 delegateType: "focusout"
3384 setup: function( data, namespaces, eventHandle ) {
3385 // We only want to do this special case on windows
3386 if ( jQuery.isWindow( this ) ) {
3387 this.onbeforeunload = eventHandle;
3391 teardown: function( namespaces, eventHandle ) {
3392 if ( this.onbeforeunload === eventHandle ) {
3393 this.onbeforeunload = null;
3399 simulate: function( type, elem, event, bubble ) {
3400 // Piggyback on a donor event to simulate a different one.
3401 // Fake originalEvent to avoid donor's stopPropagation, but if the
3402 // simulated event prevents default then we do the same on the donor.
3403 var e = jQuery.extend(
3412 jQuery.event.trigger( e, null, elem );
3414 jQuery.event.dispatch.call( elem, e );
3416 if ( e.isDefaultPrevented() ) {
3417 event.preventDefault();
3422 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3423 // The 1.7 special event interface should provide all the hooks needed now.
3424 jQuery.event.handle = jQuery.event.dispatch;
3426 jQuery.removeEvent = document.removeEventListener ?
3427 function( elem, type, handle ) {
3428 if ( elem.removeEventListener ) {
3429 elem.removeEventListener( type, handle, false );
3432 function( elem, type, handle ) {
3433 if ( elem.detachEvent ) {
3434 elem.detachEvent( "on" + type, handle );
3438 jQuery.Event = function( src, props ) {
3439 // Allow instantiation without the 'new' keyword
3440 if ( !(this instanceof jQuery.Event) ) {
3441 return new jQuery.Event( src, props );
3445 if ( src && src.type ) {
3446 this.originalEvent = src;
3447 this.type = src.type;
3449 // Events bubbling up the document may have been marked as prevented
3450 // by a handler lower down the tree; reflect the correct value.
3451 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3452 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3459 // Put explicitly provided properties onto the event object
3461 jQuery.extend( this, props );
3464 // Create a timestamp if incoming event doesn't have one
3465 this.timeStamp = src && src.timeStamp || jQuery.now();
3468 this[ jQuery.expando ] = true;
3471 function returnFalse() {
3474 function returnTrue() {
3478 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3479 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3480 jQuery.Event.prototype = {
3481 preventDefault: function() {
3482 this.isDefaultPrevented = returnTrue;
3484 var e = this.originalEvent;
3489 // if preventDefault exists run it on the original event
3490 if ( e.preventDefault ) {
3493 // otherwise set the returnValue property of the original event to false (IE)
3495 e.returnValue = false;
3498 stopPropagation: function() {
3499 this.isPropagationStopped = returnTrue;
3501 var e = this.originalEvent;
3505 // if stopPropagation exists run it on the original event
3506 if ( e.stopPropagation ) {
3507 e.stopPropagation();
3509 // otherwise set the cancelBubble property of the original event to true (IE)
3510 e.cancelBubble = true;
3512 stopImmediatePropagation: function() {
3513 this.isImmediatePropagationStopped = returnTrue;
3514 this.stopPropagation();
3516 isDefaultPrevented: returnFalse,
3517 isPropagationStopped: returnFalse,
3518 isImmediatePropagationStopped: returnFalse
3521 // Create mouseenter/leave events using mouseover/out and event-time checks
3523 mouseenter: "mouseover",
3524 mouseleave: "mouseout"
3525 }, function( orig, fix ) {
3526 jQuery.event.special[ orig ] = {
3530 handle: function( event ) {
3532 related = event.relatedTarget,
3533 handleObj = event.handleObj,
3534 selector = handleObj.selector,
3537 // For mousenter/leave call the handler if related is outside the target.
3538 // NB: No relatedTarget if the mouse left/entered the browser window
3539 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3540 event.type = handleObj.origType;
3541 ret = handleObj.handler.apply( this, arguments );
3549 // IE submit delegation
3550 if ( !jQuery.support.submitBubbles ) {
3552 jQuery.event.special.submit = {
3554 // Only need this for delegated form submit events
3555 if ( jQuery.nodeName( this, "form" ) ) {
3559 // Lazy-add a submit handler when a descendant form may potentially be submitted
3560 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3561 // Node name check avoids a VML-related crash in IE (#9807)
3562 var elem = e.target,
3563 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3564 if ( form && !form._submit_attached ) {
3565 jQuery.event.add( form, "submit._submit", function( event ) {
3566 // If form was submitted by the user, bubble the event up the tree
3567 if ( this.parentNode && !event.isTrigger ) {
3568 jQuery.event.simulate( "submit", this.parentNode, event, true );
3571 form._submit_attached = true;
3574 // return undefined since we don't need an event listener
3577 teardown: function() {
3578 // Only need this for delegated form submit events
3579 if ( jQuery.nodeName( this, "form" ) ) {
3583 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3584 jQuery.event.remove( this, "._submit" );
3589 // IE change delegation and checkbox/radio fix
3590 if ( !jQuery.support.changeBubbles ) {
3592 jQuery.event.special.change = {
3596 if ( rformElems.test( this.nodeName ) ) {
3597 // IE doesn't fire change on a check/radio until blur; trigger it on click
3598 // after a propertychange. Eat the blur-change in special.change.handle.
3599 // This still fires onchange a second time for check/radio after blur.
3600 if ( this.type === "checkbox" || this.type === "radio" ) {
3601 jQuery.event.add( this, "propertychange._change", function( event ) {
3602 if ( event.originalEvent.propertyName === "checked" ) {
3603 this._just_changed = true;
3606 jQuery.event.add( this, "click._change", function( event ) {
3607 if ( this._just_changed && !event.isTrigger ) {
3608 this._just_changed = false;
3609 jQuery.event.simulate( "change", this, event, true );
3615 // Delegated event; lazy-add a change handler on descendant inputs
3616 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3617 var elem = e.target;
3619 if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
3620 jQuery.event.add( elem, "change._change", function( event ) {
3621 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3622 jQuery.event.simulate( "change", this.parentNode, event, true );
3625 elem._change_attached = true;
3630 handle: function( event ) {
3631 var elem = event.target;
3633 // Swallow native change events from checkbox/radio, we already triggered them above
3634 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3635 return event.handleObj.handler.apply( this, arguments );
3639 teardown: function() {
3640 jQuery.event.remove( this, "._change" );
3642 return rformElems.test( this.nodeName );
3647 // Create "bubbling" focus and blur events
3648 if ( !jQuery.support.focusinBubbles ) {
3649 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3651 // Attach a single capturing handler while someone wants focusin/focusout
3653 handler = function( event ) {
3654 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3657 jQuery.event.special[ fix ] = {
3659 if ( attaches++ === 0 ) {
3660 document.addEventListener( orig, handler, true );
3663 teardown: function() {
3664 if ( --attaches === 0 ) {
3665 document.removeEventListener( orig, handler, true );
3674 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3677 // Types can be a map of types/handlers
3678 if ( typeof types === "object" ) {
3679 // ( types-Object, selector, data )
3680 if ( typeof selector !== "string" ) {
3681 // ( types-Object, data )
3683 selector = undefined;
3685 for ( type in types ) {
3686 this.on( type, selector, data, types[ type ], one );
3691 if ( data == null && fn == null ) {
3694 data = selector = undefined;
3695 } else if ( fn == null ) {
3696 if ( typeof selector === "string" ) {
3697 // ( types, selector, fn )
3701 // ( types, data, fn )
3704 selector = undefined;
3707 if ( fn === false ) {
3715 fn = function( event ) {
3716 // Can use an empty set, since event contains the info
3717 jQuery().off( event );
3718 return origFn.apply( this, arguments );
3720 // Use same guid so caller can remove using origFn
3721 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3723 return this.each( function() {
3724 jQuery.event.add( this, types, fn, data, selector );
3727 one: function( types, selector, data, fn ) {
3728 return this.on.call( this, types, selector, data, fn, 1 );
3730 off: function( types, selector, fn ) {
3731 if ( types && types.preventDefault && types.handleObj ) {
3732 // ( event ) dispatched jQuery.Event
3733 var handleObj = types.handleObj;
3734 jQuery( types.delegateTarget ).off(
3735 handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
3741 if ( typeof types === "object" ) {
3742 // ( types-object [, selector] )
3743 for ( var type in types ) {
3744 this.off( type, selector, types[ type ] );
3748 if ( selector === false || typeof selector === "function" ) {
3751 selector = undefined;
3753 if ( fn === false ) {
3756 return this.each(function() {
3757 jQuery.event.remove( this, types, fn, selector );
3761 bind: function( types, data, fn ) {
3762 return this.on( types, null, data, fn );
3764 unbind: function( types, fn ) {
3765 return this.off( types, null, fn );
3768 live: function( types, data, fn ) {
3769 jQuery( this.context ).on( types, this.selector, data, fn );
3772 die: function( types, fn ) {
3773 jQuery( this.context ).off( types, this.selector || "**", fn );
3777 delegate: function( selector, types, data, fn ) {
3778 return this.on( types, selector, data, fn );
3780 undelegate: function( selector, types, fn ) {
3781 // ( namespace ) or ( selector, types [, fn] )
3782 return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn );
3785 trigger: function( type, data ) {
3786 return this.each(function() {
3787 jQuery.event.trigger( type, data, this );
3790 triggerHandler: function( type, data ) {
3792 return jQuery.event.trigger( type, data, this[0], true );
3796 toggle: function( fn ) {
3797 // Save reference to arguments for access in closure
3798 var args = arguments,
3799 guid = fn.guid || jQuery.guid++,
3801 toggler = function( event ) {
3802 // Figure out which function to execute
3803 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3804 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3806 // Make sure that clicks stop
3807 event.preventDefault();
3809 // and execute the function
3810 return args[ lastToggle ].apply( this, arguments ) || false;
3813 // link all the functions, so any of them can unbind this click handler
3814 toggler.guid = guid;
3815 while ( i < args.length ) {
3816 args[ i++ ].guid = guid;
3819 return this.click( toggler );
3822 hover: function( fnOver, fnOut ) {
3823 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3827 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3828 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3829 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3831 // Handle event binding
3832 jQuery.fn[ name ] = function( data, fn ) {
3838 return arguments.length > 0 ?
3839 this.on( name, null, data, fn ) :
3840 this.trigger( name );
3843 if ( jQuery.attrFn ) {
3844 jQuery.attrFn[ name ] = true;
3847 if ( rkeyEvent.test( name ) ) {
3848 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3851 if ( rmouseEvent.test( name ) ) {
3852 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3859 * Sizzle CSS Selector Engine
3860 * Copyright 2011, The Dojo Foundation
3861 * Released under the MIT, BSD, and GPL Licenses.
3862 * More information: http://sizzlejs.com/
3866 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3867 expando = "sizcache" + (Math.random() + '').replace('.', ''),
3869 toString = Object.prototype.toString,
3870 hasDuplicate = false,
3871 baseHasDuplicate = true,
3876 // Here we check if the JavaScript engine is using some sort of
3877 // optimization where it does not always call our comparision
3878 // function. If that is the case, discard the hasDuplicate value.
3879 // Thus far that includes Google Chrome.
3880 [0, 0].sort(function() {
3881 baseHasDuplicate = false;
3885 var Sizzle = function( selector, context, results, seed ) {
3886 results = results || [];
3887 context = context || document;
3889 var origContext = context;
3891 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3895 if ( !selector || typeof selector !== "string" ) {
3899 var m, set, checkSet, extra, ret, cur, pop, i,
3901 contextXML = Sizzle.isXML( context ),
3905 // Reset the position of the chunker regexp (start from head)
3908 m = chunker.exec( soFar );
3922 if ( parts.length > 1 && origPOS.exec( selector ) ) {
3924 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3925 set = posProcess( parts[0] + parts[1], context, seed );
3928 set = Expr.relative[ parts[0] ] ?
3930 Sizzle( parts.shift(), context );
3932 while ( parts.length ) {
3933 selector = parts.shift();
3935 if ( Expr.relative[ selector ] ) {
3936 selector += parts.shift();
3939 set = posProcess( selector, set, seed );
3944 // Take a shortcut and set the context if the root selector is an ID
3945 // (but not if it'll be faster if the inner selector is an ID)
3946 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
3947 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
3949 ret = Sizzle.find( parts.shift(), context, contextXML );
3950 context = ret.expr ?
3951 Sizzle.filter( ret.expr, ret.set )[0] :
3957 { expr: parts.pop(), set: makeArray(seed) } :
3958 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
3961 Sizzle.filter( ret.expr, ret.set ) :
3964 if ( parts.length > 0 ) {
3965 checkSet = makeArray( set );
3971 while ( parts.length ) {
3975 if ( !Expr.relative[ cur ] ) {
3981 if ( pop == null ) {
3985 Expr.relative[ cur ]( checkSet, pop, contextXML );
3989 checkSet = parts = [];
3998 Sizzle.error( cur || selector );
4001 if ( toString.call(checkSet) === "[object Array]" ) {
4003 results.push.apply( results, checkSet );
4005 } else if ( context && context.nodeType === 1 ) {
4006 for ( i = 0; checkSet[i] != null; i++ ) {
4007 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
4008 results.push( set[i] );
4013 for ( i = 0; checkSet[i] != null; i++ ) {
4014 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
4015 results.push( set[i] );
4021 makeArray( checkSet, results );
4025 Sizzle( extra, origContext, results, seed );
4026 Sizzle.uniqueSort( results );
4032 Sizzle.uniqueSort = function( results ) {
4034 hasDuplicate = baseHasDuplicate;
4035 results.sort( sortOrder );
4037 if ( hasDuplicate ) {
4038 for ( var i = 1; i < results.length; i++ ) {
4039 if ( results[i] === results[ i - 1 ] ) {
4040 results.splice( i--, 1 );
4049 Sizzle.matches = function( expr, set ) {
4050 return Sizzle( expr, null, null, set );
4053 Sizzle.matchesSelector = function( node, expr ) {
4054 return Sizzle( expr, null, null, [node] ).length > 0;
4057 Sizzle.find = function( expr, context, isXML ) {
4058 var set, i, len, match, type, left;
4064 for ( i = 0, len = Expr.order.length; i < len; i++ ) {
4065 type = Expr.order[i];
4067 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
4069 match.splice( 1, 1 );
4071 if ( left.substr( left.length - 1 ) !== "\\" ) {
4072 match[1] = (match[1] || "").replace( rBackslash, "" );
4073 set = Expr.find[ type ]( match, context, isXML );
4075 if ( set != null ) {
4076 expr = expr.replace( Expr.match[ type ], "" );
4084 set = typeof context.getElementsByTagName !== "undefined" ?
4085 context.getElementsByTagName( "*" ) :
4089 return { set: set, expr: expr };
4092 Sizzle.filter = function( expr, set, inplace, not ) {
4093 var match, anyFound,
4094 type, found, item, filter, left,
4099 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
4101 while ( expr && set.length ) {
4102 for ( type in Expr.filter ) {
4103 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
4104 filter = Expr.filter[ type ];
4111 if ( left.substr( left.length - 1 ) === "\\" ) {
4115 if ( curLoop === result ) {
4119 if ( Expr.preFilter[ type ] ) {
4120 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
4123 anyFound = found = true;
4125 } else if ( match === true ) {
4131 for ( i = 0; (item = curLoop[i]) != null; i++ ) {
4133 found = filter( item, match, i, curLoop );
4136 if ( inplace && found != null ) {
4144 } else if ( pass ) {
4145 result.push( item );
4152 if ( found !== undefined ) {
4157 expr = expr.replace( Expr.match[ type ], "" );
4168 // Improper expression
4169 if ( expr === old ) {
4170 if ( anyFound == null ) {
4171 Sizzle.error( expr );
4184 Sizzle.error = function( msg ) {
4185 throw new Error( "Syntax error, unrecognized expression: " + msg );
4189 * Utility function for retreiving the text value of an array of DOM nodes
4190 * @param {Array|Element} elem
4192 var getText = Sizzle.getText = function( elem ) {
4194 nodeType = elem.nodeType,
4198 if ( nodeType === 1 || nodeType === 9 ) {
4199 // Use textContent || innerText for elements
4200 if ( typeof elem.textContent === 'string' ) {
4201 return elem.textContent;
4202 } else if ( typeof elem.innerText === 'string' ) {
4203 // Replace IE's carriage returns
4204 return elem.innerText.replace( rReturn, '' );
4206 // Traverse it's children
4207 for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
4208 ret += getText( elem );
4211 } else if ( nodeType === 3 || nodeType === 4 ) {
4212 return elem.nodeValue;
4216 // If no nodeType, this is expected to be an array
4217 for ( i = 0; (node = elem[i]); i++ ) {
4218 // Do not traverse comment nodes
4219 if ( node.nodeType !== 8 ) {
4220 ret += getText( node );
4227 var Expr = Sizzle.selectors = {
4228 order: [ "ID", "NAME", "TAG" ],
4231 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4232 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4233 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4234 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4235 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4236 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4237 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4238 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4244 "class": "className",
4249 href: function( elem ) {
4250 return elem.getAttribute( "href" );
4252 type: function( elem ) {
4253 return elem.getAttribute( "type" );
4258 "+": function(checkSet, part){
4259 var isPartStr = typeof part === "string",
4260 isTag = isPartStr && !rNonWord.test( part ),
4261 isPartStrNotTag = isPartStr && !isTag;
4264 part = part.toLowerCase();
4267 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
4268 if ( (elem = checkSet[i]) ) {
4269 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
4271 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
4277 if ( isPartStrNotTag ) {
4278 Sizzle.filter( part, checkSet, true );
4282 ">": function( checkSet, part ) {
4284 isPartStr = typeof part === "string",
4286 l = checkSet.length;
4288 if ( isPartStr && !rNonWord.test( part ) ) {
4289 part = part.toLowerCase();
4291 for ( ; i < l; i++ ) {
4295 var parent = elem.parentNode;
4296 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
4301 for ( ; i < l; i++ ) {
4305 checkSet[i] = isPartStr ?
4307 elem.parentNode === part;
4312 Sizzle.filter( part, checkSet, true );
4317 "": function(checkSet, part, isXML){
4322 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4323 part = part.toLowerCase();
4325 checkFn = dirNodeCheck;
4328 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
4331 "~": function( checkSet, part, isXML ) {
4336 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4337 part = part.toLowerCase();
4339 checkFn = dirNodeCheck;
4342 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
4347 ID: function( match, context, isXML ) {
4348 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4349 var m = context.getElementById(match[1]);
4350 // Check parentNode to catch when Blackberry 4.6 returns
4351 // nodes that are no longer in the document #6963
4352 return m && m.parentNode ? [m] : [];
4356 NAME: function( match, context ) {
4357 if ( typeof context.getElementsByName !== "undefined" ) {
4359 results = context.getElementsByName( match[1] );
4361 for ( var i = 0, l = results.length; i < l; i++ ) {
4362 if ( results[i].getAttribute("name") === match[1] ) {
4363 ret.push( results[i] );
4367 return ret.length === 0 ? null : ret;
4371 TAG: function( match, context ) {
4372 if ( typeof context.getElementsByTagName !== "undefined" ) {
4373 return context.getElementsByTagName( match[1] );
4378 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
4379 match = " " + match[1].replace( rBackslash, "" ) + " ";
4385 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
4387 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
4389 result.push( elem );
4392 } else if ( inplace ) {
4401 ID: function( match ) {
4402 return match[1].replace( rBackslash, "" );
4405 TAG: function( match, curLoop ) {
4406 return match[1].replace( rBackslash, "" ).toLowerCase();
4409 CHILD: function( match ) {
4410 if ( match[1] === "nth" ) {
4412 Sizzle.error( match[0] );
4415 match[2] = match[2].replace(/^\+|\s*/g, '');
4417 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4418 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4419 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
4420 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
4422 // calculate the numbers (first)n+(last) including if they are negative
4423 match[2] = (test[1] + (test[2] || 1)) - 0;
4424 match[3] = test[3] - 0;
4426 else if ( match[2] ) {
4427 Sizzle.error( match[0] );
4430 // TODO: Move to normal caching system
4436 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
4437 var name = match[1] = match[1].replace( rBackslash, "" );
4439 if ( !isXML && Expr.attrMap[name] ) {
4440 match[1] = Expr.attrMap[name];
4443 // Handle if an un-quoted value was used
4444 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
4446 if ( match[2] === "~=" ) {
4447 match[4] = " " + match[4] + " ";
4453 PSEUDO: function( match, curLoop, inplace, result, not ) {
4454 if ( match[1] === "not" ) {
4455 // If we're dealing with a complex expression, or a simple one
4456 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
4457 match[3] = Sizzle(match[3], null, null, curLoop);
4460 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
4463 result.push.apply( result, ret );
4469 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
4476 POS: function( match ) {
4477 match.unshift( true );
4484 enabled: function( elem ) {
4485 return elem.disabled === false && elem.type !== "hidden";
4488 disabled: function( elem ) {
4489 return elem.disabled === true;
4492 checked: function( elem ) {
4493 return elem.checked === true;
4496 selected: function( elem ) {
4497 // Accessing this property makes selected-by-default
4498 // options in Safari work properly
4499 if ( elem.parentNode ) {
4500 elem.parentNode.selectedIndex;
4503 return elem.selected === true;
4506 parent: function( elem ) {
4507 return !!elem.firstChild;
4510 empty: function( elem ) {
4511 return !elem.firstChild;
4514 has: function( elem, i, match ) {
4515 return !!Sizzle( match[3], elem ).length;
4518 header: function( elem ) {
4519 return (/h\d/i).test( elem.nodeName );
4522 text: function( elem ) {
4523 var attr = elem.getAttribute( "type" ), type = elem.type;
4524 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4525 // use getAttribute instead to test this case
4526 return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
4529 radio: function( elem ) {
4530 return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
4533 checkbox: function( elem ) {
4534 return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
4537 file: function( elem ) {
4538 return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
4541 password: function( elem ) {
4542 return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
4545 submit: function( elem ) {
4546 var name = elem.nodeName.toLowerCase();
4547 return (name === "input" || name === "button") && "submit" === elem.type;
4550 image: function( elem ) {
4551 return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
4554 reset: function( elem ) {
4555 var name = elem.nodeName.toLowerCase();
4556 return (name === "input" || name === "button") && "reset" === elem.type;
4559 button: function( elem ) {
4560 var name = elem.nodeName.toLowerCase();
4561 return name === "input" && "button" === elem.type || name === "button";
4564 input: function( elem ) {
4565 return (/input|select|textarea|button/i).test( elem.nodeName );
4568 focus: function( elem ) {
4569 return elem === elem.ownerDocument.activeElement;
4573 first: function( elem, i ) {
4577 last: function( elem, i, match, array ) {
4578 return i === array.length - 1;
4581 even: function( elem, i ) {
4585 odd: function( elem, i ) {
4589 lt: function( elem, i, match ) {
4590 return i < match[3] - 0;
4593 gt: function( elem, i, match ) {
4594 return i > match[3] - 0;
4597 nth: function( elem, i, match ) {
4598 return match[3] - 0 === i;
4601 eq: function( elem, i, match ) {
4602 return match[3] - 0 === i;
4606 PSEUDO: function( elem, match, i, array ) {
4607 var name = match[1],
4608 filter = Expr.filters[ name ];
4611 return filter( elem, i, match, array );
4613 } else if ( name === "contains" ) {
4614 return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
4616 } else if ( name === "not" ) {
4619 for ( var j = 0, l = not.length; j < l; j++ ) {
4620 if ( not[j] === elem ) {
4628 Sizzle.error( name );
4632 CHILD: function( elem, match ) {
4634 doneName, parent, cache,
4642 while ( (node = node.previousSibling) ) {
4643 if ( node.nodeType === 1 ) {
4648 if ( type === "first" ) {
4655 while ( (node = node.nextSibling) ) {
4656 if ( node.nodeType === 1 ) {
4667 if ( first === 1 && last === 0 ) {
4671 doneName = match[0];
4672 parent = elem.parentNode;
4674 if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
4677 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4678 if ( node.nodeType === 1 ) {
4679 node.nodeIndex = ++count;
4683 parent[ expando ] = doneName;
4686 diff = elem.nodeIndex - last;
4688 if ( first === 0 ) {
4692 return ( diff % first === 0 && diff / first >= 0 );
4697 ID: function( elem, match ) {
4698 return elem.nodeType === 1 && elem.getAttribute("id") === match;
4701 TAG: function( elem, match ) {
4702 return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
4705 CLASS: function( elem, match ) {
4706 return (" " + (elem.className || elem.getAttribute("class")) + " ")
4707 .indexOf( match ) > -1;
4710 ATTR: function( elem, match ) {
4711 var name = match[1],
4712 result = Sizzle.attr ?
4713 Sizzle.attr( elem, name ) :
4714 Expr.attrHandle[ name ] ?
4715 Expr.attrHandle[ name ]( elem ) :
4716 elem[ name ] != null ?
4718 elem.getAttribute( name ),
4719 value = result + "",
4723 return result == null ?
4725 !type && Sizzle.attr ?
4730 value.indexOf(check) >= 0 :
4732 (" " + value + " ").indexOf(check) >= 0 :
4734 value && result !== false :
4738 value.indexOf(check) === 0 :
4740 value.substr(value.length - check.length) === check :
4742 value === check || value.substr(0, check.length + 1) === check + "-" :
4746 POS: function( elem, match, i, array ) {
4747 var name = match[2],
4748 filter = Expr.setFilters[ name ];
4751 return filter( elem, i, match, array );
4757 var origPOS = Expr.match.POS,
4758 fescape = function(all, num){
4759 return "\\" + (num - 0 + 1);
4762 for ( var type in Expr.match ) {
4763 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
4764 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
4767 var makeArray = function( array, results ) {
4768 array = Array.prototype.slice.call( array, 0 );
4771 results.push.apply( results, array );
4778 // Perform a simple check to determine if the browser is capable of
4779 // converting a NodeList to an array using builtin methods.
4780 // Also verifies that the returned array holds DOM nodes
4781 // (which is not the case in the Blackberry browser)
4783 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
4785 // Provide a fallback method if it does not work
4787 makeArray = function( array, results ) {
4789 ret = results || [];
4791 if ( toString.call(array) === "[object Array]" ) {
4792 Array.prototype.push.apply( ret, array );
4795 if ( typeof array.length === "number" ) {
4796 for ( var l = array.length; i < l; i++ ) {
4797 ret.push( array[i] );
4801 for ( ; array[i]; i++ ) {
4802 ret.push( array[i] );
4811 var sortOrder, siblingCheck;
4813 if ( document.documentElement.compareDocumentPosition ) {
4814 sortOrder = function( a, b ) {
4816 hasDuplicate = true;
4820 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4821 return a.compareDocumentPosition ? -1 : 1;
4824 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4828 sortOrder = function( a, b ) {
4829 // The nodes are identical, we can exit early
4831 hasDuplicate = true;
4834 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4835 } else if ( a.sourceIndex && b.sourceIndex ) {
4836 return a.sourceIndex - b.sourceIndex;
4846 // If the nodes are siblings (or identical) we can do a quick check
4847 if ( aup === bup ) {
4848 return siblingCheck( a, b );
4850 // If no parents were found then the nodes are disconnected
4851 } else if ( !aup ) {
4854 } else if ( !bup ) {
4858 // Otherwise they're somewhere else in the tree so we need
4859 // to build up a full list of the parentNodes for comparison
4862 cur = cur.parentNode;
4869 cur = cur.parentNode;
4875 // Start walking down the tree looking for a discrepancy
4876 for ( var i = 0; i < al && i < bl; i++ ) {
4877 if ( ap[i] !== bp[i] ) {
4878 return siblingCheck( ap[i], bp[i] );
4882 // We ended someplace up the tree so do a sibling check
4884 siblingCheck( a, bp[i], -1 ) :
4885 siblingCheck( ap[i], b, 1 );
4888 siblingCheck = function( a, b, ret ) {
4893 var cur = a.nextSibling;
4900 cur = cur.nextSibling;
4907 // Check to see if the browser returns elements by name when
4908 // querying by getElementById (and provide a workaround)
4910 // We're going to inject a fake input element with a specified name
4911 var form = document.createElement("div"),
4912 id = "script" + (new Date()).getTime(),
4913 root = document.documentElement;
4915 form.innerHTML = "<a name='" + id + "'/>";
4917 // Inject it into the root element, check its status, and remove it quickly
4918 root.insertBefore( form, root.firstChild );
4920 // The workaround has to do additional checks after a getElementById
4921 // Which slows things down for other browsers (hence the branching)
4922 if ( document.getElementById( id ) ) {
4923 Expr.find.ID = function( match, context, isXML ) {
4924 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4925 var m = context.getElementById(match[1]);
4928 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
4935 Expr.filter.ID = function( elem, match ) {
4936 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4938 return elem.nodeType === 1 && node && node.nodeValue === match;
4942 root.removeChild( form );
4944 // release memory in IE
4949 // Check to see if the browser returns only elements
4950 // when doing getElementsByTagName("*")
4952 // Create a fake element
4953 var div = document.createElement("div");
4954 div.appendChild( document.createComment("") );
4956 // Make sure no comments are found
4957 if ( div.getElementsByTagName("*").length > 0 ) {
4958 Expr.find.TAG = function( match, context ) {
4959 var results = context.getElementsByTagName( match[1] );
4961 // Filter out possible comments
4962 if ( match[1] === "*" ) {
4965 for ( var i = 0; results[i]; i++ ) {
4966 if ( results[i].nodeType === 1 ) {
4967 tmp.push( results[i] );
4978 // Check to see if an attribute returns normalized href attributes
4979 div.innerHTML = "<a href='#'></a>";
4981 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4982 div.firstChild.getAttribute("href") !== "#" ) {
4984 Expr.attrHandle.href = function( elem ) {
4985 return elem.getAttribute( "href", 2 );
4989 // release memory in IE
4993 if ( document.querySelectorAll ) {
4995 var oldSizzle = Sizzle,
4996 div = document.createElement("div"),
4999 div.innerHTML = "<p class='TEST'></p>";
5001 // Safari can't handle uppercase or unicode characters when
5003 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
5007 Sizzle = function( query, context, extra, seed ) {
5008 context = context || document;
5010 // Only use querySelectorAll on non-XML documents
5011 // (ID selectors don't work in non-HTML documents)
5012 if ( !seed && !Sizzle.isXML(context) ) {
5013 // See if we find a selector to speed up
5014 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
5016 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
5017 // Speed-up: Sizzle("TAG")
5019 return makeArray( context.getElementsByTagName( query ), extra );
5021 // Speed-up: Sizzle(".CLASS")
5022 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
5023 return makeArray( context.getElementsByClassName( match[2] ), extra );
5027 if ( context.nodeType === 9 ) {
5028 // Speed-up: Sizzle("body")
5029 // The body element only exists once, optimize finding it
5030 if ( query === "body" && context.body ) {
5031 return makeArray( [ context.body ], extra );
5033 // Speed-up: Sizzle("#ID")
5034 } else if ( match && match[3] ) {
5035 var elem = context.getElementById( match[3] );
5037 // Check parentNode to catch when Blackberry 4.6 returns
5038 // nodes that are no longer in the document #6963
5039 if ( elem && elem.parentNode ) {
5040 // Handle the case where IE and Opera return items
5041 // by name instead of ID
5042 if ( elem.id === match[3] ) {
5043 return makeArray( [ elem ], extra );
5047 return makeArray( [], extra );
5052 return makeArray( context.querySelectorAll(query), extra );
5053 } catch(qsaError) {}
5055 // qSA works strangely on Element-rooted queries
5056 // We can work around this by specifying an extra ID on the root
5057 // and working up from there (Thanks to Andrew Dupont for the technique)
5058 // IE 8 doesn't work on object elements
5059 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5060 var oldContext = context,
5061 old = context.getAttribute( "id" ),
5063 hasParent = context.parentNode,
5064 relativeHierarchySelector = /^\s*[+~]/.test( query );
5067 context.setAttribute( "id", nid );
5069 nid = nid.replace( /'/g, "\\$&" );
5071 if ( relativeHierarchySelector && hasParent ) {
5072 context = context.parentNode;
5076 if ( !relativeHierarchySelector || hasParent ) {
5077 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
5080 } catch(pseudoError) {
5083 oldContext.removeAttribute( "id" );
5089 return oldSizzle(query, context, extra, seed);
5092 for ( var prop in oldSizzle ) {
5093 Sizzle[ prop ] = oldSizzle[ prop ];
5096 // release memory in IE
5102 var html = document.documentElement,
5103 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
5106 // Check to see if it's possible to do matchesSelector
5107 // on a disconnected node (IE 9 fails this)
5108 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
5109 pseudoWorks = false;
5112 // This should fail with an exception
5113 // Gecko does not error, returns false instead
5114 matches.call( document.documentElement, "[test!='']:sizzle" );
5116 } catch( pseudoError ) {
5120 Sizzle.matchesSelector = function( node, expr ) {
5121 // Make sure that attribute selectors are quoted
5122 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5124 if ( !Sizzle.isXML( node ) ) {
5126 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
5127 var ret = matches.call( node, expr );
5129 // IE 9's matchesSelector returns false on disconnected nodes
5130 if ( ret || !disconnectedMatch ||
5131 // As well, disconnected nodes are said to be in a document
5132 // fragment in IE 9, so check for that
5133 node.document && node.document.nodeType !== 11 ) {
5140 return Sizzle(expr, null, null, [node]).length > 0;
5146 var div = document.createElement("div");
5148 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
5150 // Opera can't find a second classname (in 9.6)
5151 // Also, make sure that getElementsByClassName actually exists
5152 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
5156 // Safari caches class attributes, doesn't catch changes (in 3.2)
5157 div.lastChild.className = "e";
5159 if ( div.getElementsByClassName("e").length === 1 ) {
5163 Expr.order.splice(1, 0, "CLASS");
5164 Expr.find.CLASS = function( match, context, isXML ) {
5165 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
5166 return context.getElementsByClassName(match[1]);
5170 // release memory in IE
5174 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5175 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5176 var elem = checkSet[i];
5184 if ( elem[ expando ] === doneName ) {
5185 match = checkSet[elem.sizset];
5189 if ( elem.nodeType === 1 && !isXML ){
5190 elem[ expando ] = doneName;
5194 if ( elem.nodeName.toLowerCase() === cur ) {
5202 checkSet[i] = match;
5207 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5208 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5209 var elem = checkSet[i];
5217 if ( elem[ expando ] === doneName ) {
5218 match = checkSet[elem.sizset];
5222 if ( elem.nodeType === 1 ) {
5224 elem[ expando ] = doneName;
5228 if ( typeof cur !== "string" ) {
5229 if ( elem === cur ) {
5234 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
5243 checkSet[i] = match;
5248 if ( document.documentElement.contains ) {
5249 Sizzle.contains = function( a, b ) {
5250 return a !== b && (a.contains ? a.contains(b) : true);
5253 } else if ( document.documentElement.compareDocumentPosition ) {
5254 Sizzle.contains = function( a, b ) {
5255 return !!(a.compareDocumentPosition(b) & 16);
5259 Sizzle.contains = function() {
5264 Sizzle.isXML = function( elem ) {
5265 // documentElement is verified for cases where it doesn't yet exist
5266 // (such as loading iframes in IE - #4833)
5267 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
5269 return documentElement ? documentElement.nodeName !== "HTML" : false;
5272 var posProcess = function( selector, context, seed ) {
5276 root = context.nodeType ? [context] : context;
5278 // Position selectors must be done after the filter
5279 // And so must :not(positional) so we move all PSEUDOs to the end
5280 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
5282 selector = selector.replace( Expr.match.PSEUDO, "" );
5285 selector = Expr.relative[selector] ? selector + "*" : selector;
5287 for ( var i = 0, l = root.length; i < l; i++ ) {
5288 Sizzle( selector, root[i], tmpSet, seed );
5291 return Sizzle.filter( later, tmpSet );
5295 // Override sizzle attribute retrieval
5296 Sizzle.attr = jQuery.attr;
5297 Sizzle.selectors.attrMap = {};
5298 jQuery.find = Sizzle;
5299 jQuery.expr = Sizzle.selectors;
5300 jQuery.expr[":"] = jQuery.expr.filters;
5301 jQuery.unique = Sizzle.uniqueSort;
5302 jQuery.text = Sizzle.getText;
5303 jQuery.isXMLDoc = Sizzle.isXML;
5304 jQuery.contains = Sizzle.contains;
5310 var runtil = /Until$/,
5311 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
5312 // Note: This RegExp should be improved, or likely pulled from Sizzle
5313 rmultiselector = /,/,
5314 isSimple = /^.[^:#\[\.,]*$/,
5315 slice = Array.prototype.slice,
5316 POS = jQuery.expr.match.POS,
5317 // methods guaranteed to produce a unique set when starting from a unique set
5318 guaranteedUnique = {
5326 find: function( selector ) {
5330 if ( typeof selector !== "string" ) {
5331 return jQuery( selector ).filter(function() {
5332 for ( i = 0, l = self.length; i < l; i++ ) {
5333 if ( jQuery.contains( self[ i ], this ) ) {
5340 var ret = this.pushStack( "", "find", selector ),
5343 for ( i = 0, l = this.length; i < l; i++ ) {
5344 length = ret.length;
5345 jQuery.find( selector, this[i], ret );
5348 // Make sure that the results are unique
5349 for ( n = length; n < ret.length; n++ ) {
5350 for ( r = 0; r < length; r++ ) {
5351 if ( ret[r] === ret[n] ) {
5363 has: function( target ) {
5364 var targets = jQuery( target );
5365 return this.filter(function() {
5366 for ( var i = 0, l = targets.length; i < l; i++ ) {
5367 if ( jQuery.contains( this, targets[i] ) ) {
5374 not: function( selector ) {
5375 return this.pushStack( winnow(this, selector, false), "not", selector);
5378 filter: function( selector ) {
5379 return this.pushStack( winnow(this, selector, true), "filter", selector );
5382 is: function( selector ) {
5383 return !!selector && (
5384 typeof selector === "string" ?
5385 // If this is a positional selector, check membership in the returned set
5386 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5387 POS.test( selector ) ?
5388 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5389 jQuery.filter( selector, this ).length > 0 :
5390 this.filter( selector ).length > 0 );
5393 closest: function( selectors, context ) {
5394 var ret = [], i, l, cur = this[0];
5396 // Array (deprecated as of jQuery 1.7)
5397 if ( jQuery.isArray( selectors ) ) {
5400 while ( cur && cur.ownerDocument && cur !== context ) {
5401 for ( i = 0; i < selectors.length; i++ ) {
5403 if ( jQuery( cur ).is( selectors[ i ] ) ) {
5404 ret.push({ selector: selectors[ i ], elem: cur, level: level });
5408 cur = cur.parentNode;
5416 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
5417 jQuery( selectors, context || this.context ) :
5420 for ( i = 0, l = this.length; i < l; i++ ) {
5424 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5429 cur = cur.parentNode;
5430 if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
5437 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5439 return this.pushStack( ret, "closest", selectors );
5442 // Determine the position of an element within
5443 // the matched set of elements
5444 index: function( elem ) {
5446 // No argument, return index in parent
5448 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5451 // index in selector
5452 if ( typeof elem === "string" ) {
5453 return jQuery.inArray( this[0], jQuery( elem ) );
5456 // Locate the position of the desired element
5457 return jQuery.inArray(
5458 // If it receives a jQuery object, the first element is used
5459 elem.jquery ? elem[0] : elem, this );
5462 add: function( selector, context ) {
5463 var set = typeof selector === "string" ?
5464 jQuery( selector, context ) :
5465 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5466 all = jQuery.merge( this.get(), set );
5468 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5470 jQuery.unique( all ) );
5473 andSelf: function() {
5474 return this.add( this.prevObject );
5478 // A painfully simple check to see if an element is disconnected
5479 // from a document (should be improved, where feasible).
5480 function isDisconnected( node ) {
5481 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5485 parent: function( elem ) {
5486 var parent = elem.parentNode;
5487 return parent && parent.nodeType !== 11 ? parent : null;
5489 parents: function( elem ) {
5490 return jQuery.dir( elem, "parentNode" );
5492 parentsUntil: function( elem, i, until ) {
5493 return jQuery.dir( elem, "parentNode", until );
5495 next: function( elem ) {
5496 return jQuery.nth( elem, 2, "nextSibling" );
5498 prev: function( elem ) {
5499 return jQuery.nth( elem, 2, "previousSibling" );
5501 nextAll: function( elem ) {
5502 return jQuery.dir( elem, "nextSibling" );
5504 prevAll: function( elem ) {
5505 return jQuery.dir( elem, "previousSibling" );
5507 nextUntil: function( elem, i, until ) {
5508 return jQuery.dir( elem, "nextSibling", until );
5510 prevUntil: function( elem, i, until ) {
5511 return jQuery.dir( elem, "previousSibling", until );
5513 siblings: function( elem ) {
5514 return jQuery.sibling( elem.parentNode.firstChild, elem );
5516 children: function( elem ) {
5517 return jQuery.sibling( elem.firstChild );
5519 contents: function( elem ) {
5520 return jQuery.nodeName( elem, "iframe" ) ?
5521 elem.contentDocument || elem.contentWindow.document :
5522 jQuery.makeArray( elem.childNodes );
5524 }, function( name, fn ) {
5525 jQuery.fn[ name ] = function( until, selector ) {
5526 var ret = jQuery.map( this, fn, until );
5528 if ( !runtil.test( name ) ) {
5532 if ( selector && typeof selector === "string" ) {
5533 ret = jQuery.filter( selector, ret );
5536 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5538 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
5539 ret = ret.reverse();
5542 return this.pushStack( ret, name, slice.call( arguments ).join(",") );
5547 filter: function( expr, elems, not ) {
5549 expr = ":not(" + expr + ")";
5552 return elems.length === 1 ?
5553 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5554 jQuery.find.matches(expr, elems);
5557 dir: function( elem, dir, until ) {
5561 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5562 if ( cur.nodeType === 1 ) {
5563 matched.push( cur );
5570 nth: function( cur, result, dir, elem ) {
5571 result = result || 1;
5574 for ( ; cur; cur = cur[dir] ) {
5575 if ( cur.nodeType === 1 && ++num === result ) {
5583 sibling: function( n, elem ) {
5586 for ( ; n; n = n.nextSibling ) {
5587 if ( n.nodeType === 1 && n !== elem ) {
5596 // Implement the identical functionality for filter and not
5597 function winnow( elements, qualifier, keep ) {
5599 // Can't pass null or undefined to indexOf in Firefox 4
5600 // Set to 0 to skip string check
5601 qualifier = qualifier || 0;
5603 if ( jQuery.isFunction( qualifier ) ) {
5604 return jQuery.grep(elements, function( elem, i ) {
5605 var retVal = !!qualifier.call( elem, i, elem );
5606 return retVal === keep;
5609 } else if ( qualifier.nodeType ) {
5610 return jQuery.grep(elements, function( elem, i ) {
5611 return ( elem === qualifier ) === keep;
5614 } else if ( typeof qualifier === "string" ) {
5615 var filtered = jQuery.grep(elements, function( elem ) {
5616 return elem.nodeType === 1;
5619 if ( isSimple.test( qualifier ) ) {
5620 return jQuery.filter(qualifier, filtered, !keep);
5622 qualifier = jQuery.filter( qualifier, filtered );
5626 return jQuery.grep(elements, function( elem, i ) {
5627 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5634 function createSafeFragment( document ) {
5635 var list = nodeNames.split( "|" ),
5636 safeFrag = document.createDocumentFragment();
5638 if ( safeFrag.createElement ) {
5639 while ( list.length ) {
5640 safeFrag.createElement(
5648 var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" +
5649 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5650 rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5651 rleadingWhitespace = /^\s+/,
5652 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5653 rtagName = /<([\w:]+)/,
5655 rhtml = /<|&#?\w+;/,
5656 rnoInnerhtml = /<(?:script|style)/i,
5657 rnocache = /<(?:script|object|embed|option|style)/i,
5658 rnoshimcache = new RegExp("<(?:" + nodeNames + ")", "i"),
5659 // checked="checked" or checked
5660 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5661 rscriptType = /\/(java|ecma)script/i,
5662 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
5664 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5665 legend: [ 1, "<fieldset>", "</fieldset>" ],
5666 thead: [ 1, "<table>", "</table>" ],
5667 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5668 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5669 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5670 area: [ 1, "<map>", "</map>" ],
5671 _default: [ 0, "", "" ]
5673 safeFragment = createSafeFragment( document );
5675 wrapMap.optgroup = wrapMap.option;
5676 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5677 wrapMap.th = wrapMap.td;
5679 // IE can't serialize <link> and <script> tags normally
5680 if ( !jQuery.support.htmlSerialize ) {
5681 wrapMap._default = [ 1, "div<div>", "</div>" ];
5685 text: function( text ) {
5686 if ( jQuery.isFunction(text) ) {
5687 return this.each(function(i) {
5688 var self = jQuery( this );
5690 self.text( text.call(this, i, self.text()) );
5694 if ( typeof text !== "object" && text !== undefined ) {
5695 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
5698 return jQuery.text( this );
5701 wrapAll: function( html ) {
5702 if ( jQuery.isFunction( html ) ) {
5703 return this.each(function(i) {
5704 jQuery(this).wrapAll( html.call(this, i) );
5709 // The elements to wrap the target around
5710 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5712 if ( this[0].parentNode ) {
5713 wrap.insertBefore( this[0] );
5716 wrap.map(function() {
5719 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5720 elem = elem.firstChild;
5730 wrapInner: function( html ) {
5731 if ( jQuery.isFunction( html ) ) {
5732 return this.each(function(i) {
5733 jQuery(this).wrapInner( html.call(this, i) );
5737 return this.each(function() {
5738 var self = jQuery( this ),
5739 contents = self.contents();
5741 if ( contents.length ) {
5742 contents.wrapAll( html );
5745 self.append( html );
5750 wrap: function( html ) {
5751 var isFunction = jQuery.isFunction( html );
5753 return this.each(function(i) {
5754 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5758 unwrap: function() {
5759 return this.parent().each(function() {
5760 if ( !jQuery.nodeName( this, "body" ) ) {
5761 jQuery( this ).replaceWith( this.childNodes );
5766 append: function() {
5767 return this.domManip(arguments, true, function( elem ) {
5768 if ( this.nodeType === 1 ) {
5769 this.appendChild( elem );
5774 prepend: function() {
5775 return this.domManip(arguments, true, function( elem ) {
5776 if ( this.nodeType === 1 ) {
5777 this.insertBefore( elem, this.firstChild );
5782 before: function() {
5783 if ( this[0] && this[0].parentNode ) {
5784 return this.domManip(arguments, false, function( elem ) {
5785 this.parentNode.insertBefore( elem, this );
5787 } else if ( arguments.length ) {
5788 var set = jQuery.clean( arguments );
5789 set.push.apply( set, this.toArray() );
5790 return this.pushStack( set, "before", arguments );
5795 if ( this[0] && this[0].parentNode ) {
5796 return this.domManip(arguments, false, function( elem ) {
5797 this.parentNode.insertBefore( elem, this.nextSibling );
5799 } else if ( arguments.length ) {
5800 var set = this.pushStack( this, "after", arguments );
5801 set.push.apply( set, jQuery.clean(arguments) );
5806 // keepData is for internal use only--do not document
5807 remove: function( selector, keepData ) {
5808 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5809 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5810 if ( !keepData && elem.nodeType === 1 ) {
5811 jQuery.cleanData( elem.getElementsByTagName("*") );
5812 jQuery.cleanData( [ elem ] );
5815 if ( elem.parentNode ) {
5816 elem.parentNode.removeChild( elem );
5825 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5826 // Remove element nodes and prevent memory leaks
5827 if ( elem.nodeType === 1 ) {
5828 jQuery.cleanData( elem.getElementsByTagName("*") );
5831 // Remove any remaining nodes
5832 while ( elem.firstChild ) {
5833 elem.removeChild( elem.firstChild );
5840 clone: function( dataAndEvents, deepDataAndEvents ) {
5841 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5842 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5844 return this.map( function () {
5845 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5849 html: function( value ) {
5850 if ( value === undefined ) {
5851 return this[0] && this[0].nodeType === 1 ?
5852 this[0].innerHTML.replace(rinlinejQuery, "") :
5855 // See if we can take a shortcut and just use innerHTML
5856 } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5857 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5858 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5860 value = value.replace(rxhtmlTag, "<$1></$2>");
5863 for ( var i = 0, l = this.length; i < l; i++ ) {
5864 // Remove element nodes and prevent memory leaks
5865 if ( this[i].nodeType === 1 ) {
5866 jQuery.cleanData( this[i].getElementsByTagName("*") );
5867 this[i].innerHTML = value;
5871 // If using innerHTML throws an exception, use the fallback method
5873 this.empty().append( value );
5876 } else if ( jQuery.isFunction( value ) ) {
5877 this.each(function(i){
5878 var self = jQuery( this );
5880 self.html( value.call(this, i, self.html()) );
5884 this.empty().append( value );
5890 replaceWith: function( value ) {
5891 if ( this[0] && this[0].parentNode ) {
5892 // Make sure that the elements are removed from the DOM before they are inserted
5893 // this can help fix replacing a parent with child elements
5894 if ( jQuery.isFunction( value ) ) {
5895 return this.each(function(i) {
5896 var self = jQuery(this), old = self.html();
5897 self.replaceWith( value.call( this, i, old ) );
5901 if ( typeof value !== "string" ) {
5902 value = jQuery( value ).detach();
5905 return this.each(function() {
5906 var next = this.nextSibling,
5907 parent = this.parentNode;
5909 jQuery( this ).remove();
5912 jQuery(next).before( value );
5914 jQuery(parent).append( value );
5918 return this.length ?
5919 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5924 detach: function( selector ) {
5925 return this.remove( selector, true );
5928 domManip: function( args, table, callback ) {
5929 var results, first, fragment, parent,
5933 // We can't cloneNode fragments that contain checked, in WebKit
5934 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
5935 return this.each(function() {
5936 jQuery(this).domManip( args, table, callback, true );
5940 if ( jQuery.isFunction(value) ) {
5941 return this.each(function(i) {
5942 var self = jQuery(this);
5943 args[0] = value.call(this, i, table ? self.html() : undefined);
5944 self.domManip( args, table, callback );
5949 parent = value && value.parentNode;
5951 // If we're in a fragment, just use that instead of building a new one
5952 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
5953 results = { fragment: parent };
5956 results = jQuery.buildFragment( args, this, scripts );
5959 fragment = results.fragment;
5961 if ( fragment.childNodes.length === 1 ) {
5962 first = fragment = fragment.firstChild;
5964 first = fragment.firstChild;
5968 table = table && jQuery.nodeName( first, "tr" );
5970 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
5973 root(this[i], first) :
5975 // Make sure that we do not leak memory by inadvertently discarding
5976 // the original fragment (which might have attached data) instead of
5977 // using it; in addition, use the original fragment object for the last
5978 // item instead of first because it can end up being emptied incorrectly
5979 // in certain situations (Bug #8070).
5980 // Fragments from the fragment cache must always be cloned and never used
5982 results.cacheable || ( l > 1 && i < lastIndex ) ?
5983 jQuery.clone( fragment, true, true ) :
5989 if ( scripts.length ) {
5990 jQuery.each( scripts, evalScript );
5998 function root( elem, cur ) {
5999 return jQuery.nodeName(elem, "table") ?
6000 (elem.getElementsByTagName("tbody")[0] ||
6001 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
6005 function cloneCopyEvent( src, dest ) {
6007 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6012 oldData = jQuery._data( src ),
6013 curData = jQuery._data( dest, oldData ),
6014 events = oldData.events;
6017 delete curData.handle;
6018 curData.events = {};
6020 for ( type in events ) {
6021 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6022 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
6027 // make the cloned public data object a copy from the original
6028 if ( curData.data ) {
6029 curData.data = jQuery.extend( {}, curData.data );
6033 function cloneFixAttributes( src, dest ) {
6036 // We do not need to do anything for non-Elements
6037 if ( dest.nodeType !== 1 ) {
6041 // clearAttributes removes the attributes, which we don't want,
6042 // but also removes the attachEvent events, which we *do* want
6043 if ( dest.clearAttributes ) {
6044 dest.clearAttributes();
6047 // mergeAttributes, in contrast, only merges back on the
6048 // original attributes, not the events
6049 if ( dest.mergeAttributes ) {
6050 dest.mergeAttributes( src );
6053 nodeName = dest.nodeName.toLowerCase();
6055 // IE6-8 fail to clone children inside object elements that use
6056 // the proprietary classid attribute value (rather than the type
6057 // attribute) to identify the type of content to display
6058 if ( nodeName === "object" ) {
6059 dest.outerHTML = src.outerHTML;
6061 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
6062 // IE6-8 fails to persist the checked state of a cloned checkbox
6063 // or radio button. Worse, IE6-7 fail to give the cloned element
6064 // a checked appearance if the defaultChecked value isn't also set
6065 if ( src.checked ) {
6066 dest.defaultChecked = dest.checked = src.checked;
6069 // IE6-7 get confused and end up setting the value of a cloned
6070 // checkbox/radio button to an empty string instead of "on"
6071 if ( dest.value !== src.value ) {
6072 dest.value = src.value;
6075 // IE6-8 fails to return the selected option to the default selected
6076 // state when cloning options
6077 } else if ( nodeName === "option" ) {
6078 dest.selected = src.defaultSelected;
6080 // IE6-8 fails to set the defaultValue to the correct value when
6081 // cloning other types of input fields
6082 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6083 dest.defaultValue = src.defaultValue;
6086 // Event data gets referenced instead of copied if the expando
6088 dest.removeAttribute( jQuery.expando );
6091 jQuery.buildFragment = function( args, nodes, scripts ) {
6092 var fragment, cacheable, cacheresults, doc,
6095 // nodes may contain either an explicit document object,
6096 // a jQuery collection or context object.
6097 // If nodes[0] contains a valid object to assign to doc
6098 if ( nodes && nodes[0] ) {
6099 doc = nodes[0].ownerDocument || nodes[0];
6102 // Ensure that an attr object doesn't incorrectly stand in as a document object
6103 // Chrome and Firefox seem to allow this to occur and will throw exception
6105 if ( !doc.createDocumentFragment ) {
6109 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6110 // Cloning options loses the selected state, so don't cache them
6111 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6112 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6113 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6114 if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document &&
6115 first.charAt(0) === "<" && !rnocache.test( first ) &&
6116 (jQuery.support.checkClone || !rchecked.test( first )) &&
6117 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
6121 cacheresults = jQuery.fragments[ first ];
6122 if ( cacheresults && cacheresults !== 1 ) {
6123 fragment = cacheresults;
6128 fragment = doc.createDocumentFragment();
6129 jQuery.clean( args, doc, fragment, scripts );
6133 jQuery.fragments[ first ] = cacheresults ? fragment : 1;
6136 return { fragment: fragment, cacheable: cacheable };
6139 jQuery.fragments = {};
6143 prependTo: "prepend",
6144 insertBefore: "before",
6145 insertAfter: "after",
6146 replaceAll: "replaceWith"
6147 }, function( name, original ) {
6148 jQuery.fn[ name ] = function( selector ) {
6150 insert = jQuery( selector ),
6151 parent = this.length === 1 && this[0].parentNode;
6153 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
6154 insert[ original ]( this[0] );
6158 for ( var i = 0, l = insert.length; i < l; i++ ) {
6159 var elems = ( i > 0 ? this.clone(true) : this ).get();
6160 jQuery( insert[i] )[ original ]( elems );
6161 ret = ret.concat( elems );
6164 return this.pushStack( ret, name, insert.selector );
6169 function getAll( elem ) {
6170 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6171 return elem.getElementsByTagName( "*" );
6173 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6174 return elem.querySelectorAll( "*" );
6181 // Used in clean, fixes the defaultChecked property
6182 function fixDefaultChecked( elem ) {
6183 if ( elem.type === "checkbox" || elem.type === "radio" ) {
6184 elem.defaultChecked = elem.checked;
6187 // Finds all inputs and passes them to fixDefaultChecked
6188 function findInputs( elem ) {
6189 var nodeName = ( elem.nodeName || "" ).toLowerCase();
6190 if ( nodeName === "input" ) {
6191 fixDefaultChecked( elem );
6192 // Skip scripts, get other children
6193 } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) {
6194 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6198 // Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js
6199 function shimCloneNode( elem ) {
6200 var div = document.createElement( "div" );
6201 safeFragment.appendChild( div );
6203 div.innerHTML = elem.outerHTML;
6204 return div.firstChild;
6208 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6212 // IE<=8 does not properly clone detached, unknown element nodes
6213 clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ?
6214 elem.cloneNode( true ) :
6215 shimCloneNode( elem );
6217 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6218 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6219 // IE copies events bound via attachEvent when using cloneNode.
6220 // Calling detachEvent on the clone will also remove the events
6221 // from the original. In order to get around this, we use some
6222 // proprietary methods to clear the events. Thanks to MooTools
6223 // guys for this hotness.
6225 cloneFixAttributes( elem, clone );
6227 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6228 srcElements = getAll( elem );
6229 destElements = getAll( clone );
6231 // Weird iteration because IE will replace the length property
6232 // with an element if you are cloning the body and one of the
6233 // elements on the page has a name or id of "length"
6234 for ( i = 0; srcElements[i]; ++i ) {
6235 // Ensure that the destination node is not null; Fixes #9587
6236 if ( destElements[i] ) {
6237 cloneFixAttributes( srcElements[i], destElements[i] );
6242 // Copy the events from the original to the clone
6243 if ( dataAndEvents ) {
6244 cloneCopyEvent( elem, clone );
6246 if ( deepDataAndEvents ) {
6247 srcElements = getAll( elem );
6248 destElements = getAll( clone );
6250 for ( i = 0; srcElements[i]; ++i ) {
6251 cloneCopyEvent( srcElements[i], destElements[i] );
6256 srcElements = destElements = null;
6258 // Return the cloned set
6262 clean: function( elems, context, fragment, scripts ) {
6263 var checkScriptType;
6265 context = context || document;
6267 // !context.createElement fails in IE with an error but returns typeof 'object'
6268 if ( typeof context.createElement === "undefined" ) {
6269 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
6274 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6275 if ( typeof elem === "number" ) {
6283 // Convert html string into DOM nodes
6284 if ( typeof elem === "string" ) {
6285 if ( !rhtml.test( elem ) ) {
6286 elem = context.createTextNode( elem );
6288 // Fix "XHTML"-style tags in all browsers
6289 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6291 // Trim whitespace, otherwise indexOf won't work as expected
6292 var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
6293 wrap = wrapMap[ tag ] || wrapMap._default,
6295 div = context.createElement("div");
6297 // Append wrapper element to unknown element safe doc fragment
6298 if ( context === document ) {
6299 // Use the fragment we've already created for this document
6300 safeFragment.appendChild( div );
6302 // Use a fragment created with the owner document
6303 createSafeFragment( context ).appendChild( div );
6306 // Go to html and back, then peel off extra wrappers
6307 div.innerHTML = wrap[1] + elem + wrap[2];
6309 // Move to the right depth
6311 div = div.lastChild;
6314 // Remove IE's autoinserted <tbody> from table fragments
6315 if ( !jQuery.support.tbody ) {
6317 // String was a <table>, *may* have spurious <tbody>
6318 var hasBody = rtbody.test(elem),
6319 tbody = tag === "table" && !hasBody ?
6320 div.firstChild && div.firstChild.childNodes :
6322 // String was a bare <thead> or <tfoot>
6323 wrap[1] === "<table>" && !hasBody ?
6327 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6328 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6329 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6334 // IE completely kills leading whitespace when innerHTML is used
6335 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6336 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6339 elem = div.childNodes;
6343 // Resets defaultChecked for any radios and checkboxes
6344 // about to be appended to the DOM in IE 6/7 (#8060)
6346 if ( !jQuery.support.appendChecked ) {
6347 if ( elem[0] && typeof (len = elem.length) === "number" ) {
6348 for ( j = 0; j < len; j++ ) {
6349 findInputs( elem[j] );
6356 if ( elem.nodeType ) {
6359 ret = jQuery.merge( ret, elem );
6364 checkScriptType = function( elem ) {
6365 return !elem.type || rscriptType.test( elem.type );
6367 for ( i = 0; ret[i]; i++ ) {
6368 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
6369 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
6372 if ( ret[i].nodeType === 1 ) {
6373 var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
6375 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6377 fragment.appendChild( ret[i] );
6385 cleanData: function( elems ) {
6387 cache = jQuery.cache,
6388 special = jQuery.event.special,
6389 deleteExpando = jQuery.support.deleteExpando;
6391 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6392 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
6396 id = elem[ jQuery.expando ];
6401 if ( data && data.events ) {
6402 for ( var type in data.events ) {
6403 if ( special[ type ] ) {
6404 jQuery.event.remove( elem, type );
6406 // This is a shortcut to avoid jQuery.event.remove's overhead
6408 jQuery.removeEvent( elem, type, data.handle );
6412 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6413 if ( data.handle ) {
6414 data.handle.elem = null;
6418 if ( deleteExpando ) {
6419 delete elem[ jQuery.expando ];
6421 } else if ( elem.removeAttribute ) {
6422 elem.removeAttribute( jQuery.expando );
6431 function evalScript( i, elem ) {
6439 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
6442 if ( elem.parentNode ) {
6443 elem.parentNode.removeChild( elem );
6450 var ralpha = /alpha\([^)]*\)/i,
6451 ropacity = /opacity=([^)]*)/,
6452 // fixed for IE9, see #8346
6453 rupper = /([A-Z]|^ms)/g,
6454 rnumpx = /^-?\d+(?:px)?$/i,
6456 rrelNum = /^([\-+])=([\-+.\de]+)/,
6458 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6459 cssWidth = [ "Left", "Right" ],
6460 cssHeight = [ "Top", "Bottom" ],
6466 jQuery.fn.css = function( name, value ) {
6467 // Setting 'undefined' is a no-op
6468 if ( arguments.length === 2 && value === undefined ) {
6472 return jQuery.access( this, name, value, true, function( elem, name, value ) {
6473 return value !== undefined ?
6474 jQuery.style( elem, name, value ) :
6475 jQuery.css( elem, name );
6480 // Add in style property hooks for overriding the default
6481 // behavior of getting and setting a style property
6484 get: function( elem, computed ) {
6486 // We should always get a number back from opacity
6487 var ret = curCSS( elem, "opacity", "opacity" );
6488 return ret === "" ? "1" : ret;
6491 return elem.style.opacity;
6497 // Exclude the following css properties to add px
6499 "fillOpacity": true,
6509 // Add in properties whose names you wish to fix before
6510 // setting or getting the value
6512 // normalize float css property
6513 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6516 // Get and set the style property on a DOM Node
6517 style: function( elem, name, value, extra ) {
6518 // Don't set styles on text and comment nodes
6519 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6523 // Make sure that we're working with the right name
6524 var ret, type, origName = jQuery.camelCase( name ),
6525 style = elem.style, hooks = jQuery.cssHooks[ origName ];
6527 name = jQuery.cssProps[ origName ] || origName;
6529 // Check if we're setting a value
6530 if ( value !== undefined ) {
6531 type = typeof value;
6533 // convert relative number strings (+= or -=) to relative numbers. #7345
6534 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6535 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
6540 // Make sure that NaN and null values aren't set. See: #7116
6541 if ( value == null || type === "number" && isNaN( value ) ) {
6545 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6546 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6550 // If a hook was provided, use that value, otherwise just set the specified value
6551 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
6552 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6555 style[ name ] = value;
6560 // If a hook was provided get the non-computed value from there
6561 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6565 // Otherwise just get the value from the style object
6566 return style[ name ];
6570 css: function( elem, name, extra ) {
6573 // Make sure that we're working with the right name
6574 name = jQuery.camelCase( name );
6575 hooks = jQuery.cssHooks[ name ];
6576 name = jQuery.cssProps[ name ] || name;
6578 // cssFloat needs a special treatment
6579 if ( name === "cssFloat" ) {
6583 // If a hook was provided get the computed value from there
6584 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
6587 // Otherwise, if a way to get the computed value exists, use that
6588 } else if ( curCSS ) {
6589 return curCSS( elem, name );
6593 // A method for quickly swapping in/out CSS properties to get correct calculations
6594 swap: function( elem, options, callback ) {
6597 // Remember the old values, and insert the new ones
6598 for ( var name in options ) {
6599 old[ name ] = elem.style[ name ];
6600 elem.style[ name ] = options[ name ];
6603 callback.call( elem );
6605 // Revert the old values
6606 for ( name in options ) {
6607 elem.style[ name ] = old[ name ];
6612 // DEPRECATED, Use jQuery.css() instead
6613 jQuery.curCSS = jQuery.css;
6615 jQuery.each(["height", "width"], function( i, name ) {
6616 jQuery.cssHooks[ name ] = {
6617 get: function( elem, computed, extra ) {
6621 if ( elem.offsetWidth !== 0 ) {
6622 return getWH( elem, name, extra );
6624 jQuery.swap( elem, cssShow, function() {
6625 val = getWH( elem, name, extra );
6633 set: function( elem, value ) {
6634 if ( rnumpx.test( value ) ) {
6635 // ignore negative width and height values #1599
6636 value = parseFloat( value );
6639 return value + "px";
6649 if ( !jQuery.support.opacity ) {
6650 jQuery.cssHooks.opacity = {
6651 get: function( elem, computed ) {
6652 // IE uses filters for opacity
6653 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6654 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
6655 computed ? "1" : "";
6658 set: function( elem, value ) {
6659 var style = elem.style,
6660 currentStyle = elem.currentStyle,
6661 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
6662 filter = currentStyle && currentStyle.filter || style.filter || "";
6664 // IE has trouble with opacity if it does not have layout
6665 // Force it by setting the zoom level
6668 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6669 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
6671 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6672 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6673 // style.removeAttribute is IE Only, but so apparently is this code path...
6674 style.removeAttribute( "filter" );
6676 // if there there is no filter style applied in a css rule, we are done
6677 if ( currentStyle && !currentStyle.filter ) {
6682 // otherwise, set new filter values
6683 style.filter = ralpha.test( filter ) ?
6684 filter.replace( ralpha, opacity ) :
6685 filter + " " + opacity;
6691 // This hook cannot be added until DOM ready because the support test
6692 // for it is not run until after DOM ready
6693 if ( !jQuery.support.reliableMarginRight ) {
6694 jQuery.cssHooks.marginRight = {
6695 get: function( elem, computed ) {
6696 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6697 // Work around by temporarily setting element display to inline-block
6699 jQuery.swap( elem, { "display": "inline-block" }, function() {
6701 ret = curCSS( elem, "margin-right", "marginRight" );
6703 ret = elem.style.marginRight;
6712 if ( document.defaultView && document.defaultView.getComputedStyle ) {
6713 getComputedStyle = function( elem, name ) {
6714 var ret, defaultView, computedStyle;
6716 name = name.replace( rupper, "-$1" ).toLowerCase();
6718 if ( (defaultView = elem.ownerDocument.defaultView) &&
6719 (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
6720 ret = computedStyle.getPropertyValue( name );
6721 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6722 ret = jQuery.style( elem, name );
6730 if ( document.documentElement.currentStyle ) {
6731 currentStyle = function( elem, name ) {
6732 var left, rsLeft, uncomputed,
6733 ret = elem.currentStyle && elem.currentStyle[ name ],
6736 // Avoid setting ret to empty string here
6737 // so we don't default to auto
6738 if ( ret === null && style && (uncomputed = style[ name ]) ) {
6742 // From the awesome hack by Dean Edwards
6743 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6745 // If we're not dealing with a regular pixel number
6746 // but a number that has a weird ending, we need to convert it to pixels
6747 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6749 // Remember the original values
6751 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6753 // Put in the new values to get a computed value out
6755 elem.runtimeStyle.left = elem.currentStyle.left;
6757 style.left = name === "fontSize" ? "1em" : ( ret || 0 );
6758 ret = style.pixelLeft + "px";
6760 // Revert the changed values
6763 elem.runtimeStyle.left = rsLeft;
6767 return ret === "" ? "auto" : ret;
6771 curCSS = getComputedStyle || currentStyle;
6773 function getWH( elem, name, extra ) {
6775 // Start with offset property
6776 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6777 which = name === "width" ? cssWidth : cssHeight,
6782 if ( extra !== "border" ) {
6783 for ( ; i < len; i++ ) {
6785 val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
6787 if ( extra === "margin" ) {
6788 val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
6790 val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
6798 // Fall back to computed then uncomputed css if necessary
6799 val = curCSS( elem, name, name );
6800 if ( val < 0 || val == null ) {
6801 val = elem.style[ name ] || 0;
6803 // Normalize "", auto, and prepare for extra
6804 val = parseFloat( val ) || 0;
6806 // Add padding, border, margin
6808 for ( ; i < len; i++ ) {
6809 val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
6810 if ( extra !== "padding" ) {
6811 val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
6813 if ( extra === "margin" ) {
6814 val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
6822 if ( jQuery.expr && jQuery.expr.filters ) {
6823 jQuery.expr.filters.hidden = function( elem ) {
6824 var width = elem.offsetWidth,
6825 height = elem.offsetHeight;
6827 return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
6830 jQuery.expr.filters.visible = function( elem ) {
6831 return !jQuery.expr.filters.hidden( elem );
6842 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
6843 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6844 // #7653, #8125, #8152: local protocol detection
6845 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6846 rnoContent = /^(?:GET|HEAD)$/,
6847 rprotocol = /^\/\//,
6849 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6850 rselectTextarea = /^(?:select|textarea)/i,
6851 rspacesAjax = /\s+/,
6852 rts = /([?&])_=[^&]*/,
6853 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6855 // Keep a copy of the old load method
6856 _load = jQuery.fn.load,
6859 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6860 * 2) These are called:
6861 * - BEFORE asking for a transport
6862 * - AFTER param serialization (s.data is a string if s.processData is true)
6863 * 3) key is the dataType
6864 * 4) the catchall symbol "*" can be used
6865 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6869 /* Transports bindings
6870 * 1) key is the dataType
6871 * 2) the catchall symbol "*" can be used
6872 * 3) selection will start with transport dataType and THEN go to "*" if needed
6876 // Document location
6879 // Document location segments
6882 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6883 allTypes = ["*/"] + ["*"];
6885 // #8138, IE may throw an exception when accessing
6886 // a field from window.location if document.domain has been set
6888 ajaxLocation = location.href;
6890 // Use the href attribute of an A element
6891 // since IE will modify it given document.location
6892 ajaxLocation = document.createElement( "a" );
6893 ajaxLocation.href = "";
6894 ajaxLocation = ajaxLocation.href;
6897 // Segment location into parts
6898 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
6900 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6901 function addToPrefiltersOrTransports( structure ) {
6903 // dataTypeExpression is optional and defaults to "*"
6904 return function( dataTypeExpression, func ) {
6906 if ( typeof dataTypeExpression !== "string" ) {
6907 func = dataTypeExpression;
6908 dataTypeExpression = "*";
6911 if ( jQuery.isFunction( func ) ) {
6912 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
6914 length = dataTypes.length,
6919 // For each dataType in the dataTypeExpression
6920 for ( ; i < length; i++ ) {
6921 dataType = dataTypes[ i ];
6922 // We control if we're asked to add before
6923 // any existing element
6924 placeBefore = /^\+/.test( dataType );
6925 if ( placeBefore ) {
6926 dataType = dataType.substr( 1 ) || "*";
6928 list = structure[ dataType ] = structure[ dataType ] || [];
6929 // then we add to the structure accordingly
6930 list[ placeBefore ? "unshift" : "push" ]( func );
6936 // Base inspection function for prefilters and transports
6937 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6938 dataType /* internal */, inspected /* internal */ ) {
6940 dataType = dataType || options.dataTypes[ 0 ];
6941 inspected = inspected || {};
6943 inspected[ dataType ] = true;
6945 var list = structure[ dataType ],
6947 length = list ? list.length : 0,
6948 executeOnly = ( structure === prefilters ),
6951 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
6952 selection = list[ i ]( options, originalOptions, jqXHR );
6953 // If we got redirected to another dataType
6954 // we try there if executing only and not done already
6955 if ( typeof selection === "string" ) {
6956 if ( !executeOnly || inspected[ selection ] ) {
6957 selection = undefined;
6959 options.dataTypes.unshift( selection );
6960 selection = inspectPrefiltersOrTransports(
6961 structure, options, originalOptions, jqXHR, selection, inspected );
6965 // If we're only executing or nothing was selected
6966 // we try the catchall dataType if not done already
6967 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6968 selection = inspectPrefiltersOrTransports(
6969 structure, options, originalOptions, jqXHR, "*", inspected );
6971 // unnecessary when only executing (prefilters)
6972 // but it'll be ignored by the caller in that case
6976 // A special extend for ajax options
6977 // that takes "flat" options (not to be deep extended)
6979 function ajaxExtend( target, src ) {
6981 flatOptions = jQuery.ajaxSettings.flatOptions || {};
6982 for ( key in src ) {
6983 if ( src[ key ] !== undefined ) {
6984 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
6988 jQuery.extend( true, target, deep );
6993 load: function( url, params, callback ) {
6994 if ( typeof url !== "string" && _load ) {
6995 return _load.apply( this, arguments );
6997 // Don't do a request if no elements are being requested
6998 } else if ( !this.length ) {
7002 var off = url.indexOf( " " );
7004 var selector = url.slice( off, url.length );
7005 url = url.slice( 0, off );
7008 // Default to a GET request
7011 // If the second parameter was provided
7013 // If it's a function
7014 if ( jQuery.isFunction( params ) ) {
7015 // We assume that it's the callback
7019 // Otherwise, build a param string
7020 } else if ( typeof params === "object" ) {
7021 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
7028 // Request the remote document
7034 // Complete callback (responseText is used internally)
7035 complete: function( jqXHR, status, responseText ) {
7036 // Store the response as specified by the jqXHR object
7037 responseText = jqXHR.responseText;
7038 // If successful, inject the HTML into all the matched elements
7039 if ( jqXHR.isResolved() ) {
7040 // #4825: Get the actual response in case
7041 // a dataFilter is present in ajaxSettings
7042 jqXHR.done(function( r ) {
7045 // See if a selector was specified
7046 self.html( selector ?
7047 // Create a dummy div to hold the results
7049 // inject the contents of the document in, removing the scripts
7050 // to avoid any 'Permission Denied' errors in IE
7051 .append(responseText.replace(rscript, ""))
7053 // Locate the specified elements
7056 // If not, just inject the full result
7061 self.each( callback, [ responseText, status, jqXHR ] );
7069 serialize: function() {
7070 return jQuery.param( this.serializeArray() );
7073 serializeArray: function() {
7074 return this.map(function(){
7075 return this.elements ? jQuery.makeArray( this.elements ) : this;
7078 return this.name && !this.disabled &&
7079 ( this.checked || rselectTextarea.test( this.nodeName ) ||
7080 rinput.test( this.type ) );
7082 .map(function( i, elem ){
7083 var val = jQuery( this ).val();
7085 return val == null ?
7087 jQuery.isArray( val ) ?
7088 jQuery.map( val, function( val, i ){
7089 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7091 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7096 // Attach a bunch of functions for handling common AJAX events
7097 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
7098 jQuery.fn[ o ] = function( f ){
7099 return this.on( o, f );
7103 jQuery.each( [ "get", "post" ], function( i, method ) {
7104 jQuery[ method ] = function( url, data, callback, type ) {
7105 // shift arguments if data argument was omitted
7106 if ( jQuery.isFunction( data ) ) {
7107 type = type || callback;
7112 return jQuery.ajax({
7124 getScript: function( url, callback ) {
7125 return jQuery.get( url, undefined, callback, "script" );
7128 getJSON: function( url, data, callback ) {
7129 return jQuery.get( url, data, callback, "json" );
7132 // Creates a full fledged settings object into target
7133 // with both ajaxSettings and settings fields.
7134 // If target is omitted, writes into ajaxSettings.
7135 ajaxSetup: function( target, settings ) {
7137 // Building a settings object
7138 ajaxExtend( target, jQuery.ajaxSettings );
7140 // Extending ajaxSettings
7142 target = jQuery.ajaxSettings;
7144 ajaxExtend( target, settings );
7150 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7153 contentType: "application/x-www-form-urlencoded",
7168 xml: "application/xml, text/xml",
7171 json: "application/json, text/javascript",
7183 text: "responseText"
7186 // List of data converters
7187 // 1) key format is "source_type destination_type" (a single space in-between)
7188 // 2) the catchall symbol "*" can be used for source_type
7191 // Convert anything to text
7192 "* text": window.String,
7194 // Text to html (true = no transformation)
7197 // Evaluate text as a json expression
7198 "text json": jQuery.parseJSON,
7200 // Parse text as xml
7201 "text xml": jQuery.parseXML
7204 // For options that shouldn't be deep extended:
7205 // you can add your own custom options here if
7206 // and when you create one that shouldn't be
7207 // deep extended (see ajaxExtend)
7214 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7215 ajaxTransport: addToPrefiltersOrTransports( transports ),
7218 ajax: function( url, options ) {
7220 // If url is an object, simulate pre-1.5 signature
7221 if ( typeof url === "object" ) {
7226 // Force options to be an object
7227 options = options || {};
7229 var // Create the final options object
7230 s = jQuery.ajaxSetup( {}, options ),
7231 // Callbacks context
7232 callbackContext = s.context || s,
7233 // Context for global events
7234 // It's the callbackContext if one was provided in the options
7235 // and if it's a DOM node or a jQuery collection
7236 globalEventContext = callbackContext !== s &&
7237 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7238 jQuery( callbackContext ) : jQuery.event,
7240 deferred = jQuery.Deferred(),
7241 completeDeferred = jQuery.Callbacks( "once memory" ),
7242 // Status-dependent callbacks
7243 statusCode = s.statusCode || {},
7246 // Headers (they are sent all at once)
7247 requestHeaders = {},
7248 requestHeadersNames = {},
7250 responseHeadersString,
7256 // Cross-domain detection vars
7260 // To know if global events are to be dispatched
7269 // Caches the header
7270 setRequestHeader: function( name, value ) {
7272 var lname = name.toLowerCase();
7273 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7274 requestHeaders[ name ] = value;
7280 getAllResponseHeaders: function() {
7281 return state === 2 ? responseHeadersString : null;
7284 // Builds headers hashtable if needed
7285 getResponseHeader: function( key ) {
7287 if ( state === 2 ) {
7288 if ( !responseHeaders ) {
7289 responseHeaders = {};
7290 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7291 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7294 match = responseHeaders[ key.toLowerCase() ];
7296 return match === undefined ? null : match;
7299 // Overrides response content-type header
7300 overrideMimeType: function( type ) {
7307 // Cancel the request
7308 abort: function( statusText ) {
7309 statusText = statusText || "abort";
7311 transport.abort( statusText );
7313 done( 0, statusText );
7318 // Callback for when everything is done
7319 // It is defined here because jslint complains if it is declared
7320 // at the end of the function (which would be more logical and readable)
7321 function done( status, nativeStatusText, responses, headers ) {
7324 if ( state === 2 ) {
7328 // State is "done" now
7331 // Clear timeout if it exists
7332 if ( timeoutTimer ) {
7333 clearTimeout( timeoutTimer );
7336 // Dereference transport for early garbage collection
7337 // (no matter how long the jqXHR object will be used)
7338 transport = undefined;
7340 // Cache response headers
7341 responseHeadersString = headers || "";
7344 jqXHR.readyState = status > 0 ? 4 : 0;
7349 statusText = nativeStatusText,
7350 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
7354 // If successful, handle type chaining
7355 if ( status >= 200 && status < 300 || status === 304 ) {
7357 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7358 if ( s.ifModified ) {
7360 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
7361 jQuery.lastModified[ ifModifiedKey ] = lastModified;
7363 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
7364 jQuery.etag[ ifModifiedKey ] = etag;
7369 if ( status === 304 ) {
7371 statusText = "notmodified";
7378 success = ajaxConvert( s, response );
7379 statusText = "success";
7382 // We have a parsererror
7383 statusText = "parsererror";
7388 // We extract error from statusText
7389 // then normalize statusText and status for non-aborts
7391 if ( !statusText || status ) {
7392 statusText = "error";
7399 // Set data for the fake xhr object
7400 jqXHR.status = status;
7401 jqXHR.statusText = "" + ( nativeStatusText || statusText );
7405 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7407 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7410 // Status-dependent callbacks
7411 jqXHR.statusCode( statusCode );
7412 statusCode = undefined;
7414 if ( fireGlobals ) {
7415 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7416 [ jqXHR, s, isSuccess ? success : error ] );
7420 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7422 if ( fireGlobals ) {
7423 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7424 // Handle the global AJAX counter
7425 if ( !( --jQuery.active ) ) {
7426 jQuery.event.trigger( "ajaxStop" );
7432 deferred.promise( jqXHR );
7433 jqXHR.success = jqXHR.done;
7434 jqXHR.error = jqXHR.fail;
7435 jqXHR.complete = completeDeferred.add;
7437 // Status-dependent callbacks
7438 jqXHR.statusCode = function( map ) {
7442 for ( tmp in map ) {
7443 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7446 tmp = map[ jqXHR.status ];
7447 jqXHR.then( tmp, tmp );
7453 // Remove hash character (#7531: and string promotion)
7454 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7455 // We also use the url parameter if available
7456 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7458 // Extract dataTypes list
7459 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
7461 // Determine if a cross-domain request is in order
7462 if ( s.crossDomain == null ) {
7463 parts = rurl.exec( s.url.toLowerCase() );
7464 s.crossDomain = !!( parts &&
7465 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7466 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7467 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7471 // Convert data if not already a string
7472 if ( s.data && s.processData && typeof s.data !== "string" ) {
7473 s.data = jQuery.param( s.data, s.traditional );
7477 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7479 // If request was aborted inside a prefiler, stop there
7480 if ( state === 2 ) {
7484 // We can fire global events as of now if asked to
7485 fireGlobals = s.global;
7487 // Uppercase the type
7488 s.type = s.type.toUpperCase();
7490 // Determine if request has content
7491 s.hasContent = !rnoContent.test( s.type );
7493 // Watch for a new set of requests
7494 if ( fireGlobals && jQuery.active++ === 0 ) {
7495 jQuery.event.trigger( "ajaxStart" );
7498 // More options handling for requests with no content
7499 if ( !s.hasContent ) {
7501 // If data is available, append data to url
7503 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7504 // #9682: remove data so that it's not used in an eventual retry
7508 // Get ifModifiedKey before adding the anti-cache parameter
7509 ifModifiedKey = s.url;
7511 // Add anti-cache in url if needed
7512 if ( s.cache === false ) {
7514 var ts = jQuery.now(),
7515 // try replacing _= if it is there
7516 ret = s.url.replace( rts, "$1_=" + ts );
7518 // if nothing was replaced, add timestamp to the end
7519 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7523 // Set the correct header, if data is being sent
7524 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7525 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7528 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7529 if ( s.ifModified ) {
7530 ifModifiedKey = ifModifiedKey || s.url;
7531 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7532 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7534 if ( jQuery.etag[ ifModifiedKey ] ) {
7535 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7539 // Set the Accepts header for the server, depending on the dataType
7540 jqXHR.setRequestHeader(
7542 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7543 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7547 // Check for headers option
7548 for ( i in s.headers ) {
7549 jqXHR.setRequestHeader( i, s.headers[ i ] );
7552 // Allow custom headers/mimetypes and early abort
7553 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7554 // Abort if not done already
7560 // Install callbacks on deferreds
7561 for ( i in { success: 1, error: 1, complete: 1 } ) {
7562 jqXHR[ i ]( s[ i ] );
7566 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7568 // If no transport, we auto-abort
7570 done( -1, "No Transport" );
7572 jqXHR.readyState = 1;
7573 // Send global event
7574 if ( fireGlobals ) {
7575 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7578 if ( s.async && s.timeout > 0 ) {
7579 timeoutTimer = setTimeout( function(){
7580 jqXHR.abort( "timeout" );
7586 transport.send( requestHeaders, done );
7588 // Propagate exception as error if not done
7591 // Simply rethrow otherwise
7601 // Serialize an array of form elements or a set of
7602 // key/values into a query string
7603 param: function( a, traditional ) {
7605 add = function( key, value ) {
7606 // If value is a function, invoke it and return its value
7607 value = jQuery.isFunction( value ) ? value() : value;
7608 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7611 // Set traditional to true for jQuery <= 1.3.2 behavior.
7612 if ( traditional === undefined ) {
7613 traditional = jQuery.ajaxSettings.traditional;
7616 // If an array was passed in, assume that it is an array of form elements.
7617 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7618 // Serialize the form elements
7619 jQuery.each( a, function() {
7620 add( this.name, this.value );
7624 // If traditional, encode the "old" way (the way 1.3.2 or older
7625 // did it), otherwise encode params recursively.
7626 for ( var prefix in a ) {
7627 buildParams( prefix, a[ prefix ], traditional, add );
7631 // Return the resulting serialization
7632 return s.join( "&" ).replace( r20, "+" );
7636 function buildParams( prefix, obj, traditional, add ) {
7637 if ( jQuery.isArray( obj ) ) {
7638 // Serialize array item.
7639 jQuery.each( obj, function( i, v ) {
7640 if ( traditional || rbracket.test( prefix ) ) {
7641 // Treat each array item as a scalar.
7645 // If array item is non-scalar (array or object), encode its
7646 // numeric index to resolve deserialization ambiguity issues.
7647 // Note that rack (as of 1.0.0) can't currently deserialize
7648 // nested arrays properly, and attempting to do so may cause
7649 // a server error. Possible fixes are to modify rack's
7650 // deserialization algorithm or to provide an option or flag
7651 // to force array serialization to be shallow.
7652 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
7656 } else if ( !traditional && obj != null && typeof obj === "object" ) {
7657 // Serialize object item.
7658 for ( var name in obj ) {
7659 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7663 // Serialize scalar item.
7668 // This is still on the jQuery object... for now
7669 // Want to move this to jQuery.ajax some day
7672 // Counter for holding the number of active queries
7675 // Last-Modified header cache for next request
7681 /* Handles responses to an ajax request:
7682 * - sets all responseXXX fields accordingly
7683 * - finds the right dataType (mediates between content-type and expected dataType)
7684 * - returns the corresponding response
7686 function ajaxHandleResponses( s, jqXHR, responses ) {
7688 var contents = s.contents,
7689 dataTypes = s.dataTypes,
7690 responseFields = s.responseFields,
7696 // Fill responseXXX fields
7697 for ( type in responseFields ) {
7698 if ( type in responses ) {
7699 jqXHR[ responseFields[type] ] = responses[ type ];
7703 // Remove auto dataType and get content-type in the process
7704 while( dataTypes[ 0 ] === "*" ) {
7706 if ( ct === undefined ) {
7707 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
7711 // Check if we're dealing with a known content-type
7713 for ( type in contents ) {
7714 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7715 dataTypes.unshift( type );
7721 // Check to see if we have a response for the expected dataType
7722 if ( dataTypes[ 0 ] in responses ) {
7723 finalDataType = dataTypes[ 0 ];
7725 // Try convertible dataTypes
7726 for ( type in responses ) {
7727 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7728 finalDataType = type;
7731 if ( !firstDataType ) {
7732 firstDataType = type;
7735 // Or just use first one
7736 finalDataType = finalDataType || firstDataType;
7739 // If we found a dataType
7740 // We add the dataType to the list if needed
7741 // and return the corresponding response
7742 if ( finalDataType ) {
7743 if ( finalDataType !== dataTypes[ 0 ] ) {
7744 dataTypes.unshift( finalDataType );
7746 return responses[ finalDataType ];
7750 // Chain conversions given the request and the original response
7751 function ajaxConvert( s, response ) {
7753 // Apply the dataFilter if provided
7754 if ( s.dataFilter ) {
7755 response = s.dataFilter( response, s.dataType );
7758 var dataTypes = s.dataTypes,
7762 length = dataTypes.length,
7764 // Current and previous dataTypes
7765 current = dataTypes[ 0 ],
7767 // Conversion expression
7769 // Conversion function
7771 // Conversion functions (transitive conversion)
7775 // For each dataType in the chain
7776 for ( i = 1; i < length; i++ ) {
7778 // Create converters map
7779 // with lowercased keys
7781 for ( key in s.converters ) {
7782 if ( typeof key === "string" ) {
7783 converters[ key.toLowerCase() ] = s.converters[ key ];
7788 // Get the dataTypes
7790 current = dataTypes[ i ];
7792 // If current is auto dataType, update it to prev
7793 if ( current === "*" ) {
7795 // If no auto and dataTypes are actually different
7796 } else if ( prev !== "*" && prev !== current ) {
7798 // Get the converter
7799 conversion = prev + " " + current;
7800 conv = converters[ conversion ] || converters[ "* " + current ];
7802 // If there is no direct converter, search transitively
7805 for ( conv1 in converters ) {
7806 tmp = conv1.split( " " );
7807 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7808 conv2 = converters[ tmp[1] + " " + current ];
7810 conv1 = converters[ conv1 ];
7811 if ( conv1 === true ) {
7813 } else if ( conv2 === true ) {
7821 // If we found no converter, dispatch an error
7822 if ( !( conv || conv2 ) ) {
7823 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
7825 // If found converter is not an equivalence
7826 if ( conv !== true ) {
7827 // Convert with 1 or 2 converters accordingly
7828 response = conv ? conv( response ) : conv2( conv1(response) );
7838 var jsc = jQuery.now(),
7839 jsre = /(\=)\?(&|$)|\?\?/i;
7841 // Default jsonp settings
7844 jsonpCallback: function() {
7845 return jQuery.expando + "_" + ( jsc++ );
7849 // Detect, normalize options and install callbacks for jsonp requests
7850 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
7852 var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
7853 ( typeof s.data === "string" );
7855 if ( s.dataTypes[ 0 ] === "jsonp" ||
7856 s.jsonp !== false && ( jsre.test( s.url ) ||
7857 inspectData && jsre.test( s.data ) ) ) {
7859 var responseContainer,
7860 jsonpCallback = s.jsonpCallback =
7861 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
7862 previous = window[ jsonpCallback ],
7865 replace = "$1" + jsonpCallback + "$2";
7867 if ( s.jsonp !== false ) {
7868 url = url.replace( jsre, replace );
7869 if ( s.url === url ) {
7870 if ( inspectData ) {
7871 data = data.replace( jsre, replace );
7873 if ( s.data === data ) {
7874 // Add callback manually
7875 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
7884 window[ jsonpCallback ] = function( response ) {
7885 responseContainer = [ response ];
7888 // Clean-up function
7889 jqXHR.always(function() {
7890 // Set callback back to previous value
7891 window[ jsonpCallback ] = previous;
7892 // Call if it was a function and we have a response
7893 if ( responseContainer && jQuery.isFunction( previous ) ) {
7894 window[ jsonpCallback ]( responseContainer[ 0 ] );
7898 // Use data converter to retrieve json after script execution
7899 s.converters["script json"] = function() {
7900 if ( !responseContainer ) {
7901 jQuery.error( jsonpCallback + " was not called" );
7903 return responseContainer[ 0 ];
7906 // force json dataType
7907 s.dataTypes[ 0 ] = "json";
7909 // Delegate to script
7917 // Install script dataType
7920 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7923 script: /javascript|ecmascript/
7926 "text script": function( text ) {
7927 jQuery.globalEval( text );
7933 // Handle cache's special case and global
7934 jQuery.ajaxPrefilter( "script", function( s ) {
7935 if ( s.cache === undefined ) {
7938 if ( s.crossDomain ) {
7944 // Bind script tag hack transport
7945 jQuery.ajaxTransport( "script", function(s) {
7947 // This transport only deals with cross domain requests
7948 if ( s.crossDomain ) {
7951 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7955 send: function( _, callback ) {
7957 script = document.createElement( "script" );
7959 script.async = "async";
7961 if ( s.scriptCharset ) {
7962 script.charset = s.scriptCharset;
7967 // Attach handlers for all browsers
7968 script.onload = script.onreadystatechange = function( _, isAbort ) {
7970 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
7972 // Handle memory leak in IE
7973 script.onload = script.onreadystatechange = null;
7975 // Remove the script
7976 if ( head && script.parentNode ) {
7977 head.removeChild( script );
7980 // Dereference the script
7983 // Callback if not abort
7985 callback( 200, "success" );
7989 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
7990 // This arises when a base node is used (#2709 and #4378).
7991 head.insertBefore( script, head.firstChild );
7996 script.onload( 0, 1 );
8006 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8007 xhrOnUnloadAbort = window.ActiveXObject ? function() {
8008 // Abort all pending requests
8009 for ( var key in xhrCallbacks ) {
8010 xhrCallbacks[ key ]( 0, 1 );
8016 // Functions to create xhrs
8017 function createStandardXHR() {
8019 return new window.XMLHttpRequest();
8023 function createActiveXHR() {
8025 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
8029 // Create the request object
8030 // (This is still attached to ajaxSettings for backward compatibility)
8031 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8032 /* Microsoft failed to properly
8033 * implement the XMLHttpRequest in IE7 (can't request local files),
8034 * so we use the ActiveXObject when it is available
8035 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8036 * we need a fallback.
8039 return !this.isLocal && createStandardXHR() || createActiveXHR();
8041 // For all other browsers, use the standard XMLHttpRequest object
8044 // Determine support properties
8046 jQuery.extend( jQuery.support, {
8048 cors: !!xhr && ( "withCredentials" in xhr )
8050 })( jQuery.ajaxSettings.xhr() );
8052 // Create transport if the browser can provide an xhr
8053 if ( jQuery.support.ajax ) {
8055 jQuery.ajaxTransport(function( s ) {
8056 // Cross domain only allowed if supported through XMLHttpRequest
8057 if ( !s.crossDomain || jQuery.support.cors ) {
8062 send: function( headers, complete ) {
8070 // Passing null username, generates a login popup on Opera (#2865)
8072 xhr.open( s.type, s.url, s.async, s.username, s.password );
8074 xhr.open( s.type, s.url, s.async );
8077 // Apply custom fields if provided
8078 if ( s.xhrFields ) {
8079 for ( i in s.xhrFields ) {
8080 xhr[ i ] = s.xhrFields[ i ];
8084 // Override mime type if needed
8085 if ( s.mimeType && xhr.overrideMimeType ) {
8086 xhr.overrideMimeType( s.mimeType );
8089 // X-Requested-With header
8090 // For cross-domain requests, seeing as conditions for a preflight are
8091 // akin to a jigsaw puzzle, we simply never set it to be sure.
8092 // (it can always be set on a per-request basis or even using ajaxSetup)
8093 // For same-domain requests, won't change header if already provided.
8094 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8095 headers[ "X-Requested-With" ] = "XMLHttpRequest";
8098 // Need an extra try/catch for cross domain requests in Firefox 3
8100 for ( i in headers ) {
8101 xhr.setRequestHeader( i, headers[ i ] );
8105 // Do send the request
8106 // This may raise an exception which is actually
8107 // handled in jQuery.ajax (so no try/catch here)
8108 xhr.send( ( s.hasContent && s.data ) || null );
8111 callback = function( _, isAbort ) {
8119 // Firefox throws exceptions when accessing properties
8120 // of an xhr when a network error occured
8121 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8124 // Was never called and is aborted or complete
8125 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8128 callback = undefined;
8130 // Do not keep as active anymore
8132 xhr.onreadystatechange = jQuery.noop;
8133 if ( xhrOnUnloadAbort ) {
8134 delete xhrCallbacks[ handle ];
8140 // Abort it manually if needed
8141 if ( xhr.readyState !== 4 ) {
8145 status = xhr.status;
8146 responseHeaders = xhr.getAllResponseHeaders();
8148 xml = xhr.responseXML;
8150 // Construct response list
8151 if ( xml && xml.documentElement /* #4958 */ ) {
8152 responses.xml = xml;
8154 responses.text = xhr.responseText;
8156 // Firefox throws an exception when accessing
8157 // statusText for faulty cross-domain requests
8159 statusText = xhr.statusText;
8161 // We normalize with Webkit giving an empty statusText
8165 // Filter status for non standard behaviors
8167 // If the request is local and we have data: assume a success
8168 // (success with no data won't get notified, that's the best we
8169 // can do given current implementations)
8170 if ( !status && s.isLocal && !s.crossDomain ) {
8171 status = responses.text ? 200 : 404;
8172 // IE - #1450: sometimes returns 1223 when it should be 204
8173 } else if ( status === 1223 ) {
8178 } catch( firefoxAccessException ) {
8180 complete( -1, firefoxAccessException );
8184 // Call complete if needed
8186 complete( status, statusText, responses, responseHeaders );
8190 // if we're in sync mode or it's in cache
8191 // and has been retrieved directly (IE6 & IE7)
8192 // we need to manually fire the callback
8193 if ( !s.async || xhr.readyState === 4 ) {
8197 if ( xhrOnUnloadAbort ) {
8198 // Create the active xhrs callbacks list if needed
8199 // and attach the unload handler
8200 if ( !xhrCallbacks ) {
8202 jQuery( window ).unload( xhrOnUnloadAbort );
8204 // Add to list of active xhrs callbacks
8205 xhrCallbacks[ handle ] = callback;
8207 xhr.onreadystatechange = callback;
8224 var elemdisplay = {},
8226 rfxtypes = /^(?:toggle|show|hide)$/,
8227 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8230 // height animations
8231 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8233 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8234 // opacity animations
8240 show: function( speed, easing, callback ) {
8243 if ( speed || speed === 0 ) {
8244 return this.animate( genFx("show", 3), speed, easing, callback );
8247 for ( var i = 0, j = this.length; i < j; i++ ) {
8251 display = elem.style.display;
8253 // Reset the inline display of this element to learn if it is
8254 // being hidden by cascaded rules or not
8255 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
8256 display = elem.style.display = "";
8259 // Set elements which have been overridden with display: none
8260 // in a stylesheet to whatever the default browser style is
8261 // for such an element
8262 if ( display === "" && jQuery.css(elem, "display") === "none" ) {
8263 jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
8268 // Set the display of most of the elements in a second loop
8269 // to avoid the constant reflow
8270 for ( i = 0; i < j; i++ ) {
8274 display = elem.style.display;
8276 if ( display === "" || display === "none" ) {
8277 elem.style.display = jQuery._data( elem, "olddisplay" ) || "";
8286 hide: function( speed, easing, callback ) {
8287 if ( speed || speed === 0 ) {
8288 return this.animate( genFx("hide", 3), speed, easing, callback);
8295 for ( ; i < j; i++ ) {
8298 display = jQuery.css( elem, "display" );
8300 if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) {
8301 jQuery._data( elem, "olddisplay", display );
8306 // Set the display of the elements in a second loop
8307 // to avoid the constant reflow
8308 for ( i = 0; i < j; i++ ) {
8309 if ( this[i].style ) {
8310 this[i].style.display = "none";
8318 // Save the old toggle function
8319 _toggle: jQuery.fn.toggle,
8321 toggle: function( fn, fn2, callback ) {
8322 var bool = typeof fn === "boolean";
8324 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
8325 this._toggle.apply( this, arguments );
8327 } else if ( fn == null || bool ) {
8328 this.each(function() {
8329 var state = bool ? fn : jQuery(this).is(":hidden");
8330 jQuery(this)[ state ? "show" : "hide" ]();
8334 this.animate(genFx("toggle", 3), fn, fn2, callback);
8340 fadeTo: function( speed, to, easing, callback ) {
8341 return this.filter(":hidden").css("opacity", 0).show().end()
8342 .animate({opacity: to}, speed, easing, callback);
8345 animate: function( prop, speed, easing, callback ) {
8346 var optall = jQuery.speed( speed, easing, callback );
8348 if ( jQuery.isEmptyObject( prop ) ) {
8349 return this.each( optall.complete, [ false ] );
8352 // Do not change referenced properties as per-property easing will be lost
8353 prop = jQuery.extend( {}, prop );
8355 function doAnimation() {
8356 // XXX 'this' does not always have a nodeName when running the
8359 if ( optall.queue === false ) {
8360 jQuery._mark( this );
8363 var opt = jQuery.extend( {}, optall ),
8364 isElement = this.nodeType === 1,
8365 hidden = isElement && jQuery(this).is(":hidden"),
8367 parts, start, end, unit,
8370 // will store per property easing and be used to determine when an animation is complete
8371 opt.animatedProperties = {};
8375 // property name normalization
8376 name = jQuery.camelCase( p );
8378 prop[ name ] = prop[ p ];
8384 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8385 if ( jQuery.isArray( val ) ) {
8386 opt.animatedProperties[ name ] = val[ 1 ];
8387 val = prop[ name ] = val[ 0 ];
8389 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
8392 if ( val === "hide" && hidden || val === "show" && !hidden ) {
8393 return opt.complete.call( this );
8396 if ( isElement && ( name === "height" || name === "width" ) ) {
8397 // Make sure that nothing sneaks out
8398 // Record all 3 overflow attributes because IE does not
8399 // change the overflow attribute when overflowX and
8400 // overflowY are set to the same value
8401 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
8403 // Set display property to inline-block for height/width
8404 // animations on inline elements that are having width/height animated
8405 if ( jQuery.css( this, "display" ) === "inline" &&
8406 jQuery.css( this, "float" ) === "none" ) {
8408 // inline-level elements accept inline-block;
8409 // block-level elements need to be inline with layout
8410 if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) {
8411 this.style.display = "inline-block";
8414 this.style.zoom = 1;
8420 if ( opt.overflow != null ) {
8421 this.style.overflow = "hidden";
8425 e = new jQuery.fx( this, opt, p );
8428 if ( rfxtypes.test( val ) ) {
8430 // Tracks whether to show or hide based on private
8431 // data attached to the element
8432 method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 );
8434 jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" );
8441 parts = rfxnum.exec( val );
8445 end = parseFloat( parts[2] );
8446 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
8448 // We need to compute starting value
8449 if ( unit !== "px" ) {
8450 jQuery.style( this, p, (end || 1) + unit);
8451 start = ( (end || 1) / e.cur() ) * start;
8452 jQuery.style( this, p, start + unit);
8455 // If a +=/-= token was provided, we're doing a relative animation
8457 end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
8460 e.custom( start, end, unit );
8463 e.custom( start, val, "" );
8468 // For JS strict compliance
8472 return optall.queue === false ?
8473 this.each( doAnimation ) :
8474 this.queue( optall.queue, doAnimation );
8477 stop: function( type, clearQueue, gotoEnd ) {
8478 if ( typeof type !== "string" ) {
8479 gotoEnd = clearQueue;
8483 if ( clearQueue && type !== false ) {
8484 this.queue( type || "fx", [] );
8487 return this.each(function() {
8490 timers = jQuery.timers,
8491 data = jQuery._data( this );
8493 // clear marker counters if we know they won't be
8495 jQuery._unmark( true, this );
8498 function stopQueue( elem, data, index ) {
8499 var hooks = data[ index ];
8500 jQuery.removeData( elem, index, true );
8501 hooks.stop( gotoEnd );
8504 if ( type == null ) {
8505 for ( index in data ) {
8506 if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) {
8507 stopQueue( this, data, index );
8510 } else if ( data[ index = type + ".run" ] && data[ index ].stop ){
8511 stopQueue( this, data, index );
8514 for ( index = timers.length; index--; ) {
8515 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
8518 // force the next step to be the last
8519 timers[ index ]( true );
8521 timers[ index ].saveState();
8524 timers.splice( index, 1 );
8528 // start the next in the queue if the last step wasn't forced
8529 // timers currently will call their complete callbacks, which will dequeue
8530 // but only if they were gotoEnd
8531 if ( !( gotoEnd && hadTimers ) ) {
8532 jQuery.dequeue( this, type );
8539 // Animations created synchronously will run synchronously
8540 function createFxNow() {
8541 setTimeout( clearFxNow, 0 );
8542 return ( fxNow = jQuery.now() );
8545 function clearFxNow() {
8549 // Generate parameters to create a standard animation
8550 function genFx( type, num ) {
8553 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() {
8560 // Generate shortcuts for custom animations
8562 slideDown: genFx( "show", 1 ),
8563 slideUp: genFx( "hide", 1 ),
8564 slideToggle: genFx( "toggle", 1 ),
8565 fadeIn: { opacity: "show" },
8566 fadeOut: { opacity: "hide" },
8567 fadeToggle: { opacity: "toggle" }
8568 }, function( name, props ) {
8569 jQuery.fn[ name ] = function( speed, easing, callback ) {
8570 return this.animate( props, speed, easing, callback );
8575 speed: function( speed, easing, fn ) {
8576 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
8577 complete: fn || !fn && easing ||
8578 jQuery.isFunction( speed ) && speed,
8580 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
8583 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8584 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
8586 // normalize opt.queue - true/undefined/null -> "fx"
8587 if ( opt.queue == null || opt.queue === true ) {
8592 opt.old = opt.complete;
8594 opt.complete = function( noUnmark ) {
8595 if ( jQuery.isFunction( opt.old ) ) {
8596 opt.old.call( this );
8600 jQuery.dequeue( this, opt.queue );
8601 } else if ( noUnmark !== false ) {
8602 jQuery._unmark( this );
8610 linear: function( p, n, firstNum, diff ) {
8611 return firstNum + diff * p;
8613 swing: function( p, n, firstNum, diff ) {
8614 return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum;
8620 fx: function( elem, options, prop ) {
8621 this.options = options;
8625 options.orig = options.orig || {};
8630 jQuery.fx.prototype = {
8631 // Simple function for setting a style value
8632 update: function() {
8633 if ( this.options.step ) {
8634 this.options.step.call( this.elem, this.now, this );
8637 ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this );
8640 // Get the current size
8642 if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) {
8643 return this.elem[ this.prop ];
8647 r = jQuery.css( this.elem, this.prop );
8648 // Empty strings, null, undefined and "auto" are converted to 0,
8649 // complex values such as "rotate(1rad)" are returned as is,
8650 // simple values such as "10px" are parsed to Float.
8651 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
8654 // Start an animation from one number to another
8655 custom: function( from, to, unit ) {
8659 this.startTime = fxNow || createFxNow();
8661 this.now = this.start = from;
8662 this.pos = this.state = 0;
8663 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8665 function t( gotoEnd ) {
8666 return self.step( gotoEnd );
8669 t.queue = this.options.queue;
8671 t.saveState = function() {
8672 if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
8673 jQuery._data( self.elem, "fxshow" + self.prop, self.start );
8677 if ( t() && jQuery.timers.push(t) && !timerId ) {
8678 timerId = setInterval( fx.tick, fx.interval );
8682 // Simple 'show' function
8684 var dataShow = jQuery._data( this.elem, "fxshow" + this.prop );
8686 // Remember where we started, so that we can go back to it later
8687 this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop );
8688 this.options.show = true;
8690 // Begin the animation
8691 // Make sure that we start at a small width/height to avoid any flash of content
8692 if ( dataShow !== undefined ) {
8693 // This show is picking up where a previous hide or show left off
8694 this.custom( this.cur(), dataShow );
8696 this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() );
8699 // Start by showing the element
8700 jQuery( this.elem ).show();
8703 // Simple 'hide' function
8705 // Remember where we started, so that we can go back to it later
8706 this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop );
8707 this.options.hide = true;
8709 // Begin the animation
8710 this.custom( this.cur(), 0 );
8713 // Each step of an animation
8714 step: function( gotoEnd ) {
8716 t = fxNow || createFxNow(),
8719 options = this.options;
8721 if ( gotoEnd || t >= options.duration + this.startTime ) {
8722 this.now = this.end;
8723 this.pos = this.state = 1;
8726 options.animatedProperties[ this.prop ] = true;
8728 for ( p in options.animatedProperties ) {
8729 if ( options.animatedProperties[ p ] !== true ) {
8735 // Reset the overflow
8736 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
8738 jQuery.each( [ "", "X", "Y" ], function( index, value ) {
8739 elem.style[ "overflow" + value ] = options.overflow[ index ];
8743 // Hide the element if the "hide" operation was done
8744 if ( options.hide ) {
8745 jQuery( elem ).hide();
8748 // Reset the properties, if the item has been hidden or shown
8749 if ( options.hide || options.show ) {
8750 for ( p in options.animatedProperties ) {
8751 jQuery.style( elem, p, options.orig[ p ] );
8752 jQuery.removeData( elem, "fxshow" + p, true );
8753 // Toggle data is no longer needed
8754 jQuery.removeData( elem, "toggle" + p, true );
8758 // Execute the complete function
8759 // in the event that the complete function throws an exception
8760 // we must ensure it won't be called twice. #5684
8762 complete = options.complete;
8765 options.complete = false;
8766 complete.call( elem );
8773 // classical easing cannot be used with an Infinity duration
8774 if ( options.duration == Infinity ) {
8777 n = t - this.startTime;
8778 this.state = n / options.duration;
8780 // Perform the easing function, defaults to swing
8781 this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration );
8782 this.now = this.start + ( (this.end - this.start) * this.pos );
8784 // Perform the next step of the animation
8792 jQuery.extend( jQuery.fx, {
8795 timers = jQuery.timers,
8798 for ( ; i < timers.length; i++ ) {
8799 timer = timers[ i ];
8800 // Checks the timer has not already been removed
8801 if ( !timer() && timers[ i ] === timer ) {
8802 timers.splice( i--, 1 );
8806 if ( !timers.length ) {
8814 clearInterval( timerId );
8826 opacity: function( fx ) {
8827 jQuery.style( fx.elem, "opacity", fx.now );
8830 _default: function( fx ) {
8831 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
8832 fx.elem.style[ fx.prop ] = fx.now + fx.unit;
8834 fx.elem[ fx.prop ] = fx.now;
8840 // Adds width/height step functions
8841 // Do not set anything below 0
8842 jQuery.each([ "width", "height" ], function( i, prop ) {
8843 jQuery.fx.step[ prop ] = function( fx ) {
8844 jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
8848 if ( jQuery.expr && jQuery.expr.filters ) {
8849 jQuery.expr.filters.animated = function( elem ) {
8850 return jQuery.grep(jQuery.timers, function( fn ) {
8851 return elem === fn.elem;
8856 // Try to restore the default display value of an element
8857 function defaultDisplay( nodeName ) {
8859 if ( !elemdisplay[ nodeName ] ) {
8861 var body = document.body,
8862 elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
8863 display = elem.css( "display" );
8866 // If the simple way fails,
8867 // get element's real default display by attaching it to a temp iframe
8868 if ( display === "none" || display === "" ) {
8869 // No iframe to use yet, so create it
8871 iframe = document.createElement( "iframe" );
8872 iframe.frameBorder = iframe.width = iframe.height = 0;
8875 body.appendChild( iframe );
8877 // Create a cacheable copy of the iframe document on first call.
8878 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8879 // document to it; WebKit & Firefox won't allow reusing the iframe document.
8880 if ( !iframeDoc || !iframe.createElement ) {
8881 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
8882 iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8886 elem = iframeDoc.createElement( nodeName );
8888 iframeDoc.body.appendChild( elem );
8890 display = jQuery.css( elem, "display" );
8891 body.removeChild( iframe );
8894 // Store the correct default display
8895 elemdisplay[ nodeName ] = display;
8898 return elemdisplay[ nodeName ];
8904 var rtable = /^t(?:able|d|h)$/i,
8905 rroot = /^(?:body|html)$/i;
8907 if ( "getBoundingClientRect" in document.documentElement ) {
8908 jQuery.fn.offset = function( options ) {
8909 var elem = this[0], box;
8912 return this.each(function( i ) {
8913 jQuery.offset.setOffset( this, options, i );
8917 if ( !elem || !elem.ownerDocument ) {
8921 if ( elem === elem.ownerDocument.body ) {
8922 return jQuery.offset.bodyOffset( elem );
8926 box = elem.getBoundingClientRect();
8929 var doc = elem.ownerDocument,
8930 docElem = doc.documentElement;
8932 // Make sure we're not dealing with a disconnected DOM node
8933 if ( !box || !jQuery.contains( docElem, elem ) ) {
8934 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
8937 var body = doc.body,
8938 win = getWindow(doc),
8939 clientTop = docElem.clientTop || body.clientTop || 0,
8940 clientLeft = docElem.clientLeft || body.clientLeft || 0,
8941 scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
8942 scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
8943 top = box.top + scrollTop - clientTop,
8944 left = box.left + scrollLeft - clientLeft;
8946 return { top: top, left: left };
8950 jQuery.fn.offset = function( options ) {
8954 return this.each(function( i ) {
8955 jQuery.offset.setOffset( this, options, i );
8959 if ( !elem || !elem.ownerDocument ) {
8963 if ( elem === elem.ownerDocument.body ) {
8964 return jQuery.offset.bodyOffset( elem );
8968 offsetParent = elem.offsetParent,
8969 prevOffsetParent = elem,
8970 doc = elem.ownerDocument,
8971 docElem = doc.documentElement,
8973 defaultView = doc.defaultView,
8974 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
8975 top = elem.offsetTop,
8976 left = elem.offsetLeft;
8978 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
8979 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
8983 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
8984 top -= elem.scrollTop;
8985 left -= elem.scrollLeft;
8987 if ( elem === offsetParent ) {
8988 top += elem.offsetTop;
8989 left += elem.offsetLeft;
8991 if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
8992 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8993 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8996 prevOffsetParent = offsetParent;
8997 offsetParent = elem.offsetParent;
9000 if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
9001 top += parseFloat( computedStyle.borderTopWidth ) || 0;
9002 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
9005 prevComputedStyle = computedStyle;
9008 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
9009 top += body.offsetTop;
9010 left += body.offsetLeft;
9013 if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) {
9014 top += Math.max( docElem.scrollTop, body.scrollTop );
9015 left += Math.max( docElem.scrollLeft, body.scrollLeft );
9018 return { top: top, left: left };
9024 bodyOffset: function( body ) {
9025 var top = body.offsetTop,
9026 left = body.offsetLeft;
9028 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
9029 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
9030 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
9033 return { top: top, left: left };
9036 setOffset: function( elem, options, i ) {
9037 var position = jQuery.css( elem, "position" );
9039 // set position first, in-case top/left are set even on static elem
9040 if ( position === "static" ) {
9041 elem.style.position = "relative";
9044 var curElem = jQuery( elem ),
9045 curOffset = curElem.offset(),
9046 curCSSTop = jQuery.css( elem, "top" ),
9047 curCSSLeft = jQuery.css( elem, "left" ),
9048 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9049 props = {}, curPosition = {}, curTop, curLeft;
9051 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9052 if ( calculatePosition ) {
9053 curPosition = curElem.position();
9054 curTop = curPosition.top;
9055 curLeft = curPosition.left;
9057 curTop = parseFloat( curCSSTop ) || 0;
9058 curLeft = parseFloat( curCSSLeft ) || 0;
9061 if ( jQuery.isFunction( options ) ) {
9062 options = options.call( elem, i, curOffset );
9065 if ( options.top != null ) {
9066 props.top = ( options.top - curOffset.top ) + curTop;
9068 if ( options.left != null ) {
9069 props.left = ( options.left - curOffset.left ) + curLeft;
9072 if ( "using" in options ) {
9073 options.using.call( elem, props );
9075 curElem.css( props );
9083 position: function() {
9090 // Get *real* offsetParent
9091 offsetParent = this.offsetParent(),
9093 // Get correct offsets
9094 offset = this.offset(),
9095 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
9097 // Subtract element margins
9098 // note: when an element has margin: auto the offsetLeft and marginLeft
9099 // are the same in Safari causing offset.left to incorrectly be 0
9100 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
9101 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
9103 // Add offsetParent borders
9104 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
9105 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
9107 // Subtract the two offsets
9109 top: offset.top - parentOffset.top,
9110 left: offset.left - parentOffset.left
9114 offsetParent: function() {
9115 return this.map(function() {
9116 var offsetParent = this.offsetParent || document.body;
9117 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
9118 offsetParent = offsetParent.offsetParent;
9120 return offsetParent;
9126 // Create scrollLeft and scrollTop methods
9127 jQuery.each( ["Left", "Top"], function( i, name ) {
9128 var method = "scroll" + name;
9130 jQuery.fn[ method ] = function( val ) {
9133 if ( val === undefined ) {
9140 win = getWindow( elem );
9142 // Return the scroll offset
9143 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
9144 jQuery.support.boxModel && win.document.documentElement[ method ] ||
9145 win.document.body[ method ] :
9149 // Set the scroll offset
9150 return this.each(function() {
9151 win = getWindow( this );
9155 !i ? val : jQuery( win ).scrollLeft(),
9156 i ? val : jQuery( win ).scrollTop()
9160 this[ method ] = val;
9166 function getWindow( elem ) {
9167 return jQuery.isWindow( elem ) ?
9169 elem.nodeType === 9 ?
9170 elem.defaultView || elem.parentWindow :
9177 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
9178 jQuery.each([ "Height", "Width" ], function( i, name ) {
9180 var type = name.toLowerCase();
9182 // innerHeight and innerWidth
9183 jQuery.fn[ "inner" + name ] = function() {
9187 parseFloat( jQuery.css( elem, type, "padding" ) ) :
9192 // outerHeight and outerWidth
9193 jQuery.fn[ "outer" + name ] = function( margin ) {
9197 parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
9202 jQuery.fn[ type ] = function( size ) {
9203 // Get window width or height
9206 return size == null ? null : this;
9209 if ( jQuery.isFunction( size ) ) {
9210 return this.each(function( i ) {
9211 var self = jQuery( this );
9212 self[ type ]( size.call( this, i, self[ type ]() ) );
9216 if ( jQuery.isWindow( elem ) ) {
9217 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9218 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9219 var docElemProp = elem.document.documentElement[ "client" + name ],
9220 body = elem.document.body;
9221 return elem.document.compatMode === "CSS1Compat" && docElemProp ||
9222 body && body[ "client" + name ] || docElemProp;
9224 // Get document width or height
9225 } else if ( elem.nodeType === 9 ) {
9226 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9228 elem.documentElement["client" + name],
9229 elem.body["scroll" + name], elem.documentElement["scroll" + name],
9230 elem.body["offset" + name], elem.documentElement["offset" + name]
9233 // Get or set width or height on the element
9234 } else if ( size === undefined ) {
9235 var orig = jQuery.css( elem, type ),
9236 ret = parseFloat( orig );
9238 return jQuery.isNumeric( ret ) ? ret : orig;
9240 // Set the width or height on the element (default to pixels if value is unitless)
9242 return this.css( type, typeof size === "string" ? size : size + "px" );
9251 // Expose jQuery to the global object
9252 window.jQuery = window.$ = jQuery;
9254 // Expose jQuery as an AMD module, but only for AMD loaders that
9255 // understand the issues with loading multiple versions of jQuery
9256 // in a page that all might call define(). The loader will indicate
9257 // they have special allowances for multiple jQuery versions by
9258 // specifying define.amd.jQuery = true. Register as a named module,
9259 // since jQuery can be concatenated with other files that may use define,
9260 // but not use a proper concatenation script that understands anonymous
9261 // AMD modules. A named AMD is safest and most robust way to register.
9262 // Lowercase jquery is used because AMD module names are derived from
9263 // file names, and jQuery is normally delivered in a lowercase file name.
9264 // Do this after creating the global so that if an AMD module wants to call
9265 // noConflict to hide this version of jQuery, it will work.
9266 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
9267 define( "jquery", [], function () { return jQuery; } );