2 * jQuery JavaScript Library v1.11.0
\r
6 * http://sizzlejs.com/
\r
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
\r
9 * Released under the MIT license
\r
10 * http://jquery.org/license
\r
12 * Date: 2014-01-23T21:02Z
\r
15 (function( global, factory ) {
\r
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
\r
18 // For CommonJS and CommonJS-like environments where a proper window is present,
\r
19 // execute the factory and get jQuery
\r
20 // For environments that do not inherently posses a window with a document
\r
21 // (such as Node.js), expose a jQuery-making factory as module.exports
\r
22 // This accentuates the need for the creation of a real window
\r
23 // e.g. var jQuery = require("jquery")(window);
\r
24 // See ticket #14549 for more info
\r
25 module.exports = global.document ?
\r
26 factory( global, true ) :
\r
28 if ( !w.document ) {
\r
29 throw new Error( "jQuery requires a window with a document" );
\r
31 return factory( w );
\r
37 // Pass this if window is not defined yet
\r
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
\r
40 // Can't do this because several apps including ASP.NET trace
\r
41 // the stack via arguments.caller.callee and Firefox dies if
\r
42 // you try to trace through "use strict" call chains. (#13335)
\r
43 // Support: Firefox 18+
\r
46 var deletedIds = [];
\r
48 var slice = deletedIds.slice;
\r
50 var concat = deletedIds.concat;
\r
52 var push = deletedIds.push;
\r
54 var indexOf = deletedIds.indexOf;
\r
56 var class2type = {};
\r
58 var toString = class2type.toString;
\r
60 var hasOwn = class2type.hasOwnProperty;
\r
71 // Define a local copy of jQuery
\r
72 jQuery = function( selector, context ) {
\r
73 // The jQuery object is actually just the init constructor 'enhanced'
\r
74 // Need init if jQuery is called (just allow error to be thrown if not included)
\r
75 return new jQuery.fn.init( selector, context );
\r
78 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
\r
79 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
\r
81 // Matches dashed string for camelizing
\r
82 rmsPrefix = /^-ms-/,
\r
83 rdashAlpha = /-([\da-z])/gi,
\r
85 // Used by jQuery.camelCase as callback to replace()
\r
86 fcamelCase = function( all, letter ) {
\r
87 return letter.toUpperCase();
\r
90 jQuery.fn = jQuery.prototype = {
\r
91 // The current version of jQuery being used
\r
94 constructor: jQuery,
\r
96 // Start with an empty selector
\r
99 // The default length of a jQuery object is 0
\r
102 toArray: function() {
\r
103 return slice.call( this );
\r
106 // Get the Nth element in the matched element set OR
\r
107 // Get the whole matched element set as a clean array
\r
108 get: function( num ) {
\r
109 return num != null ?
\r
111 // Return a 'clean' array
\r
112 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
\r
114 // Return just the object
\r
115 slice.call( this );
\r
118 // Take an array of elements and push it onto the stack
\r
119 // (returning the new matched element set)
\r
120 pushStack: function( elems ) {
\r
122 // Build a new jQuery matched element set
\r
123 var ret = jQuery.merge( this.constructor(), elems );
\r
125 // Add the old object onto the stack (as a reference)
\r
126 ret.prevObject = this;
\r
127 ret.context = this.context;
\r
129 // Return the newly-formed element set
\r
133 // Execute a callback for every element in the matched set.
\r
134 // (You can seed the arguments with an array of args, but this is
\r
135 // only used internally.)
\r
136 each: function( callback, args ) {
\r
137 return jQuery.each( this, callback, args );
\r
140 map: function( callback ) {
\r
141 return this.pushStack( jQuery.map(this, function( elem, i ) {
\r
142 return callback.call( elem, i, elem );
\r
146 slice: function() {
\r
147 return this.pushStack( slice.apply( this, arguments ) );
\r
150 first: function() {
\r
151 return this.eq( 0 );
\r
155 return this.eq( -1 );
\r
158 eq: function( i ) {
\r
159 var len = this.length,
\r
160 j = +i + ( i < 0 ? len : 0 );
\r
161 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
\r
165 return this.prevObject || this.constructor(null);
\r
168 // For internal use only.
\r
169 // Behaves like an Array's method, not like a jQuery method.
\r
171 sort: deletedIds.sort,
\r
172 splice: deletedIds.splice
\r
175 jQuery.extend = jQuery.fn.extend = function() {
\r
176 var src, copyIsArray, copy, name, options, clone,
\r
177 target = arguments[0] || {},
\r
179 length = arguments.length,
\r
182 // Handle a deep copy situation
\r
183 if ( typeof target === "boolean" ) {
\r
186 // skip the boolean and the target
\r
187 target = arguments[ i ] || {};
\r
191 // Handle case when target is a string or something (possible in deep copy)
\r
192 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
\r
196 // extend jQuery itself if only one argument is passed
\r
197 if ( i === length ) {
\r
202 for ( ; i < length; i++ ) {
\r
203 // Only deal with non-null/undefined values
\r
204 if ( (options = arguments[ i ]) != null ) {
\r
205 // Extend the base object
\r
206 for ( name in options ) {
\r
207 src = target[ name ];
\r
208 copy = options[ name ];
\r
210 // Prevent never-ending loop
\r
211 if ( target === copy ) {
\r
215 // Recurse if we're merging plain objects or arrays
\r
216 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
\r
217 if ( copyIsArray ) {
\r
218 copyIsArray = false;
\r
219 clone = src && jQuery.isArray(src) ? src : [];
\r
222 clone = src && jQuery.isPlainObject(src) ? src : {};
\r
225 // Never move original objects, clone them
\r
226 target[ name ] = jQuery.extend( deep, clone, copy );
\r
228 // Don't bring in undefined values
\r
229 } else if ( copy !== undefined ) {
\r
230 target[ name ] = copy;
\r
236 // Return the modified object
\r
241 // Unique for each copy of jQuery on the page
\r
242 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
\r
244 // Assume jQuery is ready without the ready module
\r
247 error: function( msg ) {
\r
248 throw new Error( msg );
\r
251 noop: function() {},
\r
253 // See test/unit/core.js for details concerning isFunction.
\r
254 // Since version 1.3, DOM methods and functions like alert
\r
255 // aren't supported. They return false on IE (#2968).
\r
256 isFunction: function( obj ) {
\r
257 return jQuery.type(obj) === "function";
\r
260 isArray: Array.isArray || function( obj ) {
\r
261 return jQuery.type(obj) === "array";
\r
264 isWindow: function( obj ) {
\r
265 /* jshint eqeqeq: false */
\r
266 return obj != null && obj == obj.window;
\r
269 isNumeric: function( obj ) {
\r
270 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
\r
271 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
\r
272 // subtraction forces infinities to NaN
\r
273 return obj - parseFloat( obj ) >= 0;
\r
276 isEmptyObject: function( obj ) {
\r
278 for ( name in obj ) {
\r
284 isPlainObject: function( obj ) {
\r
287 // Must be an Object.
\r
288 // Because of IE, we also have to check the presence of the constructor property.
\r
289 // Make sure that DOM nodes and window objects don't pass through, as well
\r
290 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
\r
295 // Not own constructor property must be Object
\r
296 if ( obj.constructor &&
\r
297 !hasOwn.call(obj, "constructor") &&
\r
298 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
\r
302 // IE8,9 Will throw exceptions on certain host objects #9897
\r
307 // Handle iteration over inherited properties before own properties.
\r
308 if ( support.ownLast ) {
\r
309 for ( key in obj ) {
\r
310 return hasOwn.call( obj, key );
\r
314 // Own properties are enumerated firstly, so to speed up,
\r
315 // if last one is own, then all properties are own.
\r
316 for ( key in obj ) {}
\r
318 return key === undefined || hasOwn.call( obj, key );
\r
321 type: function( obj ) {
\r
322 if ( obj == null ) {
\r
325 return typeof obj === "object" || typeof obj === "function" ?
\r
326 class2type[ toString.call(obj) ] || "object" :
\r
330 // Evaluates a script in a global context
\r
331 // Workarounds based on findings by Jim Driscoll
\r
332 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
\r
333 globalEval: function( data ) {
\r
334 if ( data && jQuery.trim( data ) ) {
\r
335 // We use execScript on Internet Explorer
\r
336 // We use an anonymous function so that context is window
\r
337 // rather than jQuery in Firefox
\r
338 ( window.execScript || function( data ) {
\r
339 window[ "eval" ].call( window, data );
\r
344 // Convert dashed to camelCase; used by the css and data modules
\r
345 // Microsoft forgot to hump their vendor prefix (#9572)
\r
346 camelCase: function( string ) {
\r
347 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
\r
350 nodeName: function( elem, name ) {
\r
351 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
\r
354 // args is for internal usage only
\r
355 each: function( obj, callback, args ) {
\r
358 length = obj.length,
\r
359 isArray = isArraylike( obj );
\r
363 for ( ; i < length; i++ ) {
\r
364 value = callback.apply( obj[ i ], args );
\r
366 if ( value === false ) {
\r
372 value = callback.apply( obj[ i ], args );
\r
374 if ( value === false ) {
\r
380 // A special, fast, case for the most common use of each
\r
383 for ( ; i < length; i++ ) {
\r
384 value = callback.call( obj[ i ], i, obj[ i ] );
\r
386 if ( value === false ) {
\r
392 value = callback.call( obj[ i ], i, obj[ i ] );
\r
394 if ( value === false ) {
\r
404 // Use native String.trim function wherever possible
\r
405 trim: trim && !trim.call("\uFEFF\xA0") ?
\r
407 return text == null ?
\r
412 // Otherwise use our own trimming functionality
\r
414 return text == null ?
\r
416 ( text + "" ).replace( rtrim, "" );
\r
419 // results is for internal usage only
\r
420 makeArray: function( arr, results ) {
\r
421 var ret = results || [];
\r
423 if ( arr != null ) {
\r
424 if ( isArraylike( Object(arr) ) ) {
\r
426 typeof arr === "string" ?
\r
430 push.call( ret, arr );
\r
437 inArray: function( elem, arr, i ) {
\r
442 return indexOf.call( arr, elem, i );
\r
446 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
\r
448 for ( ; i < len; i++ ) {
\r
449 // Skip accessing in sparse arrays
\r
450 if ( i in arr && arr[ i ] === elem ) {
\r
459 merge: function( first, second ) {
\r
460 var len = +second.length,
\r
464 while ( j < len ) {
\r
465 first[ i++ ] = second[ j++ ];
\r
469 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
\r
470 if ( len !== len ) {
\r
471 while ( second[j] !== undefined ) {
\r
472 first[ i++ ] = second[ j++ ];
\r
481 grep: function( elems, callback, invert ) {
\r
482 var callbackInverse,
\r
485 length = elems.length,
\r
486 callbackExpect = !invert;
\r
488 // Go through the array, only saving the items
\r
489 // that pass the validator function
\r
490 for ( ; i < length; i++ ) {
\r
491 callbackInverse = !callback( elems[ i ], i );
\r
492 if ( callbackInverse !== callbackExpect ) {
\r
493 matches.push( elems[ i ] );
\r
500 // arg is for internal usage only
\r
501 map: function( elems, callback, arg ) {
\r
504 length = elems.length,
\r
505 isArray = isArraylike( elems ),
\r
508 // Go through the array, translating each of the items to their new values
\r
510 for ( ; i < length; i++ ) {
\r
511 value = callback( elems[ i ], i, arg );
\r
513 if ( value != null ) {
\r
518 // Go through every key on the object,
\r
520 for ( i in elems ) {
\r
521 value = callback( elems[ i ], i, arg );
\r
523 if ( value != null ) {
\r
529 // Flatten any nested arrays
\r
530 return concat.apply( [], ret );
\r
533 // A global GUID counter for objects
\r
536 // Bind a function to a context, optionally partially applying any
\r
538 proxy: function( fn, context ) {
\r
539 var args, proxy, tmp;
\r
541 if ( typeof context === "string" ) {
\r
542 tmp = fn[ context ];
\r
547 // Quick check to determine if target is callable, in the spec
\r
548 // this throws a TypeError, but we will just return undefined.
\r
549 if ( !jQuery.isFunction( fn ) ) {
\r
554 args = slice.call( arguments, 2 );
\r
555 proxy = function() {
\r
556 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
\r
559 // Set the guid of unique handler to the same of original handler, so it can be removed
\r
560 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
\r
566 return +( new Date() );
\r
569 // jQuery.support is not used in Core but other projects attach their
\r
570 // properties to it so it needs to exist.
\r
574 // Populate the class2type map
\r
575 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
\r
576 class2type[ "[object " + name + "]" ] = name.toLowerCase();
\r
579 function isArraylike( obj ) {
\r
580 var length = obj.length,
\r
581 type = jQuery.type( obj );
\r
583 if ( type === "function" || jQuery.isWindow( obj ) ) {
\r
587 if ( obj.nodeType === 1 && length ) {
\r
591 return type === "array" || length === 0 ||
\r
592 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
\r
596 * Sizzle CSS Selector Engine v1.10.16
\r
597 * http://sizzlejs.com/
\r
599 * Copyright 2013 jQuery Foundation, Inc. and other contributors
\r
600 * Released under the MIT license
\r
601 * http://jquery.org/license
\r
605 (function( window ) {
\r
617 // Local document vars
\r
627 // Instance-specific data
\r
628 expando = "sizzle" + -(new Date()),
\r
629 preferredDoc = window.document,
\r
632 classCache = createCache(),
\r
633 tokenCache = createCache(),
\r
634 compilerCache = createCache(),
\r
635 sortOrder = function( a, b ) {
\r
637 hasDuplicate = true;
\r
642 // General-purpose constants
\r
643 strundefined = typeof undefined,
\r
644 MAX_NEGATIVE = 1 << 31,
\r
646 // Instance methods
\r
647 hasOwn = ({}).hasOwnProperty,
\r
650 push_native = arr.push,
\r
653 // Use a stripped-down indexOf if we can't use a native one
\r
654 indexOf = arr.indexOf || function( elem ) {
\r
657 for ( ; i < len; i++ ) {
\r
658 if ( this[i] === elem ) {
\r
665 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
\r
667 // Regular expressions
\r
669 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
\r
670 whitespace = "[\\x20\\t\\r\\n\\f]",
\r
671 // http://www.w3.org/TR/css3-syntax/#characters
\r
672 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
\r
674 // Loosely modeled on CSS identifier characters
\r
675 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
\r
676 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
\r
677 identifier = characterEncoding.replace( "w", "w#" ),
\r
679 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
\r
680 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
\r
681 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
\r
683 // Prefer arguments quoted,
\r
684 // then not containing pseudos/brackets,
\r
685 // then attribute selectors/non-parenthetical expressions,
\r
686 // then anything else
\r
687 // These preferences are here to reduce the number of selectors
\r
688 // needing tokenize in the PSEUDO preFilter
\r
689 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
\r
691 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
\r
692 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
\r
694 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
\r
695 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
\r
697 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
\r
699 rpseudo = new RegExp( pseudos ),
\r
700 ridentifier = new RegExp( "^" + identifier + "$" ),
\r
703 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
\r
704 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
\r
705 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
\r
706 "ATTR": new RegExp( "^" + attributes ),
\r
707 "PSEUDO": new RegExp( "^" + pseudos ),
\r
708 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
\r
709 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
\r
710 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
\r
711 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
\r
712 // For use in libraries implementing .is()
\r
713 // We use this for POS matching in `select`
\r
714 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
\r
715 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
\r
718 rinputs = /^(?:input|select|textarea|button)$/i,
\r
719 rheader = /^h\d$/i,
\r
721 rnative = /^[^{]+\{\s*\[native \w/,
\r
723 // Easily-parseable/retrievable ID or TAG or CLASS selectors
\r
724 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
\r
729 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
\r
730 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
\r
731 funescape = function( _, escaped, escapedWhitespace ) {
\r
732 var high = "0x" + escaped - 0x10000;
\r
733 // NaN means non-codepoint
\r
734 // Support: Firefox
\r
735 // Workaround erroneous numeric interpretation of +"0x"
\r
736 return high !== high || escapedWhitespace ?
\r
740 String.fromCharCode( high + 0x10000 ) :
\r
741 // Supplemental Plane codepoint (surrogate pair)
\r
742 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
\r
745 // Optimize for push.apply( _, NodeList )
\r
748 (arr = slice.call( preferredDoc.childNodes )),
\r
749 preferredDoc.childNodes
\r
751 // Support: Android<4.0
\r
752 // Detect silently failing push.apply
\r
753 arr[ preferredDoc.childNodes.length ].nodeType;
\r
755 push = { apply: arr.length ?
\r
757 // Leverage slice if possible
\r
758 function( target, els ) {
\r
759 push_native.apply( target, slice.call(els) );
\r
763 // Otherwise append directly
\r
764 function( target, els ) {
\r
765 var j = target.length,
\r
767 // Can't trust NodeList.length
\r
768 while ( (target[j++] = els[i++]) ) {}
\r
769 target.length = j - 1;
\r
774 function Sizzle( selector, context, results, seed ) {
\r
775 var match, elem, m, nodeType,
\r
777 i, groups, old, nid, newContext, newSelector;
\r
779 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
\r
780 setDocument( context );
\r
783 context = context || document;
\r
784 results = results || [];
\r
786 if ( !selector || typeof selector !== "string" ) {
\r
790 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
\r
794 if ( documentIsHTML && !seed ) {
\r
797 if ( (match = rquickExpr.exec( selector )) ) {
\r
798 // Speed-up: Sizzle("#ID")
\r
799 if ( (m = match[1]) ) {
\r
800 if ( nodeType === 9 ) {
\r
801 elem = context.getElementById( m );
\r
802 // Check parentNode to catch when Blackberry 4.6 returns
\r
803 // nodes that are no longer in the document (jQuery #6963)
\r
804 if ( elem && elem.parentNode ) {
\r
805 // Handle the case where IE, Opera, and Webkit return items
\r
806 // by name instead of ID
\r
807 if ( elem.id === m ) {
\r
808 results.push( elem );
\r
815 // Context is not a document
\r
816 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
\r
817 contains( context, elem ) && elem.id === m ) {
\r
818 results.push( elem );
\r
823 // Speed-up: Sizzle("TAG")
\r
824 } else if ( match[2] ) {
\r
825 push.apply( results, context.getElementsByTagName( selector ) );
\r
828 // Speed-up: Sizzle(".CLASS")
\r
829 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
\r
830 push.apply( results, context.getElementsByClassName( m ) );
\r
836 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
\r
837 nid = old = expando;
\r
838 newContext = context;
\r
839 newSelector = nodeType === 9 && selector;
\r
841 // qSA works strangely on Element-rooted queries
\r
842 // We can work around this by specifying an extra ID on the root
\r
843 // and working up from there (Thanks to Andrew Dupont for the technique)
\r
844 // IE 8 doesn't work on object elements
\r
845 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
\r
846 groups = tokenize( selector );
\r
848 if ( (old = context.getAttribute("id")) ) {
\r
849 nid = old.replace( rescape, "\\$&" );
\r
851 context.setAttribute( "id", nid );
\r
853 nid = "[id='" + nid + "'] ";
\r
857 groups[i] = nid + toSelector( groups[i] );
\r
859 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
\r
860 newSelector = groups.join(",");
\r
863 if ( newSelector ) {
\r
865 push.apply( results,
\r
866 newContext.querySelectorAll( newSelector )
\r
869 } catch(qsaError) {
\r
872 context.removeAttribute("id");
\r
880 return select( selector.replace( rtrim, "$1" ), context, results, seed );
\r
884 * Create key-value caches of limited size
\r
885 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
\r
886 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
\r
887 * deleting the oldest entry
\r
889 function createCache() {
\r
892 function cache( key, value ) {
\r
893 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
\r
894 if ( keys.push( key + " " ) > Expr.cacheLength ) {
\r
895 // Only keep the most recent entries
\r
896 delete cache[ keys.shift() ];
\r
898 return (cache[ key + " " ] = value);
\r
904 * Mark a function for special use by Sizzle
\r
905 * @param {Function} fn The function to mark
\r
907 function markFunction( fn ) {
\r
908 fn[ expando ] = true;
\r
913 * Support testing using an element
\r
914 * @param {Function} fn Passed the created div and expects a boolean result
\r
916 function assert( fn ) {
\r
917 var div = document.createElement("div");
\r
920 return !!fn( div );
\r
924 // Remove from its parent by default
\r
925 if ( div.parentNode ) {
\r
926 div.parentNode.removeChild( div );
\r
928 // release memory in IE
\r
934 * Adds the same handler for all of the specified attrs
\r
935 * @param {String} attrs Pipe-separated list of attributes
\r
936 * @param {Function} handler The method that will be applied
\r
938 function addHandle( attrs, handler ) {
\r
939 var arr = attrs.split("|"),
\r
943 Expr.attrHandle[ arr[i] ] = handler;
\r
948 * Checks document order of two siblings
\r
949 * @param {Element} a
\r
950 * @param {Element} b
\r
951 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
\r
953 function siblingCheck( a, b ) {
\r
955 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
\r
956 ( ~b.sourceIndex || MAX_NEGATIVE ) -
\r
957 ( ~a.sourceIndex || MAX_NEGATIVE );
\r
959 // Use IE sourceIndex if available on both nodes
\r
964 // Check if b follows a
\r
966 while ( (cur = cur.nextSibling) ) {
\r
977 * Returns a function to use in pseudos for input types
\r
978 * @param {String} type
\r
980 function createInputPseudo( type ) {
\r
981 return function( elem ) {
\r
982 var name = elem.nodeName.toLowerCase();
\r
983 return name === "input" && elem.type === type;
\r
988 * Returns a function to use in pseudos for buttons
\r
989 * @param {String} type
\r
991 function createButtonPseudo( type ) {
\r
992 return function( elem ) {
\r
993 var name = elem.nodeName.toLowerCase();
\r
994 return (name === "input" || name === "button") && elem.type === type;
\r
999 * Returns a function to use in pseudos for positionals
\r
1000 * @param {Function} fn
\r
1002 function createPositionalPseudo( fn ) {
\r
1003 return markFunction(function( argument ) {
\r
1004 argument = +argument;
\r
1005 return markFunction(function( seed, matches ) {
\r
1007 matchIndexes = fn( [], seed.length, argument ),
\r
1008 i = matchIndexes.length;
\r
1010 // Match elements found at the specified indexes
\r
1012 if ( seed[ (j = matchIndexes[i]) ] ) {
\r
1013 seed[j] = !(matches[j] = seed[j]);
\r
1021 * Checks a node for validity as a Sizzle context
\r
1022 * @param {Element|Object=} context
\r
1023 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
\r
1025 function testContext( context ) {
\r
1026 return context && typeof context.getElementsByTagName !== strundefined && context;
\r
1029 // Expose support vars for convenience
\r
1030 support = Sizzle.support = {};
\r
1033 * Detects XML nodes
\r
1034 * @param {Element|Object} elem An element or a document
\r
1035 * @returns {Boolean} True iff elem is a non-HTML XML node
\r
1037 isXML = Sizzle.isXML = function( elem ) {
\r
1038 // documentElement is verified for cases where it doesn't yet exist
\r
1039 // (such as loading iframes in IE - #4833)
\r
1040 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
\r
1041 return documentElement ? documentElement.nodeName !== "HTML" : false;
\r
1045 * Sets document-related variables once based on the current document
\r
1046 * @param {Element|Object} [doc] An element or document object to use to set the document
\r
1047 * @returns {Object} Returns the current document
\r
1049 setDocument = Sizzle.setDocument = function( node ) {
\r
1051 doc = node ? node.ownerDocument || node : preferredDoc,
\r
1052 parent = doc.defaultView;
\r
1054 // If no document and documentElement is available, return
\r
1055 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
\r
1059 // Set our document
\r
1061 docElem = doc.documentElement;
\r
1064 documentIsHTML = !isXML( doc );
\r
1067 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
\r
1068 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
\r
1069 // IE6-8 do not support the defaultView property so parent will be undefined
\r
1070 if ( parent && parent !== parent.top ) {
\r
1071 // IE11 does not have attachEvent, so all must suffer
\r
1072 if ( parent.addEventListener ) {
\r
1073 parent.addEventListener( "unload", function() {
\r
1076 } else if ( parent.attachEvent ) {
\r
1077 parent.attachEvent( "onunload", function() {
\r
1084 ---------------------------------------------------------------------- */
\r
1087 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
\r
1088 support.attributes = assert(function( div ) {
\r
1089 div.className = "i";
\r
1090 return !div.getAttribute("className");
\r
1093 /* getElement(s)By*
\r
1094 ---------------------------------------------------------------------- */
\r
1096 // Check if getElementsByTagName("*") returns only elements
\r
1097 support.getElementsByTagName = assert(function( div ) {
\r
1098 div.appendChild( doc.createComment("") );
\r
1099 return !div.getElementsByTagName("*").length;
\r
1102 // Check if getElementsByClassName can be trusted
\r
1103 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
\r
1104 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
\r
1106 // Support: Safari<4
\r
1107 // Catch class over-caching
\r
1108 div.firstChild.className = "i";
\r
1109 // Support: Opera<10
\r
1110 // Catch gEBCN failure to find non-leading classes
\r
1111 return div.getElementsByClassName("i").length === 2;
\r
1115 // Check if getElementById returns elements by name
\r
1116 // The broken getElementById methods don't pick up programatically-set names,
\r
1117 // so use a roundabout getElementsByName test
\r
1118 support.getById = assert(function( div ) {
\r
1119 docElem.appendChild( div ).id = expando;
\r
1120 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
\r
1123 // ID find and filter
\r
1124 if ( support.getById ) {
\r
1125 Expr.find["ID"] = function( id, context ) {
\r
1126 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
\r
1127 var m = context.getElementById( id );
\r
1128 // Check parentNode to catch when Blackberry 4.6 returns
\r
1129 // nodes that are no longer in the document #6963
\r
1130 return m && m.parentNode ? [m] : [];
\r
1133 Expr.filter["ID"] = function( id ) {
\r
1134 var attrId = id.replace( runescape, funescape );
\r
1135 return function( elem ) {
\r
1136 return elem.getAttribute("id") === attrId;
\r
1141 // getElementById is not reliable as a find shortcut
\r
1142 delete Expr.find["ID"];
\r
1144 Expr.filter["ID"] = function( id ) {
\r
1145 var attrId = id.replace( runescape, funescape );
\r
1146 return function( elem ) {
\r
1147 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
\r
1148 return node && node.value === attrId;
\r
1154 Expr.find["TAG"] = support.getElementsByTagName ?
\r
1155 function( tag, context ) {
\r
1156 if ( typeof context.getElementsByTagName !== strundefined ) {
\r
1157 return context.getElementsByTagName( tag );
\r
1160 function( tag, context ) {
\r
1164 results = context.getElementsByTagName( tag );
\r
1166 // Filter out possible comments
\r
1167 if ( tag === "*" ) {
\r
1168 while ( (elem = results[i++]) ) {
\r
1169 if ( elem.nodeType === 1 ) {
\r
1180 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
\r
1181 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
\r
1182 return context.getElementsByClassName( className );
\r
1186 /* QSA/matchesSelector
\r
1187 ---------------------------------------------------------------------- */
\r
1189 // QSA and matchesSelector support
\r
1191 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
\r
1192 rbuggyMatches = [];
\r
1194 // qSa(:focus) reports false when true (Chrome 21)
\r
1195 // We allow this because of a bug in IE8/9 that throws an error
\r
1196 // whenever `document.activeElement` is accessed on an iframe
\r
1197 // So, we allow :focus to pass through QSA all the time to avoid the IE error
\r
1198 // See http://bugs.jquery.com/ticket/13378
\r
1201 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
\r
1202 // Build QSA regex
\r
1203 // Regex strategy adopted from Diego Perini
\r
1204 assert(function( div ) {
\r
1205 // Select is set to empty string on purpose
\r
1206 // This is to test IE's treatment of not explicitly
\r
1207 // setting a boolean content attribute,
\r
1208 // since its presence should be enough
\r
1209 // http://bugs.jquery.com/ticket/12359
\r
1210 div.innerHTML = "<select t=''><option selected=''></option></select>";
\r
1212 // Support: IE8, Opera 10-12
\r
1213 // Nothing should be selected when empty strings follow ^= or $= or *=
\r
1214 if ( div.querySelectorAll("[t^='']").length ) {
\r
1215 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
\r
1219 // Boolean attributes and "value" are not treated correctly
\r
1220 if ( !div.querySelectorAll("[selected]").length ) {
\r
1221 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
\r
1224 // Webkit/Opera - :checked should return selected option elements
\r
1225 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
\r
1226 // IE8 throws error here and will not see later tests
\r
1227 if ( !div.querySelectorAll(":checked").length ) {
\r
1228 rbuggyQSA.push(":checked");
\r
1232 assert(function( div ) {
\r
1233 // Support: Windows 8 Native Apps
\r
1234 // The type and name attributes are restricted during .innerHTML assignment
\r
1235 var input = doc.createElement("input");
\r
1236 input.setAttribute( "type", "hidden" );
\r
1237 div.appendChild( input ).setAttribute( "name", "D" );
\r
1240 // Enforce case-sensitivity of name attribute
\r
1241 if ( div.querySelectorAll("[name=d]").length ) {
\r
1242 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
\r
1245 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
\r
1246 // IE8 throws error here and will not see later tests
\r
1247 if ( !div.querySelectorAll(":enabled").length ) {
\r
1248 rbuggyQSA.push( ":enabled", ":disabled" );
\r
1251 // Opera 10-11 does not throw on post-comma invalid pseudos
\r
1252 div.querySelectorAll("*,:x");
\r
1253 rbuggyQSA.push(",.*:");
\r
1257 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
\r
1258 docElem.mozMatchesSelector ||
\r
1259 docElem.oMatchesSelector ||
\r
1260 docElem.msMatchesSelector) )) ) {
\r
1262 assert(function( div ) {
\r
1263 // Check to see if it's possible to do matchesSelector
\r
1264 // on a disconnected node (IE 9)
\r
1265 support.disconnectedMatch = matches.call( div, "div" );
\r
1267 // This should fail with an exception
\r
1268 // Gecko does not error, returns false instead
\r
1269 matches.call( div, "[s!='']:x" );
\r
1270 rbuggyMatches.push( "!=", pseudos );
\r
1274 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
\r
1275 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
\r
1278 ---------------------------------------------------------------------- */
\r
1279 hasCompare = rnative.test( docElem.compareDocumentPosition );
\r
1281 // Element contains another
\r
1282 // Purposefully does not implement inclusive descendent
\r
1283 // As in, an element does not contain itself
\r
1284 contains = hasCompare || rnative.test( docElem.contains ) ?
\r
1285 function( a, b ) {
\r
1286 var adown = a.nodeType === 9 ? a.documentElement : a,
\r
1287 bup = b && b.parentNode;
\r
1288 return a === bup || !!( bup && bup.nodeType === 1 && (
\r
1290 adown.contains( bup ) :
\r
1291 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
\r
1294 function( a, b ) {
\r
1296 while ( (b = b.parentNode) ) {
\r
1306 ---------------------------------------------------------------------- */
\r
1308 // Document order sorting
\r
1309 sortOrder = hasCompare ?
\r
1310 function( a, b ) {
\r
1312 // Flag for duplicate removal
\r
1314 hasDuplicate = true;
\r
1318 // Sort on method existence if only one input has compareDocumentPosition
\r
1319 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
\r
1324 // Calculate position if both inputs belong to the same document
\r
1325 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
\r
1326 a.compareDocumentPosition( b ) :
\r
1328 // Otherwise we know they are disconnected
\r
1331 // Disconnected nodes
\r
1332 if ( compare & 1 ||
\r
1333 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
\r
1335 // Choose the first element that is related to our preferred document
\r
1336 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
\r
1339 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
\r
1343 // Maintain original order
\r
1344 return sortInput ?
\r
1345 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
\r
1349 return compare & 4 ? -1 : 1;
\r
1351 function( a, b ) {
\r
1352 // Exit early if the nodes are identical
\r
1354 hasDuplicate = true;
\r
1360 aup = a.parentNode,
\r
1361 bup = b.parentNode,
\r
1365 // Parentless nodes are either documents or disconnected
\r
1366 if ( !aup || !bup ) {
\r
1367 return a === doc ? -1 :
\r
1372 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
\r
1375 // If the nodes are siblings, we can do a quick check
\r
1376 } else if ( aup === bup ) {
\r
1377 return siblingCheck( a, b );
\r
1380 // Otherwise we need full lists of their ancestors for comparison
\r
1382 while ( (cur = cur.parentNode) ) {
\r
1383 ap.unshift( cur );
\r
1386 while ( (cur = cur.parentNode) ) {
\r
1387 bp.unshift( cur );
\r
1390 // Walk down the tree looking for a discrepancy
\r
1391 while ( ap[i] === bp[i] ) {
\r
1396 // Do a sibling check if the nodes have a common ancestor
\r
1397 siblingCheck( ap[i], bp[i] ) :
\r
1399 // Otherwise nodes in our document sort first
\r
1400 ap[i] === preferredDoc ? -1 :
\r
1401 bp[i] === preferredDoc ? 1 :
\r
1408 Sizzle.matches = function( expr, elements ) {
\r
1409 return Sizzle( expr, null, null, elements );
\r
1412 Sizzle.matchesSelector = function( elem, expr ) {
\r
1413 // Set document vars if needed
\r
1414 if ( ( elem.ownerDocument || elem ) !== document ) {
\r
1415 setDocument( elem );
\r
1418 // Make sure that attribute selectors are quoted
\r
1419 expr = expr.replace( rattributeQuotes, "='$1']" );
\r
1421 if ( support.matchesSelector && documentIsHTML &&
\r
1422 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
\r
1423 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
\r
1426 var ret = matches.call( elem, expr );
\r
1428 // IE 9's matchesSelector returns false on disconnected nodes
\r
1429 if ( ret || support.disconnectedMatch ||
\r
1430 // As well, disconnected nodes are said to be in a document
\r
1431 // fragment in IE 9
\r
1432 elem.document && elem.document.nodeType !== 11 ) {
\r
1438 return Sizzle( expr, document, null, [elem] ).length > 0;
\r
1441 Sizzle.contains = function( context, elem ) {
\r
1442 // Set document vars if needed
\r
1443 if ( ( context.ownerDocument || context ) !== document ) {
\r
1444 setDocument( context );
\r
1446 return contains( context, elem );
\r
1449 Sizzle.attr = function( elem, name ) {
\r
1450 // Set document vars if needed
\r
1451 if ( ( elem.ownerDocument || elem ) !== document ) {
\r
1452 setDocument( elem );
\r
1455 var fn = Expr.attrHandle[ name.toLowerCase() ],
\r
1456 // Don't get fooled by Object.prototype properties (jQuery #13807)
\r
1457 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
\r
1458 fn( elem, name, !documentIsHTML ) :
\r
1461 return val !== undefined ?
\r
1463 support.attributes || !documentIsHTML ?
\r
1464 elem.getAttribute( name ) :
\r
1465 (val = elem.getAttributeNode(name)) && val.specified ?
\r
1470 Sizzle.error = function( msg ) {
\r
1471 throw new Error( "Syntax error, unrecognized expression: " + msg );
\r
1475 * Document sorting and removing duplicates
\r
1476 * @param {ArrayLike} results
\r
1478 Sizzle.uniqueSort = function( results ) {
\r
1484 // Unless we *know* we can detect duplicates, assume their presence
\r
1485 hasDuplicate = !support.detectDuplicates;
\r
1486 sortInput = !support.sortStable && results.slice( 0 );
\r
1487 results.sort( sortOrder );
\r
1489 if ( hasDuplicate ) {
\r
1490 while ( (elem = results[i++]) ) {
\r
1491 if ( elem === results[ i ] ) {
\r
1492 j = duplicates.push( i );
\r
1496 results.splice( duplicates[ j ], 1 );
\r
1500 // Clear input after sorting to release objects
\r
1501 // See https://github.com/jquery/sizzle/pull/225
\r
1508 * Utility function for retrieving the text value of an array of DOM nodes
\r
1509 * @param {Array|Element} elem
\r
1511 getText = Sizzle.getText = function( elem ) {
\r
1515 nodeType = elem.nodeType;
\r
1517 if ( !nodeType ) {
\r
1518 // If no nodeType, this is expected to be an array
\r
1519 while ( (node = elem[i++]) ) {
\r
1520 // Do not traverse comment nodes
\r
1521 ret += getText( node );
\r
1523 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
\r
1524 // Use textContent for elements
\r
1525 // innerText usage removed for consistency of new lines (jQuery #11153)
\r
1526 if ( typeof elem.textContent === "string" ) {
\r
1527 return elem.textContent;
\r
1529 // Traverse its children
\r
1530 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
\r
1531 ret += getText( elem );
\r
1534 } else if ( nodeType === 3 || nodeType === 4 ) {
\r
1535 return elem.nodeValue;
\r
1537 // Do not include comment or processing instruction nodes
\r
1542 Expr = Sizzle.selectors = {
\r
1544 // Can be adjusted by the user
\r
1547 createPseudo: markFunction,
\r
1556 ">": { dir: "parentNode", first: true },
\r
1557 " ": { dir: "parentNode" },
\r
1558 "+": { dir: "previousSibling", first: true },
\r
1559 "~": { dir: "previousSibling" }
\r
1563 "ATTR": function( match ) {
\r
1564 match[1] = match[1].replace( runescape, funescape );
\r
1566 // Move the given value to match[3] whether quoted or unquoted
\r
1567 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
\r
1569 if ( match[2] === "~=" ) {
\r
1570 match[3] = " " + match[3] + " ";
\r
1573 return match.slice( 0, 4 );
\r
1576 "CHILD": function( match ) {
\r
1577 /* matches from matchExpr["CHILD"]
\r
1578 1 type (only|nth|...)
\r
1579 2 what (child|of-type)
\r
1580 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
\r
1581 4 xn-component of xn+y argument ([+-]?\d*n|)
\r
1582 5 sign of xn-component
\r
1583 6 x of xn-component
\r
1584 7 sign of y-component
\r
1585 8 y of y-component
\r
1587 match[1] = match[1].toLowerCase();
\r
1589 if ( match[1].slice( 0, 3 ) === "nth" ) {
\r
1590 // nth-* requires argument
\r
1591 if ( !match[3] ) {
\r
1592 Sizzle.error( match[0] );
\r
1595 // numeric x and y parameters for Expr.filter.CHILD
\r
1596 // remember that false/true cast respectively to 0/1
\r
1597 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
\r
1598 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
\r
1600 // other types prohibit arguments
\r
1601 } else if ( match[3] ) {
\r
1602 Sizzle.error( match[0] );
\r
1608 "PSEUDO": function( match ) {
\r
1610 unquoted = !match[5] && match[2];
\r
1612 if ( matchExpr["CHILD"].test( match[0] ) ) {
\r
1616 // Accept quoted arguments as-is
\r
1617 if ( match[3] && match[4] !== undefined ) {
\r
1618 match[2] = match[4];
\r
1620 // Strip excess characters from unquoted arguments
\r
1621 } else if ( unquoted && rpseudo.test( unquoted ) &&
\r
1622 // Get excess from tokenize (recursively)
\r
1623 (excess = tokenize( unquoted, true )) &&
\r
1624 // advance to the next closing parenthesis
\r
1625 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
\r
1627 // excess is a negative index
\r
1628 match[0] = match[0].slice( 0, excess );
\r
1629 match[2] = unquoted.slice( 0, excess );
\r
1632 // Return only captures needed by the pseudo filter method (type and argument)
\r
1633 return match.slice( 0, 3 );
\r
1639 "TAG": function( nodeNameSelector ) {
\r
1640 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
\r
1641 return nodeNameSelector === "*" ?
\r
1642 function() { return true; } :
\r
1643 function( elem ) {
\r
1644 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
\r
1648 "CLASS": function( className ) {
\r
1649 var pattern = classCache[ className + " " ];
\r
1652 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
\r
1653 classCache( className, function( elem ) {
\r
1654 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
\r
1658 "ATTR": function( name, operator, check ) {
\r
1659 return function( elem ) {
\r
1660 var result = Sizzle.attr( elem, name );
\r
1662 if ( result == null ) {
\r
1663 return operator === "!=";
\r
1665 if ( !operator ) {
\r
1671 return operator === "=" ? result === check :
\r
1672 operator === "!=" ? result !== check :
\r
1673 operator === "^=" ? check && result.indexOf( check ) === 0 :
\r
1674 operator === "*=" ? check && result.indexOf( check ) > -1 :
\r
1675 operator === "$=" ? check && result.slice( -check.length ) === check :
\r
1676 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
\r
1677 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
\r
1682 "CHILD": function( type, what, argument, first, last ) {
\r
1683 var simple = type.slice( 0, 3 ) !== "nth",
\r
1684 forward = type.slice( -4 ) !== "last",
\r
1685 ofType = what === "of-type";
\r
1687 return first === 1 && last === 0 ?
\r
1689 // Shortcut for :nth-*(n)
\r
1690 function( elem ) {
\r
1691 return !!elem.parentNode;
\r
1694 function( elem, context, xml ) {
\r
1695 var cache, outerCache, node, diff, nodeIndex, start,
\r
1696 dir = simple !== forward ? "nextSibling" : "previousSibling",
\r
1697 parent = elem.parentNode,
\r
1698 name = ofType && elem.nodeName.toLowerCase(),
\r
1699 useCache = !xml && !ofType;
\r
1703 // :(first|last|only)-(child|of-type)
\r
1707 while ( (node = node[ dir ]) ) {
\r
1708 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
\r
1712 // Reverse direction for :only-* (if we haven't yet done so)
\r
1713 start = dir = type === "only" && !start && "nextSibling";
\r
1718 start = [ forward ? parent.firstChild : parent.lastChild ];
\r
1720 // non-xml :nth-child(...) stores cache data on `parent`
\r
1721 if ( forward && useCache ) {
\r
1722 // Seek `elem` from a previously-cached index
\r
1723 outerCache = parent[ expando ] || (parent[ expando ] = {});
\r
1724 cache = outerCache[ type ] || [];
\r
1725 nodeIndex = cache[0] === dirruns && cache[1];
\r
1726 diff = cache[0] === dirruns && cache[2];
\r
1727 node = nodeIndex && parent.childNodes[ nodeIndex ];
\r
1729 while ( (node = ++nodeIndex && node && node[ dir ] ||
\r
1731 // Fallback to seeking `elem` from the start
\r
1732 (diff = nodeIndex = 0) || start.pop()) ) {
\r
1734 // When found, cache indexes on `parent` and break
\r
1735 if ( node.nodeType === 1 && ++diff && node === elem ) {
\r
1736 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
\r
1741 // Use previously-cached element index if available
\r
1742 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
\r
1745 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
\r
1747 // Use the same loop as above to seek `elem` from the start
\r
1748 while ( (node = ++nodeIndex && node && node[ dir ] ||
\r
1749 (diff = nodeIndex = 0) || start.pop()) ) {
\r
1751 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
\r
1752 // Cache the index of each encountered element
\r
1754 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
\r
1757 if ( node === elem ) {
\r
1764 // Incorporate the offset, then check against cycle size
\r
1766 return diff === first || ( diff % first === 0 && diff / first >= 0 );
\r
1771 "PSEUDO": function( pseudo, argument ) {
\r
1772 // pseudo-class names are case-insensitive
\r
1773 // http://www.w3.org/TR/selectors/#pseudo-classes
\r
1774 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
\r
1775 // Remember that setFilters inherits from pseudos
\r
1777 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
\r
1778 Sizzle.error( "unsupported pseudo: " + pseudo );
\r
1780 // The user may use createPseudo to indicate that
\r
1781 // arguments are needed to create the filter function
\r
1782 // just as Sizzle does
\r
1783 if ( fn[ expando ] ) {
\r
1784 return fn( argument );
\r
1787 // But maintain support for old signatures
\r
1788 if ( fn.length > 1 ) {
\r
1789 args = [ pseudo, pseudo, "", argument ];
\r
1790 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
\r
1791 markFunction(function( seed, matches ) {
\r
1793 matched = fn( seed, argument ),
\r
1794 i = matched.length;
\r
1796 idx = indexOf.call( seed, matched[i] );
\r
1797 seed[ idx ] = !( matches[ idx ] = matched[i] );
\r
1800 function( elem ) {
\r
1801 return fn( elem, 0, args );
\r
1810 // Potentially complex pseudos
\r
1811 "not": markFunction(function( selector ) {
\r
1812 // Trim the selector passed to compile
\r
1813 // to avoid treating leading and trailing
\r
1814 // spaces as combinators
\r
1817 matcher = compile( selector.replace( rtrim, "$1" ) );
\r
1819 return matcher[ expando ] ?
\r
1820 markFunction(function( seed, matches, context, xml ) {
\r
1822 unmatched = matcher( seed, null, xml, [] ),
\r
1825 // Match elements unmatched by `matcher`
\r
1827 if ( (elem = unmatched[i]) ) {
\r
1828 seed[i] = !(matches[i] = elem);
\r
1832 function( elem, context, xml ) {
\r
1834 matcher( input, null, xml, results );
\r
1835 return !results.pop();
\r
1839 "has": markFunction(function( selector ) {
\r
1840 return function( elem ) {
\r
1841 return Sizzle( selector, elem ).length > 0;
\r
1845 "contains": markFunction(function( text ) {
\r
1846 return function( elem ) {
\r
1847 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
\r
1851 // "Whether an element is represented by a :lang() selector
\r
1852 // is based solely on the element's language value
\r
1853 // being equal to the identifier C,
\r
1854 // or beginning with the identifier C immediately followed by "-".
\r
1855 // The matching of C against the element's language value is performed case-insensitively.
\r
1856 // The identifier C does not have to be a valid language name."
\r
1857 // http://www.w3.org/TR/selectors/#lang-pseudo
\r
1858 "lang": markFunction( function( lang ) {
\r
1859 // lang value must be a valid identifier
\r
1860 if ( !ridentifier.test(lang || "") ) {
\r
1861 Sizzle.error( "unsupported lang: " + lang );
\r
1863 lang = lang.replace( runescape, funescape ).toLowerCase();
\r
1864 return function( elem ) {
\r
1867 if ( (elemLang = documentIsHTML ?
\r
1869 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
\r
1871 elemLang = elemLang.toLowerCase();
\r
1872 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
\r
1874 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
\r
1880 "target": function( elem ) {
\r
1881 var hash = window.location && window.location.hash;
\r
1882 return hash && hash.slice( 1 ) === elem.id;
\r
1885 "root": function( elem ) {
\r
1886 return elem === docElem;
\r
1889 "focus": function( elem ) {
\r
1890 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
\r
1893 // Boolean properties
\r
1894 "enabled": function( elem ) {
\r
1895 return elem.disabled === false;
\r
1898 "disabled": function( elem ) {
\r
1899 return elem.disabled === true;
\r
1902 "checked": function( elem ) {
\r
1903 // In CSS3, :checked should return both checked and selected elements
\r
1904 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
\r
1905 var nodeName = elem.nodeName.toLowerCase();
\r
1906 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
\r
1909 "selected": function( elem ) {
\r
1910 // Accessing this property makes selected-by-default
\r
1911 // options in Safari work properly
\r
1912 if ( elem.parentNode ) {
\r
1913 elem.parentNode.selectedIndex;
\r
1916 return elem.selected === true;
\r
1920 "empty": function( elem ) {
\r
1921 // http://www.w3.org/TR/selectors/#empty-pseudo
\r
1922 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
\r
1923 // but not by others (comment: 8; processing instruction: 7; etc.)
\r
1924 // nodeType < 6 works because attributes (2) do not appear as children
\r
1925 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
\r
1926 if ( elem.nodeType < 6 ) {
\r
1933 "parent": function( elem ) {
\r
1934 return !Expr.pseudos["empty"]( elem );
\r
1937 // Element/input types
\r
1938 "header": function( elem ) {
\r
1939 return rheader.test( elem.nodeName );
\r
1942 "input": function( elem ) {
\r
1943 return rinputs.test( elem.nodeName );
\r
1946 "button": function( elem ) {
\r
1947 var name = elem.nodeName.toLowerCase();
\r
1948 return name === "input" && elem.type === "button" || name === "button";
\r
1951 "text": function( elem ) {
\r
1953 return elem.nodeName.toLowerCase() === "input" &&
\r
1954 elem.type === "text" &&
\r
1957 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
\r
1958 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
\r
1961 // Position-in-collection
\r
1962 "first": createPositionalPseudo(function() {
\r
1966 "last": createPositionalPseudo(function( matchIndexes, length ) {
\r
1967 return [ length - 1 ];
\r
1970 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
1971 return [ argument < 0 ? argument + length : argument ];
\r
1974 "even": createPositionalPseudo(function( matchIndexes, length ) {
\r
1976 for ( ; i < length; i += 2 ) {
\r
1977 matchIndexes.push( i );
\r
1979 return matchIndexes;
\r
1982 "odd": createPositionalPseudo(function( matchIndexes, length ) {
\r
1984 for ( ; i < length; i += 2 ) {
\r
1985 matchIndexes.push( i );
\r
1987 return matchIndexes;
\r
1990 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
1991 var i = argument < 0 ? argument + length : argument;
\r
1992 for ( ; --i >= 0; ) {
\r
1993 matchIndexes.push( i );
\r
1995 return matchIndexes;
\r
1998 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
1999 var i = argument < 0 ? argument + length : argument;
\r
2000 for ( ; ++i < length; ) {
\r
2001 matchIndexes.push( i );
\r
2003 return matchIndexes;
\r
2008 Expr.pseudos["nth"] = Expr.pseudos["eq"];
\r
2010 // Add button/input type pseudos
\r
2011 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
\r
2012 Expr.pseudos[ i ] = createInputPseudo( i );
\r
2014 for ( i in { submit: true, reset: true } ) {
\r
2015 Expr.pseudos[ i ] = createButtonPseudo( i );
\r
2018 // Easy API for creating new setFilters
\r
2019 function setFilters() {}
\r
2020 setFilters.prototype = Expr.filters = Expr.pseudos;
\r
2021 Expr.setFilters = new setFilters();
\r
2023 function tokenize( selector, parseOnly ) {
\r
2024 var matched, match, tokens, type,
\r
2025 soFar, groups, preFilters,
\r
2026 cached = tokenCache[ selector + " " ];
\r
2029 return parseOnly ? 0 : cached.slice( 0 );
\r
2034 preFilters = Expr.preFilter;
\r
2038 // Comma and first run
\r
2039 if ( !matched || (match = rcomma.exec( soFar )) ) {
\r
2041 // Don't consume trailing commas as valid
\r
2042 soFar = soFar.slice( match[0].length ) || soFar;
\r
2044 groups.push( (tokens = []) );
\r
2050 if ( (match = rcombinators.exec( soFar )) ) {
\r
2051 matched = match.shift();
\r
2054 // Cast descendant combinators to space
\r
2055 type: match[0].replace( rtrim, " " )
\r
2057 soFar = soFar.slice( matched.length );
\r
2061 for ( type in Expr.filter ) {
\r
2062 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
\r
2063 (match = preFilters[ type ]( match ))) ) {
\r
2064 matched = match.shift();
\r
2070 soFar = soFar.slice( matched.length );
\r
2079 // Return the length of the invalid excess
\r
2080 // if we're just parsing
\r
2081 // Otherwise, throw an error or return tokens
\r
2082 return parseOnly ?
\r
2085 Sizzle.error( selector ) :
\r
2086 // Cache the tokens
\r
2087 tokenCache( selector, groups ).slice( 0 );
\r
2090 function toSelector( tokens ) {
\r
2092 len = tokens.length,
\r
2094 for ( ; i < len; i++ ) {
\r
2095 selector += tokens[i].value;
\r
2100 function addCombinator( matcher, combinator, base ) {
\r
2101 var dir = combinator.dir,
\r
2102 checkNonElements = base && dir === "parentNode",
\r
2103 doneName = done++;
\r
2105 return combinator.first ?
\r
2106 // Check against closest ancestor/preceding element
\r
2107 function( elem, context, xml ) {
\r
2108 while ( (elem = elem[ dir ]) ) {
\r
2109 if ( elem.nodeType === 1 || checkNonElements ) {
\r
2110 return matcher( elem, context, xml );
\r
2115 // Check against all ancestor/preceding elements
\r
2116 function( elem, context, xml ) {
\r
2117 var oldCache, outerCache,
\r
2118 newCache = [ dirruns, doneName ];
\r
2120 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
\r
2122 while ( (elem = elem[ dir ]) ) {
\r
2123 if ( elem.nodeType === 1 || checkNonElements ) {
\r
2124 if ( matcher( elem, context, xml ) ) {
\r
2130 while ( (elem = elem[ dir ]) ) {
\r
2131 if ( elem.nodeType === 1 || checkNonElements ) {
\r
2132 outerCache = elem[ expando ] || (elem[ expando ] = {});
\r
2133 if ( (oldCache = outerCache[ dir ]) &&
\r
2134 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
\r
2136 // Assign to newCache so results back-propagate to previous elements
\r
2137 return (newCache[ 2 ] = oldCache[ 2 ]);
\r
2139 // Reuse newcache so results back-propagate to previous elements
\r
2140 outerCache[ dir ] = newCache;
\r
2142 // A match means we're done; a fail means we have to keep checking
\r
2143 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
\r
2153 function elementMatcher( matchers ) {
\r
2154 return matchers.length > 1 ?
\r
2155 function( elem, context, xml ) {
\r
2156 var i = matchers.length;
\r
2158 if ( !matchers[i]( elem, context, xml ) ) {
\r
2167 function condense( unmatched, map, filter, context, xml ) {
\r
2169 newUnmatched = [],
\r
2171 len = unmatched.length,
\r
2172 mapped = map != null;
\r
2174 for ( ; i < len; i++ ) {
\r
2175 if ( (elem = unmatched[i]) ) {
\r
2176 if ( !filter || filter( elem, context, xml ) ) {
\r
2177 newUnmatched.push( elem );
\r
2185 return newUnmatched;
\r
2188 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
\r
2189 if ( postFilter && !postFilter[ expando ] ) {
\r
2190 postFilter = setMatcher( postFilter );
\r
2192 if ( postFinder && !postFinder[ expando ] ) {
\r
2193 postFinder = setMatcher( postFinder, postSelector );
\r
2195 return markFunction(function( seed, results, context, xml ) {
\r
2196 var temp, i, elem,
\r
2199 preexisting = results.length,
\r
2201 // Get initial elements from seed or context
\r
2202 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
\r
2204 // Prefilter to get matcher input, preserving a map for seed-results synchronization
\r
2205 matcherIn = preFilter && ( seed || !selector ) ?
\r
2206 condense( elems, preMap, preFilter, context, xml ) :
\r
2209 matcherOut = matcher ?
\r
2210 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
\r
2211 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
\r
2213 // ...intermediate processing is necessary
\r
2216 // ...otherwise use results directly
\r
2220 // Find primary matches
\r
2222 matcher( matcherIn, matcherOut, context, xml );
\r
2225 // Apply postFilter
\r
2226 if ( postFilter ) {
\r
2227 temp = condense( matcherOut, postMap );
\r
2228 postFilter( temp, [], context, xml );
\r
2230 // Un-match failing elements by moving them back to matcherIn
\r
2233 if ( (elem = temp[i]) ) {
\r
2234 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
\r
2240 if ( postFinder || preFilter ) {
\r
2241 if ( postFinder ) {
\r
2242 // Get the final matcherOut by condensing this intermediate into postFinder contexts
\r
2244 i = matcherOut.length;
\r
2246 if ( (elem = matcherOut[i]) ) {
\r
2247 // Restore matcherIn since elem is not yet a final match
\r
2248 temp.push( (matcherIn[i] = elem) );
\r
2251 postFinder( null, (matcherOut = []), temp, xml );
\r
2254 // Move matched elements from seed to results to keep them synchronized
\r
2255 i = matcherOut.length;
\r
2257 if ( (elem = matcherOut[i]) &&
\r
2258 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
\r
2260 seed[temp] = !(results[temp] = elem);
\r
2265 // Add elements to results, through postFinder if defined
\r
2267 matcherOut = condense(
\r
2268 matcherOut === results ?
\r
2269 matcherOut.splice( preexisting, matcherOut.length ) :
\r
2272 if ( postFinder ) {
\r
2273 postFinder( null, results, matcherOut, xml );
\r
2275 push.apply( results, matcherOut );
\r
2281 function matcherFromTokens( tokens ) {
\r
2282 var checkContext, matcher, j,
\r
2283 len = tokens.length,
\r
2284 leadingRelative = Expr.relative[ tokens[0].type ],
\r
2285 implicitRelative = leadingRelative || Expr.relative[" "],
\r
2286 i = leadingRelative ? 1 : 0,
\r
2288 // The foundational matcher ensures that elements are reachable from top-level context(s)
\r
2289 matchContext = addCombinator( function( elem ) {
\r
2290 return elem === checkContext;
\r
2291 }, implicitRelative, true ),
\r
2292 matchAnyContext = addCombinator( function( elem ) {
\r
2293 return indexOf.call( checkContext, elem ) > -1;
\r
2294 }, implicitRelative, true ),
\r
2295 matchers = [ function( elem, context, xml ) {
\r
2296 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
\r
2297 (checkContext = context).nodeType ?
\r
2298 matchContext( elem, context, xml ) :
\r
2299 matchAnyContext( elem, context, xml ) );
\r
2302 for ( ; i < len; i++ ) {
\r
2303 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
\r
2304 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
\r
2306 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
\r
2308 // Return special upon seeing a positional matcher
\r
2309 if ( matcher[ expando ] ) {
\r
2310 // Find the next relative operator (if any) for proper handling
\r
2312 for ( ; j < len; j++ ) {
\r
2313 if ( Expr.relative[ tokens[j].type ] ) {
\r
2317 return setMatcher(
\r
2318 i > 1 && elementMatcher( matchers ),
\r
2319 i > 1 && toSelector(
\r
2320 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
\r
2321 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
\r
2322 ).replace( rtrim, "$1" ),
\r
2324 i < j && matcherFromTokens( tokens.slice( i, j ) ),
\r
2325 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
\r
2326 j < len && toSelector( tokens )
\r
2329 matchers.push( matcher );
\r
2333 return elementMatcher( matchers );
\r
2336 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
\r
2337 var bySet = setMatchers.length > 0,
\r
2338 byElement = elementMatchers.length > 0,
\r
2339 superMatcher = function( seed, context, xml, results, outermost ) {
\r
2340 var elem, j, matcher,
\r
2343 unmatched = seed && [],
\r
2345 contextBackup = outermostContext,
\r
2346 // We must always have either seed elements or outermost context
\r
2347 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
\r
2348 // Use integer dirruns iff this is the outermost matcher
\r
2349 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
\r
2350 len = elems.length;
\r
2352 if ( outermost ) {
\r
2353 outermostContext = context !== document && context;
\r
2356 // Add elements passing elementMatchers directly to results
\r
2357 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
\r
2358 // Support: IE<9, Safari
\r
2359 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
\r
2360 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
\r
2361 if ( byElement && elem ) {
\r
2363 while ( (matcher = elementMatchers[j++]) ) {
\r
2364 if ( matcher( elem, context, xml ) ) {
\r
2365 results.push( elem );
\r
2369 if ( outermost ) {
\r
2370 dirruns = dirrunsUnique;
\r
2374 // Track unmatched elements for set filters
\r
2376 // They will have gone through all possible matchers
\r
2377 if ( (elem = !matcher && elem) ) {
\r
2381 // Lengthen the array for every element, matched or not
\r
2383 unmatched.push( elem );
\r
2388 // Apply set filters to unmatched elements
\r
2389 matchedCount += i;
\r
2390 if ( bySet && i !== matchedCount ) {
\r
2392 while ( (matcher = setMatchers[j++]) ) {
\r
2393 matcher( unmatched, setMatched, context, xml );
\r
2397 // Reintegrate element matches to eliminate the need for sorting
\r
2398 if ( matchedCount > 0 ) {
\r
2400 if ( !(unmatched[i] || setMatched[i]) ) {
\r
2401 setMatched[i] = pop.call( results );
\r
2406 // Discard index placeholder values to get only actual matches
\r
2407 setMatched = condense( setMatched );
\r
2410 // Add matches to results
\r
2411 push.apply( results, setMatched );
\r
2413 // Seedless set matches succeeding multiple successful matchers stipulate sorting
\r
2414 if ( outermost && !seed && setMatched.length > 0 &&
\r
2415 ( matchedCount + setMatchers.length ) > 1 ) {
\r
2417 Sizzle.uniqueSort( results );
\r
2421 // Override manipulation of globals by nested matchers
\r
2422 if ( outermost ) {
\r
2423 dirruns = dirrunsUnique;
\r
2424 outermostContext = contextBackup;
\r
2431 markFunction( superMatcher ) :
\r
2435 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
\r
2438 elementMatchers = [],
\r
2439 cached = compilerCache[ selector + " " ];
\r
2442 // Generate a function of recursive functions that can be used to check each element
\r
2444 group = tokenize( selector );
\r
2448 cached = matcherFromTokens( group[i] );
\r
2449 if ( cached[ expando ] ) {
\r
2450 setMatchers.push( cached );
\r
2452 elementMatchers.push( cached );
\r
2456 // Cache the compiled function
\r
2457 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
\r
2462 function multipleContexts( selector, contexts, results ) {
\r
2464 len = contexts.length;
\r
2465 for ( ; i < len; i++ ) {
\r
2466 Sizzle( selector, contexts[i], results );
\r
2471 function select( selector, context, results, seed ) {
\r
2472 var i, tokens, token, type, find,
\r
2473 match = tokenize( selector );
\r
2476 // Try to minimize operations if there is only one group
\r
2477 if ( match.length === 1 ) {
\r
2479 // Take a shortcut and set the context if the root selector is an ID
\r
2480 tokens = match[0] = match[0].slice( 0 );
\r
2481 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
\r
2482 support.getById && context.nodeType === 9 && documentIsHTML &&
\r
2483 Expr.relative[ tokens[1].type ] ) {
\r
2485 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
\r
2489 selector = selector.slice( tokens.shift().value.length );
\r
2492 // Fetch a seed set for right-to-left matching
\r
2493 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
\r
2495 token = tokens[i];
\r
2497 // Abort if we hit a combinator
\r
2498 if ( Expr.relative[ (type = token.type) ] ) {
\r
2501 if ( (find = Expr.find[ type ]) ) {
\r
2502 // Search, expanding context for leading sibling combinators
\r
2503 if ( (seed = find(
\r
2504 token.matches[0].replace( runescape, funescape ),
\r
2505 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
\r
2508 // If seed is empty or no tokens remain, we can return early
\r
2509 tokens.splice( i, 1 );
\r
2510 selector = seed.length && toSelector( tokens );
\r
2511 if ( !selector ) {
\r
2512 push.apply( results, seed );
\r
2523 // Compile and execute a filtering function
\r
2524 // Provide `match` to avoid retokenization if we modified the selector above
\r
2525 compile( selector, match )(
\r
2530 rsibling.test( selector ) && testContext( context.parentNode ) || context
\r
2535 // One-time assignments
\r
2538 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
\r
2540 // Support: Chrome<14
\r
2541 // Always assume duplicates if they aren't passed to the comparison function
\r
2542 support.detectDuplicates = !!hasDuplicate;
\r
2544 // Initialize against the default document
\r
2547 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
\r
2548 // Detached nodes confoundingly follow *each other*
\r
2549 support.sortDetached = assert(function( div1 ) {
\r
2550 // Should return 1, but returns 4 (following)
\r
2551 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
\r
2555 // Prevent attribute/property "interpolation"
\r
2556 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
\r
2557 if ( !assert(function( div ) {
\r
2558 div.innerHTML = "<a href='#'></a>";
\r
2559 return div.firstChild.getAttribute("href") === "#" ;
\r
2561 addHandle( "type|href|height|width", function( elem, name, isXML ) {
\r
2563 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
\r
2569 // Use defaultValue in place of getAttribute("value")
\r
2570 if ( !support.attributes || !assert(function( div ) {
\r
2571 div.innerHTML = "<input/>";
\r
2572 div.firstChild.setAttribute( "value", "" );
\r
2573 return div.firstChild.getAttribute( "value" ) === "";
\r
2575 addHandle( "value", function( elem, name, isXML ) {
\r
2576 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
\r
2577 return elem.defaultValue;
\r
2583 // Use getAttributeNode to fetch booleans when getAttribute lies
\r
2584 if ( !assert(function( div ) {
\r
2585 return div.getAttribute("disabled") == null;
\r
2587 addHandle( booleans, function( elem, name, isXML ) {
\r
2590 return elem[ name ] === true ? name.toLowerCase() :
\r
2591 (val = elem.getAttributeNode( name )) && val.specified ?
\r
2604 jQuery.find = Sizzle;
\r
2605 jQuery.expr = Sizzle.selectors;
\r
2606 jQuery.expr[":"] = jQuery.expr.pseudos;
\r
2607 jQuery.unique = Sizzle.uniqueSort;
\r
2608 jQuery.text = Sizzle.getText;
\r
2609 jQuery.isXMLDoc = Sizzle.isXML;
\r
2610 jQuery.contains = Sizzle.contains;
\r
2614 var rneedsContext = jQuery.expr.match.needsContext;
\r
2616 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
\r
2620 var risSimple = /^.[^:#\[\.,]*$/;
\r
2622 // Implement the identical functionality for filter and not
\r
2623 function winnow( elements, qualifier, not ) {
\r
2624 if ( jQuery.isFunction( qualifier ) ) {
\r
2625 return jQuery.grep( elements, function( elem, i ) {
\r
2626 /* jshint -W018 */
\r
2627 return !!qualifier.call( elem, i, elem ) !== not;
\r
2632 if ( qualifier.nodeType ) {
\r
2633 return jQuery.grep( elements, function( elem ) {
\r
2634 return ( elem === qualifier ) !== not;
\r
2639 if ( typeof qualifier === "string" ) {
\r
2640 if ( risSimple.test( qualifier ) ) {
\r
2641 return jQuery.filter( qualifier, elements, not );
\r
2644 qualifier = jQuery.filter( qualifier, elements );
\r
2647 return jQuery.grep( elements, function( elem ) {
\r
2648 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
\r
2652 jQuery.filter = function( expr, elems, not ) {
\r
2653 var elem = elems[ 0 ];
\r
2656 expr = ":not(" + expr + ")";
\r
2659 return elems.length === 1 && elem.nodeType === 1 ?
\r
2660 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
\r
2661 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
\r
2662 return elem.nodeType === 1;
\r
2666 jQuery.fn.extend({
\r
2667 find: function( selector ) {
\r
2671 len = self.length;
\r
2673 if ( typeof selector !== "string" ) {
\r
2674 return this.pushStack( jQuery( selector ).filter(function() {
\r
2675 for ( i = 0; i < len; i++ ) {
\r
2676 if ( jQuery.contains( self[ i ], this ) ) {
\r
2683 for ( i = 0; i < len; i++ ) {
\r
2684 jQuery.find( selector, self[ i ], ret );
\r
2687 // Needed because $( selector, context ) becomes $( context ).find( selector )
\r
2688 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
\r
2689 ret.selector = this.selector ? this.selector + " " + selector : selector;
\r
2692 filter: function( selector ) {
\r
2693 return this.pushStack( winnow(this, selector || [], false) );
\r
2695 not: function( selector ) {
\r
2696 return this.pushStack( winnow(this, selector || [], true) );
\r
2698 is: function( selector ) {
\r
2702 // If this is a positional/relative selector, check membership in the returned set
\r
2703 // so $("p:first").is("p:last") won't return true for a doc with two "p".
\r
2704 typeof selector === "string" && rneedsContext.test( selector ) ?
\r
2705 jQuery( selector ) :
\r
2713 // Initialize a jQuery object
\r
2716 // A central reference to the root jQuery(document)
\r
2719 // Use the correct document accordingly with window argument (sandbox)
\r
2720 document = window.document,
\r
2722 // A simple way to check for HTML strings
\r
2723 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
\r
2724 // Strict HTML recognition (#11290: must start with <)
\r
2725 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
\r
2727 init = jQuery.fn.init = function( selector, context ) {
\r
2730 // HANDLE: $(""), $(null), $(undefined), $(false)
\r
2731 if ( !selector ) {
\r
2735 // Handle HTML strings
\r
2736 if ( typeof selector === "string" ) {
\r
2737 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
\r
2738 // Assume that strings that start and end with <> are HTML and skip the regex check
\r
2739 match = [ null, selector, null ];
\r
2742 match = rquickExpr.exec( selector );
\r
2745 // Match html or make sure no context is specified for #id
\r
2746 if ( match && (match[1] || !context) ) {
\r
2748 // HANDLE: $(html) -> $(array)
\r
2750 context = context instanceof jQuery ? context[0] : context;
\r
2752 // scripts is true for back-compat
\r
2753 // Intentionally let the error be thrown if parseHTML is not present
\r
2754 jQuery.merge( this, jQuery.parseHTML(
\r
2756 context && context.nodeType ? context.ownerDocument || context : document,
\r
2760 // HANDLE: $(html, props)
\r
2761 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
\r
2762 for ( match in context ) {
\r
2763 // Properties of context are called as methods if possible
\r
2764 if ( jQuery.isFunction( this[ match ] ) ) {
\r
2765 this[ match ]( context[ match ] );
\r
2767 // ...and otherwise set as attributes
\r
2769 this.attr( match, context[ match ] );
\r
2778 elem = document.getElementById( match[2] );
\r
2780 // Check parentNode to catch when Blackberry 4.6 returns
\r
2781 // nodes that are no longer in the document #6963
\r
2782 if ( elem && elem.parentNode ) {
\r
2783 // Handle the case where IE and Opera return items
\r
2784 // by name instead of ID
\r
2785 if ( elem.id !== match[2] ) {
\r
2786 return rootjQuery.find( selector );
\r
2789 // Otherwise, we inject the element directly into the jQuery object
\r
2794 this.context = document;
\r
2795 this.selector = selector;
\r
2799 // HANDLE: $(expr, $(...))
\r
2800 } else if ( !context || context.jquery ) {
\r
2801 return ( context || rootjQuery ).find( selector );
\r
2803 // HANDLE: $(expr, context)
\r
2804 // (which is just equivalent to: $(context).find(expr)
\r
2806 return this.constructor( context ).find( selector );
\r
2809 // HANDLE: $(DOMElement)
\r
2810 } else if ( selector.nodeType ) {
\r
2811 this.context = this[0] = selector;
\r
2815 // HANDLE: $(function)
\r
2816 // Shortcut for document ready
\r
2817 } else if ( jQuery.isFunction( selector ) ) {
\r
2818 return typeof rootjQuery.ready !== "undefined" ?
\r
2819 rootjQuery.ready( selector ) :
\r
2820 // Execute immediately if ready is not present
\r
2821 selector( jQuery );
\r
2824 if ( selector.selector !== undefined ) {
\r
2825 this.selector = selector.selector;
\r
2826 this.context = selector.context;
\r
2829 return jQuery.makeArray( selector, this );
\r
2832 // Give the init function the jQuery prototype for later instantiation
\r
2833 init.prototype = jQuery.fn;
\r
2835 // Initialize central reference
\r
2836 rootjQuery = jQuery( document );
\r
2839 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
\r
2840 // methods guaranteed to produce a unique set when starting from a unique set
\r
2841 guaranteedUnique = {
\r
2849 dir: function( elem, dir, until ) {
\r
2851 cur = elem[ dir ];
\r
2853 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
\r
2854 if ( cur.nodeType === 1 ) {
\r
2855 matched.push( cur );
\r
2862 sibling: function( n, elem ) {
\r
2865 for ( ; n; n = n.nextSibling ) {
\r
2866 if ( n.nodeType === 1 && n !== elem ) {
\r
2875 jQuery.fn.extend({
\r
2876 has: function( target ) {
\r
2878 targets = jQuery( target, this ),
\r
2879 len = targets.length;
\r
2881 return this.filter(function() {
\r
2882 for ( i = 0; i < len; i++ ) {
\r
2883 if ( jQuery.contains( this, targets[i] ) ) {
\r
2890 closest: function( selectors, context ) {
\r
2895 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
\r
2896 jQuery( selectors, context || this.context ) :
\r
2899 for ( ; i < l; i++ ) {
\r
2900 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
\r
2901 // Always skip document fragments
\r
2902 if ( cur.nodeType < 11 && (pos ?
\r
2903 pos.index(cur) > -1 :
\r
2905 // Don't pass non-elements to Sizzle
\r
2906 cur.nodeType === 1 &&
\r
2907 jQuery.find.matchesSelector(cur, selectors)) ) {
\r
2909 matched.push( cur );
\r
2915 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
\r
2918 // Determine the position of an element within
\r
2919 // the matched set of elements
\r
2920 index: function( elem ) {
\r
2922 // No argument, return index in parent
\r
2924 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
\r
2927 // index in selector
\r
2928 if ( typeof elem === "string" ) {
\r
2929 return jQuery.inArray( this[0], jQuery( elem ) );
\r
2932 // Locate the position of the desired element
\r
2933 return jQuery.inArray(
\r
2934 // If it receives a jQuery object, the first element is used
\r
2935 elem.jquery ? elem[0] : elem, this );
\r
2938 add: function( selector, context ) {
\r
2939 return this.pushStack(
\r
2941 jQuery.merge( this.get(), jQuery( selector, context ) )
\r
2946 addBack: function( selector ) {
\r
2947 return this.add( selector == null ?
\r
2948 this.prevObject : this.prevObject.filter(selector)
\r
2953 function sibling( cur, dir ) {
\r
2956 } while ( cur && cur.nodeType !== 1 );
\r
2962 parent: function( elem ) {
\r
2963 var parent = elem.parentNode;
\r
2964 return parent && parent.nodeType !== 11 ? parent : null;
\r
2966 parents: function( elem ) {
\r
2967 return jQuery.dir( elem, "parentNode" );
\r
2969 parentsUntil: function( elem, i, until ) {
\r
2970 return jQuery.dir( elem, "parentNode", until );
\r
2972 next: function( elem ) {
\r
2973 return sibling( elem, "nextSibling" );
\r
2975 prev: function( elem ) {
\r
2976 return sibling( elem, "previousSibling" );
\r
2978 nextAll: function( elem ) {
\r
2979 return jQuery.dir( elem, "nextSibling" );
\r
2981 prevAll: function( elem ) {
\r
2982 return jQuery.dir( elem, "previousSibling" );
\r
2984 nextUntil: function( elem, i, until ) {
\r
2985 return jQuery.dir( elem, "nextSibling", until );
\r
2987 prevUntil: function( elem, i, until ) {
\r
2988 return jQuery.dir( elem, "previousSibling", until );
\r
2990 siblings: function( elem ) {
\r
2991 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
\r
2993 children: function( elem ) {
\r
2994 return jQuery.sibling( elem.firstChild );
\r
2996 contents: function( elem ) {
\r
2997 return jQuery.nodeName( elem, "iframe" ) ?
\r
2998 elem.contentDocument || elem.contentWindow.document :
\r
2999 jQuery.merge( [], elem.childNodes );
\r
3001 }, function( name, fn ) {
\r
3002 jQuery.fn[ name ] = function( until, selector ) {
\r
3003 var ret = jQuery.map( this, fn, until );
\r
3005 if ( name.slice( -5 ) !== "Until" ) {
\r
3009 if ( selector && typeof selector === "string" ) {
\r
3010 ret = jQuery.filter( selector, ret );
\r
3013 if ( this.length > 1 ) {
\r
3014 // Remove duplicates
\r
3015 if ( !guaranteedUnique[ name ] ) {
\r
3016 ret = jQuery.unique( ret );
\r
3019 // Reverse order for parents* and prev-derivatives
\r
3020 if ( rparentsprev.test( name ) ) {
\r
3021 ret = ret.reverse();
\r
3025 return this.pushStack( ret );
\r
3028 var rnotwhite = (/\S+/g);
\r
3032 // String to Object options format cache
\r
3033 var optionsCache = {};
\r
3035 // Convert String-formatted options into Object-formatted ones and store in cache
\r
3036 function createOptions( options ) {
\r
3037 var object = optionsCache[ options ] = {};
\r
3038 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
\r
3039 object[ flag ] = true;
\r
3045 * Create a callback list using the following parameters:
\r
3047 * options: an optional list of space-separated options that will change how
\r
3048 * the callback list behaves or a more traditional option object
\r
3050 * By default a callback list will act like an event callback list and can be
\r
3051 * "fired" multiple times.
\r
3053 * Possible options:
\r
3055 * once: will ensure the callback list can only be fired once (like a Deferred)
\r
3057 * memory: will keep track of previous values and will call any callback added
\r
3058 * after the list has been fired right away with the latest "memorized"
\r
3059 * values (like a Deferred)
\r
3061 * unique: will ensure a callback can only be added once (no duplicate in the list)
\r
3063 * stopOnFalse: interrupt callings when a callback returns false
\r
3066 jQuery.Callbacks = function( options ) {
\r
3068 // Convert options from String-formatted to Object-formatted if needed
\r
3069 // (we check in cache first)
\r
3070 options = typeof options === "string" ?
\r
3071 ( optionsCache[ options ] || createOptions( options ) ) :
\r
3072 jQuery.extend( {}, options );
\r
3074 var // Flag to know if list is currently firing
\r
3076 // Last fire value (for non-forgettable lists)
\r
3078 // Flag to know if list was already fired
\r
3080 // End of the loop when firing
\r
3082 // Index of currently firing callback (modified by remove if needed)
\r
3084 // First callback to fire (used internally by add and fireWith)
\r
3086 // Actual callback list
\r
3088 // Stack of fire calls for repeatable lists
\r
3089 stack = !options.once && [],
\r
3091 fire = function( data ) {
\r
3092 memory = options.memory && data;
\r
3094 firingIndex = firingStart || 0;
\r
3096 firingLength = list.length;
\r
3098 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
\r
3099 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
\r
3100 memory = false; // To prevent further calls using add
\r
3107 if ( stack.length ) {
\r
3108 fire( stack.shift() );
\r
3110 } else if ( memory ) {
\r
3117 // Actual Callbacks object
\r
3119 // Add a callback or a collection of callbacks to the list
\r
3122 // First, we save the current length
\r
3123 var start = list.length;
\r
3124 (function add( args ) {
\r
3125 jQuery.each( args, function( _, arg ) {
\r
3126 var type = jQuery.type( arg );
\r
3127 if ( type === "function" ) {
\r
3128 if ( !options.unique || !self.has( arg ) ) {
\r
3131 } else if ( arg && arg.length && type !== "string" ) {
\r
3132 // Inspect recursively
\r
3137 // Do we need to add the callbacks to the
\r
3138 // current firing batch?
\r
3140 firingLength = list.length;
\r
3141 // With memory, if we're not firing then
\r
3142 // we should call right away
\r
3143 } else if ( memory ) {
\r
3144 firingStart = start;
\r
3150 // Remove a callback from the list
\r
3151 remove: function() {
\r
3153 jQuery.each( arguments, function( _, arg ) {
\r
3155 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
\r
3156 list.splice( index, 1 );
\r
3157 // Handle firing indexes
\r
3159 if ( index <= firingLength ) {
\r
3162 if ( index <= firingIndex ) {
\r
3171 // Check if a given callback is in the list.
\r
3172 // If no argument is given, return whether or not list has callbacks attached.
\r
3173 has: function( fn ) {
\r
3174 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
\r
3176 // Remove all callbacks from the list
\r
3177 empty: function() {
\r
3182 // Have the list do nothing anymore
\r
3183 disable: function() {
\r
3184 list = stack = memory = undefined;
\r
3187 // Is it disabled?
\r
3188 disabled: function() {
\r
3191 // Lock the list in its current state
\r
3192 lock: function() {
\r
3193 stack = undefined;
\r
3200 locked: function() {
\r
3203 // Call all callbacks with the given context and arguments
\r
3204 fireWith: function( context, args ) {
\r
3205 if ( list && ( !fired || stack ) ) {
\r
3206 args = args || [];
\r
3207 args = [ context, args.slice ? args.slice() : args ];
\r
3209 stack.push( args );
\r
3216 // Call all the callbacks with the given arguments
\r
3217 fire: function() {
\r
3218 self.fireWith( this, arguments );
\r
3221 // To know if the callbacks have already been called at least once
\r
3222 fired: function() {
\r
3233 Deferred: function( func ) {
\r
3235 // action, add listener, listener list, final state
\r
3236 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
\r
3237 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
\r
3238 [ "notify", "progress", jQuery.Callbacks("memory") ]
\r
3240 state = "pending",
\r
3242 state: function() {
\r
3245 always: function() {
\r
3246 deferred.done( arguments ).fail( arguments );
\r
3249 then: function( /* fnDone, fnFail, fnProgress */ ) {
\r
3250 var fns = arguments;
\r
3251 return jQuery.Deferred(function( newDefer ) {
\r
3252 jQuery.each( tuples, function( i, tuple ) {
\r
3253 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
\r
3254 // deferred[ done | fail | progress ] for forwarding actions to newDefer
\r
3255 deferred[ tuple[1] ](function() {
\r
3256 var returned = fn && fn.apply( this, arguments );
\r
3257 if ( returned && jQuery.isFunction( returned.promise ) ) {
\r
3258 returned.promise()
\r
3259 .done( newDefer.resolve )
\r
3260 .fail( newDefer.reject )
\r
3261 .progress( newDefer.notify );
\r
3263 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
\r
3270 // Get a promise for this deferred
\r
3271 // If obj is provided, the promise aspect is added to the object
\r
3272 promise: function( obj ) {
\r
3273 return obj != null ? jQuery.extend( obj, promise ) : promise;
\r
3278 // Keep pipe for back-compat
\r
3279 promise.pipe = promise.then;
\r
3281 // Add list-specific methods
\r
3282 jQuery.each( tuples, function( i, tuple ) {
\r
3283 var list = tuple[ 2 ],
\r
3284 stateString = tuple[ 3 ];
\r
3286 // promise[ done | fail | progress ] = list.add
\r
3287 promise[ tuple[1] ] = list.add;
\r
3290 if ( stateString ) {
\r
3291 list.add(function() {
\r
3292 // state = [ resolved | rejected ]
\r
3293 state = stateString;
\r
3295 // [ reject_list | resolve_list ].disable; progress_list.lock
\r
3296 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
\r
3299 // deferred[ resolve | reject | notify ]
\r
3300 deferred[ tuple[0] ] = function() {
\r
3301 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
\r
3304 deferred[ tuple[0] + "With" ] = list.fireWith;
\r
3307 // Make the deferred a promise
\r
3308 promise.promise( deferred );
\r
3310 // Call given func if any
\r
3312 func.call( deferred, deferred );
\r
3319 // Deferred helper
\r
3320 when: function( subordinate /* , ..., subordinateN */ ) {
\r
3322 resolveValues = slice.call( arguments ),
\r
3323 length = resolveValues.length,
\r
3325 // the count of uncompleted subordinates
\r
3326 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
\r
3328 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
\r
3329 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
\r
3331 // Update function for both resolve and progress values
\r
3332 updateFunc = function( i, contexts, values ) {
\r
3333 return function( value ) {
\r
3334 contexts[ i ] = this;
\r
3335 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
\r
3336 if ( values === progressValues ) {
\r
3337 deferred.notifyWith( contexts, values );
\r
3339 } else if ( !(--remaining) ) {
\r
3340 deferred.resolveWith( contexts, values );
\r
3345 progressValues, progressContexts, resolveContexts;
\r
3347 // add listeners to Deferred subordinates; treat others as resolved
\r
3348 if ( length > 1 ) {
\r
3349 progressValues = new Array( length );
\r
3350 progressContexts = new Array( length );
\r
3351 resolveContexts = new Array( length );
\r
3352 for ( ; i < length; i++ ) {
\r
3353 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
\r
3354 resolveValues[ i ].promise()
\r
3355 .done( updateFunc( i, resolveContexts, resolveValues ) )
\r
3356 .fail( deferred.reject )
\r
3357 .progress( updateFunc( i, progressContexts, progressValues ) );
\r
3364 // if we're not waiting on anything, resolve the master
\r
3365 if ( !remaining ) {
\r
3366 deferred.resolveWith( resolveContexts, resolveValues );
\r
3369 return deferred.promise();
\r
3374 // The deferred used on DOM ready
\r
3377 jQuery.fn.ready = function( fn ) {
\r
3378 // Add the callback
\r
3379 jQuery.ready.promise().done( fn );
\r
3385 // Is the DOM ready to be used? Set to true once it occurs.
\r
3388 // A counter to track how many items to wait for before
\r
3389 // the ready event fires. See #6781
\r
3392 // Hold (or release) the ready event
\r
3393 holdReady: function( hold ) {
\r
3395 jQuery.readyWait++;
\r
3397 jQuery.ready( true );
\r
3401 // Handle when the DOM is ready
\r
3402 ready: function( wait ) {
\r
3404 // Abort if there are pending holds or we're already ready
\r
3405 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
\r
3409 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
\r
3410 if ( !document.body ) {
\r
3411 return setTimeout( jQuery.ready );
\r
3414 // Remember that the DOM is ready
\r
3415 jQuery.isReady = true;
\r
3417 // If a normal DOM Ready event fired, decrement, and wait if need be
\r
3418 if ( wait !== true && --jQuery.readyWait > 0 ) {
\r
3422 // If there are functions bound, to execute
\r
3423 readyList.resolveWith( document, [ jQuery ] );
\r
3425 // Trigger any bound ready events
\r
3426 if ( jQuery.fn.trigger ) {
\r
3427 jQuery( document ).trigger("ready").off("ready");
\r
3433 * Clean-up method for dom ready events
\r
3435 function detach() {
\r
3436 if ( document.addEventListener ) {
\r
3437 document.removeEventListener( "DOMContentLoaded", completed, false );
\r
3438 window.removeEventListener( "load", completed, false );
\r
3441 document.detachEvent( "onreadystatechange", completed );
\r
3442 window.detachEvent( "onload", completed );
\r
3447 * The ready event handler and self cleanup method
\r
3449 function completed() {
\r
3450 // readyState === "complete" is good enough for us to call the dom ready in oldIE
\r
3451 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
\r
3457 jQuery.ready.promise = function( obj ) {
\r
3458 if ( !readyList ) {
\r
3460 readyList = jQuery.Deferred();
\r
3462 // Catch cases where $(document).ready() is called after the browser event has already occurred.
\r
3463 // we once tried to use readyState "interactive" here, but it caused issues like the one
\r
3464 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
\r
3465 if ( document.readyState === "complete" ) {
\r
3466 // Handle it asynchronously to allow scripts the opportunity to delay ready
\r
3467 setTimeout( jQuery.ready );
\r
3469 // Standards-based browsers support DOMContentLoaded
\r
3470 } else if ( document.addEventListener ) {
\r
3471 // Use the handy event callback
\r
3472 document.addEventListener( "DOMContentLoaded", completed, false );
\r
3474 // A fallback to window.onload, that will always work
\r
3475 window.addEventListener( "load", completed, false );
\r
3477 // If IE event model is used
\r
3479 // Ensure firing before onload, maybe late but safe also for iframes
\r
3480 document.attachEvent( "onreadystatechange", completed );
\r
3482 // A fallback to window.onload, that will always work
\r
3483 window.attachEvent( "onload", completed );
\r
3485 // If IE and not a frame
\r
3486 // continually check to see if the document is ready
\r
3490 top = window.frameElement == null && document.documentElement;
\r
3493 if ( top && top.doScroll ) {
\r
3494 (function doScrollCheck() {
\r
3495 if ( !jQuery.isReady ) {
\r
3498 // Use the trick by Diego Perini
\r
3499 // http://javascript.nwbox.com/IEContentLoaded/
\r
3500 top.doScroll("left");
\r
3502 return setTimeout( doScrollCheck, 50 );
\r
3505 // detach all dom ready events
\r
3508 // and execute any waiting functions
\r
3515 return readyList.promise( obj );
\r
3519 var strundefined = typeof undefined;
\r
3524 // Iteration over object's inherited properties before its own
\r
3526 for ( i in jQuery( support ) ) {
\r
3529 support.ownLast = i !== "0";
\r
3531 // Note: most support tests are defined in their respective modules.
\r
3532 // false until the test is run
\r
3533 support.inlineBlockNeedsLayout = false;
\r
3535 jQuery(function() {
\r
3536 // We need to execute this one support test ASAP because we need to know
\r
3537 // if body.style.zoom needs to be set.
\r
3539 var container, div,
\r
3540 body = document.getElementsByTagName("body")[0];
\r
3543 // Return for frameset docs that don't have a body
\r
3548 container = document.createElement( "div" );
\r
3549 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
\r
3551 div = document.createElement( "div" );
\r
3552 body.appendChild( container ).appendChild( div );
\r
3554 if ( typeof div.style.zoom !== strundefined ) {
\r
3556 // Check if natively block-level elements act like inline-block
\r
3557 // elements when setting their display to 'inline' and giving
\r
3559 div.style.cssText = "border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1";
\r
3561 if ( (support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 )) ) {
\r
3562 // Prevent IE 6 from affecting layout for positioned elements #11048
\r
3563 // Prevent IE from shrinking the body in IE 7 mode #12869
\r
3565 body.style.zoom = 1;
\r
3569 body.removeChild( container );
\r
3571 // Null elements to avoid leaks in IE
\r
3572 container = div = null;
\r
3579 var div = document.createElement( "div" );
\r
3581 // Execute the test only if not already executed in another module.
\r
3582 if (support.deleteExpando == null) {
\r
3584 support.deleteExpando = true;
\r
3588 support.deleteExpando = false;
\r
3592 // Null elements to avoid leaks in IE.
\r
3598 * Determines whether an object can have data
\r
3600 jQuery.acceptData = function( elem ) {
\r
3601 var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
\r
3602 nodeType = +elem.nodeType || 1;
\r
3604 // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
\r
3605 return nodeType !== 1 && nodeType !== 9 ?
\r
3608 // Nodes accept data unless otherwise specified; rejection can be conditional
\r
3609 !noData || noData !== true && elem.getAttribute("classid") === noData;
\r
3613 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
\r
3614 rmultiDash = /([A-Z])/g;
\r
3616 function dataAttr( elem, key, data ) {
\r
3617 // If nothing was found internally, try to fetch any
\r
3618 // data from the HTML5 data-* attribute
\r
3619 if ( data === undefined && elem.nodeType === 1 ) {
\r
3621 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
\r
3623 data = elem.getAttribute( name );
\r
3625 if ( typeof data === "string" ) {
\r
3627 data = data === "true" ? true :
\r
3628 data === "false" ? false :
\r
3629 data === "null" ? null :
\r
3630 // Only convert to a number if it doesn't change the string
\r
3631 +data + "" === data ? +data :
\r
3632 rbrace.test( data ) ? jQuery.parseJSON( data ) :
\r
3636 // Make sure we set the data so it isn't changed later
\r
3637 jQuery.data( elem, key, data );
\r
3647 // checks a cache object for emptiness
\r
3648 function isEmptyDataObject( obj ) {
\r
3650 for ( name in obj ) {
\r
3652 // if the public data object is empty, the private is still empty
\r
3653 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
\r
3656 if ( name !== "toJSON" ) {
\r
3664 function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
\r
3665 if ( !jQuery.acceptData( elem ) ) {
\r
3669 var ret, thisCache,
\r
3670 internalKey = jQuery.expando,
\r
3672 // We have to handle DOM nodes and JS objects differently because IE6-7
\r
3673 // can't GC object references properly across the DOM-JS boundary
\r
3674 isNode = elem.nodeType,
\r
3676 // Only DOM nodes need the global jQuery cache; JS object data is
\r
3677 // attached directly to the object so GC can occur automatically
\r
3678 cache = isNode ? jQuery.cache : elem,
\r
3680 // Only defining an ID for JS objects if its cache already exists allows
\r
3681 // the code to shortcut on the same path as a DOM node with no cache
\r
3682 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
\r
3684 // Avoid doing any more work than we need to when trying to get data on an
\r
3685 // object that has no data at all
\r
3686 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
\r
3691 // Only DOM nodes need a new unique ID for each element since their data
\r
3692 // ends up in the global cache
\r
3694 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
\r
3700 if ( !cache[ id ] ) {
\r
3701 // Avoid exposing jQuery metadata on plain JS objects when the object
\r
3702 // is serialized using JSON.stringify
\r
3703 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
\r
3706 // An object can be passed to jQuery.data instead of a key/value pair; this gets
\r
3707 // shallow copied over onto the existing cache
\r
3708 if ( typeof name === "object" || typeof name === "function" ) {
\r
3710 cache[ id ] = jQuery.extend( cache[ id ], name );
\r
3712 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
\r
3716 thisCache = cache[ id ];
\r
3718 // jQuery data() is stored in a separate object inside the object's internal data
\r
3719 // cache in order to avoid key collisions between internal data and user-defined
\r
3722 if ( !thisCache.data ) {
\r
3723 thisCache.data = {};
\r
3726 thisCache = thisCache.data;
\r
3729 if ( data !== undefined ) {
\r
3730 thisCache[ jQuery.camelCase( name ) ] = data;
\r
3733 // Check for both converted-to-camel and non-converted data property names
\r
3734 // If a data property was specified
\r
3735 if ( typeof name === "string" ) {
\r
3737 // First Try to find as-is property data
\r
3738 ret = thisCache[ name ];
\r
3740 // Test for null|undefined property data
\r
3741 if ( ret == null ) {
\r
3743 // Try to find the camelCased property
\r
3744 ret = thisCache[ jQuery.camelCase( name ) ];
\r
3753 function internalRemoveData( elem, name, pvt ) {
\r
3754 if ( !jQuery.acceptData( elem ) ) {
\r
3759 isNode = elem.nodeType,
\r
3761 // See jQuery.data for more information
\r
3762 cache = isNode ? jQuery.cache : elem,
\r
3763 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
\r
3765 // If there is already no cache entry for this object, there is no
\r
3766 // purpose in continuing
\r
3767 if ( !cache[ id ] ) {
\r
3773 thisCache = pvt ? cache[ id ] : cache[ id ].data;
\r
3775 if ( thisCache ) {
\r
3777 // Support array or space separated string names for data keys
\r
3778 if ( !jQuery.isArray( name ) ) {
\r
3780 // try the string as a key before any manipulation
\r
3781 if ( name in thisCache ) {
\r
3785 // split the camel cased version by spaces unless a key with the spaces exists
\r
3786 name = jQuery.camelCase( name );
\r
3787 if ( name in thisCache ) {
\r
3790 name = name.split(" ");
\r
3794 // If "name" is an array of keys...
\r
3795 // When data is initially created, via ("key", "val") signature,
\r
3796 // keys will be converted to camelCase.
\r
3797 // Since there is no way to tell _how_ a key was added, remove
\r
3798 // both plain key and camelCase key. #12786
\r
3799 // This will only penalize the array argument path.
\r
3800 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
\r
3805 delete thisCache[ name[i] ];
\r
3808 // If there is no data left in the cache, we want to continue
\r
3809 // and let the cache object itself get destroyed
\r
3810 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
\r
3816 // See jQuery.data for more information
\r
3818 delete cache[ id ].data;
\r
3820 // Don't destroy the parent cache unless the internal data object
\r
3821 // had been the only thing left in it
\r
3822 if ( !isEmptyDataObject( cache[ id ] ) ) {
\r
3827 // Destroy the cache
\r
3829 jQuery.cleanData( [ elem ], true );
\r
3831 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
\r
3832 /* jshint eqeqeq: false */
\r
3833 } else if ( support.deleteExpando || cache != cache.window ) {
\r
3834 /* jshint eqeqeq: true */
\r
3835 delete cache[ id ];
\r
3837 // When all else fails, null
\r
3839 cache[ id ] = null;
\r
3846 // The following elements (space-suffixed to avoid Object.prototype collisions)
\r
3847 // throw uncatchable exceptions if you attempt to set expando properties
\r
3851 // ...but Flash objects (which have this classid) *can* handle expandos
\r
3852 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
\r
3855 hasData: function( elem ) {
\r
3856 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
\r
3857 return !!elem && !isEmptyDataObject( elem );
\r
3860 data: function( elem, name, data ) {
\r
3861 return internalData( elem, name, data );
\r
3864 removeData: function( elem, name ) {
\r
3865 return internalRemoveData( elem, name );
\r
3868 // For internal use only.
\r
3869 _data: function( elem, name, data ) {
\r
3870 return internalData( elem, name, data, true );
\r
3873 _removeData: function( elem, name ) {
\r
3874 return internalRemoveData( elem, name, true );
\r
3878 jQuery.fn.extend({
\r
3879 data: function( key, value ) {
\r
3880 var i, name, data,
\r
3882 attrs = elem && elem.attributes;
\r
3884 // Special expections of .data basically thwart jQuery.access,
\r
3885 // so implement the relevant behavior ourselves
\r
3887 // Gets all values
\r
3888 if ( key === undefined ) {
\r
3889 if ( this.length ) {
\r
3890 data = jQuery.data( elem );
\r
3892 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
\r
3895 name = attrs[i].name;
\r
3897 if ( name.indexOf("data-") === 0 ) {
\r
3898 name = jQuery.camelCase( name.slice(5) );
\r
3900 dataAttr( elem, name, data[ name ] );
\r
3903 jQuery._data( elem, "parsedAttrs", true );
\r
3910 // Sets multiple values
\r
3911 if ( typeof key === "object" ) {
\r
3912 return this.each(function() {
\r
3913 jQuery.data( this, key );
\r
3917 return arguments.length > 1 ?
\r
3920 this.each(function() {
\r
3921 jQuery.data( this, key, value );
\r
3925 // Try to fetch any internally stored data first
\r
3926 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
\r
3929 removeData: function( key ) {
\r
3930 return this.each(function() {
\r
3931 jQuery.removeData( this, key );
\r
3938 queue: function( elem, type, data ) {
\r
3942 type = ( type || "fx" ) + "queue";
\r
3943 queue = jQuery._data( elem, type );
\r
3945 // Speed up dequeue by getting out quickly if this is just a lookup
\r
3947 if ( !queue || jQuery.isArray(data) ) {
\r
3948 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
\r
3950 queue.push( data );
\r
3953 return queue || [];
\r
3957 dequeue: function( elem, type ) {
\r
3958 type = type || "fx";
\r
3960 var queue = jQuery.queue( elem, type ),
\r
3961 startLength = queue.length,
\r
3962 fn = queue.shift(),
\r
3963 hooks = jQuery._queueHooks( elem, type ),
\r
3964 next = function() {
\r
3965 jQuery.dequeue( elem, type );
\r
3968 // If the fx queue is dequeued, always remove the progress sentinel
\r
3969 if ( fn === "inprogress" ) {
\r
3970 fn = queue.shift();
\r
3976 // Add a progress sentinel to prevent the fx queue from being
\r
3977 // automatically dequeued
\r
3978 if ( type === "fx" ) {
\r
3979 queue.unshift( "inprogress" );
\r
3982 // clear up the last queue stop function
\r
3983 delete hooks.stop;
\r
3984 fn.call( elem, next, hooks );
\r
3987 if ( !startLength && hooks ) {
\r
3988 hooks.empty.fire();
\r
3992 // not intended for public consumption - generates a queueHooks object, or returns the current one
\r
3993 _queueHooks: function( elem, type ) {
\r
3994 var key = type + "queueHooks";
\r
3995 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
\r
3996 empty: jQuery.Callbacks("once memory").add(function() {
\r
3997 jQuery._removeData( elem, type + "queue" );
\r
3998 jQuery._removeData( elem, key );
\r
4004 jQuery.fn.extend({
\r
4005 queue: function( type, data ) {
\r
4008 if ( typeof type !== "string" ) {
\r
4014 if ( arguments.length < setter ) {
\r
4015 return jQuery.queue( this[0], type );
\r
4018 return data === undefined ?
\r
4020 this.each(function() {
\r
4021 var queue = jQuery.queue( this, type, data );
\r
4023 // ensure a hooks for this queue
\r
4024 jQuery._queueHooks( this, type );
\r
4026 if ( type === "fx" && queue[0] !== "inprogress" ) {
\r
4027 jQuery.dequeue( this, type );
\r
4031 dequeue: function( type ) {
\r
4032 return this.each(function() {
\r
4033 jQuery.dequeue( this, type );
\r
4036 clearQueue: function( type ) {
\r
4037 return this.queue( type || "fx", [] );
\r
4039 // Get a promise resolved when queues of a certain type
\r
4040 // are emptied (fx is the type by default)
\r
4041 promise: function( type, obj ) {
\r
4044 defer = jQuery.Deferred(),
\r
4047 resolve = function() {
\r
4048 if ( !( --count ) ) {
\r
4049 defer.resolveWith( elements, [ elements ] );
\r
4053 if ( typeof type !== "string" ) {
\r
4057 type = type || "fx";
\r
4060 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
\r
4061 if ( tmp && tmp.empty ) {
\r
4063 tmp.empty.add( resolve );
\r
4067 return defer.promise( obj );
\r
4070 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
\r
4072 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
\r
4074 var isHidden = function( elem, el ) {
\r
4075 // isHidden might be called from jQuery#filter function;
\r
4076 // in that case, element will be second argument
\r
4077 elem = el || elem;
\r
4078 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
\r
4083 // Multifunctional method to get and set values of a collection
\r
4084 // The value/s can optionally be executed if it's a function
\r
4085 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
\r
4087 length = elems.length,
\r
4088 bulk = key == null;
\r
4090 // Sets many values
\r
4091 if ( jQuery.type( key ) === "object" ) {
\r
4093 for ( i in key ) {
\r
4094 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
\r
4098 } else if ( value !== undefined ) {
\r
4101 if ( !jQuery.isFunction( value ) ) {
\r
4106 // Bulk operations run against the entire set
\r
4108 fn.call( elems, value );
\r
4111 // ...except when executing function values
\r
4114 fn = function( elem, key, value ) {
\r
4115 return bulk.call( jQuery( elem ), value );
\r
4121 for ( ; i < length; i++ ) {
\r
4122 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
\r
4127 return chainable ?
\r
4132 fn.call( elems ) :
\r
4133 length ? fn( elems[0], key ) : emptyGet;
\r
4135 var rcheckableType = (/^(?:checkbox|radio)$/i);
\r
4140 var fragment = document.createDocumentFragment(),
\r
4141 div = document.createElement("div"),
\r
4142 input = document.createElement("input");
\r
4145 div.setAttribute( "className", "t" );
\r
4146 div.innerHTML = " <link/><table></table><a href='/a'>a</a>";
\r
4148 // IE strips leading whitespace when .innerHTML is used
\r
4149 support.leadingWhitespace = div.firstChild.nodeType === 3;
\r
4151 // Make sure that tbody elements aren't automatically inserted
\r
4152 // IE will insert them into empty tables
\r
4153 support.tbody = !div.getElementsByTagName( "tbody" ).length;
\r
4155 // Make sure that link elements get serialized correctly by innerHTML
\r
4156 // This requires a wrapper element in IE
\r
4157 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
\r
4159 // Makes sure cloning an html5 element does not cause problems
\r
4160 // Where outerHTML is undefined, this still works
\r
4161 support.html5Clone =
\r
4162 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
\r
4164 // Check if a disconnected checkbox will retain its checked
\r
4165 // value of true after appended to the DOM (IE6/7)
\r
4166 input.type = "checkbox";
\r
4167 input.checked = true;
\r
4168 fragment.appendChild( input );
\r
4169 support.appendChecked = input.checked;
\r
4171 // Make sure textarea (and checkbox) defaultValue is properly cloned
\r
4172 // Support: IE6-IE11+
\r
4173 div.innerHTML = "<textarea>x</textarea>";
\r
4174 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
\r
4176 // #11217 - WebKit loses check when the name is after the checked attribute
\r
4177 fragment.appendChild( div );
\r
4178 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
\r
4180 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
\r
4181 // old WebKit doesn't clone checked state correctly in fragments
\r
4182 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
\r
4185 // Opera does not clone events (and typeof div.attachEvent === undefined).
\r
4186 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
\r
4187 support.noCloneEvent = true;
\r
4188 if ( div.attachEvent ) {
\r
4189 div.attachEvent( "onclick", function() {
\r
4190 support.noCloneEvent = false;
\r
4193 div.cloneNode( true ).click();
\r
4196 // Execute the test only if not already executed in another module.
\r
4197 if (support.deleteExpando == null) {
\r
4199 support.deleteExpando = true;
\r
4203 support.deleteExpando = false;
\r
4207 // Null elements to avoid leaks in IE.
\r
4208 fragment = div = input = null;
\r
4214 div = document.createElement( "div" );
\r
4216 // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
\r
4217 for ( i in { submit: true, change: true, focusin: true }) {
\r
4218 eventName = "on" + i;
\r
4220 if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
\r
4221 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
\r
4222 div.setAttribute( eventName, "t" );
\r
4223 support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
\r
4227 // Null elements to avoid leaks in IE.
\r
4232 var rformElems = /^(?:input|select|textarea)$/i,
\r
4233 rkeyEvent = /^key/,
\r
4234 rmouseEvent = /^(?:mouse|contextmenu)|click/,
\r
4235 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
\r
4236 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
\r
4238 function returnTrue() {
\r
4242 function returnFalse() {
\r
4246 function safeActiveElement() {
\r
4248 return document.activeElement;
\r
4249 } catch ( err ) { }
\r
4253 * Helper functions for managing events -- not part of the public interface.
\r
4254 * Props to Dean Edwards' addEvent library for many of the ideas.
\r
4260 add: function( elem, types, handler, data, selector ) {
\r
4261 var tmp, events, t, handleObjIn,
\r
4262 special, eventHandle, handleObj,
\r
4263 handlers, type, namespaces, origType,
\r
4264 elemData = jQuery._data( elem );
\r
4266 // Don't attach events to noData or text/comment nodes (but allow plain objects)
\r
4267 if ( !elemData ) {
\r
4271 // Caller can pass in an object of custom data in lieu of the handler
\r
4272 if ( handler.handler ) {
\r
4273 handleObjIn = handler;
\r
4274 handler = handleObjIn.handler;
\r
4275 selector = handleObjIn.selector;
\r
4278 // Make sure that the handler has a unique ID, used to find/remove it later
\r
4279 if ( !handler.guid ) {
\r
4280 handler.guid = jQuery.guid++;
\r
4283 // Init the element's event structure and main handler, if this is the first
\r
4284 if ( !(events = elemData.events) ) {
\r
4285 events = elemData.events = {};
\r
4287 if ( !(eventHandle = elemData.handle) ) {
\r
4288 eventHandle = elemData.handle = function( e ) {
\r
4289 // Discard the second event of a jQuery.event.trigger() and
\r
4290 // when an event is called after a page has unloaded
\r
4291 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
\r
4292 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
\r
4295 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
\r
4296 eventHandle.elem = elem;
\r
4299 // Handle multiple events separated by a space
\r
4300 types = ( types || "" ).match( rnotwhite ) || [ "" ];
\r
4303 tmp = rtypenamespace.exec( types[t] ) || [];
\r
4304 type = origType = tmp[1];
\r
4305 namespaces = ( tmp[2] || "" ).split( "." ).sort();
\r
4307 // There *must* be a type, no attaching namespace-only handlers
\r
4312 // If event changes its type, use the special event handlers for the changed type
\r
4313 special = jQuery.event.special[ type ] || {};
\r
4315 // If selector defined, determine special event api type, otherwise given type
\r
4316 type = ( selector ? special.delegateType : special.bindType ) || type;
\r
4318 // Update special based on newly reset type
\r
4319 special = jQuery.event.special[ type ] || {};
\r
4321 // handleObj is passed to all event handlers
\r
4322 handleObj = jQuery.extend({
\r
4324 origType: origType,
\r
4327 guid: handler.guid,
\r
4328 selector: selector,
\r
4329 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
\r
4330 namespace: namespaces.join(".")
\r
4333 // Init the event handler queue if we're the first
\r
4334 if ( !(handlers = events[ type ]) ) {
\r
4335 handlers = events[ type ] = [];
\r
4336 handlers.delegateCount = 0;
\r
4338 // Only use addEventListener/attachEvent if the special events handler returns false
\r
4339 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
\r
4340 // Bind the global event handler to the element
\r
4341 if ( elem.addEventListener ) {
\r
4342 elem.addEventListener( type, eventHandle, false );
\r
4344 } else if ( elem.attachEvent ) {
\r
4345 elem.attachEvent( "on" + type, eventHandle );
\r
4350 if ( special.add ) {
\r
4351 special.add.call( elem, handleObj );
\r
4353 if ( !handleObj.handler.guid ) {
\r
4354 handleObj.handler.guid = handler.guid;
\r
4358 // Add to the element's handler list, delegates in front
\r
4360 handlers.splice( handlers.delegateCount++, 0, handleObj );
\r
4362 handlers.push( handleObj );
\r
4365 // Keep track of which events have ever been used, for event optimization
\r
4366 jQuery.event.global[ type ] = true;
\r
4369 // Nullify elem to prevent memory leaks in IE
\r
4373 // Detach an event or set of events from an element
\r
4374 remove: function( elem, types, handler, selector, mappedTypes ) {
\r
4375 var j, handleObj, tmp,
\r
4376 origCount, t, events,
\r
4377 special, handlers, type,
\r
4378 namespaces, origType,
\r
4379 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
\r
4381 if ( !elemData || !(events = elemData.events) ) {
\r
4385 // Once for each type.namespace in types; type may be omitted
\r
4386 types = ( types || "" ).match( rnotwhite ) || [ "" ];
\r
4389 tmp = rtypenamespace.exec( types[t] ) || [];
\r
4390 type = origType = tmp[1];
\r
4391 namespaces = ( tmp[2] || "" ).split( "." ).sort();
\r
4393 // Unbind all events (on this namespace, if provided) for the element
\r
4395 for ( type in events ) {
\r
4396 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
\r
4401 special = jQuery.event.special[ type ] || {};
\r
4402 type = ( selector ? special.delegateType : special.bindType ) || type;
\r
4403 handlers = events[ type ] || [];
\r
4404 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
\r
4406 // Remove matching events
\r
4407 origCount = j = handlers.length;
\r
4409 handleObj = handlers[ j ];
\r
4411 if ( ( mappedTypes || origType === handleObj.origType ) &&
\r
4412 ( !handler || handler.guid === handleObj.guid ) &&
\r
4413 ( !tmp || tmp.test( handleObj.namespace ) ) &&
\r
4414 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
\r
4415 handlers.splice( j, 1 );
\r
4417 if ( handleObj.selector ) {
\r
4418 handlers.delegateCount--;
\r
4420 if ( special.remove ) {
\r
4421 special.remove.call( elem, handleObj );
\r
4426 // Remove generic event handler if we removed something and no more handlers exist
\r
4427 // (avoids potential for endless recursion during removal of special event handlers)
\r
4428 if ( origCount && !handlers.length ) {
\r
4429 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
\r
4430 jQuery.removeEvent( elem, type, elemData.handle );
\r
4433 delete events[ type ];
\r
4437 // Remove the expando if it's no longer used
\r
4438 if ( jQuery.isEmptyObject( events ) ) {
\r
4439 delete elemData.handle;
\r
4441 // removeData also checks for emptiness and clears the expando if empty
\r
4442 // so use it instead of delete
\r
4443 jQuery._removeData( elem, "events" );
\r
4447 trigger: function( event, data, elem, onlyHandlers ) {
\r
4448 var handle, ontype, cur,
\r
4449 bubbleType, special, tmp, i,
\r
4450 eventPath = [ elem || document ],
\r
4451 type = hasOwn.call( event, "type" ) ? event.type : event,
\r
4452 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
\r
4454 cur = tmp = elem = elem || document;
\r
4456 // Don't do events on text and comment nodes
\r
4457 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
\r
4461 // focus/blur morphs to focusin/out; ensure we're not firing them right now
\r
4462 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
\r
4466 if ( type.indexOf(".") >= 0 ) {
\r
4467 // Namespaced trigger; create a regexp to match event type in handle()
\r
4468 namespaces = type.split(".");
\r
4469 type = namespaces.shift();
\r
4470 namespaces.sort();
\r
4472 ontype = type.indexOf(":") < 0 && "on" + type;
\r
4474 // Caller can pass in a jQuery.Event object, Object, or just an event type string
\r
4475 event = event[ jQuery.expando ] ?
\r
4477 new jQuery.Event( type, typeof event === "object" && event );
\r
4479 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
\r
4480 event.isTrigger = onlyHandlers ? 2 : 3;
\r
4481 event.namespace = namespaces.join(".");
\r
4482 event.namespace_re = event.namespace ?
\r
4483 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
\r
4486 // Clean up the event in case it is being reused
\r
4487 event.result = undefined;
\r
4488 if ( !event.target ) {
\r
4489 event.target = elem;
\r
4492 // Clone any incoming data and prepend the event, creating the handler arg list
\r
4493 data = data == null ?
\r
4495 jQuery.makeArray( data, [ event ] );
\r
4497 // Allow special events to draw outside the lines
\r
4498 special = jQuery.event.special[ type ] || {};
\r
4499 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
\r
4503 // Determine event propagation path in advance, per W3C events spec (#9951)
\r
4504 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
\r
4505 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
\r
4507 bubbleType = special.delegateType || type;
\r
4508 if ( !rfocusMorph.test( bubbleType + type ) ) {
\r
4509 cur = cur.parentNode;
\r
4511 for ( ; cur; cur = cur.parentNode ) {
\r
4512 eventPath.push( cur );
\r
4516 // Only add window if we got to document (e.g., not plain obj or detached DOM)
\r
4517 if ( tmp === (elem.ownerDocument || document) ) {
\r
4518 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
\r
4522 // Fire handlers on the event path
\r
4524 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
\r
4526 event.type = i > 1 ?
\r
4528 special.bindType || type;
\r
4531 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
\r
4533 handle.apply( cur, data );
\r
4537 handle = ontype && cur[ ontype ];
\r
4538 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
\r
4539 event.result = handle.apply( cur, data );
\r
4540 if ( event.result === false ) {
\r
4541 event.preventDefault();
\r
4545 event.type = type;
\r
4547 // If nobody prevented the default action, do it now
\r
4548 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
\r
4550 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
\r
4551 jQuery.acceptData( elem ) ) {
\r
4553 // Call a native DOM method on the target with the same name name as the event.
\r
4554 // Can't use an .isFunction() check here because IE6/7 fails that test.
\r
4555 // Don't do default actions on window, that's where global variables be (#6170)
\r
4556 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
\r
4558 // Don't re-trigger an onFOO event when we call its FOO() method
\r
4559 tmp = elem[ ontype ];
\r
4562 elem[ ontype ] = null;
\r
4565 // Prevent re-triggering of the same event, since we already bubbled it above
\r
4566 jQuery.event.triggered = type;
\r
4570 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
\r
4571 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
\r
4573 jQuery.event.triggered = undefined;
\r
4576 elem[ ontype ] = tmp;
\r
4582 return event.result;
\r
4585 dispatch: function( event ) {
\r
4587 // Make a writable jQuery.Event from the native event object
\r
4588 event = jQuery.event.fix( event );
\r
4590 var i, ret, handleObj, matched, j,
\r
4591 handlerQueue = [],
\r
4592 args = slice.call( arguments ),
\r
4593 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
\r
4594 special = jQuery.event.special[ event.type ] || {};
\r
4596 // Use the fix-ed jQuery.Event rather than the (read-only) native event
\r
4598 event.delegateTarget = this;
\r
4600 // Call the preDispatch hook for the mapped type, and let it bail if desired
\r
4601 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
\r
4605 // Determine handlers
\r
4606 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
\r
4608 // Run delegates first; they may want to stop propagation beneath us
\r
4610 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
\r
4611 event.currentTarget = matched.elem;
\r
4614 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
\r
4616 // Triggered event must either 1) have no namespace, or
\r
4617 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
\r
4618 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
\r
4620 event.handleObj = handleObj;
\r
4621 event.data = handleObj.data;
\r
4623 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
\r
4624 .apply( matched.elem, args );
\r
4626 if ( ret !== undefined ) {
\r
4627 if ( (event.result = ret) === false ) {
\r
4628 event.preventDefault();
\r
4629 event.stopPropagation();
\r
4636 // Call the postDispatch hook for the mapped type
\r
4637 if ( special.postDispatch ) {
\r
4638 special.postDispatch.call( this, event );
\r
4641 return event.result;
\r
4644 handlers: function( event, handlers ) {
\r
4645 var sel, handleObj, matches, i,
\r
4646 handlerQueue = [],
\r
4647 delegateCount = handlers.delegateCount,
\r
4648 cur = event.target;
\r
4650 // Find delegate handlers
\r
4651 // Black-hole SVG <use> instance trees (#13180)
\r
4652 // Avoid non-left-click bubbling in Firefox (#3861)
\r
4653 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
\r
4655 /* jshint eqeqeq: false */
\r
4656 for ( ; cur != this; cur = cur.parentNode || this ) {
\r
4657 /* jshint eqeqeq: true */
\r
4659 // Don't check non-elements (#13208)
\r
4660 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
\r
4661 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
\r
4663 for ( i = 0; i < delegateCount; i++ ) {
\r
4664 handleObj = handlers[ i ];
\r
4666 // Don't conflict with Object.prototype properties (#13203)
\r
4667 sel = handleObj.selector + " ";
\r
4669 if ( matches[ sel ] === undefined ) {
\r
4670 matches[ sel ] = handleObj.needsContext ?
\r
4671 jQuery( sel, this ).index( cur ) >= 0 :
\r
4672 jQuery.find( sel, this, null, [ cur ] ).length;
\r
4674 if ( matches[ sel ] ) {
\r
4675 matches.push( handleObj );
\r
4678 if ( matches.length ) {
\r
4679 handlerQueue.push({ elem: cur, handlers: matches });
\r
4685 // Add the remaining (directly-bound) handlers
\r
4686 if ( delegateCount < handlers.length ) {
\r
4687 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
\r
4690 return handlerQueue;
\r
4693 fix: function( event ) {
\r
4694 if ( event[ jQuery.expando ] ) {
\r
4698 // Create a writable copy of the event object and normalize some properties
\r
4699 var i, prop, copy,
\r
4700 type = event.type,
\r
4701 originalEvent = event,
\r
4702 fixHook = this.fixHooks[ type ];
\r
4705 this.fixHooks[ type ] = fixHook =
\r
4706 rmouseEvent.test( type ) ? this.mouseHooks :
\r
4707 rkeyEvent.test( type ) ? this.keyHooks :
\r
4710 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
\r
4712 event = new jQuery.Event( originalEvent );
\r
4717 event[ prop ] = originalEvent[ prop ];
\r
4721 // Fix target property (#1925)
\r
4722 if ( !event.target ) {
\r
4723 event.target = originalEvent.srcElement || document;
\r
4726 // Support: Chrome 23+, Safari?
\r
4727 // Target should not be a text node (#504, #13143)
\r
4728 if ( event.target.nodeType === 3 ) {
\r
4729 event.target = event.target.parentNode;
\r
4733 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
\r
4734 event.metaKey = !!event.metaKey;
\r
4736 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
\r
4739 // Includes some event props shared by KeyEvent and MouseEvent
\r
4740 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
\r
4745 props: "char charCode key keyCode".split(" "),
\r
4746 filter: function( event, original ) {
\r
4748 // Add which for key events
\r
4749 if ( event.which == null ) {
\r
4750 event.which = original.charCode != null ? original.charCode : original.keyCode;
\r
4758 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
\r
4759 filter: function( event, original ) {
\r
4760 var body, eventDoc, doc,
\r
4761 button = original.button,
\r
4762 fromElement = original.fromElement;
\r
4764 // Calculate pageX/Y if missing and clientX/Y available
\r
4765 if ( event.pageX == null && original.clientX != null ) {
\r
4766 eventDoc = event.target.ownerDocument || document;
\r
4767 doc = eventDoc.documentElement;
\r
4768 body = eventDoc.body;
\r
4770 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
\r
4771 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
\r
4774 // Add relatedTarget, if necessary
\r
4775 if ( !event.relatedTarget && fromElement ) {
\r
4776 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
\r
4779 // Add which for click: 1 === left; 2 === middle; 3 === right
\r
4780 // Note: button is not normalized, so don't use it
\r
4781 if ( !event.which && button !== undefined ) {
\r
4782 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
\r
4791 // Prevent triggered image.load events from bubbling to window.load
\r
4795 // Fire native event if possible so blur/focus sequence is correct
\r
4796 trigger: function() {
\r
4797 if ( this !== safeActiveElement() && this.focus ) {
\r
4803 // If we error on focus to hidden element (#1486, #12518),
\r
4804 // let .trigger() run the handlers
\r
4808 delegateType: "focusin"
\r
4811 trigger: function() {
\r
4812 if ( this === safeActiveElement() && this.blur ) {
\r
4817 delegateType: "focusout"
\r
4820 // For checkbox, fire native event so checked state will be right
\r
4821 trigger: function() {
\r
4822 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
\r
4828 // For cross-browser consistency, don't fire native .click() on links
\r
4829 _default: function( event ) {
\r
4830 return jQuery.nodeName( event.target, "a" );
\r
4835 postDispatch: function( event ) {
\r
4837 // Even when returnValue equals to undefined Firefox will still show alert
\r
4838 if ( event.result !== undefined ) {
\r
4839 event.originalEvent.returnValue = event.result;
\r
4845 simulate: function( type, elem, event, bubble ) {
\r
4846 // Piggyback on a donor event to simulate a different one.
\r
4847 // Fake originalEvent to avoid donor's stopPropagation, but if the
\r
4848 // simulated event prevents default then we do the same on the donor.
\r
4849 var e = jQuery.extend(
\r
4850 new jQuery.Event(),
\r
4854 isSimulated: true,
\r
4859 jQuery.event.trigger( e, null, elem );
\r
4861 jQuery.event.dispatch.call( elem, e );
\r
4863 if ( e.isDefaultPrevented() ) {
\r
4864 event.preventDefault();
\r
4869 jQuery.removeEvent = document.removeEventListener ?
\r
4870 function( elem, type, handle ) {
\r
4871 if ( elem.removeEventListener ) {
\r
4872 elem.removeEventListener( type, handle, false );
\r
4875 function( elem, type, handle ) {
\r
4876 var name = "on" + type;
\r
4878 if ( elem.detachEvent ) {
\r
4880 // #8545, #7054, preventing memory leaks for custom events in IE6-8
\r
4881 // detachEvent needed property on element, by name of that event, to properly expose it to GC
\r
4882 if ( typeof elem[ name ] === strundefined ) {
\r
4883 elem[ name ] = null;
\r
4886 elem.detachEvent( name, handle );
\r
4890 jQuery.Event = function( src, props ) {
\r
4891 // Allow instantiation without the 'new' keyword
\r
4892 if ( !(this instanceof jQuery.Event) ) {
\r
4893 return new jQuery.Event( src, props );
\r
4897 if ( src && src.type ) {
\r
4898 this.originalEvent = src;
\r
4899 this.type = src.type;
\r
4901 // Events bubbling up the document may have been marked as prevented
\r
4902 // by a handler lower down the tree; reflect the correct value.
\r
4903 this.isDefaultPrevented = src.defaultPrevented ||
\r
4904 src.defaultPrevented === undefined && (
\r
4905 // Support: IE < 9
\r
4906 src.returnValue === false ||
\r
4907 // Support: Android < 4.0
\r
4908 src.getPreventDefault && src.getPreventDefault() ) ?
\r
4917 // Put explicitly provided properties onto the event object
\r
4919 jQuery.extend( this, props );
\r
4922 // Create a timestamp if incoming event doesn't have one
\r
4923 this.timeStamp = src && src.timeStamp || jQuery.now();
\r
4925 // Mark it as fixed
\r
4926 this[ jQuery.expando ] = true;
\r
4929 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
\r
4930 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
\r
4931 jQuery.Event.prototype = {
\r
4932 isDefaultPrevented: returnFalse,
\r
4933 isPropagationStopped: returnFalse,
\r
4934 isImmediatePropagationStopped: returnFalse,
\r
4936 preventDefault: function() {
\r
4937 var e = this.originalEvent;
\r
4939 this.isDefaultPrevented = returnTrue;
\r
4944 // If preventDefault exists, run it on the original event
\r
4945 if ( e.preventDefault ) {
\r
4946 e.preventDefault();
\r
4949 // Otherwise set the returnValue property of the original event to false
\r
4951 e.returnValue = false;
\r
4954 stopPropagation: function() {
\r
4955 var e = this.originalEvent;
\r
4957 this.isPropagationStopped = returnTrue;
\r
4961 // If stopPropagation exists, run it on the original event
\r
4962 if ( e.stopPropagation ) {
\r
4963 e.stopPropagation();
\r
4967 // Set the cancelBubble property of the original event to true
\r
4968 e.cancelBubble = true;
\r
4970 stopImmediatePropagation: function() {
\r
4971 this.isImmediatePropagationStopped = returnTrue;
\r
4972 this.stopPropagation();
\r
4976 // Create mouseenter/leave events using mouseover/out and event-time checks
\r
4978 mouseenter: "mouseover",
\r
4979 mouseleave: "mouseout"
\r
4980 }, function( orig, fix ) {
\r
4981 jQuery.event.special[ orig ] = {
\r
4982 delegateType: fix,
\r
4985 handle: function( event ) {
\r
4988 related = event.relatedTarget,
\r
4989 handleObj = event.handleObj;
\r
4991 // For mousenter/leave call the handler if related is outside the target.
\r
4992 // NB: No relatedTarget if the mouse left/entered the browser window
\r
4993 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
\r
4994 event.type = handleObj.origType;
\r
4995 ret = handleObj.handler.apply( this, arguments );
\r
5003 // IE submit delegation
\r
5004 if ( !support.submitBubbles ) {
\r
5006 jQuery.event.special.submit = {
\r
5007 setup: function() {
\r
5008 // Only need this for delegated form submit events
\r
5009 if ( jQuery.nodeName( this, "form" ) ) {
\r
5013 // Lazy-add a submit handler when a descendant form may potentially be submitted
\r
5014 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
\r
5015 // Node name check avoids a VML-related crash in IE (#9807)
\r
5016 var elem = e.target,
\r
5017 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
\r
5018 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
\r
5019 jQuery.event.add( form, "submit._submit", function( event ) {
\r
5020 event._submit_bubble = true;
\r
5022 jQuery._data( form, "submitBubbles", true );
\r
5025 // return undefined since we don't need an event listener
\r
5028 postDispatch: function( event ) {
\r
5029 // If form was submitted by the user, bubble the event up the tree
\r
5030 if ( event._submit_bubble ) {
\r
5031 delete event._submit_bubble;
\r
5032 if ( this.parentNode && !event.isTrigger ) {
\r
5033 jQuery.event.simulate( "submit", this.parentNode, event, true );
\r
5038 teardown: function() {
\r
5039 // Only need this for delegated form submit events
\r
5040 if ( jQuery.nodeName( this, "form" ) ) {
\r
5044 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
\r
5045 jQuery.event.remove( this, "._submit" );
\r
5050 // IE change delegation and checkbox/radio fix
\r
5051 if ( !support.changeBubbles ) {
\r
5053 jQuery.event.special.change = {
\r
5055 setup: function() {
\r
5057 if ( rformElems.test( this.nodeName ) ) {
\r
5058 // IE doesn't fire change on a check/radio until blur; trigger it on click
\r
5059 // after a propertychange. Eat the blur-change in special.change.handle.
\r
5060 // This still fires onchange a second time for check/radio after blur.
\r
5061 if ( this.type === "checkbox" || this.type === "radio" ) {
\r
5062 jQuery.event.add( this, "propertychange._change", function( event ) {
\r
5063 if ( event.originalEvent.propertyName === "checked" ) {
\r
5064 this._just_changed = true;
\r
5067 jQuery.event.add( this, "click._change", function( event ) {
\r
5068 if ( this._just_changed && !event.isTrigger ) {
\r
5069 this._just_changed = false;
\r
5071 // Allow triggered, simulated change events (#11500)
\r
5072 jQuery.event.simulate( "change", this, event, true );
\r
5077 // Delegated event; lazy-add a change handler on descendant inputs
\r
5078 jQuery.event.add( this, "beforeactivate._change", function( e ) {
\r
5079 var elem = e.target;
\r
5081 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
\r
5082 jQuery.event.add( elem, "change._change", function( event ) {
\r
5083 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
\r
5084 jQuery.event.simulate( "change", this.parentNode, event, true );
\r
5087 jQuery._data( elem, "changeBubbles", true );
\r
5092 handle: function( event ) {
\r
5093 var elem = event.target;
\r
5095 // Swallow native change events from checkbox/radio, we already triggered them above
\r
5096 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
\r
5097 return event.handleObj.handler.apply( this, arguments );
\r
5101 teardown: function() {
\r
5102 jQuery.event.remove( this, "._change" );
\r
5104 return !rformElems.test( this.nodeName );
\r
5109 // Create "bubbling" focus and blur events
\r
5110 if ( !support.focusinBubbles ) {
\r
5111 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
\r
5113 // Attach a single capturing handler on the document while someone wants focusin/focusout
\r
5114 var handler = function( event ) {
\r
5115 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
\r
5118 jQuery.event.special[ fix ] = {
\r
5119 setup: function() {
\r
5120 var doc = this.ownerDocument || this,
\r
5121 attaches = jQuery._data( doc, fix );
\r
5123 if ( !attaches ) {
\r
5124 doc.addEventListener( orig, handler, true );
\r
5126 jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
\r
5128 teardown: function() {
\r
5129 var doc = this.ownerDocument || this,
\r
5130 attaches = jQuery._data( doc, fix ) - 1;
\r
5132 if ( !attaches ) {
\r
5133 doc.removeEventListener( orig, handler, true );
\r
5134 jQuery._removeData( doc, fix );
\r
5136 jQuery._data( doc, fix, attaches );
\r
5143 jQuery.fn.extend({
\r
5145 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
\r
5148 // Types can be a map of types/handlers
\r
5149 if ( typeof types === "object" ) {
\r
5150 // ( types-Object, selector, data )
\r
5151 if ( typeof selector !== "string" ) {
\r
5152 // ( types-Object, data )
\r
5153 data = data || selector;
\r
5154 selector = undefined;
\r
5156 for ( type in types ) {
\r
5157 this.on( type, selector, data, types[ type ], one );
\r
5162 if ( data == null && fn == null ) {
\r
5165 data = selector = undefined;
\r
5166 } else if ( fn == null ) {
\r
5167 if ( typeof selector === "string" ) {
\r
5168 // ( types, selector, fn )
\r
5172 // ( types, data, fn )
\r
5175 selector = undefined;
\r
5178 if ( fn === false ) {
\r
5180 } else if ( !fn ) {
\r
5184 if ( one === 1 ) {
\r
5186 fn = function( event ) {
\r
5187 // Can use an empty set, since event contains the info
\r
5188 jQuery().off( event );
\r
5189 return origFn.apply( this, arguments );
\r
5191 // Use same guid so caller can remove using origFn
\r
5192 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
\r
5194 return this.each( function() {
\r
5195 jQuery.event.add( this, types, fn, data, selector );
\r
5198 one: function( types, selector, data, fn ) {
\r
5199 return this.on( types, selector, data, fn, 1 );
\r
5201 off: function( types, selector, fn ) {
\r
5202 var handleObj, type;
\r
5203 if ( types && types.preventDefault && types.handleObj ) {
\r
5204 // ( event ) dispatched jQuery.Event
\r
5205 handleObj = types.handleObj;
\r
5206 jQuery( types.delegateTarget ).off(
\r
5207 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
\r
5208 handleObj.selector,
\r
5213 if ( typeof types === "object" ) {
\r
5214 // ( types-object [, selector] )
\r
5215 for ( type in types ) {
\r
5216 this.off( type, selector, types[ type ] );
\r
5220 if ( selector === false || typeof selector === "function" ) {
\r
5221 // ( types [, fn] )
\r
5223 selector = undefined;
\r
5225 if ( fn === false ) {
\r
5228 return this.each(function() {
\r
5229 jQuery.event.remove( this, types, fn, selector );
\r
5233 trigger: function( type, data ) {
\r
5234 return this.each(function() {
\r
5235 jQuery.event.trigger( type, data, this );
\r
5238 triggerHandler: function( type, data ) {
\r
5239 var elem = this[0];
\r
5241 return jQuery.event.trigger( type, data, elem, true );
\r
5247 function createSafeFragment( document ) {
\r
5248 var list = nodeNames.split( "|" ),
\r
5249 safeFrag = document.createDocumentFragment();
\r
5251 if ( safeFrag.createElement ) {
\r
5252 while ( list.length ) {
\r
5253 safeFrag.createElement(
\r
5261 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
\r
5262 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
\r
5263 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
\r
5264 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
\r
5265 rleadingWhitespace = /^\s+/,
\r
5266 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
\r
5267 rtagName = /<([\w:]+)/,
\r
5268 rtbody = /<tbody/i,
\r
5269 rhtml = /<|&#?\w+;/,
\r
5270 rnoInnerhtml = /<(?:script|style|link)/i,
\r
5271 // checked="checked" or checked
\r
5272 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
\r
5273 rscriptType = /^$|\/(?:java|ecma)script/i,
\r
5274 rscriptTypeMasked = /^true\/(.*)/,
\r
5275 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
\r
5277 // We have to close these tags to support XHTML (#13200)
\r
5279 option: [ 1, "<select multiple='multiple'>", "</select>" ],
\r
5280 legend: [ 1, "<fieldset>", "</fieldset>" ],
\r
5281 area: [ 1, "<map>", "</map>" ],
\r
5282 param: [ 1, "<object>", "</object>" ],
\r
5283 thead: [ 1, "<table>", "</table>" ],
\r
5284 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
\r
5285 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
\r
5286 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
\r
5288 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
\r
5289 // unless wrapped in a div with non-breaking characters in front of it.
\r
5290 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
\r
5292 safeFragment = createSafeFragment( document ),
\r
5293 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
\r
5295 wrapMap.optgroup = wrapMap.option;
\r
5296 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
\r
5297 wrapMap.th = wrapMap.td;
\r
5299 function getAll( context, tag ) {
\r
5302 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
\r
5303 typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
\r
5307 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
\r
5308 if ( !tag || jQuery.nodeName( elem, tag ) ) {
\r
5309 found.push( elem );
\r
5311 jQuery.merge( found, getAll( elem, tag ) );
\r
5316 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
\r
5317 jQuery.merge( [ context ], found ) :
\r
5321 // Used in buildFragment, fixes the defaultChecked property
\r
5322 function fixDefaultChecked( elem ) {
\r
5323 if ( rcheckableType.test( elem.type ) ) {
\r
5324 elem.defaultChecked = elem.checked;
\r
5329 // Manipulating tables requires a tbody
\r
5330 function manipulationTarget( elem, content ) {
\r
5331 return jQuery.nodeName( elem, "table" ) &&
\r
5332 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
\r
5334 elem.getElementsByTagName("tbody")[0] ||
\r
5335 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
\r
5339 // Replace/restore the type attribute of script elements for safe DOM manipulation
\r
5340 function disableScript( elem ) {
\r
5341 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
\r
5344 function restoreScript( elem ) {
\r
5345 var match = rscriptTypeMasked.exec( elem.type );
\r
5347 elem.type = match[1];
\r
5349 elem.removeAttribute("type");
\r
5354 // Mark scripts as having already been evaluated
\r
5355 function setGlobalEval( elems, refElements ) {
\r
5358 for ( ; (elem = elems[i]) != null; i++ ) {
\r
5359 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
\r
5363 function cloneCopyEvent( src, dest ) {
\r
5365 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
\r
5370 oldData = jQuery._data( src ),
\r
5371 curData = jQuery._data( dest, oldData ),
\r
5372 events = oldData.events;
\r
5375 delete curData.handle;
\r
5376 curData.events = {};
\r
5378 for ( type in events ) {
\r
5379 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
\r
5380 jQuery.event.add( dest, type, events[ type ][ i ] );
\r
5385 // make the cloned public data object a copy from the original
\r
5386 if ( curData.data ) {
\r
5387 curData.data = jQuery.extend( {}, curData.data );
\r
5391 function fixCloneNodeIssues( src, dest ) {
\r
5392 var nodeName, e, data;
\r
5394 // We do not need to do anything for non-Elements
\r
5395 if ( dest.nodeType !== 1 ) {
\r
5399 nodeName = dest.nodeName.toLowerCase();
\r
5401 // IE6-8 copies events bound via attachEvent when using cloneNode.
\r
5402 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
\r
5403 data = jQuery._data( dest );
\r
5405 for ( e in data.events ) {
\r
5406 jQuery.removeEvent( dest, e, data.handle );
\r
5409 // Event data gets referenced instead of copied if the expando gets copied too
\r
5410 dest.removeAttribute( jQuery.expando );
\r
5413 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
\r
5414 if ( nodeName === "script" && dest.text !== src.text ) {
\r
5415 disableScript( dest ).text = src.text;
\r
5416 restoreScript( dest );
\r
5418 // IE6-10 improperly clones children of object elements using classid.
\r
5419 // IE10 throws NoModificationAllowedError if parent is null, #12132.
\r
5420 } else if ( nodeName === "object" ) {
\r
5421 if ( dest.parentNode ) {
\r
5422 dest.outerHTML = src.outerHTML;
\r
5425 // This path appears unavoidable for IE9. When cloning an object
\r
5426 // element in IE9, the outerHTML strategy above is not sufficient.
\r
5427 // If the src has innerHTML and the destination does not,
\r
5428 // copy the src.innerHTML into the dest.innerHTML. #10324
\r
5429 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
\r
5430 dest.innerHTML = src.innerHTML;
\r
5433 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
\r
5434 // IE6-8 fails to persist the checked state of a cloned checkbox
\r
5435 // or radio button. Worse, IE6-7 fail to give the cloned element
\r
5436 // a checked appearance if the defaultChecked value isn't also set
\r
5438 dest.defaultChecked = dest.checked = src.checked;
\r
5440 // IE6-7 get confused and end up setting the value of a cloned
\r
5441 // checkbox/radio button to an empty string instead of "on"
\r
5442 if ( dest.value !== src.value ) {
\r
5443 dest.value = src.value;
\r
5446 // IE6-8 fails to return the selected option to the default selected
\r
5447 // state when cloning options
\r
5448 } else if ( nodeName === "option" ) {
\r
5449 dest.defaultSelected = dest.selected = src.defaultSelected;
\r
5451 // IE6-8 fails to set the defaultValue to the correct value when
\r
5452 // cloning other types of input fields
\r
5453 } else if ( nodeName === "input" || nodeName === "textarea" ) {
\r
5454 dest.defaultValue = src.defaultValue;
\r
5459 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
\r
5460 var destElements, node, clone, i, srcElements,
\r
5461 inPage = jQuery.contains( elem.ownerDocument, elem );
\r
5463 if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
\r
5464 clone = elem.cloneNode( true );
\r
5466 // IE<=8 does not properly clone detached, unknown element nodes
\r
5468 fragmentDiv.innerHTML = elem.outerHTML;
\r
5469 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
\r
5472 if ( (!support.noCloneEvent || !support.noCloneChecked) &&
\r
5473 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
\r
5475 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
\r
5476 destElements = getAll( clone );
\r
5477 srcElements = getAll( elem );
\r
5479 // Fix all IE cloning issues
\r
5480 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
\r
5481 // Ensure that the destination node is not null; Fixes #9587
\r
5482 if ( destElements[i] ) {
\r
5483 fixCloneNodeIssues( node, destElements[i] );
\r
5488 // Copy the events from the original to the clone
\r
5489 if ( dataAndEvents ) {
\r
5490 if ( deepDataAndEvents ) {
\r
5491 srcElements = srcElements || getAll( elem );
\r
5492 destElements = destElements || getAll( clone );
\r
5494 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
\r
5495 cloneCopyEvent( node, destElements[i] );
\r
5498 cloneCopyEvent( elem, clone );
\r
5502 // Preserve script evaluation history
\r
5503 destElements = getAll( clone, "script" );
\r
5504 if ( destElements.length > 0 ) {
\r
5505 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
\r
5508 destElements = srcElements = node = null;
\r
5510 // Return the cloned set
\r
5514 buildFragment: function( elems, context, scripts, selection ) {
\r
5515 var j, elem, contains,
\r
5516 tmp, tag, tbody, wrap,
\r
5519 // Ensure a safe fragment
\r
5520 safe = createSafeFragment( context ),
\r
5525 for ( ; i < l; i++ ) {
\r
5526 elem = elems[ i ];
\r
5528 if ( elem || elem === 0 ) {
\r
5530 // Add nodes directly
\r
5531 if ( jQuery.type( elem ) === "object" ) {
\r
5532 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
\r
5534 // Convert non-html into a text node
\r
5535 } else if ( !rhtml.test( elem ) ) {
\r
5536 nodes.push( context.createTextNode( elem ) );
\r
5538 // Convert html into DOM nodes
\r
5540 tmp = tmp || safe.appendChild( context.createElement("div") );
\r
5542 // Deserialize a standard representation
\r
5543 tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
\r
5544 wrap = wrapMap[ tag ] || wrapMap._default;
\r
5546 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
\r
5548 // Descend through wrappers to the right content
\r
5551 tmp = tmp.lastChild;
\r
5554 // Manually add leading whitespace removed by IE
\r
5555 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
\r
5556 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
\r
5559 // Remove IE's autoinserted <tbody> from table fragments
\r
5560 if ( !support.tbody ) {
\r
5562 // String was a <table>, *may* have spurious <tbody>
\r
5563 elem = tag === "table" && !rtbody.test( elem ) ?
\r
5566 // String was a bare <thead> or <tfoot>
\r
5567 wrap[1] === "<table>" && !rtbody.test( elem ) ?
\r
5571 j = elem && elem.childNodes.length;
\r
5573 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
\r
5574 elem.removeChild( tbody );
\r
5579 jQuery.merge( nodes, tmp.childNodes );
\r
5581 // Fix #12392 for WebKit and IE > 9
\r
5582 tmp.textContent = "";
\r
5584 // Fix #12392 for oldIE
\r
5585 while ( tmp.firstChild ) {
\r
5586 tmp.removeChild( tmp.firstChild );
\r
5589 // Remember the top-level container for proper cleanup
\r
5590 tmp = safe.lastChild;
\r
5595 // Fix #11356: Clear elements from fragment
\r
5597 safe.removeChild( tmp );
\r
5600 // Reset defaultChecked for any radios and checkboxes
\r
5601 // about to be appended to the DOM in IE 6/7 (#8060)
\r
5602 if ( !support.appendChecked ) {
\r
5603 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
\r
5607 while ( (elem = nodes[ i++ ]) ) {
\r
5609 // #4087 - If origin and destination elements are the same, and this is
\r
5610 // that element, do not do anything
\r
5611 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
\r
5615 contains = jQuery.contains( elem.ownerDocument, elem );
\r
5617 // Append to fragment
\r
5618 tmp = getAll( safe.appendChild( elem ), "script" );
\r
5620 // Preserve script evaluation history
\r
5622 setGlobalEval( tmp );
\r
5625 // Capture executables
\r
5628 while ( (elem = tmp[ j++ ]) ) {
\r
5629 if ( rscriptType.test( elem.type || "" ) ) {
\r
5630 scripts.push( elem );
\r
5641 cleanData: function( elems, /* internal */ acceptData ) {
\r
5642 var elem, type, id, data,
\r
5644 internalKey = jQuery.expando,
\r
5645 cache = jQuery.cache,
\r
5646 deleteExpando = support.deleteExpando,
\r
5647 special = jQuery.event.special;
\r
5649 for ( ; (elem = elems[i]) != null; i++ ) {
\r
5650 if ( acceptData || jQuery.acceptData( elem ) ) {
\r
5652 id = elem[ internalKey ];
\r
5653 data = id && cache[ id ];
\r
5656 if ( data.events ) {
\r
5657 for ( type in data.events ) {
\r
5658 if ( special[ type ] ) {
\r
5659 jQuery.event.remove( elem, type );
\r
5661 // This is a shortcut to avoid jQuery.event.remove's overhead
\r
5663 jQuery.removeEvent( elem, type, data.handle );
\r
5668 // Remove cache only if it was not already removed by jQuery.event.remove
\r
5669 if ( cache[ id ] ) {
\r
5671 delete cache[ id ];
\r
5673 // IE does not allow us to delete expando properties from nodes,
\r
5674 // nor does it have a removeAttribute function on Document nodes;
\r
5675 // we must handle all of these cases
\r
5676 if ( deleteExpando ) {
\r
5677 delete elem[ internalKey ];
\r
5679 } else if ( typeof elem.removeAttribute !== strundefined ) {
\r
5680 elem.removeAttribute( internalKey );
\r
5683 elem[ internalKey ] = null;
\r
5686 deletedIds.push( id );
\r
5694 jQuery.fn.extend({
\r
5695 text: function( value ) {
\r
5696 return access( this, function( value ) {
\r
5697 return value === undefined ?
\r
5698 jQuery.text( this ) :
\r
5699 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
\r
5700 }, null, value, arguments.length );
\r
5703 append: function() {
\r
5704 return this.domManip( arguments, function( elem ) {
\r
5705 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
\r
5706 var target = manipulationTarget( this, elem );
\r
5707 target.appendChild( elem );
\r
5712 prepend: function() {
\r
5713 return this.domManip( arguments, function( elem ) {
\r
5714 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
\r
5715 var target = manipulationTarget( this, elem );
\r
5716 target.insertBefore( elem, target.firstChild );
\r
5721 before: function() {
\r
5722 return this.domManip( arguments, function( elem ) {
\r
5723 if ( this.parentNode ) {
\r
5724 this.parentNode.insertBefore( elem, this );
\r
5729 after: function() {
\r
5730 return this.domManip( arguments, function( elem ) {
\r
5731 if ( this.parentNode ) {
\r
5732 this.parentNode.insertBefore( elem, this.nextSibling );
\r
5737 remove: function( selector, keepData /* Internal Use Only */ ) {
\r
5739 elems = selector ? jQuery.filter( selector, this ) : this,
\r
5742 for ( ; (elem = elems[i]) != null; i++ ) {
\r
5744 if ( !keepData && elem.nodeType === 1 ) {
\r
5745 jQuery.cleanData( getAll( elem ) );
\r
5748 if ( elem.parentNode ) {
\r
5749 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
\r
5750 setGlobalEval( getAll( elem, "script" ) );
\r
5752 elem.parentNode.removeChild( elem );
\r
5759 empty: function() {
\r
5763 for ( ; (elem = this[i]) != null; i++ ) {
\r
5764 // Remove element nodes and prevent memory leaks
\r
5765 if ( elem.nodeType === 1 ) {
\r
5766 jQuery.cleanData( getAll( elem, false ) );
\r
5769 // Remove any remaining nodes
\r
5770 while ( elem.firstChild ) {
\r
5771 elem.removeChild( elem.firstChild );
\r
5774 // If this is a select, ensure that it displays empty (#12336)
\r
5776 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
\r
5777 elem.options.length = 0;
\r
5784 clone: function( dataAndEvents, deepDataAndEvents ) {
\r
5785 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
\r
5786 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
\r
5788 return this.map(function() {
\r
5789 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
\r
5793 html: function( value ) {
\r
5794 return access( this, function( value ) {
\r
5795 var elem = this[ 0 ] || {},
\r
5799 if ( value === undefined ) {
\r
5800 return elem.nodeType === 1 ?
\r
5801 elem.innerHTML.replace( rinlinejQuery, "" ) :
\r
5805 // See if we can take a shortcut and just use innerHTML
\r
5806 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
\r
5807 ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
\r
5808 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
\r
5809 !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
\r
5811 value = value.replace( rxhtmlTag, "<$1></$2>" );
\r
5814 for (; i < l; i++ ) {
\r
5815 // Remove element nodes and prevent memory leaks
\r
5816 elem = this[i] || {};
\r
5817 if ( elem.nodeType === 1 ) {
\r
5818 jQuery.cleanData( getAll( elem, false ) );
\r
5819 elem.innerHTML = value;
\r
5825 // If using innerHTML throws an exception, use the fallback method
\r
5830 this.empty().append( value );
\r
5832 }, null, value, arguments.length );
\r
5835 replaceWith: function() {
\r
5836 var arg = arguments[ 0 ];
\r
5838 // Make the changes, replacing each context element with the new content
\r
5839 this.domManip( arguments, function( elem ) {
\r
5840 arg = this.parentNode;
\r
5842 jQuery.cleanData( getAll( this ) );
\r
5845 arg.replaceChild( elem, this );
\r
5849 // Force removal if there was no new content (e.g., from empty arguments)
\r
5850 return arg && (arg.length || arg.nodeType) ? this : this.remove();
\r
5853 detach: function( selector ) {
\r
5854 return this.remove( selector, true );
\r
5857 domManip: function( args, callback ) {
\r
5859 // Flatten any nested arrays
\r
5860 args = concat.apply( [], args );
\r
5862 var first, node, hasScripts,
\r
5863 scripts, doc, fragment,
\r
5869 isFunction = jQuery.isFunction( value );
\r
5871 // We can't cloneNode fragments that contain checked, in WebKit
\r
5872 if ( isFunction ||
\r
5873 ( l > 1 && typeof value === "string" &&
\r
5874 !support.checkClone && rchecked.test( value ) ) ) {
\r
5875 return this.each(function( index ) {
\r
5876 var self = set.eq( index );
\r
5877 if ( isFunction ) {
\r
5878 args[0] = value.call( this, index, self.html() );
\r
5880 self.domManip( args, callback );
\r
5885 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
\r
5886 first = fragment.firstChild;
\r
5888 if ( fragment.childNodes.length === 1 ) {
\r
5893 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
\r
5894 hasScripts = scripts.length;
\r
5896 // Use the original fragment for the last item instead of the first because it can end up
\r
5897 // being emptied incorrectly in certain situations (#8070).
\r
5898 for ( ; i < l; i++ ) {
\r
5901 if ( i !== iNoClone ) {
\r
5902 node = jQuery.clone( node, true, true );
\r
5904 // Keep references to cloned scripts for later restoration
\r
5905 if ( hasScripts ) {
\r
5906 jQuery.merge( scripts, getAll( node, "script" ) );
\r
5910 callback.call( this[i], node, i );
\r
5913 if ( hasScripts ) {
\r
5914 doc = scripts[ scripts.length - 1 ].ownerDocument;
\r
5916 // Reenable scripts
\r
5917 jQuery.map( scripts, restoreScript );
\r
5919 // Evaluate executable scripts on first document insertion
\r
5920 for ( i = 0; i < hasScripts; i++ ) {
\r
5921 node = scripts[ i ];
\r
5922 if ( rscriptType.test( node.type || "" ) &&
\r
5923 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
\r
5926 // Optional AJAX dependency, but won't run scripts if not present
\r
5927 if ( jQuery._evalUrl ) {
\r
5928 jQuery._evalUrl( node.src );
\r
5931 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
\r
5937 // Fix #11809: Avoid leaking memory
\r
5938 fragment = first = null;
\r
5947 appendTo: "append",
\r
5948 prependTo: "prepend",
\r
5949 insertBefore: "before",
\r
5950 insertAfter: "after",
\r
5951 replaceAll: "replaceWith"
\r
5952 }, function( name, original ) {
\r
5953 jQuery.fn[ name ] = function( selector ) {
\r
5957 insert = jQuery( selector ),
\r
5958 last = insert.length - 1;
\r
5960 for ( ; i <= last; i++ ) {
\r
5961 elems = i === last ? this : this.clone(true);
\r
5962 jQuery( insert[i] )[ original ]( elems );
\r
5964 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
\r
5965 push.apply( ret, elems.get() );
\r
5968 return this.pushStack( ret );
\r
5977 * Retrieve the actual display of a element
\r
5978 * @param {String} name nodeName of the element
\r
5979 * @param {Object} doc Document object
\r
5981 // Called only from within defaultDisplay
\r
5982 function actualDisplay( name, doc ) {
\r
5983 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
\r
5985 // getDefaultComputedStyle might be reliably used only on attached element
\r
5986 display = window.getDefaultComputedStyle ?
\r
5988 // Use of this method is a temporary fix (more like optmization) until something better comes along,
\r
5989 // since it was removed from specification and supported only in FF
\r
5990 window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
\r
5992 // We don't have any data stored on the element,
\r
5993 // so use "detach" method as fast way to get rid of the element
\r
6000 * Try to determine the default display value of an element
\r
6001 * @param {String} nodeName
\r
6003 function defaultDisplay( nodeName ) {
\r
6004 var doc = document,
\r
6005 display = elemdisplay[ nodeName ];
\r
6008 display = actualDisplay( nodeName, doc );
\r
6010 // If the simple way fails, read from inside an iframe
\r
6011 if ( display === "none" || !display ) {
\r
6013 // Use the already-created iframe if possible
\r
6014 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
\r
6016 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
\r
6017 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
\r
6023 display = actualDisplay( nodeName, doc );
\r
6027 // Store the correct default display
\r
6028 elemdisplay[ nodeName ] = display;
\r
6036 var a, shrinkWrapBlocksVal,
\r
6037 div = document.createElement( "div" ),
\r
6039 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
\r
6040 "display:block;padding:0;margin:0;border:0";
\r
6043 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
6044 a = div.getElementsByTagName( "a" )[ 0 ];
\r
6046 a.style.cssText = "float:left;opacity:.5";
\r
6048 // Make sure that element opacity exists
\r
6049 // (IE uses filter instead)
\r
6050 // Use a regex to work around a WebKit issue. See #5145
\r
6051 support.opacity = /^0.5/.test( a.style.opacity );
\r
6053 // Verify style float existence
\r
6054 // (IE uses styleFloat instead of cssFloat)
\r
6055 support.cssFloat = !!a.style.cssFloat;
\r
6057 div.style.backgroundClip = "content-box";
\r
6058 div.cloneNode( true ).style.backgroundClip = "";
\r
6059 support.clearCloneStyle = div.style.backgroundClip === "content-box";
\r
6061 // Null elements to avoid leaks in IE.
\r
6064 support.shrinkWrapBlocks = function() {
\r
6065 var body, container, div, containerStyles;
\r
6067 if ( shrinkWrapBlocksVal == null ) {
\r
6068 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6070 // Test fired too early or in an unsupported environment, exit.
\r
6074 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px";
\r
6075 container = document.createElement( "div" );
\r
6076 div = document.createElement( "div" );
\r
6078 body.appendChild( container ).appendChild( div );
\r
6080 // Will be changed later if needed.
\r
6081 shrinkWrapBlocksVal = false;
\r
6083 if ( typeof div.style.zoom !== strundefined ) {
\r
6085 // Check if elements with layout shrink-wrap their children
\r
6086 div.style.cssText = divReset + ";width:1px;padding:1px;zoom:1";
\r
6087 div.innerHTML = "<div></div>";
\r
6088 div.firstChild.style.width = "5px";
\r
6089 shrinkWrapBlocksVal = div.offsetWidth !== 3;
\r
6092 body.removeChild( container );
\r
6094 // Null elements to avoid leaks in IE.
\r
6095 body = container = div = null;
\r
6098 return shrinkWrapBlocksVal;
\r
6102 var rmargin = (/^margin/);
\r
6104 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
\r
6108 var getStyles, curCSS,
\r
6109 rposition = /^(top|right|bottom|left)$/;
\r
6111 if ( window.getComputedStyle ) {
\r
6112 getStyles = function( elem ) {
\r
6113 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
\r
6116 curCSS = function( elem, name, computed ) {
\r
6117 var width, minWidth, maxWidth, ret,
\r
6118 style = elem.style;
\r
6120 computed = computed || getStyles( elem );
\r
6122 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
\r
6123 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
\r
6127 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
\r
6128 ret = jQuery.style( elem, name );
\r
6131 // A tribute to the "awesome hack by Dean Edwards"
\r
6132 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
\r
6133 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
\r
6134 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
\r
6135 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
\r
6137 // Remember the original values
\r
6138 width = style.width;
\r
6139 minWidth = style.minWidth;
\r
6140 maxWidth = style.maxWidth;
\r
6142 // Put in the new values to get a computed value out
\r
6143 style.minWidth = style.maxWidth = style.width = ret;
\r
6144 ret = computed.width;
\r
6146 // Revert the changed values
\r
6147 style.width = width;
\r
6148 style.minWidth = minWidth;
\r
6149 style.maxWidth = maxWidth;
\r
6154 // IE returns zIndex value as an integer.
\r
6155 return ret === undefined ?
\r
6159 } else if ( document.documentElement.currentStyle ) {
\r
6160 getStyles = function( elem ) {
\r
6161 return elem.currentStyle;
\r
6164 curCSS = function( elem, name, computed ) {
\r
6165 var left, rs, rsLeft, ret,
\r
6166 style = elem.style;
\r
6168 computed = computed || getStyles( elem );
\r
6169 ret = computed ? computed[ name ] : undefined;
\r
6171 // Avoid setting ret to empty string here
\r
6172 // so we don't default to auto
\r
6173 if ( ret == null && style && style[ name ] ) {
\r
6174 ret = style[ name ];
\r
6177 // From the awesome hack by Dean Edwards
\r
6178 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
\r
6180 // If we're not dealing with a regular pixel number
\r
6181 // but a number that has a weird ending, we need to convert it to pixels
\r
6182 // but not position css attributes, as those are proportional to the parent element instead
\r
6183 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
\r
6184 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
\r
6186 // Remember the original values
\r
6187 left = style.left;
\r
6188 rs = elem.runtimeStyle;
\r
6189 rsLeft = rs && rs.left;
\r
6191 // Put in the new values to get a computed value out
\r
6193 rs.left = elem.currentStyle.left;
\r
6195 style.left = name === "fontSize" ? "1em" : ret;
\r
6196 ret = style.pixelLeft + "px";
\r
6198 // Revert the changed values
\r
6199 style.left = left;
\r
6206 // IE returns zIndex value as an integer.
\r
6207 return ret === undefined ?
\r
6209 ret + "" || "auto";
\r
6216 function addGetHookIf( conditionFn, hookFn ) {
\r
6217 // Define the hook, we'll check on the first run if it's really needed.
\r
6220 var condition = conditionFn();
\r
6222 if ( condition == null ) {
\r
6223 // The test was not ready at this point; screw the hook this time
\r
6224 // but check again when needed next time.
\r
6228 if ( condition ) {
\r
6229 // Hook not needed (or it's not possible to use it due to missing dependency),
\r
6231 // Since there are no other hooks for marginRight, remove the whole object.
\r
6236 // Hook needed; redefine it so that the support test is not executed again.
\r
6238 return (this.get = hookFn).apply( this, arguments );
\r
6245 var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal,
\r
6246 pixelPositionVal, reliableMarginRightVal,
\r
6247 div = document.createElement( "div" ),
\r
6248 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px",
\r
6250 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
\r
6251 "display:block;padding:0;margin:0;border:0";
\r
6254 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
6255 a = div.getElementsByTagName( "a" )[ 0 ];
\r
6257 a.style.cssText = "float:left;opacity:.5";
\r
6259 // Make sure that element opacity exists
\r
6260 // (IE uses filter instead)
\r
6261 // Use a regex to work around a WebKit issue. See #5145
\r
6262 support.opacity = /^0.5/.test( a.style.opacity );
\r
6264 // Verify style float existence
\r
6265 // (IE uses styleFloat instead of cssFloat)
\r
6266 support.cssFloat = !!a.style.cssFloat;
\r
6268 div.style.backgroundClip = "content-box";
\r
6269 div.cloneNode( true ).style.backgroundClip = "";
\r
6270 support.clearCloneStyle = div.style.backgroundClip === "content-box";
\r
6272 // Null elements to avoid leaks in IE.
\r
6275 jQuery.extend(support, {
\r
6276 reliableHiddenOffsets: function() {
\r
6277 if ( reliableHiddenOffsetsVal != null ) {
\r
6278 return reliableHiddenOffsetsVal;
\r
6281 var container, tds, isSupported,
\r
6282 div = document.createElement( "div" ),
\r
6283 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6286 // Return for frameset docs that don't have a body
\r
6291 div.setAttribute( "className", "t" );
\r
6292 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
6294 container = document.createElement( "div" );
\r
6295 container.style.cssText = containerStyles;
\r
6297 body.appendChild( container ).appendChild( div );
\r
6300 // Check if table cells still have offsetWidth/Height when they are set
\r
6301 // to display:none and there are still other visible table cells in a
\r
6302 // table row; if so, offsetWidth/Height are not reliable for use when
\r
6303 // determining if an element has been hidden directly using
\r
6304 // display:none (it is still safe to use offsets if a parent element is
\r
6305 // hidden; don safety goggles and see bug #4512 for more information).
\r
6306 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
\r
6307 tds = div.getElementsByTagName( "td" );
\r
6308 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
\r
6309 isSupported = ( tds[ 0 ].offsetHeight === 0 );
\r
6311 tds[ 0 ].style.display = "";
\r
6312 tds[ 1 ].style.display = "none";
\r
6315 // Check if empty table cells still have offsetWidth/Height
\r
6316 reliableHiddenOffsetsVal = isSupported && ( tds[ 0 ].offsetHeight === 0 );
\r
6318 body.removeChild( container );
\r
6320 // Null elements to avoid leaks in IE.
\r
6321 div = body = null;
\r
6323 return reliableHiddenOffsetsVal;
\r
6326 boxSizing: function() {
\r
6327 if ( boxSizingVal == null ) {
\r
6328 computeStyleTests();
\r
6330 return boxSizingVal;
\r
6333 boxSizingReliable: function() {
\r
6334 if ( boxSizingReliableVal == null ) {
\r
6335 computeStyleTests();
\r
6337 return boxSizingReliableVal;
\r
6340 pixelPosition: function() {
\r
6341 if ( pixelPositionVal == null ) {
\r
6342 computeStyleTests();
\r
6344 return pixelPositionVal;
\r
6347 reliableMarginRight: function() {
\r
6348 var body, container, div, marginDiv;
\r
6350 // Use window.getComputedStyle because jsdom on node.js will break without it.
\r
6351 if ( reliableMarginRightVal == null && window.getComputedStyle ) {
\r
6352 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6354 // Test fired too early or in an unsupported environment, exit.
\r
6358 container = document.createElement( "div" );
\r
6359 div = document.createElement( "div" );
\r
6360 container.style.cssText = containerStyles;
\r
6362 body.appendChild( container ).appendChild( div );
\r
6364 // Check if div with explicit width and no margin-right incorrectly
\r
6365 // gets computed margin-right based on width of container. (#3333)
\r
6366 // Fails in WebKit before Feb 2011 nightlies
\r
6367 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
\r
6368 marginDiv = div.appendChild( document.createElement( "div" ) );
\r
6369 marginDiv.style.cssText = div.style.cssText = divReset;
\r
6370 marginDiv.style.marginRight = marginDiv.style.width = "0";
\r
6371 div.style.width = "1px";
\r
6373 reliableMarginRightVal =
\r
6374 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
\r
6376 body.removeChild( container );
\r
6379 return reliableMarginRightVal;
\r
6383 function computeStyleTests() {
\r
6384 var container, div,
\r
6385 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6388 // Test fired too early or in an unsupported environment, exit.
\r
6392 container = document.createElement( "div" );
\r
6393 div = document.createElement( "div" );
\r
6394 container.style.cssText = containerStyles;
\r
6396 body.appendChild( container ).appendChild( div );
\r
6398 div.style.cssText =
\r
6399 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
\r
6400 "position:absolute;display:block;padding:1px;border:1px;width:4px;" +
\r
6401 "margin-top:1%;top:1%";
\r
6403 // Workaround failing boxSizing test due to offsetWidth returning wrong value
\r
6404 // with some non-1 values of body zoom, ticket #13543
\r
6405 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
\r
6406 boxSizingVal = div.offsetWidth === 4;
\r
6409 // Will be changed later if needed.
\r
6410 boxSizingReliableVal = true;
\r
6411 pixelPositionVal = false;
\r
6412 reliableMarginRightVal = true;
\r
6414 // Use window.getComputedStyle because jsdom on node.js will break without it.
\r
6415 if ( window.getComputedStyle ) {
\r
6416 pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
\r
6417 boxSizingReliableVal =
\r
6418 ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
\r
6421 body.removeChild( container );
\r
6423 // Null elements to avoid leaks in IE.
\r
6424 div = body = null;
\r
6430 // A method for quickly swapping in/out CSS properties to get correct calculations.
\r
6431 jQuery.swap = function( elem, options, callback, args ) {
\r
6435 // Remember the old values, and insert the new ones
\r
6436 for ( name in options ) {
\r
6437 old[ name ] = elem.style[ name ];
\r
6438 elem.style[ name ] = options[ name ];
\r
6441 ret = callback.apply( elem, args || [] );
\r
6443 // Revert the old values
\r
6444 for ( name in options ) {
\r
6445 elem.style[ name ] = old[ name ];
\r
6453 ralpha = /alpha\([^)]*\)/i,
\r
6454 ropacity = /opacity\s*=\s*([^)]*)/,
\r
6456 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
\r
6457 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
\r
6458 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
\r
6459 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
\r
6460 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
\r
6462 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
\r
6463 cssNormalTransform = {
\r
6468 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
\r
6471 // return a css property mapped to a potentially vendor prefixed property
\r
6472 function vendorPropName( style, name ) {
\r
6474 // shortcut for names that are not vendor prefixed
\r
6475 if ( name in style ) {
\r
6479 // check for vendor prefixed names
\r
6480 var capName = name.charAt(0).toUpperCase() + name.slice(1),
\r
6482 i = cssPrefixes.length;
\r
6485 name = cssPrefixes[ i ] + capName;
\r
6486 if ( name in style ) {
\r
6494 function showHide( elements, show ) {
\r
6495 var display, elem, hidden,
\r
6498 length = elements.length;
\r
6500 for ( ; index < length; index++ ) {
\r
6501 elem = elements[ index ];
\r
6502 if ( !elem.style ) {
\r
6506 values[ index ] = jQuery._data( elem, "olddisplay" );
\r
6507 display = elem.style.display;
\r
6509 // Reset the inline display of this element to learn if it is
\r
6510 // being hidden by cascaded rules or not
\r
6511 if ( !values[ index ] && display === "none" ) {
\r
6512 elem.style.display = "";
\r
6515 // Set elements which have been overridden with display: none
\r
6516 // in a stylesheet to whatever the default browser style is
\r
6517 // for such an element
\r
6518 if ( elem.style.display === "" && isHidden( elem ) ) {
\r
6519 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
\r
6523 if ( !values[ index ] ) {
\r
6524 hidden = isHidden( elem );
\r
6526 if ( display && display !== "none" || !hidden ) {
\r
6527 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
\r
6533 // Set the display of most of the elements in a second loop
\r
6534 // to avoid the constant reflow
\r
6535 for ( index = 0; index < length; index++ ) {
\r
6536 elem = elements[ index ];
\r
6537 if ( !elem.style ) {
\r
6540 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
\r
6541 elem.style.display = show ? values[ index ] || "" : "none";
\r
6548 function setPositiveNumber( elem, value, subtract ) {
\r
6549 var matches = rnumsplit.exec( value );
\r
6551 // Guard against undefined "subtract", e.g., when used as in cssHooks
\r
6552 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
\r
6556 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
\r
6557 var i = extra === ( isBorderBox ? "border" : "content" ) ?
\r
6558 // If we already have the right measurement, avoid augmentation
\r
6560 // Otherwise initialize for horizontal or vertical properties
\r
6561 name === "width" ? 1 : 0,
\r
6565 for ( ; i < 4; i += 2 ) {
\r
6566 // both box models exclude margin, so add it if we want it
\r
6567 if ( extra === "margin" ) {
\r
6568 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
\r
6571 if ( isBorderBox ) {
\r
6572 // border-box includes padding, so remove it if we want content
\r
6573 if ( extra === "content" ) {
\r
6574 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
\r
6577 // at this point, extra isn't border nor margin, so remove border
\r
6578 if ( extra !== "margin" ) {
\r
6579 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
\r
6582 // at this point, extra isn't content, so add padding
\r
6583 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
\r
6585 // at this point, extra isn't content nor padding, so add border
\r
6586 if ( extra !== "padding" ) {
\r
6587 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
\r
6595 function getWidthOrHeight( elem, name, extra ) {
\r
6597 // Start with offset property, which is equivalent to the border-box value
\r
6598 var valueIsBorderBox = true,
\r
6599 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
\r
6600 styles = getStyles( elem ),
\r
6601 isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
\r
6603 // some non-html elements return undefined for offsetWidth, so check for null/undefined
\r
6604 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
\r
6605 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
\r
6606 if ( val <= 0 || val == null ) {
\r
6607 // Fall back to computed then uncomputed css if necessary
\r
6608 val = curCSS( elem, name, styles );
\r
6609 if ( val < 0 || val == null ) {
\r
6610 val = elem.style[ name ];
\r
6613 // Computed unit is not pixels. Stop here and return.
\r
6614 if ( rnumnonpx.test(val) ) {
\r
6618 // we need the check for style in case a browser which returns unreliable values
\r
6619 // for getComputedStyle silently falls back to the reliable elem.style
\r
6620 valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
\r
6622 // Normalize "", auto, and prepare for extra
\r
6623 val = parseFloat( val ) || 0;
\r
6626 // use the active box-sizing model to add/subtract irrelevant styles
\r
6628 augmentWidthOrHeight(
\r
6631 extra || ( isBorderBox ? "border" : "content" ),
\r
6639 // Add in style property hooks for overriding the default
\r
6640 // behavior of getting and setting a style property
\r
6643 get: function( elem, computed ) {
\r
6645 // We should always get a number back from opacity
\r
6646 var ret = curCSS( elem, "opacity" );
\r
6647 return ret === "" ? "1" : ret;
\r
6653 // Don't automatically add "px" to these possibly-unitless properties
\r
6655 "columnCount": true,
\r
6656 "fillOpacity": true,
\r
6657 "fontWeight": true,
\r
6658 "lineHeight": true,
\r
6667 // Add in properties whose names you wish to fix before
\r
6668 // setting or getting the value
\r
6670 // normalize float css property
\r
6671 "float": support.cssFloat ? "cssFloat" : "styleFloat"
\r
6674 // Get and set the style property on a DOM Node
\r
6675 style: function( elem, name, value, extra ) {
\r
6676 // Don't set styles on text and comment nodes
\r
6677 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
\r
6681 // Make sure that we're working with the right name
\r
6682 var ret, type, hooks,
\r
6683 origName = jQuery.camelCase( name ),
\r
6684 style = elem.style;
\r
6686 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
\r
6688 // gets hook for the prefixed version
\r
6689 // followed by the unprefixed version
\r
6690 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
\r
6692 // Check if we're setting a value
\r
6693 if ( value !== undefined ) {
\r
6694 type = typeof value;
\r
6696 // convert relative number strings (+= or -=) to relative numbers. #7345
\r
6697 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
\r
6698 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
\r
6699 // Fixes bug #9237
\r
6703 // Make sure that null and NaN values aren't set. See: #7116
\r
6704 if ( value == null || value !== value ) {
\r
6708 // If a number was passed in, add 'px' to the (except for certain CSS properties)
\r
6709 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
\r
6713 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
\r
6714 // but it would mean to define eight (for every problematic property) identical functions
\r
6715 if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
\r
6716 style[ name ] = "inherit";
\r
6719 // If a hook was provided, use that value, otherwise just set the specified value
\r
6720 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
\r
6723 // Swallow errors from 'invalid' CSS values (#5509)
\r
6725 // Support: Chrome, Safari
\r
6726 // Setting style to blank string required to delete "style: x !important;"
\r
6727 style[ name ] = "";
\r
6728 style[ name ] = value;
\r
6733 // If a hook was provided get the non-computed value from there
\r
6734 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
\r
6738 // Otherwise just get the value from the style object
\r
6739 return style[ name ];
\r
6743 css: function( elem, name, extra, styles ) {
\r
6744 var num, val, hooks,
\r
6745 origName = jQuery.camelCase( name );
\r
6747 // Make sure that we're working with the right name
\r
6748 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
\r
6750 // gets hook for the prefixed version
\r
6751 // followed by the unprefixed version
\r
6752 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
\r
6754 // If a hook was provided get the computed value from there
\r
6755 if ( hooks && "get" in hooks ) {
\r
6756 val = hooks.get( elem, true, extra );
\r
6759 // Otherwise, if a way to get the computed value exists, use that
\r
6760 if ( val === undefined ) {
\r
6761 val = curCSS( elem, name, styles );
\r
6764 //convert "normal" to computed value
\r
6765 if ( val === "normal" && name in cssNormalTransform ) {
\r
6766 val = cssNormalTransform[ name ];
\r
6769 // Return, converting to number if forced or a qualifier was provided and val looks numeric
\r
6770 if ( extra === "" || extra ) {
\r
6771 num = parseFloat( val );
\r
6772 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
\r
6778 jQuery.each([ "height", "width" ], function( i, name ) {
\r
6779 jQuery.cssHooks[ name ] = {
\r
6780 get: function( elem, computed, extra ) {
\r
6782 // certain elements can have dimension info if we invisibly show them
\r
6783 // however, it must have a current display style that would benefit from this
\r
6784 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
\r
6785 jQuery.swap( elem, cssShow, function() {
\r
6786 return getWidthOrHeight( elem, name, extra );
\r
6788 getWidthOrHeight( elem, name, extra );
\r
6792 set: function( elem, value, extra ) {
\r
6793 var styles = extra && getStyles( elem );
\r
6794 return setPositiveNumber( elem, value, extra ?
\r
6795 augmentWidthOrHeight(
\r
6799 support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
\r
6807 if ( !support.opacity ) {
\r
6808 jQuery.cssHooks.opacity = {
\r
6809 get: function( elem, computed ) {
\r
6810 // IE uses filters for opacity
\r
6811 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
\r
6812 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
\r
6813 computed ? "1" : "";
\r
6816 set: function( elem, value ) {
\r
6817 var style = elem.style,
\r
6818 currentStyle = elem.currentStyle,
\r
6819 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
\r
6820 filter = currentStyle && currentStyle.filter || style.filter || "";
\r
6822 // IE has trouble with opacity if it does not have layout
\r
6823 // Force it by setting the zoom level
\r
6826 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
\r
6827 // if value === "", then remove inline opacity #12685
\r
6828 if ( ( value >= 1 || value === "" ) &&
\r
6829 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
\r
6830 style.removeAttribute ) {
\r
6832 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
\r
6833 // if "filter:" is present at all, clearType is disabled, we want to avoid this
\r
6834 // style.removeAttribute is IE Only, but so apparently is this code path...
\r
6835 style.removeAttribute( "filter" );
\r
6837 // if there is no filter style applied in a css rule or unset inline opacity, we are done
\r
6838 if ( value === "" || currentStyle && !currentStyle.filter ) {
\r
6843 // otherwise, set new filter values
\r
6844 style.filter = ralpha.test( filter ) ?
\r
6845 filter.replace( ralpha, opacity ) :
\r
6846 filter + " " + opacity;
\r
6851 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
\r
6852 function( elem, computed ) {
\r
6854 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
\r
6855 // Work around by temporarily setting element display to inline-block
\r
6856 return jQuery.swap( elem, { "display": "inline-block" },
\r
6857 curCSS, [ elem, "marginRight" ] );
\r
6862 // These hooks are used by animate to expand properties
\r
6867 }, function( prefix, suffix ) {
\r
6868 jQuery.cssHooks[ prefix + suffix ] = {
\r
6869 expand: function( value ) {
\r
6873 // assumes a single number if not a string
\r
6874 parts = typeof value === "string" ? value.split(" ") : [ value ];
\r
6876 for ( ; i < 4; i++ ) {
\r
6877 expanded[ prefix + cssExpand[ i ] + suffix ] =
\r
6878 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
\r
6885 if ( !rmargin.test( prefix ) ) {
\r
6886 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
\r
6890 jQuery.fn.extend({
\r
6891 css: function( name, value ) {
\r
6892 return access( this, function( elem, name, value ) {
\r
6897 if ( jQuery.isArray( name ) ) {
\r
6898 styles = getStyles( elem );
\r
6899 len = name.length;
\r
6901 for ( ; i < len; i++ ) {
\r
6902 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
\r
6908 return value !== undefined ?
\r
6909 jQuery.style( elem, name, value ) :
\r
6910 jQuery.css( elem, name );
\r
6911 }, name, value, arguments.length > 1 );
\r
6913 show: function() {
\r
6914 return showHide( this, true );
\r
6916 hide: function() {
\r
6917 return showHide( this );
\r
6919 toggle: function( state ) {
\r
6920 if ( typeof state === "boolean" ) {
\r
6921 return state ? this.show() : this.hide();
\r
6924 return this.each(function() {
\r
6925 if ( isHidden( this ) ) {
\r
6926 jQuery( this ).show();
\r
6928 jQuery( this ).hide();
\r
6935 function Tween( elem, options, prop, end, easing ) {
\r
6936 return new Tween.prototype.init( elem, options, prop, end, easing );
\r
6938 jQuery.Tween = Tween;
\r
6940 Tween.prototype = {
\r
6941 constructor: Tween,
\r
6942 init: function( elem, options, prop, end, easing, unit ) {
\r
6945 this.easing = easing || "swing";
\r
6946 this.options = options;
\r
6947 this.start = this.now = this.cur();
\r
6949 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
\r
6952 var hooks = Tween.propHooks[ this.prop ];
\r
6954 return hooks && hooks.get ?
\r
6955 hooks.get( this ) :
\r
6956 Tween.propHooks._default.get( this );
\r
6958 run: function( percent ) {
\r
6960 hooks = Tween.propHooks[ this.prop ];
\r
6962 if ( this.options.duration ) {
\r
6963 this.pos = eased = jQuery.easing[ this.easing ](
\r
6964 percent, this.options.duration * percent, 0, 1, this.options.duration
\r
6967 this.pos = eased = percent;
\r
6969 this.now = ( this.end - this.start ) * eased + this.start;
\r
6971 if ( this.options.step ) {
\r
6972 this.options.step.call( this.elem, this.now, this );
\r
6975 if ( hooks && hooks.set ) {
\r
6976 hooks.set( this );
\r
6978 Tween.propHooks._default.set( this );
\r
6984 Tween.prototype.init.prototype = Tween.prototype;
\r
6986 Tween.propHooks = {
\r
6988 get: function( tween ) {
\r
6991 if ( tween.elem[ tween.prop ] != null &&
\r
6992 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
\r
6993 return tween.elem[ tween.prop ];
\r
6996 // passing an empty string as a 3rd parameter to .css will automatically
\r
6997 // attempt a parseFloat and fallback to a string if the parse fails
\r
6998 // so, simple values such as "10px" are parsed to Float.
\r
6999 // complex values such as "rotate(1rad)" are returned as is.
\r
7000 result = jQuery.css( tween.elem, tween.prop, "" );
\r
7001 // Empty strings, null, undefined and "auto" are converted to 0.
\r
7002 return !result || result === "auto" ? 0 : result;
\r
7004 set: function( tween ) {
\r
7005 // use step hook for back compat - use cssHook if its there - use .style if its
\r
7006 // available and use plain properties where available
\r
7007 if ( jQuery.fx.step[ tween.prop ] ) {
\r
7008 jQuery.fx.step[ tween.prop ]( tween );
\r
7009 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
\r
7010 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
\r
7012 tween.elem[ tween.prop ] = tween.now;
\r
7018 // Support: IE <=9
\r
7019 // Panic based approach to setting things on disconnected nodes
\r
7021 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
\r
7022 set: function( tween ) {
\r
7023 if ( tween.elem.nodeType && tween.elem.parentNode ) {
\r
7024 tween.elem[ tween.prop ] = tween.now;
\r
7030 linear: function( p ) {
\r
7033 swing: function( p ) {
\r
7034 return 0.5 - Math.cos( p * Math.PI ) / 2;
\r
7038 jQuery.fx = Tween.prototype.init;
\r
7040 // Back Compat <1.8 extension point
\r
7041 jQuery.fx.step = {};
\r
7048 rfxtypes = /^(?:toggle|show|hide)$/,
\r
7049 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
\r
7050 rrun = /queueHooks$/,
\r
7051 animationPrefilters = [ defaultPrefilter ],
\r
7053 "*": [ function( prop, value ) {
\r
7054 var tween = this.createTween( prop, value ),
\r
7055 target = tween.cur(),
\r
7056 parts = rfxnum.exec( value ),
\r
7057 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
\r
7059 // Starting value computation is required for potential unit mismatches
\r
7060 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
\r
7061 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
\r
7063 maxIterations = 20;
\r
7065 if ( start && start[ 3 ] !== unit ) {
\r
7066 // Trust units reported by jQuery.css
\r
7067 unit = unit || start[ 3 ];
\r
7069 // Make sure we update the tween properties later on
\r
7070 parts = parts || [];
\r
7072 // Iteratively approximate from a nonzero starting point
\r
7073 start = +target || 1;
\r
7076 // If previous iteration zeroed out, double until we get *something*
\r
7077 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
\r
7078 scale = scale || ".5";
\r
7080 // Adjust and apply
\r
7081 start = start / scale;
\r
7082 jQuery.style( tween.elem, prop, start + unit );
\r
7084 // Update scale, tolerating zero or NaN from tween.cur()
\r
7085 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
\r
7086 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
\r
7089 // Update tween properties
\r
7091 start = tween.start = +start || +target || 0;
\r
7092 tween.unit = unit;
\r
7093 // If a +=/-= token was provided, we're doing a relative animation
\r
7094 tween.end = parts[ 1 ] ?
\r
7095 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
\r
7103 // Animations created synchronously will run synchronously
\r
7104 function createFxNow() {
\r
7105 setTimeout(function() {
\r
7106 fxNow = undefined;
\r
7108 return ( fxNow = jQuery.now() );
\r
7111 // Generate parameters to create a standard animation
\r
7112 function genFx( type, includeWidth ) {
\r
7114 attrs = { height: type },
\r
7117 // if we include width, step value is 1 to do all cssExpand values,
\r
7118 // if we don't include width, step value is 2 to skip over Left and Right
\r
7119 includeWidth = includeWidth ? 1 : 0;
\r
7120 for ( ; i < 4 ; i += 2 - includeWidth ) {
\r
7121 which = cssExpand[ i ];
\r
7122 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
\r
7125 if ( includeWidth ) {
\r
7126 attrs.opacity = attrs.width = type;
\r
7132 function createTween( value, prop, animation ) {
\r
7134 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
\r
7136 length = collection.length;
\r
7137 for ( ; index < length; index++ ) {
\r
7138 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
\r
7140 // we're done with this property
\r
7146 function defaultPrefilter( elem, props, opts ) {
\r
7147 /* jshint validthis: true */
\r
7148 var prop, value, toggle, tween, hooks, oldfire, display, dDisplay,
\r
7151 style = elem.style,
\r
7152 hidden = elem.nodeType && isHidden( elem ),
\r
7153 dataShow = jQuery._data( elem, "fxshow" );
\r
7155 // handle queue: false promises
\r
7156 if ( !opts.queue ) {
\r
7157 hooks = jQuery._queueHooks( elem, "fx" );
\r
7158 if ( hooks.unqueued == null ) {
\r
7159 hooks.unqueued = 0;
\r
7160 oldfire = hooks.empty.fire;
\r
7161 hooks.empty.fire = function() {
\r
7162 if ( !hooks.unqueued ) {
\r
7169 anim.always(function() {
\r
7170 // doing this makes sure that the complete handler will be called
\r
7171 // before this completes
\r
7172 anim.always(function() {
\r
7174 if ( !jQuery.queue( elem, "fx" ).length ) {
\r
7175 hooks.empty.fire();
\r
7181 // height/width overflow pass
\r
7182 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
\r
7183 // Make sure that nothing sneaks out
\r
7184 // Record all 3 overflow attributes because IE does not
\r
7185 // change the overflow attribute when overflowX and
\r
7186 // overflowY are set to the same value
\r
7187 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
\r
7189 // Set display property to inline-block for height/width
\r
7190 // animations on inline elements that are having width/height animated
\r
7191 display = jQuery.css( elem, "display" );
\r
7192 dDisplay = defaultDisplay( elem.nodeName );
\r
7193 if ( display === "none" ) {
\r
7194 display = dDisplay;
\r
7196 if ( display === "inline" &&
\r
7197 jQuery.css( elem, "float" ) === "none" ) {
\r
7199 // inline-level elements accept inline-block;
\r
7200 // block-level elements need to be inline with layout
\r
7201 if ( !support.inlineBlockNeedsLayout || dDisplay === "inline" ) {
\r
7202 style.display = "inline-block";
\r
7209 if ( opts.overflow ) {
\r
7210 style.overflow = "hidden";
\r
7211 if ( !support.shrinkWrapBlocks() ) {
\r
7212 anim.always(function() {
\r
7213 style.overflow = opts.overflow[ 0 ];
\r
7214 style.overflowX = opts.overflow[ 1 ];
\r
7215 style.overflowY = opts.overflow[ 2 ];
\r
7221 for ( prop in props ) {
\r
7222 value = props[ prop ];
\r
7223 if ( rfxtypes.exec( value ) ) {
\r
7224 delete props[ prop ];
\r
7225 toggle = toggle || value === "toggle";
\r
7226 if ( value === ( hidden ? "hide" : "show" ) ) {
\r
7228 // 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
\r
7229 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
\r
7235 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
\r
7239 if ( !jQuery.isEmptyObject( orig ) ) {
\r
7241 if ( "hidden" in dataShow ) {
\r
7242 hidden = dataShow.hidden;
\r
7245 dataShow = jQuery._data( elem, "fxshow", {} );
\r
7248 // store state if its toggle - enables .stop().toggle() to "reverse"
\r
7250 dataShow.hidden = !hidden;
\r
7253 jQuery( elem ).show();
\r
7255 anim.done(function() {
\r
7256 jQuery( elem ).hide();
\r
7259 anim.done(function() {
\r
7261 jQuery._removeData( elem, "fxshow" );
\r
7262 for ( prop in orig ) {
\r
7263 jQuery.style( elem, prop, orig[ prop ] );
\r
7266 for ( prop in orig ) {
\r
7267 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
\r
7269 if ( !( prop in dataShow ) ) {
\r
7270 dataShow[ prop ] = tween.start;
\r
7272 tween.end = tween.start;
\r
7273 tween.start = prop === "width" || prop === "height" ? 1 : 0;
\r
7280 function propFilter( props, specialEasing ) {
\r
7281 var index, name, easing, value, hooks;
\r
7283 // camelCase, specialEasing and expand cssHook pass
\r
7284 for ( index in props ) {
\r
7285 name = jQuery.camelCase( index );
\r
7286 easing = specialEasing[ name ];
\r
7287 value = props[ index ];
\r
7288 if ( jQuery.isArray( value ) ) {
\r
7289 easing = value[ 1 ];
\r
7290 value = props[ index ] = value[ 0 ];
\r
7293 if ( index !== name ) {
\r
7294 props[ name ] = value;
\r
7295 delete props[ index ];
\r
7298 hooks = jQuery.cssHooks[ name ];
\r
7299 if ( hooks && "expand" in hooks ) {
\r
7300 value = hooks.expand( value );
\r
7301 delete props[ name ];
\r
7303 // not quite $.extend, this wont overwrite keys already present.
\r
7304 // also - reusing 'index' from above because we have the correct "name"
\r
7305 for ( index in value ) {
\r
7306 if ( !( index in props ) ) {
\r
7307 props[ index ] = value[ index ];
\r
7308 specialEasing[ index ] = easing;
\r
7312 specialEasing[ name ] = easing;
\r
7317 function Animation( elem, properties, options ) {
\r
7321 length = animationPrefilters.length,
\r
7322 deferred = jQuery.Deferred().always( function() {
\r
7323 // don't match elem in the :animated selector
\r
7326 tick = function() {
\r
7330 var currentTime = fxNow || createFxNow(),
\r
7331 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
\r
7332 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
\r
7333 temp = remaining / animation.duration || 0,
\r
7334 percent = 1 - temp,
\r
7336 length = animation.tweens.length;
\r
7338 for ( ; index < length ; index++ ) {
\r
7339 animation.tweens[ index ].run( percent );
\r
7342 deferred.notifyWith( elem, [ animation, percent, remaining ]);
\r
7344 if ( percent < 1 && length ) {
\r
7347 deferred.resolveWith( elem, [ animation ] );
\r
7351 animation = deferred.promise({
\r
7353 props: jQuery.extend( {}, properties ),
\r
7354 opts: jQuery.extend( true, { specialEasing: {} }, options ),
\r
7355 originalProperties: properties,
\r
7356 originalOptions: options,
\r
7357 startTime: fxNow || createFxNow(),
\r
7358 duration: options.duration,
\r
7360 createTween: function( prop, end ) {
\r
7361 var tween = jQuery.Tween( elem, animation.opts, prop, end,
\r
7362 animation.opts.specialEasing[ prop ] || animation.opts.easing );
\r
7363 animation.tweens.push( tween );
\r
7366 stop: function( gotoEnd ) {
\r
7368 // if we are going to the end, we want to run all the tweens
\r
7369 // otherwise we skip this part
\r
7370 length = gotoEnd ? animation.tweens.length : 0;
\r
7375 for ( ; index < length ; index++ ) {
\r
7376 animation.tweens[ index ].run( 1 );
\r
7379 // resolve when we played the last frame
\r
7380 // otherwise, reject
\r
7382 deferred.resolveWith( elem, [ animation, gotoEnd ] );
\r
7384 deferred.rejectWith( elem, [ animation, gotoEnd ] );
\r
7389 props = animation.props;
\r
7391 propFilter( props, animation.opts.specialEasing );
\r
7393 for ( ; index < length ; index++ ) {
\r
7394 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
\r
7400 jQuery.map( props, createTween, animation );
\r
7402 if ( jQuery.isFunction( animation.opts.start ) ) {
\r
7403 animation.opts.start.call( elem, animation );
\r
7407 jQuery.extend( tick, {
\r
7410 queue: animation.opts.queue
\r
7414 // attach callbacks from options
\r
7415 return animation.progress( animation.opts.progress )
\r
7416 .done( animation.opts.done, animation.opts.complete )
\r
7417 .fail( animation.opts.fail )
\r
7418 .always( animation.opts.always );
\r
7421 jQuery.Animation = jQuery.extend( Animation, {
\r
7422 tweener: function( props, callback ) {
\r
7423 if ( jQuery.isFunction( props ) ) {
\r
7427 props = props.split(" ");
\r
7432 length = props.length;
\r
7434 for ( ; index < length ; index++ ) {
\r
7435 prop = props[ index ];
\r
7436 tweeners[ prop ] = tweeners[ prop ] || [];
\r
7437 tweeners[ prop ].unshift( callback );
\r
7441 prefilter: function( callback, prepend ) {
\r
7443 animationPrefilters.unshift( callback );
\r
7445 animationPrefilters.push( callback );
\r
7450 jQuery.speed = function( speed, easing, fn ) {
\r
7451 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
\r
7452 complete: fn || !fn && easing ||
\r
7453 jQuery.isFunction( speed ) && speed,
\r
7455 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
\r
7458 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
\r
7459 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
\r
7461 // normalize opt.queue - true/undefined/null -> "fx"
\r
7462 if ( opt.queue == null || opt.queue === true ) {
\r
7467 opt.old = opt.complete;
\r
7469 opt.complete = function() {
\r
7470 if ( jQuery.isFunction( opt.old ) ) {
\r
7471 opt.old.call( this );
\r
7474 if ( opt.queue ) {
\r
7475 jQuery.dequeue( this, opt.queue );
\r
7482 jQuery.fn.extend({
\r
7483 fadeTo: function( speed, to, easing, callback ) {
\r
7485 // show any hidden elements after setting opacity to 0
\r
7486 return this.filter( isHidden ).css( "opacity", 0 ).show()
\r
7488 // animate to the value specified
\r
7489 .end().animate({ opacity: to }, speed, easing, callback );
\r
7491 animate: function( prop, speed, easing, callback ) {
\r
7492 var empty = jQuery.isEmptyObject( prop ),
\r
7493 optall = jQuery.speed( speed, easing, callback ),
\r
7494 doAnimation = function() {
\r
7495 // Operate on a copy of prop so per-property easing won't be lost
\r
7496 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
\r
7498 // Empty animations, or finishing resolves immediately
\r
7499 if ( empty || jQuery._data( this, "finish" ) ) {
\r
7500 anim.stop( true );
\r
7503 doAnimation.finish = doAnimation;
\r
7505 return empty || optall.queue === false ?
\r
7506 this.each( doAnimation ) :
\r
7507 this.queue( optall.queue, doAnimation );
\r
7509 stop: function( type, clearQueue, gotoEnd ) {
\r
7510 var stopQueue = function( hooks ) {
\r
7511 var stop = hooks.stop;
\r
7512 delete hooks.stop;
\r
7516 if ( typeof type !== "string" ) {
\r
7517 gotoEnd = clearQueue;
\r
7518 clearQueue = type;
\r
7521 if ( clearQueue && type !== false ) {
\r
7522 this.queue( type || "fx", [] );
\r
7525 return this.each(function() {
\r
7526 var dequeue = true,
\r
7527 index = type != null && type + "queueHooks",
\r
7528 timers = jQuery.timers,
\r
7529 data = jQuery._data( this );
\r
7532 if ( data[ index ] && data[ index ].stop ) {
\r
7533 stopQueue( data[ index ] );
\r
7536 for ( index in data ) {
\r
7537 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
\r
7538 stopQueue( data[ index ] );
\r
7543 for ( index = timers.length; index--; ) {
\r
7544 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
\r
7545 timers[ index ].anim.stop( gotoEnd );
\r
7547 timers.splice( index, 1 );
\r
7551 // start the next in the queue if the last step wasn't forced
\r
7552 // timers currently will call their complete callbacks, which will dequeue
\r
7553 // but only if they were gotoEnd
\r
7554 if ( dequeue || !gotoEnd ) {
\r
7555 jQuery.dequeue( this, type );
\r
7559 finish: function( type ) {
\r
7560 if ( type !== false ) {
\r
7561 type = type || "fx";
\r
7563 return this.each(function() {
\r
7565 data = jQuery._data( this ),
\r
7566 queue = data[ type + "queue" ],
\r
7567 hooks = data[ type + "queueHooks" ],
\r
7568 timers = jQuery.timers,
\r
7569 length = queue ? queue.length : 0;
\r
7571 // enable finishing flag on private data
\r
7572 data.finish = true;
\r
7574 // empty the queue first
\r
7575 jQuery.queue( this, type, [] );
\r
7577 if ( hooks && hooks.stop ) {
\r
7578 hooks.stop.call( this, true );
\r
7581 // look for any active animations, and finish them
\r
7582 for ( index = timers.length; index--; ) {
\r
7583 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
\r
7584 timers[ index ].anim.stop( true );
\r
7585 timers.splice( index, 1 );
\r
7589 // look for any animations in the old queue and finish them
\r
7590 for ( index = 0; index < length; index++ ) {
\r
7591 if ( queue[ index ] && queue[ index ].finish ) {
\r
7592 queue[ index ].finish.call( this );
\r
7596 // turn off finishing flag
\r
7597 delete data.finish;
\r
7602 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
\r
7603 var cssFn = jQuery.fn[ name ];
\r
7604 jQuery.fn[ name ] = function( speed, easing, callback ) {
\r
7605 return speed == null || typeof speed === "boolean" ?
\r
7606 cssFn.apply( this, arguments ) :
\r
7607 this.animate( genFx( name, true ), speed, easing, callback );
\r
7611 // Generate shortcuts for custom animations
\r
7613 slideDown: genFx("show"),
\r
7614 slideUp: genFx("hide"),
\r
7615 slideToggle: genFx("toggle"),
\r
7616 fadeIn: { opacity: "show" },
\r
7617 fadeOut: { opacity: "hide" },
\r
7618 fadeToggle: { opacity: "toggle" }
\r
7619 }, function( name, props ) {
\r
7620 jQuery.fn[ name ] = function( speed, easing, callback ) {
\r
7621 return this.animate( props, speed, easing, callback );
\r
7625 jQuery.timers = [];
\r
7626 jQuery.fx.tick = function() {
\r
7628 timers = jQuery.timers,
\r
7631 fxNow = jQuery.now();
\r
7633 for ( ; i < timers.length; i++ ) {
\r
7634 timer = timers[ i ];
\r
7635 // Checks the timer has not already been removed
\r
7636 if ( !timer() && timers[ i ] === timer ) {
\r
7637 timers.splice( i--, 1 );
\r
7641 if ( !timers.length ) {
\r
7644 fxNow = undefined;
\r
7647 jQuery.fx.timer = function( timer ) {
\r
7648 jQuery.timers.push( timer );
\r
7650 jQuery.fx.start();
\r
7652 jQuery.timers.pop();
\r
7656 jQuery.fx.interval = 13;
\r
7658 jQuery.fx.start = function() {
\r
7660 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
\r
7664 jQuery.fx.stop = function() {
\r
7665 clearInterval( timerId );
\r
7669 jQuery.fx.speeds = {
\r
7677 // Based off of the plugin by Clint Helfers, with permission.
\r
7678 // http://blindsignals.com/index.php/2009/07/jquery-delay/
\r
7679 jQuery.fn.delay = function( time, type ) {
\r
7680 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
\r
7681 type = type || "fx";
\r
7683 return this.queue( type, function( next, hooks ) {
\r
7684 var timeout = setTimeout( next, time );
\r
7685 hooks.stop = function() {
\r
7686 clearTimeout( timeout );
\r
7693 var a, input, select, opt,
\r
7694 div = document.createElement("div" );
\r
7697 div.setAttribute( "className", "t" );
\r
7698 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
7699 a = div.getElementsByTagName("a")[ 0 ];
\r
7701 // First batch of tests.
\r
7702 select = document.createElement("select");
\r
7703 opt = select.appendChild( document.createElement("option") );
\r
7704 input = div.getElementsByTagName("input")[ 0 ];
\r
7706 a.style.cssText = "top:1px";
\r
7708 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
\r
7709 support.getSetAttribute = div.className !== "t";
\r
7711 // Get the style information from getAttribute
\r
7712 // (IE uses .cssText instead)
\r
7713 support.style = /top/.test( a.getAttribute("style") );
\r
7715 // Make sure that URLs aren't manipulated
\r
7716 // (IE normalizes it by default)
\r
7717 support.hrefNormalized = a.getAttribute("href") === "/a";
\r
7719 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
\r
7720 support.checkOn = !!input.value;
\r
7722 // Make sure that a selected-by-default option has a working selected property.
\r
7723 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
\r
7724 support.optSelected = opt.selected;
\r
7726 // Tests for enctype support on a form (#6743)
\r
7727 support.enctype = !!document.createElement("form").enctype;
\r
7729 // Make sure that the options inside disabled selects aren't marked as disabled
\r
7730 // (WebKit marks them as disabled)
\r
7731 select.disabled = true;
\r
7732 support.optDisabled = !opt.disabled;
\r
7734 // Support: IE8 only
\r
7735 // Check if we can trust getAttribute("value")
\r
7736 input = document.createElement( "input" );
\r
7737 input.setAttribute( "value", "" );
\r
7738 support.input = input.getAttribute( "value" ) === "";
\r
7740 // Check if an input maintains its value after becoming a radio
\r
7741 input.value = "t";
\r
7742 input.setAttribute( "type", "radio" );
\r
7743 support.radioValue = input.value === "t";
\r
7745 // Null elements to avoid leaks in IE.
\r
7746 a = input = select = opt = div = null;
\r
7750 var rreturn = /\r/g;
\r
7752 jQuery.fn.extend({
\r
7753 val: function( value ) {
\r
7754 var hooks, ret, isFunction,
\r
7757 if ( !arguments.length ) {
\r
7759 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
\r
7761 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
\r
7767 return typeof ret === "string" ?
\r
7768 // handle most common string cases
\r
7769 ret.replace(rreturn, "") :
\r
7770 // handle cases where value is null/undef or number
\r
7771 ret == null ? "" : ret;
\r
7777 isFunction = jQuery.isFunction( value );
\r
7779 return this.each(function( i ) {
\r
7782 if ( this.nodeType !== 1 ) {
\r
7786 if ( isFunction ) {
\r
7787 val = value.call( this, i, jQuery( this ).val() );
\r
7792 // Treat null/undefined as ""; convert numbers to string
\r
7793 if ( val == null ) {
\r
7795 } else if ( typeof val === "number" ) {
\r
7797 } else if ( jQuery.isArray( val ) ) {
\r
7798 val = jQuery.map( val, function( value ) {
\r
7799 return value == null ? "" : value + "";
\r
7803 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
\r
7805 // If set returns undefined, fall back to normal setting
\r
7806 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
\r
7816 get: function( elem ) {
\r
7817 var val = jQuery.find.attr( elem, "value" );
\r
7818 return val != null ?
\r
7820 jQuery.text( elem );
\r
7824 get: function( elem ) {
\r
7825 var value, option,
\r
7826 options = elem.options,
\r
7827 index = elem.selectedIndex,
\r
7828 one = elem.type === "select-one" || index < 0,
\r
7829 values = one ? null : [],
\r
7830 max = one ? index + 1 : options.length,
\r
7835 // Loop through all the selected options
\r
7836 for ( ; i < max; i++ ) {
\r
7837 option = options[ i ];
\r
7839 // oldIE doesn't update selected after form reset (#2551)
\r
7840 if ( ( option.selected || i === index ) &&
\r
7841 // Don't return options that are disabled or in a disabled optgroup
\r
7842 ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
\r
7843 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
\r
7845 // Get the specific value for the option
\r
7846 value = jQuery( option ).val();
\r
7848 // We don't need an array for one selects
\r
7853 // Multi-Selects return an array
\r
7854 values.push( value );
\r
7861 set: function( elem, value ) {
\r
7862 var optionSet, option,
\r
7863 options = elem.options,
\r
7864 values = jQuery.makeArray( value ),
\r
7865 i = options.length;
\r
7868 option = options[ i ];
\r
7870 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
\r
7873 // When new option element is added to select box we need to
\r
7874 // force reflow of newly added node in order to workaround delay
\r
7875 // of initialization properties
\r
7877 option.selected = optionSet = true;
\r
7881 // Will be executed only in IE6
\r
7882 option.scrollHeight;
\r
7886 option.selected = false;
\r
7890 // Force browsers to behave consistently when non-matching value is set
\r
7891 if ( !optionSet ) {
\r
7892 elem.selectedIndex = -1;
\r
7901 // Radios and checkboxes getter/setter
\r
7902 jQuery.each([ "radio", "checkbox" ], function() {
\r
7903 jQuery.valHooks[ this ] = {
\r
7904 set: function( elem, value ) {
\r
7905 if ( jQuery.isArray( value ) ) {
\r
7906 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
\r
7910 if ( !support.checkOn ) {
\r
7911 jQuery.valHooks[ this ].get = function( elem ) {
\r
7912 // Support: Webkit
\r
7913 // "" is returned instead of "on" if a value isn't specified
\r
7914 return elem.getAttribute("value") === null ? "on" : elem.value;
\r
7922 var nodeHook, boolHook,
\r
7923 attrHandle = jQuery.expr.attrHandle,
\r
7924 ruseDefault = /^(?:checked|selected)$/i,
\r
7925 getSetAttribute = support.getSetAttribute,
\r
7926 getSetInput = support.input;
\r
7928 jQuery.fn.extend({
\r
7929 attr: function( name, value ) {
\r
7930 return access( this, jQuery.attr, name, value, arguments.length > 1 );
\r
7933 removeAttr: function( name ) {
\r
7934 return this.each(function() {
\r
7935 jQuery.removeAttr( this, name );
\r
7941 attr: function( elem, name, value ) {
\r
7943 nType = elem.nodeType;
\r
7945 // don't get/set attributes on text, comment and attribute nodes
\r
7946 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
\r
7950 // Fallback to prop when attributes are not supported
\r
7951 if ( typeof elem.getAttribute === strundefined ) {
\r
7952 return jQuery.prop( elem, name, value );
\r
7955 // All attributes are lowercase
\r
7956 // Grab necessary hook if one is defined
\r
7957 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
\r
7958 name = name.toLowerCase();
\r
7959 hooks = jQuery.attrHooks[ name ] ||
\r
7960 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
\r
7963 if ( value !== undefined ) {
\r
7965 if ( value === null ) {
\r
7966 jQuery.removeAttr( elem, name );
\r
7968 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
\r
7972 elem.setAttribute( name, value + "" );
\r
7976 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
\r
7980 ret = jQuery.find.attr( elem, name );
\r
7982 // Non-existent attributes return null, we normalize to undefined
\r
7983 return ret == null ?
\r
7989 removeAttr: function( elem, value ) {
\r
7990 var name, propName,
\r
7992 attrNames = value && value.match( rnotwhite );
\r
7994 if ( attrNames && elem.nodeType === 1 ) {
\r
7995 while ( (name = attrNames[i++]) ) {
\r
7996 propName = jQuery.propFix[ name ] || name;
\r
7998 // Boolean attributes get special treatment (#10870)
\r
7999 if ( jQuery.expr.match.bool.test( name ) ) {
\r
8000 // Set corresponding property to false
\r
8001 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
\r
8002 elem[ propName ] = false;
\r
8004 // Also clear defaultChecked/defaultSelected (if appropriate)
\r
8006 elem[ jQuery.camelCase( "default-" + name ) ] =
\r
8007 elem[ propName ] = false;
\r
8010 // See #9699 for explanation of this approach (setting first, then removal)
\r
8012 jQuery.attr( elem, name, "" );
\r
8015 elem.removeAttribute( getSetAttribute ? name : propName );
\r
8022 set: function( elem, value ) {
\r
8023 if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
\r
8024 // Setting the type on a radio button after the value resets the value in IE6-9
\r
8025 // Reset value to default in case type is set after value during creation
\r
8026 var val = elem.value;
\r
8027 elem.setAttribute( "type", value );
\r
8038 // Hook for boolean attributes
\r
8040 set: function( elem, value, name ) {
\r
8041 if ( value === false ) {
\r
8042 // Remove boolean attributes when set to false
\r
8043 jQuery.removeAttr( elem, name );
\r
8044 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
\r
8045 // IE<8 needs the *property* name
\r
8046 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
\r
8048 // Use defaultChecked and defaultSelected for oldIE
\r
8050 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
\r
8057 // Retrieve booleans specially
\r
8058 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
\r
8060 var getter = attrHandle[ name ] || jQuery.find.attr;
\r
8062 attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
\r
8063 function( elem, name, isXML ) {
\r
8066 // Avoid an infinite loop by temporarily removing this function from the getter
\r
8067 handle = attrHandle[ name ];
\r
8068 attrHandle[ name ] = ret;
\r
8069 ret = getter( elem, name, isXML ) != null ?
\r
8070 name.toLowerCase() :
\r
8072 attrHandle[ name ] = handle;
\r
8076 function( elem, name, isXML ) {
\r
8078 return elem[ jQuery.camelCase( "default-" + name ) ] ?
\r
8079 name.toLowerCase() :
\r
8085 // fix oldIE attroperties
\r
8086 if ( !getSetInput || !getSetAttribute ) {
\r
8087 jQuery.attrHooks.value = {
\r
8088 set: function( elem, value, name ) {
\r
8089 if ( jQuery.nodeName( elem, "input" ) ) {
\r
8090 // Does not return so that setAttribute is also used
\r
8091 elem.defaultValue = value;
\r
8093 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
\r
8094 return nodeHook && nodeHook.set( elem, value, name );
\r
8100 // IE6/7 do not support getting/setting some attributes with get/setAttribute
\r
8101 if ( !getSetAttribute ) {
\r
8103 // Use this for any attribute in IE6/7
\r
8104 // This fixes almost every IE6/7 issue
\r
8106 set: function( elem, value, name ) {
\r
8107 // Set the existing or create a new attribute node
\r
8108 var ret = elem.getAttributeNode( name );
\r
8110 elem.setAttributeNode(
\r
8111 (ret = elem.ownerDocument.createAttribute( name ))
\r
8115 ret.value = value += "";
\r
8117 // Break association with cloned elements by also using setAttribute (#9646)
\r
8118 if ( name === "value" || value === elem.getAttribute( name ) ) {
\r
8124 // Some attributes are constructed with empty-string values when not defined
\r
8125 attrHandle.id = attrHandle.name = attrHandle.coords =
\r
8126 function( elem, name, isXML ) {
\r
8129 return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
\r
8135 // Fixing value retrieval on a button requires this module
\r
8136 jQuery.valHooks.button = {
\r
8137 get: function( elem, name ) {
\r
8138 var ret = elem.getAttributeNode( name );
\r
8139 if ( ret && ret.specified ) {
\r
8146 // Set contenteditable to false on removals(#10429)
\r
8147 // Setting to empty string throws an error as an invalid value
\r
8148 jQuery.attrHooks.contenteditable = {
\r
8149 set: function( elem, value, name ) {
\r
8150 nodeHook.set( elem, value === "" ? false : value, name );
\r
8154 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
\r
8155 // This is for removals
\r
8156 jQuery.each([ "width", "height" ], function( i, name ) {
\r
8157 jQuery.attrHooks[ name ] = {
\r
8158 set: function( elem, value ) {
\r
8159 if ( value === "" ) {
\r
8160 elem.setAttribute( name, "auto" );
\r
8168 if ( !support.style ) {
\r
8169 jQuery.attrHooks.style = {
\r
8170 get: function( elem ) {
\r
8171 // Return undefined in the case of empty string
\r
8172 // Note: IE uppercases css property names, but if we were to .toLowerCase()
\r
8173 // .cssText, that would destroy case senstitivity in URL's, like in "background"
\r
8174 return elem.style.cssText || undefined;
\r
8176 set: function( elem, value ) {
\r
8177 return ( elem.style.cssText = value + "" );
\r
8185 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
\r
8186 rclickable = /^(?:a|area)$/i;
\r
8188 jQuery.fn.extend({
\r
8189 prop: function( name, value ) {
\r
8190 return access( this, jQuery.prop, name, value, arguments.length > 1 );
\r
8193 removeProp: function( name ) {
\r
8194 name = jQuery.propFix[ name ] || name;
\r
8195 return this.each(function() {
\r
8196 // try/catch handles cases where IE balks (such as removing a property on window)
\r
8198 this[ name ] = undefined;
\r
8199 delete this[ name ];
\r
8208 "class": "className"
\r
8211 prop: function( elem, name, value ) {
\r
8212 var ret, hooks, notxml,
\r
8213 nType = elem.nodeType;
\r
8215 // don't get/set properties on text, comment and attribute nodes
\r
8216 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
\r
8220 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
\r
8223 // Fix name and attach hooks
\r
8224 name = jQuery.propFix[ name ] || name;
\r
8225 hooks = jQuery.propHooks[ name ];
\r
8228 if ( value !== undefined ) {
\r
8229 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
\r
8231 ( elem[ name ] = value );
\r
8234 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
\r
8242 get: function( elem ) {
\r
8243 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
\r
8244 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
\r
8245 // Use proper attribute retrieval(#12072)
\r
8246 var tabindex = jQuery.find.attr( elem, "tabindex" );
\r
8249 parseInt( tabindex, 10 ) :
\r
8250 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
\r
8258 // Some attributes require a special call on IE
\r
8259 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
\r
8260 if ( !support.hrefNormalized ) {
\r
8261 // href/src property should get the full normalized URL (#10299/#12915)
\r
8262 jQuery.each([ "href", "src" ], function( i, name ) {
\r
8263 jQuery.propHooks[ name ] = {
\r
8264 get: function( elem ) {
\r
8265 return elem.getAttribute( name, 4 );
\r
8271 // Support: Safari, IE9+
\r
8272 // mis-reports the default selected property of an option
\r
8273 // Accessing the parent's selectedIndex property fixes it
\r
8274 if ( !support.optSelected ) {
\r
8275 jQuery.propHooks.selected = {
\r
8276 get: function( elem ) {
\r
8277 var parent = elem.parentNode;
\r
8280 parent.selectedIndex;
\r
8282 // Make sure that it also works with optgroups, see #5701
\r
8283 if ( parent.parentNode ) {
\r
8284 parent.parentNode.selectedIndex;
\r
8304 jQuery.propFix[ this.toLowerCase() ] = this;
\r
8307 // IE6/7 call enctype encoding
\r
8308 if ( !support.enctype ) {
\r
8309 jQuery.propFix.enctype = "encoding";
\r
8315 var rclass = /[\t\r\n\f]/g;
\r
8317 jQuery.fn.extend({
\r
8318 addClass: function( value ) {
\r
8319 var classes, elem, cur, clazz, j, finalValue,
\r
8321 len = this.length,
\r
8322 proceed = typeof value === "string" && value;
\r
8324 if ( jQuery.isFunction( value ) ) {
\r
8325 return this.each(function( j ) {
\r
8326 jQuery( this ).addClass( value.call( this, j, this.className ) );
\r
8331 // The disjunction here is for better compressibility (see removeClass)
\r
8332 classes = ( value || "" ).match( rnotwhite ) || [];
\r
8334 for ( ; i < len; i++ ) {
\r
8336 cur = elem.nodeType === 1 && ( elem.className ?
\r
8337 ( " " + elem.className + " " ).replace( rclass, " " ) :
\r
8343 while ( (clazz = classes[j++]) ) {
\r
8344 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
\r
8345 cur += clazz + " ";
\r
8349 // only assign if different to avoid unneeded rendering.
\r
8350 finalValue = jQuery.trim( cur );
\r
8351 if ( elem.className !== finalValue ) {
\r
8352 elem.className = finalValue;
\r
8361 removeClass: function( value ) {
\r
8362 var classes, elem, cur, clazz, j, finalValue,
\r
8364 len = this.length,
\r
8365 proceed = arguments.length === 0 || typeof value === "string" && value;
\r
8367 if ( jQuery.isFunction( value ) ) {
\r
8368 return this.each(function( j ) {
\r
8369 jQuery( this ).removeClass( value.call( this, j, this.className ) );
\r
8373 classes = ( value || "" ).match( rnotwhite ) || [];
\r
8375 for ( ; i < len; i++ ) {
\r
8377 // This expression is here for better compressibility (see addClass)
\r
8378 cur = elem.nodeType === 1 && ( elem.className ?
\r
8379 ( " " + elem.className + " " ).replace( rclass, " " ) :
\r
8385 while ( (clazz = classes[j++]) ) {
\r
8386 // Remove *all* instances
\r
8387 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
\r
8388 cur = cur.replace( " " + clazz + " ", " " );
\r
8392 // only assign if different to avoid unneeded rendering.
\r
8393 finalValue = value ? jQuery.trim( cur ) : "";
\r
8394 if ( elem.className !== finalValue ) {
\r
8395 elem.className = finalValue;
\r
8404 toggleClass: function( value, stateVal ) {
\r
8405 var type = typeof value;
\r
8407 if ( typeof stateVal === "boolean" && type === "string" ) {
\r
8408 return stateVal ? this.addClass( value ) : this.removeClass( value );
\r
8411 if ( jQuery.isFunction( value ) ) {
\r
8412 return this.each(function( i ) {
\r
8413 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
\r
8417 return this.each(function() {
\r
8418 if ( type === "string" ) {
\r
8419 // toggle individual class names
\r
8422 self = jQuery( this ),
\r
8423 classNames = value.match( rnotwhite ) || [];
\r
8425 while ( (className = classNames[ i++ ]) ) {
\r
8426 // check each className given, space separated list
\r
8427 if ( self.hasClass( className ) ) {
\r
8428 self.removeClass( className );
\r
8430 self.addClass( className );
\r
8434 // Toggle whole class name
\r
8435 } else if ( type === strundefined || type === "boolean" ) {
\r
8436 if ( this.className ) {
\r
8437 // store className if set
\r
8438 jQuery._data( this, "__className__", this.className );
\r
8441 // If the element has a class name or if we're passed "false",
\r
8442 // then remove the whole classname (if there was one, the above saved it).
\r
8443 // Otherwise bring back whatever was previously saved (if anything),
\r
8444 // falling back to the empty string if nothing was stored.
\r
8445 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
\r
8450 hasClass: function( selector ) {
\r
8451 var className = " " + selector + " ",
\r
8454 for ( ; i < l; i++ ) {
\r
8455 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
\r
8467 // Return jQuery for attributes-only inclusion
\r
8470 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
\r
8471 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
\r
8472 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
\r
8474 // Handle event binding
\r
8475 jQuery.fn[ name ] = function( data, fn ) {
\r
8476 return arguments.length > 0 ?
\r
8477 this.on( name, null, data, fn ) :
\r
8478 this.trigger( name );
\r
8482 jQuery.fn.extend({
\r
8483 hover: function( fnOver, fnOut ) {
\r
8484 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
\r
8487 bind: function( types, data, fn ) {
\r
8488 return this.on( types, null, data, fn );
\r
8490 unbind: function( types, fn ) {
\r
8491 return this.off( types, null, fn );
\r
8494 delegate: function( selector, types, data, fn ) {
\r
8495 return this.on( types, selector, data, fn );
\r
8497 undelegate: function( selector, types, fn ) {
\r
8498 // ( namespace ) or ( selector, types [, fn] )
\r
8499 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
\r
8504 var nonce = jQuery.now();
\r
8506 var rquery = (/\?/);
\r
8510 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
\r
8512 jQuery.parseJSON = function( data ) {
\r
8513 // Attempt to parse using the native JSON parser first
\r
8514 if ( window.JSON && window.JSON.parse ) {
\r
8515 // Support: Android 2.3
\r
8516 // Workaround failure to string-cast null input
\r
8517 return window.JSON.parse( data + "" );
\r
8520 var requireNonComma,
\r
8522 str = jQuery.trim( data + "" );
\r
8524 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
\r
8525 // after removing valid tokens
\r
8526 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
\r
8528 // Force termination if we see a misplaced comma
\r
8529 if ( requireNonComma && comma ) {
\r
8533 // Perform no more replacements after returning to outermost depth
\r
8534 if ( depth === 0 ) {
\r
8538 // Commas must not follow "[", "{", or ","
\r
8539 requireNonComma = open || comma;
\r
8541 // Determine new depth
\r
8542 // array/object open ("[" or "{"): depth += true - false (increment)
\r
8543 // array/object close ("]" or "}"): depth += false - true (decrement)
\r
8544 // other cases ("," or primitive): depth += true - true (numeric cast)
\r
8545 depth += !close - !open;
\r
8547 // Remove this token
\r
8550 ( Function( "return " + str ) )() :
\r
8551 jQuery.error( "Invalid JSON: " + data );
\r
8555 // Cross-browser xml parsing
\r
8556 jQuery.parseXML = function( data ) {
\r
8558 if ( !data || typeof data !== "string" ) {
\r
8562 if ( window.DOMParser ) { // Standard
\r
8563 tmp = new DOMParser();
\r
8564 xml = tmp.parseFromString( data, "text/xml" );
\r
8566 xml = new ActiveXObject( "Microsoft.XMLDOM" );
\r
8567 xml.async = "false";
\r
8568 xml.loadXML( data );
\r
8573 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
\r
8574 jQuery.error( "Invalid XML: " + data );
\r
8581 // Document location
\r
8586 rts = /([?&])_=[^&]*/,
\r
8587 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
\r
8588 // #7653, #8125, #8152: local protocol detection
\r
8589 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
\r
8590 rnoContent = /^(?:GET|HEAD)$/,
\r
8591 rprotocol = /^\/\//,
\r
8592 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
\r
8595 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
\r
8596 * 2) These are called:
\r
8597 * - BEFORE asking for a transport
\r
8598 * - AFTER param serialization (s.data is a string if s.processData is true)
\r
8599 * 3) key is the dataType
\r
8600 * 4) the catchall symbol "*" can be used
\r
8601 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
\r
8605 /* Transports bindings
\r
8606 * 1) key is the dataType
\r
8607 * 2) the catchall symbol "*" can be used
\r
8608 * 3) selection will start with transport dataType and THEN go to "*" if needed
\r
8612 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
\r
8613 allTypes = "*/".concat("*");
\r
8615 // #8138, IE may throw an exception when accessing
\r
8616 // a field from window.location if document.domain has been set
\r
8618 ajaxLocation = location.href;
\r
8620 // Use the href attribute of an A element
\r
8621 // since IE will modify it given document.location
\r
8622 ajaxLocation = document.createElement( "a" );
\r
8623 ajaxLocation.href = "";
\r
8624 ajaxLocation = ajaxLocation.href;
\r
8627 // Segment location into parts
\r
8628 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
\r
8630 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
\r
8631 function addToPrefiltersOrTransports( structure ) {
\r
8633 // dataTypeExpression is optional and defaults to "*"
\r
8634 return function( dataTypeExpression, func ) {
\r
8636 if ( typeof dataTypeExpression !== "string" ) {
\r
8637 func = dataTypeExpression;
\r
8638 dataTypeExpression = "*";
\r
8643 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
\r
8645 if ( jQuery.isFunction( func ) ) {
\r
8646 // For each dataType in the dataTypeExpression
\r
8647 while ( (dataType = dataTypes[i++]) ) {
\r
8648 // Prepend if requested
\r
8649 if ( dataType.charAt( 0 ) === "+" ) {
\r
8650 dataType = dataType.slice( 1 ) || "*";
\r
8651 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
\r
8653 // Otherwise append
\r
8655 (structure[ dataType ] = structure[ dataType ] || []).push( func );
\r
8662 // Base inspection function for prefilters and transports
\r
8663 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
\r
8665 var inspected = {},
\r
8666 seekingTransport = ( structure === transports );
\r
8668 function inspect( dataType ) {
\r
8670 inspected[ dataType ] = true;
\r
8671 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
\r
8672 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
\r
8673 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
\r
8674 options.dataTypes.unshift( dataTypeOrTransport );
\r
8675 inspect( dataTypeOrTransport );
\r
8677 } else if ( seekingTransport ) {
\r
8678 return !( selected = dataTypeOrTransport );
\r
8684 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
\r
8687 // A special extend for ajax options
\r
8688 // that takes "flat" options (not to be deep extended)
\r
8690 function ajaxExtend( target, src ) {
\r
8692 flatOptions = jQuery.ajaxSettings.flatOptions || {};
\r
8694 for ( key in src ) {
\r
8695 if ( src[ key ] !== undefined ) {
\r
8696 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
\r
8700 jQuery.extend( true, target, deep );
\r
8706 /* Handles responses to an ajax request:
\r
8707 * - finds the right dataType (mediates between content-type and expected dataType)
\r
8708 * - returns the corresponding response
\r
8710 function ajaxHandleResponses( s, jqXHR, responses ) {
\r
8711 var firstDataType, ct, finalDataType, type,
\r
8712 contents = s.contents,
\r
8713 dataTypes = s.dataTypes;
\r
8715 // Remove auto dataType and get content-type in the process
\r
8716 while ( dataTypes[ 0 ] === "*" ) {
\r
8717 dataTypes.shift();
\r
8718 if ( ct === undefined ) {
\r
8719 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
\r
8723 // Check if we're dealing with a known content-type
\r
8725 for ( type in contents ) {
\r
8726 if ( contents[ type ] && contents[ type ].test( ct ) ) {
\r
8727 dataTypes.unshift( type );
\r
8733 // Check to see if we have a response for the expected dataType
\r
8734 if ( dataTypes[ 0 ] in responses ) {
\r
8735 finalDataType = dataTypes[ 0 ];
\r
8737 // Try convertible dataTypes
\r
8738 for ( type in responses ) {
\r
8739 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
\r
8740 finalDataType = type;
\r
8743 if ( !firstDataType ) {
\r
8744 firstDataType = type;
\r
8747 // Or just use first one
\r
8748 finalDataType = finalDataType || firstDataType;
\r
8751 // If we found a dataType
\r
8752 // We add the dataType to the list if needed
\r
8753 // and return the corresponding response
\r
8754 if ( finalDataType ) {
\r
8755 if ( finalDataType !== dataTypes[ 0 ] ) {
\r
8756 dataTypes.unshift( finalDataType );
\r
8758 return responses[ finalDataType ];
\r
8762 /* Chain conversions given the request and the original response
\r
8763 * Also sets the responseXXX fields on the jqXHR instance
\r
8765 function ajaxConvert( s, response, jqXHR, isSuccess ) {
\r
8766 var conv2, current, conv, tmp, prev,
\r
8768 // Work with a copy of dataTypes in case we need to modify it for conversion
\r
8769 dataTypes = s.dataTypes.slice();
\r
8771 // Create converters map with lowercased keys
\r
8772 if ( dataTypes[ 1 ] ) {
\r
8773 for ( conv in s.converters ) {
\r
8774 converters[ conv.toLowerCase() ] = s.converters[ conv ];
\r
8778 current = dataTypes.shift();
\r
8780 // Convert to each sequential dataType
\r
8781 while ( current ) {
\r
8783 if ( s.responseFields[ current ] ) {
\r
8784 jqXHR[ s.responseFields[ current ] ] = response;
\r
8787 // Apply the dataFilter if provided
\r
8788 if ( !prev && isSuccess && s.dataFilter ) {
\r
8789 response = s.dataFilter( response, s.dataType );
\r
8793 current = dataTypes.shift();
\r
8797 // There's only work to do if current dataType is non-auto
\r
8798 if ( current === "*" ) {
\r
8802 // Convert response if prev dataType is non-auto and differs from current
\r
8803 } else if ( prev !== "*" && prev !== current ) {
\r
8805 // Seek a direct converter
\r
8806 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
\r
8808 // If none found, seek a pair
\r
8810 for ( conv2 in converters ) {
\r
8812 // If conv2 outputs current
\r
8813 tmp = conv2.split( " " );
\r
8814 if ( tmp[ 1 ] === current ) {
\r
8816 // If prev can be converted to accepted input
\r
8817 conv = converters[ prev + " " + tmp[ 0 ] ] ||
\r
8818 converters[ "* " + tmp[ 0 ] ];
\r
8820 // Condense equivalence converters
\r
8821 if ( conv === true ) {
\r
8822 conv = converters[ conv2 ];
\r
8824 // Otherwise, insert the intermediate dataType
\r
8825 } else if ( converters[ conv2 ] !== true ) {
\r
8826 current = tmp[ 0 ];
\r
8827 dataTypes.unshift( tmp[ 1 ] );
\r
8835 // Apply converter (if not an equivalence)
\r
8836 if ( conv !== true ) {
\r
8838 // Unless errors are allowed to bubble, catch and return them
\r
8839 if ( conv && s[ "throws" ] ) {
\r
8840 response = conv( response );
\r
8843 response = conv( response );
\r
8845 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
\r
8853 return { state: "success", data: response };
\r
8858 // Counter for holding the number of active queries
\r
8861 // Last-Modified header cache for next request
\r
8866 url: ajaxLocation,
\r
8868 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
\r
8870 processData: true,
\r
8872 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
\r
8881 traditional: false,
\r
8887 text: "text/plain",
\r
8888 html: "text/html",
\r
8889 xml: "application/xml, text/xml",
\r
8890 json: "application/json, text/javascript"
\r
8900 xml: "responseXML",
\r
8901 text: "responseText",
\r
8902 json: "responseJSON"
\r
8905 // Data converters
\r
8906 // Keys separate source (or catchall "*") and destination types with a single space
\r
8909 // Convert anything to text
\r
8912 // Text to html (true = no transformation)
\r
8913 "text html": true,
\r
8915 // Evaluate text as a json expression
\r
8916 "text json": jQuery.parseJSON,
\r
8918 // Parse text as xml
\r
8919 "text xml": jQuery.parseXML
\r
8922 // For options that shouldn't be deep extended:
\r
8923 // you can add your own custom options here if
\r
8924 // and when you create one that shouldn't be
\r
8925 // deep extended (see ajaxExtend)
\r
8932 // Creates a full fledged settings object into target
\r
8933 // with both ajaxSettings and settings fields.
\r
8934 // If target is omitted, writes into ajaxSettings.
\r
8935 ajaxSetup: function( target, settings ) {
\r
8938 // Building a settings object
\r
8939 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
\r
8941 // Extending ajaxSettings
\r
8942 ajaxExtend( jQuery.ajaxSettings, target );
\r
8945 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
\r
8946 ajaxTransport: addToPrefiltersOrTransports( transports ),
\r
8949 ajax: function( url, options ) {
\r
8951 // If url is an object, simulate pre-1.5 signature
\r
8952 if ( typeof url === "object" ) {
\r
8957 // Force options to be an object
\r
8958 options = options || {};
\r
8960 var // Cross-domain detection vars
\r
8964 // URL without anti-cache param
\r
8966 // Response headers as string
\r
8967 responseHeadersString,
\r
8971 // To know if global events are to be dispatched
\r
8975 // Response headers
\r
8977 // Create the final options object
\r
8978 s = jQuery.ajaxSetup( {}, options ),
\r
8979 // Callbacks context
\r
8980 callbackContext = s.context || s,
\r
8981 // Context for global events is callbackContext if it is a DOM node or jQuery collection
\r
8982 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
\r
8983 jQuery( callbackContext ) :
\r
8986 deferred = jQuery.Deferred(),
\r
8987 completeDeferred = jQuery.Callbacks("once memory"),
\r
8988 // Status-dependent callbacks
\r
8989 statusCode = s.statusCode || {},
\r
8990 // Headers (they are sent all at once)
\r
8991 requestHeaders = {},
\r
8992 requestHeadersNames = {},
\r
8993 // The jqXHR state
\r
8995 // Default abort message
\r
8996 strAbort = "canceled",
\r
9001 // Builds headers hashtable if needed
\r
9002 getResponseHeader: function( key ) {
\r
9004 if ( state === 2 ) {
\r
9005 if ( !responseHeaders ) {
\r
9006 responseHeaders = {};
\r
9007 while ( (match = rheaders.exec( responseHeadersString )) ) {
\r
9008 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
\r
9011 match = responseHeaders[ key.toLowerCase() ];
\r
9013 return match == null ? null : match;
\r
9017 getAllResponseHeaders: function() {
\r
9018 return state === 2 ? responseHeadersString : null;
\r
9021 // Caches the header
\r
9022 setRequestHeader: function( name, value ) {
\r
9023 var lname = name.toLowerCase();
\r
9025 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
\r
9026 requestHeaders[ name ] = value;
\r
9031 // Overrides response content-type header
\r
9032 overrideMimeType: function( type ) {
\r
9034 s.mimeType = type;
\r
9039 // Status-dependent callbacks
\r
9040 statusCode: function( map ) {
\r
9043 if ( state < 2 ) {
\r
9044 for ( code in map ) {
\r
9045 // Lazy-add the new callback in a way that preserves old ones
\r
9046 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
\r
9049 // Execute the appropriate callbacks
\r
9050 jqXHR.always( map[ jqXHR.status ] );
\r
9056 // Cancel the request
\r
9057 abort: function( statusText ) {
\r
9058 var finalText = statusText || strAbort;
\r
9059 if ( transport ) {
\r
9060 transport.abort( finalText );
\r
9062 done( 0, finalText );
\r
9067 // Attach deferreds
\r
9068 deferred.promise( jqXHR ).complete = completeDeferred.add;
\r
9069 jqXHR.success = jqXHR.done;
\r
9070 jqXHR.error = jqXHR.fail;
\r
9072 // Remove hash character (#7531: and string promotion)
\r
9073 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
\r
9074 // Handle falsy url in the settings object (#10093: consistency with old signature)
\r
9075 // We also use the url parameter if available
\r
9076 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
\r
9078 // Alias method option to type as per ticket #12004
\r
9079 s.type = options.method || options.type || s.method || s.type;
\r
9081 // Extract dataTypes list
\r
9082 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
\r
9084 // A cross-domain request is in order when we have a protocol:host:port mismatch
\r
9085 if ( s.crossDomain == null ) {
\r
9086 parts = rurl.exec( s.url.toLowerCase() );
\r
9087 s.crossDomain = !!( parts &&
\r
9088 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
\r
9089 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
\r
9090 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
\r
9094 // Convert data if not already a string
\r
9095 if ( s.data && s.processData && typeof s.data !== "string" ) {
\r
9096 s.data = jQuery.param( s.data, s.traditional );
\r
9099 // Apply prefilters
\r
9100 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
\r
9102 // If request was aborted inside a prefilter, stop there
\r
9103 if ( state === 2 ) {
\r
9107 // We can fire global events as of now if asked to
\r
9108 fireGlobals = s.global;
\r
9110 // Watch for a new set of requests
\r
9111 if ( fireGlobals && jQuery.active++ === 0 ) {
\r
9112 jQuery.event.trigger("ajaxStart");
\r
9115 // Uppercase the type
\r
9116 s.type = s.type.toUpperCase();
\r
9118 // Determine if request has content
\r
9119 s.hasContent = !rnoContent.test( s.type );
\r
9121 // Save the URL in case we're toying with the If-Modified-Since
\r
9122 // and/or If-None-Match header later on
\r
9125 // More options handling for requests with no content
\r
9126 if ( !s.hasContent ) {
\r
9128 // If data is available, append data to url
\r
9130 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
\r
9131 // #9682: remove data so that it's not used in an eventual retry
\r
9135 // Add anti-cache in url if needed
\r
9136 if ( s.cache === false ) {
\r
9137 s.url = rts.test( cacheURL ) ?
\r
9139 // If there is already a '_' parameter, set its value
\r
9140 cacheURL.replace( rts, "$1_=" + nonce++ ) :
\r
9142 // Otherwise add one to the end
\r
9143 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
\r
9147 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
\r
9148 if ( s.ifModified ) {
\r
9149 if ( jQuery.lastModified[ cacheURL ] ) {
\r
9150 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
\r
9152 if ( jQuery.etag[ cacheURL ] ) {
\r
9153 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
\r
9157 // Set the correct header, if data is being sent
\r
9158 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
\r
9159 jqXHR.setRequestHeader( "Content-Type", s.contentType );
\r
9162 // Set the Accepts header for the server, depending on the dataType
\r
9163 jqXHR.setRequestHeader(
\r
9165 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
\r
9166 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
\r
9170 // Check for headers option
\r
9171 for ( i in s.headers ) {
\r
9172 jqXHR.setRequestHeader( i, s.headers[ i ] );
\r
9175 // Allow custom headers/mimetypes and early abort
\r
9176 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
\r
9177 // Abort if not done already and return
\r
9178 return jqXHR.abort();
\r
9181 // aborting is no longer a cancellation
\r
9182 strAbort = "abort";
\r
9184 // Install callbacks on deferreds
\r
9185 for ( i in { success: 1, error: 1, complete: 1 } ) {
\r
9186 jqXHR[ i ]( s[ i ] );
\r
9190 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
\r
9192 // If no transport, we auto-abort
\r
9193 if ( !transport ) {
\r
9194 done( -1, "No Transport" );
\r
9196 jqXHR.readyState = 1;
\r
9198 // Send global event
\r
9199 if ( fireGlobals ) {
\r
9200 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
\r
9203 if ( s.async && s.timeout > 0 ) {
\r
9204 timeoutTimer = setTimeout(function() {
\r
9205 jqXHR.abort("timeout");
\r
9211 transport.send( requestHeaders, done );
\r
9213 // Propagate exception as error if not done
\r
9214 if ( state < 2 ) {
\r
9216 // Simply rethrow otherwise
\r
9223 // Callback for when everything is done
\r
9224 function done( status, nativeStatusText, responses, headers ) {
\r
9225 var isSuccess, success, error, response, modified,
\r
9226 statusText = nativeStatusText;
\r
9229 if ( state === 2 ) {
\r
9233 // State is "done" now
\r
9236 // Clear timeout if it exists
\r
9237 if ( timeoutTimer ) {
\r
9238 clearTimeout( timeoutTimer );
\r
9241 // Dereference transport for early garbage collection
\r
9242 // (no matter how long the jqXHR object will be used)
\r
9243 transport = undefined;
\r
9245 // Cache response headers
\r
9246 responseHeadersString = headers || "";
\r
9249 jqXHR.readyState = status > 0 ? 4 : 0;
\r
9251 // Determine if successful
\r
9252 isSuccess = status >= 200 && status < 300 || status === 304;
\r
9254 // Get response data
\r
9255 if ( responses ) {
\r
9256 response = ajaxHandleResponses( s, jqXHR, responses );
\r
9259 // Convert no matter what (that way responseXXX fields are always set)
\r
9260 response = ajaxConvert( s, response, jqXHR, isSuccess );
\r
9262 // If successful, handle type chaining
\r
9263 if ( isSuccess ) {
\r
9265 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
\r
9266 if ( s.ifModified ) {
\r
9267 modified = jqXHR.getResponseHeader("Last-Modified");
\r
9269 jQuery.lastModified[ cacheURL ] = modified;
\r
9271 modified = jqXHR.getResponseHeader("etag");
\r
9273 jQuery.etag[ cacheURL ] = modified;
\r
9278 if ( status === 204 || s.type === "HEAD" ) {
\r
9279 statusText = "nocontent";
\r
9281 // if not modified
\r
9282 } else if ( status === 304 ) {
\r
9283 statusText = "notmodified";
\r
9285 // If we have data, let's convert it
\r
9287 statusText = response.state;
\r
9288 success = response.data;
\r
9289 error = response.error;
\r
9290 isSuccess = !error;
\r
9293 // We extract error from statusText
\r
9294 // then normalize statusText and status for non-aborts
\r
9295 error = statusText;
\r
9296 if ( status || !statusText ) {
\r
9297 statusText = "error";
\r
9298 if ( status < 0 ) {
\r
9304 // Set data for the fake xhr object
\r
9305 jqXHR.status = status;
\r
9306 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
\r
9309 if ( isSuccess ) {
\r
9310 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
\r
9312 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
\r
9315 // Status-dependent callbacks
\r
9316 jqXHR.statusCode( statusCode );
\r
9317 statusCode = undefined;
\r
9319 if ( fireGlobals ) {
\r
9320 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
\r
9321 [ jqXHR, s, isSuccess ? success : error ] );
\r
9325 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
\r
9327 if ( fireGlobals ) {
\r
9328 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
\r
9329 // Handle the global AJAX counter
\r
9330 if ( !( --jQuery.active ) ) {
\r
9331 jQuery.event.trigger("ajaxStop");
\r
9339 getJSON: function( url, data, callback ) {
\r
9340 return jQuery.get( url, data, callback, "json" );
\r
9343 getScript: function( url, callback ) {
\r
9344 return jQuery.get( url, undefined, callback, "script" );
\r
9348 jQuery.each( [ "get", "post" ], function( i, method ) {
\r
9349 jQuery[ method ] = function( url, data, callback, type ) {
\r
9350 // shift arguments if data argument was omitted
\r
9351 if ( jQuery.isFunction( data ) ) {
\r
9352 type = type || callback;
\r
9357 return jQuery.ajax({
\r
9367 // Attach a bunch of functions for handling common AJAX events
\r
9368 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
\r
9369 jQuery.fn[ type ] = function( fn ) {
\r
9370 return this.on( type, fn );
\r
9375 jQuery._evalUrl = function( url ) {
\r
9376 return jQuery.ajax({
\r
9379 dataType: "script",
\r
9387 jQuery.fn.extend({
\r
9388 wrapAll: function( html ) {
\r
9389 if ( jQuery.isFunction( html ) ) {
\r
9390 return this.each(function(i) {
\r
9391 jQuery(this).wrapAll( html.call(this, i) );
\r
9396 // The elements to wrap the target around
\r
9397 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
\r
9399 if ( this[0].parentNode ) {
\r
9400 wrap.insertBefore( this[0] );
\r
9403 wrap.map(function() {
\r
9406 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
\r
9407 elem = elem.firstChild;
\r
9411 }).append( this );
\r
9417 wrapInner: function( html ) {
\r
9418 if ( jQuery.isFunction( html ) ) {
\r
9419 return this.each(function(i) {
\r
9420 jQuery(this).wrapInner( html.call(this, i) );
\r
9424 return this.each(function() {
\r
9425 var self = jQuery( this ),
\r
9426 contents = self.contents();
\r
9428 if ( contents.length ) {
\r
9429 contents.wrapAll( html );
\r
9432 self.append( html );
\r
9437 wrap: function( html ) {
\r
9438 var isFunction = jQuery.isFunction( html );
\r
9440 return this.each(function(i) {
\r
9441 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
\r
9445 unwrap: function() {
\r
9446 return this.parent().each(function() {
\r
9447 if ( !jQuery.nodeName( this, "body" ) ) {
\r
9448 jQuery( this ).replaceWith( this.childNodes );
\r
9455 jQuery.expr.filters.hidden = function( elem ) {
\r
9456 // Support: Opera <= 12.12
\r
9457 // Opera reports offsetWidths and offsetHeights less than zero on some elements
\r
9458 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
\r
9459 (!support.reliableHiddenOffsets() &&
\r
9460 ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
\r
9463 jQuery.expr.filters.visible = function( elem ) {
\r
9464 return !jQuery.expr.filters.hidden( elem );
\r
9471 rbracket = /\[\]$/,
\r
9473 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
\r
9474 rsubmittable = /^(?:input|select|textarea|keygen)/i;
\r
9476 function buildParams( prefix, obj, traditional, add ) {
\r
9479 if ( jQuery.isArray( obj ) ) {
\r
9480 // Serialize array item.
\r
9481 jQuery.each( obj, function( i, v ) {
\r
9482 if ( traditional || rbracket.test( prefix ) ) {
\r
9483 // Treat each array item as a scalar.
\r
9487 // Item is non-scalar (array or object), encode its numeric index.
\r
9488 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
\r
9492 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
\r
9493 // Serialize object item.
\r
9494 for ( name in obj ) {
\r
9495 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
\r
9499 // Serialize scalar item.
\r
9500 add( prefix, obj );
\r
9504 // Serialize an array of form elements or a set of
\r
9505 // key/values into a query string
\r
9506 jQuery.param = function( a, traditional ) {
\r
9509 add = function( key, value ) {
\r
9510 // If value is a function, invoke it and return its value
\r
9511 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
\r
9512 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
\r
9515 // Set traditional to true for jQuery <= 1.3.2 behavior.
\r
9516 if ( traditional === undefined ) {
\r
9517 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
\r
9520 // If an array was passed in, assume that it is an array of form elements.
\r
9521 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
\r
9522 // Serialize the form elements
\r
9523 jQuery.each( a, function() {
\r
9524 add( this.name, this.value );
\r
9528 // If traditional, encode the "old" way (the way 1.3.2 or older
\r
9529 // did it), otherwise encode params recursively.
\r
9530 for ( prefix in a ) {
\r
9531 buildParams( prefix, a[ prefix ], traditional, add );
\r
9535 // Return the resulting serialization
\r
9536 return s.join( "&" ).replace( r20, "+" );
\r
9539 jQuery.fn.extend({
\r
9540 serialize: function() {
\r
9541 return jQuery.param( this.serializeArray() );
\r
9543 serializeArray: function() {
\r
9544 return this.map(function() {
\r
9545 // Can add propHook for "elements" to filter or add form elements
\r
9546 var elements = jQuery.prop( this, "elements" );
\r
9547 return elements ? jQuery.makeArray( elements ) : this;
\r
9549 .filter(function() {
\r
9550 var type = this.type;
\r
9551 // Use .is(":disabled") so that fieldset[disabled] works
\r
9552 return this.name && !jQuery( this ).is( ":disabled" ) &&
\r
9553 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
\r
9554 ( this.checked || !rcheckableType.test( type ) );
\r
9556 .map(function( i, elem ) {
\r
9557 var val = jQuery( this ).val();
\r
9559 return val == null ?
\r
9561 jQuery.isArray( val ) ?
\r
9562 jQuery.map( val, function( val ) {
\r
9563 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
\r
9565 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
\r
9571 // Create the request object
\r
9572 // (This is still attached to ajaxSettings for backward compatibility)
\r
9573 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
\r
9577 // XHR cannot access local files, always use ActiveX for that case
\r
9578 return !this.isLocal &&
\r
9581 // oldIE XHR does not support non-RFC2616 methods (#13240)
\r
9582 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
\r
9583 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
\r
9584 // Although this check for six methods instead of eight
\r
9585 // since IE also does not support "trace" and "connect"
\r
9586 /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
\r
9588 createStandardXHR() || createActiveXHR();
\r
9590 // For all other browsers, use the standard XMLHttpRequest object
\r
9591 createStandardXHR;
\r
9594 xhrCallbacks = {},
\r
9595 xhrSupported = jQuery.ajaxSettings.xhr();
\r
9598 // Open requests must be manually aborted on unload (#5280)
\r
9599 if ( window.ActiveXObject ) {
\r
9600 jQuery( window ).on( "unload", function() {
\r
9601 for ( var key in xhrCallbacks ) {
\r
9602 xhrCallbacks[ key ]( undefined, true );
\r
9607 // Determine support properties
\r
9608 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
\r
9609 xhrSupported = support.ajax = !!xhrSupported;
\r
9611 // Create transport if the browser can provide an xhr
\r
9612 if ( xhrSupported ) {
\r
9614 jQuery.ajaxTransport(function( options ) {
\r
9615 // Cross domain only allowed if supported through XMLHttpRequest
\r
9616 if ( !options.crossDomain || support.cors ) {
\r
9621 send: function( headers, complete ) {
\r
9623 xhr = options.xhr(),
\r
9626 // Open the socket
\r
9627 xhr.open( options.type, options.url, options.async, options.username, options.password );
\r
9629 // Apply custom fields if provided
\r
9630 if ( options.xhrFields ) {
\r
9631 for ( i in options.xhrFields ) {
\r
9632 xhr[ i ] = options.xhrFields[ i ];
\r
9636 // Override mime type if needed
\r
9637 if ( options.mimeType && xhr.overrideMimeType ) {
\r
9638 xhr.overrideMimeType( options.mimeType );
\r
9641 // X-Requested-With header
\r
9642 // For cross-domain requests, seeing as conditions for a preflight are
\r
9643 // akin to a jigsaw puzzle, we simply never set it to be sure.
\r
9644 // (it can always be set on a per-request basis or even using ajaxSetup)
\r
9645 // For same-domain requests, won't change header if already provided.
\r
9646 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
\r
9647 headers["X-Requested-With"] = "XMLHttpRequest";
\r
9651 for ( i in headers ) {
\r
9653 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
\r
9654 // request header to a null-value.
\r
9656 // To keep consistent with other XHR implementations, cast the value
\r
9657 // to string and ignore `undefined`.
\r
9658 if ( headers[ i ] !== undefined ) {
\r
9659 xhr.setRequestHeader( i, headers[ i ] + "" );
\r
9663 // Do send the request
\r
9664 // This may raise an exception which is actually
\r
9665 // handled in jQuery.ajax (so no try/catch here)
\r
9666 xhr.send( ( options.hasContent && options.data ) || null );
\r
9669 callback = function( _, isAbort ) {
\r
9670 var status, statusText, responses;
\r
9672 // Was never called and is aborted or complete
\r
9673 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
\r
9675 delete xhrCallbacks[ id ];
\r
9676 callback = undefined;
\r
9677 xhr.onreadystatechange = jQuery.noop;
\r
9679 // Abort manually if needed
\r
9681 if ( xhr.readyState !== 4 ) {
\r
9686 status = xhr.status;
\r
9689 // Accessing binary-data responseText throws an exception
\r
9691 if ( typeof xhr.responseText === "string" ) {
\r
9692 responses.text = xhr.responseText;
\r
9695 // Firefox throws an exception when accessing
\r
9696 // statusText for faulty cross-domain requests
\r
9698 statusText = xhr.statusText;
\r
9700 // We normalize with Webkit giving an empty statusText
\r
9704 // Filter status for non standard behaviors
\r
9706 // If the request is local and we have data: assume a success
\r
9707 // (success with no data won't get notified, that's the best we
\r
9708 // can do given current implementations)
\r
9709 if ( !status && options.isLocal && !options.crossDomain ) {
\r
9710 status = responses.text ? 200 : 404;
\r
9711 // IE - #1450: sometimes returns 1223 when it should be 204
\r
9712 } else if ( status === 1223 ) {
\r
9718 // Call complete if needed
\r
9719 if ( responses ) {
\r
9720 complete( status, statusText, responses, xhr.getAllResponseHeaders() );
\r
9724 if ( !options.async ) {
\r
9725 // if we're in sync mode we fire the callback
\r
9727 } else if ( xhr.readyState === 4 ) {
\r
9728 // (IE6 & IE7) if it's in cache and has been
\r
9729 // retrieved directly we need to fire the callback
\r
9730 setTimeout( callback );
\r
9732 // Add to the list of active xhr callbacks
\r
9733 xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
\r
9737 abort: function() {
\r
9739 callback( undefined, true );
\r
9747 // Functions to create xhrs
\r
9748 function createStandardXHR() {
\r
9750 return new window.XMLHttpRequest();
\r
9754 function createActiveXHR() {
\r
9756 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
\r
9763 // Install script dataType
\r
9764 jQuery.ajaxSetup({
\r
9766 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
\r
9769 script: /(?:java|ecma)script/
\r
9772 "text script": function( text ) {
\r
9773 jQuery.globalEval( text );
\r
9779 // Handle cache's special case and global
\r
9780 jQuery.ajaxPrefilter( "script", function( s ) {
\r
9781 if ( s.cache === undefined ) {
\r
9784 if ( s.crossDomain ) {
\r
9790 // Bind script tag hack transport
\r
9791 jQuery.ajaxTransport( "script", function(s) {
\r
9793 // This transport only deals with cross domain requests
\r
9794 if ( s.crossDomain ) {
\r
9797 head = document.head || jQuery("head")[0] || document.documentElement;
\r
9801 send: function( _, callback ) {
\r
9803 script = document.createElement("script");
\r
9805 script.async = true;
\r
9807 if ( s.scriptCharset ) {
\r
9808 script.charset = s.scriptCharset;
\r
9811 script.src = s.url;
\r
9813 // Attach handlers for all browsers
\r
9814 script.onload = script.onreadystatechange = function( _, isAbort ) {
\r
9816 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
\r
9818 // Handle memory leak in IE
\r
9819 script.onload = script.onreadystatechange = null;
\r
9821 // Remove the script
\r
9822 if ( script.parentNode ) {
\r
9823 script.parentNode.removeChild( script );
\r
9826 // Dereference the script
\r
9829 // Callback if not abort
\r
9831 callback( 200, "success" );
\r
9836 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
\r
9837 // Use native DOM manipulation to avoid our domManip AJAX trickery
\r
9838 head.insertBefore( script, head.firstChild );
\r
9841 abort: function() {
\r
9843 script.onload( undefined, true );
\r
9853 var oldCallbacks = [],
\r
9854 rjsonp = /(=)\?(?=&|$)|\?\?/;
\r
9856 // Default jsonp settings
\r
9857 jQuery.ajaxSetup({
\r
9858 jsonp: "callback",
\r
9859 jsonpCallback: function() {
\r
9860 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
\r
9861 this[ callback ] = true;
\r
9866 // Detect, normalize options and install callbacks for jsonp requests
\r
9867 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
\r
9869 var callbackName, overwritten, responseContainer,
\r
9870 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
\r
9872 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
\r
9875 // Handle iff the expected data type is "jsonp" or we have a parameter to set
\r
9876 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
\r
9878 // Get callback name, remembering preexisting value associated with it
\r
9879 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
\r
9880 s.jsonpCallback() :
\r
9883 // Insert callback into url or form data
\r
9885 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
\r
9886 } else if ( s.jsonp !== false ) {
\r
9887 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
\r
9890 // Use data converter to retrieve json after script execution
\r
9891 s.converters["script json"] = function() {
\r
9892 if ( !responseContainer ) {
\r
9893 jQuery.error( callbackName + " was not called" );
\r
9895 return responseContainer[ 0 ];
\r
9898 // force json dataType
\r
9899 s.dataTypes[ 0 ] = "json";
\r
9901 // Install callback
\r
9902 overwritten = window[ callbackName ];
\r
9903 window[ callbackName ] = function() {
\r
9904 responseContainer = arguments;
\r
9907 // Clean-up function (fires after converters)
\r
9908 jqXHR.always(function() {
\r
9909 // Restore preexisting value
\r
9910 window[ callbackName ] = overwritten;
\r
9912 // Save back as free
\r
9913 if ( s[ callbackName ] ) {
\r
9914 // make sure that re-using the options doesn't screw things around
\r
9915 s.jsonpCallback = originalSettings.jsonpCallback;
\r
9917 // save the callback name for future use
\r
9918 oldCallbacks.push( callbackName );
\r
9921 // Call if it was a function and we have a response
\r
9922 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
\r
9923 overwritten( responseContainer[ 0 ] );
\r
9926 responseContainer = overwritten = undefined;
\r
9929 // Delegate to script
\r
9937 // data: string of html
\r
9938 // context (optional): If specified, the fragment will be created in this context, defaults to document
\r
9939 // keepScripts (optional): If true, will include scripts passed in the html string
\r
9940 jQuery.parseHTML = function( data, context, keepScripts ) {
\r
9941 if ( !data || typeof data !== "string" ) {
\r
9944 if ( typeof context === "boolean" ) {
\r
9945 keepScripts = context;
\r
9948 context = context || document;
\r
9950 var parsed = rsingleTag.exec( data ),
\r
9951 scripts = !keepScripts && [];
\r
9955 return [ context.createElement( parsed[1] ) ];
\r
9958 parsed = jQuery.buildFragment( [ data ], context, scripts );
\r
9960 if ( scripts && scripts.length ) {
\r
9961 jQuery( scripts ).remove();
\r
9964 return jQuery.merge( [], parsed.childNodes );
\r
9968 // Keep a copy of the old load method
\r
9969 var _load = jQuery.fn.load;
\r
9972 * Load a url into a page
\r
9974 jQuery.fn.load = function( url, params, callback ) {
\r
9975 if ( typeof url !== "string" && _load ) {
\r
9976 return _load.apply( this, arguments );
\r
9979 var selector, response, type,
\r
9981 off = url.indexOf(" ");
\r
9984 selector = url.slice( off, url.length );
\r
9985 url = url.slice( 0, off );
\r
9988 // If it's a function
\r
9989 if ( jQuery.isFunction( params ) ) {
\r
9991 // We assume that it's the callback
\r
9992 callback = params;
\r
9993 params = undefined;
\r
9995 // Otherwise, build a param string
\r
9996 } else if ( params && typeof params === "object" ) {
\r
10000 // If we have elements to modify, make the request
\r
10001 if ( self.length > 0 ) {
\r
10005 // if "type" variable is undefined, then "GET" method will be used
\r
10007 dataType: "html",
\r
10009 }).done(function( responseText ) {
\r
10011 // Save response for use in complete callback
\r
10012 response = arguments;
\r
10014 self.html( selector ?
\r
10016 // If a selector was specified, locate the right elements in a dummy div
\r
10017 // Exclude scripts to avoid IE 'Permission Denied' errors
\r
10018 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
\r
10020 // Otherwise use the full result
\r
10023 }).complete( callback && function( jqXHR, status ) {
\r
10024 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
\r
10034 jQuery.expr.filters.animated = function( elem ) {
\r
10035 return jQuery.grep(jQuery.timers, function( fn ) {
\r
10036 return elem === fn.elem;
\r
10044 var docElem = window.document.documentElement;
\r
10047 * Gets a window from an element
\r
10049 function getWindow( elem ) {
\r
10050 return jQuery.isWindow( elem ) ?
\r
10052 elem.nodeType === 9 ?
\r
10053 elem.defaultView || elem.parentWindow :
\r
10057 jQuery.offset = {
\r
10058 setOffset: function( elem, options, i ) {
\r
10059 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
\r
10060 position = jQuery.css( elem, "position" ),
\r
10061 curElem = jQuery( elem ),
\r
10064 // set position first, in-case top/left are set even on static elem
\r
10065 if ( position === "static" ) {
\r
10066 elem.style.position = "relative";
\r
10069 curOffset = curElem.offset();
\r
10070 curCSSTop = jQuery.css( elem, "top" );
\r
10071 curCSSLeft = jQuery.css( elem, "left" );
\r
10072 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
\r
10073 jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
\r
10075 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
\r
10076 if ( calculatePosition ) {
\r
10077 curPosition = curElem.position();
\r
10078 curTop = curPosition.top;
\r
10079 curLeft = curPosition.left;
\r
10081 curTop = parseFloat( curCSSTop ) || 0;
\r
10082 curLeft = parseFloat( curCSSLeft ) || 0;
\r
10085 if ( jQuery.isFunction( options ) ) {
\r
10086 options = options.call( elem, i, curOffset );
\r
10089 if ( options.top != null ) {
\r
10090 props.top = ( options.top - curOffset.top ) + curTop;
\r
10092 if ( options.left != null ) {
\r
10093 props.left = ( options.left - curOffset.left ) + curLeft;
\r
10096 if ( "using" in options ) {
\r
10097 options.using.call( elem, props );
\r
10099 curElem.css( props );
\r
10104 jQuery.fn.extend({
\r
10105 offset: function( options ) {
\r
10106 if ( arguments.length ) {
\r
10107 return options === undefined ?
\r
10109 this.each(function( i ) {
\r
10110 jQuery.offset.setOffset( this, options, i );
\r
10114 var docElem, win,
\r
10115 box = { top: 0, left: 0 },
\r
10116 elem = this[ 0 ],
\r
10117 doc = elem && elem.ownerDocument;
\r
10123 docElem = doc.documentElement;
\r
10125 // Make sure it's not a disconnected DOM node
\r
10126 if ( !jQuery.contains( docElem, elem ) ) {
\r
10130 // If we don't have gBCR, just use 0,0 rather than error
\r
10131 // BlackBerry 5, iOS 3 (original iPhone)
\r
10132 if ( typeof elem.getBoundingClientRect !== strundefined ) {
\r
10133 box = elem.getBoundingClientRect();
\r
10135 win = getWindow( doc );
\r
10137 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
\r
10138 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
\r
10142 position: function() {
\r
10143 if ( !this[ 0 ] ) {
\r
10147 var offsetParent, offset,
\r
10148 parentOffset = { top: 0, left: 0 },
\r
10149 elem = this[ 0 ];
\r
10151 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
\r
10152 if ( jQuery.css( elem, "position" ) === "fixed" ) {
\r
10153 // we assume that getBoundingClientRect is available when computed position is fixed
\r
10154 offset = elem.getBoundingClientRect();
\r
10156 // Get *real* offsetParent
\r
10157 offsetParent = this.offsetParent();
\r
10159 // Get correct offsets
\r
10160 offset = this.offset();
\r
10161 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
\r
10162 parentOffset = offsetParent.offset();
\r
10165 // Add offsetParent borders
\r
10166 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
\r
10167 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
\r
10170 // Subtract parent offsets and element margins
\r
10171 // note: when an element has margin: auto the offsetLeft and marginLeft
\r
10172 // are the same in Safari causing offset.left to incorrectly be 0
\r
10174 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
\r
10175 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
\r
10179 offsetParent: function() {
\r
10180 return this.map(function() {
\r
10181 var offsetParent = this.offsetParent || docElem;
\r
10183 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
\r
10184 offsetParent = offsetParent.offsetParent;
\r
10186 return offsetParent || docElem;
\r
10191 // Create scrollLeft and scrollTop methods
\r
10192 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
\r
10193 var top = /Y/.test( prop );
\r
10195 jQuery.fn[ method ] = function( val ) {
\r
10196 return access( this, function( elem, method, val ) {
\r
10197 var win = getWindow( elem );
\r
10199 if ( val === undefined ) {
\r
10200 return win ? (prop in win) ? win[ prop ] :
\r
10201 win.document.documentElement[ method ] :
\r
10207 !top ? val : jQuery( win ).scrollLeft(),
\r
10208 top ? val : jQuery( win ).scrollTop()
\r
10212 elem[ method ] = val;
\r
10214 }, method, val, arguments.length, null );
\r
10218 // Add the top/left cssHooks using jQuery.fn.position
\r
10219 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
\r
10220 // getComputedStyle returns percent when specified for top/left/bottom/right
\r
10221 // rather than make the css module depend on the offset module, we just check for it here
\r
10222 jQuery.each( [ "top", "left" ], function( i, prop ) {
\r
10223 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
\r
10224 function( elem, computed ) {
\r
10225 if ( computed ) {
\r
10226 computed = curCSS( elem, prop );
\r
10227 // if curCSS returns percentage, fallback to offset
\r
10228 return rnumnonpx.test( computed ) ?
\r
10229 jQuery( elem ).position()[ prop ] + "px" :
\r
10237 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
\r
10238 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
\r
10239 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
\r
10240 // margin is only for outerHeight, outerWidth
\r
10241 jQuery.fn[ funcName ] = function( margin, value ) {
\r
10242 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
\r
10243 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
\r
10245 return access( this, function( elem, type, value ) {
\r
10248 if ( jQuery.isWindow( elem ) ) {
\r
10249 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
\r
10250 // isn't a whole lot we can do. See pull request at this URL for discussion:
\r
10251 // https://github.com/jquery/jquery/pull/764
\r
10252 return elem.document.documentElement[ "client" + name ];
\r
10255 // Get document width or height
\r
10256 if ( elem.nodeType === 9 ) {
\r
10257 doc = elem.documentElement;
\r
10259 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
\r
10260 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
\r
10262 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
\r
10263 elem.body[ "offset" + name ], doc[ "offset" + name ],
\r
10264 doc[ "client" + name ]
\r
10268 return value === undefined ?
\r
10269 // Get width or height on the element, requesting but not forcing parseFloat
\r
10270 jQuery.css( elem, type, extra ) :
\r
10272 // Set width or height on the element
\r
10273 jQuery.style( elem, type, value, extra );
\r
10274 }, type, chainable ? margin : undefined, chainable, null );
\r
10280 // The number of elements contained in the matched element set
\r
10281 jQuery.fn.size = function() {
\r
10282 return this.length;
\r
10285 jQuery.fn.andSelf = jQuery.fn.addBack;
\r
10290 // Register as a named AMD module, since jQuery can be concatenated with other
\r
10291 // files that may use define, but not via a proper concatenation script that
\r
10292 // understands anonymous AMD modules. A named AMD is safest and most robust
\r
10293 // way to register. Lowercase jquery is used because AMD module names are
\r
10294 // derived from file names, and jQuery is normally delivered in a lowercase
\r
10295 // file name. Do this after creating the global so that if an AMD module wants
\r
10296 // to call noConflict to hide this version of jQuery, it will work.
\r
10297 if ( typeof define === "function" && define.amd ) {
\r
10298 define( "jquery", [], function() {
\r
10307 // Map over jQuery in case of overwrite
\r
10308 _jQuery = window.jQuery,
\r
10310 // Map over the $ in case of overwrite
\r
10313 jQuery.noConflict = function( deep ) {
\r
10314 if ( window.$ === jQuery ) {
\r
10318 if ( deep && window.jQuery === jQuery ) {
\r
10319 window.jQuery = _jQuery;
\r
10325 // Expose jQuery and $ identifiers, even in
\r
10326 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
\r
10327 // and CommonJS for browser emulators (#13566)
\r
10328 if ( typeof noGlobal === strundefined ) {
\r
10329 window.jQuery = window.$ = jQuery;
\r