2 * jQuery JavaScript Library v1.8.2
8 * Copyright 2012 jQuery Foundation and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: Thu Sep 20 2012 21:13:05 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 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
55 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/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.toLowerCase() === name.toLowerCase();
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
622 trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
624 return text == null ?
626 core_trim.call( text );
629 // Otherwise use our own trimming functionality
631 return text == null ?
633 ( text + "" ).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 || 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 browser event has already occurred.
848 // we once tried to use readyState "interactive" here, but it caused issues like the one
849 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
850 if ( document.readyState === "complete" ) {
851 // Handle it asynchronously to allow scripts the opportunity to delay ready
852 setTimeout( jQuery.ready, 1 );
854 // Standards-based browsers support DOMContentLoaded
855 } else if ( document.addEventListener ) {
856 // Use the handy event callback
857 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
859 // A fallback to window.onload, that will always work
860 window.addEventListener( "load", jQuery.ready, false );
862 // If IE event model is used
864 // Ensure firing before onload, maybe late but safe also for iframes
865 document.attachEvent( "onreadystatechange", DOMContentLoaded );
867 // A fallback to window.onload, that will always work
868 window.attachEvent( "onload", jQuery.ready );
870 // If IE and not a frame
871 // continually check to see if the document is ready
875 top = window.frameElement == null && document.documentElement;
878 if ( top && top.doScroll ) {
879 (function doScrollCheck() {
880 if ( !jQuery.isReady ) {
883 // Use the trick by Diego Perini
884 // http://javascript.nwbox.com/IEContentLoaded/
885 top.doScroll("left");
887 return setTimeout( doScrollCheck, 50 );
890 // and execute any waiting functions
897 return readyList.promise( obj );
900 // Populate the class2type map
901 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
902 class2type[ "[object " + name + "]" ] = name.toLowerCase();
905 // All jQuery objects should point back to these
906 rootjQuery = jQuery(document);
907 // String to Object options format cache
908 var optionsCache = {};
910 // Convert String-formatted options into Object-formatted ones and store in cache
911 function createOptions( options ) {
912 var object = optionsCache[ options ] = {};
913 jQuery.each( options.split( core_rspace ), function( _, flag ) {
914 object[ flag ] = true;
920 * Create a callback list using the following parameters:
922 * options: an optional list of space-separated options that will change how
923 * the callback list behaves or a more traditional option object
925 * By default a callback list will act like an event callback list and can be
926 * "fired" multiple times.
930 * once: will ensure the callback list can only be fired once (like a Deferred)
932 * memory: will keep track of previous values and will call any callback added
933 * after the list has been fired right away with the latest "memorized"
934 * values (like a Deferred)
936 * unique: will ensure a callback can only be added once (no duplicate in the list)
938 * stopOnFalse: interrupt callings when a callback returns false
941 jQuery.Callbacks = function( options ) {
943 // Convert options from String-formatted to Object-formatted if needed
944 // (we check in cache first)
945 options = typeof options === "string" ?
946 ( optionsCache[ options ] || createOptions( options ) ) :
947 jQuery.extend( {}, options );
949 var // Last fire value (for non-forgettable lists)
951 // Flag to know if list was already fired
953 // Flag to know if list is currently firing
955 // First callback to fire (used internally by add and fireWith)
957 // End of the loop when firing
959 // Index of currently firing callback (modified by remove if needed)
961 // Actual callback list
963 // Stack of fire calls for repeatable lists
964 stack = !options.once && [],
966 fire = function( data ) {
967 memory = options.memory && data;
969 firingIndex = firingStart || 0;
971 firingLength = list.length;
973 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
974 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
975 memory = false; // To prevent further calls using add
982 if ( stack.length ) {
983 fire( stack.shift() );
985 } else if ( memory ) {
992 // Actual Callbacks object
994 // Add a callback or a collection of callbacks to the list
997 // First, we save the current length
998 var start = list.length;
999 (function add( args ) {
1000 jQuery.each( args, function( _, arg ) {
1001 var type = jQuery.type( arg );
1002 if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
1004 } else if ( arg && arg.length && type !== "string" ) {
1005 // Inspect recursively
1010 // Do we need to add the callbacks to the
1011 // current firing batch?
1013 firingLength = list.length;
1014 // With memory, if we're not firing then
1015 // we should call right away
1016 } else if ( memory ) {
1017 firingStart = start;
1023 // Remove a callback from the list
1024 remove: function() {
1026 jQuery.each( arguments, function( _, arg ) {
1028 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1029 list.splice( index, 1 );
1030 // Handle firing indexes
1032 if ( index <= firingLength ) {
1035 if ( index <= firingIndex ) {
1044 // Control if a given callback is in the list
1045 has: function( fn ) {
1046 return jQuery.inArray( fn, list ) > -1;
1048 // Remove all callbacks from the list
1053 // Have the list do nothing anymore
1054 disable: function() {
1055 list = stack = memory = undefined;
1059 disabled: function() {
1062 // Lock the list in its current state
1071 locked: function() {
1074 // Call all callbacks with the given context and arguments
1075 fireWith: function( context, args ) {
1077 args = [ context, args.slice ? args.slice() : args ];
1078 if ( list && ( !fired || stack ) ) {
1087 // Call all the callbacks with the given arguments
1089 self.fireWith( this, arguments );
1092 // To know if the callbacks have already been called at least once
1102 Deferred: function( func ) {
1104 // action, add listener, listener list, final state
1105 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1106 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1107 [ "notify", "progress", jQuery.Callbacks("memory") ]
1114 always: function() {
1115 deferred.done( arguments ).fail( arguments );
1118 then: function( /* fnDone, fnFail, fnProgress */ ) {
1119 var fns = arguments;
1120 return jQuery.Deferred(function( newDefer ) {
1121 jQuery.each( tuples, function( i, tuple ) {
1122 var action = tuple[ 0 ],
1124 // deferred[ done | fail | progress ] for forwarding actions to newDefer
1125 deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
1127 var returned = fn.apply( this, arguments );
1128 if ( returned && jQuery.isFunction( returned.promise ) ) {
1130 .done( newDefer.resolve )
1131 .fail( newDefer.reject )
1132 .progress( newDefer.notify );
1134 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1143 // Get a promise for this deferred
1144 // If obj is provided, the promise aspect is added to the object
1145 promise: function( obj ) {
1146 return obj != null ? jQuery.extend( obj, promise ) : promise;
1151 // Keep pipe for back-compat
1152 promise.pipe = promise.then;
1154 // Add list-specific methods
1155 jQuery.each( tuples, function( i, tuple ) {
1156 var list = tuple[ 2 ],
1157 stateString = tuple[ 3 ];
1159 // promise[ done | fail | progress ] = list.add
1160 promise[ tuple[1] ] = list.add;
1163 if ( stateString ) {
1164 list.add(function() {
1165 // state = [ resolved | rejected ]
1166 state = stateString;
1168 // [ reject_list | resolve_list ].disable; progress_list.lock
1169 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1172 // deferred[ resolve | reject | notify ] = list.fire
1173 deferred[ tuple[0] ] = list.fire;
1174 deferred[ tuple[0] + "With" ] = list.fireWith;
1177 // Make the deferred a promise
1178 promise.promise( deferred );
1180 // Call given func if any
1182 func.call( deferred, deferred );
1190 when: function( subordinate /* , ..., subordinateN */ ) {
1192 resolveValues = core_slice.call( arguments ),
1193 length = resolveValues.length,
1195 // the count of uncompleted subordinates
1196 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1198 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1199 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1201 // Update function for both resolve and progress values
1202 updateFunc = function( i, contexts, values ) {
1203 return function( value ) {
1204 contexts[ i ] = this;
1205 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
1206 if( values === progressValues ) {
1207 deferred.notifyWith( contexts, values );
1208 } else if ( !( --remaining ) ) {
1209 deferred.resolveWith( contexts, values );
1214 progressValues, progressContexts, resolveContexts;
1216 // add listeners to Deferred subordinates; treat others as resolved
1218 progressValues = new Array( length );
1219 progressContexts = new Array( length );
1220 resolveContexts = new Array( length );
1221 for ( ; i < length; i++ ) {
1222 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1223 resolveValues[ i ].promise()
1224 .done( updateFunc( i, resolveContexts, resolveValues ) )
1225 .fail( deferred.reject )
1226 .progress( updateFunc( i, progressContexts, progressValues ) );
1233 // if we're not waiting on anything, resolve the master
1235 deferred.resolveWith( resolveContexts, resolveValues );
1238 return deferred.promise();
1241 jQuery.support = (function() {
1254 div = document.createElement("div");
1256 // Preliminary tests
1257 div.setAttribute( "className", "t" );
1258 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1260 all = div.getElementsByTagName("*");
1261 a = div.getElementsByTagName("a")[ 0 ];
1262 a.style.cssText = "top:1px;float:left;opacity:.5";
1264 // Can't get basic test support
1265 if ( !all || !all.length ) {
1269 // First batch of supports tests
1270 select = document.createElement("select");
1271 opt = select.appendChild( document.createElement("option") );
1272 input = div.getElementsByTagName("input")[ 0 ];
1275 // IE strips leading whitespace when .innerHTML is used
1276 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1278 // Make sure that tbody elements aren't automatically inserted
1279 // IE will insert them into empty tables
1280 tbody: !div.getElementsByTagName("tbody").length,
1282 // Make sure that link elements get serialized correctly by innerHTML
1283 // This requires a wrapper element in IE
1284 htmlSerialize: !!div.getElementsByTagName("link").length,
1286 // Get the style information from getAttribute
1287 // (IE uses .cssText instead)
1288 style: /top/.test( a.getAttribute("style") ),
1290 // Make sure that URLs aren't manipulated
1291 // (IE normalizes it by default)
1292 hrefNormalized: ( a.getAttribute("href") === "/a" ),
1294 // Make sure that element opacity exists
1295 // (IE uses filter instead)
1296 // Use a regex to work around a WebKit issue. See #5145
1297 opacity: /^0.5/.test( a.style.opacity ),
1299 // Verify style float existence
1300 // (IE uses styleFloat instead of cssFloat)
1301 cssFloat: !!a.style.cssFloat,
1303 // Make sure that if no value is specified for a checkbox
1304 // that it defaults to "on".
1305 // (WebKit defaults to "" instead)
1306 checkOn: ( input.value === "on" ),
1308 // Make sure that a selected-by-default option has a working selected property.
1309 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1310 optSelected: opt.selected,
1312 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1313 getSetAttribute: div.className !== "t",
1315 // Tests for enctype support on a form(#6743)
1316 enctype: !!document.createElement("form").enctype,
1318 // Makes sure cloning an html5 element does not cause problems
1319 // Where outerHTML is undefined, this still works
1320 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1322 // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1323 boxModel: ( document.compatMode === "CSS1Compat" ),
1325 // Will be defined later
1326 submitBubbles: true,
1327 changeBubbles: true,
1328 focusinBubbles: false,
1329 deleteExpando: true,
1331 inlineBlockNeedsLayout: false,
1332 shrinkWrapBlocks: false,
1333 reliableMarginRight: true,
1334 boxSizingReliable: true,
1335 pixelPosition: false
1338 // Make sure checked status is properly cloned
1339 input.checked = true;
1340 support.noCloneChecked = input.cloneNode( true ).checked;
1342 // Make sure that the options inside disabled selects aren't marked as disabled
1343 // (WebKit marks them as disabled)
1344 select.disabled = true;
1345 support.optDisabled = !opt.disabled;
1347 // Test to see if it's possible to delete an expando from an element
1348 // Fails in Internet Explorer
1352 support.deleteExpando = false;
1355 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1356 div.attachEvent( "onclick", clickFn = function() {
1357 // Cloning a node shouldn't copy over any
1358 // bound event handlers (IE does this)
1359 support.noCloneEvent = false;
1361 div.cloneNode( true ).fireEvent("onclick");
1362 div.detachEvent( "onclick", clickFn );
1365 // Check if a radio maintains its value
1366 // after being appended to the DOM
1367 input = document.createElement("input");
1369 input.setAttribute( "type", "radio" );
1370 support.radioValue = input.value === "t";
1372 input.setAttribute( "checked", "checked" );
1374 // #11217 - WebKit loses check when the name is after the checked attribute
1375 input.setAttribute( "name", "t" );
1377 div.appendChild( input );
1378 fragment = document.createDocumentFragment();
1379 fragment.appendChild( div.lastChild );
1381 // WebKit doesn't clone checked state correctly in fragments
1382 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1384 // Check if a disconnected checkbox will retain its checked
1385 // value of true after appended to the DOM (IE6/7)
1386 support.appendChecked = input.checked;
1388 fragment.removeChild( input );
1389 fragment.appendChild( div );
1391 // Technique from Juriy Zaytsev
1392 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1393 // We only care about the case where non-standard event systems
1394 // are used, namely in IE. Short-circuiting here helps us to
1395 // avoid an eval call (in setAttribute) which can cause CSP
1396 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1397 if ( div.attachEvent ) {
1403 eventName = "on" + i;
1404 isSupported = ( eventName in div );
1405 if ( !isSupported ) {
1406 div.setAttribute( eventName, "return;" );
1407 isSupported = ( typeof div[ eventName ] === "function" );
1409 support[ i + "Bubbles" ] = isSupported;
1413 // Run tests that need a body at doc ready
1415 var container, div, tds, marginDiv,
1416 divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
1417 body = document.getElementsByTagName("body")[0];
1420 // Return for frameset docs that don't have a body
1424 container = document.createElement("div");
1425 container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
1426 body.insertBefore( container, body.firstChild );
1428 // Construct the test element
1429 div = document.createElement("div");
1430 container.appendChild( div );
1432 // Check if table cells still have offsetWidth/Height when they are set
1433 // to display:none and there are still other visible table cells in a
1434 // table row; if so, offsetWidth/Height are not reliable for use when
1435 // determining if an element has been hidden directly using
1436 // display:none (it is still safe to use offsets if a parent element is
1437 // hidden; don safety goggles and see bug #4512 for more information).
1438 // (only IE 8 fails this test)
1439 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
1440 tds = div.getElementsByTagName("td");
1441 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
1442 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1444 tds[ 0 ].style.display = "";
1445 tds[ 1 ].style.display = "none";
1447 // Check if empty table cells still have offsetWidth/Height
1448 // (IE <= 8 fail this test)
1449 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1451 // Check box-sizing and margin behavior
1453 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%;";
1454 support.boxSizing = ( div.offsetWidth === 4 );
1455 support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1457 // NOTE: To any future maintainer, we've window.getComputedStyle
1458 // because jsdom on node.js will break without it.
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 = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
1509 rmultiDash = /([A-Z])/g;
1516 // Remove at next major release (1.9/2.0)
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.guid++;
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-" ) ) {
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 ),
1871 startLength = queue.length,
1873 hooks = jQuery._queueHooks( elem, type ),
1875 jQuery.dequeue( elem, type );
1878 // If the fx queue is dequeued, always remove the progress sentinel
1879 if ( fn === "inprogress" ) {
1886 // Add a progress sentinel to prevent the fx queue from being
1887 // automatically dequeued
1888 if ( type === "fx" ) {
1889 queue.unshift( "inprogress" );
1892 // clear up the last queue stop function
1894 fn.call( elem, next, hooks );
1897 if ( !startLength && hooks ) {
1902 // not intended for public consumption - generates a queueHooks object, or returns the current one
1903 _queueHooks: function( elem, type ) {
1904 var key = type + "queueHooks";
1905 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
1906 empty: jQuery.Callbacks("once memory").add(function() {
1907 jQuery.removeData( elem, type + "queue", true );
1908 jQuery.removeData( elem, key, true );
1915 queue: function( type, data ) {
1918 if ( typeof type !== "string" ) {
1924 if ( arguments.length < setter ) {
1925 return jQuery.queue( this[0], type );
1928 return data === undefined ?
1930 this.each(function() {
1931 var queue = jQuery.queue( this, type, data );
1933 // ensure a hooks for this queue
1934 jQuery._queueHooks( this, type );
1936 if ( type === "fx" && queue[0] !== "inprogress" ) {
1937 jQuery.dequeue( this, type );
1941 dequeue: function( type ) {
1942 return this.each(function() {
1943 jQuery.dequeue( this, type );
1946 // Based off of the plugin by Clint Helfers, with permission.
1947 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1948 delay: function( time, type ) {
1949 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1950 type = type || "fx";
1952 return this.queue( type, function( next, hooks ) {
1953 var timeout = setTimeout( next, time );
1954 hooks.stop = function() {
1955 clearTimeout( timeout );
1959 clearQueue: function( type ) {
1960 return this.queue( type || "fx", [] );
1962 // Get a promise resolved when queues of a certain type
1963 // are emptied (fx is the type by default)
1964 promise: function( type, obj ) {
1967 defer = jQuery.Deferred(),
1970 resolve = function() {
1971 if ( !( --count ) ) {
1972 defer.resolveWith( elements, [ elements ] );
1976 if ( typeof type !== "string" ) {
1980 type = type || "fx";
1983 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
1984 if ( tmp && tmp.empty ) {
1986 tmp.empty.add( resolve );
1990 return defer.promise( obj );
1993 var nodeHook, boolHook, fixSpecified,
1994 rclass = /[\t\r\n]/g,
1996 rtype = /^(?:button|input)$/i,
1997 rfocusable = /^(?:button|input|object|select|textarea)$/i,
1998 rclickable = /^a(?:rea|)$/i,
1999 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2000 getSetAttribute = jQuery.support.getSetAttribute;
2003 attr: function( name, value ) {
2004 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2007 removeAttr: function( name ) {
2008 return this.each(function() {
2009 jQuery.removeAttr( this, name );
2013 prop: function( name, value ) {
2014 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2017 removeProp: function( name ) {
2018 name = jQuery.propFix[ name ] || name;
2019 return this.each(function() {
2020 // try/catch handles cases where IE balks (such as removing a property on window)
2022 this[ name ] = undefined;
2023 delete this[ name ];
2028 addClass: function( value ) {
2029 var classNames, i, l, elem,
2032 if ( jQuery.isFunction( value ) ) {
2033 return this.each(function( j ) {
2034 jQuery( this ).addClass( value.call(this, j, this.className) );
2038 if ( value && typeof value === "string" ) {
2039 classNames = value.split( core_rspace );
2041 for ( i = 0, l = this.length; i < l; i++ ) {
2044 if ( elem.nodeType === 1 ) {
2045 if ( !elem.className && classNames.length === 1 ) {
2046 elem.className = value;
2049 setClass = " " + elem.className + " ";
2051 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2052 if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
2053 setClass += classNames[ c ] + " ";
2056 elem.className = jQuery.trim( setClass );
2065 removeClass: function( value ) {
2066 var removes, className, elem, c, cl, i, l;
2068 if ( jQuery.isFunction( value ) ) {
2069 return this.each(function( j ) {
2070 jQuery( this ).removeClass( value.call(this, j, this.className) );
2073 if ( (value && typeof value === "string") || value === undefined ) {
2074 removes = ( value || "" ).split( core_rspace );
2076 for ( i = 0, l = this.length; i < l; i++ ) {
2078 if ( elem.nodeType === 1 && elem.className ) {
2080 className = (" " + elem.className + " ").replace( rclass, " " );
2082 // loop over each item in the removal list
2083 for ( c = 0, cl = removes.length; c < cl; c++ ) {
2084 // Remove until there is nothing to remove,
2085 while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
2086 className = className.replace( " " + removes[ c ] + " " , " " );
2089 elem.className = value ? jQuery.trim( className ) : "";
2097 toggleClass: function( value, stateVal ) {
2098 var type = typeof value,
2099 isBool = typeof stateVal === "boolean";
2101 if ( jQuery.isFunction( value ) ) {
2102 return this.each(function( i ) {
2103 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2107 return this.each(function() {
2108 if ( type === "string" ) {
2109 // toggle individual class names
2112 self = jQuery( this ),
2114 classNames = value.split( core_rspace );
2116 while ( (className = classNames[ i++ ]) ) {
2117 // check each className given, space separated list
2118 state = isBool ? state : !self.hasClass( className );
2119 self[ state ? "addClass" : "removeClass" ]( className );
2122 } else if ( type === "undefined" || type === "boolean" ) {
2123 if ( this.className ) {
2124 // store className if set
2125 jQuery._data( this, "__className__", this.className );
2128 // toggle whole className
2129 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2134 hasClass: function( selector ) {
2135 var className = " " + selector + " ",
2138 for ( ; i < l; i++ ) {
2139 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
2147 val: function( value ) {
2148 var hooks, ret, isFunction,
2151 if ( !arguments.length ) {
2153 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2155 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2161 return typeof ret === "string" ?
2162 // handle most common string cases
2163 ret.replace(rreturn, "") :
2164 // handle cases where value is null/undef or number
2165 ret == null ? "" : ret;
2171 isFunction = jQuery.isFunction( value );
2173 return this.each(function( i ) {
2175 self = jQuery(this);
2177 if ( this.nodeType !== 1 ) {
2182 val = value.call( this, i, self.val() );
2187 // Treat null/undefined as ""; convert numbers to string
2188 if ( val == null ) {
2190 } else if ( typeof val === "number" ) {
2192 } else if ( jQuery.isArray( val ) ) {
2193 val = jQuery.map(val, function ( value ) {
2194 return value == null ? "" : value + "";
2198 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2200 // If set returns undefined, fall back to normal setting
2201 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2211 get: function( elem ) {
2212 // attributes.value is undefined in Blackberry 4.7 but
2213 // uses .value. See #6932
2214 var val = elem.attributes.value;
2215 return !val || val.specified ? elem.value : elem.text;
2219 get: function( elem ) {
2220 var value, i, max, option,
2221 index = elem.selectedIndex,
2223 options = elem.options,
2224 one = elem.type === "select-one";
2226 // Nothing was selected
2231 // Loop through all the selected options
2232 i = one ? index : 0;
2233 max = one ? index + 1 : options.length;
2234 for ( ; i < max; i++ ) {
2235 option = options[ i ];
2237 // Don't return options that are disabled or in a disabled optgroup
2238 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2239 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2241 // Get the specific value for the option
2242 value = jQuery( option ).val();
2244 // We don't need an array for one selects
2249 // Multi-Selects return an array
2250 values.push( value );
2254 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2255 if ( one && !values.length && options.length ) {
2256 return jQuery( options[ index ] ).val();
2262 set: function( elem, value ) {
2263 var values = jQuery.makeArray( value );
2265 jQuery(elem).find("option").each(function() {
2266 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2269 if ( !values.length ) {
2270 elem.selectedIndex = -1;
2277 // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
2280 attr: function( elem, name, value, pass ) {
2281 var ret, hooks, notxml,
2282 nType = elem.nodeType;
2284 // don't get/set attributes on text, comment and attribute nodes
2285 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2289 if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
2290 return jQuery( elem )[ name ]( value );
2293 // Fallback to prop when attributes are not supported
2294 if ( typeof elem.getAttribute === "undefined" ) {
2295 return jQuery.prop( elem, name, value );
2298 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2300 // All attributes are lowercase
2301 // Grab necessary hook if one is defined
2303 name = name.toLowerCase();
2304 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2307 if ( value !== undefined ) {
2309 if ( value === null ) {
2310 jQuery.removeAttr( elem, name );
2313 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2317 elem.setAttribute( name, value + "" );
2321 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2326 ret = elem.getAttribute( name );
2328 // Non-existent attributes return null, we normalize to undefined
2329 return ret === null ?
2335 removeAttr: function( elem, value ) {
2336 var propName, attrNames, name, isBool,
2339 if ( value && elem.nodeType === 1 ) {
2341 attrNames = value.split( core_rspace );
2343 for ( ; i < attrNames.length; i++ ) {
2344 name = attrNames[ i ];
2347 propName = jQuery.propFix[ name ] || name;
2348 isBool = rboolean.test( name );
2350 // See #9699 for explanation of this approach (setting first, then removal)
2351 // Do not do this for boolean attributes (see #10870)
2353 jQuery.attr( elem, name, "" );
2355 elem.removeAttribute( getSetAttribute ? name : propName );
2357 // Set corresponding property to false for boolean attributes
2358 if ( isBool && propName in elem ) {
2359 elem[ propName ] = false;
2368 set: function( elem, value ) {
2369 // We can't allow the type property to be changed (since it causes problems in IE)
2370 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2371 jQuery.error( "type property can't be changed" );
2372 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2373 // Setting the type on a radio button after the value resets the value in IE6-9
2374 // Reset value to it's default in case type is set after value
2375 // This is for element creation
2376 var val = elem.value;
2377 elem.setAttribute( "type", value );
2385 // Use the value property for back compat
2386 // Use the nodeHook for button elements in IE6/7 (#1954)
2388 get: function( elem, name ) {
2389 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2390 return nodeHook.get( elem, name );
2392 return name in elem ?
2396 set: function( elem, value, name ) {
2397 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2398 return nodeHook.set( elem, value, name );
2400 // Does not return so that setAttribute is also used
2407 tabindex: "tabIndex",
2408 readonly: "readOnly",
2410 "class": "className",
2411 maxlength: "maxLength",
2412 cellspacing: "cellSpacing",
2413 cellpadding: "cellPadding",
2417 frameborder: "frameBorder",
2418 contenteditable: "contentEditable"
2421 prop: function( elem, name, value ) {
2422 var ret, hooks, notxml,
2423 nType = elem.nodeType;
2425 // don't get/set properties on text, comment and attribute nodes
2426 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2430 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2433 // Fix name and attach hooks
2434 name = jQuery.propFix[ name ] || name;
2435 hooks = jQuery.propHooks[ name ];
2438 if ( value !== undefined ) {
2439 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2443 return ( elem[ name ] = value );
2447 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2451 return elem[ name ];
2458 get: function( elem ) {
2459 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2460 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2461 var attributeNode = elem.getAttributeNode("tabindex");
2463 return attributeNode && attributeNode.specified ?
2464 parseInt( attributeNode.value, 10 ) :
2465 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2473 // Hook for boolean attributes
2475 get: function( elem, name ) {
2476 // Align boolean attributes with corresponding properties
2477 // Fall back to attribute presence where some booleans are not supported
2479 property = jQuery.prop( elem, name );
2480 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2481 name.toLowerCase() :
2484 set: function( elem, value, name ) {
2486 if ( value === false ) {
2487 // Remove boolean attributes when set to false
2488 jQuery.removeAttr( elem, name );
2490 // value is true since we know at this point it's type boolean and not false
2491 // Set boolean attributes to the same name and set the DOM property
2492 propName = jQuery.propFix[ name ] || name;
2493 if ( propName in elem ) {
2494 // Only set the IDL specifically if it already exists on the element
2495 elem[ propName ] = true;
2498 elem.setAttribute( name, name.toLowerCase() );
2504 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2505 if ( !getSetAttribute ) {
2513 // Use this for any attribute in IE6/7
2514 // This fixes almost every IE6/7 issue
2515 nodeHook = jQuery.valHooks.button = {
2516 get: function( elem, name ) {
2518 ret = elem.getAttributeNode( name );
2519 return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
2523 set: function( elem, value, name ) {
2524 // Set the existing or create a new attribute node
2525 var ret = elem.getAttributeNode( name );
2527 ret = document.createAttribute( name );
2528 elem.setAttributeNode( ret );
2530 return ( ret.value = value + "" );
2534 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2535 // This is for removals
2536 jQuery.each([ "width", "height" ], function( i, name ) {
2537 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2538 set: function( elem, value ) {
2539 if ( value === "" ) {
2540 elem.setAttribute( name, "auto" );
2547 // Set contenteditable to false on removals(#10429)
2548 // Setting to empty string throws an error as an invalid value
2549 jQuery.attrHooks.contenteditable = {
2551 set: function( elem, value, name ) {
2552 if ( value === "" ) {
2555 nodeHook.set( elem, value, name );
2561 // Some attributes require a special call on IE
2562 if ( !jQuery.support.hrefNormalized ) {
2563 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2564 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2565 get: function( elem ) {
2566 var ret = elem.getAttribute( name, 2 );
2567 return ret === null ? undefined : ret;
2573 if ( !jQuery.support.style ) {
2574 jQuery.attrHooks.style = {
2575 get: function( elem ) {
2576 // Return undefined in the case of empty string
2577 // Normalize to lowercase since IE uppercases css property names
2578 return elem.style.cssText.toLowerCase() || undefined;
2580 set: function( elem, value ) {
2581 return ( elem.style.cssText = value + "" );
2586 // Safari mis-reports the default selected property of an option
2587 // Accessing the parent's selectedIndex property fixes it
2588 if ( !jQuery.support.optSelected ) {
2589 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2590 get: function( elem ) {
2591 var parent = elem.parentNode;
2594 parent.selectedIndex;
2596 // Make sure that it also works with optgroups, see #5701
2597 if ( parent.parentNode ) {
2598 parent.parentNode.selectedIndex;
2606 // IE6/7 call enctype encoding
2607 if ( !jQuery.support.enctype ) {
2608 jQuery.propFix.enctype = "encoding";
2611 // Radios and checkboxes getter/setter
2612 if ( !jQuery.support.checkOn ) {
2613 jQuery.each([ "radio", "checkbox" ], function() {
2614 jQuery.valHooks[ this ] = {
2615 get: function( elem ) {
2616 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2617 return elem.getAttribute("value") === null ? "on" : elem.value;
2622 jQuery.each([ "radio", "checkbox" ], function() {
2623 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2624 set: function( elem, value ) {
2625 if ( jQuery.isArray( value ) ) {
2626 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2631 var rformElems = /^(?:textarea|input|select)$/i,
2632 rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
2633 rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
2635 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2636 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2637 hoverHack = function( events ) {
2638 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2642 * Helper functions for managing events -- not part of the public interface.
2643 * Props to Dean Edwards' addEvent library for many of the ideas.
2647 add: function( elem, types, handler, data, selector ) {
2649 var elemData, eventHandle, events,
2650 t, tns, type, namespaces, handleObj,
2651 handleObjIn, handlers, special;
2653 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2654 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2658 // Caller can pass in an object of custom data in lieu of the handler
2659 if ( handler.handler ) {
2660 handleObjIn = handler;
2661 handler = handleObjIn.handler;
2662 selector = handleObjIn.selector;
2665 // Make sure that the handler has a unique ID, used to find/remove it later
2666 if ( !handler.guid ) {
2667 handler.guid = jQuery.guid++;
2670 // Init the element's event structure and main handler, if this is the first
2671 events = elemData.events;
2673 elemData.events = events = {};
2675 eventHandle = elemData.handle;
2676 if ( !eventHandle ) {
2677 elemData.handle = eventHandle = function( e ) {
2678 // Discard the second event of a jQuery.event.trigger() and
2679 // when an event is called after a page has unloaded
2680 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2681 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2684 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2685 eventHandle.elem = elem;
2688 // Handle multiple events separated by a space
2689 // jQuery(...).bind("mouseover mouseout", fn);
2690 types = jQuery.trim( hoverHack(types) ).split( " " );
2691 for ( t = 0; t < types.length; t++ ) {
2693 tns = rtypenamespace.exec( types[t] ) || [];
2695 namespaces = ( tns[2] || "" ).split( "." ).sort();
2697 // If event changes its type, use the special event handlers for the changed type
2698 special = jQuery.event.special[ type ] || {};
2700 // If selector defined, determine special event api type, otherwise given type
2701 type = ( selector ? special.delegateType : special.bindType ) || type;
2703 // Update special based on newly reset type
2704 special = jQuery.event.special[ type ] || {};
2706 // handleObj is passed to all event handlers
2707 handleObj = jQuery.extend({
2714 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2715 namespace: namespaces.join(".")
2718 // Init the event handler queue if we're the first
2719 handlers = events[ type ];
2721 handlers = events[ type ] = [];
2722 handlers.delegateCount = 0;
2724 // Only use addEventListener/attachEvent if the special events handler returns false
2725 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2726 // Bind the global event handler to the element
2727 if ( elem.addEventListener ) {
2728 elem.addEventListener( type, eventHandle, false );
2730 } else if ( elem.attachEvent ) {
2731 elem.attachEvent( "on" + type, eventHandle );
2736 if ( special.add ) {
2737 special.add.call( elem, handleObj );
2739 if ( !handleObj.handler.guid ) {
2740 handleObj.handler.guid = handler.guid;
2744 // Add to the element's handler list, delegates in front
2746 handlers.splice( handlers.delegateCount++, 0, handleObj );
2748 handlers.push( handleObj );
2751 // Keep track of which events have ever been used, for event optimization
2752 jQuery.event.global[ type ] = true;
2755 // Nullify elem to prevent memory leaks in IE
2761 // Detach an event or set of events from an element
2762 remove: function( elem, types, handler, selector, mappedTypes ) {
2764 var t, tns, type, origType, namespaces, origCount,
2765 j, events, special, eventType, handleObj,
2766 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
2768 if ( !elemData || !(events = elemData.events) ) {
2772 // Once for each type.namespace in types; type may be omitted
2773 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
2774 for ( t = 0; t < types.length; t++ ) {
2775 tns = rtypenamespace.exec( types[t] ) || [];
2776 type = origType = tns[1];
2777 namespaces = tns[2];
2779 // Unbind all events (on this namespace, if provided) for the element
2781 for ( type in events ) {
2782 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2787 special = jQuery.event.special[ type ] || {};
2788 type = ( selector? special.delegateType : special.bindType ) || type;
2789 eventType = events[ type ] || [];
2790 origCount = eventType.length;
2791 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2793 // Remove matching events
2794 for ( j = 0; j < eventType.length; j++ ) {
2795 handleObj = eventType[ j ];
2797 if ( ( mappedTypes || origType === handleObj.origType ) &&
2798 ( !handler || handler.guid === handleObj.guid ) &&
2799 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
2800 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2801 eventType.splice( j--, 1 );
2803 if ( handleObj.selector ) {
2804 eventType.delegateCount--;
2806 if ( special.remove ) {
2807 special.remove.call( elem, handleObj );
2812 // Remove generic event handler if we removed something and no more handlers exist
2813 // (avoids potential for endless recursion during removal of special event handlers)
2814 if ( eventType.length === 0 && origCount !== eventType.length ) {
2815 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2816 jQuery.removeEvent( elem, type, elemData.handle );
2819 delete events[ type ];
2823 // Remove the expando if it's no longer used
2824 if ( jQuery.isEmptyObject( events ) ) {
2825 delete elemData.handle;
2827 // removeData also checks for emptiness and clears the expando if empty
2828 // so use it instead of delete
2829 jQuery.removeData( elem, "events", true );
2833 // Events that are safe to short-circuit if no handlers are attached.
2834 // Native DOM events should not be added, they may have inline handlers.
2841 trigger: function( event, data, elem, onlyHandlers ) {
2842 // Don't do events on text and comment nodes
2843 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
2847 // Event object or event type
2848 var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
2849 type = event.type || event,
2852 // focus/blur morphs to focusin/out; ensure we're not firing them right now
2853 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2857 if ( type.indexOf( "!" ) >= 0 ) {
2858 // Exclusive events trigger only for the exact event (no namespaces)
2859 type = type.slice(0, -1);
2863 if ( type.indexOf( "." ) >= 0 ) {
2864 // Namespaced trigger; create a regexp to match event type in handle()
2865 namespaces = type.split(".");
2866 type = namespaces.shift();
2870 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2871 // No jQuery handlers for this event type, and it can't have inline handlers
2875 // Caller can pass in an Event, Object, or just an event type string
2876 event = typeof event === "object" ?
2877 // jQuery.Event object
2878 event[ jQuery.expando ] ? event :
2880 new jQuery.Event( type, event ) :
2881 // Just the event type (string)
2882 new jQuery.Event( type );
2885 event.isTrigger = true;
2886 event.exclusive = exclusive;
2887 event.namespace = namespaces.join( "." );
2888 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2889 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
2891 // Handle a global trigger
2894 // TODO: Stop taunting the data cache; remove global events and always attach to document
2895 cache = jQuery.cache;
2896 for ( i in cache ) {
2897 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
2898 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
2904 // Clean up the event in case it is being reused
2905 event.result = undefined;
2906 if ( !event.target ) {
2907 event.target = elem;
2910 // Clone any incoming data and prepend the event, creating the handler arg list
2911 data = data != null ? jQuery.makeArray( data ) : [];
2912 data.unshift( event );
2914 // Allow special events to draw outside the lines
2915 special = jQuery.event.special[ type ] || {};
2916 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
2920 // Determine event propagation path in advance, per W3C events spec (#9951)
2921 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2922 eventPath = [[ elem, special.bindType || type ]];
2923 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2925 bubbleType = special.delegateType || type;
2926 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
2927 for ( old = elem; cur; cur = cur.parentNode ) {
2928 eventPath.push([ cur, bubbleType ]);
2932 // Only add window if we got to document (e.g., not plain obj or detached DOM)
2933 if ( old === (elem.ownerDocument || document) ) {
2934 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
2938 // Fire handlers on the event path
2939 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
2941 cur = eventPath[i][0];
2942 event.type = eventPath[i][1];
2944 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2946 handle.apply( cur, data );
2948 // Note that this is a bare JS function and not a jQuery handler
2949 handle = ontype && cur[ ontype ];
2950 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2951 event.preventDefault();
2956 // If nobody prevented the default action, do it now
2957 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
2959 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
2960 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2962 // Call a native DOM method on the target with the same name name as the event.
2963 // Can't use an .isFunction() check here because IE6/7 fails that test.
2964 // Don't do default actions on window, that's where global variables be (#6170)
2965 // IE<9 dies on focus/blur to hidden element (#1486)
2966 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
2968 // Don't re-trigger an onFOO event when we call its FOO() method
2969 old = elem[ ontype ];
2972 elem[ ontype ] = null;
2975 // Prevent re-triggering of the same event, since we already bubbled it above
2976 jQuery.event.triggered = type;
2978 jQuery.event.triggered = undefined;
2981 elem[ ontype ] = old;
2987 return event.result;
2990 dispatch: function( event ) {
2992 // Make a writable jQuery.Event from the native event object
2993 event = jQuery.event.fix( event || window.event );
2995 var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
2996 handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
2997 delegateCount = handlers.delegateCount,
2998 args = core_slice.call( arguments ),
2999 run_all = !event.exclusive && !event.namespace,
3000 special = jQuery.event.special[ event.type ] || {},
3003 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3005 event.delegateTarget = this;
3007 // Call the preDispatch hook for the mapped type, and let it bail if desired
3008 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3012 // Determine handlers that should run if there are delegated events
3013 // Avoid non-left-click bubbling in Firefox (#3861)
3014 if ( delegateCount && !(event.button && event.type === "click") ) {
3016 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3018 // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
3019 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 ] = handleObj.needsContext ?
3028 jQuery( sel, this ).index( cur ) >= 0 :
3029 jQuery.find( sel, this, null, [ cur ] ).length;
3031 if ( selMatch[ sel ] ) {
3032 matches.push( handleObj );
3035 if ( matches.length ) {
3036 handlerQueue.push({ elem: cur, matches: matches });
3042 // Add the remaining (directly-bound) handlers
3043 if ( handlers.length > delegateCount ) {
3044 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3047 // Run delegates first; they may want to stop propagation beneath us
3048 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3049 matched = handlerQueue[ i ];
3050 event.currentTarget = matched.elem;
3052 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3053 handleObj = matched.matches[ j ];
3055 // Triggered event must either 1) be non-exclusive and have no namespace, or
3056 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3057 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3059 event.data = handleObj.data;
3060 event.handleObj = handleObj;
3062 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3063 .apply( matched.elem, args );
3065 if ( ret !== undefined ) {
3067 if ( ret === false ) {
3068 event.preventDefault();
3069 event.stopPropagation();
3076 // Call the postDispatch hook for the mapped type
3077 if ( special.postDispatch ) {
3078 special.postDispatch.call( this, event );
3081 return event.result;
3084 // Includes some event props shared by KeyEvent and MouseEvent
3085 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3086 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3091 props: "char charCode key keyCode".split(" "),
3092 filter: function( event, original ) {
3094 // Add which for key events
3095 if ( event.which == null ) {
3096 event.which = original.charCode != null ? original.charCode : original.keyCode;
3104 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3105 filter: function( event, original ) {
3106 var eventDoc, doc, body,
3107 button = original.button,
3108 fromElement = original.fromElement;
3110 // Calculate pageX/Y if missing and clientX/Y available
3111 if ( event.pageX == null && original.clientX != null ) {
3112 eventDoc = event.target.ownerDocument || document;
3113 doc = eventDoc.documentElement;
3114 body = eventDoc.body;
3116 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3117 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3120 // Add relatedTarget, if necessary
3121 if ( !event.relatedTarget && fromElement ) {
3122 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3125 // Add which for click: 1 === left; 2 === middle; 3 === right
3126 // Note: button is not normalized, so don't use it
3127 if ( !event.which && button !== undefined ) {
3128 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3135 fix: function( event ) {
3136 if ( event[ jQuery.expando ] ) {
3140 // Create a writable copy of the event object and normalize some properties
3142 originalEvent = event,
3143 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3144 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3146 event = jQuery.Event( originalEvent );
3148 for ( i = copy.length; i; ) {
3150 event[ prop ] = originalEvent[ prop ];
3153 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3154 if ( !event.target ) {
3155 event.target = originalEvent.srcElement || document;
3158 // Target should not be a text node (#504, Safari)
3159 if ( event.target.nodeType === 3 ) {
3160 event.target = event.target.parentNode;
3163 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
3164 event.metaKey = !!event.metaKey;
3166 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3171 // Prevent triggered image.load events from bubbling to window.load
3176 delegateType: "focusin"
3179 delegateType: "focusout"
3183 setup: function( data, namespaces, eventHandle ) {
3184 // We only want to do this special case on windows
3185 if ( jQuery.isWindow( this ) ) {
3186 this.onbeforeunload = eventHandle;
3190 teardown: function( namespaces, eventHandle ) {
3191 if ( this.onbeforeunload === eventHandle ) {
3192 this.onbeforeunload = null;
3198 simulate: function( type, elem, event, bubble ) {
3199 // Piggyback on a donor event to simulate a different one.
3200 // Fake originalEvent to avoid donor's stopPropagation, but if the
3201 // simulated event prevents default then we do the same on the donor.
3202 var e = jQuery.extend(
3211 jQuery.event.trigger( e, null, elem );
3213 jQuery.event.dispatch.call( elem, e );
3215 if ( e.isDefaultPrevented() ) {
3216 event.preventDefault();
3221 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3222 // The 1.7 special event interface should provide all the hooks needed now.
3223 jQuery.event.handle = jQuery.event.dispatch;
3225 jQuery.removeEvent = document.removeEventListener ?
3226 function( elem, type, handle ) {
3227 if ( elem.removeEventListener ) {
3228 elem.removeEventListener( type, handle, false );
3231 function( elem, type, handle ) {
3232 var name = "on" + type;
3234 if ( elem.detachEvent ) {
3236 // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
3237 // detachEvent needed property on element, by name of that event, to properly expose it to GC
3238 if ( typeof elem[ name ] === "undefined" ) {
3239 elem[ name ] = null;
3242 elem.detachEvent( name, handle );
3246 jQuery.Event = function( src, props ) {
3247 // Allow instantiation without the 'new' keyword
3248 if ( !(this instanceof jQuery.Event) ) {
3249 return new jQuery.Event( src, props );
3253 if ( src && src.type ) {
3254 this.originalEvent = src;
3255 this.type = src.type;
3257 // Events bubbling up the document may have been marked as prevented
3258 // by a handler lower down the tree; reflect the correct value.
3259 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3260 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3267 // Put explicitly provided properties onto the event object
3269 jQuery.extend( this, props );
3272 // Create a timestamp if incoming event doesn't have one
3273 this.timeStamp = src && src.timeStamp || jQuery.now();
3276 this[ jQuery.expando ] = true;
3279 function returnFalse() {
3282 function returnTrue() {
3286 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3287 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3288 jQuery.Event.prototype = {
3289 preventDefault: function() {
3290 this.isDefaultPrevented = returnTrue;
3292 var e = this.originalEvent;
3297 // if preventDefault exists run it on the original event
3298 if ( e.preventDefault ) {
3301 // otherwise set the returnValue property of the original event to false (IE)
3303 e.returnValue = false;
3306 stopPropagation: function() {
3307 this.isPropagationStopped = returnTrue;
3309 var e = this.originalEvent;
3313 // if stopPropagation exists run it on the original event
3314 if ( e.stopPropagation ) {
3315 e.stopPropagation();
3317 // otherwise set the cancelBubble property of the original event to true (IE)
3318 e.cancelBubble = true;
3320 stopImmediatePropagation: function() {
3321 this.isImmediatePropagationStopped = returnTrue;
3322 this.stopPropagation();
3324 isDefaultPrevented: returnFalse,
3325 isPropagationStopped: returnFalse,
3326 isImmediatePropagationStopped: returnFalse
3329 // Create mouseenter/leave events using mouseover/out and event-time checks
3331 mouseenter: "mouseover",
3332 mouseleave: "mouseout"
3333 }, function( orig, fix ) {
3334 jQuery.event.special[ orig ] = {
3338 handle: function( event ) {
3341 related = event.relatedTarget,
3342 handleObj = event.handleObj,
3343 selector = handleObj.selector;
3345 // For mousenter/leave call the handler if related is outside the target.
3346 // NB: No relatedTarget if the mouse left/entered the browser window
3347 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3348 event.type = handleObj.origType;
3349 ret = handleObj.handler.apply( this, arguments );
3357 // IE submit delegation
3358 if ( !jQuery.support.submitBubbles ) {
3360 jQuery.event.special.submit = {
3362 // Only need this for delegated form submit events
3363 if ( jQuery.nodeName( this, "form" ) ) {
3367 // Lazy-add a submit handler when a descendant form may potentially be submitted
3368 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3369 // Node name check avoids a VML-related crash in IE (#9807)
3370 var elem = e.target,
3371 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3372 if ( form && !jQuery._data( form, "_submit_attached" ) ) {
3373 jQuery.event.add( form, "submit._submit", function( event ) {
3374 event._submit_bubble = true;
3376 jQuery._data( form, "_submit_attached", true );
3379 // return undefined since we don't need an event listener
3382 postDispatch: function( event ) {
3383 // If form was submitted by the user, bubble the event up the tree
3384 if ( event._submit_bubble ) {
3385 delete event._submit_bubble;
3386 if ( this.parentNode && !event.isTrigger ) {
3387 jQuery.event.simulate( "submit", this.parentNode, event, true );
3392 teardown: function() {
3393 // Only need this for delegated form submit events
3394 if ( jQuery.nodeName( this, "form" ) ) {
3398 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3399 jQuery.event.remove( this, "._submit" );
3404 // IE change delegation and checkbox/radio fix
3405 if ( !jQuery.support.changeBubbles ) {
3407 jQuery.event.special.change = {
3411 if ( rformElems.test( this.nodeName ) ) {
3412 // IE doesn't fire change on a check/radio until blur; trigger it on click
3413 // after a propertychange. Eat the blur-change in special.change.handle.
3414 // This still fires onchange a second time for check/radio after blur.
3415 if ( this.type === "checkbox" || this.type === "radio" ) {
3416 jQuery.event.add( this, "propertychange._change", function( event ) {
3417 if ( event.originalEvent.propertyName === "checked" ) {
3418 this._just_changed = true;
3421 jQuery.event.add( this, "click._change", function( event ) {
3422 if ( this._just_changed && !event.isTrigger ) {
3423 this._just_changed = false;
3425 // Allow triggered, simulated change events (#11500)
3426 jQuery.event.simulate( "change", this, event, true );
3431 // Delegated event; lazy-add a change handler on descendant inputs
3432 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3433 var elem = e.target;
3435 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
3436 jQuery.event.add( elem, "change._change", function( event ) {
3437 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3438 jQuery.event.simulate( "change", this.parentNode, event, true );
3441 jQuery._data( elem, "_change_attached", true );
3446 handle: function( event ) {
3447 var elem = event.target;
3449 // Swallow native change events from checkbox/radio, we already triggered them above
3450 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3451 return event.handleObj.handler.apply( this, arguments );
3455 teardown: function() {
3456 jQuery.event.remove( this, "._change" );
3458 return !rformElems.test( this.nodeName );
3463 // Create "bubbling" focus and blur events
3464 if ( !jQuery.support.focusinBubbles ) {
3465 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3467 // Attach a single capturing handler while someone wants focusin/focusout
3469 handler = function( event ) {
3470 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3473 jQuery.event.special[ fix ] = {
3475 if ( attaches++ === 0 ) {
3476 document.addEventListener( orig, handler, true );
3479 teardown: function() {
3480 if ( --attaches === 0 ) {
3481 document.removeEventListener( orig, handler, true );
3490 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3493 // Types can be a map of types/handlers
3494 if ( typeof types === "object" ) {
3495 // ( types-Object, selector, data )
3496 if ( typeof selector !== "string" ) { // && selector != null
3497 // ( types-Object, data )
3498 data = data || selector;
3499 selector = undefined;
3501 for ( type in types ) {
3502 this.on( type, selector, data, types[ type ], one );
3507 if ( data == null && fn == null ) {
3510 data = selector = undefined;
3511 } else if ( fn == null ) {
3512 if ( typeof selector === "string" ) {
3513 // ( types, selector, fn )
3517 // ( types, data, fn )
3520 selector = undefined;
3523 if ( fn === false ) {
3531 fn = function( event ) {
3532 // Can use an empty set, since event contains the info
3533 jQuery().off( event );
3534 return origFn.apply( this, arguments );
3536 // Use same guid so caller can remove using origFn
3537 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3539 return this.each( function() {
3540 jQuery.event.add( this, types, fn, data, selector );
3543 one: function( types, selector, data, fn ) {
3544 return this.on( types, selector, data, fn, 1 );
3546 off: function( types, selector, fn ) {
3547 var handleObj, type;
3548 if ( types && types.preventDefault && types.handleObj ) {
3549 // ( event ) dispatched jQuery.Event
3550 handleObj = types.handleObj;
3551 jQuery( types.delegateTarget ).off(
3552 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3558 if ( typeof types === "object" ) {
3559 // ( types-object [, selector] )
3560 for ( type in types ) {
3561 this.off( type, selector, types[ type ] );
3565 if ( selector === false || typeof selector === "function" ) {
3568 selector = undefined;
3570 if ( fn === false ) {
3573 return this.each(function() {
3574 jQuery.event.remove( this, types, fn, selector );
3578 bind: function( types, data, fn ) {
3579 return this.on( types, null, data, fn );
3581 unbind: function( types, fn ) {
3582 return this.off( types, null, fn );
3585 live: function( types, data, fn ) {
3586 jQuery( this.context ).on( types, this.selector, data, fn );
3589 die: function( types, fn ) {
3590 jQuery( this.context ).off( types, this.selector || "**", fn );
3594 delegate: function( selector, types, data, fn ) {
3595 return this.on( types, selector, data, fn );
3597 undelegate: function( selector, types, fn ) {
3598 // ( namespace ) or ( selector, types [, fn] )
3599 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3602 trigger: function( type, data ) {
3603 return this.each(function() {
3604 jQuery.event.trigger( type, data, this );
3607 triggerHandler: function( type, data ) {
3609 return jQuery.event.trigger( type, data, this[0], true );
3613 toggle: function( fn ) {
3614 // Save reference to arguments for access in closure
3615 var args = arguments,
3616 guid = fn.guid || jQuery.guid++,
3618 toggler = function( event ) {
3619 // Figure out which function to execute
3620 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3621 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3623 // Make sure that clicks stop
3624 event.preventDefault();
3626 // and execute the function
3627 return args[ lastToggle ].apply( this, arguments ) || false;
3630 // link all the functions, so any of them can unbind this click handler
3631 toggler.guid = guid;
3632 while ( i < args.length ) {
3633 args[ i++ ].guid = guid;
3636 return this.click( toggler );
3639 hover: function( fnOver, fnOut ) {
3640 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3644 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3645 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3646 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3648 // Handle event binding
3649 jQuery.fn[ name ] = function( data, fn ) {
3655 return arguments.length > 0 ?
3656 this.on( name, null, data, fn ) :
3657 this.trigger( name );
3660 if ( rkeyEvent.test( name ) ) {
3661 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3664 if ( rmouseEvent.test( name ) ) {
3665 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3669 * Sizzle CSS Selector Engine
\r
3670 * Copyright 2012 jQuery Foundation and other contributors
\r
3671 * Released under the MIT license
\r
3672 * http://sizzlejs.com/
\r
3674 (function( window, undefined ) {
\r
3677 assertGetIdNotName,
\r
3687 baseHasDuplicate = true,
\r
3688 strundefined = "undefined",
\r
3690 expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
\r
3693 document = window.document,
\r
3694 docElem = document.documentElement,
\r
3700 // Use a stripped-down indexOf if a native one is unavailable
\r
3701 indexOf = [].indexOf || function( elem ) {
\r
3703 len = this.length;
\r
3704 for ( ; i < len; i++ ) {
\r
3705 if ( this[i] === elem ) {
\r
3712 // Augment a function for special use by Sizzle
\r
3713 markFunction = function( fn, value ) {
\r
3714 fn[ expando ] = value == null || value;
\r
3718 createCache = function() {
\r
3722 return markFunction(function( key, value ) {
\r
3723 // Only keep the most recent entries
\r
3724 if ( keys.push( key ) > Expr.cacheLength ) {
\r
3725 delete cache[ keys.shift() ];
\r
3728 return (cache[ key ] = value);
\r
3732 classCache = createCache(),
\r
3733 tokenCache = createCache(),
\r
3734 compilerCache = createCache(),
\r
3738 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
\r
3739 whitespace = "[\\x20\\t\\r\\n\\f]",
\r
3740 // http://www.w3.org/TR/css3-syntax/#characters
\r
3741 characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
\r
3743 // Loosely modeled on CSS identifier characters
\r
3744 // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
\r
3745 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
\r
3746 identifier = characterEncoding.replace( "w", "w#" ),
\r
3748 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
\r
3749 operators = "([*^$|!~]?=)",
\r
3750 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
\r
3751 "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
\r
3753 // Prefer arguments not in parens/brackets,
\r
3754 // then attribute selectors and non-pseudos (denoted by :),
\r
3755 // then anything else
\r
3756 // These preferences are here to reduce the number of selectors
\r
3757 // needing tokenize in the PSEUDO preFilter
\r
3758 pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
\r
3760 // For matchExpr.POS and matchExpr.needsContext
\r
3761 pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
\r
3762 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
\r
3764 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
\r
3765 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
\r
3767 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
\r
3768 rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
\r
3769 rpseudo = new RegExp( pseudos ),
\r
3771 // Easily-parseable/retrievable ID or TAG or CLASS selectors
\r
3772 rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
\r
3775 rsibling = /[\x20\t\r\n\f]*[+~]/,
\r
3776 rendsWithNot = /:not\($/,
\r
3779 rinputs = /input|select|textarea|button/i,
\r
3781 rbackslash = /\\(?!\\)/g,
\r
3784 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
\r
3785 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
\r
3786 "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
\r
3787 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
\r
3788 "ATTR": new RegExp( "^" + attributes ),
\r
3789 "PSEUDO": new RegExp( "^" + pseudos ),
\r
3790 "POS": new RegExp( pos, "i" ),
\r
3791 "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
\r
3792 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
\r
3793 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
\r
3794 // For use in libraries implementing .is()
\r
3795 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
\r
3800 // Used for testing something on an element
\r
3801 assert = function( fn ) {
\r
3802 var div = document.createElement("div");
\r
3809 // release memory in IE
\r
3814 // Check if getElementsByTagName("*") returns only elements
\r
3815 assertTagNameNoComments = assert(function( div ) {
\r
3816 div.appendChild( document.createComment("") );
\r
3817 return !div.getElementsByTagName("*").length;
\r
3820 // Check if getAttribute returns normalized href attributes
\r
3821 assertHrefNotNormalized = assert(function( div ) {
\r
3822 div.innerHTML = "<a href='#'></a>";
\r
3823 return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
\r
3824 div.firstChild.getAttribute("href") === "#";
\r
3827 // Check if attributes should be retrieved by attribute nodes
\r
3828 assertAttributes = assert(function( div ) {
\r
3829 div.innerHTML = "<select></select>";
\r
3830 var type = typeof div.lastChild.getAttribute("multiple");
\r
3831 // IE8 returns a string for some attributes even when not present
\r
3832 return type !== "boolean" && type !== "string";
\r
3835 // Check if getElementsByClassName can be trusted
\r
3836 assertUsableClassName = assert(function( div ) {
\r
3837 // Opera can't find a second classname (in 9.6)
\r
3838 div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
\r
3839 if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
\r
3843 // Safari 3.2 caches class attributes and doesn't catch changes
\r
3844 div.lastChild.className = "e";
\r
3845 return div.getElementsByClassName("e").length === 2;
\r
3848 // Check if getElementById returns elements by name
\r
3849 // Check if getElementsByName privileges form controls or returns elements by ID
\r
3850 assertUsableName = assert(function( div ) {
\r
3852 div.id = expando + 0;
\r
3853 div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
\r
3854 docElem.insertBefore( div, docElem.firstChild );
\r
3857 var pass = document.getElementsByName &&
\r
3858 // buggy browsers will return fewer than the correct 2
\r
3859 document.getElementsByName( expando ).length === 2 +
\r
3860 // buggy browsers will return more than the correct 0
\r
3861 document.getElementsByName( expando + 0 ).length;
\r
3862 assertGetIdNotName = !document.getElementById( expando );
\r
3865 docElem.removeChild( div );
\r
3870 // If slice is not available, provide a backup
\r
3872 slice.call( docElem.childNodes, 0 )[0].nodeType;
\r
3874 slice = function( i ) {
\r
3877 for ( ; (elem = this[i]); i++ ) {
\r
3878 results.push( elem );
\r
3884 function Sizzle( selector, context, results, seed ) {
\r
3885 results = results || [];
\r
3886 context = context || document;
\r
3887 var match, elem, xml, m,
\r
3888 nodeType = context.nodeType;
\r
3890 if ( !selector || typeof selector !== "string" ) {
\r
3894 if ( nodeType !== 1 && nodeType !== 9 ) {
\r
3898 xml = isXML( context );
\r
3900 if ( !xml && !seed ) {
\r
3901 if ( (match = rquickExpr.exec( selector )) ) {
\r
3902 // Speed-up: Sizzle("#ID")
\r
3903 if ( (m = match[1]) ) {
\r
3904 if ( nodeType === 9 ) {
\r
3905 elem = context.getElementById( m );
\r
3906 // Check parentNode to catch when Blackberry 4.6 returns
\r
3907 // nodes that are no longer in the document #6963
\r
3908 if ( elem && elem.parentNode ) {
\r
3909 // Handle the case where IE, Opera, and Webkit return items
\r
3910 // by name instead of ID
\r
3911 if ( elem.id === m ) {
\r
3912 results.push( elem );
\r
3919 // Context is not a document
\r
3920 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
\r
3921 contains( context, elem ) && elem.id === m ) {
\r
3922 results.push( elem );
\r
3927 // Speed-up: Sizzle("TAG")
\r
3928 } else if ( match[2] ) {
\r
3929 push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
\r
3932 // Speed-up: Sizzle(".CLASS")
\r
3933 } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
\r
3934 push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
\r
3941 return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
\r
3944 Sizzle.matches = function( expr, elements ) {
\r
3945 return Sizzle( expr, null, null, elements );
\r
3948 Sizzle.matchesSelector = function( elem, expr ) {
\r
3949 return Sizzle( expr, null, null, [ elem ] ).length > 0;
\r
3952 // Returns a function to use in pseudos for input types
\r
3953 function createInputPseudo( type ) {
\r
3954 return function( elem ) {
\r
3955 var name = elem.nodeName.toLowerCase();
\r
3956 return name === "input" && elem.type === type;
\r
3960 // Returns a function to use in pseudos for buttons
\r
3961 function createButtonPseudo( type ) {
\r
3962 return function( elem ) {
\r
3963 var name = elem.nodeName.toLowerCase();
\r
3964 return (name === "input" || name === "button") && elem.type === type;
\r
3968 // Returns a function to use in pseudos for positionals
\r
3969 function createPositionalPseudo( fn ) {
\r
3970 return markFunction(function( argument ) {
\r
3971 argument = +argument;
\r
3972 return markFunction(function( seed, matches ) {
\r
3974 matchIndexes = fn( [], seed.length, argument ),
\r
3975 i = matchIndexes.length;
\r
3977 // Match elements found at the specified indexes
\r
3979 if ( seed[ (j = matchIndexes[i]) ] ) {
\r
3980 seed[j] = !(matches[j] = seed[j]);
\r
3988 * Utility function for retrieving the text value of an array of DOM nodes
\r
3989 * @param {Array|Element} elem
\r
3991 getText = Sizzle.getText = function( elem ) {
\r
3995 nodeType = elem.nodeType;
\r
3998 if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
\r
3999 // Use textContent for elements
\r
4000 // innerText usage removed for consistency of new lines (see #11153)
\r
4001 if ( typeof elem.textContent === "string" ) {
\r
4002 return elem.textContent;
\r
4004 // Traverse its children
\r
4005 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
\r
4006 ret += getText( elem );
\r
4009 } else if ( nodeType === 3 || nodeType === 4 ) {
\r
4010 return elem.nodeValue;
\r
4012 // Do not include comment or processing instruction nodes
\r
4015 // If no nodeType, this is expected to be an array
\r
4016 for ( ; (node = elem[i]); i++ ) {
\r
4017 // Do not traverse comment nodes
\r
4018 ret += getText( node );
\r
4024 isXML = Sizzle.isXML = function( elem ) {
\r
4025 // documentElement is verified for cases where it doesn't yet exist
\r
4026 // (such as loading iframes in IE - #4833)
\r
4027 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
\r
4028 return documentElement ? documentElement.nodeName !== "HTML" : false;
\r
4031 // Element contains another
\r
4032 contains = Sizzle.contains = docElem.contains ?
\r
4033 function( a, b ) {
\r
4034 var adown = a.nodeType === 9 ? a.documentElement : a,
\r
4035 bup = b && b.parentNode;
\r
4036 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
\r
4038 docElem.compareDocumentPosition ?
\r
4039 function( a, b ) {
\r
4040 return b && !!( a.compareDocumentPosition( b ) & 16 );
\r
4042 function( a, b ) {
\r
4043 while ( (b = b.parentNode) ) {
\r
4051 Sizzle.attr = function( elem, name ) {
\r
4053 xml = isXML( elem );
\r
4056 name = name.toLowerCase();
\r
4058 if ( (val = Expr.attrHandle[ name ]) ) {
\r
4059 return val( elem );
\r
4061 if ( xml || assertAttributes ) {
\r
4062 return elem.getAttribute( name );
\r
4064 val = elem.getAttributeNode( name );
\r
4066 typeof elem[ name ] === "boolean" ?
\r
4067 elem[ name ] ? name : null :
\r
4068 val.specified ? val.value : null :
\r
4072 Expr = Sizzle.selectors = {
\r
4074 // Can be adjusted by the user
\r
4077 createPseudo: markFunction,
\r
4081 // IE6/7 return a modified href
\r
4082 attrHandle: assertHrefNotNormalized ?
\r
4085 "href": function( elem ) {
\r
4086 return elem.getAttribute( "href", 2 );
\r
4088 "type": function( elem ) {
\r
4089 return elem.getAttribute("type");
\r
4094 "ID": assertGetIdNotName ?
\r
4095 function( id, context, xml ) {
\r
4096 if ( typeof context.getElementById !== strundefined && !xml ) {
\r
4097 var m = context.getElementById( id );
\r
4098 // Check parentNode to catch when Blackberry 4.6 returns
\r
4099 // nodes that are no longer in the document #6963
\r
4100 return m && m.parentNode ? [m] : [];
\r
4103 function( id, context, xml ) {
\r
4104 if ( typeof context.getElementById !== strundefined && !xml ) {
\r
4105 var m = context.getElementById( id );
\r
4108 m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
\r
4115 "TAG": assertTagNameNoComments ?
\r
4116 function( tag, context ) {
\r
4117 if ( typeof context.getElementsByTagName !== strundefined ) {
\r
4118 return context.getElementsByTagName( tag );
\r
4121 function( tag, context ) {
\r
4122 var results = context.getElementsByTagName( tag );
\r
4124 // Filter out possible comments
\r
4125 if ( tag === "*" ) {
\r
4130 for ( ; (elem = results[i]); i++ ) {
\r
4131 if ( elem.nodeType === 1 ) {
\r
4141 "NAME": assertUsableName && function( tag, context ) {
\r
4142 if ( typeof context.getElementsByName !== strundefined ) {
\r
4143 return context.getElementsByName( name );
\r
4147 "CLASS": assertUsableClassName && function( className, context, xml ) {
\r
4148 if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
\r
4149 return context.getElementsByClassName( className );
\r
4155 ">": { dir: "parentNode", first: true },
\r
4156 " ": { dir: "parentNode" },
\r
4157 "+": { dir: "previousSibling", first: true },
\r
4158 "~": { dir: "previousSibling" }
\r
4162 "ATTR": function( match ) {
\r
4163 match[1] = match[1].replace( rbackslash, "" );
\r
4165 // Move the given value to match[3] whether quoted or unquoted
\r
4166 match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
\r
4168 if ( match[2] === "~=" ) {
\r
4169 match[3] = " " + match[3] + " ";
\r
4172 return match.slice( 0, 4 );
\r
4175 "CHILD": function( match ) {
\r
4176 /* matches from matchExpr["CHILD"]
\r
4177 1 type (only|nth|...)
\r
4178 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
\r
4179 3 xn-component of xn+y argument ([+-]?\d*n|)
\r
4180 4 sign of xn-component
\r
4181 5 x of xn-component
\r
4182 6 sign of y-component
\r
4183 7 y of y-component
\r
4185 match[1] = match[1].toLowerCase();
\r
4187 if ( match[1] === "nth" ) {
\r
4188 // nth-child requires argument
\r
4189 if ( !match[2] ) {
\r
4190 Sizzle.error( match[0] );
\r
4193 // numeric x and y parameters for Expr.filter.CHILD
\r
4194 // remember that false/true cast respectively to 0/1
\r
4195 match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
\r
4196 match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
\r
4198 // other types prohibit arguments
\r
4199 } else if ( match[2] ) {
\r
4200 Sizzle.error( match[0] );
\r
4206 "PSEUDO": function( match ) {
\r
4207 var unquoted, excess;
\r
4208 if ( matchExpr["CHILD"].test( match[0] ) ) {
\r
4213 match[2] = match[3];
\r
4214 } else if ( (unquoted = match[4]) ) {
\r
4215 // Only check arguments that contain a pseudo
\r
4216 if ( rpseudo.test(unquoted) &&
\r
4217 // Get excess from tokenize (recursively)
\r
4218 (excess = tokenize( unquoted, true )) &&
\r
4219 // advance to the next closing parenthesis
\r
4220 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
\r
4222 // excess is a negative index
\r
4223 unquoted = unquoted.slice( 0, excess );
\r
4224 match[0] = match[0].slice( 0, excess );
\r
4226 match[2] = unquoted;
\r
4229 // Return only captures needed by the pseudo filter method (type and argument)
\r
4230 return match.slice( 0, 3 );
\r
4235 "ID": assertGetIdNotName ?
\r
4237 id = id.replace( rbackslash, "" );
\r
4238 return function( elem ) {
\r
4239 return elem.getAttribute("id") === id;
\r
4243 id = id.replace( rbackslash, "" );
\r
4244 return function( elem ) {
\r
4245 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
\r
4246 return node && node.value === id;
\r
4250 "TAG": function( nodeName ) {
\r
4251 if ( nodeName === "*" ) {
\r
4252 return function() { return true; };
\r
4254 nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
\r
4256 return function( elem ) {
\r
4257 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
\r
4261 "CLASS": function( className ) {
\r
4262 var pattern = classCache[ expando ][ className ];
\r
4264 pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
\r
4266 return function( elem ) {
\r
4267 return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
\r
4271 "ATTR": function( name, operator, check ) {
\r
4272 return function( elem, context ) {
\r
4273 var result = Sizzle.attr( elem, name );
\r
4275 if ( result == null ) {
\r
4276 return operator === "!=";
\r
4278 if ( !operator ) {
\r
4284 return operator === "=" ? result === check :
\r
4285 operator === "!=" ? result !== check :
\r
4286 operator === "^=" ? check && result.indexOf( check ) === 0 :
\r
4287 operator === "*=" ? check && result.indexOf( check ) > -1 :
\r
4288 operator === "$=" ? check && result.substr( result.length - check.length ) === check :
\r
4289 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
\r
4290 operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
\r
4295 "CHILD": function( type, argument, first, last ) {
\r
4297 if ( type === "nth" ) {
\r
4298 return function( elem ) {
\r
4300 parent = elem.parentNode;
\r
4302 if ( first === 1 && last === 0 ) {
\r
4308 for ( node = parent.firstChild; node; node = node.nextSibling ) {
\r
4309 if ( node.nodeType === 1 ) {
\r
4311 if ( elem === node ) {
\r
4318 // Incorporate the offset (or cast to NaN), then check against cycle size
\r
4320 return diff === first || ( diff % first === 0 && diff / first >= 0 );
\r
4324 return function( elem ) {
\r
4330 while ( (node = node.previousSibling) ) {
\r
4331 if ( node.nodeType === 1 ) {
\r
4336 if ( type === "first" ) {
\r
4342 /* falls through */
\r
4344 while ( (node = node.nextSibling) ) {
\r
4345 if ( node.nodeType === 1 ) {
\r
4355 "PSEUDO": function( pseudo, argument ) {
\r
4356 // pseudo-class names are case-insensitive
\r
4357 // http://www.w3.org/TR/selectors/#pseudo-classes
\r
4358 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
\r
4359 // Remember that setFilters inherits from pseudos
\r
4361 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
\r
4362 Sizzle.error( "unsupported pseudo: " + pseudo );
\r
4364 // The user may use createPseudo to indicate that
\r
4365 // arguments are needed to create the filter function
\r
4366 // just as Sizzle does
\r
4367 if ( fn[ expando ] ) {
\r
4368 return fn( argument );
\r
4371 // But maintain support for old signatures
\r
4372 if ( fn.length > 1 ) {
\r
4373 args = [ pseudo, pseudo, "", argument ];
\r
4374 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
\r
4375 markFunction(function( seed, matches ) {
\r
4377 matched = fn( seed, argument ),
\r
4378 i = matched.length;
\r
4380 idx = indexOf.call( seed, matched[i] );
\r
4381 seed[ idx ] = !( matches[ idx ] = matched[i] );
\r
4384 function( elem ) {
\r
4385 return fn( elem, 0, args );
\r
4394 "not": markFunction(function( selector ) {
\r
4395 // Trim the selector passed to compile
\r
4396 // to avoid treating leading and trailing
\r
4397 // spaces as combinators
\r
4400 matcher = compile( selector.replace( rtrim, "$1" ) );
\r
4402 return matcher[ expando ] ?
\r
4403 markFunction(function( seed, matches, context, xml ) {
\r
4405 unmatched = matcher( seed, null, xml, [] ),
\r
4408 // Match elements unmatched by `matcher`
\r
4410 if ( (elem = unmatched[i]) ) {
\r
4411 seed[i] = !(matches[i] = elem);
\r
4415 function( elem, context, xml ) {
\r
4417 matcher( input, null, xml, results );
\r
4418 return !results.pop();
\r
4422 "has": markFunction(function( selector ) {
\r
4423 return function( elem ) {
\r
4424 return Sizzle( selector, elem ).length > 0;
\r
4428 "contains": markFunction(function( text ) {
\r
4429 return function( elem ) {
\r
4430 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
\r
4434 "enabled": function( elem ) {
\r
4435 return elem.disabled === false;
\r
4438 "disabled": function( elem ) {
\r
4439 return elem.disabled === true;
\r
4442 "checked": function( elem ) {
\r
4443 // In CSS3, :checked should return both checked and selected elements
\r
4444 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
\r
4445 var nodeName = elem.nodeName.toLowerCase();
\r
4446 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
\r
4449 "selected": function( elem ) {
\r
4450 // Accessing this property makes selected-by-default
\r
4451 // options in Safari work properly
\r
4452 if ( elem.parentNode ) {
\r
4453 elem.parentNode.selectedIndex;
\r
4456 return elem.selected === true;
\r
4459 "parent": function( elem ) {
\r
4460 return !Expr.pseudos["empty"]( elem );
\r
4463 "empty": function( elem ) {
\r
4464 // http://www.w3.org/TR/selectors/#empty-pseudo
\r
4465 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
\r
4466 // not comment, processing instructions, or others
\r
4467 // Thanks to Diego Perini for the nodeName shortcut
\r
4468 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
\r
4470 elem = elem.firstChild;
\r
4472 if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
\r
4475 elem = elem.nextSibling;
\r
4480 "header": function( elem ) {
\r
4481 return rheader.test( elem.nodeName );
\r
4484 "text": function( elem ) {
\r
4486 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
\r
4487 // use getAttribute instead to test this case
\r
4488 return elem.nodeName.toLowerCase() === "input" &&
\r
4489 (type = elem.type) === "text" &&
\r
4490 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
\r
4494 "radio": createInputPseudo("radio"),
\r
4495 "checkbox": createInputPseudo("checkbox"),
\r
4496 "file": createInputPseudo("file"),
\r
4497 "password": createInputPseudo("password"),
\r
4498 "image": createInputPseudo("image"),
\r
4500 "submit": createButtonPseudo("submit"),
\r
4501 "reset": createButtonPseudo("reset"),
\r
4503 "button": function( elem ) {
\r
4504 var name = elem.nodeName.toLowerCase();
\r
4505 return name === "input" && elem.type === "button" || name === "button";
\r
4508 "input": function( elem ) {
\r
4509 return rinputs.test( elem.nodeName );
\r
4512 "focus": function( elem ) {
\r
4513 var doc = elem.ownerDocument;
\r
4514 return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
\r
4517 "active": function( elem ) {
\r
4518 return elem === elem.ownerDocument.activeElement;
\r
4521 // Positional types
\r
4522 "first": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4526 "last": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4527 return [ length - 1 ];
\r
4530 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4531 return [ argument < 0 ? argument + length : argument ];
\r
4534 "even": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4535 for ( var i = 0; i < length; i += 2 ) {
\r
4536 matchIndexes.push( i );
\r
4538 return matchIndexes;
\r
4541 "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4542 for ( var i = 1; i < length; i += 2 ) {
\r
4543 matchIndexes.push( i );
\r
4545 return matchIndexes;
\r
4548 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4549 for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
\r
4550 matchIndexes.push( i );
\r
4552 return matchIndexes;
\r
4555 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
4556 for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
\r
4557 matchIndexes.push( i );
\r
4559 return matchIndexes;
\r
4564 function siblingCheck( a, b, ret ) {
\r
4569 var cur = a.nextSibling;
\r
4572 if ( cur === b ) {
\r
4576 cur = cur.nextSibling;
\r
4582 sortOrder = docElem.compareDocumentPosition ?
\r
4583 function( a, b ) {
\r
4585 hasDuplicate = true;
\r
4589 return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
\r
4590 a.compareDocumentPosition :
\r
4591 a.compareDocumentPosition(b) & 4
\r
4594 function( a, b ) {
\r
4595 // The nodes are identical, we can exit early
\r
4597 hasDuplicate = true;
\r
4600 // Fallback to using sourceIndex (in IE) if it's available on both nodes
\r
4601 } else if ( a.sourceIndex && b.sourceIndex ) {
\r
4602 return a.sourceIndex - b.sourceIndex;
\r
4608 aup = a.parentNode,
\r
4609 bup = b.parentNode,
\r
4612 // If the nodes are siblings (or identical) we can do a quick check
\r
4613 if ( aup === bup ) {
\r
4614 return siblingCheck( a, b );
\r
4616 // If no parents were found then the nodes are disconnected
\r
4617 } else if ( !aup ) {
\r
4620 } else if ( !bup ) {
\r
4624 // Otherwise they're somewhere else in the tree so we need
\r
4625 // to build up a full list of the parentNodes for comparison
\r
4627 ap.unshift( cur );
\r
4628 cur = cur.parentNode;
\r
4634 bp.unshift( cur );
\r
4635 cur = cur.parentNode;
\r
4641 // Start walking down the tree looking for a discrepancy
\r
4642 for ( var i = 0; i < al && i < bl; i++ ) {
\r
4643 if ( ap[i] !== bp[i] ) {
\r
4644 return siblingCheck( ap[i], bp[i] );
\r
4648 // We ended someplace up the tree so do a sibling check
\r
4650 siblingCheck( a, bp[i], -1 ) :
\r
4651 siblingCheck( ap[i], b, 1 );
\r
4654 // Always assume the presence of duplicates if sort doesn't
\r
4655 // pass them to our comparison function (as in Google Chrome).
\r
4656 [0, 0].sort( sortOrder );
\r
4657 baseHasDuplicate = !hasDuplicate;
\r
4659 // Document sorting and removing duplicates
\r
4660 Sizzle.uniqueSort = function( results ) {
\r
4664 hasDuplicate = baseHasDuplicate;
\r
4665 results.sort( sortOrder );
\r
4667 if ( hasDuplicate ) {
\r
4668 for ( ; (elem = results[i]); i++ ) {
\r
4669 if ( elem === results[ i - 1 ] ) {
\r
4670 results.splice( i--, 1 );
\r
4678 Sizzle.error = function( msg ) {
\r
4679 throw new Error( "Syntax error, unrecognized expression: " + msg );
\r
4682 function tokenize( selector, parseOnly ) {
\r
4683 var matched, match, tokens, type, soFar, groups, preFilters,
\r
4684 cached = tokenCache[ expando ][ selector ];
\r
4687 return parseOnly ? 0 : cached.slice( 0 );
\r
4692 preFilters = Expr.preFilter;
\r
4696 // Comma and first run
\r
4697 if ( !matched || (match = rcomma.exec( soFar )) ) {
\r
4699 soFar = soFar.slice( match[0].length );
\r
4701 groups.push( tokens = [] );
\r
4707 if ( (match = rcombinators.exec( soFar )) ) {
\r
4708 tokens.push( matched = new Token( match.shift() ) );
\r
4709 soFar = soFar.slice( matched.length );
\r
4711 // Cast descendant combinators to space
\r
4712 matched.type = match[0].replace( rtrim, " " );
\r
4716 for ( type in Expr.filter ) {
\r
4717 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
\r
4718 // The last two arguments here are (context, xml) for backCompat
\r
4719 (match = preFilters[ type ]( match, document, true ))) ) {
\r
4721 tokens.push( matched = new Token( match.shift() ) );
\r
4722 soFar = soFar.slice( matched.length );
\r
4723 matched.type = type;
\r
4724 matched.matches = match;
\r
4733 // Return the length of the invalid excess
\r
4734 // if we're just parsing
\r
4735 // Otherwise, throw an error or return tokens
\r
4736 return parseOnly ?
\r
4739 Sizzle.error( selector ) :
\r
4740 // Cache the tokens
\r
4741 tokenCache( selector, groups ).slice( 0 );
\r
4744 function addCombinator( matcher, combinator, base ) {
\r
4745 var dir = combinator.dir,
\r
4746 checkNonElements = base && combinator.dir === "parentNode",
\r
4747 doneName = done++;
\r
4749 return combinator.first ?
\r
4750 // Check against closest ancestor/preceding element
\r
4751 function( elem, context, xml ) {
\r
4752 while ( (elem = elem[ dir ]) ) {
\r
4753 if ( checkNonElements || elem.nodeType === 1 ) {
\r
4754 return matcher( elem, context, xml );
\r
4759 // Check against all ancestor/preceding elements
\r
4760 function( elem, context, xml ) {
\r
4761 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
\r
4764 dirkey = dirruns + " " + doneName + " ",
\r
4765 cachedkey = dirkey + cachedruns;
\r
4766 while ( (elem = elem[ dir ]) ) {
\r
4767 if ( checkNonElements || elem.nodeType === 1 ) {
\r
4768 if ( (cache = elem[ expando ]) === cachedkey ) {
\r
4769 return elem.sizset;
\r
4770 } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
\r
4771 if ( elem.sizset ) {
\r
4775 elem[ expando ] = cachedkey;
\r
4776 if ( matcher( elem, context, xml ) ) {
\r
4777 elem.sizset = true;
\r
4780 elem.sizset = false;
\r
4785 while ( (elem = elem[ dir ]) ) {
\r
4786 if ( checkNonElements || elem.nodeType === 1 ) {
\r
4787 if ( matcher( elem, context, xml ) ) {
\r
4796 function elementMatcher( matchers ) {
\r
4797 return matchers.length > 1 ?
\r
4798 function( elem, context, xml ) {
\r
4799 var i = matchers.length;
\r
4801 if ( !matchers[i]( elem, context, xml ) ) {
\r
4810 function condense( unmatched, map, filter, context, xml ) {
\r
4812 newUnmatched = [],
\r
4814 len = unmatched.length,
\r
4815 mapped = map != null;
\r
4817 for ( ; i < len; i++ ) {
\r
4818 if ( (elem = unmatched[i]) ) {
\r
4819 if ( !filter || filter( elem, context, xml ) ) {
\r
4820 newUnmatched.push( elem );
\r
4828 return newUnmatched;
\r
4831 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
\r
4832 if ( postFilter && !postFilter[ expando ] ) {
\r
4833 postFilter = setMatcher( postFilter );
\r
4835 if ( postFinder && !postFinder[ expando ] ) {
\r
4836 postFinder = setMatcher( postFinder, postSelector );
\r
4838 return markFunction(function( seed, results, context, xml ) {
\r
4839 // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones
\r
4840 if ( seed && postFinder ) {
\r
4844 var i, elem, postFilterIn,
\r
4847 preexisting = results.length,
\r
4849 // Get initial elements from seed or context
\r
4850 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),
\r
4852 // Prefilter to get matcher input, preserving a map for seed-results synchronization
\r
4853 matcherIn = preFilter && ( seed || !selector ) ?
\r
4854 condense( elems, preMap, preFilter, context, xml ) :
\r
4857 matcherOut = matcher ?
\r
4858 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
\r
4859 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
\r
4861 // ...intermediate processing is necessary
\r
4864 // ...otherwise use results directly
\r
4868 // Find primary matches
\r
4870 matcher( matcherIn, matcherOut, context, xml );
\r
4873 // Apply postFilter
\r
4874 if ( postFilter ) {
\r
4875 postFilterIn = condense( matcherOut, postMap );
\r
4876 postFilter( postFilterIn, [], context, xml );
\r
4878 // Un-match failing elements by moving them back to matcherIn
\r
4879 i = postFilterIn.length;
\r
4881 if ( (elem = postFilterIn[i]) ) {
\r
4882 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
\r
4887 // Keep seed and results synchronized
\r
4889 // Ignore postFinder because it can't coexist with seed
\r
4890 i = preFilter && matcherOut.length;
\r
4892 if ( (elem = matcherOut[i]) ) {
\r
4893 seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);
\r
4897 matcherOut = condense(
\r
4898 matcherOut === results ?
\r
4899 matcherOut.splice( preexisting, matcherOut.length ) :
\r
4902 if ( postFinder ) {
\r
4903 postFinder( null, results, matcherOut, xml );
\r
4905 push.apply( results, matcherOut );
\r
4911 function matcherFromTokens( tokens ) {
\r
4912 var checkContext, matcher, j,
\r
4913 len = tokens.length,
\r
4914 leadingRelative = Expr.relative[ tokens[0].type ],
\r
4915 implicitRelative = leadingRelative || Expr.relative[" "],
\r
4916 i = leadingRelative ? 1 : 0,
\r
4918 // The foundational matcher ensures that elements are reachable from top-level context(s)
\r
4919 matchContext = addCombinator( function( elem ) {
\r
4920 return elem === checkContext;
\r
4921 }, implicitRelative, true ),
\r
4922 matchAnyContext = addCombinator( function( elem ) {
\r
4923 return indexOf.call( checkContext, elem ) > -1;
\r
4924 }, implicitRelative, true ),
\r
4925 matchers = [ function( elem, context, xml ) {
\r
4926 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
\r
4927 (checkContext = context).nodeType ?
\r
4928 matchContext( elem, context, xml ) :
\r
4929 matchAnyContext( elem, context, xml ) );
\r
4932 for ( ; i < len; i++ ) {
\r
4933 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
\r
4934 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
\r
4936 // The concatenated values are (context, xml) for backCompat
\r
4937 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
\r
4939 // Return special upon seeing a positional matcher
\r
4940 if ( matcher[ expando ] ) {
\r
4941 // Find the next relative operator (if any) for proper handling
\r
4943 for ( ; j < len; j++ ) {
\r
4944 if ( Expr.relative[ tokens[j].type ] ) {
\r
4948 return setMatcher(
\r
4949 i > 1 && elementMatcher( matchers ),
\r
4950 i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
\r
4952 i < j && matcherFromTokens( tokens.slice( i, j ) ),
\r
4953 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
\r
4954 j < len && tokens.join("")
\r
4957 matchers.push( matcher );
\r
4961 return elementMatcher( matchers );
\r
4964 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
\r
4965 var bySet = setMatchers.length > 0,
\r
4966 byElement = elementMatchers.length > 0,
\r
4967 superMatcher = function( seed, context, xml, results, expandContext ) {
\r
4968 var elem, j, matcher,
\r
4972 unmatched = seed && [],
\r
4973 outermost = expandContext != null,
\r
4974 contextBackup = outermostContext,
\r
4975 // We must always have either seed elements or context
\r
4976 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
\r
4977 // Nested matchers should use non-integer dirruns
\r
4978 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
\r
4980 if ( outermost ) {
\r
4981 outermostContext = context !== document && context;
\r
4982 cachedruns = superMatcher.el;
\r
4985 // Add elements passing elementMatchers directly to results
\r
4986 for ( ; (elem = elems[i]) != null; i++ ) {
\r
4987 if ( byElement && elem ) {
\r
4988 for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
\r
4989 if ( matcher( elem, context, xml ) ) {
\r
4990 results.push( elem );
\r
4994 if ( outermost ) {
\r
4995 dirruns = dirrunsUnique;
\r
4996 cachedruns = ++superMatcher.el;
\r
5000 // Track unmatched elements for set filters
\r
5002 // They will have gone through all possible matchers
\r
5003 if ( (elem = !matcher && elem) ) {
\r
5007 // Lengthen the array for every element, matched or not
\r
5009 unmatched.push( elem );
\r
5014 // Apply set filters to unmatched elements
\r
5015 matchedCount += i;
\r
5016 if ( bySet && i !== matchedCount ) {
\r
5017 for ( j = 0; (matcher = setMatchers[j]); j++ ) {
\r
5018 matcher( unmatched, setMatched, context, xml );
\r
5022 // Reintegrate element matches to eliminate the need for sorting
\r
5023 if ( matchedCount > 0 ) {
\r
5025 if ( !(unmatched[i] || setMatched[i]) ) {
\r
5026 setMatched[i] = pop.call( results );
\r
5031 // Discard index placeholder values to get only actual matches
\r
5032 setMatched = condense( setMatched );
\r
5035 // Add matches to results
\r
5036 push.apply( results, setMatched );
\r
5038 // Seedless set matches succeeding multiple successful matchers stipulate sorting
\r
5039 if ( outermost && !seed && setMatched.length > 0 &&
\r
5040 ( matchedCount + setMatchers.length ) > 1 ) {
\r
5042 Sizzle.uniqueSort( results );
\r
5046 // Override manipulation of globals by nested matchers
\r
5047 if ( outermost ) {
\r
5048 dirruns = dirrunsUnique;
\r
5049 outermostContext = contextBackup;
\r
5055 superMatcher.el = 0;
\r
5057 markFunction( superMatcher ) :
\r
5061 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
\r
5064 elementMatchers = [],
\r
5065 cached = compilerCache[ expando ][ selector ];
\r
5068 // Generate a function of recursive functions that can be used to check each element
\r
5070 group = tokenize( selector );
\r
5074 cached = matcherFromTokens( group[i] );
\r
5075 if ( cached[ expando ] ) {
\r
5076 setMatchers.push( cached );
\r
5078 elementMatchers.push( cached );
\r
5082 // Cache the compiled function
\r
5083 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
\r
5088 function multipleContexts( selector, contexts, results, seed ) {
\r
5090 len = contexts.length;
\r
5091 for ( ; i < len; i++ ) {
\r
5092 Sizzle( selector, contexts[i], results, seed );
\r
5097 function select( selector, context, results, seed, xml ) {
\r
5098 var i, tokens, token, type, find,
\r
5099 match = tokenize( selector ),
\r
5103 // Try to minimize operations if there is only one group
\r
5104 if ( match.length === 1 ) {
\r
5106 // Take a shortcut and set the context if the root selector is an ID
\r
5107 tokens = match[0] = match[0].slice( 0 );
\r
5108 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
\r
5109 context.nodeType === 9 && !xml &&
\r
5110 Expr.relative[ tokens[1].type ] ) {
\r
5112 context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
\r
5117 selector = selector.slice( tokens.shift().length );
\r
5120 // Fetch a seed set for right-to-left matching
\r
5121 for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
\r
5122 token = tokens[i];
\r
5124 // Abort if we hit a combinator
\r
5125 if ( Expr.relative[ (type = token.type) ] ) {
\r
5128 if ( (find = Expr.find[ type ]) ) {
\r
5129 // Search, expanding context for leading sibling combinators
\r
5130 if ( (seed = find(
\r
5131 token.matches[0].replace( rbackslash, "" ),
\r
5132 rsibling.test( tokens[0].type ) && context.parentNode || context,
\r
5136 // If seed is empty or no tokens remain, we can return early
\r
5137 tokens.splice( i, 1 );
\r
5138 selector = seed.length && tokens.join("");
\r
5139 if ( !selector ) {
\r
5140 push.apply( results, slice.call( seed, 0 ) );
\r
5151 // Compile and execute a filtering function
\r
5152 // Provide `match` to avoid retokenization if we modified the selector above
\r
5153 compile( selector, match )(
\r
5158 rsibling.test( selector )
\r
5163 if ( document.querySelectorAll ) {
\r
5165 var disconnectedMatch,
\r
5166 oldSelect = select,
\r
5167 rescape = /'|\\/g,
\r
5168 rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
\r
5170 // qSa(:focus) reports false when true (Chrome 21),
\r
5171 // A support test would require too much code (would include document ready)
\r
5172 rbuggyQSA = [":focus"],
\r
5174 // matchesSelector(:focus) reports false when true (Chrome 21),
\r
5175 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
\r
5176 // A support test would require too much code (would include document ready)
\r
5177 // just skip matchesSelector for :active
\r
5178 rbuggyMatches = [ ":active", ":focus" ],
\r
5179 matches = docElem.matchesSelector ||
\r
5180 docElem.mozMatchesSelector ||
\r
5181 docElem.webkitMatchesSelector ||
\r
5182 docElem.oMatchesSelector ||
\r
5183 docElem.msMatchesSelector;
\r
5185 // Build QSA regex
\r
5186 // Regex strategy adopted from Diego Perini
\r
5187 assert(function( div ) {
\r
5188 // Select is set to empty string on purpose
\r
5189 // This is to test IE's treatment of not explictly
\r
5190 // setting a boolean content attribute,
\r
5191 // since its presence should be enough
\r
5192 // http://bugs.jquery.com/ticket/12359
\r
5193 div.innerHTML = "<select><option selected=''></option></select>";
\r
5195 // IE8 - Some boolean attributes are not treated correctly
\r
5196 if ( !div.querySelectorAll("[selected]").length ) {
\r
5197 rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
\r
5200 // Webkit/Opera - :checked should return selected option elements
\r
5201 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
\r
5202 // IE8 throws error here (do not put tests after this one)
\r
5203 if ( !div.querySelectorAll(":checked").length ) {
\r
5204 rbuggyQSA.push(":checked");
\r
5208 assert(function( div ) {
\r
5210 // Opera 10-12/IE9 - ^= $= *= and empty values
\r
5211 // Should not select anything
\r
5212 div.innerHTML = "<p test=''></p>";
\r
5213 if ( div.querySelectorAll("[test^='']").length ) {
\r
5214 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
\r
5217 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
\r
5218 // IE8 throws error here (do not put tests after this one)
\r
5219 div.innerHTML = "<input type='hidden'/>";
\r
5220 if ( !div.querySelectorAll(":enabled").length ) {
\r
5221 rbuggyQSA.push(":enabled", ":disabled");
\r
5225 // rbuggyQSA always contains :focus, so no need for a length check
\r
5226 rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
\r
5228 select = function( selector, context, results, seed, xml ) {
\r
5229 // Only use querySelectorAll when not filtering,
\r
5230 // when this is not xml,
\r
5231 // and when no QSA bugs apply
\r
5232 if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
\r
5236 newContext = context,
\r
5237 newSelector = context.nodeType === 9 && selector;
\r
5239 // qSA works strangely on Element-rooted queries
\r
5240 // We can work around this by specifying an extra ID on the root
\r
5241 // and working up from there (Thanks to Andrew Dupont for the technique)
\r
5242 // IE 8 doesn't work on object elements
\r
5243 if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
\r
5244 groups = tokenize( selector );
\r
5246 if ( (old = context.getAttribute("id")) ) {
\r
5247 nid = old.replace( rescape, "\\$&" );
\r
5249 context.setAttribute( "id", nid );
\r
5251 nid = "[id='" + nid + "'] ";
\r
5253 i = groups.length;
\r
5255 groups[i] = nid + groups[i].join("");
\r
5257 newContext = rsibling.test( selector ) && context.parentNode || context;
\r
5258 newSelector = groups.join(",");
\r
5261 if ( newSelector ) {
\r
5263 push.apply( results, slice.call( newContext.querySelectorAll(
\r
5267 } catch(qsaError) {
\r
5270 context.removeAttribute("id");
\r
5276 return oldSelect( selector, context, results, seed, xml );
\r
5280 assert(function( div ) {
\r
5281 // Check to see if it's possible to do matchesSelector
\r
5282 // on a disconnected node (IE 9)
\r
5283 disconnectedMatch = matches.call( div, "div" );
\r
5285 // This should fail with an exception
\r
5286 // Gecko does not error, returns false instead
\r
5288 matches.call( div, "[test!='']:sizzle" );
\r
5289 rbuggyMatches.push( "!=", pseudos );
\r
5293 // rbuggyMatches always contains :active and :focus, so no need for a length check
\r
5294 rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
\r
5296 Sizzle.matchesSelector = function( elem, expr ) {
\r
5297 // Make sure that attribute selectors are quoted
\r
5298 expr = expr.replace( rattributeQuotes, "='$1']" );
\r
5300 // rbuggyMatches always contains :active, so no need for an existence check
\r
5301 if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
\r
5303 var ret = matches.call( elem, expr );
\r
5305 // IE 9's matchesSelector returns false on disconnected nodes
\r
5306 if ( ret || disconnectedMatch ||
\r
5307 // As well, disconnected nodes are said to be in a document
\r
5308 // fragment in IE 9
\r
5309 elem.document && elem.document.nodeType !== 11 ) {
\r
5315 return Sizzle( expr, null, null, [ elem ] ).length > 0;
\r
5322 Expr.pseudos["nth"] = Expr.pseudos["eq"];
\r
5325 function setFilters() {}
\r
5326 Expr.filters = setFilters.prototype = Expr.pseudos;
\r
5327 Expr.setFilters = new setFilters();
\r
5329 // Override sizzle attribute retrieval
5330 Sizzle.attr = jQuery.attr;
5331 jQuery.find = Sizzle;
5332 jQuery.expr = Sizzle.selectors;
5333 jQuery.expr[":"] = jQuery.expr.pseudos;
5334 jQuery.unique = Sizzle.uniqueSort;
5335 jQuery.text = Sizzle.getText;
5336 jQuery.isXMLDoc = Sizzle.isXML;
5337 jQuery.contains = Sizzle.contains;
5341 var runtil = /Until$/,
5342 rparentsprev = /^(?:parents|prev(?:Until|All))/,
5343 isSimple = /^.[^:#\[\.,]*$/,
5344 rneedsContext = jQuery.expr.match.needsContext,
5345 // methods guaranteed to produce a unique set when starting from a unique set
5346 guaranteedUnique = {
5354 find: function( selector ) {
5355 var i, l, length, n, r, ret,
5358 if ( typeof selector !== "string" ) {
5359 return jQuery( selector ).filter(function() {
5360 for ( i = 0, l = self.length; i < l; i++ ) {
5361 if ( jQuery.contains( self[ i ], this ) ) {
5368 ret = this.pushStack( "", "find", selector );
5370 for ( i = 0, l = this.length; i < l; i++ ) {
5371 length = ret.length;
5372 jQuery.find( selector, this[i], ret );
5375 // Make sure that the results are unique
5376 for ( n = length; n < ret.length; n++ ) {
5377 for ( r = 0; r < length; r++ ) {
5378 if ( ret[r] === ret[n] ) {
5390 has: function( target ) {
5392 targets = jQuery( target, this ),
5393 len = targets.length;
5395 return this.filter(function() {
5396 for ( i = 0; i < len; i++ ) {
5397 if ( jQuery.contains( this, targets[i] ) ) {
5404 not: function( selector ) {
5405 return this.pushStack( winnow(this, selector, false), "not", selector);
5408 filter: function( selector ) {
5409 return this.pushStack( winnow(this, selector, true), "filter", selector );
5412 is: function( selector ) {
5413 return !!selector && (
5414 typeof selector === "string" ?
5415 // If this is a positional/relative selector, check membership in the returned set
5416 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5417 rneedsContext.test( selector ) ?
5418 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5419 jQuery.filter( selector, this ).length > 0 :
5420 this.filter( selector ).length > 0 );
5423 closest: function( selectors, context ) {
5428 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5429 jQuery( selectors, context || this.context ) :
5432 for ( ; i < l; i++ ) {
5435 while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5436 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5440 cur = cur.parentNode;
5444 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5446 return this.pushStack( ret, "closest", selectors );
5449 // Determine the position of an element within
5450 // the matched set of elements
5451 index: function( elem ) {
5453 // No argument, return index in parent
5455 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5458 // index in selector
5459 if ( typeof elem === "string" ) {
5460 return jQuery.inArray( this[0], jQuery( elem ) );
5463 // Locate the position of the desired element
5464 return jQuery.inArray(
5465 // If it receives a jQuery object, the first element is used
5466 elem.jquery ? elem[0] : elem, this );
5469 add: function( selector, context ) {
5470 var set = typeof selector === "string" ?
5471 jQuery( selector, context ) :
5472 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5473 all = jQuery.merge( this.get(), set );
5475 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5477 jQuery.unique( all ) );
5480 addBack: function( selector ) {
5481 return this.add( selector == null ?
5482 this.prevObject : this.prevObject.filter(selector)
5487 jQuery.fn.andSelf = jQuery.fn.addBack;
5489 // A painfully simple check to see if an element is disconnected
5490 // from a document (should be improved, where feasible).
5491 function isDisconnected( node ) {
5492 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5495 function sibling( cur, dir ) {
5498 } while ( cur && cur.nodeType !== 1 );
5504 parent: function( elem ) {
5505 var parent = elem.parentNode;
5506 return parent && parent.nodeType !== 11 ? parent : null;
5508 parents: function( elem ) {
5509 return jQuery.dir( elem, "parentNode" );
5511 parentsUntil: function( elem, i, until ) {
5512 return jQuery.dir( elem, "parentNode", until );
5514 next: function( elem ) {
5515 return sibling( elem, "nextSibling" );
5517 prev: function( elem ) {
5518 return sibling( elem, "previousSibling" );
5520 nextAll: function( elem ) {
5521 return jQuery.dir( elem, "nextSibling" );
5523 prevAll: function( elem ) {
5524 return jQuery.dir( elem, "previousSibling" );
5526 nextUntil: function( elem, i, until ) {
5527 return jQuery.dir( elem, "nextSibling", until );
5529 prevUntil: function( elem, i, until ) {
5530 return jQuery.dir( elem, "previousSibling", until );
5532 siblings: function( elem ) {
5533 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5535 children: function( elem ) {
5536 return jQuery.sibling( elem.firstChild );
5538 contents: function( elem ) {
5539 return jQuery.nodeName( elem, "iframe" ) ?
5540 elem.contentDocument || elem.contentWindow.document :
5541 jQuery.merge( [], elem.childNodes );
5543 }, function( name, fn ) {
5544 jQuery.fn[ name ] = function( until, selector ) {
5545 var ret = jQuery.map( this, fn, until );
5547 if ( !runtil.test( name ) ) {
5551 if ( selector && typeof selector === "string" ) {
5552 ret = jQuery.filter( selector, ret );
5555 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5557 if ( this.length > 1 && rparentsprev.test( name ) ) {
5558 ret = ret.reverse();
5561 return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
5566 filter: function( expr, elems, not ) {
5568 expr = ":not(" + expr + ")";
5571 return elems.length === 1 ?
5572 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5573 jQuery.find.matches(expr, elems);
5576 dir: function( elem, dir, until ) {
5580 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5581 if ( cur.nodeType === 1 ) {
5582 matched.push( cur );
5589 sibling: function( n, elem ) {
5592 for ( ; n; n = n.nextSibling ) {
5593 if ( n.nodeType === 1 && n !== elem ) {
5602 // Implement the identical functionality for filter and not
5603 function winnow( elements, qualifier, keep ) {
5605 // Can't pass null or undefined to indexOf in Firefox 4
5606 // Set to 0 to skip string check
5607 qualifier = qualifier || 0;
5609 if ( jQuery.isFunction( qualifier ) ) {
5610 return jQuery.grep(elements, function( elem, i ) {
5611 var retVal = !!qualifier.call( elem, i, elem );
5612 return retVal === keep;
5615 } else if ( qualifier.nodeType ) {
5616 return jQuery.grep(elements, function( elem, i ) {
5617 return ( elem === qualifier ) === keep;
5620 } else if ( typeof qualifier === "string" ) {
5621 var filtered = jQuery.grep(elements, function( elem ) {
5622 return elem.nodeType === 1;
5625 if ( isSimple.test( qualifier ) ) {
5626 return jQuery.filter(qualifier, filtered, !keep);
5628 qualifier = jQuery.filter( qualifier, filtered );
5632 return jQuery.grep(elements, function( elem, i ) {
5633 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5636 function createSafeFragment( document ) {
5637 var list = nodeNames.split( "|" ),
5638 safeFrag = document.createDocumentFragment();
5640 if ( safeFrag.createElement ) {
5641 while ( list.length ) {
5642 safeFrag.createElement(
5650 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5651 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5652 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5653 rleadingWhitespace = /^\s+/,
5654 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5655 rtagName = /<([\w:]+)/,
5657 rhtml = /<|&#?\w+;/,
5658 rnoInnerhtml = /<(?:script|style|link)/i,
5659 rnocache = /<(?:script|object|embed|option|style)/i,
5660 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5661 rcheckableType = /^(?:checkbox|radio)$/,
5662 // checked="checked" or checked
5663 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5664 rscriptType = /\/(java|ecma)script/i,
5665 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
5667 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5668 legend: [ 1, "<fieldset>", "</fieldset>" ],
5669 thead: [ 1, "<table>", "</table>" ],
5670 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5671 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5672 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5673 area: [ 1, "<map>", "</map>" ],
5674 _default: [ 0, "", "" ]
5676 safeFragment = createSafeFragment( document ),
5677 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5679 wrapMap.optgroup = wrapMap.option;
5680 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5681 wrapMap.th = wrapMap.td;
5683 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5684 // unless wrapped in a div with non-breaking characters in front of it.
5685 if ( !jQuery.support.htmlSerialize ) {
5686 wrapMap._default = [ 1, "X<div>", "</div>" ];
5690 text: function( value ) {
5691 return jQuery.access( this, function( value ) {
5692 return value === undefined ?
5693 jQuery.text( this ) :
5694 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5695 }, null, value, arguments.length );
5698 wrapAll: function( html ) {
5699 if ( jQuery.isFunction( html ) ) {
5700 return this.each(function(i) {
5701 jQuery(this).wrapAll( html.call(this, i) );
5706 // The elements to wrap the target around
5707 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5709 if ( this[0].parentNode ) {
5710 wrap.insertBefore( this[0] );
5713 wrap.map(function() {
5716 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5717 elem = elem.firstChild;
5727 wrapInner: function( html ) {
5728 if ( jQuery.isFunction( html ) ) {
5729 return this.each(function(i) {
5730 jQuery(this).wrapInner( html.call(this, i) );
5734 return this.each(function() {
5735 var self = jQuery( this ),
5736 contents = self.contents();
5738 if ( contents.length ) {
5739 contents.wrapAll( html );
5742 self.append( html );
5747 wrap: function( html ) {
5748 var isFunction = jQuery.isFunction( html );
5750 return this.each(function(i) {
5751 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5755 unwrap: function() {
5756 return this.parent().each(function() {
5757 if ( !jQuery.nodeName( this, "body" ) ) {
5758 jQuery( this ).replaceWith( this.childNodes );
5763 append: function() {
5764 return this.domManip(arguments, true, function( elem ) {
5765 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5766 this.appendChild( elem );
5771 prepend: function() {
5772 return this.domManip(arguments, true, function( elem ) {
5773 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5774 this.insertBefore( elem, this.firstChild );
5779 before: function() {
5780 if ( !isDisconnected( this[0] ) ) {
5781 return this.domManip(arguments, false, function( elem ) {
5782 this.parentNode.insertBefore( elem, this );
5786 if ( arguments.length ) {
5787 var set = jQuery.clean( arguments );
5788 return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
5793 if ( !isDisconnected( this[0] ) ) {
5794 return this.domManip(arguments, false, function( elem ) {
5795 this.parentNode.insertBefore( elem, this.nextSibling );
5799 if ( arguments.length ) {
5800 var set = jQuery.clean( arguments );
5801 return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
5805 // keepData is for internal use only--do not document
5806 remove: function( selector, keepData ) {
5810 for ( ; (elem = this[i]) != null; i++ ) {
5811 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5812 if ( !keepData && elem.nodeType === 1 ) {
5813 jQuery.cleanData( elem.getElementsByTagName("*") );
5814 jQuery.cleanData( [ elem ] );
5817 if ( elem.parentNode ) {
5818 elem.parentNode.removeChild( elem );
5830 for ( ; (elem = this[i]) != null; i++ ) {
5831 // Remove element nodes and prevent memory leaks
5832 if ( elem.nodeType === 1 ) {
5833 jQuery.cleanData( elem.getElementsByTagName("*") );
5836 // Remove any remaining nodes
5837 while ( elem.firstChild ) {
5838 elem.removeChild( elem.firstChild );
5845 clone: function( dataAndEvents, deepDataAndEvents ) {
5846 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5847 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5849 return this.map( function () {
5850 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5854 html: function( value ) {
5855 return jQuery.access( this, function( value ) {
5856 var elem = this[0] || {},
5860 if ( value === undefined ) {
5861 return elem.nodeType === 1 ?
5862 elem.innerHTML.replace( rinlinejQuery, "" ) :
5866 // See if we can take a shortcut and just use innerHTML
5867 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5868 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5869 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5870 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
5872 value = value.replace( rxhtmlTag, "<$1></$2>" );
5875 for (; i < l; i++ ) {
5876 // Remove element nodes and prevent memory leaks
5877 elem = this[i] || {};
5878 if ( elem.nodeType === 1 ) {
5879 jQuery.cleanData( elem.getElementsByTagName( "*" ) );
5880 elem.innerHTML = value;
5886 // If using innerHTML throws an exception, use the fallback method
5891 this.empty().append( value );
5893 }, null, value, arguments.length );
5896 replaceWith: function( value ) {
5897 if ( !isDisconnected( this[0] ) ) {
5898 // Make sure that the elements are removed from the DOM before they are inserted
5899 // this can help fix replacing a parent with child elements
5900 if ( jQuery.isFunction( value ) ) {
5901 return this.each(function(i) {
5902 var self = jQuery(this), old = self.html();
5903 self.replaceWith( value.call( this, i, old ) );
5907 if ( typeof value !== "string" ) {
5908 value = jQuery( value ).detach();
5911 return this.each(function() {
5912 var next = this.nextSibling,
5913 parent = this.parentNode;
5915 jQuery( this ).remove();
5918 jQuery(next).before( value );
5920 jQuery(parent).append( value );
5925 return this.length ?
5926 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5930 detach: function( selector ) {
5931 return this.remove( selector, true );
5934 domManip: function( args, table, callback ) {
5936 // Flatten any nested arrays
5937 args = [].concat.apply( [], args );
5939 var results, first, fragment, iNoClone,
5945 // We can't cloneNode fragments that contain checked, in WebKit
5946 if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
5947 return this.each(function() {
5948 jQuery(this).domManip( args, table, callback );
5952 if ( jQuery.isFunction(value) ) {
5953 return this.each(function(i) {
5954 var self = jQuery(this);
5955 args[0] = value.call( this, i, table ? self.html() : undefined );
5956 self.domManip( args, table, callback );
5961 results = jQuery.buildFragment( args, this, scripts );
5962 fragment = results.fragment;
5963 first = fragment.firstChild;
5965 if ( fragment.childNodes.length === 1 ) {
5970 table = table && jQuery.nodeName( first, "tr" );
5972 // Use the original fragment for the last item instead of the first because it can end up
5973 // being emptied incorrectly in certain situations (#8070).
5974 // Fragments from the fragment cache must always be cloned and never used in place.
5975 for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
5977 table && jQuery.nodeName( this[i], "table" ) ?
5978 findOrAppend( this[i], "tbody" ) :
5982 jQuery.clone( fragment, true, true )
5987 // Fix #11809: Avoid leaking memory
5988 fragment = first = null;
5990 if ( scripts.length ) {
5991 jQuery.each( scripts, function( i, elem ) {
5993 if ( jQuery.ajax ) {
6003 jQuery.error("no ajax");
6006 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
6009 if ( elem.parentNode ) {
6010 elem.parentNode.removeChild( elem );
6020 function findOrAppend( elem, tag ) {
6021 return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
6024 function cloneCopyEvent( src, dest ) {
6026 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6031 oldData = jQuery._data( src ),
6032 curData = jQuery._data( dest, oldData ),
6033 events = oldData.events;
6036 delete curData.handle;
6037 curData.events = {};
6039 for ( type in events ) {
6040 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6041 jQuery.event.add( dest, type, events[ type ][ i ] );
6046 // make the cloned public data object a copy from the original
6047 if ( curData.data ) {
6048 curData.data = jQuery.extend( {}, curData.data );
6052 function cloneFixAttributes( src, dest ) {
6055 // We do not need to do anything for non-Elements
6056 if ( dest.nodeType !== 1 ) {
6060 // clearAttributes removes the attributes, which we don't want,
6061 // but also removes the attachEvent events, which we *do* want
6062 if ( dest.clearAttributes ) {
6063 dest.clearAttributes();
6066 // mergeAttributes, in contrast, only merges back on the
6067 // original attributes, not the events
6068 if ( dest.mergeAttributes ) {
6069 dest.mergeAttributes( src );
6072 nodeName = dest.nodeName.toLowerCase();
6074 if ( nodeName === "object" ) {
6075 // IE6-10 improperly clones children of object elements using classid.
6076 // IE10 throws NoModificationAllowedError if parent is null, #12132.
6077 if ( dest.parentNode ) {
6078 dest.outerHTML = src.outerHTML;
6081 // This path appears unavoidable for IE9. When cloning an object
6082 // element in IE9, the outerHTML strategy above is not sufficient.
6083 // If the src has innerHTML and the destination does not,
6084 // copy the src.innerHTML into the dest.innerHTML. #10324
6085 if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
6086 dest.innerHTML = src.innerHTML;
6089 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
6090 // IE6-8 fails to persist the checked state of a cloned checkbox
6091 // or radio button. Worse, IE6-7 fail to give the cloned element
6092 // a checked appearance if the defaultChecked value isn't also set
6094 dest.defaultChecked = dest.checked = src.checked;
6096 // IE6-7 get confused and end up setting the value of a cloned
6097 // checkbox/radio button to an empty string instead of "on"
6098 if ( dest.value !== src.value ) {
6099 dest.value = src.value;
6102 // IE6-8 fails to return the selected option to the default selected
6103 // state when cloning options
6104 } else if ( nodeName === "option" ) {
6105 dest.selected = src.defaultSelected;
6107 // IE6-8 fails to set the defaultValue to the correct value when
6108 // cloning other types of input fields
6109 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6110 dest.defaultValue = src.defaultValue;
6112 // IE blanks contents when cloning scripts
6113 } else if ( nodeName === "script" && dest.text !== src.text ) {
6114 dest.text = src.text;
6117 // Event data gets referenced instead of copied if the expando
6119 dest.removeAttribute( jQuery.expando );
6122 jQuery.buildFragment = function( args, context, scripts ) {
6123 var fragment, cacheable, cachehit,
6126 // Set context from what may come in as undefined or a jQuery collection or a node
6127 // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
6128 // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
6129 context = context || document;
6130 context = !context.nodeType && context[0] || context;
6131 context = context.ownerDocument || context;
6133 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6134 // Cloning options loses the selected state, so don't cache them
6135 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6136 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6137 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6138 if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
6139 first.charAt(0) === "<" && !rnocache.test( first ) &&
6140 (jQuery.support.checkClone || !rchecked.test( first )) &&
6141 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
6143 // Mark cacheable and look for a hit
6145 fragment = jQuery.fragments[ first ];
6146 cachehit = fragment !== undefined;
6150 fragment = context.createDocumentFragment();
6151 jQuery.clean( args, context, fragment, scripts );
6153 // Update the cache, but only store false
6154 // unless this is a second parsing of the same content
6156 jQuery.fragments[ first ] = cachehit && fragment;
6160 return { fragment: fragment, cacheable: cacheable };
6163 jQuery.fragments = {};
6167 prependTo: "prepend",
6168 insertBefore: "before",
6169 insertAfter: "after",
6170 replaceAll: "replaceWith"
6171 }, function( name, original ) {
6172 jQuery.fn[ name ] = function( selector ) {
6176 insert = jQuery( selector ),
6178 parent = this.length === 1 && this[0].parentNode;
6180 if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
6181 insert[ original ]( this[0] );
6184 for ( ; i < l; i++ ) {
6185 elems = ( i > 0 ? this.clone(true) : this ).get();
6186 jQuery( insert[i] )[ original ]( elems );
6187 ret = ret.concat( elems );
6190 return this.pushStack( ret, name, insert.selector );
6195 function getAll( elem ) {
6196 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6197 return elem.getElementsByTagName( "*" );
6199 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6200 return elem.querySelectorAll( "*" );
6207 // Used in clean, fixes the defaultChecked property
6208 function fixDefaultChecked( elem ) {
6209 if ( rcheckableType.test( elem.type ) ) {
6210 elem.defaultChecked = elem.checked;
6215 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6221 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6222 clone = elem.cloneNode( true );
6224 // IE<=8 does not properly clone detached, unknown element nodes
6226 fragmentDiv.innerHTML = elem.outerHTML;
6227 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6230 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6231 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6232 // IE copies events bound via attachEvent when using cloneNode.
6233 // Calling detachEvent on the clone will also remove the events
6234 // from the original. In order to get around this, we use some
6235 // proprietary methods to clear the events. Thanks to MooTools
6236 // guys for this hotness.
6238 cloneFixAttributes( elem, clone );
6240 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6241 srcElements = getAll( elem );
6242 destElements = getAll( clone );
6244 // Weird iteration because IE will replace the length property
6245 // with an element if you are cloning the body and one of the
6246 // elements on the page has a name or id of "length"
6247 for ( i = 0; srcElements[i]; ++i ) {
6248 // Ensure that the destination node is not null; Fixes #9587
6249 if ( destElements[i] ) {
6250 cloneFixAttributes( srcElements[i], destElements[i] );
6255 // Copy the events from the original to the clone
6256 if ( dataAndEvents ) {
6257 cloneCopyEvent( elem, clone );
6259 if ( deepDataAndEvents ) {
6260 srcElements = getAll( elem );
6261 destElements = getAll( clone );
6263 for ( i = 0; srcElements[i]; ++i ) {
6264 cloneCopyEvent( srcElements[i], destElements[i] );
6269 srcElements = destElements = null;
6271 // Return the cloned set
6275 clean: function( elems, context, fragment, scripts ) {
6276 var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6277 safe = context === document && safeFragment,
6280 // Ensure that context is a document
6281 if ( !context || typeof context.createDocumentFragment === "undefined" ) {
6285 // Use the already-created safe fragment if context permits
6286 for ( i = 0; (elem = elems[i]) != null; i++ ) {
6287 if ( typeof elem === "number" ) {
6295 // Convert html string into DOM nodes
6296 if ( typeof elem === "string" ) {
6297 if ( !rhtml.test( elem ) ) {
6298 elem = context.createTextNode( elem );
6300 // Ensure a safe container in which to render the html
6301 safe = safe || createSafeFragment( context );
6302 div = context.createElement("div");
6303 safe.appendChild( div );
6305 // Fix "XHTML"-style tags in all browsers
6306 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6308 // Go to html and back, then peel off extra wrappers
6309 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6310 wrap = wrapMap[ tag ] || wrapMap._default;
6312 div.innerHTML = wrap[1] + elem + wrap[2];
6314 // Move to the right depth
6316 div = div.lastChild;
6319 // Remove IE's autoinserted <tbody> from table fragments
6320 if ( !jQuery.support.tbody ) {
6322 // String was a <table>, *may* have spurious <tbody>
6323 hasBody = rtbody.test(elem);
6324 tbody = tag === "table" && !hasBody ?
6325 div.firstChild && div.firstChild.childNodes :
6327 // String was a bare <thead> or <tfoot>
6328 wrap[1] === "<table>" && !hasBody ?
6332 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6333 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6334 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6339 // IE completely kills leading whitespace when innerHTML is used
6340 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6341 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6344 elem = div.childNodes;
6346 // Take out of fragment container (we need a fresh div each time)
6347 div.parentNode.removeChild( div );
6351 if ( elem.nodeType ) {
6354 jQuery.merge( ret, elem );
6358 // Fix #11356: Clear elements from safeFragment
6360 elem = div = safe = null;
6363 // Reset defaultChecked for any radios and checkboxes
6364 // about to be appended to the DOM in IE 6/7 (#8060)
6365 if ( !jQuery.support.appendChecked ) {
6366 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6367 if ( jQuery.nodeName( elem, "input" ) ) {
6368 fixDefaultChecked( elem );
6369 } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
6370 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6375 // Append elements to a provided document fragment
6377 // Special handling of each script element
6378 handleScript = function( elem ) {
6379 // Check if we consider it executable
6380 if ( !elem.type || rscriptType.test( elem.type ) ) {
6381 // Detach the script and store it in the scripts array (if provided) or the fragment
6382 // Return truthy to indicate that it has been handled
6384 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
6385 fragment.appendChild( elem );
6389 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6390 // Check if we're done after handling an executable script
6391 if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
6392 // Append to fragment and handle embedded scripts
6393 fragment.appendChild( elem );
6394 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6395 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
6396 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
6398 // Splice the scripts into ret after their former ancestor and advance our index beyond them
6399 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6409 cleanData: function( elems, /* internal */ acceptData ) {
6410 var data, id, elem, type,
6412 internalKey = jQuery.expando,
6413 cache = jQuery.cache,
6414 deleteExpando = jQuery.support.deleteExpando,
6415 special = jQuery.event.special;
6417 for ( ; (elem = elems[i]) != null; i++ ) {
6419 if ( acceptData || jQuery.acceptData( elem ) ) {
6421 id = elem[ internalKey ];
6422 data = id && cache[ id ];
6425 if ( data.events ) {
6426 for ( type in data.events ) {
6427 if ( special[ type ] ) {
6428 jQuery.event.remove( elem, type );
6430 // This is a shortcut to avoid jQuery.event.remove's overhead
6432 jQuery.removeEvent( elem, type, data.handle );
6437 // Remove cache only if it was not already removed by jQuery.event.remove
6438 if ( cache[ id ] ) {
6442 // IE does not allow us to delete expando properties from nodes,
6443 // nor does it have a removeAttribute function on Document nodes;
6444 // we must handle all of these cases
6445 if ( deleteExpando ) {
6446 delete elem[ internalKey ];
6448 } else if ( elem.removeAttribute ) {
6449 elem.removeAttribute( internalKey );
6452 elem[ internalKey ] = null;
6455 jQuery.deletedIds.push( id );
6462 // Limit scope pollution from any deprecated API
6465 var matched, browser;
6467 // Use of jQuery.browser is frowned upon.
6468 // More details: http://api.jquery.com/jQuery.browser
6469 // jQuery.uaMatch maintained for back-compat
6470 jQuery.uaMatch = function( ua ) {
6471 ua = ua.toLowerCase();
6473 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
6474 /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
6475 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
6476 /(msie) ([\w.]+)/.exec( ua ) ||
6477 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
6481 browser: match[ 1 ] || "",
6482 version: match[ 2 ] || "0"
6486 matched = jQuery.uaMatch( navigator.userAgent );
6489 if ( matched.browser ) {
6490 browser[ matched.browser ] = true;
6491 browser.version = matched.version;
6494 // Chrome is Webkit, but Webkit is also Safari.
6495 if ( browser.chrome ) {
6496 browser.webkit = true;
6497 } else if ( browser.webkit ) {
6498 browser.safari = true;
6501 jQuery.browser = browser;
6503 jQuery.sub = function() {
6504 function jQuerySub( selector, context ) {
6505 return new jQuerySub.fn.init( selector, context );
6507 jQuery.extend( true, jQuerySub, this );
6508 jQuerySub.superclass = this;
6509 jQuerySub.fn = jQuerySub.prototype = this();
6510 jQuerySub.fn.constructor = jQuerySub;
6511 jQuerySub.sub = this.sub;
6512 jQuerySub.fn.init = function init( selector, context ) {
6513 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
6514 context = jQuerySub( context );
6517 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
6519 jQuerySub.fn.init.prototype = jQuerySub.fn;
6520 var rootjQuerySub = jQuerySub(document);
6525 var curCSS, iframe, iframeDoc,
6526 ralpha = /alpha\([^)]*\)/i,
6527 ropacity = /opacity=([^)]*)/,
6528 rposition = /^(top|right|bottom|left)$/,
6529 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6530 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6531 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6532 rmargin = /^margin/,
6533 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6534 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6535 rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
6538 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6539 cssNormalTransform = {
6544 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6545 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
6547 eventsToggle = jQuery.fn.toggle;
6549 // return a css property mapped to a potentially vendor prefixed property
6550 function vendorPropName( style, name ) {
6552 // shortcut for names that are not vendor prefixed
6553 if ( name in style ) {
6557 // check for vendor prefixed names
6558 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6560 i = cssPrefixes.length;
6563 name = cssPrefixes[ i ] + capName;
6564 if ( name in style ) {
6572 function isHidden( elem, el ) {
6574 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6577 function showHide( elements, show ) {
6581 length = elements.length;
6583 for ( ; index < length; index++ ) {
6584 elem = elements[ index ];
6585 if ( !elem.style ) {
6588 values[ index ] = jQuery._data( elem, "olddisplay" );
6590 // Reset the inline display of this element to learn if it is
6591 // being hidden by cascaded rules or not
6592 if ( !values[ index ] && elem.style.display === "none" ) {
6593 elem.style.display = "";
6596 // Set elements which have been overridden with display: none
6597 // in a stylesheet to whatever the default browser style is
6598 // for such an element
6599 if ( elem.style.display === "" && isHidden( elem ) ) {
6600 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6603 display = curCSS( elem, "display" );
6605 if ( !values[ index ] && display !== "none" ) {
6606 jQuery._data( elem, "olddisplay", display );
6611 // Set the display of most of the elements in a second loop
6612 // to avoid the constant reflow
6613 for ( index = 0; index < length; index++ ) {
6614 elem = elements[ index ];
6615 if ( !elem.style ) {
6618 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6619 elem.style.display = show ? values[ index ] || "" : "none";
6627 css: function( name, value ) {
6628 return jQuery.access( this, function( elem, name, value ) {
6629 return value !== undefined ?
6630 jQuery.style( elem, name, value ) :
6631 jQuery.css( elem, name );
6632 }, name, value, arguments.length > 1 );
6635 return showHide( this, true );
6638 return showHide( this );
6640 toggle: function( state, fn2 ) {
6641 var bool = typeof state === "boolean";
6643 if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
6644 return eventsToggle.apply( this, arguments );
6647 return this.each(function() {
6648 if ( bool ? state : isHidden( this ) ) {
6649 jQuery( this ).show();
6651 jQuery( this ).hide();
6658 // Add in style property hooks for overriding the default
6659 // behavior of getting and setting a style property
6662 get: function( elem, computed ) {
6664 // We should always get a number back from opacity
6665 var ret = curCSS( elem, "opacity" );
6666 return ret === "" ? "1" : ret;
6673 // Exclude the following css properties to add px
6675 "fillOpacity": true,
6685 // Add in properties whose names you wish to fix before
6686 // setting or getting the value
6688 // normalize float css property
6689 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6692 // Get and set the style property on a DOM Node
6693 style: function( elem, name, value, extra ) {
6694 // Don't set styles on text and comment nodes
6695 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6699 // Make sure that we're working with the right name
6700 var ret, type, hooks,
6701 origName = jQuery.camelCase( name ),
6704 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6706 // gets hook for the prefixed version
6707 // followed by the unprefixed version
6708 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6710 // Check if we're setting a value
6711 if ( value !== undefined ) {
6712 type = typeof value;
6714 // convert relative number strings (+= or -=) to relative numbers. #7345
6715 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6716 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6721 // Make sure that NaN and null values aren't set. See: #7116
6722 if ( value == null || type === "number" && isNaN( value ) ) {
6726 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6727 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6731 // If a hook was provided, use that value, otherwise just set the specified value
6732 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6733 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6736 style[ name ] = value;
6741 // If a hook was provided get the non-computed value from there
6742 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6746 // Otherwise just get the value from the style object
6747 return style[ name ];
6751 css: function( elem, name, numeric, extra ) {
6752 var val, num, hooks,
6753 origName = jQuery.camelCase( name );
6755 // Make sure that we're working with the right name
6756 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6758 // gets hook for the prefixed version
6759 // followed by the unprefixed version
6760 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6762 // If a hook was provided get the computed value from there
6763 if ( hooks && "get" in hooks ) {
6764 val = hooks.get( elem, true, extra );
6767 // Otherwise, if a way to get the computed value exists, use that
6768 if ( val === undefined ) {
6769 val = curCSS( elem, name );
6772 //convert "normal" to computed value
6773 if ( val === "normal" && name in cssNormalTransform ) {
6774 val = cssNormalTransform[ name ];
6777 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6778 if ( numeric || extra !== undefined ) {
6779 num = parseFloat( val );
6780 return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
6785 // A method for quickly swapping in/out CSS properties to get correct calculations
6786 swap: function( elem, options, callback ) {
6790 // Remember the old values, and insert the new ones
6791 for ( name in options ) {
6792 old[ name ] = elem.style[ name ];
6793 elem.style[ name ] = options[ name ];
6796 ret = callback.call( elem );
6798 // Revert the old values
6799 for ( name in options ) {
6800 elem.style[ name ] = old[ name ];
6807 // NOTE: To any future maintainer, we've window.getComputedStyle
6808 // because jsdom on node.js will break without it.
6809 if ( window.getComputedStyle ) {
6810 curCSS = function( elem, name ) {
6811 var ret, width, minWidth, maxWidth,
6812 computed = window.getComputedStyle( elem, null ),
6817 ret = computed[ name ];
6818 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6819 ret = jQuery.style( elem, name );
6822 // A tribute to the "awesome hack by Dean Edwards"
6823 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6824 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6825 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6826 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6827 width = style.width;
6828 minWidth = style.minWidth;
6829 maxWidth = style.maxWidth;
6831 style.minWidth = style.maxWidth = style.width = ret;
6832 ret = computed.width;
6834 style.width = width;
6835 style.minWidth = minWidth;
6836 style.maxWidth = maxWidth;
6842 } else if ( document.documentElement.currentStyle ) {
6843 curCSS = function( elem, name ) {
6845 ret = elem.currentStyle && elem.currentStyle[ name ],
6848 // Avoid setting ret to empty string here
6849 // so we don't default to auto
6850 if ( ret == null && style && style[ name ] ) {
6851 ret = style[ name ];
6854 // From the awesome hack by Dean Edwards
6855 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6857 // If we're not dealing with a regular pixel number
6858 // but a number that has a weird ending, we need to convert it to pixels
6859 // but not position css attributes, as those are proportional to the parent element instead
6860 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6861 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6863 // Remember the original values
6865 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6867 // Put in the new values to get a computed value out
6869 elem.runtimeStyle.left = elem.currentStyle.left;
6871 style.left = name === "fontSize" ? "1em" : ret;
6872 ret = style.pixelLeft + "px";
6874 // Revert the changed values
6877 elem.runtimeStyle.left = rsLeft;
6881 return ret === "" ? "auto" : ret;
6885 function setPositiveNumber( elem, value, subtract ) {
6886 var matches = rnumsplit.exec( value );
6888 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6892 function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
6893 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6894 // If we already have the right measurement, avoid augmentation
6896 // Otherwise initialize for horizontal or vertical properties
6897 name === "width" ? 1 : 0,
6901 for ( ; i < 4; i += 2 ) {
6902 // both box models exclude margin, so add it if we want it
6903 if ( extra === "margin" ) {
6904 // we use jQuery.css instead of curCSS here
6905 // because of the reliableMarginRight CSS hook!
6906 val += jQuery.css( elem, extra + cssExpand[ i ], true );
6909 // From this point on we use curCSS for maximum performance (relevant in animations)
6910 if ( isBorderBox ) {
6911 // border-box includes padding, so remove it if we want content
6912 if ( extra === "content" ) {
6913 val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6916 // at this point, extra isn't border nor margin, so remove border
6917 if ( extra !== "margin" ) {
6918 val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6921 // at this point, extra isn't content, so add padding
6922 val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6924 // at this point, extra isn't content nor padding, so add border
6925 if ( extra !== "padding" ) {
6926 val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6934 function getWidthOrHeight( elem, name, extra ) {
6936 // Start with offset property, which is equivalent to the border-box value
6937 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6938 valueIsBorderBox = true,
6939 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
6941 // some non-html elements return undefined for offsetWidth, so check for null/undefined
6942 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6943 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6944 if ( val <= 0 || val == null ) {
6945 // Fall back to computed then uncomputed css if necessary
6946 val = curCSS( elem, name );
6947 if ( val < 0 || val == null ) {
6948 val = elem.style[ name ];
6951 // Computed unit is not pixels. Stop here and return.
6952 if ( rnumnonpx.test(val) ) {
6956 // we need the check for style in case a browser which returns unreliable values
6957 // for getComputedStyle silently falls back to the reliable elem.style
6958 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
6960 // Normalize "", auto, and prepare for extra
6961 val = parseFloat( val ) || 0;
6964 // use the active box-sizing model to add/subtract irrelevant styles
6966 augmentWidthOrHeight(
6969 extra || ( isBorderBox ? "border" : "content" ),
6976 // Try to determine the default display value of an element
6977 function css_defaultDisplay( nodeName ) {
6978 if ( elemdisplay[ nodeName ] ) {
6979 return elemdisplay[ nodeName ];
6982 var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
6983 display = elem.css("display");
6986 // If the simple way fails,
6987 // get element's real default display by attaching it to a temp iframe
6988 if ( display === "none" || display === "" ) {
6989 // Use the already-created iframe if possible
6990 iframe = document.body.appendChild(
6991 iframe || jQuery.extend( document.createElement("iframe"), {
6998 // Create a cacheable copy of the iframe document on first call.
6999 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
7000 // document to it; WebKit & Firefox won't allow reusing the iframe document.
7001 if ( !iframeDoc || !iframe.createElement ) {
7002 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
7003 iframeDoc.write("<!doctype html><html><body>");
7007 elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
7009 display = curCSS( elem, "display" );
7010 document.body.removeChild( iframe );
7013 // Store the correct default display
7014 elemdisplay[ nodeName ] = display;
7019 jQuery.each([ "height", "width" ], function( i, name ) {
7020 jQuery.cssHooks[ name ] = {
7021 get: function( elem, computed, extra ) {
7023 // certain elements can have dimension info if we invisibly show them
7024 // however, it must have a current display style that would benefit from this
7025 if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
7026 return jQuery.swap( elem, cssShow, function() {
7027 return getWidthOrHeight( elem, name, extra );
7030 return getWidthOrHeight( elem, name, extra );
7035 set: function( elem, value, extra ) {
7036 return setPositiveNumber( elem, value, extra ?
7037 augmentWidthOrHeight(
7041 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
7048 if ( !jQuery.support.opacity ) {
7049 jQuery.cssHooks.opacity = {
7050 get: function( elem, computed ) {
7051 // IE uses filters for opacity
7052 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
7053 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7054 computed ? "1" : "";
7057 set: function( elem, value ) {
7058 var style = elem.style,
7059 currentStyle = elem.currentStyle,
7060 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7061 filter = currentStyle && currentStyle.filter || style.filter || "";
7063 // IE has trouble with opacity if it does not have layout
7064 // Force it by setting the zoom level
7067 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
7068 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7069 style.removeAttribute ) {
7071 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7072 // if "filter:" is present at all, clearType is disabled, we want to avoid this
7073 // style.removeAttribute is IE Only, but so apparently is this code path...
7074 style.removeAttribute( "filter" );
7076 // if there there is no filter style applied in a css rule, we are done
7077 if ( currentStyle && !currentStyle.filter ) {
7082 // otherwise, set new filter values
7083 style.filter = ralpha.test( filter ) ?
7084 filter.replace( ralpha, opacity ) :
7085 filter + " " + opacity;
7090 // These hooks cannot be added until DOM ready because the support test
7091 // for it is not run until after DOM ready
7093 if ( !jQuery.support.reliableMarginRight ) {
7094 jQuery.cssHooks.marginRight = {
7095 get: function( elem, computed ) {
7096 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7097 // Work around by temporarily setting element display to inline-block
7098 return jQuery.swap( elem, { "display": "inline-block" }, function() {
7100 return curCSS( elem, "marginRight" );
7107 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7108 // getComputedStyle returns percent when specified for top/left/bottom/right
7109 // rather than make the css module depend on the offset module, we just check for it here
7110 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
7111 jQuery.each( [ "top", "left" ], function( i, prop ) {
7112 jQuery.cssHooks[ prop ] = {
7113 get: function( elem, computed ) {
7115 var ret = curCSS( elem, prop );
7116 // if curCSS returns percentage, fallback to offset
7117 return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
7126 if ( jQuery.expr && jQuery.expr.filters ) {
7127 jQuery.expr.filters.hidden = function( elem ) {
7128 return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
7131 jQuery.expr.filters.visible = function( elem ) {
7132 return !jQuery.expr.filters.hidden( elem );
7136 // These hooks are used by animate to expand properties
7141 }, function( prefix, suffix ) {
7142 jQuery.cssHooks[ prefix + suffix ] = {
7143 expand: function( value ) {
7146 // assumes a single number if not a string
7147 parts = typeof value === "string" ? value.split(" ") : [ value ],
7150 for ( i = 0; i < 4; i++ ) {
7151 expanded[ prefix + cssExpand[ i ] + suffix ] =
7152 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7159 if ( !rmargin.test( prefix ) ) {
7160 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7166 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
7167 rselectTextarea = /^(?:select|textarea)/i;
7170 serialize: function() {
7171 return jQuery.param( this.serializeArray() );
7173 serializeArray: function() {
7174 return this.map(function(){
7175 return this.elements ? jQuery.makeArray( this.elements ) : this;
7178 return this.name && !this.disabled &&
7179 ( this.checked || rselectTextarea.test( this.nodeName ) ||
7180 rinput.test( this.type ) );
7182 .map(function( i, elem ){
7183 var val = jQuery( this ).val();
7185 return val == null ?
7187 jQuery.isArray( val ) ?
7188 jQuery.map( val, function( val, i ){
7189 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7191 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7196 //Serialize an array of form elements or a set of
7197 //key/values into a query string
7198 jQuery.param = function( a, traditional ) {
7201 add = function( key, value ) {
7202 // If value is a function, invoke it and return its value
7203 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7204 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7207 // Set traditional to true for jQuery <= 1.3.2 behavior.
7208 if ( traditional === undefined ) {
7209 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7212 // If an array was passed in, assume that it is an array of form elements.
7213 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7214 // Serialize the form elements
7215 jQuery.each( a, function() {
7216 add( this.name, this.value );
7220 // If traditional, encode the "old" way (the way 1.3.2 or older
7221 // did it), otherwise encode params recursively.
7222 for ( prefix in a ) {
7223 buildParams( prefix, a[ prefix ], traditional, add );
7227 // Return the resulting serialization
7228 return s.join( "&" ).replace( r20, "+" );
7231 function buildParams( prefix, obj, traditional, add ) {
7234 if ( jQuery.isArray( obj ) ) {
7235 // Serialize array item.
7236 jQuery.each( obj, function( i, v ) {
7237 if ( traditional || rbracket.test( prefix ) ) {
7238 // Treat each array item as a scalar.
7242 // If array item is non-scalar (array or object), encode its
7243 // numeric index to resolve deserialization ambiguity issues.
7244 // Note that rack (as of 1.0.0) can't currently deserialize
7245 // nested arrays properly, and attempting to do so may cause
7246 // a server error. Possible fixes are to modify rack's
7247 // deserialization algorithm or to provide an option or flag
7248 // to force array serialization to be shallow.
7249 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7253 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
7254 // Serialize object item.
7255 for ( name in obj ) {
7256 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7260 // Serialize scalar item.
7265 // Document location
7270 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7271 // #7653, #8125, #8152: local protocol detection
7272 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
7273 rnoContent = /^(?:GET|HEAD)$/,
7274 rprotocol = /^\/\//,
7276 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
7277 rts = /([?&])_=[^&]*/,
7278 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7280 // Keep a copy of the old load method
7281 _load = jQuery.fn.load,
7284 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7285 * 2) These are called:
7286 * - BEFORE asking for a transport
7287 * - AFTER param serialization (s.data is a string if s.processData is true)
7288 * 3) key is the dataType
7289 * 4) the catchall symbol "*" can be used
7290 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7294 /* Transports bindings
7295 * 1) key is the dataType
7296 * 2) the catchall symbol "*" can be used
7297 * 3) selection will start with transport dataType and THEN go to "*" if needed
7301 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7302 allTypes = ["*/"] + ["*"];
7304 // #8138, IE may throw an exception when accessing
7305 // a field from window.location if document.domain has been set
7307 ajaxLocation = location.href;
7309 // Use the href attribute of an A element
7310 // since IE will modify it given document.location
7311 ajaxLocation = document.createElement( "a" );
7312 ajaxLocation.href = "";
7313 ajaxLocation = ajaxLocation.href;
7316 // Segment location into parts
7317 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7319 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7320 function addToPrefiltersOrTransports( structure ) {
7322 // dataTypeExpression is optional and defaults to "*"
7323 return function( dataTypeExpression, func ) {
7325 if ( typeof dataTypeExpression !== "string" ) {
7326 func = dataTypeExpression;
7327 dataTypeExpression = "*";
7330 var dataType, list, placeBefore,
7331 dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
7333 length = dataTypes.length;
7335 if ( jQuery.isFunction( func ) ) {
7336 // For each dataType in the dataTypeExpression
7337 for ( ; i < length; i++ ) {
7338 dataType = dataTypes[ i ];
7339 // We control if we're asked to add before
7340 // any existing element
7341 placeBefore = /^\+/.test( dataType );
7342 if ( placeBefore ) {
7343 dataType = dataType.substr( 1 ) || "*";
7345 list = structure[ dataType ] = structure[ dataType ] || [];
7346 // then we add to the structure accordingly
7347 list[ placeBefore ? "unshift" : "push" ]( func );
7353 // Base inspection function for prefilters and transports
7354 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
7355 dataType /* internal */, inspected /* internal */ ) {
7357 dataType = dataType || options.dataTypes[ 0 ];
7358 inspected = inspected || {};
7360 inspected[ dataType ] = true;
7363 list = structure[ dataType ],
7365 length = list ? list.length : 0,
7366 executeOnly = ( structure === prefilters );
7368 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
7369 selection = list[ i ]( options, originalOptions, jqXHR );
7370 // If we got redirected to another dataType
7371 // we try there if executing only and not done already
7372 if ( typeof selection === "string" ) {
7373 if ( !executeOnly || inspected[ selection ] ) {
7374 selection = undefined;
7376 options.dataTypes.unshift( selection );
7377 selection = inspectPrefiltersOrTransports(
7378 structure, options, originalOptions, jqXHR, selection, inspected );
7382 // If we're only executing or nothing was selected
7383 // we try the catchall dataType if not done already
7384 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
7385 selection = inspectPrefiltersOrTransports(
7386 structure, options, originalOptions, jqXHR, "*", inspected );
7388 // unnecessary when only executing (prefilters)
7389 // but it'll be ignored by the caller in that case
7393 // A special extend for ajax options
7394 // that takes "flat" options (not to be deep extended)
7396 function ajaxExtend( target, src ) {
7398 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7399 for ( key in src ) {
7400 if ( src[ key ] !== undefined ) {
7401 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
7405 jQuery.extend( true, target, deep );
7409 jQuery.fn.load = function( url, params, callback ) {
7410 if ( typeof url !== "string" && _load ) {
7411 return _load.apply( this, arguments );
7414 // Don't do a request if no elements are being requested
7415 if ( !this.length ) {
7419 var selector, type, response,
7421 off = url.indexOf(" ");
7424 selector = url.slice( off, url.length );
7425 url = url.slice( 0, off );
7428 // If it's a function
7429 if ( jQuery.isFunction( params ) ) {
7431 // We assume that it's the callback
7435 // Otherwise, build a param string
7436 } else if ( params && typeof params === "object" ) {
7440 // Request the remote document
7444 // if "type" variable is undefined, then "GET" method will be used
7448 complete: function( jqXHR, status ) {
7450 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7453 }).done(function( responseText ) {
7455 // Save response for use in complete callback
7456 response = arguments;
7458 // See if a selector was specified
7459 self.html( selector ?
7461 // Create a dummy div to hold the results
7464 // inject the contents of the document in, removing the scripts
7465 // to avoid any 'Permission Denied' errors in IE
7466 .append( responseText.replace( rscript, "" ) )
7468 // Locate the specified elements
7471 // If not, just inject the full result
7479 // Attach a bunch of functions for handling common AJAX events
7480 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
7481 jQuery.fn[ o ] = function( f ){
7482 return this.on( o, f );
7486 jQuery.each( [ "get", "post" ], function( i, method ) {
7487 jQuery[ method ] = function( url, data, callback, type ) {
7488 // shift arguments if data argument was omitted
7489 if ( jQuery.isFunction( data ) ) {
7490 type = type || callback;
7495 return jQuery.ajax({
7507 getScript: function( url, callback ) {
7508 return jQuery.get( url, undefined, callback, "script" );
7511 getJSON: function( url, data, callback ) {
7512 return jQuery.get( url, data, callback, "json" );
7515 // Creates a full fledged settings object into target
7516 // with both ajaxSettings and settings fields.
7517 // If target is omitted, writes into ajaxSettings.
7518 ajaxSetup: function( target, settings ) {
7520 // Building a settings object
7521 ajaxExtend( target, jQuery.ajaxSettings );
7523 // Extending ajaxSettings
7525 target = jQuery.ajaxSettings;
7527 ajaxExtend( target, settings );
7533 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7536 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7552 xml: "application/xml, text/xml",
7555 json: "application/json, text/javascript",
7567 text: "responseText"
7570 // List of data converters
7571 // 1) key format is "source_type destination_type" (a single space in-between)
7572 // 2) the catchall symbol "*" can be used for source_type
7575 // Convert anything to text
7576 "* text": window.String,
7578 // Text to html (true = no transformation)
7581 // Evaluate text as a json expression
7582 "text json": jQuery.parseJSON,
7584 // Parse text as xml
7585 "text xml": jQuery.parseXML
7588 // For options that shouldn't be deep extended:
7589 // you can add your own custom options here if
7590 // and when you create one that shouldn't be
7591 // deep extended (see ajaxExtend)
7598 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7599 ajaxTransport: addToPrefiltersOrTransports( transports ),
7602 ajax: function( url, options ) {
7604 // If url is an object, simulate pre-1.5 signature
7605 if ( typeof url === "object" ) {
7610 // Force options to be an object
7611 options = options || {};
7613 var // ifModified key
7616 responseHeadersString,
7622 // Cross-domain detection vars
7624 // To know if global events are to be dispatched
7628 // Create the final options object
7629 s = jQuery.ajaxSetup( {}, options ),
7630 // Callbacks context
7631 callbackContext = s.context || s,
7632 // Context for global events
7633 // It's the callbackContext if one was provided in the options
7634 // and if it's a DOM node or a jQuery collection
7635 globalEventContext = callbackContext !== s &&
7636 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7637 jQuery( callbackContext ) : jQuery.event,
7639 deferred = jQuery.Deferred(),
7640 completeDeferred = jQuery.Callbacks( "once memory" ),
7641 // Status-dependent callbacks
7642 statusCode = s.statusCode || {},
7643 // Headers (they are sent all at once)
7644 requestHeaders = {},
7645 requestHeadersNames = {},
7648 // Default abort message
7649 strAbort = "canceled",
7655 // Caches the header
7656 setRequestHeader: function( name, value ) {
7658 var lname = name.toLowerCase();
7659 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7660 requestHeaders[ name ] = value;
7666 getAllResponseHeaders: function() {
7667 return state === 2 ? responseHeadersString : null;
7670 // Builds headers hashtable if needed
7671 getResponseHeader: function( key ) {
7673 if ( state === 2 ) {
7674 if ( !responseHeaders ) {
7675 responseHeaders = {};
7676 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7677 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7680 match = responseHeaders[ key.toLowerCase() ];
7682 return match === undefined ? null : match;
7685 // Overrides response content-type header
7686 overrideMimeType: function( type ) {
7693 // Cancel the request
7694 abort: function( statusText ) {
7695 statusText = statusText || strAbort;
7697 transport.abort( statusText );
7699 done( 0, statusText );
7704 // Callback for when everything is done
7705 // It is defined here because jslint complains if it is declared
7706 // at the end of the function (which would be more logical and readable)
7707 function done( status, nativeStatusText, responses, headers ) {
7708 var isSuccess, success, error, response, modified,
7709 statusText = nativeStatusText;
7712 if ( state === 2 ) {
7716 // State is "done" now
7719 // Clear timeout if it exists
7720 if ( timeoutTimer ) {
7721 clearTimeout( timeoutTimer );
7724 // Dereference transport for early garbage collection
7725 // (no matter how long the jqXHR object will be used)
7726 transport = undefined;
7728 // Cache response headers
7729 responseHeadersString = headers || "";
7732 jqXHR.readyState = status > 0 ? 4 : 0;
7734 // Get response data
7736 response = ajaxHandleResponses( s, jqXHR, responses );
7739 // If successful, handle type chaining
7740 if ( status >= 200 && status < 300 || status === 304 ) {
7742 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7743 if ( s.ifModified ) {
7745 modified = jqXHR.getResponseHeader("Last-Modified");
7747 jQuery.lastModified[ ifModifiedKey ] = modified;
7749 modified = jqXHR.getResponseHeader("Etag");
7751 jQuery.etag[ ifModifiedKey ] = modified;
7756 if ( status === 304 ) {
7758 statusText = "notmodified";
7764 isSuccess = ajaxConvert( s, response );
7765 statusText = isSuccess.state;
7766 success = isSuccess.data;
7767 error = isSuccess.error;
7771 // We extract error from statusText
7772 // then normalize statusText and status for non-aborts
7774 if ( !statusText || status ) {
7775 statusText = "error";
7782 // Set data for the fake xhr object
7783 jqXHR.status = status;
7784 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
7788 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7790 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7793 // Status-dependent callbacks
7794 jqXHR.statusCode( statusCode );
7795 statusCode = undefined;
7797 if ( fireGlobals ) {
7798 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7799 [ jqXHR, s, isSuccess ? success : error ] );
7803 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7805 if ( fireGlobals ) {
7806 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7807 // Handle the global AJAX counter
7808 if ( !( --jQuery.active ) ) {
7809 jQuery.event.trigger( "ajaxStop" );
7815 deferred.promise( jqXHR );
7816 jqXHR.success = jqXHR.done;
7817 jqXHR.error = jqXHR.fail;
7818 jqXHR.complete = completeDeferred.add;
7820 // Status-dependent callbacks
7821 jqXHR.statusCode = function( map ) {
7825 for ( tmp in map ) {
7826 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7829 tmp = map[ jqXHR.status ];
7830 jqXHR.always( tmp );
7836 // Remove hash character (#7531: and string promotion)
7837 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7838 // We also use the url parameter if available
7839 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7841 // Extract dataTypes list
7842 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
7844 // A cross-domain request is in order when we have a protocol:host:port mismatch
7845 if ( s.crossDomain == null ) {
7846 parts = rurl.exec( s.url.toLowerCase() ) || false;
7847 s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
7848 ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
7851 // Convert data if not already a string
7852 if ( s.data && s.processData && typeof s.data !== "string" ) {
7853 s.data = jQuery.param( s.data, s.traditional );
7857 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7859 // If request was aborted inside a prefilter, stop there
7860 if ( state === 2 ) {
7864 // We can fire global events as of now if asked to
7865 fireGlobals = s.global;
7867 // Uppercase the type
7868 s.type = s.type.toUpperCase();
7870 // Determine if request has content
7871 s.hasContent = !rnoContent.test( s.type );
7873 // Watch for a new set of requests
7874 if ( fireGlobals && jQuery.active++ === 0 ) {
7875 jQuery.event.trigger( "ajaxStart" );
7878 // More options handling for requests with no content
7879 if ( !s.hasContent ) {
7881 // If data is available, append data to url
7883 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7884 // #9682: remove data so that it's not used in an eventual retry
7888 // Get ifModifiedKey before adding the anti-cache parameter
7889 ifModifiedKey = s.url;
7891 // Add anti-cache in url if needed
7892 if ( s.cache === false ) {
7894 var ts = jQuery.now(),
7895 // try replacing _= if it is there
7896 ret = s.url.replace( rts, "$1_=" + ts );
7898 // if nothing was replaced, add timestamp to the end
7899 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7903 // Set the correct header, if data is being sent
7904 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7905 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7908 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7909 if ( s.ifModified ) {
7910 ifModifiedKey = ifModifiedKey || s.url;
7911 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7912 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7914 if ( jQuery.etag[ ifModifiedKey ] ) {
7915 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7919 // Set the Accepts header for the server, depending on the dataType
7920 jqXHR.setRequestHeader(
7922 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7923 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7927 // Check for headers option
7928 for ( i in s.headers ) {
7929 jqXHR.setRequestHeader( i, s.headers[ i ] );
7932 // Allow custom headers/mimetypes and early abort
7933 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7934 // Abort if not done already and return
7935 return jqXHR.abort();
7939 // aborting is no longer a cancellation
7942 // Install callbacks on deferreds
7943 for ( i in { success: 1, error: 1, complete: 1 } ) {
7944 jqXHR[ i ]( s[ i ] );
7948 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7950 // If no transport, we auto-abort
7952 done( -1, "No Transport" );
7954 jqXHR.readyState = 1;
7955 // Send global event
7956 if ( fireGlobals ) {
7957 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7960 if ( s.async && s.timeout > 0 ) {
7961 timeoutTimer = setTimeout( function(){
7962 jqXHR.abort( "timeout" );
7968 transport.send( requestHeaders, done );
7970 // Propagate exception as error if not done
7973 // Simply rethrow otherwise
7983 // Counter for holding the number of active queries
7986 // Last-Modified header cache for next request
7992 /* Handles responses to an ajax request:
7993 * - sets all responseXXX fields accordingly
7994 * - finds the right dataType (mediates between content-type and expected dataType)
7995 * - returns the corresponding response
7997 function ajaxHandleResponses( s, jqXHR, responses ) {
7999 var ct, type, finalDataType, firstDataType,
8000 contents = s.contents,
8001 dataTypes = s.dataTypes,
8002 responseFields = s.responseFields;
8004 // Fill responseXXX fields
8005 for ( type in responseFields ) {
8006 if ( type in responses ) {
8007 jqXHR[ responseFields[type] ] = responses[ type ];
8011 // Remove auto dataType and get content-type in the process
8012 while( dataTypes[ 0 ] === "*" ) {
8014 if ( ct === undefined ) {
8015 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
8019 // Check if we're dealing with a known content-type
8021 for ( type in contents ) {
8022 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8023 dataTypes.unshift( type );
8029 // Check to see if we have a response for the expected dataType
8030 if ( dataTypes[ 0 ] in responses ) {
8031 finalDataType = dataTypes[ 0 ];
8033 // Try convertible dataTypes
8034 for ( type in responses ) {
8035 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8036 finalDataType = type;
8039 if ( !firstDataType ) {
8040 firstDataType = type;
8043 // Or just use first one
8044 finalDataType = finalDataType || firstDataType;
8047 // If we found a dataType
8048 // We add the dataType to the list if needed
8049 // and return the corresponding response
8050 if ( finalDataType ) {
8051 if ( finalDataType !== dataTypes[ 0 ] ) {
8052 dataTypes.unshift( finalDataType );
8054 return responses[ finalDataType ];
8058 // Chain conversions given the request and the original response
8059 function ajaxConvert( s, response ) {
8061 var conv, conv2, current, tmp,
8062 // Work with a copy of dataTypes in case we need to modify it for conversion
8063 dataTypes = s.dataTypes.slice(),
8064 prev = dataTypes[ 0 ],
8068 // Apply the dataFilter if provided
8069 if ( s.dataFilter ) {
8070 response = s.dataFilter( response, s.dataType );
8073 // Create converters map with lowercased keys
8074 if ( dataTypes[ 1 ] ) {
8075 for ( conv in s.converters ) {
8076 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8080 // Convert to each sequential dataType, tolerating list modification
8081 for ( ; (current = dataTypes[++i]); ) {
8083 // There's only work to do if current dataType is non-auto
8084 if ( current !== "*" ) {
8086 // Convert response if prev dataType is non-auto and differs from current
8087 if ( prev !== "*" && prev !== current ) {
8089 // Seek a direct converter
8090 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8092 // If none found, seek a pair
8094 for ( conv2 in converters ) {
8096 // If conv2 outputs current
8097 tmp = conv2.split(" ");
8098 if ( tmp[ 1 ] === current ) {
8100 // If prev can be converted to accepted input
8101 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8102 converters[ "* " + tmp[ 0 ] ];
8104 // Condense equivalence converters
8105 if ( conv === true ) {
8106 conv = converters[ conv2 ];
8108 // Otherwise, insert the intermediate dataType
8109 } else if ( converters[ conv2 ] !== true ) {
8111 dataTypes.splice( i--, 0, current );
8120 // Apply converter (if not an equivalence)
8121 if ( conv !== true ) {
8123 // Unless errors are allowed to bubble, catch and return them
8124 if ( conv && s["throws"] ) {
8125 response = conv( response );
8128 response = conv( response );
8130 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8136 // Update prev for next iteration
8141 return { state: "success", data: response };
8143 var oldCallbacks = [],
8145 rjsonp = /(=)\?(?=&|$)|\?\?/,
8146 nonce = jQuery.now();
8148 // Default jsonp settings
8151 jsonpCallback: function() {
8152 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
8153 this[ callback ] = true;
8158 // Detect, normalize options and install callbacks for jsonp requests
8159 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8161 var callbackName, overwritten, responseContainer,
8164 hasCallback = s.jsonp !== false,
8165 replaceInUrl = hasCallback && rjsonp.test( url ),
8166 replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
8167 !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
8168 rjsonp.test( data );
8170 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8171 if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
8173 // Get callback name, remembering preexisting value associated with it
8174 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8177 overwritten = window[ callbackName ];
8179 // Insert callback into url or form data
8180 if ( replaceInUrl ) {
8181 s.url = url.replace( rjsonp, "$1" + callbackName );
8182 } else if ( replaceInData ) {
8183 s.data = data.replace( rjsonp, "$1" + callbackName );
8184 } else if ( hasCallback ) {
8185 s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8188 // Use data converter to retrieve json after script execution
8189 s.converters["script json"] = function() {
8190 if ( !responseContainer ) {
8191 jQuery.error( callbackName + " was not called" );
8193 return responseContainer[ 0 ];
8196 // force json dataType
8197 s.dataTypes[ 0 ] = "json";
8200 window[ callbackName ] = function() {
8201 responseContainer = arguments;
8204 // Clean-up function (fires after converters)
8205 jqXHR.always(function() {
8206 // Restore preexisting value
8207 window[ callbackName ] = overwritten;
8209 // Save back as free
8210 if ( s[ callbackName ] ) {
8211 // make sure that re-using the options doesn't screw things around
8212 s.jsonpCallback = originalSettings.jsonpCallback;
8214 // save the callback name for future use
8215 oldCallbacks.push( callbackName );
8218 // Call if it was a function and we have a response
8219 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8220 overwritten( responseContainer[ 0 ] );
8223 responseContainer = overwritten = undefined;
8226 // Delegate to script
8230 // Install script dataType
8233 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8236 script: /javascript|ecmascript/
8239 "text script": function( text ) {
8240 jQuery.globalEval( text );
8246 // Handle cache's special case and global
8247 jQuery.ajaxPrefilter( "script", function( s ) {
8248 if ( s.cache === undefined ) {
8251 if ( s.crossDomain ) {
8257 // Bind script tag hack transport
8258 jQuery.ajaxTransport( "script", function(s) {
8260 // This transport only deals with cross domain requests
8261 if ( s.crossDomain ) {
8264 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
8268 send: function( _, callback ) {
8270 script = document.createElement( "script" );
8272 script.async = "async";
8274 if ( s.scriptCharset ) {
8275 script.charset = s.scriptCharset;
8280 // Attach handlers for all browsers
8281 script.onload = script.onreadystatechange = function( _, isAbort ) {
8283 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8285 // Handle memory leak in IE
8286 script.onload = script.onreadystatechange = null;
8288 // Remove the script
8289 if ( head && script.parentNode ) {
8290 head.removeChild( script );
8293 // Dereference the script
8296 // Callback if not abort
8298 callback( 200, "success" );
8302 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
8303 // This arises when a base node is used (#2709 and #4378).
8304 head.insertBefore( script, head.firstChild );
8309 script.onload( 0, 1 );
8316 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8317 xhrOnUnloadAbort = window.ActiveXObject ? function() {
8318 // Abort all pending requests
8319 for ( var key in xhrCallbacks ) {
8320 xhrCallbacks[ key ]( 0, 1 );
8325 // Functions to create xhrs
8326 function createStandardXHR() {
8328 return new window.XMLHttpRequest();
8332 function createActiveXHR() {
8334 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
8338 // Create the request object
8339 // (This is still attached to ajaxSettings for backward compatibility)
8340 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8341 /* Microsoft failed to properly
8342 * implement the XMLHttpRequest in IE7 (can't request local files),
8343 * so we use the ActiveXObject when it is available
8344 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8345 * we need a fallback.
8348 return !this.isLocal && createStandardXHR() || createActiveXHR();
8350 // For all other browsers, use the standard XMLHttpRequest object
8353 // Determine support properties
8355 jQuery.extend( jQuery.support, {
8357 cors: !!xhr && ( "withCredentials" in xhr )
8359 })( jQuery.ajaxSettings.xhr() );
8361 // Create transport if the browser can provide an xhr
8362 if ( jQuery.support.ajax ) {
8364 jQuery.ajaxTransport(function( s ) {
8365 // Cross domain only allowed if supported through XMLHttpRequest
8366 if ( !s.crossDomain || jQuery.support.cors ) {
8371 send: function( headers, complete ) {
8378 // Passing null username, generates a login popup on Opera (#2865)
8380 xhr.open( s.type, s.url, s.async, s.username, s.password );
8382 xhr.open( s.type, s.url, s.async );
8385 // Apply custom fields if provided
8386 if ( s.xhrFields ) {
8387 for ( i in s.xhrFields ) {
8388 xhr[ i ] = s.xhrFields[ i ];
8392 // Override mime type if needed
8393 if ( s.mimeType && xhr.overrideMimeType ) {
8394 xhr.overrideMimeType( s.mimeType );
8397 // X-Requested-With header
8398 // For cross-domain requests, seeing as conditions for a preflight are
8399 // akin to a jigsaw puzzle, we simply never set it to be sure.
8400 // (it can always be set on a per-request basis or even using ajaxSetup)
8401 // For same-domain requests, won't change header if already provided.
8402 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8403 headers[ "X-Requested-With" ] = "XMLHttpRequest";
8406 // Need an extra try/catch for cross domain requests in Firefox 3
8408 for ( i in headers ) {
8409 xhr.setRequestHeader( i, headers[ i ] );
8413 // Do send the request
8414 // This may raise an exception which is actually
8415 // handled in jQuery.ajax (so no try/catch here)
8416 xhr.send( ( s.hasContent && s.data ) || null );
8419 callback = function( _, isAbort ) {
8427 // Firefox throws exceptions when accessing properties
8428 // of an xhr when a network error occurred
8429 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8432 // Was never called and is aborted or complete
8433 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8436 callback = undefined;
8438 // Do not keep as active anymore
8440 xhr.onreadystatechange = jQuery.noop;
8441 if ( xhrOnUnloadAbort ) {
8442 delete xhrCallbacks[ handle ];
8448 // Abort it manually if needed
8449 if ( xhr.readyState !== 4 ) {
8453 status = xhr.status;
8454 responseHeaders = xhr.getAllResponseHeaders();
8456 xml = xhr.responseXML;
8458 // Construct response list
8459 if ( xml && xml.documentElement /* #4958 */ ) {
8460 responses.xml = xml;
8463 // When requesting binary data, IE6-9 will throw an exception
8464 // on any attempt to access responseText (#11426)
8466 responses.text = xhr.responseText;
8470 // Firefox throws an exception when accessing
8471 // statusText for faulty cross-domain requests
8473 statusText = xhr.statusText;
8475 // We normalize with Webkit giving an empty statusText
8479 // Filter status for non standard behaviors
8481 // If the request is local and we have data: assume a success
8482 // (success with no data won't get notified, that's the best we
8483 // can do given current implementations)
8484 if ( !status && s.isLocal && !s.crossDomain ) {
8485 status = responses.text ? 200 : 404;
8486 // IE - #1450: sometimes returns 1223 when it should be 204
8487 } else if ( status === 1223 ) {
8492 } catch( firefoxAccessException ) {
8494 complete( -1, firefoxAccessException );
8498 // Call complete if needed
8500 complete( status, statusText, responses, responseHeaders );
8505 // if we're in sync mode we fire the callback
8507 } else if ( xhr.readyState === 4 ) {
8508 // (IE6 & IE7) if it's in cache and has been
8509 // retrieved directly we need to fire the callback
8510 setTimeout( callback, 0 );
8513 if ( xhrOnUnloadAbort ) {
8514 // Create the active xhrs callbacks list if needed
8515 // and attach the unload handler
8516 if ( !xhrCallbacks ) {
8518 jQuery( window ).unload( xhrOnUnloadAbort );
8520 // Add to list of active xhrs callbacks
8521 xhrCallbacks[ handle ] = callback;
8523 xhr.onreadystatechange = callback;
8537 rfxtypes = /^(?:toggle|show|hide)$/,
8538 rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8539 rrun = /queueHooks$/,
8540 animationPrefilters = [ defaultPrefilter ],
8542 "*": [function( prop, value ) {
8544 tween = this.createTween( prop, value ),
8545 parts = rfxnum.exec( value ),
8546 target = tween.cur(),
8547 start = +target || 0,
8553 unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8555 // We need to compute starting value
8556 if ( unit !== "px" && start ) {
8557 // Iteratively approximate from a nonzero starting point
8558 // Prefer the current property, because this process will be trivial if it uses the same units
8559 // Fallback to end or a simple constant
8560 start = jQuery.css( tween.elem, prop, true ) || end || 1;
8563 // If previous iteration zeroed out, double until we get *something*
8564 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8565 scale = scale || ".5";
8568 start = start / scale;
8569 jQuery.style( tween.elem, prop, start + unit );
8571 // Update scale, tolerating zero or NaN from tween.cur()
8572 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8573 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8577 tween.start = start;
8578 // If a +=/-= token was provided, we're doing a relative animation
8579 tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
8585 // Animations created synchronously will run synchronously
8586 function createFxNow() {
8587 setTimeout(function() {
8590 return ( fxNow = jQuery.now() );
8593 function createTweens( animation, props ) {
8594 jQuery.each( props, function( prop, value ) {
8595 var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8597 length = collection.length;
8598 for ( ; index < length; index++ ) {
8599 if ( collection[ index ].call( animation, prop, value ) ) {
8601 // we're done with this property
8608 function Animation( elem, properties, options ) {
8612 length = animationPrefilters.length,
8613 deferred = jQuery.Deferred().always( function() {
8614 // don't match elem in the :animated selector
8618 var currentTime = fxNow || createFxNow(),
8619 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8620 percent = 1 - ( remaining / animation.duration || 0 ),
8622 length = animation.tweens.length;
8624 for ( ; index < length ; index++ ) {
8625 animation.tweens[ index ].run( percent );
8628 deferred.notifyWith( elem, [ animation, percent, remaining ]);
8630 if ( percent < 1 && length ) {
8633 deferred.resolveWith( elem, [ animation ] );
8637 animation = deferred.promise({
8639 props: jQuery.extend( {}, properties ),
8640 opts: jQuery.extend( true, { specialEasing: {} }, options ),
8641 originalProperties: properties,
8642 originalOptions: options,
8643 startTime: fxNow || createFxNow(),
8644 duration: options.duration,
8646 createTween: function( prop, end, easing ) {
8647 var tween = jQuery.Tween( elem, animation.opts, prop, end,
8648 animation.opts.specialEasing[ prop ] || animation.opts.easing );
8649 animation.tweens.push( tween );
8652 stop: function( gotoEnd ) {
8654 // if we are going to the end, we want to run all the tweens
8655 // otherwise we skip this part
8656 length = gotoEnd ? animation.tweens.length : 0;
8658 for ( ; index < length ; index++ ) {
8659 animation.tweens[ index ].run( 1 );
8662 // resolve when we played the last frame
8663 // otherwise, reject
8665 deferred.resolveWith( elem, [ animation, gotoEnd ] );
8667 deferred.rejectWith( elem, [ animation, gotoEnd ] );
8672 props = animation.props;
8674 propFilter( props, animation.opts.specialEasing );
8676 for ( ; index < length ; index++ ) {
8677 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8683 createTweens( animation, props );
8685 if ( jQuery.isFunction( animation.opts.start ) ) {
8686 animation.opts.start.call( elem, animation );
8690 jQuery.extend( tick, {
8692 queue: animation.opts.queue,
8697 // attach callbacks from options
8698 return animation.progress( animation.opts.progress )
8699 .done( animation.opts.done, animation.opts.complete )
8700 .fail( animation.opts.fail )
8701 .always( animation.opts.always );
8704 function propFilter( props, specialEasing ) {
8705 var index, name, easing, value, hooks;
8707 // camelCase, specialEasing and expand cssHook pass
8708 for ( index in props ) {
8709 name = jQuery.camelCase( index );
8710 easing = specialEasing[ name ];
8711 value = props[ index ];
8712 if ( jQuery.isArray( value ) ) {
8713 easing = value[ 1 ];
8714 value = props[ index ] = value[ 0 ];
8717 if ( index !== name ) {
8718 props[ name ] = value;
8719 delete props[ index ];
8722 hooks = jQuery.cssHooks[ name ];
8723 if ( hooks && "expand" in hooks ) {
8724 value = hooks.expand( value );
8725 delete props[ name ];
8727 // not quite $.extend, this wont overwrite keys already present.
8728 // also - reusing 'index' from above because we have the correct "name"
8729 for ( index in value ) {
8730 if ( !( index in props ) ) {
8731 props[ index ] = value[ index ];
8732 specialEasing[ index ] = easing;
8736 specialEasing[ name ] = easing;
8741 jQuery.Animation = jQuery.extend( Animation, {
8743 tweener: function( props, callback ) {
8744 if ( jQuery.isFunction( props ) ) {
8748 props = props.split(" ");
8753 length = props.length;
8755 for ( ; index < length ; index++ ) {
8756 prop = props[ index ];
8757 tweeners[ prop ] = tweeners[ prop ] || [];
8758 tweeners[ prop ].unshift( callback );
8762 prefilter: function( callback, prepend ) {
8764 animationPrefilters.unshift( callback );
8766 animationPrefilters.push( callback );
8771 function defaultPrefilter( elem, props, opts ) {
8772 var index, prop, value, length, dataShow, tween, hooks, oldfire,
8777 hidden = elem.nodeType && isHidden( elem );
8779 // handle queue: false promises
8780 if ( !opts.queue ) {
8781 hooks = jQuery._queueHooks( elem, "fx" );
8782 if ( hooks.unqueued == null ) {
8784 oldfire = hooks.empty.fire;
8785 hooks.empty.fire = function() {
8786 if ( !hooks.unqueued ) {
8793 anim.always(function() {
8794 // doing this makes sure that the complete handler will be called
8795 // before this completes
8796 anim.always(function() {
8798 if ( !jQuery.queue( elem, "fx" ).length ) {
8805 // height/width overflow pass
8806 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8807 // Make sure that nothing sneaks out
8808 // Record all 3 overflow attributes because IE does not
8809 // change the overflow attribute when overflowX and
8810 // overflowY are set to the same value
8811 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8813 // Set display property to inline-block for height/width
8814 // animations on inline elements that are having width/height animated
8815 if ( jQuery.css( elem, "display" ) === "inline" &&
8816 jQuery.css( elem, "float" ) === "none" ) {
8818 // inline-level elements accept inline-block;
8819 // block-level elements need to be inline with layout
8820 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
8821 style.display = "inline-block";
8829 if ( opts.overflow ) {
8830 style.overflow = "hidden";
8831 if ( !jQuery.support.shrinkWrapBlocks ) {
8832 anim.done(function() {
8833 style.overflow = opts.overflow[ 0 ];
8834 style.overflowX = opts.overflow[ 1 ];
8835 style.overflowY = opts.overflow[ 2 ];
8842 for ( index in props ) {
8843 value = props[ index ];
8844 if ( rfxtypes.exec( value ) ) {
8845 delete props[ index ];
8846 if ( value === ( hidden ? "hide" : "show" ) ) {
8849 handled.push( index );
8853 length = handled.length;
8855 dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8857 jQuery( elem ).show();
8859 anim.done(function() {
8860 jQuery( elem ).hide();
8863 anim.done(function() {
8865 jQuery.removeData( elem, "fxshow", true );
8866 for ( prop in orig ) {
8867 jQuery.style( elem, prop, orig[ prop ] );
8870 for ( index = 0 ; index < length ; index++ ) {
8871 prop = handled[ index ];
8872 tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
8873 orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
8875 if ( !( prop in dataShow ) ) {
8876 dataShow[ prop ] = tween.start;
8878 tween.end = tween.start;
8879 tween.start = prop === "width" || prop === "height" ? 1 : 0;
8886 function Tween( elem, options, prop, end, easing ) {
8887 return new Tween.prototype.init( elem, options, prop, end, easing );
8889 jQuery.Tween = Tween;
8893 init: function( elem, options, prop, end, easing, unit ) {
8896 this.easing = easing || "swing";
8897 this.options = options;
8898 this.start = this.now = this.cur();
8900 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8903 var hooks = Tween.propHooks[ this.prop ];
8905 return hooks && hooks.get ?
8907 Tween.propHooks._default.get( this );
8909 run: function( percent ) {
8911 hooks = Tween.propHooks[ this.prop ];
8913 if ( this.options.duration ) {
8914 this.pos = eased = jQuery.easing[ this.easing ](
8915 percent, this.options.duration * percent, 0, 1, this.options.duration
8918 this.pos = eased = percent;
8920 this.now = ( this.end - this.start ) * eased + this.start;
8922 if ( this.options.step ) {
8923 this.options.step.call( this.elem, this.now, this );
8926 if ( hooks && hooks.set ) {
8929 Tween.propHooks._default.set( this );
8935 Tween.prototype.init.prototype = Tween.prototype;
8939 get: function( tween ) {
8942 if ( tween.elem[ tween.prop ] != null &&
8943 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
8944 return tween.elem[ tween.prop ];
8947 // passing any value as a 4th parameter to .css will automatically
8948 // attempt a parseFloat and fallback to a string if the parse fails
8949 // so, simple values such as "10px" are parsed to Float.
8950 // complex values such as "rotate(1rad)" are returned as is.
8951 result = jQuery.css( tween.elem, tween.prop, false, "" );
8952 // Empty strings, null, undefined and "auto" are converted to 0.
8953 return !result || result === "auto" ? 0 : result;
8955 set: function( tween ) {
8956 // use step hook for back compat - use cssHook if its there - use .style if its
8957 // available and use plain properties where available
8958 if ( jQuery.fx.step[ tween.prop ] ) {
8959 jQuery.fx.step[ tween.prop ]( tween );
8960 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
8961 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
8963 tween.elem[ tween.prop ] = tween.now;
8969 // Remove in 2.0 - this supports IE8's panic based approach
8970 // to setting things on disconnected nodes
8972 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
8973 set: function( tween ) {
8974 if ( tween.elem.nodeType && tween.elem.parentNode ) {
8975 tween.elem[ tween.prop ] = tween.now;
8980 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
8981 var cssFn = jQuery.fn[ name ];
8982 jQuery.fn[ name ] = function( speed, easing, callback ) {
8983 return speed == null || typeof speed === "boolean" ||
8984 // special check for .toggle( handler, handler, ... )
8985 ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
8986 cssFn.apply( this, arguments ) :
8987 this.animate( genFx( name, true ), speed, easing, callback );
8992 fadeTo: function( speed, to, easing, callback ) {
8994 // show any hidden elements after setting opacity to 0
8995 return this.filter( isHidden ).css( "opacity", 0 ).show()
8997 // animate to the value specified
8998 .end().animate({ opacity: to }, speed, easing, callback );
9000 animate: function( prop, speed, easing, callback ) {
9001 var empty = jQuery.isEmptyObject( prop ),
9002 optall = jQuery.speed( speed, easing, callback ),
9003 doAnimation = function() {
9004 // Operate on a copy of prop so per-property easing won't be lost
9005 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
9007 // Empty animations resolve immediately
9013 return empty || optall.queue === false ?
9014 this.each( doAnimation ) :
9015 this.queue( optall.queue, doAnimation );
9017 stop: function( type, clearQueue, gotoEnd ) {
9018 var stopQueue = function( hooks ) {
9019 var stop = hooks.stop;
9024 if ( typeof type !== "string" ) {
9025 gotoEnd = clearQueue;
9029 if ( clearQueue && type !== false ) {
9030 this.queue( type || "fx", [] );
9033 return this.each(function() {
9035 index = type != null && type + "queueHooks",
9036 timers = jQuery.timers,
9037 data = jQuery._data( this );
9040 if ( data[ index ] && data[ index ].stop ) {
9041 stopQueue( data[ index ] );
9044 for ( index in data ) {
9045 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
9046 stopQueue( data[ index ] );
9051 for ( index = timers.length; index--; ) {
9052 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
9053 timers[ index ].anim.stop( gotoEnd );
9055 timers.splice( index, 1 );
9059 // start the next in the queue if the last step wasn't forced
9060 // timers currently will call their complete callbacks, which will dequeue
9061 // but only if they were gotoEnd
9062 if ( dequeue || !gotoEnd ) {
9063 jQuery.dequeue( this, type );
9069 // Generate parameters to create a standard animation
9070 function genFx( type, includeWidth ) {
9072 attrs = { height: type },
9075 // if we include width, step value is 1 to do all cssExpand values,
9076 // if we don't include width, step value is 2 to skip over Left and Right
9077 includeWidth = includeWidth? 1 : 0;
9078 for( ; i < 4 ; i += 2 - includeWidth ) {
9079 which = cssExpand[ i ];
9080 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
9083 if ( includeWidth ) {
9084 attrs.opacity = attrs.width = type;
9090 // Generate shortcuts for custom animations
9092 slideDown: genFx("show"),
9093 slideUp: genFx("hide"),
9094 slideToggle: genFx("toggle"),
9095 fadeIn: { opacity: "show" },
9096 fadeOut: { opacity: "hide" },
9097 fadeToggle: { opacity: "toggle" }
9098 }, function( name, props ) {
9099 jQuery.fn[ name ] = function( speed, easing, callback ) {
9100 return this.animate( props, speed, easing, callback );
9104 jQuery.speed = function( speed, easing, fn ) {
9105 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
9106 complete: fn || !fn && easing ||
9107 jQuery.isFunction( speed ) && speed,
9109 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
9112 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
9113 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
9115 // normalize opt.queue - true/undefined/null -> "fx"
9116 if ( opt.queue == null || opt.queue === true ) {
9121 opt.old = opt.complete;
9123 opt.complete = function() {
9124 if ( jQuery.isFunction( opt.old ) ) {
9125 opt.old.call( this );
9129 jQuery.dequeue( this, opt.queue );
9137 linear: function( p ) {
9140 swing: function( p ) {
9141 return 0.5 - Math.cos( p*Math.PI ) / 2;
9146 jQuery.fx = Tween.prototype.init;
9147 jQuery.fx.tick = function() {
9149 timers = jQuery.timers,
9152 for ( ; i < timers.length; i++ ) {
9153 timer = timers[ i ];
9154 // Checks the timer has not already been removed
9155 if ( !timer() && timers[ i ] === timer ) {
9156 timers.splice( i--, 1 );
9160 if ( !timers.length ) {
9165 jQuery.fx.timer = function( timer ) {
9166 if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
9167 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
9171 jQuery.fx.interval = 13;
9173 jQuery.fx.stop = function() {
9174 clearInterval( timerId );
9178 jQuery.fx.speeds = {
9185 // Back Compat <1.8 extension point
9186 jQuery.fx.step = {};
9188 if ( jQuery.expr && jQuery.expr.filters ) {
9189 jQuery.expr.filters.animated = function( elem ) {
9190 return jQuery.grep(jQuery.timers, function( fn ) {
9191 return elem === fn.elem;
9195 var rroot = /^(?:body|html)$/i;
9197 jQuery.fn.offset = function( options ) {
9198 if ( arguments.length ) {
9199 return options === undefined ?
9201 this.each(function( i ) {
9202 jQuery.offset.setOffset( this, options, i );
9206 var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
9207 box = { top: 0, left: 0 },
9209 doc = elem && elem.ownerDocument;
9215 if ( (body = doc.body) === elem ) {
9216 return jQuery.offset.bodyOffset( elem );
9219 docElem = doc.documentElement;
9221 // Make sure it's not a disconnected DOM node
9222 if ( !jQuery.contains( docElem, elem ) ) {
9226 // If we don't have gBCR, just use 0,0 rather than error
9227 // BlackBerry 5, iOS 3 (original iPhone)
9228 if ( typeof elem.getBoundingClientRect !== "undefined" ) {
9229 box = elem.getBoundingClientRect();
9231 win = getWindow( doc );
9232 clientTop = docElem.clientTop || body.clientTop || 0;
9233 clientLeft = docElem.clientLeft || body.clientLeft || 0;
9234 scrollTop = win.pageYOffset || docElem.scrollTop;
9235 scrollLeft = win.pageXOffset || docElem.scrollLeft;
9237 top: box.top + scrollTop - clientTop,
9238 left: box.left + scrollLeft - clientLeft
9244 bodyOffset: function( body ) {
9245 var top = body.offsetTop,
9246 left = body.offsetLeft;
9248 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
9249 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
9250 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
9253 return { top: top, left: left };
9256 setOffset: function( elem, options, i ) {
9257 var position = jQuery.css( elem, "position" );
9259 // set position first, in-case top/left are set even on static elem
9260 if ( position === "static" ) {
9261 elem.style.position = "relative";
9264 var curElem = jQuery( elem ),
9265 curOffset = curElem.offset(),
9266 curCSSTop = jQuery.css( elem, "top" ),
9267 curCSSLeft = jQuery.css( elem, "left" ),
9268 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9269 props = {}, curPosition = {}, curTop, curLeft;
9271 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9272 if ( calculatePosition ) {
9273 curPosition = curElem.position();
9274 curTop = curPosition.top;
9275 curLeft = curPosition.left;
9277 curTop = parseFloat( curCSSTop ) || 0;
9278 curLeft = parseFloat( curCSSLeft ) || 0;
9281 if ( jQuery.isFunction( options ) ) {
9282 options = options.call( elem, i, curOffset );
9285 if ( options.top != null ) {
9286 props.top = ( options.top - curOffset.top ) + curTop;
9288 if ( options.left != null ) {
9289 props.left = ( options.left - curOffset.left ) + curLeft;
9292 if ( "using" in options ) {
9293 options.using.call( elem, props );
9295 curElem.css( props );
9303 position: function() {
9310 // Get *real* offsetParent
9311 offsetParent = this.offsetParent(),
9313 // Get correct offsets
9314 offset = this.offset(),
9315 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
9317 // Subtract element margins
9318 // note: when an element has margin: auto the offsetLeft and marginLeft
9319 // are the same in Safari causing offset.left to incorrectly be 0
9320 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
9321 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
9323 // Add offsetParent borders
9324 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
9325 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
9327 // Subtract the two offsets
9329 top: offset.top - parentOffset.top,
9330 left: offset.left - parentOffset.left
9334 offsetParent: function() {
9335 return this.map(function() {
9336 var offsetParent = this.offsetParent || document.body;
9337 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
9338 offsetParent = offsetParent.offsetParent;
9340 return offsetParent || document.body;
9346 // Create scrollLeft and scrollTop methods
9347 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
9348 var top = /Y/.test( prop );
9350 jQuery.fn[ method ] = function( val ) {
9351 return jQuery.access( this, function( elem, method, val ) {
9352 var win = getWindow( elem );
9354 if ( val === undefined ) {
9355 return win ? (prop in win) ? win[ prop ] :
9356 win.document.documentElement[ method ] :
9362 !top ? val : jQuery( win ).scrollLeft(),
9363 top ? val : jQuery( win ).scrollTop()
9367 elem[ method ] = val;
9369 }, method, val, arguments.length, null );
9373 function getWindow( elem ) {
9374 return jQuery.isWindow( elem ) ?
9376 elem.nodeType === 9 ?
9377 elem.defaultView || elem.parentWindow :
9380 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9381 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9382 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9383 // margin is only for outerHeight, outerWidth
9384 jQuery.fn[ funcName ] = function( margin, value ) {
9385 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9386 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9388 return jQuery.access( this, function( elem, type, value ) {
9391 if ( jQuery.isWindow( elem ) ) {
9392 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9393 // isn't a whole lot we can do. See pull request at this URL for discussion:
9394 // https://github.com/jquery/jquery/pull/764
9395 return elem.document.documentElement[ "client" + name ];
9398 // Get document width or height
9399 if ( elem.nodeType === 9 ) {
9400 doc = elem.documentElement;
9402 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9403 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9405 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9406 elem.body[ "offset" + name ], doc[ "offset" + name ],
9407 doc[ "client" + name ]
9411 return value === undefined ?
9412 // Get width or height on the element, requesting but not forcing parseFloat
9413 jQuery.css( elem, type, value, extra ) :
9415 // Set width or height on the element
9416 jQuery.style( elem, type, value, extra );
9417 }, type, chainable ? margin : undefined, chainable, null );
9421 // Expose jQuery to the global object
9422 window.jQuery = window.$ = jQuery;
9424 // Expose jQuery as an AMD module, but only for AMD loaders that
9425 // understand the issues with loading multiple versions of jQuery
9426 // in a page that all might call define(). The loader will indicate
9427 // they have special allowances for multiple jQuery versions by
9428 // specifying define.amd.jQuery = true. Register as a named module,
9429 // since jQuery can be concatenated with other files that may use define,
9430 // but not use a proper concatenation script that understands anonymous
9431 // AMD modules. A named AMD is safest and most robust way to register.
9432 // Lowercase jquery is used because AMD module names are derived from
9433 // file names, and jQuery is normally delivered in a lowercase file name.
9434 // Do this after creating the global so that if an AMD module wants to call
9435 // noConflict to hide this version of jQuery, it will work.
9436 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
9437 define( "jquery", [], function () { return jQuery; } );