2 * jQuery JavaScript Library v2.1.1 -deprecated,-css/hiddenVisibleSelectors,-effects/animatedSelector
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2014-09-28T02:59Z
15 (function( global, factory ) {
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper window is present,
19 // execute the factory and get jQuery
20 // For environments that do not inherently posses a window with a document
21 // (such as Node.js), expose a jQuery-making factory as module.exports
22 // This accentuates the need for the creation of a real window
23 // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info
25 module.exports = global.document ?
26 factory( global, true ) :
29 throw new Error( "jQuery requires a window with a document" );
37 // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40 // Can't do this because several apps including ASP.NET trace
41 // the stack via arguments.caller.callee and Firefox dies if
42 // you try to trace through "use strict" call chains. (#13335)
43 // Support: Firefox 18+
48 var slice = arr.slice;
50 var concat = arr.concat;
54 var indexOf = arr.indexOf;
58 var toString = class2type.toString;
60 var hasOwn = class2type.hasOwnProperty;
67 // Use the correct document accordingly with window argument (sandbox)
68 document = window.document,
70 version = "2.1.1 -deprecated,-css/hiddenVisibleSelectors,-effects/animatedSelector",
72 // Define a local copy of jQuery
73 jQuery = function( selector, context ) {
74 // The jQuery object is actually just the init constructor 'enhanced'
75 // Need init if jQuery is called (just allow error to be thrown if not included)
76 return new jQuery.fn.init( selector, context );
79 // Support: Android<4.1
80 // Make sure we trim BOM and NBSP
81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
83 // Matches dashed string for camelizing
85 rdashAlpha = /-([\da-z])/gi,
87 // Used by jQuery.camelCase as callback to replace()
88 fcamelCase = function( all, letter ) {
89 return letter.toUpperCase();
92 jQuery.fn = jQuery.prototype = {
93 // The current version of jQuery being used
98 // Start with an empty selector
101 // The default length of a jQuery object is 0
104 toArray: function() {
105 return slice.call( this );
108 // Get the Nth element in the matched element set OR
109 // Get the whole matched element set as a clean array
110 get: function( num ) {
113 // Return just the one element from the set
114 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
116 // Return all the elements in a clean array
120 // Take an array of elements and push it onto the stack
121 // (returning the new matched element set)
122 pushStack: function( elems ) {
124 // Build a new jQuery matched element set
125 var ret = jQuery.merge( this.constructor(), elems );
127 // Add the old object onto the stack (as a reference)
128 ret.prevObject = this;
129 ret.context = this.context;
131 // Return the newly-formed element set
135 // Execute a callback for every element in the matched set.
136 // (You can seed the arguments with an array of args, but this is
137 // only used internally.)
138 each: function( callback, args ) {
139 return jQuery.each( this, callback, args );
142 map: function( callback ) {
143 return this.pushStack( jQuery.map(this, function( elem, i ) {
144 return callback.call( elem, i, elem );
149 return this.pushStack( slice.apply( this, arguments ) );
157 return this.eq( -1 );
161 var len = this.length,
162 j = +i + ( i < 0 ? len : 0 );
163 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
167 return this.prevObject || this.constructor(null);
170 // For internal use only.
171 // Behaves like an Array's method, not like a jQuery method.
177 jQuery.extend = jQuery.fn.extend = function() {
178 var options, name, src, copy, copyIsArray, clone,
179 target = arguments[0] || {},
181 length = arguments.length,
184 // Handle a deep copy situation
185 if ( typeof target === "boolean" ) {
188 // skip the boolean and the target
189 target = arguments[ i ] || {};
193 // Handle case when target is a string or something (possible in deep copy)
194 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
198 // extend jQuery itself if only one argument is passed
199 if ( i === length ) {
204 for ( ; i < length; i++ ) {
205 // Only deal with non-null/undefined values
206 if ( (options = arguments[ i ]) != null ) {
207 // Extend the base object
208 for ( name in options ) {
209 src = target[ name ];
210 copy = options[ name ];
212 // Prevent never-ending loop
213 if ( target === copy ) {
217 // Recurse if we're merging plain objects or arrays
218 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
221 clone = src && jQuery.isArray(src) ? src : [];
224 clone = src && jQuery.isPlainObject(src) ? src : {};
227 // Never move original objects, clone them
228 target[ name ] = jQuery.extend( deep, clone, copy );
230 // Don't bring in undefined values
231 } else if ( copy !== undefined ) {
232 target[ name ] = copy;
238 // Return the modified object
243 // Unique for each copy of jQuery on the page
244 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
246 // Assume jQuery is ready without the ready module
249 error: function( msg ) {
250 throw new Error( msg );
255 // See test/unit/core.js for details concerning isFunction.
256 // Since version 1.3, DOM methods and functions like alert
257 // aren't supported. They return false on IE (#2968).
258 isFunction: function( obj ) {
259 return jQuery.type(obj) === "function";
262 isArray: Array.isArray,
264 isWindow: function( obj ) {
265 return obj != null && obj === obj.window;
268 isNumeric: function( obj ) {
269 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
270 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
271 // subtraction forces infinities to NaN
272 return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0;
275 isPlainObject: function( obj ) {
276 // Not plain objects:
277 // - Any object or value whose internal [[Class]] property is not "[object Object]"
280 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
284 if ( obj.constructor &&
285 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
289 // If the function hasn't returned already, we're confident that
290 // |obj| is a plain object, created by {} or constructed with new Object
294 isEmptyObject: function( obj ) {
296 for ( name in obj ) {
302 type: function( obj ) {
306 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
307 return typeof obj === "object" || typeof obj === "function" ?
308 class2type[ toString.call(obj) ] || "object" :
312 // Evaluates a script in a global context
313 globalEval: function( code ) {
317 code = jQuery.trim( code );
320 // If the code includes a valid, prologue position
321 // strict mode pragma, execute code by injecting a
322 // script tag into the document.
323 if ( code.indexOf("use strict") === 1 ) {
324 script = document.createElement("script");
326 document.head.appendChild( script ).parentNode.removeChild( script );
328 // Otherwise, avoid the DOM node creation, insertion
329 // and removal by using an indirect global eval
335 // Convert dashed to camelCase; used by the css and data modules
336 // Microsoft forgot to hump their vendor prefix (#9572)
337 camelCase: function( string ) {
338 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
341 nodeName: function( elem, name ) {
342 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
345 // args is for internal usage only
346 each: function( obj, callback, args ) {
350 isArray = isArraylike( obj );
354 for ( ; i < length; i++ ) {
355 value = callback.apply( obj[ i ], args );
357 if ( value === false ) {
363 value = callback.apply( obj[ i ], args );
365 if ( value === false ) {
371 // A special, fast, case for the most common use of each
374 for ( ; i < length; i++ ) {
375 value = callback.call( obj[ i ], i, obj[ i ] );
377 if ( value === false ) {
383 value = callback.call( obj[ i ], i, obj[ i ] );
385 if ( value === false ) {
395 // Support: Android<4.1
396 trim: function( text ) {
397 return text == null ?
399 ( text + "" ).replace( rtrim, "" );
402 // results is for internal usage only
403 makeArray: function( arr, results ) {
404 var ret = results || [];
407 if ( isArraylike( Object(arr) ) ) {
409 typeof arr === "string" ?
413 push.call( ret, arr );
420 inArray: function( elem, arr, i ) {
421 return arr == null ? -1 : indexOf.call( arr, elem, i );
424 merge: function( first, second ) {
425 var len = +second.length,
429 for ( ; j < len; j++ ) {
430 first[ i++ ] = second[ j ];
438 grep: function( elems, callback, invert ) {
442 length = elems.length,
443 callbackExpect = !invert;
445 // Go through the array, only saving the items
446 // that pass the validator function
447 for ( ; i < length; i++ ) {
448 callbackInverse = !callback( elems[ i ], i );
449 if ( callbackInverse !== callbackExpect ) {
450 matches.push( elems[ i ] );
457 // arg is for internal usage only
458 map: function( elems, callback, arg ) {
461 length = elems.length,
462 isArray = isArraylike( elems ),
465 // Go through the array, translating each of the items to their new values
467 for ( ; i < length; i++ ) {
468 value = callback( elems[ i ], i, arg );
470 if ( value != null ) {
475 // Go through every key on the object,
478 value = callback( elems[ i ], i, arg );
480 if ( value != null ) {
486 // Flatten any nested arrays
487 return concat.apply( [], ret );
490 // A global GUID counter for objects
493 // Bind a function to a context, optionally partially applying any
495 proxy: function( fn, context ) {
496 var tmp, args, proxy;
498 if ( typeof context === "string" ) {
504 // Quick check to determine if target is callable, in the spec
505 // this throws a TypeError, but we will just return undefined.
506 if ( !jQuery.isFunction( fn ) ) {
511 args = slice.call( arguments, 2 );
513 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
516 // Set the guid of unique handler to the same of original handler, so it can be removed
517 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
524 // jQuery.support is not used in Core but other projects attach their
525 // properties to it so it needs to exist.
529 // Populate the class2type map
530 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
531 class2type[ "[object " + name + "]" ] = name.toLowerCase();
534 function isArraylike( obj ) {
535 var length = obj.length,
536 type = jQuery.type( obj );
538 if ( type === "function" || jQuery.isWindow( obj ) ) {
542 if ( obj.nodeType === 1 && length ) {
546 return type === "array" || length === 0 ||
547 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
552 * Optional (non-Sizzle) selector module for custom builds.
554 * Note that this DOES NOT SUPPORT many documented jQuery
555 * features in exchange for its smaller size:
557 * Attribute not equal selector
558 * Positional selectors (:first; :eq(n); :odd; etc.)
559 * Type selectors (:input; :checkbox; :button; etc.)
560 * State-based selectors (:animated; :visible; :hidden; etc.)
562 * :not(complex selector)
563 * custom selectors via Sizzle extensions
564 * Leading combinators (e.g., $collection.find("> *"))
565 * Reliable functionality on XML fragments
566 * Requiring all parts of a selector to match elements under context
567 * (e.g., $div.find("div > *") now matches children of $div)
568 * Matching against non-elements
569 * Reliable sorting of disconnected nodes
570 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
572 * If any of these are unacceptable tradeoffs, either use Sizzle or
573 * customize this stub for the project's specific needs.
576 var docElem = window.document.documentElement,
577 selector_hasDuplicate,
578 matches = docElem.matches ||
579 docElem.webkitMatchesSelector ||
580 docElem.mozMatchesSelector ||
581 docElem.oMatchesSelector ||
582 docElem.msMatchesSelector,
583 selector_sortOrder = function( a, b ) {
584 // Flag for duplicate removal
586 selector_hasDuplicate = true;
590 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
593 // Disconnected nodes
596 // Choose the first element that is related to our document
597 if ( a === document || jQuery.contains(document, a) ) {
600 if ( b === document || jQuery.contains(document, b) ) {
604 // Maintain original order
608 return compare & 4 ? -1 : 1;
611 // Not directly comparable, sort on existence of method
612 return a.compareDocumentPosition ? -1 : 1;
616 find: function( selector, context, results, seed ) {
620 results = results || [];
621 context = context || document;
623 // Same basic safeguard as Sizzle
624 if ( !selector || typeof selector !== "string" ) {
628 // Early return if context is not an element or document
629 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
634 while ( (elem = seed[i++]) ) {
635 if ( jQuery.find.matchesSelector(elem, selector) ) {
636 results.push( elem );
640 jQuery.merge( results, context.querySelectorAll(selector) );
645 unique: function( results ) {
651 selector_hasDuplicate = false;
652 results.sort( selector_sortOrder );
654 if ( selector_hasDuplicate ) {
655 while ( (elem = results[i++]) ) {
656 if ( elem === results[ i ] ) {
657 j = duplicates.push( i );
661 results.splice( duplicates[ j ], 1 );
667 text: function( elem ) {
671 nodeType = elem.nodeType;
674 // If no nodeType, this is expected to be an array
675 while ( (node = elem[i++]) ) {
676 // Do not traverse comment nodes
677 ret += jQuery.text( node );
679 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
680 // Use textContent for elements
681 return elem.textContent;
682 } else if ( nodeType === 3 || nodeType === 4 ) {
683 return elem.nodeValue;
685 // Do not include comment or processing instruction nodes
689 contains: function( a, b ) {
690 var adown = a.nodeType === 9 ? a.documentElement : a,
691 bup = b && b.parentNode;
692 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) );
694 isXMLDoc: function( elem ) {
695 return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML";
700 bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,
701 needsContext: /^[\x20\t\r\n\f]*[>+~]/
706 jQuery.extend( jQuery.find, {
707 matches: function( expr, elements ) {
708 return jQuery.find( expr, null, null, elements );
710 matchesSelector: function( elem, expr ) {
711 return matches.call( elem, expr );
713 attr: function( elem, name ) {
714 return elem.getAttribute( name );
720 var rneedsContext = jQuery.expr.match.needsContext;
722 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
726 var risSimple = /^.[^:#\[\.,]*$/;
728 // Implement the identical functionality for filter and not
729 function winnow( elements, qualifier, not ) {
730 if ( jQuery.isFunction( qualifier ) ) {
731 return jQuery.grep( elements, function( elem, i ) {
733 return !!qualifier.call( elem, i, elem ) !== not;
738 if ( qualifier.nodeType ) {
739 return jQuery.grep( elements, function( elem ) {
740 return ( elem === qualifier ) !== not;
745 if ( typeof qualifier === "string" ) {
746 if ( risSimple.test( qualifier ) ) {
747 return jQuery.filter( qualifier, elements, not );
750 qualifier = jQuery.filter( qualifier, elements );
753 return jQuery.grep( elements, function( elem ) {
754 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
758 jQuery.filter = function( expr, elems, not ) {
759 var elem = elems[ 0 ];
762 expr = ":not(" + expr + ")";
765 return elems.length === 1 && elem.nodeType === 1 ?
766 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
767 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
768 return elem.nodeType === 1;
773 find: function( selector ) {
779 if ( typeof selector !== "string" ) {
780 return this.pushStack( jQuery( selector ).filter(function() {
781 for ( i = 0; i < len; i++ ) {
782 if ( jQuery.contains( self[ i ], this ) ) {
789 for ( i = 0; i < len; i++ ) {
790 jQuery.find( selector, self[ i ], ret );
793 // Needed because $( selector, context ) becomes $( context ).find( selector )
794 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
795 ret.selector = this.selector ? this.selector + " " + selector : selector;
798 filter: function( selector ) {
799 return this.pushStack( winnow(this, selector || [], false) );
801 not: function( selector ) {
802 return this.pushStack( winnow(this, selector || [], true) );
804 is: function( selector ) {
808 // If this is a positional/relative selector, check membership in the returned set
809 // so $("p:first").is("p:last") won't return true for a doc with two "p".
810 typeof selector === "string" && rneedsContext.test( selector ) ?
819 // Initialize a jQuery object
822 // A central reference to the root jQuery(document)
825 // A simple way to check for HTML strings
826 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
827 // Strict HTML recognition (#11290: must start with <)
828 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
830 init = jQuery.fn.init = function( selector, context ) {
833 // HANDLE: $(""), $(null), $(undefined), $(false)
838 // Handle HTML strings
839 if ( typeof selector === "string" ) {
840 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
841 // Assume that strings that start and end with <> are HTML and skip the regex check
842 match = [ null, selector, null ];
845 match = rquickExpr.exec( selector );
848 // Match html or make sure no context is specified for #id
849 if ( match && (match[1] || !context) ) {
851 // HANDLE: $(html) -> $(array)
853 context = context instanceof jQuery ? context[0] : context;
855 // scripts is true for back-compat
856 // Intentionally let the error be thrown if parseHTML is not present
857 jQuery.merge( this, jQuery.parseHTML(
859 context && context.nodeType ? context.ownerDocument || context : document,
863 // HANDLE: $(html, props)
864 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
865 for ( match in context ) {
866 // Properties of context are called as methods if possible
867 if ( jQuery.isFunction( this[ match ] ) ) {
868 this[ match ]( context[ match ] );
870 // ...and otherwise set as attributes
872 this.attr( match, context[ match ] );
881 elem = document.getElementById( match[2] );
883 // Check parentNode to catch when Blackberry 4.6 returns
884 // nodes that are no longer in the document #6963
885 if ( elem && elem.parentNode ) {
886 // Inject the element directly into the jQuery object
891 this.context = document;
892 this.selector = selector;
896 // HANDLE: $(expr, $(...))
897 } else if ( !context || context.jquery ) {
898 return ( context || rootjQuery ).find( selector );
900 // HANDLE: $(expr, context)
901 // (which is just equivalent to: $(context).find(expr)
903 return this.constructor( context ).find( selector );
906 // HANDLE: $(DOMElement)
907 } else if ( selector.nodeType ) {
908 this.context = this[0] = selector;
912 // HANDLE: $(function)
913 // Shortcut for document ready
914 } else if ( jQuery.isFunction( selector ) ) {
915 return typeof rootjQuery.ready !== "undefined" ?
916 rootjQuery.ready( selector ) :
917 // Execute immediately if ready is not present
921 if ( selector.selector !== undefined ) {
922 this.selector = selector.selector;
923 this.context = selector.context;
926 return jQuery.makeArray( selector, this );
929 // Give the init function the jQuery prototype for later instantiation
930 init.prototype = jQuery.fn;
932 // Initialize central reference
933 rootjQuery = jQuery( document );
936 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
937 // methods guaranteed to produce a unique set when starting from a unique set
946 dir: function( elem, dir, until ) {
948 truncate = until !== undefined;
950 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
951 if ( elem.nodeType === 1 ) {
952 if ( truncate && jQuery( elem ).is( until ) ) {
955 matched.push( elem );
961 sibling: function( n, elem ) {
964 for ( ; n; n = n.nextSibling ) {
965 if ( n.nodeType === 1 && n !== elem ) {
975 has: function( target ) {
976 var targets = jQuery( target, this ),
979 return this.filter(function() {
981 for ( ; i < l; i++ ) {
982 if ( jQuery.contains( this, targets[i] ) ) {
989 closest: function( selectors, context ) {
994 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
995 jQuery( selectors, context || this.context ) :
998 for ( ; i < l; i++ ) {
999 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
1000 // Always skip document fragments
1001 if ( cur.nodeType < 11 && (pos ?
1002 pos.index(cur) > -1 :
1004 // Don't pass non-elements to Sizzle
1005 cur.nodeType === 1 &&
1006 jQuery.find.matchesSelector(cur, selectors)) ) {
1008 matched.push( cur );
1014 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
1017 // Determine the position of an element within
1018 // the matched set of elements
1019 index: function( elem ) {
1021 // No argument, return index in parent
1023 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
1026 // index in selector
1027 if ( typeof elem === "string" ) {
1028 return indexOf.call( jQuery( elem ), this[ 0 ] );
1031 // Locate the position of the desired element
1032 return indexOf.call( this,
1034 // If it receives a jQuery object, the first element is used
1035 elem.jquery ? elem[ 0 ] : elem
1039 add: function( selector, context ) {
1040 return this.pushStack(
1042 jQuery.merge( this.get(), jQuery( selector, context ) )
1047 addBack: function( selector ) {
1048 return this.add( selector == null ?
1049 this.prevObject : this.prevObject.filter(selector)
1054 function sibling( cur, dir ) {
1055 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
1060 parent: function( elem ) {
1061 var parent = elem.parentNode;
1062 return parent && parent.nodeType !== 11 ? parent : null;
1064 parents: function( elem ) {
1065 return jQuery.dir( elem, "parentNode" );
1067 parentsUntil: function( elem, i, until ) {
1068 return jQuery.dir( elem, "parentNode", until );
1070 next: function( elem ) {
1071 return sibling( elem, "nextSibling" );
1073 prev: function( elem ) {
1074 return sibling( elem, "previousSibling" );
1076 nextAll: function( elem ) {
1077 return jQuery.dir( elem, "nextSibling" );
1079 prevAll: function( elem ) {
1080 return jQuery.dir( elem, "previousSibling" );
1082 nextUntil: function( elem, i, until ) {
1083 return jQuery.dir( elem, "nextSibling", until );
1085 prevUntil: function( elem, i, until ) {
1086 return jQuery.dir( elem, "previousSibling", until );
1088 siblings: function( elem ) {
1089 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
1091 children: function( elem ) {
1092 return jQuery.sibling( elem.firstChild );
1094 contents: function( elem ) {
1095 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
1097 }, function( name, fn ) {
1098 jQuery.fn[ name ] = function( until, selector ) {
1099 var matched = jQuery.map( this, fn, until );
1101 if ( name.slice( -5 ) !== "Until" ) {
1105 if ( selector && typeof selector === "string" ) {
1106 matched = jQuery.filter( selector, matched );
1109 if ( this.length > 1 ) {
1110 // Remove duplicates
1111 if ( !guaranteedUnique[ name ] ) {
1112 jQuery.unique( matched );
1115 // Reverse order for parents* and prev-derivatives
1116 if ( rparentsprev.test( name ) ) {
1121 return this.pushStack( matched );
1124 var rnotwhite = (/\S+/g);
1128 // String to Object options format cache
1129 var optionsCache = {};
1131 // Convert String-formatted options into Object-formatted ones and store in cache
1132 function createOptions( options ) {
1133 var object = optionsCache[ options ] = {};
1134 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
1135 object[ flag ] = true;
1141 * Create a callback list using the following parameters:
1143 * options: an optional list of space-separated options that will change how
1144 * the callback list behaves or a more traditional option object
1146 * By default a callback list will act like an event callback list and can be
1147 * "fired" multiple times.
1151 * once: will ensure the callback list can only be fired once (like a Deferred)
1153 * memory: will keep track of previous values and will call any callback added
1154 * after the list has been fired right away with the latest "memorized"
1155 * values (like a Deferred)
1157 * unique: will ensure a callback can only be added once (no duplicate in the list)
1159 * stopOnFalse: interrupt callings when a callback returns false
1162 jQuery.Callbacks = function( options ) {
1164 // Convert options from String-formatted to Object-formatted if needed
1165 // (we check in cache first)
1166 options = typeof options === "string" ?
1167 ( optionsCache[ options ] || createOptions( options ) ) :
1168 jQuery.extend( {}, options );
1170 var // Last fire value (for non-forgettable lists)
1172 // Flag to know if list was already fired
1174 // Flag to know if list is currently firing
1176 // First callback to fire (used internally by add and fireWith)
1178 // End of the loop when firing
1180 // Index of currently firing callback (modified by remove if needed)
1182 // Actual callback list
1184 // Stack of fire calls for repeatable lists
1185 stack = !options.once && [],
1187 fire = function( data ) {
1188 memory = options.memory && data;
1190 firingIndex = firingStart || 0;
1192 firingLength = list.length;
1194 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
1195 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
1196 memory = false; // To prevent further calls using add
1203 if ( stack.length ) {
1204 fire( stack.shift() );
1206 } else if ( memory ) {
1213 // Actual Callbacks object
1215 // Add a callback or a collection of callbacks to the list
1218 // First, we save the current length
1219 var start = list.length;
1220 (function add( args ) {
1221 jQuery.each( args, function( _, arg ) {
1222 var type = jQuery.type( arg );
1223 if ( type === "function" ) {
1224 if ( !options.unique || !self.has( arg ) ) {
1227 } else if ( arg && arg.length && type !== "string" ) {
1228 // Inspect recursively
1233 // Do we need to add the callbacks to the
1234 // current firing batch?
1236 firingLength = list.length;
1237 // With memory, if we're not firing then
1238 // we should call right away
1239 } else if ( memory ) {
1240 firingStart = start;
1246 // Remove a callback from the list
1247 remove: function() {
1249 jQuery.each( arguments, function( _, arg ) {
1251 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
1252 list.splice( index, 1 );
1253 // Handle firing indexes
1255 if ( index <= firingLength ) {
1258 if ( index <= firingIndex ) {
1267 // Check if a given callback is in the list.
1268 // If no argument is given, return whether or not list has callbacks attached.
1269 has: function( fn ) {
1270 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
1272 // Remove all callbacks from the list
1278 // Have the list do nothing anymore
1279 disable: function() {
1280 list = stack = memory = undefined;
1284 disabled: function() {
1287 // Lock the list in its current state
1296 locked: function() {
1299 // Call all callbacks with the given context and arguments
1300 fireWith: function( context, args ) {
1301 if ( list && ( !fired || stack ) ) {
1303 args = [ context, args.slice ? args.slice() : args ];
1312 // Call all the callbacks with the given arguments
1314 self.fireWith( this, arguments );
1317 // To know if the callbacks have already been called at least once
1329 Deferred: function( func ) {
1331 // action, add listener, listener list, final state
1332 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
1333 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
1334 [ "notify", "progress", jQuery.Callbacks("memory") ]
1341 always: function() {
1342 deferred.done( arguments ).fail( arguments );
1345 then: function( /* fnDone, fnFail, fnProgress */ ) {
1346 var fns = arguments;
1347 return jQuery.Deferred(function( newDefer ) {
1348 jQuery.each( tuples, function( i, tuple ) {
1349 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
1350 // deferred[ done | fail | progress ] for forwarding actions to newDefer
1351 deferred[ tuple[1] ](function() {
1352 var returned = fn && fn.apply( this, arguments );
1353 if ( returned && jQuery.isFunction( returned.promise ) ) {
1355 .done( newDefer.resolve )
1356 .fail( newDefer.reject )
1357 .progress( newDefer.notify );
1359 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
1366 // Get a promise for this deferred
1367 // If obj is provided, the promise aspect is added to the object
1368 promise: function( obj ) {
1369 return obj != null ? jQuery.extend( obj, promise ) : promise;
1374 // Keep pipe for back-compat
1375 promise.pipe = promise.then;
1377 // Add list-specific methods
1378 jQuery.each( tuples, function( i, tuple ) {
1379 var list = tuple[ 2 ],
1380 stateString = tuple[ 3 ];
1382 // promise[ done | fail | progress ] = list.add
1383 promise[ tuple[1] ] = list.add;
1386 if ( stateString ) {
1387 list.add(function() {
1388 // state = [ resolved | rejected ]
1389 state = stateString;
1391 // [ reject_list | resolve_list ].disable; progress_list.lock
1392 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
1395 // deferred[ resolve | reject | notify ]
1396 deferred[ tuple[0] ] = function() {
1397 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
1400 deferred[ tuple[0] + "With" ] = list.fireWith;
1403 // Make the deferred a promise
1404 promise.promise( deferred );
1406 // Call given func if any
1408 func.call( deferred, deferred );
1416 when: function( subordinate /* , ..., subordinateN */ ) {
1418 resolveValues = slice.call( arguments ),
1419 length = resolveValues.length,
1421 // the count of uncompleted subordinates
1422 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
1424 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
1425 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
1427 // Update function for both resolve and progress values
1428 updateFunc = function( i, contexts, values ) {
1429 return function( value ) {
1430 contexts[ i ] = this;
1431 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
1432 if ( values === progressValues ) {
1433 deferred.notifyWith( contexts, values );
1434 } else if ( !( --remaining ) ) {
1435 deferred.resolveWith( contexts, values );
1440 progressValues, progressContexts, resolveContexts;
1442 // add listeners to Deferred subordinates; treat others as resolved
1444 progressValues = new Array( length );
1445 progressContexts = new Array( length );
1446 resolveContexts = new Array( length );
1447 for ( ; i < length; i++ ) {
1448 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
1449 resolveValues[ i ].promise()
1450 .done( updateFunc( i, resolveContexts, resolveValues ) )
1451 .fail( deferred.reject )
1452 .progress( updateFunc( i, progressContexts, progressValues ) );
1459 // if we're not waiting on anything, resolve the master
1461 deferred.resolveWith( resolveContexts, resolveValues );
1464 return deferred.promise();
1469 // The deferred used on DOM ready
1472 jQuery.fn.ready = function( fn ) {
1474 jQuery.ready.promise().done( fn );
1480 // Is the DOM ready to be used? Set to true once it occurs.
1483 // A counter to track how many items to wait for before
1484 // the ready event fires. See #6781
1487 // Hold (or release) the ready event
1488 holdReady: function( hold ) {
1492 jQuery.ready( true );
1496 // Handle when the DOM is ready
1497 ready: function( wait ) {
1499 // Abort if there are pending holds or we're already ready
1500 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
1504 // Remember that the DOM is ready
1505 jQuery.isReady = true;
1507 // If a normal DOM Ready event fired, decrement, and wait if need be
1508 if ( wait !== true && --jQuery.readyWait > 0 ) {
1512 // If there are functions bound, to execute
1513 readyList.resolveWith( document, [ jQuery ] );
1515 // Trigger any bound ready events
1516 if ( jQuery.fn.triggerHandler ) {
1517 jQuery( document ).triggerHandler( "ready" );
1518 jQuery( document ).off( "ready" );
1524 * The ready event handler and self cleanup method
1526 function completed() {
1527 document.removeEventListener( "DOMContentLoaded", completed, false );
1528 window.removeEventListener( "load", completed, false );
1532 jQuery.ready.promise = function( obj ) {
1535 readyList = jQuery.Deferred();
1537 // Catch cases where $(document).ready() is called after the browser event has already occurred.
1538 // we once tried to use readyState "interactive" here, but it caused issues like the one
1539 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
1540 if ( document.readyState === "complete" ) {
1541 // Handle it asynchronously to allow scripts the opportunity to delay ready
1542 setTimeout( jQuery.ready );
1546 // Use the handy event callback
1547 document.addEventListener( "DOMContentLoaded", completed, false );
1549 // A fallback to window.onload, that will always work
1550 window.addEventListener( "load", completed, false );
1553 return readyList.promise( obj );
1556 // Kick off the DOM ready check even if the user does not
1557 jQuery.ready.promise();
1562 // Multifunctional method to get and set values of a collection
1563 // The value/s can optionally be executed if it's a function
1564 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
1570 if ( jQuery.type( key ) === "object" ) {
1573 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
1577 } else if ( value !== undefined ) {
1580 if ( !jQuery.isFunction( value ) ) {
1585 // Bulk operations run against the entire set
1587 fn.call( elems, value );
1590 // ...except when executing function values
1593 fn = function( elem, key, value ) {
1594 return bulk.call( jQuery( elem ), value );
1600 for ( ; i < len; i++ ) {
1601 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
1612 len ? fn( elems[0], key ) : emptyGet;
1617 * Determines whether an object can have data
1619 jQuery.acceptData = function( owner ) {
1622 // - Node.ELEMENT_NODE
1623 // - Node.DOCUMENT_NODE
1627 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
1632 // Support: Android < 4,
1633 // Old WebKit does not have Object.preventExtensions/freeze method,
1634 // return new empty object instead with no [[set]] accessor
1635 Object.defineProperty( this.cache = {}, 0, {
1641 this.expando = jQuery.expando + Math.random();
1645 Data.accepts = jQuery.acceptData;
1648 key: function( owner ) {
1649 // We can accept data for non-element nodes in modern browsers,
1650 // but we should not, see #8335.
1651 // Always return the key for a frozen object.
1652 if ( !Data.accepts( owner ) ) {
1656 var descriptor = {},
1657 // Check if the owner object already has a cache key
1658 unlock = owner[ this.expando ];
1660 // If not, create one
1662 unlock = Data.uid++;
1664 // Secure it in a non-enumerable, non-writable property
1666 descriptor[ this.expando ] = { value: unlock };
1667 Object.defineProperties( owner, descriptor );
1669 // Support: Android < 4
1670 // Fallback to a less secure definition
1672 descriptor[ this.expando ] = unlock;
1673 jQuery.extend( owner, descriptor );
1677 // Ensure the cache object
1678 if ( !this.cache[ unlock ] ) {
1679 this.cache[ unlock ] = {};
1684 set: function( owner, data, value ) {
1686 // There may be an unlock assigned to this node,
1687 // if there is no entry for this "owner", create one inline
1688 // and set the unlock as though an owner entry had always existed
1689 unlock = this.key( owner ),
1690 cache = this.cache[ unlock ];
1692 // Handle: [ owner, key, value ] args
1693 if ( typeof data === "string" ) {
1694 cache[ data ] = value;
1696 // Handle: [ owner, { properties } ] args
1698 // Fresh assignments by object are shallow copied
1699 if ( jQuery.isEmptyObject( cache ) ) {
1700 jQuery.extend( this.cache[ unlock ], data );
1701 // Otherwise, copy the properties one-by-one to the cache object
1703 for ( prop in data ) {
1704 cache[ prop ] = data[ prop ];
1710 get: function( owner, key ) {
1711 // Either a valid cache is found, or will be created.
1712 // New caches will be created and the unlock returned,
1713 // allowing direct access to the newly created
1714 // empty data object. A valid owner object must be provided.
1715 var cache = this.cache[ this.key( owner ) ];
1717 return key === undefined ?
1718 cache : cache[ key ];
1720 access: function( owner, key, value ) {
1722 // In cases where either:
1724 // 1. No key was specified
1725 // 2. A string key was specified, but no value provided
1727 // Take the "read" path and allow the get method to determine
1728 // which value to return, respectively either:
1730 // 1. The entire cache object
1731 // 2. The data stored at the key
1733 if ( key === undefined ||
1734 ((key && typeof key === "string") && value === undefined) ) {
1736 stored = this.get( owner, key );
1738 return stored !== undefined ?
1739 stored : this.get( owner, jQuery.camelCase(key) );
1742 // [*]When the key is not a string, or both a key and value
1743 // are specified, set or extend (existing objects) with either:
1745 // 1. An object of properties
1746 // 2. A key and value
1748 this.set( owner, key, value );
1750 // Since the "set" path can have two possible entry points
1751 // return the expected data based on which path was taken[*]
1752 return value !== undefined ? value : key;
1754 remove: function( owner, key ) {
1756 unlock = this.key( owner ),
1757 cache = this.cache[ unlock ];
1759 if ( key === undefined ) {
1760 this.cache[ unlock ] = {};
1763 // Support array or space separated string of keys
1764 if ( jQuery.isArray( key ) ) {
1765 // If "name" is an array of keys...
1766 // When data is initially created, via ("key", "val") signature,
1767 // keys will be converted to camelCase.
1768 // Since there is no way to tell _how_ a key was added, remove
1769 // both plain key and camelCase key. #12786
1770 // This will only penalize the array argument path.
1771 name = key.concat( key.map( jQuery.camelCase ) );
1773 camel = jQuery.camelCase( key );
1774 // Try the string as a key before any manipulation
1775 if ( key in cache ) {
1776 name = [ key, camel ];
1778 // If a key with the spaces exists, use it.
1779 // Otherwise, create an array by matching non-whitespace
1781 name = name in cache ?
1782 [ name ] : ( name.match( rnotwhite ) || [] );
1788 delete cache[ name[ i ] ];
1792 hasData: function( owner ) {
1793 return !jQuery.isEmptyObject(
1794 this.cache[ owner[ this.expando ] ] || {}
1797 discard: function( owner ) {
1798 if ( owner[ this.expando ] ) {
1799 delete this.cache[ owner[ this.expando ] ];
1803 var data_priv = new Data();
1805 var data_user = new Data();
1810 Implementation Summary
1812 1. Enforce API surface and semantic compatibility with 1.9.x branch
1813 2. Improve the module's maintainability by reducing the storage
1814 paths to a single mechanism.
1815 3. Use the same single mechanism to support "private" and "user" data.
1816 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
1817 5. Avoid exposing implementation details on user objects (eg. expando properties)
1818 6. Provide a clear path for implementation upgrade to WeakMap in 2014
1820 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
1821 rmultiDash = /([A-Z])/g;
1823 function dataAttr( elem, key, data ) {
1826 // If nothing was found internally, try to fetch any
1827 // data from the HTML5 data-* attribute
1828 if ( data === undefined && elem.nodeType === 1 ) {
1829 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
1830 data = elem.getAttribute( name );
1832 if ( typeof data === "string" ) {
1834 data = data === "true" ? true :
1835 data === "false" ? false :
1836 data === "null" ? null :
1837 // Only convert to a number if it doesn't change the string
1838 +data + "" === data ? +data :
1839 rbrace.test( data ) ? jQuery.parseJSON( data ) :
1843 // Make sure we set the data so it isn't changed later
1844 data_user.set( elem, key, data );
1853 hasData: function( elem ) {
1854 return data_user.hasData( elem ) || data_priv.hasData( elem );
1857 data: function( elem, name, data ) {
1858 return data_user.access( elem, name, data );
1861 removeData: function( elem, name ) {
1862 data_user.remove( elem, name );
1865 // TODO: Now that all calls to _data and _removeData have been replaced
1866 // with direct calls to data_priv methods, these can be deprecated.
1867 _data: function( elem, name, data ) {
1868 return data_priv.access( elem, name, data );
1871 _removeData: function( elem, name ) {
1872 data_priv.remove( elem, name );
1877 data: function( key, value ) {
1880 attrs = elem && elem.attributes;
1883 if ( key === undefined ) {
1884 if ( this.length ) {
1885 data = data_user.get( elem );
1887 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
1892 // The attrs elements can be null (#14894)
1894 name = attrs[ i ].name;
1895 if ( name.indexOf( "data-" ) === 0 ) {
1896 name = jQuery.camelCase( name.slice(5) );
1897 dataAttr( elem, name, data[ name ] );
1901 data_priv.set( elem, "hasDataAttrs", true );
1908 // Sets multiple values
1909 if ( typeof key === "object" ) {
1910 return this.each(function() {
1911 data_user.set( this, key );
1915 return access( this, function( value ) {
1917 camelKey = jQuery.camelCase( key );
1919 // The calling jQuery object (element matches) is not empty
1920 // (and therefore has an element appears at this[ 0 ]) and the
1921 // `value` parameter was not undefined. An empty jQuery object
1922 // will result in `undefined` for elem = this[ 0 ] which will
1923 // throw an exception if an attempt to read a data cache is made.
1924 if ( elem && value === undefined ) {
1925 // Attempt to get data from the cache
1926 // with the key as-is
1927 data = data_user.get( elem, key );
1928 if ( data !== undefined ) {
1932 // Attempt to get data from the cache
1933 // with the key camelized
1934 data = data_user.get( elem, camelKey );
1935 if ( data !== undefined ) {
1939 // Attempt to "discover" the data in
1940 // HTML5 custom data-* attrs
1941 data = dataAttr( elem, camelKey, undefined );
1942 if ( data !== undefined ) {
1946 // We tried really hard, but the data doesn't exist.
1951 this.each(function() {
1952 // First, attempt to store a copy or reference of any
1953 // data that might've been store with a camelCased key.
1954 var data = data_user.get( this, camelKey );
1956 // For HTML5 data-* attribute interop, we have to
1957 // store property names with dashes in a camelCase form.
1958 // This might not apply to all properties...*
1959 data_user.set( this, camelKey, value );
1961 // *... In the case of properties that might _actually_
1962 // have dashes, we need to also store a copy of that
1963 // unchanged property.
1964 if ( key.indexOf("-") !== -1 && data !== undefined ) {
1965 data_user.set( this, key, value );
1968 }, null, value, arguments.length > 1, null, true );
1971 removeData: function( key ) {
1972 return this.each(function() {
1973 data_user.remove( this, key );
1980 queue: function( elem, type, data ) {
1984 type = ( type || "fx" ) + "queue";
1985 queue = data_priv.get( elem, type );
1987 // Speed up dequeue by getting out quickly if this is just a lookup
1989 if ( !queue || jQuery.isArray( data ) ) {
1990 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
1999 dequeue: function( elem, type ) {
2000 type = type || "fx";
2002 var queue = jQuery.queue( elem, type ),
2003 startLength = queue.length,
2005 hooks = jQuery._queueHooks( elem, type ),
2007 jQuery.dequeue( elem, type );
2010 // If the fx queue is dequeued, always remove the progress sentinel
2011 if ( fn === "inprogress" ) {
2018 // Add a progress sentinel to prevent the fx queue from being
2019 // automatically dequeued
2020 if ( type === "fx" ) {
2021 queue.unshift( "inprogress" );
2024 // clear up the last queue stop function
2026 fn.call( elem, next, hooks );
2029 if ( !startLength && hooks ) {
2034 // not intended for public consumption - generates a queueHooks object, or returns the current one
2035 _queueHooks: function( elem, type ) {
2036 var key = type + "queueHooks";
2037 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
2038 empty: jQuery.Callbacks("once memory").add(function() {
2039 data_priv.remove( elem, [ type + "queue", key ] );
2046 queue: function( type, data ) {
2049 if ( typeof type !== "string" ) {
2055 if ( arguments.length < setter ) {
2056 return jQuery.queue( this[0], type );
2059 return data === undefined ?
2061 this.each(function() {
2062 var queue = jQuery.queue( this, type, data );
2064 // ensure a hooks for this queue
2065 jQuery._queueHooks( this, type );
2067 if ( type === "fx" && queue[0] !== "inprogress" ) {
2068 jQuery.dequeue( this, type );
2072 dequeue: function( type ) {
2073 return this.each(function() {
2074 jQuery.dequeue( this, type );
2077 clearQueue: function( type ) {
2078 return this.queue( type || "fx", [] );
2080 // Get a promise resolved when queues of a certain type
2081 // are emptied (fx is the type by default)
2082 promise: function( type, obj ) {
2085 defer = jQuery.Deferred(),
2088 resolve = function() {
2089 if ( !( --count ) ) {
2090 defer.resolveWith( elements, [ elements ] );
2094 if ( typeof type !== "string" ) {
2098 type = type || "fx";
2101 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
2102 if ( tmp && tmp.empty ) {
2104 tmp.empty.add( resolve );
2108 return defer.promise( obj );
2111 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
2113 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
2115 var isHidden = function( elem, el ) {
2116 // isHidden might be called from jQuery#filter function;
2117 // in that case, element will be second argument
2119 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
2122 var rcheckableType = (/^(?:checkbox|radio)$/i);
2127 var fragment = document.createDocumentFragment(),
2128 div = fragment.appendChild( document.createElement( "div" ) ),
2129 input = document.createElement( "input" );
2131 // #11217 - WebKit loses check when the name is after the checked attribute
2132 // Support: Windows Web Apps (WWA)
2133 // `name` and `type` need .setAttribute for WWA
2134 input.setAttribute( "type", "radio" );
2135 input.setAttribute( "checked", "checked" );
2136 input.setAttribute( "name", "t" );
2138 div.appendChild( input );
2140 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
2141 // old WebKit doesn't clone checked state correctly in fragments
2142 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
2144 // Make sure textarea (and checkbox) defaultValue is properly cloned
2145 // Support: IE9-IE11+
2146 div.innerHTML = "<textarea>x</textarea>";
2147 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
2149 var strundefined = typeof undefined;
2153 support.focusinBubbles = "onfocusin" in window;
2158 rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
2159 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
2160 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
2162 function returnTrue() {
2166 function returnFalse() {
2170 function safeActiveElement() {
2172 return document.activeElement;
2177 * Helper functions for managing events -- not part of the public interface.
2178 * Props to Dean Edwards' addEvent library for many of the ideas.
2184 add: function( elem, types, handler, data, selector ) {
2186 var handleObjIn, eventHandle, tmp,
2187 events, t, handleObj,
2188 special, handlers, type, namespaces, origType,
2189 elemData = data_priv.get( elem );
2191 // Don't attach events to noData or text/comment nodes (but allow plain objects)
2196 // Caller can pass in an object of custom data in lieu of the handler
2197 if ( handler.handler ) {
2198 handleObjIn = handler;
2199 handler = handleObjIn.handler;
2200 selector = handleObjIn.selector;
2203 // Make sure that the handler has a unique ID, used to find/remove it later
2204 if ( !handler.guid ) {
2205 handler.guid = jQuery.guid++;
2208 // Init the element's event structure and main handler, if this is the first
2209 if ( !(events = elemData.events) ) {
2210 events = elemData.events = {};
2212 if ( !(eventHandle = elemData.handle) ) {
2213 eventHandle = elemData.handle = function( e ) {
2214 // Discard the second event of a jQuery.event.trigger() and
2215 // when an event is called after a page has unloaded
2216 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
2217 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
2221 // Handle multiple events separated by a space
2222 types = ( types || "" ).match( rnotwhite ) || [ "" ];
2225 tmp = rtypenamespace.exec( types[t] ) || [];
2226 type = origType = tmp[1];
2227 namespaces = ( tmp[2] || "" ).split( "." ).sort();
2229 // There *must* be a type, no attaching namespace-only handlers
2234 // If event changes its type, use the special event handlers for the changed type
2235 special = jQuery.event.special[ type ] || {};
2237 // If selector defined, determine special event api type, otherwise given type
2238 type = ( selector ? special.delegateType : special.bindType ) || type;
2240 // Update special based on newly reset type
2241 special = jQuery.event.special[ type ] || {};
2243 // handleObj is passed to all event handlers
2244 handleObj = jQuery.extend({
2251 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
2252 namespace: namespaces.join(".")
2255 // Init the event handler queue if we're the first
2256 if ( !(handlers = events[ type ]) ) {
2257 handlers = events[ type ] = [];
2258 handlers.delegateCount = 0;
2260 // Only use addEventListener if the special events handler returns false
2261 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
2262 if ( elem.addEventListener ) {
2263 elem.addEventListener( type, eventHandle, false );
2268 if ( special.add ) {
2269 special.add.call( elem, handleObj );
2271 if ( !handleObj.handler.guid ) {
2272 handleObj.handler.guid = handler.guid;
2276 // Add to the element's handler list, delegates in front
2278 handlers.splice( handlers.delegateCount++, 0, handleObj );
2280 handlers.push( handleObj );
2283 // Keep track of which events have ever been used, for event optimization
2284 jQuery.event.global[ type ] = true;
2289 // Detach an event or set of events from an element
2290 remove: function( elem, types, handler, selector, mappedTypes ) {
2292 var j, origCount, tmp,
2293 events, t, handleObj,
2294 special, handlers, type, namespaces, origType,
2295 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
2297 if ( !elemData || !(events = elemData.events) ) {
2301 // Once for each type.namespace in types; type may be omitted
2302 types = ( types || "" ).match( rnotwhite ) || [ "" ];
2305 tmp = rtypenamespace.exec( types[t] ) || [];
2306 type = origType = tmp[1];
2307 namespaces = ( tmp[2] || "" ).split( "." ).sort();
2309 // Unbind all events (on this namespace, if provided) for the element
2311 for ( type in events ) {
2312 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
2317 special = jQuery.event.special[ type ] || {};
2318 type = ( selector ? special.delegateType : special.bindType ) || type;
2319 handlers = events[ type ] || [];
2320 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
2322 // Remove matching events
2323 origCount = j = handlers.length;
2325 handleObj = handlers[ j ];
2327 if ( ( mappedTypes || origType === handleObj.origType ) &&
2328 ( !handler || handler.guid === handleObj.guid ) &&
2329 ( !tmp || tmp.test( handleObj.namespace ) ) &&
2330 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
2331 handlers.splice( j, 1 );
2333 if ( handleObj.selector ) {
2334 handlers.delegateCount--;
2336 if ( special.remove ) {
2337 special.remove.call( elem, handleObj );
2342 // Remove generic event handler if we removed something and no more handlers exist
2343 // (avoids potential for endless recursion during removal of special event handlers)
2344 if ( origCount && !handlers.length ) {
2345 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
2346 jQuery.removeEvent( elem, type, elemData.handle );
2349 delete events[ type ];
2353 // Remove the expando if it's no longer used
2354 if ( jQuery.isEmptyObject( events ) ) {
2355 delete elemData.handle;
2356 data_priv.remove( elem, "events" );
2360 trigger: function( event, data, elem, onlyHandlers ) {
2362 var i, cur, tmp, bubbleType, ontype, handle, special,
2363 eventPath = [ elem || document ],
2364 type = hasOwn.call( event, "type" ) ? event.type : event,
2365 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
2367 cur = tmp = elem = elem || document;
2369 // Don't do events on text and comment nodes
2370 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
2374 // focus/blur morphs to focusin/out; ensure we're not firing them right now
2375 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
2379 if ( type.indexOf(".") >= 0 ) {
2380 // Namespaced trigger; create a regexp to match event type in handle()
2381 namespaces = type.split(".");
2382 type = namespaces.shift();
2385 ontype = type.indexOf(":") < 0 && "on" + type;
2387 // Caller can pass in a jQuery.Event object, Object, or just an event type string
2388 event = event[ jQuery.expando ] ?
2390 new jQuery.Event( type, typeof event === "object" && event );
2392 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
2393 event.isTrigger = onlyHandlers ? 2 : 3;
2394 event.namespace = namespaces.join(".");
2395 event.namespace_re = event.namespace ?
2396 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
2399 // Clean up the event in case it is being reused
2400 event.result = undefined;
2401 if ( !event.target ) {
2402 event.target = elem;
2405 // Clone any incoming data and prepend the event, creating the handler arg list
2406 data = data == null ?
2408 jQuery.makeArray( data, [ event ] );
2410 // Allow special events to draw outside the lines
2411 special = jQuery.event.special[ type ] || {};
2412 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
2416 // Determine event propagation path in advance, per W3C events spec (#9951)
2417 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
2418 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
2420 bubbleType = special.delegateType || type;
2421 if ( !rfocusMorph.test( bubbleType + type ) ) {
2422 cur = cur.parentNode;
2424 for ( ; cur; cur = cur.parentNode ) {
2425 eventPath.push( cur );
2429 // Only add window if we got to document (e.g., not plain obj or detached DOM)
2430 if ( tmp === (elem.ownerDocument || document) ) {
2431 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
2435 // Fire handlers on the event path
2437 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
2439 event.type = i > 1 ?
2441 special.bindType || type;
2444 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
2446 handle.apply( cur, data );
2450 handle = ontype && cur[ ontype ];
2451 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
2452 event.result = handle.apply( cur, data );
2453 if ( event.result === false ) {
2454 event.preventDefault();
2460 // If nobody prevented the default action, do it now
2461 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
2463 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
2464 jQuery.acceptData( elem ) ) {
2466 // Call a native DOM method on the target with the same name name as the event.
2467 // Don't do default actions on window, that's where global variables be (#6170)
2468 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
2470 // Don't re-trigger an onFOO event when we call its FOO() method
2471 tmp = elem[ ontype ];
2474 elem[ ontype ] = null;
2477 // Prevent re-triggering of the same event, since we already bubbled it above
2478 jQuery.event.triggered = type;
2480 jQuery.event.triggered = undefined;
2483 elem[ ontype ] = tmp;
2489 return event.result;
2492 dispatch: function( event ) {
2494 // Make a writable jQuery.Event from the native event object
2495 event = jQuery.event.fix( event );
2497 var i, j, ret, matched, handleObj,
2499 args = slice.call( arguments ),
2500 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
2501 special = jQuery.event.special[ event.type ] || {};
2503 // Use the fix-ed jQuery.Event rather than the (read-only) native event
2505 event.delegateTarget = this;
2507 // Call the preDispatch hook for the mapped type, and let it bail if desired
2508 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
2512 // Determine handlers
2513 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
2515 // Run delegates first; they may want to stop propagation beneath us
2517 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
2518 event.currentTarget = matched.elem;
2521 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
2523 // Triggered event must either 1) have no namespace, or
2524 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
2525 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
2527 event.handleObj = handleObj;
2528 event.data = handleObj.data;
2530 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
2531 .apply( matched.elem, args );
2533 if ( ret !== undefined ) {
2534 if ( (event.result = ret) === false ) {
2535 event.preventDefault();
2536 event.stopPropagation();
2543 // Call the postDispatch hook for the mapped type
2544 if ( special.postDispatch ) {
2545 special.postDispatch.call( this, event );
2548 return event.result;
2551 handlers: function( event, handlers ) {
2552 var i, matches, sel, handleObj,
2554 delegateCount = handlers.delegateCount,
2557 // Find delegate handlers
2558 // Black-hole SVG <use> instance trees (#13180)
2559 // Avoid non-left-click bubbling in Firefox (#3861)
2560 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
2562 for ( ; cur !== this; cur = cur.parentNode || this ) {
2564 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
2565 if ( cur.disabled !== true || event.type !== "click" ) {
2567 for ( i = 0; i < delegateCount; i++ ) {
2568 handleObj = handlers[ i ];
2570 // Don't conflict with Object.prototype properties (#13203)
2571 sel = handleObj.selector + " ";
2573 if ( matches[ sel ] === undefined ) {
2574 matches[ sel ] = handleObj.needsContext ?
2575 jQuery( sel, this ).index( cur ) >= 0 :
2576 jQuery.find( sel, this, null, [ cur ] ).length;
2578 if ( matches[ sel ] ) {
2579 matches.push( handleObj );
2582 if ( matches.length ) {
2583 handlerQueue.push({ elem: cur, handlers: matches });
2589 // Add the remaining (directly-bound) handlers
2590 if ( delegateCount < handlers.length ) {
2591 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
2594 return handlerQueue;
2597 // Includes some event props shared by KeyEvent and MouseEvent
2598 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
2603 props: "char charCode key keyCode".split(" "),
2604 filter: function( event, original ) {
2606 // Add which for key events
2607 if ( event.which == null ) {
2608 event.which = original.charCode != null ? original.charCode : original.keyCode;
2616 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
2617 filter: function( event, original ) {
2618 var eventDoc, doc, body,
2619 button = original.button;
2621 // Calculate pageX/Y if missing and clientX/Y available
2622 if ( event.pageX == null && original.clientX != null ) {
2623 eventDoc = event.target.ownerDocument || document;
2624 doc = eventDoc.documentElement;
2625 body = eventDoc.body;
2627 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
2628 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
2631 // Add which for click: 1 === left; 2 === middle; 3 === right
2632 // Note: button is not normalized, so don't use it
2633 if ( !event.which && button !== undefined ) {
2634 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
2641 fix: function( event ) {
2642 if ( event[ jQuery.expando ] ) {
2646 // Create a writable copy of the event object and normalize some properties
2649 originalEvent = event,
2650 fixHook = this.fixHooks[ type ];
2653 this.fixHooks[ type ] = fixHook =
2654 rmouseEvent.test( type ) ? this.mouseHooks :
2655 rkeyEvent.test( type ) ? this.keyHooks :
2658 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
2660 event = new jQuery.Event( originalEvent );
2665 event[ prop ] = originalEvent[ prop ];
2668 // Support: Cordova 2.5 (WebKit) (#13255)
2669 // All events should have a target; Cordova deviceready doesn't
2670 if ( !event.target ) {
2671 event.target = document;
2674 // Support: Safari 6.0+, Chrome < 28
2675 // Target should not be a text node (#504, #13143)
2676 if ( event.target.nodeType === 3 ) {
2677 event.target = event.target.parentNode;
2680 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
2685 // Prevent triggered image.load events from bubbling to window.load
2689 // Fire native event if possible so blur/focus sequence is correct
2690 trigger: function() {
2691 if ( this !== safeActiveElement() && this.focus ) {
2696 delegateType: "focusin"
2699 trigger: function() {
2700 if ( this === safeActiveElement() && this.blur ) {
2705 delegateType: "focusout"
2708 // For checkbox, fire native event so checked state will be right
2709 trigger: function() {
2710 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
2716 // For cross-browser consistency, don't fire native .click() on links
2717 _default: function( event ) {
2718 return jQuery.nodeName( event.target, "a" );
2723 postDispatch: function( event ) {
2725 // Support: Firefox 20+
2726 // Firefox doesn't alert if the returnValue field is not set.
2727 if ( event.result !== undefined && event.originalEvent ) {
2728 event.originalEvent.returnValue = event.result;
2734 simulate: function( type, elem, event, bubble ) {
2735 // Piggyback on a donor event to simulate a different one.
2736 // Fake originalEvent to avoid donor's stopPropagation, but if the
2737 // simulated event prevents default then we do the same on the donor.
2738 var e = jQuery.extend(
2748 jQuery.event.trigger( e, null, elem );
2750 jQuery.event.dispatch.call( elem, e );
2752 if ( e.isDefaultPrevented() ) {
2753 event.preventDefault();
2758 jQuery.removeEvent = function( elem, type, handle ) {
2759 if ( elem.removeEventListener ) {
2760 elem.removeEventListener( type, handle, false );
2764 jQuery.Event = function( src, props ) {
2765 // Allow instantiation without the 'new' keyword
2766 if ( !(this instanceof jQuery.Event) ) {
2767 return new jQuery.Event( src, props );
2771 if ( src && src.type ) {
2772 this.originalEvent = src;
2773 this.type = src.type;
2775 // Events bubbling up the document may have been marked as prevented
2776 // by a handler lower down the tree; reflect the correct value.
2777 this.isDefaultPrevented = src.defaultPrevented ||
2778 src.defaultPrevented === undefined &&
2779 // Support: Android < 4.0
2780 src.returnValue === false ?
2789 // Put explicitly provided properties onto the event object
2791 jQuery.extend( this, props );
2794 // Create a timestamp if incoming event doesn't have one
2795 this.timeStamp = src && src.timeStamp || jQuery.now();
2798 this[ jQuery.expando ] = true;
2801 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
2802 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
2803 jQuery.Event.prototype = {
2804 isDefaultPrevented: returnFalse,
2805 isPropagationStopped: returnFalse,
2806 isImmediatePropagationStopped: returnFalse,
2808 preventDefault: function() {
2809 var e = this.originalEvent;
2811 this.isDefaultPrevented = returnTrue;
2813 if ( e && e.preventDefault ) {
2817 stopPropagation: function() {
2818 var e = this.originalEvent;
2820 this.isPropagationStopped = returnTrue;
2822 if ( e && e.stopPropagation ) {
2823 e.stopPropagation();
2826 stopImmediatePropagation: function() {
2827 var e = this.originalEvent;
2829 this.isImmediatePropagationStopped = returnTrue;
2831 if ( e && e.stopImmediatePropagation ) {
2832 e.stopImmediatePropagation();
2835 this.stopPropagation();
2839 // Create mouseenter/leave events using mouseover/out and event-time checks
2840 // Support: Chrome 15+
2842 mouseenter: "mouseover",
2843 mouseleave: "mouseout",
2844 pointerenter: "pointerover",
2845 pointerleave: "pointerout"
2846 }, function( orig, fix ) {
2847 jQuery.event.special[ orig ] = {
2851 handle: function( event ) {
2854 related = event.relatedTarget,
2855 handleObj = event.handleObj;
2857 // For mousenter/leave call the handler if related is outside the target.
2858 // NB: No relatedTarget if the mouse left/entered the browser window
2859 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
2860 event.type = handleObj.origType;
2861 ret = handleObj.handler.apply( this, arguments );
2869 // Create "bubbling" focus and blur events
2870 // Support: Firefox, Chrome, Safari
2871 if ( !support.focusinBubbles ) {
2872 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
2874 // Attach a single capturing handler on the document while someone wants focusin/focusout
2875 var handler = function( event ) {
2876 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
2879 jQuery.event.special[ fix ] = {
2881 var doc = this.ownerDocument || this,
2882 attaches = data_priv.access( doc, fix );
2885 doc.addEventListener( orig, handler, true );
2887 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
2889 teardown: function() {
2890 var doc = this.ownerDocument || this,
2891 attaches = data_priv.access( doc, fix ) - 1;
2894 doc.removeEventListener( orig, handler, true );
2895 data_priv.remove( doc, fix );
2898 data_priv.access( doc, fix, attaches );
2907 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
2910 // Types can be a map of types/handlers
2911 if ( typeof types === "object" ) {
2912 // ( types-Object, selector, data )
2913 if ( typeof selector !== "string" ) {
2914 // ( types-Object, data )
2915 data = data || selector;
2916 selector = undefined;
2918 for ( type in types ) {
2919 this.on( type, selector, data, types[ type ], one );
2924 if ( data == null && fn == null ) {
2927 data = selector = undefined;
2928 } else if ( fn == null ) {
2929 if ( typeof selector === "string" ) {
2930 // ( types, selector, fn )
2934 // ( types, data, fn )
2937 selector = undefined;
2940 if ( fn === false ) {
2948 fn = function( event ) {
2949 // Can use an empty set, since event contains the info
2950 jQuery().off( event );
2951 return origFn.apply( this, arguments );
2953 // Use same guid so caller can remove using origFn
2954 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
2956 return this.each( function() {
2957 jQuery.event.add( this, types, fn, data, selector );
2960 one: function( types, selector, data, fn ) {
2961 return this.on( types, selector, data, fn, 1 );
2963 off: function( types, selector, fn ) {
2964 var handleObj, type;
2965 if ( types && types.preventDefault && types.handleObj ) {
2966 // ( event ) dispatched jQuery.Event
2967 handleObj = types.handleObj;
2968 jQuery( types.delegateTarget ).off(
2969 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
2975 if ( typeof types === "object" ) {
2976 // ( types-object [, selector] )
2977 for ( type in types ) {
2978 this.off( type, selector, types[ type ] );
2982 if ( selector === false || typeof selector === "function" ) {
2985 selector = undefined;
2987 if ( fn === false ) {
2990 return this.each(function() {
2991 jQuery.event.remove( this, types, fn, selector );
2995 trigger: function( type, data ) {
2996 return this.each(function() {
2997 jQuery.event.trigger( type, data, this );
3000 triggerHandler: function( type, data ) {
3003 return jQuery.event.trigger( type, data, elem, true );
3010 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
3011 rtagName = /<([\w:]+)/,
3012 rhtml = /<|&#?\w+;/,
3013 rnoInnerhtml = /<(?:script|style|link)/i,
3014 // checked="checked" or checked
3015 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
3016 rscriptType = /^$|\/(?:java|ecma)script/i,
3017 rscriptTypeMasked = /^true\/(.*)/,
3018 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
3020 // We have to close these tags to support XHTML (#13200)
3024 option: [ 1, "<select multiple='multiple'>", "</select>" ],
3026 thead: [ 1, "<table>", "</table>" ],
3027 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
3028 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
3029 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
3031 _default: [ 0, "", "" ]
3035 wrapMap.optgroup = wrapMap.option;
3037 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
3038 wrapMap.th = wrapMap.td;
3040 // Support: 1.x compatibility
3041 // Manipulating tables requires a tbody
3042 function manipulationTarget( elem, content ) {
3043 return jQuery.nodeName( elem, "table" ) &&
3044 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
3046 elem.getElementsByTagName("tbody")[0] ||
3047 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
3051 // Replace/restore the type attribute of script elements for safe DOM manipulation
3052 function disableScript( elem ) {
3053 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
3056 function restoreScript( elem ) {
3057 var match = rscriptTypeMasked.exec( elem.type );
3060 elem.type = match[ 1 ];
3062 elem.removeAttribute("type");
3068 // Mark scripts as having already been evaluated
3069 function setGlobalEval( elems, refElements ) {
3073 for ( ; i < l; i++ ) {
3075 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
3080 function cloneCopyEvent( src, dest ) {
3081 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
3083 if ( dest.nodeType !== 1 ) {
3087 // 1. Copy private data: events, handlers, etc.
3088 if ( data_priv.hasData( src ) ) {
3089 pdataOld = data_priv.access( src );
3090 pdataCur = data_priv.set( dest, pdataOld );
3091 events = pdataOld.events;
3094 delete pdataCur.handle;
3095 pdataCur.events = {};
3097 for ( type in events ) {
3098 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
3099 jQuery.event.add( dest, type, events[ type ][ i ] );
3105 // 2. Copy user data
3106 if ( data_user.hasData( src ) ) {
3107 udataOld = data_user.access( src );
3108 udataCur = jQuery.extend( {}, udataOld );
3110 data_user.set( dest, udataCur );
3114 function getAll( context, tag ) {
3115 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
3116 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
3119 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
3120 jQuery.merge( [ context ], ret ) :
3125 function fixInput( src, dest ) {
3126 var nodeName = dest.nodeName.toLowerCase();
3128 // Fails to persist the checked state of a cloned checkbox or radio button.
3129 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
3130 dest.checked = src.checked;
3132 // Fails to return the selected option to the default selected state when cloning options
3133 } else if ( nodeName === "input" || nodeName === "textarea" ) {
3134 dest.defaultValue = src.defaultValue;
3139 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
3140 var i, l, srcElements, destElements,
3141 clone = elem.cloneNode( true ),
3142 inPage = jQuery.contains( elem.ownerDocument, elem );
3145 // Fix Cloning issues
3146 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
3147 !jQuery.isXMLDoc( elem ) ) {
3149 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
3150 destElements = getAll( clone );
3151 srcElements = getAll( elem );
3153 for ( i = 0, l = srcElements.length; i < l; i++ ) {
3154 fixInput( srcElements[ i ], destElements[ i ] );
3158 // Copy the events from the original to the clone
3159 if ( dataAndEvents ) {
3160 if ( deepDataAndEvents ) {
3161 srcElements = srcElements || getAll( elem );
3162 destElements = destElements || getAll( clone );
3164 for ( i = 0, l = srcElements.length; i < l; i++ ) {
3165 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
3168 cloneCopyEvent( elem, clone );
3172 // Preserve script evaluation history
3173 destElements = getAll( clone, "script" );
3174 if ( destElements.length > 0 ) {
3175 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
3178 // Return the cloned set
3182 buildFragment: function( elems, context, scripts, selection ) {
3183 var elem, tmp, tag, wrap, contains, j,
3184 fragment = context.createDocumentFragment(),
3189 for ( ; i < l; i++ ) {
3192 if ( elem || elem === 0 ) {
3194 // Add nodes directly
3195 if ( jQuery.type( elem ) === "object" ) {
3196 // Support: QtWebKit
3197 // jQuery.merge because push.apply(_, arraylike) throws
3198 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
3200 // Convert non-html into a text node
3201 } else if ( !rhtml.test( elem ) ) {
3202 nodes.push( context.createTextNode( elem ) );
3204 // Convert html into DOM nodes
3206 tmp = tmp || fragment.appendChild( context.createElement("div") );
3208 // Deserialize a standard representation
3209 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
3210 wrap = wrapMap[ tag ] || wrapMap._default;
3211 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
3213 // Descend through wrappers to the right content
3216 tmp = tmp.lastChild;
3219 // Support: QtWebKit
3220 // jQuery.merge because push.apply(_, arraylike) throws
3221 jQuery.merge( nodes, tmp.childNodes );
3223 // Remember the top-level container
3224 tmp = fragment.firstChild;
3227 // Support: Webkit, IE
3228 tmp.textContent = "";
3233 // Remove wrapper from fragment
3234 fragment.textContent = "";
3237 while ( (elem = nodes[ i++ ]) ) {
3239 // #4087 - If origin and destination elements are the same, and this is
3240 // that element, do not do anything
3241 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
3245 contains = jQuery.contains( elem.ownerDocument, elem );
3247 // Append to fragment
3248 tmp = getAll( fragment.appendChild( elem ), "script" );
3250 // Preserve script evaluation history
3252 setGlobalEval( tmp );
3255 // Capture executables
3258 while ( (elem = tmp[ j++ ]) ) {
3259 if ( rscriptType.test( elem.type || "" ) ) {
3260 scripts.push( elem );
3269 cleanData: function( elems ) {
3270 var data, elem, type, key,
3271 special = jQuery.event.special,
3274 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
3275 if ( jQuery.acceptData( elem ) ) {
3276 key = elem[ data_priv.expando ];
3278 if ( key && (data = data_priv.cache[ key ]) ) {
3279 if ( data.events ) {
3280 for ( type in data.events ) {
3281 if ( special[ type ] ) {
3282 jQuery.event.remove( elem, type );
3284 // This is a shortcut to avoid jQuery.event.remove's overhead
3286 jQuery.removeEvent( elem, type, data.handle );
3290 if ( data_priv.cache[ key ] ) {
3291 // Discard any remaining `private` data
3292 delete data_priv.cache[ key ];
3296 // Discard any remaining `user` data
3297 delete data_user.cache[ elem[ data_user.expando ] ];
3303 text: function( value ) {
3304 return access( this, function( value ) {
3305 return value === undefined ?
3306 jQuery.text( this ) :
3307 this.empty().each(function() {
3308 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
3309 this.textContent = value;
3312 }, null, value, arguments.length );
3315 append: function() {
3316 return this.domManip( arguments, function( elem ) {
3317 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
3318 var target = manipulationTarget( this, elem );
3319 target.appendChild( elem );
3324 prepend: function() {
3325 return this.domManip( arguments, function( elem ) {
3326 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
3327 var target = manipulationTarget( this, elem );
3328 target.insertBefore( elem, target.firstChild );
3333 before: function() {
3334 return this.domManip( arguments, function( elem ) {
3335 if ( this.parentNode ) {
3336 this.parentNode.insertBefore( elem, this );
3342 return this.domManip( arguments, function( elem ) {
3343 if ( this.parentNode ) {
3344 this.parentNode.insertBefore( elem, this.nextSibling );
3349 remove: function( selector, keepData /* Internal Use Only */ ) {
3351 elems = selector ? jQuery.filter( selector, this ) : this,
3354 for ( ; (elem = elems[i]) != null; i++ ) {
3355 if ( !keepData && elem.nodeType === 1 ) {
3356 jQuery.cleanData( getAll( elem ) );
3359 if ( elem.parentNode ) {
3360 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
3361 setGlobalEval( getAll( elem, "script" ) );
3363 elem.parentNode.removeChild( elem );
3374 for ( ; (elem = this[i]) != null; i++ ) {
3375 if ( elem.nodeType === 1 ) {
3377 // Prevent memory leaks
3378 jQuery.cleanData( getAll( elem, false ) );
3380 // Remove any remaining nodes
3381 elem.textContent = "";
3388 clone: function( dataAndEvents, deepDataAndEvents ) {
3389 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
3390 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
3392 return this.map(function() {
3393 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
3397 html: function( value ) {
3398 return access( this, function( value ) {
3399 var elem = this[ 0 ] || {},
3403 if ( value === undefined && elem.nodeType === 1 ) {
3404 return elem.innerHTML;
3407 // See if we can take a shortcut and just use innerHTML
3408 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
3409 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
3411 value = value.replace( rxhtmlTag, "<$1></$2>" );
3414 for ( ; i < l; i++ ) {
3415 elem = this[ i ] || {};
3417 // Remove element nodes and prevent memory leaks
3418 if ( elem.nodeType === 1 ) {
3419 jQuery.cleanData( getAll( elem, false ) );
3420 elem.innerHTML = value;
3426 // If using innerHTML throws an exception, use the fallback method
3431 this.empty().append( value );
3433 }, null, value, arguments.length );
3436 replaceWith: function() {
3437 var arg = arguments[ 0 ];
3439 // Make the changes, replacing each context element with the new content
3440 this.domManip( arguments, function( elem ) {
3441 arg = this.parentNode;
3443 jQuery.cleanData( getAll( this ) );
3446 arg.replaceChild( elem, this );
3450 // Force removal if there was no new content (e.g., from empty arguments)
3451 return arg && (arg.length || arg.nodeType) ? this : this.remove();
3454 detach: function( selector ) {
3455 return this.remove( selector, true );
3458 domManip: function( args, callback ) {
3460 // Flatten any nested arrays
3461 args = concat.apply( [], args );
3463 var fragment, first, scripts, hasScripts, node, doc,
3469 isFunction = jQuery.isFunction( value );
3471 // We can't cloneNode fragments that contain checked, in WebKit
3473 ( l > 1 && typeof value === "string" &&
3474 !support.checkClone && rchecked.test( value ) ) ) {
3475 return this.each(function( index ) {
3476 var self = set.eq( index );
3478 args[ 0 ] = value.call( this, index, self.html() );
3480 self.domManip( args, callback );
3485 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
3486 first = fragment.firstChild;
3488 if ( fragment.childNodes.length === 1 ) {
3493 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
3494 hasScripts = scripts.length;
3496 // Use the original fragment for the last item instead of the first because it can end up
3497 // being emptied incorrectly in certain situations (#8070).
3498 for ( ; i < l; i++ ) {
3501 if ( i !== iNoClone ) {
3502 node = jQuery.clone( node, true, true );
3504 // Keep references to cloned scripts for later restoration
3506 // Support: QtWebKit
3507 // jQuery.merge because push.apply(_, arraylike) throws
3508 jQuery.merge( scripts, getAll( node, "script" ) );
3512 callback.call( this[ i ], node, i );
3516 doc = scripts[ scripts.length - 1 ].ownerDocument;
3519 jQuery.map( scripts, restoreScript );
3521 // Evaluate executable scripts on first document insertion
3522 for ( i = 0; i < hasScripts; i++ ) {
3523 node = scripts[ i ];
3524 if ( rscriptType.test( node.type || "" ) &&
3525 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
3528 // Optional AJAX dependency, but won't run scripts if not present
3529 if ( jQuery._evalUrl ) {
3530 jQuery._evalUrl( node.src );
3533 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
3547 prependTo: "prepend",
3548 insertBefore: "before",
3549 insertAfter: "after",
3550 replaceAll: "replaceWith"
3551 }, function( name, original ) {
3552 jQuery.fn[ name ] = function( selector ) {
3555 insert = jQuery( selector ),
3556 last = insert.length - 1,
3559 for ( ; i <= last; i++ ) {
3560 elems = i === last ? this : this.clone( true );
3561 jQuery( insert[ i ] )[ original ]( elems );
3563 // Support: QtWebKit
3564 // .get() because push.apply(_, arraylike) throws
3565 push.apply( ret, elems.get() );
3568 return this.pushStack( ret );
3577 * Retrieve the actual display of a element
3578 * @param {String} name nodeName of the element
3579 * @param {Object} doc Document object
3581 // Called only from within defaultDisplay
3582 function actualDisplay( name, doc ) {
3584 elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
3586 // getDefaultComputedStyle might be reliably used only on attached element
3587 display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
3589 // Use of this method is a temporary fix (more like optmization) until something better comes along,
3590 // since it was removed from specification and supported only in FF
3591 style.display : jQuery.css( elem[ 0 ], "display" );
3593 // We don't have any data stored on the element,
3594 // so use "detach" method as fast way to get rid of the element
3601 * Try to determine the default display value of an element
3602 * @param {String} nodeName
3604 function defaultDisplay( nodeName ) {
3606 display = elemdisplay[ nodeName ];
3609 display = actualDisplay( nodeName, doc );
3611 // If the simple way fails, read from inside an iframe
3612 if ( display === "none" || !display ) {
3614 // Use the already-created iframe if possible
3615 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
3617 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
3618 doc = iframe[ 0 ].contentDocument;
3624 display = actualDisplay( nodeName, doc );
3628 // Store the correct default display
3629 elemdisplay[ nodeName ] = display;
3634 var rmargin = (/^margin/);
3636 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
3638 var getStyles = function( elem ) {
3639 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
3644 function curCSS( elem, name, computed ) {
3645 var width, minWidth, maxWidth, ret,
3648 computed = computed || getStyles( elem );
3651 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
3653 ret = computed.getPropertyValue( name ) || computed[ name ];
3658 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
3659 ret = jQuery.style( elem, name );
3663 // A tribute to the "awesome hack by Dean Edwards"
3664 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
3665 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
3666 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
3668 // Remember the original values
3669 width = style.width;
3670 minWidth = style.minWidth;
3671 maxWidth = style.maxWidth;
3673 // Put in the new values to get a computed value out
3674 style.minWidth = style.maxWidth = style.width = ret;
3675 ret = computed.width;
3677 // Revert the changed values
3678 style.width = width;
3679 style.minWidth = minWidth;
3680 style.maxWidth = maxWidth;
3684 return ret !== undefined ?
3686 // IE returns zIndex value as an integer.
3692 function addGetHookIf( conditionFn, hookFn ) {
3693 // Define the hook, we'll check on the first run if it's really needed.
3696 if ( conditionFn() ) {
3697 // Hook not needed (or it's not possible to use it due to missing dependency),
3699 // Since there are no other hooks for marginRight, remove the whole object.
3704 // Hook needed; redefine it so that the support test is not executed again.
3706 return (this.get = hookFn).apply( this, arguments );
3713 var pixelPositionVal, boxSizingReliableVal,
3714 docElem = document.documentElement,
3715 container = document.createElement( "div" ),
3716 div = document.createElement( "div" );
3722 div.style.backgroundClip = "content-box";
3723 div.cloneNode( true ).style.backgroundClip = "";
3724 support.clearCloneStyle = div.style.backgroundClip === "content-box";
3726 container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
3727 "position:absolute";
3728 container.appendChild( div );
3730 // Executing both pixelPosition & boxSizingReliable tests require only one layout
3731 // so they're executed at the same time to save the second computation.
3732 function computePixelPositionAndBoxSizingReliable() {
3734 // Support: Firefox<29, Android 2.3
3735 // Vendor-prefix box-sizing
3736 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
3737 "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
3738 "border:1px;padding:1px;width:4px;position:absolute";
3740 docElem.appendChild( container );
3742 var divStyle = window.getComputedStyle( div, null );
3743 pixelPositionVal = divStyle.top !== "1%";
3744 boxSizingReliableVal = divStyle.width === "4px";
3746 docElem.removeChild( container );
3749 // Support: node.js jsdom
3750 // Don't assume that getComputedStyle is a property of the global object
3751 if ( window.getComputedStyle ) {
3752 jQuery.extend( support, {
3753 pixelPosition: function() {
3754 // This test is executed only once but we still do memoizing
3755 // since we can use the boxSizingReliable pre-computing.
3756 // No need to check if the test was already performed, though.
3757 computePixelPositionAndBoxSizingReliable();
3758 return pixelPositionVal;
3760 boxSizingReliable: function() {
3761 if ( boxSizingReliableVal == null ) {
3762 computePixelPositionAndBoxSizingReliable();
3764 return boxSizingReliableVal;
3766 reliableMarginRight: function() {
3767 // Support: Android 2.3
3768 // Check if div with explicit width and no margin-right incorrectly
3769 // gets computed margin-right based on width of container. (#3333)
3770 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
3771 // This support function is only executed once so no memoizing is needed.
3773 marginDiv = div.appendChild( document.createElement( "div" ) );
3775 // Reset CSS: box-sizing; display; margin; border; padding
3776 marginDiv.style.cssText = div.style.cssText =
3777 // Support: Firefox<29, Android 2.3
3778 // Vendor-prefix box-sizing
3779 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
3780 "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
3781 marginDiv.style.marginRight = marginDiv.style.width = "0";
3782 div.style.width = "1px";
3783 docElem.appendChild( container );
3785 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
3787 docElem.removeChild( container );
3796 // A method for quickly swapping in/out CSS properties to get correct calculations.
3797 jQuery.swap = function( elem, options, callback, args ) {
3801 // Remember the old values, and insert the new ones
3802 for ( name in options ) {
3803 old[ name ] = elem.style[ name ];
3804 elem.style[ name ] = options[ name ];
3807 ret = callback.apply( elem, args || [] );
3809 // Revert the old values
3810 for ( name in options ) {
3811 elem.style[ name ] = old[ name ];
3819 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
3820 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
3821 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
3822 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
3823 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
3825 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
3826 cssNormalTransform = {
3831 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
3833 // return a css property mapped to a potentially vendor prefixed property
3834 function vendorPropName( style, name ) {
3836 // shortcut for names that are not vendor prefixed
3837 if ( name in style ) {
3841 // check for vendor prefixed names
3842 var capName = name[0].toUpperCase() + name.slice(1),
3844 i = cssPrefixes.length;
3847 name = cssPrefixes[ i ] + capName;
3848 if ( name in style ) {
3856 function setPositiveNumber( elem, value, subtract ) {
3857 var matches = rnumsplit.exec( value );
3859 // Guard against undefined "subtract", e.g., when used as in cssHooks
3860 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
3864 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
3865 var i = extra === ( isBorderBox ? "border" : "content" ) ?
3866 // If we already have the right measurement, avoid augmentation
3868 // Otherwise initialize for horizontal or vertical properties
3869 name === "width" ? 1 : 0,
3873 for ( ; i < 4; i += 2 ) {
3874 // both box models exclude margin, so add it if we want it
3875 if ( extra === "margin" ) {
3876 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
3879 if ( isBorderBox ) {
3880 // border-box includes padding, so remove it if we want content
3881 if ( extra === "content" ) {
3882 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
3885 // at this point, extra isn't border nor margin, so remove border
3886 if ( extra !== "margin" ) {
3887 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
3890 // at this point, extra isn't content, so add padding
3891 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
3893 // at this point, extra isn't content nor padding, so add border
3894 if ( extra !== "padding" ) {
3895 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
3903 function getWidthOrHeight( elem, name, extra ) {
3905 // Start with offset property, which is equivalent to the border-box value
3906 var valueIsBorderBox = true,
3907 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
3908 styles = getStyles( elem ),
3909 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
3911 // some non-html elements return undefined for offsetWidth, so check for null/undefined
3912 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
3913 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
3914 if ( val <= 0 || val == null ) {
3915 // Fall back to computed then uncomputed css if necessary
3916 val = curCSS( elem, name, styles );
3917 if ( val < 0 || val == null ) {
3918 val = elem.style[ name ];
3921 // Computed unit is not pixels. Stop here and return.
3922 if ( rnumnonpx.test(val) ) {
3926 // we need the check for style in case a browser which returns unreliable values
3927 // for getComputedStyle silently falls back to the reliable elem.style
3928 valueIsBorderBox = isBorderBox &&
3929 ( support.boxSizingReliable() || val === elem.style[ name ] );
3931 // Normalize "", auto, and prepare for extra
3932 val = parseFloat( val ) || 0;
3935 // use the active box-sizing model to add/subtract irrelevant styles
3937 augmentWidthOrHeight(
3940 extra || ( isBorderBox ? "border" : "content" ),
3947 function showHide( elements, show ) {
3948 var display, elem, hidden,
3951 length = elements.length;
3953 for ( ; index < length; index++ ) {
3954 elem = elements[ index ];
3955 if ( !elem.style ) {
3959 values[ index ] = data_priv.get( elem, "olddisplay" );
3960 display = elem.style.display;
3962 // Reset the inline display of this element to learn if it is
3963 // being hidden by cascaded rules or not
3964 if ( !values[ index ] && display === "none" ) {
3965 elem.style.display = "";
3968 // Set elements which have been overridden with display: none
3969 // in a stylesheet to whatever the default browser style is
3970 // for such an element
3971 if ( elem.style.display === "" && isHidden( elem ) ) {
3972 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
3975 hidden = isHidden( elem );
3977 if ( display !== "none" || !hidden ) {
3978 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
3983 // Set the display of most of the elements in a second loop
3984 // to avoid the constant reflow
3985 for ( index = 0; index < length; index++ ) {
3986 elem = elements[ index ];
3987 if ( !elem.style ) {
3990 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
3991 elem.style.display = show ? values[ index ] || "" : "none";
3999 // Add in style property hooks for overriding the default
4000 // behavior of getting and setting a style property
4003 get: function( elem, computed ) {
4005 // We should always get a number back from opacity
4006 var ret = curCSS( elem, "opacity" );
4007 return ret === "" ? "1" : ret;
4013 // Don't automatically add "px" to these possibly-unitless properties
4015 "columnCount": true,
4016 "fillOpacity": true,
4029 // Add in properties whose names you wish to fix before
4030 // setting or getting the value
4032 // normalize float css property
4036 // Get and set the style property on a DOM Node
4037 style: function( elem, name, value, extra ) {
4038 // Don't set styles on text and comment nodes
4039 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
4043 // Make sure that we're working with the right name
4044 var ret, type, hooks,
4045 origName = jQuery.camelCase( name ),
4048 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
4050 // gets hook for the prefixed version
4051 // followed by the unprefixed version
4052 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
4054 // Check if we're setting a value
4055 if ( value !== undefined ) {
4056 type = typeof value;
4058 // convert relative number strings (+= or -=) to relative numbers. #7345
4059 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
4060 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
4065 // Make sure that null and NaN values aren't set. See: #7116
4066 if ( value == null || value !== value ) {
4070 // If a number was passed in, add 'px' to the (except for certain CSS properties)
4071 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
4075 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
4076 // but it would mean to define eight (for every problematic property) identical functions
4077 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
4078 style[ name ] = "inherit";
4081 // If a hook was provided, use that value, otherwise just set the specified value
4082 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
4083 style[ name ] = value;
4087 // If a hook was provided get the non-computed value from there
4088 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
4092 // Otherwise just get the value from the style object
4093 return style[ name ];
4097 css: function( elem, name, extra, styles ) {
4098 var val, num, hooks,
4099 origName = jQuery.camelCase( name );
4101 // Make sure that we're working with the right name
4102 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
4104 // gets hook for the prefixed version
4105 // followed by the unprefixed version
4106 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
4108 // If a hook was provided get the computed value from there
4109 if ( hooks && "get" in hooks ) {
4110 val = hooks.get( elem, true, extra );
4113 // Otherwise, if a way to get the computed value exists, use that
4114 if ( val === undefined ) {
4115 val = curCSS( elem, name, styles );
4118 //convert "normal" to computed value
4119 if ( val === "normal" && name in cssNormalTransform ) {
4120 val = cssNormalTransform[ name ];
4123 // Return, converting to number if forced or a qualifier was provided and val looks numeric
4124 if ( extra === "" || extra ) {
4125 num = parseFloat( val );
4126 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
4132 jQuery.each([ "height", "width" ], function( i, name ) {
4133 jQuery.cssHooks[ name ] = {
4134 get: function( elem, computed, extra ) {
4136 // certain elements can have dimension info if we invisibly show them
4137 // however, it must have a current display style that would benefit from this
4138 return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
4139 jQuery.swap( elem, cssShow, function() {
4140 return getWidthOrHeight( elem, name, extra );
4142 getWidthOrHeight( elem, name, extra );
4146 set: function( elem, value, extra ) {
4147 var styles = extra && getStyles( elem );
4148 return setPositiveNumber( elem, value, extra ?
4149 augmentWidthOrHeight(
4153 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
4161 // Support: Android 2.3
4162 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
4163 function( elem, computed ) {
4165 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
4166 // Work around by temporarily setting element display to inline-block
4167 return jQuery.swap( elem, { "display": "inline-block" },
4168 curCSS, [ elem, "marginRight" ] );
4173 // These hooks are used by animate to expand properties
4178 }, function( prefix, suffix ) {
4179 jQuery.cssHooks[ prefix + suffix ] = {
4180 expand: function( value ) {
4184 // assumes a single number if not a string
4185 parts = typeof value === "string" ? value.split(" ") : [ value ];
4187 for ( ; i < 4; i++ ) {
4188 expanded[ prefix + cssExpand[ i ] + suffix ] =
4189 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
4196 if ( !rmargin.test( prefix ) ) {
4197 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
4202 css: function( name, value ) {
4203 return access( this, function( elem, name, value ) {
4208 if ( jQuery.isArray( name ) ) {
4209 styles = getStyles( elem );
4212 for ( ; i < len; i++ ) {
4213 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
4219 return value !== undefined ?
4220 jQuery.style( elem, name, value ) :
4221 jQuery.css( elem, name );
4222 }, name, value, arguments.length > 1 );
4225 return showHide( this, true );
4228 return showHide( this );
4230 toggle: function( state ) {
4231 if ( typeof state === "boolean" ) {
4232 return state ? this.show() : this.hide();
4235 return this.each(function() {
4236 if ( isHidden( this ) ) {
4237 jQuery( this ).show();
4239 jQuery( this ).hide();
4246 function Tween( elem, options, prop, end, easing ) {
4247 return new Tween.prototype.init( elem, options, prop, end, easing );
4249 jQuery.Tween = Tween;
4253 init: function( elem, options, prop, end, easing, unit ) {
4256 this.easing = easing || "swing";
4257 this.options = options;
4258 this.start = this.now = this.cur();
4260 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
4263 var hooks = Tween.propHooks[ this.prop ];
4265 return hooks && hooks.get ?
4267 Tween.propHooks._default.get( this );
4269 run: function( percent ) {
4271 hooks = Tween.propHooks[ this.prop ];
4273 if ( this.options.duration ) {
4274 this.pos = eased = jQuery.easing[ this.easing ](
4275 percent, this.options.duration * percent, 0, 1, this.options.duration
4278 this.pos = eased = percent;
4280 this.now = ( this.end - this.start ) * eased + this.start;
4282 if ( this.options.step ) {
4283 this.options.step.call( this.elem, this.now, this );
4286 if ( hooks && hooks.set ) {
4289 Tween.propHooks._default.set( this );
4295 Tween.prototype.init.prototype = Tween.prototype;
4299 get: function( tween ) {
4302 if ( tween.elem[ tween.prop ] != null &&
4303 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
4304 return tween.elem[ tween.prop ];
4307 // passing an empty string as a 3rd parameter to .css will automatically
4308 // attempt a parseFloat and fallback to a string if the parse fails
4309 // so, simple values such as "10px" are parsed to Float.
4310 // complex values such as "rotate(1rad)" are returned as is.
4311 result = jQuery.css( tween.elem, tween.prop, "" );
4312 // Empty strings, null, undefined and "auto" are converted to 0.
4313 return !result || result === "auto" ? 0 : result;
4315 set: function( tween ) {
4316 // use step hook for back compat - use cssHook if its there - use .style if its
4317 // available and use plain properties where available
4318 if ( jQuery.fx.step[ tween.prop ] ) {
4319 jQuery.fx.step[ tween.prop ]( tween );
4320 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
4321 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
4323 tween.elem[ tween.prop ] = tween.now;
4330 // Panic based approach to setting things on disconnected nodes
4332 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
4333 set: function( tween ) {
4334 if ( tween.elem.nodeType && tween.elem.parentNode ) {
4335 tween.elem[ tween.prop ] = tween.now;
4341 linear: function( p ) {
4344 swing: function( p ) {
4345 return 0.5 - Math.cos( p * Math.PI ) / 2;
4349 jQuery.fx = Tween.prototype.init;
4351 // Back Compat <1.8 extension point
4352 jQuery.fx.step = {};
4359 rfxtypes = /^(?:toggle|show|hide)$/,
4360 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
4361 rrun = /queueHooks$/,
4362 animationPrefilters = [ defaultPrefilter ],
4364 "*": [ function( prop, value ) {
4365 var tween = this.createTween( prop, value ),
4366 target = tween.cur(),
4367 parts = rfxnum.exec( value ),
4368 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4370 // Starting value computation is required for potential unit mismatches
4371 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
4372 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
4376 if ( start && start[ 3 ] !== unit ) {
4377 // Trust units reported by jQuery.css
4378 unit = unit || start[ 3 ];
4380 // Make sure we update the tween properties later on
4381 parts = parts || [];
4383 // Iteratively approximate from a nonzero starting point
4384 start = +target || 1;
4387 // If previous iteration zeroed out, double until we get *something*
4388 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
4389 scale = scale || ".5";
4392 start = start / scale;
4393 jQuery.style( tween.elem, prop, start + unit );
4395 // Update scale, tolerating zero or NaN from tween.cur()
4396 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
4397 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
4400 // Update tween properties
4402 start = tween.start = +start || +target || 0;
4404 // If a +=/-= token was provided, we're doing a relative animation
4405 tween.end = parts[ 1 ] ?
4406 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
4414 // Animations created synchronously will run synchronously
4415 function createFxNow() {
4416 setTimeout(function() {
4419 return ( fxNow = jQuery.now() );
4422 // Generate parameters to create a standard animation
4423 function genFx( type, includeWidth ) {
4426 attrs = { height: type };
4428 // if we include width, step value is 1 to do all cssExpand values,
4429 // if we don't include width, step value is 2 to skip over Left and Right
4430 includeWidth = includeWidth ? 1 : 0;
4431 for ( ; i < 4 ; i += 2 - includeWidth ) {
4432 which = cssExpand[ i ];
4433 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
4436 if ( includeWidth ) {
4437 attrs.opacity = attrs.width = type;
4443 function createTween( value, prop, animation ) {
4445 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
4447 length = collection.length;
4448 for ( ; index < length; index++ ) {
4449 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
4451 // we're done with this property
4457 function defaultPrefilter( elem, props, opts ) {
4458 /* jshint validthis: true */
4459 var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
4463 hidden = elem.nodeType && isHidden( elem ),
4464 dataShow = data_priv.get( elem, "fxshow" );
4466 // handle queue: false promises
4467 if ( !opts.queue ) {
4468 hooks = jQuery._queueHooks( elem, "fx" );
4469 if ( hooks.unqueued == null ) {
4471 oldfire = hooks.empty.fire;
4472 hooks.empty.fire = function() {
4473 if ( !hooks.unqueued ) {
4480 anim.always(function() {
4481 // doing this makes sure that the complete handler will be called
4482 // before this completes
4483 anim.always(function() {
4485 if ( !jQuery.queue( elem, "fx" ).length ) {
4492 // height/width overflow pass
4493 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
4494 // Make sure that nothing sneaks out
4495 // Record all 3 overflow attributes because IE9-10 do not
4496 // change the overflow attribute when overflowX and
4497 // overflowY are set to the same value
4498 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
4500 // Set display property to inline-block for height/width
4501 // animations on inline elements that are having width/height animated
4502 display = jQuery.css( elem, "display" );
4504 // Test default display if display is currently "none"
4505 checkDisplay = display === "none" ?
4506 data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
4508 if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
4509 style.display = "inline-block";
4513 if ( opts.overflow ) {
4514 style.overflow = "hidden";
4515 anim.always(function() {
4516 style.overflow = opts.overflow[ 0 ];
4517 style.overflowX = opts.overflow[ 1 ];
4518 style.overflowY = opts.overflow[ 2 ];
4523 for ( prop in props ) {
4524 value = props[ prop ];
4525 if ( rfxtypes.exec( value ) ) {
4526 delete props[ prop ];
4527 toggle = toggle || value === "toggle";
4528 if ( value === ( hidden ? "hide" : "show" ) ) {
4530 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
4531 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
4537 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
4539 // Any non-fx value stops us from restoring the original display value
4541 display = undefined;
4545 if ( !jQuery.isEmptyObject( orig ) ) {
4547 if ( "hidden" in dataShow ) {
4548 hidden = dataShow.hidden;
4551 dataShow = data_priv.access( elem, "fxshow", {} );
4554 // store state if its toggle - enables .stop().toggle() to "reverse"
4556 dataShow.hidden = !hidden;
4559 jQuery( elem ).show();
4561 anim.done(function() {
4562 jQuery( elem ).hide();
4565 anim.done(function() {
4568 data_priv.remove( elem, "fxshow" );
4569 for ( prop in orig ) {
4570 jQuery.style( elem, prop, orig[ prop ] );
4573 for ( prop in orig ) {
4574 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
4576 if ( !( prop in dataShow ) ) {
4577 dataShow[ prop ] = tween.start;
4579 tween.end = tween.start;
4580 tween.start = prop === "width" || prop === "height" ? 1 : 0;
4585 // If this is a noop like .hide().hide(), restore an overwritten display value
4586 } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
4587 style.display = display;
4591 function propFilter( props, specialEasing ) {
4592 var index, name, easing, value, hooks;
4594 // camelCase, specialEasing and expand cssHook pass
4595 for ( index in props ) {
4596 name = jQuery.camelCase( index );
4597 easing = specialEasing[ name ];
4598 value = props[ index ];
4599 if ( jQuery.isArray( value ) ) {
4600 easing = value[ 1 ];
4601 value = props[ index ] = value[ 0 ];
4604 if ( index !== name ) {
4605 props[ name ] = value;
4606 delete props[ index ];
4609 hooks = jQuery.cssHooks[ name ];
4610 if ( hooks && "expand" in hooks ) {
4611 value = hooks.expand( value );
4612 delete props[ name ];
4614 // not quite $.extend, this wont overwrite keys already present.
4615 // also - reusing 'index' from above because we have the correct "name"
4616 for ( index in value ) {
4617 if ( !( index in props ) ) {
4618 props[ index ] = value[ index ];
4619 specialEasing[ index ] = easing;
4623 specialEasing[ name ] = easing;
4628 function Animation( elem, properties, options ) {
4632 length = animationPrefilters.length,
4633 deferred = jQuery.Deferred().always( function() {
4634 // don't match elem in the :animated selector
4641 var currentTime = fxNow || createFxNow(),
4642 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
4643 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
4644 temp = remaining / animation.duration || 0,
4647 length = animation.tweens.length;
4649 for ( ; index < length ; index++ ) {
4650 animation.tweens[ index ].run( percent );
4653 deferred.notifyWith( elem, [ animation, percent, remaining ]);
4655 if ( percent < 1 && length ) {
4658 deferred.resolveWith( elem, [ animation ] );
4662 animation = deferred.promise({
4664 props: jQuery.extend( {}, properties ),
4665 opts: jQuery.extend( true, { specialEasing: {} }, options ),
4666 originalProperties: properties,
4667 originalOptions: options,
4668 startTime: fxNow || createFxNow(),
4669 duration: options.duration,
4671 createTween: function( prop, end ) {
4672 var tween = jQuery.Tween( elem, animation.opts, prop, end,
4673 animation.opts.specialEasing[ prop ] || animation.opts.easing );
4674 animation.tweens.push( tween );
4677 stop: function( gotoEnd ) {
4679 // if we are going to the end, we want to run all the tweens
4680 // otherwise we skip this part
4681 length = gotoEnd ? animation.tweens.length : 0;
4686 for ( ; index < length ; index++ ) {
4687 animation.tweens[ index ].run( 1 );
4690 // resolve when we played the last frame
4691 // otherwise, reject
4693 deferred.resolveWith( elem, [ animation, gotoEnd ] );
4695 deferred.rejectWith( elem, [ animation, gotoEnd ] );
4700 props = animation.props;
4702 propFilter( props, animation.opts.specialEasing );
4704 for ( ; index < length ; index++ ) {
4705 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
4711 jQuery.map( props, createTween, animation );
4713 if ( jQuery.isFunction( animation.opts.start ) ) {
4714 animation.opts.start.call( elem, animation );
4718 jQuery.extend( tick, {
4721 queue: animation.opts.queue
4725 // attach callbacks from options
4726 return animation.progress( animation.opts.progress )
4727 .done( animation.opts.done, animation.opts.complete )
4728 .fail( animation.opts.fail )
4729 .always( animation.opts.always );
4732 jQuery.Animation = jQuery.extend( Animation, {
4734 tweener: function( props, callback ) {
4735 if ( jQuery.isFunction( props ) ) {
4739 props = props.split(" ");
4744 length = props.length;
4746 for ( ; index < length ; index++ ) {
4747 prop = props[ index ];
4748 tweeners[ prop ] = tweeners[ prop ] || [];
4749 tweeners[ prop ].unshift( callback );
4753 prefilter: function( callback, prepend ) {
4755 animationPrefilters.unshift( callback );
4757 animationPrefilters.push( callback );
4762 jQuery.speed = function( speed, easing, fn ) {
4763 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
4764 complete: fn || !fn && easing ||
4765 jQuery.isFunction( speed ) && speed,
4767 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
4770 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
4771 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
4773 // normalize opt.queue - true/undefined/null -> "fx"
4774 if ( opt.queue == null || opt.queue === true ) {
4779 opt.old = opt.complete;
4781 opt.complete = function() {
4782 if ( jQuery.isFunction( opt.old ) ) {
4783 opt.old.call( this );
4787 jQuery.dequeue( this, opt.queue );
4795 fadeTo: function( speed, to, easing, callback ) {
4797 // show any hidden elements after setting opacity to 0
4798 return this.filter( isHidden ).css( "opacity", 0 ).show()
4800 // animate to the value specified
4801 .end().animate({ opacity: to }, speed, easing, callback );
4803 animate: function( prop, speed, easing, callback ) {
4804 var empty = jQuery.isEmptyObject( prop ),
4805 optall = jQuery.speed( speed, easing, callback ),
4806 doAnimation = function() {
4807 // Operate on a copy of prop so per-property easing won't be lost
4808 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
4810 // Empty animations, or finishing resolves immediately
4811 if ( empty || data_priv.get( this, "finish" ) ) {
4815 doAnimation.finish = doAnimation;
4817 return empty || optall.queue === false ?
4818 this.each( doAnimation ) :
4819 this.queue( optall.queue, doAnimation );
4821 stop: function( type, clearQueue, gotoEnd ) {
4822 var stopQueue = function( hooks ) {
4823 var stop = hooks.stop;
4828 if ( typeof type !== "string" ) {
4829 gotoEnd = clearQueue;
4833 if ( clearQueue && type !== false ) {
4834 this.queue( type || "fx", [] );
4837 return this.each(function() {
4839 index = type != null && type + "queueHooks",
4840 timers = jQuery.timers,
4841 data = data_priv.get( this );
4844 if ( data[ index ] && data[ index ].stop ) {
4845 stopQueue( data[ index ] );
4848 for ( index in data ) {
4849 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
4850 stopQueue( data[ index ] );
4855 for ( index = timers.length; index--; ) {
4856 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
4857 timers[ index ].anim.stop( gotoEnd );
4859 timers.splice( index, 1 );
4863 // start the next in the queue if the last step wasn't forced
4864 // timers currently will call their complete callbacks, which will dequeue
4865 // but only if they were gotoEnd
4866 if ( dequeue || !gotoEnd ) {
4867 jQuery.dequeue( this, type );
4871 finish: function( type ) {
4872 if ( type !== false ) {
4873 type = type || "fx";
4875 return this.each(function() {
4877 data = data_priv.get( this ),
4878 queue = data[ type + "queue" ],
4879 hooks = data[ type + "queueHooks" ],
4880 timers = jQuery.timers,
4881 length = queue ? queue.length : 0;
4883 // enable finishing flag on private data
4886 // empty the queue first
4887 jQuery.queue( this, type, [] );
4889 if ( hooks && hooks.stop ) {
4890 hooks.stop.call( this, true );
4893 // look for any active animations, and finish them
4894 for ( index = timers.length; index--; ) {
4895 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
4896 timers[ index ].anim.stop( true );
4897 timers.splice( index, 1 );
4901 // look for any animations in the old queue and finish them
4902 for ( index = 0; index < length; index++ ) {
4903 if ( queue[ index ] && queue[ index ].finish ) {
4904 queue[ index ].finish.call( this );
4908 // turn off finishing flag
4914 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
4915 var cssFn = jQuery.fn[ name ];
4916 jQuery.fn[ name ] = function( speed, easing, callback ) {
4917 return speed == null || typeof speed === "boolean" ?
4918 cssFn.apply( this, arguments ) :
4919 this.animate( genFx( name, true ), speed, easing, callback );
4923 // Generate shortcuts for custom animations
4925 slideDown: genFx("show"),
4926 slideUp: genFx("hide"),
4927 slideToggle: genFx("toggle"),
4928 fadeIn: { opacity: "show" },
4929 fadeOut: { opacity: "hide" },
4930 fadeToggle: { opacity: "toggle" }
4931 }, function( name, props ) {
4932 jQuery.fn[ name ] = function( speed, easing, callback ) {
4933 return this.animate( props, speed, easing, callback );
4938 jQuery.fx.tick = function() {
4941 timers = jQuery.timers;
4943 fxNow = jQuery.now();
4945 for ( ; i < timers.length; i++ ) {
4946 timer = timers[ i ];
4947 // Checks the timer has not already been removed
4948 if ( !timer() && timers[ i ] === timer ) {
4949 timers.splice( i--, 1 );
4953 if ( !timers.length ) {
4959 jQuery.fx.timer = function( timer ) {
4960 jQuery.timers.push( timer );
4964 jQuery.timers.pop();
4968 jQuery.fx.interval = 13;
4970 jQuery.fx.start = function() {
4972 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
4976 jQuery.fx.stop = function() {
4977 clearInterval( timerId );
4981 jQuery.fx.speeds = {
4989 // Based off of the plugin by Clint Helfers, with permission.
4990 // http://blindsignals.com/index.php/2009/07/jquery-delay/
4991 jQuery.fn.delay = function( time, type ) {
4992 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
4993 type = type || "fx";
4995 return this.queue( type, function( next, hooks ) {
4996 var timeout = setTimeout( next, time );
4997 hooks.stop = function() {
4998 clearTimeout( timeout );
5005 var input = document.createElement( "input" ),
5006 select = document.createElement( "select" ),
5007 opt = select.appendChild( document.createElement( "option" ) );
5009 input.type = "checkbox";
5011 // Support: iOS 5.1, Android 4.x, Android 2.3
5012 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
5013 support.checkOn = input.value !== "";
5015 // Must access the parent to make an option select properly
5016 // Support: IE9, IE10
5017 support.optSelected = opt.selected;
5019 // Make sure that the options inside disabled selects aren't marked as disabled
5020 // (WebKit marks them as disabled)
5021 select.disabled = true;
5022 support.optDisabled = !opt.disabled;
5024 // Check if an input maintains its value after becoming a radio
5025 // Support: IE9, IE10
5026 input = document.createElement( "input" );
5028 input.type = "radio";
5029 support.radioValue = input.value === "t";
5033 var nodeHook, boolHook,
5034 attrHandle = jQuery.expr.attrHandle;
5037 attr: function( name, value ) {
5038 return access( this, jQuery.attr, name, value, arguments.length > 1 );
5041 removeAttr: function( name ) {
5042 return this.each(function() {
5043 jQuery.removeAttr( this, name );
5049 attr: function( elem, name, value ) {
5051 nType = elem.nodeType;
5053 // don't get/set attributes on text, comment and attribute nodes
5054 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
5058 // Fallback to prop when attributes are not supported
5059 if ( typeof elem.getAttribute === strundefined ) {
5060 return jQuery.prop( elem, name, value );
5063 // All attributes are lowercase
5064 // Grab necessary hook if one is defined
5065 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
5066 name = name.toLowerCase();
5067 hooks = jQuery.attrHooks[ name ] ||
5068 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
5071 if ( value !== undefined ) {
5073 if ( value === null ) {
5074 jQuery.removeAttr( elem, name );
5076 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
5080 elem.setAttribute( name, value + "" );
5084 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
5088 ret = jQuery.find.attr( elem, name );
5090 // Non-existent attributes return null, we normalize to undefined
5091 return ret == null ?
5097 removeAttr: function( elem, value ) {
5100 attrNames = value && value.match( rnotwhite );
5102 if ( attrNames && elem.nodeType === 1 ) {
5103 while ( (name = attrNames[i++]) ) {
5104 propName = jQuery.propFix[ name ] || name;
5106 // Boolean attributes get special treatment (#10870)
5107 if ( jQuery.expr.match.bool.test( name ) ) {
5108 // Set corresponding property to false
5109 elem[ propName ] = false;
5112 elem.removeAttribute( name );
5119 set: function( elem, value ) {
5120 if ( !support.radioValue && value === "radio" &&
5121 jQuery.nodeName( elem, "input" ) ) {
5122 // Setting the type on a radio button after the value resets the value in IE6-9
5123 // Reset value to default in case type is set after value during creation
5124 var val = elem.value;
5125 elem.setAttribute( "type", value );
5136 // Hooks for boolean attributes
5138 set: function( elem, value, name ) {
5139 if ( value === false ) {
5140 // Remove boolean attributes when set to false
5141 jQuery.removeAttr( elem, name );
5143 elem.setAttribute( name, name );
5148 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
5149 var getter = attrHandle[ name ] || jQuery.find.attr;
5151 attrHandle[ name ] = function( elem, name, isXML ) {
5154 // Avoid an infinite loop by temporarily removing this function from the getter
5155 handle = attrHandle[ name ];
5156 attrHandle[ name ] = ret;
5157 ret = getter( elem, name, isXML ) != null ?
5158 name.toLowerCase() :
5160 attrHandle[ name ] = handle;
5169 var rfocusable = /^(?:input|select|textarea|button)$/i;
5172 prop: function( name, value ) {
5173 return access( this, jQuery.prop, name, value, arguments.length > 1 );
5176 removeProp: function( name ) {
5177 return this.each(function() {
5178 delete this[ jQuery.propFix[ name ] || name ];
5186 "class": "className"
5189 prop: function( elem, name, value ) {
5190 var ret, hooks, notxml,
5191 nType = elem.nodeType;
5193 // don't get/set properties on text, comment and attribute nodes
5194 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
5198 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
5201 // Fix name and attach hooks
5202 name = jQuery.propFix[ name ] || name;
5203 hooks = jQuery.propHooks[ name ];
5206 if ( value !== undefined ) {
5207 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
5209 ( elem[ name ] = value );
5212 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
5220 get: function( elem ) {
5221 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
5230 // Selectedness for an option in an optgroup can be inaccurate
5231 if ( !support.optSelected ) {
5232 jQuery.propHooks.selected = {
5233 get: function( elem ) {
5234 var parent = elem.parentNode;
5235 if ( parent && parent.parentNode ) {
5236 parent.parentNode.selectedIndex;
5255 jQuery.propFix[ this.toLowerCase() ] = this;
5261 var rclass = /[\t\r\n\f]/g;
5264 addClass: function( value ) {
5265 var classes, elem, cur, clazz, j, finalValue,
5266 proceed = typeof value === "string" && value,
5270 if ( jQuery.isFunction( value ) ) {
5271 return this.each(function( j ) {
5272 jQuery( this ).addClass( value.call( this, j, this.className ) );
5277 // The disjunction here is for better compressibility (see removeClass)
5278 classes = ( value || "" ).match( rnotwhite ) || [];
5280 for ( ; i < len; i++ ) {
5282 cur = elem.nodeType === 1 && ( elem.className ?
5283 ( " " + elem.className + " " ).replace( rclass, " " ) :
5289 while ( (clazz = classes[j++]) ) {
5290 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
5295 // only assign if different to avoid unneeded rendering.
5296 finalValue = jQuery.trim( cur );
5297 if ( elem.className !== finalValue ) {
5298 elem.className = finalValue;
5307 removeClass: function( value ) {
5308 var classes, elem, cur, clazz, j, finalValue,
5309 proceed = arguments.length === 0 || typeof value === "string" && value,
5313 if ( jQuery.isFunction( value ) ) {
5314 return this.each(function( j ) {
5315 jQuery( this ).removeClass( value.call( this, j, this.className ) );
5319 classes = ( value || "" ).match( rnotwhite ) || [];
5321 for ( ; i < len; i++ ) {
5323 // This expression is here for better compressibility (see addClass)
5324 cur = elem.nodeType === 1 && ( elem.className ?
5325 ( " " + elem.className + " " ).replace( rclass, " " ) :
5331 while ( (clazz = classes[j++]) ) {
5332 // Remove *all* instances
5333 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
5334 cur = cur.replace( " " + clazz + " ", " " );
5338 // only assign if different to avoid unneeded rendering.
5339 finalValue = value ? jQuery.trim( cur ) : "";
5340 if ( elem.className !== finalValue ) {
5341 elem.className = finalValue;
5350 toggleClass: function( value, stateVal ) {
5351 var type = typeof value;
5353 if ( typeof stateVal === "boolean" && type === "string" ) {
5354 return stateVal ? this.addClass( value ) : this.removeClass( value );
5357 if ( jQuery.isFunction( value ) ) {
5358 return this.each(function( i ) {
5359 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
5363 return this.each(function() {
5364 if ( type === "string" ) {
5365 // toggle individual class names
5368 self = jQuery( this ),
5369 classNames = value.match( rnotwhite ) || [];
5371 while ( (className = classNames[ i++ ]) ) {
5372 // check each className given, space separated list
5373 if ( self.hasClass( className ) ) {
5374 self.removeClass( className );
5376 self.addClass( className );
5380 // Toggle whole class name
5381 } else if ( type === strundefined || type === "boolean" ) {
5382 if ( this.className ) {
5383 // store className if set
5384 data_priv.set( this, "__className__", this.className );
5387 // If the element has a class name or if we're passed "false",
5388 // then remove the whole classname (if there was one, the above saved it).
5389 // Otherwise bring back whatever was previously saved (if anything),
5390 // falling back to the empty string if nothing was stored.
5391 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
5396 hasClass: function( selector ) {
5397 var className = " " + selector + " ",
5400 for ( ; i < l; i++ ) {
5401 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
5413 var rreturn = /\r/g;
5416 val: function( value ) {
5417 var hooks, ret, isFunction,
5420 if ( !arguments.length ) {
5422 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
5424 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
5430 return typeof ret === "string" ?
5431 // handle most common string cases
5432 ret.replace(rreturn, "") :
5433 // handle cases where value is null/undef or number
5434 ret == null ? "" : ret;
5440 isFunction = jQuery.isFunction( value );
5442 return this.each(function( i ) {
5445 if ( this.nodeType !== 1 ) {
5450 val = value.call( this, i, jQuery( this ).val() );
5455 // Treat null/undefined as ""; convert numbers to string
5456 if ( val == null ) {
5459 } else if ( typeof val === "number" ) {
5462 } else if ( jQuery.isArray( val ) ) {
5463 val = jQuery.map( val, function( value ) {
5464 return value == null ? "" : value + "";
5468 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
5470 // If set returns undefined, fall back to normal setting
5471 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
5481 get: function( elem ) {
5482 var val = jQuery.find.attr( elem, "value" );
5483 return val != null ?
5485 // Support: IE10-11+
5486 // option.text throws exceptions (#14686, #14858)
5487 jQuery.trim( jQuery.text( elem ) );
5491 get: function( elem ) {
5493 options = elem.options,
5494 index = elem.selectedIndex,
5495 one = elem.type === "select-one" || index < 0,
5496 values = one ? null : [],
5497 max = one ? index + 1 : options.length,
5502 // Loop through all the selected options
5503 for ( ; i < max; i++ ) {
5504 option = options[ i ];
5506 // IE6-9 doesn't update selected after form reset (#2551)
5507 if ( ( option.selected || i === index ) &&
5508 // Don't return options that are disabled or in a disabled optgroup
5509 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
5510 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
5512 // Get the specific value for the option
5513 value = jQuery( option ).val();
5515 // We don't need an array for one selects
5520 // Multi-Selects return an array
5521 values.push( value );
5528 set: function( elem, value ) {
5529 var optionSet, option,
5530 options = elem.options,
5531 values = jQuery.makeArray( value ),
5535 option = options[ i ];
5536 if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
5541 // force browsers to behave consistently when non-matching value is set
5543 elem.selectedIndex = -1;
5551 // Radios and checkboxes getter/setter
5552 jQuery.each([ "radio", "checkbox" ], function() {
5553 jQuery.valHooks[ this ] = {
5554 set: function( elem, value ) {
5555 if ( jQuery.isArray( value ) ) {
5556 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
5560 if ( !support.checkOn ) {
5561 jQuery.valHooks[ this ].get = function( elem ) {
5563 // "" is returned instead of "on" if a value isn't specified
5564 return elem.getAttribute("value") === null ? "on" : elem.value;
5572 // Return jQuery for attributes-only inclusion
5575 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
5576 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
5577 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
5579 // Handle event binding
5580 jQuery.fn[ name ] = function( data, fn ) {
5581 return arguments.length > 0 ?
5582 this.on( name, null, data, fn ) :
5583 this.trigger( name );
5588 hover: function( fnOver, fnOut ) {
5589 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
5592 bind: function( types, data, fn ) {
5593 return this.on( types, null, data, fn );
5595 unbind: function( types, fn ) {
5596 return this.off( types, null, fn );
5599 delegate: function( selector, types, data, fn ) {
5600 return this.on( types, selector, data, fn );
5602 undelegate: function( selector, types, fn ) {
5603 // ( namespace ) or ( selector, types [, fn] )
5604 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
5609 var nonce = jQuery.now();
5611 var rquery = (/\?/);
5615 // Support: Android 2.3
5616 // Workaround failure to string-cast null input
5617 jQuery.parseJSON = function( data ) {
5618 return JSON.parse( data + "" );
5622 // Cross-browser xml parsing
5623 jQuery.parseXML = function( data ) {
5625 if ( !data || typeof data !== "string" ) {
5631 tmp = new DOMParser();
5632 xml = tmp.parseFromString( data, "text/xml" );
5637 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
5638 jQuery.error( "Invalid XML: " + data );
5645 // Document location
5650 rts = /([?&])_=[^&]*/,
5651 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
5652 // #7653, #8125, #8152: local protocol detection
5653 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
5654 rnoContent = /^(?:GET|HEAD)$/,
5655 rprotocol = /^\/\//,
5656 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
5659 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
5660 * 2) These are called:
5661 * - BEFORE asking for a transport
5662 * - AFTER param serialization (s.data is a string if s.processData is true)
5663 * 3) key is the dataType
5664 * 4) the catchall symbol "*" can be used
5665 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
5669 /* Transports bindings
5670 * 1) key is the dataType
5671 * 2) the catchall symbol "*" can be used
5672 * 3) selection will start with transport dataType and THEN go to "*" if needed
5676 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
5677 allTypes = "*/".concat("*");
5679 // #8138, IE may throw an exception when accessing
5680 // a field from window.location if document.domain has been set
5682 ajaxLocation = location.href;
5684 // Use the href attribute of an A element
5685 // since IE will modify it given document.location
5686 ajaxLocation = document.createElement( "a" );
5687 ajaxLocation.href = "";
5688 ajaxLocation = ajaxLocation.href;
5691 // Segment location into parts
5692 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
5694 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
5695 function addToPrefiltersOrTransports( structure ) {
5697 // dataTypeExpression is optional and defaults to "*"
5698 return function( dataTypeExpression, func ) {
5700 if ( typeof dataTypeExpression !== "string" ) {
5701 func = dataTypeExpression;
5702 dataTypeExpression = "*";
5707 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
5709 if ( jQuery.isFunction( func ) ) {
5710 // For each dataType in the dataTypeExpression
5711 while ( (dataType = dataTypes[i++]) ) {
5712 // Prepend if requested
5713 if ( dataType[0] === "+" ) {
5714 dataType = dataType.slice( 1 ) || "*";
5715 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
5719 (structure[ dataType ] = structure[ dataType ] || []).push( func );
5726 // Base inspection function for prefilters and transports
5727 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
5730 seekingTransport = ( structure === transports );
5732 function inspect( dataType ) {
5734 inspected[ dataType ] = true;
5735 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
5736 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
5737 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
5738 options.dataTypes.unshift( dataTypeOrTransport );
5739 inspect( dataTypeOrTransport );
5741 } else if ( seekingTransport ) {
5742 return !( selected = dataTypeOrTransport );
5748 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
5751 // A special extend for ajax options
5752 // that takes "flat" options (not to be deep extended)
5754 function ajaxExtend( target, src ) {
5756 flatOptions = jQuery.ajaxSettings.flatOptions || {};
5758 for ( key in src ) {
5759 if ( src[ key ] !== undefined ) {
5760 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
5764 jQuery.extend( true, target, deep );
5770 /* Handles responses to an ajax request:
5771 * - finds the right dataType (mediates between content-type and expected dataType)
5772 * - returns the corresponding response
5774 function ajaxHandleResponses( s, jqXHR, responses ) {
5776 var ct, type, finalDataType, firstDataType,
5777 contents = s.contents,
5778 dataTypes = s.dataTypes;
5780 // Remove auto dataType and get content-type in the process
5781 while ( dataTypes[ 0 ] === "*" ) {
5783 if ( ct === undefined ) {
5784 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
5788 // Check if we're dealing with a known content-type
5790 for ( type in contents ) {
5791 if ( contents[ type ] && contents[ type ].test( ct ) ) {
5792 dataTypes.unshift( type );
5798 // Check to see if we have a response for the expected dataType
5799 if ( dataTypes[ 0 ] in responses ) {
5800 finalDataType = dataTypes[ 0 ];
5802 // Try convertible dataTypes
5803 for ( type in responses ) {
5804 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
5805 finalDataType = type;
5808 if ( !firstDataType ) {
5809 firstDataType = type;
5812 // Or just use first one
5813 finalDataType = finalDataType || firstDataType;
5816 // If we found a dataType
5817 // We add the dataType to the list if needed
5818 // and return the corresponding response
5819 if ( finalDataType ) {
5820 if ( finalDataType !== dataTypes[ 0 ] ) {
5821 dataTypes.unshift( finalDataType );
5823 return responses[ finalDataType ];
5827 /* Chain conversions given the request and the original response
5828 * Also sets the responseXXX fields on the jqXHR instance
5830 function ajaxConvert( s, response, jqXHR, isSuccess ) {
5831 var conv2, current, conv, tmp, prev,
5833 // Work with a copy of dataTypes in case we need to modify it for conversion
5834 dataTypes = s.dataTypes.slice();
5836 // Create converters map with lowercased keys
5837 if ( dataTypes[ 1 ] ) {
5838 for ( conv in s.converters ) {
5839 converters[ conv.toLowerCase() ] = s.converters[ conv ];
5843 current = dataTypes.shift();
5845 // Convert to each sequential dataType
5848 if ( s.responseFields[ current ] ) {
5849 jqXHR[ s.responseFields[ current ] ] = response;
5852 // Apply the dataFilter if provided
5853 if ( !prev && isSuccess && s.dataFilter ) {
5854 response = s.dataFilter( response, s.dataType );
5858 current = dataTypes.shift();
5862 // There's only work to do if current dataType is non-auto
5863 if ( current === "*" ) {
5867 // Convert response if prev dataType is non-auto and differs from current
5868 } else if ( prev !== "*" && prev !== current ) {
5870 // Seek a direct converter
5871 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
5873 // If none found, seek a pair
5875 for ( conv2 in converters ) {
5877 // If conv2 outputs current
5878 tmp = conv2.split( " " );
5879 if ( tmp[ 1 ] === current ) {
5881 // If prev can be converted to accepted input
5882 conv = converters[ prev + " " + tmp[ 0 ] ] ||
5883 converters[ "* " + tmp[ 0 ] ];
5885 // Condense equivalence converters
5886 if ( conv === true ) {
5887 conv = converters[ conv2 ];
5889 // Otherwise, insert the intermediate dataType
5890 } else if ( converters[ conv2 ] !== true ) {
5892 dataTypes.unshift( tmp[ 1 ] );
5900 // Apply converter (if not an equivalence)
5901 if ( conv !== true ) {
5903 // Unless errors are allowed to bubble, catch and return them
5904 if ( conv && s[ "throws" ] ) {
5905 response = conv( response );
5908 response = conv( response );
5910 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
5918 return { state: "success", data: response };
5923 // Counter for holding the number of active queries
5926 // Last-Modified header cache for next request
5933 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
5937 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
5954 xml: "application/xml, text/xml",
5955 json: "application/json, text/javascript"
5966 text: "responseText",
5967 json: "responseJSON"
5971 // Keys separate source (or catchall "*") and destination types with a single space
5974 // Convert anything to text
5977 // Text to html (true = no transformation)
5980 // Evaluate text as a json expression
5981 "text json": jQuery.parseJSON,
5983 // Parse text as xml
5984 "text xml": jQuery.parseXML
5987 // For options that shouldn't be deep extended:
5988 // you can add your own custom options here if
5989 // and when you create one that shouldn't be
5990 // deep extended (see ajaxExtend)
5997 // Creates a full fledged settings object into target
5998 // with both ajaxSettings and settings fields.
5999 // If target is omitted, writes into ajaxSettings.
6000 ajaxSetup: function( target, settings ) {
6003 // Building a settings object
6004 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
6006 // Extending ajaxSettings
6007 ajaxExtend( jQuery.ajaxSettings, target );
6010 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
6011 ajaxTransport: addToPrefiltersOrTransports( transports ),
6014 ajax: function( url, options ) {
6016 // If url is an object, simulate pre-1.5 signature
6017 if ( typeof url === "object" ) {
6022 // Force options to be an object
6023 options = options || {};
6026 // URL without anti-cache param
6029 responseHeadersString,
6033 // Cross-domain detection vars
6035 // To know if global events are to be dispatched
6039 // Create the final options object
6040 s = jQuery.ajaxSetup( {}, options ),
6041 // Callbacks context
6042 callbackContext = s.context || s,
6043 // Context for global events is callbackContext if it is a DOM node or jQuery collection
6044 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
6045 jQuery( callbackContext ) :
6048 deferred = jQuery.Deferred(),
6049 completeDeferred = jQuery.Callbacks("once memory"),
6050 // Status-dependent callbacks
6051 statusCode = s.statusCode || {},
6052 // Headers (they are sent all at once)
6053 requestHeaders = {},
6054 requestHeadersNames = {},
6057 // Default abort message
6058 strAbort = "canceled",
6063 // Builds headers hashtable if needed
6064 getResponseHeader: function( key ) {
6066 if ( state === 2 ) {
6067 if ( !responseHeaders ) {
6068 responseHeaders = {};
6069 while ( (match = rheaders.exec( responseHeadersString )) ) {
6070 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
6073 match = responseHeaders[ key.toLowerCase() ];
6075 return match == null ? null : match;
6079 getAllResponseHeaders: function() {
6080 return state === 2 ? responseHeadersString : null;
6083 // Caches the header
6084 setRequestHeader: function( name, value ) {
6085 var lname = name.toLowerCase();
6087 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
6088 requestHeaders[ name ] = value;
6093 // Overrides response content-type header
6094 overrideMimeType: function( type ) {
6101 // Status-dependent callbacks
6102 statusCode: function( map ) {
6106 for ( code in map ) {
6107 // Lazy-add the new callback in a way that preserves old ones
6108 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
6111 // Execute the appropriate callbacks
6112 jqXHR.always( map[ jqXHR.status ] );
6118 // Cancel the request
6119 abort: function( statusText ) {
6120 var finalText = statusText || strAbort;
6122 transport.abort( finalText );
6124 done( 0, finalText );
6130 deferred.promise( jqXHR ).complete = completeDeferred.add;
6131 jqXHR.success = jqXHR.done;
6132 jqXHR.error = jqXHR.fail;
6134 // Remove hash character (#7531: and string promotion)
6135 // Add protocol if not provided (prefilters might expect it)
6136 // Handle falsy url in the settings object (#10093: consistency with old signature)
6137 // We also use the url parameter if available
6138 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
6139 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
6141 // Alias method option to type as per ticket #12004
6142 s.type = options.method || options.type || s.method || s.type;
6144 // Extract dataTypes list
6145 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
6147 // A cross-domain request is in order when we have a protocol:host:port mismatch
6148 if ( s.crossDomain == null ) {
6149 parts = rurl.exec( s.url.toLowerCase() );
6150 s.crossDomain = !!( parts &&
6151 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
6152 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
6153 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
6157 // Convert data if not already a string
6158 if ( s.data && s.processData && typeof s.data !== "string" ) {
6159 s.data = jQuery.param( s.data, s.traditional );
6163 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
6165 // If request was aborted inside a prefilter, stop there
6166 if ( state === 2 ) {
6170 // We can fire global events as of now if asked to
6171 fireGlobals = s.global;
6173 // Watch for a new set of requests
6174 if ( fireGlobals && jQuery.active++ === 0 ) {
6175 jQuery.event.trigger("ajaxStart");
6178 // Uppercase the type
6179 s.type = s.type.toUpperCase();
6181 // Determine if request has content
6182 s.hasContent = !rnoContent.test( s.type );
6184 // Save the URL in case we're toying with the If-Modified-Since
6185 // and/or If-None-Match header later on
6188 // More options handling for requests with no content
6189 if ( !s.hasContent ) {
6191 // If data is available, append data to url
6193 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
6194 // #9682: remove data so that it's not used in an eventual retry
6198 // Add anti-cache in url if needed
6199 if ( s.cache === false ) {
6200 s.url = rts.test( cacheURL ) ?
6202 // If there is already a '_' parameter, set its value
6203 cacheURL.replace( rts, "$1_=" + nonce++ ) :
6205 // Otherwise add one to the end
6206 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
6210 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6211 if ( s.ifModified ) {
6212 if ( jQuery.lastModified[ cacheURL ] ) {
6213 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
6215 if ( jQuery.etag[ cacheURL ] ) {
6216 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
6220 // Set the correct header, if data is being sent
6221 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
6222 jqXHR.setRequestHeader( "Content-Type", s.contentType );
6225 // Set the Accepts header for the server, depending on the dataType
6226 jqXHR.setRequestHeader(
6228 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
6229 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
6233 // Check for headers option
6234 for ( i in s.headers ) {
6235 jqXHR.setRequestHeader( i, s.headers[ i ] );
6238 // Allow custom headers/mimetypes and early abort
6239 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
6240 // Abort if not done already and return
6241 return jqXHR.abort();
6244 // aborting is no longer a cancellation
6247 // Install callbacks on deferreds
6248 for ( i in { success: 1, error: 1, complete: 1 } ) {
6249 jqXHR[ i ]( s[ i ] );
6253 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
6255 // If no transport, we auto-abort
6257 done( -1, "No Transport" );
6259 jqXHR.readyState = 1;
6261 // Send global event
6262 if ( fireGlobals ) {
6263 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
6266 if ( s.async && s.timeout > 0 ) {
6267 timeoutTimer = setTimeout(function() {
6268 jqXHR.abort("timeout");
6274 transport.send( requestHeaders, done );
6276 // Propagate exception as error if not done
6279 // Simply rethrow otherwise
6286 // Callback for when everything is done
6287 function done( status, nativeStatusText, responses, headers ) {
6288 var isSuccess, success, error, response, modified,
6289 statusText = nativeStatusText;
6292 if ( state === 2 ) {
6296 // State is "done" now
6299 // Clear timeout if it exists
6300 if ( timeoutTimer ) {
6301 clearTimeout( timeoutTimer );
6304 // Dereference transport for early garbage collection
6305 // (no matter how long the jqXHR object will be used)
6306 transport = undefined;
6308 // Cache response headers
6309 responseHeadersString = headers || "";
6312 jqXHR.readyState = status > 0 ? 4 : 0;
6314 // Determine if successful
6315 isSuccess = status >= 200 && status < 300 || status === 304;
6317 // Get response data
6319 response = ajaxHandleResponses( s, jqXHR, responses );
6322 // Convert no matter what (that way responseXXX fields are always set)
6323 response = ajaxConvert( s, response, jqXHR, isSuccess );
6325 // If successful, handle type chaining
6328 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
6329 if ( s.ifModified ) {
6330 modified = jqXHR.getResponseHeader("Last-Modified");
6332 jQuery.lastModified[ cacheURL ] = modified;
6334 modified = jqXHR.getResponseHeader("etag");
6336 jQuery.etag[ cacheURL ] = modified;
6341 if ( status === 204 || s.type === "HEAD" ) {
6342 statusText = "nocontent";
6345 } else if ( status === 304 ) {
6346 statusText = "notmodified";
6348 // If we have data, let's convert it
6350 statusText = response.state;
6351 success = response.data;
6352 error = response.error;
6356 // We extract error from statusText
6357 // then normalize statusText and status for non-aborts
6359 if ( status || !statusText ) {
6360 statusText = "error";
6367 // Set data for the fake xhr object
6368 jqXHR.status = status;
6369 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
6373 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
6375 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
6378 // Status-dependent callbacks
6379 jqXHR.statusCode( statusCode );
6380 statusCode = undefined;
6382 if ( fireGlobals ) {
6383 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
6384 [ jqXHR, s, isSuccess ? success : error ] );
6388 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
6390 if ( fireGlobals ) {
6391 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
6392 // Handle the global AJAX counter
6393 if ( !( --jQuery.active ) ) {
6394 jQuery.event.trigger("ajaxStop");
6402 getJSON: function( url, data, callback ) {
6403 return jQuery.get( url, data, callback, "json" );
6406 getScript: function( url, callback ) {
6407 return jQuery.get( url, undefined, callback, "script" );
6411 jQuery.each( [ "get", "post" ], function( i, method ) {
6412 jQuery[ method ] = function( url, data, callback, type ) {
6413 // shift arguments if data argument was omitted
6414 if ( jQuery.isFunction( data ) ) {
6415 type = type || callback;
6420 return jQuery.ajax({
6430 // Attach a bunch of functions for handling common AJAX events
6431 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
6432 jQuery.fn[ type ] = function( fn ) {
6433 return this.on( type, fn );
6438 jQuery._evalUrl = function( url ) {
6439 return jQuery.ajax({
6451 wrapAll: function( html ) {
6454 if ( jQuery.isFunction( html ) ) {
6455 return this.each(function( i ) {
6456 jQuery( this ).wrapAll( html.call(this, i) );
6462 // The elements to wrap the target around
6463 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
6465 if ( this[ 0 ].parentNode ) {
6466 wrap.insertBefore( this[ 0 ] );
6469 wrap.map(function() {
6472 while ( elem.firstElementChild ) {
6473 elem = elem.firstElementChild;
6483 wrapInner: function( html ) {
6484 if ( jQuery.isFunction( html ) ) {
6485 return this.each(function( i ) {
6486 jQuery( this ).wrapInner( html.call(this, i) );
6490 return this.each(function() {
6491 var self = jQuery( this ),
6492 contents = self.contents();
6494 if ( contents.length ) {
6495 contents.wrapAll( html );
6498 self.append( html );
6503 wrap: function( html ) {
6504 var isFunction = jQuery.isFunction( html );
6506 return this.each(function( i ) {
6507 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
6511 unwrap: function() {
6512 return this.parent().each(function() {
6513 if ( !jQuery.nodeName( this, "body" ) ) {
6514 jQuery( this ).replaceWith( this.childNodes );
6524 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
6525 rsubmittable = /^(?:input|select|textarea|keygen)/i;
6527 function buildParams( prefix, obj, traditional, add ) {
6530 if ( jQuery.isArray( obj ) ) {
6531 // Serialize array item.
6532 jQuery.each( obj, function( i, v ) {
6533 if ( traditional || rbracket.test( prefix ) ) {
6534 // Treat each array item as a scalar.
6538 // Item is non-scalar (array or object), encode its numeric index.
6539 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
6543 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
6544 // Serialize object item.
6545 for ( name in obj ) {
6546 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
6550 // Serialize scalar item.
6555 // Serialize an array of form elements or a set of
6556 // key/values into a query string
6557 jQuery.param = function( a, traditional ) {
6560 add = function( key, value ) {
6561 // If value is a function, invoke it and return its value
6562 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
6563 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
6566 // Set traditional to true for jQuery <= 1.3.2 behavior.
6567 if ( traditional === undefined ) {
6568 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
6571 // If an array was passed in, assume that it is an array of form elements.
6572 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
6573 // Serialize the form elements
6574 jQuery.each( a, function() {
6575 add( this.name, this.value );
6579 // If traditional, encode the "old" way (the way 1.3.2 or older
6580 // did it), otherwise encode params recursively.
6581 for ( prefix in a ) {
6582 buildParams( prefix, a[ prefix ], traditional, add );
6586 // Return the resulting serialization
6587 return s.join( "&" ).replace( r20, "+" );
6591 serialize: function() {
6592 return jQuery.param( this.serializeArray() );
6594 serializeArray: function() {
6595 return this.map(function() {
6596 // Can add propHook for "elements" to filter or add form elements
6597 var elements = jQuery.prop( this, "elements" );
6598 return elements ? jQuery.makeArray( elements ) : this;
6600 .filter(function() {
6601 var type = this.type;
6603 // Use .is( ":disabled" ) so that fieldset[disabled] works
6604 return this.name && !jQuery( this ).is( ":disabled" ) &&
6605 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
6606 ( this.checked || !rcheckableType.test( type ) );
6608 .map(function( i, elem ) {
6609 var val = jQuery( this ).val();
6611 return val == null ?
6613 jQuery.isArray( val ) ?
6614 jQuery.map( val, function( val ) {
6615 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6617 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
6623 jQuery.ajaxSettings.xhr = function() {
6625 return new XMLHttpRequest();
6631 xhrSuccessStatus = {
6632 // file protocol always yields status code 0, assume 200
6635 // #1450: sometimes IE returns 1223 when it should be 204
6638 xhrSupported = jQuery.ajaxSettings.xhr();
6641 // Open requests must be manually aborted on unload (#5280)
6642 if ( window.ActiveXObject ) {
6643 jQuery( window ).on( "unload", function() {
6644 for ( var key in xhrCallbacks ) {
6645 xhrCallbacks[ key ]();
6650 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
6651 support.ajax = xhrSupported = !!xhrSupported;
6653 jQuery.ajaxTransport(function( options ) {
6656 // Cross domain only allowed if supported through XMLHttpRequest
6657 if ( support.cors || xhrSupported && !options.crossDomain ) {
6659 send: function( headers, complete ) {
6661 xhr = options.xhr(),
6664 xhr.open( options.type, options.url, options.async, options.username, options.password );
6666 // Apply custom fields if provided
6667 if ( options.xhrFields ) {
6668 for ( i in options.xhrFields ) {
6669 xhr[ i ] = options.xhrFields[ i ];
6673 // Override mime type if needed
6674 if ( options.mimeType && xhr.overrideMimeType ) {
6675 xhr.overrideMimeType( options.mimeType );
6678 // X-Requested-With header
6679 // For cross-domain requests, seeing as conditions for a preflight are
6680 // akin to a jigsaw puzzle, we simply never set it to be sure.
6681 // (it can always be set on a per-request basis or even using ajaxSetup)
6682 // For same-domain requests, won't change header if already provided.
6683 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
6684 headers["X-Requested-With"] = "XMLHttpRequest";
6688 for ( i in headers ) {
6689 xhr.setRequestHeader( i, headers[ i ] );
6693 callback = function( type ) {
6696 delete xhrCallbacks[ id ];
6697 callback = xhr.onload = xhr.onerror = null;
6699 if ( type === "abort" ) {
6701 } else if ( type === "error" ) {
6703 // file: protocol always yields status 0; see #8605, #14207
6709 xhrSuccessStatus[ xhr.status ] || xhr.status,
6712 // Accessing binary-data responseText throws an exception
6714 typeof xhr.responseText === "string" ? {
6715 text: xhr.responseText
6717 xhr.getAllResponseHeaders()
6725 xhr.onload = callback();
6726 xhr.onerror = callback("error");
6728 // Create the abort callback
6729 callback = xhrCallbacks[ id ] = callback("abort");
6732 // Do send the request (this may raise an exception)
6733 xhr.send( options.hasContent && options.data || null );
6735 // #14683: Only rethrow if this hasn't been notified as an error yet
6754 // Install script dataType
6757 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
6760 script: /(?:java|ecma)script/
6763 "text script": function( text ) {
6764 jQuery.globalEval( text );
6770 // Handle cache's special case and crossDomain
6771 jQuery.ajaxPrefilter( "script", function( s ) {
6772 if ( s.cache === undefined ) {
6775 if ( s.crossDomain ) {
6780 // Bind script tag hack transport
6781 jQuery.ajaxTransport( "script", function( s ) {
6782 // This transport only deals with cross domain requests
6783 if ( s.crossDomain ) {
6784 var script, callback;
6786 send: function( _, complete ) {
6787 script = jQuery("<script>").prop({
6789 charset: s.scriptCharset,
6793 callback = function( evt ) {
6797 complete( evt.type === "error" ? 404 : 200, evt.type );
6801 document.head.appendChild( script[ 0 ] );
6815 var oldCallbacks = [],
6816 rjsonp = /(=)\?(?=&|$)|\?\?/;
6818 // Default jsonp settings
6821 jsonpCallback: function() {
6822 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
6823 this[ callback ] = true;
6828 // Detect, normalize options and install callbacks for jsonp requests
6829 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
6831 var callbackName, overwritten, responseContainer,
6832 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
6834 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
6837 // Handle iff the expected data type is "jsonp" or we have a parameter to set
6838 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
6840 // Get callback name, remembering preexisting value associated with it
6841 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
6845 // Insert callback into url or form data
6847 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
6848 } else if ( s.jsonp !== false ) {
6849 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
6852 // Use data converter to retrieve json after script execution
6853 s.converters["script json"] = function() {
6854 if ( !responseContainer ) {
6855 jQuery.error( callbackName + " was not called" );
6857 return responseContainer[ 0 ];
6860 // force json dataType
6861 s.dataTypes[ 0 ] = "json";
6864 overwritten = window[ callbackName ];
6865 window[ callbackName ] = function() {
6866 responseContainer = arguments;
6869 // Clean-up function (fires after converters)
6870 jqXHR.always(function() {
6871 // Restore preexisting value
6872 window[ callbackName ] = overwritten;
6874 // Save back as free
6875 if ( s[ callbackName ] ) {
6876 // make sure that re-using the options doesn't screw things around
6877 s.jsonpCallback = originalSettings.jsonpCallback;
6879 // save the callback name for future use
6880 oldCallbacks.push( callbackName );
6883 // Call if it was a function and we have a response
6884 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
6885 overwritten( responseContainer[ 0 ] );
6888 responseContainer = overwritten = undefined;
6891 // Delegate to script
6899 // data: string of html
6900 // context (optional): If specified, the fragment will be created in this context, defaults to document
6901 // keepScripts (optional): If true, will include scripts passed in the html string
6902 jQuery.parseHTML = function( data, context, keepScripts ) {
6903 if ( !data || typeof data !== "string" ) {
6906 if ( typeof context === "boolean" ) {
6907 keepScripts = context;
6910 context = context || document;
6912 var parsed = rsingleTag.exec( data ),
6913 scripts = !keepScripts && [];
6917 return [ context.createElement( parsed[1] ) ];
6920 parsed = jQuery.buildFragment( [ data ], context, scripts );
6922 if ( scripts && scripts.length ) {
6923 jQuery( scripts ).remove();
6926 return jQuery.merge( [], parsed.childNodes );
6930 // Keep a copy of the old load method
6931 var _load = jQuery.fn.load;
6934 * Load a url into a page
6936 jQuery.fn.load = function( url, params, callback ) {
6937 if ( typeof url !== "string" && _load ) {
6938 return _load.apply( this, arguments );
6941 var selector, type, response,
6943 off = url.indexOf(" ");
6946 selector = jQuery.trim( url.slice( off ) );
6947 url = url.slice( 0, off );
6950 // If it's a function
6951 if ( jQuery.isFunction( params ) ) {
6953 // We assume that it's the callback
6957 // Otherwise, build a param string
6958 } else if ( params && typeof params === "object" ) {
6962 // If we have elements to modify, make the request
6963 if ( self.length > 0 ) {
6967 // if "type" variable is undefined, then "GET" method will be used
6971 }).done(function( responseText ) {
6973 // Save response for use in complete callback
6974 response = arguments;
6976 self.html( selector ?
6978 // If a selector was specified, locate the right elements in a dummy div
6979 // Exclude scripts to avoid IE 'Permission Denied' errors
6980 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
6982 // Otherwise use the full result
6985 }).complete( callback && function( jqXHR, status ) {
6986 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
6996 var docElem = window.document.documentElement;
6999 * Gets a window from an element
7001 function getWindow( elem ) {
7002 return jQuery.isWindow( elem ) ? elem : elem.nodeType === 9 && elem.defaultView;
7006 setOffset: function( elem, options, i ) {
7007 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
7008 position = jQuery.css( elem, "position" ),
7009 curElem = jQuery( elem ),
7012 // Set position first, in-case top/left are set even on static elem
7013 if ( position === "static" ) {
7014 elem.style.position = "relative";
7017 curOffset = curElem.offset();
7018 curCSSTop = jQuery.css( elem, "top" );
7019 curCSSLeft = jQuery.css( elem, "left" );
7020 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
7021 ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
7023 // Need to be able to calculate position if either top or left is auto and position is either absolute or fixed
7024 if ( calculatePosition ) {
7025 curPosition = curElem.position();
7026 curTop = curPosition.top;
7027 curLeft = curPosition.left;
7030 curTop = parseFloat( curCSSTop ) || 0;
7031 curLeft = parseFloat( curCSSLeft ) || 0;
7034 if ( jQuery.isFunction( options ) ) {
7035 options = options.call( elem, i, curOffset );
7038 if ( options.top != null ) {
7039 props.top = ( options.top - curOffset.top ) + curTop;
7041 if ( options.left != null ) {
7042 props.left = ( options.left - curOffset.left ) + curLeft;
7045 if ( "using" in options ) {
7046 options.using.call( elem, props );
7049 curElem.css( props );
7055 offset: function( options ) {
7056 if ( arguments.length ) {
7057 return options === undefined ?
7059 this.each(function( i ) {
7060 jQuery.offset.setOffset( this, options, i );
7066 box = { top: 0, left: 0 },
7067 doc = elem && elem.ownerDocument;
7073 docElem = doc.documentElement;
7075 // Make sure it's not a disconnected DOM node
7076 if ( !jQuery.contains( docElem, elem ) ) {
7080 // If we don't have gBCR, just use 0,0 rather than error
7081 // BlackBerry 5, iOS 3 (original iPhone)
7082 if ( typeof elem.getBoundingClientRect !== strundefined ) {
7083 box = elem.getBoundingClientRect();
7085 win = getWindow( doc );
7087 top: box.top + win.pageYOffset - docElem.clientTop,
7088 left: box.left + win.pageXOffset - docElem.clientLeft
7092 position: function() {
7097 var offsetParent, offset,
7099 parentOffset = { top: 0, left: 0 };
7101 // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
7102 if ( jQuery.css( elem, "position" ) === "fixed" ) {
7103 // We assume that getBoundingClientRect is available when computed position is fixed
7104 offset = elem.getBoundingClientRect();
7107 // Get *real* offsetParent
7108 offsetParent = this.offsetParent();
7110 // Get correct offsets
7111 offset = this.offset();
7112 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
7113 parentOffset = offsetParent.offset();
7116 // Add offsetParent borders
7117 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
7118 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
7121 // Subtract parent offsets and element margins
7123 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
7124 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
7128 offsetParent: function() {
7129 return this.map(function() {
7130 var offsetParent = this.offsetParent || docElem;
7132 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
7133 offsetParent = offsetParent.offsetParent;
7136 return offsetParent || docElem;
7141 // Create scrollLeft and scrollTop methods
7142 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
7143 var top = "pageYOffset" === prop;
7145 jQuery.fn[ method ] = function( val ) {
7146 return access( this, function( elem, method, val ) {
7147 var win = getWindow( elem );
7149 if ( val === undefined ) {
7150 return win ? win[ prop ] : elem[ method ];
7155 !top ? val : window.pageXOffset,
7156 top ? val : window.pageYOffset
7160 elem[ method ] = val;
7162 }, method, val, arguments.length, null );
7166 // Add the top/left cssHooks using jQuery.fn.position
7167 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
7168 // getComputedStyle returns percent when specified for top/left/bottom/right
7169 // rather than make the css module depend on the offset module, we just check for it here
7170 jQuery.each( [ "top", "left" ], function( i, prop ) {
7171 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
7172 function( elem, computed ) {
7174 computed = curCSS( elem, prop );
7175 // if curCSS returns percentage, fallback to offset
7176 return rnumnonpx.test( computed ) ?
7177 jQuery( elem ).position()[ prop ] + "px" :
7185 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
7186 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
7187 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
7188 // margin is only for outerHeight, outerWidth
7189 jQuery.fn[ funcName ] = function( margin, value ) {
7190 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
7191 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
7193 return access( this, function( elem, type, value ) {
7196 if ( jQuery.isWindow( elem ) ) {
7197 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
7198 // isn't a whole lot we can do. See pull request at this URL for discussion:
7199 // https://github.com/jquery/jquery/pull/764
7200 return elem.document.documentElement[ "client" + name ];
7203 // Get document width or height
7204 if ( elem.nodeType === 9 ) {
7205 doc = elem.documentElement;
7207 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
7208 // whichever is greatest
7210 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
7211 elem.body[ "offset" + name ], doc[ "offset" + name ],
7212 doc[ "client" + name ]
7216 return value === undefined ?
7217 // Get width or height on the element, requesting but not forcing parseFloat
7218 jQuery.css( elem, type, extra ) :
7220 // Set width or height on the element
7221 jQuery.style( elem, type, value, extra );
7222 }, type, chainable ? margin : undefined, chainable, null );
7228 // Register as a named AMD module, since jQuery can be concatenated with other
7229 // files that may use define, but not via a proper concatenation script that
7230 // understands anonymous AMD modules. A named AMD is safest and most robust
7231 // way to register. Lowercase jquery is used because AMD module names are
7232 // derived from file names, and jQuery is normally delivered in a lowercase
7233 // file name. Do this after creating the global so that if an AMD module wants
7234 // to call noConflict to hide this version of jQuery, it will work.
7236 // Note that for maximum portability, libraries that are not jQuery should
7237 // declare themselves as anonymous modules, and avoid setting a global if an
7238 // AMD loader is present. jQuery is a special case. For more information, see
7239 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
7241 if ( typeof define === "function" && define.amd ) {
7242 define( "jquery", [], function() {
7251 // Map over jQuery in case of overwrite
7252 _jQuery = window.jQuery,
7254 // Map over the $ in case of overwrite
7257 jQuery.noConflict = function( deep ) {
7258 if ( window.$ === jQuery ) {
7262 if ( deep && window.jQuery === jQuery ) {
7263 window.jQuery = _jQuery;
7269 // Expose jQuery and $ identifiers, even in
7270 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
7271 // and CommonJS for browser emulators (#13566)
7272 if ( typeof noGlobal === strundefined ) {
7273 window.jQuery = window.$ = jQuery;