2 * jQuery JavaScript Library v1.8.0
8 * Copyright 2012 jQuery Foundation and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: Thu Aug 09 2012 16:24:48 GMT-0400 (Eastern Daylight Time)
14 (function( window, undefined ) {
16 // A central reference to the root jQuery(document)
19 // The deferred used on DOM ready
22 // Use the correct document accordingly with window argument (sandbox)
23 document = window.document,
24 location = window.location,
25 navigator = window.navigator,
27 // Map over jQuery in case of overwrite
28 _jQuery = window.jQuery,
30 // Map over the $ in case of overwrite
33 // Save a reference to some core methods
34 core_push = Array.prototype.push,
35 core_slice = Array.prototype.slice,
36 core_indexOf = Array.prototype.indexOf,
37 core_toString = Object.prototype.toString,
38 core_hasOwn = Object.prototype.hasOwnProperty,
39 core_trim = String.prototype.trim,
41 // Define a local copy of jQuery
42 jQuery = function( selector, context ) {
43 // The jQuery object is actually just the init constructor 'enhanced'
44 return new jQuery.fn.init( selector, context, rootjQuery );
47 // Used for matching numbers
48 core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
50 // Used for detecting and trimming whitespace
51 core_rnotwhite = /\S/,
54 // IE doesn't match non-breaking spaces with \s
55 rtrim = core_rnotwhite.test("\xA0") ? (/^[\s\xA0]+|[\s\xA0]+$/g) : /^\s+|\s+$/g,
57 // A simple way to check for HTML strings
58 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
59 rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
61 // Match a standalone tag
62 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
65 rvalidchars = /^[\],:{}\s]*$/,
66 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
67 rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
68 rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
70 // Matches dashed string for camelizing
72 rdashAlpha = /-([\da-z])/gi,
74 // Used by jQuery.camelCase as callback to replace()
75 fcamelCase = function( all, letter ) {
76 return ( letter + "" ).toUpperCase();
79 // The ready event handler and self cleanup method
80 DOMContentLoaded = function() {
81 if ( document.addEventListener ) {
82 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
84 } else if ( document.readyState === "complete" ) {
85 // we're here because readyState === "complete" in oldIE
86 // which is good enough for us to call the dom ready!
87 document.detachEvent( "onreadystatechange", DOMContentLoaded );
92 // [[Class]] -> type pairs
95 jQuery.fn = jQuery.prototype = {
97 init: function( selector, context, rootjQuery ) {
98 var match, elem, ret, doc;
100 // Handle $(""), $(null), $(undefined), $(false)
105 // Handle $(DOMElement)
106 if ( selector.nodeType ) {
107 this.context = this[0] = selector;
112 // Handle HTML strings
113 if ( typeof selector === "string" ) {
114 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
115 // Assume that strings that start and end with <> are HTML and skip the regex check
116 match = [ null, selector, null ];
119 match = rquickExpr.exec( selector );
122 // Match html or make sure no context is specified for #id
123 if ( match && (match[1] || !context) ) {
125 // HANDLE: $(html) -> $(array)
127 context = context instanceof jQuery ? context[0] : context;
128 doc = ( context && context.nodeType ? context.ownerDocument || context : document );
130 // scripts is true for back-compat
131 selector = jQuery.parseHTML( match[1], doc, true );
132 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
133 this.attr.call( selector, context, true );
136 return jQuery.merge( this, selector );
140 elem = document.getElementById( match[2] );
142 // Check parentNode to catch when Blackberry 4.6 returns
143 // nodes that are no longer in the document #6963
144 if ( elem && elem.parentNode ) {
145 // Handle the case where IE and Opera return items
146 // by name instead of ID
147 if ( elem.id !== match[2] ) {
148 return rootjQuery.find( selector );
151 // Otherwise, we inject the element directly into the jQuery object
156 this.context = document;
157 this.selector = selector;
161 // HANDLE: $(expr, $(...))
162 } else if ( !context || context.jquery ) {
163 return ( context || rootjQuery ).find( selector );
165 // HANDLE: $(expr, context)
166 // (which is just equivalent to: $(context).find(expr)
168 return this.constructor( context ).find( selector );
171 // HANDLE: $(function)
172 // Shortcut for document ready
173 } else if ( jQuery.isFunction( selector ) ) {
174 return rootjQuery.ready( selector );
177 if ( selector.selector !== undefined ) {
178 this.selector = selector.selector;
179 this.context = selector.context;
182 return jQuery.makeArray( selector, this );
185 // Start with an empty selector
188 // The current version of jQuery being used
191 // The default length of a jQuery object is 0
194 // The number of elements contained in the matched element set
199 toArray: function() {
200 return core_slice.call( this );
203 // Get the Nth element in the matched element set OR
204 // Get the whole matched element set as a clean array
205 get: function( num ) {
208 // Return a 'clean' array
211 // Return just the object
212 ( num < 0 ? this[ this.length + num ] : this[ num ] );
215 // Take an array of elements and push it onto the stack
216 // (returning the new matched element set)
217 pushStack: function( elems, name, selector ) {
219 // Build a new jQuery matched element set
220 var ret = jQuery.merge( this.constructor(), elems );
222 // Add the old object onto the stack (as a reference)
223 ret.prevObject = this;
225 ret.context = this.context;
227 if ( name === "find" ) {
228 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
230 ret.selector = this.selector + "." + name + "(" + selector + ")";
233 // Return the newly-formed element set
237 // Execute a callback for every element in the matched set.
238 // (You can seed the arguments with an array of args, but this is
239 // only used internally.)
240 each: function( callback, args ) {
241 return jQuery.each( this, callback, args );
244 ready: function( fn ) {
246 jQuery.ready.promise().done( fn );
255 this.slice( i, i + 1 );
263 return this.eq( -1 );
267 return this.pushStack( core_slice.apply( this, arguments ),
268 "slice", core_slice.call(arguments).join(",") );
271 map: function( callback ) {
272 return this.pushStack( jQuery.map(this, function( elem, i ) {
273 return callback.call( elem, i, elem );
278 return this.prevObject || this.constructor(null);
281 // For internal use only.
282 // Behaves like an Array's method, not like a jQuery method.
288 // Give the init function the jQuery prototype for later instantiation
289 jQuery.fn.init.prototype = jQuery.fn;
291 jQuery.extend = jQuery.fn.extend = function() {
292 var options, name, src, copy, copyIsArray, clone,
293 target = arguments[0] || {},
295 length = arguments.length,
298 // Handle a deep copy situation
299 if ( typeof target === "boolean" ) {
301 target = arguments[1] || {};
302 // skip the boolean and the target
306 // Handle case when target is a string or something (possible in deep copy)
307 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
311 // extend jQuery itself if only one argument is passed
312 if ( length === i ) {
317 for ( ; i < length; i++ ) {
318 // Only deal with non-null/undefined values
319 if ( (options = arguments[ i ]) != null ) {
320 // Extend the base object
321 for ( name in options ) {
322 src = target[ name ];
323 copy = options[ name ];
325 // Prevent never-ending loop
326 if ( target === copy ) {
330 // Recurse if we're merging plain objects or arrays
331 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
334 clone = src && jQuery.isArray(src) ? src : [];
337 clone = src && jQuery.isPlainObject(src) ? src : {};
340 // Never move original objects, clone them
341 target[ name ] = jQuery.extend( deep, clone, copy );
343 // Don't bring in undefined values
344 } else if ( copy !== undefined ) {
345 target[ name ] = copy;
351 // Return the modified object
356 noConflict: function( deep ) {
357 if ( window.$ === jQuery ) {
361 if ( deep && window.jQuery === jQuery ) {
362 window.jQuery = _jQuery;
368 // Is the DOM ready to be used? Set to true once it occurs.
371 // A counter to track how many items to wait for before
372 // the ready event fires. See #6781
375 // Hold (or release) the ready event
376 holdReady: function( hold ) {
380 jQuery.ready( true );
384 // Handle when the DOM is ready
385 ready: function( wait ) {
387 // Abort if there are pending holds or we're already ready
388 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
392 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
393 if ( !document.body ) {
394 return setTimeout( jQuery.ready, 1 );
397 // Remember that the DOM is ready
398 jQuery.isReady = true;
400 // If a normal DOM Ready event fired, decrement, and wait if need be
401 if ( wait !== true && --jQuery.readyWait > 0 ) {
405 // If there are functions bound, to execute
406 readyList.resolveWith( document, [ jQuery ] );
408 // Trigger any bound ready events
409 if ( jQuery.fn.trigger ) {
410 jQuery( document ).trigger("ready").off("ready");
414 // See test/unit/core.js for details concerning isFunction.
415 // Since version 1.3, DOM methods and functions like alert
416 // aren't supported. They return false on IE (#2968).
417 isFunction: function( obj ) {
418 return jQuery.type(obj) === "function";
421 isArray: Array.isArray || function( obj ) {
422 return jQuery.type(obj) === "array";
425 isWindow: function( obj ) {
426 return obj != null && obj == obj.window;
429 isNumeric: function( obj ) {
430 return !isNaN( parseFloat(obj) ) && isFinite( obj );
433 type: function( obj ) {
436 class2type[ core_toString.call(obj) ] || "object";
439 isPlainObject: function( obj ) {
440 // Must be an Object.
441 // Because of IE, we also have to check the presence of the constructor property.
442 // Make sure that DOM nodes and window objects don't pass through, as well
443 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
448 // Not own constructor property must be Object
449 if ( obj.constructor &&
450 !core_hasOwn.call(obj, "constructor") &&
451 !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
455 // IE8,9 Will throw exceptions on certain host objects #9897
459 // Own properties are enumerated firstly, so to speed up,
460 // if last one is own, then all properties are own.
463 for ( key in obj ) {}
465 return key === undefined || core_hasOwn.call( obj, key );
468 isEmptyObject: function( obj ) {
470 for ( name in obj ) {
476 error: function( msg ) {
477 throw new Error( msg );
480 // data: string of html
481 // context (optional): If specified, the fragment will be created in this context, defaults to document
482 // scripts (optional): If true, will include scripts passed in the html string
483 parseHTML: function( data, context, scripts ) {
485 if ( !data || typeof data !== "string" ) {
488 if ( typeof context === "boolean" ) {
492 context = context || document;
495 if ( (parsed = rsingleTag.exec( data )) ) {
496 return [ context.createElement( parsed[1] ) ];
499 parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
500 return jQuery.merge( [],
501 (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
504 parseJSON: function( data ) {
505 if ( !data || typeof data !== "string") {
509 // Make sure leading/trailing whitespace is removed (IE can't handle it)
510 data = jQuery.trim( data );
512 // Attempt to parse using the native JSON parser first
513 if ( window.JSON && window.JSON.parse ) {
514 return window.JSON.parse( data );
517 // Make sure the incoming data is actual JSON
518 // Logic borrowed from http://json.org/json2.js
519 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
520 .replace( rvalidtokens, "]" )
521 .replace( rvalidbraces, "")) ) {
523 return ( new Function( "return " + data ) )();
526 jQuery.error( "Invalid JSON: " + data );
529 // Cross-browser xml parsing
530 parseXML: function( data ) {
532 if ( !data || typeof data !== "string" ) {
536 if ( window.DOMParser ) { // Standard
537 tmp = new DOMParser();
538 xml = tmp.parseFromString( data , "text/xml" );
540 xml = new ActiveXObject( "Microsoft.XMLDOM" );
547 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
548 jQuery.error( "Invalid XML: " + data );
555 // Evaluates a script in a global context
556 // Workarounds based on findings by Jim Driscoll
557 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
558 globalEval: function( data ) {
559 if ( data && core_rnotwhite.test( data ) ) {
560 // We use execScript on Internet Explorer
561 // We use an anonymous function so that context is window
562 // rather than jQuery in Firefox
563 ( window.execScript || function( data ) {
564 window[ "eval" ].call( window, data );
569 // Convert dashed to camelCase; used by the css and data modules
570 // Microsoft forgot to hump their vendor prefix (#9572)
571 camelCase: function( string ) {
572 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
575 nodeName: function( elem, name ) {
576 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
579 // args is for internal usage only
580 each: function( obj, callback, args ) {
584 isObj = length === undefined || jQuery.isFunction( obj );
588 for ( name in obj ) {
589 if ( callback.apply( obj[ name ], args ) === false ) {
594 for ( ; i < length; ) {
595 if ( callback.apply( obj[ i++ ], args ) === false ) {
601 // A special, fast, case for the most common use of each
604 for ( name in obj ) {
605 if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
610 for ( ; i < length; ) {
611 if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
621 // Use native String.trim function wherever possible
624 return text == null ?
626 core_trim.call( text );
629 // Otherwise use our own trimming functionality
631 return text == null ?
633 text.toString().replace( rtrim, "" );
636 // results is for internal usage only
637 makeArray: function( arr, results ) {
642 // The window, strings (and functions) also have 'length'
643 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
644 type = jQuery.type( arr );
646 if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
647 core_push.call( ret, arr );
649 jQuery.merge( ret, arr );
656 inArray: function( elem, arr, i ) {
660 if ( core_indexOf ) {
661 return core_indexOf.call( arr, elem, i );
665 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
667 for ( ; i < len; i++ ) {
668 // Skip accessing in sparse arrays
669 if ( i in arr && arr[ i ] === elem ) {
678 merge: function( first, second ) {
679 var l = second.length,
683 if ( typeof l === "number" ) {
684 for ( ; j < l; j++ ) {
685 first[ i++ ] = second[ j ];
689 while ( second[j] !== undefined ) {
690 first[ i++ ] = second[ j++ ];
699 grep: function( elems, callback, inv ) {
703 length = elems.length;
706 // Go through the array, only saving the items
707 // that pass the validator function
708 for ( ; i < length; i++ ) {
709 retVal = !!callback( elems[ i ], i );
710 if ( inv !== retVal ) {
711 ret.push( elems[ i ] );
718 // arg is for internal usage only
719 map: function( elems, callback, arg ) {
723 length = elems.length,
724 // jquery objects are treated as arrays
725 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
727 // Go through the array, translating each of the items to their
729 for ( ; i < length; i++ ) {
730 value = callback( elems[ i ], i, arg );
732 if ( value != null ) {
733 ret[ ret.length ] = value;
737 // Go through every key on the object,
739 for ( key in elems ) {
740 value = callback( elems[ key ], key, arg );
742 if ( value != null ) {
743 ret[ ret.length ] = value;
748 // Flatten any nested arrays
749 return ret.concat.apply( [], ret );
752 // A global GUID counter for objects
755 // Bind a function to a context, optionally partially applying any
757 proxy: function( fn, context ) {
758 var tmp, args, proxy;
760 if ( typeof context === "string" ) {
766 // Quick check to determine if target is callable, in the spec
767 // this throws a TypeError, but we will just return undefined.
768 if ( !jQuery.isFunction( fn ) ) {
773 args = core_slice.call( arguments, 2 );
775 return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
778 // Set the guid of unique handler to the same of original handler, so it can be removed
779 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
784 // Multifunctional method to get and set values of a collection
785 // The value/s can optionally be executed if it's a function
786 access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
790 length = elems.length;
793 if ( key && typeof key === "object" ) {
795 jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
800 } else if ( value !== undefined ) {
801 // Optionally, function values get executed if exec is true
802 exec = pass === undefined && jQuery.isFunction( value );
805 // Bulk operations only iterate when executing function values
808 fn = function( elem, key, value ) {
809 return exec.call( jQuery( elem ), value );
812 // Otherwise they run against the entire set
814 fn.call( elems, value );
820 for (; i < length; i++ ) {
821 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
834 length ? fn( elems[0], key ) : emptyGet;
838 return ( new Date() ).getTime();
842 jQuery.ready.promise = function( obj ) {
845 readyList = jQuery.Deferred();
847 // Catch cases where $(document).ready() is called after the
848 // browser event has already occurred.
849 if ( document.readyState === "complete" || ( document.readyState !== "loading" && document.addEventListener ) ) {
850 // Handle it asynchronously to allow scripts the opportunity to delay ready
851 setTimeout( jQuery.ready, 1 );
853 // Standards-based browsers support DOMContentLoaded
854 } else if ( document.addEventListener ) {
855 // Use the handy event callback
856 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
858 // A fallback to window.onload, that will always work
859 window.addEventListener( "load", jQuery.ready, false );
861 // If IE event model is used
863 // Ensure firing before onload, maybe late but safe also for iframes
864 document.attachEvent( "onreadystatechange", DOMContentLoaded );
866 // A fallback to window.onload, that will always work
867 window.attachEvent( "onload", jQuery.ready );
869 // If IE and not a frame
870 // continually check to see if the document is ready
874 top = window.frameElement == null && document.documentElement;
877 if ( top && top.doScroll ) {
878 (function doScrollCheck() {
879 if ( !jQuery.isReady ) {
882 // Use the trick by Diego Perini
883 // http://javascript.nwbox.com/IEContentLoaded/
884 top.doScroll("left");
886 return setTimeout( doScrollCheck, 50 );
889 // and execute any waiting functions
896 return readyList.promise( obj );
899 // Populate the class2type map
900 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
901 class2type[ "[object " + name + "]" ] = name.toLowerCase();
904 // All jQuery objects should point back to these
905 rootjQuery = jQuery(document);
906 // String to Object options format cache
907 var optionsCache = {};
909 // Convert String-formatted options into Object-formatted ones and store in cache
910 function createOptions( options ) {
911 var object = optionsCache[ options ] = {};
912 jQuery.each( options.split( core_rspace ), function( _, flag ) {
913 object[ flag ] = true;
919 * Create a callback list using the following parameters:
921 * options: an optional list of space-separated options that will change how
922 * the callback list behaves or a more traditional option object
924 * By default a callback list will act like an event callback list and can be
925 * "fired" multiple times.
929 * once: will ensure the callback list can only be fired once (like a Deferred)
931 * memory: will keep track of previous values and will call any callback added
932 * after the list has been fired right away with the latest "memorized"
933 * values (like a Deferred)
935 * unique: will ensure a callback can only be added once (no duplicate in the list)
937 * stopOnFalse: interrupt callings when a callback returns false
940 jQuery.Callbacks = function( options ) {
942 // Convert options from String-formatted to Object-formatted if needed
943 // (we check in cache first)
944 options = typeof options === "string" ?
945 ( optionsCache[ options ] || createOptions( options ) ) :
946 jQuery.extend( {}, options );
948 var // Last fire value (for non-forgettable lists)
950 // Flag to know if list was already fired
952 // Flag to know if list is currently firing
954 // First callback to fire (used internally by add and fireWith)
956 // End of the loop when firing
958 // Index of currently firing callback (modified by remove if needed)
960 // Actual callback list
962 // Stack of fire calls for repeatable lists
963 stack = !options.once && [],
965 fire = function( data ) {
966 memory = options.memory && data;
968 firingIndex = firingStart || 0;
970 firingLength = list.length;
972 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
973 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
974 memory = false; // To prevent further calls using add
981 if ( stack.length ) {
982 fire( stack.shift() );
984 } else if ( memory ) {
991 // Actual Callbacks object
993 // Add a callback or a collection of callbacks to the list
996 // First, we save the current length
997 var start = list.length;
998 (function add( args ) {
999 jQuery.each( args, function( _, arg ) {
1000 if ( jQuery.isFunction( arg ) && ( !options.unique || !self.has( arg ) ) ) {
1002 } else if ( arg && arg.length ) {
1003 // Inspect recursively
1008 // Do we need to add the callbacks to the
1009 // current firing batch?
1011 firingLength = list.length;
1012 // With memory, if we're not firing then
1013 // we should call right away
1014 } else if ( memory ) {
1015 firingStart = start;
1021 // Remove a callback from the list
1022 remove: function() {
1024 jQuery.each( arguments, function( _, arg ) {
1026 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1027 list.splice( index, 1 );
1028 // Handle firing indexes
1030 if ( index <= firingLength ) {
1033 if ( index <= firingIndex ) {
1042 // Control if a given callback is in the list
1043 has: function( fn ) {
1044 return jQuery.inArray( fn, list ) > -1;
1046 // Remove all callbacks from the list
1051 // Have the list do nothing anymore
1052 disable: function() {
1053 list = stack = memory = undefined;
1057 disabled: function() {
1060 // Lock the list in its current state
1069 locked: function() {
1072 // Call all callbacks with the given context and arguments
1073 fireWith: function( context, args ) {
1075 args = [ context, args.slice ? args.slice() : args ];
1076 if ( list && ( !fired || stack ) ) {
1085 // Call all the callbacks with the given arguments
1087 self.fireWith( this, arguments );
1090 // To know if the callbacks have already been called at least once
1100 Deferred: function( func ) {
1102 // action, add listener, listener list, final state
1103 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1104 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1105 [ "notify", "progress", jQuery.Callbacks("memory") ]
1112 always: function() {
1113 deferred.done( arguments ).fail( arguments );
1116 then: function( /* fnDone, fnFail, fnProgress */ ) {
1117 var fns = arguments;
1118 return jQuery.Deferred(function( newDefer ) {
1119 jQuery.each( tuples, function( i, tuple ) {
1120 var action = tuple[ 0 ],
1122 // deferred[ done | fail | progress ] for forwarding actions to newDefer
1123 deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
1125 var returned = fn.apply( this, arguments );
1126 if ( returned && jQuery.isFunction( returned.promise ) ) {
1128 .done( newDefer.resolve )
1129 .fail( newDefer.reject )
1130 .progress( newDefer.notify );
1132 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1141 // Get a promise for this deferred
1142 // If obj is provided, the promise aspect is added to the object
1143 promise: function( obj ) {
1144 return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise;
1149 // Keep pipe for back-compat
1150 promise.pipe = promise.then;
1152 // Add list-specific methods
1153 jQuery.each( tuples, function( i, tuple ) {
1154 var list = tuple[ 2 ],
1155 stateString = tuple[ 3 ];
1157 // promise[ done | fail | progress ] = list.add
1158 promise[ tuple[1] ] = list.add;
1161 if ( stateString ) {
1162 list.add(function() {
1163 // state = [ resolved | rejected ]
1164 state = stateString;
1166 // [ reject_list | resolve_list ].disable; progress_list.lock
1167 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1170 // deferred[ resolve | reject | notify ] = list.fire
1171 deferred[ tuple[0] ] = list.fire;
1172 deferred[ tuple[0] + "With" ] = list.fireWith;
1175 // Make the deferred a promise
1176 promise.promise( deferred );
1178 // Call given func if any
1180 func.call( deferred, deferred );
1188 when: function( subordinate /* , ..., subordinateN */ ) {
1190 resolveValues = core_slice.call( arguments ),
1191 length = resolveValues.length,
1193 // the count of uncompleted subordinates
1194 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1196 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1197 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1199 // Update function for both resolve and progress values
1200 updateFunc = function( i, contexts, values ) {
1201 return function( value ) {
1202 contexts[ i ] = this;
1203 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
1204 if( values === progressValues ) {
1205 deferred.notifyWith( contexts, values );
1206 } else if ( !( --remaining ) ) {
1207 deferred.resolveWith( contexts, values );
1212 progressValues, progressContexts, resolveContexts;
1214 // add listeners to Deferred subordinates; treat others as resolved
1216 progressValues = new Array( length );
1217 progressContexts = new Array( length );
1218 resolveContexts = new Array( length );
1219 for ( ; i < length; i++ ) {
1220 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1221 resolveValues[ i ].promise()
1222 .done( updateFunc( i, resolveContexts, resolveValues ) )
1223 .fail( deferred.reject )
1224 .progress( updateFunc( i, progressContexts, progressValues ) );
1231 // if we're not waiting on anything, resolve the master
1233 deferred.resolveWith( resolveContexts, resolveValues );
1236 return deferred.promise();
1239 jQuery.support = (function() {
1252 div = document.createElement("div");
1254 // Preliminary tests
1255 div.setAttribute( "className", "t" );
1256 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1258 all = div.getElementsByTagName("*");
1259 a = div.getElementsByTagName("a")[ 0 ];
1260 a.style.cssText = "top:1px;float:left;opacity:.5";
1262 // Can't get basic test support
1263 if ( !all || !all.length || !a ) {
1267 // First batch of supports tests
1268 select = document.createElement("select");
1269 opt = select.appendChild( document.createElement("option") );
1270 input = div.getElementsByTagName("input")[ 0 ];
1273 // IE strips leading whitespace when .innerHTML is used
1274 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1276 // Make sure that tbody elements aren't automatically inserted
1277 // IE will insert them into empty tables
1278 tbody: !div.getElementsByTagName("tbody").length,
1280 // Make sure that link elements get serialized correctly by innerHTML
1281 // This requires a wrapper element in IE
1282 htmlSerialize: !!div.getElementsByTagName("link").length,
1284 // Get the style information from getAttribute
1285 // (IE uses .cssText instead)
1286 style: /top/.test( a.getAttribute("style") ),
1288 // Make sure that URLs aren't manipulated
1289 // (IE normalizes it by default)
1290 hrefNormalized: ( a.getAttribute("href") === "/a" ),
1292 // Make sure that element opacity exists
1293 // (IE uses filter instead)
1294 // Use a regex to work around a WebKit issue. See #5145
1295 opacity: /^0.5/.test( a.style.opacity ),
1297 // Verify style float existence
1298 // (IE uses styleFloat instead of cssFloat)
1299 cssFloat: !!a.style.cssFloat,
1301 // Make sure that if no value is specified for a checkbox
1302 // that it defaults to "on".
1303 // (WebKit defaults to "" instead)
1304 checkOn: ( input.value === "on" ),
1306 // Make sure that a selected-by-default option has a working selected property.
1307 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1308 optSelected: opt.selected,
1310 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1311 getSetAttribute: div.className !== "t",
1313 // Tests for enctype support on a form(#6743)
1314 enctype: !!document.createElement("form").enctype,
1316 // Makes sure cloning an html5 element does not cause problems
1317 // Where outerHTML is undefined, this still works
1318 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1320 // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1321 boxModel: ( document.compatMode === "CSS1Compat" ),
1323 // Will be defined later
1324 submitBubbles: true,
1325 changeBubbles: true,
1326 focusinBubbles: false,
1327 deleteExpando: true,
1329 inlineBlockNeedsLayout: false,
1330 shrinkWrapBlocks: false,
1331 reliableMarginRight: true,
1332 boxSizingReliable: true,
1333 pixelPosition: false
1336 // Make sure checked status is properly cloned
1337 input.checked = true;
1338 support.noCloneChecked = input.cloneNode( true ).checked;
1340 // Make sure that the options inside disabled selects aren't marked as disabled
1341 // (WebKit marks them as disabled)
1342 select.disabled = true;
1343 support.optDisabled = !opt.disabled;
1345 // Test to see if it's possible to delete an expando from an element
1346 // Fails in Internet Explorer
1350 support.deleteExpando = false;
1353 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1354 div.attachEvent( "onclick", clickFn = function() {
1355 // Cloning a node shouldn't copy over any
1356 // bound event handlers (IE does this)
1357 support.noCloneEvent = false;
1359 div.cloneNode( true ).fireEvent("onclick");
1360 div.detachEvent( "onclick", clickFn );
1363 // Check if a radio maintains its value
1364 // after being appended to the DOM
1365 input = document.createElement("input");
1367 input.setAttribute( "type", "radio" );
1368 support.radioValue = input.value === "t";
1370 input.setAttribute( "checked", "checked" );
1372 // #11217 - WebKit loses check when the name is after the checked attribute
1373 input.setAttribute( "name", "t" );
1375 div.appendChild( input );
1376 fragment = document.createDocumentFragment();
1377 fragment.appendChild( div.lastChild );
1379 // WebKit doesn't clone checked state correctly in fragments
1380 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1382 // Check if a disconnected checkbox will retain its checked
1383 // value of true after appended to the DOM (IE6/7)
1384 support.appendChecked = input.checked;
1386 fragment.removeChild( input );
1387 fragment.appendChild( div );
1389 // Technique from Juriy Zaytsev
1390 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1391 // We only care about the case where non-standard event systems
1392 // are used, namely in IE. Short-circuiting here helps us to
1393 // avoid an eval call (in setAttribute) which can cause CSP
1394 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1395 if ( div.attachEvent ) {
1401 eventName = "on" + i;
1402 isSupported = ( eventName in div );
1403 if ( !isSupported ) {
1404 div.setAttribute( eventName, "return;" );
1405 isSupported = ( typeof div[ eventName ] === "function" );
1407 support[ i + "Bubbles" ] = isSupported;
1411 // Run tests that need a body at doc ready
1413 var container, div, tds, marginDiv,
1414 divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
1415 body = document.getElementsByTagName("body")[0];
1418 // Return for frameset docs that don't have a body
1422 container = document.createElement("div");
1423 container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
1424 body.insertBefore( container, body.firstChild );
1426 // Construct the test element
1427 div = document.createElement("div");
1428 container.appendChild( div );
1430 // Check if table cells still have offsetWidth/Height when they are set
1431 // to display:none and there are still other visible table cells in a
1432 // table row; if so, offsetWidth/Height are not reliable for use when
1433 // determining if an element has been hidden directly using
1434 // display:none (it is still safe to use offsets if a parent element is
1435 // hidden; don safety goggles and see bug #4512 for more information).
1436 // (only IE 8 fails this test)
1437 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
1438 tds = div.getElementsByTagName("td");
1439 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
1440 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1442 tds[ 0 ].style.display = "";
1443 tds[ 1 ].style.display = "none";
1445 // Check if empty table cells still have offsetWidth/Height
1446 // (IE <= 8 fail this test)
1447 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1449 // Check box-sizing and margin behavior
1451 div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
1452 support.boxSizing = ( div.offsetWidth === 4 );
1453 support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1455 // NOTE: To any future maintainer, window.getComputedStyle was used here
1456 // instead of getComputedStyle because it gave a better gzip size.
1457 // The difference between window.getComputedStyle and getComputedStyle is
1459 if ( window.getComputedStyle ) {
1460 support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
1461 support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
1463 // Check if div with explicit width and no margin-right incorrectly
1464 // gets computed margin-right based on width of container. For more
1465 // info see bug #3333
1466 // Fails in WebKit before Feb 2011 nightlies
1467 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1468 marginDiv = document.createElement("div");
1469 marginDiv.style.cssText = div.style.cssText = divReset;
1470 marginDiv.style.marginRight = marginDiv.style.width = "0";
1471 div.style.width = "1px";
1472 div.appendChild( marginDiv );
1473 support.reliableMarginRight =
1474 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
1477 if ( typeof div.style.zoom !== "undefined" ) {
1478 // Check if natively block-level elements act like inline-block
1479 // elements when setting their display to 'inline' and giving
1481 // (IE < 8 does this)
1483 div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
1484 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
1486 // Check if elements with layout shrink-wrap their children
1488 div.style.display = "block";
1489 div.style.overflow = "visible";
1490 div.innerHTML = "<div></div>";
1491 div.firstChild.style.width = "5px";
1492 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
1494 container.style.zoom = 1;
1497 // Null elements to avoid leaks in IE
1498 body.removeChild( container );
1499 container = div = tds = marginDiv = null;
1502 // Null elements to avoid leaks in IE
1503 fragment.removeChild( div );
1504 all = a = select = opt = input = fragment = div = null;
1508 var rbrace = /^(?:\{.*\}|\[.*\])$/,
1509 rmultiDash = /([A-Z])/g;
1516 // Please use with caution
1519 // Unique for each copy of jQuery on the page
1520 // Non-digits removed to match rinlinejQuery
1521 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1523 // The following elements throw uncatchable exceptions if you
1524 // attempt to add expando properties to them.
1527 // Ban all objects except for Flash (which handle expandos)
1528 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1532 hasData: function( elem ) {
1533 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1534 return !!elem && !isEmptyDataObject( elem );
1537 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1538 if ( !jQuery.acceptData( elem ) ) {
1543 internalKey = jQuery.expando,
1544 getByName = typeof name === "string",
1546 // We have to handle DOM nodes and JS objects differently because IE6-7
1547 // can't GC object references properly across the DOM-JS boundary
1548 isNode = elem.nodeType,
1550 // Only DOM nodes need the global jQuery cache; JS object data is
1551 // attached directly to the object so GC can occur automatically
1552 cache = isNode ? jQuery.cache : elem,
1554 // Only defining an ID for JS objects if its cache already exists allows
1555 // the code to shortcut on the same path as a DOM node with no cache
1556 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
1558 // Avoid doing any more work than we need to when trying to get data on an
1559 // object that has no data at all
1560 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
1565 // Only DOM nodes need a new unique ID for each element since their data
1566 // ends up in the global cache
1568 elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
1574 if ( !cache[ id ] ) {
1577 // Avoids exposing jQuery metadata on plain JS objects when the object
1578 // is serialized using JSON.stringify
1580 cache[ id ].toJSON = jQuery.noop;
1584 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1585 // shallow copied over onto the existing cache
1586 if ( typeof name === "object" || typeof name === "function" ) {
1588 cache[ id ] = jQuery.extend( cache[ id ], name );
1590 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1594 thisCache = cache[ id ];
1596 // jQuery data() is stored in a separate object inside the object's internal data
1597 // cache in order to avoid key collisions between internal data and user-defined
1600 if ( !thisCache.data ) {
1601 thisCache.data = {};
1604 thisCache = thisCache.data;
1607 if ( data !== undefined ) {
1608 thisCache[ jQuery.camelCase( name ) ] = data;
1611 // Check for both converted-to-camel and non-converted data property names
1612 // If a data property was specified
1615 // First Try to find as-is property data
1616 ret = thisCache[ name ];
1618 // Test for null|undefined property data
1619 if ( ret == null ) {
1621 // Try to find the camelCased property
1622 ret = thisCache[ jQuery.camelCase( name ) ];
1631 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1632 if ( !jQuery.acceptData( elem ) ) {
1636 var thisCache, i, l,
1638 isNode = elem.nodeType,
1640 // See jQuery.data for more information
1641 cache = isNode ? jQuery.cache : elem,
1642 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1644 // If there is already no cache entry for this object, there is no
1645 // purpose in continuing
1646 if ( !cache[ id ] ) {
1652 thisCache = pvt ? cache[ id ] : cache[ id ].data;
1656 // Support array or space separated string names for data keys
1657 if ( !jQuery.isArray( name ) ) {
1659 // try the string as a key before any manipulation
1660 if ( name in thisCache ) {
1664 // split the camel cased version by spaces unless a key with the spaces exists
1665 name = jQuery.camelCase( name );
1666 if ( name in thisCache ) {
1669 name = name.split(" ");
1674 for ( i = 0, l = name.length; i < l; i++ ) {
1675 delete thisCache[ name[i] ];
1678 // If there is no data left in the cache, we want to continue
1679 // and let the cache object itself get destroyed
1680 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1686 // See jQuery.data for more information
1688 delete cache[ id ].data;
1690 // Don't destroy the parent cache unless the internal data object
1691 // had been the only thing left in it
1692 if ( !isEmptyDataObject( cache[ id ] ) ) {
1697 // Destroy the cache
1699 jQuery.cleanData( [ elem ], true );
1701 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
1702 } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
1705 // When all else fails, null
1711 // For internal use only.
1712 _data: function( elem, name, data ) {
1713 return jQuery.data( elem, name, data, true );
1716 // A method for determining if a DOM node can handle the data expando
1717 acceptData: function( elem ) {
1718 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
1720 // nodes accept data unless otherwise specified; rejection can be conditional
1721 return !noData || noData !== true && elem.getAttribute("classid") === noData;
1726 data: function( key, value ) {
1727 var parts, part, attr, name, l,
1733 if ( key === undefined ) {
1734 if ( this.length ) {
1735 data = jQuery.data( elem );
1737 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
1738 attr = elem.attributes;
1739 for ( l = attr.length; i < l; i++ ) {
1740 name = attr[i].name;
1742 if ( name.indexOf( "data-" ) === 0 ) {
1743 name = jQuery.camelCase( name.substring(5) );
1745 dataAttr( elem, name, data[ name ] );
1748 jQuery._data( elem, "parsedAttrs", true );
1755 // Sets multiple values
1756 if ( typeof key === "object" ) {
1757 return this.each(function() {
1758 jQuery.data( this, key );
1762 parts = key.split( ".", 2 );
1763 parts[1] = parts[1] ? "." + parts[1] : "";
1764 part = parts[1] + "!";
1766 return jQuery.access( this, function( value ) {
1768 if ( value === undefined ) {
1769 data = this.triggerHandler( "getData" + part, [ parts[0] ] );
1771 // Try to fetch any internally stored data first
1772 if ( data === undefined && elem ) {
1773 data = jQuery.data( elem, key );
1774 data = dataAttr( elem, key, data );
1777 return data === undefined && parts[1] ?
1778 this.data( parts[0] ) :
1783 this.each(function() {
1784 var self = jQuery( this );
1786 self.triggerHandler( "setData" + part, parts );
1787 jQuery.data( this, key, value );
1788 self.triggerHandler( "changeData" + part, parts );
1790 }, null, value, arguments.length > 1, null, false );
1793 removeData: function( key ) {
1794 return this.each(function() {
1795 jQuery.removeData( this, key );
1800 function dataAttr( elem, key, data ) {
1801 // If nothing was found internally, try to fetch any
1802 // data from the HTML5 data-* attribute
1803 if ( data === undefined && elem.nodeType === 1 ) {
1805 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1807 data = elem.getAttribute( name );
1809 if ( typeof data === "string" ) {
1811 data = data === "true" ? true :
1812 data === "false" ? false :
1813 data === "null" ? null :
1814 // Only convert to a number if it doesn't change the string
1815 +data + "" === data ? +data :
1816 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1820 // Make sure we set the data so it isn't changed later
1821 jQuery.data( elem, key, data );
1831 // checks a cache object for emptiness
1832 function isEmptyDataObject( obj ) {
1834 for ( name in obj ) {
1836 // if the public data object is empty, the private is still empty
1837 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1840 if ( name !== "toJSON" ) {
1848 queue: function( elem, type, data ) {
1852 type = ( type || "fx" ) + "queue";
1853 queue = jQuery._data( elem, type );
1855 // Speed up dequeue by getting out quickly if this is just a lookup
1857 if ( !queue || jQuery.isArray(data) ) {
1858 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
1867 dequeue: function( elem, type ) {
1868 type = type || "fx";
1870 var queue = jQuery.queue( elem, type ),
1872 hooks = jQuery._queueHooks( elem, type ),
1874 jQuery.dequeue( elem, type );
1877 // If the fx queue is dequeued, always remove the progress sentinel
1878 if ( fn === "inprogress" ) {
1884 // Add a progress sentinel to prevent the fx queue from being
1885 // automatically dequeued
1886 if ( type === "fx" ) {
1887 queue.unshift( "inprogress" );
1890 // clear up the last queue stop function
1892 fn.call( elem, next, hooks );
1894 if ( !queue.length && hooks ) {
1899 // not intended for public consumption - generates a queueHooks object, or returns the current one
1900 _queueHooks: function( elem, type ) {
1901 var key = type + "queueHooks";
1902 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
1903 empty: jQuery.Callbacks("once memory").add(function() {
1904 jQuery.removeData( elem, type + "queue", true );
1905 jQuery.removeData( elem, key, true );
1912 queue: function( type, data ) {
1915 if ( typeof type !== "string" ) {
1921 if ( arguments.length < setter ) {
1922 return jQuery.queue( this[0], type );
1925 return data === undefined ?
1927 this.each(function() {
1928 var queue = jQuery.queue( this, type, data );
1930 // ensure a hooks for this queue
1931 jQuery._queueHooks( this, type );
1933 if ( type === "fx" && queue[0] !== "inprogress" ) {
1934 jQuery.dequeue( this, type );
1938 dequeue: function( type ) {
1939 return this.each(function() {
1940 jQuery.dequeue( this, type );
1943 // Based off of the plugin by Clint Helfers, with permission.
1944 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1945 delay: function( time, type ) {
1946 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1947 type = type || "fx";
1949 return this.queue( type, function( next, hooks ) {
1950 var timeout = setTimeout( next, time );
1951 hooks.stop = function() {
1952 clearTimeout( timeout );
1956 clearQueue: function( type ) {
1957 return this.queue( type || "fx", [] );
1959 // Get a promise resolved when queues of a certain type
1960 // are emptied (fx is the type by default)
1961 promise: function( type, obj ) {
1964 defer = jQuery.Deferred(),
1967 resolve = function() {
1968 if ( !( --count ) ) {
1969 defer.resolveWith( elements, [ elements ] );
1973 if ( typeof type !== "string" ) {
1977 type = type || "fx";
1980 if ( (tmp = jQuery._data( elements[ i ], type + "queueHooks" )) && tmp.empty ) {
1982 tmp.empty.add( resolve );
1986 return defer.promise( obj );
1989 var nodeHook, boolHook, fixSpecified,
1990 rclass = /[\t\r\n]/g,
1992 rtype = /^(?:button|input)$/i,
1993 rfocusable = /^(?:button|input|object|select|textarea)$/i,
1994 rclickable = /^a(?:rea|)$/i,
1995 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
1996 getSetAttribute = jQuery.support.getSetAttribute;
1999 attr: function( name, value ) {
2000 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2003 removeAttr: function( name ) {
2004 return this.each(function() {
2005 jQuery.removeAttr( this, name );
2009 prop: function( name, value ) {
2010 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2013 removeProp: function( name ) {
2014 name = jQuery.propFix[ name ] || name;
2015 return this.each(function() {
2016 // try/catch handles cases where IE balks (such as removing a property on window)
2018 this[ name ] = undefined;
2019 delete this[ name ];
2024 addClass: function( value ) {
2025 var classNames, i, l, elem,
2028 if ( jQuery.isFunction( value ) ) {
2029 return this.each(function( j ) {
2030 jQuery( this ).addClass( value.call(this, j, this.className) );
2034 if ( value && typeof value === "string" ) {
2035 classNames = value.split( core_rspace );
2037 for ( i = 0, l = this.length; i < l; i++ ) {
2040 if ( elem.nodeType === 1 ) {
2041 if ( !elem.className && classNames.length === 1 ) {
2042 elem.className = value;
2045 setClass = " " + elem.className + " ";
2047 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2048 if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
2049 setClass += classNames[ c ] + " ";
2052 elem.className = jQuery.trim( setClass );
2061 removeClass: function( value ) {
2062 var removes, className, elem, c, cl, i, l;
2064 if ( jQuery.isFunction( value ) ) {
2065 return this.each(function( j ) {
2066 jQuery( this ).removeClass( value.call(this, j, this.className) );
2069 if ( (value && typeof value === "string") || value === undefined ) {
2070 removes = ( value || "" ).split( core_rspace );
2072 for ( i = 0, l = this.length; i < l; i++ ) {
2074 if ( elem.nodeType === 1 && elem.className ) {
2076 className = (" " + elem.className + " ").replace( rclass, " " );
2078 // loop over each item in the removal list
2079 for ( c = 0, cl = removes.length; c < cl; c++ ) {
2080 // Remove until there is nothing to remove,
2081 while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) {
2082 className = className.replace( " " + removes[ c ] + " " , " " );
2085 elem.className = value ? jQuery.trim( className ) : "";
2093 toggleClass: function( value, stateVal ) {
2094 var type = typeof value,
2095 isBool = typeof stateVal === "boolean";
2097 if ( jQuery.isFunction( value ) ) {
2098 return this.each(function( i ) {
2099 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2103 return this.each(function() {
2104 if ( type === "string" ) {
2105 // toggle individual class names
2108 self = jQuery( this ),
2110 classNames = value.split( core_rspace );
2112 while ( (className = classNames[ i++ ]) ) {
2113 // check each className given, space separated list
2114 state = isBool ? state : !self.hasClass( className );
2115 self[ state ? "addClass" : "removeClass" ]( className );
2118 } else if ( type === "undefined" || type === "boolean" ) {
2119 if ( this.className ) {
2120 // store className if set
2121 jQuery._data( this, "__className__", this.className );
2124 // toggle whole className
2125 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2130 hasClass: function( selector ) {
2131 var className = " " + selector + " ",
2134 for ( ; i < l; i++ ) {
2135 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
2143 val: function( value ) {
2144 var hooks, ret, isFunction,
2147 if ( !arguments.length ) {
2149 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2151 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2157 return typeof ret === "string" ?
2158 // handle most common string cases
2159 ret.replace(rreturn, "") :
2160 // handle cases where value is null/undef or number
2161 ret == null ? "" : ret;
2167 isFunction = jQuery.isFunction( value );
2169 return this.each(function( i ) {
2171 self = jQuery(this);
2173 if ( this.nodeType !== 1 ) {
2178 val = value.call( this, i, self.val() );
2183 // Treat null/undefined as ""; convert numbers to string
2184 if ( val == null ) {
2186 } else if ( typeof val === "number" ) {
2188 } else if ( jQuery.isArray( val ) ) {
2189 val = jQuery.map(val, function ( value ) {
2190 return value == null ? "" : value + "";
2194 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2196 // If set returns undefined, fall back to normal setting
2197 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2207 get: function( elem ) {
2208 // attributes.value is undefined in Blackberry 4.7 but
2209 // uses .value. See #6932
2210 var val = elem.attributes.value;
2211 return !val || val.specified ? elem.value : elem.text;
2215 get: function( elem ) {
2216 var value, i, max, option,
2217 index = elem.selectedIndex,
2219 options = elem.options,
2220 one = elem.type === "select-one";
2222 // Nothing was selected
2227 // Loop through all the selected options
2228 i = one ? index : 0;
2229 max = one ? index + 1 : options.length;
2230 for ( ; i < max; i++ ) {
2231 option = options[ i ];
2233 // Don't return options that are disabled or in a disabled optgroup
2234 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2235 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2237 // Get the specific value for the option
2238 value = jQuery( option ).val();
2240 // We don't need an array for one selects
2245 // Multi-Selects return an array
2246 values.push( value );
2250 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2251 if ( one && !values.length && options.length ) {
2252 return jQuery( options[ index ] ).val();
2258 set: function( elem, value ) {
2259 var values = jQuery.makeArray( value );
2261 jQuery(elem).find("option").each(function() {
2262 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2265 if ( !values.length ) {
2266 elem.selectedIndex = -1;
2273 // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
2276 attr: function( elem, name, value, pass ) {
2277 var ret, hooks, notxml,
2278 nType = elem.nodeType;
2280 // don't get/set attributes on text, comment and attribute nodes
2281 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2285 if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
2286 return jQuery( elem )[ name ]( value );
2289 // Fallback to prop when attributes are not supported
2290 if ( typeof elem.getAttribute === "undefined" ) {
2291 return jQuery.prop( elem, name, value );
2294 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2296 // All attributes are lowercase
2297 // Grab necessary hook if one is defined
2299 name = name.toLowerCase();
2300 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2303 if ( value !== undefined ) {
2305 if ( value === null ) {
2306 jQuery.removeAttr( elem, name );
2309 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2313 elem.setAttribute( name, "" + value );
2317 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2322 ret = elem.getAttribute( name );
2324 // Non-existent attributes return null, we normalize to undefined
2325 return ret === null ?
2331 removeAttr: function( elem, value ) {
2332 var propName, attrNames, name, isBool,
2335 if ( value && elem.nodeType === 1 ) {
2337 attrNames = value.split( core_rspace );
2339 for ( ; i < attrNames.length; i++ ) {
2340 name = attrNames[ i ];
2343 propName = jQuery.propFix[ name ] || name;
2344 isBool = rboolean.test( name );
2346 // See #9699 for explanation of this approach (setting first, then removal)
2347 // Do not do this for boolean attributes (see #10870)
2349 jQuery.attr( elem, name, "" );
2351 elem.removeAttribute( getSetAttribute ? name : propName );
2353 // Set corresponding property to false for boolean attributes
2354 if ( isBool && propName in elem ) {
2355 elem[ propName ] = false;
2364 set: function( elem, value ) {
2365 // We can't allow the type property to be changed (since it causes problems in IE)
2366 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2367 jQuery.error( "type property can't be changed" );
2368 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2369 // Setting the type on a radio button after the value resets the value in IE6-9
2370 // Reset value to it's default in case type is set after value
2371 // This is for element creation
2372 var val = elem.value;
2373 elem.setAttribute( "type", value );
2381 // Use the value property for back compat
2382 // Use the nodeHook for button elements in IE6/7 (#1954)
2384 get: function( elem, name ) {
2385 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2386 return nodeHook.get( elem, name );
2388 return name in elem ?
2392 set: function( elem, value, name ) {
2393 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2394 return nodeHook.set( elem, value, name );
2396 // Does not return so that setAttribute is also used
2403 tabindex: "tabIndex",
2404 readonly: "readOnly",
2406 "class": "className",
2407 maxlength: "maxLength",
2408 cellspacing: "cellSpacing",
2409 cellpadding: "cellPadding",
2413 frameborder: "frameBorder",
2414 contenteditable: "contentEditable"
2417 prop: function( elem, name, value ) {
2418 var ret, hooks, notxml,
2419 nType = elem.nodeType;
2421 // don't get/set properties on text, comment and attribute nodes
2422 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2426 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2429 // Fix name and attach hooks
2430 name = jQuery.propFix[ name ] || name;
2431 hooks = jQuery.propHooks[ name ];
2434 if ( value !== undefined ) {
2435 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2439 return ( elem[ name ] = value );
2443 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2447 return elem[ name ];
2454 get: function( elem ) {
2455 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2456 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2457 var attributeNode = elem.getAttributeNode("tabindex");
2459 return attributeNode && attributeNode.specified ?
2460 parseInt( attributeNode.value, 10 ) :
2461 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2469 // Hook for boolean attributes
2471 get: function( elem, name ) {
2472 // Align boolean attributes with corresponding properties
2473 // Fall back to attribute presence where some booleans are not supported
2475 property = jQuery.prop( elem, name );
2476 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2477 name.toLowerCase() :
2480 set: function( elem, value, name ) {
2482 if ( value === false ) {
2483 // Remove boolean attributes when set to false
2484 jQuery.removeAttr( elem, name );
2486 // value is true since we know at this point it's type boolean and not false
2487 // Set boolean attributes to the same name and set the DOM property
2488 propName = jQuery.propFix[ name ] || name;
2489 if ( propName in elem ) {
2490 // Only set the IDL specifically if it already exists on the element
2491 elem[ propName ] = true;
2494 elem.setAttribute( name, name.toLowerCase() );
2500 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2501 if ( !getSetAttribute ) {
2509 // Use this for any attribute in IE6/7
2510 // This fixes almost every IE6/7 issue
2511 nodeHook = jQuery.valHooks.button = {
2512 get: function( elem, name ) {
2514 ret = elem.getAttributeNode( name );
2515 return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
2519 set: function( elem, value, name ) {
2520 // Set the existing or create a new attribute node
2521 var ret = elem.getAttributeNode( name );
2523 ret = document.createAttribute( name );
2524 elem.setAttributeNode( ret );
2526 return ( ret.value = value + "" );
2530 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2531 // This is for removals
2532 jQuery.each([ "width", "height" ], function( i, name ) {
2533 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2534 set: function( elem, value ) {
2535 if ( value === "" ) {
2536 elem.setAttribute( name, "auto" );
2543 // Set contenteditable to false on removals(#10429)
2544 // Setting to empty string throws an error as an invalid value
2545 jQuery.attrHooks.contenteditable = {
2547 set: function( elem, value, name ) {
2548 if ( value === "" ) {
2551 nodeHook.set( elem, value, name );
2557 // Some attributes require a special call on IE
2558 if ( !jQuery.support.hrefNormalized ) {
2559 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2560 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2561 get: function( elem ) {
2562 var ret = elem.getAttribute( name, 2 );
2563 return ret === null ? undefined : ret;
2569 if ( !jQuery.support.style ) {
2570 jQuery.attrHooks.style = {
2571 get: function( elem ) {
2572 // Return undefined in the case of empty string
2573 // Normalize to lowercase since IE uppercases css property names
2574 return elem.style.cssText.toLowerCase() || undefined;
2576 set: function( elem, value ) {
2577 return ( elem.style.cssText = "" + value );
2582 // Safari mis-reports the default selected property of an option
2583 // Accessing the parent's selectedIndex property fixes it
2584 if ( !jQuery.support.optSelected ) {
2585 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2586 get: function( elem ) {
2587 var parent = elem.parentNode;
2590 parent.selectedIndex;
2592 // Make sure that it also works with optgroups, see #5701
2593 if ( parent.parentNode ) {
2594 parent.parentNode.selectedIndex;
2602 // IE6/7 call enctype encoding
2603 if ( !jQuery.support.enctype ) {
2604 jQuery.propFix.enctype = "encoding";
2607 // Radios and checkboxes getter/setter
2608 if ( !jQuery.support.checkOn ) {
2609 jQuery.each([ "radio", "checkbox" ], function() {
2610 jQuery.valHooks[ this ] = {
2611 get: function( elem ) {
2612 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2613 return elem.getAttribute("value") === null ? "on" : elem.value;
2618 jQuery.each([ "radio", "checkbox" ], function() {
2619 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2620 set: function( elem, value ) {
2621 if ( jQuery.isArray( value ) ) {
2622 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2627 var rformElems = /^(?:textarea|input|select)$/i,
2628 rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
2629 rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
2631 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2632 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2633 hoverHack = function( events ) {
2634 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2638 * Helper functions for managing events -- not part of the public interface.
2639 * Props to Dean Edwards' addEvent library for many of the ideas.
2643 add: function( elem, types, handler, data, selector ) {
2645 var elemData, eventHandle, events,
2646 t, tns, type, namespaces, handleObj,
2647 handleObjIn, handlers, special;
2649 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2650 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2654 // Caller can pass in an object of custom data in lieu of the handler
2655 if ( handler.handler ) {
2656 handleObjIn = handler;
2657 handler = handleObjIn.handler;
2658 selector = handleObjIn.selector;
2661 // Make sure that the handler has a unique ID, used to find/remove it later
2662 if ( !handler.guid ) {
2663 handler.guid = jQuery.guid++;
2666 // Init the element's event structure and main handler, if this is the first
2667 events = elemData.events;
2669 elemData.events = events = {};
2671 eventHandle = elemData.handle;
2672 if ( !eventHandle ) {
2673 elemData.handle = eventHandle = function( e ) {
2674 // Discard the second event of a jQuery.event.trigger() and
2675 // when an event is called after a page has unloaded
2676 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2677 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2680 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2681 eventHandle.elem = elem;
2684 // Handle multiple events separated by a space
2685 // jQuery(...).bind("mouseover mouseout", fn);
2686 types = jQuery.trim( hoverHack(types) ).split( " " );
2687 for ( t = 0; t < types.length; t++ ) {
2689 tns = rtypenamespace.exec( types[t] ) || [];
2691 namespaces = ( tns[2] || "" ).split( "." ).sort();
2693 // If event changes its type, use the special event handlers for the changed type
2694 special = jQuery.event.special[ type ] || {};
2696 // If selector defined, determine special event api type, otherwise given type
2697 type = ( selector ? special.delegateType : special.bindType ) || type;
2699 // Update special based on newly reset type
2700 special = jQuery.event.special[ type ] || {};
2702 // handleObj is passed to all event handlers
2703 handleObj = jQuery.extend({
2710 namespace: namespaces.join(".")
2713 // Init the event handler queue if we're the first
2714 handlers = events[ type ];
2716 handlers = events[ type ] = [];
2717 handlers.delegateCount = 0;
2719 // Only use addEventListener/attachEvent if the special events handler returns false
2720 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2721 // Bind the global event handler to the element
2722 if ( elem.addEventListener ) {
2723 elem.addEventListener( type, eventHandle, false );
2725 } else if ( elem.attachEvent ) {
2726 elem.attachEvent( "on" + type, eventHandle );
2731 if ( special.add ) {
2732 special.add.call( elem, handleObj );
2734 if ( !handleObj.handler.guid ) {
2735 handleObj.handler.guid = handler.guid;
2739 // Add to the element's handler list, delegates in front
2741 handlers.splice( handlers.delegateCount++, 0, handleObj );
2743 handlers.push( handleObj );
2746 // Keep track of which events have ever been used, for event optimization
2747 jQuery.event.global[ type ] = true;
2750 // Nullify elem to prevent memory leaks in IE
2756 // Detach an event or set of events from an element
2757 remove: function( elem, types, handler, selector, mappedTypes ) {
2759 var t, tns, type, origType, namespaces, origCount,
2760 j, events, special, eventType, handleObj,
2761 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
2763 if ( !elemData || !(events = elemData.events) ) {
2767 // Once for each type.namespace in types; type may be omitted
2768 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
2769 for ( t = 0; t < types.length; t++ ) {
2770 tns = rtypenamespace.exec( types[t] ) || [];
2771 type = origType = tns[1];
2772 namespaces = tns[2];
2774 // Unbind all events (on this namespace, if provided) for the element
2776 for ( type in events ) {
2777 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2782 special = jQuery.event.special[ type ] || {};
2783 type = ( selector? special.delegateType : special.bindType ) || type;
2784 eventType = events[ type ] || [];
2785 origCount = eventType.length;
2786 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2788 // Remove matching events
2789 for ( j = 0; j < eventType.length; j++ ) {
2790 handleObj = eventType[ j ];
2792 if ( ( mappedTypes || origType === handleObj.origType ) &&
2793 ( !handler || handler.guid === handleObj.guid ) &&
2794 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
2795 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2796 eventType.splice( j--, 1 );
2798 if ( handleObj.selector ) {
2799 eventType.delegateCount--;
2801 if ( special.remove ) {
2802 special.remove.call( elem, handleObj );
2807 // Remove generic event handler if we removed something and no more handlers exist
2808 // (avoids potential for endless recursion during removal of special event handlers)
2809 if ( eventType.length === 0 && origCount !== eventType.length ) {
2810 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2811 jQuery.removeEvent( elem, type, elemData.handle );
2814 delete events[ type ];
2818 // Remove the expando if it's no longer used
2819 if ( jQuery.isEmptyObject( events ) ) {
2820 delete elemData.handle;
2822 // removeData also checks for emptiness and clears the expando if empty
2823 // so use it instead of delete
2824 jQuery.removeData( elem, "events", true );
2828 // Events that are safe to short-circuit if no handlers are attached.
2829 // Native DOM events should not be added, they may have inline handlers.
2836 trigger: function( event, data, elem, onlyHandlers ) {
2837 // Don't do events on text and comment nodes
2838 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
2842 // Event object or event type
2843 var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
2844 type = event.type || event,
2847 // focus/blur morphs to focusin/out; ensure we're not firing them right now
2848 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2852 if ( type.indexOf( "!" ) >= 0 ) {
2853 // Exclusive events trigger only for the exact event (no namespaces)
2854 type = type.slice(0, -1);
2858 if ( type.indexOf( "." ) >= 0 ) {
2859 // Namespaced trigger; create a regexp to match event type in handle()
2860 namespaces = type.split(".");
2861 type = namespaces.shift();
2865 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2866 // No jQuery handlers for this event type, and it can't have inline handlers
2870 // Caller can pass in an Event, Object, or just an event type string
2871 event = typeof event === "object" ?
2872 // jQuery.Event object
2873 event[ jQuery.expando ] ? event :
2875 new jQuery.Event( type, event ) :
2876 // Just the event type (string)
2877 new jQuery.Event( type );
2880 event.isTrigger = true;
2881 event.exclusive = exclusive;
2882 event.namespace = namespaces.join( "." );
2883 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2884 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
2886 // Handle a global trigger
2889 // TODO: Stop taunting the data cache; remove global events and always attach to document
2890 cache = jQuery.cache;
2891 for ( i in cache ) {
2892 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
2893 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
2899 // Clean up the event in case it is being reused
2900 event.result = undefined;
2901 if ( !event.target ) {
2902 event.target = elem;
2905 // Clone any incoming data and prepend the event, creating the handler arg list
2906 data = data != null ? jQuery.makeArray( data ) : [];
2907 data.unshift( event );
2909 // Allow special events to draw outside the lines
2910 special = jQuery.event.special[ type ] || {};
2911 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
2915 // Determine event propagation path in advance, per W3C events spec (#9951)
2916 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2917 eventPath = [[ elem, special.bindType || type ]];
2918 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2920 bubbleType = special.delegateType || type;
2921 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
2922 for ( old = elem; cur; cur = cur.parentNode ) {
2923 eventPath.push([ cur, bubbleType ]);
2927 // Only add window if we got to document (e.g., not plain obj or detached DOM)
2928 if ( old === (elem.ownerDocument || document) ) {
2929 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
2933 // Fire handlers on the event path
2934 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
2936 cur = eventPath[i][0];
2937 event.type = eventPath[i][1];
2939 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2941 handle.apply( cur, data );
2943 // Note that this is a bare JS function and not a jQuery handler
2944 handle = ontype && cur[ ontype ];
2945 if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
2946 event.preventDefault();
2951 // If nobody prevented the default action, do it now
2952 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
2954 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
2955 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2957 // Call a native DOM method on the target with the same name name as the event.
2958 // Can't use an .isFunction() check here because IE6/7 fails that test.
2959 // Don't do default actions on window, that's where global variables be (#6170)
2960 // IE<9 dies on focus/blur to hidden element (#1486)
2961 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
2963 // Don't re-trigger an onFOO event when we call its FOO() method
2964 old = elem[ ontype ];
2967 elem[ ontype ] = null;
2970 // Prevent re-triggering of the same event, since we already bubbled it above
2971 jQuery.event.triggered = type;
2973 jQuery.event.triggered = undefined;
2976 elem[ ontype ] = old;
2982 return event.result;
2985 dispatch: function( event ) {
2987 // Make a writable jQuery.Event from the native event object
2988 event = jQuery.event.fix( event || window.event );
2990 var i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related,
2991 handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
2992 delegateCount = handlers.delegateCount,
2993 args = [].slice.call( arguments ),
2994 run_all = !event.exclusive && !event.namespace,
2995 special = jQuery.event.special[ event.type ] || {},
2998 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3000 event.delegateTarget = this;
3002 // Call the preDispatch hook for the mapped type, and let it bail if desired
3003 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3007 // Determine handlers that should run if there are delegated events
3008 // Avoid non-left-click bubbling in Firefox (#3861)
3009 if ( delegateCount && !(event.button && event.type === "click") ) {
3011 // Pregenerate a single jQuery object for reuse with .is()
3012 jqcur = jQuery(this);
3013 jqcur.context = this;
3015 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3017 // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #xxxx)
3018 if ( cur.disabled !== true || event.type !== "click" ) {
3022 for ( i = 0; i < delegateCount; i++ ) {
3023 handleObj = handlers[ i ];
3024 sel = handleObj.selector;
3026 if ( selMatch[ sel ] === undefined ) {
3027 selMatch[ sel ] = jqcur.is( sel );
3029 if ( selMatch[ sel ] ) {
3030 matches.push( handleObj );
3033 if ( matches.length ) {
3034 handlerQueue.push({ elem: cur, matches: matches });
3040 // Add the remaining (directly-bound) handlers
3041 if ( handlers.length > delegateCount ) {
3042 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3045 // Run delegates first; they may want to stop propagation beneath us
3046 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3047 matched = handlerQueue[ i ];
3048 event.currentTarget = matched.elem;
3050 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3051 handleObj = matched.matches[ j ];
3053 // Triggered event must either 1) be non-exclusive and have no namespace, or
3054 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3055 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3057 event.data = handleObj.data;
3058 event.handleObj = handleObj;
3060 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3061 .apply( matched.elem, args );
3063 if ( ret !== undefined ) {
3065 if ( ret === false ) {
3066 event.preventDefault();
3067 event.stopPropagation();
3074 // Call the postDispatch hook for the mapped type
3075 if ( special.postDispatch ) {
3076 special.postDispatch.call( this, event );
3079 return event.result;
3082 // Includes some event props shared by KeyEvent and MouseEvent
3083 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3084 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3089 props: "char charCode key keyCode".split(" "),
3090 filter: function( event, original ) {
3092 // Add which for key events
3093 if ( event.which == null ) {
3094 event.which = original.charCode != null ? original.charCode : original.keyCode;
3102 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3103 filter: function( event, original ) {
3104 var eventDoc, doc, body,
3105 button = original.button,
3106 fromElement = original.fromElement;
3108 // Calculate pageX/Y if missing and clientX/Y available
3109 if ( event.pageX == null && original.clientX != null ) {
3110 eventDoc = event.target.ownerDocument || document;
3111 doc = eventDoc.documentElement;
3112 body = eventDoc.body;
3114 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3115 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3118 // Add relatedTarget, if necessary
3119 if ( !event.relatedTarget && fromElement ) {
3120 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3123 // Add which for click: 1 === left; 2 === middle; 3 === right
3124 // Note: button is not normalized, so don't use it
3125 if ( !event.which && button !== undefined ) {
3126 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3133 fix: function( event ) {
3134 if ( event[ jQuery.expando ] ) {
3138 // Create a writable copy of the event object and normalize some properties
3140 originalEvent = event,
3141 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3142 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3144 event = jQuery.Event( originalEvent );
3146 for ( i = copy.length; i; ) {
3148 event[ prop ] = originalEvent[ prop ];
3151 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3152 if ( !event.target ) {
3153 event.target = originalEvent.srcElement || document;
3156 // Target should not be a text node (#504, Safari)
3157 if ( event.target.nodeType === 3 ) {
3158 event.target = event.target.parentNode;
3161 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
3162 event.metaKey = !!event.metaKey;
3164 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3169 // Make sure the ready event is setup
3170 setup: jQuery.bindReady
3174 // Prevent triggered image.load events from bubbling to window.load
3179 delegateType: "focusin"
3182 delegateType: "focusout"
3186 setup: function( data, namespaces, eventHandle ) {
3187 // We only want to do this special case on windows
3188 if ( jQuery.isWindow( this ) ) {
3189 this.onbeforeunload = eventHandle;
3193 teardown: function( namespaces, eventHandle ) {
3194 if ( this.onbeforeunload === eventHandle ) {
3195 this.onbeforeunload = null;
3201 simulate: function( type, elem, event, bubble ) {
3202 // Piggyback on a donor event to simulate a different one.
3203 // Fake originalEvent to avoid donor's stopPropagation, but if the
3204 // simulated event prevents default then we do the same on the donor.
3205 var e = jQuery.extend(
3214 jQuery.event.trigger( e, null, elem );
3216 jQuery.event.dispatch.call( elem, e );
3218 if ( e.isDefaultPrevented() ) {
3219 event.preventDefault();
3224 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3225 // The 1.7 special event interface should provide all the hooks needed now.
3226 jQuery.event.handle = jQuery.event.dispatch;
3228 jQuery.removeEvent = document.removeEventListener ?
3229 function( elem, type, handle ) {
3230 if ( elem.removeEventListener ) {
3231 elem.removeEventListener( type, handle, false );
3234 function( elem, type, handle ) {
3235 var name = "on" + type;
3237 if ( elem.detachEvent ) {
3239 // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
3240 // detachEvent needed property on element, by name of that event, to properly expose it to GC
3241 if ( typeof elem[ name ] === "undefined" ) {
3242 elem[ name ] = null;
3245 elem.detachEvent( name, handle );
3249 jQuery.Event = function( src, props ) {
3250 // Allow instantiation without the 'new' keyword
3251 if ( !(this instanceof jQuery.Event) ) {
3252 return new jQuery.Event( src, props );
3256 if ( src && src.type ) {
3257 this.originalEvent = src;
3258 this.type = src.type;
3260 // Events bubbling up the document may have been marked as prevented
3261 // by a handler lower down the tree; reflect the correct value.
3262 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3263 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3270 // Put explicitly provided properties onto the event object
3272 jQuery.extend( this, props );
3275 // Create a timestamp if incoming event doesn't have one
3276 this.timeStamp = src && src.timeStamp || jQuery.now();
3279 this[ jQuery.expando ] = true;
3282 function returnFalse() {
3285 function returnTrue() {
3289 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3290 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3291 jQuery.Event.prototype = {
3292 preventDefault: function() {
3293 this.isDefaultPrevented = returnTrue;
3295 var e = this.originalEvent;
3300 // if preventDefault exists run it on the original event
3301 if ( e.preventDefault ) {
3304 // otherwise set the returnValue property of the original event to false (IE)
3306 e.returnValue = false;
3309 stopPropagation: function() {
3310 this.isPropagationStopped = returnTrue;
3312 var e = this.originalEvent;
3316 // if stopPropagation exists run it on the original event
3317 if ( e.stopPropagation ) {
3318 e.stopPropagation();
3320 // otherwise set the cancelBubble property of the original event to true (IE)
3321 e.cancelBubble = true;
3323 stopImmediatePropagation: function() {
3324 this.isImmediatePropagationStopped = returnTrue;
3325 this.stopPropagation();
3327 isDefaultPrevented: returnFalse,
3328 isPropagationStopped: returnFalse,
3329 isImmediatePropagationStopped: returnFalse
3332 // Create mouseenter/leave events using mouseover/out and event-time checks
3334 mouseenter: "mouseover",
3335 mouseleave: "mouseout"
3336 }, function( orig, fix ) {
3337 jQuery.event.special[ orig ] = {
3341 handle: function( event ) {
3344 related = event.relatedTarget,
3345 handleObj = event.handleObj,
3346 selector = handleObj.selector;
3348 // For mousenter/leave call the handler if related is outside the target.
3349 // NB: No relatedTarget if the mouse left/entered the browser window
3350 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3351 event.type = handleObj.origType;
3352 ret = handleObj.handler.apply( this, arguments );
3360 // IE submit delegation
3361 if ( !jQuery.support.submitBubbles ) {
3363 jQuery.event.special.submit = {
3365 // Only need this for delegated form submit events
3366 if ( jQuery.nodeName( this, "form" ) ) {
3370 // Lazy-add a submit handler when a descendant form may potentially be submitted
3371 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3372 // Node name check avoids a VML-related crash in IE (#9807)
3373 var elem = e.target,
3374 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3375 if ( form && !jQuery._data( form, "_submit_attached" ) ) {
3376 jQuery.event.add( form, "submit._submit", function( event ) {
3377 event._submit_bubble = true;
3379 jQuery._data( form, "_submit_attached", true );
3382 // return undefined since we don't need an event listener
3385 postDispatch: function( event ) {
3386 // If form was submitted by the user, bubble the event up the tree
3387 if ( event._submit_bubble ) {
3388 delete event._submit_bubble;
3389 if ( this.parentNode && !event.isTrigger ) {
3390 jQuery.event.simulate( "submit", this.parentNode, event, true );
3395 teardown: function() {
3396 // Only need this for delegated form submit events
3397 if ( jQuery.nodeName( this, "form" ) ) {
3401 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3402 jQuery.event.remove( this, "._submit" );
3407 // IE change delegation and checkbox/radio fix
3408 if ( !jQuery.support.changeBubbles ) {
3410 jQuery.event.special.change = {
3414 if ( rformElems.test( this.nodeName ) ) {
3415 // IE doesn't fire change on a check/radio until blur; trigger it on click
3416 // after a propertychange. Eat the blur-change in special.change.handle.
3417 // This still fires onchange a second time for check/radio after blur.
3418 if ( this.type === "checkbox" || this.type === "radio" ) {
3419 jQuery.event.add( this, "propertychange._change", function( event ) {
3420 if ( event.originalEvent.propertyName === "checked" ) {
3421 this._just_changed = true;
3424 jQuery.event.add( this, "click._change", function( event ) {
3425 if ( this._just_changed && !event.isTrigger ) {
3426 this._just_changed = false;
3428 // Allow triggered, simulated change events (#11500)
3429 jQuery.event.simulate( "change", this, event, true );
3434 // Delegated event; lazy-add a change handler on descendant inputs
3435 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3436 var elem = e.target;
3438 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
3439 jQuery.event.add( elem, "change._change", function( event ) {
3440 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3441 jQuery.event.simulate( "change", this.parentNode, event, true );
3444 jQuery._data( elem, "_change_attached", true );
3449 handle: function( event ) {
3450 var elem = event.target;
3452 // Swallow native change events from checkbox/radio, we already triggered them above
3453 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3454 return event.handleObj.handler.apply( this, arguments );
3458 teardown: function() {
3459 jQuery.event.remove( this, "._change" );
3461 return rformElems.test( this.nodeName );
3466 // Create "bubbling" focus and blur events
3467 if ( !jQuery.support.focusinBubbles ) {
3468 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3470 // Attach a single capturing handler while someone wants focusin/focusout
3472 handler = function( event ) {
3473 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3476 jQuery.event.special[ fix ] = {
3478 if ( attaches++ === 0 ) {
3479 document.addEventListener( orig, handler, true );
3482 teardown: function() {
3483 if ( --attaches === 0 ) {
3484 document.removeEventListener( orig, handler, true );
3493 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3496 // Types can be a map of types/handlers
3497 if ( typeof types === "object" ) {
3498 // ( types-Object, selector, data )
3499 if ( typeof selector !== "string" ) { // && selector != null
3500 // ( types-Object, data )
3501 data = data || selector;
3502 selector = undefined;
3504 for ( type in types ) {
3505 this.on( type, selector, data, types[ type ], one );
3510 if ( data == null && fn == null ) {
3513 data = selector = undefined;
3514 } else if ( fn == null ) {
3515 if ( typeof selector === "string" ) {
3516 // ( types, selector, fn )
3520 // ( types, data, fn )
3523 selector = undefined;
3526 if ( fn === false ) {
3534 fn = function( event ) {
3535 // Can use an empty set, since event contains the info
3536 jQuery().off( event );
3537 return origFn.apply( this, arguments );
3539 // Use same guid so caller can remove using origFn
3540 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3542 return this.each( function() {
3543 jQuery.event.add( this, types, fn, data, selector );
3546 one: function( types, selector, data, fn ) {
3547 return this.on( types, selector, data, fn, 1 );
3549 off: function( types, selector, fn ) {
3550 var handleObj, type;
3551 if ( types && types.preventDefault && types.handleObj ) {
3552 // ( event ) dispatched jQuery.Event
3553 handleObj = types.handleObj;
3554 jQuery( types.delegateTarget ).off(
3555 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3561 if ( typeof types === "object" ) {
3562 // ( types-object [, selector] )
3563 for ( type in types ) {
3564 this.off( type, selector, types[ type ] );
3568 if ( selector === false || typeof selector === "function" ) {
3571 selector = undefined;
3573 if ( fn === false ) {
3576 return this.each(function() {
3577 jQuery.event.remove( this, types, fn, selector );
3581 bind: function( types, data, fn ) {
3582 return this.on( types, null, data, fn );
3584 unbind: function( types, fn ) {
3585 return this.off( types, null, fn );
3588 live: function( types, data, fn ) {
3589 jQuery( this.context ).on( types, this.selector, data, fn );
3592 die: function( types, fn ) {
3593 jQuery( this.context ).off( types, this.selector || "**", fn );
3597 delegate: function( selector, types, data, fn ) {
3598 return this.on( types, selector, data, fn );
3600 undelegate: function( selector, types, fn ) {
3601 // ( namespace ) or ( selector, types [, fn] )
3602 return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3605 trigger: function( type, data ) {
3606 return this.each(function() {
3607 jQuery.event.trigger( type, data, this );
3610 triggerHandler: function( type, data ) {
3612 return jQuery.event.trigger( type, data, this[0], true );
3616 toggle: function( fn ) {
3617 // Save reference to arguments for access in closure
3618 var args = arguments,
3619 guid = fn.guid || jQuery.guid++,
3621 toggler = function( event ) {
3622 // Figure out which function to execute
3623 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3624 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3626 // Make sure that clicks stop
3627 event.preventDefault();
3629 // and execute the function
3630 return args[ lastToggle ].apply( this, arguments ) || false;
3633 // link all the functions, so any of them can unbind this click handler
3634 toggler.guid = guid;
3635 while ( i < args.length ) {
3636 args[ i++ ].guid = guid;
3639 return this.click( toggler );
3642 hover: function( fnOver, fnOut ) {
3643 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3647 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3648 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3649 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3651 // Handle event binding
3652 jQuery.fn[ name ] = function( data, fn ) {
3658 return arguments.length > 0 ?
3659 this.on( name, null, data, fn ) :
3660 this.trigger( name );
3663 if ( rkeyEvent.test( name ) ) {
3664 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3667 if ( rmouseEvent.test( name ) ) {
3668 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3672 * Sizzle CSS Selector Engine
3673 * Copyright 2012 jQuery Foundation and other contributors
3674 * Released under the MIT license
3675 * http://sizzlejs.com/
3677 (function( window, undefined ) {
3685 document = window.document,
3686 docElem = document.documentElement,
3688 strundefined = "undefined",
3689 hasDuplicate = false,
3690 baseHasDuplicate = true,
3695 expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
3699 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
3700 whitespace = "[\\x20\\t\\r\\n\\f]",
3701 // http://www.w3.org/TR/css3-syntax/#characters
3702 characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
3704 // Loosely modeled on CSS identifier characters
3705 // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
3706 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
3707 identifier = characterEncoding.replace( "w", "w#" ),
3709 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
3710 operators = "([*^$|!~]?=)",
3711 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
3712 "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
3713 pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|((?:[^,]|\\\\,|(?:,(?=[^\\[]*\\]))|(?:,(?=[^\\(]*\\))))*))\\)|)",
3714 pos = ":(nth|eq|gt|lt|first|last|even|odd)(?:\\((\\d*)\\)|)(?=[^-]|$)",
3715 combinators = whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*",
3716 groups = "(?=[^\\x20\\t\\r\\n\\f])(?:\\\\.|" + attributes + "|" + pseudos.replace( 2, 7 ) + "|[^\\\\(),])+",
3718 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3719 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3721 rcombinators = new RegExp( "^" + combinators ),
3723 // All simple (non-comma) selectors, excluding insignifant trailing whitespace
3724 rgroups = new RegExp( groups + "?(?=" + whitespace + "*,|$)", "g" ),
3726 // A selector, or everything after leading whitespace
3727 // Optionally followed in either case by a ")" for terminating sub-selectors
3728 rselector = new RegExp( "^(?:(?!,)(?:(?:^|,)" + whitespace + "*" + groups + ")*?|" + whitespace + "*(.*?))(\\)|$)" ),
3730 // All combinators and selector components (attribute test, tag, pseudo, etc.), the latter appearing together when consecutive
3731 rtokens = new RegExp( groups.slice( 19, -6 ) + "\\x20\\t\\r\\n\\f>+~])+|" + combinators, "g" ),
3733 // Easily-parseable/retrievable ID or TAG or CLASS selectors
3734 rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
3736 rsibling = /[\x20\t\r\n\f]*[+~]/,
3737 rendsWithNot = /:not\($/,
3740 rinputs = /input|select|textarea|button/i,
3742 rbackslash = /\\(?!\\)/g,
3745 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
3746 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
3747 "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
3748 "TAG": new RegExp( "^(" + characterEncoding.replace( "[-", "[-\\*" ) + ")" ),
3749 "ATTR": new RegExp( "^" + attributes ),
3750 "PSEUDO": new RegExp( "^" + pseudos ),
3751 "CHILD": new RegExp( "^:(only|nth|last|first)-child(?:\\(" + whitespace +
3752 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3753 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3754 "POS": new RegExp( pos, "ig" ),
3755 // For use in libraries implementing .is()
3756 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
3762 cachedSelectors = [],
3764 // Mark a function for use in filtering
3765 markFunction = function( fn ) {
3766 fn.sizzleFilter = true;
3770 // Returns a function to use in pseudos for input types
3771 createInputFunction = function( type ) {
3772 return function( elem ) {
3773 // Check the input's nodeName and type
3774 return elem.nodeName.toLowerCase() === "input" && elem.type === type;
3778 // Returns a function to use in pseudos for buttons
3779 createButtonFunction = function( type ) {
3780 return function( elem ) {
3781 var name = elem.nodeName.toLowerCase();
3782 return (name === "input" || name === "button") && elem.type === type;
3786 // Used for testing something on an element
3787 assert = function( fn ) {
3789 div = document.createElement("div");
3793 // release memory in IE
3798 // Check if attributes should be retrieved by attribute nodes
3799 assertAttributes = assert(function( div ) {
3800 div.innerHTML = "<select></select>";
3801 var type = typeof div.lastChild.getAttribute("multiple");
3802 // IE8 returns a string for some attributes even when not present
3803 return type !== "boolean" && type !== "string";
3806 // Check if getElementById returns elements by name
3807 // Check if getElementsByName privileges form controls or returns elements by ID
3808 assertUsableName = assert(function( div ) {
3810 div.id = expando + 0;
3811 div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
3812 docElem.insertBefore( div, docElem.firstChild );
3815 var pass = document.getElementsByName &&
3816 // buggy browsers will return fewer than the correct 2
3817 document.getElementsByName( expando ).length ===
3818 // buggy browsers will return more than the correct 0
3819 2 + document.getElementsByName( expando + 0 ).length;
3820 assertGetIdNotName = !document.getElementById( expando );
3823 docElem.removeChild( div );
3828 // Check if the browser returns only elements
3829 // when doing getElementsByTagName("*")
3830 assertTagNameNoComments = assert(function( div ) {
3831 div.appendChild( document.createComment("") );
3832 return div.getElementsByTagName("*").length === 0;
3835 // Check if getAttribute returns normalized href attributes
3836 assertHrefNotNormalized = assert(function( div ) {
3837 div.innerHTML = "<a href='#'></a>";
3838 return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
3839 div.firstChild.getAttribute("href") === "#";
3842 // Check if getElementsByClassName can be trusted
3843 assertUsableClassName = assert(function( div ) {
3844 // Opera can't find a second classname (in 9.6)
3845 div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
3846 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
3850 // Safari caches class attributes, doesn't catch changes (in 3.2)
3851 div.lastChild.className = "e";
3852 return div.getElementsByClassName("e").length !== 1;
3855 var Sizzle = function( selector, context, results, seed ) {
3856 results = results || [];
3857 context = context || document;
3858 var match, elem, xml, m,
3859 nodeType = context.nodeType;
3861 if ( nodeType !== 1 && nodeType !== 9 ) {
3865 if ( !selector || typeof selector !== "string" ) {
3869 xml = isXML( context );
3871 if ( !xml && !seed ) {
3872 if ( (match = rquickExpr.exec( selector )) ) {
3873 // Speed-up: Sizzle("#ID")
3874 if ( (m = match[1]) ) {
3875 if ( nodeType === 9 ) {
3876 elem = context.getElementById( m );
3877 // Check parentNode to catch when Blackberry 4.6 returns
3878 // nodes that are no longer in the document #6963
3879 if ( elem && elem.parentNode ) {
3880 // Handle the case where IE, Opera, and Webkit return items
3881 // by name instead of ID
3882 if ( elem.id === m ) {
3883 results.push( elem );
3890 // Context is not a document
3891 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
3892 contains( context, elem ) && elem.id === m ) {
3893 results.push( elem );
3898 // Speed-up: Sizzle("TAG")
3899 } else if ( match[2] ) {
3900 push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
3903 // Speed-up: Sizzle(".CLASS")
3904 } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
3905 push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
3912 return select( selector, context, results, seed, xml );
3915 var Expr = Sizzle.selectors = {
3917 // Can be adjusted by the user
3922 order: [ "ID", "TAG" ],
3926 createPseudo: markFunction,
3929 "ID": assertGetIdNotName ?
3930 function( id, context, xml ) {
3931 if ( typeof context.getElementById !== strundefined && !xml ) {
3932 var m = context.getElementById( id );
3933 // Check parentNode to catch when Blackberry 4.6 returns
3934 // nodes that are no longer in the document #6963
3935 return m && m.parentNode ? [m] : [];
3938 function( id, context, xml ) {
3939 if ( typeof context.getElementById !== strundefined && !xml ) {
3940 var m = context.getElementById( id );
3943 m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
3950 "TAG": assertTagNameNoComments ?
3951 function( tag, context ) {
3952 if ( typeof context.getElementsByTagName !== strundefined ) {
3953 return context.getElementsByTagName( tag );
3956 function( tag, context ) {
3957 var results = context.getElementsByTagName( tag );
3959 // Filter out possible comments
3960 if ( tag === "*" ) {
3965 for ( ; (elem = results[i]); i++ ) {
3966 if ( elem.nodeType === 1 ) {
3978 ">": { dir: "parentNode", first: true },
3979 " ": { dir: "parentNode" },
3980 "+": { dir: "previousSibling", first: true },
3981 "~": { dir: "previousSibling" }
3985 "ATTR": function( match ) {
3986 match[1] = match[1].replace( rbackslash, "" );
3988 // Move the given value to match[3] whether quoted or unquoted
3989 match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
3991 if ( match[2] === "~=" ) {
3992 match[3] = " " + match[3] + " ";
3995 return match.slice( 0, 4 );
3998 "CHILD": function( match ) {
3999 /* matches from matchExpr.CHILD
4000 1 type (only|nth|...)
4001 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4002 3 xn-component of xn+y argument ([+-]?\d*n|)
4003 4 sign of xn-component
4005 6 sign of y-component
4008 match[1] = match[1].toLowerCase();
4010 if ( match[1] === "nth" ) {
4011 // nth-child requires argument
4013 Sizzle.error( match[0] );
4016 // numeric x and y parameters for Expr.filter.CHILD
4017 // remember that false/true cast respectively to 0/1
4018 match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
4019 match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
4021 // other types prohibit arguments
4022 } else if ( match[2] ) {
4023 Sizzle.error( match[0] );
4029 "PSEUDO": function( match ) {
4031 unquoted = match[4];
4033 if ( matchExpr["CHILD"].test( match[0] ) ) {
4037 // Relinquish our claim on characters in `unquoted` from a closing parenthesis on
4038 if ( unquoted && (argument = rselector.exec( unquoted )) && argument.pop() ) {
4040 match[0] = match[0].slice( 0, argument[0].length - unquoted.length - 1 );
4041 unquoted = argument[0].slice( 0, -1 );
4044 // Quoted or unquoted, we have the full argument
4045 // Return only captures needed by the pseudo filter method (type and argument)
4046 match.splice( 2, 3, unquoted || match[3] );
4052 "ID": assertGetIdNotName ?
4054 id = id.replace( rbackslash, "" );
4055 return function( elem ) {
4056 return elem.getAttribute("id") === id;
4060 id = id.replace( rbackslash, "" );
4061 return function( elem ) {
4062 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
4063 return node && node.value === id;
4067 "TAG": function( nodeName ) {
4068 if ( nodeName === "*" ) {
4069 return function() { return true; };
4071 nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
4073 return function( elem ) {
4074 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
4078 "CLASS": function( className ) {
4079 var pattern = classCache[ className ];
4081 pattern = classCache[ className ] = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" );
4082 cachedClasses.push( className );
4083 // Avoid too large of a cache
4084 if ( cachedClasses.length > Expr.cacheLength ) {
4085 delete classCache[ cachedClasses.shift() ];
4088 return function( elem ) {
4089 return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4093 "ATTR": function( name, operator, check ) {
4095 return function( elem ) {
4096 return Sizzle.attr( elem, name ) != null;
4100 return function( elem ) {
4101 var result = Sizzle.attr( elem, name ),
4102 value = result + "";
4104 if ( result == null ) {
4105 return operator === "!=";
4108 switch ( operator ) {
4110 return value === check;
4112 return value !== check;
4114 return check && value.indexOf( check ) === 0;
4116 return check && value.indexOf( check ) > -1;
4118 return check && value.substr( value.length - check.length ) === check;
4120 return ( " " + value + " " ).indexOf( check ) > -1;
4122 return value === check || value.substr( 0, check.length + 1 ) === check + "-";
4127 "CHILD": function( type, argument, first, last ) {
4129 if ( type === "nth" ) {
4130 var doneName = done++;
4132 return function( elem ) {
4137 if ( first === 1 && last === 0 ) {
4141 parent = elem.parentNode;
4143 if ( parent && (parent[ expando ] !== doneName || !elem.sizset) ) {
4144 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4145 if ( node.nodeType === 1 ) {
4146 node.sizset = ++count;
4147 if ( node === elem ) {
4153 parent[ expando ] = doneName;
4156 diff = elem.sizset - last;
4158 if ( first === 0 ) {
4162 return ( diff % first === 0 && diff / first >= 0 );
4167 return function( elem ) {
4173 while ( (node = node.previousSibling) ) {
4174 if ( node.nodeType === 1 ) {
4179 if ( type === "first" ) {
4187 while ( (node = node.nextSibling) ) {
4188 if ( node.nodeType === 1 ) {
4198 "PSEUDO": function( pseudo, argument, context, xml ) {
4199 // pseudo-class names are case-insensitive
4200 // http://www.w3.org/TR/selectors/#pseudo-classes
4201 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4202 var fn = Expr.pseudos[ pseudo ] || Expr.pseudos[ pseudo.toLowerCase() ];
4205 Sizzle.error( "unsupported pseudo: " + pseudo );
4208 // The user may set fn.sizzleFilter to indicate
4209 // that arguments are needed to create the filter function
4210 // just as Sizzle does
4211 if ( !fn.sizzleFilter ) {
4215 return fn( argument, context, xml );
4220 "not": markFunction(function( selector, context, xml ) {
4221 // Trim the selector passed to compile
4222 // to avoid treating leading and trailing
4223 // spaces as combinators
4224 var matcher = compile( selector.replace( rtrim, "$1" ), context, xml );
4225 return function( elem ) {
4226 return !matcher( elem );
4230 "enabled": function( elem ) {
4231 return elem.disabled === false;
4234 "disabled": function( elem ) {
4235 return elem.disabled === true;
4238 "checked": function( elem ) {
4239 // In CSS3, :checked should return both checked and selected elements
4240 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4241 var nodeName = elem.nodeName.toLowerCase();
4242 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
4245 "selected": function( elem ) {
4246 // Accessing this property makes selected-by-default
4247 // options in Safari work properly
4248 if ( elem.parentNode ) {
4249 elem.parentNode.selectedIndex;
4252 return elem.selected === true;
4255 "parent": function( elem ) {
4256 return !Expr.pseudos["empty"]( elem );
4259 "empty": function( elem ) {
4260 // http://www.w3.org/TR/selectors/#empty-pseudo
4261 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
4262 // not comment, processing instructions, or others
4263 // Thanks to Diego Perini for the nodeName shortcut
4264 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
4266 elem = elem.firstChild;
4268 if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
4271 elem = elem.nextSibling;
4276 "contains": markFunction(function( text ) {
4277 return function( elem ) {
4278 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4282 "has": markFunction(function( selector ) {
4283 return function( elem ) {
4284 return Sizzle( selector, elem ).length > 0;
4288 "header": function( elem ) {
4289 return rheader.test( elem.nodeName );
4292 "text": function( elem ) {
4294 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4295 // use getAttribute instead to test this case
4296 return elem.nodeName.toLowerCase() === "input" &&
4297 (type = elem.type) === "text" &&
4298 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
4302 "radio": createInputFunction("radio"),
4303 "checkbox": createInputFunction("checkbox"),
4304 "file": createInputFunction("file"),
4305 "password": createInputFunction("password"),
4306 "image": createInputFunction("image"),
4308 "submit": createButtonFunction("submit"),
4309 "reset": createButtonFunction("reset"),
4311 "button": function( elem ) {
4312 var name = elem.nodeName.toLowerCase();
4313 return name === "input" && elem.type === "button" || name === "button";
4316 "input": function( elem ) {
4317 return rinputs.test( elem.nodeName );
4320 "focus": function( elem ) {
4321 var doc = elem.ownerDocument;
4322 return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
4325 "active": function( elem ) {
4326 return elem === elem.ownerDocument.activeElement;
4331 "first": function( elements, argument, not ) {
4332 return not ? elements.slice( 1 ) : [ elements[0] ];
4335 "last": function( elements, argument, not ) {
4336 var elem = elements.pop();
4337 return not ? elements : [ elem ];
4340 "even": function( elements, argument, not ) {
4343 len = elements.length;
4344 for ( ; i < len; i = i + 2 ) {
4345 results.push( elements[i] );
4350 "odd": function( elements, argument, not ) {
4353 len = elements.length;
4354 for ( ; i < len; i = i + 2 ) {
4355 results.push( elements[i] );
4360 "lt": function( elements, argument, not ) {
4361 return not ? elements.slice( +argument ) : elements.slice( 0, +argument );
4364 "gt": function( elements, argument, not ) {
4365 return not ? elements.slice( 0, +argument + 1 ) : elements.slice( +argument + 1 );
4368 "eq": function( elements, argument, not ) {
4369 var elem = elements.splice( +argument, 1 );
4370 return not ? elements : elem;
4376 Expr.setFilters["nth"] = Expr.setFilters["eq"];
4379 Expr.filters = Expr.pseudos;
4381 // IE6/7 return a modified href
4382 if ( !assertHrefNotNormalized ) {
4384 "href": function( elem ) {
4385 return elem.getAttribute( "href", 2 );
4387 "type": function( elem ) {
4388 return elem.getAttribute("type");
4393 // Add getElementsByName if usable
4394 if ( assertUsableName ) {
4395 Expr.order.push("NAME");
4396 Expr.find["NAME"] = function( name, context ) {
4397 if ( typeof context.getElementsByName !== strundefined ) {
4398 return context.getElementsByName( name );
4403 // Add getElementsByClassName if usable
4404 if ( assertUsableClassName ) {
4405 Expr.order.splice( 1, 0, "CLASS" );
4406 Expr.find["CLASS"] = function( className, context, xml ) {
4407 if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
4408 return context.getElementsByClassName( className );
4413 // If slice is not available, provide a backup
4415 slice.call( docElem.childNodes, 0 )[0].nodeType;
4417 slice = function( i ) {
4418 var elem, results = [];
4419 for ( ; (elem = this[i]); i++ ) {
4420 results.push( elem );
4426 var isXML = Sizzle.isXML = function( elem ) {
4427 // documentElement is verified for cases where it doesn't yet exist
4428 // (such as loading iframes in IE - #4833)
4429 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
4430 return documentElement ? documentElement.nodeName !== "HTML" : false;
4433 // Element contains another
4434 var contains = Sizzle.contains = docElem.compareDocumentPosition ?
4436 return !!( a.compareDocumentPosition( b ) & 16 );
4440 var adown = a.nodeType === 9 ? a.documentElement : a,
4442 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
4445 while ( (b = b.parentNode) ) {
4454 * Utility function for retrieving the text value of an array of DOM nodes
4455 * @param {Array|Element} elem
4457 var getText = Sizzle.getText = function( elem ) {
4461 nodeType = elem.nodeType;
4464 if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
4465 // Use textContent for elements
4466 // innerText usage removed for consistency of new lines (see #11153)
4467 if ( typeof elem.textContent === "string" ) {
4468 return elem.textContent;
4470 // Traverse its children
4471 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4472 ret += getText( elem );
4475 } else if ( nodeType === 3 || nodeType === 4 ) {
4476 return elem.nodeValue;
4478 // Do not include comment or processing instruction nodes
4481 // If no nodeType, this is expected to be an array
4482 for ( ; (node = elem[i]); i++ ) {
4483 // Do not traverse comment nodes
4484 ret += getText( node );
4490 Sizzle.attr = function( elem, name ) {
4492 xml = isXML( elem );
4495 name = name.toLowerCase();
4497 if ( Expr.attrHandle[ name ] ) {
4498 return Expr.attrHandle[ name ]( elem );
4500 if ( assertAttributes || xml ) {
4501 return elem.getAttribute( name );
4503 attr = elem.getAttributeNode( name );
4505 typeof elem[ name ] === "boolean" ?
4506 elem[ name ] ? name : null :
4507 attr.specified ? attr.value : null :
4511 Sizzle.error = function( msg ) {
4512 throw new Error( "Syntax error, unrecognized expression: " + msg );
4515 // Check if the JavaScript engine is using some sort of
4516 // optimization where it does not always call our comparision
4517 // function. If that is the case, discard the hasDuplicate value.
4518 // Thus far that includes Google Chrome.
4519 [0, 0].sort(function() {
4520 return (baseHasDuplicate = 0);
4524 if ( docElem.compareDocumentPosition ) {
4525 sortOrder = function( a, b ) {
4527 hasDuplicate = true;
4531 return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
4532 a.compareDocumentPosition :
4533 a.compareDocumentPosition(b) & 4
4538 sortOrder = function( a, b ) {
4539 // The nodes are identical, we can exit early
4541 hasDuplicate = true;
4544 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4545 } else if ( a.sourceIndex && b.sourceIndex ) {
4546 return a.sourceIndex - b.sourceIndex;
4556 // If the nodes are siblings (or identical) we can do a quick check
4557 if ( aup === bup ) {
4558 return siblingCheck( a, b );
4560 // If no parents were found then the nodes are disconnected
4561 } else if ( !aup ) {
4564 } else if ( !bup ) {
4568 // Otherwise they're somewhere else in the tree so we need
4569 // to build up a full list of the parentNodes for comparison
4572 cur = cur.parentNode;
4579 cur = cur.parentNode;
4585 // Start walking down the tree looking for a discrepancy
4586 for ( var i = 0; i < al && i < bl; i++ ) {
4587 if ( ap[i] !== bp[i] ) {
4588 return siblingCheck( ap[i], bp[i] );
4592 // We ended someplace up the tree so do a sibling check
4594 siblingCheck( a, bp[i], -1 ) :
4595 siblingCheck( ap[i], b, 1 );
4598 siblingCheck = function( a, b, ret ) {
4603 var cur = a.nextSibling;
4610 cur = cur.nextSibling;
4617 // Document sorting and removing duplicates
4618 Sizzle.uniqueSort = function( results ) {
4623 hasDuplicate = baseHasDuplicate;
4624 results.sort( sortOrder );
4626 if ( hasDuplicate ) {
4627 for ( ; (elem = results[i]); i++ ) {
4628 if ( elem === results[ i - 1 ] ) {
4629 results.splice( i--, 1 );
4638 function multipleContexts( selector, contexts, results, seed ) {
4640 len = contexts.length;
4641 for ( ; i < len; i++ ) {
4642 Sizzle( selector, contexts[i], results, seed );
4646 function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) {
4648 fn = Expr.setFilters[ posfilter.toLowerCase() ];
4651 Sizzle.error( posfilter );
4654 if ( selector || !(results = seed) ) {
4655 multipleContexts( selector || "*", contexts, (results = []), seed );
4658 return results.length > 0 ? fn( results, argument, not ) : [];
4661 function handlePOS( selector, context, results, seed, groups ) {
4662 var match, not, anchor, ret, elements, currentContexts, part, lastIndex,
4664 len = groups.length,
4665 rpos = matchExpr["POS"],
4666 // This is generated here in case matchExpr["POS"] is extended
4667 rposgroups = new RegExp( "^" + rpos.source + "(?!" + whitespace + ")", "i" ),
4668 // This is for making sure non-participating
4669 // matching groups are represented cross-browser (IE6-8)
4670 setUndefined = function() {
4672 len = arguments.length - 2;
4673 for ( ; i < len; i++ ) {
4674 if ( arguments[i] === undefined ) {
4675 match[i] = undefined;
4680 for ( ; i < len; i++ ) {
4681 // Reset regex index to 0
4683 selector = groups[i];
4687 while ( (match = rpos.exec( selector )) ) {
4688 lastIndex = rpos.lastIndex = match.index + match[0].length;
4689 if ( lastIndex > anchor ) {
4690 part = selector.slice( anchor, match.index );
4692 currentContexts = [ context ];
4694 if ( rcombinators.test(part) ) {
4696 currentContexts = elements;
4701 if ( (not = rendsWithNot.test( part )) ) {
4702 part = part.slice( 0, -5 ).replace( rcombinators, "$&*" );
4705 if ( match.length > 1 ) {
4706 match[0].replace( rposgroups, setUndefined );
4708 elements = handlePOSGroup( part, match[1], match[2], currentContexts, elements, not );
4713 ret = ret.concat( elements );
4715 if ( (part = selector.slice( anchor )) && part !== ")" ) {
4716 if ( rcombinators.test(part) ) {
4717 multipleContexts( part, ret, results, seed );
4719 Sizzle( part, context, results, seed ? seed.concat(elements) : elements );
4722 push.apply( results, ret );
4725 Sizzle( selector, context, results, seed );
4729 // Do not sort if this is a single filter
4730 return len === 1 ? results : Sizzle.uniqueSort( results );
4733 function tokenize( selector, context, xml ) {
4734 var tokens, soFar, type,
4738 // Catch obvious selector issues: terminal ")"; nonempty fallback match
4739 // rselector never fails to match *something*
4740 match = rselector.exec( selector ),
4741 matched = !match.pop() && !match.pop(),
4742 selectorGroups = matched && selector.match( rgroups ) || [""],
4744 preFilters = Expr.preFilter,
4745 filters = Expr.filter,
4746 checkContext = !xml && context !== document;
4748 for ( ; (soFar = selectorGroups[i]) != null && matched; i++ ) {
4749 groups.push( tokens = [] );
4751 // Need to make sure we're within a narrower context if necessary
4752 // Adding a descendant combinator will generate what is needed
4753 if ( checkContext ) {
4754 soFar = " " + soFar;
4761 if ( (match = rcombinators.exec( soFar )) ) {
4762 soFar = soFar.slice( match[0].length );
4764 // Cast descendant combinators to space
4765 matched = tokens.push({ part: match.pop().replace( rtrim, " " ), captures: match });
4769 for ( type in filters ) {
4770 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
4771 (match = preFilters[ type ]( match, context, xml )) ) ) {
4773 soFar = soFar.slice( match.shift().length );
4774 matched = tokens.push({ part: type, captures: match });
4785 Sizzle.error( selector );
4791 function addCombinator( matcher, combinator, context ) {
4792 var dir = combinator.dir,
4796 // If there is no matcher to check, check against the context
4797 matcher = function( elem ) {
4798 return elem === context;
4801 return combinator.first ?
4802 function( elem, context ) {
4803 while ( (elem = elem[ dir ]) ) {
4804 if ( elem.nodeType === 1 ) {
4805 return matcher( elem, context ) && elem;
4809 function( elem, context ) {
4811 dirkey = doneName + "." + dirruns,
4812 cachedkey = dirkey + "." + cachedruns;
4813 while ( (elem = elem[ dir ]) ) {
4814 if ( elem.nodeType === 1 ) {
4815 if ( (cache = elem[ expando ]) === cachedkey ) {
4817 } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
4818 if ( elem.sizset ) {
4822 elem[ expando ] = cachedkey;
4823 if ( matcher( elem, context ) ) {
4827 elem.sizset = false;
4834 function addMatcher( higher, deeper ) {
4836 function( elem, context ) {
4837 var result = deeper( elem, context );
4838 return result && higher( result === true ? elem : result, context );
4843 // ["TAG", ">", "ID", " ", "CLASS"]
4844 function matcherFromTokens( tokens, context, xml ) {
4848 for ( ; (token = tokens[i]); i++ ) {
4849 if ( Expr.relative[ token.part ] ) {
4850 matcher = addCombinator( matcher, Expr.relative[ token.part ], context );
4852 token.captures.push( context, xml );
4853 matcher = addMatcher( matcher, Expr.filter[ token.part ].apply( null, token.captures ) );
4860 function matcherFromGroupMatchers( matchers ) {
4861 return function( elem, context ) {
4864 for ( ; (matcher = matchers[j]); j++ ) {
4865 if ( matcher(elem, context) ) {
4873 var compile = Sizzle.compile = function( selector, context, xml ) {
4874 var tokens, group, i,
4875 cached = compilerCache[ selector ];
4877 // Return a cached group function if already generated (context dependent)
4878 if ( cached && cached.context === context ) {
4882 // Generate a function of recursive functions that can be used to check each element
4883 group = tokenize( selector, context, xml );
4884 for ( i = 0; (tokens = group[i]); i++ ) {
4885 group[i] = matcherFromTokens( tokens, context, xml );
4888 // Cache the compiled function
4889 cached = compilerCache[ selector ] = matcherFromGroupMatchers( group );
4890 cached.context = context;
4891 cached.runs = cached.dirruns = 0;
4892 cachedSelectors.push( selector );
4893 // Ensure only the most recent are cached
4894 if ( cachedSelectors.length > Expr.cacheLength ) {
4895 delete compilerCache[ cachedSelectors.shift() ];
4900 Sizzle.matches = function( expr, elements ) {
4901 return Sizzle( expr, null, null, elements );
4904 Sizzle.matchesSelector = function( elem, expr ) {
4905 return Sizzle( expr, null, null, [ elem ] ).length > 0;
4908 var select = function( selector, context, results, seed, xml ) {
4909 // Remove excessive whitespace
4910 selector = selector.replace( rtrim, "$1" );
4911 var elements, matcher, i, len, elem, token,
4912 type, findContext, notTokens,
4913 match = selector.match( rgroups ),
4914 tokens = selector.match( rtokens ),
4915 contextNodeType = context.nodeType;
4918 if ( matchExpr["POS"].test(selector) ) {
4919 return handlePOS( selector, context, results, seed, match );
4923 elements = slice.call( seed, 0 );
4925 // To maintain document order, only narrow the
4926 // set if there is one group
4927 } else if ( match && match.length === 1 ) {
4929 // Take a shortcut and set the context if the root selector is an ID
4930 if ( tokens.length > 1 && contextNodeType === 9 && !xml &&
4931 (match = matchExpr["ID"].exec( tokens[0] )) ) {
4933 context = Expr.find["ID"]( match[1], context, xml )[0];
4938 selector = selector.slice( tokens.shift().length );
4941 findContext = ( (match = rsibling.exec( tokens[0] )) && !match.index && context.parentNode ) || context;
4943 // Get the last token, excluding :not
4944 notTokens = tokens.pop();
4945 token = notTokens.split(":not")[0];
4947 for ( i = 0, len = Expr.order.length; i < len; i++ ) {
4948 type = Expr.order[i];
4950 if ( (match = matchExpr[ type ].exec( token )) ) {
4951 elements = Expr.find[ type ]( (match[1] || "").replace( rbackslash, "" ), findContext, xml );
4953 if ( elements == null ) {
4957 if ( token === notTokens ) {
4958 selector = selector.slice( 0, selector.length - notTokens.length ) +
4959 token.replace( matchExpr[ type ], "" );
4962 push.apply( results, slice.call(elements, 0) );
4970 // Only loop over the given elements once
4971 // If selector is empty, we're already done
4973 matcher = compile( selector, context, xml );
4974 dirruns = matcher.dirruns++;
4976 if ( elements == null ) {
4977 elements = Expr.find["TAG"]( "*", (rsibling.test( selector ) && context.parentNode) || context );
4979 for ( i = 0; (elem = elements[i]); i++ ) {
4980 cachedruns = matcher.runs++;
4981 if ( matcher(elem, context) ) {
4982 results.push( elem );
4990 if ( document.querySelectorAll ) {
4992 var disconnectedMatch,
4995 rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
4997 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
4998 // A support test would require too much code (would include document ready)
4999 // just skip matchesSelector for :active
5000 rbuggyMatches = [":active"],
5001 matches = docElem.matchesSelector ||
5002 docElem.mozMatchesSelector ||
5003 docElem.webkitMatchesSelector ||
5004 docElem.oMatchesSelector ||
5005 docElem.msMatchesSelector;
5008 // Regex strategy adopted from Diego Perini
5009 assert(function( div ) {
5010 div.innerHTML = "<select><option selected></option></select>";
5012 // IE8 - Some boolean attributes are not treated correctly
5013 if ( !div.querySelectorAll("[selected]").length ) {
5014 rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
5017 // Webkit/Opera - :checked should return selected option elements
5018 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
5019 // IE8 throws error here (do not put tests after this one)
5020 if ( !div.querySelectorAll(":checked").length ) {
5021 rbuggyQSA.push(":checked");
5025 assert(function( div ) {
5027 // Opera 10-12/IE9 - ^= $= *= and empty values
5028 // Should not select anything
5029 div.innerHTML = "<p test=''></p>";
5030 if ( div.querySelectorAll("[test^='']").length ) {
5031 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
5034 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
5035 // IE8 throws error here (do not put tests after this one)
5036 div.innerHTML = "<input type='hidden'>";
5037 if ( !div.querySelectorAll(":enabled").length ) {
5038 rbuggyQSA.push(":enabled", ":disabled");
5042 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
5044 select = function( selector, context, results, seed, xml ) {
5045 // Only use querySelectorAll when not filtering,
5046 // when this is not xml,
5047 // and when no QSA bugs apply
5048 if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
5049 if ( context.nodeType === 9 ) {
5051 push.apply( results, slice.call(context.querySelectorAll( selector ), 0) );
5053 } catch(qsaError) {}
5054 // qSA works strangely on Element-rooted queries
5055 // We can work around this by specifying an extra ID on the root
5056 // and working up from there (Thanks to Andrew Dupont for the technique)
5057 // IE 8 doesn't work on object elements
5058 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5059 var old = context.getAttribute("id"),
5060 nid = old || expando,
5061 newContext = rsibling.test( selector ) && context.parentNode || context;
5064 nid = nid.replace( rescape, "\\$&" );
5066 context.setAttribute( "id", nid );
5070 push.apply( results, slice.call( newContext.querySelectorAll(
5071 selector.replace( rgroups, "[id='" + nid + "'] $&" )
5077 context.removeAttribute("id");
5083 return oldSelect( selector, context, results, seed, xml );
5087 assert(function( div ) {
5088 // Check to see if it's possible to do matchesSelector
5089 // on a disconnected node (IE 9)
5090 disconnectedMatch = matches.call( div, "div" );
5092 // This should fail with an exception
5093 // Gecko does not error, returns false instead
5095 matches.call( div, "[test!='']:sizzle" );
5096 rbuggyMatches.push( Expr.match.PSEUDO );
5100 // rbuggyMatches always contains :active, so no need for a length check
5101 rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
5103 Sizzle.matchesSelector = function( elem, expr ) {
5104 // Make sure that attribute selectors are quoted
5105 expr = expr.replace( rattributeQuotes, "='$1']" );
5107 // rbuggyMatches always contains :active, so no need for an existence check
5108 if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
5110 var ret = matches.call( elem, expr );
5112 // IE 9's matchesSelector returns false on disconnected nodes
5113 if ( ret || disconnectedMatch ||
5114 // As well, disconnected nodes are said to be in a document
5116 elem.document && elem.document.nodeType !== 11 ) {
5122 return Sizzle( expr, null, null, [ elem ] ).length > 0;
5128 // Override sizzle attribute retrieval
5129 Sizzle.attr = jQuery.attr;
5130 jQuery.find = Sizzle;
5131 jQuery.expr = Sizzle.selectors;
5132 jQuery.expr[":"] = jQuery.expr.pseudos;
5133 jQuery.unique = Sizzle.uniqueSort;
5134 jQuery.text = Sizzle.getText;
5135 jQuery.isXMLDoc = Sizzle.isXML;
5136 jQuery.contains = Sizzle.contains;
5140 var runtil = /Until$/,
5141 rparentsprev = /^(?:parents|prev(?:Until|All))/,
5142 isSimple = /^.[^:#\[\.,]*$/,
5143 rneedsContext = jQuery.expr.match.needsContext,
5144 // methods guaranteed to produce a unique set when starting from a unique set
5145 guaranteedUnique = {
5153 find: function( selector ) {
5154 var i, l, length, n, r, ret,
5157 if ( typeof selector !== "string" ) {
5158 return jQuery( selector ).filter(function() {
5159 for ( i = 0, l = self.length; i < l; i++ ) {
5160 if ( jQuery.contains( self[ i ], this ) ) {
5167 ret = this.pushStack( "", "find", selector );
5169 for ( i = 0, l = this.length; i < l; i++ ) {
5170 length = ret.length;
5171 jQuery.find( selector, this[i], ret );
5174 // Make sure that the results are unique
5175 for ( n = length; n < ret.length; n++ ) {
5176 for ( r = 0; r < length; r++ ) {
5177 if ( ret[r] === ret[n] ) {
5189 has: function( target ) {
5191 targets = jQuery( target, this ),
5192 len = targets.length;
5194 return this.filter(function() {
5195 for ( i = 0; i < len; i++ ) {
5196 if ( jQuery.contains( this, targets[i] ) ) {
5203 not: function( selector ) {
5204 return this.pushStack( winnow(this, selector, false), "not", selector);
5207 filter: function( selector ) {
5208 return this.pushStack( winnow(this, selector, true), "filter", selector );
5211 is: function( selector ) {
5212 return !!selector && (
5213 typeof selector === "string" ?
5214 // If this is a positional/relative selector, check membership in the returned set
5215 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5216 rneedsContext.test( selector ) ?
5217 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5218 jQuery.filter( selector, this ).length > 0 :
5219 this.filter( selector ).length > 0 );
5222 closest: function( selectors, context ) {
5227 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5228 jQuery( selectors, context || this.context ) :
5231 for ( ; i < l; i++ ) {
5234 while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5235 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5239 cur = cur.parentNode;
5243 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5245 return this.pushStack( ret, "closest", selectors );
5248 // Determine the position of an element within
5249 // the matched set of elements
5250 index: function( elem ) {
5252 // No argument, return index in parent
5254 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5257 // index in selector
5258 if ( typeof elem === "string" ) {
5259 return jQuery.inArray( this[0], jQuery( elem ) );
5262 // Locate the position of the desired element
5263 return jQuery.inArray(
5264 // If it receives a jQuery object, the first element is used
5265 elem.jquery ? elem[0] : elem, this );
5268 add: function( selector, context ) {
5269 var set = typeof selector === "string" ?
5270 jQuery( selector, context ) :
5271 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5272 all = jQuery.merge( this.get(), set );
5274 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5276 jQuery.unique( all ) );
5279 addBack: function( selector ) {
5280 return this.add( selector == null ?
5281 this.prevObject : this.prevObject.filter(selector)
5286 jQuery.fn.andSelf = jQuery.fn.addBack;
5288 // A painfully simple check to see if an element is disconnected
5289 // from a document (should be improved, where feasible).
5290 function isDisconnected( node ) {
5291 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5294 function sibling( cur, dir ) {
5297 } while ( cur && cur.nodeType !== 1 );
5303 parent: function( elem ) {
5304 var parent = elem.parentNode;
5305 return parent && parent.nodeType !== 11 ? parent : null;
5307 parents: function( elem ) {
5308 return jQuery.dir( elem, "parentNode" );
5310 parentsUntil: function( elem, i, until ) {
5311 return jQuery.dir( elem, "parentNode", until );
5313 next: function( elem ) {
5314 return sibling( elem, "nextSibling" );
5316 prev: function( elem ) {
5317 return sibling( elem, "previousSibling" );
5319 nextAll: function( elem ) {
5320 return jQuery.dir( elem, "nextSibling" );
5322 prevAll: function( elem ) {
5323 return jQuery.dir( elem, "previousSibling" );
5325 nextUntil: function( elem, i, until ) {
5326 return jQuery.dir( elem, "nextSibling", until );
5328 prevUntil: function( elem, i, until ) {
5329 return jQuery.dir( elem, "previousSibling", until );
5331 siblings: function( elem ) {
5332 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5334 children: function( elem ) {
5335 return jQuery.sibling( elem.firstChild );
5337 contents: function( elem ) {
5338 return jQuery.nodeName( elem, "iframe" ) ?
5339 elem.contentDocument || elem.contentWindow.document :
5340 jQuery.merge( [], elem.childNodes );
5342 }, function( name, fn ) {
5343 jQuery.fn[ name ] = function( until, selector ) {
5344 var ret = jQuery.map( this, fn, until );
5346 if ( !runtil.test( name ) ) {
5350 if ( selector && typeof selector === "string" ) {
5351 ret = jQuery.filter( selector, ret );
5354 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5356 if ( this.length > 1 && rparentsprev.test( name ) ) {
5357 ret = ret.reverse();
5360 return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
5365 filter: function( expr, elems, not ) {
5367 expr = ":not(" + expr + ")";
5370 return elems.length === 1 ?
5371 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5372 jQuery.find.matches(expr, elems);
5375 dir: function( elem, dir, until ) {
5379 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5380 if ( cur.nodeType === 1 ) {
5381 matched.push( cur );
5388 sibling: function( n, elem ) {
5391 for ( ; n; n = n.nextSibling ) {
5392 if ( n.nodeType === 1 && n !== elem ) {
5401 // Implement the identical functionality for filter and not
5402 function winnow( elements, qualifier, keep ) {
5404 // Can't pass null or undefined to indexOf in Firefox 4
5405 // Set to 0 to skip string check
5406 qualifier = qualifier || 0;
5408 if ( jQuery.isFunction( qualifier ) ) {
5409 return jQuery.grep(elements, function( elem, i ) {
5410 var retVal = !!qualifier.call( elem, i, elem );
5411 return retVal === keep;
5414 } else if ( qualifier.nodeType ) {
5415 return jQuery.grep(elements, function( elem, i ) {
5416 return ( elem === qualifier ) === keep;
5419 } else if ( typeof qualifier === "string" ) {
5420 var filtered = jQuery.grep(elements, function( elem ) {
5421 return elem.nodeType === 1;
5424 if ( isSimple.test( qualifier ) ) {
5425 return jQuery.filter(qualifier, filtered, !keep);
5427 qualifier = jQuery.filter( qualifier, filtered );
5431 return jQuery.grep(elements, function( elem, i ) {
5432 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5435 function createSafeFragment( document ) {
5436 var list = nodeNames.split( "|" ),
5437 safeFrag = document.createDocumentFragment();
5439 if ( safeFrag.createElement ) {
5440 while ( list.length ) {
5441 safeFrag.createElement(
5449 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5450 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5451 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5452 rleadingWhitespace = /^\s+/,
5453 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5454 rtagName = /<([\w:]+)/,
5456 rhtml = /<|&#?\w+;/,
5457 rnoInnerhtml = /<(?:script|style|link)/i,
5458 rnocache = /<(?:script|object|embed|option|style)/i,
5459 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5460 rcheckableType = /^(?:checkbox|radio)$/,
5461 // checked="checked" or checked
5462 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5463 rscriptType = /\/(java|ecma)script/i,
5464 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
5466 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5467 legend: [ 1, "<fieldset>", "</fieldset>" ],
5468 thead: [ 1, "<table>", "</table>" ],
5469 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5470 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5471 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5472 area: [ 1, "<map>", "</map>" ],
5473 _default: [ 0, "", "" ]
5475 safeFragment = createSafeFragment( document ),
5476 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5478 wrapMap.optgroup = wrapMap.option;
5479 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5480 wrapMap.th = wrapMap.td;
5482 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5483 // unless wrapped in a div with non-breaking characters in front of it.
5484 if ( !jQuery.support.htmlSerialize ) {
5485 wrapMap._default = [ 1, "X<div>", "</div>" ];
5489 text: function( value ) {
5490 return jQuery.access( this, function( value ) {
5491 return value === undefined ?
5492 jQuery.text( this ) :
5493 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5494 }, null, value, arguments.length );
5497 wrapAll: function( html ) {
5498 if ( jQuery.isFunction( html ) ) {
5499 return this.each(function(i) {
5500 jQuery(this).wrapAll( html.call(this, i) );
5505 // The elements to wrap the target around
5506 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5508 if ( this[0].parentNode ) {
5509 wrap.insertBefore( this[0] );
5512 wrap.map(function() {
5515 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5516 elem = elem.firstChild;
5526 wrapInner: function( html ) {
5527 if ( jQuery.isFunction( html ) ) {
5528 return this.each(function(i) {
5529 jQuery(this).wrapInner( html.call(this, i) );
5533 return this.each(function() {
5534 var self = jQuery( this ),
5535 contents = self.contents();
5537 if ( contents.length ) {
5538 contents.wrapAll( html );
5541 self.append( html );
5546 wrap: function( html ) {
5547 var isFunction = jQuery.isFunction( html );
5549 return this.each(function(i) {
5550 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5554 unwrap: function() {
5555 return this.parent().each(function() {
5556 if ( !jQuery.nodeName( this, "body" ) ) {
5557 jQuery( this ).replaceWith( this.childNodes );
5562 append: function() {
5563 return this.domManip(arguments, true, function( elem ) {
5564 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5565 this.appendChild( elem );
5570 prepend: function() {
5571 return this.domManip(arguments, true, function( elem ) {
5572 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5573 this.insertBefore( elem, this.firstChild );
5578 before: function() {
5579 if ( !isDisconnected( this[0] ) ) {
5580 return this.domManip(arguments, false, function( elem ) {
5581 this.parentNode.insertBefore( elem, this );
5585 if ( arguments.length ) {
5586 var set = jQuery.clean( arguments );
5587 return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
5592 if ( !isDisconnected( this[0] ) ) {
5593 return this.domManip(arguments, false, function( elem ) {
5594 this.parentNode.insertBefore( elem, this.nextSibling );
5598 if ( arguments.length ) {
5599 var set = jQuery.clean( arguments );
5600 return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
5604 // keepData is for internal use only--do not document
5605 remove: function( selector, keepData ) {
5609 for ( ; (elem = this[i]) != null; i++ ) {
5610 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5611 if ( !keepData && elem.nodeType === 1 ) {
5612 jQuery.cleanData( elem.getElementsByTagName("*") );
5613 jQuery.cleanData( [ elem ] );
5616 if ( elem.parentNode ) {
5617 elem.parentNode.removeChild( elem );
5629 for ( ; (elem = this[i]) != null; i++ ) {
5630 // Remove element nodes and prevent memory leaks
5631 if ( elem.nodeType === 1 ) {
5632 jQuery.cleanData( elem.getElementsByTagName("*") );
5635 // Remove any remaining nodes
5636 while ( elem.firstChild ) {
5637 elem.removeChild( elem.firstChild );
5644 clone: function( dataAndEvents, deepDataAndEvents ) {
5645 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5646 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5648 return this.map( function () {
5649 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5653 html: function( value ) {
5654 return jQuery.access( this, function( value ) {
5655 var elem = this[0] || {},
5659 if ( value === undefined ) {
5660 return elem.nodeType === 1 ?
5661 elem.innerHTML.replace( rinlinejQuery, "" ) :
5665 // See if we can take a shortcut and just use innerHTML
5666 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5667 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5668 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5669 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
5671 value = value.replace( rxhtmlTag, "<$1></$2>" );
5674 for (; i < l; i++ ) {
5675 // Remove element nodes and prevent memory leaks
5676 elem = this[i] || {};
5677 if ( elem.nodeType === 1 ) {
5678 jQuery.cleanData( elem.getElementsByTagName( "*" ) );
5679 elem.innerHTML = value;
5685 // If using innerHTML throws an exception, use the fallback method
5690 this.empty().append( value );
5692 }, null, value, arguments.length );
5695 replaceWith: function( value ) {
5696 if ( !isDisconnected( this[0] ) ) {
5697 // Make sure that the elements are removed from the DOM before they are inserted
5698 // this can help fix replacing a parent with child elements
5699 if ( jQuery.isFunction( value ) ) {
5700 return this.each(function(i) {
5701 var self = jQuery(this), old = self.html();
5702 self.replaceWith( value.call( this, i, old ) );
5706 if ( typeof value !== "string" ) {
5707 value = jQuery( value ).detach();
5710 return this.each(function() {
5711 var next = this.nextSibling,
5712 parent = this.parentNode;
5714 jQuery( this ).remove();
5717 jQuery(next).before( value );
5719 jQuery(parent).append( value );
5724 return this.length ?
5725 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5729 detach: function( selector ) {
5730 return this.remove( selector, true );
5733 domManip: function( args, table, callback ) {
5735 // Flatten any nested arrays
5736 args = [].concat.apply( [], args );
5738 var results, first, fragment, iNoClone,
5744 // We can't cloneNode fragments that contain checked, in WebKit
5745 if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
5746 return this.each(function() {
5747 jQuery(this).domManip( args, table, callback );
5751 if ( jQuery.isFunction(value) ) {
5752 return this.each(function(i) {
5753 var self = jQuery(this);
5754 args[0] = value.call( this, i, table ? self.html() : undefined );
5755 self.domManip( args, table, callback );
5760 results = jQuery.buildFragment( args, this, scripts );
5761 fragment = results.fragment;
5762 first = fragment.firstChild;
5764 if ( fragment.childNodes.length === 1 ) {
5769 table = table && jQuery.nodeName( first, "tr" );
5771 // Use the original fragment for the last item instead of the first because it can end up
5772 // being emptied incorrectly in certain situations (#8070).
5773 // Fragments from the fragment cache must always be cloned and never used in place.
5774 for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
5776 table && jQuery.nodeName( this[i], "table" ) ?
5777 findOrAppend( this[i], "tbody" ) :
5781 jQuery.clone( fragment, true, true )
5786 // Fix #11809: Avoid leaking memory
5787 fragment = first = null;
5789 if ( scripts.length ) {
5790 jQuery.each( scripts, function( i, elem ) {
5792 if ( jQuery.ajax ) {
5802 jQuery.error("no ajax");
5805 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
5808 if ( elem.parentNode ) {
5809 elem.parentNode.removeChild( elem );
5819 function findOrAppend( elem, tag ) {
5820 return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
5823 function cloneCopyEvent( src, dest ) {
5825 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
5830 oldData = jQuery._data( src ),
5831 curData = jQuery._data( dest, oldData ),
5832 events = oldData.events;
5835 delete curData.handle;
5836 curData.events = {};
5838 for ( type in events ) {
5839 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
5840 jQuery.event.add( dest, type, events[ type ][ i ] );
5845 // make the cloned public data object a copy from the original
5846 if ( curData.data ) {
5847 curData.data = jQuery.extend( {}, curData.data );
5851 function cloneFixAttributes( src, dest ) {
5854 // We do not need to do anything for non-Elements
5855 if ( dest.nodeType !== 1 ) {
5859 // clearAttributes removes the attributes, which we don't want,
5860 // but also removes the attachEvent events, which we *do* want
5861 if ( dest.clearAttributes ) {
5862 dest.clearAttributes();
5865 // mergeAttributes, in contrast, only merges back on the
5866 // original attributes, not the events
5867 if ( dest.mergeAttributes ) {
5868 dest.mergeAttributes( src );
5871 nodeName = dest.nodeName.toLowerCase();
5873 if ( nodeName === "object" ) {
5874 // IE6-10 improperly clones children of object elements using classid.
5875 // IE10 throws NoModificationAllowedError if parent is null, #12132.
5876 if ( dest.parentNode ) {
5877 dest.outerHTML = src.outerHTML;
5880 // This path appears unavoidable for IE9. When cloning an object
5881 // element in IE9, the outerHTML strategy above is not sufficient.
5882 // If the src has innerHTML and the destination does not,
5883 // copy the src.innerHTML into the dest.innerHTML. #10324
5884 if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
5885 dest.innerHTML = src.innerHTML;
5888 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
5889 // IE6-8 fails to persist the checked state of a cloned checkbox
5890 // or radio button. Worse, IE6-7 fail to give the cloned element
5891 // a checked appearance if the defaultChecked value isn't also set
5893 dest.defaultChecked = dest.checked = src.checked;
5895 // IE6-7 get confused and end up setting the value of a cloned
5896 // checkbox/radio button to an empty string instead of "on"
5897 if ( dest.value !== src.value ) {
5898 dest.value = src.value;
5901 // IE6-8 fails to return the selected option to the default selected
5902 // state when cloning options
5903 } else if ( nodeName === "option" ) {
5904 dest.selected = src.defaultSelected;
5906 // IE6-8 fails to set the defaultValue to the correct value when
5907 // cloning other types of input fields
5908 } else if ( nodeName === "input" || nodeName === "textarea" ) {
5909 dest.defaultValue = src.defaultValue;
5911 // IE blanks contents when cloning scripts
5912 } else if ( nodeName === "script" && dest.text !== src.text ) {
5913 dest.text = src.text;
5916 // Event data gets referenced instead of copied if the expando
5918 dest.removeAttribute( jQuery.expando );
5921 jQuery.buildFragment = function( args, context, scripts ) {
5922 var fragment, cacheable, cachehit,
5925 // Set context from what may come in as undefined or a jQuery collection or a node
5926 context = context || document;
5927 context = (context[0] || context).ownerDocument || context[0] || context;
5929 // Ensure that an attr object doesn't incorrectly stand in as a document object
5930 // Chrome and Firefox seem to allow this to occur and will throw exception
5932 if ( typeof context.createDocumentFragment === "undefined" ) {
5936 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
5937 // Cloning options loses the selected state, so don't cache them
5938 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
5939 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
5940 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
5941 if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
5942 first.charAt(0) === "<" && !rnocache.test( first ) &&
5943 (jQuery.support.checkClone || !rchecked.test( first )) &&
5944 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
5946 // Mark cacheable and look for a hit
5948 fragment = jQuery.fragments[ first ];
5949 cachehit = fragment !== undefined;
5953 fragment = context.createDocumentFragment();
5954 jQuery.clean( args, context, fragment, scripts );
5956 // Update the cache, but only store false
5957 // unless this is a second parsing of the same content
5959 jQuery.fragments[ first ] = cachehit && fragment;
5963 return { fragment: fragment, cacheable: cacheable };
5966 jQuery.fragments = {};
5970 prependTo: "prepend",
5971 insertBefore: "before",
5972 insertAfter: "after",
5973 replaceAll: "replaceWith"
5974 }, function( name, original ) {
5975 jQuery.fn[ name ] = function( selector ) {
5979 insert = jQuery( selector ),
5981 parent = this.length === 1 && this[0].parentNode;
5983 if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
5984 insert[ original ]( this[0] );
5987 for ( ; i < l; i++ ) {
5988 elems = ( i > 0 ? this.clone(true) : this ).get();
5989 jQuery( insert[i] )[ original ]( elems );
5990 ret = ret.concat( elems );
5993 return this.pushStack( ret, name, insert.selector );
5998 function getAll( elem ) {
5999 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6000 return elem.getElementsByTagName( "*" );
6002 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6003 return elem.querySelectorAll( "*" );
6010 // Used in clean, fixes the defaultChecked property
6011 function fixDefaultChecked( elem ) {
6012 if ( rcheckableType.test( elem.type ) ) {
6013 elem.defaultChecked = elem.checked;
6018 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6024 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6025 clone = elem.cloneNode( true );
6027 // IE<=8 does not properly clone detached, unknown element nodes
6029 fragmentDiv.innerHTML = elem.outerHTML;
6030 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6033 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6034 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6035 // IE copies events bound via attachEvent when using cloneNode.
6036 // Calling detachEvent on the clone will also remove the events
6037 // from the original. In order to get around this, we use some
6038 // proprietary methods to clear the events. Thanks to MooTools
6039 // guys for this hotness.
6041 cloneFixAttributes( elem, clone );
6043 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6044 srcElements = getAll( elem );
6045 destElements = getAll( clone );
6047 // Weird iteration because IE will replace the length property
6048 // with an element if you are cloning the body and one of the
6049 // elements on the page has a name or id of "length"
6050 for ( i = 0; srcElements[i]; ++i ) {
6051 // Ensure that the destination node is not null; Fixes #9587
6052 if ( destElements[i] ) {
6053 cloneFixAttributes( srcElements[i], destElements[i] );
6058 // Copy the events from the original to the clone
6059 if ( dataAndEvents ) {
6060 cloneCopyEvent( elem, clone );
6062 if ( deepDataAndEvents ) {
6063 srcElements = getAll( elem );
6064 destElements = getAll( clone );
6066 for ( i = 0; srcElements[i]; ++i ) {
6067 cloneCopyEvent( srcElements[i], destElements[i] );
6072 srcElements = destElements = null;
6074 // Return the cloned set
6078 clean: function( elems, context, fragment, scripts ) {
6079 var j, safe, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6083 // Ensure that context is a document
6084 if ( !context || typeof context.createDocumentFragment === "undefined" ) {
6088 // Use the already-created safe fragment if context permits
6089 for ( safe = context === document && safeFragment; (elem = elems[i]) != null; i++ ) {
6090 if ( typeof elem === "number" ) {
6098 // Convert html string into DOM nodes
6099 if ( typeof elem === "string" ) {
6100 if ( !rhtml.test( elem ) ) {
6101 elem = context.createTextNode( elem );
6103 // Ensure a safe container in which to render the html
6104 safe = safe || createSafeFragment( context );
6105 div = div || safe.appendChild( context.createElement("div") );
6107 // Fix "XHTML"-style tags in all browsers
6108 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6110 // Go to html and back, then peel off extra wrappers
6111 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6112 wrap = wrapMap[ tag ] || wrapMap._default;
6114 div.innerHTML = wrap[1] + elem + wrap[2];
6116 // Move to the right depth
6118 div = div.lastChild;
6121 // Remove IE's autoinserted <tbody> from table fragments
6122 if ( !jQuery.support.tbody ) {
6124 // String was a <table>, *may* have spurious <tbody>
6125 hasBody = rtbody.test(elem);
6126 tbody = tag === "table" && !hasBody ?
6127 div.firstChild && div.firstChild.childNodes :
6129 // String was a bare <thead> or <tfoot>
6130 wrap[1] === "<table>" && !hasBody ?
6134 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6135 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6136 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6141 // IE completely kills leading whitespace when innerHTML is used
6142 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6143 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6146 elem = div.childNodes;
6148 // Remember the top-level container for proper cleanup
6149 div = safe.lastChild;
6153 if ( elem.nodeType ) {
6156 ret = jQuery.merge( ret, elem );
6160 // Fix #11356: Clear elements from safeFragment
6162 safe.removeChild( div );
6163 elem = div = safe = null;
6166 // Reset defaultChecked for any radios and checkboxes
6167 // about to be appended to the DOM in IE 6/7 (#8060)
6168 if ( !jQuery.support.appendChecked ) {
6169 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6170 if ( jQuery.nodeName( elem, "input" ) ) {
6171 fixDefaultChecked( elem );
6172 } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
6173 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6178 // Append elements to a provided document fragment
6180 // Special handling of each script element
6181 handleScript = function( elem ) {
6182 // Check if we consider it executable
6183 if ( !elem.type || rscriptType.test( elem.type ) ) {
6184 // Detach the script and store it in the scripts array (if provided) or the fragment
6185 // Return truthy to indicate that it has been handled
6187 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
6188 fragment.appendChild( elem );
6192 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6193 // Check if we're done after handling an executable script
6194 if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
6195 // Append to fragment and handle embedded scripts
6196 fragment.appendChild( elem );
6197 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6198 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
6199 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
6201 // Splice the scripts into ret after their former ancestor and advance our index beyond them
6202 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6212 cleanData: function( elems, /* internal */ acceptData ) {
6213 var data, id, elem, type,
6215 internalKey = jQuery.expando,
6216 cache = jQuery.cache,
6217 deleteExpando = jQuery.support.deleteExpando,
6218 special = jQuery.event.special;
6220 for ( ; (elem = elems[i]) != null; i++ ) {
6222 if ( acceptData || jQuery.acceptData( elem ) ) {
6224 id = elem[ internalKey ];
6225 data = id && cache[ id ];
6228 if ( data.events ) {
6229 for ( type in data.events ) {
6230 if ( special[ type ] ) {
6231 jQuery.event.remove( elem, type );
6233 // This is a shortcut to avoid jQuery.event.remove's overhead
6235 jQuery.removeEvent( elem, type, data.handle );
6240 // Remove cache only if it was not already removed by jQuery.event.remove
6241 if ( cache[ id ] ) {
6245 // IE does not allow us to delete expando properties from nodes,
6246 // nor does it have a removeAttribute function on Document nodes;
6247 // we must handle all of these cases
6248 if ( deleteExpando ) {
6249 delete elem[ internalKey ];
6251 } else if ( elem.removeAttribute ) {
6252 elem.removeAttribute( internalKey );
6255 elem[ internalKey ] = null;
6258 jQuery.deletedIds.push( id );
6265 // Limit scope pollution from any deprecated API
6268 var matched, browser;
6270 // Use of jQuery.browser is frowned upon.
6271 // More details: http://api.jquery.com/jQuery.browser
6272 // jQuery.uaMatch maintained for back-compat
6273 jQuery.uaMatch = function( ua ) {
6274 ua = ua.toLowerCase();
6276 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
6277 /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
6278 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
6279 /(msie) ([\w.]+)/.exec( ua ) ||
6280 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
6284 browser: match[ 1 ] || "",
6285 version: match[ 2 ] || "0"
6289 matched = jQuery.uaMatch( navigator.userAgent );
6292 if ( matched.browser ) {
6293 browser[ matched.browser ] = true;
6294 browser.version = matched.version;
6297 // Deprecated, use jQuery.browser.webkit instead
6298 // Maintained for back-compat only
6299 if ( browser.webkit ) {
6300 browser.safari = true;
6303 jQuery.browser = browser;
6305 jQuery.sub = function() {
6306 function jQuerySub( selector, context ) {
6307 return new jQuerySub.fn.init( selector, context );
6309 jQuery.extend( true, jQuerySub, this );
6310 jQuerySub.superclass = this;
6311 jQuerySub.fn = jQuerySub.prototype = this();
6312 jQuerySub.fn.constructor = jQuerySub;
6313 jQuerySub.sub = this.sub;
6314 jQuerySub.fn.init = function init( selector, context ) {
6315 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
6316 context = jQuerySub( context );
6319 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
6321 jQuerySub.fn.init.prototype = jQuerySub.fn;
6322 var rootjQuerySub = jQuerySub(document);
6327 var curCSS, iframe, iframeDoc,
6328 ralpha = /alpha\([^)]*\)/i,
6329 ropacity = /opacity=([^)]*)/,
6330 rposition = /^(top|right|bottom|left)$/,
6331 rmargin = /^margin/,
6332 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6333 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6334 rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
6337 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6338 cssNormalTransform = {
6344 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6345 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
6347 eventsToggle = jQuery.fn.toggle;
6349 // return a css property mapped to a potentially vendor prefixed property
6350 function vendorPropName( style, name ) {
6352 // shortcut for names that are not vendor prefixed
6353 if ( name in style ) {
6357 // check for vendor prefixed names
6358 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6360 i = cssPrefixes.length;
6363 name = cssPrefixes[ i ] + capName;
6364 if ( name in style ) {
6372 function isHidden( elem, el ) {
6374 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6377 function showHide( elements, show ) {
6381 length = elements.length;
6383 for ( ; index < length; index++ ) {
6384 elem = elements[ index ];
6385 if ( !elem.style ) {
6388 values[ index ] = jQuery._data( elem, "olddisplay" );
6390 // Reset the inline display of this element to learn if it is
6391 // being hidden by cascaded rules or not
6392 if ( !values[ index ] && elem.style.display === "none" ) {
6393 elem.style.display = "";
6396 // Set elements which have been overridden with display: none
6397 // in a stylesheet to whatever the default browser style is
6398 // for such an element
6399 if ( elem.style.display === "" && isHidden( elem ) ) {
6400 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6403 display = curCSS( elem, "display" );
6405 if ( !values[ index ] && display !== "none" ) {
6406 jQuery._data( elem, "olddisplay", display );
6411 // Set the display of most of the elements in a second loop
6412 // to avoid the constant reflow
6413 for ( index = 0; index < length; index++ ) {
6414 elem = elements[ index ];
6415 if ( !elem.style ) {
6418 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6419 elem.style.display = show ? values[ index ] || "" : "none";
6427 css: function( name, value ) {
6428 return jQuery.access( this, function( elem, name, value ) {
6429 return value !== undefined ?
6430 jQuery.style( elem, name, value ) :
6431 jQuery.css( elem, name );
6432 }, name, value, arguments.length > 1 );
6435 return showHide( this, true );
6438 return showHide( this );
6440 toggle: function( state, fn2 ) {
6441 var bool = typeof state === "boolean";
6443 if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
6444 return eventsToggle.apply( this, arguments );
6447 return this.each(function() {
6448 if ( bool ? state : isHidden( this ) ) {
6449 jQuery( this ).show();
6451 jQuery( this ).hide();
6458 // Add in style property hooks for overriding the default
6459 // behavior of getting and setting a style property
6462 get: function( elem, computed ) {
6464 // We should always get a number back from opacity
6465 var ret = curCSS( elem, "opacity" );
6466 return ret === "" ? "1" : ret;
6473 // Exclude the following css properties to add px
6475 "fillOpacity": true,
6485 // Add in properties whose names you wish to fix before
6486 // setting or getting the value
6488 // normalize float css property
6489 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6492 // Get and set the style property on a DOM Node
6493 style: function( elem, name, value, extra ) {
6494 // Don't set styles on text and comment nodes
6495 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6499 // Make sure that we're working with the right name
6500 var ret, type, hooks,
6501 origName = jQuery.camelCase( name ),
6504 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6506 // gets hook for the prefixed version
6507 // followed by the unprefixed version
6508 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6510 // Check if we're setting a value
6511 if ( value !== undefined ) {
6512 type = typeof value;
6514 // convert relative number strings (+= or -=) to relative numbers. #7345
6515 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6516 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6521 // Make sure that NaN and null values aren't set. See: #7116
6522 if ( value == null || type === "number" && isNaN( value ) ) {
6526 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6527 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6531 // If a hook was provided, use that value, otherwise just set the specified value
6532 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6533 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6536 style[ name ] = value;
6541 // If a hook was provided get the non-computed value from there
6542 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6546 // Otherwise just get the value from the style object
6547 return style[ name ];
6551 css: function( elem, name, numeric, extra ) {
6552 var val, num, hooks,
6553 origName = jQuery.camelCase( name );
6555 // Make sure that we're working with the right name
6556 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6558 // gets hook for the prefixed version
6559 // followed by the unprefixed version
6560 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6562 // If a hook was provided get the computed value from there
6563 if ( hooks && "get" in hooks ) {
6564 val = hooks.get( elem, true, extra );
6567 // Otherwise, if a way to get the computed value exists, use that
6568 if ( val === undefined ) {
6569 val = curCSS( elem, name );
6572 //convert "normal" to computed value
6573 if ( val === "normal" && name in cssNormalTransform ) {
6574 val = cssNormalTransform[ name ];
6577 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6578 if ( numeric || extra !== undefined ) {
6579 num = parseFloat( val );
6580 return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
6585 // A method for quickly swapping in/out CSS properties to get correct calculations
6586 swap: function( elem, options, callback ) {
6590 // Remember the old values, and insert the new ones
6591 for ( name in options ) {
6592 old[ name ] = elem.style[ name ];
6593 elem.style[ name ] = options[ name ];
6596 ret = callback.call( elem );
6598 // Revert the old values
6599 for ( name in options ) {
6600 elem.style[ name ] = old[ name ];
6607 // NOTE: To any future maintainer, we've used both window.getComputedStyle
6608 // and getComputedStyle here to produce a better gzip size
6609 if ( window.getComputedStyle ) {
6610 curCSS = function( elem, name ) {
6611 var ret, width, minWidth, maxWidth,
6612 computed = getComputedStyle( elem, null ),
6617 ret = computed[ name ];
6618 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
6619 ret = jQuery.style( elem, name );
6622 // A tribute to the "awesome hack by Dean Edwards"
6623 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6624 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6625 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6626 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6627 width = style.width;
6628 minWidth = style.minWidth;
6629 maxWidth = style.maxWidth;
6631 style.minWidth = style.maxWidth = style.width = ret;
6632 ret = computed.width;
6634 style.width = width;
6635 style.minWidth = minWidth;
6636 style.maxWidth = maxWidth;
6642 } else if ( document.documentElement.currentStyle ) {
6643 curCSS = function( elem, name ) {
6645 ret = elem.currentStyle && elem.currentStyle[ name ],
6648 // Avoid setting ret to empty string here
6649 // so we don't default to auto
6650 if ( ret == null && style && style[ name ] ) {
6651 ret = style[ name ];
6654 // From the awesome hack by Dean Edwards
6655 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6657 // If we're not dealing with a regular pixel number
6658 // but a number that has a weird ending, we need to convert it to pixels
6659 // but not position css attributes, as those are proportional to the parent element instead
6660 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6661 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6663 // Remember the original values
6665 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6667 // Put in the new values to get a computed value out
6669 elem.runtimeStyle.left = elem.currentStyle.left;
6671 style.left = name === "fontSize" ? "1em" : ret;
6672 ret = style.pixelLeft + "px";
6674 // Revert the changed values
6677 elem.runtimeStyle.left = rsLeft;
6681 return ret === "" ? "auto" : ret;
6685 function setPositiveNumber( elem, value, subtract ) {
6686 var matches = rnumsplit.exec( value );
6688 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6692 function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
6693 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6694 // If we already have the right measurement, avoid augmentation
6696 // Otherwise initialize for horizontal or vertical properties
6697 name === "width" ? 1 : 0,
6701 for ( ; i < 4; i += 2 ) {
6702 // both box models exclude margin, so add it if we want it
6703 if ( extra === "margin" ) {
6704 // we use jQuery.css instead of curCSS here
6705 // because of the reliableMarginRight CSS hook!
6706 val += jQuery.css( elem, extra + cssExpand[ i ], true );
6709 // From this point on we use curCSS for maximum performance (relevant in animations)
6710 if ( isBorderBox ) {
6711 // border-box includes padding, so remove it if we want content
6712 if ( extra === "content" ) {
6713 val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6716 // at this point, extra isn't border nor margin, so remove border
6717 if ( extra !== "margin" ) {
6718 val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6721 // at this point, extra isn't content, so add padding
6722 val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6724 // at this point, extra isn't content nor padding, so add border
6725 if ( extra !== "padding" ) {
6726 val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6734 function getWidthOrHeight( elem, name, extra ) {
6736 // Start with offset property, which is equivalent to the border-box value
6737 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6738 valueIsBorderBox = true,
6739 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
6742 // Fall back to computed then uncomputed css if necessary
6743 val = curCSS( elem, name );
6744 if ( val < 0 || val == null ) {
6745 val = elem.style[ name ];
6748 // Computed unit is not pixels. Stop here and return.
6749 if ( rnumnonpx.test(val) ) {
6753 // we need the check for style in case a browser which returns unreliable values
6754 // for getComputedStyle silently falls back to the reliable elem.style
6755 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
6757 // Normalize "", auto, and prepare for extra
6758 val = parseFloat( val ) || 0;
6761 // use the active box-sizing model to add/subtract irrelevant styles
6763 augmentWidthOrHeight(
6766 extra || ( isBorderBox ? "border" : "content" ),
6773 // Try to determine the default display value of an element
6774 function css_defaultDisplay( nodeName ) {
6775 if ( elemdisplay[ nodeName ] ) {
6776 return elemdisplay[ nodeName ];
6779 var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
6780 display = elem.css("display");
6783 // If the simple way fails,
6784 // get element's real default display by attaching it to a temp iframe
6785 if ( display === "none" || display === "" ) {
6786 // Use the already-created iframe if possible
6787 iframe = document.body.appendChild(
6788 iframe || jQuery.extend( document.createElement("iframe"), {
6795 // Create a cacheable copy of the iframe document on first call.
6796 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
6797 // document to it; WebKit & Firefox won't allow reusing the iframe document.
6798 if ( !iframeDoc || !iframe.createElement ) {
6799 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
6800 iframeDoc.write("<!doctype html><html><body>");
6804 elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
6806 display = curCSS( elem, "display" );
6807 document.body.removeChild( iframe );
6810 // Store the correct default display
6811 elemdisplay[ nodeName ] = display;
6816 jQuery.each([ "height", "width" ], function( i, name ) {
6817 jQuery.cssHooks[ name ] = {
6818 get: function( elem, computed, extra ) {
6820 if ( elem.offsetWidth !== 0 || curCSS( elem, "display" ) !== "none" ) {
6821 return getWidthOrHeight( elem, name, extra );
6823 return jQuery.swap( elem, cssShow, function() {
6824 return getWidthOrHeight( elem, name, extra );
6830 set: function( elem, value, extra ) {
6831 return setPositiveNumber( elem, value, extra ?
6832 augmentWidthOrHeight(
6836 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
6843 if ( !jQuery.support.opacity ) {
6844 jQuery.cssHooks.opacity = {
6845 get: function( elem, computed ) {
6846 // IE uses filters for opacity
6847 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
6848 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
6849 computed ? "1" : "";
6852 set: function( elem, value ) {
6853 var style = elem.style,
6854 currentStyle = elem.currentStyle,
6855 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
6856 filter = currentStyle && currentStyle.filter || style.filter || "";
6858 // IE has trouble with opacity if it does not have layout
6859 // Force it by setting the zoom level
6862 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
6863 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
6864 style.removeAttribute ) {
6866 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
6867 // if "filter:" is present at all, clearType is disabled, we want to avoid this
6868 // style.removeAttribute is IE Only, but so apparently is this code path...
6869 style.removeAttribute( "filter" );
6871 // if there there is no filter style applied in a css rule, we are done
6872 if ( currentStyle && !currentStyle.filter ) {
6877 // otherwise, set new filter values
6878 style.filter = ralpha.test( filter ) ?
6879 filter.replace( ralpha, opacity ) :
6880 filter + " " + opacity;
6885 // These hooks cannot be added until DOM ready because the support test
6886 // for it is not run until after DOM ready
6888 if ( !jQuery.support.reliableMarginRight ) {
6889 jQuery.cssHooks.marginRight = {
6890 get: function( elem, computed ) {
6891 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
6892 // Work around by temporarily setting element display to inline-block
6893 return jQuery.swap( elem, { "display": "inline-block" }, function() {
6895 return curCSS( elem, "marginRight" );
6902 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
6903 // getComputedStyle returns percent when specified for top/left/bottom/right
6904 // rather than make the css module depend on the offset module, we just check for it here
6905 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
6906 jQuery.each( [ "top", "left" ], function( i, prop ) {
6907 jQuery.cssHooks[ prop ] = {
6908 get: function( elem, computed ) {
6910 var ret = curCSS( elem, prop );
6911 // if curCSS returns percentage, fallback to offset
6912 return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
6921 if ( jQuery.expr && jQuery.expr.filters ) {
6922 jQuery.expr.filters.hidden = function( elem ) {
6923 return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
6926 jQuery.expr.filters.visible = function( elem ) {
6927 return !jQuery.expr.filters.hidden( elem );
6931 // These hooks are used by animate to expand properties
6936 }, function( prefix, suffix ) {
6937 jQuery.cssHooks[ prefix + suffix ] = {
6938 expand: function( value ) {
6941 // assumes a single number if not a string
6942 parts = typeof value === "string" ? value.split(" ") : [ value ],
6945 for ( i = 0; i < 4; i++ ) {
6946 expanded[ prefix + cssExpand[ i ] + suffix ] =
6947 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
6954 if ( !rmargin.test( prefix ) ) {
6955 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
6961 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
6962 rselectTextarea = /^(?:select|textarea)/i;
6965 serialize: function() {
6966 return jQuery.param( this.serializeArray() );
6968 serializeArray: function() {
6969 return this.map(function(){
6970 return this.elements ? jQuery.makeArray( this.elements ) : this;
6973 return this.name && !this.disabled &&
6974 ( this.checked || rselectTextarea.test( this.nodeName ) ||
6975 rinput.test( this.type ) );
6977 .map(function( i, elem ){
6978 var val = jQuery( this ).val();
6980 return val == null ?
6982 jQuery.isArray( val ) ?
6983 jQuery.map( val, function( val, i ){
6984 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6986 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6991 //Serialize an array of form elements or a set of
6992 //key/values into a query string
6993 jQuery.param = function( a, traditional ) {
6996 add = function( key, value ) {
6997 // If value is a function, invoke it and return its value
6998 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
6999 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7002 // Set traditional to true for jQuery <= 1.3.2 behavior.
7003 if ( traditional === undefined ) {
7004 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7007 // If an array was passed in, assume that it is an array of form elements.
7008 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7009 // Serialize the form elements
7010 jQuery.each( a, function() {
7011 add( this.name, this.value );
7015 // If traditional, encode the "old" way (the way 1.3.2 or older
7016 // did it), otherwise encode params recursively.
7017 for ( prefix in a ) {
7018 buildParams( prefix, a[ prefix ], traditional, add );
7022 // Return the resulting serialization
7023 return s.join( "&" ).replace( r20, "+" );
7026 function buildParams( prefix, obj, traditional, add ) {
7029 if ( jQuery.isArray( obj ) ) {
7030 // Serialize array item.
7031 jQuery.each( obj, function( i, v ) {
7032 if ( traditional || rbracket.test( prefix ) ) {
7033 // Treat each array item as a scalar.
7037 // If array item is non-scalar (array or object), encode its
7038 // numeric index to resolve deserialization ambiguity issues.
7039 // Note that rack (as of 1.0.0) can't currently deserialize
7040 // nested arrays properly, and attempting to do so may cause
7041 // a server error. Possible fixes are to modify rack's
7042 // deserialization algorithm or to provide an option or flag
7043 // to force array serialization to be shallow.
7044 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7048 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
7049 // Serialize object item.
7050 for ( name in obj ) {
7051 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7055 // Serialize scalar item.
7059 var // Document location
7061 // Document location segments
7065 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7066 // #7653, #8125, #8152: local protocol detection
7067 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
7068 rnoContent = /^(?:GET|HEAD)$/,
7069 rprotocol = /^\/\//,
7071 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
7072 rts = /([?&])_=[^&]*/,
7073 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7075 // Keep a copy of the old load method
7076 _load = jQuery.fn.load,
7079 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7080 * 2) These are called:
7081 * - BEFORE asking for a transport
7082 * - AFTER param serialization (s.data is a string if s.processData is true)
7083 * 3) key is the dataType
7084 * 4) the catchall symbol "*" can be used
7085 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7089 /* Transports bindings
7090 * 1) key is the dataType
7091 * 2) the catchall symbol "*" can be used
7092 * 3) selection will start with transport dataType and THEN go to "*" if needed
7096 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7097 allTypes = ["*/"] + ["*"];
7099 // #8138, IE may throw an exception when accessing
7100 // a field from window.location if document.domain has been set
7102 ajaxLocation = location.href;
7104 // Use the href attribute of an A element
7105 // since IE will modify it given document.location
7106 ajaxLocation = document.createElement( "a" );
7107 ajaxLocation.href = "";
7108 ajaxLocation = ajaxLocation.href;
7111 // Segment location into parts
7112 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7114 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7115 function addToPrefiltersOrTransports( structure ) {
7117 // dataTypeExpression is optional and defaults to "*"
7118 return function( dataTypeExpression, func ) {
7120 if ( typeof dataTypeExpression !== "string" ) {
7121 func = dataTypeExpression;
7122 dataTypeExpression = "*";
7125 var dataType, list, placeBefore,
7126 dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
7128 length = dataTypes.length;
7130 if ( jQuery.isFunction( func ) ) {
7131 // For each dataType in the dataTypeExpression
7132 for ( ; i < length; i++ ) {
7133 dataType = dataTypes[ i ];
7134 // We control if we're asked to add before
7135 // any existing element
7136 placeBefore = /^\+/.test( dataType );
7137 if ( placeBefore ) {
7138 dataType = dataType.substr( 1 ) || "*";
7140 list = structure[ dataType ] = structure[ dataType ] || [];
7141 // then we add to the structure accordingly
7142 list[ placeBefore ? "unshift" : "push" ]( func );
7148 // Base inspection function for prefilters and transports
7149 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
7150 dataType /* internal */, inspected /* internal */ ) {
7152 dataType = dataType || options.dataTypes[ 0 ];
7153 inspected = inspected || {};
7155 inspected[ dataType ] = true;
7158 list = structure[ dataType ],
7160 length = list ? list.length : 0,
7161 executeOnly = ( structure === prefilters );
7163 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
7164 selection = list[ i ]( options, originalOptions, jqXHR );
7165 // If we got redirected to another dataType
7166 // we try there if executing only and not done already
7167 if ( typeof selection === "string" ) {
7168 if ( !executeOnly || inspected[ selection ] ) {
7169 selection = undefined;
7171 options.dataTypes.unshift( selection );
7172 selection = inspectPrefiltersOrTransports(
7173 structure, options, originalOptions, jqXHR, selection, inspected );
7177 // If we're only executing or nothing was selected
7178 // we try the catchall dataType if not done already
7179 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
7180 selection = inspectPrefiltersOrTransports(
7181 structure, options, originalOptions, jqXHR, "*", inspected );
7183 // unnecessary when only executing (prefilters)
7184 // but it'll be ignored by the caller in that case
7188 // A special extend for ajax options
7189 // that takes "flat" options (not to be deep extended)
7191 function ajaxExtend( target, src ) {
7193 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7194 for ( key in src ) {
7195 if ( src[ key ] !== undefined ) {
7196 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
7200 jQuery.extend( true, target, deep );
7204 jQuery.fn.load = function( url, params, callback ) {
7205 if ( typeof url !== "string" && _load ) {
7206 return _load.apply( this, arguments );
7209 // Don't do a request if no elements are being requested
7210 if ( !this.length ) {
7214 var selector, type, response,
7216 off = url.indexOf(" ");
7219 selector = url.slice( off, url.length );
7220 url = url.slice( 0, off );
7223 // If it's a function
7224 if ( jQuery.isFunction( params ) ) {
7226 // We assume that it's the callback
7230 // Otherwise, build a param string
7231 } else if ( typeof params === "object" ) {
7235 // Request the remote document
7239 // if "type" variable is undefined, then "GET" method will be used
7243 complete: function( jqXHR, status ) {
7245 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7248 }).done(function( responseText ) {
7250 // Save response for use in complete callback
7251 response = arguments;
7253 // See if a selector was specified
7254 self.html( selector ?
7256 // Create a dummy div to hold the results
7259 // inject the contents of the document in, removing the scripts
7260 // to avoid any 'Permission Denied' errors in IE
7261 .append( responseText.replace( rscript, "" ) )
7263 // Locate the specified elements
7266 // If not, just inject the full result
7274 // Attach a bunch of functions for handling common AJAX events
7275 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
7276 jQuery.fn[ o ] = function( f ){
7277 return this.on( o, f );
7281 jQuery.each( [ "get", "post" ], function( i, method ) {
7282 jQuery[ method ] = function( url, data, callback, type ) {
7283 // shift arguments if data argument was omitted
7284 if ( jQuery.isFunction( data ) ) {
7285 type = type || callback;
7290 return jQuery.ajax({
7302 getScript: function( url, callback ) {
7303 return jQuery.get( url, undefined, callback, "script" );
7306 getJSON: function( url, data, callback ) {
7307 return jQuery.get( url, data, callback, "json" );
7310 // Creates a full fledged settings object into target
7311 // with both ajaxSettings and settings fields.
7312 // If target is omitted, writes into ajaxSettings.
7313 ajaxSetup: function( target, settings ) {
7315 // Building a settings object
7316 ajaxExtend( target, jQuery.ajaxSettings );
7318 // Extending ajaxSettings
7320 target = jQuery.ajaxSettings;
7322 ajaxExtend( target, settings );
7328 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7331 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7347 xml: "application/xml, text/xml",
7350 json: "application/json, text/javascript",
7362 text: "responseText"
7365 // List of data converters
7366 // 1) key format is "source_type destination_type" (a single space in-between)
7367 // 2) the catchall symbol "*" can be used for source_type
7370 // Convert anything to text
7371 "* text": window.String,
7373 // Text to html (true = no transformation)
7376 // Evaluate text as a json expression
7377 "text json": jQuery.parseJSON,
7379 // Parse text as xml
7380 "text xml": jQuery.parseXML
7383 // For options that shouldn't be deep extended:
7384 // you can add your own custom options here if
7385 // and when you create one that shouldn't be
7386 // deep extended (see ajaxExtend)
7393 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7394 ajaxTransport: addToPrefiltersOrTransports( transports ),
7397 ajax: function( url, options ) {
7399 // If url is an object, simulate pre-1.5 signature
7400 if ( typeof url === "object" ) {
7405 // Force options to be an object
7406 options = options || {};
7408 var // ifModified key
7411 responseHeadersString,
7417 // Cross-domain detection vars
7419 // To know if global events are to be dispatched
7423 // Create the final options object
7424 s = jQuery.ajaxSetup( {}, options ),
7425 // Callbacks context
7426 callbackContext = s.context || s,
7427 // Context for global events
7428 // It's the callbackContext if one was provided in the options
7429 // and if it's a DOM node or a jQuery collection
7430 globalEventContext = callbackContext !== s &&
7431 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7432 jQuery( callbackContext ) : jQuery.event,
7434 deferred = jQuery.Deferred(),
7435 completeDeferred = jQuery.Callbacks( "once memory" ),
7436 // Status-dependent callbacks
7437 statusCode = s.statusCode || {},
7438 // Headers (they are sent all at once)
7439 requestHeaders = {},
7440 requestHeadersNames = {},
7443 // Default abort message
7444 strAbort = "canceled",
7450 // Caches the header
7451 setRequestHeader: function( name, value ) {
7453 var lname = name.toLowerCase();
7454 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7455 requestHeaders[ name ] = value;
7461 getAllResponseHeaders: function() {
7462 return state === 2 ? responseHeadersString : null;
7465 // Builds headers hashtable if needed
7466 getResponseHeader: function( key ) {
7468 if ( state === 2 ) {
7469 if ( !responseHeaders ) {
7470 responseHeaders = {};
7471 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7472 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7475 match = responseHeaders[ key.toLowerCase() ];
7477 return match === undefined ? null : match;
7480 // Overrides response content-type header
7481 overrideMimeType: function( type ) {
7488 // Cancel the request
7489 abort: function( statusText ) {
7490 statusText = statusText || strAbort;
7492 transport.abort( statusText );
7494 done( 0, statusText );
7499 // Callback for when everything is done
7500 // It is defined here because jslint complains if it is declared
7501 // at the end of the function (which would be more logical and readable)
7502 function done( status, nativeStatusText, responses, headers ) {
7503 var isSuccess, success, error, response, modified,
7504 statusText = nativeStatusText;
7507 if ( state === 2 ) {
7511 // State is "done" now
7514 // Clear timeout if it exists
7515 if ( timeoutTimer ) {
7516 clearTimeout( timeoutTimer );
7519 // Dereference transport for early garbage collection
7520 // (no matter how long the jqXHR object will be used)
7521 transport = undefined;
7523 // Cache response headers
7524 responseHeadersString = headers || "";
7527 jqXHR.readyState = status > 0 ? 4 : 0;
7529 // Get response data
7531 response = ajaxHandleResponses( s, jqXHR, responses );
7534 // If successful, handle type chaining
7535 if ( status >= 200 && status < 300 || status === 304 ) {
7537 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7538 if ( s.ifModified ) {
7540 modified = jqXHR.getResponseHeader("Last-Modified");
7542 jQuery.lastModified[ ifModifiedKey ] = modified;
7544 modified = jqXHR.getResponseHeader("Etag");
7546 jQuery.etag[ ifModifiedKey ] = modified;
7551 if ( status === 304 ) {
7553 statusText = "notmodified";
7559 isSuccess = ajaxConvert( s, response );
7560 statusText = isSuccess.state;
7561 success = isSuccess.data;
7562 error = isSuccess.error;
7566 // We extract error from statusText
7567 // then normalize statusText and status for non-aborts
7569 if ( !statusText || status ) {
7570 statusText = "error";
7577 // Set data for the fake xhr object
7578 jqXHR.status = status;
7579 jqXHR.statusText = "" + ( nativeStatusText || statusText );
7583 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7585 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7588 // Status-dependent callbacks
7589 jqXHR.statusCode( statusCode );
7590 statusCode = undefined;
7592 if ( fireGlobals ) {
7593 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7594 [ jqXHR, s, isSuccess ? success : error ] );
7598 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7600 if ( fireGlobals ) {
7601 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7602 // Handle the global AJAX counter
7603 if ( !( --jQuery.active ) ) {
7604 jQuery.event.trigger( "ajaxStop" );
7610 deferred.promise( jqXHR );
7611 jqXHR.success = jqXHR.done;
7612 jqXHR.error = jqXHR.fail;
7613 jqXHR.complete = completeDeferred.add;
7615 // Status-dependent callbacks
7616 jqXHR.statusCode = function( map ) {
7620 for ( tmp in map ) {
7621 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7624 tmp = map[ jqXHR.status ];
7625 jqXHR.always( tmp );
7631 // Remove hash character (#7531: and string promotion)
7632 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7633 // We also use the url parameter if available
7634 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7636 // Extract dataTypes list
7637 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
7639 // Determine if a cross-domain request is in order
7640 if ( s.crossDomain == null ) {
7641 parts = rurl.exec( s.url.toLowerCase() );
7642 s.crossDomain = !!( parts &&
7643 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
7644 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
7645 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
7649 // Convert data if not already a string
7650 if ( s.data && s.processData && typeof s.data !== "string" ) {
7651 s.data = jQuery.param( s.data, s.traditional );
7655 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7657 // If request was aborted inside a prefilter, stop there
7658 if ( state === 2 ) {
7662 // We can fire global events as of now if asked to
7663 fireGlobals = s.global;
7665 // Uppercase the type
7666 s.type = s.type.toUpperCase();
7668 // Determine if request has content
7669 s.hasContent = !rnoContent.test( s.type );
7671 // Watch for a new set of requests
7672 if ( fireGlobals && jQuery.active++ === 0 ) {
7673 jQuery.event.trigger( "ajaxStart" );
7676 // More options handling for requests with no content
7677 if ( !s.hasContent ) {
7679 // If data is available, append data to url
7681 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7682 // #9682: remove data so that it's not used in an eventual retry
7686 // Get ifModifiedKey before adding the anti-cache parameter
7687 ifModifiedKey = s.url;
7689 // Add anti-cache in url if needed
7690 if ( s.cache === false ) {
7692 var ts = jQuery.now(),
7693 // try replacing _= if it is there
7694 ret = s.url.replace( rts, "$1_=" + ts );
7696 // if nothing was replaced, add timestamp to the end
7697 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7701 // Set the correct header, if data is being sent
7702 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7703 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7706 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7707 if ( s.ifModified ) {
7708 ifModifiedKey = ifModifiedKey || s.url;
7709 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7710 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7712 if ( jQuery.etag[ ifModifiedKey ] ) {
7713 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7717 // Set the Accepts header for the server, depending on the dataType
7718 jqXHR.setRequestHeader(
7720 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7721 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7725 // Check for headers option
7726 for ( i in s.headers ) {
7727 jqXHR.setRequestHeader( i, s.headers[ i ] );
7730 // Allow custom headers/mimetypes and early abort
7731 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7732 // Abort if not done already and return
7733 return jqXHR.abort();
7737 // aborting is no longer a cancellation
7740 // Install callbacks on deferreds
7741 for ( i in { success: 1, error: 1, complete: 1 } ) {
7742 jqXHR[ i ]( s[ i ] );
7746 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7748 // If no transport, we auto-abort
7750 done( -1, "No Transport" );
7752 jqXHR.readyState = 1;
7753 // Send global event
7754 if ( fireGlobals ) {
7755 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7758 if ( s.async && s.timeout > 0 ) {
7759 timeoutTimer = setTimeout( function(){
7760 jqXHR.abort( "timeout" );
7766 transport.send( requestHeaders, done );
7768 // Propagate exception as error if not done
7771 // Simply rethrow otherwise
7781 // Counter for holding the number of active queries
7784 // Last-Modified header cache for next request
7790 /* Handles responses to an ajax request:
7791 * - sets all responseXXX fields accordingly
7792 * - finds the right dataType (mediates between content-type and expected dataType)
7793 * - returns the corresponding response
7795 function ajaxHandleResponses( s, jqXHR, responses ) {
7797 var ct, type, finalDataType, firstDataType,
7798 contents = s.contents,
7799 dataTypes = s.dataTypes,
7800 responseFields = s.responseFields;
7802 // Fill responseXXX fields
7803 for ( type in responseFields ) {
7804 if ( type in responses ) {
7805 jqXHR[ responseFields[type] ] = responses[ type ];
7809 // Remove auto dataType and get content-type in the process
7810 while( dataTypes[ 0 ] === "*" ) {
7812 if ( ct === undefined ) {
7813 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
7817 // Check if we're dealing with a known content-type
7819 for ( type in contents ) {
7820 if ( contents[ type ] && contents[ type ].test( ct ) ) {
7821 dataTypes.unshift( type );
7827 // Check to see if we have a response for the expected dataType
7828 if ( dataTypes[ 0 ] in responses ) {
7829 finalDataType = dataTypes[ 0 ];
7831 // Try convertible dataTypes
7832 for ( type in responses ) {
7833 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
7834 finalDataType = type;
7837 if ( !firstDataType ) {
7838 firstDataType = type;
7841 // Or just use first one
7842 finalDataType = finalDataType || firstDataType;
7845 // If we found a dataType
7846 // We add the dataType to the list if needed
7847 // and return the corresponding response
7848 if ( finalDataType ) {
7849 if ( finalDataType !== dataTypes[ 0 ] ) {
7850 dataTypes.unshift( finalDataType );
7852 return responses[ finalDataType ];
7856 // Chain conversions given the request and the original response
7857 function ajaxConvert( s, response ) {
7859 var conv, conv2, current, tmp,
7860 // Work with a copy of dataTypes in case we need to modify it for conversion
7861 dataTypes = s.dataTypes.slice(),
7862 prev = dataTypes[ 0 ],
7866 // Apply the dataFilter if provided
7867 if ( s.dataFilter ) {
7868 response = s.dataFilter( response, s.dataType );
7871 // Create converters map with lowercased keys
7872 if ( dataTypes[ 1 ] ) {
7873 for ( conv in s.converters ) {
7874 converters[ conv.toLowerCase() ] = s.converters[ conv ];
7878 // Convert to each sequential dataType, tolerating list modification
7879 for ( ; (current = dataTypes[++i]); ) {
7881 // There's only work to do if current dataType is non-auto
7882 if ( current !== "*" ) {
7884 // Convert response if prev dataType is non-auto and differs from current
7885 if ( prev !== "*" && prev !== current ) {
7887 // Seek a direct converter
7888 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
7890 // If none found, seek a pair
7892 for ( conv2 in converters ) {
7894 // If conv2 outputs current
7895 tmp = conv2.split(" ");
7896 if ( tmp[ 1 ] === current ) {
7898 // If prev can be converted to accepted input
7899 conv = converters[ prev + " " + tmp[ 0 ] ] ||
7900 converters[ "* " + tmp[ 0 ] ];
7902 // Condense equivalence converters
7903 if ( conv === true ) {
7904 conv = converters[ conv2 ];
7906 // Otherwise, insert the intermediate dataType
7907 } else if ( converters[ conv2 ] !== true ) {
7909 dataTypes.splice( i--, 0, current );
7918 // Apply converter (if not an equivalence)
7919 if ( conv !== true ) {
7921 // Unless errors are allowed to bubble, catch and return them
7922 if ( conv && s["throws"] ) {
7923 response = conv( response );
7926 response = conv( response );
7928 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
7934 // Update prev for next iteration
7939 return { state: "success", data: response };
7941 var oldCallbacks = [],
7943 rjsonp = /(=)\?(?=&|$)|\?\?/,
7944 nonce = jQuery.now();
7946 // Default jsonp settings
7949 jsonpCallback: function() {
7950 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
7951 this[ callback ] = true;
7956 // Detect, normalize options and install callbacks for jsonp requests
7957 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
7959 var callbackName, overwritten, responseContainer,
7962 hasCallback = s.jsonp !== false,
7963 replaceInUrl = hasCallback && rjsonp.test( url ),
7964 replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
7965 !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
7966 rjsonp.test( data );
7968 // Handle iff the expected data type is "jsonp" or we have a parameter to set
7969 if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
7971 // Get callback name, remembering preexisting value associated with it
7972 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
7975 overwritten = window[ callbackName ];
7977 // Insert callback into url or form data
7978 if ( replaceInUrl ) {
7979 s.url = url.replace( rjsonp, "$1" + callbackName );
7980 } else if ( replaceInData ) {
7981 s.data = data.replace( rjsonp, "$1" + callbackName );
7982 } else if ( hasCallback ) {
7983 s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
7986 // Use data converter to retrieve json after script execution
7987 s.converters["script json"] = function() {
7988 if ( !responseContainer ) {
7989 jQuery.error( callbackName + " was not called" );
7991 return responseContainer[ 0 ];
7994 // force json dataType
7995 s.dataTypes[ 0 ] = "json";
7998 window[ callbackName ] = function() {
7999 responseContainer = arguments;
8002 // Clean-up function (fires after converters)
8003 jqXHR.always(function() {
8004 // Restore preexisting value
8005 window[ callbackName ] = overwritten;
8007 // Save back as free
8008 if ( s[ callbackName ] ) {
8009 // make sure that re-using the options doesn't screw things around
8010 s.jsonpCallback = originalSettings.jsonpCallback;
8012 // save the callback name for future use
8013 oldCallbacks.push( callbackName );
8016 // Call if it was a function and we have a response
8017 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8018 overwritten( responseContainer[ 0 ] );
8021 responseContainer = overwritten = undefined;
8024 // Delegate to script
8028 // Install script dataType
8031 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8034 script: /javascript|ecmascript/
8037 "text script": function( text ) {
8038 jQuery.globalEval( text );
8044 // Handle cache's special case and global
8045 jQuery.ajaxPrefilter( "script", function( s ) {
8046 if ( s.cache === undefined ) {
8049 if ( s.crossDomain ) {
8055 // Bind script tag hack transport
8056 jQuery.ajaxTransport( "script", function(s) {
8058 // This transport only deals with cross domain requests
8059 if ( s.crossDomain ) {
8062 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
8066 send: function( _, callback ) {
8068 script = document.createElement( "script" );
8070 script.async = "async";
8072 if ( s.scriptCharset ) {
8073 script.charset = s.scriptCharset;
8078 // Attach handlers for all browsers
8079 script.onload = script.onreadystatechange = function( _, isAbort ) {
8081 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8083 // Handle memory leak in IE
8084 script.onload = script.onreadystatechange = null;
8086 // Remove the script
8087 if ( head && script.parentNode ) {
8088 head.removeChild( script );
8091 // Dereference the script
8094 // Callback if not abort
8096 callback( 200, "success" );
8100 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
8101 // This arises when a base node is used (#2709 and #4378).
8102 head.insertBefore( script, head.firstChild );
8107 script.onload( 0, 1 );
8114 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8115 xhrOnUnloadAbort = window.ActiveXObject ? function() {
8116 // Abort all pending requests
8117 for ( var key in xhrCallbacks ) {
8118 xhrCallbacks[ key ]( 0, 1 );
8123 // Functions to create xhrs
8124 function createStandardXHR() {
8126 return new window.XMLHttpRequest();
8130 function createActiveXHR() {
8132 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
8136 // Create the request object
8137 // (This is still attached to ajaxSettings for backward compatibility)
8138 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8139 /* Microsoft failed to properly
8140 * implement the XMLHttpRequest in IE7 (can't request local files),
8141 * so we use the ActiveXObject when it is available
8142 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8143 * we need a fallback.
8146 return !this.isLocal && createStandardXHR() || createActiveXHR();
8148 // For all other browsers, use the standard XMLHttpRequest object
8151 // Determine support properties
8153 jQuery.extend( jQuery.support, {
8155 cors: !!xhr && ( "withCredentials" in xhr )
8157 })( jQuery.ajaxSettings.xhr() );
8159 // Create transport if the browser can provide an xhr
8160 if ( jQuery.support.ajax ) {
8162 jQuery.ajaxTransport(function( s ) {
8163 // Cross domain only allowed if supported through XMLHttpRequest
8164 if ( !s.crossDomain || jQuery.support.cors ) {
8169 send: function( headers, complete ) {
8176 // Passing null username, generates a login popup on Opera (#2865)
8178 xhr.open( s.type, s.url, s.async, s.username, s.password );
8180 xhr.open( s.type, s.url, s.async );
8183 // Apply custom fields if provided
8184 if ( s.xhrFields ) {
8185 for ( i in s.xhrFields ) {
8186 xhr[ i ] = s.xhrFields[ i ];
8190 // Override mime type if needed
8191 if ( s.mimeType && xhr.overrideMimeType ) {
8192 xhr.overrideMimeType( s.mimeType );
8195 // X-Requested-With header
8196 // For cross-domain requests, seeing as conditions for a preflight are
8197 // akin to a jigsaw puzzle, we simply never set it to be sure.
8198 // (it can always be set on a per-request basis or even using ajaxSetup)
8199 // For same-domain requests, won't change header if already provided.
8200 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8201 headers[ "X-Requested-With" ] = "XMLHttpRequest";
8204 // Need an extra try/catch for cross domain requests in Firefox 3
8206 for ( i in headers ) {
8207 xhr.setRequestHeader( i, headers[ i ] );
8211 // Do send the request
8212 // This may raise an exception which is actually
8213 // handled in jQuery.ajax (so no try/catch here)
8214 xhr.send( ( s.hasContent && s.data ) || null );
8217 callback = function( _, isAbort ) {
8225 // Firefox throws exceptions when accessing properties
8226 // of an xhr when a network error occurred
8227 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8230 // Was never called and is aborted or complete
8231 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8234 callback = undefined;
8236 // Do not keep as active anymore
8238 xhr.onreadystatechange = jQuery.noop;
8239 if ( xhrOnUnloadAbort ) {
8240 delete xhrCallbacks[ handle ];
8246 // Abort it manually if needed
8247 if ( xhr.readyState !== 4 ) {
8251 status = xhr.status;
8252 responseHeaders = xhr.getAllResponseHeaders();
8254 xml = xhr.responseXML;
8256 // Construct response list
8257 if ( xml && xml.documentElement /* #4958 */ ) {
8258 responses.xml = xml;
8261 // When requesting binary data, IE6-9 will throw an exception
8262 // on any attempt to access responseText (#11426)
8264 responses.text = xhr.responseText;
8268 // Firefox throws an exception when accessing
8269 // statusText for faulty cross-domain requests
8271 statusText = xhr.statusText;
8273 // We normalize with Webkit giving an empty statusText
8277 // Filter status for non standard behaviors
8279 // If the request is local and we have data: assume a success
8280 // (success with no data won't get notified, that's the best we
8281 // can do given current implementations)
8282 if ( !status && s.isLocal && !s.crossDomain ) {
8283 status = responses.text ? 200 : 404;
8284 // IE - #1450: sometimes returns 1223 when it should be 204
8285 } else if ( status === 1223 ) {
8290 } catch( firefoxAccessException ) {
8292 complete( -1, firefoxAccessException );
8296 // Call complete if needed
8298 complete( status, statusText, responses, responseHeaders );
8303 // if we're in sync mode we fire the callback
8305 } else if ( xhr.readyState === 4 ) {
8306 // (IE6 & IE7) if it's in cache and has been
8307 // retrieved directly we need to fire the callback
8308 setTimeout( callback, 0 );
8311 if ( xhrOnUnloadAbort ) {
8312 // Create the active xhrs callbacks list if needed
8313 // and attach the unload handler
8314 if ( !xhrCallbacks ) {
8316 jQuery( window ).unload( xhrOnUnloadAbort );
8318 // Add to list of active xhrs callbacks
8319 xhrCallbacks[ handle ] = callback;
8321 xhr.onreadystatechange = callback;
8335 rfxtypes = /^(?:toggle|show|hide)$/,
8336 rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8337 rrun = /queueHooks$/,
8338 animationPrefilters = [ defaultPrefilter ],
8340 "*": [function( prop, value ) {
8341 var end, unit, prevScale,
8342 tween = this.createTween( prop, value ),
8343 parts = rfxnum.exec( value ),
8344 target = tween.cur(),
8345 start = +target || 0,
8350 unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8352 // We need to compute starting value
8353 if ( unit !== "px" && start ) {
8354 // Iteratively approximate from a nonzero starting point
8355 // Prefer the current property, because this process will be trivial if it uses the same units
8356 // Fallback to end or a simple constant
8357 start = jQuery.css( tween.elem, prop, true ) || end || 1;
8360 // If previous iteration zeroed out, double until we get *something*
8361 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8362 prevScale = scale = scale || ".5";
8365 start = start / scale;
8366 jQuery.style( tween.elem, prop, start + unit );
8368 // Update scale, tolerating zeroes from tween.cur()
8369 scale = tween.cur() / target;
8371 // Stop looping if we've hit the mark or scale is unchanged
8372 } while ( scale !== 1 && scale !== prevScale );
8376 tween.start = start;
8377 // If a +=/-= token was provided, we're doing a relative animation
8378 tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
8384 // Animations created synchronously will run synchronously
8385 function createFxNow() {
8386 setTimeout(function() {
8389 return ( fxNow = jQuery.now() );
8392 function createTweens( animation, props ) {
8393 jQuery.each( props, function( prop, value ) {
8394 var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8396 length = collection.length;
8397 for ( ; index < length; index++ ) {
8398 if ( collection[ index ].call( animation, prop, value ) ) {
8400 // we're done with this property
8407 function Animation( elem, properties, options ) {
8411 length = animationPrefilters.length,
8412 deferred = jQuery.Deferred().always( function() {
8413 // don't match elem in the :animated selector
8417 var currentTime = fxNow || createFxNow(),
8418 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8419 percent = 1 - ( remaining / animation.duration || 0 ),
8421 length = animation.tweens.length;
8423 for ( ; index < length ; index++ ) {
8424 animation.tweens[ index ].run( percent );
8427 deferred.notifyWith( elem, [ animation, percent, remaining ]);
8429 if ( percent < 1 && length ) {
8432 deferred.resolveWith( elem, [ animation ] );
8436 animation = deferred.promise({
8438 props: jQuery.extend( {}, properties ),
8439 opts: jQuery.extend( true, { specialEasing: {} }, options ),
8440 originalProperties: properties,
8441 originalOptions: options,
8442 startTime: fxNow || createFxNow(),
8443 duration: options.duration,
8445 createTween: function( prop, end, easing ) {
8446 var tween = jQuery.Tween( elem, animation.opts, prop, end,
8447 animation.opts.specialEasing[ prop ] || animation.opts.easing );
8448 animation.tweens.push( tween );
8451 stop: function( gotoEnd ) {
8453 // if we are going to the end, we want to run all the tweens
8454 // otherwise we skip this part
8455 length = gotoEnd ? animation.tweens.length : 0;
8457 for ( ; index < length ; index++ ) {
8458 animation.tweens[ index ].run( 1 );
8461 // resolve when we played the last frame
8462 // otherwise, reject
8464 deferred.resolveWith( elem, [ animation, gotoEnd ] );
8466 deferred.rejectWith( elem, [ animation, gotoEnd ] );
8471 props = animation.props;
8473 propFilter( props, animation.opts.specialEasing );
8475 for ( ; index < length ; index++ ) {
8476 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8482 createTweens( animation, props );
8484 if ( jQuery.isFunction( animation.opts.start ) ) {
8485 animation.opts.start.call( elem, animation );
8489 jQuery.extend( tick, {
8491 queue: animation.opts.queue,
8496 // attach callbacks from options
8497 return animation.progress( animation.opts.progress )
8498 .done( animation.opts.done, animation.opts.complete )
8499 .fail( animation.opts.fail )
8500 .always( animation.opts.always );
8503 function propFilter( props, specialEasing ) {
8504 var index, name, easing, value, hooks;
8506 // camelCase, specialEasing and expand cssHook pass
8507 for ( index in props ) {
8508 name = jQuery.camelCase( index );
8509 easing = specialEasing[ name ];
8510 value = props[ index ];
8511 if ( jQuery.isArray( value ) ) {
8512 easing = value[ 1 ];
8513 value = props[ index ] = value[ 0 ];
8516 if ( index !== name ) {
8517 props[ name ] = value;
8518 delete props[ index ];
8521 hooks = jQuery.cssHooks[ name ];
8522 if ( hooks && "expand" in hooks ) {
8523 value = hooks.expand( value );
8524 delete props[ name ];
8526 // not quite $.extend, this wont overwrite keys already present.
8527 // also - reusing 'index' from above because we have the correct "name"
8528 for ( index in value ) {
8529 if ( !( index in props ) ) {
8530 props[ index ] = value[ index ];
8531 specialEasing[ index ] = easing;
8535 specialEasing[ name ] = easing;
8540 jQuery.Animation = jQuery.extend( Animation, {
8542 tweener: function( props, callback ) {
8543 if ( jQuery.isFunction( props ) ) {
8547 props = props.split(" ");
8552 length = props.length;
8554 for ( ; index < length ; index++ ) {
8555 prop = props[ index ];
8556 tweeners[ prop ] = tweeners[ prop ] || [];
8557 tweeners[ prop ].unshift( callback );
8561 prefilter: function( callback, prepend ) {
8563 animationPrefilters.unshift( callback );
8565 animationPrefilters.push( callback );
8570 function defaultPrefilter( elem, props, opts ) {
8571 var index, prop, value, length, dataShow, tween, hooks, oldfire,
8576 hidden = elem.nodeType && isHidden( elem );
8578 // handle queue: false promises
8579 if ( !opts.queue ) {
8580 hooks = jQuery._queueHooks( elem, "fx" );
8581 if ( hooks.unqueued == null ) {
8583 oldfire = hooks.empty.fire;
8584 hooks.empty.fire = function() {
8585 if ( !hooks.unqueued ) {
8592 anim.always(function() {
8593 // doing this makes sure that the complete handler will be called
8594 // before this completes
8595 anim.always(function() {
8597 if ( !jQuery.queue( elem, "fx" ).length ) {
8604 // height/width overflow pass
8605 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8606 // Make sure that nothing sneaks out
8607 // Record all 3 overflow attributes because IE does not
8608 // change the overflow attribute when overflowX and
8609 // overflowY are set to the same value
8610 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8612 // Set display property to inline-block for height/width
8613 // animations on inline elements that are having width/height animated
8614 if ( jQuery.css( elem, "display" ) === "inline" &&
8615 jQuery.css( elem, "float" ) === "none" ) {
8617 // inline-level elements accept inline-block;
8618 // block-level elements need to be inline with layout
8619 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
8620 style.display = "inline-block";
8628 if ( opts.overflow ) {
8629 style.overflow = "hidden";
8630 if ( !jQuery.support.shrinkWrapBlocks ) {
8631 anim.done(function() {
8632 style.overflow = opts.overflow[ 0 ];
8633 style.overflowX = opts.overflow[ 1 ];
8634 style.overflowY = opts.overflow[ 2 ];
8641 for ( index in props ) {
8642 value = props[ index ];
8643 if ( rfxtypes.exec( value ) ) {
8644 delete props[ index ];
8645 if ( value === ( hidden ? "hide" : "show" ) ) {
8648 handled.push( index );
8652 length = handled.length;
8654 dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8656 jQuery( elem ).show();
8658 anim.done(function() {
8659 jQuery( elem ).hide();
8662 anim.done(function() {
8664 jQuery.removeData( elem, "fxshow", true );
8665 for ( prop in orig ) {
8666 jQuery.style( elem, prop, orig[ prop ] );
8669 for ( index = 0 ; index < length ; index++ ) {
8670 prop = handled[ index ];
8671 tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
8672 orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
8674 if ( !( prop in dataShow ) ) {
8675 dataShow[ prop ] = tween.start;
8677 tween.end = tween.start;
8678 tween.start = prop === "width" || prop === "height" ? 1 : 0;
8685 function Tween( elem, options, prop, end, easing ) {
8686 return new Tween.prototype.init( elem, options, prop, end, easing );
8688 jQuery.Tween = Tween;
8692 init: function( elem, options, prop, end, easing, unit ) {
8695 this.easing = easing || "swing";
8696 this.options = options;
8697 this.start = this.now = this.cur();
8699 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8702 var hooks = Tween.propHooks[ this.prop ];
8704 return hooks && hooks.get ?
8706 Tween.propHooks._default.get( this );
8708 run: function( percent ) {
8710 hooks = Tween.propHooks[ this.prop ];
8712 this.pos = eased = jQuery.easing[ this.easing ]( percent, this.options.duration * percent, 0, 1, this.options.duration );
8713 this.now = ( this.end - this.start ) * eased + this.start;
8715 if ( this.options.step ) {
8716 this.options.step.call( this.elem, this.now, this );
8719 if ( hooks && hooks.set ) {
8722 Tween.propHooks._default.set( this );
8728 Tween.prototype.init.prototype = Tween.prototype;
8732 get: function( tween ) {
8735 if ( tween.elem[ tween.prop ] != null &&
8736 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
8737 return tween.elem[ tween.prop ];
8740 // passing any value as a 4th parameter to .css will automatically
8741 // attempt a parseFloat and fallback to a string if the parse fails
8742 // so, simple values such as "10px" are parsed to Float.
8743 // complex values such as "rotate(1rad)" are returned as is.
8744 result = jQuery.css( tween.elem, tween.prop, false, "" );
8745 // Empty strings, null, undefined and "auto" are converted to 0.
8746 return !result || result === "auto" ? 0 : result;
8748 set: function( tween ) {
8749 // use step hook for back compat - use cssHook if its there - use .style if its
8750 // available and use plain properties where available
8751 if ( jQuery.fx.step[ tween.prop ] ) {
8752 jQuery.fx.step[ tween.prop ]( tween );
8753 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
8754 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
8756 tween.elem[ tween.prop ] = tween.now;
8762 // Remove in 2.0 - this supports IE8's panic based approach
8763 // to setting things on disconnected nodes
8765 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
8766 set: function( tween ) {
8767 if ( tween.elem.nodeType && tween.elem.parentNode ) {
8768 tween.elem[ tween.prop ] = tween.now;
8773 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
8774 var cssFn = jQuery.fn[ name ];
8775 jQuery.fn[ name ] = function( speed, easing, callback ) {
8776 return speed == null || typeof speed === "boolean" ||
8777 // special check for .toggle( handler, handler, ... )
8778 ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
8779 cssFn.apply( this, arguments ) :
8780 this.animate( genFx( name, true ), speed, easing, callback );
8785 fadeTo: function( speed, to, easing, callback ) {
8787 // show any hidden elements after setting opacity to 0
8788 return this.filter( isHidden ).css( "opacity", 0 ).show()
8790 // animate to the value specified
8791 .end().animate({ opacity: to }, speed, easing, callback );
8793 animate: function( prop, speed, easing, callback ) {
8794 var empty = jQuery.isEmptyObject( prop ),
8795 optall = jQuery.speed( speed, easing, callback ),
8796 doAnimation = function() {
8797 // Operate on a copy of prop so per-property easing won't be lost
8798 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
8800 // Empty animations resolve immediately
8806 return empty || optall.queue === false ?
8807 this.each( doAnimation ) :
8808 this.queue( optall.queue, doAnimation );
8810 stop: function( type, clearQueue, gotoEnd ) {
8811 var stopQueue = function( hooks ) {
8812 var stop = hooks.stop;
8817 if ( typeof type !== "string" ) {
8818 gotoEnd = clearQueue;
8822 if ( clearQueue && type !== false ) {
8823 this.queue( type || "fx", [] );
8826 return this.each(function() {
8828 index = type != null && type + "queueHooks",
8829 timers = jQuery.timers,
8830 data = jQuery._data( this );
8833 if ( data[ index ] && data[ index ].stop ) {
8834 stopQueue( data[ index ] );
8837 for ( index in data ) {
8838 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
8839 stopQueue( data[ index ] );
8844 for ( index = timers.length; index--; ) {
8845 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
8846 timers[ index ].anim.stop( gotoEnd );
8848 timers.splice( index, 1 );
8852 // start the next in the queue if the last step wasn't forced
8853 // timers currently will call their complete callbacks, which will dequeue
8854 // but only if they were gotoEnd
8855 if ( dequeue || !gotoEnd ) {
8856 jQuery.dequeue( this, type );
8862 // Generate parameters to create a standard animation
8863 function genFx( type, includeWidth ) {
8865 attrs = { height: type },
8868 // if we include width, step value is 1 to do all cssExpand values,
8869 // if we don't include width, step value is 2 to skip over Left and Right
8870 for( ; i < 4 ; i += 2 - includeWidth ) {
8871 which = cssExpand[ i ];
8872 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
8875 if ( includeWidth ) {
8876 attrs.opacity = attrs.width = type;
8882 // Generate shortcuts for custom animations
8884 slideDown: genFx("show"),
8885 slideUp: genFx("hide"),
8886 slideToggle: genFx("toggle"),
8887 fadeIn: { opacity: "show" },
8888 fadeOut: { opacity: "hide" },
8889 fadeToggle: { opacity: "toggle" }
8890 }, function( name, props ) {
8891 jQuery.fn[ name ] = function( speed, easing, callback ) {
8892 return this.animate( props, speed, easing, callback );
8896 jQuery.speed = function( speed, easing, fn ) {
8897 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
8898 complete: fn || !fn && easing ||
8899 jQuery.isFunction( speed ) && speed,
8901 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
8904 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
8905 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
8907 // normalize opt.queue - true/undefined/null -> "fx"
8908 if ( opt.queue == null || opt.queue === true ) {
8913 opt.old = opt.complete;
8915 opt.complete = function() {
8916 if ( jQuery.isFunction( opt.old ) ) {
8917 opt.old.call( this );
8921 jQuery.dequeue( this, opt.queue );
8929 linear: function( p ) {
8932 swing: function( p ) {
8933 return 0.5 - Math.cos( p*Math.PI ) / 2;
8938 jQuery.fx = Tween.prototype.init;
8939 jQuery.fx.tick = function() {
8941 timers = jQuery.timers,
8944 for ( ; i < timers.length; i++ ) {
8945 timer = timers[ i ];
8946 // Checks the timer has not already been removed
8947 if ( !timer() && timers[ i ] === timer ) {
8948 timers.splice( i--, 1 );
8952 if ( !timers.length ) {
8957 jQuery.fx.timer = function( timer ) {
8958 if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
8959 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
8963 jQuery.fx.interval = 13;
8965 jQuery.fx.stop = function() {
8966 clearInterval( timerId );
8970 jQuery.fx.speeds = {
8977 // Back Compat <1.8 extension point
8978 jQuery.fx.step = {};
8980 if ( jQuery.expr && jQuery.expr.filters ) {
8981 jQuery.expr.filters.animated = function( elem ) {
8982 return jQuery.grep(jQuery.timers, function( fn ) {
8983 return elem === fn.elem;
8987 var rroot = /^(?:body|html)$/i;
8989 jQuery.fn.offset = function( options ) {
8990 if ( arguments.length ) {
8991 return options === undefined ?
8993 this.each(function( i ) {
8994 jQuery.offset.setOffset( this, options, i );
8998 var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left,
9000 doc = elem && elem.ownerDocument;
9006 if ( (body = doc.body) === elem ) {
9007 return jQuery.offset.bodyOffset( elem );
9010 docElem = doc.documentElement;
9012 // Make sure we're not dealing with a disconnected DOM node
9013 if ( !jQuery.contains( docElem, elem ) ) {
9014 return { top: 0, left: 0 };
9017 box = elem.getBoundingClientRect();
9018 win = getWindow( doc );
9019 clientTop = docElem.clientTop || body.clientTop || 0;
9020 clientLeft = docElem.clientLeft || body.clientLeft || 0;
9021 scrollTop = win.pageYOffset || docElem.scrollTop;
9022 scrollLeft = win.pageXOffset || docElem.scrollLeft;
9023 top = box.top + scrollTop - clientTop;
9024 left = box.left + scrollLeft - clientLeft;
9026 return { top: top, left: left };
9031 bodyOffset: function( body ) {
9032 var top = body.offsetTop,
9033 left = body.offsetLeft;
9035 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
9036 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
9037 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
9040 return { top: top, left: left };
9043 setOffset: function( elem, options, i ) {
9044 var position = jQuery.css( elem, "position" );
9046 // set position first, in-case top/left are set even on static elem
9047 if ( position === "static" ) {
9048 elem.style.position = "relative";
9051 var curElem = jQuery( elem ),
9052 curOffset = curElem.offset(),
9053 curCSSTop = jQuery.css( elem, "top" ),
9054 curCSSLeft = jQuery.css( elem, "left" ),
9055 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9056 props = {}, curPosition = {}, curTop, curLeft;
9058 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9059 if ( calculatePosition ) {
9060 curPosition = curElem.position();
9061 curTop = curPosition.top;
9062 curLeft = curPosition.left;
9064 curTop = parseFloat( curCSSTop ) || 0;
9065 curLeft = parseFloat( curCSSLeft ) || 0;
9068 if ( jQuery.isFunction( options ) ) {
9069 options = options.call( elem, i, curOffset );
9072 if ( options.top != null ) {
9073 props.top = ( options.top - curOffset.top ) + curTop;
9075 if ( options.left != null ) {
9076 props.left = ( options.left - curOffset.left ) + curLeft;
9079 if ( "using" in options ) {
9080 options.using.call( elem, props );
9082 curElem.css( props );
9090 position: function() {
9097 // Get *real* offsetParent
9098 offsetParent = this.offsetParent(),
9100 // Get correct offsets
9101 offset = this.offset(),
9102 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
9104 // Subtract element margins
9105 // note: when an element has margin: auto the offsetLeft and marginLeft
9106 // are the same in Safari causing offset.left to incorrectly be 0
9107 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
9108 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
9110 // Add offsetParent borders
9111 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
9112 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
9114 // Subtract the two offsets
9116 top: offset.top - parentOffset.top,
9117 left: offset.left - parentOffset.left
9121 offsetParent: function() {
9122 return this.map(function() {
9123 var offsetParent = this.offsetParent || document.body;
9124 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
9125 offsetParent = offsetParent.offsetParent;
9127 return offsetParent || document.body;
9133 // Create scrollLeft and scrollTop methods
9134 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
9135 var top = /Y/.test( prop );
9137 jQuery.fn[ method ] = function( val ) {
9138 return jQuery.access( this, function( elem, method, val ) {
9139 var win = getWindow( elem );
9141 if ( val === undefined ) {
9142 return win ? (prop in win) ? win[ prop ] :
9143 win.document.documentElement[ method ] :
9149 !top ? val : jQuery( win ).scrollLeft(),
9150 top ? val : jQuery( win ).scrollTop()
9154 elem[ method ] = val;
9156 }, method, val, arguments.length, null );
9160 function getWindow( elem ) {
9161 return jQuery.isWindow( elem ) ?
9163 elem.nodeType === 9 ?
9164 elem.defaultView || elem.parentWindow :
9167 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9168 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9169 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9170 // margin is only for outerHeight, outerWidth
9171 jQuery.fn[ funcName ] = function( margin, value ) {
9172 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9173 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9175 return jQuery.access( this, function( elem, type, value ) {
9178 if ( jQuery.isWindow( elem ) ) {
9179 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9180 // isn't a whole lot we can do. See pull request at this URL for discussion:
9181 // https://github.com/jquery/jquery/pull/764
9182 return elem.document.documentElement[ "client" + name ];
9185 // Get document width or height
9186 if ( elem.nodeType === 9 ) {
9187 doc = elem.documentElement;
9189 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9190 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9192 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9193 elem.body[ "offset" + name ], doc[ "offset" + name ],
9194 doc[ "client" + name ]
9198 return value === undefined ?
9199 // Get width or height on the element, requesting but not forcing parseFloat
9200 jQuery.css( elem, type, value, extra ) :
9202 // Set width or height on the element
9203 jQuery.style( elem, type, value, extra );
9204 }, type, chainable ? margin : undefined, chainable );
9208 // Expose jQuery to the global object
9209 window.jQuery = window.$ = jQuery;
9211 // Expose jQuery as an AMD module, but only for AMD loaders that
9212 // understand the issues with loading multiple versions of jQuery
9213 // in a page that all might call define(). The loader will indicate
9214 // they have special allowances for multiple jQuery versions by
9215 // specifying define.amd.jQuery = true. Register as a named module,
9216 // since jQuery can be concatenated with other files that may use define,
9217 // but not use a proper concatenation script that understands anonymous
9218 // AMD modules. A named AMD is safest and most robust way to register.
9219 // Lowercase jquery is used because AMD module names are derived from
9220 // file names, and jQuery is normally delivered in a lowercase file name.
9221 // Do this after creating the global so that if an AMD module wants to call
9222 // noConflict to hide this version of jQuery, it will work.
9223 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
9224 define( "jquery", [], function () { return jQuery; } );