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
17 (function( window, undefined ) {
19 // Use the correct document accordingly with window argument (sandbox)
20 var document = window.document,
21 navigator = window.navigator,
22 location = window.location;
23 var jQuery = (function() {
25 // Define a local copy of jQuery
26 var jQuery = function( selector, context ) {
27 // The jQuery object is actually just the init constructor 'enhanced'
28 return new jQuery.fn.init( selector, context, rootjQuery );
31 // Map over jQuery in case of overwrite
32 _jQuery = window.jQuery,
34 // Map over the $ in case of overwrite
37 // A central reference to the root jQuery(document)
40 // A simple way to check for HTML strings or ID strings
41 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
42 quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
44 // Check if a string has a non-whitespace character in it
47 // Used for trimming whitespace
54 // Match a standalone tag
55 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
58 rvalidchars = /^[\],:{}\s]*$/,
59 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
60 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
61 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
64 rwebkit = /(webkit)[ \/]([\w.]+)/,
65 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
66 rmsie = /(msie) ([\w.]+)/,
67 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
69 // Matches dashed string for camelizing
70 rdashAlpha = /-([a-z]|[0-9])/ig,
73 // Used by jQuery.camelCase as callback to replace()
74 fcamelCase = function( all, letter ) {
75 return ( letter + "" ).toUpperCase();
78 // Keep a UserAgent string for use with jQuery.browser
79 userAgent = navigator.userAgent,
81 // For matching the engine and version of the browser
84 // The deferred used on DOM ready
87 // The ready event handler
90 // Save a reference to some core methods
91 toString = Object.prototype.toString,
92 hasOwn = Object.prototype.hasOwnProperty,
93 push = Array.prototype.push,
94 slice = Array.prototype.slice,
95 trim = String.prototype.trim,
96 indexOf = Array.prototype.indexOf,
98 // [[Class]] -> type pairs
101 jQuery.fn = jQuery.prototype = {
103 init: function( selector, context, rootjQuery ) {
104 var match, elem, ret, doc;
106 // Handle $(""), $(null), or $(undefined)
111 // Handle $(DOMElement)
112 if ( selector.nodeType ) {
113 this.context = this[0] = selector;
118 // The body element only exists once, optimize finding it
119 if ( selector === "body" && !context && document.body ) {
120 this.context = document;
121 this[0] = document.body;
122 this.selector = selector;
127 // Handle HTML strings
128 if ( typeof selector === "string" ) {
129 // Are we dealing with HTML string or an ID?
130 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
131 // Assume that strings that start and end with <> are HTML and skip the regex check
132 match = [ null, selector, null ];
135 match = quickExpr.exec( selector );
138 // Verify a match, and that no context was specified for #id
139 if ( match && (match[1] || !context) ) {
141 // HANDLE: $(html) -> $(array)
143 context = context instanceof jQuery ? context[0] : context;
144 doc = (context ? context.ownerDocument || context : document);
146 // If a single string is passed in and it's a single tag
147 // just do a createElement and skip the rest
148 ret = rsingleTag.exec( selector );
151 if ( jQuery.isPlainObject( context ) ) {
152 selector = [ document.createElement( ret[1] ) ];
153 jQuery.fn.attr.call( selector, context, true );
156 selector = [ doc.createElement( ret[1] ) ];
160 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
161 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
164 return jQuery.merge( this, selector );
168 elem = document.getElementById( match[2] );
170 // Check parentNode to catch when Blackberry 4.6 returns
171 // nodes that are no longer in the document #6963
172 if ( elem && elem.parentNode ) {
173 // Handle the case where IE and Opera return items
174 // by name instead of ID
175 if ( elem.id !== match[2] ) {
176 return rootjQuery.find( selector );
179 // Otherwise, we inject the element directly into the jQuery object
184 this.context = document;
185 this.selector = selector;
189 // HANDLE: $(expr, $(...))
190 } else if ( !context || context.jquery ) {
191 return (context || rootjQuery).find( selector );
193 // HANDLE: $(expr, context)
194 // (which is just equivalent to: $(context).find(expr)
196 return this.constructor( context ).find( selector );
199 // HANDLE: $(function)
200 // Shortcut for document ready
201 } else if ( jQuery.isFunction( selector ) ) {
202 return rootjQuery.ready( selector );
205 if (selector.selector !== undefined) {
206 this.selector = selector.selector;
207 this.context = selector.context;
210 return jQuery.makeArray( selector, this );
213 // Start with an empty selector
216 // The current version of jQuery being used
219 // The default length of a jQuery object is 0
222 // The number of elements contained in the matched element set
227 toArray: function() {
228 return slice.call( this, 0 );
231 // Get the Nth element in the matched element set OR
232 // Get the whole matched element set as a clean array
233 get: function( num ) {
236 // Return a 'clean' array
239 // Return just the object
240 ( num < 0 ? this[ this.length + num ] : this[ num ] );
243 // Take an array of elements and push it onto the stack
244 // (returning the new matched element set)
245 pushStack: function( elems, name, selector ) {
246 // Build a new jQuery matched element set
247 var ret = this.constructor();
249 if ( jQuery.isArray( elems ) ) {
250 push.apply( ret, elems );
253 jQuery.merge( ret, elems );
256 // Add the old object onto the stack (as a reference)
257 ret.prevObject = this;
259 ret.context = this.context;
261 if ( name === "find" ) {
262 ret.selector = this.selector + (this.selector ? " " : "") + selector;
264 ret.selector = this.selector + "." + name + "(" + selector + ")";
267 // Return the newly-formed element set
271 // Execute a callback for every element in the matched set.
272 // (You can seed the arguments with an array of args, but this is
273 // only used internally.)
274 each: function( callback, args ) {
275 return jQuery.each( this, callback, args );
278 ready: function( fn ) {
279 // Attach the listeners
283 readyList.done( fn );
291 this.slice( i, +i + 1 );
299 return this.eq( -1 );
303 return this.pushStack( slice.apply( this, arguments ),
304 "slice", slice.call(arguments).join(",") );
307 map: function( callback ) {
308 return this.pushStack( jQuery.map(this, function( elem, i ) {
309 return callback.call( elem, i, elem );
314 return this.prevObject || this.constructor(null);
317 // For internal use only.
318 // Behaves like an Array's method, not like a jQuery method.
324 // Give the init function the jQuery prototype for later instantiation
325 jQuery.fn.init.prototype = jQuery.fn;
327 jQuery.extend = jQuery.fn.extend = function() {
328 var options, name, src, copy, copyIsArray, clone,
329 target = arguments[0] || {},
331 length = arguments.length,
334 // Handle a deep copy situation
335 if ( typeof target === "boolean" ) {
337 target = arguments[1] || {};
338 // skip the boolean and the target
342 // Handle case when target is a string or something (possible in deep copy)
343 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
347 // extend jQuery itself if only one argument is passed
348 if ( length === i ) {
353 for ( ; i < length; i++ ) {
354 // Only deal with non-null/undefined values
355 if ( (options = arguments[ i ]) != null ) {
356 // Extend the base object
357 for ( name in options ) {
358 src = target[ name ];
359 copy = options[ name ];
361 // Prevent never-ending loop
362 if ( target === copy ) {
366 // Recurse if we're merging plain objects or arrays
367 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
370 clone = src && jQuery.isArray(src) ? src : [];
373 clone = src && jQuery.isPlainObject(src) ? src : {};
376 // Never move original objects, clone them
377 target[ name ] = jQuery.extend( deep, clone, copy );
379 // Don't bring in undefined values
380 } else if ( copy !== undefined ) {
381 target[ name ] = copy;
387 // Return the modified object
392 noConflict: function( deep ) {
393 if ( window.$ === jQuery ) {
397 if ( deep && window.jQuery === jQuery ) {
398 window.jQuery = _jQuery;
404 // Is the DOM ready to be used? Set to true once it occurs.
407 // A counter to track how many items to wait for before
408 // the ready event fires. See #6781
411 // Hold (or release) the ready event
412 holdReady: function( hold ) {
416 jQuery.ready( true );
420 // Handle when the DOM is ready
421 ready: function( wait ) {
422 // Either a released hold or an DOMready/load event and not yet ready
423 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
424 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
425 if ( !document.body ) {
426 return setTimeout( jQuery.ready, 1 );
429 // Remember that the DOM is ready
430 jQuery.isReady = true;
432 // If a normal DOM Ready event fired, decrement, and wait if need be
433 if ( wait !== true && --jQuery.readyWait > 0 ) {
437 // If there are functions bound, to execute
438 readyList.resolveWith( document, [ jQuery ] );
440 // Trigger any bound ready events
441 if ( jQuery.fn.trigger ) {
442 jQuery( document ).trigger( "ready" ).unbind( "ready" );
447 bindReady: function() {
452 readyList = jQuery._Deferred();
454 // Catch cases where $(document).ready() is called after the
455 // browser event has already occurred.
456 if ( document.readyState === "complete" ) {
457 // Handle it asynchronously to allow scripts the opportunity to delay ready
458 return setTimeout( jQuery.ready, 1 );
461 // Mozilla, Opera and webkit nightlies currently support this event
462 if ( document.addEventListener ) {
463 // Use the handy event callback
464 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
466 // A fallback to window.onload, that will always work
467 window.addEventListener( "load", jQuery.ready, false );
469 // If IE event model is used
470 } else if ( document.attachEvent ) {
471 // ensure firing before onload,
472 // maybe late but safe also for iframes
473 document.attachEvent( "onreadystatechange", DOMContentLoaded );
475 // A fallback to window.onload, that will always work
476 window.attachEvent( "onload", jQuery.ready );
478 // If IE and not a frame
479 // continually check to see if the document is ready
480 var toplevel = false;
483 toplevel = window.frameElement == null;
486 if ( document.documentElement.doScroll && toplevel ) {
492 // See test/unit/core.js for details concerning isFunction.
493 // Since version 1.3, DOM methods and functions like alert
494 // aren't supported. They return false on IE (#2968).
495 isFunction: function( obj ) {
496 return jQuery.type(obj) === "function";
499 isArray: Array.isArray || function( obj ) {
500 return jQuery.type(obj) === "array";
503 // A crude way of determining if an object is a window
504 isWindow: function( obj ) {
505 return obj && typeof obj === "object" && "setInterval" in obj;
508 isNaN: function( obj ) {
509 return obj == null || !rdigit.test( obj ) || isNaN( obj );
512 type: function( obj ) {
515 class2type[ toString.call(obj) ] || "object";
518 isPlainObject: function( obj ) {
519 // Must be an Object.
520 // Because of IE, we also have to check the presence of the constructor property.
521 // Make sure that DOM nodes and window objects don't pass through, as well
522 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
527 // Not own constructor property must be Object
528 if ( obj.constructor &&
529 !hasOwn.call(obj, "constructor") &&
530 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
534 // IE8,9 Will throw exceptions on certain host objects #9897
538 // Own properties are enumerated firstly, so to speed up,
539 // if last one is own, then all properties are own.
542 for ( key in obj ) {}
544 return key === undefined || hasOwn.call( obj, key );
547 isEmptyObject: function( obj ) {
548 for ( var name in obj ) {
554 error: function( msg ) {
558 parseJSON: function( data ) {
559 if ( typeof data !== "string" || !data ) {
563 // Make sure leading/trailing whitespace is removed (IE can't handle it)
564 data = jQuery.trim( data );
566 // Attempt to parse using the native JSON parser first
567 if ( window.JSON && window.JSON.parse ) {
568 return window.JSON.parse( data );
571 // Make sure the incoming data is actual JSON
572 // Logic borrowed from http://json.org/json2.js
573 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
574 .replace( rvalidtokens, "]" )
575 .replace( rvalidbraces, "")) ) {
577 return (new Function( "return " + data ))();
580 jQuery.error( "Invalid JSON: " + data );
583 // Cross-browser xml parsing
584 parseXML: function( data ) {
587 if ( window.DOMParser ) { // Standard
588 tmp = new DOMParser();
589 xml = tmp.parseFromString( data , "text/xml" );
591 xml = new ActiveXObject( "Microsoft.XMLDOM" );
598 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
599 jQuery.error( "Invalid XML: " + data );
606 // Evaluates a script in a global context
607 // Workarounds based on findings by Jim Driscoll
608 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
609 globalEval: function( data ) {
610 if ( data && rnotwhite.test( data ) ) {
611 // We use execScript on Internet Explorer
612 // We use an anonymous function so that context is window
613 // rather than jQuery in Firefox
614 ( window.execScript || function( data ) {
615 window[ "eval" ].call( window, data );
620 // Convert dashed to camelCase; used by the css and data modules
621 // Microsoft forgot to hump their vendor prefix (#9572)
622 camelCase: function( string ) {
623 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
626 nodeName: function( elem, name ) {
627 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
630 // args is for internal usage only
631 each: function( object, callback, args ) {
633 length = object.length,
634 isObj = length === undefined || jQuery.isFunction( object );
638 for ( name in object ) {
639 if ( callback.apply( object[ name ], args ) === false ) {
644 for ( ; i < length; ) {
645 if ( callback.apply( object[ i++ ], args ) === false ) {
651 // A special, fast, case for the most common use of each
654 for ( name in object ) {
655 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
660 for ( ; i < length; ) {
661 if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
671 // Use native String.trim function wherever possible
674 return text == null ?
679 // Otherwise use our own trimming functionality
681 return text == null ?
683 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
686 // results is for internal usage only
687 makeArray: function( array, results ) {
688 var ret = results || [];
690 if ( array != null ) {
691 // The window, strings (and functions) also have 'length'
692 // The extra typeof function check is to prevent crashes
693 // in Safari 2 (See: #3039)
694 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
695 var type = jQuery.type( array );
697 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
698 push.call( ret, array );
700 jQuery.merge( ret, array );
707 inArray: function( elem, array ) {
713 return indexOf.call( array, elem );
716 for ( var i = 0, length = array.length; i < length; i++ ) {
717 if ( array[ i ] === elem ) {
725 merge: function( first, second ) {
726 var i = first.length,
729 if ( typeof second.length === "number" ) {
730 for ( var l = second.length; j < l; j++ ) {
731 first[ i++ ] = second[ j ];
735 while ( second[j] !== undefined ) {
736 first[ i++ ] = second[ j++ ];
745 grep: function( elems, callback, inv ) {
746 var ret = [], retVal;
749 // Go through the array, only saving the items
750 // that pass the validator function
751 for ( var i = 0, length = elems.length; i < length; i++ ) {
752 retVal = !!callback( elems[ i ], i );
753 if ( inv !== retVal ) {
754 ret.push( elems[ i ] );
761 // arg is for internal usage only
762 map: function( elems, callback, arg ) {
763 var value, key, ret = [],
765 length = elems.length,
766 // jquery objects are treated as arrays
767 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
769 // Go through the array, translating each of the items to their
771 for ( ; i < length; i++ ) {
772 value = callback( elems[ i ], i, arg );
774 if ( value != null ) {
775 ret[ ret.length ] = value;
779 // Go through every key on the object,
781 for ( key in elems ) {
782 value = callback( elems[ key ], key, arg );
784 if ( value != null ) {
785 ret[ ret.length ] = value;
790 // Flatten any nested arrays
791 return ret.concat.apply( [], ret );
794 // A global GUID counter for objects
797 // Bind a function to a context, optionally partially applying any
799 proxy: function( fn, context ) {
800 if ( typeof context === "string" ) {
801 var tmp = fn[ context ];
806 // Quick check to determine if target is callable, in the spec
807 // this throws a TypeError, but we will just return undefined.
808 if ( !jQuery.isFunction( fn ) ) {
813 var args = slice.call( arguments, 2 ),
815 return fn.apply( context, args.concat( slice.call( arguments ) ) );
818 // Set the guid of unique handler to the same of original handler, so it can be removed
819 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
824 // Mutifunctional method to get and set values to a collection
825 // The value/s can optionally be executed if it's a function
826 access: function( elems, key, value, exec, fn, pass ) {
827 var length = elems.length;
829 // Setting many attributes
830 if ( typeof key === "object" ) {
831 for ( var k in key ) {
832 jQuery.access( elems, k, key[k], exec, fn, value );
837 // Setting one attribute
838 if ( value !== undefined ) {
839 // Optionally, function values get executed if exec is true
840 exec = !pass && exec && jQuery.isFunction(value);
842 for ( var i = 0; i < length; i++ ) {
843 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
849 // Getting an attribute
850 return length ? fn( elems[0], key ) : undefined;
854 return (new Date()).getTime();
857 // Use of jQuery.browser is frowned upon.
858 // More details: http://docs.jquery.com/Utilities/jQuery.browser
859 uaMatch: function( ua ) {
860 ua = ua.toLowerCase();
862 var match = rwebkit.exec( ua ) ||
865 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
868 return { browser: match[1] || "", version: match[2] || "0" };
872 function jQuerySub( selector, context ) {
873 return new jQuerySub.fn.init( selector, context );
875 jQuery.extend( true, jQuerySub, this );
876 jQuerySub.superclass = this;
877 jQuerySub.fn = jQuerySub.prototype = this();
878 jQuerySub.fn.constructor = jQuerySub;
879 jQuerySub.sub = this.sub;
880 jQuerySub.fn.init = function init( selector, context ) {
881 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
882 context = jQuerySub( context );
885 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
887 jQuerySub.fn.init.prototype = jQuerySub.fn;
888 var rootjQuerySub = jQuerySub(document);
895 // Populate the class2type map
896 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
897 class2type[ "[object " + name + "]" ] = name.toLowerCase();
900 browserMatch = jQuery.uaMatch( userAgent );
901 if ( browserMatch.browser ) {
902 jQuery.browser[ browserMatch.browser ] = true;
903 jQuery.browser.version = browserMatch.version;
906 // Deprecated, use jQuery.browser.webkit instead
907 if ( jQuery.browser.webkit ) {
908 jQuery.browser.safari = true;
911 // IE doesn't match non-breaking spaces with \s
912 if ( rnotwhite.test( "\xA0" ) ) {
913 trimLeft = /^[\s\xA0]+/;
914 trimRight = /[\s\xA0]+$/;
917 // All jQuery objects should point back to these
918 rootjQuery = jQuery(document);
920 // Cleanup functions for the document ready method
921 if ( document.addEventListener ) {
922 DOMContentLoaded = function() {
923 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
927 } else if ( document.attachEvent ) {
928 DOMContentLoaded = function() {
929 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
930 if ( document.readyState === "complete" ) {
931 document.detachEvent( "onreadystatechange", DOMContentLoaded );
937 // The DOM ready check for Internet Explorer
938 function doScrollCheck() {
939 if ( jQuery.isReady ) {
944 // If IE is used, use the trick by Diego Perini
945 // http://javascript.nwbox.com/IEContentLoaded/
946 document.documentElement.doScroll("left");
948 setTimeout( doScrollCheck, 1 );
952 // and execute any waiting functions
961 var // Promise methods
962 promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
963 // Static reference to slice
964 sliceDeferred = [].slice;
967 // Create a simple deferred (one callbacks list)
968 _Deferred: function() {
969 var // callbacks list
971 // stored [ context , args ]
973 // to avoid firing when already doing so
975 // flag to know if the deferred has been cancelled
977 // the deferred itself
980 // done( f1, f2, ...)
983 var args = arguments,
993 for ( i = 0, length = args.length; i < length; i++ ) {
995 type = jQuery.type( elem );
996 if ( type === "array" ) {
997 deferred.done.apply( deferred, elem );
998 } else if ( type === "function" ) {
999 callbacks.push( elem );
1003 deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
1009 // resolve with given context and args
1010 resolveWith: function( context, args ) {
1011 if ( !cancelled && !fired && !firing ) {
1012 // make sure args are available (#8421)
1016 while( callbacks[ 0 ] ) {
1017 callbacks.shift().apply( context, args );
1021 fired = [ context, args ];
1028 // resolve with this as context and given arguments
1029 resolve: function() {
1030 deferred.resolveWith( this, arguments );
1034 // Has this deferred been resolved?
1035 isResolved: function() {
1036 return !!( firing || fired );
1040 cancel: function() {
1050 // Full fledged deferred (two callbacks list)
1051 Deferred: function( func ) {
1052 var deferred = jQuery._Deferred(),
1053 failDeferred = jQuery._Deferred(),
1055 // Add errorDeferred methods, then and promise
1056 jQuery.extend( deferred, {
1057 then: function( doneCallbacks, failCallbacks ) {
1058 deferred.done( doneCallbacks ).fail( failCallbacks );
1061 always: function() {
1062 return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
1064 fail: failDeferred.done,
1065 rejectWith: failDeferred.resolveWith,
1066 reject: failDeferred.resolve,
1067 isRejected: failDeferred.isResolved,
1068 pipe: function( fnDone, fnFail ) {
1069 return jQuery.Deferred(function( newDefer ) {
1071 done: [ fnDone, "resolve" ],
1072 fail: [ fnFail, "reject" ]
1073 }, function( handler, data ) {
1077 if ( jQuery.isFunction( fn ) ) {
1078 deferred[ handler ](function() {
1079 returned = fn.apply( this, arguments );
1080 if ( returned && jQuery.isFunction( returned.promise ) ) {
1081 returned.promise().then( newDefer.resolve, newDefer.reject );
1083 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1087 deferred[ handler ]( newDefer[ action ] );
1092 // Get a promise for this deferred
1093 // If obj is provided, the promise aspect is added to the object
1094 promise: function( obj ) {
1095 if ( obj == null ) {
1101 var i = promiseMethods.length;
1103 obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
1108 // Make sure only one callback list will be used
1109 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
1111 delete deferred.cancel;
1112 // Call given func if any
1114 func.call( deferred, deferred );
1120 when: function( firstParam ) {
1121 var args = arguments,
1123 length = args.length,
1125 deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
1128 function resolveFunc( i ) {
1129 return function( value ) {
1130 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
1131 if ( !( --count ) ) {
1132 // Strange bug in FF4:
1133 // Values changed onto the arguments object sometimes end up as undefined values
1134 // outside the $.when method. Cloning the object into a fresh array solves the issue
1135 deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
1140 for( ; i < length; i++ ) {
1141 if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
1142 args[ i ].promise().then( resolveFunc(i), deferred.reject );
1148 deferred.resolveWith( deferred, args );
1150 } else if ( deferred !== firstParam ) {
1151 deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
1153 return deferred.promise();
1159 jQuery.support = (function() {
1161 var div = document.createElement( "div" ),
1162 documentElement = document.documentElement,
1181 // Preliminary tests
1182 div.setAttribute("className", "t");
1183 div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
1186 all = div.getElementsByTagName( "*" );
1187 a = div.getElementsByTagName( "a" )[ 0 ];
1189 // Can't get basic test support
1190 if ( !all || !all.length || !a ) {
1194 // First batch of supports tests
1195 select = document.createElement( "select" );
1196 opt = select.appendChild( document.createElement("option") );
1197 input = div.getElementsByTagName( "input" )[ 0 ];
1200 // IE strips leading whitespace when .innerHTML is used
1201 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1203 // Make sure that tbody elements aren't automatically inserted
1204 // IE will insert them into empty tables
1205 tbody: !div.getElementsByTagName( "tbody" ).length,
1207 // Make sure that link elements get serialized correctly by innerHTML
1208 // This requires a wrapper element in IE
1209 htmlSerialize: !!div.getElementsByTagName( "link" ).length,
1211 // Get the style information from getAttribute
1212 // (IE uses .cssText instead)
1213 style: /top/.test( a.getAttribute("style") ),
1215 // Make sure that URLs aren't manipulated
1216 // (IE normalizes it by default)
1217 hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
1219 // Make sure that element opacity exists
1220 // (IE uses filter instead)
1221 // Use a regex to work around a WebKit issue. See #5145
1222 opacity: /^0.55$/.test( a.style.opacity ),
1224 // Verify style float existence
1225 // (IE uses styleFloat instead of cssFloat)
1226 cssFloat: !!a.style.cssFloat,
1228 // Make sure that if no value is specified for a checkbox
1229 // that it defaults to "on".
1230 // (WebKit defaults to "" instead)
1231 checkOn: ( input.value === "on" ),
1233 // Make sure that a selected-by-default option has a working selected property.
1234 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1235 optSelected: opt.selected,
1237 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1238 getSetAttribute: div.className !== "t",
1240 // Will be defined later
1241 submitBubbles: true,
1242 changeBubbles: true,
1243 focusinBubbles: false,
1244 deleteExpando: true,
1246 inlineBlockNeedsLayout: false,
1247 shrinkWrapBlocks: false,
1248 reliableMarginRight: true
1251 // Make sure checked status is properly cloned
1252 input.checked = true;
1253 support.noCloneChecked = input.cloneNode( true ).checked;
1255 // Make sure that the options inside disabled selects aren't marked as disabled
1256 // (WebKit marks them as disabled)
1257 select.disabled = true;
1258 support.optDisabled = !opt.disabled;
1260 // Test to see if it's possible to delete an expando from an element
1261 // Fails in Internet Explorer
1265 support.deleteExpando = false;
1268 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1269 div.attachEvent( "onclick", function() {
1270 // Cloning a node shouldn't copy over any
1271 // bound event handlers (IE does this)
1272 support.noCloneEvent = false;
1274 div.cloneNode( true ).fireEvent( "onclick" );
1277 // Check if a radio maintains it's value
1278 // after being appended to the DOM
1279 input = document.createElement("input");
1281 input.setAttribute("type", "radio");
1282 support.radioValue = input.value === "t";
1284 input.setAttribute("checked", "checked");
1285 div.appendChild( input );
1286 fragment = document.createDocumentFragment();
1287 fragment.appendChild( div.firstChild );
1289 // WebKit doesn't clone checked state correctly in fragments
1290 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1294 // Figure out if the W3C box model works as expected
1295 div.style.width = div.style.paddingLeft = "1px";
1297 body = document.getElementsByTagName( "body" )[ 0 ];
1298 // We use our own, invisible, body unless the body is already present
1299 // in which case we use a div (#9239)
1300 testElement = document.createElement( body ? "div" : "body" );
1301 testElementStyle = {
1302 visibility: "hidden",
1310 jQuery.extend( testElementStyle, {
1311 position: "absolute",
1316 for ( i in testElementStyle ) {
1317 testElement.style[ i ] = testElementStyle[ i ];
1319 testElement.appendChild( div );
1320 testElementParent = body || documentElement;
1321 testElementParent.insertBefore( testElement, testElementParent.firstChild );
1323 // Check if a disconnected checkbox will retain its checked
1324 // value of true after appended to the DOM (IE6/7)
1325 support.appendChecked = input.checked;
1327 support.boxModel = div.offsetWidth === 2;
1329 if ( "zoom" in div.style ) {
1330 // Check if natively block-level elements act like inline-block
1331 // elements when setting their display to 'inline' and giving
1333 // (IE < 8 does this)
1334 div.style.display = "inline";
1336 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
1338 // Check if elements with layout shrink-wrap their children
1340 div.style.display = "";
1341 div.innerHTML = "<div style='width:4px;'></div>";
1342 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
1345 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
1346 tds = div.getElementsByTagName( "td" );
1348 // Check if table cells still have offsetWidth/Height when they are set
1349 // to display:none and there are still other visible table cells in a
1350 // table row; if so, offsetWidth/Height are not reliable for use when
1351 // determining if an element has been hidden directly using
1352 // display:none (it is still safe to use offsets if a parent element is
1353 // hidden; don safety goggles and see bug #4512 for more information).
1354 // (only IE 8 fails this test)
1355 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1357 tds[ 0 ].style.display = "";
1358 tds[ 1 ].style.display = "none";
1360 // Check if empty table cells still have offsetWidth/Height
1361 // (IE < 8 fail this test)
1362 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1365 // Check if div with explicit width and no margin-right incorrectly
1366 // gets computed margin-right based on width of container. For more
1367 // info see bug #3333
1368 // Fails in WebKit before Feb 2011 nightlies
1369 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1370 if ( document.defaultView && document.defaultView.getComputedStyle ) {
1371 marginDiv = document.createElement( "div" );
1372 marginDiv.style.width = "0";
1373 marginDiv.style.marginRight = "0";
1374 div.appendChild( marginDiv );
1375 support.reliableMarginRight =
1376 ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
1379 // Remove the body element we added
1380 testElement.innerHTML = "";
1381 testElementParent.removeChild( testElement );
1383 // Technique from Juriy Zaytsev
1384 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
1385 // We only care about the case where non-standard event systems
1386 // are used, namely in IE. Short-circuiting here helps us to
1387 // avoid an eval call (in setAttribute) which can cause CSP
1388 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1389 if ( div.attachEvent ) {
1395 eventName = "on" + i;
1396 isSupported = ( eventName in div );
1397 if ( !isSupported ) {
1398 div.setAttribute( eventName, "return;" );
1399 isSupported = ( typeof div[ eventName ] === "function" );
1401 support[ i + "Bubbles" ] = isSupported;
1405 // Null connected elements to avoid leaks in IE
1406 testElement = fragment = select = opt = body = marginDiv = div = input = null;
1411 // Keep track of boxModel
1412 jQuery.boxModel = jQuery.support.boxModel;
1417 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1418 rmultiDash = /([A-Z])/g;
1423 // Please use with caution
1426 // Unique for each copy of jQuery on the page
1427 // Non-digits removed to match rinlinejQuery
1428 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1430 // The following elements throw uncatchable exceptions if you
1431 // attempt to add expando properties to them.
1434 // Ban all objects except for Flash (which handle expandos)
1435 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1439 hasData: function( elem ) {
1440 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1442 return !!elem && !isEmptyDataObject( elem );
1445 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1446 if ( !jQuery.acceptData( elem ) ) {
1451 internalKey = jQuery.expando,
1452 getByName = typeof name === "string",
1454 // We have to handle DOM nodes and JS objects differently because IE6-7
1455 // can't GC object references properly across the DOM-JS boundary
1456 isNode = elem.nodeType,
1458 // Only DOM nodes need the global jQuery cache; JS object data is
1459 // attached directly to the object so GC can occur automatically
1460 cache = isNode ? jQuery.cache : elem,
1462 // Only defining an ID for JS objects if its cache already exists allows
1463 // the code to shortcut on the same path as a DOM node with no cache
1464 id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
1466 // Avoid doing any more work than we need to when trying to get data on an
1467 // object that has no data at all
1468 if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
1473 // Only DOM nodes need a new unique ID for each element since their data
1474 // ends up in the global cache
1476 elem[ jQuery.expando ] = id = ++jQuery.uuid;
1478 id = jQuery.expando;
1482 if ( !cache[ id ] ) {
1485 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1486 // metadata on plain JS objects when the object is serialized using
1489 cache[ id ].toJSON = jQuery.noop;
1493 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1494 // shallow copied over onto the existing cache
1495 if ( typeof name === "object" || typeof name === "function" ) {
1497 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
1499 cache[ id ] = jQuery.extend(cache[ id ], name);
1503 thisCache = cache[ id ];
1505 // Internal jQuery data is stored in a separate object inside the object's data
1506 // cache in order to avoid key collisions between internal data and user-defined
1509 if ( !thisCache[ internalKey ] ) {
1510 thisCache[ internalKey ] = {};
1513 thisCache = thisCache[ internalKey ];
1516 if ( data !== undefined ) {
1517 thisCache[ jQuery.camelCase( name ) ] = data;
1520 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
1521 // not attempt to inspect the internal events object using jQuery.data, as this
1522 // internal data object is undocumented and subject to change.
1523 if ( name === "events" && !thisCache[name] ) {
1524 return thisCache[ internalKey ] && thisCache[ internalKey ].events;
1527 // Check for both converted-to-camel and non-converted data property names
1528 // If a data property was specified
1531 // First Try to find as-is property data
1532 ret = thisCache[ name ];
1534 // Test for null|undefined property data
1535 if ( ret == null ) {
1537 // Try to find the camelCased property
1538 ret = thisCache[ jQuery.camelCase( name ) ];
1547 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1548 if ( !jQuery.acceptData( elem ) ) {
1554 // Reference to internal data cache key
1555 internalKey = jQuery.expando,
1557 isNode = elem.nodeType,
1559 // See jQuery.data for more information
1560 cache = isNode ? jQuery.cache : elem,
1562 // See jQuery.data for more information
1563 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1565 // If there is already no cache entry for this object, there is no
1566 // purpose in continuing
1567 if ( !cache[ id ] ) {
1573 thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
1577 // Support interoperable removal of hyphenated or camelcased keys
1578 if ( !thisCache[ name ] ) {
1579 name = jQuery.camelCase( name );
1582 delete thisCache[ name ];
1584 // If there is no data left in the cache, we want to continue
1585 // and let the cache object itself get destroyed
1586 if ( !isEmptyDataObject(thisCache) ) {
1592 // See jQuery.data for more information
1594 delete cache[ id ][ internalKey ];
1596 // Don't destroy the parent cache unless the internal data object
1597 // had been the only thing left in it
1598 if ( !isEmptyDataObject(cache[ id ]) ) {
1603 var internalCache = cache[ id ][ internalKey ];
1605 // Browsers that fail expando deletion also refuse to delete expandos on
1606 // the window, but it will allow it on all other JS objects; other browsers
1608 // Ensure that `cache` is not a window object #10080
1609 if ( jQuery.support.deleteExpando || !cache.setInterval ) {
1615 // We destroyed the entire user cache at once because it's faster than
1616 // iterating through each key, but we need to continue to persist internal
1617 // data if it existed
1618 if ( internalCache ) {
1620 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
1621 // metadata on plain JS objects when the object is serialized using
1624 cache[ id ].toJSON = jQuery.noop;
1627 cache[ id ][ internalKey ] = internalCache;
1629 // Otherwise, we need to eliminate the expando on the node to avoid
1630 // false lookups in the cache for entries that no longer exist
1631 } else if ( isNode ) {
1632 // IE does not allow us to delete expando properties from nodes,
1633 // nor does it have a removeAttribute function on Document nodes;
1634 // we must handle all of these cases
1635 if ( jQuery.support.deleteExpando ) {
1636 delete elem[ jQuery.expando ];
1637 } else if ( elem.removeAttribute ) {
1638 elem.removeAttribute( jQuery.expando );
1640 elem[ jQuery.expando ] = null;
1645 // For internal use only.
1646 _data: function( elem, name, data ) {
1647 return jQuery.data( elem, name, data, true );
1650 // A method for determining if a DOM node can handle the data expando
1651 acceptData: function( elem ) {
1652 if ( elem.nodeName ) {
1653 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
1656 return !(match === true || elem.getAttribute("classid") !== match);
1665 data: function( key, value ) {
1668 if ( typeof key === "undefined" ) {
1669 if ( this.length ) {
1670 data = jQuery.data( this[0] );
1672 if ( this[0].nodeType === 1 ) {
1673 var attr = this[0].attributes, name;
1674 for ( var i = 0, l = attr.length; i < l; i++ ) {
1675 name = attr[i].name;
1677 if ( name.indexOf( "data-" ) === 0 ) {
1678 name = jQuery.camelCase( name.substring(5) );
1680 dataAttr( this[0], name, data[ name ] );
1688 } else if ( typeof key === "object" ) {
1689 return this.each(function() {
1690 jQuery.data( this, key );
1694 var parts = key.split(".");
1695 parts[1] = parts[1] ? "." + parts[1] : "";
1697 if ( value === undefined ) {
1698 data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
1700 // Try to fetch any internally stored data first
1701 if ( data === undefined && this.length ) {
1702 data = jQuery.data( this[0], key );
1703 data = dataAttr( this[0], key, data );
1706 return data === undefined && parts[1] ?
1707 this.data( parts[0] ) :
1711 return this.each(function() {
1712 var $this = jQuery( this ),
1713 args = [ parts[0], value ];
1715 $this.triggerHandler( "setData" + parts[1] + "!", args );
1716 jQuery.data( this, key, value );
1717 $this.triggerHandler( "changeData" + parts[1] + "!", args );
1722 removeData: function( key ) {
1723 return this.each(function() {
1724 jQuery.removeData( this, key );
1729 function dataAttr( elem, key, data ) {
1730 // If nothing was found internally, try to fetch any
1731 // data from the HTML5 data-* attribute
1732 if ( data === undefined && elem.nodeType === 1 ) {
1734 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1736 data = elem.getAttribute( name );
1738 if ( typeof data === "string" ) {
1740 data = data === "true" ? true :
1741 data === "false" ? false :
1742 data === "null" ? null :
1743 !jQuery.isNaN( data ) ? parseFloat( data ) :
1744 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1748 // Make sure we set the data so it isn't changed later
1749 jQuery.data( elem, key, data );
1759 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
1760 // property to be considered empty objects; this property always exists in
1761 // order to make sure JSON.stringify does not expose internal metadata
1762 function isEmptyDataObject( obj ) {
1763 for ( var name in obj ) {
1764 if ( name !== "toJSON" ) {
1775 function handleQueueMarkDefer( elem, type, src ) {
1776 var deferDataKey = type + "defer",
1777 queueDataKey = type + "queue",
1778 markDataKey = type + "mark",
1779 defer = jQuery.data( elem, deferDataKey, undefined, true );
1781 ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
1782 ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
1783 // Give room for hard-coded callbacks to fire first
1784 // and eventually mark/queue something else on the element
1785 setTimeout( function() {
1786 if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
1787 !jQuery.data( elem, markDataKey, undefined, true ) ) {
1788 jQuery.removeData( elem, deferDataKey, true );
1797 _mark: function( elem, type ) {
1799 type = (type || "fx") + "mark";
1800 jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
1804 _unmark: function( force, elem, type ) {
1805 if ( force !== true ) {
1811 type = type || "fx";
1812 var key = type + "mark",
1813 count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
1815 jQuery.data( elem, key, count, true );
1817 jQuery.removeData( elem, key, true );
1818 handleQueueMarkDefer( elem, type, "mark" );
1823 queue: function( elem, type, data ) {
1825 type = (type || "fx") + "queue";
1826 var q = jQuery.data( elem, type, undefined, true );
1827 // Speed up dequeue by getting out quickly if this is just a lookup
1829 if ( !q || jQuery.isArray(data) ) {
1830 q = jQuery.data( elem, type, jQuery.makeArray(data), true );
1839 dequeue: function( elem, type ) {
1840 type = type || "fx";
1842 var queue = jQuery.queue( elem, type ),
1846 // If the fx queue is dequeued, always remove the progress sentinel
1847 if ( fn === "inprogress" ) {
1852 // Add a progress sentinel to prevent the fx queue from being
1853 // automatically dequeued
1854 if ( type === "fx" ) {
1855 queue.unshift("inprogress");
1858 fn.call(elem, function() {
1859 jQuery.dequeue(elem, type);
1863 if ( !queue.length ) {
1864 jQuery.removeData( elem, type + "queue", true );
1865 handleQueueMarkDefer( elem, type, "queue" );
1871 queue: function( type, data ) {
1872 if ( typeof type !== "string" ) {
1877 if ( data === undefined ) {
1878 return jQuery.queue( this[0], type );
1880 return this.each(function() {
1881 var queue = jQuery.queue( this, type, data );
1883 if ( type === "fx" && queue[0] !== "inprogress" ) {
1884 jQuery.dequeue( this, type );
1888 dequeue: function( type ) {
1889 return this.each(function() {
1890 jQuery.dequeue( this, type );
1893 // Based off of the plugin by Clint Helfers, with permission.
1894 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1895 delay: function( time, type ) {
1896 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
1897 type = type || "fx";
1899 return this.queue( type, function() {
1901 setTimeout(function() {
1902 jQuery.dequeue( elem, type );
1906 clearQueue: function( type ) {
1907 return this.queue( type || "fx", [] );
1909 // Get a promise resolved when queues of a certain type
1910 // are emptied (fx is the type by default)
1911 promise: function( type, object ) {
1912 if ( typeof type !== "string" ) {
1916 type = type || "fx";
1917 var defer = jQuery.Deferred(),
1919 i = elements.length,
1921 deferDataKey = type + "defer",
1922 queueDataKey = type + "queue",
1923 markDataKey = type + "mark",
1925 function resolve() {
1926 if ( !( --count ) ) {
1927 defer.resolveWith( elements, [ elements ] );
1931 if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
1932 ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
1933 jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
1934 jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
1936 tmp.done( resolve );
1940 return defer.promise();
1947 var rclass = /[\n\t\r]/g,
1950 rtype = /^(?:button|input)$/i,
1951 rfocusable = /^(?:button|input|object|select|textarea)$/i,
1952 rclickable = /^a(?:rea)?$/i,
1953 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
1957 attr: function( name, value ) {
1958 return jQuery.access( this, name, value, true, jQuery.attr );
1961 removeAttr: function( name ) {
1962 return this.each(function() {
1963 jQuery.removeAttr( this, name );
1967 prop: function( name, value ) {
1968 return jQuery.access( this, name, value, true, jQuery.prop );
1971 removeProp: function( name ) {
1972 name = jQuery.propFix[ name ] || name;
1973 return this.each(function() {
1974 // try/catch handles cases where IE balks (such as removing a property on window)
1976 this[ name ] = undefined;
1977 delete this[ name ];
1982 addClass: function( value ) {
1983 var classNames, i, l, elem,
1986 if ( jQuery.isFunction( value ) ) {
1987 return this.each(function( j ) {
1988 jQuery( this ).addClass( value.call(this, j, this.className) );
1992 if ( value && typeof value === "string" ) {
1993 classNames = value.split( rspace );
1995 for ( i = 0, l = this.length; i < l; i++ ) {
1998 if ( elem.nodeType === 1 ) {
1999 if ( !elem.className && classNames.length === 1 ) {
2000 elem.className = value;
2003 setClass = " " + elem.className + " ";
2005 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2006 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2007 setClass += classNames[ c ] + " ";
2010 elem.className = jQuery.trim( setClass );
2019 removeClass: function( value ) {
2020 var classNames, i, l, elem, className, c, cl;
2022 if ( jQuery.isFunction( value ) ) {
2023 return this.each(function( j ) {
2024 jQuery( this ).removeClass( value.call(this, j, this.className) );
2028 if ( (value && typeof value === "string") || value === undefined ) {
2029 classNames = (value || "").split( rspace );
2031 for ( i = 0, l = this.length; i < l; i++ ) {
2034 if ( elem.nodeType === 1 && elem.className ) {
2036 className = (" " + elem.className + " ").replace( rclass, " " );
2037 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2038 className = className.replace(" " + classNames[ c ] + " ", " ");
2040 elem.className = jQuery.trim( className );
2043 elem.className = "";
2052 toggleClass: function( value, stateVal ) {
2053 var type = typeof value,
2054 isBool = typeof stateVal === "boolean";
2056 if ( jQuery.isFunction( value ) ) {
2057 return this.each(function( i ) {
2058 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2062 return this.each(function() {
2063 if ( type === "string" ) {
2064 // toggle individual class names
2067 self = jQuery( this ),
2069 classNames = value.split( rspace );
2071 while ( (className = classNames[ i++ ]) ) {
2072 // check each className given, space seperated list
2073 state = isBool ? state : !self.hasClass( className );
2074 self[ state ? "addClass" : "removeClass" ]( className );
2077 } else if ( type === "undefined" || type === "boolean" ) {
2078 if ( this.className ) {
2079 // store className if set
2080 jQuery._data( this, "__className__", this.className );
2083 // toggle whole className
2084 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2089 hasClass: function( selector ) {
2090 var className = " " + selector + " ";
2091 for ( var i = 0, l = this.length; i < l; i++ ) {
2092 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2100 val: function( value ) {
2104 if ( !arguments.length ) {
2106 hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
2108 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2114 return typeof ret === "string" ?
2115 // handle most common string cases
2116 ret.replace(rreturn, "") :
2117 // handle cases where value is null/undef or number
2118 ret == null ? "" : ret;
2124 var isFunction = jQuery.isFunction( value );
2126 return this.each(function( i ) {
2127 var self = jQuery(this), val;
2129 if ( this.nodeType !== 1 ) {
2134 val = value.call( this, i, self.val() );
2139 // Treat null/undefined as ""; convert numbers to string
2140 if ( val == null ) {
2142 } else if ( typeof val === "number" ) {
2144 } else if ( jQuery.isArray( val ) ) {
2145 val = jQuery.map(val, function ( value ) {
2146 return value == null ? "" : value + "";
2150 hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
2152 // If set returns undefined, fall back to normal setting
2153 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2163 get: function( elem ) {
2164 // attributes.value is undefined in Blackberry 4.7 but
2165 // uses .value. See #6932
2166 var val = elem.attributes.value;
2167 return !val || val.specified ? elem.value : elem.text;
2171 get: function( elem ) {
2173 index = elem.selectedIndex,
2175 options = elem.options,
2176 one = elem.type === "select-one";
2178 // Nothing was selected
2183 // Loop through all the selected options
2184 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
2185 var option = options[ i ];
2187 // Don't return options that are disabled or in a disabled optgroup
2188 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2189 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2191 // Get the specific value for the option
2192 value = jQuery( option ).val();
2194 // We don't need an array for one selects
2199 // Multi-Selects return an array
2200 values.push( value );
2204 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2205 if ( one && !values.length && options.length ) {
2206 return jQuery( options[ index ] ).val();
2212 set: function( elem, value ) {
2213 var values = jQuery.makeArray( value );
2215 jQuery(elem).find("option").each(function() {
2216 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2219 if ( !values.length ) {
2220 elem.selectedIndex = -1;
2239 // Always normalize to ensure hook usage
2240 tabindex: "tabIndex"
2243 attr: function( elem, name, value, pass ) {
2244 var nType = elem.nodeType;
2246 // don't get/set attributes on text, comment and attribute nodes
2247 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2251 if ( pass && name in jQuery.attrFn ) {
2252 return jQuery( elem )[ name ]( value );
2255 // Fallback to prop when attributes are not supported
2256 if ( !("getAttribute" in elem) ) {
2257 return jQuery.prop( elem, name, value );
2261 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2263 // Normalize the name if needed
2265 name = jQuery.attrFix[ name ] || name;
2267 hooks = jQuery.attrHooks[ name ];
2270 // Use boolHook for boolean attributes
2271 if ( rboolean.test( name ) ) {
2274 // Use nodeHook if available( IE6/7 )
2275 } else if ( nodeHook ) {
2281 if ( value !== undefined ) {
2283 if ( value === null ) {
2284 jQuery.removeAttr( elem, name );
2287 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2291 elem.setAttribute( name, "" + value );
2295 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2300 ret = elem.getAttribute( name );
2302 // Non-existent attributes return null, we normalize to undefined
2303 return ret === null ?
2309 removeAttr: function( elem, name ) {
2311 if ( elem.nodeType === 1 ) {
2312 name = jQuery.attrFix[ name ] || name;
2314 jQuery.attr( elem, name, "" );
2315 elem.removeAttribute( name );
2317 // Set corresponding property to false for boolean attributes
2318 if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
2319 elem[ propName ] = false;
2326 set: function( elem, value ) {
2327 // We can't allow the type property to be changed (since it causes problems in IE)
2328 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2329 jQuery.error( "type property can't be changed" );
2330 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2331 // Setting the type on a radio button after the value resets the value in IE6-9
2332 // Reset value to it's default in case type is set after value
2333 // This is for element creation
2334 var val = elem.value;
2335 elem.setAttribute( "type", value );
2343 // Use the value property for back compat
2344 // Use the nodeHook for button elements in IE6/7 (#1954)
2346 get: function( elem, name ) {
2347 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2348 return nodeHook.get( elem, name );
2350 return name in elem ?
2354 set: function( elem, value, name ) {
2355 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2356 return nodeHook.set( elem, value, name );
2358 // Does not return so that setAttribute is also used
2365 tabindex: "tabIndex",
2366 readonly: "readOnly",
2368 "class": "className",
2369 maxlength: "maxLength",
2370 cellspacing: "cellSpacing",
2371 cellpadding: "cellPadding",
2375 frameborder: "frameBorder",
2376 contenteditable: "contentEditable"
2379 prop: function( elem, name, value ) {
2380 var nType = elem.nodeType;
2382 // don't get/set properties on text, comment and attribute nodes
2383 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2388 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2391 // Fix name and attach hooks
2392 name = jQuery.propFix[ name ] || name;
2393 hooks = jQuery.propHooks[ name ];
2396 if ( value !== undefined ) {
2397 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2401 return (elem[ name ] = value);
2405 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2409 return elem[ name ];
2416 get: function( elem ) {
2417 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2418 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2419 var attributeNode = elem.getAttributeNode("tabindex");
2421 return attributeNode && attributeNode.specified ?
2422 parseInt( attributeNode.value, 10 ) :
2423 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2431 // Add the tabindex propHook to attrHooks for back-compat
2432 jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
2434 // Hook for boolean attributes
2436 get: function( elem, name ) {
2437 // Align boolean attributes with corresponding properties
2438 // Fall back to attribute presence where some booleans are not supported
2440 return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
2441 name.toLowerCase() :
2444 set: function( elem, value, name ) {
2446 if ( value === false ) {
2447 // Remove boolean attributes when set to false
2448 jQuery.removeAttr( elem, name );
2450 // value is true since we know at this point it's type boolean and not false
2451 // Set boolean attributes to the same name and set the DOM property
2452 propName = jQuery.propFix[ name ] || name;
2453 if ( propName in elem ) {
2454 // Only set the IDL specifically if it already exists on the element
2455 elem[ propName ] = true;
2458 elem.setAttribute( name, name.toLowerCase() );
2464 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2465 if ( !jQuery.support.getSetAttribute ) {
2467 // Use this for any attribute in IE6/7
2468 // This fixes almost every IE6/7 issue
2469 nodeHook = jQuery.valHooks.button = {
2470 get: function( elem, name ) {
2472 ret = elem.getAttributeNode( name );
2473 // Return undefined if nodeValue is empty string
2474 return ret && ret.nodeValue !== "" ?
2478 set: function( elem, value, name ) {
2479 // Set the existing or create a new attribute node
2480 var ret = elem.getAttributeNode( name );
2482 ret = document.createAttribute( name );
2483 elem.setAttributeNode( ret );
2485 return (ret.nodeValue = value + "");
2489 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2490 // This is for removals
2491 jQuery.each([ "width", "height" ], function( i, name ) {
2492 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2493 set: function( elem, value ) {
2494 if ( value === "" ) {
2495 elem.setAttribute( name, "auto" );
2504 // Some attributes require a special call on IE
2505 if ( !jQuery.support.hrefNormalized ) {
2506 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2507 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2508 get: function( elem ) {
2509 var ret = elem.getAttribute( name, 2 );
2510 return ret === null ? undefined : ret;
2516 if ( !jQuery.support.style ) {
2517 jQuery.attrHooks.style = {
2518 get: function( elem ) {
2519 // Return undefined in the case of empty string
2520 // Normalize to lowercase since IE uppercases css property names
2521 return elem.style.cssText.toLowerCase() || undefined;
2523 set: function( elem, value ) {
2524 return (elem.style.cssText = "" + value);
2529 // Safari mis-reports the default selected property of an option
2530 // Accessing the parent's selectedIndex property fixes it
2531 if ( !jQuery.support.optSelected ) {
2532 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2533 get: function( elem ) {
2534 var parent = elem.parentNode;
2537 parent.selectedIndex;
2539 // Make sure that it also works with optgroups, see #5701
2540 if ( parent.parentNode ) {
2541 parent.parentNode.selectedIndex;
2549 // Radios and checkboxes getter/setter
2550 if ( !jQuery.support.checkOn ) {
2551 jQuery.each([ "radio", "checkbox" ], function() {
2552 jQuery.valHooks[ this ] = {
2553 get: function( elem ) {
2554 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2555 return elem.getAttribute("value") === null ? "on" : elem.value;
2560 jQuery.each([ "radio", "checkbox" ], function() {
2561 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2562 set: function( elem, value ) {
2563 if ( jQuery.isArray( value ) ) {
2564 return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
2573 var rnamespaces = /\.(.*)$/,
2574 rformElems = /^(?:textarea|input|select)$/i,
2577 rescape = /[^\w\s.|`]/g,
2578 fcleanup = function( nm ) {
2579 return nm.replace(rescape, "\\$&");
2583 * A number of helper functions used for managing events.
2584 * Many of the ideas behind this code originated from
2585 * Dean Edwards' addEvent library.
2589 // Bind an event to an element
2590 // Original by Dean Edwards
2591 add: function( elem, types, handler, data ) {
2592 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2596 if ( handler === false ) {
2597 handler = returnFalse;
2598 } else if ( !handler ) {
2599 // Fixes bug #7229. Fix recommended by jdalton
2603 var handleObjIn, handleObj;
2605 if ( handler.handler ) {
2606 handleObjIn = handler;
2607 handler = handleObjIn.handler;
2610 // Make sure that the function being executed has a unique ID
2611 if ( !handler.guid ) {
2612 handler.guid = jQuery.guid++;
2615 // Init the element's event structure
2616 var elemData = jQuery._data( elem );
2618 // If no elemData is found then we must be trying to bind to one of the
2619 // banned noData elements
2624 var events = elemData.events,
2625 eventHandle = elemData.handle;
2628 elemData.events = events = {};
2631 if ( !eventHandle ) {
2632 elemData.handle = eventHandle = function( e ) {
2633 // Discard the second event of a jQuery.event.trigger() and
2634 // when an event is called after a page has unloaded
2635 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2636 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
2641 // Add elem as a property of the handle function
2642 // This is to prevent a memory leak with non-native events in IE.
2643 eventHandle.elem = elem;
2645 // Handle multiple events separated by a space
2646 // jQuery(...).bind("mouseover mouseout", fn);
2647 types = types.split(" ");
2649 var type, i = 0, namespaces;
2651 while ( (type = types[ i++ ]) ) {
2652 handleObj = handleObjIn ?
2653 jQuery.extend({}, handleObjIn) :
2654 { handler: handler, data: data };
2656 // Namespaced event handlers
2657 if ( type.indexOf(".") > -1 ) {
2658 namespaces = type.split(".");
2659 type = namespaces.shift();
2660 handleObj.namespace = namespaces.slice(0).sort().join(".");
2664 handleObj.namespace = "";
2667 handleObj.type = type;
2668 if ( !handleObj.guid ) {
2669 handleObj.guid = handler.guid;
2672 // Get the current list of functions bound to this event
2673 var handlers = events[ type ],
2674 special = jQuery.event.special[ type ] || {};
2676 // Init the event handler queue
2678 handlers = events[ type ] = [];
2680 // Check for a special event handler
2681 // Only use addEventListener/attachEvent if the special
2682 // events handler returns false
2683 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2684 // Bind the global event handler to the element
2685 if ( elem.addEventListener ) {
2686 elem.addEventListener( type, eventHandle, false );
2688 } else if ( elem.attachEvent ) {
2689 elem.attachEvent( "on" + type, eventHandle );
2694 if ( special.add ) {
2695 special.add.call( elem, handleObj );
2697 if ( !handleObj.handler.guid ) {
2698 handleObj.handler.guid = handler.guid;
2702 // Add the function to the element's handler list
2703 handlers.push( handleObj );
2705 // Keep track of which events have been used, for event optimization
2706 jQuery.event.global[ type ] = true;
2709 // Nullify elem to prevent memory leaks in IE
2715 // Detach an event or set of events from an element
2716 remove: function( elem, types, handler, pos ) {
2717 // don't do events on text and comment nodes
2718 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2722 if ( handler === false ) {
2723 handler = returnFalse;
2726 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
2727 elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
2728 events = elemData && elemData.events;
2730 if ( !elemData || !events ) {
2734 // types is actually an event object here
2735 if ( types && types.type ) {
2736 handler = types.handler;
2740 // Unbind all events for the element
2741 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
2742 types = types || "";
2744 for ( type in events ) {
2745 jQuery.event.remove( elem, type + types );
2751 // Handle multiple events separated by a space
2752 // jQuery(...).unbind("mouseover mouseout", fn);
2753 types = types.split(" ");
2755 while ( (type = types[ i++ ]) ) {
2758 all = type.indexOf(".") < 0;
2762 // Namespaced event handlers
2763 namespaces = type.split(".");
2764 type = namespaces.shift();
2766 namespace = new RegExp("(^|\\.)" +
2767 jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
2770 eventType = events[ type ];
2777 for ( j = 0; j < eventType.length; j++ ) {
2778 handleObj = eventType[ j ];
2780 if ( all || namespace.test( handleObj.namespace ) ) {
2781 jQuery.event.remove( elem, origType, handleObj.handler, j );
2782 eventType.splice( j--, 1 );
2789 special = jQuery.event.special[ type ] || {};
2791 for ( j = pos || 0; j < eventType.length; j++ ) {
2792 handleObj = eventType[ j ];
2794 if ( handler.guid === handleObj.guid ) {
2795 // remove the given handler for the given type
2796 if ( all || namespace.test( handleObj.namespace ) ) {
2797 if ( pos == null ) {
2798 eventType.splice( j--, 1 );
2801 if ( special.remove ) {
2802 special.remove.call( elem, handleObj );
2806 if ( pos != null ) {
2812 // remove generic event handler if no more handlers exist
2813 if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
2814 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
2815 jQuery.removeEvent( elem, type, elemData.handle );
2819 delete events[ type ];
2823 // Remove the expando if it's no longer used
2824 if ( jQuery.isEmptyObject( events ) ) {
2825 var handle = elemData.handle;
2830 delete elemData.events;
2831 delete elemData.handle;
2833 if ( jQuery.isEmptyObject( elemData ) ) {
2834 jQuery.removeData( elem, undefined, true );
2839 // Events that are safe to short-circuit if no handlers are attached.
2840 // Native DOM events should not be added, they may have inline handlers.
2847 trigger: function( event, data, elem, onlyHandlers ) {
2848 // Event object or event type
2849 var type = event.type || event,
2853 if ( type.indexOf("!") >= 0 ) {
2854 // Exclusive events trigger only for the exact event (no namespaces)
2855 type = type.slice(0, -1);
2859 if ( type.indexOf(".") >= 0 ) {
2860 // Namespaced trigger; create a regexp to match event type in handle()
2861 namespaces = type.split(".");
2862 type = namespaces.shift();
2866 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2867 // No jQuery handlers for this event type, and it can't have inline handlers
2871 // Caller can pass in an Event, Object, or just an event type string
2872 event = typeof event === "object" ?
2873 // jQuery.Event object
2874 event[ jQuery.expando ] ? event :
2876 new jQuery.Event( type, event ) :
2877 // Just the event type (string)
2878 new jQuery.Event( type );
2881 event.exclusive = exclusive;
2882 event.namespace = namespaces.join(".");
2883 event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
2885 // triggerHandler() and global events don't bubble or run the default action
2886 if ( onlyHandlers || !elem ) {
2887 event.preventDefault();
2888 event.stopPropagation();
2891 // Handle a global trigger
2893 // TODO: Stop taunting the data cache; remove global events and always attach to document
2894 jQuery.each( jQuery.cache, function() {
2895 // internalKey variable is just used to make it easier to find
2896 // and potentially change this stuff later; currently it just
2897 // points to jQuery.expando
2898 var internalKey = jQuery.expando,
2899 internalCache = this[ internalKey ];
2900 if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
2901 jQuery.event.trigger( event, data, internalCache.handle.elem );
2907 // Don't do events on text and comment nodes
2908 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2912 // Clean up the event in case it is being reused
2913 event.result = undefined;
2914 event.target = elem;
2916 // Clone any incoming data and prepend the event, creating the handler arg list
2917 data = data != null ? jQuery.makeArray( data ) : [];
2918 data.unshift( event );
2921 // IE doesn't like method names with a colon (#3533, #8272)
2922 ontype = type.indexOf(":") < 0 ? "on" + type : "";
2924 // Fire event on the current element, then bubble up the DOM tree
2926 var handle = jQuery._data( cur, "handle" );
2928 event.currentTarget = cur;
2930 handle.apply( cur, data );
2933 // Trigger an inline bound script
2934 if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
2935 event.result = false;
2936 event.preventDefault();
2939 // Bubble up to document, then to window
2940 cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
2941 } while ( cur && !event.isPropagationStopped() );
2943 // If nobody prevented the default action, do it now
2944 if ( !event.isDefaultPrevented() ) {
2946 special = jQuery.event.special[ type ] || {};
2948 if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
2949 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2951 // Call a native DOM method on the target with the same name name as the event.
2952 // Can't use an .isFunction)() check here because IE6/7 fails that test.
2953 // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
2955 if ( ontype && elem[ type ] ) {
2956 // Don't re-trigger an onFOO event when we call its FOO() method
2957 old = elem[ ontype ];
2960 elem[ ontype ] = null;
2963 jQuery.event.triggered = type;
2966 } catch ( ieError ) {}
2969 elem[ ontype ] = old;
2972 jQuery.event.triggered = undefined;
2976 return event.result;
2979 handle: function( event ) {
2980 event = jQuery.event.fix( event || window.event );
2981 // Snapshot the handlers list since a called handler may add/remove events.
2982 var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
2983 run_all = !event.exclusive && !event.namespace,
2984 args = Array.prototype.slice.call( arguments, 0 );
2986 // Use the fix-ed Event rather than the (read-only) native event
2988 event.currentTarget = this;
2990 for ( var j = 0, l = handlers.length; j < l; j++ ) {
2991 var handleObj = handlers[ j ];
2993 // Triggered event must 1) be non-exclusive and have no namespace, or
2994 // 2) have namespace(s) a subset or equal to those in the bound event.
2995 if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
2996 // Pass in a reference to the handler function itself
2997 // So that we can later remove it
2998 event.handler = handleObj.handler;
2999 event.data = handleObj.data;
3000 event.handleObj = handleObj;
3002 var ret = handleObj.handler.apply( this, args );
3004 if ( ret !== undefined ) {
3006 if ( ret === false ) {
3007 event.preventDefault();
3008 event.stopPropagation();
3012 if ( event.isImmediatePropagationStopped() ) {
3017 return event.result;
3020 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(" "),
3022 fix: function( event ) {
3023 if ( event[ jQuery.expando ] ) {
3027 // store a copy of the original event object
3028 // and "clone" to set read-only properties
3029 var originalEvent = event;
3030 event = jQuery.Event( originalEvent );
3032 for ( var i = this.props.length, prop; i; ) {
3033 prop = this.props[ --i ];
3034 event[ prop ] = originalEvent[ prop ];
3037 // Fix target property, if necessary
3038 if ( !event.target ) {
3039 // Fixes #1925 where srcElement might not be defined either
3040 event.target = event.srcElement || document;
3043 // check if target is a textnode (safari)
3044 if ( event.target.nodeType === 3 ) {
3045 event.target = event.target.parentNode;
3048 // Add relatedTarget, if necessary
3049 if ( !event.relatedTarget && event.fromElement ) {
3050 event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
3053 // Calculate pageX/Y if missing and clientX/Y available
3054 if ( event.pageX == null && event.clientX != null ) {
3055 var eventDocument = event.target.ownerDocument || document,
3056 doc = eventDocument.documentElement,
3057 body = eventDocument.body;
3059 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
3060 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
3063 // Add which for key events
3064 if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
3065 event.which = event.charCode != null ? event.charCode : event.keyCode;
3068 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
3069 if ( !event.metaKey && event.ctrlKey ) {
3070 event.metaKey = event.ctrlKey;
3073 // Add which for click: 1 === left; 2 === middle; 3 === right
3074 // Note: button is not normalized, so don't use it
3075 if ( !event.which && event.button !== undefined ) {
3076 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
3082 // Deprecated, use jQuery.guid instead
3085 // Deprecated, use jQuery.proxy instead
3086 proxy: jQuery.proxy,
3090 // Make sure the ready event is setup
3091 setup: jQuery.bindReady,
3092 teardown: jQuery.noop
3096 add: function( handleObj ) {
3097 jQuery.event.add( this,
3098 liveConvert( handleObj.origType, handleObj.selector ),
3099 jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
3102 remove: function( handleObj ) {
3103 jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
3108 setup: function( data, namespaces, eventHandle ) {
3109 // We only want to do this special case on windows
3110 if ( jQuery.isWindow( this ) ) {
3111 this.onbeforeunload = eventHandle;
3115 teardown: function( namespaces, eventHandle ) {
3116 if ( this.onbeforeunload === eventHandle ) {
3117 this.onbeforeunload = null;
3124 jQuery.removeEvent = document.removeEventListener ?
3125 function( elem, type, handle ) {
3126 if ( elem.removeEventListener ) {
3127 elem.removeEventListener( type, handle, false );
3130 function( elem, type, handle ) {
3131 if ( elem.detachEvent ) {
3132 elem.detachEvent( "on" + type, handle );
3136 jQuery.Event = function( src, props ) {
3137 // Allow instantiation without the 'new' keyword
3138 if ( !this.preventDefault ) {
3139 return new jQuery.Event( src, props );
3143 if ( src && src.type ) {
3144 this.originalEvent = src;
3145 this.type = src.type;
3147 // Events bubbling up the document may have been marked as prevented
3148 // by a handler lower down the tree; reflect the correct value.
3149 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
3150 src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
3157 // Put explicitly provided properties onto the event object
3159 jQuery.extend( this, props );
3162 // timeStamp is buggy for some events on Firefox(#3843)
3163 // So we won't rely on the native value
3164 this.timeStamp = jQuery.now();
3167 this[ jQuery.expando ] = true;
3170 function returnFalse() {
3173 function returnTrue() {
3177 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3178 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3179 jQuery.Event.prototype = {
3180 preventDefault: function() {
3181 this.isDefaultPrevented = returnTrue;
3183 var e = this.originalEvent;
3188 // if preventDefault exists run it on the original event
3189 if ( e.preventDefault ) {
3192 // otherwise set the returnValue property of the original event to false (IE)
3194 e.returnValue = false;
3197 stopPropagation: function() {
3198 this.isPropagationStopped = returnTrue;
3200 var e = this.originalEvent;
3204 // if stopPropagation exists run it on the original event
3205 if ( e.stopPropagation ) {
3206 e.stopPropagation();
3208 // otherwise set the cancelBubble property of the original event to true (IE)
3209 e.cancelBubble = true;
3211 stopImmediatePropagation: function() {
3212 this.isImmediatePropagationStopped = returnTrue;
3213 this.stopPropagation();
3215 isDefaultPrevented: returnFalse,
3216 isPropagationStopped: returnFalse,
3217 isImmediatePropagationStopped: returnFalse
3220 // Checks if an event happened on an element within another element
3221 // Used in jQuery.event.special.mouseenter and mouseleave handlers
3222 var withinElement = function( event ) {
3224 // Check if mouse(over|out) are still within the same parent element
3225 var related = event.relatedTarget,
3227 eventType = event.type;
3229 event.type = event.data;
3231 if ( related !== this ) {
3234 inside = jQuery.contains( this, related );
3239 jQuery.event.handle.apply( this, arguments );
3241 event.type = eventType;
3246 // In case of event delegation, we only need to rename the event.type,
3247 // liveHandler will take care of the rest.
3248 delegate = function( event ) {
3249 event.type = event.data;
3250 jQuery.event.handle.apply( this, arguments );
3253 // Create mouseenter and mouseleave events
3255 mouseenter: "mouseover",
3256 mouseleave: "mouseout"
3257 }, function( orig, fix ) {
3258 jQuery.event.special[ orig ] = {
3259 setup: function( data ) {
3260 jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
3262 teardown: function( data ) {
3263 jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
3268 // submit delegation
3269 if ( !jQuery.support.submitBubbles ) {
3271 jQuery.event.special.submit = {
3272 setup: function( data, namespaces ) {
3273 if ( !jQuery.nodeName( this, "form" ) ) {
3274 jQuery.event.add(this, "click.specialSubmit", function( e ) {
3275 // Avoid triggering error on non-existent type attribute in IE VML (#7071)
3276 var elem = e.target,
3277 type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3279 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
3280 trigger( "submit", this, arguments );
3284 jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
3285 var elem = e.target,
3286 type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
3288 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
3289 trigger( "submit", this, arguments );
3298 teardown: function( namespaces ) {
3299 jQuery.event.remove( this, ".specialSubmit" );
3305 // change delegation, happens here so we have bind.
3306 if ( !jQuery.support.changeBubbles ) {
3310 getVal = function( elem ) {
3311 var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
3314 if ( type === "radio" || type === "checkbox" ) {
3317 } else if ( type === "select-multiple" ) {
3318 val = elem.selectedIndex > -1 ?
3319 jQuery.map( elem.options, function( elem ) {
3320 return elem.selected;
3324 } else if ( jQuery.nodeName( elem, "select" ) ) {
3325 val = elem.selectedIndex;
3331 testChange = function testChange( e ) {
3332 var elem = e.target, data, val;
3334 if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
3338 data = jQuery._data( elem, "_change_data" );
3341 // the current data will be also retrieved by beforeactivate
3342 if ( e.type !== "focusout" || elem.type !== "radio" ) {
3343 jQuery._data( elem, "_change_data", val );
3346 if ( data === undefined || val === data ) {
3350 if ( data != null || val ) {
3352 e.liveFired = undefined;
3353 jQuery.event.trigger( e, arguments[1], elem );
3357 jQuery.event.special.change = {
3359 focusout: testChange,
3361 beforedeactivate: testChange,
3363 click: function( e ) {
3364 var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3366 if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
3367 testChange.call( this, e );
3371 // Change has to be called before submit
3372 // Keydown will be called before keypress, which is used in submit-event delegation
3373 keydown: function( e ) {
3374 var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
3376 if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
3377 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
3378 type === "select-multiple" ) {
3379 testChange.call( this, e );
3383 // Beforeactivate happens also before the previous element is blurred
3384 // with this event you can't trigger a change event, but you can store
3386 beforeactivate: function( e ) {
3387 var elem = e.target;
3388 jQuery._data( elem, "_change_data", getVal(elem) );
3392 setup: function( data, namespaces ) {
3393 if ( this.type === "file" ) {
3397 for ( var type in changeFilters ) {
3398 jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
3401 return rformElems.test( this.nodeName );
3404 teardown: function( namespaces ) {
3405 jQuery.event.remove( this, ".specialChange" );
3407 return rformElems.test( this.nodeName );
3411 changeFilters = jQuery.event.special.change.filters;
3413 // Handle when the input is .focus()'d
3414 changeFilters.focus = changeFilters.beforeactivate;
3417 function trigger( type, elem, args ) {
3418 // Piggyback on a donor event to simulate a different one.
3419 // Fake originalEvent to avoid donor's stopPropagation, but if the
3420 // simulated event prevents default then we do the same on the donor.
3421 // Don't pass args or remember liveFired; they apply to the donor event.
3422 var event = jQuery.extend( {}, args[ 0 ] );
3424 event.originalEvent = {};
3425 event.liveFired = undefined;
3426 jQuery.event.handle.call( elem, event );
3427 if ( event.isDefaultPrevented() ) {
3428 args[ 0 ].preventDefault();
3432 // Create "bubbling" focus and blur events
3433 if ( !jQuery.support.focusinBubbles ) {
3434 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3436 // Attach a single capturing handler while someone wants focusin/focusout
3439 jQuery.event.special[ fix ] = {
3441 if ( attaches++ === 0 ) {
3442 document.addEventListener( orig, handler, true );
3445 teardown: function() {
3446 if ( --attaches === 0 ) {
3447 document.removeEventListener( orig, handler, true );
3452 function handler( donor ) {
3453 // Donor event is always a native one; fix it and switch its type.
3454 // Let focusin/out handler cancel the donor focus/blur event.
3455 var e = jQuery.event.fix( donor );
3457 e.originalEvent = {};
3458 jQuery.event.trigger( e, null, e.target );
3459 if ( e.isDefaultPrevented() ) {
3460 donor.preventDefault();
3466 jQuery.each(["bind", "one"], function( i, name ) {
3467 jQuery.fn[ name ] = function( type, data, fn ) {
3470 // Handle object literals
3471 if ( typeof type === "object" ) {
3472 for ( var key in type ) {
3473 this[ name ](key, data, type[key], fn);
3478 if ( arguments.length === 2 || data === false ) {
3483 if ( name === "one" ) {
3484 handler = function( event ) {
3485 jQuery( this ).unbind( event, handler );
3486 return fn.apply( this, arguments );
3488 handler.guid = fn.guid || jQuery.guid++;
3493 if ( type === "unload" && name !== "one" ) {
3494 this.one( type, data, fn );
3497 for ( var i = 0, l = this.length; i < l; i++ ) {
3498 jQuery.event.add( this[i], type, handler, data );
3507 unbind: function( type, fn ) {
3508 // Handle object literals
3509 if ( typeof type === "object" && !type.preventDefault ) {
3510 for ( var key in type ) {
3511 this.unbind(key, type[key]);
3515 for ( var i = 0, l = this.length; i < l; i++ ) {
3516 jQuery.event.remove( this[i], type, fn );
3523 delegate: function( selector, types, data, fn ) {
3524 return this.live( types, data, fn, selector );
3527 undelegate: function( selector, types, fn ) {
3528 if ( arguments.length === 0 ) {
3529 return this.unbind( "live" );
3532 return this.die( types, null, fn, selector );
3536 trigger: function( type, data ) {
3537 return this.each(function() {
3538 jQuery.event.trigger( type, data, this );
3542 triggerHandler: function( type, data ) {
3544 return jQuery.event.trigger( type, data, this[0], true );
3548 toggle: function( fn ) {
3549 // Save reference to arguments for access in closure
3550 var args = arguments,
3551 guid = fn.guid || jQuery.guid++,
3553 toggler = function( event ) {
3554 // Figure out which function to execute
3555 var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3556 jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3558 // Make sure that clicks stop
3559 event.preventDefault();
3561 // and execute the function
3562 return args[ lastToggle ].apply( this, arguments ) || false;
3565 // link all the functions, so any of them can unbind this click handler
3566 toggler.guid = guid;
3567 while ( i < args.length ) {
3568 args[ i++ ].guid = guid;
3571 return this.click( toggler );
3574 hover: function( fnOver, fnOut ) {
3575 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3582 mouseenter: "mouseover",
3583 mouseleave: "mouseout"
3586 jQuery.each(["live", "die"], function( i, name ) {
3587 jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
3588 var type, i = 0, match, namespaces, preType,
3589 selector = origSelector || this.selector,
3590 context = origSelector ? this : jQuery( this.context );
3592 if ( typeof types === "object" && !types.preventDefault ) {
3593 for ( var key in types ) {
3594 context[ name ]( key, data, types[key], selector );
3600 if ( name === "die" && !types &&
3601 origSelector && origSelector.charAt(0) === "." ) {
3603 context.unbind( origSelector );
3608 if ( data === false || jQuery.isFunction( data ) ) {
3609 fn = data || returnFalse;
3613 types = (types || "").split(" ");
3615 while ( (type = types[ i++ ]) != null ) {
3616 match = rnamespaces.exec( type );
3620 namespaces = match[0];
3621 type = type.replace( rnamespaces, "" );
3624 if ( type === "hover" ) {
3625 types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
3631 if ( liveMap[ type ] ) {
3632 types.push( liveMap[ type ] + namespaces );
3633 type = type + namespaces;
3636 type = (liveMap[ type ] || type) + namespaces;
3639 if ( name === "live" ) {
3640 // bind live handler
3641 for ( var j = 0, l = context.length; j < l; j++ ) {
3642 jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
3643 { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
3647 // unbind live handler
3648 context.unbind( "live." + liveConvert( type, selector ), fn );
3656 function liveHandler( event ) {
3657 var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
3660 events = jQuery._data( this, "events" );
3662 // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
3663 if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
3667 if ( event.namespace ) {
3668 namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
3671 event.liveFired = this;
3673 var live = events.live.slice(0);
3675 for ( j = 0; j < live.length; j++ ) {
3676 handleObj = live[j];
3678 if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
3679 selectors.push( handleObj.selector );
3682 live.splice( j--, 1 );
3686 match = jQuery( event.target ).closest( selectors, event.currentTarget );
3688 for ( i = 0, l = match.length; i < l; i++ ) {
3691 for ( j = 0; j < live.length; j++ ) {
3692 handleObj = live[j];
3694 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
3698 // Those two events require additional checking
3699 if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
3700 event.type = handleObj.preType;
3701 related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
3703 // Make sure not to accidentally match a child element with the same selector
3704 if ( related && jQuery.contains( elem, related ) ) {
3709 if ( !related || related !== elem ) {
3710 elems.push({ elem: elem, handleObj: handleObj, level: close.level });
3716 for ( i = 0, l = elems.length; i < l; i++ ) {
3719 if ( maxLevel && match.level > maxLevel ) {
3723 event.currentTarget = match.elem;
3724 event.data = match.handleObj.data;
3725 event.handleObj = match.handleObj;
3727 ret = match.handleObj.origHandler.apply( match.elem, arguments );
3729 if ( ret === false || event.isPropagationStopped() ) {
3730 maxLevel = match.level;
3732 if ( ret === false ) {
3735 if ( event.isImmediatePropagationStopped() ) {
3744 function liveConvert( type, selector ) {
3745 return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
3748 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3749 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3750 "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
3752 // Handle event binding
3753 jQuery.fn[ name ] = function( data, fn ) {
3759 return arguments.length > 0 ?
3760 this.bind( name, data, fn ) :
3761 this.trigger( name );
3764 if ( jQuery.attrFn ) {
3765 jQuery.attrFn[ name ] = true;
3772 * Sizzle CSS Selector Engine
3773 * Copyright 2011, The Dojo Foundation
3774 * Released under the MIT, BSD, and GPL Licenses.
3775 * More information: http://sizzlejs.com/
3779 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
3781 toString = Object.prototype.toString,
3782 hasDuplicate = false,
3783 baseHasDuplicate = true,
3787 // Here we check if the JavaScript engine is using some sort of
3788 // optimization where it does not always call our comparision
3789 // function. If that is the case, discard the hasDuplicate value.
3790 // Thus far that includes Google Chrome.
3791 [0, 0].sort(function() {
3792 baseHasDuplicate = false;
3796 var Sizzle = function( selector, context, results, seed ) {
3797 results = results || [];
3798 context = context || document;
3800 var origContext = context;
3802 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
3806 if ( !selector || typeof selector !== "string" ) {
3810 var m, set, checkSet, extra, ret, cur, pop, i,
3812 contextXML = Sizzle.isXML( context ),
3816 // Reset the position of the chunker regexp (start from head)
3819 m = chunker.exec( soFar );
3833 if ( parts.length > 1 && origPOS.exec( selector ) ) {
3835 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
3836 set = posProcess( parts[0] + parts[1], context );
3839 set = Expr.relative[ parts[0] ] ?
3841 Sizzle( parts.shift(), context );
3843 while ( parts.length ) {
3844 selector = parts.shift();
3846 if ( Expr.relative[ selector ] ) {
3847 selector += parts.shift();
3850 set = posProcess( selector, set );
3855 // Take a shortcut and set the context if the root selector is an ID
3856 // (but not if it'll be faster if the inner selector is an ID)
3857 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
3858 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
3860 ret = Sizzle.find( parts.shift(), context, contextXML );
3861 context = ret.expr ?
3862 Sizzle.filter( ret.expr, ret.set )[0] :
3868 { expr: parts.pop(), set: makeArray(seed) } :
3869 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
3872 Sizzle.filter( ret.expr, ret.set ) :
3875 if ( parts.length > 0 ) {
3876 checkSet = makeArray( set );
3882 while ( parts.length ) {
3886 if ( !Expr.relative[ cur ] ) {
3892 if ( pop == null ) {
3896 Expr.relative[ cur ]( checkSet, pop, contextXML );
3900 checkSet = parts = [];
3909 Sizzle.error( cur || selector );
3912 if ( toString.call(checkSet) === "[object Array]" ) {
3914 results.push.apply( results, checkSet );
3916 } else if ( context && context.nodeType === 1 ) {
3917 for ( i = 0; checkSet[i] != null; i++ ) {
3918 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
3919 results.push( set[i] );
3924 for ( i = 0; checkSet[i] != null; i++ ) {
3925 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
3926 results.push( set[i] );
3932 makeArray( checkSet, results );
3936 Sizzle( extra, origContext, results, seed );
3937 Sizzle.uniqueSort( results );
3943 Sizzle.uniqueSort = function( results ) {
3945 hasDuplicate = baseHasDuplicate;
3946 results.sort( sortOrder );
3948 if ( hasDuplicate ) {
3949 for ( var i = 1; i < results.length; i++ ) {
3950 if ( results[i] === results[ i - 1 ] ) {
3951 results.splice( i--, 1 );
3960 Sizzle.matches = function( expr, set ) {
3961 return Sizzle( expr, null, null, set );
3964 Sizzle.matchesSelector = function( node, expr ) {
3965 return Sizzle( expr, null, null, [node] ).length > 0;
3968 Sizzle.find = function( expr, context, isXML ) {
3975 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
3977 type = Expr.order[i];
3979 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
3980 var left = match[1];
3981 match.splice( 1, 1 );
3983 if ( left.substr( left.length - 1 ) !== "\\" ) {
3984 match[1] = (match[1] || "").replace( rBackslash, "" );
3985 set = Expr.find[ type ]( match, context, isXML );
3987 if ( set != null ) {
3988 expr = expr.replace( Expr.match[ type ], "" );
3996 set = typeof context.getElementsByTagName !== "undefined" ?
3997 context.getElementsByTagName( "*" ) :
4001 return { set: set, expr: expr };
4004 Sizzle.filter = function( expr, set, inplace, not ) {
4005 var match, anyFound,
4009 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
4011 while ( expr && set.length ) {
4012 for ( var type in Expr.filter ) {
4013 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
4015 filter = Expr.filter[ type ],
4022 if ( left.substr( left.length - 1 ) === "\\" ) {
4026 if ( curLoop === result ) {
4030 if ( Expr.preFilter[ type ] ) {
4031 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
4034 anyFound = found = true;
4036 } else if ( match === true ) {
4042 for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
4044 found = filter( item, match, i, curLoop );
4045 var pass = not ^ !!found;
4047 if ( inplace && found != null ) {
4055 } else if ( pass ) {
4056 result.push( item );
4063 if ( found !== undefined ) {
4068 expr = expr.replace( Expr.match[ type ], "" );
4079 // Improper expression
4080 if ( expr === old ) {
4081 if ( anyFound == null ) {
4082 Sizzle.error( expr );
4095 Sizzle.error = function( msg ) {
4096 throw "Syntax error, unrecognized expression: " + msg;
4099 var Expr = Sizzle.selectors = {
4100 order: [ "ID", "NAME", "TAG" ],
4103 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4104 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
4105 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
4106 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
4107 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
4108 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
4109 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
4110 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
4116 "class": "className",
4121 href: function( elem ) {
4122 return elem.getAttribute( "href" );
4124 type: function( elem ) {
4125 return elem.getAttribute( "type" );
4130 "+": function(checkSet, part){
4131 var isPartStr = typeof part === "string",
4132 isTag = isPartStr && !rNonWord.test( part ),
4133 isPartStrNotTag = isPartStr && !isTag;
4136 part = part.toLowerCase();
4139 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
4140 if ( (elem = checkSet[i]) ) {
4141 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
4143 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
4149 if ( isPartStrNotTag ) {
4150 Sizzle.filter( part, checkSet, true );
4154 ">": function( checkSet, part ) {
4156 isPartStr = typeof part === "string",
4158 l = checkSet.length;
4160 if ( isPartStr && !rNonWord.test( part ) ) {
4161 part = part.toLowerCase();
4163 for ( ; i < l; i++ ) {
4167 var parent = elem.parentNode;
4168 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
4173 for ( ; i < l; i++ ) {
4177 checkSet[i] = isPartStr ?
4179 elem.parentNode === part;
4184 Sizzle.filter( part, checkSet, true );
4189 "": function(checkSet, part, isXML){
4194 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4195 part = part.toLowerCase();
4197 checkFn = dirNodeCheck;
4200 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
4203 "~": function( checkSet, part, isXML ) {
4208 if ( typeof part === "string" && !rNonWord.test( part ) ) {
4209 part = part.toLowerCase();
4211 checkFn = dirNodeCheck;
4214 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
4219 ID: function( match, context, isXML ) {
4220 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4221 var m = context.getElementById(match[1]);
4222 // Check parentNode to catch when Blackberry 4.6 returns
4223 // nodes that are no longer in the document #6963
4224 return m && m.parentNode ? [m] : [];
4228 NAME: function( match, context ) {
4229 if ( typeof context.getElementsByName !== "undefined" ) {
4231 results = context.getElementsByName( match[1] );
4233 for ( var i = 0, l = results.length; i < l; i++ ) {
4234 if ( results[i].getAttribute("name") === match[1] ) {
4235 ret.push( results[i] );
4239 return ret.length === 0 ? null : ret;
4243 TAG: function( match, context ) {
4244 if ( typeof context.getElementsByTagName !== "undefined" ) {
4245 return context.getElementsByTagName( match[1] );
4250 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
4251 match = " " + match[1].replace( rBackslash, "" ) + " ";
4257 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
4259 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
4261 result.push( elem );
4264 } else if ( inplace ) {
4273 ID: function( match ) {
4274 return match[1].replace( rBackslash, "" );
4277 TAG: function( match, curLoop ) {
4278 return match[1].replace( rBackslash, "" ).toLowerCase();
4281 CHILD: function( match ) {
4282 if ( match[1] === "nth" ) {
4284 Sizzle.error( match[0] );
4287 match[2] = match[2].replace(/^\+|\s*/g, '');
4289 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
4290 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
4291 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
4292 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
4294 // calculate the numbers (first)n+(last) including if they are negative
4295 match[2] = (test[1] + (test[2] || 1)) - 0;
4296 match[3] = test[3] - 0;
4298 else if ( match[2] ) {
4299 Sizzle.error( match[0] );
4302 // TODO: Move to normal caching system
4308 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
4309 var name = match[1] = match[1].replace( rBackslash, "" );
4311 if ( !isXML && Expr.attrMap[name] ) {
4312 match[1] = Expr.attrMap[name];
4315 // Handle if an un-quoted value was used
4316 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
4318 if ( match[2] === "~=" ) {
4319 match[4] = " " + match[4] + " ";
4325 PSEUDO: function( match, curLoop, inplace, result, not ) {
4326 if ( match[1] === "not" ) {
4327 // If we're dealing with a complex expression, or a simple one
4328 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
4329 match[3] = Sizzle(match[3], null, null, curLoop);
4332 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
4335 result.push.apply( result, ret );
4341 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
4348 POS: function( match ) {
4349 match.unshift( true );
4356 enabled: function( elem ) {
4357 return elem.disabled === false && elem.type !== "hidden";
4360 disabled: function( elem ) {
4361 return elem.disabled === true;
4364 checked: function( elem ) {
4365 return elem.checked === true;
4368 selected: function( elem ) {
4369 // Accessing this property makes selected-by-default
4370 // options in Safari work properly
4371 if ( elem.parentNode ) {
4372 elem.parentNode.selectedIndex;
4375 return elem.selected === true;
4378 parent: function( elem ) {
4379 return !!elem.firstChild;
4382 empty: function( elem ) {
4383 return !elem.firstChild;
4386 has: function( elem, i, match ) {
4387 return !!Sizzle( match[3], elem ).length;
4390 header: function( elem ) {
4391 return (/h\d/i).test( elem.nodeName );
4394 text: function( elem ) {
4395 var attr = elem.getAttribute( "type" ), type = elem.type;
4396 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4397 // use getAttribute instead to test this case
4398 return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
4401 radio: function( elem ) {
4402 return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
4405 checkbox: function( elem ) {
4406 return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
4409 file: function( elem ) {
4410 return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
4413 password: function( elem ) {
4414 return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
4417 submit: function( elem ) {
4418 var name = elem.nodeName.toLowerCase();
4419 return (name === "input" || name === "button") && "submit" === elem.type;
4422 image: function( elem ) {
4423 return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
4426 reset: function( elem ) {
4427 var name = elem.nodeName.toLowerCase();
4428 return (name === "input" || name === "button") && "reset" === elem.type;
4431 button: function( elem ) {
4432 var name = elem.nodeName.toLowerCase();
4433 return name === "input" && "button" === elem.type || name === "button";
4436 input: function( elem ) {
4437 return (/input|select|textarea|button/i).test( elem.nodeName );
4440 focus: function( elem ) {
4441 return elem === elem.ownerDocument.activeElement;
4445 first: function( elem, i ) {
4449 last: function( elem, i, match, array ) {
4450 return i === array.length - 1;
4453 even: function( elem, i ) {
4457 odd: function( elem, i ) {
4461 lt: function( elem, i, match ) {
4462 return i < match[3] - 0;
4465 gt: function( elem, i, match ) {
4466 return i > match[3] - 0;
4469 nth: function( elem, i, match ) {
4470 return match[3] - 0 === i;
4473 eq: function( elem, i, match ) {
4474 return match[3] - 0 === i;
4478 PSEUDO: function( elem, match, i, array ) {
4479 var name = match[1],
4480 filter = Expr.filters[ name ];
4483 return filter( elem, i, match, array );
4485 } else if ( name === "contains" ) {
4486 return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
4488 } else if ( name === "not" ) {
4491 for ( var j = 0, l = not.length; j < l; j++ ) {
4492 if ( not[j] === elem ) {
4500 Sizzle.error( name );
4504 CHILD: function( elem, match ) {
4505 var type = match[1],
4511 while ( (node = node.previousSibling) ) {
4512 if ( node.nodeType === 1 ) {
4517 if ( type === "first" ) {
4524 while ( (node = node.nextSibling) ) {
4525 if ( node.nodeType === 1 ) {
4533 var first = match[2],
4536 if ( first === 1 && last === 0 ) {
4540 var doneName = match[0],
4541 parent = elem.parentNode;
4543 if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
4546 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4547 if ( node.nodeType === 1 ) {
4548 node.nodeIndex = ++count;
4552 parent.sizcache = doneName;
4555 var diff = elem.nodeIndex - last;
4557 if ( first === 0 ) {
4561 return ( diff % first === 0 && diff / first >= 0 );
4566 ID: function( elem, match ) {
4567 return elem.nodeType === 1 && elem.getAttribute("id") === match;
4570 TAG: function( elem, match ) {
4571 return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
4574 CLASS: function( elem, match ) {
4575 return (" " + (elem.className || elem.getAttribute("class")) + " ")
4576 .indexOf( match ) > -1;
4579 ATTR: function( elem, match ) {
4580 var name = match[1],
4581 result = Expr.attrHandle[ name ] ?
4582 Expr.attrHandle[ name ]( elem ) :
4583 elem[ name ] != null ?
4585 elem.getAttribute( name ),
4586 value = result + "",
4590 return result == null ?
4595 value.indexOf(check) >= 0 :
4597 (" " + value + " ").indexOf(check) >= 0 :
4599 value && result !== false :
4603 value.indexOf(check) === 0 :
4605 value.substr(value.length - check.length) === check :
4607 value === check || value.substr(0, check.length + 1) === check + "-" :
4611 POS: function( elem, match, i, array ) {
4612 var name = match[2],
4613 filter = Expr.setFilters[ name ];
4616 return filter( elem, i, match, array );
4622 var origPOS = Expr.match.POS,
4623 fescape = function(all, num){
4624 return "\\" + (num - 0 + 1);
4627 for ( var type in Expr.match ) {
4628 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
4629 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
4632 var makeArray = function( array, results ) {
4633 array = Array.prototype.slice.call( array, 0 );
4636 results.push.apply( results, array );
4643 // Perform a simple check to determine if the browser is capable of
4644 // converting a NodeList to an array using builtin methods.
4645 // Also verifies that the returned array holds DOM nodes
4646 // (which is not the case in the Blackberry browser)
4648 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
4650 // Provide a fallback method if it does not work
4652 makeArray = function( array, results ) {
4654 ret = results || [];
4656 if ( toString.call(array) === "[object Array]" ) {
4657 Array.prototype.push.apply( ret, array );
4660 if ( typeof array.length === "number" ) {
4661 for ( var l = array.length; i < l; i++ ) {
4662 ret.push( array[i] );
4666 for ( ; array[i]; i++ ) {
4667 ret.push( array[i] );
4676 var sortOrder, siblingCheck;
4678 if ( document.documentElement.compareDocumentPosition ) {
4679 sortOrder = function( a, b ) {
4681 hasDuplicate = true;
4685 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
4686 return a.compareDocumentPosition ? -1 : 1;
4689 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
4693 sortOrder = function( a, b ) {
4694 // The nodes are identical, we can exit early
4696 hasDuplicate = true;
4699 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4700 } else if ( a.sourceIndex && b.sourceIndex ) {
4701 return a.sourceIndex - b.sourceIndex;
4711 // If the nodes are siblings (or identical) we can do a quick check
4712 if ( aup === bup ) {
4713 return siblingCheck( a, b );
4715 // If no parents were found then the nodes are disconnected
4716 } else if ( !aup ) {
4719 } else if ( !bup ) {
4723 // Otherwise they're somewhere else in the tree so we need
4724 // to build up a full list of the parentNodes for comparison
4727 cur = cur.parentNode;
4734 cur = cur.parentNode;
4740 // Start walking down the tree looking for a discrepancy
4741 for ( var i = 0; i < al && i < bl; i++ ) {
4742 if ( ap[i] !== bp[i] ) {
4743 return siblingCheck( ap[i], bp[i] );
4747 // We ended someplace up the tree so do a sibling check
4749 siblingCheck( a, bp[i], -1 ) :
4750 siblingCheck( ap[i], b, 1 );
4753 siblingCheck = function( a, b, ret ) {
4758 var cur = a.nextSibling;
4765 cur = cur.nextSibling;
4772 // Utility function for retreiving the text value of an array of DOM nodes
4773 Sizzle.getText = function( elems ) {
4776 for ( var i = 0; elems[i]; i++ ) {
4779 // Get the text from text nodes and CDATA nodes
4780 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
4781 ret += elem.nodeValue;
4783 // Traverse everything else, except comment nodes
4784 } else if ( elem.nodeType !== 8 ) {
4785 ret += Sizzle.getText( elem.childNodes );
4792 // Check to see if the browser returns elements by name when
4793 // querying by getElementById (and provide a workaround)
4795 // We're going to inject a fake input element with a specified name
4796 var form = document.createElement("div"),
4797 id = "script" + (new Date()).getTime(),
4798 root = document.documentElement;
4800 form.innerHTML = "<a name='" + id + "'/>";
4802 // Inject it into the root element, check its status, and remove it quickly
4803 root.insertBefore( form, root.firstChild );
4805 // The workaround has to do additional checks after a getElementById
4806 // Which slows things down for other browsers (hence the branching)
4807 if ( document.getElementById( id ) ) {
4808 Expr.find.ID = function( match, context, isXML ) {
4809 if ( typeof context.getElementById !== "undefined" && !isXML ) {
4810 var m = context.getElementById(match[1]);
4813 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
4820 Expr.filter.ID = function( elem, match ) {
4821 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
4823 return elem.nodeType === 1 && node && node.nodeValue === match;
4827 root.removeChild( form );
4829 // release memory in IE
4834 // Check to see if the browser returns only elements
4835 // when doing getElementsByTagName("*")
4837 // Create a fake element
4838 var div = document.createElement("div");
4839 div.appendChild( document.createComment("") );
4841 // Make sure no comments are found
4842 if ( div.getElementsByTagName("*").length > 0 ) {
4843 Expr.find.TAG = function( match, context ) {
4844 var results = context.getElementsByTagName( match[1] );
4846 // Filter out possible comments
4847 if ( match[1] === "*" ) {
4850 for ( var i = 0; results[i]; i++ ) {
4851 if ( results[i].nodeType === 1 ) {
4852 tmp.push( results[i] );
4863 // Check to see if an attribute returns normalized href attributes
4864 div.innerHTML = "<a href='#'></a>";
4866 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
4867 div.firstChild.getAttribute("href") !== "#" ) {
4869 Expr.attrHandle.href = function( elem ) {
4870 return elem.getAttribute( "href", 2 );
4874 // release memory in IE
4878 if ( document.querySelectorAll ) {
4880 var oldSizzle = Sizzle,
4881 div = document.createElement("div"),
4884 div.innerHTML = "<p class='TEST'></p>";
4886 // Safari can't handle uppercase or unicode characters when
4888 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
4892 Sizzle = function( query, context, extra, seed ) {
4893 context = context || document;
4895 // Only use querySelectorAll on non-XML documents
4896 // (ID selectors don't work in non-HTML documents)
4897 if ( !seed && !Sizzle.isXML(context) ) {
4898 // See if we find a selector to speed up
4899 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
4901 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
4902 // Speed-up: Sizzle("TAG")
4904 return makeArray( context.getElementsByTagName( query ), extra );
4906 // Speed-up: Sizzle(".CLASS")
4907 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
4908 return makeArray( context.getElementsByClassName( match[2] ), extra );
4912 if ( context.nodeType === 9 ) {
4913 // Speed-up: Sizzle("body")
4914 // The body element only exists once, optimize finding it
4915 if ( query === "body" && context.body ) {
4916 return makeArray( [ context.body ], extra );
4918 // Speed-up: Sizzle("#ID")
4919 } else if ( match && match[3] ) {
4920 var elem = context.getElementById( match[3] );
4922 // Check parentNode to catch when Blackberry 4.6 returns
4923 // nodes that are no longer in the document #6963
4924 if ( elem && elem.parentNode ) {
4925 // Handle the case where IE and Opera return items
4926 // by name instead of ID
4927 if ( elem.id === match[3] ) {
4928 return makeArray( [ elem ], extra );
4932 return makeArray( [], extra );
4937 return makeArray( context.querySelectorAll(query), extra );
4938 } catch(qsaError) {}
4940 // qSA works strangely on Element-rooted queries
4941 // We can work around this by specifying an extra ID on the root
4942 // and working up from there (Thanks to Andrew Dupont for the technique)
4943 // IE 8 doesn't work on object elements
4944 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
4945 var oldContext = context,
4946 old = context.getAttribute( "id" ),
4948 hasParent = context.parentNode,
4949 relativeHierarchySelector = /^\s*[+~]/.test( query );
4952 context.setAttribute( "id", nid );
4954 nid = nid.replace( /'/g, "\\$&" );
4956 if ( relativeHierarchySelector && hasParent ) {
4957 context = context.parentNode;
4961 if ( !relativeHierarchySelector || hasParent ) {
4962 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
4965 } catch(pseudoError) {
4968 oldContext.removeAttribute( "id" );
4974 return oldSizzle(query, context, extra, seed);
4977 for ( var prop in oldSizzle ) {
4978 Sizzle[ prop ] = oldSizzle[ prop ];
4981 // release memory in IE
4987 var html = document.documentElement,
4988 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
4991 // Check to see if it's possible to do matchesSelector
4992 // on a disconnected node (IE 9 fails this)
4993 var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
4994 pseudoWorks = false;
4997 // This should fail with an exception
4998 // Gecko does not error, returns false instead
4999 matches.call( document.documentElement, "[test!='']:sizzle" );
5001 } catch( pseudoError ) {
5005 Sizzle.matchesSelector = function( node, expr ) {
5006 // Make sure that attribute selectors are quoted
5007 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
5009 if ( !Sizzle.isXML( node ) ) {
5011 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
5012 var ret = matches.call( node, expr );
5014 // IE 9's matchesSelector returns false on disconnected nodes
5015 if ( ret || !disconnectedMatch ||
5016 // As well, disconnected nodes are said to be in a document
5017 // fragment in IE 9, so check for that
5018 node.document && node.document.nodeType !== 11 ) {
5025 return Sizzle(expr, null, null, [node]).length > 0;
5031 var div = document.createElement("div");
5033 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
5035 // Opera can't find a second classname (in 9.6)
5036 // Also, make sure that getElementsByClassName actually exists
5037 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
5041 // Safari caches class attributes, doesn't catch changes (in 3.2)
5042 div.lastChild.className = "e";
5044 if ( div.getElementsByClassName("e").length === 1 ) {
5048 Expr.order.splice(1, 0, "CLASS");
5049 Expr.find.CLASS = function( match, context, isXML ) {
5050 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
5051 return context.getElementsByClassName(match[1]);
5055 // release memory in IE
5059 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5060 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5061 var elem = checkSet[i];
5069 if ( elem.sizcache === doneName ) {
5070 match = checkSet[elem.sizset];
5074 if ( elem.nodeType === 1 && !isXML ){
5075 elem.sizcache = doneName;
5079 if ( elem.nodeName.toLowerCase() === cur ) {
5087 checkSet[i] = match;
5092 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
5093 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
5094 var elem = checkSet[i];
5102 if ( elem.sizcache === doneName ) {
5103 match = checkSet[elem.sizset];
5107 if ( elem.nodeType === 1 ) {
5109 elem.sizcache = doneName;
5113 if ( typeof cur !== "string" ) {
5114 if ( elem === cur ) {
5119 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
5128 checkSet[i] = match;
5133 if ( document.documentElement.contains ) {
5134 Sizzle.contains = function( a, b ) {
5135 return a !== b && (a.contains ? a.contains(b) : true);
5138 } else if ( document.documentElement.compareDocumentPosition ) {
5139 Sizzle.contains = function( a, b ) {
5140 return !!(a.compareDocumentPosition(b) & 16);
5144 Sizzle.contains = function() {
5149 Sizzle.isXML = function( elem ) {
5150 // documentElement is verified for cases where it doesn't yet exist
5151 // (such as loading iframes in IE - #4833)
5152 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
5154 return documentElement ? documentElement.nodeName !== "HTML" : false;
5157 var posProcess = function( selector, context ) {
5161 root = context.nodeType ? [context] : context;
5163 // Position selectors must be done after the filter
5164 // And so must :not(positional) so we move all PSEUDOs to the end
5165 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
5167 selector = selector.replace( Expr.match.PSEUDO, "" );
5170 selector = Expr.relative[selector] ? selector + "*" : selector;
5172 for ( var i = 0, l = root.length; i < l; i++ ) {
5173 Sizzle( selector, root[i], tmpSet );
5176 return Sizzle.filter( later, tmpSet );
5180 jQuery.find = Sizzle;
5181 jQuery.expr = Sizzle.selectors;
5182 jQuery.expr[":"] = jQuery.expr.filters;
5183 jQuery.unique = Sizzle.uniqueSort;
5184 jQuery.text = Sizzle.getText;
5185 jQuery.isXMLDoc = Sizzle.isXML;
5186 jQuery.contains = Sizzle.contains;
5192 var runtil = /Until$/,
5193 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
5194 // Note: This RegExp should be improved, or likely pulled from Sizzle
5195 rmultiselector = /,/,
5196 isSimple = /^.[^:#\[\.,]*$/,
5197 slice = Array.prototype.slice,
5198 POS = jQuery.expr.match.POS,
5199 // methods guaranteed to produce a unique set when starting from a unique set
5200 guaranteedUnique = {
5208 find: function( selector ) {
5212 if ( typeof selector !== "string" ) {
5213 return jQuery( selector ).filter(function() {
5214 for ( i = 0, l = self.length; i < l; i++ ) {
5215 if ( jQuery.contains( self[ i ], this ) ) {
5222 var ret = this.pushStack( "", "find", selector ),
5225 for ( i = 0, l = this.length; i < l; i++ ) {
5226 length = ret.length;
5227 jQuery.find( selector, this[i], ret );
5230 // Make sure that the results are unique
5231 for ( n = length; n < ret.length; n++ ) {
5232 for ( r = 0; r < length; r++ ) {
5233 if ( ret[r] === ret[n] ) {
5245 has: function( target ) {
5246 var targets = jQuery( target );
5247 return this.filter(function() {
5248 for ( var i = 0, l = targets.length; i < l; i++ ) {
5249 if ( jQuery.contains( this, targets[i] ) ) {
5256 not: function( selector ) {
5257 return this.pushStack( winnow(this, selector, false), "not", selector);
5260 filter: function( selector ) {
5261 return this.pushStack( winnow(this, selector, true), "filter", selector );
5264 is: function( selector ) {
5265 return !!selector && ( typeof selector === "string" ?
5266 jQuery.filter( selector, this ).length > 0 :
5267 this.filter( selector ).length > 0 );
5270 closest: function( selectors, context ) {
5271 var ret = [], i, l, cur = this[0];
5274 if ( jQuery.isArray( selectors ) ) {
5275 var match, selector,
5279 if ( cur && selectors.length ) {
5280 for ( i = 0, l = selectors.length; i < l; i++ ) {
5281 selector = selectors[i];
5283 if ( !matches[ selector ] ) {
5284 matches[ selector ] = POS.test( selector ) ?
5285 jQuery( selector, context || this.context ) :
5290 while ( cur && cur.ownerDocument && cur !== context ) {
5291 for ( selector in matches ) {
5292 match = matches[ selector ];
5294 if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
5295 ret.push({ selector: selector, elem: cur, level: level });
5299 cur = cur.parentNode;
5308 var pos = POS.test( selectors ) || typeof selectors !== "string" ?
5309 jQuery( selectors, context || this.context ) :
5312 for ( i = 0, l = this.length; i < l; i++ ) {
5316 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5321 cur = cur.parentNode;
5322 if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
5329 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5331 return this.pushStack( ret, "closest", selectors );
5334 // Determine the position of an element within
5335 // the matched set of elements
5336 index: function( elem ) {
5338 // No argument, return index in parent
5340 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5343 // index in selector
5344 if ( typeof elem === "string" ) {
5345 return jQuery.inArray( this[0], jQuery( elem ) );
5348 // Locate the position of the desired element
5349 return jQuery.inArray(
5350 // If it receives a jQuery object, the first element is used
5351 elem.jquery ? elem[0] : elem, this );
5354 add: function( selector, context ) {
5355 var set = typeof selector === "string" ?
5356 jQuery( selector, context ) :
5357 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5358 all = jQuery.merge( this.get(), set );
5360 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5362 jQuery.unique( all ) );
5365 andSelf: function() {
5366 return this.add( this.prevObject );
5370 // A painfully simple check to see if an element is disconnected
5371 // from a document (should be improved, where feasible).
5372 function isDisconnected( node ) {
5373 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5377 parent: function( elem ) {
5378 var parent = elem.parentNode;
5379 return parent && parent.nodeType !== 11 ? parent : null;
5381 parents: function( elem ) {
5382 return jQuery.dir( elem, "parentNode" );
5384 parentsUntil: function( elem, i, until ) {
5385 return jQuery.dir( elem, "parentNode", until );
5387 next: function( elem ) {
5388 return jQuery.nth( elem, 2, "nextSibling" );
5390 prev: function( elem ) {
5391 return jQuery.nth( elem, 2, "previousSibling" );
5393 nextAll: function( elem ) {
5394 return jQuery.dir( elem, "nextSibling" );
5396 prevAll: function( elem ) {
5397 return jQuery.dir( elem, "previousSibling" );
5399 nextUntil: function( elem, i, until ) {
5400 return jQuery.dir( elem, "nextSibling", until );
5402 prevUntil: function( elem, i, until ) {
5403 return jQuery.dir( elem, "previousSibling", until );
5405 siblings: function( elem ) {
5406 return jQuery.sibling( elem.parentNode.firstChild, elem );
5408 children: function( elem ) {
5409 return jQuery.sibling( elem.firstChild );
5411 contents: function( elem ) {
5412 return jQuery.nodeName( elem, "iframe" ) ?
5413 elem.contentDocument || elem.contentWindow.document :
5414 jQuery.makeArray( elem.childNodes );
5416 }, function( name, fn ) {
5417 jQuery.fn[ name ] = function( until, selector ) {
5418 var ret = jQuery.map( this, fn, until ),
5419 // The variable 'args' was introduced in
5420 // https://github.com/jquery/jquery/commit/52a0238
5421 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
5422 // http://code.google.com/p/v8/issues/detail?id=1050
5423 args = slice.call(arguments);
5425 if ( !runtil.test( name ) ) {
5429 if ( selector && typeof selector === "string" ) {
5430 ret = jQuery.filter( selector, ret );
5433 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5435 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
5436 ret = ret.reverse();
5439 return this.pushStack( ret, name, args.join(",") );
5444 filter: function( expr, elems, not ) {
5446 expr = ":not(" + expr + ")";
5449 return elems.length === 1 ?
5450 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5451 jQuery.find.matches(expr, elems);
5454 dir: function( elem, dir, until ) {
5458 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5459 if ( cur.nodeType === 1 ) {
5460 matched.push( cur );
5467 nth: function( cur, result, dir, elem ) {
5468 result = result || 1;
5471 for ( ; cur; cur = cur[dir] ) {
5472 if ( cur.nodeType === 1 && ++num === result ) {
5480 sibling: function( n, elem ) {
5483 for ( ; n; n = n.nextSibling ) {
5484 if ( n.nodeType === 1 && n !== elem ) {
5493 // Implement the identical functionality for filter and not
5494 function winnow( elements, qualifier, keep ) {
5496 // Can't pass null or undefined to indexOf in Firefox 4
5497 // Set to 0 to skip string check
5498 qualifier = qualifier || 0;
5500 if ( jQuery.isFunction( qualifier ) ) {
5501 return jQuery.grep(elements, function( elem, i ) {
5502 var retVal = !!qualifier.call( elem, i, elem );
5503 return retVal === keep;
5506 } else if ( qualifier.nodeType ) {
5507 return jQuery.grep(elements, function( elem, i ) {
5508 return (elem === qualifier) === keep;
5511 } else if ( typeof qualifier === "string" ) {
5512 var filtered = jQuery.grep(elements, function( elem ) {
5513 return elem.nodeType === 1;
5516 if ( isSimple.test( qualifier ) ) {
5517 return jQuery.filter(qualifier, filtered, !keep);
5519 qualifier = jQuery.filter( qualifier, filtered );
5523 return jQuery.grep(elements, function( elem, i ) {
5524 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
5531 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
5532 rleadingWhitespace = /^\s+/,
5533 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
5534 rtagName = /<([\w:]+)/,
5536 rhtml = /<|&#?\w+;/,
5537 rnocache = /<(?:script|object|embed|option|style)/i,
5538 // checked="checked" or checked
5539 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5540 rscriptType = /\/(java|ecma)script/i,
5541 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
5543 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5544 legend: [ 1, "<fieldset>", "</fieldset>" ],
5545 thead: [ 1, "<table>", "</table>" ],
5546 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5547 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5548 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5549 area: [ 1, "<map>", "</map>" ],
5550 _default: [ 0, "", "" ]
5553 wrapMap.optgroup = wrapMap.option;
5554 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5555 wrapMap.th = wrapMap.td;
5557 // IE can't serialize <link> and <script> tags normally
5558 if ( !jQuery.support.htmlSerialize ) {
5559 wrapMap._default = [ 1, "div<div>", "</div>" ];
5563 text: function( text ) {
5564 if ( jQuery.isFunction(text) ) {
5565 return this.each(function(i) {
5566 var self = jQuery( this );
5568 self.text( text.call(this, i, self.text()) );
5572 if ( typeof text !== "object" && text !== undefined ) {
5573 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
5576 return jQuery.text( this );
5579 wrapAll: function( html ) {
5580 if ( jQuery.isFunction( html ) ) {
5581 return this.each(function(i) {
5582 jQuery(this).wrapAll( html.call(this, i) );
5587 // The elements to wrap the target around
5588 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5590 if ( this[0].parentNode ) {
5591 wrap.insertBefore( this[0] );
5594 wrap.map(function() {
5597 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5598 elem = elem.firstChild;
5608 wrapInner: function( html ) {
5609 if ( jQuery.isFunction( html ) ) {
5610 return this.each(function(i) {
5611 jQuery(this).wrapInner( html.call(this, i) );
5615 return this.each(function() {
5616 var self = jQuery( this ),
5617 contents = self.contents();
5619 if ( contents.length ) {
5620 contents.wrapAll( html );
5623 self.append( html );
5628 wrap: function( html ) {
5629 return this.each(function() {
5630 jQuery( this ).wrapAll( html );
5634 unwrap: function() {
5635 return this.parent().each(function() {
5636 if ( !jQuery.nodeName( this, "body" ) ) {
5637 jQuery( this ).replaceWith( this.childNodes );
5642 append: function() {
5643 return this.domManip(arguments, true, function( elem ) {
5644 if ( this.nodeType === 1 ) {
5645 this.appendChild( elem );
5650 prepend: function() {
5651 return this.domManip(arguments, true, function( elem ) {
5652 if ( this.nodeType === 1 ) {
5653 this.insertBefore( elem, this.firstChild );
5658 before: function() {
5659 if ( this[0] && this[0].parentNode ) {
5660 return this.domManip(arguments, false, function( elem ) {
5661 this.parentNode.insertBefore( elem, this );
5663 } else if ( arguments.length ) {
5664 var set = jQuery(arguments[0]);
5665 set.push.apply( set, this.toArray() );
5666 return this.pushStack( set, "before", arguments );
5671 if ( this[0] && this[0].parentNode ) {
5672 return this.domManip(arguments, false, function( elem ) {
5673 this.parentNode.insertBefore( elem, this.nextSibling );
5675 } else if ( arguments.length ) {
5676 var set = this.pushStack( this, "after", arguments );
5677 set.push.apply( set, jQuery(arguments[0]).toArray() );
5682 // keepData is for internal use only--do not document
5683 remove: function( selector, keepData ) {
5684 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5685 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5686 if ( !keepData && elem.nodeType === 1 ) {
5687 jQuery.cleanData( elem.getElementsByTagName("*") );
5688 jQuery.cleanData( [ elem ] );
5691 if ( elem.parentNode ) {
5692 elem.parentNode.removeChild( elem );
5701 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
5702 // Remove element nodes and prevent memory leaks
5703 if ( elem.nodeType === 1 ) {
5704 jQuery.cleanData( elem.getElementsByTagName("*") );
5707 // Remove any remaining nodes
5708 while ( elem.firstChild ) {
5709 elem.removeChild( elem.firstChild );
5716 clone: function( dataAndEvents, deepDataAndEvents ) {
5717 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5718 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5720 return this.map( function () {
5721 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5725 html: function( value ) {
5726 if ( value === undefined ) {
5727 return this[0] && this[0].nodeType === 1 ?
5728 this[0].innerHTML.replace(rinlinejQuery, "") :
5731 // See if we can take a shortcut and just use innerHTML
5732 } else if ( typeof value === "string" && !rnocache.test( value ) &&
5733 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
5734 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
5736 value = value.replace(rxhtmlTag, "<$1></$2>");
5739 for ( var i = 0, l = this.length; i < l; i++ ) {
5740 // Remove element nodes and prevent memory leaks
5741 if ( this[i].nodeType === 1 ) {
5742 jQuery.cleanData( this[i].getElementsByTagName("*") );
5743 this[i].innerHTML = value;
5747 // If using innerHTML throws an exception, use the fallback method
5749 this.empty().append( value );
5752 } else if ( jQuery.isFunction( value ) ) {
5753 this.each(function(i){
5754 var self = jQuery( this );
5756 self.html( value.call(this, i, self.html()) );
5760 this.empty().append( value );
5766 replaceWith: function( value ) {
5767 if ( this[0] && this[0].parentNode ) {
5768 // Make sure that the elements are removed from the DOM before they are inserted
5769 // this can help fix replacing a parent with child elements
5770 if ( jQuery.isFunction( value ) ) {
5771 return this.each(function(i) {
5772 var self = jQuery(this), old = self.html();
5773 self.replaceWith( value.call( this, i, old ) );
5777 if ( typeof value !== "string" ) {
5778 value = jQuery( value ).detach();
5781 return this.each(function() {
5782 var next = this.nextSibling,
5783 parent = this.parentNode;
5785 jQuery( this ).remove();
5788 jQuery(next).before( value );
5790 jQuery(parent).append( value );
5794 return this.length ?
5795 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5800 detach: function( selector ) {
5801 return this.remove( selector, true );
5804 domManip: function( args, table, callback ) {
5805 var results, first, fragment, parent,
5809 // We can't cloneNode fragments that contain checked, in WebKit
5810 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
5811 return this.each(function() {
5812 jQuery(this).domManip( args, table, callback, true );
5816 if ( jQuery.isFunction(value) ) {
5817 return this.each(function(i) {
5818 var self = jQuery(this);
5819 args[0] = value.call(this, i, table ? self.html() : undefined);
5820 self.domManip( args, table, callback );
5825 parent = value && value.parentNode;
5827 // If we're in a fragment, just use that instead of building a new one
5828 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
5829 results = { fragment: parent };
5832 results = jQuery.buildFragment( args, this, scripts );
5835 fragment = results.fragment;
5837 if ( fragment.childNodes.length === 1 ) {
5838 first = fragment = fragment.firstChild;
5840 first = fragment.firstChild;
5844 table = table && jQuery.nodeName( first, "tr" );
5846 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
5849 root(this[i], first) :
5851 // Make sure that we do not leak memory by inadvertently discarding
5852 // the original fragment (which might have attached data) instead of
5853 // using it; in addition, use the original fragment object for the last
5854 // item instead of first because it can end up being emptied incorrectly
5855 // in certain situations (Bug #8070).
5856 // Fragments from the fragment cache must always be cloned and never used
5858 results.cacheable || (l > 1 && i < lastIndex) ?
5859 jQuery.clone( fragment, true, true ) :
5865 if ( scripts.length ) {
5866 jQuery.each( scripts, evalScript );
5874 function root( elem, cur ) {
5875 return jQuery.nodeName(elem, "table") ?
5876 (elem.getElementsByTagName("tbody")[0] ||
5877 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
5881 function cloneCopyEvent( src, dest ) {
5883 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5887 var internalKey = jQuery.expando,
5888 oldData = jQuery.data( src ),
5889 curData = jQuery.data( dest, oldData );
5891 // Switch to use the internal data object, if it exists, for the next
5892 // stage of data copying
5893 if ( (oldData = oldData[ internalKey ]) ) {
5894 var events = oldData.events;
5895 curData = curData[ internalKey ] = jQuery.extend({}, oldData);
5898 delete curData.handle;
5899 curData.events = {};
5901 for ( var type in events ) {
5902 for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
5903 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
5910 function cloneFixAttributes( src, dest ) {
5913 // We do not need to do anything for non-Elements
5914 if ( dest.nodeType !== 1 ) {
5918 // clearAttributes removes the attributes, which we don't want,
5919 // but also removes the attachEvent events, which we *do* want
5920 if ( dest.clearAttributes ) {
5921 dest.clearAttributes();
5924 // mergeAttributes, in contrast, only merges back on the
5925 // original attributes, not the events
5926 if ( dest.mergeAttributes ) {
5927 dest.mergeAttributes( src );
5930 nodeName = dest.nodeName.toLowerCase();
5932 // IE6-8 fail to clone children inside object elements that use
5933 // the proprietary classid attribute value (rather than the type
5934 // attribute) to identify the type of content to display
5935 if ( nodeName === "object" ) {
5936 dest.outerHTML = src.outerHTML;
5938 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
5939 // IE6-8 fails to persist the checked state of a cloned checkbox
5940 // or radio button. Worse, IE6-7 fail to give the cloned element
5941 // a checked appearance if the defaultChecked value isn't also set
5942 if ( src.checked ) {
5943 dest.defaultChecked = dest.checked = src.checked;
5946 // IE6-7 get confused and end up setting the value of a cloned
5947 // checkbox/radio button to an empty string instead of "on"
5948 if ( dest.value !== src.value ) {
5949 dest.value = src.value;
5952 // IE6-8 fails to return the selected option to the default selected
5953 // state when cloning options
5954 } else if ( nodeName === "option" ) {
5955 dest.selected = src.defaultSelected;
5957 // IE6-8 fails to set the defaultValue to the correct value when
5958 // cloning other types of input fields
5959 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5960 dest.defaultValue = src.defaultValue;
5963 // Event data gets referenced instead of copied if the expando
5965 dest.removeAttribute( jQuery.expando );
5968 jQuery.buildFragment = function( args, nodes, scripts ) {
5969 var fragment, cacheable, cacheresults, doc;
5971 // nodes may contain either an explicit document object,
5972 // a jQuery collection or context object.
5973 // If nodes[0] contains a valid object to assign to doc
5974 if ( nodes && nodes[0] ) {
5975 doc = nodes[0].ownerDocument || nodes[0];
5978 // Ensure that an attr object doesn't incorrectly stand in as a document object
5979 // Chrome and Firefox seem to allow this to occur and will throw exception
5981 if ( !doc.createDocumentFragment ) {
5985 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
5986 // Cloning options loses the selected state, so don't cache them
5987 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
5988 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
5989 if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
5990 args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
5994 cacheresults = jQuery.fragments[ args[0] ];
5995 if ( cacheresults && cacheresults !== 1 ) {
5996 fragment = cacheresults;
6001 fragment = doc.createDocumentFragment();
6002 jQuery.clean( args, doc, fragment, scripts );
6006 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
6009 return { fragment: fragment, cacheable: cacheable };
6012 jQuery.fragments = {};
6016 prependTo: "prepend",
6017 insertBefore: "before",
6018 insertAfter: "after",
6019 replaceAll: "replaceWith"
6020 }, function( name, original ) {
6021 jQuery.fn[ name ] = function( selector ) {
6023 insert = jQuery( selector ),
6024 parent = this.length === 1 && this[0].parentNode;
6026 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
6027 insert[ original ]( this[0] );
6031 for ( var i = 0, l = insert.length; i < l; i++ ) {
6032 var elems = (i > 0 ? this.clone(true) : this).get();
6033 jQuery( insert[i] )[ original ]( elems );
6034 ret = ret.concat( elems );
6037 return this.pushStack( ret, name, insert.selector );
6042 function getAll( elem ) {
6043 if ( "getElementsByTagName" in elem ) {
6044 return elem.getElementsByTagName( "*" );
6046 } else if ( "querySelectorAll" in elem ) {
6047 return elem.querySelectorAll( "*" );
6054 // Used in clean, fixes the defaultChecked property
6055 function fixDefaultChecked( elem ) {
6056 if ( elem.type === "checkbox" || elem.type === "radio" ) {
6057 elem.defaultChecked = elem.checked;
6060 // Finds all inputs and passes them to fixDefaultChecked
6061 function findInputs( elem ) {
6062 if ( jQuery.nodeName( elem, "input" ) ) {
6063 fixDefaultChecked( elem );
6064 } else if ( "getElementsByTagName" in elem ) {
6065 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6070 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6071 var clone = elem.cloneNode(true),
6076 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6077 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6078 // IE copies events bound via attachEvent when using cloneNode.
6079 // Calling detachEvent on the clone will also remove the events
6080 // from the original. In order to get around this, we use some
6081 // proprietary methods to clear the events. Thanks to MooTools
6082 // guys for this hotness.
6084 cloneFixAttributes( elem, clone );
6086 // Using Sizzle here is crazy slow, so we use getElementsByTagName
6088 srcElements = getAll( elem );
6089 destElements = getAll( clone );
6091 // Weird iteration because IE will replace the length property
6092 // with an element if you are cloning the body and one of the
6093 // elements on the page has a name or id of "length"
6094 for ( i = 0; srcElements[i]; ++i ) {
6095 // Ensure that the destination node is not null; Fixes #9587
6096 if ( destElements[i] ) {
6097 cloneFixAttributes( srcElements[i], destElements[i] );
6102 // Copy the events from the original to the clone
6103 if ( dataAndEvents ) {
6104 cloneCopyEvent( elem, clone );
6106 if ( deepDataAndEvents ) {
6107 srcElements = getAll( elem );
6108 destElements = getAll( clone );
6110 for ( i = 0; srcElements[i]; ++i ) {
6111 cloneCopyEvent( srcElements[i], destElements[i] );
6116 srcElements = destElements = null;
6118 // Return the cloned set
6122 clean: function( elems, context, fragment, scripts ) {
6123 var checkScriptType;
6125 context = context || document;
6127 // !context.createElement fails in IE with an error but returns typeof 'object'
6128 if ( typeof context.createElement === "undefined" ) {
6129 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
6134 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6135 if ( typeof elem === "number" ) {
6143 // Convert html string into DOM nodes
6144 if ( typeof elem === "string" ) {
6145 if ( !rhtml.test( elem ) ) {
6146 elem = context.createTextNode( elem );
6148 // Fix "XHTML"-style tags in all browsers
6149 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6151 // Trim whitespace, otherwise indexOf won't work as expected
6152 var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
6153 wrap = wrapMap[ tag ] || wrapMap._default,
6155 div = context.createElement("div");
6157 // Go to html and back, then peel off extra wrappers
6158 div.innerHTML = wrap[1] + elem + wrap[2];
6160 // Move to the right depth
6162 div = div.lastChild;
6165 // Remove IE's autoinserted <tbody> from table fragments
6166 if ( !jQuery.support.tbody ) {
6168 // String was a <table>, *may* have spurious <tbody>
6169 var hasBody = rtbody.test(elem),
6170 tbody = tag === "table" && !hasBody ?
6171 div.firstChild && div.firstChild.childNodes :
6173 // String was a bare <thead> or <tfoot>
6174 wrap[1] === "<table>" && !hasBody ?
6178 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6179 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6180 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6185 // IE completely kills leading whitespace when innerHTML is used
6186 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6187 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6190 elem = div.childNodes;
6194 // Resets defaultChecked for any radios and checkboxes
6195 // about to be appended to the DOM in IE 6/7 (#8060)
6197 if ( !jQuery.support.appendChecked ) {
6198 if ( elem[0] && typeof (len = elem.length) === "number" ) {
6199 for ( j = 0; j < len; j++ ) {
6200 findInputs( elem[j] );
6207 if ( elem.nodeType ) {
6210 ret = jQuery.merge( ret, elem );
6215 checkScriptType = function( elem ) {
6216 return !elem.type || rscriptType.test( elem.type );
6218 for ( i = 0; ret[i]; i++ ) {
6219 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
6220 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
6223 if ( ret[i].nodeType === 1 ) {
6224 var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
6226 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6228 fragment.appendChild( ret[i] );
6236 cleanData: function( elems ) {
6237 var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
6238 deleteExpando = jQuery.support.deleteExpando;
6240 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
6241 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
6245 id = elem[ jQuery.expando ];
6248 data = cache[ id ] && cache[ id ][ internalKey ];
6250 if ( data && data.events ) {
6251 for ( var type in data.events ) {
6252 if ( special[ type ] ) {
6253 jQuery.event.remove( elem, type );
6255 // This is a shortcut to avoid jQuery.event.remove's overhead
6257 jQuery.removeEvent( elem, type, data.handle );
6261 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
6262 if ( data.handle ) {
6263 data.handle.elem = null;
6267 if ( deleteExpando ) {
6268 delete elem[ jQuery.expando ];
6270 } else if ( elem.removeAttribute ) {
6271 elem.removeAttribute( jQuery.expando );
6280 function evalScript( i, elem ) {
6288 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
6291 if ( elem.parentNode ) {
6292 elem.parentNode.removeChild( elem );
6299 var ralpha = /alpha\([^)]*\)/i,
6300 ropacity = /opacity=([^)]*)/,
6301 // fixed for IE9, see #8346
6302 rupper = /([A-Z]|^ms)/g,
6303 rnumpx = /^-?\d+(?:px)?$/i,
6305 rrelNum = /^([\-+])=([\-+.\de]+)/,
6307 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6308 cssWidth = [ "Left", "Right" ],
6309 cssHeight = [ "Top", "Bottom" ],
6315 jQuery.fn.css = function( name, value ) {
6316 // Setting 'undefined' is a no-op
6317 if ( arguments.length === 2 && value === undefined ) {
6321 return jQuery.access( this, name, value, true, function( elem, name, value ) {
6322 return value !== undefined ?
6323 jQuery.style( elem, name, value ) :
6324 jQuery.css( elem, name );
6329 // Add in style property hooks for overriding the default
6330 // behavior of getting and setting a style property
6333 get: function( elem, computed ) {
6335 // We should always get a number back from opacity
6336 var ret = curCSS( elem, "opacity", "opacity" );
6337 return ret === "" ? "1" : ret;
6340 return elem.style.opacity;
6346 // Exclude the following css properties to add px
6348 "fillOpacity": true,
6358 // Add in properties whose names you wish to fix before
6359 // setting or getting the value
6361 // normalize float css property
6362 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6365 // Get and set the style property on a DOM Node
6366 style: function( elem, name, value, extra ) {
6367 // Don't set styles on text and comment nodes
6368 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6372 // Make sure that we're working with the right name
6373 var ret, type, origName = jQuery.camelCase( name ),
6374 style = elem.style, hooks = jQuery.cssHooks[ origName ];
6376 name = jQuery.cssProps[ origName ] || origName;
6378 // Check if we're setting a value
6379 if ( value !== undefined ) {
6380 type = typeof value;
6382 // convert relative number strings (+= or -=) to relative numbers. #7345
6383 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6384 value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
6389 // Make sure that NaN and null values aren't set. See: #7116
6390 if ( value == null || type === "number" && isNaN( value ) ) {
6394 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6395 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6399 // If a hook was provided, use that value, otherwise just set the specified value
6400 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
6401 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6404 style[ name ] = value;
6409 // If a hook was provided get the non-computed value from there
6410 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6414 // Otherwise just get the value from the style object
6415 return style[ name ];
6419 css: function( elem, name, extra ) {
6422 // Make sure that we're working with the right name
6423 name = jQuery.camelCase( name );
6424 hooks = jQuery.cssHooks[ name ];
6425 name = jQuery.cssProps[ name ] || name;
6427 // cssFloat needs a special treatment
6428 if ( name === "cssFloat" ) {
6432 // If a hook was provided get the computed value from there
6433 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
6436 // Otherwise, if a way to get the computed value exists, use that
6437 } else if ( curCSS ) {
6438 return curCSS( elem, name );
6442 // A method for quickly swapping in/out CSS properties to get correct calculations
6443 swap: function( elem, options, callback ) {
6446 // Remember the old values, and insert the new ones
6447 for ( var name in options ) {
6448 old[ name ] = elem.style[ name ];
6449 elem.style[ name ] = options[ name ];
6452 callback.call( elem );
6454 // Revert the old values
6455 for ( name in options ) {
6456 elem.style[ name ] = old[ name ];
6461 // DEPRECATED, Use jQuery.css() instead
6462 jQuery.curCSS = jQuery.css;
6464 jQuery.each(["height", "width"], function( i, name ) {
6465 jQuery.cssHooks[ name ] = {
6466 get: function( elem, computed, extra ) {
6470 if ( elem.offsetWidth !== 0 ) {
6471 return getWH( elem, name, extra );
6473 jQuery.swap( elem, cssShow, function() {
6474 val = getWH( elem, name, extra );
6482 set: function( elem, value ) {
6483 if ( rnumpx.test( value ) ) {
6484 // ignore negative width and height values #1599
6485 value = parseFloat( value );
6488 return value + "px";
6498 if ( !jQuery.support.opacity ) {
6499 jQuery.cssHooks.opacity = {
6500 get: function( elem, computed ) {
6501 // IE uses filters for opacity
6502 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6503 ( parseFloat( RegExp.$1 ) / 100 ) + "" :
6504 computed ? "1" : "";
6507 set: function( elem, value ) {
6508 var style = elem.style,
6509 currentStyle = elem.currentStyle,
6510 opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
6511 filter = currentStyle && currentStyle.filter || style.filter || "";
6513 // IE has trouble with opacity if it does not have layout
6514 // Force it by setting the zoom level
6517 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6518 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
6520 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6521 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6522 // style.removeAttribute is IE Only, but so apparently is this code path...
6523 style.removeAttribute( "filter" );
6525 // if there there is no filter style applied in a css rule, we are done
6526 if ( currentStyle && !currentStyle.filter ) {
6531 // otherwise, set new filter values
6532 style.filter = ralpha.test( filter ) ?
6533 filter.replace( ralpha, opacity ) :
6534 filter + " " + opacity;
6540 // This hook cannot be added until DOM ready because the support test
6541 // for it is not run until after DOM ready
6542 if ( !jQuery.support.reliableMarginRight ) {
6543 jQuery.cssHooks.marginRight = {
6544 get: function( elem, computed ) {
6545 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6546 // Work around by temporarily setting element display to inline-block
6548 jQuery.swap( elem, { "display": "inline-block" }, function() {
6550 ret = curCSS( elem, "margin-right", "marginRight" );
6552 ret = elem.style.marginRight;
6561 if ( document.defaultView && document.defaultView.getComputedStyle ) {
6562 getComputedStyle = function( elem, name ) {
6563 var ret, defaultView, computedStyle;
6565 name = name.replace( rupper, "-$1" ).toLowerCase();
6567 if ( !(defaultView = elem.ownerDocument.defaultView) ) {
6571 if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
6572 ret = computedStyle.getPropertyValue( name );
6573 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6574 ret = jQuery.style( elem, name );
6582 if ( document.documentElement.currentStyle ) {
6583 currentStyle = function( elem, name ) {
6585 ret = elem.currentStyle && elem.currentStyle[ name ],
6586 rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
6589 // From the awesome hack by Dean Edwards
6590 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6592 // If we're not dealing with a regular pixel number
6593 // but a number that has a weird ending, we need to convert it to pixels
6594 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
6595 // Remember the original values
6598 // Put in the new values to get a computed value out
6600 elem.runtimeStyle.left = elem.currentStyle.left;
6602 style.left = name === "fontSize" ? "1em" : (ret || 0);
6603 ret = style.pixelLeft + "px";
6605 // Revert the changed values
6608 elem.runtimeStyle.left = rsLeft;
6612 return ret === "" ? "auto" : ret;
6616 curCSS = getComputedStyle || currentStyle;
6618 function getWH( elem, name, extra ) {
6620 // Start with offset property
6621 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6622 which = name === "width" ? cssWidth : cssHeight;
6625 if ( extra !== "border" ) {
6626 jQuery.each( which, function() {
6628 val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
6630 if ( extra === "margin" ) {
6631 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
6633 val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
6641 // Fall back to computed then uncomputed css if necessary
6642 val = curCSS( elem, name, name );
6643 if ( val < 0 || val == null ) {
6644 val = elem.style[ name ] || 0;
6646 // Normalize "", auto, and prepare for extra
6647 val = parseFloat( val ) || 0;
6649 // Add padding, border, margin
6651 jQuery.each( which, function() {
6652 val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
6653 if ( extra !== "padding" ) {
6654 val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
6656 if ( extra === "margin" ) {
6657 val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
6665 if ( jQuery.expr && jQuery.expr.filters ) {
6666 jQuery.expr.filters.hidden = function( elem ) {
6667 var width = elem.offsetWidth,
6668 height = elem.offsetHeight;
6670 return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
6673 jQuery.expr.filters.visible = function( elem ) {
6674 return !jQuery.expr.filters.hidden( elem );
6685 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
6686 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6687 // #7653, #8125, #8152: local protocol detection
6688 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
6689 rnoContent = /^(?:GET|HEAD)$/,
6690 rprotocol = /^\/\//,
6692 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
6693 rselectTextarea = /^(?:select|textarea)/i,
6694 rspacesAjax = /\s+/,
6695 rts = /([?&])_=[^&]*/,
6696 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
6698 // Keep a copy of the old load method
6699 _load = jQuery.fn.load,
6702 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
6703 * 2) These are called:
6704 * - BEFORE asking for a transport
6705 * - AFTER param serialization (s.data is a string if s.processData is true)
6706 * 3) key is the dataType
6707 * 4) the catchall symbol "*" can be used
6708 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
6712 /* Transports bindings
6713 * 1) key is the dataType
6714 * 2) the catchall symbol "*" can be used
6715 * 3) selection will start with transport dataType and THEN go to "*" if needed
6719 // Document location
6722 // Document location segments
6725 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
6726 allTypes = ["*/"] + ["*"];
6728 // #8138, IE may throw an exception when accessing
6729 // a field from window.location if document.domain has been set
6731 ajaxLocation = location.href;
6733 // Use the href attribute of an A element
6734 // since IE will modify it given document.location
6735 ajaxLocation = document.createElement( "a" );
6736 ajaxLocation.href = "";
6737 ajaxLocation = ajaxLocation.href;
6740 // Segment location into parts
6741 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
6743 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
6744 function addToPrefiltersOrTransports( structure ) {
6746 // dataTypeExpression is optional and defaults to "*"
6747 return function( dataTypeExpression, func ) {
6749 if ( typeof dataTypeExpression !== "string" ) {
6750 func = dataTypeExpression;
6751 dataTypeExpression = "*";
6754 if ( jQuery.isFunction( func ) ) {
6755 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
6757 length = dataTypes.length,
6762 // For each dataType in the dataTypeExpression
6763 for(; i < length; i++ ) {
6764 dataType = dataTypes[ i ];
6765 // We control if we're asked to add before
6766 // any existing element
6767 placeBefore = /^\+/.test( dataType );
6768 if ( placeBefore ) {
6769 dataType = dataType.substr( 1 ) || "*";
6771 list = structure[ dataType ] = structure[ dataType ] || [];
6772 // then we add to the structure accordingly
6773 list[ placeBefore ? "unshift" : "push" ]( func );
6779 // Base inspection function for prefilters and transports
6780 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
6781 dataType /* internal */, inspected /* internal */ ) {
6783 dataType = dataType || options.dataTypes[ 0 ];
6784 inspected = inspected || {};
6786 inspected[ dataType ] = true;
6788 var list = structure[ dataType ],
6790 length = list ? list.length : 0,
6791 executeOnly = ( structure === prefilters ),
6794 for(; i < length && ( executeOnly || !selection ); i++ ) {
6795 selection = list[ i ]( options, originalOptions, jqXHR );
6796 // If we got redirected to another dataType
6797 // we try there if executing only and not done already
6798 if ( typeof selection === "string" ) {
6799 if ( !executeOnly || inspected[ selection ] ) {
6800 selection = undefined;
6802 options.dataTypes.unshift( selection );
6803 selection = inspectPrefiltersOrTransports(
6804 structure, options, originalOptions, jqXHR, selection, inspected );
6808 // If we're only executing or nothing was selected
6809 // we try the catchall dataType if not done already
6810 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
6811 selection = inspectPrefiltersOrTransports(
6812 structure, options, originalOptions, jqXHR, "*", inspected );
6814 // unnecessary when only executing (prefilters)
6815 // but it'll be ignored by the caller in that case
6819 // A special extend for ajax options
6820 // that takes "flat" options (not to be deep extended)
6822 function ajaxExtend( target, src ) {
6824 flatOptions = jQuery.ajaxSettings.flatOptions || {};
6826 if ( src[ key ] !== undefined ) {
6827 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
6831 jQuery.extend( true, target, deep );
6836 load: function( url, params, callback ) {
6837 if ( typeof url !== "string" && _load ) {
6838 return _load.apply( this, arguments );
6840 // Don't do a request if no elements are being requested
6841 } else if ( !this.length ) {
6845 var off = url.indexOf( " " );
6847 var selector = url.slice( off, url.length );
6848 url = url.slice( 0, off );
6851 // Default to a GET request
6854 // If the second parameter was provided
6856 // If it's a function
6857 if ( jQuery.isFunction( params ) ) {
6858 // We assume that it's the callback
6862 // Otherwise, build a param string
6863 } else if ( typeof params === "object" ) {
6864 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
6871 // Request the remote document
6877 // Complete callback (responseText is used internally)
6878 complete: function( jqXHR, status, responseText ) {
6879 // Store the response as specified by the jqXHR object
6880 responseText = jqXHR.responseText;
6881 // If successful, inject the HTML into all the matched elements
6882 if ( jqXHR.isResolved() ) {
6883 // #4825: Get the actual response in case
6884 // a dataFilter is present in ajaxSettings
6885 jqXHR.done(function( r ) {
6888 // See if a selector was specified
6889 self.html( selector ?
6890 // Create a dummy div to hold the results
6892 // inject the contents of the document in, removing the scripts
6893 // to avoid any 'Permission Denied' errors in IE
6894 .append(responseText.replace(rscript, ""))
6896 // Locate the specified elements
6899 // If not, just inject the full result
6904 self.each( callback, [ responseText, status, jqXHR ] );
6912 serialize: function() {
6913 return jQuery.param( this.serializeArray() );
6916 serializeArray: function() {
6917 return this.map(function(){
6918 return this.elements ? jQuery.makeArray( this.elements ) : this;
6921 return this.name && !this.disabled &&
6922 ( this.checked || rselectTextarea.test( this.nodeName ) ||
6923 rinput.test( this.type ) );
6925 .map(function( i, elem ){
6926 var val = jQuery( this ).val();
6928 return val == null ?
6930 jQuery.isArray( val ) ?
6931 jQuery.map( val, function( val, i ){
6932 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6934 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6939 // Attach a bunch of functions for handling common AJAX events
6940 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
6941 jQuery.fn[ o ] = function( f ){
6942 return this.bind( o, f );
6946 jQuery.each( [ "get", "post" ], function( i, method ) {
6947 jQuery[ method ] = function( url, data, callback, type ) {
6948 // shift arguments if data argument was omitted
6949 if ( jQuery.isFunction( data ) ) {
6950 type = type || callback;
6955 return jQuery.ajax({
6967 getScript: function( url, callback ) {
6968 return jQuery.get( url, undefined, callback, "script" );
6971 getJSON: function( url, data, callback ) {
6972 return jQuery.get( url, data, callback, "json" );
6975 // Creates a full fledged settings object into target
6976 // with both ajaxSettings and settings fields.
6977 // If target is omitted, writes into ajaxSettings.
6978 ajaxSetup: function( target, settings ) {
6980 // Building a settings object
6981 ajaxExtend( target, jQuery.ajaxSettings );
6983 // Extending ajaxSettings
6985 target = jQuery.ajaxSettings;
6987 ajaxExtend( target, settings );
6993 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
6996 contentType: "application/x-www-form-urlencoded",
7011 xml: "application/xml, text/xml",
7014 json: "application/json, text/javascript",
7026 text: "responseText"
7029 // List of data converters
7030 // 1) key format is "source_type destination_type" (a single space in-between)
7031 // 2) the catchall symbol "*" can be used for source_type
7034 // Convert anything to text
7035 "* text": window.String,
7037 // Text to html (true = no transformation)
7040 // Evaluate text as a json expression
7041 "text json": jQuery.parseJSON,
7043 // Parse text as xml
7044 "text xml": jQuery.parseXML
7047 // For options that shouldn't be deep extended:
7048 // you can add your own custom options here if
7049 // and when you create one that shouldn't be
7050 // deep extended (see ajaxExtend)
7057 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7058 ajaxTransport: addToPrefiltersOrTransports( transports ),
7061 ajax: function( url, options ) {
7063 // If url is an object, simulate pre-1.5 signature
7064 if ( typeof url === "object" ) {
7069 // Force options to be an object
7070 options = options || {};
7072 var // Create the final options object
7073 s = jQuery.ajaxSetup( {}, options ),
7074 // Callbacks context
7075 callbackContext = s.context || s,
7076 // Context for global events
7077 // It's the callbackContext if one was provided in the options
7078 // and if it's a DOM node or a jQuery collection
7079 globalEventContext = callbackContext !== s &&
7080 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7081 jQuery( callbackContext ) : jQuery.event,
7083 deferred = jQuery.Deferred(),
7084 completeDeferred = jQuery._Deferred(),
7085 // Status-dependent callbacks
7086 statusCode = s.statusCode || {},
7089 // Headers (they are sent all at once)
7090 requestHeaders = {},
7091 requestHeadersNames = {},
7093 responseHeadersString,
7099 // Cross-domain detection vars
7103 // To know if global events are to be dispatched
7112 // Caches the header
7113 setRequestHeader: function( name, value ) {
7115 var lname = name.toLowerCase();
7116 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7117 requestHeaders[ name ] = value;
7123 getAllResponseHeaders: function() {
7124 return state === 2 ? responseHeadersString : null;
7127 // Builds headers hashtable if needed
7128 getResponseHeader: function( key ) {
7130 if ( state === 2 ) {
7131 if ( !responseHeaders ) {
7132 responseHeaders = {};
7133 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7134 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7137 match = responseHeaders[ key.toLowerCase() ];
7139 return match === undefined ? null : match;
7142 // Overrides response content-type header
7143 overrideMimeType: function( type ) {
7150 // Cancel the request
7151 abort: function( statusText ) {
7152 statusText = statusText || "abort";
7154 transport.abort( statusText );
7156 done( 0, statusText );
7161 // Callback for when everything is done
7162 // It is defined here because jslint complains if it is declared
7163 // at the end of the function (which would be more logical and readable)
7164 function done( status, nativeStatusText, responses, headers ) {
7167 if ( state === 2 ) {
7171 // State is "done" now
7174 // Clear timeout if it exists
7175 if ( timeoutTimer ) {
7176 clearTimeout( timeoutTimer );
7179 // Dereference transport for early garbage collection
7180 // (no matter how long the jqXHR object will be used)
7181 transport = undefined;
7183 // Cache response headers
7184 responseHeadersString = headers || "";
7187 jqXHR.readyState = status > 0 ? 4 : 0;
7192 statusText = nativeStatusText,
7193 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
7197 // If successful, handle type chaining
7198 if ( status >= 200 && status < 300 || status === 304 ) {
7200 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7201 if ( s.ifModified ) {
7203 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
7204 jQuery.lastModified[ ifModifiedKey ] = lastModified;
7206 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
7207 jQuery.etag[ ifModifiedKey ] = etag;
7212 if ( status === 304 ) {
7214 statusText = "notmodified";
7221 success = ajaxConvert( s, response );
7222 statusText = "success";
7225 // We have a parsererror
7226 statusText = "parsererror";
7231 // We extract error from statusText
7232 // then normalize statusText and status for non-aborts
7234 if( !statusText || status ) {
7235 statusText = "error";
7242 // Set data for the fake xhr object
7243 jqXHR.status = status;
7244 jqXHR.statusText = "" + ( nativeStatusText || statusText );
7248 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7250 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7253 // Status-dependent callbacks
7254 jqXHR.statusCode( statusCode );
7255 statusCode = undefined;
7257 if ( fireGlobals ) {
7258 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7259 [ jqXHR, s, isSuccess ? success : error ] );
7263 completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
7265 if ( fireGlobals ) {
7266 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7267 // Handle the global AJAX counter
7268 if ( !( --jQuery.active ) ) {
7269 jQuery.event.trigger( "ajaxStop" );
7275 deferred.promise( jqXHR );
7276 jqXHR.success = jqXHR.done;
7277 jqXHR.error = jqXHR.fail;
7278 jqXHR.complete = completeDeferred.done;
7280 // Status-dependent callbacks
7281 jqXHR.statusCode = function( map ) {
7286 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7289 tmp = map[ jqXHR.status ];
7290 jqXHR.then( tmp, tmp );
7296 // Remove hash character (#7531: and string promotion)
7297 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7298 // We also use the url parameter if available
7299 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7301 // Extract dataTypes list
7302 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
7304 // Determine if a cross-domain request is in order
7305 if ( s.crossDomain == null ) {
7306 parts = rurl.exec( s.url.toLowerCase() );
7307 s.crossDomain = !!( parts &&
7308 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7309 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7310 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7314 // Convert data if not already a string
7315 if ( s.data && s.processData && typeof s.data !== "string" ) {
7316 s.data = jQuery.param( s.data, s.traditional );
7320 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7322 // If request was aborted inside a prefiler, stop there
7323 if ( state === 2 ) {
7327 // We can fire global events as of now if asked to
7328 fireGlobals = s.global;
7330 // Uppercase the type
7331 s.type = s.type.toUpperCase();
7333 // Determine if request has content
7334 s.hasContent = !rnoContent.test( s.type );
7336 // Watch for a new set of requests
7337 if ( fireGlobals && jQuery.active++ === 0 ) {
7338 jQuery.event.trigger( "ajaxStart" );
7341 // More options handling for requests with no content
7342 if ( !s.hasContent ) {
7344 // If data is available, append data to url
7346 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7347 // #9682: remove data so that it's not used in an eventual retry
7351 // Get ifModifiedKey before adding the anti-cache parameter
7352 ifModifiedKey = s.url;
7354 // Add anti-cache in url if needed
7355 if ( s.cache === false ) {
7357 var ts = jQuery.now(),
7358 // try replacing _= if it is there
7359 ret = s.url.replace( rts, "$1_=" + ts );
7361 // if nothing was replaced, add timestamp to the end
7362 s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7366 // Set the correct header, if data is being sent
7367 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7368 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7371 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7372 if ( s.ifModified ) {
7373 ifModifiedKey = ifModifiedKey || s.url;
7374 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7375 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7377 if ( jQuery.etag[ ifModifiedKey ] ) {
7378 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7382 // Set the Accepts header for the server, depending on the dataType
7383 jqXHR.setRequestHeader(
7385 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7386 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7390 // Check for headers option
7391 for ( i in s.headers ) {
7392 jqXHR.setRequestHeader( i, s.headers[ i ] );
7395 // Allow custom headers/mimetypes and early abort
7396 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7397 // Abort if not done already
7403 // Install callbacks on deferreds
7404 for ( i in { success: 1, error: 1, complete: 1 } ) {
7405 jqXHR[ i ]( s[ i ] );
7409 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7411 // If no transport, we auto-abort
7413 done( -1, "No Transport" );
7415 jqXHR.readyState = 1;
7416 // Send global event
7417 if ( fireGlobals ) {
7418 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7421 if ( s.async && s.timeout > 0 ) {
7422 timeoutTimer = setTimeout( function(){
7423 jqXHR.abort( "timeout" );
7429 transport.send( requestHeaders, done );
7431 // Propagate exception as error if not done
7434 // Simply rethrow otherwise
7444 // Serialize an array of form elements or a set of
7445 // key/values into a query string
7446 param: function( a, traditional ) {
7448 add = function( key, value ) {
7449 // If value is a function, invoke it and return its value
7450 value = jQuery.isFunction( value ) ? value() : value;
7451 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7454 // Set traditional to true for jQuery <= 1.3.2 behavior.
7455 if ( traditional === undefined ) {
7456 traditional = jQuery.ajaxSettings.traditional;
7459 // If an array was passed in, assume that it is an array of form elements.
7460 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7461 // Serialize the form elements
7462 jQuery.each( a, function() {
7463 add( this.name, this.value );
7467 // If traditional, encode the "old" way (the way 1.3.2 or older
7468 // did it), otherwise encode params recursively.
7469 for ( var prefix in a ) {
7470 buildParams( prefix, a[ prefix ], traditional, add );
7474 // Return the resulting serialization
7475 return s.join( "&" ).replace( r20, "+" );
7479 function buildParams( prefix, obj, traditional, add ) {
7480 if ( jQuery.isArray( obj ) ) {
7481 // Serialize array item.
7482 jQuery.each( obj, function( i, v ) {
7483 if ( traditional || rbracket.test( prefix ) ) {
7484 // Treat each array item as a scalar.
7488 // If array item is non-scalar (array or object), encode its
7489 // numeric index to resolve deserialization ambiguity issues.
7490 // Note that rack (as of 1.0.0) can't currently deserialize
7491 // nested arrays properly, and attempting to do so may cause
7492 // a server error. Possible fixes are to modify rack's
7493 // deserialization algorithm or to provide an option or flag
7494 // to force array serialization to be shallow.
7495 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
7499 } else if ( !traditional && obj != null && typeof obj === "object" ) {
7500 // Serialize object item.
7501 for ( var name in obj ) {
7502 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7506 // Serialize scalar item.
7511 // This is still on the jQuery object... for now
7512 // Want to move this to jQuery.ajax some day
7515 // Counter for holding the number of active queries
7518 // Last-Modified header cache for next request
7524 /* Handles responses to an ajax request:
7525 * - sets all responseXXX fields accordingly
7526 * - finds the right dataType (mediates between content-type and expected dataType)
7527 * - returns the corresponding response
7529 function ajaxHandleResponses( s, jqXHR, responses ) {
7531 var contents = s.contents,
7532 dataTypes = s.dataTypes,
7533 responseFields = s.responseFields,
7539 // Fill responseXXX fields
7540 for( type in responseFields ) {
7541 if ( type in responses ) {
7542 jqXHR[ responseFields[type] ] = responses[ type ];
7546 // Remove auto dataType and get content-type in the process
7547 while( dataTypes[ 0 ] === "*" ) {
7549 if ( ct === undefined ) {
7550 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
7554 // Check if we're dealing with a known content-type
7556 for ( type in contents ) {
7557 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7558 dataTypes.unshift( type );
7564 // Check to see if we have a response for the expected dataType
7565 if ( dataTypes[ 0 ] in responses ) {
7566 finalDataType = dataTypes[ 0 ];
7568 // Try convertible dataTypes
7569 for ( type in responses ) {
7570 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7571 finalDataType = type;
7574 if ( !firstDataType ) {
7575 firstDataType = type;
7578 // Or just use first one
7579 finalDataType = finalDataType || firstDataType;
7582 // If we found a dataType
7583 // We add the dataType to the list if needed
7584 // and return the corresponding response
7585 if ( finalDataType ) {
7586 if ( finalDataType !== dataTypes[ 0 ] ) {
7587 dataTypes.unshift( finalDataType );
7589 return responses[ finalDataType ];
7593 // Chain conversions given the request and the original response
7594 function ajaxConvert( s, response ) {
7596 // Apply the dataFilter if provided
7597 if ( s.dataFilter ) {
7598 response = s.dataFilter( response, s.dataType );
7601 var dataTypes = s.dataTypes,
7605 length = dataTypes.length,
7607 // Current and previous dataTypes
7608 current = dataTypes[ 0 ],
7610 // Conversion expression
7612 // Conversion function
7614 // Conversion functions (transitive conversion)
7618 // For each dataType in the chain
7619 for( i = 1; i < length; i++ ) {
7621 // Create converters map
7622 // with lowercased keys
7624 for( key in s.converters ) {
7625 if( typeof key === "string" ) {
7626 converters[ key.toLowerCase() ] = s.converters[ key ];
7631 // Get the dataTypes
7633 current = dataTypes[ i ];
7635 // If current is auto dataType, update it to prev
7636 if( current === "*" ) {
7638 // If no auto and dataTypes are actually different
7639 } else if ( prev !== "*" && prev !== current ) {
7641 // Get the converter
7642 conversion = prev + " " + current;
7643 conv = converters[ conversion ] || converters[ "* " + current ];
7645 // If there is no direct converter, search transitively
7648 for( conv1 in converters ) {
7649 tmp = conv1.split( " " );
7650 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
7651 conv2 = converters[ tmp[1] + " " + current ];
7653 conv1 = converters[ conv1 ];
7654 if ( conv1 === true ) {
7656 } else if ( conv2 === true ) {
7664 // If we found no converter, dispatch an error
7665 if ( !( conv || conv2 ) ) {
7666 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
7668 // If found converter is not an equivalence
7669 if ( conv !== true ) {
7670 // Convert with 1 or 2 converters accordingly
7671 response = conv ? conv( response ) : conv2( conv1(response) );
7681 var jsc = jQuery.now(),
7682 jsre = /(\=)\?(&|$)|\?\?/i;
7684 // Default jsonp settings
7687 jsonpCallback: function() {
7688 return jQuery.expando + "_" + ( jsc++ );
7692 // Detect, normalize options and install callbacks for jsonp requests
7693 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
7695 var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
7696 ( typeof s.data === "string" );
7698 if ( s.dataTypes[ 0 ] === "jsonp" ||
7699 s.jsonp !== false && ( jsre.test( s.url ) ||
7700 inspectData && jsre.test( s.data ) ) ) {
7702 var responseContainer,
7703 jsonpCallback = s.jsonpCallback =
7704 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
7705 previous = window[ jsonpCallback ],
7708 replace = "$1" + jsonpCallback + "$2";
7710 if ( s.jsonp !== false ) {
7711 url = url.replace( jsre, replace );
7712 if ( s.url === url ) {
7713 if ( inspectData ) {
7714 data = data.replace( jsre, replace );
7716 if ( s.data === data ) {
7717 // Add callback manually
7718 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
7727 window[ jsonpCallback ] = function( response ) {
7728 responseContainer = [ response ];
7731 // Clean-up function
7732 jqXHR.always(function() {
7733 // Set callback back to previous value
7734 window[ jsonpCallback ] = previous;
7735 // Call if it was a function and we have a response
7736 if ( responseContainer && jQuery.isFunction( previous ) ) {
7737 window[ jsonpCallback ]( responseContainer[ 0 ] );
7741 // Use data converter to retrieve json after script execution
7742 s.converters["script json"] = function() {
7743 if ( !responseContainer ) {
7744 jQuery.error( jsonpCallback + " was not called" );
7746 return responseContainer[ 0 ];
7749 // force json dataType
7750 s.dataTypes[ 0 ] = "json";
7752 // Delegate to script
7760 // Install script dataType
7763 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
7766 script: /javascript|ecmascript/
7769 "text script": function( text ) {
7770 jQuery.globalEval( text );
7776 // Handle cache's special case and global
7777 jQuery.ajaxPrefilter( "script", function( s ) {
7778 if ( s.cache === undefined ) {
7781 if ( s.crossDomain ) {
7787 // Bind script tag hack transport
7788 jQuery.ajaxTransport( "script", function(s) {
7790 // This transport only deals with cross domain requests
7791 if ( s.crossDomain ) {
7794 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
7798 send: function( _, callback ) {
7800 script = document.createElement( "script" );
7802 script.async = "async";
7804 if ( s.scriptCharset ) {
7805 script.charset = s.scriptCharset;
7810 // Attach handlers for all browsers
7811 script.onload = script.onreadystatechange = function( _, isAbort ) {
7813 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
7815 // Handle memory leak in IE
7816 script.onload = script.onreadystatechange = null;
7818 // Remove the script
7819 if ( head && script.parentNode ) {
7820 head.removeChild( script );
7823 // Dereference the script
7826 // Callback if not abort
7828 callback( 200, "success" );
7832 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
7833 // This arises when a base node is used (#2709 and #4378).
7834 head.insertBefore( script, head.firstChild );
7839 script.onload( 0, 1 );
7849 var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
7850 xhrOnUnloadAbort = window.ActiveXObject ? function() {
7851 // Abort all pending requests
7852 for ( var key in xhrCallbacks ) {
7853 xhrCallbacks[ key ]( 0, 1 );
7859 // Functions to create xhrs
7860 function createStandardXHR() {
7862 return new window.XMLHttpRequest();
7866 function createActiveXHR() {
7868 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
7872 // Create the request object
7873 // (This is still attached to ajaxSettings for backward compatibility)
7874 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
7875 /* Microsoft failed to properly
7876 * implement the XMLHttpRequest in IE7 (can't request local files),
7877 * so we use the ActiveXObject when it is available
7878 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
7879 * we need a fallback.
7882 return !this.isLocal && createStandardXHR() || createActiveXHR();
7884 // For all other browsers, use the standard XMLHttpRequest object
7887 // Determine support properties
7889 jQuery.extend( jQuery.support, {
7891 cors: !!xhr && ( "withCredentials" in xhr )
7893 })( jQuery.ajaxSettings.xhr() );
7895 // Create transport if the browser can provide an xhr
7896 if ( jQuery.support.ajax ) {
7898 jQuery.ajaxTransport(function( s ) {
7899 // Cross domain only allowed if supported through XMLHttpRequest
7900 if ( !s.crossDomain || jQuery.support.cors ) {
7905 send: function( headers, complete ) {
7913 // Passing null username, generates a login popup on Opera (#2865)
7915 xhr.open( s.type, s.url, s.async, s.username, s.password );
7917 xhr.open( s.type, s.url, s.async );
7920 // Apply custom fields if provided
7921 if ( s.xhrFields ) {
7922 for ( i in s.xhrFields ) {
7923 xhr[ i ] = s.xhrFields[ i ];
7927 // Override mime type if needed
7928 if ( s.mimeType && xhr.overrideMimeType ) {
7929 xhr.overrideMimeType( s.mimeType );
7932 // X-Requested-With header
7933 // For cross-domain requests, seeing as conditions for a preflight are
7934 // akin to a jigsaw puzzle, we simply never set it to be sure.
7935 // (it can always be set on a per-request basis or even using ajaxSetup)
7936 // For same-domain requests, won't change header if already provided.
7937 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
7938 headers[ "X-Requested-With" ] = "XMLHttpRequest";
7941 // Need an extra try/catch for cross domain requests in Firefox 3
7943 for ( i in headers ) {
7944 xhr.setRequestHeader( i, headers[ i ] );
7948 // Do send the request
7949 // This may raise an exception which is actually
7950 // handled in jQuery.ajax (so no try/catch here)
7951 xhr.send( ( s.hasContent && s.data ) || null );
7954 callback = function( _, isAbort ) {
7962 // Firefox throws exceptions when accessing properties
7963 // of an xhr when a network error occured
7964 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
7967 // Was never called and is aborted or complete
7968 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
7971 callback = undefined;
7973 // Do not keep as active anymore
7975 xhr.onreadystatechange = jQuery.noop;
7976 if ( xhrOnUnloadAbort ) {
7977 delete xhrCallbacks[ handle ];
7983 // Abort it manually if needed
7984 if ( xhr.readyState !== 4 ) {
7988 status = xhr.status;
7989 responseHeaders = xhr.getAllResponseHeaders();
7991 xml = xhr.responseXML;
7993 // Construct response list
7994 if ( xml && xml.documentElement /* #4958 */ ) {
7995 responses.xml = xml;
7997 responses.text = xhr.responseText;
7999 // Firefox throws an exception when accessing
8000 // statusText for faulty cross-domain requests
8002 statusText = xhr.statusText;
8004 // We normalize with Webkit giving an empty statusText
8008 // Filter status for non standard behaviors
8010 // If the request is local and we have data: assume a success
8011 // (success with no data won't get notified, that's the best we
8012 // can do given current implementations)
8013 if ( !status && s.isLocal && !s.crossDomain ) {
8014 status = responses.text ? 200 : 404;
8015 // IE - #1450: sometimes returns 1223 when it should be 204
8016 } else if ( status === 1223 ) {
8021 } catch( firefoxAccessException ) {
8023 complete( -1, firefoxAccessException );
8027 // Call complete if needed
8029 complete( status, statusText, responses, responseHeaders );
8033 // if we're in sync mode or it's in cache
8034 // and has been retrieved directly (IE6 & IE7)
8035 // we need to manually fire the callback
8036 if ( !s.async || xhr.readyState === 4 ) {
8040 if ( xhrOnUnloadAbort ) {
8041 // Create the active xhrs callbacks list if needed
8042 // and attach the unload handler
8043 if ( !xhrCallbacks ) {
8045 jQuery( window ).unload( xhrOnUnloadAbort );
8047 // Add to list of active xhrs callbacks
8048 xhrCallbacks[ handle ] = callback;
8050 xhr.onreadystatechange = callback;
8067 var elemdisplay = {},
8069 rfxtypes = /^(?:toggle|show|hide)$/,
8070 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
8073 // height animations
8074 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
8076 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
8077 // opacity animations
8083 show: function( speed, easing, callback ) {
8086 if ( speed || speed === 0 ) {
8087 return this.animate( genFx("show", 3), speed, easing, callback);
8090 for ( var i = 0, j = this.length; i < j; i++ ) {
8094 display = elem.style.display;
8096 // Reset the inline display of this element to learn if it is
8097 // being hidden by cascaded rules or not
8098 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
8099 display = elem.style.display = "";
8102 // Set elements which have been overridden with display: none
8103 // in a stylesheet to whatever the default browser style is
8104 // for such an element
8105 if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
8106 jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
8111 // Set the display of most of the elements in a second loop
8112 // to avoid the constant reflow
8113 for ( i = 0; i < j; i++ ) {
8117 display = elem.style.display;
8119 if ( display === "" || display === "none" ) {
8120 elem.style.display = jQuery._data(elem, "olddisplay") || "";
8129 hide: function( speed, easing, callback ) {
8130 if ( speed || speed === 0 ) {
8131 return this.animate( genFx("hide", 3), speed, easing, callback);
8134 for ( var i = 0, j = this.length; i < j; i++ ) {
8135 if ( this[i].style ) {
8136 var display = jQuery.css( this[i], "display" );
8138 if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
8139 jQuery._data( this[i], "olddisplay", display );
8144 // Set the display of the elements in a second loop
8145 // to avoid the constant reflow
8146 for ( i = 0; i < j; i++ ) {
8147 if ( this[i].style ) {
8148 this[i].style.display = "none";
8156 // Save the old toggle function
8157 _toggle: jQuery.fn.toggle,
8159 toggle: function( fn, fn2, callback ) {
8160 var bool = typeof fn === "boolean";
8162 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
8163 this._toggle.apply( this, arguments );
8165 } else if ( fn == null || bool ) {
8166 this.each(function() {
8167 var state = bool ? fn : jQuery(this).is(":hidden");
8168 jQuery(this)[ state ? "show" : "hide" ]();
8172 this.animate(genFx("toggle", 3), fn, fn2, callback);
8178 fadeTo: function( speed, to, easing, callback ) {
8179 return this.filter(":hidden").css("opacity", 0).show().end()
8180 .animate({opacity: to}, speed, easing, callback);
8183 animate: function( prop, speed, easing, callback ) {
8184 var optall = jQuery.speed(speed, easing, callback);
8186 if ( jQuery.isEmptyObject( prop ) ) {
8187 return this.each( optall.complete, [ false ] );
8190 // Do not change referenced properties as per-property easing will be lost
8191 prop = jQuery.extend( {}, prop );
8193 return this[ optall.queue === false ? "each" : "queue" ](function() {
8194 // XXX 'this' does not always have a nodeName when running the
8197 if ( optall.queue === false ) {
8198 jQuery._mark( this );
8201 var opt = jQuery.extend( {}, optall ),
8202 isElement = this.nodeType === 1,
8203 hidden = isElement && jQuery(this).is(":hidden"),
8206 parts, start, end, unit;
8208 // will store per property easing and be used to determine when an animation is complete
8209 opt.animatedProperties = {};
8213 // property name normalization
8214 name = jQuery.camelCase( p );
8216 prop[ name ] = prop[ p ];
8222 // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
8223 if ( jQuery.isArray( val ) ) {
8224 opt.animatedProperties[ name ] = val[ 1 ];
8225 val = prop[ name ] = val[ 0 ];
8227 opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
8230 if ( val === "hide" && hidden || val === "show" && !hidden ) {
8231 return opt.complete.call( this );
8234 if ( isElement && ( name === "height" || name === "width" ) ) {
8235 // Make sure that nothing sneaks out
8236 // Record all 3 overflow attributes because IE does not
8237 // change the overflow attribute when overflowX and
8238 // overflowY are set to the same value
8239 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
8241 // Set display property to inline-block for height/width
8242 // animations on inline elements that are having width/height
8244 if ( jQuery.css( this, "display" ) === "inline" &&
8245 jQuery.css( this, "float" ) === "none" ) {
8246 if ( !jQuery.support.inlineBlockNeedsLayout ) {
8247 this.style.display = "inline-block";
8250 display = defaultDisplay( this.nodeName );
8252 // inline-level elements accept inline-block;
8253 // block-level elements need to be inline with layout
8254 if ( display === "inline" ) {
8255 this.style.display = "inline-block";
8258 this.style.display = "inline";
8259 this.style.zoom = 1;
8266 if ( opt.overflow != null ) {
8267 this.style.overflow = "hidden";
8271 e = new jQuery.fx( this, opt, p );
8274 if ( rfxtypes.test(val) ) {
8275 e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
8278 parts = rfxnum.exec( val );
8282 end = parseFloat( parts[2] );
8283 unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
8285 // We need to compute starting value
8286 if ( unit !== "px" ) {
8287 jQuery.style( this, p, (end || 1) + unit);
8288 start = ((end || 1) / e.cur()) * start;
8289 jQuery.style( this, p, start + unit);
8292 // If a +=/-= token was provided, we're doing a relative animation
8294 end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
8297 e.custom( start, end, unit );
8300 e.custom( start, val, "" );
8305 // For JS strict compliance
8310 stop: function( clearQueue, gotoEnd ) {
8315 this.each(function() {
8316 var timers = jQuery.timers,
8318 // clear marker counters if we know they won't be
8320 jQuery._unmark( true, this );
8323 if ( timers[i].elem === this ) {
8325 // force the next step to be the last
8329 timers.splice(i, 1);
8334 // start the next in the queue if the last step wasn't forced
8344 // Animations created synchronously will run synchronously
8345 function createFxNow() {
8346 setTimeout( clearFxNow, 0 );
8347 return ( fxNow = jQuery.now() );
8350 function clearFxNow() {
8354 // Generate parameters to create a standard animation
8355 function genFx( type, num ) {
8358 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
8365 // Generate shortcuts for custom animations
8367 slideDown: genFx("show", 1),
8368 slideUp: genFx("hide", 1),
8369 slideToggle: genFx("toggle", 1),
8370 fadeIn: { opacity: "show" },
8371 fadeOut: { opacity: "hide" },
8372 fadeToggle: { opacity: "toggle" }
8373 }, function( name, props ) {
8374 jQuery.fn[ name ] = function( speed, easing, callback ) {
8375 return this.animate( props, speed, easing, callback );
8380 speed: function( speed, easing, fn ) {
8381 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
8382 complete: fn || !fn && easing ||
8383 jQuery.isFunction( speed ) && speed,
8385 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
8388 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8389 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
8392 opt.old = opt.complete;
8393 opt.complete = function( noUnmark ) {
8394 if ( jQuery.isFunction( opt.old ) ) {
8395 opt.old.call( this );
8398 if ( opt.queue !== false ) {
8399 jQuery.dequeue( this );
8400 } else if ( noUnmark !== false ) {
8401 jQuery._unmark( this );
8409 linear: function( p, n, firstNum, diff ) {
8410 return firstNum + diff * p;
8412 swing: function( p, n, firstNum, diff ) {
8413 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
8419 fx: function( elem, options, prop ) {
8420 this.options = options;
8424 options.orig = options.orig || {};
8429 jQuery.fx.prototype = {
8430 // Simple function for setting a style value
8431 update: function() {
8432 if ( this.options.step ) {
8433 this.options.step.call( this.elem, this.now, this );
8436 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
8439 // Get the current size
8441 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
8442 return this.elem[ this.prop ];
8446 r = jQuery.css( this.elem, this.prop );
8447 // Empty strings, null, undefined and "auto" are converted to 0,
8448 // complex values such as "rotate(1rad)" are returned as is,
8449 // simple values such as "10px" are parsed to Float.
8450 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
8453 // Start an animation from one number to another
8454 custom: function( from, to, unit ) {
8458 this.startTime = fxNow || createFxNow();
8461 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
8462 this.now = this.start;
8463 this.pos = this.state = 0;
8465 function t( gotoEnd ) {
8466 return self.step(gotoEnd);
8471 if ( t() && jQuery.timers.push(t) && !timerId ) {
8472 timerId = setInterval( fx.tick, fx.interval );
8476 // Simple 'show' function
8478 // Remember where we started, so that we can go back to it later
8479 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8480 this.options.show = true;
8482 // Begin the animation
8483 // Make sure that we start at a small width/height to avoid any
8485 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
8487 // Start by showing the element
8488 jQuery( this.elem ).show();
8491 // Simple 'hide' function
8493 // Remember where we started, so that we can go back to it later
8494 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
8495 this.options.hide = true;
8497 // Begin the animation
8498 this.custom(this.cur(), 0);
8501 // Each step of an animation
8502 step: function( gotoEnd ) {
8503 var t = fxNow || createFxNow(),
8506 options = this.options,
8509 if ( gotoEnd || t >= options.duration + this.startTime ) {
8510 this.now = this.end;
8511 this.pos = this.state = 1;
8514 options.animatedProperties[ this.prop ] = true;
8516 for ( i in options.animatedProperties ) {
8517 if ( options.animatedProperties[i] !== true ) {
8523 // Reset the overflow
8524 if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
8526 jQuery.each( [ "", "X", "Y" ], function (index, value) {
8527 elem.style[ "overflow" + value ] = options.overflow[index];
8531 // Hide the element if the "hide" operation was done
8532 if ( options.hide ) {
8533 jQuery(elem).hide();
8536 // Reset the properties, if the item has been hidden or shown
8537 if ( options.hide || options.show ) {
8538 for ( var p in options.animatedProperties ) {
8539 jQuery.style( elem, p, options.orig[p] );
8543 // Execute the complete function
8544 options.complete.call( elem );
8550 // classical easing cannot be used with an Infinity duration
8551 if ( options.duration == Infinity ) {
8554 n = t - this.startTime;
8555 this.state = n / options.duration;
8557 // Perform the easing function, defaults to swing
8558 this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
8559 this.now = this.start + ((this.end - this.start) * this.pos);
8561 // Perform the next step of the animation
8569 jQuery.extend( jQuery.fx, {
8571 for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
8572 if ( !timers[i]() ) {
8573 timers.splice(i--, 1);
8577 if ( !timers.length ) {
8585 clearInterval( timerId );
8597 opacity: function( fx ) {
8598 jQuery.style( fx.elem, "opacity", fx.now );
8601 _default: function( fx ) {
8602 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
8603 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
8605 fx.elem[ fx.prop ] = fx.now;
8611 if ( jQuery.expr && jQuery.expr.filters ) {
8612 jQuery.expr.filters.animated = function( elem ) {
8613 return jQuery.grep(jQuery.timers, function( fn ) {
8614 return elem === fn.elem;
8619 // Try to restore the default display value of an element
8620 function defaultDisplay( nodeName ) {
8622 if ( !elemdisplay[ nodeName ] ) {
8624 var body = document.body,
8625 elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
8626 display = elem.css( "display" );
8630 // If the simple way fails,
8631 // get element's real default display by attaching it to a temp iframe
8632 if ( display === "none" || display === "" ) {
8633 // No iframe to use yet, so create it
8635 iframe = document.createElement( "iframe" );
8636 iframe.frameBorder = iframe.width = iframe.height = 0;
8639 body.appendChild( iframe );
8641 // Create a cacheable copy of the iframe document on first call.
8642 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
8643 // document to it; WebKit & Firefox won't allow reusing the iframe document.
8644 if ( !iframeDoc || !iframe.createElement ) {
8645 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
8646 iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
8650 elem = iframeDoc.createElement( nodeName );
8652 iframeDoc.body.appendChild( elem );
8654 display = jQuery.css( elem, "display" );
8656 body.removeChild( iframe );
8659 // Store the correct default display
8660 elemdisplay[ nodeName ] = display;
8663 return elemdisplay[ nodeName ];
8669 var rtable = /^t(?:able|d|h)$/i,
8670 rroot = /^(?:body|html)$/i;
8672 if ( "getBoundingClientRect" in document.documentElement ) {
8673 jQuery.fn.offset = function( options ) {
8674 var elem = this[0], box;
8677 return this.each(function( i ) {
8678 jQuery.offset.setOffset( this, options, i );
8682 if ( !elem || !elem.ownerDocument ) {
8686 if ( elem === elem.ownerDocument.body ) {
8687 return jQuery.offset.bodyOffset( elem );
8691 box = elem.getBoundingClientRect();
8694 var doc = elem.ownerDocument,
8695 docElem = doc.documentElement;
8697 // Make sure we're not dealing with a disconnected DOM node
8698 if ( !box || !jQuery.contains( docElem, elem ) ) {
8699 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
8702 var body = doc.body,
8703 win = getWindow(doc),
8704 clientTop = docElem.clientTop || body.clientTop || 0,
8705 clientLeft = docElem.clientLeft || body.clientLeft || 0,
8706 scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
8707 scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
8708 top = box.top + scrollTop - clientTop,
8709 left = box.left + scrollLeft - clientLeft;
8711 return { top: top, left: left };
8715 jQuery.fn.offset = function( options ) {
8719 return this.each(function( i ) {
8720 jQuery.offset.setOffset( this, options, i );
8724 if ( !elem || !elem.ownerDocument ) {
8728 if ( elem === elem.ownerDocument.body ) {
8729 return jQuery.offset.bodyOffset( elem );
8732 jQuery.offset.initialize();
8735 offsetParent = elem.offsetParent,
8736 prevOffsetParent = elem,
8737 doc = elem.ownerDocument,
8738 docElem = doc.documentElement,
8740 defaultView = doc.defaultView,
8741 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
8742 top = elem.offsetTop,
8743 left = elem.offsetLeft;
8745 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
8746 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
8750 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
8751 top -= elem.scrollTop;
8752 left -= elem.scrollLeft;
8754 if ( elem === offsetParent ) {
8755 top += elem.offsetTop;
8756 left += elem.offsetLeft;
8758 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
8759 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8760 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8763 prevOffsetParent = offsetParent;
8764 offsetParent = elem.offsetParent;
8767 if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
8768 top += parseFloat( computedStyle.borderTopWidth ) || 0;
8769 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
8772 prevComputedStyle = computedStyle;
8775 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
8776 top += body.offsetTop;
8777 left += body.offsetLeft;
8780 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
8781 top += Math.max( docElem.scrollTop, body.scrollTop );
8782 left += Math.max( docElem.scrollLeft, body.scrollLeft );
8785 return { top: top, left: left };
8790 initialize: function() {
8791 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
8792 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>";
8794 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
8796 container.innerHTML = html;
8797 body.insertBefore( container, body.firstChild );
8798 innerDiv = container.firstChild;
8799 checkDiv = innerDiv.firstChild;
8800 td = innerDiv.nextSibling.firstChild.firstChild;
8802 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
8803 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
8805 checkDiv.style.position = "fixed";
8806 checkDiv.style.top = "20px";
8808 // safari subtracts parent border width here which is 5px
8809 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
8810 checkDiv.style.position = checkDiv.style.top = "";
8812 innerDiv.style.overflow = "hidden";
8813 innerDiv.style.position = "relative";
8815 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
8817 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
8819 body.removeChild( container );
8820 jQuery.offset.initialize = jQuery.noop;
8823 bodyOffset: function( body ) {
8824 var top = body.offsetTop,
8825 left = body.offsetLeft;
8827 jQuery.offset.initialize();
8829 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
8830 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
8831 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
8834 return { top: top, left: left };
8837 setOffset: function( elem, options, i ) {
8838 var position = jQuery.css( elem, "position" );
8840 // set position first, in-case top/left are set even on static elem
8841 if ( position === "static" ) {
8842 elem.style.position = "relative";
8845 var curElem = jQuery( elem ),
8846 curOffset = curElem.offset(),
8847 curCSSTop = jQuery.css( elem, "top" ),
8848 curCSSLeft = jQuery.css( elem, "left" ),
8849 calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
8850 props = {}, curPosition = {}, curTop, curLeft;
8852 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
8853 if ( calculatePosition ) {
8854 curPosition = curElem.position();
8855 curTop = curPosition.top;
8856 curLeft = curPosition.left;
8858 curTop = parseFloat( curCSSTop ) || 0;
8859 curLeft = parseFloat( curCSSLeft ) || 0;
8862 if ( jQuery.isFunction( options ) ) {
8863 options = options.call( elem, i, curOffset );
8866 if (options.top != null) {
8867 props.top = (options.top - curOffset.top) + curTop;
8869 if (options.left != null) {
8870 props.left = (options.left - curOffset.left) + curLeft;
8873 if ( "using" in options ) {
8874 options.using.call( elem, props );
8876 curElem.css( props );
8883 position: function() {
8890 // Get *real* offsetParent
8891 offsetParent = this.offsetParent(),
8893 // Get correct offsets
8894 offset = this.offset(),
8895 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
8897 // Subtract element margins
8898 // note: when an element has margin: auto the offsetLeft and marginLeft
8899 // are the same in Safari causing offset.left to incorrectly be 0
8900 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
8901 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
8903 // Add offsetParent borders
8904 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
8905 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
8907 // Subtract the two offsets
8909 top: offset.top - parentOffset.top,
8910 left: offset.left - parentOffset.left
8914 offsetParent: function() {
8915 return this.map(function() {
8916 var offsetParent = this.offsetParent || document.body;
8917 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
8918 offsetParent = offsetParent.offsetParent;
8920 return offsetParent;
8926 // Create scrollLeft and scrollTop methods
8927 jQuery.each( ["Left", "Top"], function( i, name ) {
8928 var method = "scroll" + name;
8930 jQuery.fn[ method ] = function( val ) {
8933 if ( val === undefined ) {
8940 win = getWindow( elem );
8942 // Return the scroll offset
8943 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
8944 jQuery.support.boxModel && win.document.documentElement[ method ] ||
8945 win.document.body[ method ] :
8949 // Set the scroll offset
8950 return this.each(function() {
8951 win = getWindow( this );
8955 !i ? val : jQuery( win ).scrollLeft(),
8956 i ? val : jQuery( win ).scrollTop()
8960 this[ method ] = val;
8966 function getWindow( elem ) {
8967 return jQuery.isWindow( elem ) ?
8969 elem.nodeType === 9 ?
8970 elem.defaultView || elem.parentWindow :
8977 // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
8978 jQuery.each([ "Height", "Width" ], function( i, name ) {
8980 var type = name.toLowerCase();
8982 // innerHeight and innerWidth
8983 jQuery.fn[ "inner" + name ] = function() {
8985 return elem && elem.style ?
8986 parseFloat( jQuery.css( elem, type, "padding" ) ) :
8990 // outerHeight and outerWidth
8991 jQuery.fn[ "outer" + name ] = function( margin ) {
8993 return elem && elem.style ?
8994 parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
8998 jQuery.fn[ type ] = function( size ) {
8999 // Get window width or height
9002 return size == null ? null : this;
9005 if ( jQuery.isFunction( size ) ) {
9006 return this.each(function( i ) {
9007 var self = jQuery( this );
9008 self[ type ]( size.call( this, i, self[ type ]() ) );
9012 if ( jQuery.isWindow( elem ) ) {
9013 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
9014 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
9015 var docElemProp = elem.document.documentElement[ "client" + name ],
9016 body = elem.document.body;
9017 return elem.document.compatMode === "CSS1Compat" && docElemProp ||
9018 body && body[ "client" + name ] || docElemProp;
9020 // Get document width or height
9021 } else if ( elem.nodeType === 9 ) {
9022 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
9024 elem.documentElement["client" + name],
9025 elem.body["scroll" + name], elem.documentElement["scroll" + name],
9026 elem.body["offset" + name], elem.documentElement["offset" + name]
9029 // Get or set width or height on the element
9030 } else if ( size === undefined ) {
9031 var orig = jQuery.css( elem, type ),
9032 ret = parseFloat( orig );
9034 return jQuery.isNaN( ret ) ? orig : ret;
9036 // Set the width or height on the element (default to pixels if value is unitless)
9038 return this.css( type, typeof size === "string" ? size : size + "px" );
9045 // Expose jQuery to the global object
9046 window.jQuery = window.$ = jQuery;