2 * @namespace com.intel.tizen.coulomb.2012
6 * Extension methods for jQuery JavaScript Library v1.8.2 provided by theme http://com.intel.tizen/coulomb.2012
11 * jQuery JavaScript Library v1.8.2
15 * http://sizzlejs.com/
17 * Copyright 2012 jQuery Foundation and other contributors
18 * Released under the MIT license
19 * http://jquery.org/license
21 * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time)
23 (function( window, undefined ) {
25 // A central reference to the root jQuery(document)
28 // The deferred used on DOM ready
31 // Use the correct document accordingly with window argument (sandbox)
32 document = window.document,
33 location = window.location,
34 navigator = window.navigator,
36 // Map over jQuery in case of overwrite
37 _jQuery = window.jQuery,
39 // Map over the $ in case of overwrite
42 // Save a reference to some core methods
43 core_push = Array.prototype.push,
44 core_slice = Array.prototype.slice,
45 core_indexOf = Array.prototype.indexOf,
46 core_toString = Object.prototype.toString,
47 core_hasOwn = Object.prototype.hasOwnProperty,
48 core_trim = String.prototype.trim,
50 // Define a local copy of jQuery
51 jQuery = function( selector, context ) {
52 // The jQuery object is actually just the init constructor 'enhanced'
53 return new jQuery.fn.init( selector, context, rootjQuery );
56 // Used for matching numbers
57 core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,
59 // Used for detecting and trimming whitespace
60 core_rnotwhite = /\S/,
63 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
64 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
66 // A simple way to check for HTML strings
67 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
68 rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
70 // Match a standalone tag
71 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
74 rvalidchars = /^[\],:{}\s]*$/,
75 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
76 rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
77 rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,
79 // Matches dashed string for camelizing
81 rdashAlpha = /-([\da-z])/gi,
83 // Used by jQuery.camelCase as callback to replace()
84 fcamelCase = function( all, letter ) {
85 return ( letter + "" ).toUpperCase();
88 // The ready event handler and self cleanup method
89 DOMContentLoaded = function() {
90 if ( document.addEventListener ) {
91 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
93 } else if ( document.readyState === "complete" ) {
94 // we're here because readyState === "complete" in oldIE
95 // which is good enough for us to call the dom ready!
96 document.detachEvent( "onreadystatechange", DOMContentLoaded );
101 // [[Class]] -> type pairs
104 jQuery.fn = jQuery.prototype = {
106 init: function( selector, context, rootjQuery ) {
107 var match, elem, ret, doc;
109 // Handle $(""), $(null), $(undefined), $(false)
114 // Handle $(DOMElement)
115 if ( selector.nodeType ) {
116 this.context = this[0] = selector;
121 // Handle HTML strings
122 if ( typeof selector === "string" ) {
123 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
124 // Assume that strings that start and end with <> are HTML and skip the regex check
125 match = [ null, selector, null ];
128 match = rquickExpr.exec( selector );
131 // Match html or make sure no context is specified for #id
132 if ( match && (match[1] || !context) ) {
134 // HANDLE: $(html) -> $(array)
136 context = context instanceof jQuery ? context[0] : context;
137 doc = ( context && context.nodeType ? context.ownerDocument || context : document );
139 // scripts is true for back-compat
140 selector = jQuery.parseHTML( match[1], doc, true );
141 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
142 this.attr.call( selector, context, true );
145 return jQuery.merge( this, selector );
149 elem = document.getElementById( match[2] );
151 // Check parentNode to catch when Blackberry 4.6 returns
152 // nodes that are no longer in the document #6963
153 if ( elem && elem.parentNode ) {
154 // Handle the case where IE and Opera return items
155 // by name instead of ID
156 if ( elem.id !== match[2] ) {
157 return rootjQuery.find( selector );
160 // Otherwise, we inject the element directly into the jQuery object
165 this.context = document;
166 this.selector = selector;
170 // HANDLE: $(expr, $(...))
171 } else if ( !context || context.jquery ) {
172 return ( context || rootjQuery ).find( selector );
174 // HANDLE: $(expr, context)
175 // (which is just equivalent to: $(context).find(expr)
177 return this.constructor( context ).find( selector );
180 // HANDLE: $(function)
181 // Shortcut for document ready
182 } else if ( jQuery.isFunction( selector ) ) {
183 return rootjQuery.ready( selector );
186 if ( selector.selector !== undefined ) {
187 this.selector = selector.selector;
188 this.context = selector.context;
191 return jQuery.makeArray( selector, this );
194 // Start with an empty selector
197 // The current version of jQuery being used
200 // The default length of a jQuery object is 0
203 // The number of elements contained in the matched element set
208 toArray: function() {
209 return core_slice.call( this );
212 // Get the Nth element in the matched element set OR
213 // Get the whole matched element set as a clean array
214 get: function( num ) {
217 // Return a 'clean' array
220 // Return just the object
221 ( num < 0 ? this[ this.length + num ] : this[ num ] );
224 // Take an array of elements and push it onto the stack
225 // (returning the new matched element set)
226 pushStack: function( elems, name, selector ) {
228 // Build a new jQuery matched element set
229 var ret = jQuery.merge( this.constructor(), elems );
231 // Add the old object onto the stack (as a reference)
232 ret.prevObject = this;
234 ret.context = this.context;
236 if ( name === "find" ) {
237 ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
239 ret.selector = this.selector + "." + name + "(" + selector + ")";
242 // Return the newly-formed element set
246 // Execute a callback for every element in the matched set.
247 // (You can seed the arguments with an array of args, but this is
248 // only used internally.)
249 each: function( callback, args ) {
250 return jQuery.each( this, callback, args );
253 ready: function( fn ) {
255 jQuery.ready.promise().done( fn );
264 this.slice( i, i + 1 );
272 return this.eq( -1 );
276 return this.pushStack( core_slice.apply( this, arguments ),
277 "slice", core_slice.call(arguments).join(",") );
280 map: function( callback ) {
281 return this.pushStack( jQuery.map(this, function( elem, i ) {
282 return callback.call( elem, i, elem );
287 return this.prevObject || this.constructor(null);
290 // For internal use only.
291 // Behaves like an Array's method, not like a jQuery method.
297 // Give the init function the jQuery prototype for later instantiation
298 jQuery.fn.init.prototype = jQuery.fn;
300 jQuery.extend = jQuery.fn.extend = function() {
301 var options, name, src, copy, copyIsArray, clone,
302 target = arguments[0] || {},
304 length = arguments.length,
307 // Handle a deep copy situation
308 if ( typeof target === "boolean" ) {
310 target = arguments[1] || {};
311 // skip the boolean and the target
315 // Handle case when target is a string or something (possible in deep copy)
316 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
320 // extend jQuery itself if only one argument is passed
321 if ( length === i ) {
326 for ( ; i < length; i++ ) {
327 // Only deal with non-null/undefined values
328 if ( (options = arguments[ i ]) != null ) {
329 // Extend the base object
330 for ( name in options ) {
331 src = target[ name ];
332 copy = options[ name ];
334 // Prevent never-ending loop
335 if ( target === copy ) {
339 // Recurse if we're merging plain objects or arrays
340 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
343 clone = src && jQuery.isArray(src) ? src : [];
346 clone = src && jQuery.isPlainObject(src) ? src : {};
349 // Never move original objects, clone them
350 target[ name ] = jQuery.extend( deep, clone, copy );
352 // Don't bring in undefined values
353 } else if ( copy !== undefined ) {
354 target[ name ] = copy;
360 // Return the modified object
365 noConflict: function( deep ) {
366 if ( window.$ === jQuery ) {
370 if ( deep && window.jQuery === jQuery ) {
371 window.jQuery = _jQuery;
377 // Is the DOM ready to be used? Set to true once it occurs.
380 // A counter to track how many items to wait for before
381 // the ready event fires. See #6781
384 // Hold (or release) the ready event
385 holdReady: function( hold ) {
389 jQuery.ready( true );
393 // Handle when the DOM is ready
394 ready: function( wait ) {
396 // Abort if there are pending holds or we're already ready
397 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
401 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
402 if ( !document.body ) {
403 return setTimeout( jQuery.ready, 1 );
406 // Remember that the DOM is ready
407 jQuery.isReady = true;
409 // If a normal DOM Ready event fired, decrement, and wait if need be
410 if ( wait !== true && --jQuery.readyWait > 0 ) {
414 // If there are functions bound, to execute
415 readyList.resolveWith( document, [ jQuery ] );
417 // Trigger any bound ready events
418 if ( jQuery.fn.trigger ) {
419 jQuery( document ).trigger("ready").off("ready");
423 // See test/unit/core.js for details concerning isFunction.
424 // Since version 1.3, DOM methods and functions like alert
425 // aren't supported. They return false on IE (#2968).
426 isFunction: function( obj ) {
427 return jQuery.type(obj) === "function";
430 isArray: Array.isArray || function( obj ) {
431 return jQuery.type(obj) === "array";
434 isWindow: function( obj ) {
435 return obj != null && obj == obj.window;
438 isNumeric: function( obj ) {
439 return !isNaN( parseFloat(obj) ) && isFinite( obj );
442 type: function( obj ) {
445 class2type[ core_toString.call(obj) ] || "object";
448 isPlainObject: function( obj ) {
449 // Must be an Object.
450 // Because of IE, we also have to check the presence of the constructor property.
451 // Make sure that DOM nodes and window objects don't pass through, as well
452 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
457 // Not own constructor property must be Object
458 if ( obj.constructor &&
459 !core_hasOwn.call(obj, "constructor") &&
460 !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
464 // IE8,9 Will throw exceptions on certain host objects #9897
468 // Own properties are enumerated firstly, so to speed up,
469 // if last one is own, then all properties are own.
472 for ( key in obj ) {}
474 return key === undefined || core_hasOwn.call( obj, key );
477 isEmptyObject: function( obj ) {
479 for ( name in obj ) {
485 error: function( msg ) {
486 throw new Error( msg );
489 // data: string of html
490 // context (optional): If specified, the fragment will be created in this context, defaults to document
491 // scripts (optional): If true, will include scripts passed in the html string
492 parseHTML: function( data, context, scripts ) {
494 if ( !data || typeof data !== "string" ) {
497 if ( typeof context === "boolean" ) {
501 context = context || document;
504 if ( (parsed = rsingleTag.exec( data )) ) {
505 return [ context.createElement( parsed[1] ) ];
508 parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
509 return jQuery.merge( [],
510 (parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
513 parseJSON: function( data ) {
514 if ( !data || typeof data !== "string") {
518 // Make sure leading/trailing whitespace is removed (IE can't handle it)
519 data = jQuery.trim( data );
521 // Attempt to parse using the native JSON parser first
522 if ( window.JSON && window.JSON.parse ) {
523 return window.JSON.parse( data );
526 // Make sure the incoming data is actual JSON
527 // Logic borrowed from http://json.org/json2.js
528 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
529 .replace( rvalidtokens, "]" )
530 .replace( rvalidbraces, "")) ) {
532 return ( new Function( "return " + data ) )();
535 jQuery.error( "Invalid JSON: " + data );
538 // Cross-browser xml parsing
539 parseXML: function( data ) {
541 if ( !data || typeof data !== "string" ) {
545 if ( window.DOMParser ) { // Standard
546 tmp = new DOMParser();
547 xml = tmp.parseFromString( data , "text/xml" );
549 xml = new ActiveXObject( "Microsoft.XMLDOM" );
556 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
557 jQuery.error( "Invalid XML: " + data );
564 // Evaluates a script in a global context
565 // Workarounds based on findings by Jim Driscoll
566 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
567 globalEval: function( data ) {
568 if ( data && core_rnotwhite.test( data ) ) {
569 // We use execScript on Internet Explorer
570 // We use an anonymous function so that context is window
571 // rather than jQuery in Firefox
572 ( window.execScript || function( data ) {
573 window[ "eval" ].call( window, data );
578 // Convert dashed to camelCase; used by the css and data modules
579 // Microsoft forgot to hump their vendor prefix (#9572)
580 camelCase: function( string ) {
581 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
584 nodeName: function( elem, name ) {
585 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
588 // args is for internal usage only
589 each: function( obj, callback, args ) {
593 isObj = length === undefined || jQuery.isFunction( obj );
597 for ( name in obj ) {
598 if ( callback.apply( obj[ name ], args ) === false ) {
603 for ( ; i < length; ) {
604 if ( callback.apply( obj[ i++ ], args ) === false ) {
610 // A special, fast, case for the most common use of each
613 for ( name in obj ) {
614 if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
619 for ( ; i < length; ) {
620 if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
630 // Use native String.trim function wherever possible
631 trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
633 return text == null ?
635 core_trim.call( text );
638 // Otherwise use our own trimming functionality
640 return text == null ?
642 ( text + "" ).replace( rtrim, "" );
645 // results is for internal usage only
646 makeArray: function( arr, results ) {
651 // The window, strings (and functions) also have 'length'
652 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
653 type = jQuery.type( arr );
655 if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
656 core_push.call( ret, arr );
658 jQuery.merge( ret, arr );
665 inArray: function( elem, arr, i ) {
669 if ( core_indexOf ) {
670 return core_indexOf.call( arr, elem, i );
674 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
676 for ( ; i < len; i++ ) {
677 // Skip accessing in sparse arrays
678 if ( i in arr && arr[ i ] === elem ) {
687 merge: function( first, second ) {
688 var l = second.length,
692 if ( typeof l === "number" ) {
693 for ( ; j < l; j++ ) {
694 first[ i++ ] = second[ j ];
698 while ( second[j] !== undefined ) {
699 first[ i++ ] = second[ j++ ];
708 grep: function( elems, callback, inv ) {
712 length = elems.length;
715 // Go through the array, only saving the items
716 // that pass the validator function
717 for ( ; i < length; i++ ) {
718 retVal = !!callback( elems[ i ], i );
719 if ( inv !== retVal ) {
720 ret.push( elems[ i ] );
727 // arg is for internal usage only
728 map: function( elems, callback, arg ) {
732 length = elems.length,
733 // jquery objects are treated as arrays
734 isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
736 // Go through the array, translating each of the items to their
738 for ( ; i < length; i++ ) {
739 value = callback( elems[ i ], i, arg );
741 if ( value != null ) {
742 ret[ ret.length ] = value;
746 // Go through every key on the object,
748 for ( key in elems ) {
749 value = callback( elems[ key ], key, arg );
751 if ( value != null ) {
752 ret[ ret.length ] = value;
757 // Flatten any nested arrays
758 return ret.concat.apply( [], ret );
761 // A global GUID counter for objects
764 // Bind a function to a context, optionally partially applying any
766 proxy: function( fn, context ) {
767 var tmp, args, proxy;
769 if ( typeof context === "string" ) {
775 // Quick check to determine if target is callable, in the spec
776 // this throws a TypeError, but we will just return undefined.
777 if ( !jQuery.isFunction( fn ) ) {
782 args = core_slice.call( arguments, 2 );
784 return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
787 // Set the guid of unique handler to the same of original handler, so it can be removed
788 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
793 // Multifunctional method to get and set values of a collection
794 // The value/s can optionally be executed if it's a function
795 access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
799 length = elems.length;
802 if ( key && typeof key === "object" ) {
804 jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
809 } else if ( value !== undefined ) {
810 // Optionally, function values get executed if exec is true
811 exec = pass === undefined && jQuery.isFunction( value );
814 // Bulk operations only iterate when executing function values
817 fn = function( elem, key, value ) {
818 return exec.call( jQuery( elem ), value );
821 // Otherwise they run against the entire set
823 fn.call( elems, value );
829 for (; i < length; i++ ) {
830 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
843 length ? fn( elems[0], key ) : emptyGet;
847 return ( new Date() ).getTime();
851 jQuery.ready.promise = function( obj ) {
854 readyList = jQuery.Deferred();
856 // Catch cases where $(document).ready() is called after the browser event has already occurred.
857 // we once tried to use readyState "interactive" here, but it caused issues like the one
858 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
859 if ( document.readyState === "complete" ) {
860 // Handle it asynchronously to allow scripts the opportunity to delay ready
861 setTimeout( jQuery.ready, 1 );
863 // Standards-based browsers support DOMContentLoaded
864 } else if ( document.addEventListener ) {
865 // Use the handy event callback
866 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
868 // A fallback to window.onload, that will always work
869 window.addEventListener( "load", jQuery.ready, false );
871 // If IE event model is used
873 // Ensure firing before onload, maybe late but safe also for iframes
874 document.attachEvent( "onreadystatechange", DOMContentLoaded );
876 // A fallback to window.onload, that will always work
877 window.attachEvent( "onload", jQuery.ready );
879 // If IE and not a frame
880 // continually check to see if the document is ready
884 top = window.frameElement == null && document.documentElement;
887 if ( top && top.doScroll ) {
888 (function doScrollCheck() {
889 if ( !jQuery.isReady ) {
892 // Use the trick by Diego Perini
893 // http://javascript.nwbox.com/IEContentLoaded/
894 top.doScroll("left");
896 return setTimeout( doScrollCheck, 50 );
899 // and execute any waiting functions
906 return readyList.promise( obj );
909 // Populate the class2type map
910 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
911 class2type[ "[object " + name + "]" ] = name.toLowerCase();
914 // All jQuery objects should point back to these
915 rootjQuery = jQuery(document);
916 // String to Object options format cache
917 var optionsCache = {};
919 // Convert String-formatted options into Object-formatted ones and store in cache
920 function createOptions( options ) {
921 var object = optionsCache[ options ] = {};
922 jQuery.each( options.split( core_rspace ), function( _, flag ) {
923 object[ flag ] = true;
929 * Create a callback list using the following parameters:
931 * options: an optional list of space-separated options that will change how
932 * the callback list behaves or a more traditional option object
934 * By default a callback list will act like an event callback list and can be
935 * "fired" multiple times.
939 * once: will ensure the callback list can only be fired once (like a Deferred)
941 * memory: will keep track of previous values and will call any callback added
942 * after the list has been fired right away with the latest "memorized"
943 * values (like a Deferred)
945 * unique: will ensure a callback can only be added once (no duplicate in the list)
947 * stopOnFalse: interrupt callings when a callback returns false
950 jQuery.Callbacks = function( options ) {
952 // Convert options from String-formatted to Object-formatted if needed
953 // (we check in cache first)
954 options = typeof options === "string" ?
955 ( optionsCache[ options ] || createOptions( options ) ) :
956 jQuery.extend( {}, options );
958 var // Last fire value (for non-forgettable lists)
960 // Flag to know if list was already fired
962 // Flag to know if list is currently firing
964 // First callback to fire (used internally by add and fireWith)
966 // End of the loop when firing
968 // Index of currently firing callback (modified by remove if needed)
970 // Actual callback list
972 // Stack of fire calls for repeatable lists
973 stack = !options.once && [],
975 fire = function( data ) {
976 memory = options.memory && data;
978 firingIndex = firingStart || 0;
980 firingLength = list.length;
982 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
983 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
984 memory = false; // To prevent further calls using add
991 if ( stack.length ) {
992 fire( stack.shift() );
994 } else if ( memory ) {
1001 // Actual Callbacks object
1003 // Add a callback or a collection of callbacks to the list
1006 // First, we save the current length
1007 var start = list.length;
1008 (function add( args ) {
1009 jQuery.each( args, function( _, arg ) {
1010 var type = jQuery.type( arg );
1011 if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
1013 } else if ( arg && arg.length && type !== "string" ) {
1014 // Inspect recursively
1019 // Do we need to add the callbacks to the
1020 // current firing batch?
1022 firingLength = list.length;
1023 // With memory, if we're not firing then
1024 // we should call right away
1025 } else if ( memory ) {
1026 firingStart = start;
1032 // Remove a callback from the list
1033 remove: function() {
1035 jQuery.each( arguments, function( _, arg ) {
1037 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1038 list.splice( index, 1 );
1039 // Handle firing indexes
1041 if ( index <= firingLength ) {
1044 if ( index <= firingIndex ) {
1053 // Control if a given callback is in the list
1054 has: function( fn ) {
1055 return jQuery.inArray( fn, list ) > -1;
1057 // Remove all callbacks from the list
1062 // Have the list do nothing anymore
1063 disable: function() {
1064 list = stack = memory = undefined;
1068 disabled: function() {
1071 // Lock the list in its current state
1080 locked: function() {
1083 // Call all callbacks with the given context and arguments
1084 fireWith: function( context, args ) {
1086 args = [ context, args.slice ? args.slice() : args ];
1087 if ( list && ( !fired || stack ) ) {
1096 // Call all the callbacks with the given arguments
1098 self.fireWith( this, arguments );
1101 // To know if the callbacks have already been called at least once
1111 Deferred: function( func ) {
1113 // action, add listener, listener list, final state
1114 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1115 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1116 [ "notify", "progress", jQuery.Callbacks("memory") ]
1123 always: function() {
1124 deferred.done( arguments ).fail( arguments );
1127 then: function( /* fnDone, fnFail, fnProgress */ ) {
1128 var fns = arguments;
1129 return jQuery.Deferred(function( newDefer ) {
1130 jQuery.each( tuples, function( i, tuple ) {
1131 var action = tuple[ 0 ],
1133 // deferred[ done | fail | progress ] for forwarding actions to newDefer
1134 deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
1136 var returned = fn.apply( this, arguments );
1137 if ( returned && jQuery.isFunction( returned.promise ) ) {
1139 .done( newDefer.resolve )
1140 .fail( newDefer.reject )
1141 .progress( newDefer.notify );
1143 newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
1152 // Get a promise for this deferred
1153 // If obj is provided, the promise aspect is added to the object
1154 promise: function( obj ) {
1155 return obj != null ? jQuery.extend( obj, promise ) : promise;
1160 // Keep pipe for back-compat
1161 promise.pipe = promise.then;
1163 // Add list-specific methods
1164 jQuery.each( tuples, function( i, tuple ) {
1165 var list = tuple[ 2 ],
1166 stateString = tuple[ 3 ];
1168 // promise[ done | fail | progress ] = list.add
1169 promise[ tuple[1] ] = list.add;
1172 if ( stateString ) {
1173 list.add(function() {
1174 // state = [ resolved | rejected ]
1175 state = stateString;
1177 // [ reject_list | resolve_list ].disable; progress_list.lock
1178 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1181 // deferred[ resolve | reject | notify ] = list.fire
1182 deferred[ tuple[0] ] = list.fire;
1183 deferred[ tuple[0] + "With" ] = list.fireWith;
1186 // Make the deferred a promise
1187 promise.promise( deferred );
1189 // Call given func if any
1191 func.call( deferred, deferred );
1199 when: function( subordinate /* , ..., subordinateN */ ) {
1201 resolveValues = core_slice.call( arguments ),
1202 length = resolveValues.length,
1204 // the count of uncompleted subordinates
1205 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1207 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1208 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1210 // Update function for both resolve and progress values
1211 updateFunc = function( i, contexts, values ) {
1212 return function( value ) {
1213 contexts[ i ] = this;
1214 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
1215 if( values === progressValues ) {
1216 deferred.notifyWith( contexts, values );
1217 } else if ( !( --remaining ) ) {
1218 deferred.resolveWith( contexts, values );
1223 progressValues, progressContexts, resolveContexts;
1225 // add listeners to Deferred subordinates; treat others as resolved
1227 progressValues = new Array( length );
1228 progressContexts = new Array( length );
1229 resolveContexts = new Array( length );
1230 for ( ; i < length; i++ ) {
1231 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1232 resolveValues[ i ].promise()
1233 .done( updateFunc( i, resolveContexts, resolveValues ) )
1234 .fail( deferred.reject )
1235 .progress( updateFunc( i, progressContexts, progressValues ) );
1242 // if we're not waiting on anything, resolve the master
1244 deferred.resolveWith( resolveContexts, resolveValues );
1247 return deferred.promise();
1250 jQuery.support = (function() {
1263 div = document.createElement("div");
1265 // Preliminary tests
1266 div.setAttribute( "className", "t" );
1267 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
1269 all = div.getElementsByTagName("*");
1270 a = div.getElementsByTagName("a")[ 0 ];
1271 a.style.cssText = "top:1px;float:left;opacity:.5";
1273 // Can't get basic test support
1274 if ( !all || !all.length ) {
1278 // First batch of supports tests
1279 select = document.createElement("select");
1280 opt = select.appendChild( document.createElement("option") );
1281 input = div.getElementsByTagName("input")[ 0 ];
1284 // IE strips leading whitespace when .innerHTML is used
1285 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
1287 // Make sure that tbody elements aren't automatically inserted
1288 // IE will insert them into empty tables
1289 tbody: !div.getElementsByTagName("tbody").length,
1291 // Make sure that link elements get serialized correctly by innerHTML
1292 // This requires a wrapper element in IE
1293 htmlSerialize: !!div.getElementsByTagName("link").length,
1295 // Get the style information from getAttribute
1296 // (IE uses .cssText instead)
1297 style: /top/.test( a.getAttribute("style") ),
1299 // Make sure that URLs aren't manipulated
1300 // (IE normalizes it by default)
1301 hrefNormalized: ( a.getAttribute("href") === "/a" ),
1303 // Make sure that element opacity exists
1304 // (IE uses filter instead)
1305 // Use a regex to work around a WebKit issue. See #5145
1306 opacity: /^0.5/.test( a.style.opacity ),
1308 // Verify style float existence
1309 // (IE uses styleFloat instead of cssFloat)
1310 cssFloat: !!a.style.cssFloat,
1312 // Make sure that if no value is specified for a checkbox
1313 // that it defaults to "on".
1314 // (WebKit defaults to "" instead)
1315 checkOn: ( input.value === "on" ),
1317 // Make sure that a selected-by-default option has a working selected property.
1318 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
1319 optSelected: opt.selected,
1321 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
1322 getSetAttribute: div.className !== "t",
1324 // Tests for enctype support on a form(#6743)
1325 enctype: !!document.createElement("form").enctype,
1327 // Makes sure cloning an html5 element does not cause problems
1328 // Where outerHTML is undefined, this still works
1329 html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
1331 // jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
1332 boxModel: ( document.compatMode === "CSS1Compat" ),
1334 // Will be defined later
1335 submitBubbles: true,
1336 changeBubbles: true,
1337 focusinBubbles: false,
1338 deleteExpando: true,
1340 inlineBlockNeedsLayout: false,
1341 shrinkWrapBlocks: false,
1342 reliableMarginRight: true,
1343 boxSizingReliable: true,
1344 pixelPosition: false
1347 // Make sure checked status is properly cloned
1348 input.checked = true;
1349 support.noCloneChecked = input.cloneNode( true ).checked;
1351 // Make sure that the options inside disabled selects aren't marked as disabled
1352 // (WebKit marks them as disabled)
1353 select.disabled = true;
1354 support.optDisabled = !opt.disabled;
1356 // Test to see if it's possible to delete an expando from an element
1357 // Fails in Internet Explorer
1361 support.deleteExpando = false;
1364 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
1365 div.attachEvent( "onclick", clickFn = function() {
1366 // Cloning a node shouldn't copy over any
1367 // bound event handlers (IE does this)
1368 support.noCloneEvent = false;
1370 div.cloneNode( true ).fireEvent("onclick");
1371 div.detachEvent( "onclick", clickFn );
1374 // Check if a radio maintains its value
1375 // after being appended to the DOM
1376 input = document.createElement("input");
1378 input.setAttribute( "type", "radio" );
1379 support.radioValue = input.value === "t";
1381 input.setAttribute( "checked", "checked" );
1383 // #11217 - WebKit loses check when the name is after the checked attribute
1384 input.setAttribute( "name", "t" );
1386 div.appendChild( input );
1387 fragment = document.createDocumentFragment();
1388 fragment.appendChild( div.lastChild );
1390 // WebKit doesn't clone checked state correctly in fragments
1391 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
1393 // Check if a disconnected checkbox will retain its checked
1394 // value of true after appended to the DOM (IE6/7)
1395 support.appendChecked = input.checked;
1397 fragment.removeChild( input );
1398 fragment.appendChild( div );
1400 // Technique from Juriy Zaytsev
1401 // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
1402 // We only care about the case where non-standard event systems
1403 // are used, namely in IE. Short-circuiting here helps us to
1404 // avoid an eval call (in setAttribute) which can cause CSP
1405 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
1406 if ( div.attachEvent ) {
1412 eventName = "on" + i;
1413 isSupported = ( eventName in div );
1414 if ( !isSupported ) {
1415 div.setAttribute( eventName, "return;" );
1416 isSupported = ( typeof div[ eventName ] === "function" );
1418 support[ i + "Bubbles" ] = isSupported;
1422 // Run tests that need a body at doc ready
1424 var container, div, tds, marginDiv,
1425 divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
1426 body = document.getElementsByTagName("body")[0];
1429 // Return for frameset docs that don't have a body
1433 container = document.createElement("div");
1434 container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
1435 body.insertBefore( container, body.firstChild );
1437 // Construct the test element
1438 div = document.createElement("div");
1439 container.appendChild( div );
1441 // Check if table cells still have offsetWidth/Height when they are set
1442 // to display:none and there are still other visible table cells in a
1443 // table row; if so, offsetWidth/Height are not reliable for use when
1444 // determining if an element has been hidden directly using
1445 // display:none (it is still safe to use offsets if a parent element is
1446 // hidden; don safety goggles and see bug #4512 for more information).
1447 // (only IE 8 fails this test)
1448 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
1449 tds = div.getElementsByTagName("td");
1450 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
1451 isSupported = ( tds[ 0 ].offsetHeight === 0 );
1453 tds[ 0 ].style.display = "";
1454 tds[ 1 ].style.display = "none";
1456 // Check if empty table cells still have offsetWidth/Height
1457 // (IE <= 8 fail this test)
1458 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
1460 // Check box-sizing and margin behavior
1462 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%;";
1463 support.boxSizing = ( div.offsetWidth === 4 );
1464 support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
1466 // NOTE: To any future maintainer, we've window.getComputedStyle
1467 // because jsdom on node.js will break without it.
1468 if ( window.getComputedStyle ) {
1469 support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
1470 support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
1472 // Check if div with explicit width and no margin-right incorrectly
1473 // gets computed margin-right based on width of container. For more
1474 // info see bug #3333
1475 // Fails in WebKit before Feb 2011 nightlies
1476 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
1477 marginDiv = document.createElement("div");
1478 marginDiv.style.cssText = div.style.cssText = divReset;
1479 marginDiv.style.marginRight = marginDiv.style.width = "0";
1480 div.style.width = "1px";
1481 div.appendChild( marginDiv );
1482 support.reliableMarginRight =
1483 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
1486 if ( typeof div.style.zoom !== "undefined" ) {
1487 // Check if natively block-level elements act like inline-block
1488 // elements when setting their display to 'inline' and giving
1490 // (IE < 8 does this)
1492 div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
1493 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
1495 // Check if elements with layout shrink-wrap their children
1497 div.style.display = "block";
1498 div.style.overflow = "visible";
1499 div.innerHTML = "<div></div>";
1500 div.firstChild.style.width = "5px";
1501 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
1503 container.style.zoom = 1;
1506 // Null elements to avoid leaks in IE
1507 body.removeChild( container );
1508 container = div = tds = marginDiv = null;
1511 // Null elements to avoid leaks in IE
1512 fragment.removeChild( div );
1513 all = a = select = opt = input = fragment = div = null;
1517 var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
1518 rmultiDash = /([A-Z])/g;
1525 // Remove at next major release (1.9/2.0)
1528 // Unique for each copy of jQuery on the page
1529 // Non-digits removed to match rinlinejQuery
1530 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
1532 // The following elements throw uncatchable exceptions if you
1533 // attempt to add expando properties to them.
1536 // Ban all objects except for Flash (which handle expandos)
1537 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
1541 hasData: function( elem ) {
1542 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
1543 return !!elem && !isEmptyDataObject( elem );
1546 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
1547 if ( !jQuery.acceptData( elem ) ) {
1552 internalKey = jQuery.expando,
1553 getByName = typeof name === "string",
1555 // We have to handle DOM nodes and JS objects differently because IE6-7
1556 // can't GC object references properly across the DOM-JS boundary
1557 isNode = elem.nodeType,
1559 // Only DOM nodes need the global jQuery cache; JS object data is
1560 // attached directly to the object so GC can occur automatically
1561 cache = isNode ? jQuery.cache : elem,
1563 // Only defining an ID for JS objects if its cache already exists allows
1564 // the code to shortcut on the same path as a DOM node with no cache
1565 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
1567 // Avoid doing any more work than we need to when trying to get data on an
1568 // object that has no data at all
1569 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
1574 // Only DOM nodes need a new unique ID for each element since their data
1575 // ends up in the global cache
1577 elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
1583 if ( !cache[ id ] ) {
1586 // Avoids exposing jQuery metadata on plain JS objects when the object
1587 // is serialized using JSON.stringify
1589 cache[ id ].toJSON = jQuery.noop;
1593 // An object can be passed to jQuery.data instead of a key/value pair; this gets
1594 // shallow copied over onto the existing cache
1595 if ( typeof name === "object" || typeof name === "function" ) {
1597 cache[ id ] = jQuery.extend( cache[ id ], name );
1599 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
1603 thisCache = cache[ id ];
1605 // jQuery data() is stored in a separate object inside the object's internal data
1606 // cache in order to avoid key collisions between internal data and user-defined
1609 if ( !thisCache.data ) {
1610 thisCache.data = {};
1613 thisCache = thisCache.data;
1616 if ( data !== undefined ) {
1617 thisCache[ jQuery.camelCase( name ) ] = data;
1620 // Check for both converted-to-camel and non-converted data property names
1621 // If a data property was specified
1624 // First Try to find as-is property data
1625 ret = thisCache[ name ];
1627 // Test for null|undefined property data
1628 if ( ret == null ) {
1630 // Try to find the camelCased property
1631 ret = thisCache[ jQuery.camelCase( name ) ];
1640 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
1641 if ( !jQuery.acceptData( elem ) ) {
1645 var thisCache, i, l,
1647 isNode = elem.nodeType,
1649 // See jQuery.data for more information
1650 cache = isNode ? jQuery.cache : elem,
1651 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
1653 // If there is already no cache entry for this object, there is no
1654 // purpose in continuing
1655 if ( !cache[ id ] ) {
1661 thisCache = pvt ? cache[ id ] : cache[ id ].data;
1665 // Support array or space separated string names for data keys
1666 if ( !jQuery.isArray( name ) ) {
1668 // try the string as a key before any manipulation
1669 if ( name in thisCache ) {
1673 // split the camel cased version by spaces unless a key with the spaces exists
1674 name = jQuery.camelCase( name );
1675 if ( name in thisCache ) {
1678 name = name.split(" ");
1683 for ( i = 0, l = name.length; i < l; i++ ) {
1684 delete thisCache[ name[i] ];
1687 // If there is no data left in the cache, we want to continue
1688 // and let the cache object itself get destroyed
1689 if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
1695 // See jQuery.data for more information
1697 delete cache[ id ].data;
1699 // Don't destroy the parent cache unless the internal data object
1700 // had been the only thing left in it
1701 if ( !isEmptyDataObject( cache[ id ] ) ) {
1706 // Destroy the cache
1708 jQuery.cleanData( [ elem ], true );
1710 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
1711 } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
1714 // When all else fails, null
1720 // For internal use only.
1721 _data: function( elem, name, data ) {
1722 return jQuery.data( elem, name, data, true );
1725 // A method for determining if a DOM node can handle the data expando
1726 acceptData: function( elem ) {
1727 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
1729 // nodes accept data unless otherwise specified; rejection can be conditional
1730 return !noData || noData !== true && elem.getAttribute("classid") === noData;
1735 data: function( key, value ) {
1736 var parts, part, attr, name, l,
1742 if ( key === undefined ) {
1743 if ( this.length ) {
1744 data = jQuery.data( elem );
1746 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
1747 attr = elem.attributes;
1748 for ( l = attr.length; i < l; i++ ) {
1749 name = attr[i].name;
1751 if ( !name.indexOf( "data-" ) ) {
1752 name = jQuery.camelCase( name.substring(5) );
1754 dataAttr( elem, name, data[ name ] );
1757 jQuery._data( elem, "parsedAttrs", true );
1764 // Sets multiple values
1765 if ( typeof key === "object" ) {
1766 return this.each(function() {
1767 jQuery.data( this, key );
1771 parts = key.split( ".", 2 );
1772 parts[1] = parts[1] ? "." + parts[1] : "";
1773 part = parts[1] + "!";
1775 return jQuery.access( this, function( value ) {
1777 if ( value === undefined ) {
1778 data = this.triggerHandler( "getData" + part, [ parts[0] ] );
1780 // Try to fetch any internally stored data first
1781 if ( data === undefined && elem ) {
1782 data = jQuery.data( elem, key );
1783 data = dataAttr( elem, key, data );
1786 return data === undefined && parts[1] ?
1787 this.data( parts[0] ) :
1792 this.each(function() {
1793 var self = jQuery( this );
1795 self.triggerHandler( "setData" + part, parts );
1796 jQuery.data( this, key, value );
1797 self.triggerHandler( "changeData" + part, parts );
1799 }, null, value, arguments.length > 1, null, false );
1802 removeData: function( key ) {
1803 return this.each(function() {
1804 jQuery.removeData( this, key );
1809 function dataAttr( elem, key, data ) {
1810 // If nothing was found internally, try to fetch any
1811 // data from the HTML5 data-* attribute
1812 if ( data === undefined && elem.nodeType === 1 ) {
1814 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1816 data = elem.getAttribute( name );
1818 if ( typeof data === "string" ) {
1820 data = data === "true" ? true :
1821 data === "false" ? false :
1822 data === "null" ? null :
1823 // Only convert to a number if it doesn't change the string
1824 +data + "" === data ? +data :
1825 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1829 // Make sure we set the data so it isn't changed later
1830 jQuery.data( elem, key, data );
1840 // checks a cache object for emptiness
1841 function isEmptyDataObject( obj ) {
1843 for ( name in obj ) {
1845 // if the public data object is empty, the private is still empty
1846 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
1849 if ( name !== "toJSON" ) {
1857 queue: function( elem, type, data ) {
1861 type = ( type || "fx" ) + "queue";
1862 queue = jQuery._data( elem, type );
1864 // Speed up dequeue by getting out quickly if this is just a lookup
1866 if ( !queue || jQuery.isArray(data) ) {
1867 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
1876 dequeue: function( elem, type ) {
1877 type = type || "fx";
1879 var queue = jQuery.queue( elem, type ),
1880 startLength = queue.length,
1882 hooks = jQuery._queueHooks( elem, type ),
1884 jQuery.dequeue( elem, type );
1887 // If the fx queue is dequeued, always remove the progress sentinel
1888 if ( fn === "inprogress" ) {
1895 // Add a progress sentinel to prevent the fx queue from being
1896 // automatically dequeued
1897 if ( type === "fx" ) {
1898 queue.unshift( "inprogress" );
1901 // clear up the last queue stop function
1903 fn.call( elem, next, hooks );
1906 if ( !startLength && hooks ) {
1911 // not intended for public consumption - generates a queueHooks object, or returns the current one
1912 _queueHooks: function( elem, type ) {
1913 var key = type + "queueHooks";
1914 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
1915 empty: jQuery.Callbacks("once memory").add(function() {
1916 jQuery.removeData( elem, type + "queue", true );
1917 jQuery.removeData( elem, key, true );
1924 queue: function( type, data ) {
1927 if ( typeof type !== "string" ) {
1933 if ( arguments.length < setter ) {
1934 return jQuery.queue( this[0], type );
1937 return data === undefined ?
1939 this.each(function() {
1940 var queue = jQuery.queue( this, type, data );
1942 // ensure a hooks for this queue
1943 jQuery._queueHooks( this, type );
1945 if ( type === "fx" && queue[0] !== "inprogress" ) {
1946 jQuery.dequeue( this, type );
1950 dequeue: function( type ) {
1951 return this.each(function() {
1952 jQuery.dequeue( this, type );
1955 // Based off of the plugin by Clint Helfers, with permission.
1956 // http://blindsignals.com/index.php/2009/07/jquery-delay/
1957 delay: function( time, type ) {
1958 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
1959 type = type || "fx";
1961 return this.queue( type, function( next, hooks ) {
1962 var timeout = setTimeout( next, time );
1963 hooks.stop = function() {
1964 clearTimeout( timeout );
1968 clearQueue: function( type ) {
1969 return this.queue( type || "fx", [] );
1971 // Get a promise resolved when queues of a certain type
1972 // are emptied (fx is the type by default)
1973 promise: function( type, obj ) {
1976 defer = jQuery.Deferred(),
1979 resolve = function() {
1980 if ( !( --count ) ) {
1981 defer.resolveWith( elements, [ elements ] );
1985 if ( typeof type !== "string" ) {
1989 type = type || "fx";
1992 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
1993 if ( tmp && tmp.empty ) {
1995 tmp.empty.add( resolve );
1999 return defer.promise( obj );
2002 var nodeHook, boolHook, fixSpecified,
2003 rclass = /[\t\r\n]/g,
2005 rtype = /^(?:button|input)$/i,
2006 rfocusable = /^(?:button|input|object|select|textarea)$/i,
2007 rclickable = /^a(?:rea|)$/i,
2008 rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
2009 getSetAttribute = jQuery.support.getSetAttribute;
2012 attr: function( name, value ) {
2013 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
2016 removeAttr: function( name ) {
2017 return this.each(function() {
2018 jQuery.removeAttr( this, name );
2022 prop: function( name, value ) {
2023 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
2026 removeProp: function( name ) {
2027 name = jQuery.propFix[ name ] || name;
2028 return this.each(function() {
2029 // try/catch handles cases where IE balks (such as removing a property on window)
2031 this[ name ] = undefined;
2032 delete this[ name ];
2037 addClass: function( value ) {
2038 var classNames, i, l, elem,
2041 if ( jQuery.isFunction( value ) ) {
2042 return this.each(function( j ) {
2043 jQuery( this ).addClass( value.call(this, j, this.className) );
2047 if ( value && typeof value === "string" ) {
2048 classNames = value.split( core_rspace );
2050 for ( i = 0, l = this.length; i < l; i++ ) {
2053 if ( elem.nodeType === 1 ) {
2054 if ( !elem.className && classNames.length === 1 ) {
2055 elem.className = value;
2058 setClass = " " + elem.className + " ";
2060 for ( c = 0, cl = classNames.length; c < cl; c++ ) {
2061 if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
2062 setClass += classNames[ c ] + " ";
2065 elem.className = jQuery.trim( setClass );
2074 removeClass: function( value ) {
2075 var removes, className, elem, c, cl, i, l;
2077 if ( jQuery.isFunction( value ) ) {
2078 return this.each(function( j ) {
2079 jQuery( this ).removeClass( value.call(this, j, this.className) );
2082 if ( (value && typeof value === "string") || value === undefined ) {
2083 removes = ( value || "" ).split( core_rspace );
2085 for ( i = 0, l = this.length; i < l; i++ ) {
2087 if ( elem.nodeType === 1 && elem.className ) {
2089 className = (" " + elem.className + " ").replace( rclass, " " );
2091 // loop over each item in the removal list
2092 for ( c = 0, cl = removes.length; c < cl; c++ ) {
2093 // Remove until there is nothing to remove,
2094 while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
2095 className = className.replace( " " + removes[ c ] + " " , " " );
2098 elem.className = value ? jQuery.trim( className ) : "";
2106 toggleClass: function( value, stateVal ) {
2107 var type = typeof value,
2108 isBool = typeof stateVal === "boolean";
2110 if ( jQuery.isFunction( value ) ) {
2111 return this.each(function( i ) {
2112 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
2116 return this.each(function() {
2117 if ( type === "string" ) {
2118 // toggle individual class names
2121 self = jQuery( this ),
2123 classNames = value.split( core_rspace );
2125 while ( (className = classNames[ i++ ]) ) {
2126 // check each className given, space separated list
2127 state = isBool ? state : !self.hasClass( className );
2128 self[ state ? "addClass" : "removeClass" ]( className );
2131 } else if ( type === "undefined" || type === "boolean" ) {
2132 if ( this.className ) {
2133 // store className if set
2134 jQuery._data( this, "__className__", this.className );
2137 // toggle whole className
2138 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
2143 hasClass: function( selector ) {
2144 var className = " " + selector + " ",
2147 for ( ; i < l; i++ ) {
2148 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
2156 val: function( value ) {
2157 var hooks, ret, isFunction,
2160 if ( !arguments.length ) {
2162 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
2164 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
2170 return typeof ret === "string" ?
2171 // handle most common string cases
2172 ret.replace(rreturn, "") :
2173 // handle cases where value is null/undef or number
2174 ret == null ? "" : ret;
2180 isFunction = jQuery.isFunction( value );
2182 return this.each(function( i ) {
2184 self = jQuery(this);
2186 if ( this.nodeType !== 1 ) {
2191 val = value.call( this, i, self.val() );
2196 // Treat null/undefined as ""; convert numbers to string
2197 if ( val == null ) {
2199 } else if ( typeof val === "number" ) {
2201 } else if ( jQuery.isArray( val ) ) {
2202 val = jQuery.map(val, function ( value ) {
2203 return value == null ? "" : value + "";
2207 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
2209 // If set returns undefined, fall back to normal setting
2210 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
2220 get: function( elem ) {
2221 // attributes.value is undefined in Blackberry 4.7 but
2222 // uses .value. See #6932
2223 var val = elem.attributes.value;
2224 return !val || val.specified ? elem.value : elem.text;
2228 get: function( elem ) {
2229 var value, i, max, option,
2230 index = elem.selectedIndex,
2232 options = elem.options,
2233 one = elem.type === "select-one";
2235 // Nothing was selected
2240 // Loop through all the selected options
2241 i = one ? index : 0;
2242 max = one ? index + 1 : options.length;
2243 for ( ; i < max; i++ ) {
2244 option = options[ i ];
2246 // Don't return options that are disabled or in a disabled optgroup
2247 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
2248 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
2250 // Get the specific value for the option
2251 value = jQuery( option ).val();
2253 // We don't need an array for one selects
2258 // Multi-Selects return an array
2259 values.push( value );
2263 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
2264 if ( one && !values.length && options.length ) {
2265 return jQuery( options[ index ] ).val();
2271 set: function( elem, value ) {
2272 var values = jQuery.makeArray( value );
2274 jQuery(elem).find("option").each(function() {
2275 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
2278 if ( !values.length ) {
2279 elem.selectedIndex = -1;
2286 // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
2289 attr: function( elem, name, value, pass ) {
2290 var ret, hooks, notxml,
2291 nType = elem.nodeType;
2293 // don't get/set attributes on text, comment and attribute nodes
2294 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2298 if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
2299 return jQuery( elem )[ name ]( value );
2302 // Fallback to prop when attributes are not supported
2303 if ( typeof elem.getAttribute === "undefined" ) {
2304 return jQuery.prop( elem, name, value );
2307 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2309 // All attributes are lowercase
2310 // Grab necessary hook if one is defined
2312 name = name.toLowerCase();
2313 hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
2316 if ( value !== undefined ) {
2318 if ( value === null ) {
2319 jQuery.removeAttr( elem, name );
2322 } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
2326 elem.setAttribute( name, value + "" );
2330 } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
2335 ret = elem.getAttribute( name );
2337 // Non-existent attributes return null, we normalize to undefined
2338 return ret === null ?
2344 removeAttr: function( elem, value ) {
2345 var propName, attrNames, name, isBool,
2348 if ( value && elem.nodeType === 1 ) {
2350 attrNames = value.split( core_rspace );
2352 for ( ; i < attrNames.length; i++ ) {
2353 name = attrNames[ i ];
2356 propName = jQuery.propFix[ name ] || name;
2357 isBool = rboolean.test( name );
2359 // See #9699 for explanation of this approach (setting first, then removal)
2360 // Do not do this for boolean attributes (see #10870)
2362 jQuery.attr( elem, name, "" );
2364 elem.removeAttribute( getSetAttribute ? name : propName );
2366 // Set corresponding property to false for boolean attributes
2367 if ( isBool && propName in elem ) {
2368 elem[ propName ] = false;
2377 set: function( elem, value ) {
2378 // We can't allow the type property to be changed (since it causes problems in IE)
2379 if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
2380 jQuery.error( "type property can't be changed" );
2381 } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
2382 // Setting the type on a radio button after the value resets the value in IE6-9
2383 // Reset value to it's default in case type is set after value
2384 // This is for element creation
2385 var val = elem.value;
2386 elem.setAttribute( "type", value );
2394 // Use the value property for back compat
2395 // Use the nodeHook for button elements in IE6/7 (#1954)
2397 get: function( elem, name ) {
2398 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2399 return nodeHook.get( elem, name );
2401 return name in elem ?
2405 set: function( elem, value, name ) {
2406 if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
2407 return nodeHook.set( elem, value, name );
2409 // Does not return so that setAttribute is also used
2416 tabindex: "tabIndex",
2417 readonly: "readOnly",
2419 "class": "className",
2420 maxlength: "maxLength",
2421 cellspacing: "cellSpacing",
2422 cellpadding: "cellPadding",
2426 frameborder: "frameBorder",
2427 contenteditable: "contentEditable"
2430 prop: function( elem, name, value ) {
2431 var ret, hooks, notxml,
2432 nType = elem.nodeType;
2434 // don't get/set properties on text, comment and attribute nodes
2435 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
2439 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
2442 // Fix name and attach hooks
2443 name = jQuery.propFix[ name ] || name;
2444 hooks = jQuery.propHooks[ name ];
2447 if ( value !== undefined ) {
2448 if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
2452 return ( elem[ name ] = value );
2456 if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
2460 return elem[ name ];
2467 get: function( elem ) {
2468 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
2469 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
2470 var attributeNode = elem.getAttributeNode("tabindex");
2472 return attributeNode && attributeNode.specified ?
2473 parseInt( attributeNode.value, 10 ) :
2474 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
2482 // Hook for boolean attributes
2484 get: function( elem, name ) {
2485 // Align boolean attributes with corresponding properties
2486 // Fall back to attribute presence where some booleans are not supported
2488 property = jQuery.prop( elem, name );
2489 return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
2490 name.toLowerCase() :
2493 set: function( elem, value, name ) {
2495 if ( value === false ) {
2496 // Remove boolean attributes when set to false
2497 jQuery.removeAttr( elem, name );
2499 // value is true since we know at this point it's type boolean and not false
2500 // Set boolean attributes to the same name and set the DOM property
2501 propName = jQuery.propFix[ name ] || name;
2502 if ( propName in elem ) {
2503 // Only set the IDL specifically if it already exists on the element
2504 elem[ propName ] = true;
2507 elem.setAttribute( name, name.toLowerCase() );
2513 // IE6/7 do not support getting/setting some attributes with get/setAttribute
2514 if ( !getSetAttribute ) {
2522 // Use this for any attribute in IE6/7
2523 // This fixes almost every IE6/7 issue
2524 nodeHook = jQuery.valHooks.button = {
2525 get: function( elem, name ) {
2527 ret = elem.getAttributeNode( name );
2528 return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
2532 set: function( elem, value, name ) {
2533 // Set the existing or create a new attribute node
2534 var ret = elem.getAttributeNode( name );
2536 ret = document.createAttribute( name );
2537 elem.setAttributeNode( ret );
2539 return ( ret.value = value + "" );
2543 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
2544 // This is for removals
2545 jQuery.each([ "width", "height" ], function( i, name ) {
2546 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2547 set: function( elem, value ) {
2548 if ( value === "" ) {
2549 elem.setAttribute( name, "auto" );
2556 // Set contenteditable to false on removals(#10429)
2557 // Setting to empty string throws an error as an invalid value
2558 jQuery.attrHooks.contenteditable = {
2560 set: function( elem, value, name ) {
2561 if ( value === "" ) {
2564 nodeHook.set( elem, value, name );
2570 // Some attributes require a special call on IE
2571 if ( !jQuery.support.hrefNormalized ) {
2572 jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
2573 jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
2574 get: function( elem ) {
2575 var ret = elem.getAttribute( name, 2 );
2576 return ret === null ? undefined : ret;
2582 if ( !jQuery.support.style ) {
2583 jQuery.attrHooks.style = {
2584 get: function( elem ) {
2585 // Return undefined in the case of empty string
2586 // Normalize to lowercase since IE uppercases css property names
2587 return elem.style.cssText.toLowerCase() || undefined;
2589 set: function( elem, value ) {
2590 return ( elem.style.cssText = value + "" );
2595 // Safari mis-reports the default selected property of an option
2596 // Accessing the parent's selectedIndex property fixes it
2597 if ( !jQuery.support.optSelected ) {
2598 jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
2599 get: function( elem ) {
2600 var parent = elem.parentNode;
2603 parent.selectedIndex;
2605 // Make sure that it also works with optgroups, see #5701
2606 if ( parent.parentNode ) {
2607 parent.parentNode.selectedIndex;
2615 // IE6/7 call enctype encoding
2616 if ( !jQuery.support.enctype ) {
2617 jQuery.propFix.enctype = "encoding";
2620 // Radios and checkboxes getter/setter
2621 if ( !jQuery.support.checkOn ) {
2622 jQuery.each([ "radio", "checkbox" ], function() {
2623 jQuery.valHooks[ this ] = {
2624 get: function( elem ) {
2625 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
2626 return elem.getAttribute("value") === null ? "on" : elem.value;
2631 jQuery.each([ "radio", "checkbox" ], function() {
2632 jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
2633 set: function( elem, value ) {
2634 if ( jQuery.isArray( value ) ) {
2635 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
2640 var rformElems = /^(?:textarea|input|select)$/i,
2641 rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
2642 rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
2644 rmouseEvent = /^(?:mouse|contextmenu)|click/,
2645 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2646 hoverHack = function( events ) {
2647 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
2651 * Helper functions for managing events -- not part of the public interface.
2652 * Props to Dean Edwards' addEvent library for many of the ideas.
2656 add: function( elem, types, handler, data, selector ) {
2658 var elemData, eventHandle, events,
2659 t, tns, type, namespaces, handleObj,
2660 handleObjIn, handlers, special;
2662 // Don't attach events to noData or text/comment nodes (allow plain objects tho)
2663 if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
2667 // Caller can pass in an object of custom data in lieu of the handler
2668 if ( handler.handler ) {
2669 handleObjIn = handler;
2670 handler = handleObjIn.handler;
2671 selector = handleObjIn.selector;
2674 // Make sure that the handler has a unique ID, used to find/remove it later
2675 if ( !handler.guid ) {
2676 handler.guid = jQuery.guid++;
2679 // Init the element's event structure and main handler, if this is the first
2680 events = elemData.events;
2682 elemData.events = events = {};
2684 eventHandle = elemData.handle;
2685 if ( !eventHandle ) {
2686 elemData.handle = eventHandle = function( e ) {
2687 // Discard the second event of a jQuery.event.trigger() and
2688 // when an event is called after a page has unloaded
2689 return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
2690 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
2693 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
2694 eventHandle.elem = elem;
2697 // Handle multiple events separated by a space
2698 // jQuery(...).bind("mouseover mouseout", fn);
2699 types = jQuery.trim( hoverHack(types) ).split( " " );
2700 for ( t = 0; t < types.length; t++ ) {
2702 tns = rtypenamespace.exec( types[t] ) || [];
2704 namespaces = ( tns[2] || "" ).split( "." ).sort();
2706 // If event changes its type, use the special event handlers for the changed type
2707 special = jQuery.event.special[ type ] || {};
2709 // If selector defined, determine special event api type, otherwise given type
2710 type = ( selector ? special.delegateType : special.bindType ) || type;
2712 // Update special based on newly reset type
2713 special = jQuery.event.special[ type ] || {};
2715 // handleObj is passed to all event handlers
2716 handleObj = jQuery.extend({
2723 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2724 namespace: namespaces.join(".")
2727 // Init the event handler queue if we're the first
2728 handlers = events[ type ];
2730 handlers = events[ type ] = [];
2731 handlers.delegateCount = 0;
2733 // Only use addEventListener/attachEvent if the special events handler returns false
2734 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2735 // Bind the global event handler to the element
2736 if ( elem.addEventListener ) {
2737 elem.addEventListener( type, eventHandle, false );
2739 } else if ( elem.attachEvent ) {
2740 elem.attachEvent( "on" + type, eventHandle );
2745 if ( special.add ) {
2746 special.add.call( elem, handleObj );
2748 if ( !handleObj.handler.guid ) {
2749 handleObj.handler.guid = handler.guid;
2753 // Add to the element's handler list, delegates in front
2755 handlers.splice( handlers.delegateCount++, 0, handleObj );
2757 handlers.push( handleObj );
2760 // Keep track of which events have ever been used, for event optimization
2761 jQuery.event.global[ type ] = true;
2764 // Nullify elem to prevent memory leaks in IE
2770 // Detach an event or set of events from an element
2771 remove: function( elem, types, handler, selector, mappedTypes ) {
2773 var t, tns, type, origType, namespaces, origCount,
2774 j, events, special, eventType, handleObj,
2775 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
2777 if ( !elemData || !(events = elemData.events) ) {
2781 // Once for each type.namespace in types; type may be omitted
2782 types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
2783 for ( t = 0; t < types.length; t++ ) {
2784 tns = rtypenamespace.exec( types[t] ) || [];
2785 type = origType = tns[1];
2786 namespaces = tns[2];
2788 // Unbind all events (on this namespace, if provided) for the element
2790 for ( type in events ) {
2791 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2796 special = jQuery.event.special[ type ] || {};
2797 type = ( selector? special.delegateType : special.bindType ) || type;
2798 eventType = events[ type ] || [];
2799 origCount = eventType.length;
2800 namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2802 // Remove matching events
2803 for ( j = 0; j < eventType.length; j++ ) {
2804 handleObj = eventType[ j ];
2806 if ( ( mappedTypes || origType === handleObj.origType ) &&
2807 ( !handler || handler.guid === handleObj.guid ) &&
2808 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
2809 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2810 eventType.splice( j--, 1 );
2812 if ( handleObj.selector ) {
2813 eventType.delegateCount--;
2815 if ( special.remove ) {
2816 special.remove.call( elem, handleObj );
2821 // Remove generic event handler if we removed something and no more handlers exist
2822 // (avoids potential for endless recursion during removal of special event handlers)
2823 if ( eventType.length === 0 && origCount !== eventType.length ) {
2824 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2825 jQuery.removeEvent( elem, type, elemData.handle );
2828 delete events[ type ];
2832 // Remove the expando if it's no longer used
2833 if ( jQuery.isEmptyObject( events ) ) {
2834 delete elemData.handle;
2836 // removeData also checks for emptiness and clears the expando if empty
2837 // so use it instead of delete
2838 jQuery.removeData( elem, "events", true );
2842 // Events that are safe to short-circuit if no handlers are attached.
2843 // Native DOM events should not be added, they may have inline handlers.
2850 trigger: function( event, data, elem, onlyHandlers ) {
2851 // Don't do events on text and comment nodes
2852 if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
2856 // Event object or event type
2857 var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
2858 type = event.type || event,
2861 // focus/blur morphs to focusin/out; ensure we're not firing them right now
2862 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2866 if ( type.indexOf( "!" ) >= 0 ) {
2867 // Exclusive events trigger only for the exact event (no namespaces)
2868 type = type.slice(0, -1);
2872 if ( type.indexOf( "." ) >= 0 ) {
2873 // Namespaced trigger; create a regexp to match event type in handle()
2874 namespaces = type.split(".");
2875 type = namespaces.shift();
2879 if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
2880 // No jQuery handlers for this event type, and it can't have inline handlers
2884 // Caller can pass in an Event, Object, or just an event type string
2885 event = typeof event === "object" ?
2886 // jQuery.Event object
2887 event[ jQuery.expando ] ? event :
2889 new jQuery.Event( type, event ) :
2890 // Just the event type (string)
2891 new jQuery.Event( type );
2894 event.isTrigger = true;
2895 event.exclusive = exclusive;
2896 event.namespace = namespaces.join( "." );
2897 event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
2898 ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";
2900 // Handle a global trigger
2903 // TODO: Stop taunting the data cache; remove global events and always attach to document
2904 cache = jQuery.cache;
2905 for ( i in cache ) {
2906 if ( cache[ i ].events && cache[ i ].events[ type ] ) {
2907 jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
2913 // Clean up the event in case it is being reused
2914 event.result = undefined;
2915 if ( !event.target ) {
2916 event.target = elem;
2919 // Clone any incoming data and prepend the event, creating the handler arg list
2920 data = data != null ? jQuery.makeArray( data ) : [];
2921 data.unshift( event );
2923 // Allow special events to draw outside the lines
2924 special = jQuery.event.special[ type ] || {};
2925 if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
2929 // Determine event propagation path in advance, per W3C events spec (#9951)
2930 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2931 eventPath = [[ elem, special.bindType || type ]];
2932 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2934 bubbleType = special.delegateType || type;
2935 cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
2936 for ( old = elem; cur; cur = cur.parentNode ) {
2937 eventPath.push([ cur, bubbleType ]);
2941 // Only add window if we got to document (e.g., not plain obj or detached DOM)
2942 if ( old === (elem.ownerDocument || document) ) {
2943 eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
2947 // Fire handlers on the event path
2948 for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {
2950 cur = eventPath[i][0];
2951 event.type = eventPath[i][1];
2953 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
2955 handle.apply( cur, data );
2957 // Note that this is a bare JS function and not a jQuery handler
2958 handle = ontype && cur[ ontype ];
2959 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
2960 event.preventDefault();
2965 // If nobody prevented the default action, do it now
2966 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
2968 if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
2969 !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
2971 // Call a native DOM method on the target with the same name name as the event.
2972 // Can't use an .isFunction() check here because IE6/7 fails that test.
2973 // Don't do default actions on window, that's where global variables be (#6170)
2974 // IE<9 dies on focus/blur to hidden element (#1486)
2975 if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
2977 // Don't re-trigger an onFOO event when we call its FOO() method
2978 old = elem[ ontype ];
2981 elem[ ontype ] = null;
2984 // Prevent re-triggering of the same event, since we already bubbled it above
2985 jQuery.event.triggered = type;
2987 jQuery.event.triggered = undefined;
2990 elem[ ontype ] = old;
2996 return event.result;
2999 dispatch: function( event ) {
3001 // Make a writable jQuery.Event from the native event object
3002 event = jQuery.event.fix( event || window.event );
3004 var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
3005 handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
3006 delegateCount = handlers.delegateCount,
3007 args = core_slice.call( arguments ),
3008 run_all = !event.exclusive && !event.namespace,
3009 special = jQuery.event.special[ event.type ] || {},
3012 // Use the fix-ed jQuery.Event rather than the (read-only) native event
3014 event.delegateTarget = this;
3016 // Call the preDispatch hook for the mapped type, and let it bail if desired
3017 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
3021 // Determine handlers that should run if there are delegated events
3022 // Avoid non-left-click bubbling in Firefox (#3861)
3023 if ( delegateCount && !(event.button && event.type === "click") ) {
3025 for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
3027 // Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
3028 if ( cur.disabled !== true || event.type !== "click" ) {
3031 for ( i = 0; i < delegateCount; i++ ) {
3032 handleObj = handlers[ i ];
3033 sel = handleObj.selector;
3035 if ( selMatch[ sel ] === undefined ) {
3036 selMatch[ sel ] = handleObj.needsContext ?
3037 jQuery( sel, this ).index( cur ) >= 0 :
3038 jQuery.find( sel, this, null, [ cur ] ).length;
3040 if ( selMatch[ sel ] ) {
3041 matches.push( handleObj );
3044 if ( matches.length ) {
3045 handlerQueue.push({ elem: cur, matches: matches });
3051 // Add the remaining (directly-bound) handlers
3052 if ( handlers.length > delegateCount ) {
3053 handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
3056 // Run delegates first; they may want to stop propagation beneath us
3057 for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
3058 matched = handlerQueue[ i ];
3059 event.currentTarget = matched.elem;
3061 for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
3062 handleObj = matched.matches[ j ];
3064 // Triggered event must either 1) be non-exclusive and have no namespace, or
3065 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
3066 if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {
3068 event.data = handleObj.data;
3069 event.handleObj = handleObj;
3071 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
3072 .apply( matched.elem, args );
3074 if ( ret !== undefined ) {
3076 if ( ret === false ) {
3077 event.preventDefault();
3078 event.stopPropagation();
3085 // Call the postDispatch hook for the mapped type
3086 if ( special.postDispatch ) {
3087 special.postDispatch.call( this, event );
3090 return event.result;
3093 // Includes some event props shared by KeyEvent and MouseEvent
3094 // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
3095 props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
3100 props: "char charCode key keyCode".split(" "),
3101 filter: function( event, original ) {
3103 // Add which for key events
3104 if ( event.which == null ) {
3105 event.which = original.charCode != null ? original.charCode : original.keyCode;
3113 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
3114 filter: function( event, original ) {
3115 var eventDoc, doc, body,
3116 button = original.button,
3117 fromElement = original.fromElement;
3119 // Calculate pageX/Y if missing and clientX/Y available
3120 if ( event.pageX == null && original.clientX != null ) {
3121 eventDoc = event.target.ownerDocument || document;
3122 doc = eventDoc.documentElement;
3123 body = eventDoc.body;
3125 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
3126 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
3129 // Add relatedTarget, if necessary
3130 if ( !event.relatedTarget && fromElement ) {
3131 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
3134 // Add which for click: 1 === left; 2 === middle; 3 === right
3135 // Note: button is not normalized, so don't use it
3136 if ( !event.which && button !== undefined ) {
3137 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
3144 fix: function( event ) {
3145 if ( event[ jQuery.expando ] ) {
3149 // Create a writable copy of the event object and normalize some properties
3151 originalEvent = event,
3152 fixHook = jQuery.event.fixHooks[ event.type ] || {},
3153 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
3155 event = jQuery.Event( originalEvent );
3157 for ( i = copy.length; i; ) {
3159 event[ prop ] = originalEvent[ prop ];
3162 // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
3163 if ( !event.target ) {
3164 event.target = originalEvent.srcElement || document;
3167 // Target should not be a text node (#504, Safari)
3168 if ( event.target.nodeType === 3 ) {
3169 event.target = event.target.parentNode;
3172 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
3173 event.metaKey = !!event.metaKey;
3175 return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
3180 // Prevent triggered image.load events from bubbling to window.load
3185 delegateType: "focusin"
3188 delegateType: "focusout"
3192 setup: function( data, namespaces, eventHandle ) {
3193 // We only want to do this special case on windows
3194 if ( jQuery.isWindow( this ) ) {
3195 this.onbeforeunload = eventHandle;
3199 teardown: function( namespaces, eventHandle ) {
3200 if ( this.onbeforeunload === eventHandle ) {
3201 this.onbeforeunload = null;
3207 simulate: function( type, elem, event, bubble ) {
3208 // Piggyback on a donor event to simulate a different one.
3209 // Fake originalEvent to avoid donor's stopPropagation, but if the
3210 // simulated event prevents default then we do the same on the donor.
3211 var e = jQuery.extend(
3220 jQuery.event.trigger( e, null, elem );
3222 jQuery.event.dispatch.call( elem, e );
3224 if ( e.isDefaultPrevented() ) {
3225 event.preventDefault();
3230 // Some plugins are using, but it's undocumented/deprecated and will be removed.
3231 // The 1.7 special event interface should provide all the hooks needed now.
3232 jQuery.event.handle = jQuery.event.dispatch;
3234 jQuery.removeEvent = document.removeEventListener ?
3235 function( elem, type, handle ) {
3236 if ( elem.removeEventListener ) {
3237 elem.removeEventListener( type, handle, false );
3240 function( elem, type, handle ) {
3241 var name = "on" + type;
3243 if ( elem.detachEvent ) {
3245 // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
3246 // detachEvent needed property on element, by name of that event, to properly expose it to GC
3247 if ( typeof elem[ name ] === "undefined" ) {
3248 elem[ name ] = null;
3251 elem.detachEvent( name, handle );
3255 jQuery.Event = function( src, props ) {
3256 // Allow instantiation without the 'new' keyword
3257 if ( !(this instanceof jQuery.Event) ) {
3258 return new jQuery.Event( src, props );
3262 if ( src && src.type ) {
3263 this.originalEvent = src;
3264 this.type = src.type;
3266 // Events bubbling up the document may have been marked as prevented
3267 // by a handler lower down the tree; reflect the correct value.
3268 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
3269 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
3276 // Put explicitly provided properties onto the event object
3278 jQuery.extend( this, props );
3281 // Create a timestamp if incoming event doesn't have one
3282 this.timeStamp = src && src.timeStamp || jQuery.now();
3285 this[ jQuery.expando ] = true;
3288 function returnFalse() {
3291 function returnTrue() {
3295 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
3296 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
3297 jQuery.Event.prototype = {
3298 preventDefault: function() {
3299 this.isDefaultPrevented = returnTrue;
3301 var e = this.originalEvent;
3306 // if preventDefault exists run it on the original event
3307 if ( e.preventDefault ) {
3310 // otherwise set the returnValue property of the original event to false (IE)
3312 e.returnValue = false;
3315 stopPropagation: function() {
3316 this.isPropagationStopped = returnTrue;
3318 var e = this.originalEvent;
3322 // if stopPropagation exists run it on the original event
3323 if ( e.stopPropagation ) {
3324 e.stopPropagation();
3326 // otherwise set the cancelBubble property of the original event to true (IE)
3327 e.cancelBubble = true;
3329 stopImmediatePropagation: function() {
3330 this.isImmediatePropagationStopped = returnTrue;
3331 this.stopPropagation();
3333 isDefaultPrevented: returnFalse,
3334 isPropagationStopped: returnFalse,
3335 isImmediatePropagationStopped: returnFalse
3338 // Create mouseenter/leave events using mouseover/out and event-time checks
3340 mouseenter: "mouseover",
3341 mouseleave: "mouseout"
3342 }, function( orig, fix ) {
3343 jQuery.event.special[ orig ] = {
3347 handle: function( event ) {
3350 related = event.relatedTarget,
3351 handleObj = event.handleObj,
3352 selector = handleObj.selector;
3354 // For mousenter/leave call the handler if related is outside the target.
3355 // NB: No relatedTarget if the mouse left/entered the browser window
3356 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
3357 event.type = handleObj.origType;
3358 ret = handleObj.handler.apply( this, arguments );
3366 // IE submit delegation
3367 if ( !jQuery.support.submitBubbles ) {
3369 jQuery.event.special.submit = {
3371 // Only need this for delegated form submit events
3372 if ( jQuery.nodeName( this, "form" ) ) {
3376 // Lazy-add a submit handler when a descendant form may potentially be submitted
3377 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
3378 // Node name check avoids a VML-related crash in IE (#9807)
3379 var elem = e.target,
3380 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
3381 if ( form && !jQuery._data( form, "_submit_attached" ) ) {
3382 jQuery.event.add( form, "submit._submit", function( event ) {
3383 event._submit_bubble = true;
3385 jQuery._data( form, "_submit_attached", true );
3388 // return undefined since we don't need an event listener
3391 postDispatch: function( event ) {
3392 // If form was submitted by the user, bubble the event up the tree
3393 if ( event._submit_bubble ) {
3394 delete event._submit_bubble;
3395 if ( this.parentNode && !event.isTrigger ) {
3396 jQuery.event.simulate( "submit", this.parentNode, event, true );
3401 teardown: function() {
3402 // Only need this for delegated form submit events
3403 if ( jQuery.nodeName( this, "form" ) ) {
3407 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
3408 jQuery.event.remove( this, "._submit" );
3413 // IE change delegation and checkbox/radio fix
3414 if ( !jQuery.support.changeBubbles ) {
3416 jQuery.event.special.change = {
3420 if ( rformElems.test( this.nodeName ) ) {
3421 // IE doesn't fire change on a check/radio until blur; trigger it on click
3422 // after a propertychange. Eat the blur-change in special.change.handle.
3423 // This still fires onchange a second time for check/radio after blur.
3424 if ( this.type === "checkbox" || this.type === "radio" ) {
3425 jQuery.event.add( this, "propertychange._change", function( event ) {
3426 if ( event.originalEvent.propertyName === "checked" ) {
3427 this._just_changed = true;
3430 jQuery.event.add( this, "click._change", function( event ) {
3431 if ( this._just_changed && !event.isTrigger ) {
3432 this._just_changed = false;
3434 // Allow triggered, simulated change events (#11500)
3435 jQuery.event.simulate( "change", this, event, true );
3440 // Delegated event; lazy-add a change handler on descendant inputs
3441 jQuery.event.add( this, "beforeactivate._change", function( e ) {
3442 var elem = e.target;
3444 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
3445 jQuery.event.add( elem, "change._change", function( event ) {
3446 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
3447 jQuery.event.simulate( "change", this.parentNode, event, true );
3450 jQuery._data( elem, "_change_attached", true );
3455 handle: function( event ) {
3456 var elem = event.target;
3458 // Swallow native change events from checkbox/radio, we already triggered them above
3459 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
3460 return event.handleObj.handler.apply( this, arguments );
3464 teardown: function() {
3465 jQuery.event.remove( this, "._change" );
3467 return !rformElems.test( this.nodeName );
3472 // Create "bubbling" focus and blur events
3473 if ( !jQuery.support.focusinBubbles ) {
3474 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
3476 // Attach a single capturing handler while someone wants focusin/focusout
3478 handler = function( event ) {
3479 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
3482 jQuery.event.special[ fix ] = {
3484 if ( attaches++ === 0 ) {
3485 document.addEventListener( orig, handler, true );
3488 teardown: function() {
3489 if ( --attaches === 0 ) {
3490 document.removeEventListener( orig, handler, true );
3499 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
3502 // Types can be a map of types/handlers
3503 if ( typeof types === "object" ) {
3504 // ( types-Object, selector, data )
3505 if ( typeof selector !== "string" ) { // && selector != null
3506 // ( types-Object, data )
3507 data = data || selector;
3508 selector = undefined;
3510 for ( type in types ) {
3511 this.on( type, selector, data, types[ type ], one );
3516 if ( data == null && fn == null ) {
3519 data = selector = undefined;
3520 } else if ( fn == null ) {
3521 if ( typeof selector === "string" ) {
3522 // ( types, selector, fn )
3526 // ( types, data, fn )
3529 selector = undefined;
3532 if ( fn === false ) {
3540 fn = function( event ) {
3541 // Can use an empty set, since event contains the info
3542 jQuery().off( event );
3543 return origFn.apply( this, arguments );
3545 // Use same guid so caller can remove using origFn
3546 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
3548 return this.each( function() {
3549 jQuery.event.add( this, types, fn, data, selector );
3552 one: function( types, selector, data, fn ) {
3553 return this.on( types, selector, data, fn, 1 );
3555 off: function( types, selector, fn ) {
3556 var handleObj, type;
3557 if ( types && types.preventDefault && types.handleObj ) {
3558 // ( event ) dispatched jQuery.Event
3559 handleObj = types.handleObj;
3560 jQuery( types.delegateTarget ).off(
3561 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
3567 if ( typeof types === "object" ) {
3568 // ( types-object [, selector] )
3569 for ( type in types ) {
3570 this.off( type, selector, types[ type ] );
3574 if ( selector === false || typeof selector === "function" ) {
3577 selector = undefined;
3579 if ( fn === false ) {
3582 return this.each(function() {
3583 jQuery.event.remove( this, types, fn, selector );
3587 bind: function( types, data, fn ) {
3588 return this.on( types, null, data, fn );
3590 unbind: function( types, fn ) {
3591 return this.off( types, null, fn );
3594 live: function( types, data, fn ) {
3595 jQuery( this.context ).on( types, this.selector, data, fn );
3598 die: function( types, fn ) {
3599 jQuery( this.context ).off( types, this.selector || "**", fn );
3603 delegate: function( selector, types, data, fn ) {
3604 return this.on( types, selector, data, fn );
3606 undelegate: function( selector, types, fn ) {
3607 // ( namespace ) or ( selector, types [, fn] )
3608 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
3611 trigger: function( type, data ) {
3612 return this.each(function() {
3613 jQuery.event.trigger( type, data, this );
3616 triggerHandler: function( type, data ) {
3618 return jQuery.event.trigger( type, data, this[0], true );
3622 toggle: function( fn ) {
3623 // Save reference to arguments for access in closure
3624 var args = arguments,
3625 guid = fn.guid || jQuery.guid++,
3627 toggler = function( event ) {
3628 // Figure out which function to execute
3629 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
3630 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
3632 // Make sure that clicks stop
3633 event.preventDefault();
3635 // and execute the function
3636 return args[ lastToggle ].apply( this, arguments ) || false;
3639 // link all the functions, so any of them can unbind this click handler
3640 toggler.guid = guid;
3641 while ( i < args.length ) {
3642 args[ i++ ].guid = guid;
3645 return this.click( toggler );
3648 hover: function( fnOver, fnOut ) {
3649 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
3653 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
3654 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
3655 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
3657 // Handle event binding
3658 jQuery.fn[ name ] = function( data, fn ) {
3664 return arguments.length > 0 ?
3665 this.on( name, null, data, fn ) :
3666 this.trigger( name );
3669 if ( rkeyEvent.test( name ) ) {
3670 jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
3673 if ( rmouseEvent.test( name ) ) {
3674 jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
3678 * Sizzle CSS Selector Engine
3679 * Copyright 2012 jQuery Foundation and other contributors
3680 * Released under the MIT license
3681 * http://sizzlejs.com/
3683 (function( window, undefined ) {
3696 baseHasDuplicate = true,
3697 strundefined = "undefined",
3699 expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
3702 document = window.document,
3703 docElem = document.documentElement,
3709 // Use a stripped-down indexOf if a native one is unavailable
3710 indexOf = [].indexOf || function( elem ) {
3713 for ( ; i < len; i++ ) {
3714 if ( this[i] === elem ) {
3721 // Augment a function for special use by Sizzle
3722 markFunction = function( fn, value ) {
3723 fn[ expando ] = value == null || value;
3727 createCache = function() {
3731 return markFunction(function( key, value ) {
3732 // Only keep the most recent entries
3733 if ( keys.push( key ) > Expr.cacheLength ) {
3734 delete cache[ keys.shift() ];
3737 return (cache[ key ] = value);
3741 classCache = createCache(),
3742 tokenCache = createCache(),
3743 compilerCache = createCache(),
3747 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
3748 whitespace = "[\\x20\\t\\r\\n\\f]",
3749 // http://www.w3.org/TR/css3-syntax/#characters
3750 characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",
3752 // Loosely modeled on CSS identifier characters
3753 // An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
3754 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
3755 identifier = characterEncoding.replace( "w", "w#" ),
3757 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
3758 operators = "([*^$|!~]?=)",
3759 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
3760 "*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
3762 // Prefer arguments not in parens/brackets,
3763 // then attribute selectors and non-pseudos (denoted by :),
3764 // then anything else
3765 // These preferences are here to reduce the number of selectors
3766 // needing tokenize in the PSEUDO preFilter
3767 pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
3769 // For matchExpr.POS and matchExpr.needsContext
3770 pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
3771 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
3773 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
3774 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
3776 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
3777 rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
3778 rpseudo = new RegExp( pseudos ),
3780 // Easily-parseable/retrievable ID or TAG or CLASS selectors
3781 rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,
3784 rsibling = /[\x20\t\r\n\f]*[+~]/,
3785 rendsWithNot = /:not\($/,
3788 rinputs = /input|select|textarea|button/i,
3790 rbackslash = /\\(?!\\)/g,
3793 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
3794 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
3795 "NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
3796 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
3797 "ATTR": new RegExp( "^" + attributes ),
3798 "PSEUDO": new RegExp( "^" + pseudos ),
3799 "POS": new RegExp( pos, "i" ),
3800 "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
3801 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
3802 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
3803 // For use in libraries implementing .is()
3804 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
3809 // Used for testing something on an element
3810 assert = function( fn ) {
3811 var div = document.createElement("div");
3818 // release memory in IE
3823 // Check if getElementsByTagName("*") returns only elements
3824 assertTagNameNoComments = assert(function( div ) {
3825 div.appendChild( document.createComment("") );
3826 return !div.getElementsByTagName("*").length;
3829 // Check if getAttribute returns normalized href attributes
3830 assertHrefNotNormalized = assert(function( div ) {
3831 div.innerHTML = "<a href='#'></a>";
3832 return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
3833 div.firstChild.getAttribute("href") === "#";
3836 // Check if attributes should be retrieved by attribute nodes
3837 assertAttributes = assert(function( div ) {
3838 div.innerHTML = "<select></select>";
3839 var type = typeof div.lastChild.getAttribute("multiple");
3840 // IE8 returns a string for some attributes even when not present
3841 return type !== "boolean" && type !== "string";
3844 // Check if getElementsByClassName can be trusted
3845 assertUsableClassName = assert(function( div ) {
3846 // Opera can't find a second classname (in 9.6)
3847 div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
3848 if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
3852 // Safari 3.2 caches class attributes and doesn't catch changes
3853 div.lastChild.className = "e";
3854 return div.getElementsByClassName("e").length === 2;
3857 // Check if getElementById returns elements by name
3858 // Check if getElementsByName privileges form controls or returns elements by ID
3859 assertUsableName = assert(function( div ) {
3861 div.id = expando + 0;
3862 div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
3863 docElem.insertBefore( div, docElem.firstChild );
3866 var pass = document.getElementsByName &&
3867 // buggy browsers will return fewer than the correct 2
3868 document.getElementsByName( expando ).length === 2 +
3869 // buggy browsers will return more than the correct 0
3870 document.getElementsByName( expando + 0 ).length;
3871 assertGetIdNotName = !document.getElementById( expando );
3874 docElem.removeChild( div );
3879 // If slice is not available, provide a backup
3881 slice.call( docElem.childNodes, 0 )[0].nodeType;
3883 slice = function( i ) {
3886 for ( ; (elem = this[i]); i++ ) {
3887 results.push( elem );
3893 function Sizzle( selector, context, results, seed ) {
3894 results = results || [];
3895 context = context || document;
3896 var match, elem, xml, m,
3897 nodeType = context.nodeType;
3899 if ( !selector || typeof selector !== "string" ) {
3903 if ( nodeType !== 1 && nodeType !== 9 ) {
3907 xml = isXML( context );
3909 if ( !xml && !seed ) {
3910 if ( (match = rquickExpr.exec( selector )) ) {
3911 // Speed-up: Sizzle("#ID")
3912 if ( (m = match[1]) ) {
3913 if ( nodeType === 9 ) {
3914 elem = context.getElementById( m );
3915 // Check parentNode to catch when Blackberry 4.6 returns
3916 // nodes that are no longer in the document #6963
3917 if ( elem && elem.parentNode ) {
3918 // Handle the case where IE, Opera, and Webkit return items
3919 // by name instead of ID
3920 if ( elem.id === m ) {
3921 results.push( elem );
3928 // Context is not a document
3929 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
3930 contains( context, elem ) && elem.id === m ) {
3931 results.push( elem );
3936 // Speed-up: Sizzle("TAG")
3937 } else if ( match[2] ) {
3938 push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
3941 // Speed-up: Sizzle(".CLASS")
3942 } else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
3943 push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
3950 return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
3953 Sizzle.matches = function( expr, elements ) {
3954 return Sizzle( expr, null, null, elements );
3957 Sizzle.matchesSelector = function( elem, expr ) {
3958 return Sizzle( expr, null, null, [ elem ] ).length > 0;
3961 // Returns a function to use in pseudos for input types
3962 function createInputPseudo( type ) {
3963 return function( elem ) {
3964 var name = elem.nodeName.toLowerCase();
3965 return name === "input" && elem.type === type;
3969 // Returns a function to use in pseudos for buttons
3970 function createButtonPseudo( type ) {
3971 return function( elem ) {
3972 var name = elem.nodeName.toLowerCase();
3973 return (name === "input" || name === "button") && elem.type === type;
3977 // Returns a function to use in pseudos for positionals
3978 function createPositionalPseudo( fn ) {
3979 return markFunction(function( argument ) {
3980 argument = +argument;
3981 return markFunction(function( seed, matches ) {
3983 matchIndexes = fn( [], seed.length, argument ),
3984 i = matchIndexes.length;
3986 // Match elements found at the specified indexes
3988 if ( seed[ (j = matchIndexes[i]) ] ) {
3989 seed[j] = !(matches[j] = seed[j]);
3997 * Utility function for retrieving the text value of an array of DOM nodes
3998 * @param {Array|Element} elem
4000 getText = Sizzle.getText = function( elem ) {
4004 nodeType = elem.nodeType;
4007 if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
4008 // Use textContent for elements
4009 // innerText usage removed for consistency of new lines (see #11153)
4010 if ( typeof elem.textContent === "string" ) {
4011 return elem.textContent;
4013 // Traverse its children
4014 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
4015 ret += getText( elem );
4018 } else if ( nodeType === 3 || nodeType === 4 ) {
4019 return elem.nodeValue;
4021 // Do not include comment or processing instruction nodes
4024 // If no nodeType, this is expected to be an array
4025 for ( ; (node = elem[i]); i++ ) {
4026 // Do not traverse comment nodes
4027 ret += getText( node );
4033 isXML = Sizzle.isXML = function( elem ) {
4034 // documentElement is verified for cases where it doesn't yet exist
4035 // (such as loading iframes in IE - #4833)
4036 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
4037 return documentElement ? documentElement.nodeName !== "HTML" : false;
4040 // Element contains another
4041 contains = Sizzle.contains = docElem.contains ?
4043 var adown = a.nodeType === 9 ? a.documentElement : a,
4044 bup = b && b.parentNode;
4045 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
4047 docElem.compareDocumentPosition ?
4049 return b && !!( a.compareDocumentPosition( b ) & 16 );
4052 while ( (b = b.parentNode) ) {
4060 Sizzle.attr = function( elem, name ) {
4062 xml = isXML( elem );
4065 name = name.toLowerCase();
4067 if ( (val = Expr.attrHandle[ name ]) ) {
4070 if ( xml || assertAttributes ) {
4071 return elem.getAttribute( name );
4073 val = elem.getAttributeNode( name );
4075 typeof elem[ name ] === "boolean" ?
4076 elem[ name ] ? name : null :
4077 val.specified ? val.value : null :
4081 Expr = Sizzle.selectors = {
4083 // Can be adjusted by the user
4086 createPseudo: markFunction,
4090 // IE6/7 return a modified href
4091 attrHandle: assertHrefNotNormalized ?
4094 "href": function( elem ) {
4095 return elem.getAttribute( "href", 2 );
4097 "type": function( elem ) {
4098 return elem.getAttribute("type");
4103 "ID": assertGetIdNotName ?
4104 function( id, context, xml ) {
4105 if ( typeof context.getElementById !== strundefined && !xml ) {
4106 var m = context.getElementById( id );
4107 // Check parentNode to catch when Blackberry 4.6 returns
4108 // nodes that are no longer in the document #6963
4109 return m && m.parentNode ? [m] : [];
4112 function( id, context, xml ) {
4113 if ( typeof context.getElementById !== strundefined && !xml ) {
4114 var m = context.getElementById( id );
4117 m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
4124 "TAG": assertTagNameNoComments ?
4125 function( tag, context ) {
4126 if ( typeof context.getElementsByTagName !== strundefined ) {
4127 return context.getElementsByTagName( tag );
4130 function( tag, context ) {
4131 var results = context.getElementsByTagName( tag );
4133 // Filter out possible comments
4134 if ( tag === "*" ) {
4139 for ( ; (elem = results[i]); i++ ) {
4140 if ( elem.nodeType === 1 ) {
4150 "NAME": assertUsableName && function( tag, context ) {
4151 if ( typeof context.getElementsByName !== strundefined ) {
4152 return context.getElementsByName( name );
4156 "CLASS": assertUsableClassName && function( className, context, xml ) {
4157 if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
4158 return context.getElementsByClassName( className );
4164 ">": { dir: "parentNode", first: true },
4165 " ": { dir: "parentNode" },
4166 "+": { dir: "previousSibling", first: true },
4167 "~": { dir: "previousSibling" }
4171 "ATTR": function( match ) {
4172 match[1] = match[1].replace( rbackslash, "" );
4174 // Move the given value to match[3] whether quoted or unquoted
4175 match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );
4177 if ( match[2] === "~=" ) {
4178 match[3] = " " + match[3] + " ";
4181 return match.slice( 0, 4 );
4184 "CHILD": function( match ) {
4185 /* matches from matchExpr["CHILD"]
4186 1 type (only|nth|...)
4187 2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
4188 3 xn-component of xn+y argument ([+-]?\d*n|)
4189 4 sign of xn-component
4191 6 sign of y-component
4194 match[1] = match[1].toLowerCase();
4196 if ( match[1] === "nth" ) {
4197 // nth-child requires argument
4199 Sizzle.error( match[0] );
4202 // numeric x and y parameters for Expr.filter.CHILD
4203 // remember that false/true cast respectively to 0/1
4204 match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
4205 match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );
4207 // other types prohibit arguments
4208 } else if ( match[2] ) {
4209 Sizzle.error( match[0] );
4215 "PSEUDO": function( match ) {
4216 var unquoted, excess;
4217 if ( matchExpr["CHILD"].test( match[0] ) ) {
4222 match[2] = match[3];
4223 } else if ( (unquoted = match[4]) ) {
4224 // Only check arguments that contain a pseudo
4225 if ( rpseudo.test(unquoted) &&
4226 // Get excess from tokenize (recursively)
4227 (excess = tokenize( unquoted, true )) &&
4228 // advance to the next closing parenthesis
4229 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
4231 // excess is a negative index
4232 unquoted = unquoted.slice( 0, excess );
4233 match[0] = match[0].slice( 0, excess );
4235 match[2] = unquoted;
4238 // Return only captures needed by the pseudo filter method (type and argument)
4239 return match.slice( 0, 3 );
4244 "ID": assertGetIdNotName ?
4246 id = id.replace( rbackslash, "" );
4247 return function( elem ) {
4248 return elem.getAttribute("id") === id;
4252 id = id.replace( rbackslash, "" );
4253 return function( elem ) {
4254 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
4255 return node && node.value === id;
4259 "TAG": function( nodeName ) {
4260 if ( nodeName === "*" ) {
4261 return function() { return true; };
4263 nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();
4265 return function( elem ) {
4266 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
4270 "CLASS": function( className ) {
4271 var pattern = classCache[ expando ][ className ];
4273 pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
4275 return function( elem ) {
4276 return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
4280 "ATTR": function( name, operator, check ) {
4281 return function( elem, context ) {
4282 var result = Sizzle.attr( elem, name );
4284 if ( result == null ) {
4285 return operator === "!=";
4293 return operator === "=" ? result === check :
4294 operator === "!=" ? result !== check :
4295 operator === "^=" ? check && result.indexOf( check ) === 0 :
4296 operator === "*=" ? check && result.indexOf( check ) > -1 :
4297 operator === "$=" ? check && result.substr( result.length - check.length ) === check :
4298 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
4299 operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
4304 "CHILD": function( type, argument, first, last ) {
4306 if ( type === "nth" ) {
4307 return function( elem ) {
4309 parent = elem.parentNode;
4311 if ( first === 1 && last === 0 ) {
4317 for ( node = parent.firstChild; node; node = node.nextSibling ) {
4318 if ( node.nodeType === 1 ) {
4320 if ( elem === node ) {
4327 // Incorporate the offset (or cast to NaN), then check against cycle size
4329 return diff === first || ( diff % first === 0 && diff / first >= 0 );
4333 return function( elem ) {
4339 while ( (node = node.previousSibling) ) {
4340 if ( node.nodeType === 1 ) {
4345 if ( type === "first" ) {
4353 while ( (node = node.nextSibling) ) {
4354 if ( node.nodeType === 1 ) {
4364 "PSEUDO": function( pseudo, argument ) {
4365 // pseudo-class names are case-insensitive
4366 // http://www.w3.org/TR/selectors/#pseudo-classes
4367 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
4368 // Remember that setFilters inherits from pseudos
4370 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
4371 Sizzle.error( "unsupported pseudo: " + pseudo );
4373 // The user may use createPseudo to indicate that
4374 // arguments are needed to create the filter function
4375 // just as Sizzle does
4376 if ( fn[ expando ] ) {
4377 return fn( argument );
4380 // But maintain support for old signatures
4381 if ( fn.length > 1 ) {
4382 args = [ pseudo, pseudo, "", argument ];
4383 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
4384 markFunction(function( seed, matches ) {
4386 matched = fn( seed, argument ),
4389 idx = indexOf.call( seed, matched[i] );
4390 seed[ idx ] = !( matches[ idx ] = matched[i] );
4394 return fn( elem, 0, args );
4403 "not": markFunction(function( selector ) {
4404 // Trim the selector passed to compile
4405 // to avoid treating leading and trailing
4406 // spaces as combinators
4409 matcher = compile( selector.replace( rtrim, "$1" ) );
4411 return matcher[ expando ] ?
4412 markFunction(function( seed, matches, context, xml ) {
4414 unmatched = matcher( seed, null, xml, [] ),
4417 // Match elements unmatched by `matcher`
4419 if ( (elem = unmatched[i]) ) {
4420 seed[i] = !(matches[i] = elem);
4424 function( elem, context, xml ) {
4426 matcher( input, null, xml, results );
4427 return !results.pop();
4431 "has": markFunction(function( selector ) {
4432 return function( elem ) {
4433 return Sizzle( selector, elem ).length > 0;
4437 "contains": markFunction(function( text ) {
4438 return function( elem ) {
4439 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
4443 "enabled": function( elem ) {
4444 return elem.disabled === false;
4447 "disabled": function( elem ) {
4448 return elem.disabled === true;
4451 "checked": function( elem ) {
4452 // In CSS3, :checked should return both checked and selected elements
4453 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
4454 var nodeName = elem.nodeName.toLowerCase();
4455 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
4458 "selected": function( elem ) {
4459 // Accessing this property makes selected-by-default
4460 // options in Safari work properly
4461 if ( elem.parentNode ) {
4462 elem.parentNode.selectedIndex;
4465 return elem.selected === true;
4468 "parent": function( elem ) {
4469 return !Expr.pseudos["empty"]( elem );
4472 "empty": function( elem ) {
4473 // http://www.w3.org/TR/selectors/#empty-pseudo
4474 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
4475 // not comment, processing instructions, or others
4476 // Thanks to Diego Perini for the nodeName shortcut
4477 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
4479 elem = elem.firstChild;
4481 if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
4484 elem = elem.nextSibling;
4489 "header": function( elem ) {
4490 return rheader.test( elem.nodeName );
4493 "text": function( elem ) {
4495 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
4496 // use getAttribute instead to test this case
4497 return elem.nodeName.toLowerCase() === "input" &&
4498 (type = elem.type) === "text" &&
4499 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
4503 "radio": createInputPseudo("radio"),
4504 "checkbox": createInputPseudo("checkbox"),
4505 "file": createInputPseudo("file"),
4506 "password": createInputPseudo("password"),
4507 "image": createInputPseudo("image"),
4509 "submit": createButtonPseudo("submit"),
4510 "reset": createButtonPseudo("reset"),
4512 "button": function( elem ) {
4513 var name = elem.nodeName.toLowerCase();
4514 return name === "input" && elem.type === "button" || name === "button";
4517 "input": function( elem ) {
4518 return rinputs.test( elem.nodeName );
4521 "focus": function( elem ) {
4522 var doc = elem.ownerDocument;
4523 return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
4526 "active": function( elem ) {
4527 return elem === elem.ownerDocument.activeElement;
4531 "first": createPositionalPseudo(function( matchIndexes, length, argument ) {
4535 "last": createPositionalPseudo(function( matchIndexes, length, argument ) {
4536 return [ length - 1 ];
4539 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
4540 return [ argument < 0 ? argument + length : argument ];
4543 "even": createPositionalPseudo(function( matchIndexes, length, argument ) {
4544 for ( var i = 0; i < length; i += 2 ) {
4545 matchIndexes.push( i );
4547 return matchIndexes;
4550 "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {
4551 for ( var i = 1; i < length; i += 2 ) {
4552 matchIndexes.push( i );
4554 return matchIndexes;
4557 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4558 for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
4559 matchIndexes.push( i );
4561 return matchIndexes;
4564 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
4565 for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
4566 matchIndexes.push( i );
4568 return matchIndexes;
4573 function siblingCheck( a, b, ret ) {
4578 var cur = a.nextSibling;
4585 cur = cur.nextSibling;
4591 sortOrder = docElem.compareDocumentPosition ?
4594 hasDuplicate = true;
4598 return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
4599 a.compareDocumentPosition :
4600 a.compareDocumentPosition(b) & 4
4604 // The nodes are identical, we can exit early
4606 hasDuplicate = true;
4609 // Fallback to using sourceIndex (in IE) if it's available on both nodes
4610 } else if ( a.sourceIndex && b.sourceIndex ) {
4611 return a.sourceIndex - b.sourceIndex;
4621 // If the nodes are siblings (or identical) we can do a quick check
4622 if ( aup === bup ) {
4623 return siblingCheck( a, b );
4625 // If no parents were found then the nodes are disconnected
4626 } else if ( !aup ) {
4629 } else if ( !bup ) {
4633 // Otherwise they're somewhere else in the tree so we need
4634 // to build up a full list of the parentNodes for comparison
4637 cur = cur.parentNode;
4644 cur = cur.parentNode;
4650 // Start walking down the tree looking for a discrepancy
4651 for ( var i = 0; i < al && i < bl; i++ ) {
4652 if ( ap[i] !== bp[i] ) {
4653 return siblingCheck( ap[i], bp[i] );
4657 // We ended someplace up the tree so do a sibling check
4659 siblingCheck( a, bp[i], -1 ) :
4660 siblingCheck( ap[i], b, 1 );
4663 // Always assume the presence of duplicates if sort doesn't
4664 // pass them to our comparison function (as in Google Chrome).
4665 [0, 0].sort( sortOrder );
4666 baseHasDuplicate = !hasDuplicate;
4668 // Document sorting and removing duplicates
4669 Sizzle.uniqueSort = function( results ) {
4673 hasDuplicate = baseHasDuplicate;
4674 results.sort( sortOrder );
4676 if ( hasDuplicate ) {
4677 for ( ; (elem = results[i]); i++ ) {
4678 if ( elem === results[ i - 1 ] ) {
4679 results.splice( i--, 1 );
4687 Sizzle.error = function( msg ) {
4688 throw new Error( "Syntax error, unrecognized expression: " + msg );
4691 function tokenize( selector, parseOnly ) {
4692 var matched, match, tokens, type, soFar, groups, preFilters,
4693 cached = tokenCache[ expando ][ selector ];
4696 return parseOnly ? 0 : cached.slice( 0 );
4701 preFilters = Expr.preFilter;
4705 // Comma and first run
4706 if ( !matched || (match = rcomma.exec( soFar )) ) {
4708 soFar = soFar.slice( match[0].length );
4710 groups.push( tokens = [] );
4716 if ( (match = rcombinators.exec( soFar )) ) {
4717 tokens.push( matched = new Token( match.shift() ) );
4718 soFar = soFar.slice( matched.length );
4720 // Cast descendant combinators to space
4721 matched.type = match[0].replace( rtrim, " " );
4725 for ( type in Expr.filter ) {
4726 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
4727 // The last two arguments here are (context, xml) for backCompat
4728 (match = preFilters[ type ]( match, document, true ))) ) {
4730 tokens.push( matched = new Token( match.shift() ) );
4731 soFar = soFar.slice( matched.length );
4732 matched.type = type;
4733 matched.matches = match;
4742 // Return the length of the invalid excess
4743 // if we're just parsing
4744 // Otherwise, throw an error or return tokens
4748 Sizzle.error( selector ) :
4750 tokenCache( selector, groups ).slice( 0 );
4753 function addCombinator( matcher, combinator, base ) {
4754 var dir = combinator.dir,
4755 checkNonElements = base && combinator.dir === "parentNode",
4758 return combinator.first ?
4759 // Check against closest ancestor/preceding element
4760 function( elem, context, xml ) {
4761 while ( (elem = elem[ dir ]) ) {
4762 if ( checkNonElements || elem.nodeType === 1 ) {
4763 return matcher( elem, context, xml );
4768 // Check against all ancestor/preceding elements
4769 function( elem, context, xml ) {
4770 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
4773 dirkey = dirruns + " " + doneName + " ",
4774 cachedkey = dirkey + cachedruns;
4775 while ( (elem = elem[ dir ]) ) {
4776 if ( checkNonElements || elem.nodeType === 1 ) {
4777 if ( (cache = elem[ expando ]) === cachedkey ) {
4779 } else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
4780 if ( elem.sizset ) {
4784 elem[ expando ] = cachedkey;
4785 if ( matcher( elem, context, xml ) ) {
4789 elem.sizset = false;
4794 while ( (elem = elem[ dir ]) ) {
4795 if ( checkNonElements || elem.nodeType === 1 ) {
4796 if ( matcher( elem, context, xml ) ) {
4805 function elementMatcher( matchers ) {
4806 return matchers.length > 1 ?
4807 function( elem, context, xml ) {
4808 var i = matchers.length;
4810 if ( !matchers[i]( elem, context, xml ) ) {
4819 function condense( unmatched, map, filter, context, xml ) {
4823 len = unmatched.length,
4824 mapped = map != null;
4826 for ( ; i < len; i++ ) {
4827 if ( (elem = unmatched[i]) ) {
4828 if ( !filter || filter( elem, context, xml ) ) {
4829 newUnmatched.push( elem );
4837 return newUnmatched;
4840 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
4841 if ( postFilter && !postFilter[ expando ] ) {
4842 postFilter = setMatcher( postFilter );
4844 if ( postFinder && !postFinder[ expando ] ) {
4845 postFinder = setMatcher( postFinder, postSelector );
4847 return markFunction(function( seed, results, context, xml ) {
4848 // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones
4849 if ( seed && postFinder ) {
4853 var i, elem, postFilterIn,
4856 preexisting = results.length,
4858 // Get initial elements from seed or context
4859 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),
4861 // Prefilter to get matcher input, preserving a map for seed-results synchronization
4862 matcherIn = preFilter && ( seed || !selector ) ?
4863 condense( elems, preMap, preFilter, context, xml ) :
4866 matcherOut = matcher ?
4867 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
4868 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
4870 // ...intermediate processing is necessary
4873 // ...otherwise use results directly
4877 // Find primary matches
4879 matcher( matcherIn, matcherOut, context, xml );
4884 postFilterIn = condense( matcherOut, postMap );
4885 postFilter( postFilterIn, [], context, xml );
4887 // Un-match failing elements by moving them back to matcherIn
4888 i = postFilterIn.length;
4890 if ( (elem = postFilterIn[i]) ) {
4891 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
4896 // Keep seed and results synchronized
4898 // Ignore postFinder because it can't coexist with seed
4899 i = preFilter && matcherOut.length;
4901 if ( (elem = matcherOut[i]) ) {
4902 seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);
4906 matcherOut = condense(
4907 matcherOut === results ?
4908 matcherOut.splice( preexisting, matcherOut.length ) :
4912 postFinder( null, results, matcherOut, xml );
4914 push.apply( results, matcherOut );
4920 function matcherFromTokens( tokens ) {
4921 var checkContext, matcher, j,
4922 len = tokens.length,
4923 leadingRelative = Expr.relative[ tokens[0].type ],
4924 implicitRelative = leadingRelative || Expr.relative[" "],
4925 i = leadingRelative ? 1 : 0,
4927 // The foundational matcher ensures that elements are reachable from top-level context(s)
4928 matchContext = addCombinator( function( elem ) {
4929 return elem === checkContext;
4930 }, implicitRelative, true ),
4931 matchAnyContext = addCombinator( function( elem ) {
4932 return indexOf.call( checkContext, elem ) > -1;
4933 }, implicitRelative, true ),
4934 matchers = [ function( elem, context, xml ) {
4935 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
4936 (checkContext = context).nodeType ?
4937 matchContext( elem, context, xml ) :
4938 matchAnyContext( elem, context, xml ) );
4941 for ( ; i < len; i++ ) {
4942 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
4943 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
4945 // The concatenated values are (context, xml) for backCompat
4946 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
4948 // Return special upon seeing a positional matcher
4949 if ( matcher[ expando ] ) {
4950 // Find the next relative operator (if any) for proper handling
4952 for ( ; j < len; j++ ) {
4953 if ( Expr.relative[ tokens[j].type ] ) {
4958 i > 1 && elementMatcher( matchers ),
4959 i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
4961 i < j && matcherFromTokens( tokens.slice( i, j ) ),
4962 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
4963 j < len && tokens.join("")
4966 matchers.push( matcher );
4970 return elementMatcher( matchers );
4973 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
4974 var bySet = setMatchers.length > 0,
4975 byElement = elementMatchers.length > 0,
4976 superMatcher = function( seed, context, xml, results, expandContext ) {
4977 var elem, j, matcher,
4981 unmatched = seed && [],
4982 outermost = expandContext != null,
4983 contextBackup = outermostContext,
4984 // We must always have either seed elements or context
4985 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
4986 // Nested matchers should use non-integer dirruns
4987 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
4990 outermostContext = context !== document && context;
4991 cachedruns = superMatcher.el;
4994 // Add elements passing elementMatchers directly to results
4995 for ( ; (elem = elems[i]) != null; i++ ) {
4996 if ( byElement && elem ) {
4997 for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
4998 if ( matcher( elem, context, xml ) ) {
4999 results.push( elem );
5004 dirruns = dirrunsUnique;
5005 cachedruns = ++superMatcher.el;
5009 // Track unmatched elements for set filters
5011 // They will have gone through all possible matchers
5012 if ( (elem = !matcher && elem) ) {
5016 // Lengthen the array for every element, matched or not
5018 unmatched.push( elem );
5023 // Apply set filters to unmatched elements
5025 if ( bySet && i !== matchedCount ) {
5026 for ( j = 0; (matcher = setMatchers[j]); j++ ) {
5027 matcher( unmatched, setMatched, context, xml );
5031 // Reintegrate element matches to eliminate the need for sorting
5032 if ( matchedCount > 0 ) {
5034 if ( !(unmatched[i] || setMatched[i]) ) {
5035 setMatched[i] = pop.call( results );
5040 // Discard index placeholder values to get only actual matches
5041 setMatched = condense( setMatched );
5044 // Add matches to results
5045 push.apply( results, setMatched );
5047 // Seedless set matches succeeding multiple successful matchers stipulate sorting
5048 if ( outermost && !seed && setMatched.length > 0 &&
5049 ( matchedCount + setMatchers.length ) > 1 ) {
5051 Sizzle.uniqueSort( results );
5055 // Override manipulation of globals by nested matchers
5057 dirruns = dirrunsUnique;
5058 outermostContext = contextBackup;
5064 superMatcher.el = 0;
5066 markFunction( superMatcher ) :
5070 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
5073 elementMatchers = [],
5074 cached = compilerCache[ expando ][ selector ];
5077 // Generate a function of recursive functions that can be used to check each element
5079 group = tokenize( selector );
5083 cached = matcherFromTokens( group[i] );
5084 if ( cached[ expando ] ) {
5085 setMatchers.push( cached );
5087 elementMatchers.push( cached );
5091 // Cache the compiled function
5092 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
5097 function multipleContexts( selector, contexts, results, seed ) {
5099 len = contexts.length;
5100 for ( ; i < len; i++ ) {
5101 Sizzle( selector, contexts[i], results, seed );
5106 function select( selector, context, results, seed, xml ) {
5107 var i, tokens, token, type, find,
5108 match = tokenize( selector ),
5112 // Try to minimize operations if there is only one group
5113 if ( match.length === 1 ) {
5115 // Take a shortcut and set the context if the root selector is an ID
5116 tokens = match[0] = match[0].slice( 0 );
5117 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
5118 context.nodeType === 9 && !xml &&
5119 Expr.relative[ tokens[1].type ] ) {
5121 context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
5126 selector = selector.slice( tokens.shift().length );
5129 // Fetch a seed set for right-to-left matching
5130 for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
5133 // Abort if we hit a combinator
5134 if ( Expr.relative[ (type = token.type) ] ) {
5137 if ( (find = Expr.find[ type ]) ) {
5138 // Search, expanding context for leading sibling combinators
5140 token.matches[0].replace( rbackslash, "" ),
5141 rsibling.test( tokens[0].type ) && context.parentNode || context,
5145 // If seed is empty or no tokens remain, we can return early
5146 tokens.splice( i, 1 );
5147 selector = seed.length && tokens.join("");
5149 push.apply( results, slice.call( seed, 0 ) );
5160 // Compile and execute a filtering function
5161 // Provide `match` to avoid retokenization if we modified the selector above
5162 compile( selector, match )(
5167 rsibling.test( selector )
5172 if ( document.querySelectorAll ) {
5174 var disconnectedMatch,
5177 rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
5179 // qSa(:focus) reports false when true (Chrome 21),
5180 // A support test would require too much code (would include document ready)
5181 rbuggyQSA = [":focus"],
5183 // matchesSelector(:focus) reports false when true (Chrome 21),
5184 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
5185 // A support test would require too much code (would include document ready)
5186 // just skip matchesSelector for :active
5187 rbuggyMatches = [ ":active", ":focus" ],
5188 matches = docElem.matchesSelector ||
5189 docElem.mozMatchesSelector ||
5190 docElem.webkitMatchesSelector ||
5191 docElem.oMatchesSelector ||
5192 docElem.msMatchesSelector;
5195 // Regex strategy adopted from Diego Perini
5196 assert(function( div ) {
5197 // Select is set to empty string on purpose
5198 // This is to test IE's treatment of not explictly
5199 // setting a boolean content attribute,
5200 // since its presence should be enough
5201 // http://bugs.jquery.com/ticket/12359
5202 div.innerHTML = "<select><option selected=''></option></select>";
5204 // IE8 - Some boolean attributes are not treated correctly
5205 if ( !div.querySelectorAll("[selected]").length ) {
5206 rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
5209 // Webkit/Opera - :checked should return selected option elements
5210 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
5211 // IE8 throws error here (do not put tests after this one)
5212 if ( !div.querySelectorAll(":checked").length ) {
5213 rbuggyQSA.push(":checked");
5217 assert(function( div ) {
5219 // Opera 10-12/IE9 - ^= $= *= and empty values
5220 // Should not select anything
5221 div.innerHTML = "<p test=''></p>";
5222 if ( div.querySelectorAll("[test^='']").length ) {
5223 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
5226 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
5227 // IE8 throws error here (do not put tests after this one)
5228 div.innerHTML = "<input type='hidden'/>";
5229 if ( !div.querySelectorAll(":enabled").length ) {
5230 rbuggyQSA.push(":enabled", ":disabled");
5234 // rbuggyQSA always contains :focus, so no need for a length check
5235 rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
5237 select = function( selector, context, results, seed, xml ) {
5238 // Only use querySelectorAll when not filtering,
5239 // when this is not xml,
5240 // and when no QSA bugs apply
5241 if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
5245 newContext = context,
5246 newSelector = context.nodeType === 9 && selector;
5248 // qSA works strangely on Element-rooted queries
5249 // We can work around this by specifying an extra ID on the root
5250 // and working up from there (Thanks to Andrew Dupont for the technique)
5251 // IE 8 doesn't work on object elements
5252 if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
5253 groups = tokenize( selector );
5255 if ( (old = context.getAttribute("id")) ) {
5256 nid = old.replace( rescape, "\\$&" );
5258 context.setAttribute( "id", nid );
5260 nid = "[id='" + nid + "'] ";
5264 groups[i] = nid + groups[i].join("");
5266 newContext = rsibling.test( selector ) && context.parentNode || context;
5267 newSelector = groups.join(",");
5270 if ( newSelector ) {
5272 push.apply( results, slice.call( newContext.querySelectorAll(
5279 context.removeAttribute("id");
5285 return oldSelect( selector, context, results, seed, xml );
5289 assert(function( div ) {
5290 // Check to see if it's possible to do matchesSelector
5291 // on a disconnected node (IE 9)
5292 disconnectedMatch = matches.call( div, "div" );
5294 // This should fail with an exception
5295 // Gecko does not error, returns false instead
5297 matches.call( div, "[test!='']:sizzle" );
5298 rbuggyMatches.push( "!=", pseudos );
5302 // rbuggyMatches always contains :active and :focus, so no need for a length check
5303 rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
5305 Sizzle.matchesSelector = function( elem, expr ) {
5306 // Make sure that attribute selectors are quoted
5307 expr = expr.replace( rattributeQuotes, "='$1']" );
5309 // rbuggyMatches always contains :active, so no need for an existence check
5310 if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
5312 var ret = matches.call( elem, expr );
5314 // IE 9's matchesSelector returns false on disconnected nodes
5315 if ( ret || disconnectedMatch ||
5316 // As well, disconnected nodes are said to be in a document
5318 elem.document && elem.document.nodeType !== 11 ) {
5324 return Sizzle( expr, null, null, [ elem ] ).length > 0;
5331 Expr.pseudos["nth"] = Expr.pseudos["eq"];
5334 function setFilters() {}
5335 Expr.filters = setFilters.prototype = Expr.pseudos;
5336 Expr.setFilters = new setFilters();
5338 // Override sizzle attribute retrieval
5339 Sizzle.attr = jQuery.attr;
5340 jQuery.find = Sizzle;
5341 jQuery.expr = Sizzle.selectors;
5342 jQuery.expr[":"] = jQuery.expr.pseudos;
5343 jQuery.unique = Sizzle.uniqueSort;
5344 jQuery.text = Sizzle.getText;
5345 jQuery.isXMLDoc = Sizzle.isXML;
5346 jQuery.contains = Sizzle.contains;
5350 var runtil = /Until$/,
5351 rparentsprev = /^(?:parents|prev(?:Until|All))/,
5352 isSimple = /^.[^:#\[\.,]*$/,
5353 rneedsContext = jQuery.expr.match.needsContext,
5354 // methods guaranteed to produce a unique set when starting from a unique set
5355 guaranteedUnique = {
5363 find: function( selector ) {
5364 var i, l, length, n, r, ret,
5367 if ( typeof selector !== "string" ) {
5368 return jQuery( selector ).filter(function() {
5369 for ( i = 0, l = self.length; i < l; i++ ) {
5370 if ( jQuery.contains( self[ i ], this ) ) {
5377 ret = this.pushStack( "", "find", selector );
5379 for ( i = 0, l = this.length; i < l; i++ ) {
5380 length = ret.length;
5381 jQuery.find( selector, this[i], ret );
5384 // Make sure that the results are unique
5385 for ( n = length; n < ret.length; n++ ) {
5386 for ( r = 0; r < length; r++ ) {
5387 if ( ret[r] === ret[n] ) {
5399 has: function( target ) {
5401 targets = jQuery( target, this ),
5402 len = targets.length;
5404 return this.filter(function() {
5405 for ( i = 0; i < len; i++ ) {
5406 if ( jQuery.contains( this, targets[i] ) ) {
5413 not: function( selector ) {
5414 return this.pushStack( winnow(this, selector, false), "not", selector);
5417 filter: function( selector ) {
5418 return this.pushStack( winnow(this, selector, true), "filter", selector );
5421 is: function( selector ) {
5422 return !!selector && (
5423 typeof selector === "string" ?
5424 // If this is a positional/relative selector, check membership in the returned set
5425 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5426 rneedsContext.test( selector ) ?
5427 jQuery( selector, this.context ).index( this[0] ) >= 0 :
5428 jQuery.filter( selector, this ).length > 0 :
5429 this.filter( selector ).length > 0 );
5432 closest: function( selectors, context ) {
5437 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5438 jQuery( selectors, context || this.context ) :
5441 for ( ; i < l; i++ ) {
5444 while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
5445 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
5449 cur = cur.parentNode;
5453 ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
5455 return this.pushStack( ret, "closest", selectors );
5458 // Determine the position of an element within
5459 // the matched set of elements
5460 index: function( elem ) {
5462 // No argument, return index in parent
5464 return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
5467 // index in selector
5468 if ( typeof elem === "string" ) {
5469 return jQuery.inArray( this[0], jQuery( elem ) );
5472 // Locate the position of the desired element
5473 return jQuery.inArray(
5474 // If it receives a jQuery object, the first element is used
5475 elem.jquery ? elem[0] : elem, this );
5478 add: function( selector, context ) {
5479 var set = typeof selector === "string" ?
5480 jQuery( selector, context ) :
5481 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5482 all = jQuery.merge( this.get(), set );
5484 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
5486 jQuery.unique( all ) );
5489 addBack: function( selector ) {
5490 return this.add( selector == null ?
5491 this.prevObject : this.prevObject.filter(selector)
5496 jQuery.fn.andSelf = jQuery.fn.addBack;
5498 // A painfully simple check to see if an element is disconnected
5499 // from a document (should be improved, where feasible).
5500 function isDisconnected( node ) {
5501 return !node || !node.parentNode || node.parentNode.nodeType === 11;
5504 function sibling( cur, dir ) {
5507 } while ( cur && cur.nodeType !== 1 );
5513 parent: function( elem ) {
5514 var parent = elem.parentNode;
5515 return parent && parent.nodeType !== 11 ? parent : null;
5517 parents: function( elem ) {
5518 return jQuery.dir( elem, "parentNode" );
5520 parentsUntil: function( elem, i, until ) {
5521 return jQuery.dir( elem, "parentNode", until );
5523 next: function( elem ) {
5524 return sibling( elem, "nextSibling" );
5526 prev: function( elem ) {
5527 return sibling( elem, "previousSibling" );
5529 nextAll: function( elem ) {
5530 return jQuery.dir( elem, "nextSibling" );
5532 prevAll: function( elem ) {
5533 return jQuery.dir( elem, "previousSibling" );
5535 nextUntil: function( elem, i, until ) {
5536 return jQuery.dir( elem, "nextSibling", until );
5538 prevUntil: function( elem, i, until ) {
5539 return jQuery.dir( elem, "previousSibling", until );
5541 siblings: function( elem ) {
5542 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5544 children: function( elem ) {
5545 return jQuery.sibling( elem.firstChild );
5547 contents: function( elem ) {
5548 return jQuery.nodeName( elem, "iframe" ) ?
5549 elem.contentDocument || elem.contentWindow.document :
5550 jQuery.merge( [], elem.childNodes );
5552 }, function( name, fn ) {
5553 jQuery.fn[ name ] = function( until, selector ) {
5554 var ret = jQuery.map( this, fn, until );
5556 if ( !runtil.test( name ) ) {
5560 if ( selector && typeof selector === "string" ) {
5561 ret = jQuery.filter( selector, ret );
5564 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
5566 if ( this.length > 1 && rparentsprev.test( name ) ) {
5567 ret = ret.reverse();
5570 return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
5575 filter: function( expr, elems, not ) {
5577 expr = ":not(" + expr + ")";
5580 return elems.length === 1 ?
5581 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
5582 jQuery.find.matches(expr, elems);
5585 dir: function( elem, dir, until ) {
5589 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5590 if ( cur.nodeType === 1 ) {
5591 matched.push( cur );
5598 sibling: function( n, elem ) {
5601 for ( ; n; n = n.nextSibling ) {
5602 if ( n.nodeType === 1 && n !== elem ) {
5611 // Implement the identical functionality for filter and not
5612 function winnow( elements, qualifier, keep ) {
5614 // Can't pass null or undefined to indexOf in Firefox 4
5615 // Set to 0 to skip string check
5616 qualifier = qualifier || 0;
5618 if ( jQuery.isFunction( qualifier ) ) {
5619 return jQuery.grep(elements, function( elem, i ) {
5620 var retVal = !!qualifier.call( elem, i, elem );
5621 return retVal === keep;
5624 } else if ( qualifier.nodeType ) {
5625 return jQuery.grep(elements, function( elem, i ) {
5626 return ( elem === qualifier ) === keep;
5629 } else if ( typeof qualifier === "string" ) {
5630 var filtered = jQuery.grep(elements, function( elem ) {
5631 return elem.nodeType === 1;
5634 if ( isSimple.test( qualifier ) ) {
5635 return jQuery.filter(qualifier, filtered, !keep);
5637 qualifier = jQuery.filter( qualifier, filtered );
5641 return jQuery.grep(elements, function( elem, i ) {
5642 return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
5645 function createSafeFragment( document ) {
5646 var list = nodeNames.split( "|" ),
5647 safeFrag = document.createDocumentFragment();
5649 if ( safeFrag.createElement ) {
5650 while ( list.length ) {
5651 safeFrag.createElement(
5659 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
5660 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
5661 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
5662 rleadingWhitespace = /^\s+/,
5663 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
5664 rtagName = /<([\w:]+)/,
5666 rhtml = /<|&#?\w+;/,
5667 rnoInnerhtml = /<(?:script|style|link)/i,
5668 rnocache = /<(?:script|object|embed|option|style)/i,
5669 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
5670 rcheckableType = /^(?:checkbox|radio)$/,
5671 // checked="checked" or checked
5672 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
5673 rscriptType = /\/(java|ecma)script/i,
5674 rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
5676 option: [ 1, "<select multiple='multiple'>", "</select>" ],
5677 legend: [ 1, "<fieldset>", "</fieldset>" ],
5678 thead: [ 1, "<table>", "</table>" ],
5679 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5680 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5681 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
5682 area: [ 1, "<map>", "</map>" ],
5683 _default: [ 0, "", "" ]
5685 safeFragment = createSafeFragment( document ),
5686 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
5688 wrapMap.optgroup = wrapMap.option;
5689 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5690 wrapMap.th = wrapMap.td;
5692 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
5693 // unless wrapped in a div with non-breaking characters in front of it.
5694 if ( !jQuery.support.htmlSerialize ) {
5695 wrapMap._default = [ 1, "X<div>", "</div>" ];
5699 text: function( value ) {
5700 return jQuery.access( this, function( value ) {
5701 return value === undefined ?
5702 jQuery.text( this ) :
5703 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
5704 }, null, value, arguments.length );
5707 wrapAll: function( html ) {
5708 if ( jQuery.isFunction( html ) ) {
5709 return this.each(function(i) {
5710 jQuery(this).wrapAll( html.call(this, i) );
5715 // The elements to wrap the target around
5716 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
5718 if ( this[0].parentNode ) {
5719 wrap.insertBefore( this[0] );
5722 wrap.map(function() {
5725 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
5726 elem = elem.firstChild;
5736 wrapInner: function( html ) {
5737 if ( jQuery.isFunction( html ) ) {
5738 return this.each(function(i) {
5739 jQuery(this).wrapInner( html.call(this, i) );
5743 return this.each(function() {
5744 var self = jQuery( this ),
5745 contents = self.contents();
5747 if ( contents.length ) {
5748 contents.wrapAll( html );
5751 self.append( html );
5756 wrap: function( html ) {
5757 var isFunction = jQuery.isFunction( html );
5759 return this.each(function(i) {
5760 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
5764 unwrap: function() {
5765 return this.parent().each(function() {
5766 if ( !jQuery.nodeName( this, "body" ) ) {
5767 jQuery( this ).replaceWith( this.childNodes );
5772 append: function() {
5773 return this.domManip(arguments, true, function( elem ) {
5774 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5775 this.appendChild( elem );
5780 prepend: function() {
5781 return this.domManip(arguments, true, function( elem ) {
5782 if ( this.nodeType === 1 || this.nodeType === 11 ) {
5783 this.insertBefore( elem, this.firstChild );
5788 before: function() {
5789 if ( !isDisconnected( this[0] ) ) {
5790 return this.domManip(arguments, false, function( elem ) {
5791 this.parentNode.insertBefore( elem, this );
5795 if ( arguments.length ) {
5796 var set = jQuery.clean( arguments );
5797 return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
5802 if ( !isDisconnected( this[0] ) ) {
5803 return this.domManip(arguments, false, function( elem ) {
5804 this.parentNode.insertBefore( elem, this.nextSibling );
5808 if ( arguments.length ) {
5809 var set = jQuery.clean( arguments );
5810 return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
5814 // keepData is for internal use only--do not document
5815 remove: function( selector, keepData ) {
5819 for ( ; (elem = this[i]) != null; i++ ) {
5820 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
5821 if ( !keepData && elem.nodeType === 1 ) {
5822 jQuery.cleanData( elem.getElementsByTagName("*") );
5823 jQuery.cleanData( [ elem ] );
5826 if ( elem.parentNode ) {
5827 elem.parentNode.removeChild( elem );
5839 for ( ; (elem = this[i]) != null; i++ ) {
5840 // Remove element nodes and prevent memory leaks
5841 if ( elem.nodeType === 1 ) {
5842 jQuery.cleanData( elem.getElementsByTagName("*") );
5845 // Remove any remaining nodes
5846 while ( elem.firstChild ) {
5847 elem.removeChild( elem.firstChild );
5854 clone: function( dataAndEvents, deepDataAndEvents ) {
5855 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
5856 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
5858 return this.map( function () {
5859 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
5863 html: function( value ) {
5864 return jQuery.access( this, function( value ) {
5865 var elem = this[0] || {},
5869 if ( value === undefined ) {
5870 return elem.nodeType === 1 ?
5871 elem.innerHTML.replace( rinlinejQuery, "" ) :
5875 // See if we can take a shortcut and just use innerHTML
5876 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
5877 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
5878 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
5879 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
5881 value = value.replace( rxhtmlTag, "<$1></$2>" );
5884 for (; i < l; i++ ) {
5885 // Remove element nodes and prevent memory leaks
5886 elem = this[i] || {};
5887 if ( elem.nodeType === 1 ) {
5888 jQuery.cleanData( elem.getElementsByTagName( "*" ) );
5889 elem.innerHTML = value;
5895 // If using innerHTML throws an exception, use the fallback method
5900 this.empty().append( value );
5902 }, null, value, arguments.length );
5905 replaceWith: function( value ) {
5906 if ( !isDisconnected( this[0] ) ) {
5907 // Make sure that the elements are removed from the DOM before they are inserted
5908 // this can help fix replacing a parent with child elements
5909 if ( jQuery.isFunction( value ) ) {
5910 return this.each(function(i) {
5911 var self = jQuery(this), old = self.html();
5912 self.replaceWith( value.call( this, i, old ) );
5916 if ( typeof value !== "string" ) {
5917 value = jQuery( value ).detach();
5920 return this.each(function() {
5921 var next = this.nextSibling,
5922 parent = this.parentNode;
5924 jQuery( this ).remove();
5927 jQuery(next).before( value );
5929 jQuery(parent).append( value );
5934 return this.length ?
5935 this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
5939 detach: function( selector ) {
5940 return this.remove( selector, true );
5943 domManip: function( args, table, callback ) {
5945 // Flatten any nested arrays
5946 args = [].concat.apply( [], args );
5948 var results, first, fragment, iNoClone,
5954 // We can't cloneNode fragments that contain checked, in WebKit
5955 if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
5956 return this.each(function() {
5957 jQuery(this).domManip( args, table, callback );
5961 if ( jQuery.isFunction(value) ) {
5962 return this.each(function(i) {
5963 var self = jQuery(this);
5964 args[0] = value.call( this, i, table ? self.html() : undefined );
5965 self.domManip( args, table, callback );
5970 results = jQuery.buildFragment( args, this, scripts );
5971 fragment = results.fragment;
5972 first = fragment.firstChild;
5974 if ( fragment.childNodes.length === 1 ) {
5979 table = table && jQuery.nodeName( first, "tr" );
5981 // Use the original fragment for the last item instead of the first because it can end up
5982 // being emptied incorrectly in certain situations (#8070).
5983 // Fragments from the fragment cache must always be cloned and never used in place.
5984 for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
5986 table && jQuery.nodeName( this[i], "table" ) ?
5987 findOrAppend( this[i], "tbody" ) :
5991 jQuery.clone( fragment, true, true )
5996 // Fix #11809: Avoid leaking memory
5997 fragment = first = null;
5999 if ( scripts.length ) {
6000 jQuery.each( scripts, function( i, elem ) {
6002 if ( jQuery.ajax ) {
6012 jQuery.error("no ajax");
6015 jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
6018 if ( elem.parentNode ) {
6019 elem.parentNode.removeChild( elem );
6029 function findOrAppend( elem, tag ) {
6030 return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
6033 function cloneCopyEvent( src, dest ) {
6035 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6040 oldData = jQuery._data( src ),
6041 curData = jQuery._data( dest, oldData ),
6042 events = oldData.events;
6045 delete curData.handle;
6046 curData.events = {};
6048 for ( type in events ) {
6049 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6050 jQuery.event.add( dest, type, events[ type ][ i ] );
6055 // make the cloned public data object a copy from the original
6056 if ( curData.data ) {
6057 curData.data = jQuery.extend( {}, curData.data );
6061 function cloneFixAttributes( src, dest ) {
6064 // We do not need to do anything for non-Elements
6065 if ( dest.nodeType !== 1 ) {
6069 // clearAttributes removes the attributes, which we don't want,
6070 // but also removes the attachEvent events, which we *do* want
6071 if ( dest.clearAttributes ) {
6072 dest.clearAttributes();
6075 // mergeAttributes, in contrast, only merges back on the
6076 // original attributes, not the events
6077 if ( dest.mergeAttributes ) {
6078 dest.mergeAttributes( src );
6081 nodeName = dest.nodeName.toLowerCase();
6083 if ( nodeName === "object" ) {
6084 // IE6-10 improperly clones children of object elements using classid.
6085 // IE10 throws NoModificationAllowedError if parent is null, #12132.
6086 if ( dest.parentNode ) {
6087 dest.outerHTML = src.outerHTML;
6090 // This path appears unavoidable for IE9. When cloning an object
6091 // element in IE9, the outerHTML strategy above is not sufficient.
6092 // If the src has innerHTML and the destination does not,
6093 // copy the src.innerHTML into the dest.innerHTML. #10324
6094 if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
6095 dest.innerHTML = src.innerHTML;
6098 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
6099 // IE6-8 fails to persist the checked state of a cloned checkbox
6100 // or radio button. Worse, IE6-7 fail to give the cloned element
6101 // a checked appearance if the defaultChecked value isn't also set
6103 dest.defaultChecked = dest.checked = src.checked;
6105 // IE6-7 get confused and end up setting the value of a cloned
6106 // checkbox/radio button to an empty string instead of "on"
6107 if ( dest.value !== src.value ) {
6108 dest.value = src.value;
6111 // IE6-8 fails to return the selected option to the default selected
6112 // state when cloning options
6113 } else if ( nodeName === "option" ) {
6114 dest.selected = src.defaultSelected;
6116 // IE6-8 fails to set the defaultValue to the correct value when
6117 // cloning other types of input fields
6118 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6119 dest.defaultValue = src.defaultValue;
6121 // IE blanks contents when cloning scripts
6122 } else if ( nodeName === "script" && dest.text !== src.text ) {
6123 dest.text = src.text;
6126 // Event data gets referenced instead of copied if the expando
6128 dest.removeAttribute( jQuery.expando );
6131 jQuery.buildFragment = function( args, context, scripts ) {
6132 var fragment, cacheable, cachehit,
6135 // Set context from what may come in as undefined or a jQuery collection or a node
6136 // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
6137 // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
6138 context = context || document;
6139 context = !context.nodeType && context[0] || context;
6140 context = context.ownerDocument || context;
6142 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
6143 // Cloning options loses the selected state, so don't cache them
6144 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
6145 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
6146 // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
6147 if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
6148 first.charAt(0) === "<" && !rnocache.test( first ) &&
6149 (jQuery.support.checkClone || !rchecked.test( first )) &&
6150 (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {
6152 // Mark cacheable and look for a hit
6154 fragment = jQuery.fragments[ first ];
6155 cachehit = fragment !== undefined;
6159 fragment = context.createDocumentFragment();
6160 jQuery.clean( args, context, fragment, scripts );
6162 // Update the cache, but only store false
6163 // unless this is a second parsing of the same content
6165 jQuery.fragments[ first ] = cachehit && fragment;
6169 return { fragment: fragment, cacheable: cacheable };
6172 jQuery.fragments = {};
6176 prependTo: "prepend",
6177 insertBefore: "before",
6178 insertAfter: "after",
6179 replaceAll: "replaceWith"
6180 }, function( name, original ) {
6181 jQuery.fn[ name ] = function( selector ) {
6185 insert = jQuery( selector ),
6187 parent = this.length === 1 && this[0].parentNode;
6189 if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
6190 insert[ original ]( this[0] );
6193 for ( ; i < l; i++ ) {
6194 elems = ( i > 0 ? this.clone(true) : this ).get();
6195 jQuery( insert[i] )[ original ]( elems );
6196 ret = ret.concat( elems );
6199 return this.pushStack( ret, name, insert.selector );
6204 function getAll( elem ) {
6205 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6206 return elem.getElementsByTagName( "*" );
6208 } else if ( typeof elem.querySelectorAll !== "undefined" ) {
6209 return elem.querySelectorAll( "*" );
6216 // Used in clean, fixes the defaultChecked property
6217 function fixDefaultChecked( elem ) {
6218 if ( rcheckableType.test( elem.type ) ) {
6219 elem.defaultChecked = elem.checked;
6224 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6230 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6231 clone = elem.cloneNode( true );
6233 // IE<=8 does not properly clone detached, unknown element nodes
6235 fragmentDiv.innerHTML = elem.outerHTML;
6236 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6239 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6240 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6241 // IE copies events bound via attachEvent when using cloneNode.
6242 // Calling detachEvent on the clone will also remove the events
6243 // from the original. In order to get around this, we use some
6244 // proprietary methods to clear the events. Thanks to MooTools
6245 // guys for this hotness.
6247 cloneFixAttributes( elem, clone );
6249 // Using Sizzle here is crazy slow, so we use getElementsByTagName instead
6250 srcElements = getAll( elem );
6251 destElements = getAll( clone );
6253 // Weird iteration because IE will replace the length property
6254 // with an element if you are cloning the body and one of the
6255 // elements on the page has a name or id of "length"
6256 for ( i = 0; srcElements[i]; ++i ) {
6257 // Ensure that the destination node is not null; Fixes #9587
6258 if ( destElements[i] ) {
6259 cloneFixAttributes( srcElements[i], destElements[i] );
6264 // Copy the events from the original to the clone
6265 if ( dataAndEvents ) {
6266 cloneCopyEvent( elem, clone );
6268 if ( deepDataAndEvents ) {
6269 srcElements = getAll( elem );
6270 destElements = getAll( clone );
6272 for ( i = 0; srcElements[i]; ++i ) {
6273 cloneCopyEvent( srcElements[i], destElements[i] );
6278 srcElements = destElements = null;
6280 // Return the cloned set
6284 clean: function( elems, context, fragment, scripts ) {
6285 var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
6286 safe = context === document && safeFragment,
6289 // Ensure that context is a document
6290 if ( !context || typeof context.createDocumentFragment === "undefined" ) {
6294 // Use the already-created safe fragment if context permits
6295 for ( i = 0; (elem = elems[i]) != null; i++ ) {
6296 if ( typeof elem === "number" ) {
6304 // Convert html string into DOM nodes
6305 if ( typeof elem === "string" ) {
6306 if ( !rhtml.test( elem ) ) {
6307 elem = context.createTextNode( elem );
6309 // Ensure a safe container in which to render the html
6310 safe = safe || createSafeFragment( context );
6311 div = context.createElement("div");
6312 safe.appendChild( div );
6314 // Fix "XHTML"-style tags in all browsers
6315 elem = elem.replace(rxhtmlTag, "<$1></$2>");
6317 // Go to html and back, then peel off extra wrappers
6318 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6319 wrap = wrapMap[ tag ] || wrapMap._default;
6321 div.innerHTML = wrap[1] + elem + wrap[2];
6323 // Move to the right depth
6325 div = div.lastChild;
6328 // Remove IE's autoinserted <tbody> from table fragments
6329 if ( !jQuery.support.tbody ) {
6331 // String was a <table>, *may* have spurious <tbody>
6332 hasBody = rtbody.test(elem);
6333 tbody = tag === "table" && !hasBody ?
6334 div.firstChild && div.firstChild.childNodes :
6336 // String was a bare <thead> or <tfoot>
6337 wrap[1] === "<table>" && !hasBody ?
6341 for ( j = tbody.length - 1; j >= 0 ; --j ) {
6342 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
6343 tbody[ j ].parentNode.removeChild( tbody[ j ] );
6348 // IE completely kills leading whitespace when innerHTML is used
6349 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6350 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
6353 elem = div.childNodes;
6355 // Take out of fragment container (we need a fresh div each time)
6356 div.parentNode.removeChild( div );
6360 if ( elem.nodeType ) {
6363 jQuery.merge( ret, elem );
6367 // Fix #11356: Clear elements from safeFragment
6369 elem = div = safe = null;
6372 // Reset defaultChecked for any radios and checkboxes
6373 // about to be appended to the DOM in IE 6/7 (#8060)
6374 if ( !jQuery.support.appendChecked ) {
6375 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6376 if ( jQuery.nodeName( elem, "input" ) ) {
6377 fixDefaultChecked( elem );
6378 } else if ( typeof elem.getElementsByTagName !== "undefined" ) {
6379 jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
6384 // Append elements to a provided document fragment
6386 // Special handling of each script element
6387 handleScript = function( elem ) {
6388 // Check if we consider it executable
6389 if ( !elem.type || rscriptType.test( elem.type ) ) {
6390 // Detach the script and store it in the scripts array (if provided) or the fragment
6391 // Return truthy to indicate that it has been handled
6393 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
6394 fragment.appendChild( elem );
6398 for ( i = 0; (elem = ret[i]) != null; i++ ) {
6399 // Check if we're done after handling an executable script
6400 if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
6401 // Append to fragment and handle embedded scripts
6402 fragment.appendChild( elem );
6403 if ( typeof elem.getElementsByTagName !== "undefined" ) {
6404 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
6405 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
6407 // Splice the scripts into ret after their former ancestor and advance our index beyond them
6408 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
6418 cleanData: function( elems, /* internal */ acceptData ) {
6419 var data, id, elem, type,
6421 internalKey = jQuery.expando,
6422 cache = jQuery.cache,
6423 deleteExpando = jQuery.support.deleteExpando,
6424 special = jQuery.event.special;
6426 for ( ; (elem = elems[i]) != null; i++ ) {
6428 if ( acceptData || jQuery.acceptData( elem ) ) {
6430 id = elem[ internalKey ];
6431 data = id && cache[ id ];
6434 if ( data.events ) {
6435 for ( type in data.events ) {
6436 if ( special[ type ] ) {
6437 jQuery.event.remove( elem, type );
6439 // This is a shortcut to avoid jQuery.event.remove's overhead
6441 jQuery.removeEvent( elem, type, data.handle );
6446 // Remove cache only if it was not already removed by jQuery.event.remove
6447 if ( cache[ id ] ) {
6451 // IE does not allow us to delete expando properties from nodes,
6452 // nor does it have a removeAttribute function on Document nodes;
6453 // we must handle all of these cases
6454 if ( deleteExpando ) {
6455 delete elem[ internalKey ];
6457 } else if ( elem.removeAttribute ) {
6458 elem.removeAttribute( internalKey );
6461 elem[ internalKey ] = null;
6464 jQuery.deletedIds.push( id );
6471 // Limit scope pollution from any deprecated API
6474 var matched, browser;
6476 // Use of jQuery.browser is frowned upon.
6477 // More details: http://api.jquery.com/jQuery.browser
6478 // jQuery.uaMatch maintained for back-compat
6479 jQuery.uaMatch = function( ua ) {
6480 ua = ua.toLowerCase();
6482 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
6483 /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
6484 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
6485 /(msie) ([\w.]+)/.exec( ua ) ||
6486 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
6490 browser: match[ 1 ] || "",
6491 version: match[ 2 ] || "0"
6495 matched = jQuery.uaMatch( navigator.userAgent );
6498 if ( matched.browser ) {
6499 browser[ matched.browser ] = true;
6500 browser.version = matched.version;
6503 // Chrome is Webkit, but Webkit is also Safari.
6504 if ( browser.chrome ) {
6505 browser.webkit = true;
6506 } else if ( browser.webkit ) {
6507 browser.safari = true;
6510 jQuery.browser = browser;
6512 jQuery.sub = function() {
6513 function jQuerySub( selector, context ) {
6514 return new jQuerySub.fn.init( selector, context );
6516 jQuery.extend( true, jQuerySub, this );
6517 jQuerySub.superclass = this;
6518 jQuerySub.fn = jQuerySub.prototype = this();
6519 jQuerySub.fn.constructor = jQuerySub;
6520 jQuerySub.sub = this.sub;
6521 jQuerySub.fn.init = function init( selector, context ) {
6522 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
6523 context = jQuerySub( context );
6526 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
6528 jQuerySub.fn.init.prototype = jQuerySub.fn;
6529 var rootjQuerySub = jQuerySub(document);
6534 var curCSS, iframe, iframeDoc,
6535 ralpha = /alpha\([^)]*\)/i,
6536 ropacity = /opacity=([^)]*)/,
6537 rposition = /^(top|right|bottom|left)$/,
6538 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6539 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6540 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6541 rmargin = /^margin/,
6542 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6543 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6544 rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
6547 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6548 cssNormalTransform = {
6553 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6554 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],
6556 eventsToggle = jQuery.fn.toggle;
6558 // return a css property mapped to a potentially vendor prefixed property
6559 function vendorPropName( style, name ) {
6561 // shortcut for names that are not vendor prefixed
6562 if ( name in style ) {
6566 // check for vendor prefixed names
6567 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6569 i = cssPrefixes.length;
6572 name = cssPrefixes[ i ] + capName;
6573 if ( name in style ) {
6581 function isHidden( elem, el ) {
6583 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6586 function showHide( elements, show ) {
6590 length = elements.length;
6592 for ( ; index < length; index++ ) {
6593 elem = elements[ index ];
6594 if ( !elem.style ) {
6597 values[ index ] = jQuery._data( elem, "olddisplay" );
6599 // Reset the inline display of this element to learn if it is
6600 // being hidden by cascaded rules or not
6601 if ( !values[ index ] && elem.style.display === "none" ) {
6602 elem.style.display = "";
6605 // Set elements which have been overridden with display: none
6606 // in a stylesheet to whatever the default browser style is
6607 // for such an element
6608 if ( elem.style.display === "" && isHidden( elem ) ) {
6609 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6612 display = curCSS( elem, "display" );
6614 if ( !values[ index ] && display !== "none" ) {
6615 jQuery._data( elem, "olddisplay", display );
6620 // Set the display of most of the elements in a second loop
6621 // to avoid the constant reflow
6622 for ( index = 0; index < length; index++ ) {
6623 elem = elements[ index ];
6624 if ( !elem.style ) {
6627 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6628 elem.style.display = show ? values[ index ] || "" : "none";
6636 css: function( name, value ) {
6637 return jQuery.access( this, function( elem, name, value ) {
6638 return value !== undefined ?
6639 jQuery.style( elem, name, value ) :
6640 jQuery.css( elem, name );
6641 }, name, value, arguments.length > 1 );
6644 return showHide( this, true );
6647 return showHide( this );
6649 toggle: function( state, fn2 ) {
6650 var bool = typeof state === "boolean";
6652 if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
6653 return eventsToggle.apply( this, arguments );
6656 return this.each(function() {
6657 if ( bool ? state : isHidden( this ) ) {
6658 jQuery( this ).show();
6660 jQuery( this ).hide();
6667 // Add in style property hooks for overriding the default
6668 // behavior of getting and setting a style property
6671 get: function( elem, computed ) {
6673 // We should always get a number back from opacity
6674 var ret = curCSS( elem, "opacity" );
6675 return ret === "" ? "1" : ret;
6682 // Exclude the following css properties to add px
6684 "fillOpacity": true,
6694 // Add in properties whose names you wish to fix before
6695 // setting or getting the value
6697 // normalize float css property
6698 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6701 // Get and set the style property on a DOM Node
6702 style: function( elem, name, value, extra ) {
6703 // Don't set styles on text and comment nodes
6704 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
6708 // Make sure that we're working with the right name
6709 var ret, type, hooks,
6710 origName = jQuery.camelCase( name ),
6713 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
6715 // gets hook for the prefixed version
6716 // followed by the unprefixed version
6717 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6719 // Check if we're setting a value
6720 if ( value !== undefined ) {
6721 type = typeof value;
6723 // convert relative number strings (+= or -=) to relative numbers. #7345
6724 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
6725 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
6730 // Make sure that NaN and null values aren't set. See: #7116
6731 if ( value == null || type === "number" && isNaN( value ) ) {
6735 // If a number was passed in, add 'px' to the (except for certain CSS properties)
6736 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
6740 // If a hook was provided, use that value, otherwise just set the specified value
6741 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
6742 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
6745 style[ name ] = value;
6750 // If a hook was provided get the non-computed value from there
6751 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
6755 // Otherwise just get the value from the style object
6756 return style[ name ];
6760 css: function( elem, name, numeric, extra ) {
6761 var val, num, hooks,
6762 origName = jQuery.camelCase( name );
6764 // Make sure that we're working with the right name
6765 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
6767 // gets hook for the prefixed version
6768 // followed by the unprefixed version
6769 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
6771 // If a hook was provided get the computed value from there
6772 if ( hooks && "get" in hooks ) {
6773 val = hooks.get( elem, true, extra );
6776 // Otherwise, if a way to get the computed value exists, use that
6777 if ( val === undefined ) {
6778 val = curCSS( elem, name );
6781 //convert "normal" to computed value
6782 if ( val === "normal" && name in cssNormalTransform ) {
6783 val = cssNormalTransform[ name ];
6786 // Return, converting to number if forced or a qualifier was provided and val looks numeric
6787 if ( numeric || extra !== undefined ) {
6788 num = parseFloat( val );
6789 return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
6794 // A method for quickly swapping in/out CSS properties to get correct calculations
6795 swap: function( elem, options, callback ) {
6799 // Remember the old values, and insert the new ones
6800 for ( name in options ) {
6801 old[ name ] = elem.style[ name ];
6802 elem.style[ name ] = options[ name ];
6805 ret = callback.call( elem );
6807 // Revert the old values
6808 for ( name in options ) {
6809 elem.style[ name ] = old[ name ];
6816 // NOTE: To any future maintainer, we've window.getComputedStyle
6817 // because jsdom on node.js will break without it.
6818 if ( window.getComputedStyle ) {
6819 curCSS = function( elem, name ) {
6820 var ret, width, minWidth, maxWidth,
6821 computed = window.getComputedStyle( elem, null ),
6826 ret = computed[ name ];
6827 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
6828 ret = jQuery.style( elem, name );
6831 // A tribute to the "awesome hack by Dean Edwards"
6832 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
6833 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
6834 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
6835 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
6836 width = style.width;
6837 minWidth = style.minWidth;
6838 maxWidth = style.maxWidth;
6840 style.minWidth = style.maxWidth = style.width = ret;
6841 ret = computed.width;
6843 style.width = width;
6844 style.minWidth = minWidth;
6845 style.maxWidth = maxWidth;
6851 } else if ( document.documentElement.currentStyle ) {
6852 curCSS = function( elem, name ) {
6854 ret = elem.currentStyle && elem.currentStyle[ name ],
6857 // Avoid setting ret to empty string here
6858 // so we don't default to auto
6859 if ( ret == null && style && style[ name ] ) {
6860 ret = style[ name ];
6863 // From the awesome hack by Dean Edwards
6864 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
6866 // If we're not dealing with a regular pixel number
6867 // but a number that has a weird ending, we need to convert it to pixels
6868 // but not position css attributes, as those are proportional to the parent element instead
6869 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
6870 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
6872 // Remember the original values
6874 rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;
6876 // Put in the new values to get a computed value out
6878 elem.runtimeStyle.left = elem.currentStyle.left;
6880 style.left = name === "fontSize" ? "1em" : ret;
6881 ret = style.pixelLeft + "px";
6883 // Revert the changed values
6886 elem.runtimeStyle.left = rsLeft;
6890 return ret === "" ? "auto" : ret;
6894 function setPositiveNumber( elem, value, subtract ) {
6895 var matches = rnumsplit.exec( value );
6897 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
6901 function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
6902 var i = extra === ( isBorderBox ? "border" : "content" ) ?
6903 // If we already have the right measurement, avoid augmentation
6905 // Otherwise initialize for horizontal or vertical properties
6906 name === "width" ? 1 : 0,
6910 for ( ; i < 4; i += 2 ) {
6911 // both box models exclude margin, so add it if we want it
6912 if ( extra === "margin" ) {
6913 // we use jQuery.css instead of curCSS here
6914 // because of the reliableMarginRight CSS hook!
6915 val += jQuery.css( elem, extra + cssExpand[ i ], true );
6918 // From this point on we use curCSS for maximum performance (relevant in animations)
6919 if ( isBorderBox ) {
6920 // border-box includes padding, so remove it if we want content
6921 if ( extra === "content" ) {
6922 val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6925 // at this point, extra isn't border nor margin, so remove border
6926 if ( extra !== "margin" ) {
6927 val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6930 // at this point, extra isn't content, so add padding
6931 val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
6933 // at this point, extra isn't content nor padding, so add border
6934 if ( extra !== "padding" ) {
6935 val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
6943 function getWidthOrHeight( elem, name, extra ) {
6945 // Start with offset property, which is equivalent to the border-box value
6946 var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
6947 valueIsBorderBox = true,
6948 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";
6950 // some non-html elements return undefined for offsetWidth, so check for null/undefined
6951 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
6952 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
6953 if ( val <= 0 || val == null ) {
6954 // Fall back to computed then uncomputed css if necessary
6955 val = curCSS( elem, name );
6956 if ( val < 0 || val == null ) {
6957 val = elem.style[ name ];
6960 // Computed unit is not pixels. Stop here and return.
6961 if ( rnumnonpx.test(val) ) {
6965 // we need the check for style in case a browser which returns unreliable values
6966 // for getComputedStyle silently falls back to the reliable elem.style
6967 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
6969 // Normalize "", auto, and prepare for extra
6970 val = parseFloat( val ) || 0;
6973 // use the active box-sizing model to add/subtract irrelevant styles
6975 augmentWidthOrHeight(
6978 extra || ( isBorderBox ? "border" : "content" ),
6985 // Try to determine the default display value of an element
6986 function css_defaultDisplay( nodeName ) {
6987 if ( elemdisplay[ nodeName ] ) {
6988 return elemdisplay[ nodeName ];
6991 var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
6992 display = elem.css("display");
6995 // If the simple way fails,
6996 // get element's real default display by attaching it to a temp iframe
6997 if ( display === "none" || display === "" ) {
6998 // Use the already-created iframe if possible
6999 iframe = document.body.appendChild(
7000 iframe || jQuery.extend( document.createElement("iframe"), {
7007 // Create a cacheable copy of the iframe document on first call.
7008 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
7009 // document to it; WebKit & Firefox won't allow reusing the iframe document.
7010 if ( !iframeDoc || !iframe.createElement ) {
7011 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
7012 iframeDoc.write("<!doctype html><html><body>");
7016 elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );
7018 display = curCSS( elem, "display" );
7019 document.body.removeChild( iframe );
7022 // Store the correct default display
7023 elemdisplay[ nodeName ] = display;
7028 jQuery.each([ "height", "width" ], function( i, name ) {
7029 jQuery.cssHooks[ name ] = {
7030 get: function( elem, computed, extra ) {
7032 // certain elements can have dimension info if we invisibly show them
7033 // however, it must have a current display style that would benefit from this
7034 if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
7035 return jQuery.swap( elem, cssShow, function() {
7036 return getWidthOrHeight( elem, name, extra );
7039 return getWidthOrHeight( elem, name, extra );
7044 set: function( elem, value, extra ) {
7045 return setPositiveNumber( elem, value, extra ?
7046 augmentWidthOrHeight(
7050 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
7057 if ( !jQuery.support.opacity ) {
7058 jQuery.cssHooks.opacity = {
7059 get: function( elem, computed ) {
7060 // IE uses filters for opacity
7061 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
7062 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7063 computed ? "1" : "";
7066 set: function( elem, value ) {
7067 var style = elem.style,
7068 currentStyle = elem.currentStyle,
7069 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7070 filter = currentStyle && currentStyle.filter || style.filter || "";
7072 // IE has trouble with opacity if it does not have layout
7073 // Force it by setting the zoom level
7076 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
7077 if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7078 style.removeAttribute ) {
7080 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7081 // if "filter:" is present at all, clearType is disabled, we want to avoid this
7082 // style.removeAttribute is IE Only, but so apparently is this code path...
7083 style.removeAttribute( "filter" );
7085 // if there there is no filter style applied in a css rule, we are done
7086 if ( currentStyle && !currentStyle.filter ) {
7091 // otherwise, set new filter values
7092 style.filter = ralpha.test( filter ) ?
7093 filter.replace( ralpha, opacity ) :
7094 filter + " " + opacity;
7099 // These hooks cannot be added until DOM ready because the support test
7100 // for it is not run until after DOM ready
7102 if ( !jQuery.support.reliableMarginRight ) {
7103 jQuery.cssHooks.marginRight = {
7104 get: function( elem, computed ) {
7105 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7106 // Work around by temporarily setting element display to inline-block
7107 return jQuery.swap( elem, { "display": "inline-block" }, function() {
7109 return curCSS( elem, "marginRight" );
7116 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7117 // getComputedStyle returns percent when specified for top/left/bottom/right
7118 // rather than make the css module depend on the offset module, we just check for it here
7119 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
7120 jQuery.each( [ "top", "left" ], function( i, prop ) {
7121 jQuery.cssHooks[ prop ] = {
7122 get: function( elem, computed ) {
7124 var ret = curCSS( elem, prop );
7125 // if curCSS returns percentage, fallback to offset
7126 return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
7135 if ( jQuery.expr && jQuery.expr.filters ) {
7136 jQuery.expr.filters.hidden = function( elem ) {
7137 return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
7140 jQuery.expr.filters.visible = function( elem ) {
7141 return !jQuery.expr.filters.hidden( elem );
7145 // These hooks are used by animate to expand properties
7150 }, function( prefix, suffix ) {
7151 jQuery.cssHooks[ prefix + suffix ] = {
7152 expand: function( value ) {
7155 // assumes a single number if not a string
7156 parts = typeof value === "string" ? value.split(" ") : [ value ],
7159 for ( i = 0; i < 4; i++ ) {
7160 expanded[ prefix + cssExpand[ i ] + suffix ] =
7161 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7168 if ( !rmargin.test( prefix ) ) {
7169 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7175 rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
7176 rselectTextarea = /^(?:select|textarea)/i;
7179 serialize: function() {
7180 return jQuery.param( this.serializeArray() );
7182 serializeArray: function() {
7183 return this.map(function(){
7184 return this.elements ? jQuery.makeArray( this.elements ) : this;
7187 return this.name && !this.disabled &&
7188 ( this.checked || rselectTextarea.test( this.nodeName ) ||
7189 rinput.test( this.type ) );
7191 .map(function( i, elem ){
7192 var val = jQuery( this ).val();
7194 return val == null ?
7196 jQuery.isArray( val ) ?
7197 jQuery.map( val, function( val, i ){
7198 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7200 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7205 //Serialize an array of form elements or a set of
7206 //key/values into a query string
7207 jQuery.param = function( a, traditional ) {
7210 add = function( key, value ) {
7211 // If value is a function, invoke it and return its value
7212 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7213 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7216 // Set traditional to true for jQuery <= 1.3.2 behavior.
7217 if ( traditional === undefined ) {
7218 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7221 // If an array was passed in, assume that it is an array of form elements.
7222 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7223 // Serialize the form elements
7224 jQuery.each( a, function() {
7225 add( this.name, this.value );
7229 // If traditional, encode the "old" way (the way 1.3.2 or older
7230 // did it), otherwise encode params recursively.
7231 for ( prefix in a ) {
7232 buildParams( prefix, a[ prefix ], traditional, add );
7236 // Return the resulting serialization
7237 return s.join( "&" ).replace( r20, "+" );
7240 function buildParams( prefix, obj, traditional, add ) {
7243 if ( jQuery.isArray( obj ) ) {
7244 // Serialize array item.
7245 jQuery.each( obj, function( i, v ) {
7246 if ( traditional || rbracket.test( prefix ) ) {
7247 // Treat each array item as a scalar.
7251 // If array item is non-scalar (array or object), encode its
7252 // numeric index to resolve deserialization ambiguity issues.
7253 // Note that rack (as of 1.0.0) can't currently deserialize
7254 // nested arrays properly, and attempting to do so may cause
7255 // a server error. Possible fixes are to modify rack's
7256 // deserialization algorithm or to provide an option or flag
7257 // to force array serialization to be shallow.
7258 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7262 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
7263 // Serialize object item.
7264 for ( name in obj ) {
7265 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7269 // Serialize scalar item.
7274 // Document location
7279 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7280 // #7653, #8125, #8152: local protocol detection
7281 rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
7282 rnoContent = /^(?:GET|HEAD)$/,
7283 rprotocol = /^\/\//,
7285 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
7286 rts = /([?&])_=[^&]*/,
7287 rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7289 // Keep a copy of the old load method
7290 _load = jQuery.fn.load,
7293 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7294 * 2) These are called:
7295 * - BEFORE asking for a transport
7296 * - AFTER param serialization (s.data is a string if s.processData is true)
7297 * 3) key is the dataType
7298 * 4) the catchall symbol "*" can be used
7299 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7303 /* Transports bindings
7304 * 1) key is the dataType
7305 * 2) the catchall symbol "*" can be used
7306 * 3) selection will start with transport dataType and THEN go to "*" if needed
7310 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7311 allTypes = ["*/"] + ["*"];
7313 // #8138, IE may throw an exception when accessing
7314 // a field from window.location if document.domain has been set
7316 ajaxLocation = location.href;
7318 // Use the href attribute of an A element
7319 // since IE will modify it given document.location
7320 ajaxLocation = document.createElement( "a" );
7321 ajaxLocation.href = "";
7322 ajaxLocation = ajaxLocation.href;
7325 // Segment location into parts
7326 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7328 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7329 function addToPrefiltersOrTransports( structure ) {
7331 // dataTypeExpression is optional and defaults to "*"
7332 return function( dataTypeExpression, func ) {
7334 if ( typeof dataTypeExpression !== "string" ) {
7335 func = dataTypeExpression;
7336 dataTypeExpression = "*";
7339 var dataType, list, placeBefore,
7340 dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
7342 length = dataTypes.length;
7344 if ( jQuery.isFunction( func ) ) {
7345 // For each dataType in the dataTypeExpression
7346 for ( ; i < length; i++ ) {
7347 dataType = dataTypes[ i ];
7348 // We control if we're asked to add before
7349 // any existing element
7350 placeBefore = /^\+/.test( dataType );
7351 if ( placeBefore ) {
7352 dataType = dataType.substr( 1 ) || "*";
7354 list = structure[ dataType ] = structure[ dataType ] || [];
7355 // then we add to the structure accordingly
7356 list[ placeBefore ? "unshift" : "push" ]( func );
7362 // Base inspection function for prefilters and transports
7363 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
7364 dataType /* internal */, inspected /* internal */ ) {
7366 dataType = dataType || options.dataTypes[ 0 ];
7367 inspected = inspected || {};
7369 inspected[ dataType ] = true;
7372 list = structure[ dataType ],
7374 length = list ? list.length : 0,
7375 executeOnly = ( structure === prefilters );
7377 for ( ; i < length && ( executeOnly || !selection ); i++ ) {
7378 selection = list[ i ]( options, originalOptions, jqXHR );
7379 // If we got redirected to another dataType
7380 // we try there if executing only and not done already
7381 if ( typeof selection === "string" ) {
7382 if ( !executeOnly || inspected[ selection ] ) {
7383 selection = undefined;
7385 options.dataTypes.unshift( selection );
7386 selection = inspectPrefiltersOrTransports(
7387 structure, options, originalOptions, jqXHR, selection, inspected );
7391 // If we're only executing or nothing was selected
7392 // we try the catchall dataType if not done already
7393 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
7394 selection = inspectPrefiltersOrTransports(
7395 structure, options, originalOptions, jqXHR, "*", inspected );
7397 // unnecessary when only executing (prefilters)
7398 // but it'll be ignored by the caller in that case
7402 // A special extend for ajax options
7403 // that takes "flat" options (not to be deep extended)
7405 function ajaxExtend( target, src ) {
7407 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7408 for ( key in src ) {
7409 if ( src[ key ] !== undefined ) {
7410 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
7414 jQuery.extend( true, target, deep );
7418 jQuery.fn.load = function( url, params, callback ) {
7419 if ( typeof url !== "string" && _load ) {
7420 return _load.apply( this, arguments );
7423 // Don't do a request if no elements are being requested
7424 if ( !this.length ) {
7428 var selector, type, response,
7430 off = url.indexOf(" ");
7433 selector = url.slice( off, url.length );
7434 url = url.slice( 0, off );
7437 // If it's a function
7438 if ( jQuery.isFunction( params ) ) {
7440 // We assume that it's the callback
7444 // Otherwise, build a param string
7445 } else if ( params && typeof params === "object" ) {
7449 // Request the remote document
7453 // if "type" variable is undefined, then "GET" method will be used
7457 complete: function( jqXHR, status ) {
7459 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7462 }).done(function( responseText ) {
7464 // Save response for use in complete callback
7465 response = arguments;
7467 // See if a selector was specified
7468 self.html( selector ?
7470 // Create a dummy div to hold the results
7473 // inject the contents of the document in, removing the scripts
7474 // to avoid any 'Permission Denied' errors in IE
7475 .append( responseText.replace( rscript, "" ) )
7477 // Locate the specified elements
7480 // If not, just inject the full result
7488 // Attach a bunch of functions for handling common AJAX events
7489 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
7490 jQuery.fn[ o ] = function( f ){
7491 return this.on( o, f );
7495 jQuery.each( [ "get", "post" ], function( i, method ) {
7496 jQuery[ method ] = function( url, data, callback, type ) {
7497 // shift arguments if data argument was omitted
7498 if ( jQuery.isFunction( data ) ) {
7499 type = type || callback;
7504 return jQuery.ajax({
7516 getScript: function( url, callback ) {
7517 return jQuery.get( url, undefined, callback, "script" );
7520 getJSON: function( url, data, callback ) {
7521 return jQuery.get( url, data, callback, "json" );
7524 // Creates a full fledged settings object into target
7525 // with both ajaxSettings and settings fields.
7526 // If target is omitted, writes into ajaxSettings.
7527 ajaxSetup: function( target, settings ) {
7529 // Building a settings object
7530 ajaxExtend( target, jQuery.ajaxSettings );
7532 // Extending ajaxSettings
7534 target = jQuery.ajaxSettings;
7536 ajaxExtend( target, settings );
7542 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7545 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7561 xml: "application/xml, text/xml",
7564 json: "application/json, text/javascript",
7576 text: "responseText"
7579 // List of data converters
7580 // 1) key format is "source_type destination_type" (a single space in-between)
7581 // 2) the catchall symbol "*" can be used for source_type
7584 // Convert anything to text
7585 "* text": window.String,
7587 // Text to html (true = no transformation)
7590 // Evaluate text as a json expression
7591 "text json": jQuery.parseJSON,
7593 // Parse text as xml
7594 "text xml": jQuery.parseXML
7597 // For options that shouldn't be deep extended:
7598 // you can add your own custom options here if
7599 // and when you create one that shouldn't be
7600 // deep extended (see ajaxExtend)
7607 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7608 ajaxTransport: addToPrefiltersOrTransports( transports ),
7611 ajax: function( url, options ) {
7613 // If url is an object, simulate pre-1.5 signature
7614 if ( typeof url === "object" ) {
7619 // Force options to be an object
7620 options = options || {};
7622 var // ifModified key
7625 responseHeadersString,
7631 // Cross-domain detection vars
7633 // To know if global events are to be dispatched
7637 // Create the final options object
7638 s = jQuery.ajaxSetup( {}, options ),
7639 // Callbacks context
7640 callbackContext = s.context || s,
7641 // Context for global events
7642 // It's the callbackContext if one was provided in the options
7643 // and if it's a DOM node or a jQuery collection
7644 globalEventContext = callbackContext !== s &&
7645 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
7646 jQuery( callbackContext ) : jQuery.event,
7648 deferred = jQuery.Deferred(),
7649 completeDeferred = jQuery.Callbacks( "once memory" ),
7650 // Status-dependent callbacks
7651 statusCode = s.statusCode || {},
7652 // Headers (they are sent all at once)
7653 requestHeaders = {},
7654 requestHeadersNames = {},
7657 // Default abort message
7658 strAbort = "canceled",
7664 // Caches the header
7665 setRequestHeader: function( name, value ) {
7667 var lname = name.toLowerCase();
7668 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7669 requestHeaders[ name ] = value;
7675 getAllResponseHeaders: function() {
7676 return state === 2 ? responseHeadersString : null;
7679 // Builds headers hashtable if needed
7680 getResponseHeader: function( key ) {
7682 if ( state === 2 ) {
7683 if ( !responseHeaders ) {
7684 responseHeaders = {};
7685 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
7686 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7689 match = responseHeaders[ key.toLowerCase() ];
7691 return match === undefined ? null : match;
7694 // Overrides response content-type header
7695 overrideMimeType: function( type ) {
7702 // Cancel the request
7703 abort: function( statusText ) {
7704 statusText = statusText || strAbort;
7706 transport.abort( statusText );
7708 done( 0, statusText );
7713 // Callback for when everything is done
7714 // It is defined here because jslint complains if it is declared
7715 // at the end of the function (which would be more logical and readable)
7716 function done( status, nativeStatusText, responses, headers ) {
7717 var isSuccess, success, error, response, modified,
7718 statusText = nativeStatusText;
7721 if ( state === 2 ) {
7725 // State is "done" now
7728 // Clear timeout if it exists
7729 if ( timeoutTimer ) {
7730 clearTimeout( timeoutTimer );
7733 // Dereference transport for early garbage collection
7734 // (no matter how long the jqXHR object will be used)
7735 transport = undefined;
7737 // Cache response headers
7738 responseHeadersString = headers || "";
7741 jqXHR.readyState = status > 0 ? 4 : 0;
7743 // Get response data
7745 response = ajaxHandleResponses( s, jqXHR, responses );
7748 // If successful, handle type chaining
7749 if ( status >= 200 && status < 300 || status === 304 ) {
7751 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7752 if ( s.ifModified ) {
7754 modified = jqXHR.getResponseHeader("Last-Modified");
7756 jQuery.lastModified[ ifModifiedKey ] = modified;
7758 modified = jqXHR.getResponseHeader("Etag");
7760 jQuery.etag[ ifModifiedKey ] = modified;
7765 if ( status === 304 ) {
7767 statusText = "notmodified";
7773 isSuccess = ajaxConvert( s, response );
7774 statusText = isSuccess.state;
7775 success = isSuccess.data;
7776 error = isSuccess.error;
7780 // We extract error from statusText
7781 // then normalize statusText and status for non-aborts
7783 if ( !statusText || status ) {
7784 statusText = "error";
7791 // Set data for the fake xhr object
7792 jqXHR.status = status;
7793 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
7797 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
7799 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
7802 // Status-dependent callbacks
7803 jqXHR.statusCode( statusCode );
7804 statusCode = undefined;
7806 if ( fireGlobals ) {
7807 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
7808 [ jqXHR, s, isSuccess ? success : error ] );
7812 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
7814 if ( fireGlobals ) {
7815 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
7816 // Handle the global AJAX counter
7817 if ( !( --jQuery.active ) ) {
7818 jQuery.event.trigger( "ajaxStop" );
7824 deferred.promise( jqXHR );
7825 jqXHR.success = jqXHR.done;
7826 jqXHR.error = jqXHR.fail;
7827 jqXHR.complete = completeDeferred.add;
7829 // Status-dependent callbacks
7830 jqXHR.statusCode = function( map ) {
7834 for ( tmp in map ) {
7835 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
7838 tmp = map[ jqXHR.status ];
7839 jqXHR.always( tmp );
7845 // Remove hash character (#7531: and string promotion)
7846 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
7847 // We also use the url parameter if available
7848 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
7850 // Extract dataTypes list
7851 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
7853 // A cross-domain request is in order when we have a protocol:host:port mismatch
7854 if ( s.crossDomain == null ) {
7855 parts = rurl.exec( s.url.toLowerCase() ) || false;
7856 s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
7857 ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
7860 // Convert data if not already a string
7861 if ( s.data && s.processData && typeof s.data !== "string" ) {
7862 s.data = jQuery.param( s.data, s.traditional );
7866 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
7868 // If request was aborted inside a prefilter, stop there
7869 if ( state === 2 ) {
7873 // We can fire global events as of now if asked to
7874 fireGlobals = s.global;
7876 // Uppercase the type
7877 s.type = s.type.toUpperCase();
7879 // Determine if request has content
7880 s.hasContent = !rnoContent.test( s.type );
7882 // Watch for a new set of requests
7883 if ( fireGlobals && jQuery.active++ === 0 ) {
7884 jQuery.event.trigger( "ajaxStart" );
7887 // More options handling for requests with no content
7888 if ( !s.hasContent ) {
7890 // If data is available, append data to url
7892 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
7893 // #9682: remove data so that it's not used in an eventual retry
7897 // Get ifModifiedKey before adding the anti-cache parameter
7898 ifModifiedKey = s.url;
7900 // Add anti-cache in url if needed
7901 if ( s.cache === false ) {
7903 var ts = jQuery.now(),
7904 // try replacing _= if it is there
7905 ret = s.url.replace( rts, "$1_=" + ts );
7907 // if nothing was replaced, add timestamp to the end
7908 s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
7912 // Set the correct header, if data is being sent
7913 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
7914 jqXHR.setRequestHeader( "Content-Type", s.contentType );
7917 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
7918 if ( s.ifModified ) {
7919 ifModifiedKey = ifModifiedKey || s.url;
7920 if ( jQuery.lastModified[ ifModifiedKey ] ) {
7921 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
7923 if ( jQuery.etag[ ifModifiedKey ] ) {
7924 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
7928 // Set the Accepts header for the server, depending on the dataType
7929 jqXHR.setRequestHeader(
7931 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
7932 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
7936 // Check for headers option
7937 for ( i in s.headers ) {
7938 jqXHR.setRequestHeader( i, s.headers[ i ] );
7941 // Allow custom headers/mimetypes and early abort
7942 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
7943 // Abort if not done already and return
7944 return jqXHR.abort();
7948 // aborting is no longer a cancellation
7951 // Install callbacks on deferreds
7952 for ( i in { success: 1, error: 1, complete: 1 } ) {
7953 jqXHR[ i ]( s[ i ] );
7957 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
7959 // If no transport, we auto-abort
7961 done( -1, "No Transport" );
7963 jqXHR.readyState = 1;
7964 // Send global event
7965 if ( fireGlobals ) {
7966 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
7969 if ( s.async && s.timeout > 0 ) {
7970 timeoutTimer = setTimeout( function(){
7971 jqXHR.abort( "timeout" );
7977 transport.send( requestHeaders, done );
7979 // Propagate exception as error if not done
7982 // Simply rethrow otherwise
7992 // Counter for holding the number of active queries
7995 // Last-Modified header cache for next request
8001 /* Handles responses to an ajax request:
8002 * - sets all responseXXX fields accordingly
8003 * - finds the right dataType (mediates between content-type and expected dataType)
8004 * - returns the corresponding response
8006 function ajaxHandleResponses( s, jqXHR, responses ) {
8008 var ct, type, finalDataType, firstDataType,
8009 contents = s.contents,
8010 dataTypes = s.dataTypes,
8011 responseFields = s.responseFields;
8013 // Fill responseXXX fields
8014 for ( type in responseFields ) {
8015 if ( type in responses ) {
8016 jqXHR[ responseFields[type] ] = responses[ type ];
8020 // Remove auto dataType and get content-type in the process
8021 while( dataTypes[ 0 ] === "*" ) {
8023 if ( ct === undefined ) {
8024 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
8028 // Check if we're dealing with a known content-type
8030 for ( type in contents ) {
8031 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8032 dataTypes.unshift( type );
8038 // Check to see if we have a response for the expected dataType
8039 if ( dataTypes[ 0 ] in responses ) {
8040 finalDataType = dataTypes[ 0 ];
8042 // Try convertible dataTypes
8043 for ( type in responses ) {
8044 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8045 finalDataType = type;
8048 if ( !firstDataType ) {
8049 firstDataType = type;
8052 // Or just use first one
8053 finalDataType = finalDataType || firstDataType;
8056 // If we found a dataType
8057 // We add the dataType to the list if needed
8058 // and return the corresponding response
8059 if ( finalDataType ) {
8060 if ( finalDataType !== dataTypes[ 0 ] ) {
8061 dataTypes.unshift( finalDataType );
8063 return responses[ finalDataType ];
8067 // Chain conversions given the request and the original response
8068 function ajaxConvert( s, response ) {
8070 var conv, conv2, current, tmp,
8071 // Work with a copy of dataTypes in case we need to modify it for conversion
8072 dataTypes = s.dataTypes.slice(),
8073 prev = dataTypes[ 0 ],
8077 // Apply the dataFilter if provided
8078 if ( s.dataFilter ) {
8079 response = s.dataFilter( response, s.dataType );
8082 // Create converters map with lowercased keys
8083 if ( dataTypes[ 1 ] ) {
8084 for ( conv in s.converters ) {
8085 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8089 // Convert to each sequential dataType, tolerating list modification
8090 for ( ; (current = dataTypes[++i]); ) {
8092 // There's only work to do if current dataType is non-auto
8093 if ( current !== "*" ) {
8095 // Convert response if prev dataType is non-auto and differs from current
8096 if ( prev !== "*" && prev !== current ) {
8098 // Seek a direct converter
8099 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8101 // If none found, seek a pair
8103 for ( conv2 in converters ) {
8105 // If conv2 outputs current
8106 tmp = conv2.split(" ");
8107 if ( tmp[ 1 ] === current ) {
8109 // If prev can be converted to accepted input
8110 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8111 converters[ "* " + tmp[ 0 ] ];
8113 // Condense equivalence converters
8114 if ( conv === true ) {
8115 conv = converters[ conv2 ];
8117 // Otherwise, insert the intermediate dataType
8118 } else if ( converters[ conv2 ] !== true ) {
8120 dataTypes.splice( i--, 0, current );
8129 // Apply converter (if not an equivalence)
8130 if ( conv !== true ) {
8132 // Unless errors are allowed to bubble, catch and return them
8133 if ( conv && s["throws"] ) {
8134 response = conv( response );
8137 response = conv( response );
8139 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8145 // Update prev for next iteration
8150 return { state: "success", data: response };
8152 var oldCallbacks = [],
8154 rjsonp = /(=)\?(?=&|$)|\?\?/,
8155 nonce = jQuery.now();
8157 // Default jsonp settings
8160 jsonpCallback: function() {
8161 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
8162 this[ callback ] = true;
8167 // Detect, normalize options and install callbacks for jsonp requests
8168 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8170 var callbackName, overwritten, responseContainer,
8173 hasCallback = s.jsonp !== false,
8174 replaceInUrl = hasCallback && rjsonp.test( url ),
8175 replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
8176 !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
8177 rjsonp.test( data );
8179 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8180 if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {
8182 // Get callback name, remembering preexisting value associated with it
8183 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8186 overwritten = window[ callbackName ];
8188 // Insert callback into url or form data
8189 if ( replaceInUrl ) {
8190 s.url = url.replace( rjsonp, "$1" + callbackName );
8191 } else if ( replaceInData ) {
8192 s.data = data.replace( rjsonp, "$1" + callbackName );
8193 } else if ( hasCallback ) {
8194 s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8197 // Use data converter to retrieve json after script execution
8198 s.converters["script json"] = function() {
8199 if ( !responseContainer ) {
8200 jQuery.error( callbackName + " was not called" );
8202 return responseContainer[ 0 ];
8205 // force json dataType
8206 s.dataTypes[ 0 ] = "json";
8209 window[ callbackName ] = function() {
8210 responseContainer = arguments;
8213 // Clean-up function (fires after converters)
8214 jqXHR.always(function() {
8215 // Restore preexisting value
8216 window[ callbackName ] = overwritten;
8218 // Save back as free
8219 if ( s[ callbackName ] ) {
8220 // make sure that re-using the options doesn't screw things around
8221 s.jsonpCallback = originalSettings.jsonpCallback;
8223 // save the callback name for future use
8224 oldCallbacks.push( callbackName );
8227 // Call if it was a function and we have a response
8228 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8229 overwritten( responseContainer[ 0 ] );
8232 responseContainer = overwritten = undefined;
8235 // Delegate to script
8239 // Install script dataType
8242 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8245 script: /javascript|ecmascript/
8248 "text script": function( text ) {
8249 jQuery.globalEval( text );
8255 // Handle cache's special case and global
8256 jQuery.ajaxPrefilter( "script", function( s ) {
8257 if ( s.cache === undefined ) {
8260 if ( s.crossDomain ) {
8266 // Bind script tag hack transport
8267 jQuery.ajaxTransport( "script", function(s) {
8269 // This transport only deals with cross domain requests
8270 if ( s.crossDomain ) {
8273 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
8277 send: function( _, callback ) {
8279 script = document.createElement( "script" );
8281 script.async = "async";
8283 if ( s.scriptCharset ) {
8284 script.charset = s.scriptCharset;
8289 // Attach handlers for all browsers
8290 script.onload = script.onreadystatechange = function( _, isAbort ) {
8292 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8294 // Handle memory leak in IE
8295 script.onload = script.onreadystatechange = null;
8297 // Remove the script
8298 if ( head && script.parentNode ) {
8299 head.removeChild( script );
8302 // Dereference the script
8305 // Callback if not abort
8307 callback( 200, "success" );
8311 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
8312 // This arises when a base node is used (#2709 and #4378).
8313 head.insertBefore( script, head.firstChild );
8318 script.onload( 0, 1 );
8325 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8326 xhrOnUnloadAbort = window.ActiveXObject ? function() {
8327 // Abort all pending requests
8328 for ( var key in xhrCallbacks ) {
8329 xhrCallbacks[ key ]( 0, 1 );
8334 // Functions to create xhrs
8335 function createStandardXHR() {
8337 return new window.XMLHttpRequest();
8341 function createActiveXHR() {
8343 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
8347 // Create the request object
8348 // (This is still attached to ajaxSettings for backward compatibility)
8349 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8350 /* Microsoft failed to properly
8351 * implement the XMLHttpRequest in IE7 (can't request local files),
8352 * so we use the ActiveXObject when it is available
8353 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8354 * we need a fallback.
8357 return !this.isLocal && createStandardXHR() || createActiveXHR();
8359 // For all other browsers, use the standard XMLHttpRequest object
8362 // Determine support properties
8364 jQuery.extend( jQuery.support, {
8366 cors: !!xhr && ( "withCredentials" in xhr )
8368 })( jQuery.ajaxSettings.xhr() );
8370 // Create transport if the browser can provide an xhr
8371 if ( jQuery.support.ajax ) {
8373 jQuery.ajaxTransport(function( s ) {
8374 // Cross domain only allowed if supported through XMLHttpRequest
8375 if ( !s.crossDomain || jQuery.support.cors ) {
8380 send: function( headers, complete ) {
8387 // Passing null username, generates a login popup on Opera (#2865)
8389 xhr.open( s.type, s.url, s.async, s.username, s.password );
8391 xhr.open( s.type, s.url, s.async );
8394 // Apply custom fields if provided
8395 if ( s.xhrFields ) {
8396 for ( i in s.xhrFields ) {
8397 xhr[ i ] = s.xhrFields[ i ];
8401 // Override mime type if needed
8402 if ( s.mimeType && xhr.overrideMimeType ) {
8403 xhr.overrideMimeType( s.mimeType );
8406 // X-Requested-With header
8407 // For cross-domain requests, seeing as conditions for a preflight are
8408 // akin to a jigsaw puzzle, we simply never set it to be sure.
8409 // (it can always be set on a per-request basis or even using ajaxSetup)
8410 // For same-domain requests, won't change header if already provided.
8411 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8412 headers[ "X-Requested-With" ] = "XMLHttpRequest";
8415 // Need an extra try/catch for cross domain requests in Firefox 3
8417 for ( i in headers ) {
8418 xhr.setRequestHeader( i, headers[ i ] );
8422 // Do send the request
8423 // This may raise an exception which is actually
8424 // handled in jQuery.ajax (so no try/catch here)
8425 xhr.send( ( s.hasContent && s.data ) || null );
8428 callback = function( _, isAbort ) {
8436 // Firefox throws exceptions when accessing properties
8437 // of an xhr when a network error occurred
8438 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8441 // Was never called and is aborted or complete
8442 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8445 callback = undefined;
8447 // Do not keep as active anymore
8449 xhr.onreadystatechange = jQuery.noop;
8450 if ( xhrOnUnloadAbort ) {
8451 delete xhrCallbacks[ handle ];
8457 // Abort it manually if needed
8458 if ( xhr.readyState !== 4 ) {
8462 status = xhr.status;
8463 responseHeaders = xhr.getAllResponseHeaders();
8465 xml = xhr.responseXML;
8467 // Construct response list
8468 if ( xml && xml.documentElement /* #4958 */ ) {
8469 responses.xml = xml;
8472 // When requesting binary data, IE6-9 will throw an exception
8473 // on any attempt to access responseText (#11426)
8475 responses.text = xhr.responseText;
8479 // Firefox throws an exception when accessing
8480 // statusText for faulty cross-domain requests
8482 statusText = xhr.statusText;
8484 // We normalize with Webkit giving an empty statusText
8488 // Filter status for non standard behaviors
8490 // If the request is local and we have data: assume a success
8491 // (success with no data won't get notified, that's the best we
8492 // can do given current implementations)
8493 if ( !status && s.isLocal && !s.crossDomain ) {
8494 status = responses.text ? 200 : 404;
8495 // IE - #1450: sometimes returns 1223 when it should be 204
8496 } else if ( status === 1223 ) {
8501 } catch( firefoxAccessException ) {
8503 complete( -1, firefoxAccessException );
8507 // Call complete if needed
8509 complete( status, statusText, responses, responseHeaders );
8514 // if we're in sync mode we fire the callback
8516 } else if ( xhr.readyState === 4 ) {
8517 // (IE6 & IE7) if it's in cache and has been
8518 // retrieved directly we need to fire the callback
8519 setTimeout( callback, 0 );
8522 if ( xhrOnUnloadAbort ) {
8523 // Create the active xhrs callbacks list if needed
8524 // and attach the unload handler
8525 if ( !xhrCallbacks ) {
8527 jQuery( window ).unload( xhrOnUnloadAbort );
8529 // Add to list of active xhrs callbacks
8530 xhrCallbacks[ handle ] = callback;
8532 xhr.onreadystatechange = callback;
8546 rfxtypes = /^(?:toggle|show|hide)$/,
8547 rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8548 rrun = /queueHooks$/,
8549 animationPrefilters = [ defaultPrefilter ],
8551 "*": [function( prop, value ) {
8553 tween = this.createTween( prop, value ),
8554 parts = rfxnum.exec( value ),
8555 target = tween.cur(),
8556 start = +target || 0,
8562 unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8564 // We need to compute starting value
8565 if ( unit !== "px" && start ) {
8566 // Iteratively approximate from a nonzero starting point
8567 // Prefer the current property, because this process will be trivial if it uses the same units
8568 // Fallback to end or a simple constant
8569 start = jQuery.css( tween.elem, prop, true ) || end || 1;
8572 // If previous iteration zeroed out, double until we get *something*
8573 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8574 scale = scale || ".5";
8577 start = start / scale;
8578 jQuery.style( tween.elem, prop, start + unit );
8580 // Update scale, tolerating zero or NaN from tween.cur()
8581 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8582 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8586 tween.start = start;
8587 // If a +=/-= token was provided, we're doing a relative animation
8588 tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
8594 // Animations created synchronously will run synchronously
8595 function createFxNow() {
8596 setTimeout(function() {
8599 return ( fxNow = jQuery.now() );
8602 function createTweens( animation, props ) {
8603 jQuery.each( props, function( prop, value ) {
8604 var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8606 length = collection.length;
8607 for ( ; index < length; index++ ) {
8608 if ( collection[ index ].call( animation, prop, value ) ) {
8610 // we're done with this property
8617 function Animation( elem, properties, options ) {
8621 length = animationPrefilters.length,
8622 deferred = jQuery.Deferred().always( function() {
8623 // don't match elem in the :animated selector
8627 var currentTime = fxNow || createFxNow(),
8628 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8629 percent = 1 - ( remaining / animation.duration || 0 ),
8631 length = animation.tweens.length;
8633 for ( ; index < length ; index++ ) {
8634 animation.tweens[ index ].run( percent );
8637 deferred.notifyWith( elem, [ animation, percent, remaining ]);
8639 if ( percent < 1 && length ) {
8642 deferred.resolveWith( elem, [ animation ] );
8646 animation = deferred.promise({
8648 props: jQuery.extend( {}, properties ),
8649 opts: jQuery.extend( true, { specialEasing: {} }, options ),
8650 originalProperties: properties,
8651 originalOptions: options,
8652 startTime: fxNow || createFxNow(),
8653 duration: options.duration,
8655 createTween: function( prop, end, easing ) {
8656 var tween = jQuery.Tween( elem, animation.opts, prop, end,
8657 animation.opts.specialEasing[ prop ] || animation.opts.easing );
8658 animation.tweens.push( tween );
8661 stop: function( gotoEnd ) {
8663 // if we are going to the end, we want to run all the tweens
8664 // otherwise we skip this part
8665 length = gotoEnd ? animation.tweens.length : 0;
8667 for ( ; index < length ; index++ ) {
8668 animation.tweens[ index ].run( 1 );
8671 // resolve when we played the last frame
8672 // otherwise, reject
8674 deferred.resolveWith( elem, [ animation, gotoEnd ] );
8676 deferred.rejectWith( elem, [ animation, gotoEnd ] );
8681 props = animation.props;
8683 propFilter( props, animation.opts.specialEasing );
8685 for ( ; index < length ; index++ ) {
8686 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8692 createTweens( animation, props );
8694 if ( jQuery.isFunction( animation.opts.start ) ) {
8695 animation.opts.start.call( elem, animation );
8699 jQuery.extend( tick, {
8701 queue: animation.opts.queue,
8706 // attach callbacks from options
8707 return animation.progress( animation.opts.progress )
8708 .done( animation.opts.done, animation.opts.complete )
8709 .fail( animation.opts.fail )
8710 .always( animation.opts.always );
8713 function propFilter( props, specialEasing ) {
8714 var index, name, easing, value, hooks;
8716 // camelCase, specialEasing and expand cssHook pass
8717 for ( index in props ) {
8718 name = jQuery.camelCase( index );
8719 easing = specialEasing[ name ];
8720 value = props[ index ];
8721 if ( jQuery.isArray( value ) ) {
8722 easing = value[ 1 ];
8723 value = props[ index ] = value[ 0 ];
8726 if ( index !== name ) {
8727 props[ name ] = value;
8728 delete props[ index ];
8731 hooks = jQuery.cssHooks[ name ];
8732 if ( hooks && "expand" in hooks ) {
8733 value = hooks.expand( value );
8734 delete props[ name ];
8736 // not quite $.extend, this wont overwrite keys already present.
8737 // also - reusing 'index' from above because we have the correct "name"
8738 for ( index in value ) {
8739 if ( !( index in props ) ) {
8740 props[ index ] = value[ index ];
8741 specialEasing[ index ] = easing;
8745 specialEasing[ name ] = easing;
8750 jQuery.Animation = jQuery.extend( Animation, {
8752 tweener: function( props, callback ) {
8753 if ( jQuery.isFunction( props ) ) {
8757 props = props.split(" ");
8762 length = props.length;
8764 for ( ; index < length ; index++ ) {
8765 prop = props[ index ];
8766 tweeners[ prop ] = tweeners[ prop ] || [];
8767 tweeners[ prop ].unshift( callback );
8771 prefilter: function( callback, prepend ) {
8773 animationPrefilters.unshift( callback );
8775 animationPrefilters.push( callback );
8780 function defaultPrefilter( elem, props, opts ) {
8781 var index, prop, value, length, dataShow, tween, hooks, oldfire,
8786 hidden = elem.nodeType && isHidden( elem );
8788 // handle queue: false promises
8789 if ( !opts.queue ) {
8790 hooks = jQuery._queueHooks( elem, "fx" );
8791 if ( hooks.unqueued == null ) {
8793 oldfire = hooks.empty.fire;
8794 hooks.empty.fire = function() {
8795 if ( !hooks.unqueued ) {
8802 anim.always(function() {
8803 // doing this makes sure that the complete handler will be called
8804 // before this completes
8805 anim.always(function() {
8807 if ( !jQuery.queue( elem, "fx" ).length ) {
8814 // height/width overflow pass
8815 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
8816 // Make sure that nothing sneaks out
8817 // Record all 3 overflow attributes because IE does not
8818 // change the overflow attribute when overflowX and
8819 // overflowY are set to the same value
8820 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
8822 // Set display property to inline-block for height/width
8823 // animations on inline elements that are having width/height animated
8824 if ( jQuery.css( elem, "display" ) === "inline" &&
8825 jQuery.css( elem, "float" ) === "none" ) {
8827 // inline-level elements accept inline-block;
8828 // block-level elements need to be inline with layout
8829 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
8830 style.display = "inline-block";
8838 if ( opts.overflow ) {
8839 style.overflow = "hidden";
8840 if ( !jQuery.support.shrinkWrapBlocks ) {
8841 anim.done(function() {
8842 style.overflow = opts.overflow[ 0 ];
8843 style.overflowX = opts.overflow[ 1 ];
8844 style.overflowY = opts.overflow[ 2 ];
8851 for ( index in props ) {
8852 value = props[ index ];
8853 if ( rfxtypes.exec( value ) ) {
8854 delete props[ index ];
8855 if ( value === ( hidden ? "hide" : "show" ) ) {
8858 handled.push( index );
8862 length = handled.length;
8864 dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
8866 jQuery( elem ).show();
8868 anim.done(function() {
8869 jQuery( elem ).hide();
8872 anim.done(function() {
8874 jQuery.removeData( elem, "fxshow", true );
8875 for ( prop in orig ) {
8876 jQuery.style( elem, prop, orig[ prop ] );
8879 for ( index = 0 ; index < length ; index++ ) {
8880 prop = handled[ index ];
8881 tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
8882 orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );
8884 if ( !( prop in dataShow ) ) {
8885 dataShow[ prop ] = tween.start;
8887 tween.end = tween.start;
8888 tween.start = prop === "width" || prop === "height" ? 1 : 0;
8895 function Tween( elem, options, prop, end, easing ) {
8896 return new Tween.prototype.init( elem, options, prop, end, easing );
8898 jQuery.Tween = Tween;
8902 init: function( elem, options, prop, end, easing, unit ) {
8905 this.easing = easing || "swing";
8906 this.options = options;
8907 this.start = this.now = this.cur();
8909 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
8912 var hooks = Tween.propHooks[ this.prop ];
8914 return hooks && hooks.get ?
8916 Tween.propHooks._default.get( this );
8918 run: function( percent ) {
8920 hooks = Tween.propHooks[ this.prop ];
8922 if ( this.options.duration ) {
8923 this.pos = eased = jQuery.easing[ this.easing ](
8924 percent, this.options.duration * percent, 0, 1, this.options.duration
8927 this.pos = eased = percent;
8929 this.now = ( this.end - this.start ) * eased + this.start;
8931 if ( this.options.step ) {
8932 this.options.step.call( this.elem, this.now, this );
8935 if ( hooks && hooks.set ) {
8938 Tween.propHooks._default.set( this );
8944 Tween.prototype.init.prototype = Tween.prototype;
8948 get: function( tween ) {
8951 if ( tween.elem[ tween.prop ] != null &&
8952 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
8953 return tween.elem[ tween.prop ];
8956 // passing any value as a 4th parameter to .css will automatically
8957 // attempt a parseFloat and fallback to a string if the parse fails
8958 // so, simple values such as "10px" are parsed to Float.
8959 // complex values such as "rotate(1rad)" are returned as is.
8960 result = jQuery.css( tween.elem, tween.prop, false, "" );
8961 // Empty strings, null, undefined and "auto" are converted to 0.
8962 return !result || result === "auto" ? 0 : result;
8964 set: function( tween ) {
8965 // use step hook for back compat - use cssHook if its there - use .style if its
8966 // available and use plain properties where available
8967 if ( jQuery.fx.step[ tween.prop ] ) {
8968 jQuery.fx.step[ tween.prop ]( tween );
8969 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
8970 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
8972 tween.elem[ tween.prop ] = tween.now;
8978 // Remove in 2.0 - this supports IE8's panic based approach
8979 // to setting things on disconnected nodes
8981 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
8982 set: function( tween ) {
8983 if ( tween.elem.nodeType && tween.elem.parentNode ) {
8984 tween.elem[ tween.prop ] = tween.now;
8989 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
8990 var cssFn = jQuery.fn[ name ];
8991 jQuery.fn[ name ] = function( speed, easing, callback ) {
8992 return speed == null || typeof speed === "boolean" ||
8993 // special check for .toggle( handler, handler, ... )
8994 ( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
8995 cssFn.apply( this, arguments ) :
8996 this.animate( genFx( name, true ), speed, easing, callback );
9001 fadeTo: function( speed, to, easing, callback ) {
9003 // show any hidden elements after setting opacity to 0
9004 return this.filter( isHidden ).css( "opacity", 0 ).show()
9006 // animate to the value specified
9007 .end().animate({ opacity: to }, speed, easing, callback );
9009 animate: function( prop, speed, easing, callback ) {
9010 var empty = jQuery.isEmptyObject( prop ),
9011 optall = jQuery.speed( speed, easing, callback ),
9012 doAnimation = function() {
9013 // Operate on a copy of prop so per-property easing won't be lost
9014 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
9016 // Empty animations resolve immediately
9022 return empty || optall.queue === false ?
9023 this.each( doAnimation ) :
9024 this.queue( optall.queue, doAnimation );
9026 stop: function( type, clearQueue, gotoEnd ) {
9027 var stopQueue = function( hooks ) {
9028 var stop = hooks.stop;
9033 if ( typeof type !== "string" ) {
9034 gotoEnd = clearQueue;
9038 if ( clearQueue && type !== false ) {
9039 this.queue( type || "fx", [] );
9042 return this.each(function() {
9044 index = type != null && type + "queueHooks",
9045 timers = jQuery.timers,
9046 data = jQuery._data( this );
9049 if ( data[ index ] && data[ index ].stop ) {
9050 stopQueue( data[ index ] );
9053 for ( index in data ) {
9054 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
9055 stopQueue( data[ index ] );
9060 for ( index = timers.length; index--; ) {
9061 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
9062 timers[ index ].anim.stop( gotoEnd );
9064 timers.splice( index, 1 );
9068 // start the next in the queue if the last step wasn't forced
9069 // timers currently will call their complete callbacks, which will dequeue
9070 // but only if they were gotoEnd
9071 if ( dequeue || !gotoEnd ) {
9072 jQuery.dequeue( this, type );
9078 // Generate parameters to create a standard animation
9079 function genFx( type, includeWidth ) {
9081 attrs = { height: type },
9084 // if we include width, step value is 1 to do all cssExpand values,
9085 // if we don't include width, step value is 2 to skip over Left and Right
9086 includeWidth = includeWidth? 1 : 0;
9087 for( ; i < 4 ; i += 2 - includeWidth ) {
9088 which = cssExpand[ i ];
9089 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
9092 if ( includeWidth ) {
9093 attrs.opacity = attrs.width = type;
9099 // Generate shortcuts for custom animations
9101 slideDown: genFx("show"),
9102 slideUp: genFx("hide"),
9103 slideToggle: genFx("toggle"),
9104 fadeIn: { opacity: "show" },
9105 fadeOut: { opacity: "hide" },
9106 fadeToggle: { opacity: "toggle" }
9107 }, function( name, props ) {
9108 jQuery.fn[ name ] = function( speed, easing, callback ) {
9109 return this.animate( props, speed, easing, callback );
9113 jQuery.speed = function( speed, easing, fn ) {
9114 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
9115 complete: fn || !fn && easing ||
9116 jQuery.isFunction( speed ) && speed,
9118 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
9121 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
9122 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
9124 // normalize opt.queue - true/undefined/null -> "fx"
9125 if ( opt.queue == null || opt.queue === true ) {
9130 opt.old = opt.complete;
9132 opt.complete = function() {
9133 if ( jQuery.isFunction( opt.old ) ) {
9134 opt.old.call( this );
9138 jQuery.dequeue( this, opt.queue );
9146 linear: function( p ) {
9149 swing: function( p ) {
9150 return 0.5 - Math.cos( p*Math.PI ) / 2;
9155 jQuery.fx = Tween.prototype.init;
9156 jQuery.fx.tick = function() {
9158 timers = jQuery.timers,
9161 for ( ; i < timers.length; i++ ) {
9162 timer = timers[ i ];
9163 // Checks the timer has not already been removed
9164 if ( !timer() && timers[ i ] === timer ) {
9165 timers.splice( i--, 1 );
9169 if ( !timers.length ) {
9174 jQuery.fx.timer = function( timer ) {
9175 if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
9176 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
9180 jQuery.fx.interval = 13;
9182 jQuery.fx.stop = function() {
9183 clearInterval( timerId );
9187 jQuery.fx.speeds = {
9194 // Back Compat <1.8 extension point
9195 jQuery.fx.step = {};
9197 if ( jQuery.expr && jQuery.expr.filters ) {
9198 jQuery.expr.filters.animated = function( elem ) {
9199 return jQuery.grep(jQuery.timers, function( fn ) {
9200 return elem === fn.elem;
9204 var rroot = /^(?:body|html)$/i;
9206 jQuery.fn.offset = function( options ) {
9207 if ( arguments.length ) {
9208 return options === undefined ?
9210 this.each(function( i ) {
9211 jQuery.offset.setOffset( this, options, i );
9215 var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
9216 box = { top: 0, left: 0 },
9218 doc = elem && elem.ownerDocument;
9224 if ( (body = doc.body) === elem ) {
9225 return jQuery.offset.bodyOffset( elem );
9228 docElem = doc.documentElement;
9230 // Make sure it's not a disconnected DOM node
9231 if ( !jQuery.contains( docElem, elem ) ) {
9235 // If we don't have gBCR, just use 0,0 rather than error
9236 // BlackBerry 5, iOS 3 (original iPhone)
9237 if ( typeof elem.getBoundingClientRect !== "undefined" ) {
9238 box = elem.getBoundingClientRect();
9240 win = getWindow( doc );
9241 clientTop = docElem.clientTop || body.clientTop || 0;
9242 clientLeft = docElem.clientLeft || body.clientLeft || 0;
9243 scrollTop = win.pageYOffset || docElem.scrollTop;
9244 scrollLeft = win.pageXOffset || docElem.scrollLeft;
9246 top: box.top + scrollTop - clientTop,
9247 left: box.left + scrollLeft - clientLeft
9253 bodyOffset: function( body ) {
9254 var top = body.offsetTop,
9255 left = body.offsetLeft;
9257 if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
9258 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
9259 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
9262 return { top: top, left: left };
9265 setOffset: function( elem, options, i ) {
9266 var position = jQuery.css( elem, "position" );
9268 // set position first, in-case top/left are set even on static elem
9269 if ( position === "static" ) {
9270 elem.style.position = "relative";
9273 var curElem = jQuery( elem ),
9274 curOffset = curElem.offset(),
9275 curCSSTop = jQuery.css( elem, "top" ),
9276 curCSSLeft = jQuery.css( elem, "left" ),
9277 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9278 props = {}, curPosition = {}, curTop, curLeft;
9280 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9281 if ( calculatePosition ) {
9282 curPosition = curElem.position();
9283 curTop = curPosition.top;
9284 curLeft = curPosition.left;
9286 curTop = parseFloat( curCSSTop ) || 0;
9287 curLeft = parseFloat( curCSSLeft ) || 0;
9290 if ( jQuery.isFunction( options ) ) {
9291 options = options.call( elem, i, curOffset );
9294 if ( options.top != null ) {
9295 props.top = ( options.top - curOffset.top ) + curTop;
9297 if ( options.left != null ) {
9298 props.left = ( options.left - curOffset.left ) + curLeft;
9301 if ( "using" in options ) {
9302 options.using.call( elem, props );
9304 curElem.css( props );
9312 position: function() {
9319 // Get *real* offsetParent
9320 offsetParent = this.offsetParent(),
9322 // Get correct offsets
9323 offset = this.offset(),
9324 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
9326 // Subtract element margins
9327 // note: when an element has margin: auto the offsetLeft and marginLeft
9328 // are the same in Safari causing offset.left to incorrectly be 0
9329 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
9330 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
9332 // Add offsetParent borders
9333 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
9334 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
9336 // Subtract the two offsets
9338 top: offset.top - parentOffset.top,
9339 left: offset.left - parentOffset.left
9343 offsetParent: function() {
9344 return this.map(function() {
9345 var offsetParent = this.offsetParent || document.body;
9346 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
9347 offsetParent = offsetParent.offsetParent;
9349 return offsetParent || document.body;
9355 // Create scrollLeft and scrollTop methods
9356 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
9357 var top = /Y/.test( prop );
9359 jQuery.fn[ method ] = function( val ) {
9360 return jQuery.access( this, function( elem, method, val ) {
9361 var win = getWindow( elem );
9363 if ( val === undefined ) {
9364 return win ? (prop in win) ? win[ prop ] :
9365 win.document.documentElement[ method ] :
9371 !top ? val : jQuery( win ).scrollLeft(),
9372 top ? val : jQuery( win ).scrollTop()
9376 elem[ method ] = val;
9378 }, method, val, arguments.length, null );
9382 function getWindow( elem ) {
9383 return jQuery.isWindow( elem ) ?
9385 elem.nodeType === 9 ?
9386 elem.defaultView || elem.parentWindow :
9389 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9390 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9391 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9392 // margin is only for outerHeight, outerWidth
9393 jQuery.fn[ funcName ] = function( margin, value ) {
9394 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9395 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9397 return jQuery.access( this, function( elem, type, value ) {
9400 if ( jQuery.isWindow( elem ) ) {
9401 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9402 // isn't a whole lot we can do. See pull request at this URL for discussion:
9403 // https://github.com/jquery/jquery/pull/764
9404 return elem.document.documentElement[ "client" + name ];
9407 // Get document width or height
9408 if ( elem.nodeType === 9 ) {
9409 doc = elem.documentElement;
9411 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9412 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9414 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9415 elem.body[ "offset" + name ], doc[ "offset" + name ],
9416 doc[ "client" + name ]
9420 return value === undefined ?
9421 // Get width or height on the element, requesting but not forcing parseFloat
9422 jQuery.css( elem, type, value, extra ) :
9424 // Set width or height on the element
9425 jQuery.style( elem, type, value, extra );
9426 }, type, chainable ? margin : undefined, chainable, null );
9430 // Expose jQuery to the global object
9431 window.jQuery = window.$ = jQuery;
9433 // Expose jQuery as an AMD module, but only for AMD loaders that
9434 // understand the issues with loading multiple versions of jQuery
9435 // in a page that all might call define(). The loader will indicate
9436 // they have special allowances for multiple jQuery versions by
9437 // specifying define.amd.jQuery = true. Register as a named module,
9438 // since jQuery can be concatenated with other files that may use define,
9439 // but not use a proper concatenation script that understands anonymous
9440 // AMD modules. A named AMD is safest and most robust way to register.
9441 // Lowercase jquery is used because AMD module names are derived from
9442 // file names, and jQuery is normally delivered in a lowercase file name.
9443 // Do this after creating the global so that if an AMD module wants to call
9444 // noConflict to hide this version of jQuery, it will work.
9445 if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
9446 define( "jquery", [], function () { return jQuery; } );