2 * jQuery JavaScript Library v1.6.4
5 * Copyright 2011, John Resig
6 * Dual licensed under the MIT or GPL Version 2 licenses.
7 * http://jquery.org/license
10 * http://sizzlejs.com/
11 * Copyright 2011, The Dojo Foundation
12 * Released under the MIT, BSD, and GPL Licenses.
14 * Date: Mon Sep 12 18:54:48 2011 -0400
16 (function( window, undefined ) {
18 // Use the correct document accordingly with window argument (sandbox)
19 var document = window.document,
20 navigator = window.navigator,
21 location = window.location;
22 var jQuery = (function() {
24 // Define a local copy of jQuery
25 var jQuery = function( selector, context ) {
26 // The jQuery object is actually just the init constructor 'enhanced'
27 return new jQuery.fn.init( selector, context, rootjQuery );
30 // Map over jQuery in case of overwrite
31 _jQuery = window.jQuery,
33 // Map over the $ in case of overwrite
36 // A central reference to the root jQuery(document)
39 // A simple way to check for HTML strings or ID strings
40 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
41 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
43 // Check if a string has a non-whitespace character in it
46 // Used for trimming whitespace
53 // Match a standalone tag
54 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
57 rvalidchars = /^[\],:{}\s]*$/,
58 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
59 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
60 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
63 rwebkit = /(webkit)[ \/]([\w.]+)/,
64 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
65 rmsie = /(msie) ([\w.]+)/,
66 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
68 // Matches dashed string for camelizing
69 rdashAlpha = /-([a-z]|[0-9])/ig,
72 // Used by jQuery.camelCase as callback to replace()
73 fcamelCase = function( all, letter ) {
74 return ( letter + "" ).toUpperCase();
77 // Keep a UserAgent string for use with jQuery.browser
78 userAgent = navigator.userAgent,
80 // For matching the engine and version of the browser
83 // The deferred used on DOM ready
86 // The ready event handler
89 // Save a reference to some core methods
90 toString = Object.prototype.toString,
91 hasOwn = Object.prototype.hasOwnProperty,
92 push = Array.prototype.push,
93 slice = Array.prototype.slice,
94 trim = String.prototype.trim,
95 indexOf = Array.prototype.indexOf,
97 // [[Class]] -> type pairs
100 jQuery.fn = jQuery.prototype = {
102 init: function( selector, context, rootjQuery ) {
103 var match, elem, ret, doc;
105 // Handle $(""), $(null), or $(undefined)
110 // Handle $(DOMElement)
111 if ( selector.nodeType ) {
112 this.context = this[0] = selector;
117 // The body element only exists once, optimize finding it
118 if ( selector === "body" && !context && document.body ) {
119 this.context = document;
120 this[0] = document.body;
121 this.selector = selector;
126 // Handle HTML strings
127 if ( typeof selector === "string" ) {
128 // Are we dealing with HTML string or an ID?
129 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
130 // Assume that strings that start and end with <> are HTML and skip the regex check
131 match = [ null, selector, null ];
134 match = quickExpr.exec( selector );
137 // Verify a match, and that no context was specified for #id
138 if ( match && (match[1] || !context) ) {
140 // HANDLE: $(html) -> $(array)
142 context = context instanceof jQuery ? context[0] : context;
143 doc = (context ? context.ownerDocument || context : document);
145 // If a single string is passed in and it's a single tag
146 // just do a createElement and skip the rest
147 ret = rsingleTag.exec( selector );
150 if ( jQuery.isPlainObject( context ) ) {
151 selector = [ document.createElement( ret[1] ) ];
152 jQuery.fn.attr.call( selector, context, true );
155 selector = [ doc.createElement( ret[1] ) ];
159 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
160 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
163 return jQuery.merge( this, selector );
167 elem = document.getElementById( match[2] );
169 // Check parentNode to catch when Blackberry 4.6 returns
170 // nodes that are no longer in the document #6963
171 if ( elem && elem.parentNode ) {
172 // Handle the case where IE and Opera return items
173 // by name instead of ID
174 if ( elem.id !== match[2] ) {
175 return rootjQuery.find( selector );
178 // Otherwise, we inject the element directly into the jQuery object
183 this.context = document;
184 this.selector = selector;
188 // HANDLE: $(expr, $(...))
189 } else if ( !context || context.jquery ) {
190 return (context || rootjQuery).find( selector );
192 // HANDLE: $(expr, context)
193 // (which is just equivalent to: $(context).find(expr)
195 return this.constructor( context ).find( selector );
198 // HANDLE: $(function)
199 // Shortcut for document ready
200 } else if ( jQuery.isFunction( selector ) ) {
201 return rootjQuery.ready( selector );
204 if (selector.selector !== undefined) {
205 this.selector = selector.selector;
206 this.context = selector.context;
209 return jQuery.makeArray( selector, this );
212 // Start with an empty selector
215 // The current version of jQuery being used
218 // The default length of a jQuery object is 0
221 // The number of elements contained in the matched element set
226 toArray: function() {
227 return slice.call( this, 0 );
230 // Get the Nth element in the matched element set OR
231 // Get the whole matched element set as a clean array
232 get: function( num ) {
235 // Return a 'clean' array
238 // Return just the object
239 ( num < 0 ? this[ this.length + num ] : this[ num ] );
242 // Take an array of elements and push it onto the stack
243 // (returning the new matched element set)
244 pushStack: function( elems, name, selector ) {
245 // Build a new jQuery matched element set
246 var ret = this.constructor();
248 if ( jQuery.isArray( elems ) ) {
249 push.apply( ret, elems );
252 jQuery.merge( ret, elems );
255 // Add the old object onto the stack (as a reference)
256 ret.prevObject = this;
258 ret.context = this.context;
260 if ( name === "find" ) {
261 ret.selector = this.selector + (this.selector ? " " : "") + selector;
263 ret.selector = this.selector + "." + name + "(" + selector + ")";
266 // Return the newly-formed element set
270 // Execute a callback for every element in the matched set.
271 // (You can seed the arguments with an array of args, but this is
272 // only used internally.)
273 each: function( callback, args ) {
274 return jQuery.each( this, callback, args );
277 ready: function( fn ) {
278 // Attach the listeners
282 readyList.done( fn );
290 this.slice( i, +i + 1 );
298 return this.eq( -1 );
302 return this.pushStack( slice.apply( this, arguments ),
303 "slice", slice.call(arguments).join(",") );
306 map: function( callback ) {
307 return this.pushStack( jQuery.map(this, function( elem, i ) {
308 return callback.call( elem, i, elem );
313 return this.prevObject || this.constructor(null);
316 // For internal use only.
317 // Behaves like an Array's method, not like a jQuery method.
323 // Give the init function the jQuery prototype for later instantiation
324 jQuery.fn.init.prototype = jQuery.fn;
326 jQuery.extend = jQuery.fn.extend = function() {
327 var options, name, src, copy, copyIsArray, clone,
328 target = arguments[0] || {},
330 length = arguments.length,
333 // Handle a deep copy situation
334 if ( typeof target === "boolean" ) {
336 target = arguments[1] || {};
337 // skip the boolean and the target
341 // Handle case when target is a string or something (possible in deep copy)
342 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
346 // extend jQuery itself if only one argument is passed
347 if ( length === i ) {
352 for ( ; i < length; i++ ) {
353 // Only deal with non-null/undefined values
354 if ( (options = arguments[ i ]) != null ) {
355 // Extend the base object
356 for ( name in options ) {
357 src = target[ name ];
358 copy = options[ name ];
360 // Prevent never-ending loop
361 if ( target === copy ) {
365 // Recurse if we're merging plain objects or arrays
366 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
369 clone = src && jQuery.isArray(src) ? src : [];
372 clone = src && jQuery.isPlainObject(src) ? src : {};
375 // Never move original objects, clone them
376 target[ name ] = jQuery.extend( deep, clone, copy );
378 // Don't bring in undefined values
379 } else if ( copy !== undefined ) {
380 target[ name ] = copy;
386 // Return the modified object
391 noConflict: function( deep ) {
392 if ( window.$ === jQuery ) {
396 if ( deep && window.jQuery === jQuery ) {
397 window.jQuery = _jQuery;
403 // Is the DOM ready to be used? Set to true once it occurs.
406 // A counter to track how many items to wait for before
407 // the ready event fires. See #6781
410 // Hold (or release) the ready event
411 holdReady: function( hold ) {
415 jQuery.ready( true );
419 // Handle when the DOM is ready
420 ready: function( wait ) {
421 // Either a released hold or an DOMready/load event and not yet ready
422 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
423 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
424 if ( !document.body ) {
425 return setTimeout( jQuery.ready, 1 );
428 // Remember that the DOM is ready
429 jQuery.isReady = true;
431 // If a normal DOM Ready event fired, decrement, and wait if need be
432 if ( wait !== true && --jQuery.readyWait > 0 ) {
436 // If there are functions bound, to execute
437 readyList.resolveWith( document, [ jQuery ] );
439 // Trigger any bound ready events
440 if ( jQuery.fn.trigger ) {
441 jQuery( document ).trigger( "ready" ).unbind( "ready" );
446 bindReady: function() {
451 readyList = jQuery._Deferred();
453 // Catch cases where $(document).ready() is called after the
454 // browser event has already occurred.
455 if ( document.readyState === "complete" ) {
456 // Handle it asynchronously to allow scripts the opportunity to delay ready
457 return setTimeout( jQuery.ready, 1 );
460 // Mozilla, Opera and webkit nightlies currently support this event
461 if ( document.addEventListener ) {
462 // Use the handy event callback
463 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
465 // A fallback to window.onload, that will always work
466 window.addEventListener( "load", jQuery.ready, false );
468 // If IE event model is used
469 } else if ( document.attachEvent ) {
470 // ensure firing before onload,
471 // maybe late but safe also for iframes
472 document.attachEvent( "onreadystatechange", DOMContentLoaded );
474 // A fallback to window.onload, that will always work
475 window.attachEvent( "onload", jQuery.ready );
477 // If IE and not a frame
478 // continually check to see if the document is ready
479 var toplevel = false;
482 toplevel = window.frameElement == null;
485 if ( document.documentElement.doScroll && toplevel ) {
491 // See test/unit/core.js for details concerning isFunction.
492 // Since version 1.3, DOM methods and functions like alert
493 // aren't supported. They return false on IE (#2968).
494 isFunction: function( obj ) {
495 return jQuery.type(obj) === "function";
498 isArray: Array.isArray || function( obj ) {
499 return jQuery.type(obj) === "array";
502 // A crude way of determining if an object is a window
503 isWindow: function( obj ) {
504 return obj && typeof obj === "object" && "setInterval" in obj;
507 isNaN: function( obj ) {
508 return obj == null || !rdigit.test( obj ) || isNaN( obj );
511 type: function( obj ) {
514 class2type[ toString.call(obj) ] || "object";
517 isPlainObject: function( obj ) {
518 // Must be an Object.
519 // Because of IE, we also have to check the presence of the constructor property.
520 // Make sure that DOM nodes and window objects don't pass through, as well
521 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
526 // Not own constructor property must be Object
527 if ( obj.constructor &&
528 !hasOwn.call(obj, "constructor") &&
529 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
533 // IE8,9 Will throw exceptions on certain host objects #9897
537 // Own properties are enumerated firstly, so to speed up,
538 // if last one is own, then all properties are own.
541 for ( key in obj ) {}
543 return key === undefined || hasOwn.call( obj, key );
546 isEmptyObject: function( obj ) {
547 for ( var name in obj ) {
553 error: function( msg ) {
557 parseJSON: function( data ) {
558 if ( typeof data !== "string" || !data ) {
562 // Make sure leading/trailing whitespace is removed (IE can't handle it)
563 data = jQuery.trim( data );
565 // Attempt to parse using the native JSON parser first
566 if ( window.JSON && window.JSON.parse ) {
567 return window.JSON.parse( data );
570 // Make sure the incoming data is actual JSON
571 // Logic borrowed from http://json.org/json2.js
572 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
573 .replace( rvalidtokens, "]" )
574 .replace( rvalidbraces, "")) ) {
576 return (new Function( "return " + data ))();
579 jQuery.error( "Invalid JSON: " + data );
582 // Cross-browser xml parsing
583 parseXML: function( data ) {
586 if ( window.DOMParser ) { // Standard
587 tmp = new DOMParser();
588 xml = tmp.parseFromString( data , "text/xml" );
590 xml = new ActiveXObject( "Microsoft.XMLDOM" );
597 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
598 jQuery.error( "Invalid XML: " + data );
605 // Evaluates a script in a global context
606 // Workarounds based on findings by Jim Driscoll
607 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
608 globalEval: function( data ) {
609 if ( data && rnotwhite.test( data ) ) {
610 // We use execScript on Internet Explorer
611 // We use an anonymous function so that context is window
612 // rather than jQuery in Firefox
613 ( window.execScript || function( data ) {
614 window[ "eval" ].call( window, data );
619 // Convert dashed to camelCase; used by the css and data modules
620 // Microsoft forgot to hump their vendor prefix (#9572)
621 camelCase: function( string ) {
622 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
625 nodeName: function( elem, name ) {
626 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
629 // args is for internal usage only
630 each: function( object, callback, args ) {
632 length = object.length,
633 isObj = length === undefined || jQuery.isFunction( object );
637 for ( name in object ) {
638 if ( callback.apply( object[ name ], args ) === false ) {
643 for ( ; i < length; ) {
644 if ( callback.apply( object[ i++ ], args ) === false ) {
650 // A special, fast, case for the most common use of each
653 for ( name in object ) {
654 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
659 for ( ; i < length; ) {
660 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
670 // Use native String.trim function wherever possible
673 return text == null ?
678 // Otherwise use our own trimming functionality
680 return text == null ?
682 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
685 // results is for internal usage only
686 makeArray: function( array, results ) {
687 var ret = results || [];
689 if ( array != null ) {
690 // The window, strings (and functions) also have 'length'
691 // The extra typeof function check is to prevent crashes
692 // in Safari 2 (See: #3039)
693 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
694 var type = jQuery.type( array );
696 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
697 push.call( ret, array );
699 jQuery.merge( ret, array );
706 inArray: function( elem, array ) {
712 return indexOf.call( array, elem );
715 for ( var i = 0, length = array.length; i < length; i++ ) {
716 if ( array[ i ] === elem ) {
724 merge: function( first, second ) {
725 var i = first.length,
728 if ( typeof second.length === "number" ) {
729 for ( var l = second.length; j < l; j++ ) {
730 first[ i++ ] = second[ j ];
734 while ( second[j] !== undefined ) {
735 first[ i++ ] = second[ j++ ];
744 grep: function( elems, callback, inv ) {
745 var ret = [], retVal;
748 // Go through the array, only saving the items
749 // that pass the validator function
750 for ( var i = 0, length = elems.length; i < length; i++ ) {
751 retVal = !!callback( elems[ i ], i );
752 if ( inv !== retVal ) {
753 ret.push( elems[ i ] );
760 // arg is for internal usage only
761 map: function( elems, callback, arg ) {
762 var value, key, ret = [],
764 length = elems.length,
765 // jquery objects are treated as arrays
766 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
768 // Go through the array, translating each of the items to their
770 for ( ; i < length; i++ ) {
771 value = callback( elems[ i ], i, arg );
773 if ( value != null ) {
774 ret[ ret.length ] = value;
778 // Go through every key on the object,
780 for ( key in elems ) {
781 value = callback( elems[ key ], key, arg );
783 if ( value != null ) {
784 ret[ ret.length ] = value;
789 // Flatten any nested arrays
790 return ret.concat.apply( [], ret );
793 // A global GUID counter for objects
796 // Bind a function to a context, optionally partially applying any
798 proxy: function( fn, context ) {
799 if ( typeof context === "string" ) {
800 var tmp = fn[ context ];
805 // Quick check to determine if target is callable, in the spec
806 // this throws a TypeError, but we will just return undefined.
807 if ( !jQuery.isFunction( fn ) ) {
812 var args = slice.call( arguments, 2 ),
814 return fn.apply( context, args.concat( slice.call( arguments ) ) );
817 // Set the guid of unique handler to the same of original handler, so it can be removed
818 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
823 // Mutifunctional method to get and set values to a collection
824 // The value/s can optionally be executed if it's a function
825 access: function( elems, key, value, exec, fn, pass ) {
826 var length = elems.length;
828 // Setting many attributes
829 if ( typeof key === "object" ) {
830 for ( var k in key ) {
831 jQuery.access( elems, k, key[k], exec, fn, value );
836 // Setting one attribute
837 if ( value !== undefined ) {
838 // Optionally, function values get executed if exec is true
839 exec = !pass && exec && jQuery.isFunction(value);
841 for ( var i = 0; i < length; i++ ) {
842 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
848 // Getting an attribute
849 return length ? fn( elems[0], key ) : undefined;
853 return (new Date()).getTime();
856 // Use of jQuery.browser is frowned upon.
857 // More details: http://docs.jquery.com/Utilities/jQuery.browser
858 uaMatch: function( ua ) {
859 ua = ua.toLowerCase();
861 var match = rwebkit.exec( ua ) ||
864 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
867 return { browser: match[1] || "", version: match[2] || "0" };
871 function jQuerySub( selector, context ) {
872 return new jQuerySub.fn.init( selector, context );
874 jQuery.extend( true, jQuerySub, this );
875 jQuerySub.superclass = this;
876 jQuerySub.fn = jQuerySub.prototype = this();
877 jQuerySub.fn.constructor = jQuerySub;
878 jQuerySub.sub = this.sub;
879 jQuerySub.fn.init = function init( selector, context ) {
880 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
881 context = jQuerySub( context );
884 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
886 jQuerySub.fn.init.prototype = jQuerySub.fn;
887 var rootjQuerySub = jQuerySub(document);
894 // Populate the class2type map
895 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
896 class2type[ "[object " + name + "]" ] = name.toLowerCase();
899 browserMatch = jQuery.uaMatch( userAgent );
900 if ( browserMatch.browser ) {
901 jQuery.browser[ browserMatch.browser ] = true;
902 jQuery.browser.version = browserMatch.version;
905 // Deprecated, use jQuery.browser.webkit instead
906 if ( jQuery.browser.webkit ) {
907 jQuery.browser.safari = true;
910 // IE doesn't match non-breaking spaces with \s
911 if ( rnotwhite.test( "\xA0" ) ) {
912 trimLeft = /^[\s\xA0]+/;
913 trimRight = /[\s\xA0]+$/;
916 // All jQuery objects should point back to these
917 rootjQuery = jQuery(document);
919 // Cleanup functions for the document ready method
920 if ( document.addEventListener ) {
921 DOMContentLoaded = function() {
922 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
926 } else if ( document.attachEvent ) {
927 DOMContentLoaded = function() {
928 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
929 if ( document.readyState === "complete" ) {
930 document.detachEvent( "onreadystatechange", DOMContentLoaded );
936 // The DOM ready check for Internet Explorer
937 function doScrollCheck() {
938 if ( jQuery.isReady ) {
943 // If IE is used, use the trick by Diego Perini
944 // http://javascript.nwbox.com/IEContentLoaded/
945 document.documentElement.doScroll("left");
947 setTimeout( doScrollCheck, 1 );
951 // and execute any waiting functions
960 var // Promise methods
961 promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
962 // Static reference to slice
963 sliceDeferred = [].slice;
966 // Create a simple deferred (one callbacks list)
967 _Deferred: function() {
968 var // callbacks list
970 // stored [ context , args ]
972 // to avoid firing when already doing so
974 // flag to know if the deferred has been cancelled
976 // the deferred itself
979 // done( f1, f2, ...)
982 var args = arguments,
992 for ( i = 0, length = args.length; i < length; i++ ) {
994 type = jQuery.type( elem );
995 if ( type === "array" ) {
996 deferred.done.apply( deferred, elem );
997 } else if ( type === "function" ) {
998 callbacks.push( elem );
1002 deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
1008 // resolve with given context and args
1009 resolveWith: function( context, args ) {
1010 if ( !cancelled && !fired && !firing ) {
1011 // make sure args are available (#8421)
1015 while( callbacks[ 0 ] ) {
1016 callbacks.shift().apply( context, args );
1020 fired = [ context, args ];
1027 // resolve with this as context and given arguments
1028 resolve: function() {
1029 deferred.resolveWith( this, arguments );
1033 // Has this deferred been resolved?
1034 isResolved: function() {
1035 return !!( firing || fired );
1039 cancel: function() {
1049 // Full fledged deferred (two callbacks list)
1050 Deferred: function( func ) {
1051 var deferred = jQuery._Deferred(),
1052 failDeferred = jQuery._Deferred(),
1054 // Add errorDeferred methods, then and promise
1055 jQuery.extend( deferred, {
1056 then: function( doneCallbacks, failCallbacks ) {
1057 deferred.done( doneCallbacks ).fail( failCallbacks );
1060 always: function() {
1061 return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
1063 fail: failDeferred.done,
1064 rejectWith: failDeferred.resolveWith,
1065 reject: failDeferred.resolve,
1066 isRejected: failDeferred.isResolved,
1067 pipe: function( fnDone, fnFail ) {
1068 return jQuery.Deferred(function( newDefer ) {
1070 done: [ fnDone, "resolve" ],
1071 fail: [ fnFail, "reject" ]
1072 }, function( handler, data ) {
1076 if ( jQuery.isFunction( fn ) ) {
1077 deferred[ handler ](function() {
1078 returned = fn.apply( this, arguments );
1079 if ( returned && jQuery.isFunction( returned.promise ) ) {
1080 returned.promise().then( newDefer.resolve, newDefer.reject );
1082 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1086 deferred[ handler ]( newDefer[ action ] );
1091 // Get a promise for this deferred
1092 // If obj is provided, the promise aspect is added to the object
1093 promise: function( obj ) {
1094 if ( obj == null ) {
1100 var i = promiseMethods.length;
1102 obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
1107 // Make sure only one callback list will be used
1108 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
1110 delete deferred.cancel;
1111 // Call given func if any
1113 func.call( deferred, deferred );
1119 when: function( firstParam ) {
1120 var args = arguments,
1122 length = args.length,
1124 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1127 function resolveFunc( i ) {
1128 return function( value ) {
1129 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1130 if ( !( --count ) ) {
1131 // Strange bug in FF4:
1132 // Values changed onto the arguments object sometimes end up as undefined values
1133 // outside the $.when method. Cloning the object into a fresh array solves the issue
1134 deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1139 for( ; i < length; i++ ) {
1140 if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1141 args[ i ].promise().then( resolveFunc(i), deferred.reject );
1147 deferred.resolveWith( deferred, args );
1149 } else if ( deferred !== firstParam ) {
1150 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1152 return deferred.promise();
1158 jQuery.support = (function() {
1160 var div = document.createElement( "div" ),
1161 documentElement = document.documentElement,
1180 // Preliminary tests
1181 div.setAttribute("className", "t");
1182 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1185 all = div.getElementsByTagName( "*" );
1186 a = div.getElementsByTagName( "a" )[ 0 ];
1188 // Can't get basic test support
1189 if ( !all || !all.length || !a ) {
1193 // First batch of supports tests
1194 select = document.createElement( "select" );
1195 opt = select.appendChild( document.createElement("option") );
1196 input = div.getElementsByTagName( "input" )[ 0 ];
1199 // IE strips leading whitespace when .innerHTML is used
1200 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1202 // Make sure that tbody elements aren't automatically inserted
1203 // IE will insert them into empty tables
1204 tbody: !div.getElementsByTagName( "tbody" ).length,
1206 // Make sure that link elements get serialized correctly by innerHTML
1207 // This requires a wrapper element in IE
1208 htmlSerialize: !!div.getElementsByTagName( "link" ).length,
1210 // Get the style information from getAttribute
1211 // (IE uses .cssText instead)
1212 style: /top/.test( a.getAttribute("style") ),
1214 // Make sure that URLs aren't manipulated
1215 // (IE normalizes it by default)
1216 hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
1218 // Make sure that element opacity exists
1219 // (IE uses filter instead)
1220 // Use a regex to work around a WebKit issue. See #5145
1221 opacity: /^0.55$/.test( a.style.opacity ),
1223 // Verify style float existence
1224 // (IE uses styleFloat instead of cssFloat)
1225 cssFloat: !!a.style.cssFloat,
1227 // Make sure that if no value is specified for a checkbox
1228 // that it defaults to "on".
1229 // (WebKit defaults to "" instead)
1230 checkOn: ( input.value === "on" ),
1232 // Make sure that a selected-by-default option has a working selected property.
1233 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1234 optSelected: opt.selected,
1236 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1237 getSetAttribute: div.className !== "t",
1239 // Will be defined later
1240 submitBubbles: true,
1241 changeBubbles: true,
1242 focusinBubbles: false,
1243 deleteExpando: true,
1245 inlineBlockNeedsLayout: false,
1246 shrinkWrapBlocks: false,
1247 reliableMarginRight: true
1250 // Make sure checked status is properly cloned
1251 input.checked = true;
1252 support.noCloneChecked = input.cloneNode( true ).checked;
1254 // Make sure that the options inside disabled selects aren't marked as disabled
1255 // (WebKit marks them as disabled)
1256 select.disabled = true;
1257 support.optDisabled = !opt.disabled;
1259 // Test to see if it's possible to delete an expando from an element
1260 // Fails in Internet Explorer
1264 support.deleteExpando = false;
1267 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1268 div.attachEvent( "onclick", function() {
1269 // Cloning a node shouldn't copy over any
1270 // bound event handlers (IE does this)
1271 support.noCloneEvent = false;
1273 div.cloneNode( true ).fireEvent( "onclick" );
1276 // Check if a radio maintains it's value
1277 // after being appended to the DOM
1278 input = document.createElement("input");
1280 input.setAttribute("type", "radio");
1281 support.radioValue = input.value === "t";
1283 input.setAttribute("checked", "checked");
1284 div.appendChild( input );
1285 fragment = document.createDocumentFragment();
1286 fragment.appendChild( div.firstChild );
1288 // WebKit doesn't clone checked state correctly in fragments
1289 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1293 // Figure out if the W3C box model works as expected
1294 div.style.width = div.style.paddingLeft = "1px";
1296 body = document.getElementsByTagName( "body" )[ 0 ];
1297 // We use our own, invisible, body unless the body is already present
1298 // in which case we use a div (#9239)
1299 testElement = document.createElement( body ? "div" : "body" );
1300 testElementStyle = {
1301 visibility: "hidden",
1309 jQuery.extend( testElementStyle, {
1310 position: "absolute",
1315 for ( i in testElementStyle ) {
1316 testElement.style[ i ] = testElementStyle[ i ];
1318 testElement.appendChild( div );
1319 testElementParent = body || documentElement;
1320 testElementParent.insertBefore( testElement, testElementParent.firstChild );
1322 // Check if a disconnected checkbox will retain its checked
1323 // value of true after appended to the DOM (IE6/7)
1324 support.appendChecked = input.checked;
1326 support.boxModel = div.offsetWidth === 2;
1328 if ( "zoom" in div.style ) {
1329 // Check if natively block-level elements act like inline-block
1330 // elements when setting their display to 'inline' and giving
1332 // (IE < 8 does this)
1333 div.style.display = "inline";
1335 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1337 // Check if elements with layout shrink-wrap their children
1339 div.style.display = "";
1340 div.innerHTML = "<div style='width:4px;'></div>";
1341 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1344 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1345 tds = div.getElementsByTagName( "td" );
1347 // Check if table cells still have offsetWidth/Height when they are set
1348 // to display:none and there are still other visible table cells in a
1349 // table row; if so, offsetWidth/Height are not reliable for use when
1350 // determining if an element has been hidden directly using
1351 // display:none (it is still safe to use offsets if a parent element is
1352 // hidden; don safety goggles and see bug #4512 for more information).
1353 // (only IE 8 fails this test)
1354 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1356 tds[ 0 ].style.display = "";
1357 tds[ 1 ].style.display = "none";
1359 // Check if empty table cells still have offsetWidth/Height
1360 // (IE < 8 fail this test)
1361 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1364 // Check if div with explicit width and no margin-right incorrectly
1365 // gets computed margin-right based on width of container. For more
1366 // info see bug #3333
1367 // Fails in WebKit before Feb 2011 nightlies
1368 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1369 if ( document.defaultView && document.defaultView.getComputedStyle ) {
1370 marginDiv = document.createElement( "div" );
1371 marginDiv.style.width = "0";
1372 marginDiv.style.marginRight = "0";
1373 div.appendChild( marginDiv );
1374 support.reliableMarginRight =
1375 ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1378 // Remove the body element we added
1379 testElement.innerHTML = "";
1380 testElementParent.removeChild( testElement );
1382 // Technique from Juriy Zaytsev
1383 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1384 // We only care about the case where non-standard event systems
1385 // are used, namely in IE. Short-circuiting here helps us to
1386 // avoid an eval call (in setAttribute) which can cause CSP
1387 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1388 if ( div.attachEvent ) {
1394 eventName = "on" + i;
1395 isSupported = ( eventName in div );
1396 if ( !isSupported ) {
1397 div.setAttribute( eventName, "return;" );
1398 isSupported = ( typeof div[ eventName ] === "function" );
1400 support[ i + "Bubbles" ] = isSupported;
1404 // Null connected elements to avoid leaks in IE
1405 testElement = fragment = select = opt = body = marginDiv = div = input = null;
1410 // Keep track of boxModel
1411 jQuery.boxModel = jQuery.support.boxModel;
1416 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1417 rmultiDash = /([A-Z])/g;
1422 // Please use with caution
1425 // Unique for each copy of jQuery on the page
1426 // Non-digits removed to match rinlinejQuery
1427 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1429 // The following elements throw uncatchable exceptions if you
1430 // attempt to add expando properties to them.
1433 // Ban all objects except for Flash (which handle expandos)
1434 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1438 hasData: function( elem ) {
1439 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1441 return !!elem && !isEmptyDataObject( elem );
1444 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1445 if ( !jQuery.acceptData( elem ) ) {
1450 internalKey = jQuery.expando,
1451 getByName = typeof name === "string",
1453 // We have to handle DOM nodes and JS objects differently because IE6-7
1454 // can't GC object references properly across the DOM-JS boundary
1455 isNode = elem.nodeType,
1457 // Only DOM nodes need the global jQuery cache; JS object data is
1458 // attached directly to the object so GC can occur automatically
1459 cache = isNode ? jQuery.cache : elem,
1461 // Only defining an ID for JS objects if its cache already exists allows
1462 // the code to shortcut on the same path as a DOM node with no cache
1463 id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
1465 // Avoid doing any more work than we need to when trying to get data on an
1466 // object that has no data at all
1467 if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
1472 // Only DOM nodes need a new unique ID for each element since their data
1473 // ends up in the global cache
1475 elem[ jQuery.expando ] = id = ++jQuery.uuid;
1477 id = jQuery.expando;
1481 if ( !cache[ id ] ) {
1484 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1485 // metadata on plain JS objects when the object is serialized using
1488 cache[ id ].toJSON = jQuery.noop;
1492 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1493 // shallow copied over onto the existing cache
1494 if ( typeof name === "object" || typeof name === "function" ) {
1496 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1498 cache[ id ] = jQuery.extend(cache[ id ], name);
1502 thisCache = cache[ id ];
1504 // Internal jQuery data is stored in a separate object inside the object's data
1505 // cache in order to avoid key collisions between internal data and user-defined
1508 if ( !thisCache[ internalKey ] ) {
1509 thisCache[ internalKey ] = {};
1512 thisCache = thisCache[ internalKey ];
1515 if ( data !== undefined ) {
1516 thisCache[ jQuery.camelCase( name ) ] = data;
1519 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
1520 // not attempt to inspect the internal events object using jQuery.data, as this
1521 // internal data object is undocumented and subject to change.
1522 if ( name === "events" && !thisCache[name] ) {
1523 return thisCache[ internalKey ] && thisCache[ internalKey ].events;
1526 // Check for both converted-to-camel and non-converted data property names
1527 // If a data property was specified
1530 // First Try to find as-is property data
1531 ret = thisCache[ name ];
1533 // Test for null|undefined property data
1534 if ( ret == null ) {
1536 // Try to find the camelCased property
1537 ret = thisCache[ jQuery.camelCase( name ) ];
1546 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1547 if ( !jQuery.acceptData( elem ) ) {
1553 // Reference to internal data cache key
1554 internalKey = jQuery.expando,
1556 isNode = elem.nodeType,
1558 // See jQuery.data for more information
1559 cache = isNode ? jQuery.cache : elem,
1561 // See jQuery.data for more information
1562 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1564 // If there is already no cache entry for this object, there is no
1565 // purpose in continuing
1566 if ( !cache[ id ] ) {
1572 thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
1576 // Support interoperable removal of hyphenated or camelcased keys
1577 if ( !thisCache[ name ] ) {
1578 name = jQuery.camelCase( name );
1581 delete thisCache[ name ];
1583 // If there is no data left in the cache, we want to continue
1584 // and let the cache object itself get destroyed
1585 if ( !isEmptyDataObject(thisCache) ) {
1591 // See jQuery.data for more information
1593 delete cache[ id ][ internalKey ];
1595 // Don't destroy the parent cache unless the internal data object
1596 // had been the only thing left in it
1597 if ( !isEmptyDataObject(cache[ id ]) ) {
1602 var internalCache = cache[ id ][ internalKey ];
1604 // Browsers that fail expando deletion also refuse to delete expandos on
1605 // the window, but it will allow it on all other JS objects; other browsers
1607 // Ensure that `cache` is not a window object #10080
1608 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1614 // We destroyed the entire user cache at once because it's faster than
1615 // iterating through each key, but we need to continue to persist internal
1616 // data if it existed
1617 if ( internalCache ) {
1619 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1620 // metadata on plain JS objects when the object is serialized using
1623 cache[ id ].toJSON = jQuery.noop;
1626 cache[ id ][ internalKey ] = internalCache;
1628 // Otherwise, we need to eliminate the expando on the node to avoid
1629 // false lookups in the cache for entries that no longer exist
1630 } else if ( isNode ) {
1631 // IE does not allow us to delete expando properties from nodes,
1632 // nor does it have a removeAttribute function on Document nodes;
1633 // we must handle all of these cases
1634 if ( jQuery.support.deleteExpando ) {
1635 delete elem[ jQuery.expando ];
1636 } else if ( elem.removeAttribute ) {
1637 elem.removeAttribute( jQuery.expando );
1639 elem[ jQuery.expando ] = null;
1644 // For internal use only.
1645 _data: function( elem, name, data ) {
1646 return jQuery.data( elem, name, data, true );
1649 // A method for determining if a DOM node can handle the data expando
1650 acceptData: function( elem ) {
1651 if ( elem.nodeName ) {
1652 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1655 return !(match === true || elem.getAttribute("classid") !== match);
1664 data: function( key, value ) {
1667 if ( typeof key === "undefined" ) {
1668 if ( this.length ) {
1669 data = jQuery.data( this[0] );
1671 if ( this[0].nodeType === 1 ) {
1672 var attr = this[0].attributes, name;
1673 for ( var i = 0, l = attr.length; i < l; i++ ) {
1674 name = attr[i].name;
1676 if ( name.indexOf( "data-" ) === 0 ) {
1677 name = jQuery.camelCase( name.substring(5) );
1679 dataAttr( this[0], name, data[ name ] );
1687 } else if ( typeof key === "object" ) {
1688 return this.each(function() {
1689 jQuery.data( this, key );
1693 var parts = key.split(".");
1694 parts[1] = parts[1] ? "." + parts[1] : "";
1696 if ( value === undefined ) {
1697 data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1699 // Try to fetch any internally stored data first
1700 if ( data === undefined && this.length ) {
1701 data = jQuery.data( this[0], key );
1702 data = dataAttr( this[0], key, data );
1705 return data === undefined && parts[1] ?
1706 this.data( parts[0] ) :
1710 return this.each(function() {
1711 var $this = jQuery( this ),
1712 args = [ parts[0], value ];
1714 $this.triggerHandler( "setData" + parts[1] + "!", args );
1715 jQuery.data( this, key, value );
1716 $this.triggerHandler( "changeData" + parts[1] + "!", args );
1721 removeData: function( key ) {
1722 return this.each(function() {
1723 jQuery.removeData( this, key );
1728 function dataAttr( elem, key, data ) {
1729 // If nothing was found internally, try to fetch any
1730 // data from the HTML5 data-* attribute
1731 if ( data === undefined && elem.nodeType === 1 ) {
1733 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1735 data = elem.getAttribute( name );
1737 if ( typeof data === "string" ) {
1739 data = data === "true" ? true :
1740 data === "false" ? false :
1741 data === "null" ? null :
1742 !jQuery.isNaN( data ) ? parseFloat( data ) :
1743 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1747 // Make sure we set the data so it isn't changed later
1748 jQuery.data( elem, key, data );
1758 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1759 // property to be considered empty objects; this property always exists in
1760 // order to make sure JSON.stringify does not expose internal metadata
1761 function isEmptyDataObject( obj ) {
1762 for ( var name in obj ) {
1763 if ( name !== "toJSON" ) {
1774 function handleQueueMarkDefer( elem, type, src ) {
1775 var deferDataKey = type + "defer",
1776 queueDataKey = type + "queue",
1777 markDataKey = type + "mark",
1778 defer = jQuery.data( elem, deferDataKey, undefined, true );
1780 ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
1781 ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
1782 // Give room for hard-coded callbacks to fire first
1783 // and eventually mark/queue something else on the element
1784 setTimeout( function() {
1785 if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
1786 !jQuery.data( elem, markDataKey, undefined, true ) ) {
1787 jQuery.removeData( elem, deferDataKey, true );
1796 _mark: function( elem, type ) {
1798 type = (type || "fx") + "mark";
1799 jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
1803 _unmark: function( force, elem, type ) {
1804 if ( force !== true ) {
1810 type = type || "fx";
1811 var key = type + "mark",
1812 count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
1814 jQuery.data( elem, key, count, true );
1816 jQuery.removeData( elem, key, true );
1817 handleQueueMarkDefer( elem, type, "mark" );
1822 queue: function( elem, type, data ) {
1824 type = (type || "fx") + "queue";
1825 var q = jQuery.data( elem, type, undefined, true );
1826 // Speed up dequeue by getting out quickly if this is just a lookup
1828 if ( !q || jQuery.isArray(data) ) {
1829 q = jQuery.data( elem, type, jQuery.makeArray(data), true );
1838 dequeue: function( elem, type ) {
1839 type = type || "fx";
1841 var queue = jQuery.queue( elem, type ),
1845 // If the fx queue is dequeued, always remove the progress sentinel
1846 if ( fn === "inprogress" ) {
1851 // Add a progress sentinel to prevent the fx queue from being
1852 // automatically dequeued
1853 if ( type === "fx" ) {
1854 queue.unshift("inprogress");
1857 fn.call(elem, function() {
1858 jQuery.dequeue(elem, type);
1862 if ( !queue.length ) {
1863 jQuery.removeData( elem, type + "queue", true );
1864 handleQueueMarkDefer( elem, type, "queue" );
1870 queue: function( type, data ) {
1871 if ( typeof type !== "string" ) {
1876 if ( data === undefined ) {
1877 return jQuery.queue( this[0], type );
1879 return this.each(function() {
1880 var queue = jQuery.queue( this, type, data );
1882 if ( type === "fx" && queue[0] !== "inprogress" ) {
1883 jQuery.dequeue( this, type );
1887 dequeue: function( type ) {
1888 return this.each(function() {
1889 jQuery.dequeue( this, type );
1892 // Based off of the plugin by Clint Helfers, with permission.
1893 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1894 delay: function( time, type ) {
1895 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
1896 type = type || "fx";
1898 return this.queue( type, function() {
1900 setTimeout(function() {
1901 jQuery.dequeue( elem, type );
1905 clearQueue: function( type ) {
1906 return this.queue( type || "fx", [] );
1908 // Get a promise resolved when queues of a certain type
1909 // are emptied (fx is the type by default)
1910 promise: function( type, object ) {
1911 if ( typeof type !== "string" ) {
1915 type = type || "fx";
1916 var defer = jQuery.Deferred(),
1918 i = elements.length,
1920 deferDataKey = type + "defer",
1921 queueDataKey = type + "queue",
1922 markDataKey = type + "mark",
1924 function resolve() {
1925 if ( !( --count ) ) {
1926 defer.resolveWith( elements, [ elements ] );
1930 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
1931 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
1932 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
1933 jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
1935 tmp.done( resolve );
1939 return defer.promise();
1946 var rclass = /[\n\t\r]/g,
1949 rtype = /^(?:button|input)$/i,
1950 rfocusable = /^(?:button|input|object|select|textarea)$/i,
1951 rclickable = /^a(?:rea)?$/i,
1952 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
1956 attr: function( name, value ) {
1957 return jQuery.access( this, name, value, true, jQuery.attr );
1960 removeAttr: function( name ) {
1961 return this.each(function() {
1962 jQuery.removeAttr( this, name );
1966 prop: function( name, value ) {
1967 return jQuery.access( this, name, value, true, jQuery.prop );
1970 removeProp: function( name ) {
1971 name = jQuery.propFix[ name ] || name;
1972 return this.each(function() {
1973 // try/catch handles cases where IE balks (such as removing a property on window)
1975 this[ name ] = undefined;
1976 delete this[ name ];
1981 addClass: function( value ) {
1982 var classNames, i, l, elem,
1985 if ( jQuery.isFunction( value ) ) {
1986 return this.each(function( j ) {
1987 jQuery( this ).addClass( value.call(this, j, this.className) );
1991 if ( value && typeof value === "string" ) {
1992 classNames = value.split( rspace );
1994 for ( i = 0, l = this.length; i < l; i++ ) {
1997 if ( elem.nodeType === 1 ) {
1998 if ( !elem.className && classNames.length === 1 ) {
1999 elem.className = value;
2002 setClass = " " + elem.className + " ";
2004 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2005 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2006 setClass += classNames[ c ] + " ";
2009 elem.className = jQuery.trim( setClass );
2018 removeClass: function( value ) {
2019 var classNames, i, l, elem, className, c, cl;
2021 if ( jQuery.isFunction( value ) ) {
2022 return this.each(function( j ) {
2023 jQuery( this ).removeClass( value.call(this, j, this.className) );
2027 if ( (value && typeof value === "string") || value === undefined ) {
2028 classNames = (value || "").split( rspace );
2030 for ( i = 0, l = this.length; i < l; i++ ) {
2033 if ( elem.nodeType === 1 && elem.className ) {
2035 className = (" " + elem.className + " ").replace( rclass, " " );
2036 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2037 className = className.replace(" " + classNames[ c ] + " ", " ");
2039 elem.className = jQuery.trim( className );
2042 elem.className = "";
2051 toggleClass: function( value, stateVal ) {
2052 var type = typeof value,
2053 isBool = typeof stateVal === "boolean";
2055 if ( jQuery.isFunction( value ) ) {
2056 return this.each(function( i ) {
2057 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2061 return this.each(function() {
2062 if ( type === "string" ) {
2063 // toggle individual class names
2066 self = jQuery( this ),
2068 classNames = value.split( rspace );
2070 while ( (className = classNames[ i++ ]) ) {
2071 // check each className given, space seperated list
2072 state = isBool ? state : !self.hasClass( className );
2073 self[ state ? "addClass" : "removeClass" ]( className );
2076 } else if ( type === "undefined" || type === "boolean" ) {
2077 if ( this.className ) {
2078 // store className if set
2079 jQuery._data( this, "__className__", this.className );
2082 // toggle whole className
2083 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2088 hasClass: function( selector ) {
2089 var className = " " + selector + " ";
2090 for ( var i = 0, l = this.length; i < l; i++ ) {
2091 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2099 val: function( value ) {
2103 if ( !arguments.length ) {
2105 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2107 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2113 return typeof ret === "string" ?
2114 // handle most common string cases
2115 ret.replace(rreturn, "") :
2116 // handle cases where value is null/undef or number
2117 ret == null ? "" : ret;
2123 var isFunction = jQuery.isFunction( value );
2125 return this.each(function( i ) {
2126 var self = jQuery(this), val;
2128 if ( this.nodeType !== 1 ) {
2133 val = value.call( this, i, self.val() );
2138 // Treat null/undefined as ""; convert numbers to string
2139 if ( val == null ) {
2141 } else if ( typeof val === "number" ) {
2143 } else if ( jQuery.isArray( val ) ) {
2144 val = jQuery.map(val, function ( value ) {
2145 return value == null ? "" : value + "";
2149 hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2151 // If set returns undefined, fall back to normal setting
2152 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2162 get: function( elem ) {
2163 // attributes.value is undefined in Blackberry 4.7 but
2164 // uses .value. See #6932
2165 var val = elem.attributes.value;
2166 return !val || val.specified ? elem.value : elem.text;
2170 get: function( elem ) {
2172 index = elem.selectedIndex,
2174 options = elem.options,
2175 one = elem.type === "select-one";
2177 // Nothing was selected
2182 // Loop through all the selected options
2183 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
2184 var option = options[ i ];
2186 // Don't return options that are disabled or in a disabled optgroup
2187 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2188 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2190 // Get the specific value for the option
2191 value = jQuery( option ).val();
2193 // We don't need an array for one selects
2198 // Multi-Selects return an array
2199 values.push( value );
2203 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2204 if ( one && !values.length && options.length ) {
2205 return jQuery( options[ index ] ).val();
2211 set: function( elem, value ) {
2212 var values = jQuery.makeArray( value );
2214 jQuery(elem).find("option").each(function() {
2215 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2218 if ( !values.length ) {
2219 elem.selectedIndex = -1;
2238 // Always normalize to ensure hook usage
2239 tabindex: "tabIndex"
2242 attr: function( elem, name, value, pass ) {
2243 var nType = elem.nodeType;
2245 // don't get/set attributes on text, comment and attribute nodes
2246 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2250 if ( pass && name in jQuery.attrFn ) {
2251 return jQuery( elem )[ name ]( value );
2254 // Fallback to prop when attributes are not supported
2255 if ( !("getAttribute" in elem) ) {
2256 return jQuery.prop( elem, name, value );
2260 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2262 // Normalize the name if needed
2264 name = jQuery.attrFix[ name ] || name;
2266 hooks = jQuery.attrHooks[ name ];
2269 // Use boolHook for boolean attributes
2270 if ( rboolean.test( name ) ) {
2273 // Use nodeHook if available( IE6/7 )
2274 } else if ( nodeHook ) {
2280 if ( value !== undefined ) {
2282 if ( value === null ) {
2283 jQuery.removeAttr( elem, name );
2286 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2290 elem.setAttribute( name, "" + value );
2294 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2299 ret = elem.getAttribute( name );
2301 // Non-existent attributes return null, we normalize to undefined
2302 return ret === null ?
2308 removeAttr: function( elem, name ) {
2310 if ( elem.nodeType === 1 ) {
2311 name = jQuery.attrFix[ name ] || name;
2313 jQuery.attr( elem, name, "" );
2314 elem.removeAttribute( name );
2316 // Set corresponding property to false for boolean attributes
2317 if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
2318 elem[ propName ] = false;
2325 set: function( elem, value ) {
2326 // We can't allow the type property to be changed (since it causes problems in IE)
2327 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2328 jQuery.error( "type property can't be changed" );
2329 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2330 // Setting the type on a radio button after the value resets the value in IE6-9
2331 // Reset value to it's default in case type is set after value
2332 // This is for element creation
2333 var val = elem.value;
2334 elem.setAttribute( "type", value );
2342 // Use the value property for back compat
2343 // Use the nodeHook for button elements in IE6/7 (#1954)
2345 get: function( elem, name ) {
2346 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2347 return nodeHook.get( elem, name );
2349 return name in elem ?
2353 set: function( elem, value, name ) {
2354 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2355 return nodeHook.set( elem, value, name );
2357 // Does not return so that setAttribute is also used
2364 tabindex: "tabIndex",
2365 readonly: "readOnly",
2367 "class": "className",
2368 maxlength: "maxLength",
2369 cellspacing: "cellSpacing",
2370 cellpadding: "cellPadding",
2374 frameborder: "frameBorder",
2375 contenteditable: "contentEditable"
2378 prop: function( elem, name, value ) {
2379 var nType = elem.nodeType;
2381 // don't get/set properties on text, comment and attribute nodes
2382 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2387 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2390 // Fix name and attach hooks
2391 name = jQuery.propFix[ name ] || name;
2392 hooks = jQuery.propHooks[ name ];
2395 if ( value !== undefined ) {
2396 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2400 return (elem[ name ] = value);
2404 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2408 return elem[ name ];
2415 get: function( elem ) {
2416 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2417 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2418 var attributeNode = elem.getAttributeNode("tabindex");
2420 return attributeNode && attributeNode.specified ?
2421 parseInt( attributeNode.value, 10 ) :
2422 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2430 // Add the tabindex propHook to attrHooks for back-compat
2431 jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
2433 // Hook for boolean attributes
2435 get: function( elem, name ) {
2436 // Align boolean attributes with corresponding properties
2437 // Fall back to attribute presence where some booleans are not supported
2439 return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
2440 name.toLowerCase() :
2443 set: function( elem, value, name ) {
2445 if ( value === false ) {
2446 // Remove boolean attributes when set to false
2447 jQuery.removeAttr( elem, name );
2449 // value is true since we know at this point it's type boolean and not false
2450 // Set boolean attributes to the same name and set the DOM property
2451 propName = jQuery.propFix[ name ] || name;
2452 if ( propName in elem ) {
2453 // Only set the IDL specifically if it already exists on the element
2454 elem[ propName ] = true;
2457 elem.setAttribute( name, name.toLowerCase() );
2463 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2464 if ( !jQuery.support.getSetAttribute ) {
2466 // Use this for any attribute in IE6/7
2467 // This fixes almost every IE6/7 issue
2468 nodeHook = jQuery.valHooks.button = {
2469 get: function( elem, name ) {
2471 ret = elem.getAttributeNode( name );
2472 // Return undefined if nodeValue is empty string
2473 return ret && ret.nodeValue !== "" ?
2477 set: function( elem, value, name ) {
2478 // Set the existing or create a new attribute node
2479 var ret = elem.getAttributeNode( name );
2481 ret = document.createAttribute( name );
2482 elem.setAttributeNode( ret );
2484 return (ret.nodeValue = value + "");
2488 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2489 // This is for removals
2490 jQuery.each([ "width", "height" ], function( i, name ) {
2491 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2492 set: function( elem, value ) {
2493 if ( value === "" ) {
2494 elem.setAttribute( name, "auto" );
2503 // Some attributes require a special call on IE
2504 if ( !jQuery.support.hrefNormalized ) {
2505 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2506 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2507 get: function( elem ) {
2508 var ret = elem.getAttribute( name, 2 );
2509 return ret === null ? undefined : ret;
2515 if ( !jQuery.support.style ) {
2516 jQuery.attrHooks.style = {
2517 get: function( elem ) {
2518 // Return undefined in the case of empty string
2519 // Normalize to lowercase since IE uppercases css property names
2520 return elem.style.cssText.toLowerCase() || undefined;
2522 set: function( elem, value ) {
2523 return (elem.style.cssText = "" + value);
2528 // Safari mis-reports the default selected property of an option
2529 // Accessing the parent's selectedIndex property fixes it
2530 if ( !jQuery.support.optSelected ) {
2531 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2532 get: function( elem ) {
2533 var parent = elem.parentNode;
2536 parent.selectedIndex;
2538 // Make sure that it also works with optgroups, see #5701
2539 if ( parent.parentNode ) {
2540 parent.parentNode.selectedIndex;
2548 // Radios and checkboxes getter/setter
2549 if ( !jQuery.support.checkOn ) {
2550 jQuery.each([ "radio", "checkbox" ], function() {
2551 jQuery.valHooks[ this ] = {
2552 get: function( elem ) {
2553 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2554 return elem.getAttribute("value") === null ? "on" : elem.value;
2559 jQuery.each([ "radio", "checkbox" ], function() {
2560 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2561 set: function( elem, value ) {
2562 if ( jQuery.isArray( value ) ) {
2563 return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
2572 var rnamespaces = /\.(.*)$/,
2573 rformElems = /^(?:textarea|input|select)$/i,
2576 rescape = /[^\w\s.|`]/g,
2577 fcleanup = function( nm ) {
2578 return nm.replace(rescape, "\\$&");
2582 * A number of helper functions used for managing events.
2583 * Many of the ideas behind this code originated from
2584 * Dean Edwards' addEvent library.
2588 // Bind an event to an element
2589 // Original by Dean Edwards
2590 add: function( elem, types, handler, data ) {
2591 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2595 if ( handler === false ) {
2596 handler = returnFalse;
2597 } else if ( !handler ) {
2598 // Fixes bug #7229. Fix recommended by jdalton
2602 var handleObjIn, handleObj;
2604 if ( handler.handler ) {
2605 handleObjIn = handler;
2606 handler = handleObjIn.handler;
2609 // Make sure that the function being executed has a unique ID
2610 if ( !handler.guid ) {
2611 handler.guid = jQuery.guid++;
2614 // Init the element's event structure
2615 var elemData = jQuery._data( elem );
2617 // If no elemData is found then we must be trying to bind to one of the
2618 // banned noData elements
2623 var events = elemData.events,
2624 eventHandle = elemData.handle;
2627 elemData.events = events = {};
2630 if ( !eventHandle ) {
2631 elemData.handle = eventHandle = function( e ) {
2632 // Discard the second event of a jQuery.event.trigger() and
2633 // when an event is called after a page has unloaded
2634 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2635 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2640 // Add elem as a property of the handle function
2641 // This is to prevent a memory leak with non-native events in IE.
2642 eventHandle.elem = elem;
2644 // Handle multiple events separated by a space
2645 // jQuery(...).bind("mouseover mouseout", fn);
2646 types = types.split(" ");
2648 var type, i = 0, namespaces;
2650 while ( (type = types[ i++ ]) ) {
2651 handleObj = handleObjIn ?
2652 jQuery.extend({}, handleObjIn) :
2653 { handler: handler, data: data };
2655 // Namespaced event handlers
2656 if ( type.indexOf(".") > -1 ) {
2657 namespaces = type.split(".");
2658 type = namespaces.shift();
2659 handleObj.namespace = namespaces.slice(0).sort().join(".");
2663 handleObj.namespace = "";
2666 handleObj.type = type;
2667 if ( !handleObj.guid ) {
2668 handleObj.guid = handler.guid;
2671 // Get the current list of functions bound to this event
2672 var handlers = events[ type ],
2673 special = jQuery.event.special[ type ] || {};
2675 // Init the event handler queue
2677 handlers = events[ type ] = [];
2679 // Check for a special event handler
2680 // Only use addEventListener/attachEvent if the special
2681 // events handler returns false
2682 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2683 // Bind the global event handler to the element
2684 if ( elem.addEventListener ) {
2685 elem.addEventListener( type, eventHandle, false );
2687 } else if ( elem.attachEvent ) {
2688 elem.attachEvent( "on" + type, eventHandle );
2693 if ( special.add ) {
2694 special.add.call( elem, handleObj );
2696 if ( !handleObj.handler.guid ) {
2697 handleObj.handler.guid = handler.guid;
2701 // Add the function to the element's handler list
2702 handlers.push( handleObj );
2704 // Keep track of which events have been used, for event optimization
2705 jQuery.event.global[ type ] = true;
2708 // Nullify elem to prevent memory leaks in IE
2714 // Detach an event or set of events from an element
2715 remove: function( elem, types, handler, pos ) {
2716 // don't do events on text and comment nodes
2717 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2721 if ( handler === false ) {
2722 handler = returnFalse;
2725 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2726 elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2727 events = elemData && elemData.events;
2729 if ( !elemData || !events ) {
2733 // types is actually an event object here
2734 if ( types && types.type ) {
2735 handler = types.handler;
2739 // Unbind all events for the element
2740 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
2741 types = types || "";
2743 for ( type in events ) {
2744 jQuery.event.remove( elem, type + types );
2750 // Handle multiple events separated by a space
2751 // jQuery(...).unbind("mouseover mouseout", fn);
2752 types = types.split(" ");
2754 while ( (type = types[ i++ ]) ) {
2757 all = type.indexOf(".") < 0;
2761 // Namespaced event handlers
2762 namespaces = type.split(".");
2763 type = namespaces.shift();
2765 namespace = new RegExp("(^|\\.)" +
2766 jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
2769 eventType = events[ type ];
2776 for ( j = 0; j < eventType.length; j++ ) {
2777 handleObj = eventType[ j ];
2779 if ( all || namespace.test( handleObj.namespace ) ) {
2780 jQuery.event.remove( elem, origType, handleObj.handler, j );
2781 eventType.splice( j--, 1 );
2788 special = jQuery.event.special[ type ] || {};
2790 for ( j = pos || 0; j < eventType.length; j++ ) {
2791 handleObj = eventType[ j ];
2793 if ( handler.guid === handleObj.guid ) {
2794 // remove the given handler for the given type
2795 if ( all || namespace.test( handleObj.namespace ) ) {
2796 if ( pos == null ) {
2797 eventType.splice( j--, 1 );
2800 if ( special.remove ) {
2801 special.remove.call( elem, handleObj );
2805 if ( pos != null ) {
2811 // remove generic event handler if no more handlers exist
2812 if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
2813 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2814 jQuery.removeEvent( elem, type, elemData.handle );
2818 delete events[ type ];
2822 // Remove the expando if it's no longer used
2823 if ( jQuery.isEmptyObject( events ) ) {
2824 var handle = elemData.handle;
2829 delete elemData.events;
2830 delete elemData.handle;
2832 if ( jQuery.isEmptyObject( elemData ) ) {
2833 jQuery.removeData( elem, undefined, true );
2838 // Events that are safe to short-circuit if no handlers are attached.
2839 // Native DOM events should not be added, they may have inline handlers.
2846 trigger: function( event, data, elem, onlyHandlers ) {
2847 // Event object or event type
2848 var type = event.type || event,
2852 if ( type.indexOf("!") >= 0 ) {
2853 // Exclusive events trigger only for the exact event (no namespaces)
2854 type = type.slice(0, -1);
2858 if ( type.indexOf(".") >= 0 ) {
2859 // Namespaced trigger; create a regexp to match event type in handle()
2860 namespaces = type.split(".");
2861 type = namespaces.shift();
2865 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2866 // No jQuery handlers for this event type, and it can't have inline handlers
2870 // Caller can pass in an Event, Object, or just an event type string
2871 event = typeof event === "object" ?
2872 // jQuery.Event object
2873 event[ jQuery.expando ] ? event :
2875 new jQuery.Event( type, event ) :
2876 // Just the event type (string)
2877 new jQuery.Event( type );
2880 event.exclusive = exclusive;
2881 event.namespace = namespaces.join(".");
2882 event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
2884 // triggerHandler() and global events don't bubble or run the default action
2885 if ( onlyHandlers || !elem ) {
2886 event.preventDefault();
2887 event.stopPropagation();
2890 // Handle a global trigger
2892 // TODO: Stop taunting the data cache; remove global events and always attach to document
2893 jQuery.each( jQuery.cache, function() {
2894 // internalKey variable is just used to make it easier to find
2895 // and potentially change this stuff later; currently it just
2896 // points to jQuery.expando
2897 var internalKey = jQuery.expando,
2898 internalCache = this[ internalKey ];
2899 if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
2900 jQuery.event.trigger( event, data, internalCache.handle.elem );
2906 // Don't do events on text and comment nodes
2907 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2911 // Clean up the event in case it is being reused
2912 event.result = undefined;
2913 event.target = elem;
2915 // Clone any incoming data and prepend the event, creating the handler arg list
2916 data = data != null ? jQuery.makeArray( data ) : [];
2917 data.unshift( event );
2920 // IE doesn't like method names with a colon (#3533, #8272)
2921 ontype = type.indexOf(":") < 0 ? "on" + type : "";
2923 // Fire event on the current element, then bubble up the DOM tree
2925 var handle = jQuery._data( cur, "handle" );
2927 event.currentTarget = cur;
2929 handle.apply( cur, data );
2932 // Trigger an inline bound script
2933 if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
2934 event.result = false;
2935 event.preventDefault();
2938 // Bubble up to document, then to window
2939 cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
2940 } while ( cur && !event.isPropagationStopped() );
2942 // If nobody prevented the default action, do it now
2943 if ( !event.isDefaultPrevented() ) {
2945 special = jQuery.event.special[ type ] || {};
2947 if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
2948 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2950 // Call a native DOM method on the target with the same name name as the event.
2951 // Can't use an .isFunction)() check here because IE6/7 fails that test.
2952 // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
2954 if ( ontype && elem[ type ] ) {
2955 // Don't re-trigger an onFOO event when we call its FOO() method
2956 old = elem[ ontype ];
2959 elem[ ontype ] = null;
2962 jQuery.event.triggered = type;
2965 } catch ( ieError ) {}
2968 elem[ ontype ] = old;
2971 jQuery.event.triggered = undefined;
2975 return event.result;
2978 handle: function( event ) {
2979 event = jQuery.event.fix( event || window.event );
2980 // Snapshot the handlers list since a called handler may add/remove events.
2981 var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
2982 run_all = !event.exclusive && !event.namespace,
2983 args = Array.prototype.slice.call( arguments, 0 );
2985 // Use the fix-ed Event rather than the (read-only) native event
2987 event.currentTarget = this;
2989 for ( var j = 0, l = handlers.length; j < l; j++ ) {
2990 var handleObj = handlers[ j ];
2992 // Triggered event must 1) be non-exclusive and have no namespace, or
2993 // 2) have namespace(s) a subset or equal to those in the bound event.
2994 if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
2995 // Pass in a reference to the handler function itself
2996 // So that we can later remove it
2997 event.handler = handleObj.handler;
2998 event.data = handleObj.data;
2999 event.handleObj = handleObj;
3001 var ret = handleObj.handler.apply( this, args );
3003 if ( ret !== undefined ) {
3005 if ( ret === false ) {
3006 event.preventDefault();
3007 event.stopPropagation();
3011 if ( event.isImmediatePropagationStopped() ) {
3016 return event.result;
3019 props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
3021 fix: function( event ) {
3022 if ( event[ jQuery.expando ] ) {
3026 // store a copy of the original event object
3027 // and "clone" to set read-only properties
3028 var originalEvent = event;
3029 event = jQuery.Event( originalEvent );
3031 for ( var i = this.props.length, prop; i; ) {
3032 prop = this.props[ --i ];
3033 event[ prop ] = originalEvent[ prop ];
3036 // Fix target property, if necessary
3037 if ( !event.target ) {
3038 // Fixes #1925 where srcElement might not be defined either
3039 event.target = event.srcElement || document;
3042 // check if target is a textnode (safari)
3043 if ( event.target.nodeType === 3 ) {
3044 event.target = event.target.parentNode;
3047 // Add relatedTarget, if necessary
3048 if ( !event.relatedTarget && event.fromElement ) {
3049 event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
3052 // Calculate pageX/Y if missing and clientX/Y available
3053 if ( event.pageX == null && event.clientX != null ) {
3054 var eventDocument = event.target.ownerDocument || document,
3055 doc = eventDocument.documentElement,
3056 body = eventDocument.body;
3058 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
3059 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
3062 // Add which for key events
3063 if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
3064 event.which = event.charCode != null ? event.charCode : event.keyCode;
3067 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
3068 if ( !event.metaKey && event.ctrlKey ) {
3069 event.metaKey = event.ctrlKey;
3072 // Add which for click: 1 === left; 2 === middle; 3 === right
3073 // Note: button is not normalized, so don't use it
3074 if ( !event.which && event.button !== undefined ) {
3075 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
3081 // Deprecated, use jQuery.guid instead
3084 // Deprecated, use jQuery.proxy instead
3085 proxy: jQuery.proxy,
3089 // Make sure the ready event is setup
3090 setup: jQuery.bindReady,
3091 teardown: jQuery.noop
3095 add: function( handleObj ) {
3096 jQuery.event.add( this,
3097 liveConvert( handleObj.origType, handleObj.selector ),
3098 jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
3101 remove: function( handleObj ) {
3102 jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
3107 setup: function( data, namespaces, eventHandle ) {
3108 // We only want to do this special case on windows
3109 if ( jQuery.isWindow( this ) ) {
3110 this.onbeforeunload = eventHandle;
3114 teardown: function( namespaces, eventHandle ) {
3115 if ( this.onbeforeunload === eventHandle ) {
3116 this.onbeforeunload = null;
3123 jQuery.removeEvent = document.removeEventListener ?
3124 function( elem, type, handle ) {
3125 if ( elem.removeEventListener ) {
3126 elem.removeEventListener( type, handle, false );
3129 function( elem, type, handle ) {
3130 if ( elem.detachEvent ) {
3131 elem.detachEvent( "on" + type, handle );
3135 jQuery.Event = function( src, props ) {
3136 // Allow instantiation without the 'new' keyword
3137 if ( !this.preventDefault ) {
3138 return new jQuery.Event( src, props );
3142 if ( src && src.type ) {
3143 this.originalEvent = src;
3144 this.type = src.type;
3146 // Events bubbling up the document may have been marked as prevented
3147 // by a handler lower down the tree; reflect the correct value.
3148 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
3149 src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
3156 // Put explicitly provided properties onto the event object
3158 jQuery.extend( this, props );
3161 // timeStamp is buggy for some events on Firefox(#3843)
3162 // So we won't rely on the native value
3163 this.timeStamp = jQuery.now();
3166 this[ jQuery.expando ] = true;
3169 function returnFalse() {
3172 function returnTrue() {
3176 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3177 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3178 jQuery.Event.prototype = {
3179 preventDefault: function() {
3180 this.isDefaultPrevented = returnTrue;
3182 var e = this.originalEvent;
3187 // if preventDefault exists run it on the original event
3188 if ( e.preventDefault ) {
3191 // otherwise set the returnValue property of the original event to false (IE)
3193 e.returnValue = false;
3196 stopPropagation: function() {
3197 this.isPropagationStopped = returnTrue;
3199 var e = this.originalEvent;
3203 // if stopPropagation exists run it on the original event
3204 if ( e.stopPropagation ) {
3205 e.stopPropagation();
3207 // otherwise set the cancelBubble property of the original event to true (IE)
3208 e.cancelBubble = true;
3210 stopImmediatePropagation: function() {
3211 this.isImmediatePropagationStopped = returnTrue;
3212 this.stopPropagation();
3214 isDefaultPrevented: returnFalse,
3215 isPropagationStopped: returnFalse,
3216 isImmediatePropagationStopped: returnFalse
3219 // Checks if an event happened on an element within another element
3220 // Used in jQuery.event.special.mouseenter and mouseleave handlers
3221 var withinElement = function( event ) {
3223 // Check if mouse(over|out) are still within the same parent element
3224 var related = event.relatedTarget,
3226 eventType = event.type;
3228 event.type = event.data;
3230 if ( related !== this ) {
3233 inside = jQuery.contains( this, related );
3238 jQuery.event.handle.apply( this, arguments );
3240 event.type = eventType;
3245 // In case of event delegation, we only need to rename the event.type,
3246 // liveHandler will take care of the rest.
3247 delegate = function( event ) {
3248 event.type = event.data;
3249 jQuery.event.handle.apply( this, arguments );
3252 // Create mouseenter and mouseleave events
3254 mouseenter: "mouseover",
3255 mouseleave: "mouseout"
3256 }, function( orig, fix ) {
3257 jQuery.event.special[ orig ] = {
3258 setup: function( data ) {
3259 jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
3261 teardown: function( data ) {
3262 jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
3267 // submit delegation
3268 if ( !jQuery.support.submitBubbles ) {
3270 jQuery.event.special.submit = {
3271 setup: function( data, namespaces ) {
3272 if ( !jQuery.nodeName( this, "form" ) ) {
3273 jQuery.event.add(this, "click.specialSubmit", function( e ) {
3274 // Avoid triggering error on non-existent type attribute in IE VML (#7071)
3275 var elem = e.target,
3276 type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3278 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
3279 trigger( "submit", this, arguments );
3283 jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
3284 var elem = e.target,
3285 type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3287 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
3288 trigger( "submit", this, arguments );
3297 teardown: function( namespaces ) {
3298 jQuery.event.remove( this, ".specialSubmit" );
3304 // change delegation, happens here so we have bind.
3305 if ( !jQuery.support.changeBubbles ) {
3309 getVal = function( elem ) {
3310 var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
3313 if ( type === "radio" || type === "checkbox" ) {
3316 } else if ( type === "select-multiple" ) {
3317 val = elem.selectedIndex > -1 ?
3318 jQuery.map( elem.options, function( elem ) {
3319 return elem.selected;
3323 } else if ( jQuery.nodeName( elem, "select" ) ) {
3324 val = elem.selectedIndex;
3330 testChange = function testChange( e ) {
3331 var elem = e.target, data, val;
3333 if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
3337 data = jQuery._data( elem, "_change_data" );
3340 // the current data will be also retrieved by beforeactivate
3341 if ( e.type !== "focusout" || elem.type !== "radio" ) {
3342 jQuery._data( elem, "_change_data", val );
3345 if ( data === undefined || val === data ) {
3349 if ( data != null || val ) {
3351 e.liveFired = undefined;
3352 jQuery.event.trigger( e, arguments[1], elem );
3356 jQuery.event.special.change = {
3358 focusout: testChange,
3360 beforedeactivate: testChange,
3362 click: function( e ) {
3363 var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3365 if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
3366 testChange.call( this, e );
3370 // Change has to be called before submit
3371 // Keydown will be called before keypress, which is used in submit-event delegation
3372 keydown: function( e ) {
3373 var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3375 if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
3376 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
3377 type === "select-multiple" ) {
3378 testChange.call( this, e );
3382 // Beforeactivate happens also before the previous element is blurred
3383 // with this event you can't trigger a change event, but you can store
3385 beforeactivate: function( e ) {
3386 var elem = e.target;
3387 jQuery._data( elem, "_change_data", getVal(elem) );
3391 setup: function( data, namespaces ) {
3392 if ( this.type === "file" ) {
3396 for ( var type in changeFilters ) {
3397 jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
3400 return rformElems.test( this.nodeName );
3403 teardown: function( namespaces ) {
3404 jQuery.event.remove( this, ".specialChange" );
3406 return rformElems.test( this.nodeName );
3410 changeFilters = jQuery.event.special.change.filters;
3412 // Handle when the input is .focus()'d
3413 changeFilters.focus = changeFilters.beforeactivate;
3416 function trigger( type, elem, args ) {
3417 // Piggyback on a donor event to simulate a different one.
3418 // Fake originalEvent to avoid donor's stopPropagation, but if the
3419 // simulated event prevents default then we do the same on the donor.
3420 // Don't pass args or remember liveFired; they apply to the donor event.
3421 var event = jQuery.extend( {}, args[ 0 ] );
3423 event.originalEvent = {};
3424 event.liveFired = undefined;
3425 jQuery.event.handle.call( elem, event );
3426 if ( event.isDefaultPrevented() ) {
3427 args[ 0 ].preventDefault();
3431 // Create "bubbling" focus and blur events
3432 if ( !jQuery.support.focusinBubbles ) {
3433 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3435 // Attach a single capturing handler while someone wants focusin/focusout
3438 jQuery.event.special[ fix ] = {
3440 if ( attaches++ === 0 ) {
3441 document.addEventListener( orig, handler, true );
3444 teardown: function() {
3445 if ( --attaches === 0 ) {
3446 document.removeEventListener( orig, handler, true );
3451 function handler( donor ) {
3452 // Donor event is always a native one; fix it and switch its type.
3453 // Let focusin/out handler cancel the donor focus/blur event.
3454 var e = jQuery.event.fix( donor );
3456 e.originalEvent = {};
3457 jQuery.event.trigger( e, null, e.target );
3458 if ( e.isDefaultPrevented() ) {
3459 donor.preventDefault();
3465 jQuery.each(["bind", "one"], function( i, name ) {
3466 jQuery.fn[ name ] = function( type, data, fn ) {
3469 // Handle object literals
3470 if ( typeof type === "object" ) {
3471 for ( var key in type ) {
3472 this[ name ](key, data, type[key], fn);
3477 if ( arguments.length === 2 || data === false ) {
3482 if ( name === "one" ) {
3483 handler = function( event ) {
3484 jQuery( this ).unbind( event, handler );
3485 return fn.apply( this, arguments );
3487 handler.guid = fn.guid || jQuery.guid++;
3492 if ( type === "unload" && name !== "one" ) {
3493 this.one( type, data, fn );
3496 for ( var i = 0, l = this.length; i < l; i++ ) {
3497 jQuery.event.add( this[i], type, handler, data );
3506 unbind: function( type, fn ) {
3507 // Handle object literals
3508 if ( typeof type === "object" && !type.preventDefault ) {
3509 for ( var key in type ) {
3510 this.unbind(key, type[key]);
3514 for ( var i = 0, l = this.length; i < l; i++ ) {
3515 jQuery.event.remove( this[i], type, fn );
3522 delegate: function( selector, types, data, fn ) {
3523 return this.live( types, data, fn, selector );
3526 undelegate: function( selector, types, fn ) {
3527 if ( arguments.length === 0 ) {
3528 return this.unbind( "live" );
3531 return this.die( types, null, fn, selector );
3535 trigger: function( type, data ) {
3536 return this.each(function() {
3537 jQuery.event.trigger( type, data, this );
3541 triggerHandler: function( type, data ) {
3543 return jQuery.event.trigger( type, data, this[0], true );
3547 toggle: function( fn ) {
3548 // Save reference to arguments for access in closure
3549 var args = arguments,
3550 guid = fn.guid || jQuery.guid++,
3552 toggler = function( event ) {
3553 // Figure out which function to execute
3554 var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3555 jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3557 // Make sure that clicks stop
3558 event.preventDefault();
3560 // and execute the function
3561 return args[ lastToggle ].apply( this, arguments ) || false;
3564 // link all the functions, so any of them can unbind this click handler
3565 toggler.guid = guid;
3566 while ( i < args.length ) {
3567 args[ i++ ].guid = guid;
3570 return this.click( toggler );
3573 hover: function( fnOver, fnOut ) {
3574 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3581 mouseenter: "mouseover",
3582 mouseleave: "mouseout"
3585 jQuery.each(["live", "die"], function( i, name ) {
3586 jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
3587 var type, i = 0, match, namespaces, preType,
3588 selector = origSelector || this.selector,
3589 context = origSelector ? this : jQuery( this.context );
3591 if ( typeof types === "object" && !types.preventDefault ) {
3592 for ( var key in types ) {
3593 context[ name ]( key, data, types[key], selector );
3599 if ( name === "die" && !types &&
3600 origSelector && origSelector.charAt(0) === "." ) {
3602 context.unbind( origSelector );
3607 if ( data === false || jQuery.isFunction( data ) ) {
3608 fn = data || returnFalse;
3612 types = (types || "").split(" ");
3614 while ( (type = types[ i++ ]) != null ) {
3615 match = rnamespaces.exec( type );
3619 namespaces = match[0];
3620 type = type.replace( rnamespaces, "" );
3623 if ( type === "hover" ) {
3624 types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
3630 if ( liveMap[ type ] ) {
3631 types.push( liveMap[ type ] + namespaces );
3632 type = type + namespaces;
3635 type = (liveMap[ type ] || type) + namespaces;
3638 if ( name === "live" ) {
3639 // bind live handler
3640 for ( var j = 0, l = context.length; j < l; j++ ) {
3641 jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
3642 { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
3646 // unbind live handler
3647 context.unbind( "live." + liveConvert( type, selector ), fn );
3655 function liveHandler( event ) {
3656 var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
3659 events = jQuery._data( this, "events" );
3661 // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
3662 if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
3666 if ( event.namespace ) {
3667 namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
3670 event.liveFired = this;
3672 var live = events.live.slice(0);
3674 for ( j = 0; j < live.length; j++ ) {
3675 handleObj = live[j];
3677 if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
3678 selectors.push( handleObj.selector );
3681 live.splice( j--, 1 );
3685 match = jQuery( event.target ).closest( selectors, event.currentTarget );
3687 for ( i = 0, l = match.length; i < l; i++ ) {
3690 for ( j = 0; j < live.length; j++ ) {
3691 handleObj = live[j];
3693 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
3697 // Those two events require additional checking
3698 if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
3699 event.type = handleObj.preType;
3700 related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
3702 // Make sure not to accidentally match a child element with the same selector
3703 if ( related && jQuery.contains( elem, related ) ) {
3708 if ( !related || related !== elem ) {
3709 elems.push({ elem: elem, handleObj: handleObj, level: close.level });
3715 for ( i = 0, l = elems.length; i < l; i++ ) {
3718 if ( maxLevel && match.level > maxLevel ) {
3722 event.currentTarget = match.elem;
3723 event.data = match.handleObj.data;
3724 event.handleObj = match.handleObj;
3726 ret = match.handleObj.origHandler.apply( match.elem, arguments );
3728 if ( ret === false || event.isPropagationStopped() ) {
3729 maxLevel = match.level;
3731 if ( ret === false ) {
3734 if ( event.isImmediatePropagationStopped() ) {
3743 function liveConvert( type, selector ) {
3744 return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
3747 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3748 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3749 "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
3751 // Handle event binding
3752 jQuery.fn[ name ] = function( data, fn ) {
3758 return arguments.length > 0 ?
3759 this.bind( name, data, fn ) :
3760 this.trigger( name );
3763 if ( jQuery.attrFn ) {
3764 jQuery.attrFn[ name ] = true;
3771 * Sizzle CSS Selector Engine
3772 * Copyright 2011, The Dojo Foundation
3773 * Released under the MIT, BSD, and GPL Licenses.
3774 * More information: http://sizzlejs.com/
3778 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3780 toString = Object.prototype.toString,
3781 hasDuplicate = false,
3782 baseHasDuplicate = true,
3786 // Here we check if the JavaScript engine is using some sort of
3787 // optimization where it does not always call our comparision
3788 // function. If that is the case, discard the hasDuplicate value.
3789 // Thus far that includes Google Chrome.
3790 [0, 0].sort(function() {
3791 baseHasDuplicate = false;
3795 var Sizzle = function( selector, context, results, seed ) {
3796 results = results || [];
3797 context = context || document;
3799 var origContext = context;
3801 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3805 if ( !selector || typeof selector !== "string" ) {
3809 var m, set, checkSet, extra, ret, cur, pop, i,
3811 contextXML = Sizzle.isXML( context ),
3815 // Reset the position of the chunker regexp (start from head)
3818 m = chunker.exec( soFar );
3832 if ( parts.length > 1 && origPOS.exec( selector ) ) {
3834 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3835 set = posProcess( parts[0] + parts[1], context );
3838 set = Expr.relative[ parts[0] ] ?
3840 Sizzle( parts.shift(), context );
3842 while ( parts.length ) {
3843 selector = parts.shift();
3845 if ( Expr.relative[ selector ] ) {
3846 selector += parts.shift();
3849 set = posProcess( selector, set );
3854 // Take a shortcut and set the context if the root selector is an ID
3855 // (but not if it'll be faster if the inner selector is an ID)
3856 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
3857 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
3859 ret = Sizzle.find( parts.shift(), context, contextXML );
3860 context = ret.expr ?
3861 Sizzle.filter( ret.expr, ret.set )[0] :
3867 { expr: parts.pop(), set: makeArray(seed) } :
3868 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
3871 Sizzle.filter( ret.expr, ret.set ) :
3874 if ( parts.length > 0 ) {
3875 checkSet = makeArray( set );
3881 while ( parts.length ) {
3885 if ( !Expr.relative[ cur ] ) {
3891 if ( pop == null ) {
3895 Expr.relative[ cur ]( checkSet, pop, contextXML );
3899 checkSet = parts = [];
3908 Sizzle.error( cur || selector );
3911 if ( toString.call(checkSet) === "[object Array]" ) {
3913 results.push.apply( results, checkSet );
3915 } else if ( context && context.nodeType === 1 ) {
3916 for ( i = 0; checkSet[i] != null; i++ ) {
3917 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
3918 results.push( set[i] );
3923 for ( i = 0; checkSet[i] != null; i++ ) {
3924 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
3925 results.push( set[i] );
3931 makeArray( checkSet, results );
3935 Sizzle( extra, origContext, results, seed );
3936 Sizzle.uniqueSort( results );
3942 Sizzle.uniqueSort = function( results ) {
3944 hasDuplicate = baseHasDuplicate;
3945 results.sort( sortOrder );
3947 if ( hasDuplicate ) {
3948 for ( var i = 1; i < results.length; i++ ) {
3949 if ( results[i] === results[ i - 1 ] ) {
3950 results.splice( i--, 1 );
3959 Sizzle.matches = function( expr, set ) {
3960 return Sizzle( expr, null, null, set );
3963 Sizzle.matchesSelector = function( node, expr ) {
3964 return Sizzle( expr, null, null, [node] ).length > 0;
3967 Sizzle.find = function( expr, context, isXML ) {
3974 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
3976 type = Expr.order[i];
3978 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
3979 var left = match[1];
3980 match.splice( 1, 1 );
3982 if ( left.substr( left.length - 1 ) !== "\\" ) {
3983 match[1] = (match[1] || "").replace( rBackslash, "" );
3984 set = Expr.find[ type ]( match, context, isXML );
3986 if ( set != null ) {
3987 expr = expr.replace( Expr.match[ type ], "" );
3995 set = typeof context.getElementsByTagName !== "undefined" ?
3996 context.getElementsByTagName( "*" ) :
4000 return { set: set, expr: expr };
4003 Sizzle.filter = function( expr, set, inplace, not ) {
4004 var match, anyFound,
4008 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
4010 while ( expr && set.length ) {
4011 for ( var type in Expr.filter ) {
4012 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
4014 filter = Expr.filter[ type ],
4021 if ( left.substr( left.length - 1 ) === "\\" ) {
4025 if ( curLoop === result ) {
4029 if ( Expr.preFilter[ type ] ) {
4030 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
4033 anyFound = found = true;
4035 } else if ( match === true ) {
4041 for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
4043 found = filter( item, match, i, curLoop );
4044 var pass = not ^ !!found;
4046 if ( inplace && found != null ) {
4054 } else if ( pass ) {
4055 result.push( item );
4062 if ( found !== undefined ) {
4067 expr = expr.replace( Expr.match[ type ], "" );
4078 // Improper expression
4079 if ( expr === old ) {
4080 if ( anyFound == null ) {
4081 Sizzle.error( expr );
4094 Sizzle.error = function( msg ) {
4095 throw "Syntax error, unrecognized expression: " + msg;
4098 var Expr = Sizzle.selectors = {
4099 order: [ "ID", "NAME", "TAG" ],
4102 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4103 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4104 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4105 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4106 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4107 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4108 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4109 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4115 "class": "className",
4120 href: function( elem ) {
4121 return elem.getAttribute( "href" );
4123 type: function( elem ) {
4124 return elem.getAttribute( "type" );
4129 "+": function(checkSet, part){
4130 var isPartStr = typeof part === "string",
4131 isTag = isPartStr && !rNonWord.test( part ),
4132 isPartStrNotTag = isPartStr && !isTag;
4135 part = part.toLowerCase();
4138 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
4139 if ( (elem = checkSet[i]) ) {
4140 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
4142 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
4148 if ( isPartStrNotTag ) {
4149 Sizzle.filter( part, checkSet, true );
4153 ">": function( checkSet, part ) {
4155 isPartStr = typeof part === "string",
4157 l = checkSet.length;
4159 if ( isPartStr && !rNonWord.test( part ) ) {
4160 part = part.toLowerCase();
4162 for ( ; i < l; i++ ) {
4166 var parent = elem.parentNode;
4167 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
4172 for ( ; i < l; i++ ) {
4176 checkSet[i] = isPartStr ?
4178 elem.parentNode === part;
4183 Sizzle.filter( part, checkSet, true );
4188 "": function(checkSet, part, isXML){
4193 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4194 part = part.toLowerCase();
4196 checkFn = dirNodeCheck;
4199 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
4202 "~": function( checkSet, part, isXML ) {
4207 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4208 part = part.toLowerCase();
4210 checkFn = dirNodeCheck;
4213 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
4218 ID: function( match, context, isXML ) {
4219 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4220 var m = context.getElementById(match[1]);
4221 // Check parentNode to catch when Blackberry 4.6 returns
4222 // nodes that are no longer in the document #6963
4223 return m && m.parentNode ? [m] : [];
4227 NAME: function( match, context ) {
4228 if ( typeof context.getElementsByName !== "undefined" ) {
4230 results = context.getElementsByName( match[1] );
4232 for ( var i = 0, l = results.length; i < l; i++ ) {
4233 if ( results[i].getAttribute("name") === match[1] ) {
4234 ret.push( results[i] );
4238 return ret.length === 0 ? null : ret;
4242 TAG: function( match, context ) {
4243 if ( typeof context.getElementsByTagName !== "undefined" ) {
4244 return context.getElementsByTagName( match[1] );
4249 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
4250 match = " " + match[1].replace( rBackslash, "" ) + " ";
4256 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
4258 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
4260 result.push( elem );
4263 } else if ( inplace ) {
4272 ID: function( match ) {
4273 return match[1].replace( rBackslash, "" );
4276 TAG: function( match, curLoop ) {
4277 return match[1].replace( rBackslash, "" ).toLowerCase();
4280 CHILD: function( match ) {
4281 if ( match[1] === "nth" ) {
4283 Sizzle.error( match[0] );
4286 match[2] = match[2].replace(/^\+|\s*/g, '');
4288 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4289 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4290 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
4291 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
4293 // calculate the numbers (first)n+(last) including if they are negative
4294 match[2] = (test[1] + (test[2] || 1)) - 0;
4295 match[3] = test[3] - 0;
4297 else if ( match[2] ) {
4298 Sizzle.error( match[0] );
4301 // TODO: Move to normal caching system
4307 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
4308 var name = match[1] = match[1].replace( rBackslash, "" );
4310 if ( !isXML && Expr.attrMap[name] ) {
4311 match[1] = Expr.attrMap[name];
4314 // Handle if an un-quoted value was used
4315 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
4317 if ( match[2] === "~=" ) {
4318 match[4] = " " + match[4] + " ";
4324 PSEUDO: function( match, curLoop, inplace, result, not ) {
4325 if ( match[1] === "not" ) {
4326 // If we're dealing with a complex expression, or a simple one
4327 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
4328 match[3] = Sizzle(match[3], null, null, curLoop);
4331 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
4334 result.push.apply( result, ret );
4340 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
4347 POS: function( match ) {
4348 match.unshift( true );
4355 enabled: function( elem ) {
4356 return elem.disabled === false && elem.type !== "hidden";
4359 disabled: function( elem ) {
4360 return elem.disabled === true;
4363 checked: function( elem ) {
4364 return elem.checked === true;
4367 selected: function( elem ) {
4368 // Accessing this property makes selected-by-default
4369 // options in Safari work properly
4370 if ( elem.parentNode ) {
4371 elem.parentNode.selectedIndex;
4374 return elem.selected === true;
4377 parent: function( elem ) {
4378 return !!elem.firstChild;
4381 empty: function( elem ) {
4382 return !elem.firstChild;
4385 has: function( elem, i, match ) {
4386 return !!Sizzle( match[3], elem ).length;
4389 header: function( elem ) {
4390 return (/h\d/i).test( elem.nodeName );
4393 text: function( elem ) {
4394 var attr = elem.getAttribute( "type" ), type = elem.type;
4395 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4396 // use getAttribute instead to test this case
4397 return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
4400 radio: function( elem ) {
4401 return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
4404 checkbox: function( elem ) {
4405 return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
4408 file: function( elem ) {
4409 return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
4412 password: function( elem ) {
4413 return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
4416 submit: function( elem ) {
4417 var name = elem.nodeName.toLowerCase();
4418 return (name === "input" || name === "button") && "submit" === elem.type;
4421 image: function( elem ) {
4422 return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
4425 reset: function( elem ) {
4426 var name = elem.nodeName.toLowerCase();
4427 return (name === "input" || name === "button") && "reset" === elem.type;
4430 button: function( elem ) {
4431 var name = elem.nodeName.toLowerCase();
4432 return name === "input" && "button" === elem.type || name === "button";
4435 input: function( elem ) {
4436 return (/input|select|textarea|button/i).test( elem.nodeName );
4439 focus: function( elem ) {
4440 return elem === elem.ownerDocument.activeElement;
4444 first: function( elem, i ) {
4448 last: function( elem, i, match, array ) {
4449 return i === array.length - 1;
4452 even: function( elem, i ) {
4456 odd: function( elem, i ) {
4460 lt: function( elem, i, match ) {
4461 return i < match[3] - 0;
4464 gt: function( elem, i, match ) {
4465 return i > match[3] - 0;
4468 nth: function( elem, i, match ) {
4469 return match[3] - 0 === i;
4472 eq: function( elem, i, match ) {
4473 return match[3] - 0 === i;
4477 PSEUDO: function( elem, match, i, array ) {
4478 var name = match[1],
4479 filter = Expr.filters[ name ];
4482 return filter( elem, i, match, array );
4484 } else if ( name === "contains" ) {
4485 return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
4487 } else if ( name === "not" ) {
4490 for ( var j = 0, l = not.length; j < l; j++ ) {
4491 if ( not[j] === elem ) {
4499 Sizzle.error( name );
4503 CHILD: function( elem, match ) {
4504 var type = match[1],
4510 while ( (node = node.previousSibling) ) {
4511 if ( node.nodeType === 1 ) {
4516 if ( type === "first" ) {
4523 while ( (node = node.nextSibling) ) {
4524 if ( node.nodeType === 1 ) {
4532 var first = match[2],
4535 if ( first === 1 && last === 0 ) {
4539 var doneName = match[0],
4540 parent = elem.parentNode;
4542 if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
4545 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4546 if ( node.nodeType === 1 ) {
4547 node.nodeIndex = ++count;
4551 parent.sizcache = doneName;
4554 var diff = elem.nodeIndex - last;
4556 if ( first === 0 ) {
4560 return ( diff % first === 0 && diff / first >= 0 );
4565 ID: function( elem, match ) {
4566 return elem.nodeType === 1 && elem.getAttribute("id") === match;
4569 TAG: function( elem, match ) {
4570 return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
4573 CLASS: function( elem, match ) {
4574 return (" " + (elem.className || elem.getAttribute("class")) + " ")
4575 .indexOf( match ) > -1;
4578 ATTR: function( elem, match ) {
4579 var name = match[1],
4580 result = Expr.attrHandle[ name ] ?
4581 Expr.attrHandle[ name ]( elem ) :
4582 elem[ name ] != null ?
4584 elem.getAttribute( name ),
4585 value = result + "",
4589 return result == null ?
4594 value.indexOf(check) >= 0 :
4596 (" " + value + " ").indexOf(check) >= 0 :
4598 value && result !== false :
4602 value.indexOf(check) === 0 :
4604 value.substr(value.length - check.length) === check :
4606 value === check || value.substr(0, check.length + 1) === check + "-" :
4610 POS: function( elem, match, i, array ) {
4611 var name = match[2],
4612 filter = Expr.setFilters[ name ];
4615 return filter( elem, i, match, array );
4621 var origPOS = Expr.match.POS,
4622 fescape = function(all, num){
4623 return "\\" + (num - 0 + 1);
4626 for ( var type in Expr.match ) {
4627 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
4628 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
4631 var makeArray = function( array, results ) {
4632 array = Array.prototype.slice.call( array, 0 );
4635 results.push.apply( results, array );
4642 // Perform a simple check to determine if the browser is capable of
4643 // converting a NodeList to an array using builtin methods.
4644 // Also verifies that the returned array holds DOM nodes
4645 // (which is not the case in the Blackberry browser)
4647 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
4649 // Provide a fallback method if it does not work
4651 makeArray = function( array, results ) {
4653 ret = results || [];
4655 if ( toString.call(array) === "[object Array]" ) {
4656 Array.prototype.push.apply( ret, array );
4659 if ( typeof array.length === "number" ) {
4660 for ( var l = array.length; i < l; i++ ) {
4661 ret.push( array[i] );
4665 for ( ; array[i]; i++ ) {
4666 ret.push( array[i] );
4675 var sortOrder, siblingCheck;
4677 if ( document.documentElement.compareDocumentPosition ) {
4678 sortOrder = function( a, b ) {
4680 hasDuplicate = true;
4684 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4685 return a.compareDocumentPosition ? -1 : 1;
4688 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4692 sortOrder = function( a, b ) {
4693 // The nodes are identical, we can exit early
4695 hasDuplicate = true;
4698 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4699 } else if ( a.sourceIndex && b.sourceIndex ) {
4700 return a.sourceIndex - b.sourceIndex;
4710 // If the nodes are siblings (or identical) we can do a quick check
4711 if ( aup === bup ) {
4712 return siblingCheck( a, b );
4714 // If no parents were found then the nodes are disconnected
4715 } else if ( !aup ) {
4718 } else if ( !bup ) {
4722 // Otherwise they're somewhere else in the tree so we need
4723 // to build up a full list of the parentNodes for comparison
4726 cur = cur.parentNode;
4733 cur = cur.parentNode;
4739 // Start walking down the tree looking for a discrepancy
4740 for ( var i = 0; i < al && i < bl; i++ ) {
4741 if ( ap[i] !== bp[i] ) {
4742 return siblingCheck( ap[i], bp[i] );
4746 // We ended someplace up the tree so do a sibling check
4748 siblingCheck( a, bp[i], -1 ) :
4749 siblingCheck( ap[i], b, 1 );
4752 siblingCheck = function( a, b, ret ) {
4757 var cur = a.nextSibling;
4764 cur = cur.nextSibling;
4771 // Utility function for retreiving the text value of an array of DOM nodes
4772 Sizzle.getText = function( elems ) {
4775 for ( var i = 0; elems[i]; i++ ) {
4778 // Get the text from text nodes and CDATA nodes
4779 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
4780 ret += elem.nodeValue;
4782 // Traverse everything else, except comment nodes
4783 } else if ( elem.nodeType !== 8 ) {
4784 ret += Sizzle.getText( elem.childNodes );
4791 // Check to see if the browser returns elements by name when
4792 // querying by getElementById (and provide a workaround)
4794 // We're going to inject a fake input element with a specified name
4795 var form = document.createElement("div"),
4796 id = "script" + (new Date()).getTime(),
4797 root = document.documentElement;
4799 form.innerHTML = "<a name='" + id + "'/>";
4801 // Inject it into the root element, check its status, and remove it quickly
4802 root.insertBefore( form, root.firstChild );
4804 // The workaround has to do additional checks after a getElementById
4805 // Which slows things down for other browsers (hence the branching)
4806 if ( document.getElementById( id ) ) {
4807 Expr.find.ID = function( match, context, isXML ) {
4808 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4809 var m = context.getElementById(match[1]);
4812 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
4819 Expr.filter.ID = function( elem, match ) {
4820 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4822 return elem.nodeType === 1 && node && node.nodeValue === match;
4826 root.removeChild( form );
4828 // release memory in IE
4833 // Check to see if the browser returns only elements
4834 // when doing getElementsByTagName("*")
4836 // Create a fake element
4837 var div = document.createElement("div");
4838 div.appendChild( document.createComment("") );
4840 // Make sure no comments are found
4841 if ( div.getElementsByTagName("*").length > 0 ) {
4842 Expr.find.TAG = function( match, context ) {
4843 var results = context.getElementsByTagName( match[1] );
4845 // Filter out possible comments
4846 if ( match[1] === "*" ) {
4849 for ( var i = 0; results[i]; i++ ) {
4850 if ( results[i].nodeType === 1 ) {
4851 tmp.push( results[i] );
4862 // Check to see if an attribute returns normalized href attributes
4863 div.innerHTML = "<a href='#'></a>";
4865 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4866 div.firstChild.getAttribute("href") !== "#" ) {
4868 Expr.attrHandle.href = function( elem ) {
4869 return elem.getAttribute( "href", 2 );
4873 // release memory in IE
4877 if ( document.querySelectorAll ) {
4879 var oldSizzle = Sizzle,
4880 div = document.createElement("div"),
4883 div.innerHTML = "<p class='TEST'></p>";
4885 // Safari can't handle uppercase or unicode characters when
4887 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4891 Sizzle = function( query, context, extra, seed ) {
4892 context = context || document;
4894 // Only use querySelectorAll on non-XML documents
4895 // (ID selectors don't work in non-HTML documents)
4896 if ( !seed && !Sizzle.isXML(context) ) {
4897 // See if we find a selector to speed up
4898 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
4900 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
4901 // Speed-up: Sizzle("TAG")
4903 return makeArray( context.getElementsByTagName( query ), extra );
4905 // Speed-up: Sizzle(".CLASS")
4906 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
4907 return makeArray( context.getElementsByClassName( match[2] ), extra );
4911 if ( context.nodeType === 9 ) {
4912 // Speed-up: Sizzle("body")
4913 // The body element only exists once, optimize finding it
4914 if ( query === "body" && context.body ) {
4915 return makeArray( [ context.body ], extra );
4917 // Speed-up: Sizzle("#ID")
4918 } else if ( match && match[3] ) {
4919 var elem = context.getElementById( match[3] );
4921 // Check parentNode to catch when Blackberry 4.6 returns
4922 // nodes that are no longer in the document #6963
4923 if ( elem && elem.parentNode ) {
4924 // Handle the case where IE and Opera return items
4925 // by name instead of ID
4926 if ( elem.id === match[3] ) {
4927 return makeArray( [ elem ], extra );
4931 return makeArray( [], extra );
4936 return makeArray( context.querySelectorAll(query), extra );
4937 } catch(qsaError) {}
4939 // qSA works strangely on Element-rooted queries
4940 // We can work around this by specifying an extra ID on the root
4941 // and working up from there (Thanks to Andrew Dupont for the technique)
4942 // IE 8 doesn't work on object elements
4943 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
4944 var oldContext = context,
4945 old = context.getAttribute( "id" ),
4947 hasParent = context.parentNode,
4948 relativeHierarchySelector = /^\s*[+~]/.test( query );
4951 context.setAttribute( "id", nid );
4953 nid = nid.replace( /'/g, "\\$&" );
4955 if ( relativeHierarchySelector && hasParent ) {
4956 context = context.parentNode;
4960 if ( !relativeHierarchySelector || hasParent ) {
4961 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
4964 } catch(pseudoError) {
4967 oldContext.removeAttribute( "id" );
4973 return oldSizzle(query, context, extra, seed);
4976 for ( var prop in oldSizzle ) {
4977 Sizzle[ prop ] = oldSizzle[ prop ];
4980 // release memory in IE
4986 var html = document.documentElement,
4987 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
4990 // Check to see if it's possible to do matchesSelector
4991 // on a disconnected node (IE 9 fails this)
4992 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
4993 pseudoWorks = false;
4996 // This should fail with an exception
4997 // Gecko does not error, returns false instead
4998 matches.call( document.documentElement, "[test!='']:sizzle" );
5000 } catch( pseudoError ) {
5004 Sizzle.matchesSelector = function( node, expr ) {
5005 // Make sure that attribute selectors are quoted
5006 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5008 if ( !Sizzle.isXML( node ) ) {
5010 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
5011 var ret = matches.call( node, expr );
5013 // IE 9's matchesSelector returns false on disconnected nodes
5014 if ( ret || !disconnectedMatch ||
5015 // As well, disconnected nodes are said to be in a document
5016 // fragment in IE 9, so check for that
5017 node.document && node.document.nodeType !== 11 ) {
5024 return Sizzle(expr, null, null, [node]).length > 0;
5030 var div = document.createElement("div");
5032 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
5034 // Opera can't find a second classname (in 9.6)
5035 // Also, make sure that getElementsByClassName actually exists
5036 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
5040 // Safari caches class attributes, doesn't catch changes (in 3.2)
5041 div.lastChild.className = "e";
5043 if ( div.getElementsByClassName("e").length === 1 ) {
5047 Expr.order.splice(1, 0, "CLASS");
5048 Expr.find.CLASS = function( match, context, isXML ) {
5049 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
5050 return context.getElementsByClassName(match[1]);
5054 // release memory in IE
5058 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5059 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5060 var elem = checkSet[i];
5068 if ( elem.sizcache === doneName ) {
5069 match = checkSet[elem.sizset];
5073 if ( elem.nodeType === 1 && !isXML ){
5074 elem.sizcache = doneName;
5078 if ( elem.nodeName.toLowerCase() === cur ) {
5086 checkSet[i] = match;
5091 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5092 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5093 var elem = checkSet[i];
5101 if ( elem.sizcache === doneName ) {
5102 match = checkSet[elem.sizset];
5106 if ( elem.nodeType === 1 ) {
5108 elem.sizcache = doneName;
5112 if ( typeof cur !== "string" ) {
5113 if ( elem === cur ) {
5118 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
5127 checkSet[i] = match;
5132 if ( document.documentElement.contains ) {
5133 Sizzle.contains = function( a, b ) {
5134 return a !== b && (a.contains ? a.contains(b) : true);
5137 } else if ( document.documentElement.compareDocumentPosition ) {
5138 Sizzle.contains = function( a, b ) {
5139 return !!(a.compareDocumentPosition(b) & 16);
5143 Sizzle.contains = function() {
5148 Sizzle.isXML = function( elem ) {
5149 // documentElement is verified for cases where it doesn't yet exist
5150 // (such as loading iframes in IE - #4833)
5151 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
5153 return documentElement ? documentElement.nodeName !== "HTML" : false;
5156 var posProcess = function( selector, context ) {
5160 root = context.nodeType ? [context] : context;
5162 // Position selectors must be done after the filter
5163 // And so must :not(positional) so we move all PSEUDOs to the end
5164 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
5166 selector = selector.replace( Expr.match.PSEUDO, "" );
5169 selector = Expr.relative[selector] ? selector + "*" : selector;
5171 for ( var i = 0, l = root.length; i < l; i++ ) {
5172 Sizzle( selector, root[i], tmpSet );
5175 return Sizzle.filter( later, tmpSet );
5179 jQuery.find = Sizzle;
5180 jQuery.expr = Sizzle.selectors;
5181 jQuery.expr[":"] = jQuery.expr.filters;
5182 jQuery.unique = Sizzle.uniqueSort;
5183 jQuery.text = Sizzle.getText;
5184 jQuery.isXMLDoc = Sizzle.isXML;
5185 jQuery.contains = Sizzle.contains;
5191 var runtil = /Until$/,
5192 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
5193 // Note: This RegExp should be improved, or likely pulled from Sizzle
5194 rmultiselector = /,/,
5195 isSimple = /^.[^:#\[\.,]*$/,
5196 slice = Array.prototype.slice,
5197 POS = jQuery.expr.match.POS,
5198 // methods guaranteed to produce a unique set when starting from a unique set
5199 guaranteedUnique = {
5207 find: function( selector ) {
5211 if ( typeof selector !== "string" ) {
5212 return jQuery( selector ).filter(function() {
5213 for ( i = 0, l = self.length; i < l; i++ ) {
5214 if ( jQuery.contains( self[ i ], this ) ) {
5221 var ret = this.pushStack( "", "find", selector ),
5224 for ( i = 0, l = this.length; i < l; i++ ) {
5225 length = ret.length;
5226 jQuery.find( selector, this[i], ret );
5229 // Make sure that the results are unique
5230 for ( n = length; n < ret.length; n++ ) {
5231 for ( r = 0; r < length; r++ ) {
5232 if ( ret[r] === ret[n] ) {
5244 has: function( target ) {
5245 var targets = jQuery( target );
5246 return this.filter(function() {
5247 for ( var i = 0, l = targets.length; i < l; i++ ) {
5248 if ( jQuery.contains( this, targets[i] ) ) {
5255 not: function( selector ) {
5256 return this.pushStack( winnow(this, selector, false), "not", selector);
5259 filter: function( selector ) {
5260 return this.pushStack( winnow(this, selector, true), "filter", selector );
5263 is: function( selector ) {
5264 return !!selector && ( typeof selector === "string" ?
5265 jQuery.filter( selector, this ).length > 0 :
5266 this.filter( selector ).length > 0 );
5269 closest: function( selectors, context ) {
5270 var ret = [], i, l, cur = this[0];
5273 if ( jQuery.isArray( selectors ) ) {
5274 var match, selector,
5278 if ( cur && selectors.length ) {
5279 for ( i = 0, l = selectors.length; i < l; i++ ) {
5280 selector = selectors[i];
5282 if ( !matches[ selector ] ) {
5283 matches[ selector ] = POS.test( selector ) ?
5284 jQuery( selector, context || this.context ) :
5289 while ( cur && cur.ownerDocument && cur !== context ) {
5290 for ( selector in matches ) {
5291 match = matches[ selector ];
5293 if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
5294 ret.push({ selector: selector, elem: cur, level: level });
5298 cur = cur.parentNode;
5307 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
5308 jQuery( selectors, context || this.context ) :
5311 for ( i = 0, l = this.length; i < l; i++ ) {
5315 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5320 cur = cur.parentNode;
5321 if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
5328 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5330 return this.pushStack( ret, "closest", selectors );
5333 // Determine the position of an element within
5334 // the matched set of elements
5335 index: function( elem ) {
5337 // No argument, return index in parent
5339 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5342 // index in selector
5343 if ( typeof elem === "string" ) {
5344 return jQuery.inArray( this[0], jQuery( elem ) );
5347 // Locate the position of the desired element
5348 return jQuery.inArray(
5349 // If it receives a jQuery object, the first element is used
5350 elem.jquery ? elem[0] : elem, this );
5353 add: function( selector, context ) {
5354 var set = typeof selector === "string" ?
5355 jQuery( selector, context ) :
5356 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5357 all = jQuery.merge( this.get(), set );
5359 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5361 jQuery.unique( all ) );
5364 andSelf: function() {
5365 return this.add( this.prevObject );
5369 // A painfully simple check to see if an element is disconnected
5370 // from a document (should be improved, where feasible).
5371 function isDisconnected( node ) {
5372 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5376 parent: function( elem ) {
5377 var parent = elem.parentNode;
5378 return parent && parent.nodeType !== 11 ? parent : null;
5380 parents: function( elem ) {
5381 return jQuery.dir( elem, "parentNode" );
5383 parentsUntil: function( elem, i, until ) {
5384 return jQuery.dir( elem, "parentNode", until );
5386 next: function( elem ) {
5387 return jQuery.nth( elem, 2, "nextSibling" );
5389 prev: function( elem ) {
5390 return jQuery.nth( elem, 2, "previousSibling" );
5392 nextAll: function( elem ) {
5393 return jQuery.dir( elem, "nextSibling" );
5395 prevAll: function( elem ) {
5396 return jQuery.dir( elem, "previousSibling" );
5398 nextUntil: function( elem, i, until ) {
5399 return jQuery.dir( elem, "nextSibling", until );
5401 prevUntil: function( elem, i, until ) {
5402 return jQuery.dir( elem, "previousSibling", until );
5404 siblings: function( elem ) {
5405 return jQuery.sibling( elem.parentNode.firstChild, elem );
5407 children: function( elem ) {
5408 return jQuery.sibling( elem.firstChild );
5410 contents: function( elem ) {
5411 return jQuery.nodeName( elem, "iframe" ) ?
5412 elem.contentDocument || elem.contentWindow.document :
5413 jQuery.makeArray( elem.childNodes );
5415 }, function( name, fn ) {
5416 jQuery.fn[ name ] = function( until, selector ) {
5417 var ret = jQuery.map( this, fn, until ),
5418 // The variable 'args' was introduced in
5419 // https://github.com/jquery/jquery/commit/52a0238
5420 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
5421 // http://code.google.com/p/v8/issues/detail?id=1050
5422 args = slice.call(arguments);
5424 if ( !runtil.test( name ) ) {
5428 if ( selector && typeof selector === "string" ) {
5429 ret = jQuery.filter( selector, ret );
5432 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5434 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
5435 ret = ret.reverse();
5438 return this.pushStack( ret, name, args.join(",") );
5443 filter: function( expr, elems, not ) {
5445 expr = ":not(" + expr + ")";
5448 return elems.length === 1 ?
5449 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5450 jQuery.find.matches(expr, elems);
5453 dir: function( elem, dir, until ) {
5457 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5458 if ( cur.nodeType === 1 ) {
5459 matched.push( cur );
5466 nth: function( cur, result, dir, elem ) {
5467 result = result || 1;
5470 for ( ; cur; cur = cur[dir] ) {
5471 if ( cur.nodeType === 1 && ++num === result ) {
5479 sibling: function( n, elem ) {
5482 for ( ; n; n = n.nextSibling ) {
5483 if ( n.nodeType === 1 && n !== elem ) {
5492 // Implement the identical functionality for filter and not
5493 function winnow( elements, qualifier, keep ) {
5495 // Can't pass null or undefined to indexOf in Firefox 4
5496 // Set to 0 to skip string check
5497 qualifier = qualifier || 0;
5499 if ( jQuery.isFunction( qualifier ) ) {
5500 return jQuery.grep(elements, function( elem, i ) {
5501 var retVal = !!qualifier.call( elem, i, elem );
5502 return retVal === keep;
5505 } else if ( qualifier.nodeType ) {
5506 return jQuery.grep(elements, function( elem, i ) {
5507 return (elem === qualifier) === keep;
5510 } else if ( typeof qualifier === "string" ) {
5511 var filtered = jQuery.grep(elements, function( elem ) {
5512 return elem.nodeType === 1;
5515 if ( isSimple.test( qualifier ) ) {
5516 return jQuery.filter(qualifier, filtered, !keep);
5518 qualifier = jQuery.filter( qualifier, filtered );
5522 return jQuery.grep(elements, function( elem, i ) {
5523 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
5530 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5531 rleadingWhitespace = /^\s+/,
5532 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5533 rtagName = /<([\w:]+)/,
5535 rhtml = /<|&#?\w+;/,
5536 rnocache = /<(?:script|object|embed|option|style)/i,
5537 // checked="checked" or checked
5538 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5539 rscriptType = /\/(java|ecma)script/i,
5540 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
5542 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5543 legend: [ 1, "<fieldset>", "</fieldset>" ],
5544 thead: [ 1, "<table>", "</table>" ],
5545 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5546 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5547 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5548 area: [ 1, "<map>", "</map>" ],
5549 _default: [ 0, "", "" ]
5552 wrapMap.optgroup = wrapMap.option;
5553 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5554 wrapMap.th = wrapMap.td;
5556 // IE can't serialize <link> and <script> tags normally
5557 if ( !jQuery.support.htmlSerialize ) {
5558 wrapMap._default = [ 1, "div<div>", "</div>" ];
5562 text: function( text ) {
5563 if ( jQuery.isFunction(text) ) {
5564 return this.each(function(i) {
5565 var self = jQuery( this );
5567 self.text( text.call(this, i, self.text()) );
5571 if ( typeof text !== "object" && text !== undefined ) {
5572 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
5575 return jQuery.text( this );
5578 wrapAll: function( html ) {
5579 if ( jQuery.isFunction( html ) ) {
5580 return this.each(function(i) {
5581 jQuery(this).wrapAll( html.call(this, i) );
5586 // The elements to wrap the target around
5587 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5589 if ( this[0].parentNode ) {
5590 wrap.insertBefore( this[0] );
5593 wrap.map(function() {
5596 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5597 elem = elem.firstChild;
5607 wrapInner: function( html ) {
5608 if ( jQuery.isFunction( html ) ) {
5609 return this.each(function(i) {
5610 jQuery(this).wrapInner( html.call(this, i) );
5614 return this.each(function() {
5615 var self = jQuery( this ),
5616 contents = self.contents();
5618 if ( contents.length ) {
5619 contents.wrapAll( html );
5622 self.append( html );
5627 wrap: function( html ) {
5628 return this.each(function() {
5629 jQuery( this ).wrapAll( html );
5633 unwrap: function() {
5634 return this.parent().each(function() {
5635 if ( !jQuery.nodeName( this, "body" ) ) {
5636 jQuery( this ).replaceWith( this.childNodes );
5641 append: function() {
5642 return this.domManip(arguments, true, function( elem ) {
5643 if ( this.nodeType === 1 ) {
5644 this.appendChild( elem );
5649 prepend: function() {
5650 return this.domManip(arguments, true, function( elem ) {
5651 if ( this.nodeType === 1 ) {
5652 this.insertBefore( elem, this.firstChild );
5657 before: function() {
5658 if ( this[0] && this[0].parentNode ) {
5659 return this.domManip(arguments, false, function( elem ) {
5660 this.parentNode.insertBefore( elem, this );
5662 } else if ( arguments.length ) {
5663 var set = jQuery(arguments[0]);
5664 set.push.apply( set, this.toArray() );
5665 return this.pushStack( set, "before", arguments );
5670 if ( this[0] && this[0].parentNode ) {
5671 return this.domManip(arguments, false, function( elem ) {
5672 this.parentNode.insertBefore( elem, this.nextSibling );
5674 } else if ( arguments.length ) {
5675 var set = this.pushStack( this, "after", arguments );
5676 set.push.apply( set, jQuery(arguments[0]).toArray() );
5681 // keepData is for internal use only--do not document
5682 remove: function( selector, keepData ) {
5683 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5684 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5685 if ( !keepData && elem.nodeType === 1 ) {
5686 jQuery.cleanData( elem.getElementsByTagName("*") );
5687 jQuery.cleanData( [ elem ] );
5690 if ( elem.parentNode ) {
5691 elem.parentNode.removeChild( elem );
5700 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5701 // Remove element nodes and prevent memory leaks
5702 if ( elem.nodeType === 1 ) {
5703 jQuery.cleanData( elem.getElementsByTagName("*") );
5706 // Remove any remaining nodes
5707 while ( elem.firstChild ) {
5708 elem.removeChild( elem.firstChild );
5715 clone: function( dataAndEvents, deepDataAndEvents ) {
5716 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5717 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5719 return this.map( function () {
5720 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5724 html: function( value ) {
5725 if ( value === undefined ) {
5726 return this[0] && this[0].nodeType === 1 ?
5727 this[0].innerHTML.replace(rinlinejQuery, "") :
5730 // See if we can take a shortcut and just use innerHTML
5731 } else if ( typeof value === "string" && !rnocache.test( value ) &&
5732 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5733 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5735 value = value.replace(rxhtmlTag, "<$1></$2>");
5738 for ( var i = 0, l = this.length; i < l; i++ ) {
5739 // Remove element nodes and prevent memory leaks
5740 if ( this[i].nodeType === 1 ) {
5741 jQuery.cleanData( this[i].getElementsByTagName("*") );
5742 this[i].innerHTML = value;
5746 // If using innerHTML throws an exception, use the fallback method
5748 this.empty().append( value );
5751 } else if ( jQuery.isFunction( value ) ) {
5752 this.each(function(i){
5753 var self = jQuery( this );
5755 self.html( value.call(this, i, self.html()) );
5759 this.empty().append( value );
5765 replaceWith: function( value ) {
5766 if ( this[0] && this[0].parentNode ) {
5767 // Make sure that the elements are removed from the DOM before they are inserted
5768 // this can help fix replacing a parent with child elements
5769 if ( jQuery.isFunction( value ) ) {
5770 return this.each(function(i) {
5771 var self = jQuery(this), old = self.html();
5772 self.replaceWith( value.call( this, i, old ) );
5776 if ( typeof value !== "string" ) {
5777 value = jQuery( value ).detach();
5780 return this.each(function() {
5781 var next = this.nextSibling,
5782 parent = this.parentNode;
5784 jQuery( this ).remove();
5787 jQuery(next).before( value );
5789 jQuery(parent).append( value );
5793 return this.length ?
5794 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5799 detach: function( selector ) {
5800 return this.remove( selector, true );
5803 domManip: function( args, table, callback ) {
5804 var results, first, fragment, parent,
5808 // We can't cloneNode fragments that contain checked, in WebKit
5809 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
5810 return this.each(function() {
5811 jQuery(this).domManip( args, table, callback, true );
5815 if ( jQuery.isFunction(value) ) {
5816 return this.each(function(i) {
5817 var self = jQuery(this);
5818 args[0] = value.call(this, i, table ? self.html() : undefined);
5819 self.domManip( args, table, callback );
5824 parent = value && value.parentNode;
5826 // If we're in a fragment, just use that instead of building a new one
5827 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
5828 results = { fragment: parent };
5831 results = jQuery.buildFragment( args, this, scripts );
5834 fragment = results.fragment;
5836 if ( fragment.childNodes.length === 1 ) {
5837 first = fragment = fragment.firstChild;
5839 first = fragment.firstChild;
5843 table = table && jQuery.nodeName( first, "tr" );
5845 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
5848 root(this[i], first) :
5850 // Make sure that we do not leak memory by inadvertently discarding
5851 // the original fragment (which might have attached data) instead of
5852 // using it; in addition, use the original fragment object for the last
5853 // item instead of first because it can end up being emptied incorrectly
5854 // in certain situations (Bug #8070).
5855 // Fragments from the fragment cache must always be cloned and never used
5857 results.cacheable || (l > 1 && i < lastIndex) ?
5858 jQuery.clone( fragment, true, true ) :
5864 if ( scripts.length ) {
5865 jQuery.each( scripts, evalScript );
5873 function root( elem, cur ) {
5874 return jQuery.nodeName(elem, "table") ?
5875 (elem.getElementsByTagName("tbody")[0] ||
5876 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
5880 function cloneCopyEvent( src, dest ) {
5882 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5886 var internalKey = jQuery.expando,
5887 oldData = jQuery.data( src ),
5888 curData = jQuery.data( dest, oldData );
5890 // Switch to use the internal data object, if it exists, for the next
5891 // stage of data copying
5892 if ( (oldData = oldData[ internalKey ]) ) {
5893 var events = oldData.events;
5894 curData = curData[ internalKey ] = jQuery.extend({}, oldData);
5897 delete curData.handle;
5898 curData.events = {};
5900 for ( var type in events ) {
5901 for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
5902 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5909 function cloneFixAttributes( src, dest ) {
5912 // We do not need to do anything for non-Elements
5913 if ( dest.nodeType !== 1 ) {
5917 // clearAttributes removes the attributes, which we don't want,
5918 // but also removes the attachEvent events, which we *do* want
5919 if ( dest.clearAttributes ) {
5920 dest.clearAttributes();
5923 // mergeAttributes, in contrast, only merges back on the
5924 // original attributes, not the events
5925 if ( dest.mergeAttributes ) {
5926 dest.mergeAttributes( src );
5929 nodeName = dest.nodeName.toLowerCase();
5931 // IE6-8 fail to clone children inside object elements that use
5932 // the proprietary classid attribute value (rather than the type
5933 // attribute) to identify the type of content to display
5934 if ( nodeName === "object" ) {
5935 dest.outerHTML = src.outerHTML;
5937 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
5938 // IE6-8 fails to persist the checked state of a cloned checkbox
5939 // or radio button. Worse, IE6-7 fail to give the cloned element
5940 // a checked appearance if the defaultChecked value isn't also set
5941 if ( src.checked ) {
5942 dest.defaultChecked = dest.checked = src.checked;
5945 // IE6-7 get confused and end up setting the value of a cloned
5946 // checkbox/radio button to an empty string instead of "on"
5947 if ( dest.value !== src.value ) {
5948 dest.value = src.value;
5951 // IE6-8 fails to return the selected option to the default selected
5952 // state when cloning options
5953 } else if ( nodeName === "option" ) {
5954 dest.selected = src.defaultSelected;
5956 // IE6-8 fails to set the defaultValue to the correct value when
5957 // cloning other types of input fields
5958 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5959 dest.defaultValue = src.defaultValue;
5962 // Event data gets referenced instead of copied if the expando
5964 dest.removeAttribute( jQuery.expando );
5967 jQuery.buildFragment = function( args, nodes, scripts ) {
5968 var fragment, cacheable, cacheresults, doc;
5970 // nodes may contain either an explicit document object,
5971 // a jQuery collection or context object.
5972 // If nodes[0] contains a valid object to assign to doc
5973 if ( nodes && nodes[0] ) {
5974 doc = nodes[0].ownerDocument || nodes[0];
5977 // Ensure that an attr object doesn't incorrectly stand in as a document object
5978 // Chrome and Firefox seem to allow this to occur and will throw exception
5980 if ( !doc.createDocumentFragment ) {
5984 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
5985 // Cloning options loses the selected state, so don't cache them
5986 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
5987 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
5988 if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
5989 args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
5993 cacheresults = jQuery.fragments[ args[0] ];
5994 if ( cacheresults && cacheresults !== 1 ) {
5995 fragment = cacheresults;
6000 fragment = doc.createDocumentFragment();
6001 jQuery.clean( args, doc, fragment, scripts );
6005 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
6008 return { fragment: fragment, cacheable: cacheable };
6011 jQuery.fragments = {};
6015 prependTo: "prepend",
6016 insertBefore: "before",
6017 insertAfter: "after",
6018 replaceAll: "replaceWith"
6019 }, function( name, original ) {
6020 jQuery.fn[ name ] = function( selector ) {
6022 insert = jQuery( selector ),
6023 parent = this.length === 1 && this[0].parentNode;
6025 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
6026 insert[ original ]( this[0] );
6030 for ( var i = 0, l = insert.length; i < l; i++ ) {
6031 var elems = (i > 0 ? this.clone(true) : this).get();
6032 jQuery( insert[i] )[ original ]( elems );
6033 ret = ret.concat( elems );
6036 return this.pushStack( ret, name, insert.selector );
6041 function getAll( elem ) {
6042 if ( "getElementsByTagName" in elem ) {
6043 return elem.getElementsByTagName( "*" );
6045 } else if ( "querySelectorAll" in elem ) {
6046 return elem.querySelectorAll( "*" );
6053 // Used in clean, fixes the defaultChecked property
6054 function fixDefaultChecked( elem ) {
6055 if ( elem.type === "checkbox" || elem.type === "radio" ) {
6056 elem.defaultChecked = elem.checked;
6059 // Finds all inputs and passes them to fixDefaultChecked
6060 function findInputs( elem ) {
6061 if ( jQuery.nodeName( elem, "input" ) ) {
6062 fixDefaultChecked( elem );
6063 } else if ( "getElementsByTagName" in elem ) {
6064 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6069 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6070 var clone = elem.cloneNode(true),
6075 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6076 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6077 // IE copies events bound via attachEvent when using cloneNode.
6078 // Calling detachEvent on the clone will also remove the events
6079 // from the original. In order to get around this, we use some
6080 // proprietary methods to clear the events. Thanks to MooTools
6081 // guys for this hotness.
6083 cloneFixAttributes( elem, clone );
6085 // Using Sizzle here is crazy slow, so we use getElementsByTagName
6087 srcElements = getAll( elem );
6088 destElements = getAll( clone );
6090 // Weird iteration because IE will replace the length property
6091 // with an element if you are cloning the body and one of the
6092 // elements on the page has a name or id of "length"
6093 for ( i = 0; srcElements[i]; ++i ) {
6094 // Ensure that the destination node is not null; Fixes #9587
6095 if ( destElements[i] ) {
6096 cloneFixAttributes( srcElements[i], destElements[i] );
6101 // Copy the events from the original to the clone
6102 if ( dataAndEvents ) {
6103 cloneCopyEvent( elem, clone );
6105 if ( deepDataAndEvents ) {
6106 srcElements = getAll( elem );
6107 destElements = getAll( clone );
6109 for ( i = 0; srcElements[i]; ++i ) {
6110 cloneCopyEvent( srcElements[i], destElements[i] );
6115 srcElements = destElements = null;
6117 // Return the cloned set
6121 clean: function( elems, context, fragment, scripts ) {
6122 var checkScriptType;
6124 context = context || document;
6126 // !context.createElement fails in IE with an error but returns typeof 'object'
6127 if ( typeof context.createElement === "undefined" ) {
6128 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
6133 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6134 if ( typeof elem === "number" ) {
6142 // Convert html string into DOM nodes
6143 if ( typeof elem === "string" ) {
6144 if ( !rhtml.test( elem ) ) {
6145 elem = context.createTextNode( elem );
6147 // Fix "XHTML"-style tags in all browsers
6148 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6150 // Trim whitespace, otherwise indexOf won't work as expected
6151 var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
6152 wrap = wrapMap[ tag ] || wrapMap._default,
6154 div = context.createElement("div");
6156 // Go to html and back, then peel off extra wrappers
6157 div.innerHTML = wrap[1] + elem + wrap[2];
6159 // Move to the right depth
6161 div = div.lastChild;
6164 // Remove IE's autoinserted <tbody> from table fragments
6165 if ( !jQuery.support.tbody ) {
6167 // String was a <table>, *may* have spurious <tbody>
6168 var hasBody = rtbody.test(elem),
6169 tbody = tag === "table" && !hasBody ?
6170 div.firstChild && div.firstChild.childNodes :
6172 // String was a bare <thead> or <tfoot>
6173 wrap[1] === "<table>" && !hasBody ?
6177 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6178 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6179 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6184 // IE completely kills leading whitespace when innerHTML is used
6185 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6186 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6189 elem = div.childNodes;
6193 // Resets defaultChecked for any radios and checkboxes
6194 // about to be appended to the DOM in IE 6/7 (#8060)
6196 if ( !jQuery.support.appendChecked ) {
6197 if ( elem[0] && typeof (len = elem.length) === "number" ) {
6198 for ( j = 0; j < len; j++ ) {
6199 findInputs( elem[j] );
6206 if ( elem.nodeType ) {
6209 ret = jQuery.merge( ret, elem );
6214 checkScriptType = function( elem ) {
6215 return !elem.type || rscriptType.test( elem.type );
6217 for ( i = 0; ret[i]; i++ ) {
6218 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
6219 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
6222 if ( ret[i].nodeType === 1 ) {
6223 var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
6225 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6227 fragment.appendChild( ret[i] );
6235 cleanData: function( elems ) {
6236 var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
6237 deleteExpando = jQuery.support.deleteExpando;
6239 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6240 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
6244 id = elem[ jQuery.expando ];
6247 data = cache[ id ] && cache[ id ][ internalKey ];
6249 if ( data && data.events ) {
6250 for ( var type in data.events ) {
6251 if ( special[ type ] ) {
6252 jQuery.event.remove( elem, type );
6254 // This is a shortcut to avoid jQuery.event.remove's overhead
6256 jQuery.removeEvent( elem, type, data.handle );
6260 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6261 if ( data.handle ) {
6262 data.handle.elem = null;
6266 if ( deleteExpando ) {
6267 delete elem[ jQuery.expando ];
6269 } else if ( elem.removeAttribute ) {
6270 elem.removeAttribute( jQuery.expando );
6279 function evalScript( i, elem ) {
6287 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
6290 if ( elem.parentNode ) {
6291 elem.parentNode.removeChild( elem );
6298 var ralpha = /alpha\([^)]*\)/i,
6299 ropacity = /opacity=([^)]*)/,
6300 // fixed for IE9, see #8346
6301 rupper = /([A-Z]|^ms)/g,
6302 rnumpx = /^-?\d+(?:px)?$/i,
6304 rrelNum = /^([\-+])=([\-+.\de]+)/,
6306 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6307 cssWidth = [ "Left", "Right" ],
6308 cssHeight = [ "Top", "Bottom" ],
6314 jQuery.fn.css = function( name, value ) {
6315 // Setting 'undefined' is a no-op
6316 if ( arguments.length === 2 && value === undefined ) {
6320 return jQuery.access( this, name, value, true, function( elem, name, value ) {
6321 return value !== undefined ?
6322 jQuery.style( elem, name, value ) :
6323 jQuery.css( elem, name );
6328 // Add in style property hooks for overriding the default
6329 // behavior of getting and setting a style property
6332 get: function( elem, computed ) {
6334 // We should always get a number back from opacity
6335 var ret = curCSS( elem, "opacity", "opacity" );
6336 return ret === "" ? "1" : ret;
6339 return elem.style.opacity;
6345 // Exclude the following css properties to add px
6347 "fillOpacity": true,
6357 // Add in properties whose names you wish to fix before
6358 // setting or getting the value
6360 // normalize float css property
6361 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6364 // Get and set the style property on a DOM Node
6365 style: function( elem, name, value, extra ) {
6366 // Don't set styles on text and comment nodes
6367 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6371 // Make sure that we're working with the right name
6372 var ret, type, origName = jQuery.camelCase( name ),
6373 style = elem.style, hooks = jQuery.cssHooks[ origName ];
6375 name = jQuery.cssProps[ origName ] || origName;
6377 // Check if we're setting a value
6378 if ( value !== undefined ) {
6379 type = typeof value;
6381 // convert relative number strings (+= or -=) to relative numbers. #7345
6382 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6383 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
6388 // Make sure that NaN and null values aren't set. See: #7116
6389 if ( value == null || type === "number" && isNaN( value ) ) {
6393 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6394 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6398 // If a hook was provided, use that value, otherwise just set the specified value
6399 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
6400 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6403 style[ name ] = value;
6408 // If a hook was provided get the non-computed value from there
6409 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6413 // Otherwise just get the value from the style object
6414 return style[ name ];
6418 css: function( elem, name, extra ) {
6421 // Make sure that we're working with the right name
6422 name = jQuery.camelCase( name );
6423 hooks = jQuery.cssHooks[ name ];
6424 name = jQuery.cssProps[ name ] || name;
6426 // cssFloat needs a special treatment
6427 if ( name === "cssFloat" ) {
6431 // If a hook was provided get the computed value from there
6432 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
6435 // Otherwise, if a way to get the computed value exists, use that
6436 } else if ( curCSS ) {
6437 return curCSS( elem, name );
6441 // A method for quickly swapping in/out CSS properties to get correct calculations
6442 swap: function( elem, options, callback ) {
6445 // Remember the old values, and insert the new ones
6446 for ( var name in options ) {
6447 old[ name ] = elem.style[ name ];
6448 elem.style[ name ] = options[ name ];
6451 callback.call( elem );
6453 // Revert the old values
6454 for ( name in options ) {
6455 elem.style[ name ] = old[ name ];
6460 // DEPRECATED, Use jQuery.css() instead
6461 jQuery.curCSS = jQuery.css;
6463 jQuery.each(["height", "width"], function( i, name ) {
6464 jQuery.cssHooks[ name ] = {
6465 get: function( elem, computed, extra ) {
6469 if ( elem.offsetWidth !== 0 ) {
6470 return getWH( elem, name, extra );
6472 jQuery.swap( elem, cssShow, function() {
6473 val = getWH( elem, name, extra );
6481 set: function( elem, value ) {
6482 if ( rnumpx.test( value ) ) {
6483 // ignore negative width and height values #1599
6484 value = parseFloat( value );
6487 return value + "px";
6497 if ( !jQuery.support.opacity ) {
6498 jQuery.cssHooks.opacity = {
6499 get: function( elem, computed ) {
6500 // IE uses filters for opacity
6501 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6502 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
6503 computed ? "1" : "";
6506 set: function( elem, value ) {
6507 var style = elem.style,
6508 currentStyle = elem.currentStyle,
6509 opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
6510 filter = currentStyle && currentStyle.filter || style.filter || "";
6512 // IE has trouble with opacity if it does not have layout
6513 // Force it by setting the zoom level
6516 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6517 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
6519 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6520 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6521 // style.removeAttribute is IE Only, but so apparently is this code path...
6522 style.removeAttribute( "filter" );
6524 // if there there is no filter style applied in a css rule, we are done
6525 if ( currentStyle && !currentStyle.filter ) {
6530 // otherwise, set new filter values
6531 style.filter = ralpha.test( filter ) ?
6532 filter.replace( ralpha, opacity ) :
6533 filter + " " + opacity;
6539 // This hook cannot be added until DOM ready because the support test
6540 // for it is not run until after DOM ready
6541 if ( !jQuery.support.reliableMarginRight ) {
6542 jQuery.cssHooks.marginRight = {
6543 get: function( elem, computed ) {
6544 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6545 // Work around by temporarily setting element display to inline-block
6547 jQuery.swap( elem, { "display": "inline-block" }, function() {
6549 ret = curCSS( elem, "margin-right", "marginRight" );
6551 ret = elem.style.marginRight;
6560 if ( document.defaultView && document.defaultView.getComputedStyle ) {
6561 getComputedStyle = function( elem, name ) {
6562 var ret, defaultView, computedStyle;
6564 name = name.replace( rupper, "-$1" ).toLowerCase();
6566 if ( !(defaultView = elem.ownerDocument.defaultView) ) {
6570 if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
6571 ret = computedStyle.getPropertyValue( name );
6572 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6573 ret = jQuery.style( elem, name );
6581 if ( document.documentElement.currentStyle ) {
6582 currentStyle = function( elem, name ) {
6584 ret = elem.currentStyle && elem.currentStyle[ name ],
6585 rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
6588 // From the awesome hack by Dean Edwards
6589 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6591 // If we're not dealing with a regular pixel number
6592 // but a number that has a weird ending, we need to convert it to pixels
6593 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6594 // Remember the original values
6597 // Put in the new values to get a computed value out
6599 elem.runtimeStyle.left = elem.currentStyle.left;
6601 style.left = name === "fontSize" ? "1em" : (ret || 0);
6602 ret = style.pixelLeft + "px";
6604 // Revert the changed values
6607 elem.runtimeStyle.left = rsLeft;
6611 return ret === "" ? "auto" : ret;
6615 curCSS = getComputedStyle || currentStyle;
6617 function getWH( elem, name, extra ) {
6619 // Start with offset property
6620 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6621 which = name === "width" ? cssWidth : cssHeight;
6624 if ( extra !== "border" ) {
6625 jQuery.each( which, function() {
6627 val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
6629 if ( extra === "margin" ) {
6630 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
6632 val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
6640 // Fall back to computed then uncomputed css if necessary
6641 val = curCSS( elem, name, name );
6642 if ( val < 0 || val == null ) {
6643 val = elem.style[ name ] || 0;
6645 // Normalize "", auto, and prepare for extra
6646 val = parseFloat( val ) || 0;
6648 // Add padding, border, margin
6650 jQuery.each( which, function() {
6651 val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
6652 if ( extra !== "padding" ) {
6653 val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
6655 if ( extra === "margin" ) {
6656 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
6664 if ( jQuery.expr && jQuery.expr.filters ) {
6665 jQuery.expr.filters.hidden = function( elem ) {
6666 var width = elem.offsetWidth,
6667 height = elem.offsetHeight;
6669 return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
6672 jQuery.expr.filters.visible = function( elem ) {
6673 return !jQuery.expr.filters.hidden( elem );
6684 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
6685 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6686 // #7653, #8125, #8152: local protocol detection
6687 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6688 rnoContent = /^(?:GET|HEAD)$/,
6689 rprotocol = /^\/\//,
6691 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6692 rselectTextarea = /^(?:select|textarea)/i,
6693 rspacesAjax = /\s+/,
6694 rts = /([?&])_=[^&]*/,
6695 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6697 // Keep a copy of the old load method
6698 _load = jQuery.fn.load,
6701 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6702 * 2) These are called:
6703 * - BEFORE asking for a transport
6704 * - AFTER param serialization (s.data is a string if s.processData is true)
6705 * 3) key is the dataType
6706 * 4) the catchall symbol "*" can be used
6707 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6711 /* Transports bindings
6712 * 1) key is the dataType
6713 * 2) the catchall symbol "*" can be used
6714 * 3) selection will start with transport dataType and THEN go to "*" if needed
6718 // Document location
6721 // Document location segments
6724 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6725 allTypes = ["*/"] + ["*"];
6727 // #8138, IE may throw an exception when accessing
6728 // a field from window.location if document.domain has been set
6730 ajaxLocation = location.href;
6732 // Use the href attribute of an A element
6733 // since IE will modify it given document.location
6734 ajaxLocation = document.createElement( "a" );
6735 ajaxLocation.href = "";
6736 ajaxLocation = ajaxLocation.href;
6739 // Segment location into parts
6740 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
6742 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6743 function addToPrefiltersOrTransports( structure ) {
6745 // dataTypeExpression is optional and defaults to "*"
6746 return function( dataTypeExpression, func ) {
6748 if ( typeof dataTypeExpression !== "string" ) {
6749 func = dataTypeExpression;
6750 dataTypeExpression = "*";
6753 if ( jQuery.isFunction( func ) ) {
6754 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
6756 length = dataTypes.length,
6761 // For each dataType in the dataTypeExpression
6762 for(; i < length; i++ ) {
6763 dataType = dataTypes[ i ];
6764 // We control if we're asked to add before
6765 // any existing element
6766 placeBefore = /^\+/.test( dataType );
6767 if ( placeBefore ) {
6768 dataType = dataType.substr( 1 ) || "*";
6770 list = structure[ dataType ] = structure[ dataType ] || [];
6771 // then we add to the structure accordingly
6772 list[ placeBefore ? "unshift" : "push" ]( func );
6778 // Base inspection function for prefilters and transports
6779 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6780 dataType /* internal */, inspected /* internal */ ) {
6782 dataType = dataType || options.dataTypes[ 0 ];
6783 inspected = inspected || {};
6785 inspected[ dataType ] = true;
6787 var list = structure[ dataType ],
6789 length = list ? list.length : 0,
6790 executeOnly = ( structure === prefilters ),
6793 for(; i < length && ( executeOnly || !selection ); i++ ) {
6794 selection = list[ i ]( options, originalOptions, jqXHR );
6795 // If we got redirected to another dataType
6796 // we try there if executing only and not done already
6797 if ( typeof selection === "string" ) {
6798 if ( !executeOnly || inspected[ selection ] ) {
6799 selection = undefined;
6801 options.dataTypes.unshift( selection );
6802 selection = inspectPrefiltersOrTransports(
6803 structure, options, originalOptions, jqXHR, selection, inspected );
6807 // If we're only executing or nothing was selected
6808 // we try the catchall dataType if not done already
6809 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6810 selection = inspectPrefiltersOrTransports(
6811 structure, options, originalOptions, jqXHR, "*", inspected );
6813 // unnecessary when only executing (prefilters)
6814 // but it'll be ignored by the caller in that case
6818 // A special extend for ajax options
6819 // that takes "flat" options (not to be deep extended)
6821 function ajaxExtend( target, src ) {
6823 flatOptions = jQuery.ajaxSettings.flatOptions || {};
6825 if ( src[ key ] !== undefined ) {
6826 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
6830 jQuery.extend( true, target, deep );
6835 load: function( url, params, callback ) {
6836 if ( typeof url !== "string" && _load ) {
6837 return _load.apply( this, arguments );
6839 // Don't do a request if no elements are being requested
6840 } else if ( !this.length ) {
6844 var off = url.indexOf( " " );
6846 var selector = url.slice( off, url.length );
6847 url = url.slice( 0, off );
6850 // Default to a GET request
6853 // If the second parameter was provided
6855 // If it's a function
6856 if ( jQuery.isFunction( params ) ) {
6857 // We assume that it's the callback
6861 // Otherwise, build a param string
6862 } else if ( typeof params === "object" ) {
6863 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
6870 // Request the remote document
6876 // Complete callback (responseText is used internally)
6877 complete: function( jqXHR, status, responseText ) {
6878 // Store the response as specified by the jqXHR object
6879 responseText = jqXHR.responseText;
6880 // If successful, inject the HTML into all the matched elements
6881 if ( jqXHR.isResolved() ) {
6882 // #4825: Get the actual response in case
6883 // a dataFilter is present in ajaxSettings
6884 jqXHR.done(function( r ) {
6887 // See if a selector was specified
6888 self.html( selector ?
6889 // Create a dummy div to hold the results
6891 // inject the contents of the document in, removing the scripts
6892 // to avoid any 'Permission Denied' errors in IE
6893 .append(responseText.replace(rscript, ""))
6895 // Locate the specified elements
6898 // If not, just inject the full result
6903 self.each( callback, [ responseText, status, jqXHR ] );
6911 serialize: function() {
6912 return jQuery.param( this.serializeArray() );
6915 serializeArray: function() {
6916 return this.map(function(){
6917 return this.elements ? jQuery.makeArray( this.elements ) : this;
6920 return this.name && !this.disabled &&
6921 ( this.checked || rselectTextarea.test( this.nodeName ) ||
6922 rinput.test( this.type ) );
6924 .map(function( i, elem ){
6925 var val = jQuery( this ).val();
6927 return val == null ?
6929 jQuery.isArray( val ) ?
6930 jQuery.map( val, function( val, i ){
6931 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6933 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6938 // Attach a bunch of functions for handling common AJAX events
6939 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
6940 jQuery.fn[ o ] = function( f ){
6941 return this.bind( o, f );
6945 jQuery.each( [ "get", "post" ], function( i, method ) {
6946 jQuery[ method ] = function( url, data, callback, type ) {
6947 // shift arguments if data argument was omitted
6948 if ( jQuery.isFunction( data ) ) {
6949 type = type || callback;
6954 return jQuery.ajax({
6966 getScript: function( url, callback ) {
6967 return jQuery.get( url, undefined, callback, "script" );
6970 getJSON: function( url, data, callback ) {
6971 return jQuery.get( url, data, callback, "json" );
6974 // Creates a full fledged settings object into target
6975 // with both ajaxSettings and settings fields.
6976 // If target is omitted, writes into ajaxSettings.
6977 ajaxSetup: function( target, settings ) {
6979 // Building a settings object
6980 ajaxExtend( target, jQuery.ajaxSettings );
6982 // Extending ajaxSettings
6984 target = jQuery.ajaxSettings;
6986 ajaxExtend( target, settings );
6992 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
6995 contentType: "application/x-www-form-urlencoded",
7010 xml: "application/xml, text/xml",
7013 json: "application/json, text/javascript",
7025 text: "responseText"
7028 // List of data converters
7029 // 1) key format is "source_type destination_type" (a single space in-between)
7030 // 2) the catchall symbol "*" can be used for source_type
7033 // Convert anything to text
7034 "* text": window.String,
7036 // Text to html (true = no transformation)
7039 // Evaluate text as a json expression
7040 "text json": jQuery.parseJSON,
7042 // Parse text as xml
7043 "text xml": jQuery.parseXML
7046 // For options that shouldn't be deep extended:
7047 // you can add your own custom options here if
7048 // and when you create one that shouldn't be
7049 // deep extended (see ajaxExtend)
7056 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7057 ajaxTransport: addToPrefiltersOrTransports( transports ),
7060 ajax: function( url, options ) {
7062 // If url is an object, simulate pre-1.5 signature
7063 if ( typeof url === "object" ) {
7068 // Force options to be an object
7069 options = options || {};
7071 var // Create the final options object
7072 s = jQuery.ajaxSetup( {}, options ),
7073 // Callbacks context
7074 callbackContext = s.context || s,
7075 // Context for global events
7076 // It's the callbackContext if one was provided in the options
7077 // and if it's a DOM node or a jQuery collection
7078 globalEventContext = callbackContext !== s &&
7079 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7080 jQuery( callbackContext ) : jQuery.event,
7082 deferred = jQuery.Deferred(),
7083 completeDeferred = jQuery._Deferred(),
7084 // Status-dependent callbacks
7085 statusCode = s.statusCode || {},
7088 // Headers (they are sent all at once)
7089 requestHeaders = {},
7090 requestHeadersNames = {},
7092 responseHeadersString,
7098 // Cross-domain detection vars
7102 // To know if global events are to be dispatched
7111 // Caches the header
7112 setRequestHeader: function( name, value ) {
7114 var lname = name.toLowerCase();
7115 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7116 requestHeaders[ name ] = value;
7122 getAllResponseHeaders: function() {
7123 return state === 2 ? responseHeadersString : null;
7126 // Builds headers hashtable if needed
7127 getResponseHeader: function( key ) {
7129 if ( state === 2 ) {
7130 if ( !responseHeaders ) {
7131 responseHeaders = {};
7132 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7133 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7136 match = responseHeaders[ key.toLowerCase() ];
7138 return match === undefined ? null : match;
7141 // Overrides response content-type header
7142 overrideMimeType: function( type ) {
7149 // Cancel the request
7150 abort: function( statusText ) {
7151 statusText = statusText || "abort";
7153 transport.abort( statusText );
7155 done( 0, statusText );
7160 // Callback for when everything is done
7161 // It is defined here because jslint complains if it is declared
7162 // at the end of the function (which would be more logical and readable)
7163 function done( status, nativeStatusText, responses, headers ) {
7166 if ( state === 2 ) {
7170 // State is "done" now
7173 // Clear timeout if it exists
7174 if ( timeoutTimer ) {
7175 clearTimeout( timeoutTimer );
7178 // Dereference transport for early garbage collection
7179 // (no matter how long the jqXHR object will be used)
7180 transport = undefined;
7182 // Cache response headers
7183 responseHeadersString = headers || "";
7186 jqXHR.readyState = status > 0 ? 4 : 0;
7191 statusText = nativeStatusText,
7192 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
7196 // If successful, handle type chaining
7197 if ( status >= 200 && status < 300 || status === 304 ) {
7199 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7200 if ( s.ifModified ) {
7202 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
7203 jQuery.lastModified[ ifModifiedKey ] = lastModified;
7205 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
7206 jQuery.etag[ ifModifiedKey ] = etag;
7211 if ( status === 304 ) {
7213 statusText = "notmodified";
7220 success = ajaxConvert( s, response );
7221 statusText = "success";
7224 // We have a parsererror
7225 statusText = "parsererror";
7230 // We extract error from statusText
7231 // then normalize statusText and status for non-aborts
7233 if( !statusText || status ) {
7234 statusText = "error";
7241 // Set data for the fake xhr object
7242 jqXHR.status = status;
7243 jqXHR.statusText = "" + ( nativeStatusText || statusText );
7247 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7249 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7252 // Status-dependent callbacks
7253 jqXHR.statusCode( statusCode );
7254 statusCode = undefined;
7256 if ( fireGlobals ) {
7257 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7258 [ jqXHR, s, isSuccess ? success : error ] );
7262 completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
7264 if ( fireGlobals ) {
7265 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7266 // Handle the global AJAX counter
7267 if ( !( --jQuery.active ) ) {
7268 jQuery.event.trigger( "ajaxStop" );
7274 deferred.promise( jqXHR );
7275 jqXHR.success = jqXHR.done;
7276 jqXHR.error = jqXHR.fail;
7277 jqXHR.complete = completeDeferred.done;
7279 // Status-dependent callbacks
7280 jqXHR.statusCode = function( map ) {
7285 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7288 tmp = map[ jqXHR.status ];
7289 jqXHR.then( tmp, tmp );
7295 // Remove hash character (#7531: and string promotion)
7296 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7297 // We also use the url parameter if available
7298 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7300 // Extract dataTypes list
7301 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
7303 // Determine if a cross-domain request is in order
7304 if ( s.crossDomain == null ) {
7305 parts = rurl.exec( s.url.toLowerCase() );
7306 s.crossDomain = !!( parts &&
7307 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7308 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7309 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7313 // Convert data if not already a string
7314 if ( s.data && s.processData && typeof s.data !== "string" ) {
7315 s.data = jQuery.param( s.data, s.traditional );
7319 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7321 // If request was aborted inside a prefiler, stop there
7322 if ( state === 2 ) {
7326 // We can fire global events as of now if asked to
7327 fireGlobals = s.global;
7329 // Uppercase the type
7330 s.type = s.type.toUpperCase();
7332 // Determine if request has content
7333 s.hasContent = !rnoContent.test( s.type );
7335 // Watch for a new set of requests
7336 if ( fireGlobals && jQuery.active++ === 0 ) {
7337 jQuery.event.trigger( "ajaxStart" );
7340 // More options handling for requests with no content
7341 if ( !s.hasContent ) {
7343 // If data is available, append data to url
7345 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7346 // #9682: remove data so that it's not used in an eventual retry
7350 // Get ifModifiedKey before adding the anti-cache parameter
7351 ifModifiedKey = s.url;
7353 // Add anti-cache in url if needed
7354 if ( s.cache === false ) {
7356 var ts = jQuery.now(),
7357 // try replacing _= if it is there
7358 ret = s.url.replace( rts, "$1_=" + ts );
7360 // if nothing was replaced, add timestamp to the end
7361 s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7365 // Set the correct header, if data is being sent
7366 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7367 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7370 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7371 if ( s.ifModified ) {
7372 ifModifiedKey = ifModifiedKey || s.url;
7373 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7374 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7376 if ( jQuery.etag[ ifModifiedKey ] ) {
7377 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7381 // Set the Accepts header for the server, depending on the dataType
7382 jqXHR.setRequestHeader(
7384 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7385 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7389 // Check for headers option
7390 for ( i in s.headers ) {
7391 jqXHR.setRequestHeader( i, s.headers[ i ] );
7394 // Allow custom headers/mimetypes and early abort
7395 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7396 // Abort if not done already
7402 // Install callbacks on deferreds
7403 for ( i in { success: 1, error: 1, complete: 1 } ) {
7404 jqXHR[ i ]( s[ i ] );
7408 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7410 // If no transport, we auto-abort
7412 done( -1, "No Transport" );
7414 jqXHR.readyState = 1;
7415 // Send global event
7416 if ( fireGlobals ) {
7417 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7420 if ( s.async && s.timeout > 0 ) {
7421 timeoutTimer = setTimeout( function(){
7422 jqXHR.abort( "timeout" );
7428 transport.send( requestHeaders, done );
7430 // Propagate exception as error if not done
7433 // Simply rethrow otherwise
7443 // Serialize an array of form elements or a set of
7444 // key/values into a query string
7445 param: function( a, traditional ) {
7447 add = function( key, value ) {
7448 // If value is a function, invoke it and return its value
7449 value = jQuery.isFunction( value ) ? value() : value;
7450 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7453 // Set traditional to true for jQuery <= 1.3.2 behavior.
7454 if ( traditional === undefined ) {
7455 traditional = jQuery.ajaxSettings.traditional;
7458 // If an array was passed in, assume that it is an array of form elements.
7459 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7460 // Serialize the form elements
7461 jQuery.each( a, function() {
7462 add( this.name, this.value );
7466 // If traditional, encode the "old" way (the way 1.3.2 or older
7467 // did it), otherwise encode params recursively.
7468 for ( var prefix in a ) {
7469 buildParams( prefix, a[ prefix ], traditional, add );
7473 // Return the resulting serialization
7474 return s.join( "&" ).replace( r20, "+" );
7478 function buildParams( prefix, obj, traditional, add ) {
7479 if ( jQuery.isArray( obj ) ) {
7480 // Serialize array item.
7481 jQuery.each( obj, function( i, v ) {
7482 if ( traditional || rbracket.test( prefix ) ) {
7483 // Treat each array item as a scalar.
7487 // If array item is non-scalar (array or object), encode its
7488 // numeric index to resolve deserialization ambiguity issues.
7489 // Note that rack (as of 1.0.0) can't currently deserialize
7490 // nested arrays properly, and attempting to do so may cause
7491 // a server error. Possible fixes are to modify rack's
7492 // deserialization algorithm or to provide an option or flag
7493 // to force array serialization to be shallow.
7494 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
7498 } else if ( !traditional && obj != null && typeof obj === "object" ) {
7499 // Serialize object item.
7500 for ( var name in obj ) {
7501 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7505 // Serialize scalar item.
7510 // This is still on the jQuery object... for now
7511 // Want to move this to jQuery.ajax some day
7514 // Counter for holding the number of active queries
7517 // Last-Modified header cache for next request
7523 /* Handles responses to an ajax request:
7524 * - sets all responseXXX fields accordingly
7525 * - finds the right dataType (mediates between content-type and expected dataType)
7526 * - returns the corresponding response
7528 function ajaxHandleResponses( s, jqXHR, responses ) {
7530 var contents = s.contents,
7531 dataTypes = s.dataTypes,
7532 responseFields = s.responseFields,
7538 // Fill responseXXX fields
7539 for( type in responseFields ) {
7540 if ( type in responses ) {
7541 jqXHR[ responseFields[type] ] = responses[ type ];
7545 // Remove auto dataType and get content-type in the process
7546 while( dataTypes[ 0 ] === "*" ) {
7548 if ( ct === undefined ) {
7549 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
7553 // Check if we're dealing with a known content-type
7555 for ( type in contents ) {
7556 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7557 dataTypes.unshift( type );
7563 // Check to see if we have a response for the expected dataType
7564 if ( dataTypes[ 0 ] in responses ) {
7565 finalDataType = dataTypes[ 0 ];
7567 // Try convertible dataTypes
7568 for ( type in responses ) {
7569 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7570 finalDataType = type;
7573 if ( !firstDataType ) {
7574 firstDataType = type;
7577 // Or just use first one
7578 finalDataType = finalDataType || firstDataType;
7581 // If we found a dataType
7582 // We add the dataType to the list if needed
7583 // and return the corresponding response
7584 if ( finalDataType ) {
7585 if ( finalDataType !== dataTypes[ 0 ] ) {
7586 dataTypes.unshift( finalDataType );
7588 return responses[ finalDataType ];
7592 // Chain conversions given the request and the original response
7593 function ajaxConvert( s, response ) {
7595 // Apply the dataFilter if provided
7596 if ( s.dataFilter ) {
7597 response = s.dataFilter( response, s.dataType );
7600 var dataTypes = s.dataTypes,
7604 length = dataTypes.length,
7606 // Current and previous dataTypes
7607 current = dataTypes[ 0 ],
7609 // Conversion expression
7611 // Conversion function
7613 // Conversion functions (transitive conversion)
7617 // For each dataType in the chain
7618 for( i = 1; i < length; i++ ) {
7620 // Create converters map
7621 // with lowercased keys
7623 for( key in s.converters ) {
7624 if( typeof key === "string" ) {
7625 converters[ key.toLowerCase() ] = s.converters[ key ];
7630 // Get the dataTypes
7632 current = dataTypes[ i ];
7634 // If current is auto dataType, update it to prev
7635 if( current === "*" ) {
7637 // If no auto and dataTypes are actually different
7638 } else if ( prev !== "*" && prev !== current ) {
7640 // Get the converter
7641 conversion = prev + " " + current;
7642 conv = converters[ conversion ] || converters[ "* " + current ];
7644 // If there is no direct converter, search transitively
7647 for( conv1 in converters ) {
7648 tmp = conv1.split( " " );
7649 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7650 conv2 = converters[ tmp[1] + " " + current ];
7652 conv1 = converters[ conv1 ];
7653 if ( conv1 === true ) {
7655 } else if ( conv2 === true ) {
7663 // If we found no converter, dispatch an error
7664 if ( !( conv || conv2 ) ) {
7665 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
7667 // If found converter is not an equivalence
7668 if ( conv !== true ) {
7669 // Convert with 1 or 2 converters accordingly
7670 response = conv ? conv( response ) : conv2( conv1(response) );
7680 var jsc = jQuery.now(),
7681 jsre = /(\=)\?(&|$)|\?\?/i;
7683 // Default jsonp settings
7686 jsonpCallback: function() {
7687 return jQuery.expando + "_" + ( jsc++ );
7691 // Detect, normalize options and install callbacks for jsonp requests
7692 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
7694 var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
7695 ( typeof s.data === "string" );
7697 if ( s.dataTypes[ 0 ] === "jsonp" ||
7698 s.jsonp !== false && ( jsre.test( s.url ) ||
7699 inspectData && jsre.test( s.data ) ) ) {
7701 var responseContainer,
7702 jsonpCallback = s.jsonpCallback =
7703 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
7704 previous = window[ jsonpCallback ],
7707 replace = "$1" + jsonpCallback + "$2";
7709 if ( s.jsonp !== false ) {
7710 url = url.replace( jsre, replace );
7711 if ( s.url === url ) {
7712 if ( inspectData ) {
7713 data = data.replace( jsre, replace );
7715 if ( s.data === data ) {
7716 // Add callback manually
7717 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
7726 window[ jsonpCallback ] = function( response ) {
7727 responseContainer = [ response ];
7730 // Clean-up function
7731 jqXHR.always(function() {
7732 // Set callback back to previous value
7733 window[ jsonpCallback ] = previous;
7734 // Call if it was a function and we have a response
7735 if ( responseContainer && jQuery.isFunction( previous ) ) {
7736 window[ jsonpCallback ]( responseContainer[ 0 ] );
7740 // Use data converter to retrieve json after script execution
7741 s.converters["script json"] = function() {
7742 if ( !responseContainer ) {
7743 jQuery.error( jsonpCallback + " was not called" );
7745 return responseContainer[ 0 ];
7748 // force json dataType
7749 s.dataTypes[ 0 ] = "json";
7751 // Delegate to script
7759 // Install script dataType
7762 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7765 script: /javascript|ecmascript/
7768 "text script": function( text ) {
7769 jQuery.globalEval( text );
7775 // Handle cache's special case and global
7776 jQuery.ajaxPrefilter( "script", function( s ) {
7777 if ( s.cache === undefined ) {
7780 if ( s.crossDomain ) {
7786 // Bind script tag hack transport
7787 jQuery.ajaxTransport( "script", function(s) {
7789 // This transport only deals with cross domain requests
7790 if ( s.crossDomain ) {
7793 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7797 send: function( _, callback ) {
7799 script = document.createElement( "script" );
7801 script.async = "async";
7803 if ( s.scriptCharset ) {
7804 script.charset = s.scriptCharset;
7809 // Attach handlers for all browsers
7810 script.onload = script.onreadystatechange = function( _, isAbort ) {
7812 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
7814 // Handle memory leak in IE
7815 script.onload = script.onreadystatechange = null;
7817 // Remove the script
7818 if ( head && script.parentNode ) {
7819 head.removeChild( script );
7822 // Dereference the script
7825 // Callback if not abort
7827 callback( 200, "success" );
7831 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
7832 // This arises when a base node is used (#2709 and #4378).
7833 head.insertBefore( script, head.firstChild );
7838 script.onload( 0, 1 );
7848 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
7849 xhrOnUnloadAbort = window.ActiveXObject ? function() {
7850 // Abort all pending requests
7851 for ( var key in xhrCallbacks ) {
7852 xhrCallbacks[ key ]( 0, 1 );
7858 // Functions to create xhrs
7859 function createStandardXHR() {
7861 return new window.XMLHttpRequest();
7865 function createActiveXHR() {
7867 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
7871 // Create the request object
7872 // (This is still attached to ajaxSettings for backward compatibility)
7873 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
7874 /* Microsoft failed to properly
7875 * implement the XMLHttpRequest in IE7 (can't request local files),
7876 * so we use the ActiveXObject when it is available
7877 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
7878 * we need a fallback.
7881 return !this.isLocal && createStandardXHR() || createActiveXHR();
7883 // For all other browsers, use the standard XMLHttpRequest object
7886 // Determine support properties
7888 jQuery.extend( jQuery.support, {
7890 cors: !!xhr && ( "withCredentials" in xhr )
7892 })( jQuery.ajaxSettings.xhr() );
7894 // Create transport if the browser can provide an xhr
7895 if ( jQuery.support.ajax ) {
7897 jQuery.ajaxTransport(function( s ) {
7898 // Cross domain only allowed if supported through XMLHttpRequest
7899 if ( !s.crossDomain || jQuery.support.cors ) {
7904 send: function( headers, complete ) {
7912 // Passing null username, generates a login popup on Opera (#2865)
7914 xhr.open( s.type, s.url, s.async, s.username, s.password );
7916 xhr.open( s.type, s.url, s.async );
7919 // Apply custom fields if provided
7920 if ( s.xhrFields ) {
7921 for ( i in s.xhrFields ) {
7922 xhr[ i ] = s.xhrFields[ i ];
7926 // Override mime type if needed
7927 if ( s.mimeType && xhr.overrideMimeType ) {
7928 xhr.overrideMimeType( s.mimeType );
7931 // X-Requested-With header
7932 // For cross-domain requests, seeing as conditions for a preflight are
7933 // akin to a jigsaw puzzle, we simply never set it to be sure.
7934 // (it can always be set on a per-request basis or even using ajaxSetup)
7935 // For same-domain requests, won't change header if already provided.
7936 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
7937 headers[ "X-Requested-With" ] = "XMLHttpRequest";
7940 // Need an extra try/catch for cross domain requests in Firefox 3
7942 for ( i in headers ) {
7943 xhr.setRequestHeader( i, headers[ i ] );
7947 // Do send the request
7948 // This may raise an exception which is actually
7949 // handled in jQuery.ajax (so no try/catch here)
7950 xhr.send( ( s.hasContent && s.data ) || null );
7953 callback = function( _, isAbort ) {
7961 // Firefox throws exceptions when accessing properties
7962 // of an xhr when a network error occured
7963 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
7966 // Was never called and is aborted or complete
7967 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7970 callback = undefined;
7972 // Do not keep as active anymore
7974 xhr.onreadystatechange = jQuery.noop;
7975 if ( xhrOnUnloadAbort ) {
7976 delete xhrCallbacks[ handle ];
7982 // Abort it manually if needed
7983 if ( xhr.readyState !== 4 ) {
7987 status = xhr.status;
7988 responseHeaders = xhr.getAllResponseHeaders();
7990 xml = xhr.responseXML;
7992 // Construct response list
7993 if ( xml && xml.documentElement /* #4958 */ ) {
7994 responses.xml = xml;
7996 responses.text = xhr.responseText;
7998 // Firefox throws an exception when accessing
7999 // statusText for faulty cross-domain requests
8001 statusText = xhr.statusText;
8003 // We normalize with Webkit giving an empty statusText
8007 // Filter status for non standard behaviors
8009 // If the request is local and we have data: assume a success
8010 // (success with no data won't get notified, that's the best we
8011 // can do given current implementations)
8012 if ( !status && s.isLocal && !s.crossDomain ) {
8013 status = responses.text ? 200 : 404;
8014 // IE - #1450: sometimes returns 1223 when it should be 204
8015 } else if ( status === 1223 ) {
8020 } catch( firefoxAccessException ) {
8022 complete( -1, firefoxAccessException );
8026 // Call complete if needed
8028 complete( status, statusText, responses, responseHeaders );
8032 // if we're in sync mode or it's in cache
8033 // and has been retrieved directly (IE6 & IE7)
8034 // we need to manually fire the callback
8035 if ( !s.async || xhr.readyState === 4 ) {
8039 if ( xhrOnUnloadAbort ) {
8040 // Create the active xhrs callbacks list if needed
8041 // and attach the unload handler
8042 if ( !xhrCallbacks ) {
8044 jQuery( window ).unload( xhrOnUnloadAbort );
8046 // Add to list of active xhrs callbacks
8047 xhrCallbacks[ handle ] = callback;
8049 xhr.onreadystatechange = callback;
8066 var elemdisplay = {},
8068 rfxtypes = /^(?:toggle|show|hide)$/,
8069 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8072 // height animations
8073 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8075 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8076 // opacity animations
8082 show: function( speed, easing, callback ) {
8085 if ( speed || speed === 0 ) {
8086 return this.animate( genFx("show", 3), speed, easing, callback);
8089 for ( var i = 0, j = this.length; i < j; i++ ) {
8093 display = elem.style.display;
8095 // Reset the inline display of this element to learn if it is
8096 // being hidden by cascaded rules or not
8097 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
8098 display = elem.style.display = "";
8101 // Set elements which have been overridden with display: none
8102 // in a stylesheet to whatever the default browser style is
8103 // for such an element
8104 if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
8105 jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
8110 // Set the display of most of the elements in a second loop
8111 // to avoid the constant reflow
8112 for ( i = 0; i < j; i++ ) {
8116 display = elem.style.display;
8118 if ( display === "" || display === "none" ) {
8119 elem.style.display = jQuery._data(elem, "olddisplay") || "";
8128 hide: function( speed, easing, callback ) {
8129 if ( speed || speed === 0 ) {
8130 return this.animate( genFx("hide", 3), speed, easing, callback);
8133 for ( var i = 0, j = this.length; i < j; i++ ) {
8134 if ( this[i].style ) {
8135 var display = jQuery.css( this[i], "display" );
8137 if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
8138 jQuery._data( this[i], "olddisplay", display );
8143 // Set the display of the elements in a second loop
8144 // to avoid the constant reflow
8145 for ( i = 0; i < j; i++ ) {
8146 if ( this[i].style ) {
8147 this[i].style.display = "none";
8155 // Save the old toggle function
8156 _toggle: jQuery.fn.toggle,
8158 toggle: function( fn, fn2, callback ) {
8159 var bool = typeof fn === "boolean";
8161 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
8162 this._toggle.apply( this, arguments );
8164 } else if ( fn == null || bool ) {
8165 this.each(function() {
8166 var state = bool ? fn : jQuery(this).is(":hidden");
8167 jQuery(this)[ state ? "show" : "hide" ]();
8171 this.animate(genFx("toggle", 3), fn, fn2, callback);
8177 fadeTo: function( speed, to, easing, callback ) {
8178 return this.filter(":hidden").css("opacity", 0).show().end()
8179 .animate({opacity: to}, speed, easing, callback);
8182 animate: function( prop, speed, easing, callback ) {
8183 var optall = jQuery.speed(speed, easing, callback);
8185 if ( jQuery.isEmptyObject( prop ) ) {
8186 return this.each( optall.complete, [ false ] );
8189 // Do not change referenced properties as per-property easing will be lost
8190 prop = jQuery.extend( {}, prop );
8192 return this[ optall.queue === false ? "each" : "queue" ](function() {
8193 // XXX 'this' does not always have a nodeName when running the
8196 if ( optall.queue === false ) {
8197 jQuery._mark( this );
8200 var opt = jQuery.extend( {}, optall ),
8201 isElement = this.nodeType === 1,
8202 hidden = isElement && jQuery(this).is(":hidden"),
8205 parts, start, end, unit;
8207 // will store per property easing and be used to determine when an animation is complete
8208 opt.animatedProperties = {};
8212 // property name normalization
8213 name = jQuery.camelCase( p );
8215 prop[ name ] = prop[ p ];
8221 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8222 if ( jQuery.isArray( val ) ) {
8223 opt.animatedProperties[ name ] = val[ 1 ];
8224 val = prop[ name ] = val[ 0 ];
8226 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
8229 if ( val === "hide" && hidden || val === "show" && !hidden ) {
8230 return opt.complete.call( this );
8233 if ( isElement && ( name === "height" || name === "width" ) ) {
8234 // Make sure that nothing sneaks out
8235 // Record all 3 overflow attributes because IE does not
8236 // change the overflow attribute when overflowX and
8237 // overflowY are set to the same value
8238 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
8240 // Set display property to inline-block for height/width
8241 // animations on inline elements that are having width/height
8243 if ( jQuery.css( this, "display" ) === "inline" &&
8244 jQuery.css( this, "float" ) === "none" ) {
8245 if ( !jQuery.support.inlineBlockNeedsLayout ) {
8246 this.style.display = "inline-block";
8249 display = defaultDisplay( this.nodeName );
8251 // inline-level elements accept inline-block;
8252 // block-level elements need to be inline with layout
8253 if ( display === "inline" ) {
8254 this.style.display = "inline-block";
8257 this.style.display = "inline";
8258 this.style.zoom = 1;
8265 if ( opt.overflow != null ) {
8266 this.style.overflow = "hidden";
8270 e = new jQuery.fx( this, opt, p );
8273 if ( rfxtypes.test(val) ) {
8274 e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
8277 parts = rfxnum.exec( val );
8281 end = parseFloat( parts[2] );
8282 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
8284 // We need to compute starting value
8285 if ( unit !== "px" ) {
8286 jQuery.style( this, p, (end || 1) + unit);
8287 start = ((end || 1) / e.cur()) * start;
8288 jQuery.style( this, p, start + unit);
8291 // If a +=/-= token was provided, we're doing a relative animation
8293 end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
8296 e.custom( start, end, unit );
8299 e.custom( start, val, "" );
8304 // For JS strict compliance
8309 stop: function( clearQueue, gotoEnd ) {
8314 this.each(function() {
8315 var timers = jQuery.timers,
8317 // clear marker counters if we know they won't be
8319 jQuery._unmark( true, this );
8322 if ( timers[i].elem === this ) {
8324 // force the next step to be the last
8328 timers.splice(i, 1);
8333 // start the next in the queue if the last step wasn't forced
8343 // Animations created synchronously will run synchronously
8344 function createFxNow() {
8345 setTimeout( clearFxNow, 0 );
8346 return ( fxNow = jQuery.now() );
8349 function clearFxNow() {
8353 // Generate parameters to create a standard animation
8354 function genFx( type, num ) {
8357 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
8364 // Generate shortcuts for custom animations
8366 slideDown: genFx("show", 1),
8367 slideUp: genFx("hide", 1),
8368 slideToggle: genFx("toggle", 1),
8369 fadeIn: { opacity: "show" },
8370 fadeOut: { opacity: "hide" },
8371 fadeToggle: { opacity: "toggle" }
8372 }, function( name, props ) {
8373 jQuery.fn[ name ] = function( speed, easing, callback ) {
8374 return this.animate( props, speed, easing, callback );
8379 speed: function( speed, easing, fn ) {
8380 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
8381 complete: fn || !fn && easing ||
8382 jQuery.isFunction( speed ) && speed,
8384 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
8387 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8388 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
8391 opt.old = opt.complete;
8392 opt.complete = function( noUnmark ) {
8393 if ( jQuery.isFunction( opt.old ) ) {
8394 opt.old.call( this );
8397 if ( opt.queue !== false ) {
8398 jQuery.dequeue( this );
8399 } else if ( noUnmark !== false ) {
8400 jQuery._unmark( this );
8408 linear: function( p, n, firstNum, diff ) {
8409 return firstNum + diff * p;
8411 swing: function( p, n, firstNum, diff ) {
8412 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
8418 fx: function( elem, options, prop ) {
8419 this.options = options;
8423 options.orig = options.orig || {};
8428 jQuery.fx.prototype = {
8429 // Simple function for setting a style value
8430 update: function() {
8431 if ( this.options.step ) {
8432 this.options.step.call( this.elem, this.now, this );
8435 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
8438 // Get the current size
8440 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
8441 return this.elem[ this.prop ];
8445 r = jQuery.css( this.elem, this.prop );
8446 // Empty strings, null, undefined and "auto" are converted to 0,
8447 // complex values such as "rotate(1rad)" are returned as is,
8448 // simple values such as "10px" are parsed to Float.
8449 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
8452 // Start an animation from one number to another
8453 custom: function( from, to, unit ) {
8457 this.startTime = fxNow || createFxNow();
8460 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8461 this.now = this.start;
8462 this.pos = this.state = 0;
8464 function t( gotoEnd ) {
8465 return self.step(gotoEnd);
8470 if ( t() && jQuery.timers.push(t) && !timerId ) {
8471 timerId = setInterval( fx.tick, fx.interval );
8475 // Simple 'show' function
8477 // Remember where we started, so that we can go back to it later
8478 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8479 this.options.show = true;
8481 // Begin the animation
8482 // Make sure that we start at a small width/height to avoid any
8484 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
8486 // Start by showing the element
8487 jQuery( this.elem ).show();
8490 // Simple 'hide' function
8492 // Remember where we started, so that we can go back to it later
8493 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8494 this.options.hide = true;
8496 // Begin the animation
8497 this.custom(this.cur(), 0);
8500 // Each step of an animation
8501 step: function( gotoEnd ) {
8502 var t = fxNow || createFxNow(),
8505 options = this.options,
8508 if ( gotoEnd || t >= options.duration + this.startTime ) {
8509 this.now = this.end;
8510 this.pos = this.state = 1;
8513 options.animatedProperties[ this.prop ] = true;
8515 for ( i in options.animatedProperties ) {
8516 if ( options.animatedProperties[i] !== true ) {
8522 // Reset the overflow
8523 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
8525 jQuery.each( [ "", "X", "Y" ], function (index, value) {
8526 elem.style[ "overflow" + value ] = options.overflow[index];
8530 // Hide the element if the "hide" operation was done
8531 if ( options.hide ) {
8532 jQuery(elem).hide();
8535 // Reset the properties, if the item has been hidden or shown
8536 if ( options.hide || options.show ) {
8537 for ( var p in options.animatedProperties ) {
8538 jQuery.style( elem, p, options.orig[p] );
8542 // Execute the complete function
8543 options.complete.call( elem );
8549 // classical easing cannot be used with an Infinity duration
8550 if ( options.duration == Infinity ) {
8553 n = t - this.startTime;
8554 this.state = n / options.duration;
8556 // Perform the easing function, defaults to swing
8557 this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
8558 this.now = this.start + ((this.end - this.start) * this.pos);
8560 // Perform the next step of the animation
8568 jQuery.extend( jQuery.fx, {
8570 for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
8571 if ( !timers[i]() ) {
8572 timers.splice(i--, 1);
8576 if ( !timers.length ) {
8584 clearInterval( timerId );
8596 opacity: function( fx ) {
8597 jQuery.style( fx.elem, "opacity", fx.now );
8600 _default: function( fx ) {
8601 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
8602 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
8604 fx.elem[ fx.prop ] = fx.now;
8610 if ( jQuery.expr && jQuery.expr.filters ) {
8611 jQuery.expr.filters.animated = function( elem ) {
8612 return jQuery.grep(jQuery.timers, function( fn ) {
8613 return elem === fn.elem;
8618 // Try to restore the default display value of an element
8619 function defaultDisplay( nodeName ) {
8621 if ( !elemdisplay[ nodeName ] ) {
8623 var body = document.body,
8624 elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
8625 display = elem.css( "display" );
8629 // If the simple way fails,
8630 // get element's real default display by attaching it to a temp iframe
8631 if ( display === "none" || display === "" ) {
8632 // No iframe to use yet, so create it
8634 iframe = document.createElement( "iframe" );
8635 iframe.frameBorder = iframe.width = iframe.height = 0;
8638 body.appendChild( iframe );
8640 // Create a cacheable copy of the iframe document on first call.
8641 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8642 // document to it; WebKit & Firefox won't allow reusing the iframe document.
8643 if ( !iframeDoc || !iframe.createElement ) {
8644 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
8645 iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8649 elem = iframeDoc.createElement( nodeName );
8651 iframeDoc.body.appendChild( elem );
8653 display = jQuery.css( elem, "display" );
8655 body.removeChild( iframe );
8658 // Store the correct default display
8659 elemdisplay[ nodeName ] = display;
8662 return elemdisplay[ nodeName ];
8668 var rtable = /^t(?:able|d|h)$/i,
8669 rroot = /^(?:body|html)$/i;
8671 if ( "getBoundingClientRect" in document.documentElement ) {
8672 jQuery.fn.offset = function( options ) {
8673 var elem = this[0], box;
8676 return this.each(function( i ) {
8677 jQuery.offset.setOffset( this, options, i );
8681 if ( !elem || !elem.ownerDocument ) {
8685 if ( elem === elem.ownerDocument.body ) {
8686 return jQuery.offset.bodyOffset( elem );
8690 box = elem.getBoundingClientRect();
8693 var doc = elem.ownerDocument,
8694 docElem = doc.documentElement;
8696 // Make sure we're not dealing with a disconnected DOM node
8697 if ( !box || !jQuery.contains( docElem, elem ) ) {
8698 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
8701 var body = doc.body,
8702 win = getWindow(doc),
8703 clientTop = docElem.clientTop || body.clientTop || 0,
8704 clientLeft = docElem.clientLeft || body.clientLeft || 0,
8705 scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
8706 scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
8707 top = box.top + scrollTop - clientTop,
8708 left = box.left + scrollLeft - clientLeft;
8710 return { top: top, left: left };
8714 jQuery.fn.offset = function( options ) {
8718 return this.each(function( i ) {
8719 jQuery.offset.setOffset( this, options, i );
8723 if ( !elem || !elem.ownerDocument ) {
8727 if ( elem === elem.ownerDocument.body ) {
8728 return jQuery.offset.bodyOffset( elem );
8731 jQuery.offset.initialize();
8734 offsetParent = elem.offsetParent,
8735 prevOffsetParent = elem,
8736 doc = elem.ownerDocument,
8737 docElem = doc.documentElement,
8739 defaultView = doc.defaultView,
8740 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
8741 top = elem.offsetTop,
8742 left = elem.offsetLeft;
8744 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
8745 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
8749 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
8750 top -= elem.scrollTop;
8751 left -= elem.scrollLeft;
8753 if ( elem === offsetParent ) {
8754 top += elem.offsetTop;
8755 left += elem.offsetLeft;
8757 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
8758 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8759 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8762 prevOffsetParent = offsetParent;
8763 offsetParent = elem.offsetParent;
8766 if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
8767 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8768 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8771 prevComputedStyle = computedStyle;
8774 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
8775 top += body.offsetTop;
8776 left += body.offsetLeft;
8779 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
8780 top += Math.max( docElem.scrollTop, body.scrollTop );
8781 left += Math.max( docElem.scrollLeft, body.scrollLeft );
8784 return { top: top, left: left };
8789 initialize: function() {
8790 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
8791 html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
8793 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
8795 container.innerHTML = html;
8796 body.insertBefore( container, body.firstChild );
8797 innerDiv = container.firstChild;
8798 checkDiv = innerDiv.firstChild;
8799 td = innerDiv.nextSibling.firstChild.firstChild;
8801 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
8802 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
8804 checkDiv.style.position = "fixed";
8805 checkDiv.style.top = "20px";
8807 // safari subtracts parent border width here which is 5px
8808 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
8809 checkDiv.style.position = checkDiv.style.top = "";
8811 innerDiv.style.overflow = "hidden";
8812 innerDiv.style.position = "relative";
8814 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
8816 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
8818 body.removeChild( container );
8819 jQuery.offset.initialize = jQuery.noop;
8822 bodyOffset: function( body ) {
8823 var top = body.offsetTop,
8824 left = body.offsetLeft;
8826 jQuery.offset.initialize();
8828 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
8829 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
8830 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
8833 return { top: top, left: left };
8836 setOffset: function( elem, options, i ) {
8837 var position = jQuery.css( elem, "position" );
8839 // set position first, in-case top/left are set even on static elem
8840 if ( position === "static" ) {
8841 elem.style.position = "relative";
8844 var curElem = jQuery( elem ),
8845 curOffset = curElem.offset(),
8846 curCSSTop = jQuery.css( elem, "top" ),
8847 curCSSLeft = jQuery.css( elem, "left" ),
8848 calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
8849 props = {}, curPosition = {}, curTop, curLeft;
8851 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
8852 if ( calculatePosition ) {
8853 curPosition = curElem.position();
8854 curTop = curPosition.top;
8855 curLeft = curPosition.left;
8857 curTop = parseFloat( curCSSTop ) || 0;
8858 curLeft = parseFloat( curCSSLeft ) || 0;
8861 if ( jQuery.isFunction( options ) ) {
8862 options = options.call( elem, i, curOffset );
8865 if (options.top != null) {
8866 props.top = (options.top - curOffset.top) + curTop;
8868 if (options.left != null) {
8869 props.left = (options.left - curOffset.left) + curLeft;
8872 if ( "using" in options ) {
8873 options.using.call( elem, props );
8875 curElem.css( props );
8882 position: function() {
8889 // Get *real* offsetParent
8890 offsetParent = this.offsetParent(),
8892 // Get correct offsets
8893 offset = this.offset(),
8894 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
8896 // Subtract element margins
8897 // note: when an element has margin: auto the offsetLeft and marginLeft
8898 // are the same in Safari causing offset.left to incorrectly be 0
8899 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
8900 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
8902 // Add offsetParent borders
8903 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
8904 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
8906 // Subtract the two offsets
8908 top: offset.top - parentOffset.top,
8909 left: offset.left - parentOffset.left
8913 offsetParent: function() {
8914 return this.map(function() {
8915 var offsetParent = this.offsetParent || document.body;
8916 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
8917 offsetParent = offsetParent.offsetParent;
8919 return offsetParent;
8925 // Create scrollLeft and scrollTop methods
8926 jQuery.each( ["Left", "Top"], function( i, name ) {
8927 var method = "scroll" + name;
8929 jQuery.fn[ method ] = function( val ) {
8932 if ( val === undefined ) {
8939 win = getWindow( elem );
8941 // Return the scroll offset
8942 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
8943 jQuery.support.boxModel && win.document.documentElement[ method ] ||
8944 win.document.body[ method ] :
8948 // Set the scroll offset
8949 return this.each(function() {
8950 win = getWindow( this );
8954 !i ? val : jQuery( win ).scrollLeft(),
8955 i ? val : jQuery( win ).scrollTop()
8959 this[ method ] = val;
8965 function getWindow( elem ) {
8966 return jQuery.isWindow( elem ) ?
8968 elem.nodeType === 9 ?
8969 elem.defaultView || elem.parentWindow :
8976 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
8977 jQuery.each([ "Height", "Width" ], function( i, name ) {
8979 var type = name.toLowerCase();
8981 // innerHeight and innerWidth
8982 jQuery.fn[ "inner" + name ] = function() {
8984 return elem && elem.style ?
8985 parseFloat( jQuery.css( elem, type, "padding" ) ) :
8989 // outerHeight and outerWidth
8990 jQuery.fn[ "outer" + name ] = function( margin ) {
8992 return elem && elem.style ?
8993 parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
8997 jQuery.fn[ type ] = function( size ) {
8998 // Get window width or height
9001 return size == null ? null : this;
9004 if ( jQuery.isFunction( size ) ) {
9005 return this.each(function( i ) {
9006 var self = jQuery( this );
9007 self[ type ]( size.call( this, i, self[ type ]() ) );
9011 if ( jQuery.isWindow( elem ) ) {
9012 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9013 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9014 var docElemProp = elem.document.documentElement[ "client" + name ],
9015 body = elem.document.body;
9016 return elem.document.compatMode === "CSS1Compat" && docElemProp ||
9017 body && body[ "client" + name ] || docElemProp;
9019 // Get document width or height
9020 } else if ( elem.nodeType === 9 ) {
9021 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9023 elem.documentElement["client" + name],
9024 elem.body["scroll" + name], elem.documentElement["scroll" + name],
9025 elem.body["offset" + name], elem.documentElement["offset" + name]
9028 // Get or set width or height on the element
9029 } else if ( size === undefined ) {
9030 var orig = jQuery.css( elem, type ),
9031 ret = parseFloat( orig );
9033 return jQuery.isNaN( ret ) ? orig : ret;
9035 // Set the width or height on the element (default to pixels if value is unitless)
9037 return this.css( type, typeof size === "string" ? size : size + "px" );
9044 // Expose jQuery to the global object
9045 window.jQuery = window.$ = jQuery;