1 /* NUGET: BEGIN LICENSE TEXT
3 * Microsoft grants you the right to use these script files for the sole
4 * purpose of either: (i) interacting through your browser with the Microsoft
5 * website or online service, subject to the applicable licensing or use
6 * terms; or (ii) using the files as included with a Microsoft product subject
7 * to that product's license terms. Microsoft reserves all other rights to the
8 * files not expressly granted by Microsoft, whether by implication, estoppel
9 * or otherwise. Insofar as a script file is dual licensed under GPL,
10 * Microsoft neither took the code under GPL nor distributes it thereunder but
11 * under the terms set out in this paragraph. All notices and licenses
12 * below are for informational purposes only.
14 * NUGET: END LICENSE TEXT */
16 * jQuery JavaScript Library v1.10.2
20 * http://sizzlejs.com/
22 * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
23 * Released under the MIT license
24 * http://jquery.org/license
26 * Date: 2013-07-03T13:48Z
28 (function( window, undefined ) {
30 // Can't do this because several apps including ASP.NET trace
31 // the stack via arguments.caller.callee and Firefox dies if
32 // you try to trace through "use strict" call chains. (#13335)
33 // Support: Firefox 18+
36 // The deferred used on DOM ready
39 // A central reference to the root jQuery(document)
43 // For `typeof xmlNode.method` instead of `xmlNode.method !== undefined`
44 core_strundefined = typeof undefined,
46 // Use the correct document accordingly with window argument (sandbox)
47 location = window.location,
48 document = window.document,
49 docElem = document.documentElement,
51 // Map over jQuery in case of overwrite
52 _jQuery = window.jQuery,
54 // Map over the $ in case of overwrite
57 // [[Class]] -> type pairs
60 // List of deleted data cache ids, so we can reuse them
63 core_version = "1.10.2",
65 // Save a reference to some core methods
66 core_concat = core_deletedIds.concat,
67 core_push = core_deletedIds.push,
68 core_slice = core_deletedIds.slice,
69 core_indexOf = core_deletedIds.indexOf,
70 core_toString = class2type.toString,
71 core_hasOwn = class2type.hasOwnProperty,
72 core_trim = core_version.trim,
74 // Define a local copy of jQuery
75 jQuery = function( selector, context ) {
76 // The jQuery object is actually just the init constructor 'enhanced'
77 return new jQuery.fn.init( selector, context, rootjQuery );
80 // Used for matching numbers
81 core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
83 // Used for splitting on whitespace
84 core_rnotwhite = /\S+/g,
86 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
87 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
89 // A simple way to check for HTML strings
90 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
91 // Strict HTML recognition (#11290: must start with <)
92 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
94 // Match a standalone tag
95 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
98 rvalidchars = /^[\],:{}\s]*$/,
99 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
100 rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
101 rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
103 // Matches dashed string for camelizing
105 rdashAlpha = /-([\da-z])/gi,
107 // Used by jQuery.camelCase as callback to replace()
108 fcamelCase = function( all, letter ) {
109 return letter.toUpperCase();
112 // The ready event handler
113 completed = function( event ) {
115 // readyState === "complete" is good enough for us to call the dom ready in oldIE
116 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
121 // Clean-up method for dom ready events
122 detach = function() {
123 if ( document.addEventListener ) {
124 document.removeEventListener( "DOMContentLoaded", completed, false );
125 window.removeEventListener( "load", completed, false );
128 document.detachEvent( "onreadystatechange", completed );
129 window.detachEvent( "onload", completed );
133 jQuery.fn = jQuery.prototype = {
134 // The current version of jQuery being used
135 jquery: core_version,
138 init: function( selector, context, rootjQuery ) {
141 // HANDLE: $(""), $(null), $(undefined), $(false)
146 // Handle HTML strings
147 if ( typeof selector === "string" ) {
148 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
149 // Assume that strings that start and end with <> are HTML and skip the regex check
150 match = [ null, selector, null ];
153 match = rquickExpr.exec( selector );
156 // Match html or make sure no context is specified for #id
157 if ( match && (match[1] || !context) ) {
159 // HANDLE: $(html) -> $(array)
161 context = context instanceof jQuery ? context[0] : context;
163 // scripts is true for back-compat
164 jQuery.merge( this, jQuery.parseHTML(
166 context && context.nodeType ? context.ownerDocument || context : document,
170 // HANDLE: $(html, props)
171 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
172 for ( match in context ) {
173 // Properties of context are called as methods if possible
174 if ( jQuery.isFunction( this[ match ] ) ) {
175 this[ match ]( context[ match ] );
177 // ...and otherwise set as attributes
179 this.attr( match, context[ match ] );
188 elem = document.getElementById( match[2] );
190 // Check parentNode to catch when Blackberry 4.6 returns
191 // nodes that are no longer in the document #6963
192 if ( elem && elem.parentNode ) {
193 // Handle the case where IE and Opera return items
194 // by name instead of ID
195 if ( elem.id !== match[2] ) {
196 return rootjQuery.find( selector );
199 // Otherwise, we inject the element directly into the jQuery object
204 this.context = document;
205 this.selector = selector;
209 // HANDLE: $(expr, $(...))
210 } else if ( !context || context.jquery ) {
211 return ( context || rootjQuery ).find( selector );
213 // HANDLE: $(expr, context)
214 // (which is just equivalent to: $(context).find(expr)
216 return this.constructor( context ).find( selector );
219 // HANDLE: $(DOMElement)
220 } else if ( selector.nodeType ) {
221 this.context = this[0] = selector;
225 // HANDLE: $(function)
226 // Shortcut for document ready
227 } else if ( jQuery.isFunction( selector ) ) {
228 return rootjQuery.ready( selector );
231 if ( selector.selector !== undefined ) {
232 this.selector = selector.selector;
233 this.context = selector.context;
236 return jQuery.makeArray( selector, this );
239 // Start with an empty selector
242 // The default length of a jQuery object is 0
245 toArray: function() {
246 return core_slice.call( this );
249 // Get the Nth element in the matched element set OR
250 // Get the whole matched element set as a clean array
251 get: function( num ) {
254 // Return a 'clean' array
257 // Return just the object
258 ( num < 0 ? this[ this.length + num ] : this[ num ] );
261 // Take an array of elements and push it onto the stack
262 // (returning the new matched element set)
263 pushStack: function( elems ) {
265 // Build a new jQuery matched element set
266 var ret = jQuery.merge( this.constructor(), elems );
268 // Add the old object onto the stack (as a reference)
269 ret.prevObject = this;
270 ret.context = this.context;
272 // Return the newly-formed element set
276 // Execute a callback for every element in the matched set.
277 // (You can seed the arguments with an array of args, but this is
278 // only used internally.)
279 each: function( callback, args ) {
280 return jQuery.each( this, callback, args );
283 ready: function( fn ) {
285 jQuery.ready.promise().done( fn );
291 return this.pushStack( core_slice.apply( this, arguments ) );
299 return this.eq( -1 );
303 var len = this.length,
304 j = +i + ( i < 0 ? len : 0 );
305 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
308 map: function( callback ) {
309 return this.pushStack( jQuery.map(this, function( elem, i ) {
310 return callback.call( elem, i, elem );
315 return this.prevObject || this.constructor(null);
318 // For internal use only.
319 // Behaves like an Array's method, not like a jQuery method.
325 // Give the init function the jQuery prototype for later instantiation
326 jQuery.fn.init.prototype = jQuery.fn;
328 jQuery.extend = jQuery.fn.extend = function() {
329 var src, copyIsArray, copy, name, options, clone,
330 target = arguments[0] || {},
332 length = arguments.length,
335 // Handle a deep copy situation
336 if ( typeof target === "boolean" ) {
338 target = arguments[1] || {};
339 // skip the boolean and the target
343 // Handle case when target is a string or something (possible in deep copy)
344 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
348 // extend jQuery itself if only one argument is passed
349 if ( length === i ) {
354 for ( ; i < length; i++ ) {
355 // Only deal with non-null/undefined values
356 if ( (options = arguments[ i ]) != null ) {
357 // Extend the base object
358 for ( name in options ) {
359 src = target[ name ];
360 copy = options[ name ];
362 // Prevent never-ending loop
363 if ( target === copy ) {
367 // Recurse if we're merging plain objects or arrays
368 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
371 clone = src && jQuery.isArray(src) ? src : [];
374 clone = src && jQuery.isPlainObject(src) ? src : {};
377 // Never move original objects, clone them
378 target[ name ] = jQuery.extend( deep, clone, copy );
380 // Don't bring in undefined values
381 } else if ( copy !== undefined ) {
382 target[ name ] = copy;
388 // Return the modified object
393 // Unique for each copy of jQuery on the page
394 // Non-digits removed to match rinlinejQuery
395 expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
397 noConflict: function( deep ) {
398 if ( window.$ === jQuery ) {
402 if ( deep && window.jQuery === jQuery ) {
403 window.jQuery = _jQuery;
409 // Is the DOM ready to be used? Set to true once it occurs.
412 // A counter to track how many items to wait for before
413 // the ready event fires. See #6781
416 // Hold (or release) the ready event
417 holdReady: function( hold ) {
421 jQuery.ready( true );
425 // Handle when the DOM is ready
426 ready: function( wait ) {
428 // Abort if there are pending holds or we're already ready
429 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
433 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
434 if ( !document.body ) {
435 return setTimeout( jQuery.ready );
438 // Remember that the DOM is ready
439 jQuery.isReady = true;
441 // If a normal DOM Ready event fired, decrement, and wait if need be
442 if ( wait !== true && --jQuery.readyWait > 0 ) {
446 // If there are functions bound, to execute
447 readyList.resolveWith( document, [ jQuery ] );
449 // Trigger any bound ready events
450 if ( jQuery.fn.trigger ) {
451 jQuery( document ).trigger("ready").off("ready");
455 // See test/unit/core.js for details concerning isFunction.
456 // Since version 1.3, DOM methods and functions like alert
457 // aren't supported. They return false on IE (#2968).
458 isFunction: function( obj ) {
459 return jQuery.type(obj) === "function";
462 isArray: Array.isArray || function( obj ) {
463 return jQuery.type(obj) === "array";
466 isWindow: function( obj ) {
467 /* jshint eqeqeq: false */
468 return obj != null && obj == obj.window;
471 isNumeric: function( obj ) {
472 return !isNaN( parseFloat(obj) ) && isFinite( obj );
475 type: function( obj ) {
477 return String( obj );
479 return typeof obj === "object" || typeof obj === "function" ?
480 class2type[ core_toString.call(obj) ] || "object" :
484 isPlainObject: function( obj ) {
487 // Must be an Object.
488 // Because of IE, we also have to check the presence of the constructor property.
489 // Make sure that DOM nodes and window objects don't pass through, as well
490 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
495 // Not own constructor property must be Object
496 if ( obj.constructor &&
497 !core_hasOwn.call(obj, "constructor") &&
498 !core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
502 // IE8,9 Will throw exceptions on certain host objects #9897
507 // Handle iteration over inherited properties before own properties.
508 if ( jQuery.support.ownLast ) {
510 return core_hasOwn.call( obj, key );
514 // Own properties are enumerated firstly, so to speed up,
515 // if last one is own, then all properties are own.
516 for ( key in obj ) {}
518 return key === undefined || core_hasOwn.call( obj, key );
521 isEmptyObject: function( obj ) {
523 for ( name in obj ) {
529 error: function( msg ) {
530 throw new Error( msg );
533 // data: string of html
534 // context (optional): If specified, the fragment will be created in this context, defaults to document
535 // keepScripts (optional): If true, will include scripts passed in the html string
536 parseHTML: function( data, context, keepScripts ) {
537 if ( !data || typeof data !== "string" ) {
540 if ( typeof context === "boolean" ) {
541 keepScripts = context;
544 context = context || document;
546 var parsed = rsingleTag.exec( data ),
547 scripts = !keepScripts && [];
551 return [ context.createElement( parsed[1] ) ];
554 parsed = jQuery.buildFragment( [ data ], context, scripts );
556 jQuery( scripts ).remove();
558 return jQuery.merge( [], parsed.childNodes );
561 parseJSON: function( data ) {
562 // Attempt to parse using the native JSON parser first
563 if ( window.JSON && window.JSON.parse ) {
564 return window.JSON.parse( data );
567 if ( data === null ) {
571 if ( typeof data === "string" ) {
573 // Make sure leading/trailing whitespace is removed (IE can't handle it)
574 data = jQuery.trim( data );
577 // Make sure the incoming data is actual JSON
578 // Logic borrowed from http://json.org/json2.js
579 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
580 .replace( rvalidtokens, "]" )
581 .replace( rvalidbraces, "")) ) {
583 return ( new Function( "return " + data ) )();
588 jQuery.error( "Invalid JSON: " + data );
591 // Cross-browser xml parsing
592 parseXML: function( data ) {
594 if ( !data || typeof data !== "string" ) {
598 if ( window.DOMParser ) { // Standard
599 tmp = new DOMParser();
600 xml = tmp.parseFromString( data , "text/xml" );
602 xml = new ActiveXObject( "Microsoft.XMLDOM" );
609 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
610 jQuery.error( "Invalid XML: " + data );
617 // Evaluates a script in a global context
618 // Workarounds based on findings by Jim Driscoll
619 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
620 globalEval: function( data ) {
621 if ( data && jQuery.trim( data ) ) {
622 // We use execScript on Internet Explorer
623 // We use an anonymous function so that context is window
624 // rather than jQuery in Firefox
625 ( window.execScript || function( data ) {
626 window[ "eval" ].call( window, data );
631 // Convert dashed to camelCase; used by the css and data modules
632 // Microsoft forgot to hump their vendor prefix (#9572)
633 camelCase: function( string ) {
634 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
637 nodeName: function( elem, name ) {
638 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
641 // args is for internal usage only
642 each: function( obj, callback, args ) {
646 isArray = isArraylike( obj );
650 for ( ; i < length; i++ ) {
651 value = callback.apply( obj[ i ], args );
653 if ( value === false ) {
659 value = callback.apply( obj[ i ], args );
661 if ( value === false ) {
667 // A special, fast, case for the most common use of each
670 for ( ; i < length; i++ ) {
671 value = callback.call( obj[ i ], i, obj[ i ] );
673 if ( value === false ) {
679 value = callback.call( obj[ i ], i, obj[ i ] );
681 if ( value === false ) {
691 // Use native String.trim function wherever possible
692 trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
694 return text == null ?
696 core_trim.call( text );
699 // Otherwise use our own trimming functionality
701 return text == null ?
703 ( text + "" ).replace( rtrim, "" );
706 // results is for internal usage only
707 makeArray: function( arr, results ) {
708 var ret = results || [];
711 if ( isArraylike( Object(arr) ) ) {
713 typeof arr === "string" ?
717 core_push.call( ret, arr );
724 inArray: function( elem, arr, i ) {
728 if ( core_indexOf ) {
729 return core_indexOf.call( arr, elem, i );
733 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
735 for ( ; i < len; i++ ) {
736 // Skip accessing in sparse arrays
737 if ( i in arr && arr[ i ] === elem ) {
746 merge: function( first, second ) {
747 var l = second.length,
751 if ( typeof l === "number" ) {
752 for ( ; j < l; j++ ) {
753 first[ i++ ] = second[ j ];
756 while ( second[j] !== undefined ) {
757 first[ i++ ] = second[ j++ ];
766 grep: function( elems, callback, inv ) {
770 length = elems.length;
773 // Go through the array, only saving the items
774 // that pass the validator function
775 for ( ; i < length; i++ ) {
776 retVal = !!callback( elems[ i ], i );
777 if ( inv !== retVal ) {
778 ret.push( elems[ i ] );
785 // arg is for internal usage only
786 map: function( elems, callback, arg ) {
789 length = elems.length,
790 isArray = isArraylike( elems ),
793 // Go through the array, translating each of the items to their
795 for ( ; i < length; i++ ) {
796 value = callback( elems[ i ], i, arg );
798 if ( value != null ) {
799 ret[ ret.length ] = value;
803 // Go through every key on the object,
806 value = callback( elems[ i ], i, arg );
808 if ( value != null ) {
809 ret[ ret.length ] = value;
814 // Flatten any nested arrays
815 return core_concat.apply( [], ret );
818 // A global GUID counter for objects
821 // Bind a function to a context, optionally partially applying any
823 proxy: function( fn, context ) {
824 var args, proxy, tmp;
826 if ( typeof context === "string" ) {
832 // Quick check to determine if target is callable, in the spec
833 // this throws a TypeError, but we will just return undefined.
834 if ( !jQuery.isFunction( fn ) ) {
839 args = core_slice.call( arguments, 2 );
841 return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
844 // Set the guid of unique handler to the same of original handler, so it can be removed
845 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
850 // Multifunctional method to get and set values of a collection
851 // The value/s can optionally be executed if it's a function
852 access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
854 length = elems.length,
858 if ( jQuery.type( key ) === "object" ) {
861 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
865 } else if ( value !== undefined ) {
868 if ( !jQuery.isFunction( value ) ) {
873 // Bulk operations run against the entire set
875 fn.call( elems, value );
878 // ...except when executing function values
881 fn = function( elem, key, value ) {
882 return bulk.call( jQuery( elem ), value );
888 for ( ; i < length; i++ ) {
889 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
900 length ? fn( elems[0], key ) : emptyGet;
904 return ( new Date() ).getTime();
907 // A method for quickly swapping in/out CSS properties to get correct calculations.
908 // Note: this method belongs to the css module but it's needed here for the support module.
909 // If support gets modularized, this method should be moved back to the css module.
910 swap: function( elem, options, callback, args ) {
914 // Remember the old values, and insert the new ones
915 for ( name in options ) {
916 old[ name ] = elem.style[ name ];
917 elem.style[ name ] = options[ name ];
920 ret = callback.apply( elem, args || [] );
922 // Revert the old values
923 for ( name in options ) {
924 elem.style[ name ] = old[ name ];
931 jQuery.ready.promise = function( obj ) {
934 readyList = jQuery.Deferred();
936 // Catch cases where $(document).ready() is called after the browser event has already occurred.
937 // we once tried to use readyState "interactive" here, but it caused issues like the one
938 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
939 if ( document.readyState === "complete" ) {
940 // Handle it asynchronously to allow scripts the opportunity to delay ready
941 setTimeout( jQuery.ready );
943 // Standards-based browsers support DOMContentLoaded
944 } else if ( document.addEventListener ) {
945 // Use the handy event callback
946 document.addEventListener( "DOMContentLoaded", completed, false );
948 // A fallback to window.onload, that will always work
949 window.addEventListener( "load", completed, false );
951 // If IE event model is used
953 // Ensure firing before onload, maybe late but safe also for iframes
954 document.attachEvent( "onreadystatechange", completed );
956 // A fallback to window.onload, that will always work
957 window.attachEvent( "onload", completed );
959 // If IE and not a frame
960 // continually check to see if the document is ready
964 top = window.frameElement == null && document.documentElement;
967 if ( top && top.doScroll ) {
968 (function doScrollCheck() {
969 if ( !jQuery.isReady ) {
972 // Use the trick by Diego Perini
973 // http://javascript.nwbox.com/IEContentLoaded/
974 top.doScroll("left");
976 return setTimeout( doScrollCheck, 50 );
979 // detach all dom ready events
982 // and execute any waiting functions
989 return readyList.promise( obj );
992 // Populate the class2type map
993 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
994 class2type[ "[object " + name + "]" ] = name.toLowerCase();
997 function isArraylike( obj ) {
998 var length = obj.length,
999 type = jQuery.type( obj );
1001 if ( jQuery.isWindow( obj ) ) {
1005 if ( obj.nodeType === 1 && length ) {
1009 return type === "array" || type !== "function" &&
1011 typeof length === "number" && length > 0 && ( length - 1 ) in obj );
1014 // All jQuery objects should point back to these
1015 rootjQuery = jQuery(document);
1017 * Sizzle CSS Selector Engine v1.10.2
1018 * http://sizzlejs.com/
1020 * Copyright 2013 jQuery Foundation, Inc. and other contributors
1021 * Released under the MIT license
1022 * http://jquery.org/license
1026 (function( window, undefined ) {
1038 // Local document vars
1048 // Instance-specific data
1049 expando = "sizzle" + -(new Date()),
1050 preferredDoc = window.document,
1053 classCache = createCache(),
1054 tokenCache = createCache(),
1055 compilerCache = createCache(),
1056 hasDuplicate = false,
1057 sortOrder = function( a, b ) {
1059 hasDuplicate = true;
1065 // General-purpose constants
1066 strundefined = typeof undefined,
1067 MAX_NEGATIVE = 1 << 31,
1070 hasOwn = ({}).hasOwnProperty,
1073 push_native = arr.push,
1076 // Use a stripped-down indexOf if we can't use a native one
1077 indexOf = arr.indexOf || function( elem ) {
1080 for ( ; i < len; i++ ) {
1081 if ( this[i] === elem ) {
1088 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
1090 // Regular expressions
1092 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
1093 whitespace = "[\\x20\\t\\r\\n\\f]",
1094 // http://www.w3.org/TR/css3-syntax/#characters
1095 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
1097 // Loosely modeled on CSS identifier characters
1098 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
1099 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
1100 identifier = characterEncoding.replace( "w", "w#" ),
1102 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
1103 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
1104 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
1106 // Prefer arguments quoted,
1107 // then not containing pseudos/brackets,
1108 // then attribute selectors/non-parenthetical expressions,
1109 // then anything else
1110 // These preferences are here to reduce the number of selectors
1111 // needing tokenize in the PSEUDO preFilter
1112 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
1114 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
1115 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
1117 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
1118 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
1120 rsibling = new RegExp( whitespace + "*[+~]" ),
1121 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*)" + whitespace + "*\\]", "g" ),
1123 rpseudo = new RegExp( pseudos ),
1124 ridentifier = new RegExp( "^" + identifier + "$" ),
1127 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
1128 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
1129 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
1130 "ATTR": new RegExp( "^" + attributes ),
1131 "PSEUDO": new RegExp( "^" + pseudos ),
1132 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
1133 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
1134 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
1135 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
1136 // For use in libraries implementing .is()
1137 // We use this for POS matching in `select`
1138 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
1139 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
1142 rnative = /^[^{]+\{\s*\[native \w/,
1144 // Easily-parseable/retrievable ID or TAG or CLASS selectors
1145 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
1147 rinputs = /^(?:input|select|textarea|button)$/i,
1152 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
1153 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
1154 funescape = function( _, escaped, escapedWhitespace ) {
1155 var high = "0x" + escaped - 0x10000;
1156 // NaN means non-codepoint
1158 // Workaround erroneous numeric interpretation of +"0x"
1159 return high !== high || escapedWhitespace ?
1163 String.fromCharCode( high + 0x10000 ) :
1164 // Supplemental Plane codepoint (surrogate pair)
1165 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
1168 // Optimize for push.apply( _, NodeList )
1171 (arr = slice.call( preferredDoc.childNodes )),
1172 preferredDoc.childNodes
1174 // Support: Android<4.0
1175 // Detect silently failing push.apply
1176 arr[ preferredDoc.childNodes.length ].nodeType;
1178 push = { apply: arr.length ?
1180 // Leverage slice if possible
1181 function( target, els ) {
1182 push_native.apply( target, slice.call(els) );
1186 // Otherwise append directly
1187 function( target, els ) {
1188 var j = target.length,
1190 // Can't trust NodeList.length
1191 while ( (target[j++] = els[i++]) ) {}
1192 target.length = j - 1;
1197 function Sizzle( selector, context, results, seed ) {
1198 var match, elem, m, nodeType,
1200 i, groups, old, nid, newContext, newSelector;
1202 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
1203 setDocument( context );
1206 context = context || document;
1207 results = results || [];
1209 if ( !selector || typeof selector !== "string" ) {
1213 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
1217 if ( documentIsHTML && !seed ) {
1220 if ( (match = rquickExpr.exec( selector )) ) {
1221 // Speed-up: Sizzle("#ID")
1222 if ( (m = match[1]) ) {
1223 if ( nodeType === 9 ) {
1224 elem = context.getElementById( m );
1225 // Check parentNode to catch when Blackberry 4.6 returns
1226 // nodes that are no longer in the document #6963
1227 if ( elem && elem.parentNode ) {
1228 // Handle the case where IE, Opera, and Webkit return items
1229 // by name instead of ID
1230 if ( elem.id === m ) {
1231 results.push( elem );
1238 // Context is not a document
1239 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
1240 contains( context, elem ) && elem.id === m ) {
1241 results.push( elem );
1246 // Speed-up: Sizzle("TAG")
1247 } else if ( match[2] ) {
1248 push.apply( results, context.getElementsByTagName( selector ) );
1251 // Speed-up: Sizzle(".CLASS")
1252 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
1253 push.apply( results, context.getElementsByClassName( m ) );
1259 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
1260 nid = old = expando;
1261 newContext = context;
1262 newSelector = nodeType === 9 && selector;
1264 // qSA works strangely on Element-rooted queries
1265 // We can work around this by specifying an extra ID on the root
1266 // and working up from there (Thanks to Andrew Dupont for the technique)
1267 // IE 8 doesn't work on object elements
1268 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
1269 groups = tokenize( selector );
1271 if ( (old = context.getAttribute("id")) ) {
1272 nid = old.replace( rescape, "\\$&" );
1274 context.setAttribute( "id", nid );
1276 nid = "[id='" + nid + "'] ";
1280 groups[i] = nid + toSelector( groups[i] );
1282 newContext = rsibling.test( selector ) && context.parentNode || context;
1283 newSelector = groups.join(",");
1286 if ( newSelector ) {
1288 push.apply( results,
1289 newContext.querySelectorAll( newSelector )
1295 context.removeAttribute("id");
1303 return select( selector.replace( rtrim, "$1" ), context, results, seed );
1307 * Create key-value caches of limited size
1308 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
1309 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
1310 * deleting the oldest entry
1312 function createCache() {
1315 function cache( key, value ) {
1316 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
1317 if ( keys.push( key += " " ) > Expr.cacheLength ) {
1318 // Only keep the most recent entries
1319 delete cache[ keys.shift() ];
1321 return (cache[ key ] = value);
1327 * Mark a function for special use by Sizzle
1328 * @param {Function} fn The function to mark
1330 function markFunction( fn ) {
1331 fn[ expando ] = true;
1336 * Support testing using an element
1337 * @param {Function} fn Passed the created div and expects a boolean result
1339 function assert( fn ) {
1340 var div = document.createElement("div");
1347 // Remove from its parent by default
1348 if ( div.parentNode ) {
1349 div.parentNode.removeChild( div );
1351 // release memory in IE
1357 * Adds the same handler for all of the specified attrs
1358 * @param {String} attrs Pipe-separated list of attributes
1359 * @param {Function} handler The method that will be applied
1361 function addHandle( attrs, handler ) {
1362 var arr = attrs.split("|"),
1366 Expr.attrHandle[ arr[i] ] = handler;
1371 * Checks document order of two siblings
1372 * @param {Element} a
1373 * @param {Element} b
1374 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
1376 function siblingCheck( a, b ) {
1378 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
1379 ( ~b.sourceIndex || MAX_NEGATIVE ) -
1380 ( ~a.sourceIndex || MAX_NEGATIVE );
1382 // Use IE sourceIndex if available on both nodes
1387 // Check if b follows a
1389 while ( (cur = cur.nextSibling) ) {
1400 * Returns a function to use in pseudos for input types
1401 * @param {String} type
1403 function createInputPseudo( type ) {
1404 return function( elem ) {
1405 var name = elem.nodeName.toLowerCase();
1406 return name === "input" && elem.type === type;
1411 * Returns a function to use in pseudos for buttons
1412 * @param {String} type
1414 function createButtonPseudo( type ) {
1415 return function( elem ) {
1416 var name = elem.nodeName.toLowerCase();
1417 return (name === "input" || name === "button") && elem.type === type;
1422 * Returns a function to use in pseudos for positionals
1423 * @param {Function} fn
1425 function createPositionalPseudo( fn ) {
1426 return markFunction(function( argument ) {
1427 argument = +argument;
1428 return markFunction(function( seed, matches ) {
1430 matchIndexes = fn( [], seed.length, argument ),
1431 i = matchIndexes.length;
1433 // Match elements found at the specified indexes
1435 if ( seed[ (j = matchIndexes[i]) ] ) {
1436 seed[j] = !(matches[j] = seed[j]);
1445 * @param {Element|Object} elem An element or a document
1447 isXML = Sizzle.isXML = function( elem ) {
1448 // documentElement is verified for cases where it doesn't yet exist
1449 // (such as loading iframes in IE - #4833)
1450 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1451 return documentElement ? documentElement.nodeName !== "HTML" : false;
1454 // Expose support vars for convenience
1455 support = Sizzle.support = {};
1458 * Sets document-related variables once based on the current document
1459 * @param {Element|Object} [doc] An element or document object to use to set the document
1460 * @returns {Object} Returns the current document
1462 setDocument = Sizzle.setDocument = function( node ) {
1463 var doc = node ? node.ownerDocument || node : preferredDoc,
1464 parent = doc.defaultView;
1466 // If no document and documentElement is available, return
1467 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1473 docElem = doc.documentElement;
1476 documentIsHTML = !isXML( doc );
1479 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1480 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1481 // IE6-8 do not support the defaultView property so parent will be undefined
1482 if ( parent && parent.attachEvent && parent !== parent.top ) {
1483 parent.attachEvent( "onbeforeunload", function() {
1489 ---------------------------------------------------------------------- */
1492 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1493 support.attributes = assert(function( div ) {
1494 div.className = "i";
1495 return !div.getAttribute("className");
1499 ---------------------------------------------------------------------- */
1501 // Check if getElementsByTagName("*") returns only elements
1502 support.getElementsByTagName = assert(function( div ) {
1503 div.appendChild( doc.createComment("") );
1504 return !div.getElementsByTagName("*").length;
1507 // Check if getElementsByClassName can be trusted
1508 support.getElementsByClassName = assert(function( div ) {
1509 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1511 // Support: Safari<4
1512 // Catch class over-caching
1513 div.firstChild.className = "i";
1514 // Support: Opera<10
1515 // Catch gEBCN failure to find non-leading classes
1516 return div.getElementsByClassName("i").length === 2;
1520 // Check if getElementById returns elements by name
1521 // The broken getElementById methods don't pick up programatically-set names,
1522 // so use a roundabout getElementsByName test
1523 support.getById = assert(function( div ) {
1524 docElem.appendChild( div ).id = expando;
1525 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1528 // ID find and filter
1529 if ( support.getById ) {
1530 Expr.find["ID"] = function( id, context ) {
1531 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
1532 var m = context.getElementById( id );
1533 // Check parentNode to catch when Blackberry 4.6 returns
1534 // nodes that are no longer in the document #6963
1535 return m && m.parentNode ? [m] : [];
1538 Expr.filter["ID"] = function( id ) {
1539 var attrId = id.replace( runescape, funescape );
1540 return function( elem ) {
1541 return elem.getAttribute("id") === attrId;
1546 // getElementById is not reliable as a find shortcut
1547 delete Expr.find["ID"];
1549 Expr.filter["ID"] = function( id ) {
1550 var attrId = id.replace( runescape, funescape );
1551 return function( elem ) {
1552 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
1553 return node && node.value === attrId;
1559 Expr.find["TAG"] = support.getElementsByTagName ?
1560 function( tag, context ) {
1561 if ( typeof context.getElementsByTagName !== strundefined ) {
1562 return context.getElementsByTagName( tag );
1565 function( tag, context ) {
1569 results = context.getElementsByTagName( tag );
1571 // Filter out possible comments
1572 if ( tag === "*" ) {
1573 while ( (elem = results[i++]) ) {
1574 if ( elem.nodeType === 1 ) {
1585 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1586 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1587 return context.getElementsByClassName( className );
1591 /* QSA/matchesSelector
1592 ---------------------------------------------------------------------- */
1594 // QSA and matchesSelector support
1596 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1599 // qSa(:focus) reports false when true (Chrome 21)
1600 // We allow this because of a bug in IE8/9 that throws an error
1601 // whenever `document.activeElement` is accessed on an iframe
1602 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1603 // See http://bugs.jquery.com/ticket/13378
1606 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1608 // Regex strategy adopted from Diego Perini
1609 assert(function( div ) {
1610 // Select is set to empty string on purpose
1611 // This is to test IE's treatment of not explicitly
1612 // setting a boolean content attribute,
1613 // since its presence should be enough
1614 // http://bugs.jquery.com/ticket/12359
1615 div.innerHTML = "<select><option selected=''></option></select>";
1618 // Boolean attributes and "value" are not treated correctly
1619 if ( !div.querySelectorAll("[selected]").length ) {
1620 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1623 // Webkit/Opera - :checked should return selected option elements
1624 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1625 // IE8 throws error here and will not see later tests
1626 if ( !div.querySelectorAll(":checked").length ) {
1627 rbuggyQSA.push(":checked");
1631 assert(function( div ) {
1633 // Support: Opera 10-12/IE8
1634 // ^= $= *= and empty values
1635 // Should not select anything
1636 // Support: Windows 8 Native Apps
1637 // The type attribute is restricted during .innerHTML assignment
1638 var input = doc.createElement("input");
1639 input.setAttribute( "type", "hidden" );
1640 div.appendChild( input ).setAttribute( "t", "" );
1642 if ( div.querySelectorAll("[t^='']").length ) {
1643 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1646 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1647 // IE8 throws error here and will not see later tests
1648 if ( !div.querySelectorAll(":enabled").length ) {
1649 rbuggyQSA.push( ":enabled", ":disabled" );
1652 // Opera 10-11 does not throw on post-comma invalid pseudos
1653 div.querySelectorAll("*,:x");
1654 rbuggyQSA.push(",.*:");
1658 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
1659 docElem.mozMatchesSelector ||
1660 docElem.oMatchesSelector ||
1661 docElem.msMatchesSelector) )) ) {
1663 assert(function( div ) {
1664 // Check to see if it's possible to do matchesSelector
1665 // on a disconnected node (IE 9)
1666 support.disconnectedMatch = matches.call( div, "div" );
1668 // This should fail with an exception
1669 // Gecko does not error, returns false instead
1670 matches.call( div, "[s!='']:x" );
1671 rbuggyMatches.push( "!=", pseudos );
1675 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1676 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1679 ---------------------------------------------------------------------- */
1681 // Element contains another
1682 // Purposefully does not implement inclusive descendent
1683 // As in, an element does not contain itself
1684 contains = rnative.test( docElem.contains ) || docElem.compareDocumentPosition ?
1686 var adown = a.nodeType === 9 ? a.documentElement : a,
1687 bup = b && b.parentNode;
1688 return a === bup || !!( bup && bup.nodeType === 1 && (
1690 adown.contains( bup ) :
1691 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1696 while ( (b = b.parentNode) ) {
1706 ---------------------------------------------------------------------- */
1708 // Document order sorting
1709 sortOrder = docElem.compareDocumentPosition ?
1712 // Flag for duplicate removal
1714 hasDuplicate = true;
1718 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
1721 // Disconnected nodes
1723 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1725 // Choose the first element that is related to our preferred document
1726 if ( a === doc || contains(preferredDoc, a) ) {
1729 if ( b === doc || contains(preferredDoc, b) ) {
1733 // Maintain original order
1735 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1739 return compare & 4 ? -1 : 1;
1742 // Not directly comparable, sort on existence of method
1743 return a.compareDocumentPosition ? -1 : 1;
1753 // Exit early if the nodes are identical
1755 hasDuplicate = true;
1758 // Parentless nodes are either documents or disconnected
1759 } else if ( !aup || !bup ) {
1760 return a === doc ? -1 :
1765 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1768 // If the nodes are siblings, we can do a quick check
1769 } else if ( aup === bup ) {
1770 return siblingCheck( a, b );
1773 // Otherwise we need full lists of their ancestors for comparison
1775 while ( (cur = cur.parentNode) ) {
1779 while ( (cur = cur.parentNode) ) {
1783 // Walk down the tree looking for a discrepancy
1784 while ( ap[i] === bp[i] ) {
1789 // Do a sibling check if the nodes have a common ancestor
1790 siblingCheck( ap[i], bp[i] ) :
1792 // Otherwise nodes in our document sort first
1793 ap[i] === preferredDoc ? -1 :
1794 bp[i] === preferredDoc ? 1 :
1801 Sizzle.matches = function( expr, elements ) {
1802 return Sizzle( expr, null, null, elements );
1805 Sizzle.matchesSelector = function( elem, expr ) {
1806 // Set document vars if needed
1807 if ( ( elem.ownerDocument || elem ) !== document ) {
1808 setDocument( elem );
1811 // Make sure that attribute selectors are quoted
1812 expr = expr.replace( rattributeQuotes, "='$1']" );
1814 if ( support.matchesSelector && documentIsHTML &&
1815 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1816 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1819 var ret = matches.call( elem, expr );
1821 // IE 9's matchesSelector returns false on disconnected nodes
1822 if ( ret || support.disconnectedMatch ||
1823 // As well, disconnected nodes are said to be in a document
1825 elem.document && elem.document.nodeType !== 11 ) {
1831 return Sizzle( expr, document, null, [elem] ).length > 0;
1834 Sizzle.contains = function( context, elem ) {
1835 // Set document vars if needed
1836 if ( ( context.ownerDocument || context ) !== document ) {
1837 setDocument( context );
1839 return contains( context, elem );
1842 Sizzle.attr = function( elem, name ) {
1843 // Set document vars if needed
1844 if ( ( elem.ownerDocument || elem ) !== document ) {
1845 setDocument( elem );
1848 var fn = Expr.attrHandle[ name.toLowerCase() ],
1849 // Don't get fooled by Object.prototype properties (jQuery #13807)
1850 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1851 fn( elem, name, !documentIsHTML ) :
1854 return val === undefined ?
1855 support.attributes || !documentIsHTML ?
1856 elem.getAttribute( name ) :
1857 (val = elem.getAttributeNode(name)) && val.specified ?
1863 Sizzle.error = function( msg ) {
1864 throw new Error( "Syntax error, unrecognized expression: " + msg );
1868 * Document sorting and removing duplicates
1869 * @param {ArrayLike} results
1871 Sizzle.uniqueSort = function( results ) {
1877 // Unless we *know* we can detect duplicates, assume their presence
1878 hasDuplicate = !support.detectDuplicates;
1879 sortInput = !support.sortStable && results.slice( 0 );
1880 results.sort( sortOrder );
1882 if ( hasDuplicate ) {
1883 while ( (elem = results[i++]) ) {
1884 if ( elem === results[ i ] ) {
1885 j = duplicates.push( i );
1889 results.splice( duplicates[ j ], 1 );
1897 * Utility function for retrieving the text value of an array of DOM nodes
1898 * @param {Array|Element} elem
1900 getText = Sizzle.getText = function( elem ) {
1904 nodeType = elem.nodeType;
1907 // If no nodeType, this is expected to be an array
1908 for ( ; (node = elem[i]); i++ ) {
1909 // Do not traverse comment nodes
1910 ret += getText( node );
1912 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1913 // Use textContent for elements
1914 // innerText usage removed for consistency of new lines (see #11153)
1915 if ( typeof elem.textContent === "string" ) {
1916 return elem.textContent;
1918 // Traverse its children
1919 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1920 ret += getText( elem );
1923 } else if ( nodeType === 3 || nodeType === 4 ) {
1924 return elem.nodeValue;
1926 // Do not include comment or processing instruction nodes
1931 Expr = Sizzle.selectors = {
1933 // Can be adjusted by the user
1936 createPseudo: markFunction,
1945 ">": { dir: "parentNode", first: true },
1946 " ": { dir: "parentNode" },
1947 "+": { dir: "previousSibling", first: true },
1948 "~": { dir: "previousSibling" }
1952 "ATTR": function( match ) {
1953 match[1] = match[1].replace( runescape, funescape );
1955 // Move the given value to match[3] whether quoted or unquoted
1956 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
1958 if ( match[2] === "~=" ) {
1959 match[3] = " " + match[3] + " ";
1962 return match.slice( 0, 4 );
1965 "CHILD": function( match ) {
1966 /* matches from matchExpr["CHILD"]
1967 1 type (only|nth|...)
1968 2 what (child|of-type)
1969 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1970 4 xn-component of xn+y argument ([+-]?\d*n|)
1971 5 sign of xn-component
1973 7 sign of y-component
1976 match[1] = match[1].toLowerCase();
1978 if ( match[1].slice( 0, 3 ) === "nth" ) {
1979 // nth-* requires argument
1981 Sizzle.error( match[0] );
1984 // numeric x and y parameters for Expr.filter.CHILD
1985 // remember that false/true cast respectively to 0/1
1986 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1987 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1989 // other types prohibit arguments
1990 } else if ( match[3] ) {
1991 Sizzle.error( match[0] );
1997 "PSEUDO": function( match ) {
1999 unquoted = !match[5] && match[2];
2001 if ( matchExpr["CHILD"].test( match[0] ) ) {
2005 // Accept quoted arguments as-is
2006 if ( match[3] && match[4] !== undefined ) {
2007 match[2] = match[4];
2009 // Strip excess characters from unquoted arguments
2010 } else if ( unquoted && rpseudo.test( unquoted ) &&
2011 // Get excess from tokenize (recursively)
2012 (excess = tokenize( unquoted, true )) &&
2013 // advance to the next closing parenthesis
2014 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
2016 // excess is a negative index
2017 match[0] = match[0].slice( 0, excess );
2018 match[2] = unquoted.slice( 0, excess );
2021 // Return only captures needed by the pseudo filter method (type and argument)
2022 return match.slice( 0, 3 );
2028 "TAG": function( nodeNameSelector ) {
2029 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
2030 return nodeNameSelector === "*" ?
2031 function() { return true; } :
2033 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
2037 "CLASS": function( className ) {
2038 var pattern = classCache[ className + " " ];
2041 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
2042 classCache( className, function( elem ) {
2043 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
2047 "ATTR": function( name, operator, check ) {
2048 return function( elem ) {
2049 var result = Sizzle.attr( elem, name );
2051 if ( result == null ) {
2052 return operator === "!=";
2060 return operator === "=" ? result === check :
2061 operator === "!=" ? result !== check :
2062 operator === "^=" ? check && result.indexOf( check ) === 0 :
2063 operator === "*=" ? check && result.indexOf( check ) > -1 :
2064 operator === "$=" ? check && result.slice( -check.length ) === check :
2065 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
2066 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
2071 "CHILD": function( type, what, argument, first, last ) {
2072 var simple = type.slice( 0, 3 ) !== "nth",
2073 forward = type.slice( -4 ) !== "last",
2074 ofType = what === "of-type";
2076 return first === 1 && last === 0 ?
2078 // Shortcut for :nth-*(n)
2080 return !!elem.parentNode;
2083 function( elem, context, xml ) {
2084 var cache, outerCache, node, diff, nodeIndex, start,
2085 dir = simple !== forward ? "nextSibling" : "previousSibling",
2086 parent = elem.parentNode,
2087 name = ofType && elem.nodeName.toLowerCase(),
2088 useCache = !xml && !ofType;
2092 // :(first|last|only)-(child|of-type)
2096 while ( (node = node[ dir ]) ) {
2097 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
2101 // Reverse direction for :only-* (if we haven't yet done so)
2102 start = dir = type === "only" && !start && "nextSibling";
2107 start = [ forward ? parent.firstChild : parent.lastChild ];
2109 // non-xml :nth-child(...) stores cache data on `parent`
2110 if ( forward && useCache ) {
2111 // Seek `elem` from a previously-cached index
2112 outerCache = parent[ expando ] || (parent[ expando ] = {});
2113 cache = outerCache[ type ] || [];
2114 nodeIndex = cache[0] === dirruns && cache[1];
2115 diff = cache[0] === dirruns && cache[2];
2116 node = nodeIndex && parent.childNodes[ nodeIndex ];
2118 while ( (node = ++nodeIndex && node && node[ dir ] ||
2120 // Fallback to seeking `elem` from the start
2121 (diff = nodeIndex = 0) || start.pop()) ) {
2123 // When found, cache indexes on `parent` and break
2124 if ( node.nodeType === 1 && ++diff && node === elem ) {
2125 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
2130 // Use previously-cached element index if available
2131 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
2134 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
2136 // Use the same loop as above to seek `elem` from the start
2137 while ( (node = ++nodeIndex && node && node[ dir ] ||
2138 (diff = nodeIndex = 0) || start.pop()) ) {
2140 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
2141 // Cache the index of each encountered element
2143 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
2146 if ( node === elem ) {
2153 // Incorporate the offset, then check against cycle size
2155 return diff === first || ( diff % first === 0 && diff / first >= 0 );
2160 "PSEUDO": function( pseudo, argument ) {
2161 // pseudo-class names are case-insensitive
2162 // http://www.w3.org/TR/selectors/#pseudo-classes
2163 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
2164 // Remember that setFilters inherits from pseudos
2166 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
2167 Sizzle.error( "unsupported pseudo: " + pseudo );
2169 // The user may use createPseudo to indicate that
2170 // arguments are needed to create the filter function
2171 // just as Sizzle does
2172 if ( fn[ expando ] ) {
2173 return fn( argument );
2176 // But maintain support for old signatures
2177 if ( fn.length > 1 ) {
2178 args = [ pseudo, pseudo, "", argument ];
2179 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
2180 markFunction(function( seed, matches ) {
2182 matched = fn( seed, argument ),
2185 idx = indexOf.call( seed, matched[i] );
2186 seed[ idx ] = !( matches[ idx ] = matched[i] );
2190 return fn( elem, 0, args );
2199 // Potentially complex pseudos
2200 "not": markFunction(function( selector ) {
2201 // Trim the selector passed to compile
2202 // to avoid treating leading and trailing
2203 // spaces as combinators
2206 matcher = compile( selector.replace( rtrim, "$1" ) );
2208 return matcher[ expando ] ?
2209 markFunction(function( seed, matches, context, xml ) {
2211 unmatched = matcher( seed, null, xml, [] ),
2214 // Match elements unmatched by `matcher`
2216 if ( (elem = unmatched[i]) ) {
2217 seed[i] = !(matches[i] = elem);
2221 function( elem, context, xml ) {
2223 matcher( input, null, xml, results );
2224 return !results.pop();
2228 "has": markFunction(function( selector ) {
2229 return function( elem ) {
2230 return Sizzle( selector, elem ).length > 0;
2234 "contains": markFunction(function( text ) {
2235 return function( elem ) {
2236 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
2240 // "Whether an element is represented by a :lang() selector
2241 // is based solely on the element's language value
2242 // being equal to the identifier C,
2243 // or beginning with the identifier C immediately followed by "-".
2244 // The matching of C against the element's language value is performed case-insensitively.
2245 // The identifier C does not have to be a valid language name."
2246 // http://www.w3.org/TR/selectors/#lang-pseudo
2247 "lang": markFunction( function( lang ) {
2248 // lang value must be a valid identifier
2249 if ( !ridentifier.test(lang || "") ) {
2250 Sizzle.error( "unsupported lang: " + lang );
2252 lang = lang.replace( runescape, funescape ).toLowerCase();
2253 return function( elem ) {
2256 if ( (elemLang = documentIsHTML ?
2258 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
2260 elemLang = elemLang.toLowerCase();
2261 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
2263 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
2269 "target": function( elem ) {
2270 var hash = window.location && window.location.hash;
2271 return hash && hash.slice( 1 ) === elem.id;
2274 "root": function( elem ) {
2275 return elem === docElem;
2278 "focus": function( elem ) {
2279 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
2282 // Boolean properties
2283 "enabled": function( elem ) {
2284 return elem.disabled === false;
2287 "disabled": function( elem ) {
2288 return elem.disabled === true;
2291 "checked": function( elem ) {
2292 // In CSS3, :checked should return both checked and selected elements
2293 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2294 var nodeName = elem.nodeName.toLowerCase();
2295 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
2298 "selected": function( elem ) {
2299 // Accessing this property makes selected-by-default
2300 // options in Safari work properly
2301 if ( elem.parentNode ) {
2302 elem.parentNode.selectedIndex;
2305 return elem.selected === true;
2309 "empty": function( elem ) {
2310 // http://www.w3.org/TR/selectors/#empty-pseudo
2311 // :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
2312 // not comment, processing instructions, or others
2313 // Thanks to Diego Perini for the nodeName shortcut
2314 // Greater than "@" means alpha characters (specifically not starting with "#" or "?")
2315 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
2316 if ( elem.nodeName > "@" || elem.nodeType === 3 || elem.nodeType === 4 ) {
2323 "parent": function( elem ) {
2324 return !Expr.pseudos["empty"]( elem );
2327 // Element/input types
2328 "header": function( elem ) {
2329 return rheader.test( elem.nodeName );
2332 "input": function( elem ) {
2333 return rinputs.test( elem.nodeName );
2336 "button": function( elem ) {
2337 var name = elem.nodeName.toLowerCase();
2338 return name === "input" && elem.type === "button" || name === "button";
2341 "text": function( elem ) {
2343 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
2344 // use getAttribute instead to test this case
2345 return elem.nodeName.toLowerCase() === "input" &&
2346 elem.type === "text" &&
2347 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === elem.type );
2350 // Position-in-collection
2351 "first": createPositionalPseudo(function() {
2355 "last": createPositionalPseudo(function( matchIndexes, length ) {
2356 return [ length - 1 ];
2359 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
2360 return [ argument < 0 ? argument + length : argument ];
2363 "even": createPositionalPseudo(function( matchIndexes, length ) {
2365 for ( ; i < length; i += 2 ) {
2366 matchIndexes.push( i );
2368 return matchIndexes;
2371 "odd": createPositionalPseudo(function( matchIndexes, length ) {
2373 for ( ; i < length; i += 2 ) {
2374 matchIndexes.push( i );
2376 return matchIndexes;
2379 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2380 var i = argument < 0 ? argument + length : argument;
2381 for ( ; --i >= 0; ) {
2382 matchIndexes.push( i );
2384 return matchIndexes;
2387 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2388 var i = argument < 0 ? argument + length : argument;
2389 for ( ; ++i < length; ) {
2390 matchIndexes.push( i );
2392 return matchIndexes;
2397 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2399 // Add button/input type pseudos
2400 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2401 Expr.pseudos[ i ] = createInputPseudo( i );
2403 for ( i in { submit: true, reset: true } ) {
2404 Expr.pseudos[ i ] = createButtonPseudo( i );
2407 // Easy API for creating new setFilters
2408 function setFilters() {}
2409 setFilters.prototype = Expr.filters = Expr.pseudos;
2410 Expr.setFilters = new setFilters();
2412 function tokenize( selector, parseOnly ) {
2413 var matched, match, tokens, type,
2414 soFar, groups, preFilters,
2415 cached = tokenCache[ selector + " " ];
2418 return parseOnly ? 0 : cached.slice( 0 );
2423 preFilters = Expr.preFilter;
2427 // Comma and first run
2428 if ( !matched || (match = rcomma.exec( soFar )) ) {
2430 // Don't consume trailing commas as valid
2431 soFar = soFar.slice( match[0].length ) || soFar;
2433 groups.push( tokens = [] );
2439 if ( (match = rcombinators.exec( soFar )) ) {
2440 matched = match.shift();
2443 // Cast descendant combinators to space
2444 type: match[0].replace( rtrim, " " )
2446 soFar = soFar.slice( matched.length );
2450 for ( type in Expr.filter ) {
2451 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2452 (match = preFilters[ type ]( match ))) ) {
2453 matched = match.shift();
2459 soFar = soFar.slice( matched.length );
2468 // Return the length of the invalid excess
2469 // if we're just parsing
2470 // Otherwise, throw an error or return tokens
2474 Sizzle.error( selector ) :
2476 tokenCache( selector, groups ).slice( 0 );
2479 function toSelector( tokens ) {
2481 len = tokens.length,
2483 for ( ; i < len; i++ ) {
2484 selector += tokens[i].value;
2489 function addCombinator( matcher, combinator, base ) {
2490 var dir = combinator.dir,
2491 checkNonElements = base && dir === "parentNode",
2494 return combinator.first ?
2495 // Check against closest ancestor/preceding element
2496 function( elem, context, xml ) {
2497 while ( (elem = elem[ dir ]) ) {
2498 if ( elem.nodeType === 1 || checkNonElements ) {
2499 return matcher( elem, context, xml );
2504 // Check against all ancestor/preceding elements
2505 function( elem, context, xml ) {
2506 var data, cache, outerCache,
2507 dirkey = dirruns + " " + doneName;
2509 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2511 while ( (elem = elem[ dir ]) ) {
2512 if ( elem.nodeType === 1 || checkNonElements ) {
2513 if ( matcher( elem, context, xml ) ) {
2519 while ( (elem = elem[ dir ]) ) {
2520 if ( elem.nodeType === 1 || checkNonElements ) {
2521 outerCache = elem[ expando ] || (elem[ expando ] = {});
2522 if ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {
2523 if ( (data = cache[1]) === true || data === cachedruns ) {
2524 return data === true;
2527 cache = outerCache[ dir ] = [ dirkey ];
2528 cache[1] = matcher( elem, context, xml ) || cachedruns;
2529 if ( cache[1] === true ) {
2539 function elementMatcher( matchers ) {
2540 return matchers.length > 1 ?
2541 function( elem, context, xml ) {
2542 var i = matchers.length;
2544 if ( !matchers[i]( elem, context, xml ) ) {
2553 function condense( unmatched, map, filter, context, xml ) {
2557 len = unmatched.length,
2558 mapped = map != null;
2560 for ( ; i < len; i++ ) {
2561 if ( (elem = unmatched[i]) ) {
2562 if ( !filter || filter( elem, context, xml ) ) {
2563 newUnmatched.push( elem );
2571 return newUnmatched;
2574 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2575 if ( postFilter && !postFilter[ expando ] ) {
2576 postFilter = setMatcher( postFilter );
2578 if ( postFinder && !postFinder[ expando ] ) {
2579 postFinder = setMatcher( postFinder, postSelector );
2581 return markFunction(function( seed, results, context, xml ) {
2585 preexisting = results.length,
2587 // Get initial elements from seed or context
2588 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2590 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2591 matcherIn = preFilter && ( seed || !selector ) ?
2592 condense( elems, preMap, preFilter, context, xml ) :
2595 matcherOut = matcher ?
2596 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2597 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2599 // ...intermediate processing is necessary
2602 // ...otherwise use results directly
2606 // Find primary matches
2608 matcher( matcherIn, matcherOut, context, xml );
2613 temp = condense( matcherOut, postMap );
2614 postFilter( temp, [], context, xml );
2616 // Un-match failing elements by moving them back to matcherIn
2619 if ( (elem = temp[i]) ) {
2620 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2626 if ( postFinder || preFilter ) {
2628 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2630 i = matcherOut.length;
2632 if ( (elem = matcherOut[i]) ) {
2633 // Restore matcherIn since elem is not yet a final match
2634 temp.push( (matcherIn[i] = elem) );
2637 postFinder( null, (matcherOut = []), temp, xml );
2640 // Move matched elements from seed to results to keep them synchronized
2641 i = matcherOut.length;
2643 if ( (elem = matcherOut[i]) &&
2644 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2646 seed[temp] = !(results[temp] = elem);
2651 // Add elements to results, through postFinder if defined
2653 matcherOut = condense(
2654 matcherOut === results ?
2655 matcherOut.splice( preexisting, matcherOut.length ) :
2659 postFinder( null, results, matcherOut, xml );
2661 push.apply( results, matcherOut );
2667 function matcherFromTokens( tokens ) {
2668 var checkContext, matcher, j,
2669 len = tokens.length,
2670 leadingRelative = Expr.relative[ tokens[0].type ],
2671 implicitRelative = leadingRelative || Expr.relative[" "],
2672 i = leadingRelative ? 1 : 0,
2674 // The foundational matcher ensures that elements are reachable from top-level context(s)
2675 matchContext = addCombinator( function( elem ) {
2676 return elem === checkContext;
2677 }, implicitRelative, true ),
2678 matchAnyContext = addCombinator( function( elem ) {
2679 return indexOf.call( checkContext, elem ) > -1;
2680 }, implicitRelative, true ),
2681 matchers = [ function( elem, context, xml ) {
2682 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2683 (checkContext = context).nodeType ?
2684 matchContext( elem, context, xml ) :
2685 matchAnyContext( elem, context, xml ) );
2688 for ( ; i < len; i++ ) {
2689 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2690 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2692 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2694 // Return special upon seeing a positional matcher
2695 if ( matcher[ expando ] ) {
2696 // Find the next relative operator (if any) for proper handling
2698 for ( ; j < len; j++ ) {
2699 if ( Expr.relative[ tokens[j].type ] ) {
2704 i > 1 && elementMatcher( matchers ),
2705 i > 1 && toSelector(
2706 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2707 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2708 ).replace( rtrim, "$1" ),
2710 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2711 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2712 j < len && toSelector( tokens )
2715 matchers.push( matcher );
2719 return elementMatcher( matchers );
2722 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2723 // A counter to specify which element is currently being matched
2724 var matcherCachedRuns = 0,
2725 bySet = setMatchers.length > 0,
2726 byElement = elementMatchers.length > 0,
2727 superMatcher = function( seed, context, xml, results, expandContext ) {
2728 var elem, j, matcher,
2732 unmatched = seed && [],
2733 outermost = expandContext != null,
2734 contextBackup = outermostContext,
2735 // We must always have either seed elements or context
2736 elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
2737 // Use integer dirruns iff this is the outermost matcher
2738 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);
2741 outermostContext = context !== document && context;
2742 cachedruns = matcherCachedRuns;
2745 // Add elements passing elementMatchers directly to results
2746 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2747 for ( ; (elem = elems[i]) != null; i++ ) {
2748 if ( byElement && elem ) {
2750 while ( (matcher = elementMatchers[j++]) ) {
2751 if ( matcher( elem, context, xml ) ) {
2752 results.push( elem );
2757 dirruns = dirrunsUnique;
2758 cachedruns = ++matcherCachedRuns;
2762 // Track unmatched elements for set filters
2764 // They will have gone through all possible matchers
2765 if ( (elem = !matcher && elem) ) {
2769 // Lengthen the array for every element, matched or not
2771 unmatched.push( elem );
2776 // Apply set filters to unmatched elements
2778 if ( bySet && i !== matchedCount ) {
2780 while ( (matcher = setMatchers[j++]) ) {
2781 matcher( unmatched, setMatched, context, xml );
2785 // Reintegrate element matches to eliminate the need for sorting
2786 if ( matchedCount > 0 ) {
2788 if ( !(unmatched[i] || setMatched[i]) ) {
2789 setMatched[i] = pop.call( results );
2794 // Discard index placeholder values to get only actual matches
2795 setMatched = condense( setMatched );
2798 // Add matches to results
2799 push.apply( results, setMatched );
2801 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2802 if ( outermost && !seed && setMatched.length > 0 &&
2803 ( matchedCount + setMatchers.length ) > 1 ) {
2805 Sizzle.uniqueSort( results );
2809 // Override manipulation of globals by nested matchers
2811 dirruns = dirrunsUnique;
2812 outermostContext = contextBackup;
2819 markFunction( superMatcher ) :
2823 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
2826 elementMatchers = [],
2827 cached = compilerCache[ selector + " " ];
2830 // Generate a function of recursive functions that can be used to check each element
2832 group = tokenize( selector );
2836 cached = matcherFromTokens( group[i] );
2837 if ( cached[ expando ] ) {
2838 setMatchers.push( cached );
2840 elementMatchers.push( cached );
2844 // Cache the compiled function
2845 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2850 function multipleContexts( selector, contexts, results ) {
2852 len = contexts.length;
2853 for ( ; i < len; i++ ) {
2854 Sizzle( selector, contexts[i], results );
2859 function select( selector, context, results, seed ) {
2860 var i, tokens, token, type, find,
2861 match = tokenize( selector );
2864 // Try to minimize operations if there is only one group
2865 if ( match.length === 1 ) {
2867 // Take a shortcut and set the context if the root selector is an ID
2868 tokens = match[0] = match[0].slice( 0 );
2869 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2870 support.getById && context.nodeType === 9 && documentIsHTML &&
2871 Expr.relative[ tokens[1].type ] ) {
2873 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2877 selector = selector.slice( tokens.shift().value.length );
2880 // Fetch a seed set for right-to-left matching
2881 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2885 // Abort if we hit a combinator
2886 if ( Expr.relative[ (type = token.type) ] ) {
2889 if ( (find = Expr.find[ type ]) ) {
2890 // Search, expanding context for leading sibling combinators
2892 token.matches[0].replace( runescape, funescape ),
2893 rsibling.test( tokens[0].type ) && context.parentNode || context
2896 // If seed is empty or no tokens remain, we can return early
2897 tokens.splice( i, 1 );
2898 selector = seed.length && toSelector( tokens );
2900 push.apply( results, seed );
2911 // Compile and execute a filtering function
2912 // Provide `match` to avoid retokenization if we modified the selector above
2913 compile( selector, match )(
2918 rsibling.test( selector )
2923 // One-time assignments
2926 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2928 // Support: Chrome<14
2929 // Always assume duplicates if they aren't passed to the comparison function
2930 support.detectDuplicates = hasDuplicate;
2932 // Initialize against the default document
2935 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2936 // Detached nodes confoundingly follow *each other*
2937 support.sortDetached = assert(function( div1 ) {
2938 // Should return 1, but returns 4 (following)
2939 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2943 // Prevent attribute/property "interpolation"
2944 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2945 if ( !assert(function( div ) {
2946 div.innerHTML = "<a href='#'></a>";
2947 return div.firstChild.getAttribute("href") === "#" ;
2949 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2951 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2957 // Use defaultValue in place of getAttribute("value")
2958 if ( !support.attributes || !assert(function( div ) {
2959 div.innerHTML = "<input/>";
2960 div.firstChild.setAttribute( "value", "" );
2961 return div.firstChild.getAttribute( "value" ) === "";
2963 addHandle( "value", function( elem, name, isXML ) {
2964 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2965 return elem.defaultValue;
2971 // Use getAttributeNode to fetch booleans when getAttribute lies
2972 if ( !assert(function( div ) {
2973 return div.getAttribute("disabled") == null;
2975 addHandle( booleans, function( elem, name, isXML ) {
2978 return (val = elem.getAttributeNode( name )) && val.specified ?
2980 elem[ name ] === true ? name.toLowerCase() : null;
2985 jQuery.find = Sizzle;
2986 jQuery.expr = Sizzle.selectors;
2987 jQuery.expr[":"] = jQuery.expr.pseudos;
2988 jQuery.unique = Sizzle.uniqueSort;
2989 jQuery.text = Sizzle.getText;
2990 jQuery.isXMLDoc = Sizzle.isXML;
2991 jQuery.contains = Sizzle.contains;
2995 // String to Object options format cache
2996 var optionsCache = {};
2998 // Convert String-formatted options into Object-formatted ones and store in cache
2999 function createOptions( options ) {
3000 var object = optionsCache[ options ] = {};
3001 jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
3002 object[ flag ] = true;
3008 * Create a callback list using the following parameters:
3010 * options: an optional list of space-separated options that will change how
3011 * the callback list behaves or a more traditional option object
3013 * By default a callback list will act like an event callback list and can be
3014 * "fired" multiple times.
3018 * once: will ensure the callback list can only be fired once (like a Deferred)
3020 * memory: will keep track of previous values and will call any callback added
3021 * after the list has been fired right away with the latest "memorized"
3022 * values (like a Deferred)
3024 * unique: will ensure a callback can only be added once (no duplicate in the list)
3026 * stopOnFalse: interrupt callings when a callback returns false
3029 jQuery.Callbacks = function( options ) {
3031 // Convert options from String-formatted to Object-formatted if needed
3032 // (we check in cache first)
3033 options = typeof options === "string" ?
3034 ( optionsCache[ options ] || createOptions( options ) ) :
3035 jQuery.extend( {}, options );
3037 var // Flag to know if list is currently firing
3039 // Last fire value (for non-forgettable lists)
3041 // Flag to know if list was already fired
3043 // End of the loop when firing
3045 // Index of currently firing callback (modified by remove if needed)
3047 // First callback to fire (used internally by add and fireWith)
3049 // Actual callback list
3051 // Stack of fire calls for repeatable lists
3052 stack = !options.once && [],
3054 fire = function( data ) {
3055 memory = options.memory && data;
3057 firingIndex = firingStart || 0;
3059 firingLength = list.length;
3061 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3062 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
3063 memory = false; // To prevent further calls using add
3070 if ( stack.length ) {
3071 fire( stack.shift() );
3073 } else if ( memory ) {
3080 // Actual Callbacks object
3082 // Add a callback or a collection of callbacks to the list
3085 // First, we save the current length
3086 var start = list.length;
3087 (function add( args ) {
3088 jQuery.each( args, function( _, arg ) {
3089 var type = jQuery.type( arg );
3090 if ( type === "function" ) {
3091 if ( !options.unique || !self.has( arg ) ) {
3094 } else if ( arg && arg.length && type !== "string" ) {
3095 // Inspect recursively
3100 // Do we need to add the callbacks to the
3101 // current firing batch?
3103 firingLength = list.length;
3104 // With memory, if we're not firing then
3105 // we should call right away
3106 } else if ( memory ) {
3107 firingStart = start;
3113 // Remove a callback from the list
3114 remove: function() {
3116 jQuery.each( arguments, function( _, arg ) {
3118 while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3119 list.splice( index, 1 );
3120 // Handle firing indexes
3122 if ( index <= firingLength ) {
3125 if ( index <= firingIndex ) {
3134 // Check if a given callback is in the list.
3135 // If no argument is given, return whether or not list has callbacks attached.
3136 has: function( fn ) {
3137 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
3139 // Remove all callbacks from the list
3145 // Have the list do nothing anymore
3146 disable: function() {
3147 list = stack = memory = undefined;
3151 disabled: function() {
3154 // Lock the list in its current state
3163 locked: function() {
3166 // Call all callbacks with the given context and arguments
3167 fireWith: function( context, args ) {
3168 if ( list && ( !fired || stack ) ) {
3170 args = [ context, args.slice ? args.slice() : args ];
3179 // Call all the callbacks with the given arguments
3181 self.fireWith( this, arguments );
3184 // To know if the callbacks have already been called at least once
3194 Deferred: function( func ) {
3196 // action, add listener, listener list, final state
3197 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
3198 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
3199 [ "notify", "progress", jQuery.Callbacks("memory") ]
3206 always: function() {
3207 deferred.done( arguments ).fail( arguments );
3210 then: function( /* fnDone, fnFail, fnProgress */ ) {
3211 var fns = arguments;
3212 return jQuery.Deferred(function( newDefer ) {
3213 jQuery.each( tuples, function( i, tuple ) {
3214 var action = tuple[ 0 ],
3215 fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
3216 // deferred[ done | fail | progress ] for forwarding actions to newDefer
3217 deferred[ tuple[1] ](function() {
3218 var returned = fn && fn.apply( this, arguments );
3219 if ( returned && jQuery.isFunction( returned.promise ) ) {
3221 .done( newDefer.resolve )
3222 .fail( newDefer.reject )
3223 .progress( newDefer.notify );
3225 newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
3232 // Get a promise for this deferred
3233 // If obj is provided, the promise aspect is added to the object
3234 promise: function( obj ) {
3235 return obj != null ? jQuery.extend( obj, promise ) : promise;
3240 // Keep pipe for back-compat
3241 promise.pipe = promise.then;
3243 // Add list-specific methods
3244 jQuery.each( tuples, function( i, tuple ) {
3245 var list = tuple[ 2 ],
3246 stateString = tuple[ 3 ];
3248 // promise[ done | fail | progress ] = list.add
3249 promise[ tuple[1] ] = list.add;
3252 if ( stateString ) {
3253 list.add(function() {
3254 // state = [ resolved | rejected ]
3255 state = stateString;
3257 // [ reject_list | resolve_list ].disable; progress_list.lock
3258 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
3261 // deferred[ resolve | reject | notify ]
3262 deferred[ tuple[0] ] = function() {
3263 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
3266 deferred[ tuple[0] + "With" ] = list.fireWith;
3269 // Make the deferred a promise
3270 promise.promise( deferred );
3272 // Call given func if any
3274 func.call( deferred, deferred );
3282 when: function( subordinate /* , ..., subordinateN */ ) {
3284 resolveValues = core_slice.call( arguments ),
3285 length = resolveValues.length,
3287 // the count of uncompleted subordinates
3288 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
3290 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
3291 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
3293 // Update function for both resolve and progress values
3294 updateFunc = function( i, contexts, values ) {
3295 return function( value ) {
3296 contexts[ i ] = this;
3297 values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
3298 if( values === progressValues ) {
3299 deferred.notifyWith( contexts, values );
3300 } else if ( !( --remaining ) ) {
3301 deferred.resolveWith( contexts, values );
3306 progressValues, progressContexts, resolveContexts;
3308 // add listeners to Deferred subordinates; treat others as resolved
3310 progressValues = new Array( length );
3311 progressContexts = new Array( length );
3312 resolveContexts = new Array( length );
3313 for ( ; i < length; i++ ) {
3314 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
3315 resolveValues[ i ].promise()
3316 .done( updateFunc( i, resolveContexts, resolveValues ) )
3317 .fail( deferred.reject )
3318 .progress( updateFunc( i, progressContexts, progressValues ) );
3325 // if we're not waiting on anything, resolve the master
3327 deferred.resolveWith( resolveContexts, resolveValues );
3330 return deferred.promise();
3333 jQuery.support = (function( support ) {
3335 var all, a, input, select, fragment, opt, eventName, isSupported, i,
3336 div = document.createElement("div");
3339 div.setAttribute( "className", "t" );
3340 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
3342 // Finish early in limited (non-browser) environments
3343 all = div.getElementsByTagName("*") || [];
3344 a = div.getElementsByTagName("a")[ 0 ];
3345 if ( !a || !a.style || !all.length ) {
3349 // First batch of tests
3350 select = document.createElement("select");
3351 opt = select.appendChild( document.createElement("option") );
3352 input = div.getElementsByTagName("input")[ 0 ];
3354 a.style.cssText = "top:1px;float:left;opacity:.5";
3356 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
3357 support.getSetAttribute = div.className !== "t";
3359 // IE strips leading whitespace when .innerHTML is used
3360 support.leadingWhitespace = div.firstChild.nodeType === 3;
3362 // Make sure that tbody elements aren't automatically inserted
3363 // IE will insert them into empty tables
3364 support.tbody = !div.getElementsByTagName("tbody").length;
3366 // Make sure that link elements get serialized correctly by innerHTML
3367 // This requires a wrapper element in IE
3368 support.htmlSerialize = !!div.getElementsByTagName("link").length;
3370 // Get the style information from getAttribute
3371 // (IE uses .cssText instead)
3372 support.style = /top/.test( a.getAttribute("style") );
3374 // Make sure that URLs aren't manipulated
3375 // (IE normalizes it by default)
3376 support.hrefNormalized = a.getAttribute("href") === "/a";
3378 // Make sure that element opacity exists
3379 // (IE uses filter instead)
3380 // Use a regex to work around a WebKit issue. See #5145
3381 support.opacity = /^0.5/.test( a.style.opacity );
3383 // Verify style float existence
3384 // (IE uses styleFloat instead of cssFloat)
3385 support.cssFloat = !!a.style.cssFloat;
3387 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
3388 support.checkOn = !!input.value;
3390 // Make sure that a selected-by-default option has a working selected property.
3391 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
3392 support.optSelected = opt.selected;
3394 // Tests for enctype support on a form (#6743)
3395 support.enctype = !!document.createElement("form").enctype;
3397 // Makes sure cloning an html5 element does not cause problems
3398 // Where outerHTML is undefined, this still works
3399 support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>";
3401 // Will be defined later
3402 support.inlineBlockNeedsLayout = false;
3403 support.shrinkWrapBlocks = false;
3404 support.pixelPosition = false;
3405 support.deleteExpando = true;
3406 support.noCloneEvent = true;
3407 support.reliableMarginRight = true;
3408 support.boxSizingReliable = true;
3410 // Make sure checked status is properly cloned
3411 input.checked = true;
3412 support.noCloneChecked = input.cloneNode( true ).checked;
3414 // Make sure that the options inside disabled selects aren't marked as disabled
3415 // (WebKit marks them as disabled)
3416 select.disabled = true;
3417 support.optDisabled = !opt.disabled;
3423 support.deleteExpando = false;
3426 // Check if we can trust getAttribute("value")
3427 input = document.createElement("input");
3428 input.setAttribute( "value", "" );
3429 support.input = input.getAttribute( "value" ) === "";
3431 // Check if an input maintains its value after becoming a radio
3433 input.setAttribute( "type", "radio" );
3434 support.radioValue = input.value === "t";
3436 // #11217 - WebKit loses check when the name is after the checked attribute
3437 input.setAttribute( "checked", "t" );
3438 input.setAttribute( "name", "t" );
3440 fragment = document.createDocumentFragment();
3441 fragment.appendChild( input );
3443 // Check if a disconnected checkbox will retain its checked
3444 // value of true after appended to the DOM (IE6/7)
3445 support.appendChecked = input.checked;
3447 // WebKit doesn't clone checked state correctly in fragments
3448 support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
3451 // Opera does not clone events (and typeof div.attachEvent === undefined).
3452 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
3453 if ( div.attachEvent ) {
3454 div.attachEvent( "onclick", function() {
3455 support.noCloneEvent = false;
3458 div.cloneNode( true ).click();
3461 // Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
3462 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
3463 for ( i in { submit: true, change: true, focusin: true }) {
3464 div.setAttribute( eventName = "on" + i, "t" );
3466 support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
3469 div.style.backgroundClip = "content-box";
3470 div.cloneNode( true ).style.backgroundClip = "";
3471 support.clearCloneStyle = div.style.backgroundClip === "content-box";
3474 // Iteration over object's inherited properties before its own.
3475 for ( i in jQuery( support ) ) {
3478 support.ownLast = i !== "0";
3480 // Run tests that need a body at doc ready
3482 var container, marginDiv, tds,
3483 divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
3484 body = document.getElementsByTagName("body")[0];
3487 // Return for frameset docs that don't have a body
3491 container = document.createElement("div");
3492 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
3494 body.appendChild( container ).appendChild( div );
3497 // Check if table cells still have offsetWidth/Height when they are set
3498 // to display:none and there are still other visible table cells in a
3499 // table row; if so, offsetWidth/Height are not reliable for use when
3500 // determining if an element has been hidden directly using
3501 // display:none (it is still safe to use offsets if a parent element is
3502 // hidden; don safety goggles and see bug #4512 for more information).
3503 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
3504 tds = div.getElementsByTagName("td");
3505 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
3506 isSupported = ( tds[ 0 ].offsetHeight === 0 );
3508 tds[ 0 ].style.display = "";
3509 tds[ 1 ].style.display = "none";
3512 // Check if empty table cells still have offsetWidth/Height
3513 support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
3515 // Check box-sizing and margin behavior.
3517 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%;";
3519 // Workaround failing boxSizing test due to offsetWidth returning wrong value
3520 // with some non-1 values of body zoom, ticket #13543
3521 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
3522 support.boxSizing = div.offsetWidth === 4;
3525 // Use window.getComputedStyle because jsdom on node.js will break without it.
3526 if ( window.getComputedStyle ) {
3527 support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
3528 support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
3530 // Check if div with explicit width and no margin-right incorrectly
3531 // gets computed margin-right based on width of container. (#3333)
3532 // Fails in WebKit before Feb 2011 nightlies
3533 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
3534 marginDiv = div.appendChild( document.createElement("div") );
3535 marginDiv.style.cssText = div.style.cssText = divReset;
3536 marginDiv.style.marginRight = marginDiv.style.width = "0";
3537 div.style.width = "1px";
3539 support.reliableMarginRight =
3540 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
3543 if ( typeof div.style.zoom !== core_strundefined ) {
3545 // Check if natively block-level elements act like inline-block
3546 // elements when setting their display to 'inline' and giving
3549 div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
3550 support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
3553 // Check if elements with layout shrink-wrap their children
3554 div.style.display = "block";
3555 div.innerHTML = "<div></div>";
3556 div.firstChild.style.width = "5px";
3557 support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
3559 if ( support.inlineBlockNeedsLayout ) {
3560 // Prevent IE 6 from affecting layout for positioned elements #11048
3561 // Prevent IE from shrinking the body in IE 7 mode #12869
3563 body.style.zoom = 1;
3567 body.removeChild( container );
3569 // Null elements to avoid leaks in IE
3570 container = div = tds = marginDiv = null;
3573 // Null elements to avoid leaks in IE
3574 all = select = fragment = opt = a = input = null;
3579 var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
3580 rmultiDash = /([A-Z])/g;
3582 function internalData( elem, name, data, pvt /* Internal Use Only */ ){
3583 if ( !jQuery.acceptData( elem ) ) {
3588 internalKey = jQuery.expando,
3590 // We have to handle DOM nodes and JS objects differently because IE6-7
3591 // can't GC object references properly across the DOM-JS boundary
3592 isNode = elem.nodeType,
3594 // Only DOM nodes need the global jQuery cache; JS object data is
3595 // attached directly to the object so GC can occur automatically
3596 cache = isNode ? jQuery.cache : elem,
3598 // Only defining an ID for JS objects if its cache already exists allows
3599 // the code to shortcut on the same path as a DOM node with no cache
3600 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
3602 // Avoid doing any more work than we need to when trying to get data on an
3603 // object that has no data at all
3604 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
3609 // Only DOM nodes need a new unique ID for each element since their data
3610 // ends up in the global cache
3612 id = elem[ internalKey ] = core_deletedIds.pop() || jQuery.guid++;
3618 if ( !cache[ id ] ) {
3619 // Avoid exposing jQuery metadata on plain JS objects when the object
3620 // is serialized using JSON.stringify
3621 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
3624 // An object can be passed to jQuery.data instead of a key/value pair; this gets
3625 // shallow copied over onto the existing cache
3626 if ( typeof name === "object" || typeof name === "function" ) {
3628 cache[ id ] = jQuery.extend( cache[ id ], name );
3630 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
3634 thisCache = cache[ id ];
3636 // jQuery data() is stored in a separate object inside the object's internal data
3637 // cache in order to avoid key collisions between internal data and user-defined
3640 if ( !thisCache.data ) {
3641 thisCache.data = {};
3644 thisCache = thisCache.data;
3647 if ( data !== undefined ) {
3648 thisCache[ jQuery.camelCase( name ) ] = data;
3651 // Check for both converted-to-camel and non-converted data property names
3652 // If a data property was specified
3653 if ( typeof name === "string" ) {
3655 // First Try to find as-is property data
3656 ret = thisCache[ name ];
3658 // Test for null|undefined property data
3659 if ( ret == null ) {
3661 // Try to find the camelCased property
3662 ret = thisCache[ jQuery.camelCase( name ) ];
3671 function internalRemoveData( elem, name, pvt ) {
3672 if ( !jQuery.acceptData( elem ) ) {
3677 isNode = elem.nodeType,
3679 // See jQuery.data for more information
3680 cache = isNode ? jQuery.cache : elem,
3681 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
3683 // If there is already no cache entry for this object, there is no
3684 // purpose in continuing
3685 if ( !cache[ id ] ) {
3691 thisCache = pvt ? cache[ id ] : cache[ id ].data;
3695 // Support array or space separated string names for data keys
3696 if ( !jQuery.isArray( name ) ) {
3698 // try the string as a key before any manipulation
3699 if ( name in thisCache ) {
3703 // split the camel cased version by spaces unless a key with the spaces exists
3704 name = jQuery.camelCase( name );
3705 if ( name in thisCache ) {
3708 name = name.split(" ");
3712 // If "name" is an array of keys...
3713 // When data is initially created, via ("key", "val") signature,
3714 // keys will be converted to camelCase.
3715 // Since there is no way to tell _how_ a key was added, remove
3716 // both plain key and camelCase key. #12786
3717 // This will only penalize the array argument path.
3718 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
3723 delete thisCache[ name[i] ];
3726 // If there is no data left in the cache, we want to continue
3727 // and let the cache object itself get destroyed
3728 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
3734 // See jQuery.data for more information
3736 delete cache[ id ].data;
3738 // Don't destroy the parent cache unless the internal data object
3739 // had been the only thing left in it
3740 if ( !isEmptyDataObject( cache[ id ] ) ) {
3745 // Destroy the cache
3747 jQuery.cleanData( [ elem ], true );
3749 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
3750 /* jshint eqeqeq: false */
3751 } else if ( jQuery.support.deleteExpando || cache != cache.window ) {
3752 /* jshint eqeqeq: true */
3755 // When all else fails, null
3764 // The following elements throw uncatchable exceptions if you
3765 // attempt to add expando properties to them.
3769 // Ban all objects except for Flash (which handle expandos)
3770 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
3773 hasData: function( elem ) {
3774 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
3775 return !!elem && !isEmptyDataObject( elem );
3778 data: function( elem, name, data ) {
3779 return internalData( elem, name, data );
3782 removeData: function( elem, name ) {
3783 return internalRemoveData( elem, name );
3786 // For internal use only.
3787 _data: function( elem, name, data ) {
3788 return internalData( elem, name, data, true );
3791 _removeData: function( elem, name ) {
3792 return internalRemoveData( elem, name, true );
3795 // A method for determining if a DOM node can handle the data expando
3796 acceptData: function( elem ) {
3797 // Do not set data on non-element because it will not be cleared (#8335).
3798 if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
3802 var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
3804 // nodes accept data unless otherwise specified; rejection can be conditional
3805 return !noData || noData !== true && elem.getAttribute("classid") === noData;
3810 data: function( key, value ) {
3816 // Special expections of .data basically thwart jQuery.access,
3817 // so implement the relevant behavior ourselves
3820 if ( key === undefined ) {
3821 if ( this.length ) {
3822 data = jQuery.data( elem );
3824 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
3825 attrs = elem.attributes;
3826 for ( ; i < attrs.length; i++ ) {
3827 name = attrs[i].name;
3829 if ( name.indexOf("data-") === 0 ) {
3830 name = jQuery.camelCase( name.slice(5) );
3832 dataAttr( elem, name, data[ name ] );
3835 jQuery._data( elem, "parsedAttrs", true );
3842 // Sets multiple values
3843 if ( typeof key === "object" ) {
3844 return this.each(function() {
3845 jQuery.data( this, key );
3849 return arguments.length > 1 ?
3852 this.each(function() {
3853 jQuery.data( this, key, value );
3857 // Try to fetch any internally stored data first
3858 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
3861 removeData: function( key ) {
3862 return this.each(function() {
3863 jQuery.removeData( this, key );
3868 function dataAttr( elem, key, data ) {
3869 // If nothing was found internally, try to fetch any
3870 // data from the HTML5 data-* attribute
3871 if ( data === undefined && elem.nodeType === 1 ) {
3873 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
3875 data = elem.getAttribute( name );
3877 if ( typeof data === "string" ) {
3879 data = data === "true" ? true :
3880 data === "false" ? false :
3881 data === "null" ? null :
3882 // Only convert to a number if it doesn't change the string
3883 +data + "" === data ? +data :
3884 rbrace.test( data ) ? jQuery.parseJSON( data ) :
3888 // Make sure we set the data so it isn't changed later
3889 jQuery.data( elem, key, data );
3899 // checks a cache object for emptiness
3900 function isEmptyDataObject( obj ) {
3902 for ( name in obj ) {
3904 // if the public data object is empty, the private is still empty
3905 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
3908 if ( name !== "toJSON" ) {
3916 queue: function( elem, type, data ) {
3920 type = ( type || "fx" ) + "queue";
3921 queue = jQuery._data( elem, type );
3923 // Speed up dequeue by getting out quickly if this is just a lookup
3925 if ( !queue || jQuery.isArray(data) ) {
3926 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
3935 dequeue: function( elem, type ) {
3936 type = type || "fx";
3938 var queue = jQuery.queue( elem, type ),
3939 startLength = queue.length,
3941 hooks = jQuery._queueHooks( elem, type ),
3943 jQuery.dequeue( elem, type );
3946 // If the fx queue is dequeued, always remove the progress sentinel
3947 if ( fn === "inprogress" ) {
3954 // Add a progress sentinel to prevent the fx queue from being
3955 // automatically dequeued
3956 if ( type === "fx" ) {
3957 queue.unshift( "inprogress" );
3960 // clear up the last queue stop function
3962 fn.call( elem, next, hooks );
3965 if ( !startLength && hooks ) {
3970 // not intended for public consumption - generates a queueHooks object, or returns the current one
3971 _queueHooks: function( elem, type ) {
3972 var key = type + "queueHooks";
3973 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
3974 empty: jQuery.Callbacks("once memory").add(function() {
3975 jQuery._removeData( elem, type + "queue" );
3976 jQuery._removeData( elem, key );
3983 queue: function( type, data ) {
3986 if ( typeof type !== "string" ) {
3992 if ( arguments.length < setter ) {
3993 return jQuery.queue( this[0], type );
3996 return data === undefined ?
3998 this.each(function() {
3999 var queue = jQuery.queue( this, type, data );
4001 // ensure a hooks for this queue
4002 jQuery._queueHooks( this, type );
4004 if ( type === "fx" && queue[0] !== "inprogress" ) {
4005 jQuery.dequeue( this, type );
4009 dequeue: function( type ) {
4010 return this.each(function() {
4011 jQuery.dequeue( this, type );
4014 // Based off of the plugin by Clint Helfers, with permission.
4015 // http://blindsignals.com/index.php/2009/07/jquery-delay/
4016 delay: function( time, type ) {
4017 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
4018 type = type || "fx";
4020 return this.queue( type, function( next, hooks ) {
4021 var timeout = setTimeout( next, time );
4022 hooks.stop = function() {
4023 clearTimeout( timeout );
4027 clearQueue: function( type ) {
4028 return this.queue( type || "fx", [] );
4030 // Get a promise resolved when queues of a certain type
4031 // are emptied (fx is the type by default)
4032 promise: function( type, obj ) {
4035 defer = jQuery.Deferred(),
4038 resolve = function() {
4039 if ( !( --count ) ) {
4040 defer.resolveWith( elements, [ elements ] );
4044 if ( typeof type !== "string" ) {
4048 type = type || "fx";
4051 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
4052 if ( tmp && tmp.empty ) {
4054 tmp.empty.add( resolve );
4058 return defer.promise( obj );
4061 var nodeHook, boolHook,
4062 rclass = /[\t\r\n\f]/g,
4064 rfocusable = /^(?:input|select|textarea|button|object)$/i,
4065 rclickable = /^(?:a|area)$/i,
4066 ruseDefault = /^(?:checked|selected)$/i,
4067 getSetAttribute = jQuery.support.getSetAttribute,
4068 getSetInput = jQuery.support.input;
4071 attr: function( name, value ) {
4072 return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
4075 removeAttr: function( name ) {
4076 return this.each(function() {
4077 jQuery.removeAttr( this, name );
4081 prop: function( name, value ) {
4082 return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
4085 removeProp: function( name ) {
4086 name = jQuery.propFix[ name ] || name;
4087 return this.each(function() {
4088 // try/catch handles cases where IE balks (such as removing a property on window)
4090 this[ name ] = undefined;
4091 delete this[ name ];
4096 addClass: function( value ) {
4097 var classes, elem, cur, clazz, j,
4100 proceed = typeof value === "string" && value;
4102 if ( jQuery.isFunction( value ) ) {
4103 return this.each(function( j ) {
4104 jQuery( this ).addClass( value.call( this, j, this.className ) );
4109 // The disjunction here is for better compressibility (see removeClass)
4110 classes = ( value || "" ).match( core_rnotwhite ) || [];
4112 for ( ; i < len; i++ ) {
4114 cur = elem.nodeType === 1 && ( elem.className ?
4115 ( " " + elem.className + " " ).replace( rclass, " " ) :
4121 while ( (clazz = classes[j++]) ) {
4122 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
4126 elem.className = jQuery.trim( cur );
4135 removeClass: function( value ) {
4136 var classes, elem, cur, clazz, j,
4139 proceed = arguments.length === 0 || typeof value === "string" && value;
4141 if ( jQuery.isFunction( value ) ) {
4142 return this.each(function( j ) {
4143 jQuery( this ).removeClass( value.call( this, j, this.className ) );
4147 classes = ( value || "" ).match( core_rnotwhite ) || [];
4149 for ( ; i < len; i++ ) {
4151 // This expression is here for better compressibility (see addClass)
4152 cur = elem.nodeType === 1 && ( elem.className ?
4153 ( " " + elem.className + " " ).replace( rclass, " " ) :
4159 while ( (clazz = classes[j++]) ) {
4160 // Remove *all* instances
4161 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
4162 cur = cur.replace( " " + clazz + " ", " " );
4165 elem.className = value ? jQuery.trim( cur ) : "";
4173 toggleClass: function( value, stateVal ) {
4174 var type = typeof value;
4176 if ( typeof stateVal === "boolean" && type === "string" ) {
4177 return stateVal ? this.addClass( value ) : this.removeClass( value );
4180 if ( jQuery.isFunction( value ) ) {
4181 return this.each(function( i ) {
4182 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
4186 return this.each(function() {
4187 if ( type === "string" ) {
4188 // toggle individual class names
4191 self = jQuery( this ),
4192 classNames = value.match( core_rnotwhite ) || [];
4194 while ( (className = classNames[ i++ ]) ) {
4195 // check each className given, space separated list
4196 if ( self.hasClass( className ) ) {
4197 self.removeClass( className );
4199 self.addClass( className );
4203 // Toggle whole class name
4204 } else if ( type === core_strundefined || type === "boolean" ) {
4205 if ( this.className ) {
4206 // store className if set
4207 jQuery._data( this, "__className__", this.className );
4210 // If the element has a class name or if we're passed "false",
4211 // then remove the whole classname (if there was one, the above saved it).
4212 // Otherwise bring back whatever was previously saved (if anything),
4213 // falling back to the empty string if nothing was stored.
4214 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
4219 hasClass: function( selector ) {
4220 var className = " " + selector + " ",
4223 for ( ; i < l; i++ ) {
4224 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
4232 val: function( value ) {
4233 var ret, hooks, isFunction,
4236 if ( !arguments.length ) {
4238 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
4240 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
4246 return typeof ret === "string" ?
4247 // handle most common string cases
4248 ret.replace(rreturn, "") :
4249 // handle cases where value is null/undef or number
4250 ret == null ? "" : ret;
4256 isFunction = jQuery.isFunction( value );
4258 return this.each(function( i ) {
4261 if ( this.nodeType !== 1 ) {
4266 val = value.call( this, i, jQuery( this ).val() );
4271 // Treat null/undefined as ""; convert numbers to string
4272 if ( val == null ) {
4274 } else if ( typeof val === "number" ) {
4276 } else if ( jQuery.isArray( val ) ) {
4277 val = jQuery.map(val, function ( value ) {
4278 return value == null ? "" : value + "";
4282 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
4284 // If set returns undefined, fall back to normal setting
4285 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
4295 get: function( elem ) {
4296 // Use proper attribute retrieval(#6932, #12072)
4297 var val = jQuery.find.attr( elem, "value" );
4298 return val != null ?
4304 get: function( elem ) {
4306 options = elem.options,
4307 index = elem.selectedIndex,
4308 one = elem.type === "select-one" || index < 0,
4309 values = one ? null : [],
4310 max = one ? index + 1 : options.length,
4315 // Loop through all the selected options
4316 for ( ; i < max; i++ ) {
4317 option = options[ i ];
4319 // oldIE doesn't update selected after form reset (#2551)
4320 if ( ( option.selected || i === index ) &&
4321 // Don't return options that are disabled or in a disabled optgroup
4322 ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
4323 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
4325 // Get the specific value for the option
4326 value = jQuery( option ).val();
4328 // We don't need an array for one selects
4333 // Multi-Selects return an array
4334 values.push( value );
4341 set: function( elem, value ) {
4342 var optionSet, option,
4343 options = elem.options,
4344 values = jQuery.makeArray( value ),
4348 option = options[ i ];
4349 if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
4354 // force browsers to behave consistently when non-matching value is set
4356 elem.selectedIndex = -1;
4363 attr: function( elem, name, value ) {
4365 nType = elem.nodeType;
4367 // don't get/set attributes on text, comment and attribute nodes
4368 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
4372 // Fallback to prop when attributes are not supported
4373 if ( typeof elem.getAttribute === core_strundefined ) {
4374 return jQuery.prop( elem, name, value );
4377 // All attributes are lowercase
4378 // Grab necessary hook if one is defined
4379 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
4380 name = name.toLowerCase();
4381 hooks = jQuery.attrHooks[ name ] ||
4382 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
4385 if ( value !== undefined ) {
4387 if ( value === null ) {
4388 jQuery.removeAttr( elem, name );
4390 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
4394 elem.setAttribute( name, value + "" );
4398 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
4402 ret = jQuery.find.attr( elem, name );
4404 // Non-existent attributes return null, we normalize to undefined
4405 return ret == null ?
4411 removeAttr: function( elem, value ) {
4414 attrNames = value && value.match( core_rnotwhite );
4416 if ( attrNames && elem.nodeType === 1 ) {
4417 while ( (name = attrNames[i++]) ) {
4418 propName = jQuery.propFix[ name ] || name;
4420 // Boolean attributes get special treatment (#10870)
4421 if ( jQuery.expr.match.bool.test( name ) ) {
4422 // Set corresponding property to false
4423 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
4424 elem[ propName ] = false;
4426 // Also clear defaultChecked/defaultSelected (if appropriate)
4428 elem[ jQuery.camelCase( "default-" + name ) ] =
4429 elem[ propName ] = false;
4432 // See #9699 for explanation of this approach (setting first, then removal)
4434 jQuery.attr( elem, name, "" );
4437 elem.removeAttribute( getSetAttribute ? name : propName );
4444 set: function( elem, value ) {
4445 if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
4446 // Setting the type on a radio button after the value resets the value in IE6-9
4447 // Reset value to default in case type is set after value during creation
4448 var val = elem.value;
4449 elem.setAttribute( "type", value );
4461 "class": "className"
4464 prop: function( elem, name, value ) {
4465 var ret, hooks, notxml,
4466 nType = elem.nodeType;
4468 // don't get/set properties on text, comment and attribute nodes
4469 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
4473 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
4476 // Fix name and attach hooks
4477 name = jQuery.propFix[ name ] || name;
4478 hooks = jQuery.propHooks[ name ];
4481 if ( value !== undefined ) {
4482 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
4484 ( elem[ name ] = value );
4487 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
4495 get: function( elem ) {
4496 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
4497 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
4498 // Use proper attribute retrieval(#12072)
4499 var tabindex = jQuery.find.attr( elem, "tabindex" );
4502 parseInt( tabindex, 10 ) :
4503 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
4511 // Hooks for boolean attributes
4513 set: function( elem, value, name ) {
4514 if ( value === false ) {
4515 // Remove boolean attributes when set to false
4516 jQuery.removeAttr( elem, name );
4517 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
4518 // IE<8 needs the *property* name
4519 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
4521 // Use defaultChecked and defaultSelected for oldIE
4523 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
4529 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
4530 var getter = jQuery.expr.attrHandle[ name ] || jQuery.find.attr;
4532 jQuery.expr.attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
4533 function( elem, name, isXML ) {
4534 var fn = jQuery.expr.attrHandle[ name ],
4537 /* jshint eqeqeq: false */
4538 (jQuery.expr.attrHandle[ name ] = undefined) !=
4539 getter( elem, name, isXML ) ?
4541 name.toLowerCase() :
4543 jQuery.expr.attrHandle[ name ] = fn;
4546 function( elem, name, isXML ) {
4549 elem[ jQuery.camelCase( "default-" + name ) ] ?
4550 name.toLowerCase() :
4555 // fix oldIE attroperties
4556 if ( !getSetInput || !getSetAttribute ) {
4557 jQuery.attrHooks.value = {
4558 set: function( elem, value, name ) {
4559 if ( jQuery.nodeName( elem, "input" ) ) {
4560 // Does not return so that setAttribute is also used
4561 elem.defaultValue = value;
4563 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
4564 return nodeHook && nodeHook.set( elem, value, name );
4570 // IE6/7 do not support getting/setting some attributes with get/setAttribute
4571 if ( !getSetAttribute ) {
4573 // Use this for any attribute in IE6/7
4574 // This fixes almost every IE6/7 issue
4576 set: function( elem, value, name ) {
4577 // Set the existing or create a new attribute node
4578 var ret = elem.getAttributeNode( name );
4580 elem.setAttributeNode(
4581 (ret = elem.ownerDocument.createAttribute( name ))
4585 ret.value = value += "";
4587 // Break association with cloned elements by also using setAttribute (#9646)
4588 return name === "value" || value === elem.getAttribute( name ) ?
4593 jQuery.expr.attrHandle.id = jQuery.expr.attrHandle.name = jQuery.expr.attrHandle.coords =
4594 // Some attributes are constructed with empty-string values when not defined
4595 function( elem, name, isXML ) {
4599 (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
4603 jQuery.valHooks.button = {
4604 get: function( elem, name ) {
4605 var ret = elem.getAttributeNode( name );
4606 return ret && ret.specified ?
4613 // Set contenteditable to false on removals(#10429)
4614 // Setting to empty string throws an error as an invalid value
4615 jQuery.attrHooks.contenteditable = {
4616 set: function( elem, value, name ) {
4617 nodeHook.set( elem, value === "" ? false : value, name );
4621 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
4622 // This is for removals
4623 jQuery.each([ "width", "height" ], function( i, name ) {
4624 jQuery.attrHooks[ name ] = {
4625 set: function( elem, value ) {
4626 if ( value === "" ) {
4627 elem.setAttribute( name, "auto" );
4636 // Some attributes require a special call on IE
4637 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
4638 if ( !jQuery.support.hrefNormalized ) {
4639 // href/src property should get the full normalized URL (#10299/#12915)
4640 jQuery.each([ "href", "src" ], function( i, name ) {
4641 jQuery.propHooks[ name ] = {
4642 get: function( elem ) {
4643 return elem.getAttribute( name, 4 );
4649 if ( !jQuery.support.style ) {
4650 jQuery.attrHooks.style = {
4651 get: function( elem ) {
4652 // Return undefined in the case of empty string
4653 // Note: IE uppercases css property names, but if we were to .toLowerCase()
4654 // .cssText, that would destroy case senstitivity in URL's, like in "background"
4655 return elem.style.cssText || undefined;
4657 set: function( elem, value ) {
4658 return ( elem.style.cssText = value + "" );
4663 // Safari mis-reports the default selected property of an option
4664 // Accessing the parent's selectedIndex property fixes it
4665 if ( !jQuery.support.optSelected ) {
4666 jQuery.propHooks.selected = {
4667 get: function( elem ) {
4668 var parent = elem.parentNode;
4671 parent.selectedIndex;
4673 // Make sure that it also works with optgroups, see #5701
4674 if ( parent.parentNode ) {
4675 parent.parentNode.selectedIndex;
4695 jQuery.propFix[ this.toLowerCase() ] = this;
4698 // IE6/7 call enctype encoding
4699 if ( !jQuery.support.enctype ) {
4700 jQuery.propFix.enctype = "encoding";
4703 // Radios and checkboxes getter/setter
4704 jQuery.each([ "radio", "checkbox" ], function() {
4705 jQuery.valHooks[ this ] = {
4706 set: function( elem, value ) {
4707 if ( jQuery.isArray( value ) ) {
4708 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
4712 if ( !jQuery.support.checkOn ) {
4713 jQuery.valHooks[ this ].get = function( elem ) {
4715 // "" is returned instead of "on" if a value isn't specified
4716 return elem.getAttribute("value") === null ? "on" : elem.value;
4720 var rformElems = /^(?:input|select|textarea)$/i,
4722 rmouseEvent = /^(?:mouse|contextmenu)|click/,
4723 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
4724 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
4726 function returnTrue() {
4730 function returnFalse() {
4734 function safeActiveElement() {
4736 return document.activeElement;
4741 * Helper functions for managing events -- not part of the public interface.
4742 * Props to Dean Edwards' addEvent library for many of the ideas.
4748 add: function( elem, types, handler, data, selector ) {
4749 var tmp, events, t, handleObjIn,
4750 special, eventHandle, handleObj,
4751 handlers, type, namespaces, origType,
4752 elemData = jQuery._data( elem );
4754 // Don't attach events to noData or text/comment nodes (but allow plain objects)
4759 // Caller can pass in an object of custom data in lieu of the handler
4760 if ( handler.handler ) {
4761 handleObjIn = handler;
4762 handler = handleObjIn.handler;
4763 selector = handleObjIn.selector;
4766 // Make sure that the handler has a unique ID, used to find/remove it later
4767 if ( !handler.guid ) {
4768 handler.guid = jQuery.guid++;
4771 // Init the element's event structure and main handler, if this is the first
4772 if ( !(events = elemData.events) ) {
4773 events = elemData.events = {};
4775 if ( !(eventHandle = elemData.handle) ) {
4776 eventHandle = elemData.handle = function( e ) {
4777 // Discard the second event of a jQuery.event.trigger() and
4778 // when an event is called after a page has unloaded
4779 return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
4780 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
4783 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
4784 eventHandle.elem = elem;
4787 // Handle multiple events separated by a space
4788 types = ( types || "" ).match( core_rnotwhite ) || [""];
4791 tmp = rtypenamespace.exec( types[t] ) || [];
4792 type = origType = tmp[1];
4793 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4795 // There *must* be a type, no attaching namespace-only handlers
4800 // If event changes its type, use the special event handlers for the changed type
4801 special = jQuery.event.special[ type ] || {};
4803 // If selector defined, determine special event api type, otherwise given type
4804 type = ( selector ? special.delegateType : special.bindType ) || type;
4806 // Update special based on newly reset type
4807 special = jQuery.event.special[ type ] || {};
4809 // handleObj is passed to all event handlers
4810 handleObj = jQuery.extend({
4817 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
4818 namespace: namespaces.join(".")
4821 // Init the event handler queue if we're the first
4822 if ( !(handlers = events[ type ]) ) {
4823 handlers = events[ type ] = [];
4824 handlers.delegateCount = 0;
4826 // Only use addEventListener/attachEvent if the special events handler returns false
4827 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
4828 // Bind the global event handler to the element
4829 if ( elem.addEventListener ) {
4830 elem.addEventListener( type, eventHandle, false );
4832 } else if ( elem.attachEvent ) {
4833 elem.attachEvent( "on" + type, eventHandle );
4838 if ( special.add ) {
4839 special.add.call( elem, handleObj );
4841 if ( !handleObj.handler.guid ) {
4842 handleObj.handler.guid = handler.guid;
4846 // Add to the element's handler list, delegates in front
4848 handlers.splice( handlers.delegateCount++, 0, handleObj );
4850 handlers.push( handleObj );
4853 // Keep track of which events have ever been used, for event optimization
4854 jQuery.event.global[ type ] = true;
4857 // Nullify elem to prevent memory leaks in IE
4861 // Detach an event or set of events from an element
4862 remove: function( elem, types, handler, selector, mappedTypes ) {
4863 var j, handleObj, tmp,
4864 origCount, t, events,
4865 special, handlers, type,
4866 namespaces, origType,
4867 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
4869 if ( !elemData || !(events = elemData.events) ) {
4873 // Once for each type.namespace in types; type may be omitted
4874 types = ( types || "" ).match( core_rnotwhite ) || [""];
4877 tmp = rtypenamespace.exec( types[t] ) || [];
4878 type = origType = tmp[1];
4879 namespaces = ( tmp[2] || "" ).split( "." ).sort();
4881 // Unbind all events (on this namespace, if provided) for the element
4883 for ( type in events ) {
4884 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
4889 special = jQuery.event.special[ type ] || {};
4890 type = ( selector ? special.delegateType : special.bindType ) || type;
4891 handlers = events[ type ] || [];
4892 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
4894 // Remove matching events
4895 origCount = j = handlers.length;
4897 handleObj = handlers[ j ];
4899 if ( ( mappedTypes || origType === handleObj.origType ) &&
4900 ( !handler || handler.guid === handleObj.guid ) &&
4901 ( !tmp || tmp.test( handleObj.namespace ) ) &&
4902 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
4903 handlers.splice( j, 1 );
4905 if ( handleObj.selector ) {
4906 handlers.delegateCount--;
4908 if ( special.remove ) {
4909 special.remove.call( elem, handleObj );
4914 // Remove generic event handler if we removed something and no more handlers exist
4915 // (avoids potential for endless recursion during removal of special event handlers)
4916 if ( origCount && !handlers.length ) {
4917 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
4918 jQuery.removeEvent( elem, type, elemData.handle );
4921 delete events[ type ];
4925 // Remove the expando if it's no longer used
4926 if ( jQuery.isEmptyObject( events ) ) {
4927 delete elemData.handle;
4929 // removeData also checks for emptiness and clears the expando if empty
4930 // so use it instead of delete
4931 jQuery._removeData( elem, "events" );
4935 trigger: function( event, data, elem, onlyHandlers ) {
4936 var handle, ontype, cur,
4937 bubbleType, special, tmp, i,
4938 eventPath = [ elem || document ],
4939 type = core_hasOwn.call( event, "type" ) ? event.type : event,
4940 namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
4942 cur = tmp = elem = elem || document;
4944 // Don't do events on text and comment nodes
4945 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
4949 // focus/blur morphs to focusin/out; ensure we're not firing them right now
4950 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
4954 if ( type.indexOf(".") >= 0 ) {
4955 // Namespaced trigger; create a regexp to match event type in handle()
4956 namespaces = type.split(".");
4957 type = namespaces.shift();
4960 ontype = type.indexOf(":") < 0 && "on" + type;
4962 // Caller can pass in a jQuery.Event object, Object, or just an event type string
4963 event = event[ jQuery.expando ] ?
4965 new jQuery.Event( type, typeof event === "object" && event );
4967 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
4968 event.isTrigger = onlyHandlers ? 2 : 3;
4969 event.namespace = namespaces.join(".");
4970 event.namespace_re = event.namespace ?
4971 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
4974 // Clean up the event in case it is being reused
4975 event.result = undefined;
4976 if ( !event.target ) {
4977 event.target = elem;
4980 // Clone any incoming data and prepend the event, creating the handler arg list
4981 data = data == null ?
4983 jQuery.makeArray( data, [ event ] );
4985 // Allow special events to draw outside the lines
4986 special = jQuery.event.special[ type ] || {};
4987 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
4991 // Determine event propagation path in advance, per W3C events spec (#9951)
4992 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
4993 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
4995 bubbleType = special.delegateType || type;
4996 if ( !rfocusMorph.test( bubbleType + type ) ) {
4997 cur = cur.parentNode;
4999 for ( ; cur; cur = cur.parentNode ) {
5000 eventPath.push( cur );
5004 // Only add window if we got to document (e.g., not plain obj or detached DOM)
5005 if ( tmp === (elem.ownerDocument || document) ) {
5006 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
5010 // Fire handlers on the event path
5012 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
5014 event.type = i > 1 ?
5016 special.bindType || type;
5019 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
5021 handle.apply( cur, data );
5025 handle = ontype && cur[ ontype ];
5026 if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
5027 event.preventDefault();
5032 // If nobody prevented the default action, do it now
5033 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
5035 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
5036 jQuery.acceptData( elem ) ) {
5038 // Call a native DOM method on the target with the same name name as the event.
5039 // Can't use an .isFunction() check here because IE6/7 fails that test.
5040 // Don't do default actions on window, that's where global variables be (#6170)
5041 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
5043 // Don't re-trigger an onFOO event when we call its FOO() method
5044 tmp = elem[ ontype ];
5047 elem[ ontype ] = null;
5050 // Prevent re-triggering of the same event, since we already bubbled it above
5051 jQuery.event.triggered = type;
5055 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
5056 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
5058 jQuery.event.triggered = undefined;
5061 elem[ ontype ] = tmp;
5067 return event.result;
5070 dispatch: function( event ) {
5072 // Make a writable jQuery.Event from the native event object
5073 event = jQuery.event.fix( event );
5075 var i, ret, handleObj, matched, j,
5077 args = core_slice.call( arguments ),
5078 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
5079 special = jQuery.event.special[ event.type ] || {};
5081 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5083 event.delegateTarget = this;
5085 // Call the preDispatch hook for the mapped type, and let it bail if desired
5086 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5090 // Determine handlers
5091 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5093 // Run delegates first; they may want to stop propagation beneath us
5095 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
5096 event.currentTarget = matched.elem;
5099 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
5101 // Triggered event must either 1) have no namespace, or
5102 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
5103 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
5105 event.handleObj = handleObj;
5106 event.data = handleObj.data;
5108 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
5109 .apply( matched.elem, args );
5111 if ( ret !== undefined ) {
5112 if ( (event.result = ret) === false ) {
5113 event.preventDefault();
5114 event.stopPropagation();
5121 // Call the postDispatch hook for the mapped type
5122 if ( special.postDispatch ) {
5123 special.postDispatch.call( this, event );
5126 return event.result;
5129 handlers: function( event, handlers ) {
5130 var sel, handleObj, matches, i,
5132 delegateCount = handlers.delegateCount,
5135 // Find delegate handlers
5136 // Black-hole SVG <use> instance trees (#13180)
5137 // Avoid non-left-click bubbling in Firefox (#3861)
5138 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
5140 /* jshint eqeqeq: false */
5141 for ( ; cur != this; cur = cur.parentNode || this ) {
5142 /* jshint eqeqeq: true */
5144 // Don't check non-elements (#13208)
5145 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5146 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
5148 for ( i = 0; i < delegateCount; i++ ) {
5149 handleObj = handlers[ i ];
5151 // Don't conflict with Object.prototype properties (#13203)
5152 sel = handleObj.selector + " ";
5154 if ( matches[ sel ] === undefined ) {
5155 matches[ sel ] = handleObj.needsContext ?
5156 jQuery( sel, this ).index( cur ) >= 0 :
5157 jQuery.find( sel, this, null, [ cur ] ).length;
5159 if ( matches[ sel ] ) {
5160 matches.push( handleObj );
5163 if ( matches.length ) {
5164 handlerQueue.push({ elem: cur, handlers: matches });
5170 // Add the remaining (directly-bound) handlers
5171 if ( delegateCount < handlers.length ) {
5172 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
5175 return handlerQueue;
5178 fix: function( event ) {
5179 if ( event[ jQuery.expando ] ) {
5183 // Create a writable copy of the event object and normalize some properties
5186 originalEvent = event,
5187 fixHook = this.fixHooks[ type ];
5190 this.fixHooks[ type ] = fixHook =
5191 rmouseEvent.test( type ) ? this.mouseHooks :
5192 rkeyEvent.test( type ) ? this.keyHooks :
5195 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
5197 event = new jQuery.Event( originalEvent );
5202 event[ prop ] = originalEvent[ prop ];
5206 // Fix target property (#1925)
5207 if ( !event.target ) {
5208 event.target = originalEvent.srcElement || document;
5211 // Support: Chrome 23+, Safari?
5212 // Target should not be a text node (#504, #13143)
5213 if ( event.target.nodeType === 3 ) {
5214 event.target = event.target.parentNode;
5218 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
5219 event.metaKey = !!event.metaKey;
5221 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
5224 // Includes some event props shared by KeyEvent and MouseEvent
5225 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
5230 props: "char charCode key keyCode".split(" "),
5231 filter: function( event, original ) {
5233 // Add which for key events
5234 if ( event.which == null ) {
5235 event.which = original.charCode != null ? original.charCode : original.keyCode;
5243 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
5244 filter: function( event, original ) {
5245 var body, eventDoc, doc,
5246 button = original.button,
5247 fromElement = original.fromElement;
5249 // Calculate pageX/Y if missing and clientX/Y available
5250 if ( event.pageX == null && original.clientX != null ) {
5251 eventDoc = event.target.ownerDocument || document;
5252 doc = eventDoc.documentElement;
5253 body = eventDoc.body;
5255 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
5256 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
5259 // Add relatedTarget, if necessary
5260 if ( !event.relatedTarget && fromElement ) {
5261 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
5264 // Add which for click: 1 === left; 2 === middle; 3 === right
5265 // Note: button is not normalized, so don't use it
5266 if ( !event.which && button !== undefined ) {
5267 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
5276 // Prevent triggered image.load events from bubbling to window.load
5280 // Fire native event if possible so blur/focus sequence is correct
5281 trigger: function() {
5282 if ( this !== safeActiveElement() && this.focus ) {
5288 // If we error on focus to hidden element (#1486, #12518),
5289 // let .trigger() run the handlers
5293 delegateType: "focusin"
5296 trigger: function() {
5297 if ( this === safeActiveElement() && this.blur ) {
5302 delegateType: "focusout"
5305 // For checkbox, fire native event so checked state will be right
5306 trigger: function() {
5307 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
5313 // For cross-browser consistency, don't fire native .click() on links
5314 _default: function( event ) {
5315 return jQuery.nodeName( event.target, "a" );
5320 postDispatch: function( event ) {
5322 // Even when returnValue equals to undefined Firefox will still show alert
5323 if ( event.result !== undefined ) {
5324 event.originalEvent.returnValue = event.result;
5330 simulate: function( type, elem, event, bubble ) {
5331 // Piggyback on a donor event to simulate a different one.
5332 // Fake originalEvent to avoid donor's stopPropagation, but if the
5333 // simulated event prevents default then we do the same on the donor.
5334 var e = jQuery.extend(
5344 jQuery.event.trigger( e, null, elem );
5346 jQuery.event.dispatch.call( elem, e );
5348 if ( e.isDefaultPrevented() ) {
5349 event.preventDefault();
5354 jQuery.removeEvent = document.removeEventListener ?
5355 function( elem, type, handle ) {
5356 if ( elem.removeEventListener ) {
5357 elem.removeEventListener( type, handle, false );
5360 function( elem, type, handle ) {
5361 var name = "on" + type;
5363 if ( elem.detachEvent ) {
5365 // #8545, #7054, preventing memory leaks for custom events in IE6-8
5366 // detachEvent needed property on element, by name of that event, to properly expose it to GC
5367 if ( typeof elem[ name ] === core_strundefined ) {
5368 elem[ name ] = null;
5371 elem.detachEvent( name, handle );
5375 jQuery.Event = function( src, props ) {
5376 // Allow instantiation without the 'new' keyword
5377 if ( !(this instanceof jQuery.Event) ) {
5378 return new jQuery.Event( src, props );
5382 if ( src && src.type ) {
5383 this.originalEvent = src;
5384 this.type = src.type;
5386 // Events bubbling up the document may have been marked as prevented
5387 // by a handler lower down the tree; reflect the correct value.
5388 this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
5389 src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
5396 // Put explicitly provided properties onto the event object
5398 jQuery.extend( this, props );
5401 // Create a timestamp if incoming event doesn't have one
5402 this.timeStamp = src && src.timeStamp || jQuery.now();
5405 this[ jQuery.expando ] = true;
5408 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5409 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5410 jQuery.Event.prototype = {
5411 isDefaultPrevented: returnFalse,
5412 isPropagationStopped: returnFalse,
5413 isImmediatePropagationStopped: returnFalse,
5415 preventDefault: function() {
5416 var e = this.originalEvent;
5418 this.isDefaultPrevented = returnTrue;
5423 // If preventDefault exists, run it on the original event
5424 if ( e.preventDefault ) {
5428 // Otherwise set the returnValue property of the original event to false
5430 e.returnValue = false;
5433 stopPropagation: function() {
5434 var e = this.originalEvent;
5436 this.isPropagationStopped = returnTrue;
5440 // If stopPropagation exists, run it on the original event
5441 if ( e.stopPropagation ) {
5442 e.stopPropagation();
5446 // Set the cancelBubble property of the original event to true
5447 e.cancelBubble = true;
5449 stopImmediatePropagation: function() {
5450 this.isImmediatePropagationStopped = returnTrue;
5451 this.stopPropagation();
5455 // Create mouseenter/leave events using mouseover/out and event-time checks
5457 mouseenter: "mouseover",
5458 mouseleave: "mouseout"
5459 }, function( orig, fix ) {
5460 jQuery.event.special[ orig ] = {
5464 handle: function( event ) {
5467 related = event.relatedTarget,
5468 handleObj = event.handleObj;
5470 // For mousenter/leave call the handler if related is outside the target.
5471 // NB: No relatedTarget if the mouse left/entered the browser window
5472 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
5473 event.type = handleObj.origType;
5474 ret = handleObj.handler.apply( this, arguments );
5482 // IE submit delegation
5483 if ( !jQuery.support.submitBubbles ) {
5485 jQuery.event.special.submit = {
5487 // Only need this for delegated form submit events
5488 if ( jQuery.nodeName( this, "form" ) ) {
5492 // Lazy-add a submit handler when a descendant form may potentially be submitted
5493 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
5494 // Node name check avoids a VML-related crash in IE (#9807)
5495 var elem = e.target,
5496 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
5497 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
5498 jQuery.event.add( form, "submit._submit", function( event ) {
5499 event._submit_bubble = true;
5501 jQuery._data( form, "submitBubbles", true );
5504 // return undefined since we don't need an event listener
5507 postDispatch: function( event ) {
5508 // If form was submitted by the user, bubble the event up the tree
5509 if ( event._submit_bubble ) {
5510 delete event._submit_bubble;
5511 if ( this.parentNode && !event.isTrigger ) {
5512 jQuery.event.simulate( "submit", this.parentNode, event, true );
5517 teardown: function() {
5518 // Only need this for delegated form submit events
5519 if ( jQuery.nodeName( this, "form" ) ) {
5523 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
5524 jQuery.event.remove( this, "._submit" );
5529 // IE change delegation and checkbox/radio fix
5530 if ( !jQuery.support.changeBubbles ) {
5532 jQuery.event.special.change = {
5536 if ( rformElems.test( this.nodeName ) ) {
5537 // IE doesn't fire change on a check/radio until blur; trigger it on click
5538 // after a propertychange. Eat the blur-change in special.change.handle.
5539 // This still fires onchange a second time for check/radio after blur.
5540 if ( this.type === "checkbox" || this.type === "radio" ) {
5541 jQuery.event.add( this, "propertychange._change", function( event ) {
5542 if ( event.originalEvent.propertyName === "checked" ) {
5543 this._just_changed = true;
5546 jQuery.event.add( this, "click._change", function( event ) {
5547 if ( this._just_changed && !event.isTrigger ) {
5548 this._just_changed = false;
5550 // Allow triggered, simulated change events (#11500)
5551 jQuery.event.simulate( "change", this, event, true );
5556 // Delegated event; lazy-add a change handler on descendant inputs
5557 jQuery.event.add( this, "beforeactivate._change", function( e ) {
5558 var elem = e.target;
5560 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
5561 jQuery.event.add( elem, "change._change", function( event ) {
5562 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
5563 jQuery.event.simulate( "change", this.parentNode, event, true );
5566 jQuery._data( elem, "changeBubbles", true );
5571 handle: function( event ) {
5572 var elem = event.target;
5574 // Swallow native change events from checkbox/radio, we already triggered them above
5575 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
5576 return event.handleObj.handler.apply( this, arguments );
5580 teardown: function() {
5581 jQuery.event.remove( this, "._change" );
5583 return !rformElems.test( this.nodeName );
5588 // Create "bubbling" focus and blur events
5589 if ( !jQuery.support.focusinBubbles ) {
5590 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
5592 // Attach a single capturing handler while someone wants focusin/focusout
5594 handler = function( event ) {
5595 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
5598 jQuery.event.special[ fix ] = {
5600 if ( attaches++ === 0 ) {
5601 document.addEventListener( orig, handler, true );
5604 teardown: function() {
5605 if ( --attaches === 0 ) {
5606 document.removeEventListener( orig, handler, true );
5615 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
5618 // Types can be a map of types/handlers
5619 if ( typeof types === "object" ) {
5620 // ( types-Object, selector, data )
5621 if ( typeof selector !== "string" ) {
5622 // ( types-Object, data )
5623 data = data || selector;
5624 selector = undefined;
5626 for ( type in types ) {
5627 this.on( type, selector, data, types[ type ], one );
5632 if ( data == null && fn == null ) {
5635 data = selector = undefined;
5636 } else if ( fn == null ) {
5637 if ( typeof selector === "string" ) {
5638 // ( types, selector, fn )
5642 // ( types, data, fn )
5645 selector = undefined;
5648 if ( fn === false ) {
5656 fn = function( event ) {
5657 // Can use an empty set, since event contains the info
5658 jQuery().off( event );
5659 return origFn.apply( this, arguments );
5661 // Use same guid so caller can remove using origFn
5662 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
5664 return this.each( function() {
5665 jQuery.event.add( this, types, fn, data, selector );
5668 one: function( types, selector, data, fn ) {
5669 return this.on( types, selector, data, fn, 1 );
5671 off: function( types, selector, fn ) {
5672 var handleObj, type;
5673 if ( types && types.preventDefault && types.handleObj ) {
5674 // ( event ) dispatched jQuery.Event
5675 handleObj = types.handleObj;
5676 jQuery( types.delegateTarget ).off(
5677 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
5683 if ( typeof types === "object" ) {
5684 // ( types-object [, selector] )
5685 for ( type in types ) {
5686 this.off( type, selector, types[ type ] );
5690 if ( selector === false || typeof selector === "function" ) {
5693 selector = undefined;
5695 if ( fn === false ) {
5698 return this.each(function() {
5699 jQuery.event.remove( this, types, fn, selector );
5703 trigger: function( type, data ) {
5704 return this.each(function() {
5705 jQuery.event.trigger( type, data, this );
5708 triggerHandler: function( type, data ) {
5711 return jQuery.event.trigger( type, data, elem, true );
5715 var isSimple = /^.[^:#\[\.,]*$/,
5716 rparentsprev = /^(?:parents|prev(?:Until|All))/,
5717 rneedsContext = jQuery.expr.match.needsContext,
5718 // methods guaranteed to produce a unique set when starting from a unique set
5719 guaranteedUnique = {
5727 find: function( selector ) {
5733 if ( typeof selector !== "string" ) {
5734 return this.pushStack( jQuery( selector ).filter(function() {
5735 for ( i = 0; i < len; i++ ) {
5736 if ( jQuery.contains( self[ i ], this ) ) {
5743 for ( i = 0; i < len; i++ ) {
5744 jQuery.find( selector, self[ i ], ret );
5747 // Needed because $( selector, context ) becomes $( context ).find( selector )
5748 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
5749 ret.selector = this.selector ? this.selector + " " + selector : selector;
5753 has: function( target ) {
5755 targets = jQuery( target, this ),
5756 len = targets.length;
5758 return this.filter(function() {
5759 for ( i = 0; i < len; i++ ) {
5760 if ( jQuery.contains( this, targets[i] ) ) {
5767 not: function( selector ) {
5768 return this.pushStack( winnow(this, selector || [], true) );
5771 filter: function( selector ) {
5772 return this.pushStack( winnow(this, selector || [], false) );
5775 is: function( selector ) {
5779 // If this is a positional/relative selector, check membership in the returned set
5780 // so $("p:first").is("p:last") won't return true for a doc with two "p".
5781 typeof selector === "string" && rneedsContext.test( selector ) ?
5782 jQuery( selector ) :
5788 closest: function( selectors, context ) {
5793 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
5794 jQuery( selectors, context || this.context ) :
5797 for ( ; i < l; i++ ) {
5798 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
5799 // Always skip document fragments
5800 if ( cur.nodeType < 11 && (pos ?
5801 pos.index(cur) > -1 :
5803 // Don't pass non-elements to Sizzle
5804 cur.nodeType === 1 &&
5805 jQuery.find.matchesSelector(cur, selectors)) ) {
5807 cur = ret.push( cur );
5813 return this.pushStack( ret.length > 1 ? jQuery.unique( ret ) : ret );
5816 // Determine the position of an element within
5817 // the matched set of elements
5818 index: function( elem ) {
5820 // No argument, return index in parent
5822 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
5825 // index in selector
5826 if ( typeof elem === "string" ) {
5827 return jQuery.inArray( this[0], jQuery( elem ) );
5830 // Locate the position of the desired element
5831 return jQuery.inArray(
5832 // If it receives a jQuery object, the first element is used
5833 elem.jquery ? elem[0] : elem, this );
5836 add: function( selector, context ) {
5837 var set = typeof selector === "string" ?
5838 jQuery( selector, context ) :
5839 jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
5840 all = jQuery.merge( this.get(), set );
5842 return this.pushStack( jQuery.unique(all) );
5845 addBack: function( selector ) {
5846 return this.add( selector == null ?
5847 this.prevObject : this.prevObject.filter(selector)
5852 function sibling( cur, dir ) {
5855 } while ( cur && cur.nodeType !== 1 );
5861 parent: function( elem ) {
5862 var parent = elem.parentNode;
5863 return parent && parent.nodeType !== 11 ? parent : null;
5865 parents: function( elem ) {
5866 return jQuery.dir( elem, "parentNode" );
5868 parentsUntil: function( elem, i, until ) {
5869 return jQuery.dir( elem, "parentNode", until );
5871 next: function( elem ) {
5872 return sibling( elem, "nextSibling" );
5874 prev: function( elem ) {
5875 return sibling( elem, "previousSibling" );
5877 nextAll: function( elem ) {
5878 return jQuery.dir( elem, "nextSibling" );
5880 prevAll: function( elem ) {
5881 return jQuery.dir( elem, "previousSibling" );
5883 nextUntil: function( elem, i, until ) {
5884 return jQuery.dir( elem, "nextSibling", until );
5886 prevUntil: function( elem, i, until ) {
5887 return jQuery.dir( elem, "previousSibling", until );
5889 siblings: function( elem ) {
5890 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
5892 children: function( elem ) {
5893 return jQuery.sibling( elem.firstChild );
5895 contents: function( elem ) {
5896 return jQuery.nodeName( elem, "iframe" ) ?
5897 elem.contentDocument || elem.contentWindow.document :
5898 jQuery.merge( [], elem.childNodes );
5900 }, function( name, fn ) {
5901 jQuery.fn[ name ] = function( until, selector ) {
5902 var ret = jQuery.map( this, fn, until );
5904 if ( name.slice( -5 ) !== "Until" ) {
5908 if ( selector && typeof selector === "string" ) {
5909 ret = jQuery.filter( selector, ret );
5912 if ( this.length > 1 ) {
5913 // Remove duplicates
5914 if ( !guaranteedUnique[ name ] ) {
5915 ret = jQuery.unique( ret );
5918 // Reverse order for parents* and prev-derivatives
5919 if ( rparentsprev.test( name ) ) {
5920 ret = ret.reverse();
5924 return this.pushStack( ret );
5929 filter: function( expr, elems, not ) {
5930 var elem = elems[ 0 ];
5933 expr = ":not(" + expr + ")";
5936 return elems.length === 1 && elem.nodeType === 1 ?
5937 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
5938 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
5939 return elem.nodeType === 1;
5943 dir: function( elem, dir, until ) {
5947 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
5948 if ( cur.nodeType === 1 ) {
5949 matched.push( cur );
5956 sibling: function( n, elem ) {
5959 for ( ; n; n = n.nextSibling ) {
5960 if ( n.nodeType === 1 && n !== elem ) {
5969 // Implement the identical functionality for filter and not
5970 function winnow( elements, qualifier, not ) {
5971 if ( jQuery.isFunction( qualifier ) ) {
5972 return jQuery.grep( elements, function( elem, i ) {
5974 return !!qualifier.call( elem, i, elem ) !== not;
5979 if ( qualifier.nodeType ) {
5980 return jQuery.grep( elements, function( elem ) {
5981 return ( elem === qualifier ) !== not;
5986 if ( typeof qualifier === "string" ) {
5987 if ( isSimple.test( qualifier ) ) {
5988 return jQuery.filter( qualifier, elements, not );
5991 qualifier = jQuery.filter( qualifier, elements );
5994 return jQuery.grep( elements, function( elem ) {
5995 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
5998 function createSafeFragment( document ) {
5999 var list = nodeNames.split( "|" ),
6000 safeFrag = document.createDocumentFragment();
6002 if ( safeFrag.createElement ) {
6003 while ( list.length ) {
6004 safeFrag.createElement(
6012 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
6013 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
6014 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
6015 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
6016 rleadingWhitespace = /^\s+/,
6017 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
6018 rtagName = /<([\w:]+)/,
6020 rhtml = /<|&#?\w+;/,
6021 rnoInnerhtml = /<(?:script|style|link)/i,
6022 manipulation_rcheckableType = /^(?:checkbox|radio)$/i,
6023 // checked="checked" or checked
6024 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
6025 rscriptType = /^$|\/(?:java|ecma)script/i,
6026 rscriptTypeMasked = /^true\/(.*)/,
6027 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
6029 // We have to close these tags to support XHTML (#13200)
6031 option: [ 1, "<select multiple='multiple'>", "</select>" ],
6032 legend: [ 1, "<fieldset>", "</fieldset>" ],
6033 area: [ 1, "<map>", "</map>" ],
6034 param: [ 1, "<object>", "</object>" ],
6035 thead: [ 1, "<table>", "</table>" ],
6036 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
6037 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
6038 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
6040 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
6041 // unless wrapped in a div with non-breaking characters in front of it.
6042 _default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
6044 safeFragment = createSafeFragment( document ),
6045 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
6047 wrapMap.optgroup = wrapMap.option;
6048 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
6049 wrapMap.th = wrapMap.td;
6052 text: function( value ) {
6053 return jQuery.access( this, function( value ) {
6054 return value === undefined ?
6055 jQuery.text( this ) :
6056 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
6057 }, null, value, arguments.length );
6060 append: function() {
6061 return this.domManip( arguments, function( elem ) {
6062 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6063 var target = manipulationTarget( this, elem );
6064 target.appendChild( elem );
6069 prepend: function() {
6070 return this.domManip( arguments, function( elem ) {
6071 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6072 var target = manipulationTarget( this, elem );
6073 target.insertBefore( elem, target.firstChild );
6078 before: function() {
6079 return this.domManip( arguments, function( elem ) {
6080 if ( this.parentNode ) {
6081 this.parentNode.insertBefore( elem, this );
6087 return this.domManip( arguments, function( elem ) {
6088 if ( this.parentNode ) {
6089 this.parentNode.insertBefore( elem, this.nextSibling );
6094 // keepData is for internal use only--do not document
6095 remove: function( selector, keepData ) {
6097 elems = selector ? jQuery.filter( selector, this ) : this,
6100 for ( ; (elem = elems[i]) != null; i++ ) {
6102 if ( !keepData && elem.nodeType === 1 ) {
6103 jQuery.cleanData( getAll( elem ) );
6106 if ( elem.parentNode ) {
6107 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
6108 setGlobalEval( getAll( elem, "script" ) );
6110 elem.parentNode.removeChild( elem );
6121 for ( ; (elem = this[i]) != null; i++ ) {
6122 // Remove element nodes and prevent memory leaks
6123 if ( elem.nodeType === 1 ) {
6124 jQuery.cleanData( getAll( elem, false ) );
6127 // Remove any remaining nodes
6128 while ( elem.firstChild ) {
6129 elem.removeChild( elem.firstChild );
6132 // If this is a select, ensure that it displays empty (#12336)
6134 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
6135 elem.options.length = 0;
6142 clone: function( dataAndEvents, deepDataAndEvents ) {
6143 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6144 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6146 return this.map( function () {
6147 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6151 html: function( value ) {
6152 return jQuery.access( this, function( value ) {
6153 var elem = this[0] || {},
6157 if ( value === undefined ) {
6158 return elem.nodeType === 1 ?
6159 elem.innerHTML.replace( rinlinejQuery, "" ) :
6163 // See if we can take a shortcut and just use innerHTML
6164 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6165 ( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
6166 ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
6167 !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
6169 value = value.replace( rxhtmlTag, "<$1></$2>" );
6172 for (; i < l; i++ ) {
6173 // Remove element nodes and prevent memory leaks
6174 elem = this[i] || {};
6175 if ( elem.nodeType === 1 ) {
6176 jQuery.cleanData( getAll( elem, false ) );
6177 elem.innerHTML = value;
6183 // If using innerHTML throws an exception, use the fallback method
6188 this.empty().append( value );
6190 }, null, value, arguments.length );
6193 replaceWith: function() {
6195 // Snapshot the DOM in case .domManip sweeps something relevant into its fragment
6196 args = jQuery.map( this, function( elem ) {
6197 return [ elem.nextSibling, elem.parentNode ];
6201 // Make the changes, replacing each context element with the new content
6202 this.domManip( arguments, function( elem ) {
6203 var next = args[ i++ ],
6204 parent = args[ i++ ];
6207 // Don't use the snapshot next if it has moved (#13810)
6208 if ( next && next.parentNode !== parent ) {
6209 next = this.nextSibling;
6211 jQuery( this ).remove();
6212 parent.insertBefore( elem, next );
6214 // Allow new content to include elements from the context set
6217 // Force removal if there was no new content (e.g., from empty arguments)
6218 return i ? this : this.remove();
6221 detach: function( selector ) {
6222 return this.remove( selector, true );
6225 domManip: function( args, callback, allowIntersection ) {
6227 // Flatten any nested arrays
6228 args = core_concat.apply( [], args );
6230 var first, node, hasScripts,
6231 scripts, doc, fragment,
6237 isFunction = jQuery.isFunction( value );
6239 // We can't cloneNode fragments that contain checked, in WebKit
6240 if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
6241 return this.each(function( index ) {
6242 var self = set.eq( index );
6244 args[0] = value.call( this, index, self.html() );
6246 self.domManip( args, callback, allowIntersection );
6251 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
6252 first = fragment.firstChild;
6254 if ( fragment.childNodes.length === 1 ) {
6259 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6260 hasScripts = scripts.length;
6262 // Use the original fragment for the last item instead of the first because it can end up
6263 // being emptied incorrectly in certain situations (#8070).
6264 for ( ; i < l; i++ ) {
6267 if ( i !== iNoClone ) {
6268 node = jQuery.clone( node, true, true );
6270 // Keep references to cloned scripts for later restoration
6272 jQuery.merge( scripts, getAll( node, "script" ) );
6276 callback.call( this[i], node, i );
6280 doc = scripts[ scripts.length - 1 ].ownerDocument;
6283 jQuery.map( scripts, restoreScript );
6285 // Evaluate executable scripts on first document insertion
6286 for ( i = 0; i < hasScripts; i++ ) {
6287 node = scripts[ i ];
6288 if ( rscriptType.test( node.type || "" ) &&
6289 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
6292 // Hope ajax is available...
6293 jQuery._evalUrl( node.src );
6295 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
6301 // Fix #11809: Avoid leaking memory
6302 fragment = first = null;
6311 // Manipulating tables requires a tbody
6312 function manipulationTarget( elem, content ) {
6313 return jQuery.nodeName( elem, "table" ) &&
6314 jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
6316 elem.getElementsByTagName("tbody")[0] ||
6317 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
6321 // Replace/restore the type attribute of script elements for safe DOM manipulation
6322 function disableScript( elem ) {
6323 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
6326 function restoreScript( elem ) {
6327 var match = rscriptTypeMasked.exec( elem.type );
6329 elem.type = match[1];
6331 elem.removeAttribute("type");
6336 // Mark scripts as having already been evaluated
6337 function setGlobalEval( elems, refElements ) {
6340 for ( ; (elem = elems[i]) != null; i++ ) {
6341 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
6345 function cloneCopyEvent( src, dest ) {
6347 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
6352 oldData = jQuery._data( src ),
6353 curData = jQuery._data( dest, oldData ),
6354 events = oldData.events;
6357 delete curData.handle;
6358 curData.events = {};
6360 for ( type in events ) {
6361 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6362 jQuery.event.add( dest, type, events[ type ][ i ] );
6367 // make the cloned public data object a copy from the original
6368 if ( curData.data ) {
6369 curData.data = jQuery.extend( {}, curData.data );
6373 function fixCloneNodeIssues( src, dest ) {
6374 var nodeName, e, data;
6376 // We do not need to do anything for non-Elements
6377 if ( dest.nodeType !== 1 ) {
6381 nodeName = dest.nodeName.toLowerCase();
6383 // IE6-8 copies events bound via attachEvent when using cloneNode.
6384 if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
6385 data = jQuery._data( dest );
6387 for ( e in data.events ) {
6388 jQuery.removeEvent( dest, e, data.handle );
6391 // Event data gets referenced instead of copied if the expando gets copied too
6392 dest.removeAttribute( jQuery.expando );
6395 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
6396 if ( nodeName === "script" && dest.text !== src.text ) {
6397 disableScript( dest ).text = src.text;
6398 restoreScript( dest );
6400 // IE6-10 improperly clones children of object elements using classid.
6401 // IE10 throws NoModificationAllowedError if parent is null, #12132.
6402 } else if ( nodeName === "object" ) {
6403 if ( dest.parentNode ) {
6404 dest.outerHTML = src.outerHTML;
6407 // This path appears unavoidable for IE9. When cloning an object
6408 // element in IE9, the outerHTML strategy above is not sufficient.
6409 // If the src has innerHTML and the destination does not,
6410 // copy the src.innerHTML into the dest.innerHTML. #10324
6411 if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
6412 dest.innerHTML = src.innerHTML;
6415 } else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
6416 // IE6-8 fails to persist the checked state of a cloned checkbox
6417 // or radio button. Worse, IE6-7 fail to give the cloned element
6418 // a checked appearance if the defaultChecked value isn't also set
6420 dest.defaultChecked = dest.checked = src.checked;
6422 // IE6-7 get confused and end up setting the value of a cloned
6423 // checkbox/radio button to an empty string instead of "on"
6424 if ( dest.value !== src.value ) {
6425 dest.value = src.value;
6428 // IE6-8 fails to return the selected option to the default selected
6429 // state when cloning options
6430 } else if ( nodeName === "option" ) {
6431 dest.defaultSelected = dest.selected = src.defaultSelected;
6433 // IE6-8 fails to set the defaultValue to the correct value when
6434 // cloning other types of input fields
6435 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6436 dest.defaultValue = src.defaultValue;
6442 prependTo: "prepend",
6443 insertBefore: "before",
6444 insertAfter: "after",
6445 replaceAll: "replaceWith"
6446 }, function( name, original ) {
6447 jQuery.fn[ name ] = function( selector ) {
6451 insert = jQuery( selector ),
6452 last = insert.length - 1;
6454 for ( ; i <= last; i++ ) {
6455 elems = i === last ? this : this.clone(true);
6456 jQuery( insert[i] )[ original ]( elems );
6458 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
6459 core_push.apply( ret, elems.get() );
6462 return this.pushStack( ret );
6466 function getAll( context, tag ) {
6469 found = typeof context.getElementsByTagName !== core_strundefined ? context.getElementsByTagName( tag || "*" ) :
6470 typeof context.querySelectorAll !== core_strundefined ? context.querySelectorAll( tag || "*" ) :
6474 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
6475 if ( !tag || jQuery.nodeName( elem, tag ) ) {
6478 jQuery.merge( found, getAll( elem, tag ) );
6483 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
6484 jQuery.merge( [ context ], found ) :
6488 // Used in buildFragment, fixes the defaultChecked property
6489 function fixDefaultChecked( elem ) {
6490 if ( manipulation_rcheckableType.test( elem.type ) ) {
6491 elem.defaultChecked = elem.checked;
6496 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6497 var destElements, node, clone, i, srcElements,
6498 inPage = jQuery.contains( elem.ownerDocument, elem );
6500 if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
6501 clone = elem.cloneNode( true );
6503 // IE<=8 does not properly clone detached, unknown element nodes
6505 fragmentDiv.innerHTML = elem.outerHTML;
6506 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
6509 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
6510 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
6512 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
6513 destElements = getAll( clone );
6514 srcElements = getAll( elem );
6516 // Fix all IE cloning issues
6517 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
6518 // Ensure that the destination node is not null; Fixes #9587
6519 if ( destElements[i] ) {
6520 fixCloneNodeIssues( node, destElements[i] );
6525 // Copy the events from the original to the clone
6526 if ( dataAndEvents ) {
6527 if ( deepDataAndEvents ) {
6528 srcElements = srcElements || getAll( elem );
6529 destElements = destElements || getAll( clone );
6531 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
6532 cloneCopyEvent( node, destElements[i] );
6535 cloneCopyEvent( elem, clone );
6539 // Preserve script evaluation history
6540 destElements = getAll( clone, "script" );
6541 if ( destElements.length > 0 ) {
6542 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6545 destElements = srcElements = node = null;
6547 // Return the cloned set
6551 buildFragment: function( elems, context, scripts, selection ) {
6552 var j, elem, contains,
6553 tmp, tag, tbody, wrap,
6556 // Ensure a safe fragment
6557 safe = createSafeFragment( context ),
6562 for ( ; i < l; i++ ) {
6565 if ( elem || elem === 0 ) {
6567 // Add nodes directly
6568 if ( jQuery.type( elem ) === "object" ) {
6569 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
6571 // Convert non-html into a text node
6572 } else if ( !rhtml.test( elem ) ) {
6573 nodes.push( context.createTextNode( elem ) );
6575 // Convert html into DOM nodes
6577 tmp = tmp || safe.appendChild( context.createElement("div") );
6579 // Deserialize a standard representation
6580 tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
6581 wrap = wrapMap[ tag ] || wrapMap._default;
6583 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
6585 // Descend through wrappers to the right content
6588 tmp = tmp.lastChild;
6591 // Manually add leading whitespace removed by IE
6592 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
6593 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
6596 // Remove IE's autoinserted <tbody> from table fragments
6597 if ( !jQuery.support.tbody ) {
6599 // String was a <table>, *may* have spurious <tbody>
6600 elem = tag === "table" && !rtbody.test( elem ) ?
6603 // String was a bare <thead> or <tfoot>
6604 wrap[1] === "<table>" && !rtbody.test( elem ) ?
6608 j = elem && elem.childNodes.length;
6610 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
6611 elem.removeChild( tbody );
6616 jQuery.merge( nodes, tmp.childNodes );
6618 // Fix #12392 for WebKit and IE > 9
6619 tmp.textContent = "";
6621 // Fix #12392 for oldIE
6622 while ( tmp.firstChild ) {
6623 tmp.removeChild( tmp.firstChild );
6626 // Remember the top-level container for proper cleanup
6627 tmp = safe.lastChild;
6632 // Fix #11356: Clear elements from fragment
6634 safe.removeChild( tmp );
6637 // Reset defaultChecked for any radios and checkboxes
6638 // about to be appended to the DOM in IE 6/7 (#8060)
6639 if ( !jQuery.support.appendChecked ) {
6640 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
6644 while ( (elem = nodes[ i++ ]) ) {
6646 // #4087 - If origin and destination elements are the same, and this is
6647 // that element, do not do anything
6648 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
6652 contains = jQuery.contains( elem.ownerDocument, elem );
6654 // Append to fragment
6655 tmp = getAll( safe.appendChild( elem ), "script" );
6657 // Preserve script evaluation history
6659 setGlobalEval( tmp );
6662 // Capture executables
6665 while ( (elem = tmp[ j++ ]) ) {
6666 if ( rscriptType.test( elem.type || "" ) ) {
6667 scripts.push( elem );
6678 cleanData: function( elems, /* internal */ acceptData ) {
6679 var elem, type, id, data,
6681 internalKey = jQuery.expando,
6682 cache = jQuery.cache,
6683 deleteExpando = jQuery.support.deleteExpando,
6684 special = jQuery.event.special;
6686 for ( ; (elem = elems[i]) != null; i++ ) {
6688 if ( acceptData || jQuery.acceptData( elem ) ) {
6690 id = elem[ internalKey ];
6691 data = id && cache[ id ];
6694 if ( data.events ) {
6695 for ( type in data.events ) {
6696 if ( special[ type ] ) {
6697 jQuery.event.remove( elem, type );
6699 // This is a shortcut to avoid jQuery.event.remove's overhead
6701 jQuery.removeEvent( elem, type, data.handle );
6706 // Remove cache only if it was not already removed by jQuery.event.remove
6707 if ( cache[ id ] ) {
6711 // IE does not allow us to delete expando properties from nodes,
6712 // nor does it have a removeAttribute function on Document nodes;
6713 // we must handle all of these cases
6714 if ( deleteExpando ) {
6715 delete elem[ internalKey ];
6717 } else if ( typeof elem.removeAttribute !== core_strundefined ) {
6718 elem.removeAttribute( internalKey );
6721 elem[ internalKey ] = null;
6724 core_deletedIds.push( id );
6731 _evalUrl: function( url ) {
6732 return jQuery.ajax({
6743 wrapAll: function( html ) {
6744 if ( jQuery.isFunction( html ) ) {
6745 return this.each(function(i) {
6746 jQuery(this).wrapAll( html.call(this, i) );
6751 // The elements to wrap the target around
6752 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
6754 if ( this[0].parentNode ) {
6755 wrap.insertBefore( this[0] );
6758 wrap.map(function() {
6761 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
6762 elem = elem.firstChild;
6772 wrapInner: function( html ) {
6773 if ( jQuery.isFunction( html ) ) {
6774 return this.each(function(i) {
6775 jQuery(this).wrapInner( html.call(this, i) );
6779 return this.each(function() {
6780 var self = jQuery( this ),
6781 contents = self.contents();
6783 if ( contents.length ) {
6784 contents.wrapAll( html );
6787 self.append( html );
6792 wrap: function( html ) {
6793 var isFunction = jQuery.isFunction( html );
6795 return this.each(function(i) {
6796 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
6800 unwrap: function() {
6801 return this.parent().each(function() {
6802 if ( !jQuery.nodeName( this, "body" ) ) {
6803 jQuery( this ).replaceWith( this.childNodes );
6808 var iframe, getStyles, curCSS,
6809 ralpha = /alpha\([^)]*\)/i,
6810 ropacity = /opacity\s*=\s*([^)]*)/,
6811 rposition = /^(top|right|bottom|left)$/,
6812 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
6813 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6814 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6815 rmargin = /^margin/,
6816 rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
6817 rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
6818 rrelNum = new RegExp( "^([+-])=(" + core_pnum + ")", "i" ),
6819 elemdisplay = { BODY: "block" },
6821 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6822 cssNormalTransform = {
6827 cssExpand = [ "Top", "Right", "Bottom", "Left" ],
6828 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
6830 // return a css property mapped to a potentially vendor prefixed property
6831 function vendorPropName( style, name ) {
6833 // shortcut for names that are not vendor prefixed
6834 if ( name in style ) {
6838 // check for vendor prefixed names
6839 var capName = name.charAt(0).toUpperCase() + name.slice(1),
6841 i = cssPrefixes.length;
6844 name = cssPrefixes[ i ] + capName;
6845 if ( name in style ) {
6853 function isHidden( elem, el ) {
6854 // isHidden might be called from jQuery#filter function;
6855 // in that case, element will be second argument
6857 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
6860 function showHide( elements, show ) {
6861 var display, elem, hidden,
6864 length = elements.length;
6866 for ( ; index < length; index++ ) {
6867 elem = elements[ index ];
6868 if ( !elem.style ) {
6872 values[ index ] = jQuery._data( elem, "olddisplay" );
6873 display = elem.style.display;
6875 // Reset the inline display of this element to learn if it is
6876 // being hidden by cascaded rules or not
6877 if ( !values[ index ] && display === "none" ) {
6878 elem.style.display = "";
6881 // Set elements which have been overridden with display: none
6882 // in a stylesheet to whatever the default browser style is
6883 // for such an element
6884 if ( elem.style.display === "" && isHidden( elem ) ) {
6885 values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
6889 if ( !values[ index ] ) {
6890 hidden = isHidden( elem );
6892 if ( display && display !== "none" || !hidden ) {
6893 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
6899 // Set the display of most of the elements in a second loop
6900 // to avoid the constant reflow
6901 for ( index = 0; index < length; index++ ) {
6902 elem = elements[ index ];
6903 if ( !elem.style ) {
6906 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
6907 elem.style.display = show ? values[ index ] || "" : "none";
6915 css: function( name, value ) {
6916 return jQuery.access( this, function( elem, name, value ) {
6921 if ( jQuery.isArray( name ) ) {
6922 styles = getStyles( elem );
6925 for ( ; i < len; i++ ) {
6926 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
6932 return value !== undefined ?
6933 jQuery.style( elem, name, value ) :
6934 jQuery.css( elem, name );
6935 }, name, value, arguments.length > 1 );
6938 return showHide( this, true );
6941 return showHide( this );
6943 toggle: function( state ) {
6944 if ( typeof state === "boolean" ) {
6945 return state ? this.show() : this.hide();
6948 return this.each(function() {
6949 if ( isHidden( this ) ) {
6950 jQuery( this ).show();
6952 jQuery( this ).hide();
6959 // Add in style property hooks for overriding the default
6960 // behavior of getting and setting a style property
6963 get: function( elem, computed ) {
6965 // We should always get a number back from opacity
6966 var ret = curCSS( elem, "opacity" );
6967 return ret === "" ? "1" : ret;
6973 // Don't automatically add "px" to these possibly-unitless properties
6975 "columnCount": true,
6976 "fillOpacity": true,
6987 // Add in properties whose names you wish to fix before
6988 // setting or getting the value
6990 // normalize float css property
6991 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
6994 // Get and set the style property on a DOM Node
6995 style: function( elem, name, value, extra ) {
6996 // Don't set styles on text and comment nodes
6997 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
7001 // Make sure that we're working with the right name
7002 var ret, type, hooks,
7003 origName = jQuery.camelCase( name ),
7006 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
7008 // gets hook for the prefixed version
7009 // followed by the unprefixed version
7010 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7012 // Check if we're setting a value
7013 if ( value !== undefined ) {
7014 type = typeof value;
7016 // convert relative number strings (+= or -=) to relative numbers. #7345
7017 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
7018 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
7023 // Make sure that NaN and null values aren't set. See: #7116
7024 if ( value == null || type === "number" && isNaN( value ) ) {
7028 // If a number was passed in, add 'px' to the (except for certain CSS properties)
7029 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
7033 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
7034 // but it would mean to define eight (for every problematic property) identical functions
7035 if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
7036 style[ name ] = "inherit";
7039 // If a hook was provided, use that value, otherwise just set the specified value
7040 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
7042 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
7045 style[ name ] = value;
7050 // If a hook was provided get the non-computed value from there
7051 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
7055 // Otherwise just get the value from the style object
7056 return style[ name ];
7060 css: function( elem, name, extra, styles ) {
7061 var num, val, hooks,
7062 origName = jQuery.camelCase( name );
7064 // Make sure that we're working with the right name
7065 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
7067 // gets hook for the prefixed version
7068 // followed by the unprefixed version
7069 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7071 // If a hook was provided get the computed value from there
7072 if ( hooks && "get" in hooks ) {
7073 val = hooks.get( elem, true, extra );
7076 // Otherwise, if a way to get the computed value exists, use that
7077 if ( val === undefined ) {
7078 val = curCSS( elem, name, styles );
7081 //convert "normal" to computed value
7082 if ( val === "normal" && name in cssNormalTransform ) {
7083 val = cssNormalTransform[ name ];
7086 // Return, converting to number if forced or a qualifier was provided and val looks numeric
7087 if ( extra === "" || extra ) {
7088 num = parseFloat( val );
7089 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
7095 // NOTE: we've included the "window" in window.getComputedStyle
7096 // because jsdom on node.js will break without it.
7097 if ( window.getComputedStyle ) {
7098 getStyles = function( elem ) {
7099 return window.getComputedStyle( elem, null );
7102 curCSS = function( elem, name, _computed ) {
7103 var width, minWidth, maxWidth,
7104 computed = _computed || getStyles( elem ),
7106 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
7107 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined,
7112 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
7113 ret = jQuery.style( elem, name );
7116 // A tribute to the "awesome hack by Dean Edwards"
7117 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
7118 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
7119 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
7120 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
7122 // Remember the original values
7123 width = style.width;
7124 minWidth = style.minWidth;
7125 maxWidth = style.maxWidth;
7127 // Put in the new values to get a computed value out
7128 style.minWidth = style.maxWidth = style.width = ret;
7129 ret = computed.width;
7131 // Revert the changed values
7132 style.width = width;
7133 style.minWidth = minWidth;
7134 style.maxWidth = maxWidth;
7140 } else if ( document.documentElement.currentStyle ) {
7141 getStyles = function( elem ) {
7142 return elem.currentStyle;
7145 curCSS = function( elem, name, _computed ) {
7146 var left, rs, rsLeft,
7147 computed = _computed || getStyles( elem ),
7148 ret = computed ? computed[ name ] : undefined,
7151 // Avoid setting ret to empty string here
7152 // so we don't default to auto
7153 if ( ret == null && style && style[ name ] ) {
7154 ret = style[ name ];
7157 // From the awesome hack by Dean Edwards
7158 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
7160 // If we're not dealing with a regular pixel number
7161 // but a number that has a weird ending, we need to convert it to pixels
7162 // but not position css attributes, as those are proportional to the parent element instead
7163 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
7164 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
7166 // Remember the original values
7168 rs = elem.runtimeStyle;
7169 rsLeft = rs && rs.left;
7171 // Put in the new values to get a computed value out
7173 rs.left = elem.currentStyle.left;
7175 style.left = name === "fontSize" ? "1em" : ret;
7176 ret = style.pixelLeft + "px";
7178 // Revert the changed values
7185 return ret === "" ? "auto" : ret;
7189 function setPositiveNumber( elem, value, subtract ) {
7190 var matches = rnumsplit.exec( value );
7192 // Guard against undefined "subtract", e.g., when used as in cssHooks
7193 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
7197 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
7198 var i = extra === ( isBorderBox ? "border" : "content" ) ?
7199 // If we already have the right measurement, avoid augmentation
7201 // Otherwise initialize for horizontal or vertical properties
7202 name === "width" ? 1 : 0,
7206 for ( ; i < 4; i += 2 ) {
7207 // both box models exclude margin, so add it if we want it
7208 if ( extra === "margin" ) {
7209 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
7212 if ( isBorderBox ) {
7213 // border-box includes padding, so remove it if we want content
7214 if ( extra === "content" ) {
7215 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7218 // at this point, extra isn't border nor margin, so remove border
7219 if ( extra !== "margin" ) {
7220 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7223 // at this point, extra isn't content, so add padding
7224 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
7226 // at this point, extra isn't content nor padding, so add border
7227 if ( extra !== "padding" ) {
7228 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
7236 function getWidthOrHeight( elem, name, extra ) {
7238 // Start with offset property, which is equivalent to the border-box value
7239 var valueIsBorderBox = true,
7240 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
7241 styles = getStyles( elem ),
7242 isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
7244 // some non-html elements return undefined for offsetWidth, so check for null/undefined
7245 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
7246 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
7247 if ( val <= 0 || val == null ) {
7248 // Fall back to computed then uncomputed css if necessary
7249 val = curCSS( elem, name, styles );
7250 if ( val < 0 || val == null ) {
7251 val = elem.style[ name ];
7254 // Computed unit is not pixels. Stop here and return.
7255 if ( rnumnonpx.test(val) ) {
7259 // we need the check for style in case a browser which returns unreliable values
7260 // for getComputedStyle silently falls back to the reliable elem.style
7261 valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
7263 // Normalize "", auto, and prepare for extra
7264 val = parseFloat( val ) || 0;
7267 // use the active box-sizing model to add/subtract irrelevant styles
7269 augmentWidthOrHeight(
7272 extra || ( isBorderBox ? "border" : "content" ),
7279 // Try to determine the default display value of an element
7280 function css_defaultDisplay( nodeName ) {
7282 display = elemdisplay[ nodeName ];
7285 display = actualDisplay( nodeName, doc );
7287 // If the simple way fails, read from inside an iframe
7288 if ( display === "none" || !display ) {
7289 // Use the already-created iframe if possible
7290 iframe = ( iframe ||
7291 jQuery("<iframe frameborder='0' width='0' height='0'/>")
7292 .css( "cssText", "display:block !important" )
7293 ).appendTo( doc.documentElement );
7295 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
7296 doc = ( iframe[0].contentWindow || iframe[0].contentDocument ).document;
7297 doc.write("<!doctype html><html><body>");
7300 display = actualDisplay( nodeName, doc );
7304 // Store the correct default display
7305 elemdisplay[ nodeName ] = display;
7311 // Called ONLY from within css_defaultDisplay
7312 function actualDisplay( name, doc ) {
7313 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
7314 display = jQuery.css( elem[0], "display" );
7319 jQuery.each([ "height", "width" ], function( i, name ) {
7320 jQuery.cssHooks[ name ] = {
7321 get: function( elem, computed, extra ) {
7323 // certain elements can have dimension info if we invisibly show them
7324 // however, it must have a current display style that would benefit from this
7325 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
7326 jQuery.swap( elem, cssShow, function() {
7327 return getWidthOrHeight( elem, name, extra );
7329 getWidthOrHeight( elem, name, extra );
7333 set: function( elem, value, extra ) {
7334 var styles = extra && getStyles( elem );
7335 return setPositiveNumber( elem, value, extra ?
7336 augmentWidthOrHeight(
7340 jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
7348 if ( !jQuery.support.opacity ) {
7349 jQuery.cssHooks.opacity = {
7350 get: function( elem, computed ) {
7351 // IE uses filters for opacity
7352 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
7353 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
7354 computed ? "1" : "";
7357 set: function( elem, value ) {
7358 var style = elem.style,
7359 currentStyle = elem.currentStyle,
7360 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
7361 filter = currentStyle && currentStyle.filter || style.filter || "";
7363 // IE has trouble with opacity if it does not have layout
7364 // Force it by setting the zoom level
7367 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
7368 // if value === "", then remove inline opacity #12685
7369 if ( ( value >= 1 || value === "" ) &&
7370 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
7371 style.removeAttribute ) {
7373 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
7374 // if "filter:" is present at all, clearType is disabled, we want to avoid this
7375 // style.removeAttribute is IE Only, but so apparently is this code path...
7376 style.removeAttribute( "filter" );
7378 // if there is no filter style applied in a css rule or unset inline opacity, we are done
7379 if ( value === "" || currentStyle && !currentStyle.filter ) {
7384 // otherwise, set new filter values
7385 style.filter = ralpha.test( filter ) ?
7386 filter.replace( ralpha, opacity ) :
7387 filter + " " + opacity;
7392 // These hooks cannot be added until DOM ready because the support test
7393 // for it is not run until after DOM ready
7395 if ( !jQuery.support.reliableMarginRight ) {
7396 jQuery.cssHooks.marginRight = {
7397 get: function( elem, computed ) {
7399 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
7400 // Work around by temporarily setting element display to inline-block
7401 return jQuery.swap( elem, { "display": "inline-block" },
7402 curCSS, [ elem, "marginRight" ] );
7408 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7409 // getComputedStyle returns percent when specified for top/left/bottom/right
7410 // rather than make the css module depend on the offset module, we just check for it here
7411 if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
7412 jQuery.each( [ "top", "left" ], function( i, prop ) {
7413 jQuery.cssHooks[ prop ] = {
7414 get: function( elem, computed ) {
7416 computed = curCSS( elem, prop );
7417 // if curCSS returns percentage, fallback to offset
7418 return rnumnonpx.test( computed ) ?
7419 jQuery( elem ).position()[ prop ] + "px" :
7429 if ( jQuery.expr && jQuery.expr.filters ) {
7430 jQuery.expr.filters.hidden = function( elem ) {
7431 // Support: Opera <= 12.12
7432 // Opera reports offsetWidths and offsetHeights less than zero on some elements
7433 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
7434 (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
7437 jQuery.expr.filters.visible = function( elem ) {
7438 return !jQuery.expr.filters.hidden( elem );
7442 // These hooks are used by animate to expand properties
7447 }, function( prefix, suffix ) {
7448 jQuery.cssHooks[ prefix + suffix ] = {
7449 expand: function( value ) {
7453 // assumes a single number if not a string
7454 parts = typeof value === "string" ? value.split(" ") : [ value ];
7456 for ( ; i < 4; i++ ) {
7457 expanded[ prefix + cssExpand[ i ] + suffix ] =
7458 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7465 if ( !rmargin.test( prefix ) ) {
7466 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7472 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
7473 rsubmittable = /^(?:input|select|textarea|keygen)/i;
7476 serialize: function() {
7477 return jQuery.param( this.serializeArray() );
7479 serializeArray: function() {
7480 return this.map(function(){
7481 // Can add propHook for "elements" to filter or add form elements
7482 var elements = jQuery.prop( this, "elements" );
7483 return elements ? jQuery.makeArray( elements ) : this;
7486 var type = this.type;
7487 // Use .is(":disabled") so that fieldset[disabled] works
7488 return this.name && !jQuery( this ).is( ":disabled" ) &&
7489 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
7490 ( this.checked || !manipulation_rcheckableType.test( type ) );
7492 .map(function( i, elem ){
7493 var val = jQuery( this ).val();
7495 return val == null ?
7497 jQuery.isArray( val ) ?
7498 jQuery.map( val, function( val ){
7499 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7501 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
7506 //Serialize an array of form elements or a set of
7507 //key/values into a query string
7508 jQuery.param = function( a, traditional ) {
7511 add = function( key, value ) {
7512 // If value is a function, invoke it and return its value
7513 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
7514 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
7517 // Set traditional to true for jQuery <= 1.3.2 behavior.
7518 if ( traditional === undefined ) {
7519 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
7522 // If an array was passed in, assume that it is an array of form elements.
7523 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
7524 // Serialize the form elements
7525 jQuery.each( a, function() {
7526 add( this.name, this.value );
7530 // If traditional, encode the "old" way (the way 1.3.2 or older
7531 // did it), otherwise encode params recursively.
7532 for ( prefix in a ) {
7533 buildParams( prefix, a[ prefix ], traditional, add );
7537 // Return the resulting serialization
7538 return s.join( "&" ).replace( r20, "+" );
7541 function buildParams( prefix, obj, traditional, add ) {
7544 if ( jQuery.isArray( obj ) ) {
7545 // Serialize array item.
7546 jQuery.each( obj, function( i, v ) {
7547 if ( traditional || rbracket.test( prefix ) ) {
7548 // Treat each array item as a scalar.
7552 // Item is non-scalar (array or object), encode its numeric index.
7553 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
7557 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
7558 // Serialize object item.
7559 for ( name in obj ) {
7560 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
7564 // Serialize scalar item.
7568 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
7569 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
7570 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
7572 // Handle event binding
7573 jQuery.fn[ name ] = function( data, fn ) {
7574 return arguments.length > 0 ?
7575 this.on( name, null, data, fn ) :
7576 this.trigger( name );
7581 hover: function( fnOver, fnOut ) {
7582 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
7585 bind: function( types, data, fn ) {
7586 return this.on( types, null, data, fn );
7588 unbind: function( types, fn ) {
7589 return this.off( types, null, fn );
7592 delegate: function( selector, types, data, fn ) {
7593 return this.on( types, selector, data, fn );
7595 undelegate: function( selector, types, fn ) {
7596 // ( namespace ) or ( selector, types [, fn] )
7597 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
7601 // Document location
7604 ajax_nonce = jQuery.now(),
7608 rts = /([?&])_=[^&]*/,
7609 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
7610 // #7653, #8125, #8152: local protocol detection
7611 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
7612 rnoContent = /^(?:GET|HEAD)$/,
7613 rprotocol = /^\/\//,
7614 rurl = /^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
7616 // Keep a copy of the old load method
7617 _load = jQuery.fn.load,
7620 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
7621 * 2) These are called:
7622 * - BEFORE asking for a transport
7623 * - AFTER param serialization (s.data is a string if s.processData is true)
7624 * 3) key is the dataType
7625 * 4) the catchall symbol "*" can be used
7626 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
7630 /* Transports bindings
7631 * 1) key is the dataType
7632 * 2) the catchall symbol "*" can be used
7633 * 3) selection will start with transport dataType and THEN go to "*" if needed
7637 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
7638 allTypes = "*/".concat("*");
7640 // #8138, IE may throw an exception when accessing
7641 // a field from window.location if document.domain has been set
7643 ajaxLocation = location.href;
7645 // Use the href attribute of an A element
7646 // since IE will modify it given document.location
7647 ajaxLocation = document.createElement( "a" );
7648 ajaxLocation.href = "";
7649 ajaxLocation = ajaxLocation.href;
7652 // Segment location into parts
7653 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
7655 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
7656 function addToPrefiltersOrTransports( structure ) {
7658 // dataTypeExpression is optional and defaults to "*"
7659 return function( dataTypeExpression, func ) {
7661 if ( typeof dataTypeExpression !== "string" ) {
7662 func = dataTypeExpression;
7663 dataTypeExpression = "*";
7668 dataTypes = dataTypeExpression.toLowerCase().match( core_rnotwhite ) || [];
7670 if ( jQuery.isFunction( func ) ) {
7671 // For each dataType in the dataTypeExpression
7672 while ( (dataType = dataTypes[i++]) ) {
7673 // Prepend if requested
7674 if ( dataType[0] === "+" ) {
7675 dataType = dataType.slice( 1 ) || "*";
7676 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
7680 (structure[ dataType ] = structure[ dataType ] || []).push( func );
7687 // Base inspection function for prefilters and transports
7688 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
7691 seekingTransport = ( structure === transports );
7693 function inspect( dataType ) {
7695 inspected[ dataType ] = true;
7696 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
7697 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
7698 if( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
7699 options.dataTypes.unshift( dataTypeOrTransport );
7700 inspect( dataTypeOrTransport );
7702 } else if ( seekingTransport ) {
7703 return !( selected = dataTypeOrTransport );
7709 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
7712 // A special extend for ajax options
7713 // that takes "flat" options (not to be deep extended)
7715 function ajaxExtend( target, src ) {
7717 flatOptions = jQuery.ajaxSettings.flatOptions || {};
7719 for ( key in src ) {
7720 if ( src[ key ] !== undefined ) {
7721 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
7725 jQuery.extend( true, target, deep );
7731 jQuery.fn.load = function( url, params, callback ) {
7732 if ( typeof url !== "string" && _load ) {
7733 return _load.apply( this, arguments );
7736 var selector, response, type,
7738 off = url.indexOf(" ");
7741 selector = url.slice( off, url.length );
7742 url = url.slice( 0, off );
7745 // If it's a function
7746 if ( jQuery.isFunction( params ) ) {
7748 // We assume that it's the callback
7752 // Otherwise, build a param string
7753 } else if ( params && typeof params === "object" ) {
7757 // If we have elements to modify, make the request
7758 if ( self.length > 0 ) {
7762 // if "type" variable is undefined, then "GET" method will be used
7766 }).done(function( responseText ) {
7768 // Save response for use in complete callback
7769 response = arguments;
7771 self.html( selector ?
7773 // If a selector was specified, locate the right elements in a dummy div
7774 // Exclude scripts to avoid IE 'Permission Denied' errors
7775 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
7777 // Otherwise use the full result
7780 }).complete( callback && function( jqXHR, status ) {
7781 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
7788 // Attach a bunch of functions for handling common AJAX events
7789 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ){
7790 jQuery.fn[ type ] = function( fn ){
7791 return this.on( type, fn );
7797 // Counter for holding the number of active queries
7800 // Last-Modified header cache for next request
7807 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
7811 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
7828 xml: "application/xml, text/xml",
7829 json: "application/json, text/javascript"
7840 text: "responseText",
7841 json: "responseJSON"
7845 // Keys separate source (or catchall "*") and destination types with a single space
7848 // Convert anything to text
7851 // Text to html (true = no transformation)
7854 // Evaluate text as a json expression
7855 "text json": jQuery.parseJSON,
7857 // Parse text as xml
7858 "text xml": jQuery.parseXML
7861 // For options that shouldn't be deep extended:
7862 // you can add your own custom options here if
7863 // and when you create one that shouldn't be
7864 // deep extended (see ajaxExtend)
7871 // Creates a full fledged settings object into target
7872 // with both ajaxSettings and settings fields.
7873 // If target is omitted, writes into ajaxSettings.
7874 ajaxSetup: function( target, settings ) {
7877 // Building a settings object
7878 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
7880 // Extending ajaxSettings
7881 ajaxExtend( jQuery.ajaxSettings, target );
7884 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
7885 ajaxTransport: addToPrefiltersOrTransports( transports ),
7888 ajax: function( url, options ) {
7890 // If url is an object, simulate pre-1.5 signature
7891 if ( typeof url === "object" ) {
7896 // Force options to be an object
7897 options = options || {};
7899 var // Cross-domain detection vars
7903 // URL without anti-cache param
7905 // Response headers as string
7906 responseHeadersString,
7910 // To know if global events are to be dispatched
7916 // Create the final options object
7917 s = jQuery.ajaxSetup( {}, options ),
7918 // Callbacks context
7919 callbackContext = s.context || s,
7920 // Context for global events is callbackContext if it is a DOM node or jQuery collection
7921 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
7922 jQuery( callbackContext ) :
7925 deferred = jQuery.Deferred(),
7926 completeDeferred = jQuery.Callbacks("once memory"),
7927 // Status-dependent callbacks
7928 statusCode = s.statusCode || {},
7929 // Headers (they are sent all at once)
7930 requestHeaders = {},
7931 requestHeadersNames = {},
7934 // Default abort message
7935 strAbort = "canceled",
7940 // Builds headers hashtable if needed
7941 getResponseHeader: function( key ) {
7943 if ( state === 2 ) {
7944 if ( !responseHeaders ) {
7945 responseHeaders = {};
7946 while ( (match = rheaders.exec( responseHeadersString )) ) {
7947 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
7950 match = responseHeaders[ key.toLowerCase() ];
7952 return match == null ? null : match;
7956 getAllResponseHeaders: function() {
7957 return state === 2 ? responseHeadersString : null;
7960 // Caches the header
7961 setRequestHeader: function( name, value ) {
7962 var lname = name.toLowerCase();
7964 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
7965 requestHeaders[ name ] = value;
7970 // Overrides response content-type header
7971 overrideMimeType: function( type ) {
7978 // Status-dependent callbacks
7979 statusCode: function( map ) {
7983 for ( code in map ) {
7984 // Lazy-add the new callback in a way that preserves old ones
7985 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
7988 // Execute the appropriate callbacks
7989 jqXHR.always( map[ jqXHR.status ] );
7995 // Cancel the request
7996 abort: function( statusText ) {
7997 var finalText = statusText || strAbort;
7999 transport.abort( finalText );
8001 done( 0, finalText );
8007 deferred.promise( jqXHR ).complete = completeDeferred.add;
8008 jqXHR.success = jqXHR.done;
8009 jqXHR.error = jqXHR.fail;
8011 // Remove hash character (#7531: and string promotion)
8012 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
8013 // Handle falsy url in the settings object (#10093: consistency with old signature)
8014 // We also use the url parameter if available
8015 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
8017 // Alias method option to type as per ticket #12004
8018 s.type = options.method || options.type || s.method || s.type;
8020 // Extract dataTypes list
8021 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( core_rnotwhite ) || [""];
8023 // A cross-domain request is in order when we have a protocol:host:port mismatch
8024 if ( s.crossDomain == null ) {
8025 parts = rurl.exec( s.url.toLowerCase() );
8026 s.crossDomain = !!( parts &&
8027 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
8028 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
8029 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
8033 // Convert data if not already a string
8034 if ( s.data && s.processData && typeof s.data !== "string" ) {
8035 s.data = jQuery.param( s.data, s.traditional );
8039 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
8041 // If request was aborted inside a prefilter, stop there
8042 if ( state === 2 ) {
8046 // We can fire global events as of now if asked to
8047 fireGlobals = s.global;
8049 // Watch for a new set of requests
8050 if ( fireGlobals && jQuery.active++ === 0 ) {
8051 jQuery.event.trigger("ajaxStart");
8054 // Uppercase the type
8055 s.type = s.type.toUpperCase();
8057 // Determine if request has content
8058 s.hasContent = !rnoContent.test( s.type );
8060 // Save the URL in case we're toying with the If-Modified-Since
8061 // and/or If-None-Match header later on
8064 // More options handling for requests with no content
8065 if ( !s.hasContent ) {
8067 // If data is available, append data to url
8069 cacheURL = ( s.url += ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
8070 // #9682: remove data so that it's not used in an eventual retry
8074 // Add anti-cache in url if needed
8075 if ( s.cache === false ) {
8076 s.url = rts.test( cacheURL ) ?
8078 // If there is already a '_' parameter, set its value
8079 cacheURL.replace( rts, "$1_=" + ajax_nonce++ ) :
8081 // Otherwise add one to the end
8082 cacheURL + ( ajax_rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ajax_nonce++;
8086 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8087 if ( s.ifModified ) {
8088 if ( jQuery.lastModified[ cacheURL ] ) {
8089 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
8091 if ( jQuery.etag[ cacheURL ] ) {
8092 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
8096 // Set the correct header, if data is being sent
8097 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
8098 jqXHR.setRequestHeader( "Content-Type", s.contentType );
8101 // Set the Accepts header for the server, depending on the dataType
8102 jqXHR.setRequestHeader(
8104 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
8105 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
8109 // Check for headers option
8110 for ( i in s.headers ) {
8111 jqXHR.setRequestHeader( i, s.headers[ i ] );
8114 // Allow custom headers/mimetypes and early abort
8115 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
8116 // Abort if not done already and return
8117 return jqXHR.abort();
8120 // aborting is no longer a cancellation
8123 // Install callbacks on deferreds
8124 for ( i in { success: 1, error: 1, complete: 1 } ) {
8125 jqXHR[ i ]( s[ i ] );
8129 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
8131 // If no transport, we auto-abort
8133 done( -1, "No Transport" );
8135 jqXHR.readyState = 1;
8137 // Send global event
8138 if ( fireGlobals ) {
8139 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
8142 if ( s.async && s.timeout > 0 ) {
8143 timeoutTimer = setTimeout(function() {
8144 jqXHR.abort("timeout");
8150 transport.send( requestHeaders, done );
8152 // Propagate exception as error if not done
8155 // Simply rethrow otherwise
8162 // Callback for when everything is done
8163 function done( status, nativeStatusText, responses, headers ) {
8164 var isSuccess, success, error, response, modified,
8165 statusText = nativeStatusText;
8168 if ( state === 2 ) {
8172 // State is "done" now
8175 // Clear timeout if it exists
8176 if ( timeoutTimer ) {
8177 clearTimeout( timeoutTimer );
8180 // Dereference transport for early garbage collection
8181 // (no matter how long the jqXHR object will be used)
8182 transport = undefined;
8184 // Cache response headers
8185 responseHeadersString = headers || "";
8188 jqXHR.readyState = status > 0 ? 4 : 0;
8190 // Determine if successful
8191 isSuccess = status >= 200 && status < 300 || status === 304;
8193 // Get response data
8195 response = ajaxHandleResponses( s, jqXHR, responses );
8198 // Convert no matter what (that way responseXXX fields are always set)
8199 response = ajaxConvert( s, response, jqXHR, isSuccess );
8201 // If successful, handle type chaining
8204 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
8205 if ( s.ifModified ) {
8206 modified = jqXHR.getResponseHeader("Last-Modified");
8208 jQuery.lastModified[ cacheURL ] = modified;
8210 modified = jqXHR.getResponseHeader("etag");
8212 jQuery.etag[ cacheURL ] = modified;
8217 if ( status === 204 || s.type === "HEAD" ) {
8218 statusText = "nocontent";
8221 } else if ( status === 304 ) {
8222 statusText = "notmodified";
8224 // If we have data, let's convert it
8226 statusText = response.state;
8227 success = response.data;
8228 error = response.error;
8232 // We extract error from statusText
8233 // then normalize statusText and status for non-aborts
8235 if ( status || !statusText ) {
8236 statusText = "error";
8243 // Set data for the fake xhr object
8244 jqXHR.status = status;
8245 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
8249 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
8251 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
8254 // Status-dependent callbacks
8255 jqXHR.statusCode( statusCode );
8256 statusCode = undefined;
8258 if ( fireGlobals ) {
8259 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
8260 [ jqXHR, s, isSuccess ? success : error ] );
8264 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
8266 if ( fireGlobals ) {
8267 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
8268 // Handle the global AJAX counter
8269 if ( !( --jQuery.active ) ) {
8270 jQuery.event.trigger("ajaxStop");
8278 getJSON: function( url, data, callback ) {
8279 return jQuery.get( url, data, callback, "json" );
8282 getScript: function( url, callback ) {
8283 return jQuery.get( url, undefined, callback, "script" );
8287 jQuery.each( [ "get", "post" ], function( i, method ) {
8288 jQuery[ method ] = function( url, data, callback, type ) {
8289 // shift arguments if data argument was omitted
8290 if ( jQuery.isFunction( data ) ) {
8291 type = type || callback;
8296 return jQuery.ajax({
8306 /* Handles responses to an ajax request:
8307 * - finds the right dataType (mediates between content-type and expected dataType)
8308 * - returns the corresponding response
8310 function ajaxHandleResponses( s, jqXHR, responses ) {
8311 var firstDataType, ct, finalDataType, type,
8312 contents = s.contents,
8313 dataTypes = s.dataTypes;
8315 // Remove auto dataType and get content-type in the process
8316 while( dataTypes[ 0 ] === "*" ) {
8318 if ( ct === undefined ) {
8319 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
8323 // Check if we're dealing with a known content-type
8325 for ( type in contents ) {
8326 if ( contents[ type ] && contents[ type ].test( ct ) ) {
8327 dataTypes.unshift( type );
8333 // Check to see if we have a response for the expected dataType
8334 if ( dataTypes[ 0 ] in responses ) {
8335 finalDataType = dataTypes[ 0 ];
8337 // Try convertible dataTypes
8338 for ( type in responses ) {
8339 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
8340 finalDataType = type;
8343 if ( !firstDataType ) {
8344 firstDataType = type;
8347 // Or just use first one
8348 finalDataType = finalDataType || firstDataType;
8351 // If we found a dataType
8352 // We add the dataType to the list if needed
8353 // and return the corresponding response
8354 if ( finalDataType ) {
8355 if ( finalDataType !== dataTypes[ 0 ] ) {
8356 dataTypes.unshift( finalDataType );
8358 return responses[ finalDataType ];
8362 /* Chain conversions given the request and the original response
8363 * Also sets the responseXXX fields on the jqXHR instance
8365 function ajaxConvert( s, response, jqXHR, isSuccess ) {
8366 var conv2, current, conv, tmp, prev,
8368 // Work with a copy of dataTypes in case we need to modify it for conversion
8369 dataTypes = s.dataTypes.slice();
8371 // Create converters map with lowercased keys
8372 if ( dataTypes[ 1 ] ) {
8373 for ( conv in s.converters ) {
8374 converters[ conv.toLowerCase() ] = s.converters[ conv ];
8378 current = dataTypes.shift();
8380 // Convert to each sequential dataType
8383 if ( s.responseFields[ current ] ) {
8384 jqXHR[ s.responseFields[ current ] ] = response;
8387 // Apply the dataFilter if provided
8388 if ( !prev && isSuccess && s.dataFilter ) {
8389 response = s.dataFilter( response, s.dataType );
8393 current = dataTypes.shift();
8397 // There's only work to do if current dataType is non-auto
8398 if ( current === "*" ) {
8402 // Convert response if prev dataType is non-auto and differs from current
8403 } else if ( prev !== "*" && prev !== current ) {
8405 // Seek a direct converter
8406 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
8408 // If none found, seek a pair
8410 for ( conv2 in converters ) {
8412 // If conv2 outputs current
8413 tmp = conv2.split( " " );
8414 if ( tmp[ 1 ] === current ) {
8416 // If prev can be converted to accepted input
8417 conv = converters[ prev + " " + tmp[ 0 ] ] ||
8418 converters[ "* " + tmp[ 0 ] ];
8420 // Condense equivalence converters
8421 if ( conv === true ) {
8422 conv = converters[ conv2 ];
8424 // Otherwise, insert the intermediate dataType
8425 } else if ( converters[ conv2 ] !== true ) {
8427 dataTypes.unshift( tmp[ 1 ] );
8435 // Apply converter (if not an equivalence)
8436 if ( conv !== true ) {
8438 // Unless errors are allowed to bubble, catch and return them
8439 if ( conv && s[ "throws" ] ) {
8440 response = conv( response );
8443 response = conv( response );
8445 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
8453 return { state: "success", data: response };
8455 // Install script dataType
8458 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
8461 script: /(?:java|ecma)script/
8464 "text script": function( text ) {
8465 jQuery.globalEval( text );
8471 // Handle cache's special case and global
8472 jQuery.ajaxPrefilter( "script", function( s ) {
8473 if ( s.cache === undefined ) {
8476 if ( s.crossDomain ) {
8482 // Bind script tag hack transport
8483 jQuery.ajaxTransport( "script", function(s) {
8485 // This transport only deals with cross domain requests
8486 if ( s.crossDomain ) {
8489 head = document.head || jQuery("head")[0] || document.documentElement;
8493 send: function( _, callback ) {
8495 script = document.createElement("script");
8497 script.async = true;
8499 if ( s.scriptCharset ) {
8500 script.charset = s.scriptCharset;
8505 // Attach handlers for all browsers
8506 script.onload = script.onreadystatechange = function( _, isAbort ) {
8508 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
8510 // Handle memory leak in IE
8511 script.onload = script.onreadystatechange = null;
8513 // Remove the script
8514 if ( script.parentNode ) {
8515 script.parentNode.removeChild( script );
8518 // Dereference the script
8521 // Callback if not abort
8523 callback( 200, "success" );
8528 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
8529 // Use native DOM manipulation to avoid our domManip AJAX trickery
8530 head.insertBefore( script, head.firstChild );
8535 script.onload( undefined, true );
8541 var oldCallbacks = [],
8542 rjsonp = /(=)\?(?=&|$)|\?\?/;
8544 // Default jsonp settings
8547 jsonpCallback: function() {
8548 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( ajax_nonce++ ) );
8549 this[ callback ] = true;
8554 // Detect, normalize options and install callbacks for jsonp requests
8555 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8557 var callbackName, overwritten, responseContainer,
8558 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
8560 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
8563 // Handle iff the expected data type is "jsonp" or we have a parameter to set
8564 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
8566 // Get callback name, remembering preexisting value associated with it
8567 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
8571 // Insert callback into url or form data
8573 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
8574 } else if ( s.jsonp !== false ) {
8575 s.url += ( ajax_rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
8578 // Use data converter to retrieve json after script execution
8579 s.converters["script json"] = function() {
8580 if ( !responseContainer ) {
8581 jQuery.error( callbackName + " was not called" );
8583 return responseContainer[ 0 ];
8586 // force json dataType
8587 s.dataTypes[ 0 ] = "json";
8590 overwritten = window[ callbackName ];
8591 window[ callbackName ] = function() {
8592 responseContainer = arguments;
8595 // Clean-up function (fires after converters)
8596 jqXHR.always(function() {
8597 // Restore preexisting value
8598 window[ callbackName ] = overwritten;
8600 // Save back as free
8601 if ( s[ callbackName ] ) {
8602 // make sure that re-using the options doesn't screw things around
8603 s.jsonpCallback = originalSettings.jsonpCallback;
8605 // save the callback name for future use
8606 oldCallbacks.push( callbackName );
8609 // Call if it was a function and we have a response
8610 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
8611 overwritten( responseContainer[ 0 ] );
8614 responseContainer = overwritten = undefined;
8617 // Delegate to script
8621 var xhrCallbacks, xhrSupported,
8623 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
8624 xhrOnUnloadAbort = window.ActiveXObject && function() {
8625 // Abort all pending requests
8627 for ( key in xhrCallbacks ) {
8628 xhrCallbacks[ key ]( undefined, true );
8632 // Functions to create xhrs
8633 function createStandardXHR() {
8635 return new window.XMLHttpRequest();
8639 function createActiveXHR() {
8641 return new window.ActiveXObject("Microsoft.XMLHTTP");
8645 // Create the request object
8646 // (This is still attached to ajaxSettings for backward compatibility)
8647 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
8648 /* Microsoft failed to properly
8649 * implement the XMLHttpRequest in IE7 (can't request local files),
8650 * so we use the ActiveXObject when it is available
8651 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
8652 * we need a fallback.
8655 return !this.isLocal && createStandardXHR() || createActiveXHR();
8657 // For all other browsers, use the standard XMLHttpRequest object
8660 // Determine support properties
8661 xhrSupported = jQuery.ajaxSettings.xhr();
8662 jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
8663 xhrSupported = jQuery.support.ajax = !!xhrSupported;
8665 // Create transport if the browser can provide an xhr
8666 if ( xhrSupported ) {
8668 jQuery.ajaxTransport(function( s ) {
8669 // Cross domain only allowed if supported through XMLHttpRequest
8670 if ( !s.crossDomain || jQuery.support.cors ) {
8675 send: function( headers, complete ) {
8682 // Passing null username, generates a login popup on Opera (#2865)
8684 xhr.open( s.type, s.url, s.async, s.username, s.password );
8686 xhr.open( s.type, s.url, s.async );
8689 // Apply custom fields if provided
8690 if ( s.xhrFields ) {
8691 for ( i in s.xhrFields ) {
8692 xhr[ i ] = s.xhrFields[ i ];
8696 // Override mime type if needed
8697 if ( s.mimeType && xhr.overrideMimeType ) {
8698 xhr.overrideMimeType( s.mimeType );
8701 // X-Requested-With header
8702 // For cross-domain requests, seeing as conditions for a preflight are
8703 // akin to a jigsaw puzzle, we simply never set it to be sure.
8704 // (it can always be set on a per-request basis or even using ajaxSetup)
8705 // For same-domain requests, won't change header if already provided.
8706 if ( !s.crossDomain && !headers["X-Requested-With"] ) {
8707 headers["X-Requested-With"] = "XMLHttpRequest";
8710 // Need an extra try/catch for cross domain requests in Firefox 3
8712 for ( i in headers ) {
8713 xhr.setRequestHeader( i, headers[ i ] );
8717 // Do send the request
8718 // This may raise an exception which is actually
8719 // handled in jQuery.ajax (so no try/catch here)
8720 xhr.send( ( s.hasContent && s.data ) || null );
8723 callback = function( _, isAbort ) {
8724 var status, responseHeaders, statusText, responses;
8726 // Firefox throws exceptions when accessing properties
8727 // of an xhr when a network error occurred
8728 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
8731 // Was never called and is aborted or complete
8732 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
8735 callback = undefined;
8737 // Do not keep as active anymore
8739 xhr.onreadystatechange = jQuery.noop;
8740 if ( xhrOnUnloadAbort ) {
8741 delete xhrCallbacks[ handle ];
8747 // Abort it manually if needed
8748 if ( xhr.readyState !== 4 ) {
8753 status = xhr.status;
8754 responseHeaders = xhr.getAllResponseHeaders();
8756 // When requesting binary data, IE6-9 will throw an exception
8757 // on any attempt to access responseText (#11426)
8758 if ( typeof xhr.responseText === "string" ) {
8759 responses.text = xhr.responseText;
8762 // Firefox throws an exception when accessing
8763 // statusText for faulty cross-domain requests
8765 statusText = xhr.statusText;
8767 // We normalize with Webkit giving an empty statusText
8771 // Filter status for non standard behaviors
8773 // If the request is local and we have data: assume a success
8774 // (success with no data won't get notified, that's the best we
8775 // can do given current implementations)
8776 if ( !status && s.isLocal && !s.crossDomain ) {
8777 status = responses.text ? 200 : 404;
8778 // IE - #1450: sometimes returns 1223 when it should be 204
8779 } else if ( status === 1223 ) {
8784 } catch( firefoxAccessException ) {
8786 complete( -1, firefoxAccessException );
8790 // Call complete if needed
8792 complete( status, statusText, responses, responseHeaders );
8797 // if we're in sync mode we fire the callback
8799 } else if ( xhr.readyState === 4 ) {
8800 // (IE6 & IE7) if it's in cache and has been
8801 // retrieved directly we need to fire the callback
8802 setTimeout( callback );
8805 if ( xhrOnUnloadAbort ) {
8806 // Create the active xhrs callbacks list if needed
8807 // and attach the unload handler
8808 if ( !xhrCallbacks ) {
8810 jQuery( window ).unload( xhrOnUnloadAbort );
8812 // Add to list of active xhrs callbacks
8813 xhrCallbacks[ handle ] = callback;
8815 xhr.onreadystatechange = callback;
8821 callback( undefined, true );
8829 rfxtypes = /^(?:toggle|show|hide)$/,
8830 rfxnum = new RegExp( "^(?:([+-])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
8831 rrun = /queueHooks$/,
8832 animationPrefilters = [ defaultPrefilter ],
8834 "*": [function( prop, value ) {
8835 var tween = this.createTween( prop, value ),
8836 target = tween.cur(),
8837 parts = rfxnum.exec( value ),
8838 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
8840 // Starting value computation is required for potential unit mismatches
8841 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
8842 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
8846 if ( start && start[ 3 ] !== unit ) {
8847 // Trust units reported by jQuery.css
8848 unit = unit || start[ 3 ];
8850 // Make sure we update the tween properties later on
8851 parts = parts || [];
8853 // Iteratively approximate from a nonzero starting point
8854 start = +target || 1;
8857 // If previous iteration zeroed out, double until we get *something*
8858 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
8859 scale = scale || ".5";
8862 start = start / scale;
8863 jQuery.style( tween.elem, prop, start + unit );
8865 // Update scale, tolerating zero or NaN from tween.cur()
8866 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
8867 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
8870 // Update tween properties
8872 start = tween.start = +start || +target || 0;
8874 // If a +=/-= token was provided, we're doing a relative animation
8875 tween.end = parts[ 1 ] ?
8876 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
8884 // Animations created synchronously will run synchronously
8885 function createFxNow() {
8886 setTimeout(function() {
8889 return ( fxNow = jQuery.now() );
8892 function createTween( value, prop, animation ) {
8894 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
8896 length = collection.length;
8897 for ( ; index < length; index++ ) {
8898 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
8900 // we're done with this property
8906 function Animation( elem, properties, options ) {
8910 length = animationPrefilters.length,
8911 deferred = jQuery.Deferred().always( function() {
8912 // don't match elem in the :animated selector
8919 var currentTime = fxNow || createFxNow(),
8920 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
8921 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
8922 temp = remaining / animation.duration || 0,
8925 length = animation.tweens.length;
8927 for ( ; index < length ; index++ ) {
8928 animation.tweens[ index ].run( percent );
8931 deferred.notifyWith( elem, [ animation, percent, remaining ]);
8933 if ( percent < 1 && length ) {
8936 deferred.resolveWith( elem, [ animation ] );
8940 animation = deferred.promise({
8942 props: jQuery.extend( {}, properties ),
8943 opts: jQuery.extend( true, { specialEasing: {} }, options ),
8944 originalProperties: properties,
8945 originalOptions: options,
8946 startTime: fxNow || createFxNow(),
8947 duration: options.duration,
8949 createTween: function( prop, end ) {
8950 var tween = jQuery.Tween( elem, animation.opts, prop, end,
8951 animation.opts.specialEasing[ prop ] || animation.opts.easing );
8952 animation.tweens.push( tween );
8955 stop: function( gotoEnd ) {
8957 // if we are going to the end, we want to run all the tweens
8958 // otherwise we skip this part
8959 length = gotoEnd ? animation.tweens.length : 0;
8964 for ( ; index < length ; index++ ) {
8965 animation.tweens[ index ].run( 1 );
8968 // resolve when we played the last frame
8969 // otherwise, reject
8971 deferred.resolveWith( elem, [ animation, gotoEnd ] );
8973 deferred.rejectWith( elem, [ animation, gotoEnd ] );
8978 props = animation.props;
8980 propFilter( props, animation.opts.specialEasing );
8982 for ( ; index < length ; index++ ) {
8983 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
8989 jQuery.map( props, createTween, animation );
8991 if ( jQuery.isFunction( animation.opts.start ) ) {
8992 animation.opts.start.call( elem, animation );
8996 jQuery.extend( tick, {
8999 queue: animation.opts.queue
9003 // attach callbacks from options
9004 return animation.progress( animation.opts.progress )
9005 .done( animation.opts.done, animation.opts.complete )
9006 .fail( animation.opts.fail )
9007 .always( animation.opts.always );
9010 function propFilter( props, specialEasing ) {
9011 var index, name, easing, value, hooks;
9013 // camelCase, specialEasing and expand cssHook pass
9014 for ( index in props ) {
9015 name = jQuery.camelCase( index );
9016 easing = specialEasing[ name ];
9017 value = props[ index ];
9018 if ( jQuery.isArray( value ) ) {
9019 easing = value[ 1 ];
9020 value = props[ index ] = value[ 0 ];
9023 if ( index !== name ) {
9024 props[ name ] = value;
9025 delete props[ index ];
9028 hooks = jQuery.cssHooks[ name ];
9029 if ( hooks && "expand" in hooks ) {
9030 value = hooks.expand( value );
9031 delete props[ name ];
9033 // not quite $.extend, this wont overwrite keys already present.
9034 // also - reusing 'index' from above because we have the correct "name"
9035 for ( index in value ) {
9036 if ( !( index in props ) ) {
9037 props[ index ] = value[ index ];
9038 specialEasing[ index ] = easing;
9042 specialEasing[ name ] = easing;
9047 jQuery.Animation = jQuery.extend( Animation, {
9049 tweener: function( props, callback ) {
9050 if ( jQuery.isFunction( props ) ) {
9054 props = props.split(" ");
9059 length = props.length;
9061 for ( ; index < length ; index++ ) {
9062 prop = props[ index ];
9063 tweeners[ prop ] = tweeners[ prop ] || [];
9064 tweeners[ prop ].unshift( callback );
9068 prefilter: function( callback, prepend ) {
9070 animationPrefilters.unshift( callback );
9072 animationPrefilters.push( callback );
9077 function defaultPrefilter( elem, props, opts ) {
9078 /* jshint validthis: true */
9079 var prop, value, toggle, tween, hooks, oldfire,
9083 hidden = elem.nodeType && isHidden( elem ),
9084 dataShow = jQuery._data( elem, "fxshow" );
9086 // handle queue: false promises
9087 if ( !opts.queue ) {
9088 hooks = jQuery._queueHooks( elem, "fx" );
9089 if ( hooks.unqueued == null ) {
9091 oldfire = hooks.empty.fire;
9092 hooks.empty.fire = function() {
9093 if ( !hooks.unqueued ) {
9100 anim.always(function() {
9101 // doing this makes sure that the complete handler will be called
9102 // before this completes
9103 anim.always(function() {
9105 if ( !jQuery.queue( elem, "fx" ).length ) {
9112 // height/width overflow pass
9113 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
9114 // Make sure that nothing sneaks out
9115 // Record all 3 overflow attributes because IE does not
9116 // change the overflow attribute when overflowX and
9117 // overflowY are set to the same value
9118 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
9120 // Set display property to inline-block for height/width
9121 // animations on inline elements that are having width/height animated
9122 if ( jQuery.css( elem, "display" ) === "inline" &&
9123 jQuery.css( elem, "float" ) === "none" ) {
9125 // inline-level elements accept inline-block;
9126 // block-level elements need to be inline with layout
9127 if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
9128 style.display = "inline-block";
9136 if ( opts.overflow ) {
9137 style.overflow = "hidden";
9138 if ( !jQuery.support.shrinkWrapBlocks ) {
9139 anim.always(function() {
9140 style.overflow = opts.overflow[ 0 ];
9141 style.overflowX = opts.overflow[ 1 ];
9142 style.overflowY = opts.overflow[ 2 ];
9149 for ( prop in props ) {
9150 value = props[ prop ];
9151 if ( rfxtypes.exec( value ) ) {
9152 delete props[ prop ];
9153 toggle = toggle || value === "toggle";
9154 if ( value === ( hidden ? "hide" : "show" ) ) {
9157 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
9161 if ( !jQuery.isEmptyObject( orig ) ) {
9163 if ( "hidden" in dataShow ) {
9164 hidden = dataShow.hidden;
9167 dataShow = jQuery._data( elem, "fxshow", {} );
9170 // store state if its toggle - enables .stop().toggle() to "reverse"
9172 dataShow.hidden = !hidden;
9175 jQuery( elem ).show();
9177 anim.done(function() {
9178 jQuery( elem ).hide();
9181 anim.done(function() {
9183 jQuery._removeData( elem, "fxshow" );
9184 for ( prop in orig ) {
9185 jQuery.style( elem, prop, orig[ prop ] );
9188 for ( prop in orig ) {
9189 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
9191 if ( !( prop in dataShow ) ) {
9192 dataShow[ prop ] = tween.start;
9194 tween.end = tween.start;
9195 tween.start = prop === "width" || prop === "height" ? 1 : 0;
9202 function Tween( elem, options, prop, end, easing ) {
9203 return new Tween.prototype.init( elem, options, prop, end, easing );
9205 jQuery.Tween = Tween;
9209 init: function( elem, options, prop, end, easing, unit ) {
9212 this.easing = easing || "swing";
9213 this.options = options;
9214 this.start = this.now = this.cur();
9216 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
9219 var hooks = Tween.propHooks[ this.prop ];
9221 return hooks && hooks.get ?
9223 Tween.propHooks._default.get( this );
9225 run: function( percent ) {
9227 hooks = Tween.propHooks[ this.prop ];
9229 if ( this.options.duration ) {
9230 this.pos = eased = jQuery.easing[ this.easing ](
9231 percent, this.options.duration * percent, 0, 1, this.options.duration
9234 this.pos = eased = percent;
9236 this.now = ( this.end - this.start ) * eased + this.start;
9238 if ( this.options.step ) {
9239 this.options.step.call( this.elem, this.now, this );
9242 if ( hooks && hooks.set ) {
9245 Tween.propHooks._default.set( this );
9251 Tween.prototype.init.prototype = Tween.prototype;
9255 get: function( tween ) {
9258 if ( tween.elem[ tween.prop ] != null &&
9259 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
9260 return tween.elem[ tween.prop ];
9263 // passing an empty string as a 3rd parameter to .css will automatically
9264 // attempt a parseFloat and fallback to a string if the parse fails
9265 // so, simple values such as "10px" are parsed to Float.
9266 // complex values such as "rotate(1rad)" are returned as is.
9267 result = jQuery.css( tween.elem, tween.prop, "" );
9268 // Empty strings, null, undefined and "auto" are converted to 0.
9269 return !result || result === "auto" ? 0 : result;
9271 set: function( tween ) {
9272 // use step hook for back compat - use cssHook if its there - use .style if its
9273 // available and use plain properties where available
9274 if ( jQuery.fx.step[ tween.prop ] ) {
9275 jQuery.fx.step[ tween.prop ]( tween );
9276 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
9277 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
9279 tween.elem[ tween.prop ] = tween.now;
9286 // Panic based approach to setting things on disconnected nodes
9288 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
9289 set: function( tween ) {
9290 if ( tween.elem.nodeType && tween.elem.parentNode ) {
9291 tween.elem[ tween.prop ] = tween.now;
9296 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
9297 var cssFn = jQuery.fn[ name ];
9298 jQuery.fn[ name ] = function( speed, easing, callback ) {
9299 return speed == null || typeof speed === "boolean" ?
9300 cssFn.apply( this, arguments ) :
9301 this.animate( genFx( name, true ), speed, easing, callback );
9306 fadeTo: function( speed, to, easing, callback ) {
9308 // show any hidden elements after setting opacity to 0
9309 return this.filter( isHidden ).css( "opacity", 0 ).show()
9311 // animate to the value specified
9312 .end().animate({ opacity: to }, speed, easing, callback );
9314 animate: function( prop, speed, easing, callback ) {
9315 var empty = jQuery.isEmptyObject( prop ),
9316 optall = jQuery.speed( speed, easing, callback ),
9317 doAnimation = function() {
9318 // Operate on a copy of prop so per-property easing won't be lost
9319 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
9321 // Empty animations, or finishing resolves immediately
9322 if ( empty || jQuery._data( this, "finish" ) ) {
9326 doAnimation.finish = doAnimation;
9328 return empty || optall.queue === false ?
9329 this.each( doAnimation ) :
9330 this.queue( optall.queue, doAnimation );
9332 stop: function( type, clearQueue, gotoEnd ) {
9333 var stopQueue = function( hooks ) {
9334 var stop = hooks.stop;
9339 if ( typeof type !== "string" ) {
9340 gotoEnd = clearQueue;
9344 if ( clearQueue && type !== false ) {
9345 this.queue( type || "fx", [] );
9348 return this.each(function() {
9350 index = type != null && type + "queueHooks",
9351 timers = jQuery.timers,
9352 data = jQuery._data( this );
9355 if ( data[ index ] && data[ index ].stop ) {
9356 stopQueue( data[ index ] );
9359 for ( index in data ) {
9360 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
9361 stopQueue( data[ index ] );
9366 for ( index = timers.length; index--; ) {
9367 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
9368 timers[ index ].anim.stop( gotoEnd );
9370 timers.splice( index, 1 );
9374 // start the next in the queue if the last step wasn't forced
9375 // timers currently will call their complete callbacks, which will dequeue
9376 // but only if they were gotoEnd
9377 if ( dequeue || !gotoEnd ) {
9378 jQuery.dequeue( this, type );
9382 finish: function( type ) {
9383 if ( type !== false ) {
9384 type = type || "fx";
9386 return this.each(function() {
9388 data = jQuery._data( this ),
9389 queue = data[ type + "queue" ],
9390 hooks = data[ type + "queueHooks" ],
9391 timers = jQuery.timers,
9392 length = queue ? queue.length : 0;
9394 // enable finishing flag on private data
9397 // empty the queue first
9398 jQuery.queue( this, type, [] );
9400 if ( hooks && hooks.stop ) {
9401 hooks.stop.call( this, true );
9404 // look for any active animations, and finish them
9405 for ( index = timers.length; index--; ) {
9406 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
9407 timers[ index ].anim.stop( true );
9408 timers.splice( index, 1 );
9412 // look for any animations in the old queue and finish them
9413 for ( index = 0; index < length; index++ ) {
9414 if ( queue[ index ] && queue[ index ].finish ) {
9415 queue[ index ].finish.call( this );
9419 // turn off finishing flag
9425 // Generate parameters to create a standard animation
9426 function genFx( type, includeWidth ) {
9428 attrs = { height: type },
9431 // if we include width, step value is 1 to do all cssExpand values,
9432 // if we don't include width, step value is 2 to skip over Left and Right
9433 includeWidth = includeWidth? 1 : 0;
9434 for( ; i < 4 ; i += 2 - includeWidth ) {
9435 which = cssExpand[ i ];
9436 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
9439 if ( includeWidth ) {
9440 attrs.opacity = attrs.width = type;
9446 // Generate shortcuts for custom animations
9448 slideDown: genFx("show"),
9449 slideUp: genFx("hide"),
9450 slideToggle: genFx("toggle"),
9451 fadeIn: { opacity: "show" },
9452 fadeOut: { opacity: "hide" },
9453 fadeToggle: { opacity: "toggle" }
9454 }, function( name, props ) {
9455 jQuery.fn[ name ] = function( speed, easing, callback ) {
9456 return this.animate( props, speed, easing, callback );
9460 jQuery.speed = function( speed, easing, fn ) {
9461 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
9462 complete: fn || !fn && easing ||
9463 jQuery.isFunction( speed ) && speed,
9465 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
9468 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
9469 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
9471 // normalize opt.queue - true/undefined/null -> "fx"
9472 if ( opt.queue == null || opt.queue === true ) {
9477 opt.old = opt.complete;
9479 opt.complete = function() {
9480 if ( jQuery.isFunction( opt.old ) ) {
9481 opt.old.call( this );
9485 jQuery.dequeue( this, opt.queue );
9493 linear: function( p ) {
9496 swing: function( p ) {
9497 return 0.5 - Math.cos( p*Math.PI ) / 2;
9502 jQuery.fx = Tween.prototype.init;
9503 jQuery.fx.tick = function() {
9505 timers = jQuery.timers,
9508 fxNow = jQuery.now();
9510 for ( ; i < timers.length; i++ ) {
9511 timer = timers[ i ];
9512 // Checks the timer has not already been removed
9513 if ( !timer() && timers[ i ] === timer ) {
9514 timers.splice( i--, 1 );
9518 if ( !timers.length ) {
9524 jQuery.fx.timer = function( timer ) {
9525 if ( timer() && jQuery.timers.push( timer ) ) {
9530 jQuery.fx.interval = 13;
9532 jQuery.fx.start = function() {
9534 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
9538 jQuery.fx.stop = function() {
9539 clearInterval( timerId );
9543 jQuery.fx.speeds = {
9550 // Back Compat <1.8 extension point
9551 jQuery.fx.step = {};
9553 if ( jQuery.expr && jQuery.expr.filters ) {
9554 jQuery.expr.filters.animated = function( elem ) {
9555 return jQuery.grep(jQuery.timers, function( fn ) {
9556 return elem === fn.elem;
9560 jQuery.fn.offset = function( options ) {
9561 if ( arguments.length ) {
9562 return options === undefined ?
9564 this.each(function( i ) {
9565 jQuery.offset.setOffset( this, options, i );
9570 box = { top: 0, left: 0 },
9572 doc = elem && elem.ownerDocument;
9578 docElem = doc.documentElement;
9580 // Make sure it's not a disconnected DOM node
9581 if ( !jQuery.contains( docElem, elem ) ) {
9585 // If we don't have gBCR, just use 0,0 rather than error
9586 // BlackBerry 5, iOS 3 (original iPhone)
9587 if ( typeof elem.getBoundingClientRect !== core_strundefined ) {
9588 box = elem.getBoundingClientRect();
9590 win = getWindow( doc );
9592 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
9593 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
9599 setOffset: function( elem, options, i ) {
9600 var position = jQuery.css( elem, "position" );
9602 // set position first, in-case top/left are set even on static elem
9603 if ( position === "static" ) {
9604 elem.style.position = "relative";
9607 var curElem = jQuery( elem ),
9608 curOffset = curElem.offset(),
9609 curCSSTop = jQuery.css( elem, "top" ),
9610 curCSSLeft = jQuery.css( elem, "left" ),
9611 calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
9612 props = {}, curPosition = {}, curTop, curLeft;
9614 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
9615 if ( calculatePosition ) {
9616 curPosition = curElem.position();
9617 curTop = curPosition.top;
9618 curLeft = curPosition.left;
9620 curTop = parseFloat( curCSSTop ) || 0;
9621 curLeft = parseFloat( curCSSLeft ) || 0;
9624 if ( jQuery.isFunction( options ) ) {
9625 options = options.call( elem, i, curOffset );
9628 if ( options.top != null ) {
9629 props.top = ( options.top - curOffset.top ) + curTop;
9631 if ( options.left != null ) {
9632 props.left = ( options.left - curOffset.left ) + curLeft;
9635 if ( "using" in options ) {
9636 options.using.call( elem, props );
9638 curElem.css( props );
9646 position: function() {
9651 var offsetParent, offset,
9652 parentOffset = { top: 0, left: 0 },
9655 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is it's only offset parent
9656 if ( jQuery.css( elem, "position" ) === "fixed" ) {
9657 // we assume that getBoundingClientRect is available when computed position is fixed
9658 offset = elem.getBoundingClientRect();
9660 // Get *real* offsetParent
9661 offsetParent = this.offsetParent();
9663 // Get correct offsets
9664 offset = this.offset();
9665 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
9666 parentOffset = offsetParent.offset();
9669 // Add offsetParent borders
9670 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
9671 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
9674 // Subtract parent offsets and element margins
9675 // note: when an element has margin: auto the offsetLeft and marginLeft
9676 // are the same in Safari causing offset.left to incorrectly be 0
9678 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
9679 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
9683 offsetParent: function() {
9684 return this.map(function() {
9685 var offsetParent = this.offsetParent || docElem;
9686 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position") === "static" ) ) {
9687 offsetParent = offsetParent.offsetParent;
9689 return offsetParent || docElem;
9695 // Create scrollLeft and scrollTop methods
9696 jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
9697 var top = /Y/.test( prop );
9699 jQuery.fn[ method ] = function( val ) {
9700 return jQuery.access( this, function( elem, method, val ) {
9701 var win = getWindow( elem );
9703 if ( val === undefined ) {
9704 return win ? (prop in win) ? win[ prop ] :
9705 win.document.documentElement[ method ] :
9711 !top ? val : jQuery( win ).scrollLeft(),
9712 top ? val : jQuery( win ).scrollTop()
9716 elem[ method ] = val;
9718 }, method, val, arguments.length, null );
9722 function getWindow( elem ) {
9723 return jQuery.isWindow( elem ) ?
9725 elem.nodeType === 9 ?
9726 elem.defaultView || elem.parentWindow :
9729 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
9730 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
9731 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
9732 // margin is only for outerHeight, outerWidth
9733 jQuery.fn[ funcName ] = function( margin, value ) {
9734 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
9735 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
9737 return jQuery.access( this, function( elem, type, value ) {
9740 if ( jQuery.isWindow( elem ) ) {
9741 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
9742 // isn't a whole lot we can do. See pull request at this URL for discussion:
9743 // https://github.com/jquery/jquery/pull/764
9744 return elem.document.documentElement[ "client" + name ];
9747 // Get document width or height
9748 if ( elem.nodeType === 9 ) {
9749 doc = elem.documentElement;
9751 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
9752 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
9754 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
9755 elem.body[ "offset" + name ], doc[ "offset" + name ],
9756 doc[ "client" + name ]
9760 return value === undefined ?
9761 // Get width or height on the element, requesting but not forcing parseFloat
9762 jQuery.css( elem, type, extra ) :
9764 // Set width or height on the element
9765 jQuery.style( elem, type, value, extra );
9766 }, type, chainable ? margin : undefined, chainable, null );
9770 // Limit scope pollution from any deprecated API
9773 // The number of elements contained in the matched element set
9774 jQuery.fn.size = function() {
9778 jQuery.fn.andSelf = jQuery.fn.addBack;
9781 if ( typeof module === "object" && module && typeof module.exports === "object" ) {
9782 // Expose jQuery as module.exports in loaders that implement the Node
9783 // module pattern (including browserify). Do not create the global, since
9784 // the user will be storing it themselves locally, and globals are frowned
9785 // upon in the Node module world.
9786 module.exports = jQuery;
9788 // Otherwise expose jQuery to the global object as usual
9789 window.jQuery = window.$ = jQuery;
9791 // Register as a named AMD module, since jQuery can be concatenated with other
9792 // files that may use define, but not via a proper concatenation script that
9793 // understands anonymous AMD modules. A named AMD is safest and most robust
9794 // way to register. Lowercase jquery is used because AMD module names are
9795 // derived from file names, and jQuery is normally delivered in a lowercase
9796 // file name. Do this after creating the global so that if an AMD module wants
9797 // to call noConflict to hide this version of jQuery, it will work.
9798 if ( typeof define === "function" && define.amd ) {
9799 define( "jquery", [], function () { return jQuery; } );