2 * jQuery JavaScript Library v1.11.0
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2014-01-23T21:02Z
15 (function( global, factory ) {
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper window is present,
19 // execute the factory and get jQuery
20 // For environments that do not inherently posses a window with a document
21 // (such as Node.js), expose a jQuery-making factory as module.exports
22 // This accentuates the need for the creation of a real window
23 // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info
25 module.exports = global.document ?
26 factory( global, true ) :
29 throw new Error( "jQuery requires a window with a document" );
37 // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40 // Can't do this because several apps including ASP.NET trace
41 // the stack via arguments.caller.callee and Firefox dies if
42 // you try to trace through "use strict" call chains. (#13335)
43 // Support: Firefox 18+
48 var slice = deletedIds.slice;
50 var concat = deletedIds.concat;
52 var push = deletedIds.push;
54 var indexOf = deletedIds.indexOf;
58 var toString = class2type.toString;
60 var hasOwn = class2type.hasOwnProperty;
71 // Define a local copy of jQuery
72 jQuery = function( selector, context ) {
73 // The jQuery object is actually just the init constructor 'enhanced'
74 // Need init if jQuery is called (just allow error to be thrown if not included)
75 return new jQuery.fn.init( selector, context );
78 // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
79 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
81 // Matches dashed string for camelizing
83 rdashAlpha = /-([\da-z])/gi,
85 // Used by jQuery.camelCase as callback to replace()
86 fcamelCase = function( all, letter ) {
87 return letter.toUpperCase();
90 jQuery.fn = jQuery.prototype = {
91 // The current version of jQuery being used
96 // Start with an empty selector
99 // The default length of a jQuery object is 0
102 toArray: function() {
103 return slice.call( this );
106 // Get the Nth element in the matched element set OR
107 // Get the whole matched element set as a clean array
108 get: function( num ) {
111 // Return a 'clean' array
112 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
114 // Return just the object
118 // Take an array of elements and push it onto the stack
119 // (returning the new matched element set)
120 pushStack: function( elems ) {
122 // Build a new jQuery matched element set
123 var ret = jQuery.merge( this.constructor(), elems );
125 // Add the old object onto the stack (as a reference)
126 ret.prevObject = this;
127 ret.context = this.context;
129 // Return the newly-formed element set
133 // Execute a callback for every element in the matched set.
134 // (You can seed the arguments with an array of args, but this is
135 // only used internally.)
136 each: function( callback, args ) {
137 return jQuery.each( this, callback, args );
140 map: function( callback ) {
141 return this.pushStack( jQuery.map(this, function( elem, i ) {
142 return callback.call( elem, i, elem );
147 return this.pushStack( slice.apply( this, arguments ) );
155 return this.eq( -1 );
159 var len = this.length,
160 j = +i + ( i < 0 ? len : 0 );
161 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
165 return this.prevObject || this.constructor(null);
168 // For internal use only.
169 // Behaves like an Array's method, not like a jQuery method.
171 sort: deletedIds.sort,
172 splice: deletedIds.splice
175 jQuery.extend = jQuery.fn.extend = function() {
176 var src, copyIsArray, copy, name, options, clone,
177 target = arguments[0] || {},
179 length = arguments.length,
182 // Handle a deep copy situation
183 if ( typeof target === "boolean" ) {
186 // skip the boolean and the target
187 target = arguments[ i ] || {};
191 // Handle case when target is a string or something (possible in deep copy)
192 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
196 // extend jQuery itself if only one argument is passed
197 if ( i === length ) {
202 for ( ; i < length; i++ ) {
203 // Only deal with non-null/undefined values
204 if ( (options = arguments[ i ]) != null ) {
205 // Extend the base object
206 for ( name in options ) {
207 src = target[ name ];
208 copy = options[ name ];
210 // Prevent never-ending loop
211 if ( target === copy ) {
215 // Recurse if we're merging plain objects or arrays
216 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
219 clone = src && jQuery.isArray(src) ? src : [];
222 clone = src && jQuery.isPlainObject(src) ? src : {};
225 // Never move original objects, clone them
226 target[ name ] = jQuery.extend( deep, clone, copy );
228 // Don't bring in undefined values
229 } else if ( copy !== undefined ) {
230 target[ name ] = copy;
236 // Return the modified object
241 // Unique for each copy of jQuery on the page
242 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
244 // Assume jQuery is ready without the ready module
247 error: function( msg ) {
248 throw new Error( msg );
253 // See test/unit/core.js for details concerning isFunction.
254 // Since version 1.3, DOM methods and functions like alert
255 // aren't supported. They return false on IE (#2968).
256 isFunction: function( obj ) {
257 return jQuery.type(obj) === "function";
260 isArray: Array.isArray || function( obj ) {
261 return jQuery.type(obj) === "array";
264 isWindow: function( obj ) {
265 /* jshint eqeqeq: false */
266 return obj != null && obj == obj.window;
269 isNumeric: function( obj ) {
270 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
271 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
272 // subtraction forces infinities to NaN
273 return obj - parseFloat( obj ) >= 0;
276 isEmptyObject: function( obj ) {
278 for ( name in obj ) {
284 isPlainObject: function( obj ) {
287 // Must be an Object.
288 // Because of IE, we also have to check the presence of the constructor property.
289 // Make sure that DOM nodes and window objects don't pass through, as well
290 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
295 // Not own constructor property must be Object
296 if ( obj.constructor &&
297 !hasOwn.call(obj, "constructor") &&
298 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
302 // IE8,9 Will throw exceptions on certain host objects #9897
307 // Handle iteration over inherited properties before own properties.
308 if ( support.ownLast ) {
310 return hasOwn.call( obj, key );
314 // Own properties are enumerated firstly, so to speed up,
315 // if last one is own, then all properties are own.
316 for ( key in obj ) {}
318 return key === undefined || hasOwn.call( obj, key );
321 type: function( obj ) {
325 return typeof obj === "object" || typeof obj === "function" ?
326 class2type[ toString.call(obj) ] || "object" :
330 // Evaluates a script in a global context
331 // Workarounds based on findings by Jim Driscoll
332 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
333 globalEval: function( data ) {
334 if ( data && jQuery.trim( data ) ) {
335 // We use execScript on Internet Explorer
336 // We use an anonymous function so that context is window
337 // rather than jQuery in Firefox
338 ( window.execScript || function( data ) {
339 window[ "eval" ].call( window, data );
344 // Convert dashed to camelCase; used by the css and data modules
345 // Microsoft forgot to hump their vendor prefix (#9572)
346 camelCase: function( string ) {
347 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
350 nodeName: function( elem, name ) {
351 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
354 // args is for internal usage only
355 each: function( obj, callback, args ) {
359 isArray = isArraylike( obj );
363 for ( ; i < length; i++ ) {
364 value = callback.apply( obj[ i ], args );
366 if ( value === false ) {
372 value = callback.apply( obj[ i ], args );
374 if ( value === false ) {
380 // A special, fast, case for the most common use of each
383 for ( ; i < length; i++ ) {
384 value = callback.call( obj[ i ], i, obj[ i ] );
386 if ( value === false ) {
392 value = callback.call( obj[ i ], i, obj[ i ] );
394 if ( value === false ) {
404 // Use native String.trim function wherever possible
405 trim: trim && !trim.call("\uFEFF\xA0") ?
407 return text == null ?
412 // Otherwise use our own trimming functionality
414 return text == null ?
416 ( text + "" ).replace( rtrim, "" );
419 // results is for internal usage only
420 makeArray: function( arr, results ) {
421 var ret = results || [];
424 if ( isArraylike( Object(arr) ) ) {
426 typeof arr === "string" ?
430 push.call( ret, arr );
437 inArray: function( elem, arr, i ) {
442 return indexOf.call( arr, elem, i );
446 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
448 for ( ; i < len; i++ ) {
449 // Skip accessing in sparse arrays
450 if ( i in arr && arr[ i ] === elem ) {
459 merge: function( first, second ) {
460 var len = +second.length,
465 first[ i++ ] = second[ j++ ];
469 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
471 while ( second[j] !== undefined ) {
472 first[ i++ ] = second[ j++ ];
481 grep: function( elems, callback, invert ) {
485 length = elems.length,
486 callbackExpect = !invert;
488 // Go through the array, only saving the items
489 // that pass the validator function
490 for ( ; i < length; i++ ) {
491 callbackInverse = !callback( elems[ i ], i );
492 if ( callbackInverse !== callbackExpect ) {
493 matches.push( elems[ i ] );
500 // arg is for internal usage only
501 map: function( elems, callback, arg ) {
504 length = elems.length,
505 isArray = isArraylike( elems ),
508 // Go through the array, translating each of the items to their new values
510 for ( ; i < length; i++ ) {
511 value = callback( elems[ i ], i, arg );
513 if ( value != null ) {
518 // Go through every key on the object,
521 value = callback( elems[ i ], i, arg );
523 if ( value != null ) {
529 // Flatten any nested arrays
530 return concat.apply( [], ret );
533 // A global GUID counter for objects
536 // Bind a function to a context, optionally partially applying any
538 proxy: function( fn, context ) {
539 var args, proxy, tmp;
541 if ( typeof context === "string" ) {
547 // Quick check to determine if target is callable, in the spec
548 // this throws a TypeError, but we will just return undefined.
549 if ( !jQuery.isFunction( fn ) ) {
554 args = slice.call( arguments, 2 );
556 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
559 // Set the guid of unique handler to the same of original handler, so it can be removed
560 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
566 return +( new Date() );
569 // jQuery.support is not used in Core but other projects attach their
570 // properties to it so it needs to exist.
574 // Populate the class2type map
575 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
576 class2type[ "[object " + name + "]" ] = name.toLowerCase();
579 function isArraylike( obj ) {
580 var length = obj.length,
581 type = jQuery.type( obj );
583 if ( type === "function" || jQuery.isWindow( obj ) ) {
587 if ( obj.nodeType === 1 && length ) {
591 return type === "array" || length === 0 ||
592 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
596 * Sizzle CSS Selector Engine v1.10.16
597 * http://sizzlejs.com/
599 * Copyright 2013 jQuery Foundation, Inc. and other contributors
600 * Released under the MIT license
601 * http://jquery.org/license
605 (function( window ) {
617 // Local document vars
627 // Instance-specific data
628 expando = "sizzle" + -(new Date()),
629 preferredDoc = window.document,
632 classCache = createCache(),
633 tokenCache = createCache(),
634 compilerCache = createCache(),
635 sortOrder = function( a, b ) {
642 // General-purpose constants
643 strundefined = typeof undefined,
644 MAX_NEGATIVE = 1 << 31,
647 hasOwn = ({}).hasOwnProperty,
650 push_native = arr.push,
653 // Use a stripped-down indexOf if we can't use a native one
654 indexOf = arr.indexOf || function( elem ) {
657 for ( ; i < len; i++ ) {
658 if ( this[i] === elem ) {
665 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
667 // Regular expressions
669 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
670 whitespace = "[\\x20\\t\\r\\n\\f]",
671 // http://www.w3.org/TR/css3-syntax/#characters
672 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
674 // Loosely modeled on CSS identifier characters
675 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
676 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
677 identifier = characterEncoding.replace( "w", "w#" ),
679 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
680 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
681 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
683 // Prefer arguments quoted,
684 // then not containing pseudos/brackets,
685 // then attribute selectors/non-parenthetical expressions,
686 // then anything else
687 // These preferences are here to reduce the number of selectors
688 // needing tokenize in the PSEUDO preFilter
689 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
691 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
692 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
694 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
695 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
697 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
699 rpseudo = new RegExp( pseudos ),
700 ridentifier = new RegExp( "^" + identifier + "$" ),
703 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
704 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
705 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
706 "ATTR": new RegExp( "^" + attributes ),
707 "PSEUDO": new RegExp( "^" + pseudos ),
708 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
709 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
710 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
711 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
712 // For use in libraries implementing .is()
713 // We use this for POS matching in `select`
714 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
715 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
718 rinputs = /^(?:input|select|textarea|button)$/i,
721 rnative = /^[^{]+\{\s*\[native \w/,
723 // Easily-parseable/retrievable ID or TAG or CLASS selectors
724 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
729 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
730 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
731 funescape = function( _, escaped, escapedWhitespace ) {
732 var high = "0x" + escaped - 0x10000;
733 // NaN means non-codepoint
735 // Workaround erroneous numeric interpretation of +"0x"
736 return high !== high || escapedWhitespace ?
740 String.fromCharCode( high + 0x10000 ) :
741 // Supplemental Plane codepoint (surrogate pair)
742 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
745 // Optimize for push.apply( _, NodeList )
748 (arr = slice.call( preferredDoc.childNodes )),
749 preferredDoc.childNodes
751 // Support: Android<4.0
752 // Detect silently failing push.apply
753 arr[ preferredDoc.childNodes.length ].nodeType;
755 push = { apply: arr.length ?
757 // Leverage slice if possible
758 function( target, els ) {
759 push_native.apply( target, slice.call(els) );
763 // Otherwise append directly
764 function( target, els ) {
765 var j = target.length,
767 // Can't trust NodeList.length
768 while ( (target[j++] = els[i++]) ) {}
769 target.length = j - 1;
774 function Sizzle( selector, context, results, seed ) {
775 var match, elem, m, nodeType,
777 i, groups, old, nid, newContext, newSelector;
779 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
780 setDocument( context );
783 context = context || document;
784 results = results || [];
786 if ( !selector || typeof selector !== "string" ) {
790 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
794 if ( documentIsHTML && !seed ) {
797 if ( (match = rquickExpr.exec( selector )) ) {
798 // Speed-up: Sizzle("#ID")
799 if ( (m = match[1]) ) {
800 if ( nodeType === 9 ) {
801 elem = context.getElementById( m );
802 // Check parentNode to catch when Blackberry 4.6 returns
803 // nodes that are no longer in the document (jQuery #6963)
804 if ( elem && elem.parentNode ) {
805 // Handle the case where IE, Opera, and Webkit return items
806 // by name instead of ID
807 if ( elem.id === m ) {
808 results.push( elem );
815 // Context is not a document
816 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
817 contains( context, elem ) && elem.id === m ) {
818 results.push( elem );
823 // Speed-up: Sizzle("TAG")
824 } else if ( match[2] ) {
825 push.apply( results, context.getElementsByTagName( selector ) );
828 // Speed-up: Sizzle(".CLASS")
829 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
830 push.apply( results, context.getElementsByClassName( m ) );
836 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
838 newContext = context;
839 newSelector = nodeType === 9 && selector;
841 // qSA works strangely on Element-rooted queries
842 // We can work around this by specifying an extra ID on the root
843 // and working up from there (Thanks to Andrew Dupont for the technique)
844 // IE 8 doesn't work on object elements
845 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
846 groups = tokenize( selector );
848 if ( (old = context.getAttribute("id")) ) {
849 nid = old.replace( rescape, "\\$&" );
851 context.setAttribute( "id", nid );
853 nid = "[id='" + nid + "'] ";
857 groups[i] = nid + toSelector( groups[i] );
859 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
860 newSelector = groups.join(",");
866 newContext.querySelectorAll( newSelector )
872 context.removeAttribute("id");
880 return select( selector.replace( rtrim, "$1" ), context, results, seed );
884 * Create key-value caches of limited size
885 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
886 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
887 * deleting the oldest entry
889 function createCache() {
892 function cache( key, value ) {
893 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
894 if ( keys.push( key + " " ) > Expr.cacheLength ) {
895 // Only keep the most recent entries
896 delete cache[ keys.shift() ];
898 return (cache[ key + " " ] = value);
904 * Mark a function for special use by Sizzle
905 * @param {Function} fn The function to mark
907 function markFunction( fn ) {
908 fn[ expando ] = true;
913 * Support testing using an element
914 * @param {Function} fn Passed the created div and expects a boolean result
916 function assert( fn ) {
917 var div = document.createElement("div");
924 // Remove from its parent by default
925 if ( div.parentNode ) {
926 div.parentNode.removeChild( div );
928 // release memory in IE
934 * Adds the same handler for all of the specified attrs
935 * @param {String} attrs Pipe-separated list of attributes
936 * @param {Function} handler The method that will be applied
938 function addHandle( attrs, handler ) {
939 var arr = attrs.split("|"),
943 Expr.attrHandle[ arr[i] ] = handler;
948 * Checks document order of two siblings
951 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
953 function siblingCheck( a, b ) {
955 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
956 ( ~b.sourceIndex || MAX_NEGATIVE ) -
957 ( ~a.sourceIndex || MAX_NEGATIVE );
959 // Use IE sourceIndex if available on both nodes
964 // Check if b follows a
966 while ( (cur = cur.nextSibling) ) {
977 * Returns a function to use in pseudos for input types
978 * @param {String} type
980 function createInputPseudo( type ) {
981 return function( elem ) {
982 var name = elem.nodeName.toLowerCase();
983 return name === "input" && elem.type === type;
988 * Returns a function to use in pseudos for buttons
989 * @param {String} type
991 function createButtonPseudo( type ) {
992 return function( elem ) {
993 var name = elem.nodeName.toLowerCase();
994 return (name === "input" || name === "button") && elem.type === type;
999 * Returns a function to use in pseudos for positionals
1000 * @param {Function} fn
1002 function createPositionalPseudo( fn ) {
1003 return markFunction(function( argument ) {
1004 argument = +argument;
1005 return markFunction(function( seed, matches ) {
1007 matchIndexes = fn( [], seed.length, argument ),
1008 i = matchIndexes.length;
1010 // Match elements found at the specified indexes
1012 if ( seed[ (j = matchIndexes[i]) ] ) {
1013 seed[j] = !(matches[j] = seed[j]);
1021 * Checks a node for validity as a Sizzle context
1022 * @param {Element|Object=} context
1023 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1025 function testContext( context ) {
1026 return context && typeof context.getElementsByTagName !== strundefined && context;
1029 // Expose support vars for convenience
1030 support = Sizzle.support = {};
1034 * @param {Element|Object} elem An element or a document
1035 * @returns {Boolean} True iff elem is a non-HTML XML node
1037 isXML = Sizzle.isXML = function( elem ) {
1038 // documentElement is verified for cases where it doesn't yet exist
1039 // (such as loading iframes in IE - #4833)
1040 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1041 return documentElement ? documentElement.nodeName !== "HTML" : false;
1045 * Sets document-related variables once based on the current document
1046 * @param {Element|Object} [doc] An element or document object to use to set the document
1047 * @returns {Object} Returns the current document
1049 setDocument = Sizzle.setDocument = function( node ) {
1051 doc = node ? node.ownerDocument || node : preferredDoc,
1052 parent = doc.defaultView;
1054 // If no document and documentElement is available, return
1055 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1061 docElem = doc.documentElement;
1064 documentIsHTML = !isXML( doc );
1067 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1068 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1069 // IE6-8 do not support the defaultView property so parent will be undefined
1070 if ( parent && parent !== parent.top ) {
1071 // IE11 does not have attachEvent, so all must suffer
1072 if ( parent.addEventListener ) {
1073 parent.addEventListener( "unload", function() {
1076 } else if ( parent.attachEvent ) {
1077 parent.attachEvent( "onunload", function() {
1084 ---------------------------------------------------------------------- */
1087 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
1088 support.attributes = assert(function( div ) {
1089 div.className = "i";
1090 return !div.getAttribute("className");
1094 ---------------------------------------------------------------------- */
1096 // Check if getElementsByTagName("*") returns only elements
1097 support.getElementsByTagName = assert(function( div ) {
1098 div.appendChild( doc.createComment("") );
1099 return !div.getElementsByTagName("*").length;
1102 // Check if getElementsByClassName can be trusted
1103 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
1104 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
1106 // Support: Safari<4
1107 // Catch class over-caching
1108 div.firstChild.className = "i";
1109 // Support: Opera<10
1110 // Catch gEBCN failure to find non-leading classes
1111 return div.getElementsByClassName("i").length === 2;
1115 // Check if getElementById returns elements by name
1116 // The broken getElementById methods don't pick up programatically-set names,
1117 // so use a roundabout getElementsByName test
1118 support.getById = assert(function( div ) {
1119 docElem.appendChild( div ).id = expando;
1120 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1123 // ID find and filter
1124 if ( support.getById ) {
1125 Expr.find["ID"] = function( id, context ) {
1126 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
1127 var m = context.getElementById( id );
1128 // Check parentNode to catch when Blackberry 4.6 returns
1129 // nodes that are no longer in the document #6963
1130 return m && m.parentNode ? [m] : [];
1133 Expr.filter["ID"] = function( id ) {
1134 var attrId = id.replace( runescape, funescape );
1135 return function( elem ) {
1136 return elem.getAttribute("id") === attrId;
1141 // getElementById is not reliable as a find shortcut
1142 delete Expr.find["ID"];
1144 Expr.filter["ID"] = function( id ) {
1145 var attrId = id.replace( runescape, funescape );
1146 return function( elem ) {
1147 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
1148 return node && node.value === attrId;
1154 Expr.find["TAG"] = support.getElementsByTagName ?
1155 function( tag, context ) {
1156 if ( typeof context.getElementsByTagName !== strundefined ) {
1157 return context.getElementsByTagName( tag );
1160 function( tag, context ) {
1164 results = context.getElementsByTagName( tag );
1166 // Filter out possible comments
1167 if ( tag === "*" ) {
1168 while ( (elem = results[i++]) ) {
1169 if ( elem.nodeType === 1 ) {
1180 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1181 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
1182 return context.getElementsByClassName( className );
1186 /* QSA/matchesSelector
1187 ---------------------------------------------------------------------- */
1189 // QSA and matchesSelector support
1191 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1194 // qSa(:focus) reports false when true (Chrome 21)
1195 // We allow this because of a bug in IE8/9 that throws an error
1196 // whenever `document.activeElement` is accessed on an iframe
1197 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1198 // See http://bugs.jquery.com/ticket/13378
1201 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1203 // Regex strategy adopted from Diego Perini
1204 assert(function( div ) {
1205 // Select is set to empty string on purpose
1206 // This is to test IE's treatment of not explicitly
1207 // setting a boolean content attribute,
1208 // since its presence should be enough
1209 // http://bugs.jquery.com/ticket/12359
1210 div.innerHTML = "<select t=''><option selected=''></option></select>";
1212 // Support: IE8, Opera 10-12
1213 // Nothing should be selected when empty strings follow ^= or $= or *=
1214 if ( div.querySelectorAll("[t^='']").length ) {
1215 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1219 // Boolean attributes and "value" are not treated correctly
1220 if ( !div.querySelectorAll("[selected]").length ) {
1221 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1224 // Webkit/Opera - :checked should return selected option elements
1225 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1226 // IE8 throws error here and will not see later tests
1227 if ( !div.querySelectorAll(":checked").length ) {
1228 rbuggyQSA.push(":checked");
1232 assert(function( div ) {
1233 // Support: Windows 8 Native Apps
1234 // The type and name attributes are restricted during .innerHTML assignment
1235 var input = doc.createElement("input");
1236 input.setAttribute( "type", "hidden" );
1237 div.appendChild( input ).setAttribute( "name", "D" );
1240 // Enforce case-sensitivity of name attribute
1241 if ( div.querySelectorAll("[name=d]").length ) {
1242 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1245 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1246 // IE8 throws error here and will not see later tests
1247 if ( !div.querySelectorAll(":enabled").length ) {
1248 rbuggyQSA.push( ":enabled", ":disabled" );
1251 // Opera 10-11 does not throw on post-comma invalid pseudos
1252 div.querySelectorAll("*,:x");
1253 rbuggyQSA.push(",.*:");
1257 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
1258 docElem.mozMatchesSelector ||
1259 docElem.oMatchesSelector ||
1260 docElem.msMatchesSelector) )) ) {
1262 assert(function( div ) {
1263 // Check to see if it's possible to do matchesSelector
1264 // on a disconnected node (IE 9)
1265 support.disconnectedMatch = matches.call( div, "div" );
1267 // This should fail with an exception
1268 // Gecko does not error, returns false instead
1269 matches.call( div, "[s!='']:x" );
1270 rbuggyMatches.push( "!=", pseudos );
1274 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1275 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1278 ---------------------------------------------------------------------- */
1279 hasCompare = rnative.test( docElem.compareDocumentPosition );
1281 // Element contains another
1282 // Purposefully does not implement inclusive descendent
1283 // As in, an element does not contain itself
1284 contains = hasCompare || rnative.test( docElem.contains ) ?
1286 var adown = a.nodeType === 9 ? a.documentElement : a,
1287 bup = b && b.parentNode;
1288 return a === bup || !!( bup && bup.nodeType === 1 && (
1290 adown.contains( bup ) :
1291 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1296 while ( (b = b.parentNode) ) {
1306 ---------------------------------------------------------------------- */
1308 // Document order sorting
1309 sortOrder = hasCompare ?
1312 // Flag for duplicate removal
1314 hasDuplicate = true;
1318 // Sort on method existence if only one input has compareDocumentPosition
1319 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1324 // Calculate position if both inputs belong to the same document
1325 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1326 a.compareDocumentPosition( b ) :
1328 // Otherwise we know they are disconnected
1331 // Disconnected nodes
1333 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1335 // Choose the first element that is related to our preferred document
1336 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1339 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1343 // Maintain original order
1345 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1349 return compare & 4 ? -1 : 1;
1352 // Exit early if the nodes are identical
1354 hasDuplicate = true;
1365 // Parentless nodes are either documents or disconnected
1366 if ( !aup || !bup ) {
1367 return a === doc ? -1 :
1372 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
1375 // If the nodes are siblings, we can do a quick check
1376 } else if ( aup === bup ) {
1377 return siblingCheck( a, b );
1380 // Otherwise we need full lists of their ancestors for comparison
1382 while ( (cur = cur.parentNode) ) {
1386 while ( (cur = cur.parentNode) ) {
1390 // Walk down the tree looking for a discrepancy
1391 while ( ap[i] === bp[i] ) {
1396 // Do a sibling check if the nodes have a common ancestor
1397 siblingCheck( ap[i], bp[i] ) :
1399 // Otherwise nodes in our document sort first
1400 ap[i] === preferredDoc ? -1 :
1401 bp[i] === preferredDoc ? 1 :
1408 Sizzle.matches = function( expr, elements ) {
1409 return Sizzle( expr, null, null, elements );
1412 Sizzle.matchesSelector = function( elem, expr ) {
1413 // Set document vars if needed
1414 if ( ( elem.ownerDocument || elem ) !== document ) {
1415 setDocument( elem );
1418 // Make sure that attribute selectors are quoted
1419 expr = expr.replace( rattributeQuotes, "='$1']" );
1421 if ( support.matchesSelector && documentIsHTML &&
1422 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1423 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1426 var ret = matches.call( elem, expr );
1428 // IE 9's matchesSelector returns false on disconnected nodes
1429 if ( ret || support.disconnectedMatch ||
1430 // As well, disconnected nodes are said to be in a document
1432 elem.document && elem.document.nodeType !== 11 ) {
1438 return Sizzle( expr, document, null, [elem] ).length > 0;
1441 Sizzle.contains = function( context, elem ) {
1442 // Set document vars if needed
1443 if ( ( context.ownerDocument || context ) !== document ) {
1444 setDocument( context );
1446 return contains( context, elem );
1449 Sizzle.attr = function( elem, name ) {
1450 // Set document vars if needed
1451 if ( ( elem.ownerDocument || elem ) !== document ) {
1452 setDocument( elem );
1455 var fn = Expr.attrHandle[ name.toLowerCase() ],
1456 // Don't get fooled by Object.prototype properties (jQuery #13807)
1457 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1458 fn( elem, name, !documentIsHTML ) :
1461 return val !== undefined ?
1463 support.attributes || !documentIsHTML ?
1464 elem.getAttribute( name ) :
1465 (val = elem.getAttributeNode(name)) && val.specified ?
1470 Sizzle.error = function( msg ) {
1471 throw new Error( "Syntax error, unrecognized expression: " + msg );
1475 * Document sorting and removing duplicates
1476 * @param {ArrayLike} results
1478 Sizzle.uniqueSort = function( results ) {
1484 // Unless we *know* we can detect duplicates, assume their presence
1485 hasDuplicate = !support.detectDuplicates;
1486 sortInput = !support.sortStable && results.slice( 0 );
1487 results.sort( sortOrder );
1489 if ( hasDuplicate ) {
1490 while ( (elem = results[i++]) ) {
1491 if ( elem === results[ i ] ) {
1492 j = duplicates.push( i );
1496 results.splice( duplicates[ j ], 1 );
1500 // Clear input after sorting to release objects
1501 // See https://github.com/jquery/sizzle/pull/225
1508 * Utility function for retrieving the text value of an array of DOM nodes
1509 * @param {Array|Element} elem
1511 getText = Sizzle.getText = function( elem ) {
1515 nodeType = elem.nodeType;
1518 // If no nodeType, this is expected to be an array
1519 while ( (node = elem[i++]) ) {
1520 // Do not traverse comment nodes
1521 ret += getText( node );
1523 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1524 // Use textContent for elements
1525 // innerText usage removed for consistency of new lines (jQuery #11153)
1526 if ( typeof elem.textContent === "string" ) {
1527 return elem.textContent;
1529 // Traverse its children
1530 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1531 ret += getText( elem );
1534 } else if ( nodeType === 3 || nodeType === 4 ) {
1535 return elem.nodeValue;
1537 // Do not include comment or processing instruction nodes
1542 Expr = Sizzle.selectors = {
1544 // Can be adjusted by the user
1547 createPseudo: markFunction,
1556 ">": { dir: "parentNode", first: true },
1557 " ": { dir: "parentNode" },
1558 "+": { dir: "previousSibling", first: true },
1559 "~": { dir: "previousSibling" }
1563 "ATTR": function( match ) {
1564 match[1] = match[1].replace( runescape, funescape );
1566 // Move the given value to match[3] whether quoted or unquoted
1567 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
1569 if ( match[2] === "~=" ) {
1570 match[3] = " " + match[3] + " ";
1573 return match.slice( 0, 4 );
1576 "CHILD": function( match ) {
1577 /* matches from matchExpr["CHILD"]
1578 1 type (only|nth|...)
1579 2 what (child|of-type)
1580 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1581 4 xn-component of xn+y argument ([+-]?\d*n|)
1582 5 sign of xn-component
1584 7 sign of y-component
1587 match[1] = match[1].toLowerCase();
1589 if ( match[1].slice( 0, 3 ) === "nth" ) {
1590 // nth-* requires argument
1592 Sizzle.error( match[0] );
1595 // numeric x and y parameters for Expr.filter.CHILD
1596 // remember that false/true cast respectively to 0/1
1597 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1598 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1600 // other types prohibit arguments
1601 } else if ( match[3] ) {
1602 Sizzle.error( match[0] );
1608 "PSEUDO": function( match ) {
1610 unquoted = !match[5] && match[2];
1612 if ( matchExpr["CHILD"].test( match[0] ) ) {
1616 // Accept quoted arguments as-is
1617 if ( match[3] && match[4] !== undefined ) {
1618 match[2] = match[4];
1620 // Strip excess characters from unquoted arguments
1621 } else if ( unquoted && rpseudo.test( unquoted ) &&
1622 // Get excess from tokenize (recursively)
1623 (excess = tokenize( unquoted, true )) &&
1624 // advance to the next closing parenthesis
1625 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1627 // excess is a negative index
1628 match[0] = match[0].slice( 0, excess );
1629 match[2] = unquoted.slice( 0, excess );
1632 // Return only captures needed by the pseudo filter method (type and argument)
1633 return match.slice( 0, 3 );
1639 "TAG": function( nodeNameSelector ) {
1640 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1641 return nodeNameSelector === "*" ?
1642 function() { return true; } :
1644 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1648 "CLASS": function( className ) {
1649 var pattern = classCache[ className + " " ];
1652 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1653 classCache( className, function( elem ) {
1654 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1658 "ATTR": function( name, operator, check ) {
1659 return function( elem ) {
1660 var result = Sizzle.attr( elem, name );
1662 if ( result == null ) {
1663 return operator === "!=";
1671 return operator === "=" ? result === check :
1672 operator === "!=" ? result !== check :
1673 operator === "^=" ? check && result.indexOf( check ) === 0 :
1674 operator === "*=" ? check && result.indexOf( check ) > -1 :
1675 operator === "$=" ? check && result.slice( -check.length ) === check :
1676 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1677 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1682 "CHILD": function( type, what, argument, first, last ) {
1683 var simple = type.slice( 0, 3 ) !== "nth",
1684 forward = type.slice( -4 ) !== "last",
1685 ofType = what === "of-type";
1687 return first === 1 && last === 0 ?
1689 // Shortcut for :nth-*(n)
1691 return !!elem.parentNode;
1694 function( elem, context, xml ) {
1695 var cache, outerCache, node, diff, nodeIndex, start,
1696 dir = simple !== forward ? "nextSibling" : "previousSibling",
1697 parent = elem.parentNode,
1698 name = ofType && elem.nodeName.toLowerCase(),
1699 useCache = !xml && !ofType;
1703 // :(first|last|only)-(child|of-type)
1707 while ( (node = node[ dir ]) ) {
1708 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1712 // Reverse direction for :only-* (if we haven't yet done so)
1713 start = dir = type === "only" && !start && "nextSibling";
1718 start = [ forward ? parent.firstChild : parent.lastChild ];
1720 // non-xml :nth-child(...) stores cache data on `parent`
1721 if ( forward && useCache ) {
1722 // Seek `elem` from a previously-cached index
1723 outerCache = parent[ expando ] || (parent[ expando ] = {});
1724 cache = outerCache[ type ] || [];
1725 nodeIndex = cache[0] === dirruns && cache[1];
1726 diff = cache[0] === dirruns && cache[2];
1727 node = nodeIndex && parent.childNodes[ nodeIndex ];
1729 while ( (node = ++nodeIndex && node && node[ dir ] ||
1731 // Fallback to seeking `elem` from the start
1732 (diff = nodeIndex = 0) || start.pop()) ) {
1734 // When found, cache indexes on `parent` and break
1735 if ( node.nodeType === 1 && ++diff && node === elem ) {
1736 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1741 // Use previously-cached element index if available
1742 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1745 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1747 // Use the same loop as above to seek `elem` from the start
1748 while ( (node = ++nodeIndex && node && node[ dir ] ||
1749 (diff = nodeIndex = 0) || start.pop()) ) {
1751 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1752 // Cache the index of each encountered element
1754 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1757 if ( node === elem ) {
1764 // Incorporate the offset, then check against cycle size
1766 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1771 "PSEUDO": function( pseudo, argument ) {
1772 // pseudo-class names are case-insensitive
1773 // http://www.w3.org/TR/selectors/#pseudo-classes
1774 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1775 // Remember that setFilters inherits from pseudos
1777 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1778 Sizzle.error( "unsupported pseudo: " + pseudo );
1780 // The user may use createPseudo to indicate that
1781 // arguments are needed to create the filter function
1782 // just as Sizzle does
1783 if ( fn[ expando ] ) {
1784 return fn( argument );
1787 // But maintain support for old signatures
1788 if ( fn.length > 1 ) {
1789 args = [ pseudo, pseudo, "", argument ];
1790 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1791 markFunction(function( seed, matches ) {
1793 matched = fn( seed, argument ),
1796 idx = indexOf.call( seed, matched[i] );
1797 seed[ idx ] = !( matches[ idx ] = matched[i] );
1801 return fn( elem, 0, args );
1810 // Potentially complex pseudos
1811 "not": markFunction(function( selector ) {
1812 // Trim the selector passed to compile
1813 // to avoid treating leading and trailing
1814 // spaces as combinators
1817 matcher = compile( selector.replace( rtrim, "$1" ) );
1819 return matcher[ expando ] ?
1820 markFunction(function( seed, matches, context, xml ) {
1822 unmatched = matcher( seed, null, xml, [] ),
1825 // Match elements unmatched by `matcher`
1827 if ( (elem = unmatched[i]) ) {
1828 seed[i] = !(matches[i] = elem);
1832 function( elem, context, xml ) {
1834 matcher( input, null, xml, results );
1835 return !results.pop();
1839 "has": markFunction(function( selector ) {
1840 return function( elem ) {
1841 return Sizzle( selector, elem ).length > 0;
1845 "contains": markFunction(function( text ) {
1846 return function( elem ) {
1847 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1851 // "Whether an element is represented by a :lang() selector
1852 // is based solely on the element's language value
1853 // being equal to the identifier C,
1854 // or beginning with the identifier C immediately followed by "-".
1855 // The matching of C against the element's language value is performed case-insensitively.
1856 // The identifier C does not have to be a valid language name."
1857 // http://www.w3.org/TR/selectors/#lang-pseudo
1858 "lang": markFunction( function( lang ) {
1859 // lang value must be a valid identifier
1860 if ( !ridentifier.test(lang || "") ) {
1861 Sizzle.error( "unsupported lang: " + lang );
1863 lang = lang.replace( runescape, funescape ).toLowerCase();
1864 return function( elem ) {
1867 if ( (elemLang = documentIsHTML ?
1869 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1871 elemLang = elemLang.toLowerCase();
1872 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1874 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1880 "target": function( elem ) {
1881 var hash = window.location && window.location.hash;
1882 return hash && hash.slice( 1 ) === elem.id;
1885 "root": function( elem ) {
1886 return elem === docElem;
1889 "focus": function( elem ) {
1890 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1893 // Boolean properties
1894 "enabled": function( elem ) {
1895 return elem.disabled === false;
1898 "disabled": function( elem ) {
1899 return elem.disabled === true;
1902 "checked": function( elem ) {
1903 // In CSS3, :checked should return both checked and selected elements
1904 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1905 var nodeName = elem.nodeName.toLowerCase();
1906 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1909 "selected": function( elem ) {
1910 // Accessing this property makes selected-by-default
1911 // options in Safari work properly
1912 if ( elem.parentNode ) {
1913 elem.parentNode.selectedIndex;
1916 return elem.selected === true;
1920 "empty": function( elem ) {
1921 // http://www.w3.org/TR/selectors/#empty-pseudo
1922 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1923 // but not by others (comment: 8; processing instruction: 7; etc.)
1924 // nodeType < 6 works because attributes (2) do not appear as children
1925 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1926 if ( elem.nodeType < 6 ) {
1933 "parent": function( elem ) {
1934 return !Expr.pseudos["empty"]( elem );
1937 // Element/input types
1938 "header": function( elem ) {
1939 return rheader.test( elem.nodeName );
1942 "input": function( elem ) {
1943 return rinputs.test( elem.nodeName );
1946 "button": function( elem ) {
1947 var name = elem.nodeName.toLowerCase();
1948 return name === "input" && elem.type === "button" || name === "button";
1951 "text": function( elem ) {
1953 return elem.nodeName.toLowerCase() === "input" &&
1954 elem.type === "text" &&
1957 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1958 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1961 // Position-in-collection
1962 "first": createPositionalPseudo(function() {
1966 "last": createPositionalPseudo(function( matchIndexes, length ) {
1967 return [ length - 1 ];
1970 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1971 return [ argument < 0 ? argument + length : argument ];
1974 "even": createPositionalPseudo(function( matchIndexes, length ) {
1976 for ( ; i < length; i += 2 ) {
1977 matchIndexes.push( i );
1979 return matchIndexes;
1982 "odd": createPositionalPseudo(function( matchIndexes, length ) {
1984 for ( ; i < length; i += 2 ) {
1985 matchIndexes.push( i );
1987 return matchIndexes;
1990 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1991 var i = argument < 0 ? argument + length : argument;
1992 for ( ; --i >= 0; ) {
1993 matchIndexes.push( i );
1995 return matchIndexes;
1998 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1999 var i = argument < 0 ? argument + length : argument;
2000 for ( ; ++i < length; ) {
2001 matchIndexes.push( i );
2003 return matchIndexes;
2008 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2010 // Add button/input type pseudos
2011 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2012 Expr.pseudos[ i ] = createInputPseudo( i );
2014 for ( i in { submit: true, reset: true } ) {
2015 Expr.pseudos[ i ] = createButtonPseudo( i );
2018 // Easy API for creating new setFilters
2019 function setFilters() {}
2020 setFilters.prototype = Expr.filters = Expr.pseudos;
2021 Expr.setFilters = new setFilters();
2023 function tokenize( selector, parseOnly ) {
2024 var matched, match, tokens, type,
2025 soFar, groups, preFilters,
2026 cached = tokenCache[ selector + " " ];
2029 return parseOnly ? 0 : cached.slice( 0 );
2034 preFilters = Expr.preFilter;
2038 // Comma and first run
2039 if ( !matched || (match = rcomma.exec( soFar )) ) {
2041 // Don't consume trailing commas as valid
2042 soFar = soFar.slice( match[0].length ) || soFar;
2044 groups.push( (tokens = []) );
2050 if ( (match = rcombinators.exec( soFar )) ) {
2051 matched = match.shift();
2054 // Cast descendant combinators to space
2055 type: match[0].replace( rtrim, " " )
2057 soFar = soFar.slice( matched.length );
2061 for ( type in Expr.filter ) {
2062 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2063 (match = preFilters[ type ]( match ))) ) {
2064 matched = match.shift();
2070 soFar = soFar.slice( matched.length );
2079 // Return the length of the invalid excess
2080 // if we're just parsing
2081 // Otherwise, throw an error or return tokens
2085 Sizzle.error( selector ) :
2087 tokenCache( selector, groups ).slice( 0 );
2090 function toSelector( tokens ) {
2092 len = tokens.length,
2094 for ( ; i < len; i++ ) {
2095 selector += tokens[i].value;
2100 function addCombinator( matcher, combinator, base ) {
2101 var dir = combinator.dir,
2102 checkNonElements = base && dir === "parentNode",
2105 return combinator.first ?
2106 // Check against closest ancestor/preceding element
2107 function( elem, context, xml ) {
2108 while ( (elem = elem[ dir ]) ) {
2109 if ( elem.nodeType === 1 || checkNonElements ) {
2110 return matcher( elem, context, xml );
2115 // Check against all ancestor/preceding elements
2116 function( elem, context, xml ) {
2117 var oldCache, outerCache,
2118 newCache = [ dirruns, doneName ];
2120 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2122 while ( (elem = elem[ dir ]) ) {
2123 if ( elem.nodeType === 1 || checkNonElements ) {
2124 if ( matcher( elem, context, xml ) ) {
2130 while ( (elem = elem[ dir ]) ) {
2131 if ( elem.nodeType === 1 || checkNonElements ) {
2132 outerCache = elem[ expando ] || (elem[ expando ] = {});
2133 if ( (oldCache = outerCache[ dir ]) &&
2134 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2136 // Assign to newCache so results back-propagate to previous elements
2137 return (newCache[ 2 ] = oldCache[ 2 ]);
2139 // Reuse newcache so results back-propagate to previous elements
2140 outerCache[ dir ] = newCache;
2142 // A match means we're done; a fail means we have to keep checking
2143 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2153 function elementMatcher( matchers ) {
2154 return matchers.length > 1 ?
2155 function( elem, context, xml ) {
2156 var i = matchers.length;
2158 if ( !matchers[i]( elem, context, xml ) ) {
2167 function condense( unmatched, map, filter, context, xml ) {
2171 len = unmatched.length,
2172 mapped = map != null;
2174 for ( ; i < len; i++ ) {
2175 if ( (elem = unmatched[i]) ) {
2176 if ( !filter || filter( elem, context, xml ) ) {
2177 newUnmatched.push( elem );
2185 return newUnmatched;
2188 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2189 if ( postFilter && !postFilter[ expando ] ) {
2190 postFilter = setMatcher( postFilter );
2192 if ( postFinder && !postFinder[ expando ] ) {
2193 postFinder = setMatcher( postFinder, postSelector );
2195 return markFunction(function( seed, results, context, xml ) {
2199 preexisting = results.length,
2201 // Get initial elements from seed or context
2202 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2204 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2205 matcherIn = preFilter && ( seed || !selector ) ?
2206 condense( elems, preMap, preFilter, context, xml ) :
2209 matcherOut = matcher ?
2210 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2211 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2213 // ...intermediate processing is necessary
2216 // ...otherwise use results directly
2220 // Find primary matches
2222 matcher( matcherIn, matcherOut, context, xml );
2227 temp = condense( matcherOut, postMap );
2228 postFilter( temp, [], context, xml );
2230 // Un-match failing elements by moving them back to matcherIn
2233 if ( (elem = temp[i]) ) {
2234 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2240 if ( postFinder || preFilter ) {
2242 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2244 i = matcherOut.length;
2246 if ( (elem = matcherOut[i]) ) {
2247 // Restore matcherIn since elem is not yet a final match
2248 temp.push( (matcherIn[i] = elem) );
2251 postFinder( null, (matcherOut = []), temp, xml );
2254 // Move matched elements from seed to results to keep them synchronized
2255 i = matcherOut.length;
2257 if ( (elem = matcherOut[i]) &&
2258 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
2260 seed[temp] = !(results[temp] = elem);
2265 // Add elements to results, through postFinder if defined
2267 matcherOut = condense(
2268 matcherOut === results ?
2269 matcherOut.splice( preexisting, matcherOut.length ) :
2273 postFinder( null, results, matcherOut, xml );
2275 push.apply( results, matcherOut );
2281 function matcherFromTokens( tokens ) {
2282 var checkContext, matcher, j,
2283 len = tokens.length,
2284 leadingRelative = Expr.relative[ tokens[0].type ],
2285 implicitRelative = leadingRelative || Expr.relative[" "],
2286 i = leadingRelative ? 1 : 0,
2288 // The foundational matcher ensures that elements are reachable from top-level context(s)
2289 matchContext = addCombinator( function( elem ) {
2290 return elem === checkContext;
2291 }, implicitRelative, true ),
2292 matchAnyContext = addCombinator( function( elem ) {
2293 return indexOf.call( checkContext, elem ) > -1;
2294 }, implicitRelative, true ),
2295 matchers = [ function( elem, context, xml ) {
2296 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2297 (checkContext = context).nodeType ?
2298 matchContext( elem, context, xml ) :
2299 matchAnyContext( elem, context, xml ) );
2302 for ( ; i < len; i++ ) {
2303 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2304 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2306 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2308 // Return special upon seeing a positional matcher
2309 if ( matcher[ expando ] ) {
2310 // Find the next relative operator (if any) for proper handling
2312 for ( ; j < len; j++ ) {
2313 if ( Expr.relative[ tokens[j].type ] ) {
2318 i > 1 && elementMatcher( matchers ),
2319 i > 1 && toSelector(
2320 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2321 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2322 ).replace( rtrim, "$1" ),
2324 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2325 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2326 j < len && toSelector( tokens )
2329 matchers.push( matcher );
2333 return elementMatcher( matchers );
2336 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2337 var bySet = setMatchers.length > 0,
2338 byElement = elementMatchers.length > 0,
2339 superMatcher = function( seed, context, xml, results, outermost ) {
2340 var elem, j, matcher,
2343 unmatched = seed && [],
2345 contextBackup = outermostContext,
2346 // We must always have either seed elements or outermost context
2347 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2348 // Use integer dirruns iff this is the outermost matcher
2349 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2353 outermostContext = context !== document && context;
2356 // Add elements passing elementMatchers directly to results
2357 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2358 // Support: IE<9, Safari
2359 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2360 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2361 if ( byElement && elem ) {
2363 while ( (matcher = elementMatchers[j++]) ) {
2364 if ( matcher( elem, context, xml ) ) {
2365 results.push( elem );
2370 dirruns = dirrunsUnique;
2374 // Track unmatched elements for set filters
2376 // They will have gone through all possible matchers
2377 if ( (elem = !matcher && elem) ) {
2381 // Lengthen the array for every element, matched or not
2383 unmatched.push( elem );
2388 // Apply set filters to unmatched elements
2390 if ( bySet && i !== matchedCount ) {
2392 while ( (matcher = setMatchers[j++]) ) {
2393 matcher( unmatched, setMatched, context, xml );
2397 // Reintegrate element matches to eliminate the need for sorting
2398 if ( matchedCount > 0 ) {
2400 if ( !(unmatched[i] || setMatched[i]) ) {
2401 setMatched[i] = pop.call( results );
2406 // Discard index placeholder values to get only actual matches
2407 setMatched = condense( setMatched );
2410 // Add matches to results
2411 push.apply( results, setMatched );
2413 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2414 if ( outermost && !seed && setMatched.length > 0 &&
2415 ( matchedCount + setMatchers.length ) > 1 ) {
2417 Sizzle.uniqueSort( results );
2421 // Override manipulation of globals by nested matchers
2423 dirruns = dirrunsUnique;
2424 outermostContext = contextBackup;
2431 markFunction( superMatcher ) :
2435 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
2438 elementMatchers = [],
2439 cached = compilerCache[ selector + " " ];
2442 // Generate a function of recursive functions that can be used to check each element
2444 group = tokenize( selector );
2448 cached = matcherFromTokens( group[i] );
2449 if ( cached[ expando ] ) {
2450 setMatchers.push( cached );
2452 elementMatchers.push( cached );
2456 // Cache the compiled function
2457 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2462 function multipleContexts( selector, contexts, results ) {
2464 len = contexts.length;
2465 for ( ; i < len; i++ ) {
2466 Sizzle( selector, contexts[i], results );
2471 function select( selector, context, results, seed ) {
2472 var i, tokens, token, type, find,
2473 match = tokenize( selector );
2476 // Try to minimize operations if there is only one group
2477 if ( match.length === 1 ) {
2479 // Take a shortcut and set the context if the root selector is an ID
2480 tokens = match[0] = match[0].slice( 0 );
2481 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2482 support.getById && context.nodeType === 9 && documentIsHTML &&
2483 Expr.relative[ tokens[1].type ] ) {
2485 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2489 selector = selector.slice( tokens.shift().value.length );
2492 // Fetch a seed set for right-to-left matching
2493 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2497 // Abort if we hit a combinator
2498 if ( Expr.relative[ (type = token.type) ] ) {
2501 if ( (find = Expr.find[ type ]) ) {
2502 // Search, expanding context for leading sibling combinators
2504 token.matches[0].replace( runescape, funescape ),
2505 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2508 // If seed is empty or no tokens remain, we can return early
2509 tokens.splice( i, 1 );
2510 selector = seed.length && toSelector( tokens );
2512 push.apply( results, seed );
2523 // Compile and execute a filtering function
2524 // Provide `match` to avoid retokenization if we modified the selector above
2525 compile( selector, match )(
2530 rsibling.test( selector ) && testContext( context.parentNode ) || context
2535 // One-time assignments
2538 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2540 // Support: Chrome<14
2541 // Always assume duplicates if they aren't passed to the comparison function
2542 support.detectDuplicates = !!hasDuplicate;
2544 // Initialize against the default document
2547 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2548 // Detached nodes confoundingly follow *each other*
2549 support.sortDetached = assert(function( div1 ) {
2550 // Should return 1, but returns 4 (following)
2551 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2555 // Prevent attribute/property "interpolation"
2556 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2557 if ( !assert(function( div ) {
2558 div.innerHTML = "<a href='#'></a>";
2559 return div.firstChild.getAttribute("href") === "#" ;
2561 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2563 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2569 // Use defaultValue in place of getAttribute("value")
2570 if ( !support.attributes || !assert(function( div ) {
2571 div.innerHTML = "<input/>";
2572 div.firstChild.setAttribute( "value", "" );
2573 return div.firstChild.getAttribute( "value" ) === "";
2575 addHandle( "value", function( elem, name, isXML ) {
2576 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2577 return elem.defaultValue;
2583 // Use getAttributeNode to fetch booleans when getAttribute lies
2584 if ( !assert(function( div ) {
2585 return div.getAttribute("disabled") == null;
2587 addHandle( booleans, function( elem, name, isXML ) {
2590 return elem[ name ] === true ? name.toLowerCase() :
2591 (val = elem.getAttributeNode( name )) && val.specified ?
2604 jQuery.find = Sizzle;
2605 jQuery.expr = Sizzle.selectors;
2606 jQuery.expr[":"] = jQuery.expr.pseudos;
2607 jQuery.unique = Sizzle.uniqueSort;
2608 jQuery.text = Sizzle.getText;
2609 jQuery.isXMLDoc = Sizzle.isXML;
2610 jQuery.contains = Sizzle.contains;
2614 var rneedsContext = jQuery.expr.match.needsContext;
2616 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2620 var risSimple = /^.[^:#\[\.,]*$/;
2622 // Implement the identical functionality for filter and not
2623 function winnow( elements, qualifier, not ) {
2624 if ( jQuery.isFunction( qualifier ) ) {
2625 return jQuery.grep( elements, function( elem, i ) {
2627 return !!qualifier.call( elem, i, elem ) !== not;
2632 if ( qualifier.nodeType ) {
2633 return jQuery.grep( elements, function( elem ) {
2634 return ( elem === qualifier ) !== not;
2639 if ( typeof qualifier === "string" ) {
2640 if ( risSimple.test( qualifier ) ) {
2641 return jQuery.filter( qualifier, elements, not );
2644 qualifier = jQuery.filter( qualifier, elements );
2647 return jQuery.grep( elements, function( elem ) {
2648 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2652 jQuery.filter = function( expr, elems, not ) {
2653 var elem = elems[ 0 ];
2656 expr = ":not(" + expr + ")";
2659 return elems.length === 1 && elem.nodeType === 1 ?
2660 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2661 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2662 return elem.nodeType === 1;
2667 find: function( selector ) {
2673 if ( typeof selector !== "string" ) {
2674 return this.pushStack( jQuery( selector ).filter(function() {
2675 for ( i = 0; i < len; i++ ) {
2676 if ( jQuery.contains( self[ i ], this ) ) {
2683 for ( i = 0; i < len; i++ ) {
2684 jQuery.find( selector, self[ i ], ret );
2687 // Needed because $( selector, context ) becomes $( context ).find( selector )
2688 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2689 ret.selector = this.selector ? this.selector + " " + selector : selector;
2692 filter: function( selector ) {
2693 return this.pushStack( winnow(this, selector || [], false) );
2695 not: function( selector ) {
2696 return this.pushStack( winnow(this, selector || [], true) );
2698 is: function( selector ) {
2702 // If this is a positional/relative selector, check membership in the returned set
2703 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2704 typeof selector === "string" && rneedsContext.test( selector ) ?
2705 jQuery( selector ) :
2713 // Initialize a jQuery object
2716 // A central reference to the root jQuery(document)
2719 // Use the correct document accordingly with window argument (sandbox)
2720 document = window.document,
2722 // A simple way to check for HTML strings
2723 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2724 // Strict HTML recognition (#11290: must start with <)
2725 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2727 init = jQuery.fn.init = function( selector, context ) {
2730 // HANDLE: $(""), $(null), $(undefined), $(false)
2735 // Handle HTML strings
2736 if ( typeof selector === "string" ) {
2737 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2738 // Assume that strings that start and end with <> are HTML and skip the regex check
2739 match = [ null, selector, null ];
2742 match = rquickExpr.exec( selector );
2745 // Match html or make sure no context is specified for #id
2746 if ( match && (match[1] || !context) ) {
2748 // HANDLE: $(html) -> $(array)
2750 context = context instanceof jQuery ? context[0] : context;
2752 // scripts is true for back-compat
2753 // Intentionally let the error be thrown if parseHTML is not present
2754 jQuery.merge( this, jQuery.parseHTML(
2756 context && context.nodeType ? context.ownerDocument || context : document,
2760 // HANDLE: $(html, props)
2761 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2762 for ( match in context ) {
2763 // Properties of context are called as methods if possible
2764 if ( jQuery.isFunction( this[ match ] ) ) {
2765 this[ match ]( context[ match ] );
2767 // ...and otherwise set as attributes
2769 this.attr( match, context[ match ] );
2778 elem = document.getElementById( match[2] );
2780 // Check parentNode to catch when Blackberry 4.6 returns
2781 // nodes that are no longer in the document #6963
2782 if ( elem && elem.parentNode ) {
2783 // Handle the case where IE and Opera return items
2784 // by name instead of ID
2785 if ( elem.id !== match[2] ) {
2786 return rootjQuery.find( selector );
2789 // Otherwise, we inject the element directly into the jQuery object
2794 this.context = document;
2795 this.selector = selector;
2799 // HANDLE: $(expr, $(...))
2800 } else if ( !context || context.jquery ) {
2801 return ( context || rootjQuery ).find( selector );
2803 // HANDLE: $(expr, context)
2804 // (which is just equivalent to: $(context).find(expr)
2806 return this.constructor( context ).find( selector );
2809 // HANDLE: $(DOMElement)
2810 } else if ( selector.nodeType ) {
2811 this.context = this[0] = selector;
2815 // HANDLE: $(function)
2816 // Shortcut for document ready
2817 } else if ( jQuery.isFunction( selector ) ) {
2818 return typeof rootjQuery.ready !== "undefined" ?
2819 rootjQuery.ready( selector ) :
2820 // Execute immediately if ready is not present
2824 if ( selector.selector !== undefined ) {
2825 this.selector = selector.selector;
2826 this.context = selector.context;
2829 return jQuery.makeArray( selector, this );
2832 // Give the init function the jQuery prototype for later instantiation
2833 init.prototype = jQuery.fn;
2835 // Initialize central reference
2836 rootjQuery = jQuery( document );
2839 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2840 // methods guaranteed to produce a unique set when starting from a unique set
2841 guaranteedUnique = {
2849 dir: function( elem, dir, until ) {
2853 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
2854 if ( cur.nodeType === 1 ) {
2855 matched.push( cur );
2862 sibling: function( n, elem ) {
2865 for ( ; n; n = n.nextSibling ) {
2866 if ( n.nodeType === 1 && n !== elem ) {
2876 has: function( target ) {
2878 targets = jQuery( target, this ),
2879 len = targets.length;
2881 return this.filter(function() {
2882 for ( i = 0; i < len; i++ ) {
2883 if ( jQuery.contains( this, targets[i] ) ) {
2890 closest: function( selectors, context ) {