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 // modified by Bob Hanson for local MSIE 11 reading remote files
\r
17 (function( global, factory ) {
\r
19 if ( typeof module === "object" && typeof module.exports === "object" ) {
\r
20 // For CommonJS and CommonJS-like environments where a proper window is present,
\r
21 // execute the factory and get jQuery
\r
22 // For environments that do not inherently posses a window with a document
\r
23 // (such as Node.js), expose a jQuery-making factory as module.exports
\r
24 // This accentuates the need for the creation of a real window
\r
25 // e.g. var jQuery = require("jquery")(window);
\r
26 // See ticket #14549 for more info
\r
27 module.exports = global.document ?
\r
28 factory( global, true ) :
\r
30 if ( !w.document ) {
\r
31 throw new Error( "jQuery requires a window with a document" );
\r
33 return factory( w );
\r
39 // Pass this if window is not defined yet
\r
40 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
\r
42 // Can't do this because several apps including ASP.NET trace
\r
43 // the stack via arguments.caller.callee and Firefox dies if
\r
44 // you try to trace through "use strict" call chains. (#13335)
\r
45 // Support: Firefox 18+
\r
48 var deletedIds = [];
\r
50 var slice = deletedIds.slice;
\r
52 var concat = deletedIds.concat;
\r
54 var push = deletedIds.push;
\r
56 var indexOf = deletedIds.indexOf;
\r
58 var class2type = {};
\r
60 var toString = class2type.toString;
\r
62 var hasOwn = class2type.hasOwnProperty;
\r
73 // Define a local copy of jQuery
\r
74 jQuery = function( selector, context ) {
\r
75 // The jQuery object is actually just the init constructor 'enhanced'
\r
76 // Need init if jQuery is called (just allow error to be thrown if not included)
\r
77 return new jQuery.fn.init( selector, context );
\r
80 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
\r
81 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
\r
83 // Matches dashed string for camelizing
\r
84 rmsPrefix = /^-ms-/,
\r
85 rdashAlpha = /-([\da-z])/gi,
\r
87 // Used by jQuery.camelCase as callback to replace()
\r
88 fcamelCase = function( all, letter ) {
\r
89 return letter.toUpperCase();
\r
92 jQuery.fn = jQuery.prototype = {
\r
93 // The current version of jQuery being used
\r
96 constructor: jQuery,
\r
98 // Start with an empty selector
\r
101 // The default length of a jQuery object is 0
\r
104 toArray: function() {
\r
105 return slice.call( this );
\r
108 // Get the Nth element in the matched element set OR
\r
109 // Get the whole matched element set as a clean array
\r
110 get: function( num ) {
\r
111 return num != null ?
\r
113 // Return a 'clean' array
\r
114 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
\r
116 // Return just the object
\r
117 slice.call( this );
\r
120 // Take an array of elements and push it onto the stack
\r
121 // (returning the new matched element set)
\r
122 pushStack: function( elems ) {
\r
124 // Build a new jQuery matched element set
\r
125 var ret = jQuery.merge( this.constructor(), elems );
\r
127 // Add the old object onto the stack (as a reference)
\r
128 ret.prevObject = this;
\r
129 ret.context = this.context;
\r
131 // Return the newly-formed element set
\r
135 // Execute a callback for every element in the matched set.
\r
136 // (You can seed the arguments with an array of args, but this is
\r
137 // only used internally.)
\r
138 each: function( callback, args ) {
\r
139 return jQuery.each( this, callback, args );
\r
142 map: function( callback ) {
\r
143 return this.pushStack( jQuery.map(this, function( elem, i ) {
\r
144 return callback.call( elem, i, elem );
\r
148 slice: function() {
\r
149 return this.pushStack( slice.apply( this, arguments ) );
\r
152 first: function() {
\r
153 return this.eq( 0 );
\r
157 return this.eq( -1 );
\r
160 eq: function( i ) {
\r
161 var len = this.length,
\r
162 j = +i + ( i < 0 ? len : 0 );
\r
163 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
\r
167 return this.prevObject || this.constructor(null);
\r
170 // For internal use only.
\r
171 // Behaves like an Array's method, not like a jQuery method.
\r
173 sort: deletedIds.sort,
\r
174 splice: deletedIds.splice
\r
177 jQuery.extend = jQuery.fn.extend = function() {
\r
178 var src, copyIsArray, copy, name, options, clone,
\r
179 target = arguments[0] || {},
\r
181 length = arguments.length,
\r
184 // Handle a deep copy situation
\r
185 if ( typeof target === "boolean" ) {
\r
188 // skip the boolean and the target
\r
189 target = arguments[ i ] || {};
\r
193 // Handle case when target is a string or something (possible in deep copy)
\r
194 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
\r
198 // extend jQuery itself if only one argument is passed
\r
199 if ( i === length ) {
\r
204 for ( ; i < length; i++ ) {
\r
205 // Only deal with non-null/undefined values
\r
206 if ( (options = arguments[ i ]) != null ) {
\r
207 // Extend the base object
\r
208 for ( name in options ) {
\r
209 src = target[ name ];
\r
210 copy = options[ name ];
\r
212 // Prevent never-ending loop
\r
213 if ( target === copy ) {
\r
217 // Recurse if we're merging plain objects or arrays
\r
218 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
\r
219 if ( copyIsArray ) {
\r
220 copyIsArray = false;
\r
221 clone = src && jQuery.isArray(src) ? src : [];
\r
224 clone = src && jQuery.isPlainObject(src) ? src : {};
\r
227 // Never move original objects, clone them
\r
228 target[ name ] = jQuery.extend( deep, clone, copy );
\r
230 // Don't bring in undefined values
\r
231 } else if ( copy !== undefined ) {
\r
232 target[ name ] = copy;
\r
238 // Return the modified object
\r
243 // Unique for each copy of jQuery on the page
\r
244 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
\r
246 // Assume jQuery is ready without the ready module
\r
249 error: function( msg ) {
\r
250 throw new Error( msg );
\r
253 noop: function() {},
\r
255 // See test/unit/core.js for details concerning isFunction.
\r
256 // Since version 1.3, DOM methods and functions like alert
\r
257 // aren't supported. They return false on IE (#2968).
\r
258 isFunction: function( obj ) {
\r
259 return jQuery.type(obj) === "function";
\r
262 isArray: Array.isArray || function( obj ) {
\r
263 return jQuery.type(obj) === "array";
\r
266 isWindow: function( obj ) {
\r
267 /* jshint eqeqeq: false */
\r
268 return obj != null && obj == obj.window;
\r
271 isNumeric: function( obj ) {
\r
272 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
\r
273 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
\r
274 // subtraction forces infinities to NaN
\r
275 return obj - parseFloat( obj ) >= 0;
\r
278 isEmptyObject: function( obj ) {
\r
280 for ( name in obj ) {
\r
286 isPlainObject: function( obj ) {
\r
289 // Must be an Object.
\r
290 // Because of IE, we also have to check the presence of the constructor property.
\r
291 // Make sure that DOM nodes and window objects don't pass through, as well
\r
292 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
\r
297 // Not own constructor property must be Object
\r
298 if ( obj.constructor &&
\r
299 !hasOwn.call(obj, "constructor") &&
\r
300 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
\r
304 // IE8,9 Will throw exceptions on certain host objects #9897
\r
309 // Handle iteration over inherited properties before own properties.
\r
310 if ( support.ownLast ) {
\r
311 for ( key in obj ) {
\r
312 return hasOwn.call( obj, key );
\r
316 // Own properties are enumerated firstly, so to speed up,
\r
317 // if last one is own, then all properties are own.
\r
318 for ( key in obj ) {}
\r
320 return key === undefined || hasOwn.call( obj, key );
\r
323 type: function( obj ) {
\r
324 if ( obj == null ) {
\r
327 return typeof obj === "object" || typeof obj === "function" ?
\r
328 class2type[ toString.call(obj) ] || "object" :
\r
332 // Evaluates a script in a global context
\r
333 // Workarounds based on findings by Jim Driscoll
\r
334 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
\r
335 globalEval: function( data ) {
\r
336 if ( data && jQuery.trim( data ) ) {
\r
337 // We use execScript on Internet Explorer
\r
338 // We use an anonymous function so that context is window
\r
339 // rather than jQuery in Firefox
\r
340 ( window.execScript || function( data ) {
\r
341 window[ "eval" ].call( window, data );
\r
346 // Convert dashed to camelCase; used by the css and data modules
\r
347 // Microsoft forgot to hump their vendor prefix (#9572)
\r
348 camelCase: function( string ) {
\r
349 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
\r
352 nodeName: function( elem, name ) {
\r
353 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
\r
356 // args is for internal usage only
\r
357 each: function( obj, callback, args ) {
\r
360 length = obj.length,
\r
361 isArray = isArraylike( obj );
\r
365 for ( ; i < length; i++ ) {
\r
366 value = callback.apply( obj[ i ], args );
\r
368 if ( value === false ) {
\r
374 value = callback.apply( obj[ i ], args );
\r
376 if ( value === false ) {
\r
382 // A special, fast, case for the most common use of each
\r
385 for ( ; i < length; i++ ) {
\r
386 value = callback.call( obj[ i ], i, obj[ i ] );
\r
388 if ( value === false ) {
\r
394 value = callback.call( obj[ i ], i, obj[ i ] );
\r
396 if ( value === false ) {
\r
406 // Use native String.trim function wherever possible
\r
407 trim: trim && !trim.call("\uFEFF\xA0") ?
\r
409 return text == null ?
\r
414 // Otherwise use our own trimming functionality
\r
416 return text == null ?
\r
418 ( text + "" ).replace( rtrim, "" );
\r
421 // results is for internal usage only
\r
422 makeArray: function( arr, results ) {
\r
423 var ret = results || [];
\r
425 if ( arr != null ) {
\r
426 if ( isArraylike( Object(arr) ) ) {
\r
428 typeof arr === "string" ?
\r
432 push.call( ret, arr );
\r
439 inArray: function( elem, arr, i ) {
\r
444 return indexOf.call( arr, elem, i );
\r
448 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
\r
450 for ( ; i < len; i++ ) {
\r
451 // Skip accessing in sparse arrays
\r
452 if ( i in arr && arr[ i ] === elem ) {
\r
461 merge: function( first, second ) {
\r
462 var len = +second.length,
\r
466 while ( j < len ) {
\r
467 first[ i++ ] = second[ j++ ];
\r
471 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
\r
472 if ( len !== len ) {
\r
473 while ( second[j] !== undefined ) {
\r
474 first[ i++ ] = second[ j++ ];
\r
483 grep: function( elems, callback, invert ) {
\r
484 var callbackInverse,
\r
487 length = elems.length,
\r
488 callbackExpect = !invert;
\r
490 // Go through the array, only saving the items
\r
491 // that pass the validator function
\r
492 for ( ; i < length; i++ ) {
\r
493 callbackInverse = !callback( elems[ i ], i );
\r
494 if ( callbackInverse !== callbackExpect ) {
\r
495 matches.push( elems[ i ] );
\r
502 // arg is for internal usage only
\r
503 map: function( elems, callback, arg ) {
\r
506 length = elems.length,
\r
507 isArray = isArraylike( elems ),
\r
510 // Go through the array, translating each of the items to their new values
\r
512 for ( ; i < length; i++ ) {
\r
513 value = callback( elems[ i ], i, arg );
\r
515 if ( value != null ) {
\r
520 // Go through every key on the object,
\r
522 for ( i in elems ) {
\r
523 value = callback( elems[ i ], i, arg );
\r
525 if ( value != null ) {
\r
531 // Flatten any nested arrays
\r
532 return concat.apply( [], ret );
\r
535 // A global GUID counter for objects
\r
538 // Bind a function to a context, optionally partially applying any
\r
540 proxy: function( fn, context ) {
\r
541 var args, proxy, tmp;
\r
543 if ( typeof context === "string" ) {
\r
544 tmp = fn[ context ];
\r
549 // Quick check to determine if target is callable, in the spec
\r
550 // this throws a TypeError, but we will just return undefined.
\r
551 if ( !jQuery.isFunction( fn ) ) {
\r
556 args = slice.call( arguments, 2 );
\r
557 proxy = function() {
\r
558 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
\r
561 // Set the guid of unique handler to the same of original handler, so it can be removed
\r
562 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
\r
568 return +( new Date() );
\r
571 // jQuery.support is not used in Core but other projects attach their
\r
572 // properties to it so it needs to exist.
\r
576 // Populate the class2type map
\r
577 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
\r
578 class2type[ "[object " + name + "]" ] = name.toLowerCase();
\r
581 function isArraylike( obj ) {
\r
582 var length = obj.length,
\r
583 type = jQuery.type( obj );
\r
585 if ( type === "function" || jQuery.isWindow( obj ) ) {
\r
589 if ( obj.nodeType === 1 && length ) {
\r
593 return type === "array" || length === 0 ||
\r
594 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
\r
598 * Sizzle CSS Selector Engine v1.10.16
\r
599 * http://sizzlejs.com/
\r
601 * Copyright 2013 jQuery Foundation, Inc. and other contributors
\r
602 * Released under the MIT license
\r
603 * http://jquery.org/license
\r
607 (function( window ) {
\r
619 // Local document vars
\r
629 // Instance-specific data
\r
630 expando = "sizzle" + -(new Date()),
\r
631 preferredDoc = window.document,
\r
634 classCache = createCache(),
\r
635 tokenCache = createCache(),
\r
636 compilerCache = createCache(),
\r
637 sortOrder = function( a, b ) {
\r
639 hasDuplicate = true;
\r
644 // General-purpose constants
\r
645 strundefined = typeof undefined,
\r
646 MAX_NEGATIVE = 1 << 31,
\r
648 // Instance methods
\r
649 hasOwn = ({}).hasOwnProperty,
\r
652 push_native = arr.push,
\r
655 // Use a stripped-down indexOf if we can't use a native one
\r
656 indexOf = arr.indexOf || function( elem ) {
\r
659 for ( ; i < len; i++ ) {
\r
660 if ( this[i] === elem ) {
\r
667 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
\r
669 // Regular expressions
\r
671 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
\r
672 whitespace = "[\\x20\\t\\r\\n\\f]",
\r
673 // http://www.w3.org/TR/css3-syntax/#characters
\r
674 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
\r
676 // Loosely modeled on CSS identifier characters
\r
677 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
\r
678 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
\r
679 identifier = characterEncoding.replace( "w", "w#" ),
\r
681 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
\r
682 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
\r
683 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
\r
685 // Prefer arguments quoted,
\r
686 // then not containing pseudos/brackets,
\r
687 // then attribute selectors/non-parenthetical expressions,
\r
688 // then anything else
\r
689 // These preferences are here to reduce the number of selectors
\r
690 // needing tokenize in the PSEUDO preFilter
\r
691 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
\r
693 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
\r
694 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
\r
696 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
\r
697 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
\r
699 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
\r
701 rpseudo = new RegExp( pseudos ),
\r
702 ridentifier = new RegExp( "^" + identifier + "$" ),
\r
705 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
\r
706 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
\r
707 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
\r
708 "ATTR": new RegExp( "^" + attributes ),
\r
709 "PSEUDO": new RegExp( "^" + pseudos ),
\r
710 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
\r
711 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
\r
712 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
\r
713 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
\r
714 // For use in libraries implementing .is()
\r
715 // We use this for POS matching in `select`
\r
716 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
\r
717 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
\r
720 rinputs = /^(?:input|select|textarea|button)$/i,
\r
721 rheader = /^h\d$/i,
\r
723 rnative = /^[^{]+\{\s*\[native \w/,
\r
725 // Easily-parseable/retrievable ID or TAG or CLASS selectors
\r
726 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
\r
731 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
\r
732 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
\r
733 funescape = function( _, escaped, escapedWhitespace ) {
\r
734 var high = "0x" + escaped - 0x10000;
\r
735 // NaN means non-codepoint
\r
736 // Support: Firefox
\r
737 // Workaround erroneous numeric interpretation of +"0x"
\r
738 return high !== high || escapedWhitespace ?
\r
742 String.fromCharCode( high + 0x10000 ) :
\r
743 // Supplemental Plane codepoint (surrogate pair)
\r
744 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
\r
747 // Optimize for push.apply( _, NodeList )
\r
750 (arr = slice.call( preferredDoc.childNodes )),
\r
751 preferredDoc.childNodes
\r
753 // Support: Android<4.0
\r
754 // Detect silently failing push.apply
\r
755 arr[ preferredDoc.childNodes.length ].nodeType;
\r
757 push = { apply: arr.length ?
\r
759 // Leverage slice if possible
\r
760 function( target, els ) {
\r
761 push_native.apply( target, slice.call(els) );
\r
765 // Otherwise append directly
\r
766 function( target, els ) {
\r
767 var j = target.length,
\r
769 // Can't trust NodeList.length
\r
770 while ( (target[j++] = els[i++]) ) {}
\r
771 target.length = j - 1;
\r
776 function Sizzle( selector, context, results, seed ) {
\r
777 var match, elem, m, nodeType,
\r
779 i, groups, old, nid, newContext, newSelector;
\r
781 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
\r
782 setDocument( context );
\r
785 context = context || document;
\r
786 results = results || [];
\r
788 if ( !selector || typeof selector !== "string" ) {
\r
792 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
\r
796 if ( documentIsHTML && !seed ) {
\r
799 if ( (match = rquickExpr.exec( selector )) ) {
\r
800 // Speed-up: Sizzle("#ID")
\r
801 if ( (m = match[1]) ) {
\r
802 if ( nodeType === 9 ) {
\r
803 elem = context.getElementById( m );
\r
804 // Check parentNode to catch when Blackberry 4.6 returns
\r
805 // nodes that are no longer in the document (jQuery #6963)
\r
806 if ( elem && elem.parentNode ) {
\r
807 // Handle the case where IE, Opera, and Webkit return items
\r
808 // by name instead of ID
\r
809 if ( elem.id === m ) {
\r
810 results.push( elem );
\r
817 // Context is not a document
\r
818 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
\r
819 contains( context, elem ) && elem.id === m ) {
\r
820 results.push( elem );
\r
825 // Speed-up: Sizzle("TAG")
\r
826 } else if ( match[2] ) {
\r
827 push.apply( results, context.getElementsByTagName( selector ) );
\r
830 // Speed-up: Sizzle(".CLASS")
\r
831 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
\r
832 push.apply( results, context.getElementsByClassName( m ) );
\r
838 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
\r
839 nid = old = expando;
\r
840 newContext = context;
\r
841 newSelector = nodeType === 9 && selector;
\r
843 // qSA works strangely on Element-rooted queries
\r
844 // We can work around this by specifying an extra ID on the root
\r
845 // and working up from there (Thanks to Andrew Dupont for the technique)
\r
846 // IE 8 doesn't work on object elements
\r
847 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
\r
848 groups = tokenize( selector );
\r
850 if ( (old = context.getAttribute("id")) ) {
\r
851 nid = old.replace( rescape, "\\$&" );
\r
853 context.setAttribute( "id", nid );
\r
855 nid = "[id='" + nid + "'] ";
\r
859 groups[i] = nid + toSelector( groups[i] );
\r
861 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
\r
862 newSelector = groups.join(",");
\r
865 if ( newSelector ) {
\r
867 push.apply( results,
\r
868 newContext.querySelectorAll( newSelector )
\r
871 } catch(qsaError) {
\r
874 context.removeAttribute("id");
\r
882 return select( selector.replace( rtrim, "$1" ), context, results, seed );
\r
886 * Create key-value caches of limited size
\r
887 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
\r
888 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
\r
889 * deleting the oldest entry
\r
891 function createCache() {
\r
894 function cache( key, value ) {
\r
895 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
\r
896 if ( keys.push( key + " " ) > Expr.cacheLength ) {
\r
897 // Only keep the most recent entries
\r
898 delete cache[ keys.shift() ];
\r
900 return (cache[ key + " " ] = value);
\r
906 * Mark a function for special use by Sizzle
\r
907 * @param {Function} fn The function to mark
\r
909 function markFunction( fn ) {
\r
910 fn[ expando ] = true;
\r
915 * Support testing using an element
\r
916 * @param {Function} fn Passed the created div and expects a boolean result
\r
918 function assert( fn ) {
\r
919 var div = document.createElement("div");
\r
922 return !!fn( div );
\r
926 // Remove from its parent by default
\r
927 if ( div.parentNode ) {
\r
928 div.parentNode.removeChild( div );
\r
930 // release memory in IE
\r
936 * Adds the same handler for all of the specified attrs
\r
937 * @param {String} attrs Pipe-separated list of attributes
\r
938 * @param {Function} handler The method that will be applied
\r
940 function addHandle( attrs, handler ) {
\r
941 var arr = attrs.split("|"),
\r
945 Expr.attrHandle[ arr[i] ] = handler;
\r
950 * Checks document order of two siblings
\r
951 * @param {Element} a
\r
952 * @param {Element} b
\r
953 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
\r
955 function siblingCheck( a, b ) {
\r
957 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
\r
958 ( ~b.sourceIndex || MAX_NEGATIVE ) -
\r
959 ( ~a.sourceIndex || MAX_NEGATIVE );
\r
961 // Use IE sourceIndex if available on both nodes
\r
966 // Check if b follows a
\r
968 while ( (cur = cur.nextSibling) ) {
\r
979 * Returns a function to use in pseudos for input types
\r
980 * @param {String} type
\r
982 function createInputPseudo( type ) {
\r
983 return function( elem ) {
\r
984 var name = elem.nodeName.toLowerCase();
\r
985 return name === "input" && elem.type === type;
\r
990 * Returns a function to use in pseudos for buttons
\r
991 * @param {String} type
\r
993 function createButtonPseudo( type ) {
\r
994 return function( elem ) {
\r
995 var name = elem.nodeName.toLowerCase();
\r
996 return (name === "input" || name === "button") && elem.type === type;
\r
1001 * Returns a function to use in pseudos for positionals
\r
1002 * @param {Function} fn
\r
1004 function createPositionalPseudo( fn ) {
\r
1005 return markFunction(function( argument ) {
\r
1006 argument = +argument;
\r
1007 return markFunction(function( seed, matches ) {
\r
1009 matchIndexes = fn( [], seed.length, argument ),
\r
1010 i = matchIndexes.length;
\r
1012 // Match elements found at the specified indexes
\r
1014 if ( seed[ (j = matchIndexes[i]) ] ) {
\r
1015 seed[j] = !(matches[j] = seed[j]);
\r
1023 * Checks a node for validity as a Sizzle context
\r
1024 * @param {Element|Object=} context
\r
1025 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
\r
1027 function testContext( context ) {
\r
1028 return context && typeof context.getElementsByTagName !== strundefined && context;
\r
1031 // Expose support vars for convenience
\r
1032 support = Sizzle.support = {};
\r
1035 * Detects XML nodes
\r
1036 * @param {Element|Object} elem An element or a document
\r
1037 * @returns {Boolean} True iff elem is a non-HTML XML node
\r
1039 isXML = Sizzle.isXML = function( elem ) {
\r
1040 // documentElement is verified for cases where it doesn't yet exist
\r
1041 // (such as loading iframes in IE - #4833)
\r
1042 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
\r
1043 return documentElement ? documentElement.nodeName !== "HTML" : false;
\r
1047 * Sets document-related variables once based on the current document
\r
1048 * @param {Element|Object} [doc] An element or document object to use to set the document
\r
1049 * @returns {Object} Returns the current document
\r
1051 setDocument = Sizzle.setDocument = function( node ) {
\r
1053 doc = node ? node.ownerDocument || node : preferredDoc,
\r
1054 parent = doc.defaultView;
\r
1056 // If no document and documentElement is available, return
\r
1057 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
\r
1061 // Set our document
\r
1063 docElem = doc.documentElement;
\r
1066 documentIsHTML = !isXML( doc );
\r
1069 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
\r
1070 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
\r
1071 // IE6-8 do not support the defaultView property so parent will be undefined
\r
1072 if ( parent && parent !== parent.top ) {
\r
1073 // IE11 does not have attachEvent, so all must suffer
\r
1074 if ( parent.addEventListener ) {
\r
1075 parent.addEventListener( "unload", function() {
\r
1078 } else if ( parent.attachEvent ) {
\r
1079 parent.attachEvent( "onunload", function() {
\r
1086 ---------------------------------------------------------------------- */
\r
1089 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
\r
1090 support.attributes = assert(function( div ) {
\r
1091 div.className = "i";
\r
1092 return !div.getAttribute("className");
\r
1095 /* getElement(s)By*
\r
1096 ---------------------------------------------------------------------- */
\r
1098 // Check if getElementsByTagName("*") returns only elements
\r
1099 support.getElementsByTagName = assert(function( div ) {
\r
1100 div.appendChild( doc.createComment("") );
\r
1101 return !div.getElementsByTagName("*").length;
\r
1104 // Check if getElementsByClassName can be trusted
\r
1105 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
\r
1106 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
\r
1108 // Support: Safari<4
\r
1109 // Catch class over-caching
\r
1110 div.firstChild.className = "i";
\r
1111 // Support: Opera<10
\r
1112 // Catch gEBCN failure to find non-leading classes
\r
1113 return div.getElementsByClassName("i").length === 2;
\r
1117 // Check if getElementById returns elements by name
\r
1118 // The broken getElementById methods don't pick up programatically-set names,
\r
1119 // so use a roundabout getElementsByName test
\r
1120 support.getById = assert(function( div ) {
\r
1121 docElem.appendChild( div ).id = expando;
\r
1122 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
\r
1125 // ID find and filter
\r
1126 if ( support.getById ) {
\r
1127 Expr.find["ID"] = function( id, context ) {
\r
1128 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
\r
1129 var m = context.getElementById( id );
\r
1130 // Check parentNode to catch when Blackberry 4.6 returns
\r
1131 // nodes that are no longer in the document #6963
\r
1132 return m && m.parentNode ? [m] : [];
\r
1135 Expr.filter["ID"] = function( id ) {
\r
1136 var attrId = id.replace( runescape, funescape );
\r
1137 return function( elem ) {
\r
1138 return elem.getAttribute("id") === attrId;
\r
1143 // getElementById is not reliable as a find shortcut
\r
1144 delete Expr.find["ID"];
\r
1146 Expr.filter["ID"] = function( id ) {
\r
1147 var attrId = id.replace( runescape, funescape );
\r
1148 return function( elem ) {
\r
1149 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
\r
1150 return node && node.value === attrId;
\r
1156 Expr.find["TAG"] = support.getElementsByTagName ?
\r
1157 function( tag, context ) {
\r
1158 if ( typeof context.getElementsByTagName !== strundefined ) {
\r
1159 return context.getElementsByTagName( tag );
\r
1162 function( tag, context ) {
\r
1166 results = context.getElementsByTagName( tag );
\r
1168 // Filter out possible comments
\r
1169 if ( tag === "*" ) {
\r
1170 while ( (elem = results[i++]) ) {
\r
1171 if ( elem.nodeType === 1 ) {
\r
1182 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
\r
1183 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
\r
1184 return context.getElementsByClassName( className );
\r
1188 /* QSA/matchesSelector
\r
1189 ---------------------------------------------------------------------- */
\r
1191 // QSA and matchesSelector support
\r
1193 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
\r
1194 rbuggyMatches = [];
\r
1196 // qSa(:focus) reports false when true (Chrome 21)
\r
1197 // We allow this because of a bug in IE8/9 that throws an error
\r
1198 // whenever `document.activeElement` is accessed on an iframe
\r
1199 // So, we allow :focus to pass through QSA all the time to avoid the IE error
\r
1200 // See http://bugs.jquery.com/ticket/13378
\r
1203 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
\r
1204 // Build QSA regex
\r
1205 // Regex strategy adopted from Diego Perini
\r
1206 assert(function( div ) {
\r
1207 // Select is set to empty string on purpose
\r
1208 // This is to test IE's treatment of not explicitly
\r
1209 // setting a boolean content attribute,
\r
1210 // since its presence should be enough
\r
1211 // http://bugs.jquery.com/ticket/12359
\r
1212 div.innerHTML = "<select t=''><option selected=''></option></select>";
\r
1214 // Support: IE8, Opera 10-12
\r
1215 // Nothing should be selected when empty strings follow ^= or $= or *=
\r
1216 if ( div.querySelectorAll("[t^='']").length ) {
\r
1217 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
\r
1221 // Boolean attributes and "value" are not treated correctly
\r
1222 if ( !div.querySelectorAll("[selected]").length ) {
\r
1223 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
\r
1226 // Webkit/Opera - :checked should return selected option elements
\r
1227 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
\r
1228 // IE8 throws error here and will not see later tests
\r
1229 if ( !div.querySelectorAll(":checked").length ) {
\r
1230 rbuggyQSA.push(":checked");
\r
1234 assert(function( div ) {
\r
1235 // Support: Windows 8 Native Apps
\r
1236 // The type and name attributes are restricted during .innerHTML assignment
\r
1237 var input = doc.createElement("input");
\r
1238 input.setAttribute( "type", "hidden" );
\r
1239 div.appendChild( input ).setAttribute( "name", "D" );
\r
1242 // Enforce case-sensitivity of name attribute
\r
1243 if ( div.querySelectorAll("[name=d]").length ) {
\r
1244 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
\r
1247 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
\r
1248 // IE8 throws error here and will not see later tests
\r
1249 if ( !div.querySelectorAll(":enabled").length ) {
\r
1250 rbuggyQSA.push( ":enabled", ":disabled" );
\r
1253 // Opera 10-11 does not throw on post-comma invalid pseudos
\r
1254 div.querySelectorAll("*,:x");
\r
1255 rbuggyQSA.push(",.*:");
\r
1259 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
\r
1260 docElem.mozMatchesSelector ||
\r
1261 docElem.oMatchesSelector ||
\r
1262 docElem.msMatchesSelector) )) ) {
\r
1264 assert(function( div ) {
\r
1265 // Check to see if it's possible to do matchesSelector
\r
1266 // on a disconnected node (IE 9)
\r
1267 support.disconnectedMatch = matches.call( div, "div" );
\r
1269 // This should fail with an exception
\r
1270 // Gecko does not error, returns false instead
\r
1271 matches.call( div, "[s!='']:x" );
\r
1272 rbuggyMatches.push( "!=", pseudos );
\r
1276 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
\r
1277 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
\r
1280 ---------------------------------------------------------------------- */
\r
1281 hasCompare = rnative.test( docElem.compareDocumentPosition );
\r
1283 // Element contains another
\r
1284 // Purposefully does not implement inclusive descendent
\r
1285 // As in, an element does not contain itself
\r
1286 contains = hasCompare || rnative.test( docElem.contains ) ?
\r
1287 function( a, b ) {
\r
1288 var adown = a.nodeType === 9 ? a.documentElement : a,
\r
1289 bup = b && b.parentNode;
\r
1290 return a === bup || !!( bup && bup.nodeType === 1 && (
\r
1292 adown.contains( bup ) :
\r
1293 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
\r
1296 function( a, b ) {
\r
1298 while ( (b = b.parentNode) ) {
\r
1308 ---------------------------------------------------------------------- */
\r
1310 // Document order sorting
\r
1311 sortOrder = hasCompare ?
\r
1312 function( a, b ) {
\r
1314 // Flag for duplicate removal
\r
1316 hasDuplicate = true;
\r
1320 // Sort on method existence if only one input has compareDocumentPosition
\r
1321 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
\r
1326 // Calculate position if both inputs belong to the same document
\r
1327 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
\r
1328 a.compareDocumentPosition( b ) :
\r
1330 // Otherwise we know they are disconnected
\r
1333 // Disconnected nodes
\r
1334 if ( compare & 1 ||
\r
1335 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
\r
1337 // Choose the first element that is related to our preferred document
\r
1338 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
\r
1341 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
\r
1345 // Maintain original order
\r
1346 return sortInput ?
\r
1347 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
\r
1351 return compare & 4 ? -1 : 1;
\r
1353 function( a, b ) {
\r
1354 // Exit early if the nodes are identical
\r
1356 hasDuplicate = true;
\r
1362 aup = a.parentNode,
\r
1363 bup = b.parentNode,
\r
1367 // Parentless nodes are either documents or disconnected
\r
1368 if ( !aup || !bup ) {
\r
1369 return a === doc ? -1 :
\r
1374 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
\r
1377 // If the nodes are siblings, we can do a quick check
\r
1378 } else if ( aup === bup ) {
\r
1379 return siblingCheck( a, b );
\r
1382 // Otherwise we need full lists of their ancestors for comparison
\r
1384 while ( (cur = cur.parentNode) ) {
\r
1385 ap.unshift( cur );
\r
1388 while ( (cur = cur.parentNode) ) {
\r
1389 bp.unshift( cur );
\r
1392 // Walk down the tree looking for a discrepancy
\r
1393 while ( ap[i] === bp[i] ) {
\r
1398 // Do a sibling check if the nodes have a common ancestor
\r
1399 siblingCheck( ap[i], bp[i] ) :
\r
1401 // Otherwise nodes in our document sort first
\r
1402 ap[i] === preferredDoc ? -1 :
\r
1403 bp[i] === preferredDoc ? 1 :
\r
1410 Sizzle.matches = function( expr, elements ) {
\r
1411 return Sizzle( expr, null, null, elements );
\r
1414 Sizzle.matchesSelector = function( elem, expr ) {
\r
1415 // Set document vars if needed
\r
1416 if ( ( elem.ownerDocument || elem ) !== document ) {
\r
1417 setDocument( elem );
\r
1420 // Make sure that attribute selectors are quoted
\r
1421 expr = expr.replace( rattributeQuotes, "='$1']" );
\r
1423 if ( support.matchesSelector && documentIsHTML &&
\r
1424 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
\r
1425 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
\r
1428 var ret = matches.call( elem, expr );
\r
1430 // IE 9's matchesSelector returns false on disconnected nodes
\r
1431 if ( ret || support.disconnectedMatch ||
\r
1432 // As well, disconnected nodes are said to be in a document
\r
1433 // fragment in IE 9
\r
1434 elem.document && elem.document.nodeType !== 11 ) {
\r
1440 return Sizzle( expr, document, null, [elem] ).length > 0;
\r
1443 Sizzle.contains = function( context, elem ) {
\r
1444 // Set document vars if needed
\r
1445 if ( ( context.ownerDocument || context ) !== document ) {
\r
1446 setDocument( context );
\r
1448 return contains( context, elem );
\r
1451 Sizzle.attr = function( elem, name ) {
\r
1452 // Set document vars if needed
\r
1453 if ( ( elem.ownerDocument || elem ) !== document ) {
\r
1454 setDocument( elem );
\r
1457 var fn = Expr.attrHandle[ name.toLowerCase() ],
\r
1458 // Don't get fooled by Object.prototype properties (jQuery #13807)
\r
1459 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
\r
1460 fn( elem, name, !documentIsHTML ) :
\r
1463 return val !== undefined ?
\r
1465 support.attributes || !documentIsHTML ?
\r
1466 elem.getAttribute( name ) :
\r
1467 (val = elem.getAttributeNode(name)) && val.specified ?
\r
1472 Sizzle.error = function( msg ) {
\r
1473 throw new Error( "Syntax error, unrecognized expression: " + msg );
\r
1477 * Document sorting and removing duplicates
\r
1478 * @param {ArrayLike} results
\r
1480 Sizzle.uniqueSort = function( results ) {
\r
1486 // Unless we *know* we can detect duplicates, assume their presence
\r
1487 hasDuplicate = !support.detectDuplicates;
\r
1488 sortInput = !support.sortStable && results.slice( 0 );
\r
1489 results.sort( sortOrder );
\r
1491 if ( hasDuplicate ) {
\r
1492 while ( (elem = results[i++]) ) {
\r
1493 if ( elem === results[ i ] ) {
\r
1494 j = duplicates.push( i );
\r
1498 results.splice( duplicates[ j ], 1 );
\r
1502 // Clear input after sorting to release objects
\r
1503 // See https://github.com/jquery/sizzle/pull/225
\r
1510 * Utility function for retrieving the text value of an array of DOM nodes
\r
1511 * @param {Array|Element} elem
\r
1513 getText = Sizzle.getText = function( elem ) {
\r
1517 nodeType = elem.nodeType;
\r
1519 if ( !nodeType ) {
\r
1520 // If no nodeType, this is expected to be an array
\r
1521 while ( (node = elem[i++]) ) {
\r
1522 // Do not traverse comment nodes
\r
1523 ret += getText( node );
\r
1525 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
\r
1526 // Use textContent for elements
\r
1527 // innerText usage removed for consistency of new lines (jQuery #11153)
\r
1528 if ( typeof elem.textContent === "string" ) {
\r
1529 return elem.textContent;
\r
1531 // Traverse its children
\r
1532 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
\r
1533 ret += getText( elem );
\r
1536 } else if ( nodeType === 3 || nodeType === 4 ) {
\r
1537 return elem.nodeValue;
\r
1539 // Do not include comment or processing instruction nodes
\r
1544 Expr = Sizzle.selectors = {
\r
1546 // Can be adjusted by the user
\r
1549 createPseudo: markFunction,
\r
1558 ">": { dir: "parentNode", first: true },
\r
1559 " ": { dir: "parentNode" },
\r
1560 "+": { dir: "previousSibling", first: true },
\r
1561 "~": { dir: "previousSibling" }
\r
1565 "ATTR": function( match ) {
\r
1566 match[1] = match[1].replace( runescape, funescape );
\r
1568 // Move the given value to match[3] whether quoted or unquoted
\r
1569 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
\r
1571 if ( match[2] === "~=" ) {
\r
1572 match[3] = " " + match[3] + " ";
\r
1575 return match.slice( 0, 4 );
\r
1578 "CHILD": function( match ) {
\r
1579 /* matches from matchExpr["CHILD"]
\r
1580 1 type (only|nth|...)
\r
1581 2 what (child|of-type)
\r
1582 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
\r
1583 4 xn-component of xn+y argument ([+-]?\d*n|)
\r
1584 5 sign of xn-component
\r
1585 6 x of xn-component
\r
1586 7 sign of y-component
\r
1587 8 y of y-component
\r
1589 match[1] = match[1].toLowerCase();
\r
1591 if ( match[1].slice( 0, 3 ) === "nth" ) {
\r
1592 // nth-* requires argument
\r
1593 if ( !match[3] ) {
\r
1594 Sizzle.error( match[0] );
\r
1597 // numeric x and y parameters for Expr.filter.CHILD
\r
1598 // remember that false/true cast respectively to 0/1
\r
1599 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
\r
1600 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
\r
1602 // other types prohibit arguments
\r
1603 } else if ( match[3] ) {
\r
1604 Sizzle.error( match[0] );
\r
1610 "PSEUDO": function( match ) {
\r
1612 unquoted = !match[5] && match[2];
\r
1614 if ( matchExpr["CHILD"].test( match[0] ) ) {
\r
1618 // Accept quoted arguments as-is
\r
1619 if ( match[3] && match[4] !== undefined ) {
\r
1620 match[2] = match[4];
\r
1622 // Strip excess characters from unquoted arguments
\r
1623 } else if ( unquoted && rpseudo.test( unquoted ) &&
\r
1624 // Get excess from tokenize (recursively)
\r
1625 (excess = tokenize( unquoted, true )) &&
\r
1626 // advance to the next closing parenthesis
\r
1627 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
\r
1629 // excess is a negative index
\r
1630 match[0] = match[0].slice( 0, excess );
\r
1631 match[2] = unquoted.slice( 0, excess );
\r
1634 // Return only captures needed by the pseudo filter method (type and argument)
\r
1635 return match.slice( 0, 3 );
\r
1641 "TAG": function( nodeNameSelector ) {
\r
1642 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
\r
1643 return nodeNameSelector === "*" ?
\r
1644 function() { return true; } :
\r
1645 function( elem ) {
\r
1646 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
\r
1650 "CLASS": function( className ) {
\r
1651 var pattern = classCache[ className + " " ];
\r
1654 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
\r
1655 classCache( className, function( elem ) {
\r
1656 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
\r
1660 "ATTR": function( name, operator, check ) {
\r
1661 return function( elem ) {
\r
1662 var result = Sizzle.attr( elem, name );
\r
1664 if ( result == null ) {
\r
1665 return operator === "!=";
\r
1667 if ( !operator ) {
\r
1673 return operator === "=" ? result === check :
\r
1674 operator === "!=" ? result !== check :
\r
1675 operator === "^=" ? check && result.indexOf( check ) === 0 :
\r
1676 operator === "*=" ? check && result.indexOf( check ) > -1 :
\r
1677 operator === "$=" ? check && result.slice( -check.length ) === check :
\r
1678 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
\r
1679 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
\r
1684 "CHILD": function( type, what, argument, first, last ) {
\r
1685 var simple = type.slice( 0, 3 ) !== "nth",
\r
1686 forward = type.slice( -4 ) !== "last",
\r
1687 ofType = what === "of-type";
\r
1689 return first === 1 && last === 0 ?
\r
1691 // Shortcut for :nth-*(n)
\r
1692 function( elem ) {
\r
1693 return !!elem.parentNode;
\r
1696 function( elem, context, xml ) {
\r
1697 var cache, outerCache, node, diff, nodeIndex, start,
\r
1698 dir = simple !== forward ? "nextSibling" : "previousSibling",
\r
1699 parent = elem.parentNode,
\r
1700 name = ofType && elem.nodeName.toLowerCase(),
\r
1701 useCache = !xml && !ofType;
\r
1705 // :(first|last|only)-(child|of-type)
\r
1709 while ( (node = node[ dir ]) ) {
\r
1710 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
\r
1714 // Reverse direction for :only-* (if we haven't yet done so)
\r
1715 start = dir = type === "only" && !start && "nextSibling";
\r
1720 start = [ forward ? parent.firstChild : parent.lastChild ];
\r
1722 // non-xml :nth-child(...) stores cache data on `parent`
\r
1723 if ( forward && useCache ) {
\r
1724 // Seek `elem` from a previously-cached index
\r
1725 outerCache = parent[ expando ] || (parent[ expando ] = {});
\r
1726 cache = outerCache[ type ] || [];
\r
1727 nodeIndex = cache[0] === dirruns && cache[1];
\r
1728 diff = cache[0] === dirruns && cache[2];
\r
1729 node = nodeIndex && parent.childNodes[ nodeIndex ];
\r
1731 while ( (node = ++nodeIndex && node && node[ dir ] ||
\r
1733 // Fallback to seeking `elem` from the start
\r
1734 (diff = nodeIndex = 0) || start.pop()) ) {
\r
1736 // When found, cache indexes on `parent` and break
\r
1737 if ( node.nodeType === 1 && ++diff && node === elem ) {
\r
1738 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
\r
1743 // Use previously-cached element index if available
\r
1744 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
\r
1747 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
\r
1749 // Use the same loop as above to seek `elem` from the start
\r
1750 while ( (node = ++nodeIndex && node && node[ dir ] ||
\r
1751 (diff = nodeIndex = 0) || start.pop()) ) {
\r
1753 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
\r
1754 // Cache the index of each encountered element
\r
1756 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
\r
1759 if ( node === elem ) {
\r
1766 // Incorporate the offset, then check against cycle size
\r
1768 return diff === first || ( diff % first === 0 && diff / first >= 0 );
\r
1773 "PSEUDO": function( pseudo, argument ) {
\r
1774 // pseudo-class names are case-insensitive
\r
1775 // http://www.w3.org/TR/selectors/#pseudo-classes
\r
1776 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
\r
1777 // Remember that setFilters inherits from pseudos
\r
1779 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
\r
1780 Sizzle.error( "unsupported pseudo: " + pseudo );
\r
1782 // The user may use createPseudo to indicate that
\r
1783 // arguments are needed to create the filter function
\r
1784 // just as Sizzle does
\r
1785 if ( fn[ expando ] ) {
\r
1786 return fn( argument );
\r
1789 // But maintain support for old signatures
\r
1790 if ( fn.length > 1 ) {
\r
1791 args = [ pseudo, pseudo, "", argument ];
\r
1792 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
\r
1793 markFunction(function( seed, matches ) {
\r
1795 matched = fn( seed, argument ),
\r
1796 i = matched.length;
\r
1798 idx = indexOf.call( seed, matched[i] );
\r
1799 seed[ idx ] = !( matches[ idx ] = matched[i] );
\r
1802 function( elem ) {
\r
1803 return fn( elem, 0, args );
\r
1812 // Potentially complex pseudos
\r
1813 "not": markFunction(function( selector ) {
\r
1814 // Trim the selector passed to compile
\r
1815 // to avoid treating leading and trailing
\r
1816 // spaces as combinators
\r
1819 matcher = compile( selector.replace( rtrim, "$1" ) );
\r
1821 return matcher[ expando ] ?
\r
1822 markFunction(function( seed, matches, context, xml ) {
\r
1824 unmatched = matcher( seed, null, xml, [] ),
\r
1827 // Match elements unmatched by `matcher`
\r
1829 if ( (elem = unmatched[i]) ) {
\r
1830 seed[i] = !(matches[i] = elem);
\r
1834 function( elem, context, xml ) {
\r
1836 matcher( input, null, xml, results );
\r
1837 return !results.pop();
\r
1841 "has": markFunction(function( selector ) {
\r
1842 return function( elem ) {
\r
1843 return Sizzle( selector, elem ).length > 0;
\r
1847 "contains": markFunction(function( text ) {
\r
1848 return function( elem ) {
\r
1849 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
\r
1853 // "Whether an element is represented by a :lang() selector
\r
1854 // is based solely on the element's language value
\r
1855 // being equal to the identifier C,
\r
1856 // or beginning with the identifier C immediately followed by "-".
\r
1857 // The matching of C against the element's language value is performed case-insensitively.
\r
1858 // The identifier C does not have to be a valid language name."
\r
1859 // http://www.w3.org/TR/selectors/#lang-pseudo
\r
1860 "lang": markFunction( function( lang ) {
\r
1861 // lang value must be a valid identifier
\r
1862 if ( !ridentifier.test(lang || "") ) {
\r
1863 Sizzle.error( "unsupported lang: " + lang );
\r
1865 lang = lang.replace( runescape, funescape ).toLowerCase();
\r
1866 return function( elem ) {
\r
1869 if ( (elemLang = documentIsHTML ?
\r
1871 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
\r
1873 elemLang = elemLang.toLowerCase();
\r
1874 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
\r
1876 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
\r
1882 "target": function( elem ) {
\r
1883 var hash = window.location && window.location.hash;
\r
1884 return hash && hash.slice( 1 ) === elem.id;
\r
1887 "root": function( elem ) {
\r
1888 return elem === docElem;
\r
1891 "focus": function( elem ) {
\r
1892 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
\r
1895 // Boolean properties
\r
1896 "enabled": function( elem ) {
\r
1897 return elem.disabled === false;
\r
1900 "disabled": function( elem ) {
\r
1901 return elem.disabled === true;
\r
1904 "checked": function( elem ) {
\r
1905 // In CSS3, :checked should return both checked and selected elements
\r
1906 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
\r
1907 var nodeName = elem.nodeName.toLowerCase();
\r
1908 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
\r
1911 "selected": function( elem ) {
\r
1912 // Accessing this property makes selected-by-default
\r
1913 // options in Safari work properly
\r
1914 if ( elem.parentNode ) {
\r
1915 elem.parentNode.selectedIndex;
\r
1918 return elem.selected === true;
\r
1922 "empty": function( elem ) {
\r
1923 // http://www.w3.org/TR/selectors/#empty-pseudo
\r
1924 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
\r
1925 // but not by others (comment: 8; processing instruction: 7; etc.)
\r
1926 // nodeType < 6 works because attributes (2) do not appear as children
\r
1927 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
\r
1928 if ( elem.nodeType < 6 ) {
\r
1935 "parent": function( elem ) {
\r
1936 return !Expr.pseudos["empty"]( elem );
\r
1939 // Element/input types
\r
1940 "header": function( elem ) {
\r
1941 return rheader.test( elem.nodeName );
\r
1944 "input": function( elem ) {
\r
1945 return rinputs.test( elem.nodeName );
\r
1948 "button": function( elem ) {
\r
1949 var name = elem.nodeName.toLowerCase();
\r
1950 return name === "input" && elem.type === "button" || name === "button";
\r
1953 "text": function( elem ) {
\r
1955 return elem.nodeName.toLowerCase() === "input" &&
\r
1956 elem.type === "text" &&
\r
1959 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
\r
1960 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
\r
1963 // Position-in-collection
\r
1964 "first": createPositionalPseudo(function() {
\r
1968 "last": createPositionalPseudo(function( matchIndexes, length ) {
\r
1969 return [ length - 1 ];
\r
1972 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
1973 return [ argument < 0 ? argument + length : argument ];
\r
1976 "even": createPositionalPseudo(function( matchIndexes, length ) {
\r
1978 for ( ; i < length; i += 2 ) {
\r
1979 matchIndexes.push( i );
\r
1981 return matchIndexes;
\r
1984 "odd": createPositionalPseudo(function( matchIndexes, length ) {
\r
1986 for ( ; i < length; i += 2 ) {
\r
1987 matchIndexes.push( i );
\r
1989 return matchIndexes;
\r
1992 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
1993 var i = argument < 0 ? argument + length : argument;
\r
1994 for ( ; --i >= 0; ) {
\r
1995 matchIndexes.push( i );
\r
1997 return matchIndexes;
\r
2000 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
\r
2001 var i = argument < 0 ? argument + length : argument;
\r
2002 for ( ; ++i < length; ) {
\r
2003 matchIndexes.push( i );
\r
2005 return matchIndexes;
\r
2010 Expr.pseudos["nth"] = Expr.pseudos["eq"];
\r
2012 // Add button/input type pseudos
\r
2013 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
\r
2014 Expr.pseudos[ i ] = createInputPseudo( i );
\r
2016 for ( i in { submit: true, reset: true } ) {
\r
2017 Expr.pseudos[ i ] = createButtonPseudo( i );
\r
2020 // Easy API for creating new setFilters
\r
2021 function setFilters() {}
\r
2022 setFilters.prototype = Expr.filters = Expr.pseudos;
\r
2023 Expr.setFilters = new setFilters();
\r
2025 function tokenize( selector, parseOnly ) {
\r
2026 var matched, match, tokens, type,
\r
2027 soFar, groups, preFilters,
\r
2028 cached = tokenCache[ selector + " " ];
\r
2031 return parseOnly ? 0 : cached.slice( 0 );
\r
2036 preFilters = Expr.preFilter;
\r
2040 // Comma and first run
\r
2041 if ( !matched || (match = rcomma.exec( soFar )) ) {
\r
2043 // Don't consume trailing commas as valid
\r
2044 soFar = soFar.slice( match[0].length ) || soFar;
\r
2046 groups.push( (tokens = []) );
\r
2052 if ( (match = rcombinators.exec( soFar )) ) {
\r
2053 matched = match.shift();
\r
2056 // Cast descendant combinators to space
\r
2057 type: match[0].replace( rtrim, " " )
\r
2059 soFar = soFar.slice( matched.length );
\r
2063 for ( type in Expr.filter ) {
\r
2064 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
\r
2065 (match = preFilters[ type ]( match ))) ) {
\r
2066 matched = match.shift();
\r
2072 soFar = soFar.slice( matched.length );
\r
2081 // Return the length of the invalid excess
\r
2082 // if we're just parsing
\r
2083 // Otherwise, throw an error or return tokens
\r
2084 return parseOnly ?
\r
2087 Sizzle.error( selector ) :
\r
2088 // Cache the tokens
\r
2089 tokenCache( selector, groups ).slice( 0 );
\r
2092 function toSelector( tokens ) {
\r
2094 len = tokens.length,
\r
2096 for ( ; i < len; i++ ) {
\r
2097 selector += tokens[i].value;
\r
2102 function addCombinator( matcher, combinator, base ) {
\r
2103 var dir = combinator.dir,
\r
2104 checkNonElements = base && dir === "parentNode",
\r
2105 doneName = done++;
\r
2107 return combinator.first ?
\r
2108 // Check against closest ancestor/preceding element
\r
2109 function( elem, context, xml ) {
\r
2110 while ( (elem = elem[ dir ]) ) {
\r
2111 if ( elem.nodeType === 1 || checkNonElements ) {
\r
2112 return matcher( elem, context, xml );
\r
2117 // Check against all ancestor/preceding elements
\r
2118 function( elem, context, xml ) {
\r
2119 var oldCache, outerCache,
\r
2120 newCache = [ dirruns, doneName ];
\r
2122 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
\r
2124 while ( (elem = elem[ dir ]) ) {
\r
2125 if ( elem.nodeType === 1 || checkNonElements ) {
\r
2126 if ( matcher( elem, context, xml ) ) {
\r
2132 while ( (elem = elem[ dir ]) ) {
\r
2133 if ( elem.nodeType === 1 || checkNonElements ) {
\r
2134 outerCache = elem[ expando ] || (elem[ expando ] = {});
\r
2135 if ( (oldCache = outerCache[ dir ]) &&
\r
2136 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
\r
2138 // Assign to newCache so results back-propagate to previous elements
\r
2139 return (newCache[ 2 ] = oldCache[ 2 ]);
\r
2141 // Reuse newcache so results back-propagate to previous elements
\r
2142 outerCache[ dir ] = newCache;
\r
2144 // A match means we're done; a fail means we have to keep checking
\r
2145 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
\r
2155 function elementMatcher( matchers ) {
\r
2156 return matchers.length > 1 ?
\r
2157 function( elem, context, xml ) {
\r
2158 var i = matchers.length;
\r
2160 if ( !matchers[i]( elem, context, xml ) ) {
\r
2169 function condense( unmatched, map, filter, context, xml ) {
\r
2171 newUnmatched = [],
\r
2173 len = unmatched.length,
\r
2174 mapped = map != null;
\r
2176 for ( ; i < len; i++ ) {
\r
2177 if ( (elem = unmatched[i]) ) {
\r
2178 if ( !filter || filter( elem, context, xml ) ) {
\r
2179 newUnmatched.push( elem );
\r
2187 return newUnmatched;
\r
2190 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
\r
2191 if ( postFilter && !postFilter[ expando ] ) {
\r
2192 postFilter = setMatcher( postFilter );
\r
2194 if ( postFinder && !postFinder[ expando ] ) {
\r
2195 postFinder = setMatcher( postFinder, postSelector );
\r
2197 return markFunction(function( seed, results, context, xml ) {
\r
2198 var temp, i, elem,
\r
2201 preexisting = results.length,
\r
2203 // Get initial elements from seed or context
\r
2204 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
\r
2206 // Prefilter to get matcher input, preserving a map for seed-results synchronization
\r
2207 matcherIn = preFilter && ( seed || !selector ) ?
\r
2208 condense( elems, preMap, preFilter, context, xml ) :
\r
2211 matcherOut = matcher ?
\r
2212 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
\r
2213 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
\r
2215 // ...intermediate processing is necessary
\r
2218 // ...otherwise use results directly
\r
2222 // Find primary matches
\r
2224 matcher( matcherIn, matcherOut, context, xml );
\r
2227 // Apply postFilter
\r
2228 if ( postFilter ) {
\r
2229 temp = condense( matcherOut, postMap );
\r
2230 postFilter( temp, [], context, xml );
\r
2232 // Un-match failing elements by moving them back to matcherIn
\r
2235 if ( (elem = temp[i]) ) {
\r
2236 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
\r
2242 if ( postFinder || preFilter ) {
\r
2243 if ( postFinder ) {
\r
2244 // Get the final matcherOut by condensing this intermediate into postFinder contexts
\r
2246 i = matcherOut.length;
\r
2248 if ( (elem = matcherOut[i]) ) {
\r
2249 // Restore matcherIn since elem is not yet a final match
\r
2250 temp.push( (matcherIn[i] = elem) );
\r
2253 postFinder( null, (matcherOut = []), temp, xml );
\r
2256 // Move matched elements from seed to results to keep them synchronized
\r
2257 i = matcherOut.length;
\r
2259 if ( (elem = matcherOut[i]) &&
\r
2260 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
\r
2262 seed[temp] = !(results[temp] = elem);
\r
2267 // Add elements to results, through postFinder if defined
\r
2269 matcherOut = condense(
\r
2270 matcherOut === results ?
\r
2271 matcherOut.splice( preexisting, matcherOut.length ) :
\r
2274 if ( postFinder ) {
\r
2275 postFinder( null, results, matcherOut, xml );
\r
2277 push.apply( results, matcherOut );
\r
2283 function matcherFromTokens( tokens ) {
\r
2284 var checkContext, matcher, j,
\r
2285 len = tokens.length,
\r
2286 leadingRelative = Expr.relative[ tokens[0].type ],
\r
2287 implicitRelative = leadingRelative || Expr.relative[" "],
\r
2288 i = leadingRelative ? 1 : 0,
\r
2290 // The foundational matcher ensures that elements are reachable from top-level context(s)
\r
2291 matchContext = addCombinator( function( elem ) {
\r
2292 return elem === checkContext;
\r
2293 }, implicitRelative, true ),
\r
2294 matchAnyContext = addCombinator( function( elem ) {
\r
2295 return indexOf.call( checkContext, elem ) > -1;
\r
2296 }, implicitRelative, true ),
\r
2297 matchers = [ function( elem, context, xml ) {
\r
2298 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
\r
2299 (checkContext = context).nodeType ?
\r
2300 matchContext( elem, context, xml ) :
\r
2301 matchAnyContext( elem, context, xml ) );
\r
2304 for ( ; i < len; i++ ) {
\r
2305 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
\r
2306 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
\r
2308 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
\r
2310 // Return special upon seeing a positional matcher
\r
2311 if ( matcher[ expando ] ) {
\r
2312 // Find the next relative operator (if any) for proper handling
\r
2314 for ( ; j < len; j++ ) {
\r
2315 if ( Expr.relative[ tokens[j].type ] ) {
\r
2319 return setMatcher(
\r
2320 i > 1 && elementMatcher( matchers ),
\r
2321 i > 1 && toSelector(
\r
2322 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
\r
2323 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
\r
2324 ).replace( rtrim, "$1" ),
\r
2326 i < j && matcherFromTokens( tokens.slice( i, j ) ),
\r
2327 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
\r
2328 j < len && toSelector( tokens )
\r
2331 matchers.push( matcher );
\r
2335 return elementMatcher( matchers );
\r
2338 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
\r
2339 var bySet = setMatchers.length > 0,
\r
2340 byElement = elementMatchers.length > 0,
\r
2341 superMatcher = function( seed, context, xml, results, outermost ) {
\r
2342 var elem, j, matcher,
\r
2345 unmatched = seed && [],
\r
2347 contextBackup = outermostContext,
\r
2348 // We must always have either seed elements or outermost context
\r
2349 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
\r
2350 // Use integer dirruns iff this is the outermost matcher
\r
2351 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
\r
2352 len = elems.length;
\r
2354 if ( outermost ) {
\r
2355 outermostContext = context !== document && context;
\r
2358 // Add elements passing elementMatchers directly to results
\r
2359 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
\r
2360 // Support: IE<9, Safari
\r
2361 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
\r
2362 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
\r
2363 if ( byElement && elem ) {
\r
2365 while ( (matcher = elementMatchers[j++]) ) {
\r
2366 if ( matcher( elem, context, xml ) ) {
\r
2367 results.push( elem );
\r
2371 if ( outermost ) {
\r
2372 dirruns = dirrunsUnique;
\r
2376 // Track unmatched elements for set filters
\r
2378 // They will have gone through all possible matchers
\r
2379 if ( (elem = !matcher && elem) ) {
\r
2383 // Lengthen the array for every element, matched or not
\r
2385 unmatched.push( elem );
\r
2390 // Apply set filters to unmatched elements
\r
2391 matchedCount += i;
\r
2392 if ( bySet && i !== matchedCount ) {
\r
2394 while ( (matcher = setMatchers[j++]) ) {
\r
2395 matcher( unmatched, setMatched, context, xml );
\r
2399 // Reintegrate element matches to eliminate the need for sorting
\r
2400 if ( matchedCount > 0 ) {
\r
2402 if ( !(unmatched[i] || setMatched[i]) ) {
\r
2403 setMatched[i] = pop.call( results );
\r
2408 // Discard index placeholder values to get only actual matches
\r
2409 setMatched = condense( setMatched );
\r
2412 // Add matches to results
\r
2413 push.apply( results, setMatched );
\r
2415 // Seedless set matches succeeding multiple successful matchers stipulate sorting
\r
2416 if ( outermost && !seed && setMatched.length > 0 &&
\r
2417 ( matchedCount + setMatchers.length ) > 1 ) {
\r
2419 Sizzle.uniqueSort( results );
\r
2423 // Override manipulation of globals by nested matchers
\r
2424 if ( outermost ) {
\r
2425 dirruns = dirrunsUnique;
\r
2426 outermostContext = contextBackup;
\r
2433 markFunction( superMatcher ) :
\r
2437 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
\r
2440 elementMatchers = [],
\r
2441 cached = compilerCache[ selector + " " ];
\r
2444 // Generate a function of recursive functions that can be used to check each element
\r
2446 group = tokenize( selector );
\r
2450 cached = matcherFromTokens( group[i] );
\r
2451 if ( cached[ expando ] ) {
\r
2452 setMatchers.push( cached );
\r
2454 elementMatchers.push( cached );
\r
2458 // Cache the compiled function
\r
2459 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
\r
2464 function multipleContexts( selector, contexts, results ) {
\r
2466 len = contexts.length;
\r
2467 for ( ; i < len; i++ ) {
\r
2468 Sizzle( selector, contexts[i], results );
\r
2473 function select( selector, context, results, seed ) {
\r
2474 var i, tokens, token, type, find,
\r
2475 match = tokenize( selector );
\r
2478 // Try to minimize operations if there is only one group
\r
2479 if ( match.length === 1 ) {
\r
2481 // Take a shortcut and set the context if the root selector is an ID
\r
2482 tokens = match[0] = match[0].slice( 0 );
\r
2483 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
\r
2484 support.getById && context.nodeType === 9 && documentIsHTML &&
\r
2485 Expr.relative[ tokens[1].type ] ) {
\r
2487 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
\r
2491 selector = selector.slice( tokens.shift().value.length );
\r
2494 // Fetch a seed set for right-to-left matching
\r
2495 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
\r
2497 token = tokens[i];
\r
2499 // Abort if we hit a combinator
\r
2500 if ( Expr.relative[ (type = token.type) ] ) {
\r
2503 if ( (find = Expr.find[ type ]) ) {
\r
2504 // Search, expanding context for leading sibling combinators
\r
2505 if ( (seed = find(
\r
2506 token.matches[0].replace( runescape, funescape ),
\r
2507 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
\r
2510 // If seed is empty or no tokens remain, we can return early
\r
2511 tokens.splice( i, 1 );
\r
2512 selector = seed.length && toSelector( tokens );
\r
2513 if ( !selector ) {
\r
2514 push.apply( results, seed );
\r
2525 // Compile and execute a filtering function
\r
2526 // Provide `match` to avoid retokenization if we modified the selector above
\r
2527 compile( selector, match )(
\r
2532 rsibling.test( selector ) && testContext( context.parentNode ) || context
\r
2537 // One-time assignments
\r
2540 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
\r
2542 // Support: Chrome<14
\r
2543 // Always assume duplicates if they aren't passed to the comparison function
\r
2544 support.detectDuplicates = !!hasDuplicate;
\r
2546 // Initialize against the default document
\r
2549 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
\r
2550 // Detached nodes confoundingly follow *each other*
\r
2551 support.sortDetached = assert(function( div1 ) {
\r
2552 // Should return 1, but returns 4 (following)
\r
2553 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
\r
2557 // Prevent attribute/property "interpolation"
\r
2558 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
\r
2559 if ( !assert(function( div ) {
\r
2560 div.innerHTML = "<a href='#'></a>";
\r
2561 return div.firstChild.getAttribute("href") === "#" ;
\r
2563 addHandle( "type|href|height|width", function( elem, name, isXML ) {
\r
2565 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
\r
2571 // Use defaultValue in place of getAttribute("value")
\r
2572 if ( !support.attributes || !assert(function( div ) {
\r
2573 div.innerHTML = "<input/>";
\r
2574 div.firstChild.setAttribute( "value", "" );
\r
2575 return div.firstChild.getAttribute( "value" ) === "";
\r
2577 addHandle( "value", function( elem, name, isXML ) {
\r
2578 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
\r
2579 return elem.defaultValue;
\r
2585 // Use getAttributeNode to fetch booleans when getAttribute lies
\r
2586 if ( !assert(function( div ) {
\r
2587 return div.getAttribute("disabled") == null;
\r
2589 addHandle( booleans, function( elem, name, isXML ) {
\r
2592 return elem[ name ] === true ? name.toLowerCase() :
\r
2593 (val = elem.getAttributeNode( name )) && val.specified ?
\r
2606 jQuery.find = Sizzle;
\r
2607 jQuery.expr = Sizzle.selectors;
\r
2608 jQuery.expr[":"] = jQuery.expr.pseudos;
\r
2609 jQuery.unique = Sizzle.uniqueSort;
\r
2610 jQuery.text = Sizzle.getText;
\r
2611 jQuery.isXMLDoc = Sizzle.isXML;
\r
2612 jQuery.contains = Sizzle.contains;
\r
2616 var rneedsContext = jQuery.expr.match.needsContext;
\r
2618 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
\r
2622 var risSimple = /^.[^:#\[\.,]*$/;
\r
2624 // Implement the identical functionality for filter and not
\r
2625 function winnow( elements, qualifier, not ) {
\r
2626 if ( jQuery.isFunction( qualifier ) ) {
\r
2627 return jQuery.grep( elements, function( elem, i ) {
\r
2628 /* jshint -W018 */
\r
2629 return !!qualifier.call( elem, i, elem ) !== not;
\r
2634 if ( qualifier.nodeType ) {
\r
2635 return jQuery.grep( elements, function( elem ) {
\r
2636 return ( elem === qualifier ) !== not;
\r
2641 if ( typeof qualifier === "string" ) {
\r
2642 if ( risSimple.test( qualifier ) ) {
\r
2643 return jQuery.filter( qualifier, elements, not );
\r
2646 qualifier = jQuery.filter( qualifier, elements );
\r
2649 return jQuery.grep( elements, function( elem ) {
\r
2650 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
\r
2654 jQuery.filter = function( expr, elems, not ) {
\r
2655 var elem = elems[ 0 ];
\r
2658 expr = ":not(" + expr + ")";
\r
2661 return elems.length === 1 && elem.nodeType === 1 ?
\r
2662 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
\r
2663 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
\r
2664 return elem.nodeType === 1;
\r
2668 jQuery.fn.extend({
\r
2669 find: function( selector ) {
\r
2673 len = self.length;
\r
2675 if ( typeof selector !== "string" ) {
\r
2676 return this.pushStack( jQuery( selector ).filter(function() {
\r
2677 for ( i = 0; i < len; i++ ) {
\r
2678 if ( jQuery.contains( self[ i ], this ) ) {
\r
2685 for ( i = 0; i < len; i++ ) {
\r
2686 jQuery.find( selector, self[ i ], ret );
\r
2689 // Needed because $( selector, context ) becomes $( context ).find( selector )
\r
2690 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
\r
2691 ret.selector = this.selector ? this.selector + " " + selector : selector;
\r
2694 filter: function( selector ) {
\r
2695 return this.pushStack( winnow(this, selector || [], false) );
\r
2697 not: function( selector ) {
\r
2698 return this.pushStack( winnow(this, selector || [], true) );
\r
2700 is: function( selector ) {
\r
2704 // If this is a positional/relative selector, check membership in the returned set
\r
2705 // so $("p:first").is("p:last") won't return true for a doc with two "p".
\r
2706 typeof selector === "string" && rneedsContext.test( selector ) ?
\r
2707 jQuery( selector ) :
\r
2715 // Initialize a jQuery object
\r
2718 // A central reference to the root jQuery(document)
\r
2721 // Use the correct document accordingly with window argument (sandbox)
\r
2722 document = window.document,
\r
2724 // A simple way to check for HTML strings
\r
2725 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
\r
2726 // Strict HTML recognition (#11290: must start with <)
\r
2727 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
\r
2729 init = jQuery.fn.init = function( selector, context ) {
\r
2732 // HANDLE: $(""), $(null), $(undefined), $(false)
\r
2733 if ( !selector ) {
\r
2737 // Handle HTML strings
\r
2738 if ( typeof selector === "string" ) {
\r
2739 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
\r
2740 // Assume that strings that start and end with <> are HTML and skip the regex check
\r
2741 match = [ null, selector, null ];
\r
2744 match = rquickExpr.exec( selector );
\r
2747 // Match html or make sure no context is specified for #id
\r
2748 if ( match && (match[1] || !context) ) {
\r
2750 // HANDLE: $(html) -> $(array)
\r
2752 context = context instanceof jQuery ? context[0] : context;
\r
2754 // scripts is true for back-compat
\r
2755 // Intentionally let the error be thrown if parseHTML is not present
\r
2756 jQuery.merge( this, jQuery.parseHTML(
\r
2758 context && context.nodeType ? context.ownerDocument || context : document,
\r
2762 // HANDLE: $(html, props)
\r
2763 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
\r
2764 for ( match in context ) {
\r
2765 // Properties of context are called as methods if possible
\r
2766 if ( jQuery.isFunction( this[ match ] ) ) {
\r
2767 this[ match ]( context[ match ] );
\r
2769 // ...and otherwise set as attributes
\r
2771 this.attr( match, context[ match ] );
\r
2780 elem = document.getElementById( match[2] );
\r
2782 // Check parentNode to catch when Blackberry 4.6 returns
\r
2783 // nodes that are no longer in the document #6963
\r
2784 if ( elem && elem.parentNode ) {
\r
2785 // Handle the case where IE and Opera return items
\r
2786 // by name instead of ID
\r
2787 if ( elem.id !== match[2] ) {
\r
2788 return rootjQuery.find( selector );
\r
2791 // Otherwise, we inject the element directly into the jQuery object
\r
2796 this.context = document;
\r
2797 this.selector = selector;
\r
2801 // HANDLE: $(expr, $(...))
\r
2802 } else if ( !context || context.jquery ) {
\r
2803 return ( context || rootjQuery ).find( selector );
\r
2805 // HANDLE: $(expr, context)
\r
2806 // (which is just equivalent to: $(context).find(expr)
\r
2808 return this.constructor( context ).find( selector );
\r
2811 // HANDLE: $(DOMElement)
\r
2812 } else if ( selector.nodeType ) {
\r
2813 this.context = this[0] = selector;
\r
2817 // HANDLE: $(function)
\r
2818 // Shortcut for document ready
\r
2819 } else if ( jQuery.isFunction( selector ) ) {
\r
2820 return typeof rootjQuery.ready !== "undefined" ?
\r
2821 rootjQuery.ready( selector ) :
\r
2822 // Execute immediately if ready is not present
\r
2823 selector( jQuery );
\r
2826 if ( selector.selector !== undefined ) {
\r
2827 this.selector = selector.selector;
\r
2828 this.context = selector.context;
\r
2831 return jQuery.makeArray( selector, this );
\r
2834 // Give the init function the jQuery prototype for later instantiation
\r
2835 init.prototype = jQuery.fn;
\r
2837 // Initialize central reference
\r
2838 rootjQuery = jQuery( document );
\r
2841 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
\r
2842 // methods guaranteed to produce a unique set when starting from a unique set
\r
2843 guaranteedUnique = {
\r
2851 dir: function( elem, dir, until ) {
\r
2853 cur = elem[ dir ];
\r
2855 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
\r
2856 if ( cur.nodeType === 1 ) {
\r
2857 matched.push( cur );
\r
2864 sibling: function( n, elem ) {
\r
2867 for ( ; n; n = n.nextSibling ) {
\r
2868 if ( n.nodeType === 1 && n !== elem ) {
\r
2877 jQuery.fn.extend({
\r
2878 has: function( target ) {
\r
2880 targets = jQuery( target, this ),
\r
2881 len = targets.length;
\r
2883 return this.filter(function() {
\r
2884 for ( i = 0; i < len; i++ ) {
\r
2885 if ( jQuery.contains( this, targets[i] ) ) {
\r
2892 closest: function( selectors, context ) {
\r
2897 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
\r
2898 jQuery( selectors, context || this.context ) :
\r
2901 for ( ; i < l; i++ ) {
\r
2902 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
\r
2903 // Always skip document fragments
\r
2904 if ( cur.nodeType < 11 && (pos ?
\r
2905 pos.index(cur) > -1 :
\r
2907 // Don't pass non-elements to Sizzle
\r
2908 cur.nodeType === 1 &&
\r
2909 jQuery.find.matchesSelector(cur, selectors)) ) {
\r
2911 matched.push( cur );
\r
2917 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
\r
2920 // Determine the position of an element within
\r
2921 // the matched set of elements
\r
2922 index: function( elem ) {
\r
2924 // No argument, return index in parent
\r
2926 return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
\r
2929 // index in selector
\r
2930 if ( typeof elem === "string" ) {
\r
2931 return jQuery.inArray( this[0], jQuery( elem ) );
\r
2934 // Locate the position of the desired element
\r
2935 return jQuery.inArray(
\r
2936 // If it receives a jQuery object, the first element is used
\r
2937 elem.jquery ? elem[0] : elem, this );
\r
2940 add: function( selector, context ) {
\r
2941 return this.pushStack(
\r
2943 jQuery.merge( this.get(), jQuery( selector, context ) )
\r
2948 addBack: function( selector ) {
\r
2949 return this.add( selector == null ?
\r
2950 this.prevObject : this.prevObject.filter(selector)
\r
2955 function sibling( cur, dir ) {
\r
2958 } while ( cur && cur.nodeType !== 1 );
\r
2964 parent: function( elem ) {
\r
2965 var parent = elem.parentNode;
\r
2966 return parent && parent.nodeType !== 11 ? parent : null;
\r
2968 parents: function( elem ) {
\r
2969 return jQuery.dir( elem, "parentNode" );
\r
2971 parentsUntil: function( elem, i, until ) {
\r
2972 return jQuery.dir( elem, "parentNode", until );
\r
2974 next: function( elem ) {
\r
2975 return sibling( elem, "nextSibling" );
\r
2977 prev: function( elem ) {
\r
2978 return sibling( elem, "previousSibling" );
\r
2980 nextAll: function( elem ) {
\r
2981 return jQuery.dir( elem, "nextSibling" );
\r
2983 prevAll: function( elem ) {
\r
2984 return jQuery.dir( elem, "previousSibling" );
\r
2986 nextUntil: function( elem, i, until ) {
\r
2987 return jQuery.dir( elem, "nextSibling", until );
\r
2989 prevUntil: function( elem, i, until ) {
\r
2990 return jQuery.dir( elem, "previousSibling", until );
\r
2992 siblings: function( elem ) {
\r
2993 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
\r
2995 children: function( elem ) {
\r
2996 return jQuery.sibling( elem.firstChild );
\r
2998 contents: function( elem ) {
\r
2999 return jQuery.nodeName( elem, "iframe" ) ?
\r
3000 elem.contentDocument || elem.contentWindow.document :
\r
3001 jQuery.merge( [], elem.childNodes );
\r
3003 }, function( name, fn ) {
\r
3004 jQuery.fn[ name ] = function( until, selector ) {
\r
3005 var ret = jQuery.map( this, fn, until );
\r
3007 if ( name.slice( -5 ) !== "Until" ) {
\r
3011 if ( selector && typeof selector === "string" ) {
\r
3012 ret = jQuery.filter( selector, ret );
\r
3015 if ( this.length > 1 ) {
\r
3016 // Remove duplicates
\r
3017 if ( !guaranteedUnique[ name ] ) {
\r
3018 ret = jQuery.unique( ret );
\r
3021 // Reverse order for parents* and prev-derivatives
\r
3022 if ( rparentsprev.test( name ) ) {
\r
3023 ret = ret.reverse();
\r
3027 return this.pushStack( ret );
\r
3030 var rnotwhite = (/\S+/g);
\r
3034 // String to Object options format cache
\r
3035 var optionsCache = {};
\r
3037 // Convert String-formatted options into Object-formatted ones and store in cache
\r
3038 function createOptions( options ) {
\r
3039 var object = optionsCache[ options ] = {};
\r
3040 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
\r
3041 object[ flag ] = true;
\r
3047 * Create a callback list using the following parameters:
\r
3049 * options: an optional list of space-separated options that will change how
\r
3050 * the callback list behaves or a more traditional option object
\r
3052 * By default a callback list will act like an event callback list and can be
\r
3053 * "fired" multiple times.
\r
3055 * Possible options:
\r
3057 * once: will ensure the callback list can only be fired once (like a Deferred)
\r
3059 * memory: will keep track of previous values and will call any callback added
\r
3060 * after the list has been fired right away with the latest "memorized"
\r
3061 * values (like a Deferred)
\r
3063 * unique: will ensure a callback can only be added once (no duplicate in the list)
\r
3065 * stopOnFalse: interrupt callings when a callback returns false
\r
3068 jQuery.Callbacks = function( options ) {
\r
3070 // Convert options from String-formatted to Object-formatted if needed
\r
3071 // (we check in cache first)
\r
3072 options = typeof options === "string" ?
\r
3073 ( optionsCache[ options ] || createOptions( options ) ) :
\r
3074 jQuery.extend( {}, options );
\r
3076 var // Flag to know if list is currently firing
\r
3078 // Last fire value (for non-forgettable lists)
\r
3080 // Flag to know if list was already fired
\r
3082 // End of the loop when firing
\r
3084 // Index of currently firing callback (modified by remove if needed)
\r
3086 // First callback to fire (used internally by add and fireWith)
\r
3088 // Actual callback list
\r
3090 // Stack of fire calls for repeatable lists
\r
3091 stack = !options.once && [],
\r
3093 fire = function( data ) {
\r
3094 memory = options.memory && data;
\r
3096 firingIndex = firingStart || 0;
\r
3098 firingLength = list.length;
\r
3100 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
\r
3101 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
\r
3102 memory = false; // To prevent further calls using add
\r
3109 if ( stack.length ) {
\r
3110 fire( stack.shift() );
\r
3112 } else if ( memory ) {
\r
3119 // Actual Callbacks object
\r
3121 // Add a callback or a collection of callbacks to the list
\r
3124 // First, we save the current length
\r
3125 var start = list.length;
\r
3126 (function add( args ) {
\r
3127 jQuery.each( args, function( _, arg ) {
\r
3128 var type = jQuery.type( arg );
\r
3129 if ( type === "function" ) {
\r
3130 if ( !options.unique || !self.has( arg ) ) {
\r
3133 } else if ( arg && arg.length && type !== "string" ) {
\r
3134 // Inspect recursively
\r
3139 // Do we need to add the callbacks to the
\r
3140 // current firing batch?
\r
3142 firingLength = list.length;
\r
3143 // With memory, if we're not firing then
\r
3144 // we should call right away
\r
3145 } else if ( memory ) {
\r
3146 firingStart = start;
\r
3152 // Remove a callback from the list
\r
3153 remove: function() {
\r
3155 jQuery.each( arguments, function( _, arg ) {
\r
3157 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
\r
3158 list.splice( index, 1 );
\r
3159 // Handle firing indexes
\r
3161 if ( index <= firingLength ) {
\r
3164 if ( index <= firingIndex ) {
\r
3173 // Check if a given callback is in the list.
\r
3174 // If no argument is given, return whether or not list has callbacks attached.
\r
3175 has: function( fn ) {
\r
3176 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
\r
3178 // Remove all callbacks from the list
\r
3179 empty: function() {
\r
3184 // Have the list do nothing anymore
\r
3185 disable: function() {
\r
3186 list = stack = memory = undefined;
\r
3189 // Is it disabled?
\r
3190 disabled: function() {
\r
3193 // Lock the list in its current state
\r
3194 lock: function() {
\r
3195 stack = undefined;
\r
3202 locked: function() {
\r
3205 // Call all callbacks with the given context and arguments
\r
3206 fireWith: function( context, args ) {
\r
3207 if ( list && ( !fired || stack ) ) {
\r
3208 args = args || [];
\r
3209 args = [ context, args.slice ? args.slice() : args ];
\r
3211 stack.push( args );
\r
3218 // Call all the callbacks with the given arguments
\r
3219 fire: function() {
\r
3220 self.fireWith( this, arguments );
\r
3223 // To know if the callbacks have already been called at least once
\r
3224 fired: function() {
\r
3235 Deferred: function( func ) {
\r
3237 // action, add listener, listener list, final state
\r
3238 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
\r
3239 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
\r
3240 [ "notify", "progress", jQuery.Callbacks("memory") ]
\r
3242 state = "pending",
\r
3244 state: function() {
\r
3247 always: function() {
\r
3248 deferred.done( arguments ).fail( arguments );
\r
3251 then: function( /* fnDone, fnFail, fnProgress */ ) {
\r
3252 var fns = arguments;
\r
3253 return jQuery.Deferred(function( newDefer ) {
\r
3254 jQuery.each( tuples, function( i, tuple ) {
\r
3255 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
\r
3256 // deferred[ done | fail | progress ] for forwarding actions to newDefer
\r
3257 deferred[ tuple[1] ](function() {
\r
3258 var returned = fn && fn.apply( this, arguments );
\r
3259 if ( returned && jQuery.isFunction( returned.promise ) ) {
\r
3260 returned.promise()
\r
3261 .done( newDefer.resolve )
\r
3262 .fail( newDefer.reject )
\r
3263 .progress( newDefer.notify );
\r
3265 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
\r
3272 // Get a promise for this deferred
\r
3273 // If obj is provided, the promise aspect is added to the object
\r
3274 promise: function( obj ) {
\r
3275 return obj != null ? jQuery.extend( obj, promise ) : promise;
\r
3280 // Keep pipe for back-compat
\r
3281 promise.pipe = promise.then;
\r
3283 // Add list-specific methods
\r
3284 jQuery.each( tuples, function( i, tuple ) {
\r
3285 var list = tuple[ 2 ],
\r
3286 stateString = tuple[ 3 ];
\r
3288 // promise[ done | fail | progress ] = list.add
\r
3289 promise[ tuple[1] ] = list.add;
\r
3292 if ( stateString ) {
\r
3293 list.add(function() {
\r
3294 // state = [ resolved | rejected ]
\r
3295 state = stateString;
\r
3297 // [ reject_list | resolve_list ].disable; progress_list.lock
\r
3298 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
\r
3301 // deferred[ resolve | reject | notify ]
\r
3302 deferred[ tuple[0] ] = function() {
\r
3303 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
\r
3306 deferred[ tuple[0] + "With" ] = list.fireWith;
\r
3309 // Make the deferred a promise
\r
3310 promise.promise( deferred );
\r
3312 // Call given func if any
\r
3314 func.call( deferred, deferred );
\r
3321 // Deferred helper
\r
3322 when: function( subordinate /* , ..., subordinateN */ ) {
\r
3324 resolveValues = slice.call( arguments ),
\r
3325 length = resolveValues.length,
\r
3327 // the count of uncompleted subordinates
\r
3328 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
\r
3330 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
\r
3331 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
\r
3333 // Update function for both resolve and progress values
\r
3334 updateFunc = function( i, contexts, values ) {
\r
3335 return function( value ) {
\r
3336 contexts[ i ] = this;
\r
3337 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
\r
3338 if ( values === progressValues ) {
\r
3339 deferred.notifyWith( contexts, values );
\r
3341 } else if ( !(--remaining) ) {
\r
3342 deferred.resolveWith( contexts, values );
\r
3347 progressValues, progressContexts, resolveContexts;
\r
3349 // add listeners to Deferred subordinates; treat others as resolved
\r
3350 if ( length > 1 ) {
\r
3351 progressValues = new Array( length );
\r
3352 progressContexts = new Array( length );
\r
3353 resolveContexts = new Array( length );
\r
3354 for ( ; i < length; i++ ) {
\r
3355 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
\r
3356 resolveValues[ i ].promise()
\r
3357 .done( updateFunc( i, resolveContexts, resolveValues ) )
\r
3358 .fail( deferred.reject )
\r
3359 .progress( updateFunc( i, progressContexts, progressValues ) );
\r
3366 // if we're not waiting on anything, resolve the master
\r
3367 if ( !remaining ) {
\r
3368 deferred.resolveWith( resolveContexts, resolveValues );
\r
3371 return deferred.promise();
\r
3376 // The deferred used on DOM ready
\r
3379 jQuery.fn.ready = function( fn ) {
\r
3380 // Add the callback
\r
3381 jQuery.ready.promise().done( fn );
\r
3387 // Is the DOM ready to be used? Set to true once it occurs.
\r
3390 // A counter to track how many items to wait for before
\r
3391 // the ready event fires. See #6781
\r
3394 // Hold (or release) the ready event
\r
3395 holdReady: function( hold ) {
\r
3397 jQuery.readyWait++;
\r
3399 jQuery.ready( true );
\r
3403 // Handle when the DOM is ready
\r
3404 ready: function( wait ) {
\r
3406 // Abort if there are pending holds or we're already ready
\r
3407 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
\r
3411 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
\r
3412 if ( !document.body ) {
\r
3413 return setTimeout( jQuery.ready );
\r
3416 // Remember that the DOM is ready
\r
3417 jQuery.isReady = true;
\r
3419 // If a normal DOM Ready event fired, decrement, and wait if need be
\r
3420 if ( wait !== true && --jQuery.readyWait > 0 ) {
\r
3424 // If there are functions bound, to execute
\r
3425 readyList.resolveWith( document, [ jQuery ] );
\r
3427 // Trigger any bound ready events
\r
3428 if ( jQuery.fn.trigger ) {
\r
3429 jQuery( document ).trigger("ready").off("ready");
\r
3435 * Clean-up method for dom ready events
\r
3437 function detach() {
\r
3438 if ( document.addEventListener ) {
\r
3439 document.removeEventListener( "DOMContentLoaded", completed, false );
\r
3440 window.removeEventListener( "load", completed, false );
\r
3443 document.detachEvent( "onreadystatechange", completed );
\r
3444 window.detachEvent( "onload", completed );
\r
3449 * The ready event handler and self cleanup method
\r
3451 function completed() {
\r
3452 // readyState === "complete" is good enough for us to call the dom ready in oldIE
\r
3453 if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
\r
3459 jQuery.ready.promise = function( obj ) {
\r
3460 if ( !readyList ) {
\r
3462 readyList = jQuery.Deferred();
\r
3464 // Catch cases where $(document).ready() is called after the browser event has already occurred.
\r
3465 // we once tried to use readyState "interactive" here, but it caused issues like the one
\r
3466 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
\r
3467 if ( document.readyState === "complete" ) {
\r
3468 // Handle it asynchronously to allow scripts the opportunity to delay ready
\r
3469 setTimeout( jQuery.ready );
\r
3471 // Standards-based browsers support DOMContentLoaded
\r
3472 } else if ( document.addEventListener ) {
\r
3473 // Use the handy event callback
\r
3474 document.addEventListener( "DOMContentLoaded", completed, false );
\r
3476 // A fallback to window.onload, that will always work
\r
3477 window.addEventListener( "load", completed, false );
\r
3479 // If IE event model is used
\r
3481 // Ensure firing before onload, maybe late but safe also for iframes
\r
3482 document.attachEvent( "onreadystatechange", completed );
\r
3484 // A fallback to window.onload, that will always work
\r
3485 window.attachEvent( "onload", completed );
\r
3487 // If IE and not a frame
\r
3488 // continually check to see if the document is ready
\r
3492 top = window.frameElement == null && document.documentElement;
\r
3495 if ( top && top.doScroll ) {
\r
3496 (function doScrollCheck() {
\r
3497 if ( !jQuery.isReady ) {
\r
3500 // Use the trick by Diego Perini
\r
3501 // http://javascript.nwbox.com/IEContentLoaded/
\r
3502 top.doScroll("left");
\r
3504 return setTimeout( doScrollCheck, 50 );
\r
3507 // detach all dom ready events
\r
3510 // and execute any waiting functions
\r
3517 return readyList.promise( obj );
\r
3521 var strundefined = typeof undefined;
\r
3526 // Iteration over object's inherited properties before its own
\r
3528 for ( i in jQuery( support ) ) {
\r
3531 support.ownLast = i !== "0";
\r
3533 // Note: most support tests are defined in their respective modules.
\r
3534 // false until the test is run
\r
3535 support.inlineBlockNeedsLayout = false;
\r
3537 jQuery(function() {
\r
3538 // We need to execute this one support test ASAP because we need to know
\r
3539 // if body.style.zoom needs to be set.
\r
3541 var container, div,
\r
3542 body = document.getElementsByTagName("body")[0];
\r
3545 // Return for frameset docs that don't have a body
\r
3550 container = document.createElement( "div" );
\r
3551 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
\r
3553 div = document.createElement( "div" );
\r
3554 body.appendChild( container ).appendChild( div );
\r
3556 if ( typeof div.style.zoom !== strundefined ) {
\r
3558 // Check if natively block-level elements act like inline-block
\r
3559 // elements when setting their display to 'inline' and giving
\r
3561 div.style.cssText = "border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1";
\r
3563 if ( (support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 )) ) {
\r
3564 // Prevent IE 6 from affecting layout for positioned elements #11048
\r
3565 // Prevent IE from shrinking the body in IE 7 mode #12869
\r
3567 body.style.zoom = 1;
\r
3571 body.removeChild( container );
\r
3573 // Null elements to avoid leaks in IE
\r
3574 container = div = null;
\r
3581 var div = document.createElement( "div" );
\r
3583 // Execute the test only if not already executed in another module.
\r
3584 if (support.deleteExpando == null) {
\r
3586 support.deleteExpando = true;
\r
3590 support.deleteExpando = false;
\r
3594 // Null elements to avoid leaks in IE.
\r
3600 * Determines whether an object can have data
\r
3602 jQuery.acceptData = function( elem ) {
\r
3603 var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
\r
3604 nodeType = +elem.nodeType || 1;
\r
3606 // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
\r
3607 return nodeType !== 1 && nodeType !== 9 ?
\r
3610 // Nodes accept data unless otherwise specified; rejection can be conditional
\r
3611 !noData || noData !== true && elem.getAttribute("classid") === noData;
\r
3615 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
\r
3616 rmultiDash = /([A-Z])/g;
\r
3618 function dataAttr( elem, key, data ) {
\r
3619 // If nothing was found internally, try to fetch any
\r
3620 // data from the HTML5 data-* attribute
\r
3621 if ( data === undefined && elem.nodeType === 1 ) {
\r
3623 var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
\r
3625 data = elem.getAttribute( name );
\r
3627 if ( typeof data === "string" ) {
\r
3629 data = data === "true" ? true :
\r
3630 data === "false" ? false :
\r
3631 data === "null" ? null :
\r
3632 // Only convert to a number if it doesn't change the string
\r
3633 +data + "" === data ? +data :
\r
3634 rbrace.test( data ) ? jQuery.parseJSON( data ) :
\r
3638 // Make sure we set the data so it isn't changed later
\r
3639 jQuery.data( elem, key, data );
\r
3649 // checks a cache object for emptiness
\r
3650 function isEmptyDataObject( obj ) {
\r
3652 for ( name in obj ) {
\r
3654 // if the public data object is empty, the private is still empty
\r
3655 if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
\r
3658 if ( name !== "toJSON" ) {
\r
3666 function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
\r
3667 if ( !jQuery.acceptData( elem ) ) {
\r
3671 var ret, thisCache,
\r
3672 internalKey = jQuery.expando,
\r
3674 // We have to handle DOM nodes and JS objects differently because IE6-7
\r
3675 // can't GC object references properly across the DOM-JS boundary
\r
3676 isNode = elem.nodeType,
\r
3678 // Only DOM nodes need the global jQuery cache; JS object data is
\r
3679 // attached directly to the object so GC can occur automatically
\r
3680 cache = isNode ? jQuery.cache : elem,
\r
3682 // Only defining an ID for JS objects if its cache already exists allows
\r
3683 // the code to shortcut on the same path as a DOM node with no cache
\r
3684 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
\r
3686 // Avoid doing any more work than we need to when trying to get data on an
\r
3687 // object that has no data at all
\r
3688 if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
\r
3693 // Only DOM nodes need a new unique ID for each element since their data
\r
3694 // ends up in the global cache
\r
3696 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
\r
3702 if ( !cache[ id ] ) {
\r
3703 // Avoid exposing jQuery metadata on plain JS objects when the object
\r
3704 // is serialized using JSON.stringify
\r
3705 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
\r
3708 // An object can be passed to jQuery.data instead of a key/value pair; this gets
\r
3709 // shallow copied over onto the existing cache
\r
3710 if ( typeof name === "object" || typeof name === "function" ) {
\r
3712 cache[ id ] = jQuery.extend( cache[ id ], name );
\r
3714 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
\r
3718 thisCache = cache[ id ];
\r
3720 // jQuery data() is stored in a separate object inside the object's internal data
\r
3721 // cache in order to avoid key collisions between internal data and user-defined
\r
3724 if ( !thisCache.data ) {
\r
3725 thisCache.data = {};
\r
3728 thisCache = thisCache.data;
\r
3731 if ( data !== undefined ) {
\r
3732 thisCache[ jQuery.camelCase( name ) ] = data;
\r
3735 // Check for both converted-to-camel and non-converted data property names
\r
3736 // If a data property was specified
\r
3737 if ( typeof name === "string" ) {
\r
3739 // First Try to find as-is property data
\r
3740 ret = thisCache[ name ];
\r
3742 // Test for null|undefined property data
\r
3743 if ( ret == null ) {
\r
3745 // Try to find the camelCased property
\r
3746 ret = thisCache[ jQuery.camelCase( name ) ];
\r
3755 function internalRemoveData( elem, name, pvt ) {
\r
3756 if ( !jQuery.acceptData( elem ) ) {
\r
3761 isNode = elem.nodeType,
\r
3763 // See jQuery.data for more information
\r
3764 cache = isNode ? jQuery.cache : elem,
\r
3765 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
\r
3767 // If there is already no cache entry for this object, there is no
\r
3768 // purpose in continuing
\r
3769 if ( !cache[ id ] ) {
\r
3775 thisCache = pvt ? cache[ id ] : cache[ id ].data;
\r
3777 if ( thisCache ) {
\r
3779 // Support array or space separated string names for data keys
\r
3780 if ( !jQuery.isArray( name ) ) {
\r
3782 // try the string as a key before any manipulation
\r
3783 if ( name in thisCache ) {
\r
3787 // split the camel cased version by spaces unless a key with the spaces exists
\r
3788 name = jQuery.camelCase( name );
\r
3789 if ( name in thisCache ) {
\r
3792 name = name.split(" ");
\r
3796 // If "name" is an array of keys...
\r
3797 // When data is initially created, via ("key", "val") signature,
\r
3798 // keys will be converted to camelCase.
\r
3799 // Since there is no way to tell _how_ a key was added, remove
\r
3800 // both plain key and camelCase key. #12786
\r
3801 // This will only penalize the array argument path.
\r
3802 name = name.concat( jQuery.map( name, jQuery.camelCase ) );
\r
3807 delete thisCache[ name[i] ];
\r
3810 // If there is no data left in the cache, we want to continue
\r
3811 // and let the cache object itself get destroyed
\r
3812 if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
\r
3818 // See jQuery.data for more information
\r
3820 delete cache[ id ].data;
\r
3822 // Don't destroy the parent cache unless the internal data object
\r
3823 // had been the only thing left in it
\r
3824 if ( !isEmptyDataObject( cache[ id ] ) ) {
\r
3829 // Destroy the cache
\r
3831 jQuery.cleanData( [ elem ], true );
\r
3833 // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
\r
3834 /* jshint eqeqeq: false */
\r
3835 } else if ( support.deleteExpando || cache != cache.window ) {
\r
3836 /* jshint eqeqeq: true */
\r
3837 delete cache[ id ];
\r
3839 // When all else fails, null
\r
3841 cache[ id ] = null;
\r
3848 // The following elements (space-suffixed to avoid Object.prototype collisions)
\r
3849 // throw uncatchable exceptions if you attempt to set expando properties
\r
3853 // ...but Flash objects (which have this classid) *can* handle expandos
\r
3854 "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
\r
3857 hasData: function( elem ) {
\r
3858 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
\r
3859 return !!elem && !isEmptyDataObject( elem );
\r
3862 data: function( elem, name, data ) {
\r
3863 return internalData( elem, name, data );
\r
3866 removeData: function( elem, name ) {
\r
3867 return internalRemoveData( elem, name );
\r
3870 // For internal use only.
\r
3871 _data: function( elem, name, data ) {
\r
3872 return internalData( elem, name, data, true );
\r
3875 _removeData: function( elem, name ) {
\r
3876 return internalRemoveData( elem, name, true );
\r
3880 jQuery.fn.extend({
\r
3881 data: function( key, value ) {
\r
3882 var i, name, data,
\r
3884 attrs = elem && elem.attributes;
\r
3886 // Special expections of .data basically thwart jQuery.access,
\r
3887 // so implement the relevant behavior ourselves
\r
3889 // Gets all values
\r
3890 if ( key === undefined ) {
\r
3891 if ( this.length ) {
\r
3892 data = jQuery.data( elem );
\r
3894 if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
\r
3897 name = attrs[i].name;
\r
3899 if ( name.indexOf("data-") === 0 ) {
\r
3900 name = jQuery.camelCase( name.slice(5) );
\r
3902 dataAttr( elem, name, data[ name ] );
\r
3905 jQuery._data( elem, "parsedAttrs", true );
\r
3912 // Sets multiple values
\r
3913 if ( typeof key === "object" ) {
\r
3914 return this.each(function() {
\r
3915 jQuery.data( this, key );
\r
3919 return arguments.length > 1 ?
\r
3922 this.each(function() {
\r
3923 jQuery.data( this, key, value );
\r
3927 // Try to fetch any internally stored data first
\r
3928 elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
\r
3931 removeData: function( key ) {
\r
3932 return this.each(function() {
\r
3933 jQuery.removeData( this, key );
\r
3940 queue: function( elem, type, data ) {
\r
3944 type = ( type || "fx" ) + "queue";
\r
3945 queue = jQuery._data( elem, type );
\r
3947 // Speed up dequeue by getting out quickly if this is just a lookup
\r
3949 if ( !queue || jQuery.isArray(data) ) {
\r
3950 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
\r
3952 queue.push( data );
\r
3955 return queue || [];
\r
3959 dequeue: function( elem, type ) {
\r
3960 type = type || "fx";
\r
3962 var queue = jQuery.queue( elem, type ),
\r
3963 startLength = queue.length,
\r
3964 fn = queue.shift(),
\r
3965 hooks = jQuery._queueHooks( elem, type ),
\r
3966 next = function() {
\r
3967 jQuery.dequeue( elem, type );
\r
3970 // If the fx queue is dequeued, always remove the progress sentinel
\r
3971 if ( fn === "inprogress" ) {
\r
3972 fn = queue.shift();
\r
3978 // Add a progress sentinel to prevent the fx queue from being
\r
3979 // automatically dequeued
\r
3980 if ( type === "fx" ) {
\r
3981 queue.unshift( "inprogress" );
\r
3984 // clear up the last queue stop function
\r
3985 delete hooks.stop;
\r
3986 fn.call( elem, next, hooks );
\r
3989 if ( !startLength && hooks ) {
\r
3990 hooks.empty.fire();
\r
3994 // not intended for public consumption - generates a queueHooks object, or returns the current one
\r
3995 _queueHooks: function( elem, type ) {
\r
3996 var key = type + "queueHooks";
\r
3997 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
\r
3998 empty: jQuery.Callbacks("once memory").add(function() {
\r
3999 jQuery._removeData( elem, type + "queue" );
\r
4000 jQuery._removeData( elem, key );
\r
4006 jQuery.fn.extend({
\r
4007 queue: function( type, data ) {
\r
4010 if ( typeof type !== "string" ) {
\r
4016 if ( arguments.length < setter ) {
\r
4017 return jQuery.queue( this[0], type );
\r
4020 return data === undefined ?
\r
4022 this.each(function() {
\r
4023 var queue = jQuery.queue( this, type, data );
\r
4025 // ensure a hooks for this queue
\r
4026 jQuery._queueHooks( this, type );
\r
4028 if ( type === "fx" && queue[0] !== "inprogress" ) {
\r
4029 jQuery.dequeue( this, type );
\r
4033 dequeue: function( type ) {
\r
4034 return this.each(function() {
\r
4035 jQuery.dequeue( this, type );
\r
4038 clearQueue: function( type ) {
\r
4039 return this.queue( type || "fx", [] );
\r
4041 // Get a promise resolved when queues of a certain type
\r
4042 // are emptied (fx is the type by default)
\r
4043 promise: function( type, obj ) {
\r
4046 defer = jQuery.Deferred(),
\r
4049 resolve = function() {
\r
4050 if ( !( --count ) ) {
\r
4051 defer.resolveWith( elements, [ elements ] );
\r
4055 if ( typeof type !== "string" ) {
\r
4059 type = type || "fx";
\r
4062 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
\r
4063 if ( tmp && tmp.empty ) {
\r
4065 tmp.empty.add( resolve );
\r
4069 return defer.promise( obj );
\r
4072 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
\r
4074 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
\r
4076 var isHidden = function( elem, el ) {
\r
4077 // isHidden might be called from jQuery#filter function;
\r
4078 // in that case, element will be second argument
\r
4079 elem = el || elem;
\r
4080 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
\r
4085 // Multifunctional method to get and set values of a collection
\r
4086 // The value/s can optionally be executed if it's a function
\r
4087 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
\r
4089 length = elems.length,
\r
4090 bulk = key == null;
\r
4092 // Sets many values
\r
4093 if ( jQuery.type( key ) === "object" ) {
\r
4095 for ( i in key ) {
\r
4096 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
\r
4100 } else if ( value !== undefined ) {
\r
4103 if ( !jQuery.isFunction( value ) ) {
\r
4108 // Bulk operations run against the entire set
\r
4110 fn.call( elems, value );
\r
4113 // ...except when executing function values
\r
4116 fn = function( elem, key, value ) {
\r
4117 return bulk.call( jQuery( elem ), value );
\r
4123 for ( ; i < length; i++ ) {
\r
4124 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
\r
4129 return chainable ?
\r
4134 fn.call( elems ) :
\r
4135 length ? fn( elems[0], key ) : emptyGet;
\r
4137 var rcheckableType = (/^(?:checkbox|radio)$/i);
\r
4142 var fragment = document.createDocumentFragment(),
\r
4143 div = document.createElement("div"),
\r
4144 input = document.createElement("input");
\r
4147 div.setAttribute( "className", "t" );
\r
4148 div.innerHTML = " <link/><table></table><a href='/a'>a</a>";
\r
4150 // IE strips leading whitespace when .innerHTML is used
\r
4151 support.leadingWhitespace = div.firstChild.nodeType === 3;
\r
4153 // Make sure that tbody elements aren't automatically inserted
\r
4154 // IE will insert them into empty tables
\r
4155 support.tbody = !div.getElementsByTagName( "tbody" ).length;
\r
4157 // Make sure that link elements get serialized correctly by innerHTML
\r
4158 // This requires a wrapper element in IE
\r
4159 support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
\r
4161 // Makes sure cloning an html5 element does not cause problems
\r
4162 // Where outerHTML is undefined, this still works
\r
4163 support.html5Clone =
\r
4164 document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
\r
4166 // Check if a disconnected checkbox will retain its checked
\r
4167 // value of true after appended to the DOM (IE6/7)
\r
4168 input.type = "checkbox";
\r
4169 input.checked = true;
\r
4170 fragment.appendChild( input );
\r
4171 support.appendChecked = input.checked;
\r
4173 // Make sure textarea (and checkbox) defaultValue is properly cloned
\r
4174 // Support: IE6-IE11+
\r
4175 div.innerHTML = "<textarea>x</textarea>";
\r
4176 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
\r
4178 // #11217 - WebKit loses check when the name is after the checked attribute
\r
4179 fragment.appendChild( div );
\r
4180 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
\r
4182 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
\r
4183 // old WebKit doesn't clone checked state correctly in fragments
\r
4184 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
\r
4187 // Opera does not clone events (and typeof div.attachEvent === undefined).
\r
4188 // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
\r
4189 support.noCloneEvent = true;
\r
4190 if ( div.attachEvent ) {
\r
4191 div.attachEvent( "onclick", function() {
\r
4192 support.noCloneEvent = false;
\r
4195 div.cloneNode( true ).click();
\r
4198 // Execute the test only if not already executed in another module.
\r
4199 if (support.deleteExpando == null) {
\r
4201 support.deleteExpando = true;
\r
4205 support.deleteExpando = false;
\r
4209 // Null elements to avoid leaks in IE.
\r
4210 fragment = div = input = null;
\r
4216 div = document.createElement( "div" );
\r
4218 // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
\r
4219 for ( i in { submit: true, change: true, focusin: true }) {
\r
4220 eventName = "on" + i;
\r
4222 if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
\r
4223 // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
\r
4224 div.setAttribute( eventName, "t" );
\r
4225 support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
\r
4229 // Null elements to avoid leaks in IE.
\r
4234 var rformElems = /^(?:input|select|textarea)$/i,
\r
4235 rkeyEvent = /^key/,
\r
4236 rmouseEvent = /^(?:mouse|contextmenu)|click/,
\r
4237 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
\r
4238 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
\r
4240 function returnTrue() {
\r
4244 function returnFalse() {
\r
4248 function safeActiveElement() {
\r
4250 return document.activeElement;
\r
4251 } catch ( err ) { }
\r
4255 * Helper functions for managing events -- not part of the public interface.
\r
4256 * Props to Dean Edwards' addEvent library for many of the ideas.
\r
4262 add: function( elem, types, handler, data, selector ) {
\r
4263 var tmp, events, t, handleObjIn,
\r
4264 special, eventHandle, handleObj,
\r
4265 handlers, type, namespaces, origType,
\r
4266 elemData = jQuery._data( elem );
\r
4268 // Don't attach events to noData or text/comment nodes (but allow plain objects)
\r
4269 if ( !elemData ) {
\r
4273 // Caller can pass in an object of custom data in lieu of the handler
\r
4274 if ( handler.handler ) {
\r
4275 handleObjIn = handler;
\r
4276 handler = handleObjIn.handler;
\r
4277 selector = handleObjIn.selector;
\r
4280 // Make sure that the handler has a unique ID, used to find/remove it later
\r
4281 if ( !handler.guid ) {
\r
4282 handler.guid = jQuery.guid++;
\r
4285 // Init the element's event structure and main handler, if this is the first
\r
4286 if ( !(events = elemData.events) ) {
\r
4287 events = elemData.events = {};
\r
4289 if ( !(eventHandle = elemData.handle) ) {
\r
4290 eventHandle = elemData.handle = function( e ) {
\r
4291 // Discard the second event of a jQuery.event.trigger() and
\r
4292 // when an event is called after a page has unloaded
\r
4293 return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
\r
4294 jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
\r
4297 // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
\r
4298 eventHandle.elem = elem;
\r
4301 // Handle multiple events separated by a space
\r
4302 types = ( types || "" ).match( rnotwhite ) || [ "" ];
\r
4305 tmp = rtypenamespace.exec( types[t] ) || [];
\r
4306 type = origType = tmp[1];
\r
4307 namespaces = ( tmp[2] || "" ).split( "." ).sort();
\r
4309 // There *must* be a type, no attaching namespace-only handlers
\r
4314 // If event changes its type, use the special event handlers for the changed type
\r
4315 special = jQuery.event.special[ type ] || {};
\r
4317 // If selector defined, determine special event api type, otherwise given type
\r
4318 type = ( selector ? special.delegateType : special.bindType ) || type;
\r
4320 // Update special based on newly reset type
\r
4321 special = jQuery.event.special[ type ] || {};
\r
4323 // handleObj is passed to all event handlers
\r
4324 handleObj = jQuery.extend({
\r
4326 origType: origType,
\r
4329 guid: handler.guid,
\r
4330 selector: selector,
\r
4331 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
\r
4332 namespace: namespaces.join(".")
\r
4335 // Init the event handler queue if we're the first
\r
4336 if ( !(handlers = events[ type ]) ) {
\r
4337 handlers = events[ type ] = [];
\r
4338 handlers.delegateCount = 0;
\r
4340 // Only use addEventListener/attachEvent if the special events handler returns false
\r
4341 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
\r
4342 // Bind the global event handler to the element
\r
4343 if ( elem.addEventListener ) {
\r
4344 elem.addEventListener( type, eventHandle, false );
\r
4346 } else if ( elem.attachEvent ) {
\r
4347 elem.attachEvent( "on" + type, eventHandle );
\r
4352 if ( special.add ) {
\r
4353 special.add.call( elem, handleObj );
\r
4355 if ( !handleObj.handler.guid ) {
\r
4356 handleObj.handler.guid = handler.guid;
\r
4360 // Add to the element's handler list, delegates in front
\r
4362 handlers.splice( handlers.delegateCount++, 0, handleObj );
\r
4364 handlers.push( handleObj );
\r
4367 // Keep track of which events have ever been used, for event optimization
\r
4368 jQuery.event.global[ type ] = true;
\r
4371 // Nullify elem to prevent memory leaks in IE
\r
4375 // Detach an event or set of events from an element
\r
4376 remove: function( elem, types, handler, selector, mappedTypes ) {
\r
4377 var j, handleObj, tmp,
\r
4378 origCount, t, events,
\r
4379 special, handlers, type,
\r
4380 namespaces, origType,
\r
4381 elemData = jQuery.hasData( elem ) && jQuery._data( elem );
\r
4383 if ( !elemData || !(events = elemData.events) ) {
\r
4387 // Once for each type.namespace in types; type may be omitted
\r
4388 types = ( types || "" ).match( rnotwhite ) || [ "" ];
\r
4391 tmp = rtypenamespace.exec( types[t] ) || [];
\r
4392 type = origType = tmp[1];
\r
4393 namespaces = ( tmp[2] || "" ).split( "." ).sort();
\r
4395 // Unbind all events (on this namespace, if provided) for the element
\r
4397 for ( type in events ) {
\r
4398 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
\r
4403 special = jQuery.event.special[ type ] || {};
\r
4404 type = ( selector ? special.delegateType : special.bindType ) || type;
\r
4405 handlers = events[ type ] || [];
\r
4406 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
\r
4408 // Remove matching events
\r
4409 origCount = j = handlers.length;
\r
4411 handleObj = handlers[ j ];
\r
4413 if ( ( mappedTypes || origType === handleObj.origType ) &&
\r
4414 ( !handler || handler.guid === handleObj.guid ) &&
\r
4415 ( !tmp || tmp.test( handleObj.namespace ) ) &&
\r
4416 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
\r
4417 handlers.splice( j, 1 );
\r
4419 if ( handleObj.selector ) {
\r
4420 handlers.delegateCount--;
\r
4422 if ( special.remove ) {
\r
4423 special.remove.call( elem, handleObj );
\r
4428 // Remove generic event handler if we removed something and no more handlers exist
\r
4429 // (avoids potential for endless recursion during removal of special event handlers)
\r
4430 if ( origCount && !handlers.length ) {
\r
4431 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
\r
4432 jQuery.removeEvent( elem, type, elemData.handle );
\r
4435 delete events[ type ];
\r
4439 // Remove the expando if it's no longer used
\r
4440 if ( jQuery.isEmptyObject( events ) ) {
\r
4441 delete elemData.handle;
\r
4443 // removeData also checks for emptiness and clears the expando if empty
\r
4444 // so use it instead of delete
\r
4445 jQuery._removeData( elem, "events" );
\r
4449 trigger: function( event, data, elem, onlyHandlers ) {
\r
4450 var handle, ontype, cur,
\r
4451 bubbleType, special, tmp, i,
\r
4452 eventPath = [ elem || document ],
\r
4453 type = hasOwn.call( event, "type" ) ? event.type : event,
\r
4454 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
\r
4456 cur = tmp = elem = elem || document;
\r
4458 // Don't do events on text and comment nodes
\r
4459 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
\r
4463 // focus/blur morphs to focusin/out; ensure we're not firing them right now
\r
4464 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
\r
4468 if ( type.indexOf(".") >= 0 ) {
\r
4469 // Namespaced trigger; create a regexp to match event type in handle()
\r
4470 namespaces = type.split(".");
\r
4471 type = namespaces.shift();
\r
4472 namespaces.sort();
\r
4474 ontype = type.indexOf(":") < 0 && "on" + type;
\r
4476 // Caller can pass in a jQuery.Event object, Object, or just an event type string
\r
4477 event = event[ jQuery.expando ] ?
\r
4479 new jQuery.Event( type, typeof event === "object" && event );
\r
4481 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
\r
4482 event.isTrigger = onlyHandlers ? 2 : 3;
\r
4483 event.namespace = namespaces.join(".");
\r
4484 event.namespace_re = event.namespace ?
\r
4485 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
\r
4488 // Clean up the event in case it is being reused
\r
4489 event.result = undefined;
\r
4490 if ( !event.target ) {
\r
4491 event.target = elem;
\r
4494 // Clone any incoming data and prepend the event, creating the handler arg list
\r
4495 data = data == null ?
\r
4497 jQuery.makeArray( data, [ event ] );
\r
4499 // Allow special events to draw outside the lines
\r
4500 special = jQuery.event.special[ type ] || {};
\r
4501 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
\r
4505 // Determine event propagation path in advance, per W3C events spec (#9951)
\r
4506 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
\r
4507 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
\r
4509 bubbleType = special.delegateType || type;
\r
4510 if ( !rfocusMorph.test( bubbleType + type ) ) {
\r
4511 cur = cur.parentNode;
\r
4513 for ( ; cur; cur = cur.parentNode ) {
\r
4514 eventPath.push( cur );
\r
4518 // Only add window if we got to document (e.g., not plain obj or detached DOM)
\r
4519 if ( tmp === (elem.ownerDocument || document) ) {
\r
4520 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
\r
4524 // Fire handlers on the event path
\r
4526 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
\r
4528 event.type = i > 1 ?
\r
4530 special.bindType || type;
\r
4533 handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
\r
4535 handle.apply( cur, data );
\r
4539 handle = ontype && cur[ ontype ];
\r
4540 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
\r
4541 event.result = handle.apply( cur, data );
\r
4542 if ( event.result === false ) {
\r
4543 event.preventDefault();
\r
4547 event.type = type;
\r
4549 // If nobody prevented the default action, do it now
\r
4550 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
\r
4552 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
\r
4553 jQuery.acceptData( elem ) ) {
\r
4555 // Call a native DOM method on the target with the same name name as the event.
\r
4556 // Can't use an .isFunction() check here because IE6/7 fails that test.
\r
4557 // Don't do default actions on window, that's where global variables be (#6170)
\r
4558 if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
\r
4560 // Don't re-trigger an onFOO event when we call its FOO() method
\r
4561 tmp = elem[ ontype ];
\r
4564 elem[ ontype ] = null;
\r
4567 // Prevent re-triggering of the same event, since we already bubbled it above
\r
4568 jQuery.event.triggered = type;
\r
4572 // IE<9 dies on focus/blur to hidden element (#1486,#12518)
\r
4573 // only reproducible on winXP IE8 native, not IE9 in IE8 mode
\r
4575 jQuery.event.triggered = undefined;
\r
4578 elem[ ontype ] = tmp;
\r
4584 return event.result;
\r
4587 dispatch: function( event ) {
\r
4589 // Make a writable jQuery.Event from the native event object
\r
4590 event = jQuery.event.fix( event );
\r
4592 var i, ret, handleObj, matched, j,
\r
4593 handlerQueue = [],
\r
4594 args = slice.call( arguments ),
\r
4595 handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
\r
4596 special = jQuery.event.special[ event.type ] || {};
\r
4598 // Use the fix-ed jQuery.Event rather than the (read-only) native event
\r
4600 event.delegateTarget = this;
\r
4602 // Call the preDispatch hook for the mapped type, and let it bail if desired
\r
4603 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
\r
4607 // Determine handlers
\r
4608 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
\r
4610 // Run delegates first; they may want to stop propagation beneath us
\r
4612 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
\r
4613 event.currentTarget = matched.elem;
\r
4616 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
\r
4618 // Triggered event must either 1) have no namespace, or
\r
4619 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
\r
4620 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
\r
4622 event.handleObj = handleObj;
\r
4623 event.data = handleObj.data;
\r
4625 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
\r
4626 .apply( matched.elem, args );
\r
4628 if ( ret !== undefined ) {
\r
4629 if ( (event.result = ret) === false ) {
\r
4630 event.preventDefault();
\r
4631 event.stopPropagation();
\r
4638 // Call the postDispatch hook for the mapped type
\r
4639 if ( special.postDispatch ) {
\r
4640 special.postDispatch.call( this, event );
\r
4643 return event.result;
\r
4646 handlers: function( event, handlers ) {
\r
4647 var sel, handleObj, matches, i,
\r
4648 handlerQueue = [],
\r
4649 delegateCount = handlers.delegateCount,
\r
4650 cur = event.target;
\r
4652 // Find delegate handlers
\r
4653 // Black-hole SVG <use> instance trees (#13180)
\r
4654 // Avoid non-left-click bubbling in Firefox (#3861)
\r
4655 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
\r
4657 /* jshint eqeqeq: false */
\r
4658 for ( ; cur != this; cur = cur.parentNode || this ) {
\r
4659 /* jshint eqeqeq: true */
\r
4661 // Don't check non-elements (#13208)
\r
4662 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
\r
4663 if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
\r
4665 for ( i = 0; i < delegateCount; i++ ) {
\r
4666 handleObj = handlers[ i ];
\r
4668 // Don't conflict with Object.prototype properties (#13203)
\r
4669 sel = handleObj.selector + " ";
\r
4671 if ( matches[ sel ] === undefined ) {
\r
4672 matches[ sel ] = handleObj.needsContext ?
\r
4673 jQuery( sel, this ).index( cur ) >= 0 :
\r
4674 jQuery.find( sel, this, null, [ cur ] ).length;
\r
4676 if ( matches[ sel ] ) {
\r
4677 matches.push( handleObj );
\r
4680 if ( matches.length ) {
\r
4681 handlerQueue.push({ elem: cur, handlers: matches });
\r
4687 // Add the remaining (directly-bound) handlers
\r
4688 if ( delegateCount < handlers.length ) {
\r
4689 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
\r
4692 return handlerQueue;
\r
4695 fix: function( event ) {
\r
4696 if ( event[ jQuery.expando ] ) {
\r
4700 // Create a writable copy of the event object and normalize some properties
\r
4701 var i, prop, copy,
\r
4702 type = event.type,
\r
4703 originalEvent = event,
\r
4704 fixHook = this.fixHooks[ type ];
\r
4707 this.fixHooks[ type ] = fixHook =
\r
4708 rmouseEvent.test( type ) ? this.mouseHooks :
\r
4709 rkeyEvent.test( type ) ? this.keyHooks :
\r
4712 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
\r
4714 event = new jQuery.Event( originalEvent );
\r
4719 event[ prop ] = originalEvent[ prop ];
\r
4723 // Fix target property (#1925)
\r
4724 if ( !event.target ) {
\r
4725 event.target = originalEvent.srcElement || document;
\r
4728 // Support: Chrome 23+, Safari?
\r
4729 // Target should not be a text node (#504, #13143)
\r
4730 if ( event.target.nodeType === 3 ) {
\r
4731 event.target = event.target.parentNode;
\r
4735 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
\r
4736 event.metaKey = !!event.metaKey;
\r
4738 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
\r
4741 // Includes some event props shared by KeyEvent and MouseEvent
\r
4742 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
\r
4747 props: "char charCode key keyCode".split(" "),
\r
4748 filter: function( event, original ) {
\r
4750 // Add which for key events
\r
4751 if ( event.which == null ) {
\r
4752 event.which = original.charCode != null ? original.charCode : original.keyCode;
\r
4760 props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
\r
4761 filter: function( event, original ) {
\r
4762 var body, eventDoc, doc,
\r
4763 button = original.button,
\r
4764 fromElement = original.fromElement;
\r
4766 // Calculate pageX/Y if missing and clientX/Y available
\r
4767 if ( event.pageX == null && original.clientX != null ) {
\r
4768 eventDoc = event.target.ownerDocument || document;
\r
4769 doc = eventDoc.documentElement;
\r
4770 body = eventDoc.body;
\r
4772 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
\r
4773 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
\r
4776 // Add relatedTarget, if necessary
\r
4777 if ( !event.relatedTarget && fromElement ) {
\r
4778 event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
\r
4781 // Add which for click: 1 === left; 2 === middle; 3 === right
\r
4782 // Note: button is not normalized, so don't use it
\r
4783 if ( !event.which && button !== undefined ) {
\r
4784 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
\r
4793 // Prevent triggered image.load events from bubbling to window.load
\r
4797 // Fire native event if possible so blur/focus sequence is correct
\r
4798 trigger: function() {
\r
4799 if ( this !== safeActiveElement() && this.focus ) {
\r
4805 // If we error on focus to hidden element (#1486, #12518),
\r
4806 // let .trigger() run the handlers
\r
4810 delegateType: "focusin"
\r
4813 trigger: function() {
\r
4814 if ( this === safeActiveElement() && this.blur ) {
\r
4819 delegateType: "focusout"
\r
4822 // For checkbox, fire native event so checked state will be right
\r
4823 trigger: function() {
\r
4824 if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
\r
4830 // For cross-browser consistency, don't fire native .click() on links
\r
4831 _default: function( event ) {
\r
4832 return jQuery.nodeName( event.target, "a" );
\r
4837 postDispatch: function( event ) {
\r
4839 // Even when returnValue equals to undefined Firefox will still show alert
\r
4840 if ( event.result !== undefined ) {
\r
4841 event.originalEvent.returnValue = event.result;
\r
4847 simulate: function( type, elem, event, bubble ) {
\r
4848 // Piggyback on a donor event to simulate a different one.
\r
4849 // Fake originalEvent to avoid donor's stopPropagation, but if the
\r
4850 // simulated event prevents default then we do the same on the donor.
\r
4851 var e = jQuery.extend(
\r
4852 new jQuery.Event(),
\r
4856 isSimulated: true,
\r
4861 jQuery.event.trigger( e, null, elem );
\r
4863 jQuery.event.dispatch.call( elem, e );
\r
4865 if ( e.isDefaultPrevented() ) {
\r
4866 event.preventDefault();
\r
4871 jQuery.removeEvent = document.removeEventListener ?
\r
4872 function( elem, type, handle ) {
\r
4873 if ( elem.removeEventListener ) {
\r
4874 elem.removeEventListener( type, handle, false );
\r
4877 function( elem, type, handle ) {
\r
4878 var name = "on" + type;
\r
4880 if ( elem.detachEvent ) {
\r
4882 // #8545, #7054, preventing memory leaks for custom events in IE6-8
\r
4883 // detachEvent needed property on element, by name of that event, to properly expose it to GC
\r
4884 if ( typeof elem[ name ] === strundefined ) {
\r
4885 elem[ name ] = null;
\r
4888 elem.detachEvent( name, handle );
\r
4892 jQuery.Event = function( src, props ) {
\r
4893 // Allow instantiation without the 'new' keyword
\r
4894 if ( !(this instanceof jQuery.Event) ) {
\r
4895 return new jQuery.Event( src, props );
\r
4899 if ( src && src.type ) {
\r
4900 this.originalEvent = src;
\r
4901 this.type = src.type;
\r
4903 // Events bubbling up the document may have been marked as prevented
\r
4904 // by a handler lower down the tree; reflect the correct value.
\r
4905 this.isDefaultPrevented = src.defaultPrevented ||
\r
4906 src.defaultPrevented === undefined && (
\r
4907 // Support: IE < 9
\r
4908 src.returnValue === false ||
\r
4909 // Support: Android < 4.0
\r
4910 src.getPreventDefault && src.getPreventDefault() ) ?
\r
4919 // Put explicitly provided properties onto the event object
\r
4921 jQuery.extend( this, props );
\r
4924 // Create a timestamp if incoming event doesn't have one
\r
4925 this.timeStamp = src && src.timeStamp || jQuery.now();
\r
4927 // Mark it as fixed
\r
4928 this[ jQuery.expando ] = true;
\r
4931 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
\r
4932 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
\r
4933 jQuery.Event.prototype = {
\r
4934 isDefaultPrevented: returnFalse,
\r
4935 isPropagationStopped: returnFalse,
\r
4936 isImmediatePropagationStopped: returnFalse,
\r
4938 preventDefault: function() {
\r
4939 var e = this.originalEvent;
\r
4941 this.isDefaultPrevented = returnTrue;
\r
4946 // If preventDefault exists, run it on the original event
\r
4947 if ( e.preventDefault ) {
\r
4948 e.preventDefault();
\r
4951 // Otherwise set the returnValue property of the original event to false
\r
4953 e.returnValue = false;
\r
4956 stopPropagation: function() {
\r
4957 var e = this.originalEvent;
\r
4959 this.isPropagationStopped = returnTrue;
\r
4963 // If stopPropagation exists, run it on the original event
\r
4964 if ( e.stopPropagation ) {
\r
4965 e.stopPropagation();
\r
4969 // Set the cancelBubble property of the original event to true
\r
4970 e.cancelBubble = true;
\r
4972 stopImmediatePropagation: function() {
\r
4973 this.isImmediatePropagationStopped = returnTrue;
\r
4974 this.stopPropagation();
\r
4978 // Create mouseenter/leave events using mouseover/out and event-time checks
\r
4980 mouseenter: "mouseover",
\r
4981 mouseleave: "mouseout"
\r
4982 }, function( orig, fix ) {
\r
4983 jQuery.event.special[ orig ] = {
\r
4984 delegateType: fix,
\r
4987 handle: function( event ) {
\r
4990 related = event.relatedTarget,
\r
4991 handleObj = event.handleObj;
\r
4993 // For mousenter/leave call the handler if related is outside the target.
\r
4994 // NB: No relatedTarget if the mouse left/entered the browser window
\r
4995 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
\r
4996 event.type = handleObj.origType;
\r
4997 ret = handleObj.handler.apply( this, arguments );
\r
5005 // IE submit delegation
\r
5006 if ( !support.submitBubbles ) {
\r
5008 jQuery.event.special.submit = {
\r
5009 setup: function() {
\r
5010 // Only need this for delegated form submit events
\r
5011 if ( jQuery.nodeName( this, "form" ) ) {
\r
5015 // Lazy-add a submit handler when a descendant form may potentially be submitted
\r
5016 jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
\r
5017 // Node name check avoids a VML-related crash in IE (#9807)
\r
5018 var elem = e.target,
\r
5019 form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
\r
5020 if ( form && !jQuery._data( form, "submitBubbles" ) ) {
\r
5021 jQuery.event.add( form, "submit._submit", function( event ) {
\r
5022 event._submit_bubble = true;
\r
5024 jQuery._data( form, "submitBubbles", true );
\r
5027 // return undefined since we don't need an event listener
\r
5030 postDispatch: function( event ) {
\r
5031 // If form was submitted by the user, bubble the event up the tree
\r
5032 if ( event._submit_bubble ) {
\r
5033 delete event._submit_bubble;
\r
5034 if ( this.parentNode && !event.isTrigger ) {
\r
5035 jQuery.event.simulate( "submit", this.parentNode, event, true );
\r
5040 teardown: function() {
\r
5041 // Only need this for delegated form submit events
\r
5042 if ( jQuery.nodeName( this, "form" ) ) {
\r
5046 // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
\r
5047 jQuery.event.remove( this, "._submit" );
\r
5052 // IE change delegation and checkbox/radio fix
\r
5053 if ( !support.changeBubbles ) {
\r
5055 jQuery.event.special.change = {
\r
5057 setup: function() {
\r
5059 if ( rformElems.test( this.nodeName ) ) {
\r
5060 // IE doesn't fire change on a check/radio until blur; trigger it on click
\r
5061 // after a propertychange. Eat the blur-change in special.change.handle.
\r
5062 // This still fires onchange a second time for check/radio after blur.
\r
5063 if ( this.type === "checkbox" || this.type === "radio" ) {
\r
5064 jQuery.event.add( this, "propertychange._change", function( event ) {
\r
5065 if ( event.originalEvent.propertyName === "checked" ) {
\r
5066 this._just_changed = true;
\r
5069 jQuery.event.add( this, "click._change", function( event ) {
\r
5070 if ( this._just_changed && !event.isTrigger ) {
\r
5071 this._just_changed = false;
\r
5073 // Allow triggered, simulated change events (#11500)
\r
5074 jQuery.event.simulate( "change", this, event, true );
\r
5079 // Delegated event; lazy-add a change handler on descendant inputs
\r
5080 jQuery.event.add( this, "beforeactivate._change", function( e ) {
\r
5081 var elem = e.target;
\r
5083 if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
\r
5084 jQuery.event.add( elem, "change._change", function( event ) {
\r
5085 if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
\r
5086 jQuery.event.simulate( "change", this.parentNode, event, true );
\r
5089 jQuery._data( elem, "changeBubbles", true );
\r
5094 handle: function( event ) {
\r
5095 var elem = event.target;
\r
5097 // Swallow native change events from checkbox/radio, we already triggered them above
\r
5098 if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
\r
5099 return event.handleObj.handler.apply( this, arguments );
\r
5103 teardown: function() {
\r
5104 jQuery.event.remove( this, "._change" );
\r
5106 return !rformElems.test( this.nodeName );
\r
5111 // Create "bubbling" focus and blur events
\r
5112 if ( !support.focusinBubbles ) {
\r
5113 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
\r
5115 // Attach a single capturing handler on the document while someone wants focusin/focusout
\r
5116 var handler = function( event ) {
\r
5117 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
\r
5120 jQuery.event.special[ fix ] = {
\r
5121 setup: function() {
\r
5122 var doc = this.ownerDocument || this,
\r
5123 attaches = jQuery._data( doc, fix );
\r
5125 if ( !attaches ) {
\r
5126 doc.addEventListener( orig, handler, true );
\r
5128 jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
\r
5130 teardown: function() {
\r
5131 var doc = this.ownerDocument || this,
\r
5132 attaches = jQuery._data( doc, fix ) - 1;
\r
5134 if ( !attaches ) {
\r
5135 doc.removeEventListener( orig, handler, true );
\r
5136 jQuery._removeData( doc, fix );
\r
5138 jQuery._data( doc, fix, attaches );
\r
5145 jQuery.fn.extend({
\r
5147 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
\r
5150 // Types can be a map of types/handlers
\r
5151 if ( typeof types === "object" ) {
\r
5152 // ( types-Object, selector, data )
\r
5153 if ( typeof selector !== "string" ) {
\r
5154 // ( types-Object, data )
\r
5155 data = data || selector;
\r
5156 selector = undefined;
\r
5158 for ( type in types ) {
\r
5159 this.on( type, selector, data, types[ type ], one );
\r
5164 if ( data == null && fn == null ) {
\r
5167 data = selector = undefined;
\r
5168 } else if ( fn == null ) {
\r
5169 if ( typeof selector === "string" ) {
\r
5170 // ( types, selector, fn )
\r
5174 // ( types, data, fn )
\r
5177 selector = undefined;
\r
5180 if ( fn === false ) {
\r
5182 } else if ( !fn ) {
\r
5186 if ( one === 1 ) {
\r
5188 fn = function( event ) {
\r
5189 // Can use an empty set, since event contains the info
\r
5190 jQuery().off( event );
\r
5191 return origFn.apply( this, arguments );
\r
5193 // Use same guid so caller can remove using origFn
\r
5194 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
\r
5196 return this.each( function() {
\r
5197 jQuery.event.add( this, types, fn, data, selector );
\r
5200 one: function( types, selector, data, fn ) {
\r
5201 return this.on( types, selector, data, fn, 1 );
\r
5203 off: function( types, selector, fn ) {
\r
5204 var handleObj, type;
\r
5205 if ( types && types.preventDefault && types.handleObj ) {
\r
5206 // ( event ) dispatched jQuery.Event
\r
5207 handleObj = types.handleObj;
\r
5208 jQuery( types.delegateTarget ).off(
\r
5209 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
\r
5210 handleObj.selector,
\r
5215 if ( typeof types === "object" ) {
\r
5216 // ( types-object [, selector] )
\r
5217 for ( type in types ) {
\r
5218 this.off( type, selector, types[ type ] );
\r
5222 if ( selector === false || typeof selector === "function" ) {
\r
5223 // ( types [, fn] )
\r
5225 selector = undefined;
\r
5227 if ( fn === false ) {
\r
5230 return this.each(function() {
\r
5231 jQuery.event.remove( this, types, fn, selector );
\r
5235 trigger: function( type, data ) {
\r
5236 return this.each(function() {
\r
5237 jQuery.event.trigger( type, data, this );
\r
5240 triggerHandler: function( type, data ) {
\r
5241 var elem = this[0];
\r
5243 return jQuery.event.trigger( type, data, elem, true );
\r
5249 function createSafeFragment( document ) {
\r
5250 var list = nodeNames.split( "|" ),
\r
5251 safeFrag = document.createDocumentFragment();
\r
5253 if ( safeFrag.createElement ) {
\r
5254 while ( list.length ) {
\r
5255 safeFrag.createElement(
\r
5263 var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
\r
5264 "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
\r
5265 rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
\r
5266 rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
\r
5267 rleadingWhitespace = /^\s+/,
\r
5268 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
\r
5269 rtagName = /<([\w:]+)/,
\r
5270 rtbody = /<tbody/i,
\r
5271 rhtml = /<|&#?\w+;/,
\r
5272 rnoInnerhtml = /<(?:script|style|link)/i,
\r
5273 // checked="checked" or checked
\r
5274 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
\r
5275 rscriptType = /^$|\/(?:java|ecma)script/i,
\r
5276 rscriptTypeMasked = /^true\/(.*)/,
\r
5277 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
\r
5279 // We have to close these tags to support XHTML (#13200)
\r
5281 option: [ 1, "<select multiple='multiple'>", "</select>" ],
\r
5282 legend: [ 1, "<fieldset>", "</fieldset>" ],
\r
5283 area: [ 1, "<map>", "</map>" ],
\r
5284 param: [ 1, "<object>", "</object>" ],
\r
5285 thead: [ 1, "<table>", "</table>" ],
\r
5286 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
\r
5287 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
\r
5288 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
\r
5290 // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
\r
5291 // unless wrapped in a div with non-breaking characters in front of it.
\r
5292 _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
\r
5294 safeFragment = createSafeFragment( document ),
\r
5295 fragmentDiv = safeFragment.appendChild( document.createElement("div") );
\r
5297 wrapMap.optgroup = wrapMap.option;
\r
5298 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
\r
5299 wrapMap.th = wrapMap.td;
\r
5301 function getAll( context, tag ) {
\r
5304 found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
\r
5305 typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
\r
5309 for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
\r
5310 if ( !tag || jQuery.nodeName( elem, tag ) ) {
\r
5311 found.push( elem );
\r
5313 jQuery.merge( found, getAll( elem, tag ) );
\r
5318 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
\r
5319 jQuery.merge( [ context ], found ) :
\r
5323 // Used in buildFragment, fixes the defaultChecked property
\r
5324 function fixDefaultChecked( elem ) {
\r
5325 if ( rcheckableType.test( elem.type ) ) {
\r
5326 elem.defaultChecked = elem.checked;
\r
5331 // Manipulating tables requires a tbody
\r
5332 function manipulationTarget( elem, content ) {
\r
5333 return jQuery.nodeName( elem, "table" ) &&
\r
5334 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
\r
5336 elem.getElementsByTagName("tbody")[0] ||
\r
5337 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
\r
5341 // Replace/restore the type attribute of script elements for safe DOM manipulation
\r
5342 function disableScript( elem ) {
\r
5343 elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
\r
5346 function restoreScript( elem ) {
\r
5347 var match = rscriptTypeMasked.exec( elem.type );
\r
5349 elem.type = match[1];
\r
5351 elem.removeAttribute("type");
\r
5356 // Mark scripts as having already been evaluated
\r
5357 function setGlobalEval( elems, refElements ) {
\r
5360 for ( ; (elem = elems[i]) != null; i++ ) {
\r
5361 jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
\r
5365 function cloneCopyEvent( src, dest ) {
\r
5367 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
\r
5372 oldData = jQuery._data( src ),
\r
5373 curData = jQuery._data( dest, oldData ),
\r
5374 events = oldData.events;
\r
5377 delete curData.handle;
\r
5378 curData.events = {};
\r
5380 for ( type in events ) {
\r
5381 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
\r
5382 jQuery.event.add( dest, type, events[ type ][ i ] );
\r
5387 // make the cloned public data object a copy from the original
\r
5388 if ( curData.data ) {
\r
5389 curData.data = jQuery.extend( {}, curData.data );
\r
5393 function fixCloneNodeIssues( src, dest ) {
\r
5394 var nodeName, e, data;
\r
5396 // We do not need to do anything for non-Elements
\r
5397 if ( dest.nodeType !== 1 ) {
\r
5401 nodeName = dest.nodeName.toLowerCase();
\r
5403 // IE6-8 copies events bound via attachEvent when using cloneNode.
\r
5404 if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
\r
5405 data = jQuery._data( dest );
\r
5407 for ( e in data.events ) {
\r
5408 jQuery.removeEvent( dest, e, data.handle );
\r
5411 // Event data gets referenced instead of copied if the expando gets copied too
\r
5412 dest.removeAttribute( jQuery.expando );
\r
5415 // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
\r
5416 if ( nodeName === "script" && dest.text !== src.text ) {
\r
5417 disableScript( dest ).text = src.text;
\r
5418 restoreScript( dest );
\r
5420 // IE6-10 improperly clones children of object elements using classid.
\r
5421 // IE10 throws NoModificationAllowedError if parent is null, #12132.
\r
5422 } else if ( nodeName === "object" ) {
\r
5423 if ( dest.parentNode ) {
\r
5424 dest.outerHTML = src.outerHTML;
\r
5427 // This path appears unavoidable for IE9. When cloning an object
\r
5428 // element in IE9, the outerHTML strategy above is not sufficient.
\r
5429 // If the src has innerHTML and the destination does not,
\r
5430 // copy the src.innerHTML into the dest.innerHTML. #10324
\r
5431 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
\r
5432 dest.innerHTML = src.innerHTML;
\r
5435 } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
\r
5436 // IE6-8 fails to persist the checked state of a cloned checkbox
\r
5437 // or radio button. Worse, IE6-7 fail to give the cloned element
\r
5438 // a checked appearance if the defaultChecked value isn't also set
\r
5440 dest.defaultChecked = dest.checked = src.checked;
\r
5442 // IE6-7 get confused and end up setting the value of a cloned
\r
5443 // checkbox/radio button to an empty string instead of "on"
\r
5444 if ( dest.value !== src.value ) {
\r
5445 dest.value = src.value;
\r
5448 // IE6-8 fails to return the selected option to the default selected
\r
5449 // state when cloning options
\r
5450 } else if ( nodeName === "option" ) {
\r
5451 dest.defaultSelected = dest.selected = src.defaultSelected;
\r
5453 // IE6-8 fails to set the defaultValue to the correct value when
\r
5454 // cloning other types of input fields
\r
5455 } else if ( nodeName === "input" || nodeName === "textarea" ) {
\r
5456 dest.defaultValue = src.defaultValue;
\r
5461 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
\r
5462 var destElements, node, clone, i, srcElements,
\r
5463 inPage = jQuery.contains( elem.ownerDocument, elem );
\r
5465 if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
\r
5466 clone = elem.cloneNode( true );
\r
5468 // IE<=8 does not properly clone detached, unknown element nodes
\r
5470 fragmentDiv.innerHTML = elem.outerHTML;
\r
5471 fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
\r
5474 if ( (!support.noCloneEvent || !support.noCloneChecked) &&
\r
5475 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
\r
5477 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
\r
5478 destElements = getAll( clone );
\r
5479 srcElements = getAll( elem );
\r
5481 // Fix all IE cloning issues
\r
5482 for ( i = 0; (node = srcElements[i]) != null; ++i ) {
\r
5483 // Ensure that the destination node is not null; Fixes #9587
\r
5484 if ( destElements[i] ) {
\r
5485 fixCloneNodeIssues( node, destElements[i] );
\r
5490 // Copy the events from the original to the clone
\r
5491 if ( dataAndEvents ) {
\r
5492 if ( deepDataAndEvents ) {
\r
5493 srcElements = srcElements || getAll( elem );
\r
5494 destElements = destElements || getAll( clone );
\r
5496 for ( i = 0; (node = srcElements[i]) != null; i++ ) {
\r
5497 cloneCopyEvent( node, destElements[i] );
\r
5500 cloneCopyEvent( elem, clone );
\r
5504 // Preserve script evaluation history
\r
5505 destElements = getAll( clone, "script" );
\r
5506 if ( destElements.length > 0 ) {
\r
5507 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
\r
5510 destElements = srcElements = node = null;
\r
5512 // Return the cloned set
\r
5516 buildFragment: function( elems, context, scripts, selection ) {
\r
5517 var j, elem, contains,
\r
5518 tmp, tag, tbody, wrap,
\r
5521 // Ensure a safe fragment
\r
5522 safe = createSafeFragment( context ),
\r
5527 for ( ; i < l; i++ ) {
\r
5528 elem = elems[ i ];
\r
5530 if ( elem || elem === 0 ) {
\r
5532 // Add nodes directly
\r
5533 if ( jQuery.type( elem ) === "object" ) {
\r
5534 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
\r
5536 // Convert non-html into a text node
\r
5537 } else if ( !rhtml.test( elem ) ) {
\r
5538 nodes.push( context.createTextNode( elem ) );
\r
5540 // Convert html into DOM nodes
\r
5542 tmp = tmp || safe.appendChild( context.createElement("div") );
\r
5544 // Deserialize a standard representation
\r
5545 tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
\r
5546 wrap = wrapMap[ tag ] || wrapMap._default;
\r
5548 tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
\r
5550 // Descend through wrappers to the right content
\r
5553 tmp = tmp.lastChild;
\r
5556 // Manually add leading whitespace removed by IE
\r
5557 if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
\r
5558 nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
\r
5561 // Remove IE's autoinserted <tbody> from table fragments
\r
5562 if ( !support.tbody ) {
\r
5564 // String was a <table>, *may* have spurious <tbody>
\r
5565 elem = tag === "table" && !rtbody.test( elem ) ?
\r
5568 // String was a bare <thead> or <tfoot>
\r
5569 wrap[1] === "<table>" && !rtbody.test( elem ) ?
\r
5573 j = elem && elem.childNodes.length;
\r
5575 if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
\r
5576 elem.removeChild( tbody );
\r
5581 jQuery.merge( nodes, tmp.childNodes );
\r
5583 // Fix #12392 for WebKit and IE > 9
\r
5584 tmp.textContent = "";
\r
5586 // Fix #12392 for oldIE
\r
5587 while ( tmp.firstChild ) {
\r
5588 tmp.removeChild( tmp.firstChild );
\r
5591 // Remember the top-level container for proper cleanup
\r
5592 tmp = safe.lastChild;
\r
5597 // Fix #11356: Clear elements from fragment
\r
5599 safe.removeChild( tmp );
\r
5602 // Reset defaultChecked for any radios and checkboxes
\r
5603 // about to be appended to the DOM in IE 6/7 (#8060)
\r
5604 if ( !support.appendChecked ) {
\r
5605 jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
\r
5609 while ( (elem = nodes[ i++ ]) ) {
\r
5611 // #4087 - If origin and destination elements are the same, and this is
\r
5612 // that element, do not do anything
\r
5613 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
\r
5617 contains = jQuery.contains( elem.ownerDocument, elem );
\r
5619 // Append to fragment
\r
5620 tmp = getAll( safe.appendChild( elem ), "script" );
\r
5622 // Preserve script evaluation history
\r
5624 setGlobalEval( tmp );
\r
5627 // Capture executables
\r
5630 while ( (elem = tmp[ j++ ]) ) {
\r
5631 if ( rscriptType.test( elem.type || "" ) ) {
\r
5632 scripts.push( elem );
\r
5643 cleanData: function( elems, /* internal */ acceptData ) {
\r
5644 var elem, type, id, data,
\r
5646 internalKey = jQuery.expando,
\r
5647 cache = jQuery.cache,
\r
5648 deleteExpando = support.deleteExpando,
\r
5649 special = jQuery.event.special;
\r
5651 for ( ; (elem = elems[i]) != null; i++ ) {
\r
5652 if ( acceptData || jQuery.acceptData( elem ) ) {
\r
5654 id = elem[ internalKey ];
\r
5655 data = id && cache[ id ];
\r
5658 if ( data.events ) {
\r
5659 for ( type in data.events ) {
\r
5660 if ( special[ type ] ) {
\r
5661 jQuery.event.remove( elem, type );
\r
5663 // This is a shortcut to avoid jQuery.event.remove's overhead
\r
5665 jQuery.removeEvent( elem, type, data.handle );
\r
5670 // Remove cache only if it was not already removed by jQuery.event.remove
\r
5671 if ( cache[ id ] ) {
\r
5673 delete cache[ id ];
\r
5675 // IE does not allow us to delete expando properties from nodes,
\r
5676 // nor does it have a removeAttribute function on Document nodes;
\r
5677 // we must handle all of these cases
\r
5678 if ( deleteExpando ) {
\r
5679 delete elem[ internalKey ];
\r
5681 } else if ( typeof elem.removeAttribute !== strundefined ) {
\r
5682 elem.removeAttribute( internalKey );
\r
5685 elem[ internalKey ] = null;
\r
5688 deletedIds.push( id );
\r
5696 jQuery.fn.extend({
\r
5697 text: function( value ) {
\r
5698 return access( this, function( value ) {
\r
5699 return value === undefined ?
\r
5700 jQuery.text( this ) :
\r
5701 this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
\r
5702 }, null, value, arguments.length );
\r
5705 append: function() {
\r
5706 return this.domManip( arguments, function( elem ) {
\r
5707 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
\r
5708 var target = manipulationTarget( this, elem );
\r
5709 target.appendChild( elem );
\r
5714 prepend: function() {
\r
5715 return this.domManip( arguments, function( elem ) {
\r
5716 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
\r
5717 var target = manipulationTarget( this, elem );
\r
5718 target.insertBefore( elem, target.firstChild );
\r
5723 before: function() {
\r
5724 return this.domManip( arguments, function( elem ) {
\r
5725 if ( this.parentNode ) {
\r
5726 this.parentNode.insertBefore( elem, this );
\r
5731 after: function() {
\r
5732 return this.domManip( arguments, function( elem ) {
\r
5733 if ( this.parentNode ) {
\r
5734 this.parentNode.insertBefore( elem, this.nextSibling );
\r
5739 remove: function( selector, keepData /* Internal Use Only */ ) {
\r
5741 elems = selector ? jQuery.filter( selector, this ) : this,
\r
5744 for ( ; (elem = elems[i]) != null; i++ ) {
\r
5746 if ( !keepData && elem.nodeType === 1 ) {
\r
5747 jQuery.cleanData( getAll( elem ) );
\r
5750 if ( elem.parentNode ) {
\r
5751 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
\r
5752 setGlobalEval( getAll( elem, "script" ) );
\r
5754 elem.parentNode.removeChild( elem );
\r
5761 empty: function() {
\r
5765 for ( ; (elem = this[i]) != null; i++ ) {
\r
5766 // Remove element nodes and prevent memory leaks
\r
5767 if ( elem.nodeType === 1 ) {
\r
5768 jQuery.cleanData( getAll( elem, false ) );
\r
5771 // Remove any remaining nodes
\r
5772 while ( elem.firstChild ) {
\r
5773 elem.removeChild( elem.firstChild );
\r
5776 // If this is a select, ensure that it displays empty (#12336)
\r
5778 if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
\r
5779 elem.options.length = 0;
\r
5786 clone: function( dataAndEvents, deepDataAndEvents ) {
\r
5787 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
\r
5788 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
\r
5790 return this.map(function() {
\r
5791 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
\r
5795 html: function( value ) {
\r
5796 return access( this, function( value ) {
\r
5797 var elem = this[ 0 ] || {},
\r
5801 if ( value === undefined ) {
\r
5802 return elem.nodeType === 1 ?
\r
5803 elem.innerHTML.replace( rinlinejQuery, "" ) :
\r
5807 // See if we can take a shortcut and just use innerHTML
\r
5808 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
\r
5809 ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
\r
5810 ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
\r
5811 !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
\r
5813 value = value.replace( rxhtmlTag, "<$1></$2>" );
\r
5816 for (; i < l; i++ ) {
\r
5817 // Remove element nodes and prevent memory leaks
\r
5818 elem = this[i] || {};
\r
5819 if ( elem.nodeType === 1 ) {
\r
5820 jQuery.cleanData( getAll( elem, false ) );
\r
5821 elem.innerHTML = value;
\r
5827 // If using innerHTML throws an exception, use the fallback method
\r
5832 this.empty().append( value );
\r
5834 }, null, value, arguments.length );
\r
5837 replaceWith: function() {
\r
5838 var arg = arguments[ 0 ];
\r
5840 // Make the changes, replacing each context element with the new content
\r
5841 this.domManip( arguments, function( elem ) {
\r
5842 arg = this.parentNode;
\r
5844 jQuery.cleanData( getAll( this ) );
\r
5847 arg.replaceChild( elem, this );
\r
5851 // Force removal if there was no new content (e.g., from empty arguments)
\r
5852 return arg && (arg.length || arg.nodeType) ? this : this.remove();
\r
5855 detach: function( selector ) {
\r
5856 return this.remove( selector, true );
\r
5859 domManip: function( args, callback ) {
\r
5861 // Flatten any nested arrays
\r
5862 args = concat.apply( [], args );
\r
5864 var first, node, hasScripts,
\r
5865 scripts, doc, fragment,
\r
5871 isFunction = jQuery.isFunction( value );
\r
5873 // We can't cloneNode fragments that contain checked, in WebKit
\r
5874 if ( isFunction ||
\r
5875 ( l > 1 && typeof value === "string" &&
\r
5876 !support.checkClone && rchecked.test( value ) ) ) {
\r
5877 return this.each(function( index ) {
\r
5878 var self = set.eq( index );
\r
5879 if ( isFunction ) {
\r
5880 args[0] = value.call( this, index, self.html() );
\r
5882 self.domManip( args, callback );
\r
5887 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
\r
5888 first = fragment.firstChild;
\r
5890 if ( fragment.childNodes.length === 1 ) {
\r
5895 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
\r
5896 hasScripts = scripts.length;
\r
5898 // Use the original fragment for the last item instead of the first because it can end up
\r
5899 // being emptied incorrectly in certain situations (#8070).
\r
5900 for ( ; i < l; i++ ) {
\r
5903 if ( i !== iNoClone ) {
\r
5904 node = jQuery.clone( node, true, true );
\r
5906 // Keep references to cloned scripts for later restoration
\r
5907 if ( hasScripts ) {
\r
5908 jQuery.merge( scripts, getAll( node, "script" ) );
\r
5912 callback.call( this[i], node, i );
\r
5915 if ( hasScripts ) {
\r
5916 doc = scripts[ scripts.length - 1 ].ownerDocument;
\r
5918 // Reenable scripts
\r
5919 jQuery.map( scripts, restoreScript );
\r
5921 // Evaluate executable scripts on first document insertion
\r
5922 for ( i = 0; i < hasScripts; i++ ) {
\r
5923 node = scripts[ i ];
\r
5924 if ( rscriptType.test( node.type || "" ) &&
\r
5925 !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
\r
5928 // Optional AJAX dependency, but won't run scripts if not present
\r
5929 if ( jQuery._evalUrl ) {
\r
5930 jQuery._evalUrl( node.src );
\r
5933 jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
\r
5939 // Fix #11809: Avoid leaking memory
\r
5940 fragment = first = null;
\r
5949 appendTo: "append",
\r
5950 prependTo: "prepend",
\r
5951 insertBefore: "before",
\r
5952 insertAfter: "after",
\r
5953 replaceAll: "replaceWith"
\r
5954 }, function( name, original ) {
\r
5955 jQuery.fn[ name ] = function( selector ) {
\r
5959 insert = jQuery( selector ),
\r
5960 last = insert.length - 1;
\r
5962 for ( ; i <= last; i++ ) {
\r
5963 elems = i === last ? this : this.clone(true);
\r
5964 jQuery( insert[i] )[ original ]( elems );
\r
5966 // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
\r
5967 push.apply( ret, elems.get() );
\r
5970 return this.pushStack( ret );
\r
5979 * Retrieve the actual display of a element
\r
5980 * @param {String} name nodeName of the element
\r
5981 * @param {Object} doc Document object
\r
5983 // Called only from within defaultDisplay
\r
5984 function actualDisplay( name, doc ) {
\r
5985 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
\r
5987 // getDefaultComputedStyle might be reliably used only on attached element
\r
5988 display = window.getDefaultComputedStyle ?
\r
5990 // Use of this method is a temporary fix (more like optmization) until something better comes along,
\r
5991 // since it was removed from specification and supported only in FF
\r
5992 window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
\r
5994 // We don't have any data stored on the element,
\r
5995 // so use "detach" method as fast way to get rid of the element
\r
6002 * Try to determine the default display value of an element
\r
6003 * @param {String} nodeName
\r
6005 function defaultDisplay( nodeName ) {
\r
6006 var doc = document,
\r
6007 display = elemdisplay[ nodeName ];
\r
6010 display = actualDisplay( nodeName, doc );
\r
6012 // If the simple way fails, read from inside an iframe
\r
6013 if ( display === "none" || !display ) {
\r
6015 // Use the already-created iframe if possible
\r
6016 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
\r
6018 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
\r
6019 doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
\r
6025 display = actualDisplay( nodeName, doc );
\r
6029 // Store the correct default display
\r
6030 elemdisplay[ nodeName ] = display;
\r
6038 var a, shrinkWrapBlocksVal,
\r
6039 div = document.createElement( "div" ),
\r
6041 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
\r
6042 "display:block;padding:0;margin:0;border:0";
\r
6045 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
6046 a = div.getElementsByTagName( "a" )[ 0 ];
\r
6048 a.style.cssText = "float:left;opacity:.5";
\r
6050 // Make sure that element opacity exists
\r
6051 // (IE uses filter instead)
\r
6052 // Use a regex to work around a WebKit issue. See #5145
\r
6053 support.opacity = /^0.5/.test( a.style.opacity );
\r
6055 // Verify style float existence
\r
6056 // (IE uses styleFloat instead of cssFloat)
\r
6057 support.cssFloat = !!a.style.cssFloat;
\r
6059 div.style.backgroundClip = "content-box";
\r
6060 div.cloneNode( true ).style.backgroundClip = "";
\r
6061 support.clearCloneStyle = div.style.backgroundClip === "content-box";
\r
6063 // Null elements to avoid leaks in IE.
\r
6066 support.shrinkWrapBlocks = function() {
\r
6067 var body, container, div, containerStyles;
\r
6069 if ( shrinkWrapBlocksVal == null ) {
\r
6070 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6072 // Test fired too early or in an unsupported environment, exit.
\r
6076 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px";
\r
6077 container = document.createElement( "div" );
\r
6078 div = document.createElement( "div" );
\r
6080 body.appendChild( container ).appendChild( div );
\r
6082 // Will be changed later if needed.
\r
6083 shrinkWrapBlocksVal = false;
\r
6085 if ( typeof div.style.zoom !== strundefined ) {
\r
6087 // Check if elements with layout shrink-wrap their children
\r
6088 div.style.cssText = divReset + ";width:1px;padding:1px;zoom:1";
\r
6089 div.innerHTML = "<div></div>";
\r
6090 div.firstChild.style.width = "5px";
\r
6091 shrinkWrapBlocksVal = div.offsetWidth !== 3;
\r
6094 body.removeChild( container );
\r
6096 // Null elements to avoid leaks in IE.
\r
6097 body = container = div = null;
\r
6100 return shrinkWrapBlocksVal;
\r
6104 var rmargin = (/^margin/);
\r
6106 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
\r
6110 var getStyles, curCSS,
\r
6111 rposition = /^(top|right|bottom|left)$/;
\r
6113 if ( window.getComputedStyle ) {
\r
6114 getStyles = function( elem ) {
\r
6115 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
\r
6118 curCSS = function( elem, name, computed ) {
\r
6119 var width, minWidth, maxWidth, ret,
\r
6120 style = elem.style;
\r
6122 computed = computed || getStyles( elem );
\r
6124 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
\r
6125 ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
\r
6129 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
\r
6130 ret = jQuery.style( elem, name );
\r
6133 // A tribute to the "awesome hack by Dean Edwards"
\r
6134 // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
\r
6135 // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
\r
6136 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
\r
6137 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
\r
6139 // Remember the original values
\r
6140 width = style.width;
\r
6141 minWidth = style.minWidth;
\r
6142 maxWidth = style.maxWidth;
\r
6144 // Put in the new values to get a computed value out
\r
6145 style.minWidth = style.maxWidth = style.width = ret;
\r
6146 ret = computed.width;
\r
6148 // Revert the changed values
\r
6149 style.width = width;
\r
6150 style.minWidth = minWidth;
\r
6151 style.maxWidth = maxWidth;
\r
6156 // IE returns zIndex value as an integer.
\r
6157 return ret === undefined ?
\r
6161 } else if ( document.documentElement.currentStyle ) {
\r
6162 getStyles = function( elem ) {
\r
6163 return elem.currentStyle;
\r
6166 curCSS = function( elem, name, computed ) {
\r
6167 var left, rs, rsLeft, ret,
\r
6168 style = elem.style;
\r
6170 computed = computed || getStyles( elem );
\r
6171 ret = computed ? computed[ name ] : undefined;
\r
6173 // Avoid setting ret to empty string here
\r
6174 // so we don't default to auto
\r
6175 if ( ret == null && style && style[ name ] ) {
\r
6176 ret = style[ name ];
\r
6179 // From the awesome hack by Dean Edwards
\r
6180 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
\r
6182 // If we're not dealing with a regular pixel number
\r
6183 // but a number that has a weird ending, we need to convert it to pixels
\r
6184 // but not position css attributes, as those are proportional to the parent element instead
\r
6185 // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
\r
6186 if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
\r
6188 // Remember the original values
\r
6189 left = style.left;
\r
6190 rs = elem.runtimeStyle;
\r
6191 rsLeft = rs && rs.left;
\r
6193 // Put in the new values to get a computed value out
\r
6195 rs.left = elem.currentStyle.left;
\r
6197 style.left = name === "fontSize" ? "1em" : ret;
\r
6198 ret = style.pixelLeft + "px";
\r
6200 // Revert the changed values
\r
6201 style.left = left;
\r
6208 // IE returns zIndex value as an integer.
\r
6209 return ret === undefined ?
\r
6211 ret + "" || "auto";
\r
6218 function addGetHookIf( conditionFn, hookFn ) {
\r
6219 // Define the hook, we'll check on the first run if it's really needed.
\r
6222 var condition = conditionFn();
\r
6224 if ( condition == null ) {
\r
6225 // The test was not ready at this point; screw the hook this time
\r
6226 // but check again when needed next time.
\r
6230 if ( condition ) {
\r
6231 // Hook not needed (or it's not possible to use it due to missing dependency),
\r
6233 // Since there are no other hooks for marginRight, remove the whole object.
\r
6238 // Hook needed; redefine it so that the support test is not executed again.
\r
6240 return (this.get = hookFn).apply( this, arguments );
\r
6247 var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal,
\r
6248 pixelPositionVal, reliableMarginRightVal,
\r
6249 div = document.createElement( "div" ),
\r
6250 containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px",
\r
6252 "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
\r
6253 "display:block;padding:0;margin:0;border:0";
\r
6256 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
6257 a = div.getElementsByTagName( "a" )[ 0 ];
\r
6259 a.style.cssText = "float:left;opacity:.5";
\r
6261 // Make sure that element opacity exists
\r
6262 // (IE uses filter instead)
\r
6263 // Use a regex to work around a WebKit issue. See #5145
\r
6264 support.opacity = /^0.5/.test( a.style.opacity );
\r
6266 // Verify style float existence
\r
6267 // (IE uses styleFloat instead of cssFloat)
\r
6268 support.cssFloat = !!a.style.cssFloat;
\r
6270 div.style.backgroundClip = "content-box";
\r
6271 div.cloneNode( true ).style.backgroundClip = "";
\r
6272 support.clearCloneStyle = div.style.backgroundClip === "content-box";
\r
6274 // Null elements to avoid leaks in IE.
\r
6277 jQuery.extend(support, {
\r
6278 reliableHiddenOffsets: function() {
\r
6279 if ( reliableHiddenOffsetsVal != null ) {
\r
6280 return reliableHiddenOffsetsVal;
\r
6283 var container, tds, isSupported,
\r
6284 div = document.createElement( "div" ),
\r
6285 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6288 // Return for frameset docs that don't have a body
\r
6293 div.setAttribute( "className", "t" );
\r
6294 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
6296 container = document.createElement( "div" );
\r
6297 container.style.cssText = containerStyles;
\r
6299 body.appendChild( container ).appendChild( div );
\r
6302 // Check if table cells still have offsetWidth/Height when they are set
\r
6303 // to display:none and there are still other visible table cells in a
\r
6304 // table row; if so, offsetWidth/Height are not reliable for use when
\r
6305 // determining if an element has been hidden directly using
\r
6306 // display:none (it is still safe to use offsets if a parent element is
\r
6307 // hidden; don safety goggles and see bug #4512 for more information).
\r
6308 div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
\r
6309 tds = div.getElementsByTagName( "td" );
\r
6310 tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
\r
6311 isSupported = ( tds[ 0 ].offsetHeight === 0 );
\r
6313 tds[ 0 ].style.display = "";
\r
6314 tds[ 1 ].style.display = "none";
\r
6317 // Check if empty table cells still have offsetWidth/Height
\r
6318 reliableHiddenOffsetsVal = isSupported && ( tds[ 0 ].offsetHeight === 0 );
\r
6320 body.removeChild( container );
\r
6322 // Null elements to avoid leaks in IE.
\r
6323 div = body = null;
\r
6325 return reliableHiddenOffsetsVal;
\r
6328 boxSizing: function() {
\r
6329 if ( boxSizingVal == null ) {
\r
6330 computeStyleTests();
\r
6332 return boxSizingVal;
\r
6335 boxSizingReliable: function() {
\r
6336 if ( boxSizingReliableVal == null ) {
\r
6337 computeStyleTests();
\r
6339 return boxSizingReliableVal;
\r
6342 pixelPosition: function() {
\r
6343 if ( pixelPositionVal == null ) {
\r
6344 computeStyleTests();
\r
6346 return pixelPositionVal;
\r
6349 reliableMarginRight: function() {
\r
6350 var body, container, div, marginDiv;
\r
6352 // Use window.getComputedStyle because jsdom on node.js will break without it.
\r
6353 if ( reliableMarginRightVal == null && window.getComputedStyle ) {
\r
6354 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6356 // Test fired too early or in an unsupported environment, exit.
\r
6360 container = document.createElement( "div" );
\r
6361 div = document.createElement( "div" );
\r
6362 container.style.cssText = containerStyles;
\r
6364 body.appendChild( container ).appendChild( div );
\r
6366 // Check if div with explicit width and no margin-right incorrectly
\r
6367 // gets computed margin-right based on width of container. (#3333)
\r
6368 // Fails in WebKit before Feb 2011 nightlies
\r
6369 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
\r
6370 marginDiv = div.appendChild( document.createElement( "div" ) );
\r
6371 marginDiv.style.cssText = div.style.cssText = divReset;
\r
6372 marginDiv.style.marginRight = marginDiv.style.width = "0";
\r
6373 div.style.width = "1px";
\r
6375 reliableMarginRightVal =
\r
6376 !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
\r
6378 body.removeChild( container );
\r
6381 return reliableMarginRightVal;
\r
6385 function computeStyleTests() {
\r
6386 var container, div,
\r
6387 body = document.getElementsByTagName( "body" )[ 0 ];
\r
6390 // Test fired too early or in an unsupported environment, exit.
\r
6394 container = document.createElement( "div" );
\r
6395 div = document.createElement( "div" );
\r
6396 container.style.cssText = containerStyles;
\r
6398 body.appendChild( container ).appendChild( div );
\r
6400 div.style.cssText =
\r
6401 "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
\r
6402 "position:absolute;display:block;padding:1px;border:1px;width:4px;" +
\r
6403 "margin-top:1%;top:1%";
\r
6405 // Workaround failing boxSizing test due to offsetWidth returning wrong value
\r
6406 // with some non-1 values of body zoom, ticket #13543
\r
6407 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
\r
6408 boxSizingVal = div.offsetWidth === 4;
\r
6411 // Will be changed later if needed.
\r
6412 boxSizingReliableVal = true;
\r
6413 pixelPositionVal = false;
\r
6414 reliableMarginRightVal = true;
\r
6416 // Use window.getComputedStyle because jsdom on node.js will break without it.
\r
6417 if ( window.getComputedStyle ) {
\r
6418 pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
\r
6419 boxSizingReliableVal =
\r
6420 ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
\r
6423 body.removeChild( container );
\r
6425 // Null elements to avoid leaks in IE.
\r
6426 div = body = null;
\r
6432 // A method for quickly swapping in/out CSS properties to get correct calculations.
\r
6433 jQuery.swap = function( elem, options, callback, args ) {
\r
6437 // Remember the old values, and insert the new ones
\r
6438 for ( name in options ) {
\r
6439 old[ name ] = elem.style[ name ];
\r
6440 elem.style[ name ] = options[ name ];
\r
6443 ret = callback.apply( elem, args || [] );
\r
6445 // Revert the old values
\r
6446 for ( name in options ) {
\r
6447 elem.style[ name ] = old[ name ];
\r
6455 ralpha = /alpha\([^)]*\)/i,
\r
6456 ropacity = /opacity\s*=\s*([^)]*)/,
\r
6458 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
\r
6459 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
\r
6460 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
\r
6461 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
\r
6462 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
\r
6464 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
\r
6465 cssNormalTransform = {
\r
6470 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
\r
6473 // return a css property mapped to a potentially vendor prefixed property
\r
6474 function vendorPropName( style, name ) {
\r
6476 // shortcut for names that are not vendor prefixed
\r
6477 if ( name in style ) {
\r
6481 // check for vendor prefixed names
\r
6482 var capName = name.charAt(0).toUpperCase() + name.slice(1),
\r
6484 i = cssPrefixes.length;
\r
6487 name = cssPrefixes[ i ] + capName;
\r
6488 if ( name in style ) {
\r
6496 function showHide( elements, show ) {
\r
6497 var display, elem, hidden,
\r
6500 length = elements.length;
\r
6502 for ( ; index < length; index++ ) {
\r
6503 elem = elements[ index ];
\r
6504 if ( !elem.style ) {
\r
6508 values[ index ] = jQuery._data( elem, "olddisplay" );
\r
6509 display = elem.style.display;
\r
6511 // Reset the inline display of this element to learn if it is
\r
6512 // being hidden by cascaded rules or not
\r
6513 if ( !values[ index ] && display === "none" ) {
\r
6514 elem.style.display = "";
\r
6517 // Set elements which have been overridden with display: none
\r
6518 // in a stylesheet to whatever the default browser style is
\r
6519 // for such an element
\r
6520 if ( elem.style.display === "" && isHidden( elem ) ) {
\r
6521 values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
\r
6525 if ( !values[ index ] ) {
\r
6526 hidden = isHidden( elem );
\r
6528 if ( display && display !== "none" || !hidden ) {
\r
6529 jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
\r
6535 // Set the display of most of the elements in a second loop
\r
6536 // to avoid the constant reflow
\r
6537 for ( index = 0; index < length; index++ ) {
\r
6538 elem = elements[ index ];
\r
6539 if ( !elem.style ) {
\r
6542 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
\r
6543 elem.style.display = show ? values[ index ] || "" : "none";
\r
6550 function setPositiveNumber( elem, value, subtract ) {
\r
6551 var matches = rnumsplit.exec( value );
\r
6553 // Guard against undefined "subtract", e.g., when used as in cssHooks
\r
6554 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
\r
6558 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
\r
6559 var i = extra === ( isBorderBox ? "border" : "content" ) ?
\r
6560 // If we already have the right measurement, avoid augmentation
\r
6562 // Otherwise initialize for horizontal or vertical properties
\r
6563 name === "width" ? 1 : 0,
\r
6567 for ( ; i < 4; i += 2 ) {
\r
6568 // both box models exclude margin, so add it if we want it
\r
6569 if ( extra === "margin" ) {
\r
6570 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
\r
6573 if ( isBorderBox ) {
\r
6574 // border-box includes padding, so remove it if we want content
\r
6575 if ( extra === "content" ) {
\r
6576 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
\r
6579 // at this point, extra isn't border nor margin, so remove border
\r
6580 if ( extra !== "margin" ) {
\r
6581 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
\r
6584 // at this point, extra isn't content, so add padding
\r
6585 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
\r
6587 // at this point, extra isn't content nor padding, so add border
\r
6588 if ( extra !== "padding" ) {
\r
6589 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
\r
6597 function getWidthOrHeight( elem, name, extra ) {
\r
6599 // Start with offset property, which is equivalent to the border-box value
\r
6600 var valueIsBorderBox = true,
\r
6601 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
\r
6602 styles = getStyles( elem ),
\r
6603 isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
\r
6605 // some non-html elements return undefined for offsetWidth, so check for null/undefined
\r
6606 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
\r
6607 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
\r
6608 if ( val <= 0 || val == null ) {
\r
6609 // Fall back to computed then uncomputed css if necessary
\r
6610 val = curCSS( elem, name, styles );
\r
6611 if ( val < 0 || val == null ) {
\r
6612 val = elem.style[ name ];
\r
6615 // Computed unit is not pixels. Stop here and return.
\r
6616 if ( rnumnonpx.test(val) ) {
\r
6620 // we need the check for style in case a browser which returns unreliable values
\r
6621 // for getComputedStyle silently falls back to the reliable elem.style
\r
6622 valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
\r
6624 // Normalize "", auto, and prepare for extra
\r
6625 val = parseFloat( val ) || 0;
\r
6628 // use the active box-sizing model to add/subtract irrelevant styles
\r
6630 augmentWidthOrHeight(
\r
6633 extra || ( isBorderBox ? "border" : "content" ),
\r
6641 // Add in style property hooks for overriding the default
\r
6642 // behavior of getting and setting a style property
\r
6645 get: function( elem, computed ) {
\r
6647 // We should always get a number back from opacity
\r
6648 var ret = curCSS( elem, "opacity" );
\r
6649 return ret === "" ? "1" : ret;
\r
6655 // Don't automatically add "px" to these possibly-unitless properties
\r
6657 "columnCount": true,
\r
6658 "fillOpacity": true,
\r
6659 "fontWeight": true,
\r
6660 "lineHeight": true,
\r
6669 // Add in properties whose names you wish to fix before
\r
6670 // setting or getting the value
\r
6672 // normalize float css property
\r
6673 "float": support.cssFloat ? "cssFloat" : "styleFloat"
\r
6676 // Get and set the style property on a DOM Node
\r
6677 style: function( elem, name, value, extra ) {
\r
6678 // Don't set styles on text and comment nodes
\r
6679 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
\r
6683 // Make sure that we're working with the right name
\r
6684 var ret, type, hooks,
\r
6685 origName = jQuery.camelCase( name ),
\r
6686 style = elem.style;
\r
6688 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
\r
6690 // gets hook for the prefixed version
\r
6691 // followed by the unprefixed version
\r
6692 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
\r
6694 // Check if we're setting a value
\r
6695 if ( value !== undefined ) {
\r
6696 type = typeof value;
\r
6698 // convert relative number strings (+= or -=) to relative numbers. #7345
\r
6699 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
\r
6700 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
\r
6701 // Fixes bug #9237
\r
6705 // Make sure that null and NaN values aren't set. See: #7116
\r
6706 if ( value == null || value !== value ) {
\r
6710 // If a number was passed in, add 'px' to the (except for certain CSS properties)
\r
6711 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
\r
6715 // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
\r
6716 // but it would mean to define eight (for every problematic property) identical functions
\r
6717 if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
\r
6718 style[ name ] = "inherit";
\r
6721 // If a hook was provided, use that value, otherwise just set the specified value
\r
6722 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
\r
6725 // Swallow errors from 'invalid' CSS values (#5509)
\r
6727 // Support: Chrome, Safari
\r
6728 // Setting style to blank string required to delete "style: x !important;"
\r
6729 style[ name ] = "";
\r
6730 style[ name ] = value;
\r
6735 // If a hook was provided get the non-computed value from there
\r
6736 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
\r
6740 // Otherwise just get the value from the style object
\r
6741 return style[ name ];
\r
6745 css: function( elem, name, extra, styles ) {
\r
6746 var num, val, hooks,
\r
6747 origName = jQuery.camelCase( name );
\r
6749 // Make sure that we're working with the right name
\r
6750 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
\r
6752 // gets hook for the prefixed version
\r
6753 // followed by the unprefixed version
\r
6754 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
\r
6756 // If a hook was provided get the computed value from there
\r
6757 if ( hooks && "get" in hooks ) {
\r
6758 val = hooks.get( elem, true, extra );
\r
6761 // Otherwise, if a way to get the computed value exists, use that
\r
6762 if ( val === undefined ) {
\r
6763 val = curCSS( elem, name, styles );
\r
6766 //convert "normal" to computed value
\r
6767 if ( val === "normal" && name in cssNormalTransform ) {
\r
6768 val = cssNormalTransform[ name ];
\r
6771 // Return, converting to number if forced or a qualifier was provided and val looks numeric
\r
6772 if ( extra === "" || extra ) {
\r
6773 num = parseFloat( val );
\r
6774 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
\r
6780 jQuery.each([ "height", "width" ], function( i, name ) {
\r
6781 jQuery.cssHooks[ name ] = {
\r
6782 get: function( elem, computed, extra ) {
\r
6784 // certain elements can have dimension info if we invisibly show them
\r
6785 // however, it must have a current display style that would benefit from this
\r
6786 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
\r
6787 jQuery.swap( elem, cssShow, function() {
\r
6788 return getWidthOrHeight( elem, name, extra );
\r
6790 getWidthOrHeight( elem, name, extra );
\r
6794 set: function( elem, value, extra ) {
\r
6795 var styles = extra && getStyles( elem );
\r
6796 return setPositiveNumber( elem, value, extra ?
\r
6797 augmentWidthOrHeight(
\r
6801 support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
\r
6809 if ( !support.opacity ) {
\r
6810 jQuery.cssHooks.opacity = {
\r
6811 get: function( elem, computed ) {
\r
6812 // IE uses filters for opacity
\r
6813 return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
\r
6814 ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
\r
6815 computed ? "1" : "";
\r
6818 set: function( elem, value ) {
\r
6819 var style = elem.style,
\r
6820 currentStyle = elem.currentStyle,
\r
6821 opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
\r
6822 filter = currentStyle && currentStyle.filter || style.filter || "";
\r
6824 // IE has trouble with opacity if it does not have layout
\r
6825 // Force it by setting the zoom level
\r
6828 // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
\r
6829 // if value === "", then remove inline opacity #12685
\r
6830 if ( ( value >= 1 || value === "" ) &&
\r
6831 jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
\r
6832 style.removeAttribute ) {
\r
6834 // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
\r
6835 // if "filter:" is present at all, clearType is disabled, we want to avoid this
\r
6836 // style.removeAttribute is IE Only, but so apparently is this code path...
\r
6837 style.removeAttribute( "filter" );
\r
6839 // if there is no filter style applied in a css rule or unset inline opacity, we are done
\r
6840 if ( value === "" || currentStyle && !currentStyle.filter ) {
\r
6845 // otherwise, set new filter values
\r
6846 style.filter = ralpha.test( filter ) ?
\r
6847 filter.replace( ralpha, opacity ) :
\r
6848 filter + " " + opacity;
\r
6853 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
\r
6854 function( elem, computed ) {
\r
6856 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
\r
6857 // Work around by temporarily setting element display to inline-block
\r
6858 return jQuery.swap( elem, { "display": "inline-block" },
\r
6859 curCSS, [ elem, "marginRight" ] );
\r
6864 // These hooks are used by animate to expand properties
\r
6869 }, function( prefix, suffix ) {
\r
6870 jQuery.cssHooks[ prefix + suffix ] = {
\r
6871 expand: function( value ) {
\r
6875 // assumes a single number if not a string
\r
6876 parts = typeof value === "string" ? value.split(" ") : [ value ];
\r
6878 for ( ; i < 4; i++ ) {
\r
6879 expanded[ prefix + cssExpand[ i ] + suffix ] =
\r
6880 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
\r
6887 if ( !rmargin.test( prefix ) ) {
\r
6888 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
\r
6892 jQuery.fn.extend({
\r
6893 css: function( name, value ) {
\r
6894 return access( this, function( elem, name, value ) {
\r
6899 if ( jQuery.isArray( name ) ) {
\r
6900 styles = getStyles( elem );
\r
6901 len = name.length;
\r
6903 for ( ; i < len; i++ ) {
\r
6904 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
\r
6910 return value !== undefined ?
\r
6911 jQuery.style( elem, name, value ) :
\r
6912 jQuery.css( elem, name );
\r
6913 }, name, value, arguments.length > 1 );
\r
6915 show: function() {
\r
6916 return showHide( this, true );
\r
6918 hide: function() {
\r
6919 return showHide( this );
\r
6921 toggle: function( state ) {
\r
6922 if ( typeof state === "boolean" ) {
\r
6923 return state ? this.show() : this.hide();
\r
6926 return this.each(function() {
\r
6927 if ( isHidden( this ) ) {
\r
6928 jQuery( this ).show();
\r
6930 jQuery( this ).hide();
\r
6937 function Tween( elem, options, prop, end, easing ) {
\r
6938 return new Tween.prototype.init( elem, options, prop, end, easing );
\r
6940 jQuery.Tween = Tween;
\r
6942 Tween.prototype = {
\r
6943 constructor: Tween,
\r
6944 init: function( elem, options, prop, end, easing, unit ) {
\r
6947 this.easing = easing || "swing";
\r
6948 this.options = options;
\r
6949 this.start = this.now = this.cur();
\r
6951 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
\r
6954 var hooks = Tween.propHooks[ this.prop ];
\r
6956 return hooks && hooks.get ?
\r
6957 hooks.get( this ) :
\r
6958 Tween.propHooks._default.get( this );
\r
6960 run: function( percent ) {
\r
6962 hooks = Tween.propHooks[ this.prop ];
\r
6964 if ( this.options.duration ) {
\r
6965 this.pos = eased = jQuery.easing[ this.easing ](
\r
6966 percent, this.options.duration * percent, 0, 1, this.options.duration
\r
6969 this.pos = eased = percent;
\r
6971 this.now = ( this.end - this.start ) * eased + this.start;
\r
6973 if ( this.options.step ) {
\r
6974 this.options.step.call( this.elem, this.now, this );
\r
6977 if ( hooks && hooks.set ) {
\r
6978 hooks.set( this );
\r
6980 Tween.propHooks._default.set( this );
\r
6986 Tween.prototype.init.prototype = Tween.prototype;
\r
6988 Tween.propHooks = {
\r
6990 get: function( tween ) {
\r
6993 if ( tween.elem[ tween.prop ] != null &&
\r
6994 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
\r
6995 return tween.elem[ tween.prop ];
\r
6998 // passing an empty string as a 3rd parameter to .css will automatically
\r
6999 // attempt a parseFloat and fallback to a string if the parse fails
\r
7000 // so, simple values such as "10px" are parsed to Float.
\r
7001 // complex values such as "rotate(1rad)" are returned as is.
\r
7002 result = jQuery.css( tween.elem, tween.prop, "" );
\r
7003 // Empty strings, null, undefined and "auto" are converted to 0.
\r
7004 return !result || result === "auto" ? 0 : result;
\r
7006 set: function( tween ) {
\r
7007 // use step hook for back compat - use cssHook if its there - use .style if its
\r
7008 // available and use plain properties where available
\r
7009 if ( jQuery.fx.step[ tween.prop ] ) {
\r
7010 jQuery.fx.step[ tween.prop ]( tween );
\r
7011 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
\r
7012 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
\r
7014 tween.elem[ tween.prop ] = tween.now;
\r
7020 // Support: IE <=9
\r
7021 // Panic based approach to setting things on disconnected nodes
\r
7023 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
\r
7024 set: function( tween ) {
\r
7025 if ( tween.elem.nodeType && tween.elem.parentNode ) {
\r
7026 tween.elem[ tween.prop ] = tween.now;
\r
7032 linear: function( p ) {
\r
7035 swing: function( p ) {
\r
7036 return 0.5 - Math.cos( p * Math.PI ) / 2;
\r
7040 jQuery.fx = Tween.prototype.init;
\r
7042 // Back Compat <1.8 extension point
\r
7043 jQuery.fx.step = {};
\r
7050 rfxtypes = /^(?:toggle|show|hide)$/,
\r
7051 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
\r
7052 rrun = /queueHooks$/,
\r
7053 animationPrefilters = [ defaultPrefilter ],
\r
7055 "*": [ function( prop, value ) {
\r
7056 var tween = this.createTween( prop, value ),
\r
7057 target = tween.cur(),
\r
7058 parts = rfxnum.exec( value ),
\r
7059 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
\r
7061 // Starting value computation is required for potential unit mismatches
\r
7062 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
\r
7063 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
\r
7065 maxIterations = 20;
\r
7067 if ( start && start[ 3 ] !== unit ) {
\r
7068 // Trust units reported by jQuery.css
\r
7069 unit = unit || start[ 3 ];
\r
7071 // Make sure we update the tween properties later on
\r
7072 parts = parts || [];
\r
7074 // Iteratively approximate from a nonzero starting point
\r
7075 start = +target || 1;
\r
7078 // If previous iteration zeroed out, double until we get *something*
\r
7079 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
\r
7080 scale = scale || ".5";
\r
7082 // Adjust and apply
\r
7083 start = start / scale;
\r
7084 jQuery.style( tween.elem, prop, start + unit );
\r
7086 // Update scale, tolerating zero or NaN from tween.cur()
\r
7087 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
\r
7088 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
\r
7091 // Update tween properties
\r
7093 start = tween.start = +start || +target || 0;
\r
7094 tween.unit = unit;
\r
7095 // If a +=/-= token was provided, we're doing a relative animation
\r
7096 tween.end = parts[ 1 ] ?
\r
7097 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
\r
7105 // Animations created synchronously will run synchronously
\r
7106 function createFxNow() {
\r
7107 setTimeout(function() {
\r
7108 fxNow = undefined;
\r
7110 return ( fxNow = jQuery.now() );
\r
7113 // Generate parameters to create a standard animation
\r
7114 function genFx( type, includeWidth ) {
\r
7116 attrs = { height: type },
\r
7119 // if we include width, step value is 1 to do all cssExpand values,
\r
7120 // if we don't include width, step value is 2 to skip over Left and Right
\r
7121 includeWidth = includeWidth ? 1 : 0;
\r
7122 for ( ; i < 4 ; i += 2 - includeWidth ) {
\r
7123 which = cssExpand[ i ];
\r
7124 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
\r
7127 if ( includeWidth ) {
\r
7128 attrs.opacity = attrs.width = type;
\r
7134 function createTween( value, prop, animation ) {
\r
7136 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
\r
7138 length = collection.length;
\r
7139 for ( ; index < length; index++ ) {
\r
7140 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
\r
7142 // we're done with this property
\r
7148 function defaultPrefilter( elem, props, opts ) {
\r
7149 /* jshint validthis: true */
\r
7150 var prop, value, toggle, tween, hooks, oldfire, display, dDisplay,
\r
7153 style = elem.style,
\r
7154 hidden = elem.nodeType && isHidden( elem ),
\r
7155 dataShow = jQuery._data( elem, "fxshow" );
\r
7157 // handle queue: false promises
\r
7158 if ( !opts.queue ) {
\r
7159 hooks = jQuery._queueHooks( elem, "fx" );
\r
7160 if ( hooks.unqueued == null ) {
\r
7161 hooks.unqueued = 0;
\r
7162 oldfire = hooks.empty.fire;
\r
7163 hooks.empty.fire = function() {
\r
7164 if ( !hooks.unqueued ) {
\r
7171 anim.always(function() {
\r
7172 // doing this makes sure that the complete handler will be called
\r
7173 // before this completes
\r
7174 anim.always(function() {
\r
7176 if ( !jQuery.queue( elem, "fx" ).length ) {
\r
7177 hooks.empty.fire();
\r
7183 // height/width overflow pass
\r
7184 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
\r
7185 // Make sure that nothing sneaks out
\r
7186 // Record all 3 overflow attributes because IE does not
\r
7187 // change the overflow attribute when overflowX and
\r
7188 // overflowY are set to the same value
\r
7189 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
\r
7191 // Set display property to inline-block for height/width
\r
7192 // animations on inline elements that are having width/height animated
\r
7193 display = jQuery.css( elem, "display" );
\r
7194 dDisplay = defaultDisplay( elem.nodeName );
\r
7195 if ( display === "none" ) {
\r
7196 display = dDisplay;
\r
7198 if ( display === "inline" &&
\r
7199 jQuery.css( elem, "float" ) === "none" ) {
\r
7201 // inline-level elements accept inline-block;
\r
7202 // block-level elements need to be inline with layout
\r
7203 if ( !support.inlineBlockNeedsLayout || dDisplay === "inline" ) {
\r
7204 style.display = "inline-block";
\r
7211 if ( opts.overflow ) {
\r
7212 style.overflow = "hidden";
\r
7213 if ( !support.shrinkWrapBlocks() ) {
\r
7214 anim.always(function() {
\r
7215 style.overflow = opts.overflow[ 0 ];
\r
7216 style.overflowX = opts.overflow[ 1 ];
\r
7217 style.overflowY = opts.overflow[ 2 ];
\r
7223 for ( prop in props ) {
\r
7224 value = props[ prop ];
\r
7225 if ( rfxtypes.exec( value ) ) {
\r
7226 delete props[ prop ];
\r
7227 toggle = toggle || value === "toggle";
\r
7228 if ( value === ( hidden ? "hide" : "show" ) ) {
\r
7230 // 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
7231 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
\r
7237 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
\r
7241 if ( !jQuery.isEmptyObject( orig ) ) {
\r
7243 if ( "hidden" in dataShow ) {
\r
7244 hidden = dataShow.hidden;
\r
7247 dataShow = jQuery._data( elem, "fxshow", {} );
\r
7250 // store state if its toggle - enables .stop().toggle() to "reverse"
\r
7252 dataShow.hidden = !hidden;
\r
7255 jQuery( elem ).show();
\r
7257 anim.done(function() {
\r
7258 jQuery( elem ).hide();
\r
7261 anim.done(function() {
\r
7263 jQuery._removeData( elem, "fxshow" );
\r
7264 for ( prop in orig ) {
\r
7265 jQuery.style( elem, prop, orig[ prop ] );
\r
7268 for ( prop in orig ) {
\r
7269 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
\r
7271 if ( !( prop in dataShow ) ) {
\r
7272 dataShow[ prop ] = tween.start;
\r
7274 tween.end = tween.start;
\r
7275 tween.start = prop === "width" || prop === "height" ? 1 : 0;
\r
7282 function propFilter( props, specialEasing ) {
\r
7283 var index, name, easing, value, hooks;
\r
7285 // camelCase, specialEasing and expand cssHook pass
\r
7286 for ( index in props ) {
\r
7287 name = jQuery.camelCase( index );
\r
7288 easing = specialEasing[ name ];
\r
7289 value = props[ index ];
\r
7290 if ( jQuery.isArray( value ) ) {
\r
7291 easing = value[ 1 ];
\r
7292 value = props[ index ] = value[ 0 ];
\r
7295 if ( index !== name ) {
\r
7296 props[ name ] = value;
\r
7297 delete props[ index ];
\r
7300 hooks = jQuery.cssHooks[ name ];
\r
7301 if ( hooks && "expand" in hooks ) {
\r
7302 value = hooks.expand( value );
\r
7303 delete props[ name ];
\r
7305 // not quite $.extend, this wont overwrite keys already present.
\r
7306 // also - reusing 'index' from above because we have the correct "name"
\r
7307 for ( index in value ) {
\r
7308 if ( !( index in props ) ) {
\r
7309 props[ index ] = value[ index ];
\r
7310 specialEasing[ index ] = easing;
\r
7314 specialEasing[ name ] = easing;
\r
7319 function Animation( elem, properties, options ) {
\r
7323 length = animationPrefilters.length,
\r
7324 deferred = jQuery.Deferred().always( function() {
\r
7325 // don't match elem in the :animated selector
\r
7328 tick = function() {
\r
7332 var currentTime = fxNow || createFxNow(),
\r
7333 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
\r
7334 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
\r
7335 temp = remaining / animation.duration || 0,
\r
7336 percent = 1 - temp,
\r
7338 length = animation.tweens.length;
\r
7340 for ( ; index < length ; index++ ) {
\r
7341 animation.tweens[ index ].run( percent );
\r
7344 deferred.notifyWith( elem, [ animation, percent, remaining ]);
\r
7346 if ( percent < 1 && length ) {
\r
7349 deferred.resolveWith( elem, [ animation ] );
\r
7353 animation = deferred.promise({
\r
7355 props: jQuery.extend( {}, properties ),
\r
7356 opts: jQuery.extend( true, { specialEasing: {} }, options ),
\r
7357 originalProperties: properties,
\r
7358 originalOptions: options,
\r
7359 startTime: fxNow || createFxNow(),
\r
7360 duration: options.duration,
\r
7362 createTween: function( prop, end ) {
\r
7363 var tween = jQuery.Tween( elem, animation.opts, prop, end,
\r
7364 animation.opts.specialEasing[ prop ] || animation.opts.easing );
\r
7365 animation.tweens.push( tween );
\r
7368 stop: function( gotoEnd ) {
\r
7370 // if we are going to the end, we want to run all the tweens
\r
7371 // otherwise we skip this part
\r
7372 length = gotoEnd ? animation.tweens.length : 0;
\r
7377 for ( ; index < length ; index++ ) {
\r
7378 animation.tweens[ index ].run( 1 );
\r
7381 // resolve when we played the last frame
\r
7382 // otherwise, reject
\r
7384 deferred.resolveWith( elem, [ animation, gotoEnd ] );
\r
7386 deferred.rejectWith( elem, [ animation, gotoEnd ] );
\r
7391 props = animation.props;
\r
7393 propFilter( props, animation.opts.specialEasing );
\r
7395 for ( ; index < length ; index++ ) {
\r
7396 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
\r
7402 jQuery.map( props, createTween, animation );
\r
7404 if ( jQuery.isFunction( animation.opts.start ) ) {
\r
7405 animation.opts.start.call( elem, animation );
\r
7409 jQuery.extend( tick, {
\r
7412 queue: animation.opts.queue
\r
7416 // attach callbacks from options
\r
7417 return animation.progress( animation.opts.progress )
\r
7418 .done( animation.opts.done, animation.opts.complete )
\r
7419 .fail( animation.opts.fail )
\r
7420 .always( animation.opts.always );
\r
7423 jQuery.Animation = jQuery.extend( Animation, {
\r
7424 tweener: function( props, callback ) {
\r
7425 if ( jQuery.isFunction( props ) ) {
\r
7429 props = props.split(" ");
\r
7434 length = props.length;
\r
7436 for ( ; index < length ; index++ ) {
\r
7437 prop = props[ index ];
\r
7438 tweeners[ prop ] = tweeners[ prop ] || [];
\r
7439 tweeners[ prop ].unshift( callback );
\r
7443 prefilter: function( callback, prepend ) {
\r
7445 animationPrefilters.unshift( callback );
\r
7447 animationPrefilters.push( callback );
\r
7452 jQuery.speed = function( speed, easing, fn ) {
\r
7453 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
\r
7454 complete: fn || !fn && easing ||
\r
7455 jQuery.isFunction( speed ) && speed,
\r
7457 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
\r
7460 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
\r
7461 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
\r
7463 // normalize opt.queue - true/undefined/null -> "fx"
\r
7464 if ( opt.queue == null || opt.queue === true ) {
\r
7469 opt.old = opt.complete;
\r
7471 opt.complete = function() {
\r
7472 if ( jQuery.isFunction( opt.old ) ) {
\r
7473 opt.old.call( this );
\r
7476 if ( opt.queue ) {
\r
7477 jQuery.dequeue( this, opt.queue );
\r
7484 jQuery.fn.extend({
\r
7485 fadeTo: function( speed, to, easing, callback ) {
\r
7487 // show any hidden elements after setting opacity to 0
\r
7488 return this.filter( isHidden ).css( "opacity", 0 ).show()
\r
7490 // animate to the value specified
\r
7491 .end().animate({ opacity: to }, speed, easing, callback );
\r
7493 animate: function( prop, speed, easing, callback ) {
\r
7494 var empty = jQuery.isEmptyObject( prop ),
\r
7495 optall = jQuery.speed( speed, easing, callback ),
\r
7496 doAnimation = function() {
\r
7497 // Operate on a copy of prop so per-property easing won't be lost
\r
7498 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
\r
7500 // Empty animations, or finishing resolves immediately
\r
7501 if ( empty || jQuery._data( this, "finish" ) ) {
\r
7502 anim.stop( true );
\r
7505 doAnimation.finish = doAnimation;
\r
7507 return empty || optall.queue === false ?
\r
7508 this.each( doAnimation ) :
\r
7509 this.queue( optall.queue, doAnimation );
\r
7511 stop: function( type, clearQueue, gotoEnd ) {
\r
7512 var stopQueue = function( hooks ) {
\r
7513 var stop = hooks.stop;
\r
7514 delete hooks.stop;
\r
7518 if ( typeof type !== "string" ) {
\r
7519 gotoEnd = clearQueue;
\r
7520 clearQueue = type;
\r
7523 if ( clearQueue && type !== false ) {
\r
7524 this.queue( type || "fx", [] );
\r
7527 return this.each(function() {
\r
7528 var dequeue = true,
\r
7529 index = type != null && type + "queueHooks",
\r
7530 timers = jQuery.timers,
\r
7531 data = jQuery._data( this );
\r
7534 if ( data[ index ] && data[ index ].stop ) {
\r
7535 stopQueue( data[ index ] );
\r
7538 for ( index in data ) {
\r
7539 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
\r
7540 stopQueue( data[ index ] );
\r
7545 for ( index = timers.length; index--; ) {
\r
7546 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
\r
7547 timers[ index ].anim.stop( gotoEnd );
\r
7549 timers.splice( index, 1 );
\r
7553 // start the next in the queue if the last step wasn't forced
\r
7554 // timers currently will call their complete callbacks, which will dequeue
\r
7555 // but only if they were gotoEnd
\r
7556 if ( dequeue || !gotoEnd ) {
\r
7557 jQuery.dequeue( this, type );
\r
7561 finish: function( type ) {
\r
7562 if ( type !== false ) {
\r
7563 type = type || "fx";
\r
7565 return this.each(function() {
\r
7567 data = jQuery._data( this ),
\r
7568 queue = data[ type + "queue" ],
\r
7569 hooks = data[ type + "queueHooks" ],
\r
7570 timers = jQuery.timers,
\r
7571 length = queue ? queue.length : 0;
\r
7573 // enable finishing flag on private data
\r
7574 data.finish = true;
\r
7576 // empty the queue first
\r
7577 jQuery.queue( this, type, [] );
\r
7579 if ( hooks && hooks.stop ) {
\r
7580 hooks.stop.call( this, true );
\r
7583 // look for any active animations, and finish them
\r
7584 for ( index = timers.length; index--; ) {
\r
7585 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
\r
7586 timers[ index ].anim.stop( true );
\r
7587 timers.splice( index, 1 );
\r
7591 // look for any animations in the old queue and finish them
\r
7592 for ( index = 0; index < length; index++ ) {
\r
7593 if ( queue[ index ] && queue[ index ].finish ) {
\r
7594 queue[ index ].finish.call( this );
\r
7598 // turn off finishing flag
\r
7599 delete data.finish;
\r
7604 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
\r
7605 var cssFn = jQuery.fn[ name ];
\r
7606 jQuery.fn[ name ] = function( speed, easing, callback ) {
\r
7607 return speed == null || typeof speed === "boolean" ?
\r
7608 cssFn.apply( this, arguments ) :
\r
7609 this.animate( genFx( name, true ), speed, easing, callback );
\r
7613 // Generate shortcuts for custom animations
\r
7615 slideDown: genFx("show"),
\r
7616 slideUp: genFx("hide"),
\r
7617 slideToggle: genFx("toggle"),
\r
7618 fadeIn: { opacity: "show" },
\r
7619 fadeOut: { opacity: "hide" },
\r
7620 fadeToggle: { opacity: "toggle" }
\r
7621 }, function( name, props ) {
\r
7622 jQuery.fn[ name ] = function( speed, easing, callback ) {
\r
7623 return this.animate( props, speed, easing, callback );
\r
7627 jQuery.timers = [];
\r
7628 jQuery.fx.tick = function() {
\r
7630 timers = jQuery.timers,
\r
7633 fxNow = jQuery.now();
\r
7635 for ( ; i < timers.length; i++ ) {
\r
7636 timer = timers[ i ];
\r
7637 // Checks the timer has not already been removed
\r
7638 if ( !timer() && timers[ i ] === timer ) {
\r
7639 timers.splice( i--, 1 );
\r
7643 if ( !timers.length ) {
\r
7646 fxNow = undefined;
\r
7649 jQuery.fx.timer = function( timer ) {
\r
7650 jQuery.timers.push( timer );
\r
7652 jQuery.fx.start();
\r
7654 jQuery.timers.pop();
\r
7658 jQuery.fx.interval = 13;
\r
7660 jQuery.fx.start = function() {
\r
7662 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
\r
7666 jQuery.fx.stop = function() {
\r
7667 clearInterval( timerId );
\r
7671 jQuery.fx.speeds = {
\r
7679 // Based off of the plugin by Clint Helfers, with permission.
\r
7680 // http://blindsignals.com/index.php/2009/07/jquery-delay/
\r
7681 jQuery.fn.delay = function( time, type ) {
\r
7682 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
\r
7683 type = type || "fx";
\r
7685 return this.queue( type, function( next, hooks ) {
\r
7686 var timeout = setTimeout( next, time );
\r
7687 hooks.stop = function() {
\r
7688 clearTimeout( timeout );
\r
7695 var a, input, select, opt,
\r
7696 div = document.createElement("div" );
\r
7699 div.setAttribute( "className", "t" );
\r
7700 div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
\r
7701 a = div.getElementsByTagName("a")[ 0 ];
\r
7703 // First batch of tests.
\r
7704 select = document.createElement("select");
\r
7705 opt = select.appendChild( document.createElement("option") );
\r
7706 input = div.getElementsByTagName("input")[ 0 ];
\r
7708 a.style.cssText = "top:1px";
\r
7710 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
\r
7711 support.getSetAttribute = div.className !== "t";
\r
7713 // Get the style information from getAttribute
\r
7714 // (IE uses .cssText instead)
\r
7715 support.style = /top/.test( a.getAttribute("style") );
\r
7717 // Make sure that URLs aren't manipulated
\r
7718 // (IE normalizes it by default)
\r
7719 support.hrefNormalized = a.getAttribute("href") === "/a";
\r
7721 // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
\r
7722 support.checkOn = !!input.value;
\r
7724 // Make sure that a selected-by-default option has a working selected property.
\r
7725 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
\r
7726 support.optSelected = opt.selected;
\r
7728 // Tests for enctype support on a form (#6743)
\r
7729 support.enctype = !!document.createElement("form").enctype;
\r
7731 // Make sure that the options inside disabled selects aren't marked as disabled
\r
7732 // (WebKit marks them as disabled)
\r
7733 select.disabled = true;
\r
7734 support.optDisabled = !opt.disabled;
\r
7736 // Support: IE8 only
\r
7737 // Check if we can trust getAttribute("value")
\r
7738 input = document.createElement( "input" );
\r
7739 input.setAttribute( "value", "" );
\r
7740 support.input = input.getAttribute( "value" ) === "";
\r
7742 // Check if an input maintains its value after becoming a radio
\r
7743 input.value = "t";
\r
7744 input.setAttribute( "type", "radio" );
\r
7745 support.radioValue = input.value === "t";
\r
7747 // Null elements to avoid leaks in IE.
\r
7748 a = input = select = opt = div = null;
\r
7752 var rreturn = /\r/g;
\r
7754 jQuery.fn.extend({
\r
7755 val: function( value ) {
\r
7756 var hooks, ret, isFunction,
\r
7759 if ( !arguments.length ) {
\r
7761 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
\r
7763 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
\r
7769 return typeof ret === "string" ?
\r
7770 // handle most common string cases
\r
7771 ret.replace(rreturn, "") :
\r
7772 // handle cases where value is null/undef or number
\r
7773 ret == null ? "" : ret;
\r
7779 isFunction = jQuery.isFunction( value );
\r
7781 return this.each(function( i ) {
\r
7784 if ( this.nodeType !== 1 ) {
\r
7788 if ( isFunction ) {
\r
7789 val = value.call( this, i, jQuery( this ).val() );
\r
7794 // Treat null/undefined as ""; convert numbers to string
\r
7795 if ( val == null ) {
\r
7797 } else if ( typeof val === "number" ) {
\r
7799 } else if ( jQuery.isArray( val ) ) {
\r
7800 val = jQuery.map( val, function( value ) {
\r
7801 return value == null ? "" : value + "";
\r
7805 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
\r
7807 // If set returns undefined, fall back to normal setting
\r
7808 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
\r
7818 get: function( elem ) {
\r
7819 var val = jQuery.find.attr( elem, "value" );
\r
7820 return val != null ?
\r
7822 jQuery.text( elem );
\r
7826 get: function( elem ) {
\r
7827 var value, option,
\r
7828 options = elem.options,
\r
7829 index = elem.selectedIndex,
\r
7830 one = elem.type === "select-one" || index < 0,
\r
7831 values = one ? null : [],
\r
7832 max = one ? index + 1 : options.length,
\r
7837 // Loop through all the selected options
\r
7838 for ( ; i < max; i++ ) {
\r
7839 option = options[ i ];
\r
7841 // oldIE doesn't update selected after form reset (#2551)
\r
7842 if ( ( option.selected || i === index ) &&
\r
7843 // Don't return options that are disabled or in a disabled optgroup
\r
7844 ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
\r
7845 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
\r
7847 // Get the specific value for the option
\r
7848 value = jQuery( option ).val();
\r
7850 // We don't need an array for one selects
\r
7855 // Multi-Selects return an array
\r
7856 values.push( value );
\r
7863 set: function( elem, value ) {
\r
7864 var optionSet, option,
\r
7865 options = elem.options,
\r
7866 values = jQuery.makeArray( value ),
\r
7867 i = options.length;
\r
7870 option = options[ i ];
\r
7872 if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
\r
7875 // When new option element is added to select box we need to
\r
7876 // force reflow of newly added node in order to workaround delay
\r
7877 // of initialization properties
\r
7879 option.selected = optionSet = true;
\r
7883 // Will be executed only in IE6
\r
7884 option.scrollHeight;
\r
7888 option.selected = false;
\r
7892 // Force browsers to behave consistently when non-matching value is set
\r
7893 if ( !optionSet ) {
\r
7894 elem.selectedIndex = -1;
\r
7903 // Radios and checkboxes getter/setter
\r
7904 jQuery.each([ "radio", "checkbox" ], function() {
\r
7905 jQuery.valHooks[ this ] = {
\r
7906 set: function( elem, value ) {
\r
7907 if ( jQuery.isArray( value ) ) {
\r
7908 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
\r
7912 if ( !support.checkOn ) {
\r
7913 jQuery.valHooks[ this ].get = function( elem ) {
\r
7914 // Support: Webkit
\r
7915 // "" is returned instead of "on" if a value isn't specified
\r
7916 return elem.getAttribute("value") === null ? "on" : elem.value;
\r
7924 var nodeHook, boolHook,
\r
7925 attrHandle = jQuery.expr.attrHandle,
\r
7926 ruseDefault = /^(?:checked|selected)$/i,
\r
7927 getSetAttribute = support.getSetAttribute,
\r
7928 getSetInput = support.input;
\r
7930 jQuery.fn.extend({
\r
7931 attr: function( name, value ) {
\r
7932 return access( this, jQuery.attr, name, value, arguments.length > 1 );
\r
7935 removeAttr: function( name ) {
\r
7936 return this.each(function() {
\r
7937 jQuery.removeAttr( this, name );
\r
7943 attr: function( elem, name, value ) {
\r
7945 nType = elem.nodeType;
\r
7947 // don't get/set attributes on text, comment and attribute nodes
\r
7948 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
\r
7952 // Fallback to prop when attributes are not supported
\r
7953 if ( typeof elem.getAttribute === strundefined ) {
\r
7954 return jQuery.prop( elem, name, value );
\r
7957 // All attributes are lowercase
\r
7958 // Grab necessary hook if one is defined
\r
7959 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
\r
7960 name = name.toLowerCase();
\r
7961 hooks = jQuery.attrHooks[ name ] ||
\r
7962 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
\r
7965 if ( value !== undefined ) {
\r
7967 if ( value === null ) {
\r
7968 jQuery.removeAttr( elem, name );
\r
7970 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
\r
7974 elem.setAttribute( name, value + "" );
\r
7978 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
\r
7982 ret = jQuery.find.attr( elem, name );
\r
7984 // Non-existent attributes return null, we normalize to undefined
\r
7985 return ret == null ?
\r
7991 removeAttr: function( elem, value ) {
\r
7992 var name, propName,
\r
7994 attrNames = value && value.match( rnotwhite );
\r
7996 if ( attrNames && elem.nodeType === 1 ) {
\r
7997 while ( (name = attrNames[i++]) ) {
\r
7998 propName = jQuery.propFix[ name ] || name;
\r
8000 // Boolean attributes get special treatment (#10870)
\r
8001 if ( jQuery.expr.match.bool.test( name ) ) {
\r
8002 // Set corresponding property to false
\r
8003 if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
\r
8004 elem[ propName ] = false;
\r
8006 // Also clear defaultChecked/defaultSelected (if appropriate)
\r
8008 elem[ jQuery.camelCase( "default-" + name ) ] =
\r
8009 elem[ propName ] = false;
\r
8012 // See #9699 for explanation of this approach (setting first, then removal)
\r
8014 jQuery.attr( elem, name, "" );
\r
8017 elem.removeAttribute( getSetAttribute ? name : propName );
\r
8024 set: function( elem, value ) {
\r
8025 if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
\r
8026 // Setting the type on a radio button after the value resets the value in IE6-9
\r
8027 // Reset value to default in case type is set after value during creation
\r
8028 var val = elem.value;
\r
8029 elem.setAttribute( "type", value );
\r
8040 // Hook for boolean attributes
\r
8042 set: function( elem, value, name ) {
\r
8043 if ( value === false ) {
\r
8044 // Remove boolean attributes when set to false
\r
8045 jQuery.removeAttr( elem, name );
\r
8046 } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
\r
8047 // IE<8 needs the *property* name
\r
8048 elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
\r
8050 // Use defaultChecked and defaultSelected for oldIE
\r
8052 elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
\r
8059 // Retrieve booleans specially
\r
8060 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
\r
8062 var getter = attrHandle[ name ] || jQuery.find.attr;
\r
8064 attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
\r
8065 function( elem, name, isXML ) {
\r
8068 // Avoid an infinite loop by temporarily removing this function from the getter
\r
8069 handle = attrHandle[ name ];
\r
8070 attrHandle[ name ] = ret;
\r
8071 ret = getter( elem, name, isXML ) != null ?
\r
8072 name.toLowerCase() :
\r
8074 attrHandle[ name ] = handle;
\r
8078 function( elem, name, isXML ) {
\r
8080 return elem[ jQuery.camelCase( "default-" + name ) ] ?
\r
8081 name.toLowerCase() :
\r
8087 // fix oldIE attroperties
\r
8088 if ( !getSetInput || !getSetAttribute ) {
\r
8089 jQuery.attrHooks.value = {
\r
8090 set: function( elem, value, name ) {
\r
8091 if ( jQuery.nodeName( elem, "input" ) ) {
\r
8092 // Does not return so that setAttribute is also used
\r
8093 elem.defaultValue = value;
\r
8095 // Use nodeHook if defined (#1954); otherwise setAttribute is fine
\r
8096 return nodeHook && nodeHook.set( elem, value, name );
\r
8102 // IE6/7 do not support getting/setting some attributes with get/setAttribute
\r
8103 if ( !getSetAttribute ) {
\r
8105 // Use this for any attribute in IE6/7
\r
8106 // This fixes almost every IE6/7 issue
\r
8108 set: function( elem, value, name ) {
\r
8109 // Set the existing or create a new attribute node
\r
8110 var ret = elem.getAttributeNode( name );
\r
8112 elem.setAttributeNode(
\r
8113 (ret = elem.ownerDocument.createAttribute( name ))
\r
8117 ret.value = value += "";
\r
8119 // Break association with cloned elements by also using setAttribute (#9646)
\r
8120 if ( name === "value" || value === elem.getAttribute( name ) ) {
\r
8126 // Some attributes are constructed with empty-string values when not defined
\r
8127 attrHandle.id = attrHandle.name = attrHandle.coords =
\r
8128 function( elem, name, isXML ) {
\r
8131 return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
\r
8137 // Fixing value retrieval on a button requires this module
\r
8138 jQuery.valHooks.button = {
\r
8139 get: function( elem, name ) {
\r
8140 var ret = elem.getAttributeNode( name );
\r
8141 if ( ret && ret.specified ) {
\r
8148 // Set contenteditable to false on removals(#10429)
\r
8149 // Setting to empty string throws an error as an invalid value
\r
8150 jQuery.attrHooks.contenteditable = {
\r
8151 set: function( elem, value, name ) {
\r
8152 nodeHook.set( elem, value === "" ? false : value, name );
\r
8156 // Set width and height to auto instead of 0 on empty string( Bug #8150 )
\r
8157 // This is for removals
\r
8158 jQuery.each([ "width", "height" ], function( i, name ) {
\r
8159 jQuery.attrHooks[ name ] = {
\r
8160 set: function( elem, value ) {
\r
8161 if ( value === "" ) {
\r
8162 elem.setAttribute( name, "auto" );
\r
8170 if ( !support.style ) {
\r
8171 jQuery.attrHooks.style = {
\r
8172 get: function( elem ) {
\r
8173 // Return undefined in the case of empty string
\r
8174 // Note: IE uppercases css property names, but if we were to .toLowerCase()
\r
8175 // .cssText, that would destroy case senstitivity in URL's, like in "background"
\r
8176 return elem.style.cssText || undefined;
\r
8178 set: function( elem, value ) {
\r
8179 return ( elem.style.cssText = value + "" );
\r
8187 var rfocusable = /^(?:input|select|textarea|button|object)$/i,
\r
8188 rclickable = /^(?:a|area)$/i;
\r
8190 jQuery.fn.extend({
\r
8191 prop: function( name, value ) {
\r
8192 return access( this, jQuery.prop, name, value, arguments.length > 1 );
\r
8195 removeProp: function( name ) {
\r
8196 name = jQuery.propFix[ name ] || name;
\r
8197 return this.each(function() {
\r
8198 // try/catch handles cases where IE balks (such as removing a property on window)
\r
8200 this[ name ] = undefined;
\r
8201 delete this[ name ];
\r
8210 "class": "className"
\r
8213 prop: function( elem, name, value ) {
\r
8214 var ret, hooks, notxml,
\r
8215 nType = elem.nodeType;
\r
8217 // don't get/set properties on text, comment and attribute nodes
\r
8218 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
\r
8222 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
\r
8225 // Fix name and attach hooks
\r
8226 name = jQuery.propFix[ name ] || name;
\r
8227 hooks = jQuery.propHooks[ name ];
\r
8230 if ( value !== undefined ) {
\r
8231 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
\r
8233 ( elem[ name ] = value );
\r
8236 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
\r
8244 get: function( elem ) {
\r
8245 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
\r
8246 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
\r
8247 // Use proper attribute retrieval(#12072)
\r
8248 var tabindex = jQuery.find.attr( elem, "tabindex" );
\r
8251 parseInt( tabindex, 10 ) :
\r
8252 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
\r
8260 // Some attributes require a special call on IE
\r
8261 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
\r
8262 if ( !support.hrefNormalized ) {
\r
8263 // href/src property should get the full normalized URL (#10299/#12915)
\r
8264 jQuery.each([ "href", "src" ], function( i, name ) {
\r
8265 jQuery.propHooks[ name ] = {
\r
8266 get: function( elem ) {
\r
8267 return elem.getAttribute( name, 4 );
\r
8273 // Support: Safari, IE9+
\r
8274 // mis-reports the default selected property of an option
\r
8275 // Accessing the parent's selectedIndex property fixes it
\r
8276 if ( !support.optSelected ) {
\r
8277 jQuery.propHooks.selected = {
\r
8278 get: function( elem ) {
\r
8279 var parent = elem.parentNode;
\r
8282 parent.selectedIndex;
\r
8284 // Make sure that it also works with optgroups, see #5701
\r
8285 if ( parent.parentNode ) {
\r
8286 parent.parentNode.selectedIndex;
\r
8306 jQuery.propFix[ this.toLowerCase() ] = this;
\r
8309 // IE6/7 call enctype encoding
\r
8310 if ( !support.enctype ) {
\r
8311 jQuery.propFix.enctype = "encoding";
\r
8317 var rclass = /[\t\r\n\f]/g;
\r
8319 jQuery.fn.extend({
\r
8320 addClass: function( value ) {
\r
8321 var classes, elem, cur, clazz, j, finalValue,
\r
8323 len = this.length,
\r
8324 proceed = typeof value === "string" && value;
\r
8326 if ( jQuery.isFunction( value ) ) {
\r
8327 return this.each(function( j ) {
\r
8328 jQuery( this ).addClass( value.call( this, j, this.className ) );
\r
8333 // The disjunction here is for better compressibility (see removeClass)
\r
8334 classes = ( value || "" ).match( rnotwhite ) || [];
\r
8336 for ( ; i < len; i++ ) {
\r
8338 cur = elem.nodeType === 1 && ( elem.className ?
\r
8339 ( " " + elem.className + " " ).replace( rclass, " " ) :
\r
8345 while ( (clazz = classes[j++]) ) {
\r
8346 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
\r
8347 cur += clazz + " ";
\r
8351 // only assign if different to avoid unneeded rendering.
\r
8352 finalValue = jQuery.trim( cur );
\r
8353 if ( elem.className !== finalValue ) {
\r
8354 elem.className = finalValue;
\r
8363 removeClass: function( value ) {
\r
8364 var classes, elem, cur, clazz, j, finalValue,
\r
8366 len = this.length,
\r
8367 proceed = arguments.length === 0 || typeof value === "string" && value;
\r
8369 if ( jQuery.isFunction( value ) ) {
\r
8370 return this.each(function( j ) {
\r
8371 jQuery( this ).removeClass( value.call( this, j, this.className ) );
\r
8375 classes = ( value || "" ).match( rnotwhite ) || [];
\r
8377 for ( ; i < len; i++ ) {
\r
8379 // This expression is here for better compressibility (see addClass)
\r
8380 cur = elem.nodeType === 1 && ( elem.className ?
\r
8381 ( " " + elem.className + " " ).replace( rclass, " " ) :
\r
8387 while ( (clazz = classes[j++]) ) {
\r
8388 // Remove *all* instances
\r
8389 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
\r
8390 cur = cur.replace( " " + clazz + " ", " " );
\r
8394 // only assign if different to avoid unneeded rendering.
\r
8395 finalValue = value ? jQuery.trim( cur ) : "";
\r
8396 if ( elem.className !== finalValue ) {
\r
8397 elem.className = finalValue;
\r
8406 toggleClass: function( value, stateVal ) {
\r
8407 var type = typeof value;
\r
8409 if ( typeof stateVal === "boolean" && type === "string" ) {
\r
8410 return stateVal ? this.addClass( value ) : this.removeClass( value );
\r
8413 if ( jQuery.isFunction( value ) ) {
\r
8414 return this.each(function( i ) {
\r
8415 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
\r
8419 return this.each(function() {
\r
8420 if ( type === "string" ) {
\r
8421 // toggle individual class names
\r
8424 self = jQuery( this ),
\r
8425 classNames = value.match( rnotwhite ) || [];
\r
8427 while ( (className = classNames[ i++ ]) ) {
\r
8428 // check each className given, space separated list
\r
8429 if ( self.hasClass( className ) ) {
\r
8430 self.removeClass( className );
\r
8432 self.addClass( className );
\r
8436 // Toggle whole class name
\r
8437 } else if ( type === strundefined || type === "boolean" ) {
\r
8438 if ( this.className ) {
\r
8439 // store className if set
\r
8440 jQuery._data( this, "__className__", this.className );
\r
8443 // If the element has a class name or if we're passed "false",
\r
8444 // then remove the whole classname (if there was one, the above saved it).
\r
8445 // Otherwise bring back whatever was previously saved (if anything),
\r
8446 // falling back to the empty string if nothing was stored.
\r
8447 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
\r
8452 hasClass: function( selector ) {
\r
8453 var className = " " + selector + " ",
\r
8456 for ( ; i < l; i++ ) {
\r
8457 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
\r
8469 // Return jQuery for attributes-only inclusion
\r
8472 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
\r
8473 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
\r
8474 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
\r
8476 // Handle event binding
\r
8477 jQuery.fn[ name ] = function( data, fn ) {
\r
8478 return arguments.length > 0 ?
\r
8479 this.on( name, null, data, fn ) :
\r
8480 this.trigger( name );
\r
8484 jQuery.fn.extend({
\r
8485 hover: function( fnOver, fnOut ) {
\r
8486 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
\r
8489 bind: function( types, data, fn ) {
\r
8490 return this.on( types, null, data, fn );
\r
8492 unbind: function( types, fn ) {
\r
8493 return this.off( types, null, fn );
\r
8496 delegate: function( selector, types, data, fn ) {
\r
8497 return this.on( types, selector, data, fn );
\r
8499 undelegate: function( selector, types, fn ) {
\r
8500 // ( namespace ) or ( selector, types [, fn] )
\r
8501 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
\r
8506 var nonce = jQuery.now();
\r
8508 var rquery = (/\?/);
\r
8512 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
\r
8514 jQuery.parseJSON = function( data ) {
\r
8515 // Attempt to parse using the native JSON parser first
\r
8516 if ( window.JSON && window.JSON.parse ) {
\r
8517 // Support: Android 2.3
\r
8518 // Workaround failure to string-cast null input
\r
8519 return window.JSON.parse( data + "" );
\r
8522 var requireNonComma,
\r
8524 str = jQuery.trim( data + "" );
\r
8526 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
\r
8527 // after removing valid tokens
\r
8528 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
\r
8530 // Force termination if we see a misplaced comma
\r
8531 if ( requireNonComma && comma ) {
\r
8535 // Perform no more replacements after returning to outermost depth
\r
8536 if ( depth === 0 ) {
\r
8540 // Commas must not follow "[", "{", or ","
\r
8541 requireNonComma = open || comma;
\r
8543 // Determine new depth
\r
8544 // array/object open ("[" or "{"): depth += true - false (increment)
\r
8545 // array/object close ("]" or "}"): depth += false - true (decrement)
\r
8546 // other cases ("," or primitive): depth += true - true (numeric cast)
\r
8547 depth += !close - !open;
\r
8549 // Remove this token
\r
8552 ( Function( "return " + str ) )() :
\r
8553 jQuery.error( "Invalid JSON: " + data );
\r
8557 // Cross-browser xml parsing
\r
8558 jQuery.parseXML = function( data ) {
\r
8560 if ( !data || typeof data !== "string" ) {
\r
8564 if ( window.DOMParser ) { // Standard
\r
8565 tmp = new DOMParser();
\r
8566 xml = tmp.parseFromString( data, "text/xml" );
\r
8568 xml = new ActiveXObject( "Microsoft.XMLDOM" );
\r
8569 xml.async = "false";
\r
8570 xml.loadXML( data );
\r
8575 if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
\r
8576 jQuery.error( "Invalid XML: " + data );
\r
8583 // Document location
\r
8588 rts = /([?&])_=[^&]*/,
\r
8589 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
\r
8590 // #7653, #8125, #8152: local protocol detection
\r
8591 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
\r
8592 rnoContent = /^(?:GET|HEAD)$/,
\r
8593 rprotocol = /^\/\//,
\r
8594 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
\r
8597 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
\r
8598 * 2) These are called:
\r
8599 * - BEFORE asking for a transport
\r
8600 * - AFTER param serialization (s.data is a string if s.processData is true)
\r
8601 * 3) key is the dataType
\r
8602 * 4) the catchall symbol "*" can be used
\r
8603 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
\r
8607 /* Transports bindings
\r
8608 * 1) key is the dataType
\r
8609 * 2) the catchall symbol "*" can be used
\r
8610 * 3) selection will start with transport dataType and THEN go to "*" if needed
\r
8614 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
\r
8615 allTypes = "*/".concat("*");
\r
8617 // #8138, IE may throw an exception when accessing
\r
8618 // a field from window.location if document.domain has been set
\r
8620 ajaxLocation = location.href;
\r
8622 // Use the href attribute of an A element
\r
8623 // since IE will modify it given document.location
\r
8624 ajaxLocation = document.createElement( "a" );
\r
8625 ajaxLocation.href = "";
\r
8626 ajaxLocation = ajaxLocation.href;
\r
8629 // Segment location into parts
\r
8630 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
\r
8632 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
\r
8633 function addToPrefiltersOrTransports( structure ) {
\r
8635 // dataTypeExpression is optional and defaults to "*"
\r
8636 return function( dataTypeExpression, func ) {
\r
8638 if ( typeof dataTypeExpression !== "string" ) {
\r
8639 func = dataTypeExpression;
\r
8640 dataTypeExpression = "*";
\r
8645 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
\r
8647 if ( jQuery.isFunction( func ) ) {
\r
8648 // For each dataType in the dataTypeExpression
\r
8649 while ( (dataType = dataTypes[i++]) ) {
\r
8650 // Prepend if requested
\r
8651 if ( dataType.charAt( 0 ) === "+" ) {
\r
8652 dataType = dataType.slice( 1 ) || "*";
\r
8653 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
\r
8655 // Otherwise append
\r
8657 (structure[ dataType ] = structure[ dataType ] || []).push( func );
\r
8664 // Base inspection function for prefilters and transports
\r
8665 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
\r
8667 var inspected = {},
\r
8668 seekingTransport = ( structure === transports );
\r
8670 function inspect( dataType ) {
\r
8672 inspected[ dataType ] = true;
\r
8673 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
\r
8674 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
\r
8675 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
\r
8676 options.dataTypes.unshift( dataTypeOrTransport );
\r
8677 inspect( dataTypeOrTransport );
\r
8679 } else if ( seekingTransport ) {
\r
8680 return !( selected = dataTypeOrTransport );
\r
8686 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
\r
8689 // A special extend for ajax options
\r
8690 // that takes "flat" options (not to be deep extended)
\r
8692 function ajaxExtend( target, src ) {
\r
8694 flatOptions = jQuery.ajaxSettings.flatOptions || {};
\r
8696 for ( key in src ) {
\r
8697 if ( src[ key ] !== undefined ) {
\r
8698 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
\r
8702 jQuery.extend( true, target, deep );
\r
8708 /* Handles responses to an ajax request:
\r
8709 * - finds the right dataType (mediates between content-type and expected dataType)
\r
8710 * - returns the corresponding response
\r
8712 function ajaxHandleResponses( s, jqXHR, responses ) {
\r
8713 var firstDataType, ct, finalDataType, type,
\r
8714 contents = s.contents,
\r
8715 dataTypes = s.dataTypes;
\r
8717 // Remove auto dataType and get content-type in the process
\r
8718 while ( dataTypes[ 0 ] === "*" ) {
\r
8719 dataTypes.shift();
\r
8720 if ( ct === undefined ) {
\r
8721 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
\r
8725 // Check if we're dealing with a known content-type
\r
8727 for ( type in contents ) {
\r
8728 if ( contents[ type ] && contents[ type ].test( ct ) ) {
\r
8729 dataTypes.unshift( type );
\r
8735 // Check to see if we have a response for the expected dataType
\r
8736 if ( dataTypes[ 0 ] in responses ) {
\r
8737 finalDataType = dataTypes[ 0 ];
\r
8739 // Try convertible dataTypes
\r
8740 for ( type in responses ) {
\r
8741 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
\r
8742 finalDataType = type;
\r
8745 if ( !firstDataType ) {
\r
8746 firstDataType = type;
\r
8749 // Or just use first one
\r
8750 finalDataType = finalDataType || firstDataType;
\r
8753 // If we found a dataType
\r
8754 // We add the dataType to the list if needed
\r
8755 // and return the corresponding response
\r
8756 if ( finalDataType ) {
\r
8757 if ( finalDataType !== dataTypes[ 0 ] ) {
\r
8758 dataTypes.unshift( finalDataType );
\r
8760 return responses[ finalDataType ];
\r
8764 /* Chain conversions given the request and the original response
\r
8765 * Also sets the responseXXX fields on the jqXHR instance
\r
8767 function ajaxConvert( s, response, jqXHR, isSuccess ) {
\r
8768 var conv2, current, conv, tmp, prev,
\r
8770 // Work with a copy of dataTypes in case we need to modify it for conversion
\r
8771 dataTypes = s.dataTypes.slice();
\r
8773 // Create converters map with lowercased keys
\r
8774 if ( dataTypes[ 1 ] ) {
\r
8775 for ( conv in s.converters ) {
\r
8776 converters[ conv.toLowerCase() ] = s.converters[ conv ];
\r
8780 current = dataTypes.shift();
\r
8782 // Convert to each sequential dataType
\r
8783 while ( current ) {
\r
8785 if ( s.responseFields[ current ] ) {
\r
8786 jqXHR[ s.responseFields[ current ] ] = response;
\r
8789 // Apply the dataFilter if provided
\r
8790 if ( !prev && isSuccess && s.dataFilter ) {
\r
8791 response = s.dataFilter( response, s.dataType );
\r
8795 current = dataTypes.shift();
\r
8799 // There's only work to do if current dataType is non-auto
\r
8800 if ( current === "*" ) {
\r
8804 // Convert response if prev dataType is non-auto and differs from current
\r
8805 } else if ( prev !== "*" && prev !== current ) {
\r
8807 // Seek a direct converter
\r
8808 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
\r
8810 // If none found, seek a pair
\r
8812 for ( conv2 in converters ) {
\r
8814 // If conv2 outputs current
\r
8815 tmp = conv2.split( " " );
\r
8816 if ( tmp[ 1 ] === current ) {
\r
8818 // If prev can be converted to accepted input
\r
8819 conv = converters[ prev + " " + tmp[ 0 ] ] ||
\r
8820 converters[ "* " + tmp[ 0 ] ];
\r
8822 // Condense equivalence converters
\r
8823 if ( conv === true ) {
\r
8824 conv = converters[ conv2 ];
\r
8826 // Otherwise, insert the intermediate dataType
\r
8827 } else if ( converters[ conv2 ] !== true ) {
\r
8828 current = tmp[ 0 ];
\r
8829 dataTypes.unshift( tmp[ 1 ] );
\r
8837 // Apply converter (if not an equivalence)
\r
8838 if ( conv !== true ) {
\r
8840 // Unless errors are allowed to bubble, catch and return them
\r
8841 if ( conv && s[ "throws" ] ) {
\r
8842 response = conv( response );
\r
8845 response = conv( response );
\r
8847 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
\r
8855 return { state: "success", data: response };
\r
8860 // Counter for holding the number of active queries
\r
8863 // Last-Modified header cache for next request
\r
8868 url: ajaxLocation,
\r
8870 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
\r
8872 processData: true,
\r
8874 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
\r
8883 traditional: false,
\r
8889 text: "text/plain",
\r
8890 html: "text/html",
\r
8891 xml: "application/xml, text/xml",
\r
8892 json: "application/json, text/javascript"
\r
8902 xml: "responseXML",
\r
8903 text: "responseText",
\r
8904 json: "responseJSON"
\r
8907 // Data converters
\r
8908 // Keys separate source (or catchall "*") and destination types with a single space
\r
8911 // Convert anything to text
\r
8914 // Text to html (true = no transformation)
\r
8915 "text html": true,
\r
8917 // Evaluate text as a json expression
\r
8918 "text json": jQuery.parseJSON,
\r
8920 // Parse text as xml
\r
8921 "text xml": jQuery.parseXML
\r
8924 // For options that shouldn't be deep extended:
\r
8925 // you can add your own custom options here if
\r
8926 // and when you create one that shouldn't be
\r
8927 // deep extended (see ajaxExtend)
\r
8934 // Creates a full fledged settings object into target
\r
8935 // with both ajaxSettings and settings fields.
\r
8936 // If target is omitted, writes into ajaxSettings.
\r
8937 ajaxSetup: function( target, settings ) {
\r
8940 // Building a settings object
\r
8941 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
\r
8943 // Extending ajaxSettings
\r
8944 ajaxExtend( jQuery.ajaxSettings, target );
\r
8947 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
\r
8948 ajaxTransport: addToPrefiltersOrTransports( transports ),
\r
8951 ajax: function( url, options ) {
\r
8953 // If url is an object, simulate pre-1.5 signature
\r
8954 if ( typeof url === "object" ) {
\r
8959 // Force options to be an object
\r
8960 options = options || {};
\r
8962 var // Cross-domain detection vars
\r
8966 // URL without anti-cache param
\r
8968 // Response headers as string
\r
8969 responseHeadersString,
\r
8973 // To know if global events are to be dispatched
\r
8977 // Response headers
\r
8979 // Create the final options object
\r
8980 s = jQuery.ajaxSetup( {}, options ),
\r
8981 // Callbacks context
\r
8982 callbackContext = s.context || s,
\r
8983 // Context for global events is callbackContext if it is a DOM node or jQuery collection
\r
8984 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
\r
8985 jQuery( callbackContext ) :
\r
8988 deferred = jQuery.Deferred(),
\r
8989 completeDeferred = jQuery.Callbacks("once memory"),
\r
8990 // Status-dependent callbacks
\r
8991 statusCode = s.statusCode || {},
\r
8992 // Headers (they are sent all at once)
\r
8993 requestHeaders = {},
\r
8994 requestHeadersNames = {},
\r
8995 // The jqXHR state
\r
8997 // Default abort message
\r
8998 strAbort = "canceled",
\r
9003 // Builds headers hashtable if needed
\r
9004 getResponseHeader: function( key ) {
\r
9006 if ( state === 2 ) {
\r
9007 if ( !responseHeaders ) {
\r
9008 responseHeaders = {};
\r
9009 while ( (match = rheaders.exec( responseHeadersString )) ) {
\r
9010 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
\r
9013 match = responseHeaders[ key.toLowerCase() ];
\r
9015 return match == null ? null : match;
\r
9019 getAllResponseHeaders: function() {
\r
9020 return state === 2 ? responseHeadersString : null;
\r
9023 // Caches the header
\r
9024 setRequestHeader: function( name, value ) {
\r
9025 var lname = name.toLowerCase();
\r
9027 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
\r
9028 requestHeaders[ name ] = value;
\r
9033 // Overrides response content-type header
\r
9034 overrideMimeType: function( type ) {
\r
9036 s.mimeType = type;
\r
9041 // Status-dependent callbacks
\r
9042 statusCode: function( map ) {
\r
9045 if ( state < 2 ) {
\r
9046 for ( code in map ) {
\r
9047 // Lazy-add the new callback in a way that preserves old ones
\r
9048 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
\r
9051 // Execute the appropriate callbacks
\r
9052 jqXHR.always( map[ jqXHR.status ] );
\r
9058 // Cancel the request
\r
9059 abort: function( statusText ) {
\r
9060 var finalText = statusText || strAbort;
\r
9061 if ( transport ) {
\r
9062 transport.abort( finalText );
\r
9064 done( 0, finalText );
\r
9069 // Attach deferreds
\r
9070 deferred.promise( jqXHR ).complete = completeDeferred.add;
\r
9071 jqXHR.success = jqXHR.done;
\r
9072 jqXHR.error = jqXHR.fail;
\r
9074 // Remove hash character (#7531: and string promotion)
\r
9075 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
\r
9076 // Handle falsy url in the settings object (#10093: consistency with old signature)
\r
9077 // We also use the url parameter if available
\r
9078 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
\r
9080 // Alias method option to type as per ticket #12004
\r
9081 s.type = options.method || options.type || s.method || s.type;
\r
9083 // Extract dataTypes list
\r
9084 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
\r
9086 // A cross-domain request is in order when we have a protocol:host:port mismatch
\r
9087 if ( s.crossDomain == null ) {
\r
9088 parts = rurl.exec( s.url.toLowerCase() );
\r
9089 s.crossDomain = !!( parts &&
\r
9090 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
\r
9091 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
\r
9092 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
\r
9096 // Convert data if not already a string
\r
9097 if ( s.data && s.processData && typeof s.data !== "string" ) {
\r
9098 s.data = jQuery.param( s.data, s.traditional );
\r
9101 // Apply prefilters
\r
9102 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
\r
9104 // If request was aborted inside a prefilter, stop there
\r
9105 if ( state === 2 ) {
\r
9109 // We can fire global events as of now if asked to
\r
9110 fireGlobals = s.global;
\r
9112 // Watch for a new set of requests
\r
9113 if ( fireGlobals && jQuery.active++ === 0 ) {
\r
9114 jQuery.event.trigger("ajaxStart");
\r
9117 // Uppercase the type
\r
9118 s.type = s.type.toUpperCase();
\r
9120 // Determine if request has content
\r
9121 s.hasContent = !rnoContent.test( s.type );
\r
9123 // Save the URL in case we're toying with the If-Modified-Since
\r
9124 // and/or If-None-Match header later on
\r
9127 // More options handling for requests with no content
\r
9128 if ( !s.hasContent ) {
\r
9130 // If data is available, append data to url
\r
9132 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
\r
9133 // #9682: remove data so that it's not used in an eventual retry
\r
9137 // Add anti-cache in url if needed
\r
9138 if ( s.cache === false ) {
\r
9139 s.url = rts.test( cacheURL ) ?
\r
9141 // If there is already a '_' parameter, set its value
\r
9142 cacheURL.replace( rts, "$1_=" + nonce++ ) :
\r
9144 // Otherwise add one to the end
\r
9145 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
\r
9149 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
\r
9150 if ( s.ifModified ) {
\r
9151 if ( jQuery.lastModified[ cacheURL ] ) {
\r
9152 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
\r
9154 if ( jQuery.etag[ cacheURL ] ) {
\r
9155 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
\r
9159 // Set the correct header, if data is being sent
\r
9160 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
\r
9161 jqXHR.setRequestHeader( "Content-Type", s.contentType );
\r
9164 // Set the Accepts header for the server, depending on the dataType
\r
9165 jqXHR.setRequestHeader(
\r
9167 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
\r
9168 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
\r
9172 // Check for headers option
\r
9173 for ( i in s.headers ) {
\r
9174 jqXHR.setRequestHeader( i, s.headers[ i ] );
\r
9177 // Allow custom headers/mimetypes and early abort
\r
9178 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
\r
9179 // Abort if not done already and return
\r
9180 return jqXHR.abort();
\r
9183 // aborting is no longer a cancellation
\r
9184 strAbort = "abort";
\r
9186 // Install callbacks on deferreds
\r
9187 for ( i in { success: 1, error: 1, complete: 1 } ) {
\r
9188 jqXHR[ i ]( s[ i ] );
\r
9192 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
\r
9194 // If no transport, we auto-abort
\r
9195 if ( !transport ) {
\r
9196 done( -1, "No Transport" );
\r
9198 jqXHR.readyState = 1;
\r
9200 // Send global event
\r
9201 if ( fireGlobals ) {
\r
9202 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
\r
9205 if ( s.async && s.timeout > 0 ) {
\r
9206 timeoutTimer = setTimeout(function() {
\r
9207 jqXHR.abort("timeout");
\r
9213 transport.send( requestHeaders, done );
\r
9215 // Propagate exception as error if not done
\r
9216 if ( state < 2 ) {
\r
9218 // Simply rethrow otherwise
\r
9225 // Callback for when everything is done
\r
9226 function done( status, nativeStatusText, responses, headers ) {
\r
9227 var isSuccess, success, error, response, modified,
\r
9228 statusText = nativeStatusText;
\r
9231 if ( state === 2 ) {
\r
9235 // State is "done" now
\r
9238 // Clear timeout if it exists
\r
9239 if ( timeoutTimer ) {
\r
9240 clearTimeout( timeoutTimer );
\r
9243 // Dereference transport for early garbage collection
\r
9244 // (no matter how long the jqXHR object will be used)
\r
9245 transport = undefined;
\r
9247 // Cache response headers
\r
9248 responseHeadersString = headers || "";
\r
9251 jqXHR.readyState = status > 0 ? 4 : 0;
\r
9253 // Determine if successful
\r
9254 isSuccess = status >= 200 && status < 300 || status === 304;
\r
9256 // Get response data
\r
9257 if ( responses ) {
\r
9258 response = ajaxHandleResponses( s, jqXHR, responses );
\r
9261 // Convert no matter what (that way responseXXX fields are always set)
\r
9262 response = ajaxConvert( s, response, jqXHR, isSuccess );
\r
9264 // If successful, handle type chaining
\r
9265 if ( isSuccess ) {
\r
9267 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
\r
9268 if ( s.ifModified ) {
\r
9269 modified = jqXHR.getResponseHeader("Last-Modified");
\r
9271 jQuery.lastModified[ cacheURL ] = modified;
\r
9273 modified = jqXHR.getResponseHeader("etag");
\r
9275 jQuery.etag[ cacheURL ] = modified;
\r
9280 if ( status === 204 || s.type === "HEAD" ) {
\r
9281 statusText = "nocontent";
\r
9283 // if not modified
\r
9284 } else if ( status === 304 ) {
\r
9285 statusText = "notmodified";
\r
9287 // If we have data, let's convert it
\r
9289 statusText = response.state;
\r
9290 success = response.data;
\r
9291 error = response.error;
\r
9292 isSuccess = !error;
\r
9295 // We extract error from statusText
\r
9296 // then normalize statusText and status for non-aborts
\r
9297 error = statusText;
\r
9298 if ( status || !statusText ) {
\r
9299 statusText = "error";
\r
9300 if ( status < 0 ) {
\r
9306 // Set data for the fake xhr object
\r
9307 jqXHR.status = status;
\r
9308 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
\r
9311 if ( isSuccess ) {
\r
9312 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
\r
9314 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
\r
9317 // Status-dependent callbacks
\r
9318 jqXHR.statusCode( statusCode );
\r
9319 statusCode = undefined;
\r
9321 if ( fireGlobals ) {
\r
9322 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
\r
9323 [ jqXHR, s, isSuccess ? success : error ] );
\r
9327 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
\r
9329 if ( fireGlobals ) {
\r
9330 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
\r
9331 // Handle the global AJAX counter
\r
9332 if ( !( --jQuery.active ) ) {
\r
9333 jQuery.event.trigger("ajaxStop");
\r
9341 getJSON: function( url, data, callback ) {
\r
9342 return jQuery.get( url, data, callback, "json" );
\r
9345 getScript: function( url, callback ) {
\r
9346 return jQuery.get( url, undefined, callback, "script" );
\r
9350 jQuery.each( [ "get", "post" ], function( i, method ) {
\r
9351 jQuery[ method ] = function( url, data, callback, type ) {
\r
9352 // shift arguments if data argument was omitted
\r
9353 if ( jQuery.isFunction( data ) ) {
\r
9354 type = type || callback;
\r
9359 return jQuery.ajax({
\r
9369 // Attach a bunch of functions for handling common AJAX events
\r
9370 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
\r
9371 jQuery.fn[ type ] = function( fn ) {
\r
9372 return this.on( type, fn );
\r
9377 jQuery._evalUrl = function( url ) {
\r
9378 return jQuery.ajax({
\r
9381 dataType: "script",
\r
9389 jQuery.fn.extend({
\r
9390 wrapAll: function( html ) {
\r
9391 if ( jQuery.isFunction( html ) ) {
\r
9392 return this.each(function(i) {
\r
9393 jQuery(this).wrapAll( html.call(this, i) );
\r
9398 // The elements to wrap the target around
\r
9399 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
\r
9401 if ( this[0].parentNode ) {
\r
9402 wrap.insertBefore( this[0] );
\r
9405 wrap.map(function() {
\r
9408 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
\r
9409 elem = elem.firstChild;
\r
9413 }).append( this );
\r
9419 wrapInner: function( html ) {
\r
9420 if ( jQuery.isFunction( html ) ) {
\r
9421 return this.each(function(i) {
\r
9422 jQuery(this).wrapInner( html.call(this, i) );
\r
9426 return this.each(function() {
\r
9427 var self = jQuery( this ),
\r
9428 contents = self.contents();
\r
9430 if ( contents.length ) {
\r
9431 contents.wrapAll( html );
\r
9434 self.append( html );
\r
9439 wrap: function( html ) {
\r
9440 var isFunction = jQuery.isFunction( html );
\r
9442 return this.each(function(i) {
\r
9443 jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
\r
9447 unwrap: function() {
\r
9448 return this.parent().each(function() {
\r
9449 if ( !jQuery.nodeName( this, "body" ) ) {
\r
9450 jQuery( this ).replaceWith( this.childNodes );
\r
9457 jQuery.expr.filters.hidden = function( elem ) {
\r
9458 // Support: Opera <= 12.12
\r
9459 // Opera reports offsetWidths and offsetHeights less than zero on some elements
\r
9460 return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
\r
9461 (!support.reliableHiddenOffsets() &&
\r
9462 ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
\r
9465 jQuery.expr.filters.visible = function( elem ) {
\r
9466 return !jQuery.expr.filters.hidden( elem );
\r
9473 rbracket = /\[\]$/,
\r
9475 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
\r
9476 rsubmittable = /^(?:input|select|textarea|keygen)/i;
\r
9478 function buildParams( prefix, obj, traditional, add ) {
\r
9481 if ( jQuery.isArray( obj ) ) {
\r
9482 // Serialize array item.
\r
9483 jQuery.each( obj, function( i, v ) {
\r
9484 if ( traditional || rbracket.test( prefix ) ) {
\r
9485 // Treat each array item as a scalar.
\r
9489 // Item is non-scalar (array or object), encode its numeric index.
\r
9490 buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
\r
9494 } else if ( !traditional && jQuery.type( obj ) === "object" ) {
\r
9495 // Serialize object item.
\r
9496 for ( name in obj ) {
\r
9497 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
\r
9501 // Serialize scalar item.
\r
9502 add( prefix, obj );
\r
9506 // Serialize an array of form elements or a set of
\r
9507 // key/values into a query string
\r
9508 jQuery.param = function( a, traditional ) {
\r
9511 add = function( key, value ) {
\r
9512 // If value is a function, invoke it and return its value
\r
9513 value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
\r
9514 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
\r
9517 // Set traditional to true for jQuery <= 1.3.2 behavior.
\r
9518 if ( traditional === undefined ) {
\r
9519 traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
\r
9522 // If an array was passed in, assume that it is an array of form elements.
\r
9523 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
\r
9524 // Serialize the form elements
\r
9525 jQuery.each( a, function() {
\r
9526 add( this.name, this.value );
\r
9530 // If traditional, encode the "old" way (the way 1.3.2 or older
\r
9531 // did it), otherwise encode params recursively.
\r
9532 for ( prefix in a ) {
\r
9533 buildParams( prefix, a[ prefix ], traditional, add );
\r
9537 // Return the resulting serialization
\r
9538 return s.join( "&" ).replace( r20, "+" );
\r
9541 jQuery.fn.extend({
\r
9542 serialize: function() {
\r
9543 return jQuery.param( this.serializeArray() );
\r
9545 serializeArray: function() {
\r
9546 return this.map(function() {
\r
9547 // Can add propHook for "elements" to filter or add form elements
\r
9548 var elements = jQuery.prop( this, "elements" );
\r
9549 return elements ? jQuery.makeArray( elements ) : this;
\r
9551 .filter(function() {
\r
9552 var type = this.type;
\r
9553 // Use .is(":disabled") so that fieldset[disabled] works
\r
9554 return this.name && !jQuery( this ).is( ":disabled" ) &&
\r
9555 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
\r
9556 ( this.checked || !rcheckableType.test( type ) );
\r
9558 .map(function( i, elem ) {
\r
9559 var val = jQuery( this ).val();
\r
9561 return val == null ?
\r
9563 jQuery.isArray( val ) ?
\r
9564 jQuery.map( val, function( val ) {
\r
9565 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
\r
9567 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
\r
9573 // Create the request object
\r
9574 // (This is still attached to ajaxSettings for backward compatibility)
\r
9575 jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
\r
9579 // XHR cannot access local files, always use ActiveX for that case
\r
9580 return !this.isLocal &&
\r
9583 // oldIE XHR does not support non-RFC2616 methods (#13240)
\r
9584 // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
\r
9585 // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
\r
9586 // Although this check for six methods instead of eight
\r
9587 // since IE also does not support "trace" and "connect"
\r
9588 /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
\r
9590 createStandardXHR() || createActiveXHR();
\r
9592 // For all other browsers, use the standard XMLHttpRequest object
\r
9593 createStandardXHR;
\r
9597 function createXHR(isMSIE) {
\r
9599 return (isMSIE ? new window.ActiveXObject( "Microsoft.XMLHTTP" ) : new window.XMLHttpRequest());
\r
9603 jQuery.ajaxSettings.xhr = (window.ActiveXObject === undefined ? createXHR :
\r
9605 return (this.url == document.location || this.url.indexOf("http") == 0 || !this.isLocal) && // BH MSIE fix
\r
9606 /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
\r
9607 createXHR() || createXHR(1);
\r
9614 xhrCallbacks = {},
\r
9615 xhrSupported = jQuery.ajaxSettings.xhr();
\r
9618 // Open requests must be manually aborted on unload (#5280)
\r
9619 if ( window.ActiveXObject ) {
\r
9620 jQuery( window ).on( "unload", function() {
\r
9621 for ( var key in xhrCallbacks ) {
\r
9622 xhrCallbacks[ key ]( undefined, true );
\r
9627 // Determine support properties
\r
9628 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
\r
9629 xhrSupported = support.ajax = !!xhrSupported;
\r
9631 // Create transport if the browser can provide an xhr
\r
9632 if ( xhrSupported ) {
\r
9634 jQuery.ajaxTransport(function( options ) {
\r
9635 // Cross domain only allowed if supported through XMLHttpRequest
\r
9636 if ( !options.crossDomain || support.cors ) {
\r
9641 send: function( headers, complete ) {
\r
9643 xhr = options.xhr(),
\r
9646 // Open the socket
\r
9647 console.log("xhr.open async=" + options.async + " url=" + options.url);
\r
9648 xhr.open( options.type, options.url, options.async, options.username, options.password );
\r
9650 // Apply custom fields if provided
\r
9651 if ( options.xhrFields ) {
\r
9652 for ( i in options.xhrFields ) {
\r
9653 xhr[ i ] = options.xhrFields[ i ];
\r
9657 // Override mime type if needed
\r
9658 if ( options.mimeType && xhr.overrideMimeType ) {
\r
9659 xhr.overrideMimeType( options.mimeType );
\r
9662 // X-Requested-With header
\r
9663 // For cross-domain requests, seeing as conditions for a preflight are
\r
9664 // akin to a jigsaw puzzle, we simply never set it to be sure.
\r
9665 // (it can always be set on a per-request basis or even using ajaxSetup)
\r
9666 // For same-domain requests, won't change header if already provided.
\r
9667 if ( !options.crossDomain && !headers["X-Requested-With"] ) {
\r
9668 headers["X-Requested-With"] = "XMLHttpRequest";
\r
9672 for ( i in headers ) {
\r
9674 // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
\r
9675 // request header to a null-value.
\r
9677 // To keep consistent with other XHR implementations, cast the value
\r
9678 // to string and ignore `undefined`.
\r
9679 if ( headers[ i ] !== undefined ) {
\r
9680 xhr.setRequestHeader( i, headers[ i ] + "" );
\r
9684 // Do send the request
\r
9685 // This may raise an exception which is actually
\r
9686 // handled in jQuery.ajax (so no try/catch here)
\r
9687 xhr.send( ( options.hasContent && options.data ) || null );
\r
9690 callback = function( _, isAbort ) {
\r
9691 var status, statusText, responses;
\r
9693 // Was never called and is aborted or complete
\r
9694 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
\r
9696 delete xhrCallbacks[ id ];
\r
9697 callback = undefined;
\r
9698 xhr.onreadystatechange = jQuery.noop;
\r
9700 // Abort manually if needed
\r
9702 if ( xhr.readyState !== 4 ) {
\r
9707 status = xhr.status;
\r
9710 // Accessing binary-data responseText throws an exception
\r
9712 if ( typeof xhr.responseText === "string" ) {
\r
9713 responses.text = xhr.responseText;
\r
9716 // Firefox throws an exception when accessing
\r
9717 // statusText for faulty cross-domain requests
\r
9719 statusText = xhr.statusText;
\r
9721 // We normalize with Webkit giving an empty statusText
\r
9725 // Filter status for non standard behaviors
\r
9727 // If the request is local and we have data: assume a success
\r
9728 // (success with no data won't get notified, that's the best we
\r
9729 // can do given current implementations)
\r
9730 if ( !status && options.isLocal && !options.crossDomain ) {
\r
9731 status = responses.text ? 200 : 404;
\r
9732 // IE - #1450: sometimes returns 1223 when it should be 204
\r
9733 } else if ( status === 1223 ) {
\r
9739 // Call complete if needed
\r
9740 if ( responses ) {
\r
9741 complete( status, statusText, responses, xhr.getAllResponseHeaders() );
\r
9745 if ( !options.async ) {
\r
9746 // if we're in sync mode we fire the callback
\r
9748 } else if ( xhr.readyState === 4 ) {
\r
9749 // (IE6 & IE7) if it's in cache and has been
\r
9750 // retrieved directly we need to fire the callback
\r
9751 setTimeout( callback );
\r
9753 // Add to the list of active xhr callbacks
\r
9754 xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
\r
9758 abort: function() {
\r
9760 callback( undefined, true );
\r
9768 // Functions to create xhrs
\r
9769 function createStandardXHR() {
\r
9771 return new window.XMLHttpRequest();
\r
9775 function createActiveXHR() {
\r
9777 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
\r
9784 // Install script dataType
\r
9785 jQuery.ajaxSetup({
\r
9787 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
\r
9790 script: /(?:java|ecma)script/
\r
9793 "text script": function( text ) {
\r
9794 jQuery.globalEval( text );
\r
9800 // Handle cache's special case and global
\r
9801 jQuery.ajaxPrefilter( "script", function( s ) {
\r
9802 if ( s.cache === undefined ) {
\r
9805 if ( s.crossDomain ) {
\r
9811 // Bind script tag hack transport
\r
9812 jQuery.ajaxTransport( "script", function(s) {
\r
9814 // This transport only deals with cross domain requests
\r
9815 if ( s.crossDomain ) {
\r
9818 head = document.head || jQuery("head")[0] || document.documentElement;
\r
9822 send: function( _, callback ) {
\r
9824 script = document.createElement("script");
\r
9826 script.async = true;
\r
9828 if ( s.scriptCharset ) {
\r
9829 script.charset = s.scriptCharset;
\r
9832 script.src = s.url;
\r
9834 // Attach handlers for all browsers
\r
9835 script.onload = script.onreadystatechange = function( _, isAbort ) {
\r
9837 if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
\r
9839 // Handle memory leak in IE
\r
9840 script.onload = script.onreadystatechange = null;
\r
9842 // Remove the script
\r
9843 if ( script.parentNode ) {
\r
9844 script.parentNode.removeChild( script );
\r
9847 // Dereference the script
\r
9850 // Callback if not abort
\r
9852 callback( 200, "success" );
\r
9857 // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
\r
9858 // Use native DOM manipulation to avoid our domManip AJAX trickery
\r
9859 head.insertBefore( script, head.firstChild );
\r
9862 abort: function() {
\r
9864 script.onload( undefined, true );
\r
9874 var oldCallbacks = [],
\r
9875 rjsonp = /(=)\?(?=&|$)|\?\?/;
\r
9877 // Default jsonp settings
\r
9878 jQuery.ajaxSetup({
\r
9879 jsonp: "callback",
\r
9880 jsonpCallback: function() {
\r
9881 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
\r
9882 this[ callback ] = true;
\r
9887 // Detect, normalize options and install callbacks for jsonp requests
\r
9888 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
\r
9890 var callbackName, overwritten, responseContainer,
\r
9891 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
\r
9893 typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
\r
9896 // Handle iff the expected data type is "jsonp" or we have a parameter to set
\r
9897 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
\r
9899 // Get callback name, remembering preexisting value associated with it
\r
9900 callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
\r
9901 s.jsonpCallback() :
\r
9904 // Insert callback into url or form data
\r
9906 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
\r
9907 } else if ( s.jsonp !== false ) {
\r
9908 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
\r
9911 // Use data converter to retrieve json after script execution
\r
9912 s.converters["script json"] = function() {
\r
9913 if ( !responseContainer ) {
\r
9914 jQuery.error( callbackName + " was not called" );
\r
9916 return responseContainer[ 0 ];
\r
9919 // force json dataType
\r
9920 s.dataTypes[ 0 ] = "json";
\r
9922 // Install callback
\r
9923 overwritten = window[ callbackName ];
\r
9924 window[ callbackName ] = function() {
\r
9925 responseContainer = arguments;
\r
9928 // Clean-up function (fires after converters)
\r
9929 jqXHR.always(function() {
\r
9930 // Restore preexisting value
\r
9931 window[ callbackName ] = overwritten;
\r
9933 // Save back as free
\r
9934 if ( s[ callbackName ] ) {
\r
9935 // make sure that re-using the options doesn't screw things around
\r
9936 s.jsonpCallback = originalSettings.jsonpCallback;
\r
9938 // save the callback name for future use
\r
9939 oldCallbacks.push( callbackName );
\r
9942 // Call if it was a function and we have a response
\r
9943 if ( responseContainer && jQuery.isFunction( overwritten ) ) {
\r
9944 overwritten( responseContainer[ 0 ] );
\r
9947 responseContainer = overwritten = undefined;
\r
9950 // Delegate to script
\r
9958 // data: string of html
\r
9959 // context (optional): If specified, the fragment will be created in this context, defaults to document
\r
9960 // keepScripts (optional): If true, will include scripts passed in the html string
\r
9961 jQuery.parseHTML = function( data, context, keepScripts ) {
\r
9962 if ( !data || typeof data !== "string" ) {
\r
9965 if ( typeof context === "boolean" ) {
\r
9966 keepScripts = context;
\r
9969 context = context || document;
\r
9971 var parsed = rsingleTag.exec( data ),
\r
9972 scripts = !keepScripts && [];
\r
9976 return [ context.createElement( parsed[1] ) ];
\r
9979 parsed = jQuery.buildFragment( [ data ], context, scripts );
\r
9981 if ( scripts && scripts.length ) {
\r
9982 jQuery( scripts ).remove();
\r
9985 return jQuery.merge( [], parsed.childNodes );
\r
9989 // Keep a copy of the old load method
\r
9990 var _load = jQuery.fn.load;
\r
9993 * Load a url into a page
\r
9995 jQuery.fn.load = function( url, params, callback ) {
\r
9996 if ( typeof url !== "string" && _load ) {
\r
9997 return _load.apply( this, arguments );
\r
10000 var selector, response, type,
\r
10002 off = url.indexOf(" ");
\r
10004 if ( off >= 0 ) {
\r
10005 selector = url.slice( off, url.length );
\r
10006 url = url.slice( 0, off );
\r
10009 // If it's a function
\r
10010 if ( jQuery.isFunction( params ) ) {
\r
10012 // We assume that it's the callback
\r
10013 callback = params;
\r
10014 params = undefined;
\r
10016 // Otherwise, build a param string
\r
10017 } else if ( params && typeof params === "object" ) {
\r
10021 // If we have elements to modify, make the request
\r
10022 if ( self.length > 0 ) {
\r
10026 // if "type" variable is undefined, then "GET" method will be used
\r
10028 dataType: "html",
\r
10030 }).done(function( responseText ) {
\r
10032 // Save response for use in complete callback
\r
10033 response = arguments;
\r
10035 self.html( selector ?
\r
10037 // If a selector was specified, locate the right elements in a dummy div
\r
10038 // Exclude scripts to avoid IE 'Permission Denied' errors
\r
10039 jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
\r
10041 // Otherwise use the full result
\r
10044 }).complete( callback && function( jqXHR, status ) {
\r
10045 self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
\r
10055 jQuery.expr.filters.animated = function( elem ) {
\r
10056 return jQuery.grep(jQuery.timers, function( fn ) {
\r
10057 return elem === fn.elem;
\r
10065 var docElem = window.document.documentElement;
\r
10068 * Gets a window from an element
\r
10070 function getWindow( elem ) {
\r
10071 return jQuery.isWindow( elem ) ?
\r
10073 elem.nodeType === 9 ?
\r
10074 elem.defaultView || elem.parentWindow :
\r
10078 jQuery.offset = {
\r
10079 setOffset: function( elem, options, i ) {
\r
10080 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
\r
10081 position = jQuery.css( elem, "position" ),
\r
10082 curElem = jQuery( elem ),
\r
10085 // set position first, in-case top/left are set even on static elem
\r
10086 if ( position === "static" ) {
\r
10087 elem.style.position = "relative";
\r
10090 curOffset = curElem.offset();
\r
10091 curCSSTop = jQuery.css( elem, "top" );
\r
10092 curCSSLeft = jQuery.css( elem, "left" );
\r
10093 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
\r
10094 jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
\r
10096 // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
\r
10097 if ( calculatePosition ) {
\r
10098 curPosition = curElem.position();
\r
10099 curTop = curPosition.top;
\r
10100 curLeft = curPosition.left;
\r
10102 curTop = parseFloat( curCSSTop ) || 0;
\r
10103 curLeft = parseFloat( curCSSLeft ) || 0;
\r
10106 if ( jQuery.isFunction( options ) ) {
\r
10107 options = options.call( elem, i, curOffset );
\r
10110 if ( options.top != null ) {
\r
10111 props.top = ( options.top - curOffset.top ) + curTop;
\r
10113 if ( options.left != null ) {
\r
10114 props.left = ( options.left - curOffset.left ) + curLeft;
\r
10117 if ( "using" in options ) {
\r
10118 options.using.call( elem, props );
\r
10120 curElem.css( props );
\r
10125 jQuery.fn.extend({
\r
10126 offset: function( options ) {
\r
10127 if ( arguments.length ) {
\r
10128 return options === undefined ?
\r
10130 this.each(function( i ) {
\r
10131 jQuery.offset.setOffset( this, options, i );
\r
10135 var docElem, win,
\r
10136 box = { top: 0, left: 0 },
\r
10137 elem = this[ 0 ],
\r
10138 doc = elem && elem.ownerDocument;
\r
10144 docElem = doc.documentElement;
\r
10146 // Make sure it's not a disconnected DOM node
\r
10147 if ( !jQuery.contains( docElem, elem ) ) {
\r
10151 // If we don't have gBCR, just use 0,0 rather than error
\r
10152 // BlackBerry 5, iOS 3 (original iPhone)
\r
10153 if ( typeof elem.getBoundingClientRect !== strundefined ) {
\r
10154 box = elem.getBoundingClientRect();
\r
10156 win = getWindow( doc );
\r
10158 top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
\r
10159 left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
\r
10163 position: function() {
\r
10164 if ( !this[ 0 ] ) {
\r
10168 var offsetParent, offset,
\r
10169 parentOffset = { top: 0, left: 0 },
\r
10170 elem = this[ 0 ];
\r
10172 // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
\r
10173 if ( jQuery.css( elem, "position" ) === "fixed" ) {
\r
10174 // we assume that getBoundingClientRect is available when computed position is fixed
\r
10175 offset = elem.getBoundingClientRect();
\r
10177 // Get *real* offsetParent
\r
10178 offsetParent = this.offsetParent();
\r
10180 // Get correct offsets
\r
10181 offset = this.offset();
\r
10182 if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
\r
10183 parentOffset = offsetParent.offset();
\r
10186 // Add offsetParent borders
\r
10187 parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
\r
10188 parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
\r
10191 // Subtract parent offsets and element margins
\r
10192 // note: when an element has margin: auto the offsetLeft and marginLeft
\r
10193 // are the same in Safari causing offset.left to incorrectly be 0
\r
10195 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
\r
10196 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
\r
10200 offsetParent: function() {
\r
10201 return this.map(function() {
\r
10202 var offsetParent = this.offsetParent || docElem;
\r
10204 while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
\r
10205 offsetParent = offsetParent.offsetParent;
\r
10207 return offsetParent || docElem;
\r
10212 // Create scrollLeft and scrollTop methods
\r
10213 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
\r
10214 var top = /Y/.test( prop );
\r
10216 jQuery.fn[ method ] = function( val ) {
\r
10217 return access( this, function( elem, method, val ) {
\r
10218 var win = getWindow( elem );
\r
10220 if ( val === undefined ) {
\r
10221 return win ? (prop in win) ? win[ prop ] :
\r
10222 win.document.documentElement[ method ] :
\r
10228 !top ? val : jQuery( win ).scrollLeft(),
\r
10229 top ? val : jQuery( win ).scrollTop()
\r
10233 elem[ method ] = val;
\r
10235 }, method, val, arguments.length, null );
\r
10239 // Add the top/left cssHooks using jQuery.fn.position
\r
10240 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
\r
10241 // getComputedStyle returns percent when specified for top/left/bottom/right
\r
10242 // rather than make the css module depend on the offset module, we just check for it here
\r
10243 jQuery.each( [ "top", "left" ], function( i, prop ) {
\r
10244 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
\r
10245 function( elem, computed ) {
\r
10246 if ( computed ) {
\r
10247 computed = curCSS( elem, prop );
\r
10248 // if curCSS returns percentage, fallback to offset
\r
10249 return rnumnonpx.test( computed ) ?
\r
10250 jQuery( elem ).position()[ prop ] + "px" :
\r
10258 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
\r
10259 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
\r
10260 jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
\r
10261 // margin is only for outerHeight, outerWidth
\r
10262 jQuery.fn[ funcName ] = function( margin, value ) {
\r
10263 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
\r
10264 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
\r
10266 return access( this, function( elem, type, value ) {
\r
10269 if ( jQuery.isWindow( elem ) ) {
\r
10270 // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
\r
10271 // isn't a whole lot we can do. See pull request at this URL for discussion:
\r
10272 // https://github.com/jquery/jquery/pull/764
\r
10273 return elem.document.documentElement[ "client" + name ];
\r
10276 // Get document width or height
\r
10277 if ( elem.nodeType === 9 ) {
\r
10278 doc = elem.documentElement;
\r
10280 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
\r
10281 // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
\r
10283 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
\r
10284 elem.body[ "offset" + name ], doc[ "offset" + name ],
\r
10285 doc[ "client" + name ]
\r
10289 return value === undefined ?
\r
10290 // Get width or height on the element, requesting but not forcing parseFloat
\r
10291 jQuery.css( elem, type, extra ) :
\r
10293 // Set width or height on the element
\r
10294 jQuery.style( elem, type, value, extra );
\r
10295 }, type, chainable ? margin : undefined, chainable, null );
\r
10301 // The number of elements contained in the matched element set
\r
10302 jQuery.fn.size = function() {
\r
10303 return this.length;
\r
10306 jQuery.fn.andSelf = jQuery.fn.addBack;
\r
10311 // Register as a named AMD module, since jQuery can be concatenated with other
\r
10312 // files that may use define, but not via a proper concatenation script that
\r
10313 // understands anonymous AMD modules. A named AMD is safest and most robust
\r
10314 // way to register. Lowercase jquery is used because AMD module names are
\r
10315 // derived from file names, and jQuery is normally delivered in a lowercase
\r
10316 // file name. Do this after creating the global so that if an AMD module wants
\r
10317 // to call noConflict to hide this version of jQuery, it will work.
\r
10318 if ( typeof define === "function" && define.amd ) {
\r
10319 define( "jquery", [], function() {
\r
10328 // Map over jQuery in case of overwrite
\r
10329 _jQuery = window.jQuery,
\r
10331 // Map over the $ in case of overwrite
\r
10334 jQuery.noConflict = function( deep ) {
\r
10335 if ( window.$ === jQuery ) {
\r
10339 if ( deep && window.jQuery === jQuery ) {
\r
10340 window.jQuery = _jQuery;
\r
10346 // Expose jQuery and $ identifiers, even in
\r
10347 // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
\r
10348 // and CommonJS for browser emulators (#13566)
\r
10349 if ( typeof noGlobal === strundefined ) {
\r
10350 window.jQuery = window.$ = jQuery;
\r