Chris@0: /*! Chris@0: * jQuery JavaScript Library v3.2.1 Chris@0: * https://jquery.com/ Chris@0: * Chris@0: * Includes Sizzle.js Chris@0: * https://sizzlejs.com/ Chris@0: * Chris@0: * Copyright JS Foundation and other contributors Chris@0: * Released under the MIT license Chris@0: * https://jquery.org/license Chris@0: * Chris@0: * Date: 2017-03-20T18:59Z Chris@0: */ Chris@0: ( function( global, factory ) { Chris@0: Chris@0: "use strict"; Chris@0: Chris@0: if ( typeof module === "object" && typeof module.exports === "object" ) { Chris@0: Chris@0: // For CommonJS and CommonJS-like environments where a proper `window` Chris@0: // is present, execute the factory and get jQuery. Chris@0: // For environments that do not have a `window` with a `document` Chris@0: // (such as Node.js), expose a factory as module.exports. Chris@0: // This accentuates the need for the creation of a real `window`. Chris@0: // e.g. var jQuery = require("jquery")(window); Chris@0: // See ticket #14549 for more info. Chris@0: module.exports = global.document ? Chris@0: factory( global, true ) : Chris@0: function( w ) { Chris@0: if ( !w.document ) { Chris@0: throw new Error( "jQuery requires a window with a document" ); Chris@0: } Chris@0: return factory( w ); Chris@0: }; Chris@0: } else { Chris@0: factory( global ); Chris@0: } Chris@0: Chris@0: // Pass this if window is not defined yet Chris@0: } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { Chris@0: Chris@0: // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 Chris@0: // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode Chris@0: // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common Chris@0: // enough that all such attempts are guarded in a try block. Chris@0: "use strict"; Chris@0: Chris@0: var arr = []; Chris@0: Chris@0: var document = window.document; Chris@0: Chris@0: var getProto = Object.getPrototypeOf; Chris@0: Chris@0: var slice = arr.slice; Chris@0: Chris@0: var concat = arr.concat; Chris@0: Chris@0: var push = arr.push; Chris@0: Chris@0: var indexOf = arr.indexOf; Chris@0: Chris@0: var class2type = {}; Chris@0: Chris@0: var toString = class2type.toString; Chris@0: Chris@0: var hasOwn = class2type.hasOwnProperty; Chris@0: Chris@0: var fnToString = hasOwn.toString; Chris@0: Chris@0: var ObjectFunctionString = fnToString.call( Object ); Chris@0: Chris@0: var support = {}; Chris@0: Chris@0: Chris@0: Chris@0: function DOMEval( code, doc ) { Chris@0: doc = doc || document; Chris@0: Chris@0: var script = doc.createElement( "script" ); Chris@0: Chris@0: script.text = code; Chris@0: doc.head.appendChild( script ).parentNode.removeChild( script ); Chris@0: } Chris@0: /* global Symbol */ Chris@0: // Defining this global in .eslintrc.json would create a danger of using the global Chris@0: // unguarded in another place, it seems safer to define global only for this module Chris@0: Chris@0: Chris@0: Chris@0: var Chris@0: version = "3.2.1", Chris@0: Chris@0: // Define a local copy of jQuery Chris@0: jQuery = function( selector, context ) { Chris@0: Chris@0: // The jQuery object is actually just the init constructor 'enhanced' Chris@0: // Need init if jQuery is called (just allow error to be thrown if not included) Chris@0: return new jQuery.fn.init( selector, context ); Chris@0: }, Chris@0: Chris@0: // Support: Android <=4.0 only Chris@0: // Make sure we trim BOM and NBSP Chris@0: rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, Chris@0: Chris@0: // Matches dashed string for camelizing Chris@0: rmsPrefix = /^-ms-/, Chris@0: rdashAlpha = /-([a-z])/g, Chris@0: Chris@0: // Used by jQuery.camelCase as callback to replace() Chris@0: fcamelCase = function( all, letter ) { Chris@0: return letter.toUpperCase(); Chris@0: }; Chris@0: Chris@0: jQuery.fn = jQuery.prototype = { Chris@0: Chris@0: // The current version of jQuery being used Chris@0: jquery: version, Chris@0: Chris@0: constructor: jQuery, Chris@0: Chris@0: // The default length of a jQuery object is 0 Chris@0: length: 0, Chris@0: Chris@0: toArray: function() { Chris@0: return slice.call( this ); Chris@0: }, Chris@0: Chris@0: // Get the Nth element in the matched element set OR Chris@0: // Get the whole matched element set as a clean array Chris@0: get: function( num ) { Chris@0: Chris@0: // Return all the elements in a clean array Chris@0: if ( num == null ) { Chris@0: return slice.call( this ); Chris@0: } Chris@0: Chris@0: // Return just the one element from the set Chris@0: return num < 0 ? this[ num + this.length ] : this[ num ]; Chris@0: }, Chris@0: Chris@0: // Take an array of elements and push it onto the stack Chris@0: // (returning the new matched element set) Chris@0: pushStack: function( elems ) { Chris@0: Chris@0: // Build a new jQuery matched element set Chris@0: var ret = jQuery.merge( this.constructor(), elems ); Chris@0: Chris@0: // Add the old object onto the stack (as a reference) Chris@0: ret.prevObject = this; Chris@0: Chris@0: // Return the newly-formed element set Chris@0: return ret; Chris@0: }, Chris@0: Chris@0: // Execute a callback for every element in the matched set. Chris@0: each: function( callback ) { Chris@0: return jQuery.each( this, callback ); Chris@0: }, Chris@0: Chris@0: map: function( callback ) { Chris@0: return this.pushStack( jQuery.map( this, function( elem, i ) { Chris@0: return callback.call( elem, i, elem ); Chris@0: } ) ); Chris@0: }, Chris@0: Chris@0: slice: function() { Chris@0: return this.pushStack( slice.apply( this, arguments ) ); Chris@0: }, Chris@0: Chris@0: first: function() { Chris@0: return this.eq( 0 ); Chris@0: }, Chris@0: Chris@0: last: function() { Chris@0: return this.eq( -1 ); Chris@0: }, Chris@0: Chris@0: eq: function( i ) { Chris@0: var len = this.length, Chris@0: j = +i + ( i < 0 ? len : 0 ); Chris@0: return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); Chris@0: }, Chris@0: Chris@0: end: function() { Chris@0: return this.prevObject || this.constructor(); Chris@0: }, Chris@0: Chris@0: // For internal use only. Chris@0: // Behaves like an Array's method, not like a jQuery method. Chris@0: push: push, Chris@0: sort: arr.sort, Chris@0: splice: arr.splice Chris@0: }; Chris@0: Chris@0: jQuery.extend = jQuery.fn.extend = function() { Chris@0: var options, name, src, copy, copyIsArray, clone, Chris@0: target = arguments[ 0 ] || {}, Chris@0: i = 1, Chris@0: length = arguments.length, Chris@0: deep = false; Chris@0: Chris@0: // Handle a deep copy situation Chris@0: if ( typeof target === "boolean" ) { Chris@0: deep = target; Chris@0: Chris@0: // Skip the boolean and the target Chris@0: target = arguments[ i ] || {}; Chris@0: i++; Chris@0: } Chris@0: Chris@0: // Handle case when target is a string or something (possible in deep copy) Chris@0: if ( typeof target !== "object" && !jQuery.isFunction( target ) ) { Chris@0: target = {}; Chris@0: } Chris@0: Chris@0: // Extend jQuery itself if only one argument is passed Chris@0: if ( i === length ) { Chris@0: target = this; Chris@0: i--; Chris@0: } Chris@0: Chris@0: for ( ; i < length; i++ ) { Chris@0: Chris@0: // Only deal with non-null/undefined values Chris@0: if ( ( options = arguments[ i ] ) != null ) { Chris@0: Chris@0: // Extend the base object Chris@0: for ( name in options ) { Chris@0: src = target[ name ]; Chris@0: copy = options[ name ]; Chris@0: Chris@0: // Prevent never-ending loop Chris@0: if ( target === copy ) { Chris@0: continue; Chris@0: } Chris@0: Chris@0: // Recurse if we're merging plain objects or arrays Chris@0: if ( deep && copy && ( jQuery.isPlainObject( copy ) || Chris@0: ( copyIsArray = Array.isArray( copy ) ) ) ) { Chris@0: Chris@0: if ( copyIsArray ) { Chris@0: copyIsArray = false; Chris@0: clone = src && Array.isArray( src ) ? src : []; Chris@0: Chris@0: } else { Chris@0: clone = src && jQuery.isPlainObject( src ) ? src : {}; Chris@0: } Chris@0: Chris@0: // Never move original objects, clone them Chris@0: target[ name ] = jQuery.extend( deep, clone, copy ); Chris@0: Chris@0: // Don't bring in undefined values Chris@0: } else if ( copy !== undefined ) { Chris@0: target[ name ] = copy; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Return the modified object Chris@0: return target; Chris@0: }; Chris@0: Chris@0: jQuery.extend( { Chris@0: Chris@0: // Unique for each copy of jQuery on the page Chris@0: expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), Chris@0: Chris@0: // Assume jQuery is ready without the ready module Chris@0: isReady: true, Chris@0: Chris@0: error: function( msg ) { Chris@0: throw new Error( msg ); Chris@0: }, Chris@0: Chris@0: noop: function() {}, Chris@0: Chris@0: isFunction: function( obj ) { Chris@0: return jQuery.type( obj ) === "function"; Chris@0: }, Chris@0: Chris@0: isWindow: function( obj ) { Chris@0: return obj != null && obj === obj.window; Chris@0: }, Chris@0: Chris@0: isNumeric: function( obj ) { Chris@0: Chris@0: // As of jQuery 3.0, isNumeric is limited to Chris@0: // strings and numbers (primitives or objects) Chris@0: // that can be coerced to finite numbers (gh-2662) Chris@0: var type = jQuery.type( obj ); Chris@0: return ( type === "number" || type === "string" ) && Chris@0: Chris@0: // parseFloat NaNs numeric-cast false positives ("") Chris@0: // ...but misinterprets leading-number strings, particularly hex literals ("0x...") Chris@0: // subtraction forces infinities to NaN Chris@0: !isNaN( obj - parseFloat( obj ) ); Chris@0: }, Chris@0: Chris@0: isPlainObject: function( obj ) { Chris@0: var proto, Ctor; Chris@0: Chris@0: // Detect obvious negatives Chris@0: // Use toString instead of jQuery.type to catch host objects Chris@0: if ( !obj || toString.call( obj ) !== "[object Object]" ) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: proto = getProto( obj ); Chris@0: Chris@0: // Objects with no prototype (e.g., `Object.create( null )`) are plain Chris@0: if ( !proto ) { Chris@0: return true; Chris@0: } Chris@0: Chris@0: // Objects with prototype are plain iff they were constructed by a global Object function Chris@0: Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; Chris@0: return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; Chris@0: }, Chris@0: Chris@0: isEmptyObject: function( obj ) { Chris@0: Chris@0: /* eslint-disable no-unused-vars */ Chris@0: // See https://github.com/eslint/eslint/issues/6125 Chris@0: var name; Chris@0: Chris@0: for ( name in obj ) { Chris@0: return false; Chris@0: } Chris@0: return true; Chris@0: }, Chris@0: Chris@0: type: function( obj ) { Chris@0: if ( obj == null ) { Chris@0: return obj + ""; Chris@0: } Chris@0: Chris@0: // Support: Android <=2.3 only (functionish RegExp) Chris@0: return typeof obj === "object" || typeof obj === "function" ? Chris@0: class2type[ toString.call( obj ) ] || "object" : Chris@0: typeof obj; Chris@0: }, Chris@0: Chris@0: // Evaluates a script in a global context Chris@0: globalEval: function( code ) { Chris@0: DOMEval( code ); Chris@0: }, Chris@0: Chris@0: // Convert dashed to camelCase; used by the css and data modules Chris@0: // Support: IE <=9 - 11, Edge 12 - 13 Chris@0: // Microsoft forgot to hump their vendor prefix (#9572) Chris@0: camelCase: function( string ) { Chris@0: return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); Chris@0: }, Chris@0: Chris@0: each: function( obj, callback ) { Chris@0: var length, i = 0; Chris@0: Chris@0: if ( isArrayLike( obj ) ) { Chris@0: length = obj.length; Chris@0: for ( ; i < length; i++ ) { Chris@0: if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { Chris@0: break; Chris@0: } Chris@0: } Chris@0: } else { Chris@0: for ( i in obj ) { Chris@0: if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { Chris@0: break; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return obj; Chris@0: }, Chris@0: Chris@0: // Support: Android <=4.0 only Chris@0: trim: function( text ) { Chris@0: return text == null ? Chris@0: "" : Chris@0: ( text + "" ).replace( rtrim, "" ); Chris@0: }, Chris@0: Chris@0: // results is for internal usage only Chris@0: makeArray: function( arr, results ) { Chris@0: var ret = results || []; Chris@0: Chris@0: if ( arr != null ) { Chris@0: if ( isArrayLike( Object( arr ) ) ) { Chris@0: jQuery.merge( ret, Chris@0: typeof arr === "string" ? Chris@0: [ arr ] : arr Chris@0: ); Chris@0: } else { Chris@0: push.call( ret, arr ); Chris@0: } Chris@0: } Chris@0: Chris@0: return ret; Chris@0: }, Chris@0: Chris@0: inArray: function( elem, arr, i ) { Chris@0: return arr == null ? -1 : indexOf.call( arr, elem, i ); Chris@0: }, Chris@0: Chris@0: // Support: Android <=4.0 only, PhantomJS 1 only Chris@0: // push.apply(_, arraylike) throws on ancient WebKit Chris@0: merge: function( first, second ) { Chris@0: var len = +second.length, Chris@0: j = 0, Chris@0: i = first.length; Chris@0: Chris@0: for ( ; j < len; j++ ) { Chris@0: first[ i++ ] = second[ j ]; Chris@0: } Chris@0: Chris@0: first.length = i; Chris@0: Chris@0: return first; Chris@0: }, Chris@0: Chris@0: grep: function( elems, callback, invert ) { Chris@0: var callbackInverse, Chris@0: matches = [], Chris@0: i = 0, Chris@0: length = elems.length, Chris@0: callbackExpect = !invert; Chris@0: Chris@0: // Go through the array, only saving the items Chris@0: // that pass the validator function Chris@0: for ( ; i < length; i++ ) { Chris@0: callbackInverse = !callback( elems[ i ], i ); Chris@0: if ( callbackInverse !== callbackExpect ) { Chris@0: matches.push( elems[ i ] ); Chris@0: } Chris@0: } Chris@0: Chris@0: return matches; Chris@0: }, Chris@0: Chris@0: // arg is for internal usage only Chris@0: map: function( elems, callback, arg ) { Chris@0: var length, value, Chris@0: i = 0, Chris@0: ret = []; Chris@0: Chris@0: // Go through the array, translating each of the items to their new values Chris@0: if ( isArrayLike( elems ) ) { Chris@0: length = elems.length; Chris@0: for ( ; i < length; i++ ) { Chris@0: value = callback( elems[ i ], i, arg ); Chris@0: Chris@0: if ( value != null ) { Chris@0: ret.push( value ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Go through every key on the object, Chris@0: } else { Chris@0: for ( i in elems ) { Chris@0: value = callback( elems[ i ], i, arg ); Chris@0: Chris@0: if ( value != null ) { Chris@0: ret.push( value ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Flatten any nested arrays Chris@0: return concat.apply( [], ret ); Chris@0: }, Chris@0: Chris@0: // A global GUID counter for objects Chris@0: guid: 1, Chris@0: Chris@0: // Bind a function to a context, optionally partially applying any Chris@0: // arguments. Chris@0: proxy: function( fn, context ) { Chris@0: var tmp, args, proxy; Chris@0: Chris@0: if ( typeof context === "string" ) { Chris@0: tmp = fn[ context ]; Chris@0: context = fn; Chris@0: fn = tmp; Chris@0: } Chris@0: Chris@0: // Quick check to determine if target is callable, in the spec Chris@0: // this throws a TypeError, but we will just return undefined. Chris@0: if ( !jQuery.isFunction( fn ) ) { Chris@0: return undefined; Chris@0: } Chris@0: Chris@0: // Simulated bind Chris@0: args = slice.call( arguments, 2 ); Chris@0: proxy = function() { Chris@0: return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); Chris@0: }; Chris@0: Chris@0: // Set the guid of unique handler to the same of original handler, so it can be removed Chris@0: proxy.guid = fn.guid = fn.guid || jQuery.guid++; Chris@0: Chris@0: return proxy; Chris@0: }, Chris@0: Chris@0: now: Date.now, Chris@0: Chris@0: // jQuery.support is not used in Core but other projects attach their Chris@0: // properties to it so it needs to exist. Chris@0: support: support Chris@0: } ); Chris@0: Chris@0: if ( typeof Symbol === "function" ) { Chris@0: jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; Chris@0: } Chris@0: Chris@0: // Populate the class2type map Chris@0: jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), Chris@0: function( i, name ) { Chris@0: class2type[ "[object " + name + "]" ] = name.toLowerCase(); Chris@0: } ); Chris@0: Chris@0: function isArrayLike( obj ) { Chris@0: Chris@0: // Support: real iOS 8.2 only (not reproducible in simulator) Chris@0: // `in` check used to prevent JIT error (gh-2145) Chris@0: // hasOwn isn't used here due to false negatives Chris@0: // regarding Nodelist length in IE Chris@0: var length = !!obj && "length" in obj && obj.length, Chris@0: type = jQuery.type( obj ); Chris@0: Chris@0: if ( type === "function" || jQuery.isWindow( obj ) ) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: return type === "array" || length === 0 || Chris@0: typeof length === "number" && length > 0 && ( length - 1 ) in obj; Chris@0: } Chris@0: var Sizzle = Chris@0: /*! Chris@0: * Sizzle CSS Selector Engine v2.3.3 Chris@0: * https://sizzlejs.com/ Chris@0: * Chris@0: * Copyright jQuery Foundation and other contributors Chris@0: * Released under the MIT license Chris@0: * http://jquery.org/license Chris@0: * Chris@0: * Date: 2016-08-08 Chris@0: */ Chris@0: (function( window ) { Chris@0: Chris@0: var i, Chris@0: support, Chris@0: Expr, Chris@0: getText, Chris@0: isXML, Chris@0: tokenize, Chris@0: compile, Chris@0: select, Chris@0: outermostContext, Chris@0: sortInput, Chris@0: hasDuplicate, Chris@0: Chris@0: // Local document vars Chris@0: setDocument, Chris@0: document, Chris@0: docElem, Chris@0: documentIsHTML, Chris@0: rbuggyQSA, Chris@0: rbuggyMatches, Chris@0: matches, Chris@0: contains, Chris@0: Chris@0: // Instance-specific data Chris@0: expando = "sizzle" + 1 * new Date(), Chris@0: preferredDoc = window.document, Chris@0: dirruns = 0, Chris@0: done = 0, Chris@0: classCache = createCache(), Chris@0: tokenCache = createCache(), Chris@0: compilerCache = createCache(), Chris@0: sortOrder = function( a, b ) { Chris@0: if ( a === b ) { Chris@0: hasDuplicate = true; Chris@0: } Chris@0: return 0; Chris@0: }, Chris@0: Chris@0: // Instance methods Chris@0: hasOwn = ({}).hasOwnProperty, Chris@0: arr = [], Chris@0: pop = arr.pop, Chris@0: push_native = arr.push, Chris@0: push = arr.push, Chris@0: slice = arr.slice, Chris@0: // Use a stripped-down indexOf as it's faster than native Chris@0: // https://jsperf.com/thor-indexof-vs-for/5 Chris@0: indexOf = function( list, elem ) { Chris@0: var i = 0, Chris@0: len = list.length; Chris@0: for ( ; i < len; i++ ) { Chris@0: if ( list[i] === elem ) { Chris@0: return i; Chris@0: } Chris@0: } Chris@0: return -1; Chris@0: }, Chris@0: Chris@0: booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", Chris@0: Chris@0: // Regular expressions Chris@0: Chris@0: // http://www.w3.org/TR/css3-selectors/#whitespace Chris@0: whitespace = "[\\x20\\t\\r\\n\\f]", Chris@0: Chris@0: // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier Chris@0: identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+", Chris@0: Chris@0: // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors Chris@0: attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + Chris@0: // Operator (capture 2) Chris@0: "*([*^$|!~]?=)" + whitespace + Chris@0: // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" Chris@0: "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + Chris@0: "*\\]", Chris@0: Chris@0: pseudos = ":(" + identifier + ")(?:\\((" + Chris@0: // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: Chris@0: // 1. quoted (capture 3; capture 4 or capture 5) Chris@0: "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + Chris@0: // 2. simple (capture 6) Chris@0: "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + Chris@0: // 3. anything else (capture 2) Chris@0: ".*" + Chris@0: ")\\)|)", Chris@0: Chris@0: // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter Chris@0: rwhitespace = new RegExp( whitespace + "+", "g" ), Chris@0: rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), Chris@0: Chris@0: rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), Chris@0: rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), Chris@0: Chris@0: rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), Chris@0: Chris@0: rpseudo = new RegExp( pseudos ), Chris@0: ridentifier = new RegExp( "^" + identifier + "$" ), Chris@0: Chris@0: matchExpr = { Chris@0: "ID": new RegExp( "^#(" + identifier + ")" ), Chris@0: "CLASS": new RegExp( "^\\.(" + identifier + ")" ), Chris@0: "TAG": new RegExp( "^(" + identifier + "|[*])" ), Chris@0: "ATTR": new RegExp( "^" + attributes ), Chris@0: "PSEUDO": new RegExp( "^" + pseudos ), Chris@0: "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + Chris@0: "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + Chris@0: "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), Chris@0: "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), Chris@0: // For use in libraries implementing .is() Chris@0: // We use this for POS matching in `select` Chris@0: "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + Chris@0: whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) Chris@0: }, Chris@0: Chris@0: rinputs = /^(?:input|select|textarea|button)$/i, Chris@0: rheader = /^h\d$/i, Chris@0: Chris@0: rnative = /^[^{]+\{\s*\[native \w/, Chris@0: Chris@0: // Easily-parseable/retrievable ID or TAG or CLASS selectors Chris@0: rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, Chris@0: Chris@0: rsibling = /[+~]/, Chris@0: Chris@0: // CSS escapes Chris@0: // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters Chris@0: runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), Chris@0: funescape = function( _, escaped, escapedWhitespace ) { Chris@0: var high = "0x" + escaped - 0x10000; Chris@0: // NaN means non-codepoint Chris@0: // Support: Firefox<24 Chris@0: // Workaround erroneous numeric interpretation of +"0x" Chris@0: return high !== high || escapedWhitespace ? Chris@0: escaped : Chris@0: high < 0 ? Chris@0: // BMP codepoint Chris@0: String.fromCharCode( high + 0x10000 ) : Chris@0: // Supplemental Plane codepoint (surrogate pair) Chris@0: String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); Chris@0: }, Chris@0: Chris@0: // CSS string/identifier serialization Chris@0: // https://drafts.csswg.org/cssom/#common-serializing-idioms Chris@0: rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, Chris@0: fcssescape = function( ch, asCodePoint ) { Chris@0: if ( asCodePoint ) { Chris@0: Chris@0: // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER Chris@0: if ( ch === "\0" ) { Chris@0: return "\uFFFD"; Chris@0: } Chris@0: Chris@0: // Control characters and (dependent upon position) numbers get escaped as code points Chris@0: return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; Chris@0: } Chris@0: Chris@0: // Other potentially-special ASCII characters get backslash-escaped Chris@0: return "\\" + ch; Chris@0: }, Chris@0: Chris@0: // Used for iframes Chris@0: // See setDocument() Chris@0: // Removing the function wrapper causes a "Permission Denied" Chris@0: // error in IE Chris@0: unloadHandler = function() { Chris@0: setDocument(); Chris@0: }, Chris@0: Chris@0: disabledAncestor = addCombinator( Chris@0: function( elem ) { Chris@0: return elem.disabled === true && ("form" in elem || "label" in elem); Chris@0: }, Chris@0: { dir: "parentNode", next: "legend" } Chris@0: ); Chris@0: Chris@0: // Optimize for push.apply( _, NodeList ) Chris@0: try { Chris@0: push.apply( Chris@0: (arr = slice.call( preferredDoc.childNodes )), Chris@0: preferredDoc.childNodes Chris@0: ); Chris@0: // Support: Android<4.0 Chris@0: // Detect silently failing push.apply Chris@0: arr[ preferredDoc.childNodes.length ].nodeType; Chris@0: } catch ( e ) { Chris@0: push = { apply: arr.length ? Chris@0: Chris@0: // Leverage slice if possible Chris@0: function( target, els ) { Chris@0: push_native.apply( target, slice.call(els) ); Chris@0: } : Chris@0: Chris@0: // Support: IE<9 Chris@0: // Otherwise append directly Chris@0: function( target, els ) { Chris@0: var j = target.length, Chris@0: i = 0; Chris@0: // Can't trust NodeList.length Chris@0: while ( (target[j++] = els[i++]) ) {} Chris@0: target.length = j - 1; Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: function Sizzle( selector, context, results, seed ) { Chris@0: var m, i, elem, nid, match, groups, newSelector, Chris@0: newContext = context && context.ownerDocument, Chris@0: Chris@0: // nodeType defaults to 9, since context defaults to document Chris@0: nodeType = context ? context.nodeType : 9; Chris@0: Chris@0: results = results || []; Chris@0: Chris@0: // Return early from calls with invalid selector or context Chris@0: if ( typeof selector !== "string" || !selector || Chris@0: nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { Chris@0: Chris@0: return results; Chris@0: } Chris@0: Chris@0: // Try to shortcut find operations (as opposed to filters) in HTML documents Chris@0: if ( !seed ) { Chris@0: Chris@0: if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { Chris@0: setDocument( context ); Chris@0: } Chris@0: context = context || document; Chris@0: Chris@0: if ( documentIsHTML ) { Chris@0: Chris@0: // If the selector is sufficiently simple, try using a "get*By*" DOM method Chris@0: // (excepting DocumentFragment context, where the methods don't exist) Chris@0: if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { Chris@0: Chris@0: // ID selector Chris@0: if ( (m = match[1]) ) { Chris@0: Chris@0: // Document context Chris@0: if ( nodeType === 9 ) { Chris@0: if ( (elem = context.getElementById( m )) ) { Chris@0: Chris@0: // Support: IE, Opera, Webkit Chris@0: // TODO: identify versions Chris@0: // getElementById can match elements by name instead of ID Chris@0: if ( elem.id === m ) { Chris@0: results.push( elem ); Chris@0: return results; Chris@0: } Chris@0: } else { Chris@0: return results; Chris@0: } Chris@0: Chris@0: // Element context Chris@0: } else { Chris@0: Chris@0: // Support: IE, Opera, Webkit Chris@0: // TODO: identify versions Chris@0: // getElementById can match elements by name instead of ID Chris@0: if ( newContext && (elem = newContext.getElementById( m )) && Chris@0: contains( context, elem ) && Chris@0: elem.id === m ) { Chris@0: Chris@0: results.push( elem ); Chris@0: return results; Chris@0: } Chris@0: } Chris@0: Chris@0: // Type selector Chris@0: } else if ( match[2] ) { Chris@0: push.apply( results, context.getElementsByTagName( selector ) ); Chris@0: return results; Chris@0: Chris@0: // Class selector Chris@0: } else if ( (m = match[3]) && support.getElementsByClassName && Chris@0: context.getElementsByClassName ) { Chris@0: Chris@0: push.apply( results, context.getElementsByClassName( m ) ); Chris@0: return results; Chris@0: } Chris@0: } Chris@0: Chris@0: // Take advantage of querySelectorAll Chris@0: if ( support.qsa && Chris@0: !compilerCache[ selector + " " ] && Chris@0: (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { Chris@0: Chris@0: if ( nodeType !== 1 ) { Chris@0: newContext = context; Chris@0: newSelector = selector; Chris@0: Chris@0: // qSA looks outside Element context, which is not what we want Chris@0: // Thanks to Andrew Dupont for this workaround technique Chris@0: // Support: IE <=8 Chris@0: // Exclude object elements Chris@0: } else if ( context.nodeName.toLowerCase() !== "object" ) { Chris@0: Chris@0: // Capture the context ID, setting it first if necessary Chris@0: if ( (nid = context.getAttribute( "id" )) ) { Chris@0: nid = nid.replace( rcssescape, fcssescape ); Chris@0: } else { Chris@0: context.setAttribute( "id", (nid = expando) ); Chris@0: } Chris@0: Chris@0: // Prefix every selector in the list Chris@0: groups = tokenize( selector ); Chris@0: i = groups.length; Chris@0: while ( i-- ) { Chris@0: groups[i] = "#" + nid + " " + toSelector( groups[i] ); Chris@0: } Chris@0: newSelector = groups.join( "," ); Chris@0: Chris@0: // Expand context for sibling selectors Chris@0: newContext = rsibling.test( selector ) && testContext( context.parentNode ) || Chris@0: context; Chris@0: } Chris@0: Chris@0: if ( newSelector ) { Chris@0: try { Chris@0: push.apply( results, Chris@0: newContext.querySelectorAll( newSelector ) Chris@0: ); Chris@0: return results; Chris@0: } catch ( qsaError ) { Chris@0: } finally { Chris@0: if ( nid === expando ) { Chris@0: context.removeAttribute( "id" ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // All others Chris@0: return select( selector.replace( rtrim, "$1" ), context, results, seed ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Create key-value caches of limited size Chris@0: * @returns {function(string, object)} Returns the Object data after storing it on itself with Chris@0: * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) Chris@0: * deleting the oldest entry Chris@0: */ Chris@0: function createCache() { Chris@0: var keys = []; Chris@0: Chris@0: function cache( key, value ) { Chris@0: // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) Chris@0: if ( keys.push( key + " " ) > Expr.cacheLength ) { Chris@0: // Only keep the most recent entries Chris@0: delete cache[ keys.shift() ]; Chris@0: } Chris@0: return (cache[ key + " " ] = value); Chris@0: } Chris@0: return cache; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Mark a function for special use by Sizzle Chris@0: * @param {Function} fn The function to mark Chris@0: */ Chris@0: function markFunction( fn ) { Chris@0: fn[ expando ] = true; Chris@0: return fn; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Support testing using an element Chris@0: * @param {Function} fn Passed the created element and returns a boolean result Chris@0: */ Chris@0: function assert( fn ) { Chris@0: var el = document.createElement("fieldset"); Chris@0: Chris@0: try { Chris@0: return !!fn( el ); Chris@0: } catch (e) { Chris@0: return false; Chris@0: } finally { Chris@0: // Remove from its parent by default Chris@0: if ( el.parentNode ) { Chris@0: el.parentNode.removeChild( el ); Chris@0: } Chris@0: // release memory in IE Chris@0: el = null; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Adds the same handler for all of the specified attrs Chris@0: * @param {String} attrs Pipe-separated list of attributes Chris@0: * @param {Function} handler The method that will be applied Chris@0: */ Chris@0: function addHandle( attrs, handler ) { Chris@0: var arr = attrs.split("|"), Chris@0: i = arr.length; Chris@0: Chris@0: while ( i-- ) { Chris@0: Expr.attrHandle[ arr[i] ] = handler; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Checks document order of two siblings Chris@0: * @param {Element} a Chris@0: * @param {Element} b Chris@0: * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b Chris@0: */ Chris@0: function siblingCheck( a, b ) { Chris@0: var cur = b && a, Chris@0: diff = cur && a.nodeType === 1 && b.nodeType === 1 && Chris@0: a.sourceIndex - b.sourceIndex; Chris@0: Chris@0: // Use IE sourceIndex if available on both nodes Chris@0: if ( diff ) { Chris@0: return diff; Chris@0: } Chris@0: Chris@0: // Check if b follows a Chris@0: if ( cur ) { Chris@0: while ( (cur = cur.nextSibling) ) { Chris@0: if ( cur === b ) { Chris@0: return -1; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return a ? 1 : -1; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns a function to use in pseudos for input types Chris@0: * @param {String} type Chris@0: */ Chris@0: function createInputPseudo( type ) { Chris@0: return function( elem ) { Chris@0: var name = elem.nodeName.toLowerCase(); Chris@0: return name === "input" && elem.type === type; Chris@0: }; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns a function to use in pseudos for buttons Chris@0: * @param {String} type Chris@0: */ Chris@0: function createButtonPseudo( type ) { Chris@0: return function( elem ) { Chris@0: var name = elem.nodeName.toLowerCase(); Chris@0: return (name === "input" || name === "button") && elem.type === type; Chris@0: }; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns a function to use in pseudos for :enabled/:disabled Chris@0: * @param {Boolean} disabled true for :disabled; false for :enabled Chris@0: */ Chris@0: function createDisabledPseudo( disabled ) { Chris@0: Chris@0: // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable Chris@0: return function( elem ) { Chris@0: Chris@0: // Only certain elements can match :enabled or :disabled Chris@0: // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled Chris@0: // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled Chris@0: if ( "form" in elem ) { Chris@0: Chris@0: // Check for inherited disabledness on relevant non-disabled elements: Chris@0: // * listed form-associated elements in a disabled fieldset Chris@0: // https://html.spec.whatwg.org/multipage/forms.html#category-listed Chris@0: // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled Chris@0: // * option elements in a disabled optgroup Chris@0: // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled Chris@0: // All such elements have a "form" property. Chris@0: if ( elem.parentNode && elem.disabled === false ) { Chris@0: Chris@0: // Option elements defer to a parent optgroup if present Chris@0: if ( "label" in elem ) { Chris@0: if ( "label" in elem.parentNode ) { Chris@0: return elem.parentNode.disabled === disabled; Chris@0: } else { Chris@0: return elem.disabled === disabled; Chris@0: } Chris@0: } Chris@0: Chris@0: // Support: IE 6 - 11 Chris@0: // Use the isDisabled shortcut property to check for disabled fieldset ancestors Chris@0: return elem.isDisabled === disabled || Chris@0: Chris@0: // Where there is no isDisabled, check manually Chris@0: /* jshint -W018 */ Chris@0: elem.isDisabled !== !disabled && Chris@0: disabledAncestor( elem ) === disabled; Chris@0: } Chris@0: Chris@0: return elem.disabled === disabled; Chris@0: Chris@0: // Try to winnow out elements that can't be disabled before trusting the disabled property. Chris@0: // Some victims get caught in our net (label, legend, menu, track), but it shouldn't Chris@0: // even exist on them, let alone have a boolean value. Chris@0: } else if ( "label" in elem ) { Chris@0: return elem.disabled === disabled; Chris@0: } Chris@0: Chris@0: // Remaining elements are neither :enabled nor :disabled Chris@0: return false; Chris@0: }; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns a function to use in pseudos for positionals Chris@0: * @param {Function} fn Chris@0: */ Chris@0: function createPositionalPseudo( fn ) { Chris@0: return markFunction(function( argument ) { Chris@0: argument = +argument; Chris@0: return markFunction(function( seed, matches ) { Chris@0: var j, Chris@0: matchIndexes = fn( [], seed.length, argument ), Chris@0: i = matchIndexes.length; Chris@0: Chris@0: // Match elements found at the specified indexes Chris@0: while ( i-- ) { Chris@0: if ( seed[ (j = matchIndexes[i]) ] ) { Chris@0: seed[j] = !(matches[j] = seed[j]); Chris@0: } Chris@0: } Chris@0: }); Chris@0: }); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Checks a node for validity as a Sizzle context Chris@0: * @param {Element|Object=} context Chris@0: * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value Chris@0: */ Chris@0: function testContext( context ) { Chris@0: return context && typeof context.getElementsByTagName !== "undefined" && context; Chris@0: } Chris@0: Chris@0: // Expose support vars for convenience Chris@0: support = Sizzle.support = {}; Chris@0: Chris@0: /** Chris@0: * Detects XML nodes Chris@0: * @param {Element|Object} elem An element or a document Chris@0: * @returns {Boolean} True iff elem is a non-HTML XML node Chris@0: */ Chris@0: isXML = Sizzle.isXML = function( elem ) { Chris@0: // documentElement is verified for cases where it doesn't yet exist Chris@0: // (such as loading iframes in IE - #4833) Chris@0: var documentElement = elem && (elem.ownerDocument || elem).documentElement; Chris@0: return documentElement ? documentElement.nodeName !== "HTML" : false; Chris@0: }; Chris@0: Chris@0: /** Chris@0: * Sets document-related variables once based on the current document Chris@0: * @param {Element|Object} [doc] An element or document object to use to set the document Chris@0: * @returns {Object} Returns the current document Chris@0: */ Chris@0: setDocument = Sizzle.setDocument = function( node ) { Chris@0: var hasCompare, subWindow, Chris@0: doc = node ? node.ownerDocument || node : preferredDoc; Chris@0: Chris@0: // Return early if doc is invalid or already selected Chris@0: if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { Chris@0: return document; Chris@0: } Chris@0: Chris@0: // Update global variables Chris@0: document = doc; Chris@0: docElem = document.documentElement; Chris@0: documentIsHTML = !isXML( document ); Chris@0: Chris@0: // Support: IE 9-11, Edge Chris@0: // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) Chris@0: if ( preferredDoc !== document && Chris@0: (subWindow = document.defaultView) && subWindow.top !== subWindow ) { Chris@0: Chris@0: // Support: IE 11, Edge Chris@0: if ( subWindow.addEventListener ) { Chris@0: subWindow.addEventListener( "unload", unloadHandler, false ); Chris@0: Chris@0: // Support: IE 9 - 10 only Chris@0: } else if ( subWindow.attachEvent ) { Chris@0: subWindow.attachEvent( "onunload", unloadHandler ); Chris@0: } Chris@0: } Chris@0: Chris@0: /* Attributes Chris@0: ---------------------------------------------------------------------- */ Chris@0: Chris@0: // Support: IE<8 Chris@0: // Verify that getAttribute really returns attributes and not properties Chris@0: // (excepting IE8 booleans) Chris@0: support.attributes = assert(function( el ) { Chris@0: el.className = "i"; Chris@0: return !el.getAttribute("className"); Chris@0: }); Chris@0: Chris@0: /* getElement(s)By* Chris@0: ---------------------------------------------------------------------- */ Chris@0: Chris@0: // Check if getElementsByTagName("*") returns only elements Chris@0: support.getElementsByTagName = assert(function( el ) { Chris@0: el.appendChild( document.createComment("") ); Chris@0: return !el.getElementsByTagName("*").length; Chris@0: }); Chris@0: Chris@0: // Support: IE<9 Chris@0: support.getElementsByClassName = rnative.test( document.getElementsByClassName ); Chris@0: Chris@0: // Support: IE<10 Chris@0: // Check if getElementById returns elements by name Chris@0: // The broken getElementById methods don't pick up programmatically-set names, Chris@0: // so use a roundabout getElementsByName test Chris@0: support.getById = assert(function( el ) { Chris@0: docElem.appendChild( el ).id = expando; Chris@0: return !document.getElementsByName || !document.getElementsByName( expando ).length; Chris@0: }); Chris@0: Chris@0: // ID filter and find Chris@0: if ( support.getById ) { Chris@0: Expr.filter["ID"] = function( id ) { Chris@0: var attrId = id.replace( runescape, funescape ); Chris@0: return function( elem ) { Chris@0: return elem.getAttribute("id") === attrId; Chris@0: }; Chris@0: }; Chris@0: Expr.find["ID"] = function( id, context ) { Chris@0: if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { Chris@0: var elem = context.getElementById( id ); Chris@0: return elem ? [ elem ] : []; Chris@0: } Chris@0: }; Chris@0: } else { Chris@0: Expr.filter["ID"] = function( id ) { Chris@0: var attrId = id.replace( runescape, funescape ); Chris@0: return function( elem ) { Chris@0: var node = typeof elem.getAttributeNode !== "undefined" && Chris@0: elem.getAttributeNode("id"); Chris@0: return node && node.value === attrId; Chris@0: }; Chris@0: }; Chris@0: Chris@0: // Support: IE 6 - 7 only Chris@0: // getElementById is not reliable as a find shortcut Chris@0: Expr.find["ID"] = function( id, context ) { Chris@0: if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { Chris@0: var node, i, elems, Chris@0: elem = context.getElementById( id ); Chris@0: Chris@0: if ( elem ) { Chris@0: Chris@0: // Verify the id attribute Chris@0: node = elem.getAttributeNode("id"); Chris@0: if ( node && node.value === id ) { Chris@0: return [ elem ]; Chris@0: } Chris@0: Chris@0: // Fall back on getElementsByName Chris@0: elems = context.getElementsByName( id ); Chris@0: i = 0; Chris@0: while ( (elem = elems[i++]) ) { Chris@0: node = elem.getAttributeNode("id"); Chris@0: if ( node && node.value === id ) { Chris@0: return [ elem ]; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return []; Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: // Tag Chris@0: Expr.find["TAG"] = support.getElementsByTagName ? Chris@0: function( tag, context ) { Chris@0: if ( typeof context.getElementsByTagName !== "undefined" ) { Chris@0: return context.getElementsByTagName( tag ); Chris@0: Chris@0: // DocumentFragment nodes don't have gEBTN Chris@0: } else if ( support.qsa ) { Chris@0: return context.querySelectorAll( tag ); Chris@0: } Chris@0: } : Chris@0: Chris@0: function( tag, context ) { Chris@0: var elem, Chris@0: tmp = [], Chris@0: i = 0, Chris@0: // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too Chris@0: results = context.getElementsByTagName( tag ); Chris@0: Chris@0: // Filter out possible comments Chris@0: if ( tag === "*" ) { Chris@0: while ( (elem = results[i++]) ) { Chris@0: if ( elem.nodeType === 1 ) { Chris@0: tmp.push( elem ); Chris@0: } Chris@0: } Chris@0: Chris@0: return tmp; Chris@0: } Chris@0: return results; Chris@0: }; Chris@0: Chris@0: // Class Chris@0: Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { Chris@0: if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { Chris@0: return context.getElementsByClassName( className ); Chris@0: } Chris@0: }; Chris@0: Chris@0: /* QSA/matchesSelector Chris@0: ---------------------------------------------------------------------- */ Chris@0: Chris@0: // QSA and matchesSelector support Chris@0: Chris@0: // matchesSelector(:active) reports false when true (IE9/Opera 11.5) Chris@0: rbuggyMatches = []; Chris@0: Chris@0: // qSa(:focus) reports false when true (Chrome 21) Chris@0: // We allow this because of a bug in IE8/9 that throws an error Chris@0: // whenever `document.activeElement` is accessed on an iframe Chris@0: // So, we allow :focus to pass through QSA all the time to avoid the IE error Chris@0: // See https://bugs.jquery.com/ticket/13378 Chris@0: rbuggyQSA = []; Chris@0: Chris@0: if ( (support.qsa = rnative.test( document.querySelectorAll )) ) { Chris@0: // Build QSA regex Chris@0: // Regex strategy adopted from Diego Perini Chris@0: assert(function( el ) { Chris@0: // Select is set to empty string on purpose Chris@0: // This is to test IE's treatment of not explicitly Chris@0: // setting a boolean content attribute, Chris@0: // since its presence should be enough Chris@0: // https://bugs.jquery.com/ticket/12359 Chris@0: docElem.appendChild( el ).innerHTML = "" + Chris@0: ""; Chris@0: Chris@0: // Support: IE8, Opera 11-12.16 Chris@0: // Nothing should be selected when empty strings follow ^= or $= or *= Chris@0: // The test attribute must be unknown in Opera but "safe" for WinRT Chris@0: // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section Chris@0: if ( el.querySelectorAll("[msallowcapture^='']").length ) { Chris@0: rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); Chris@0: } Chris@0: Chris@0: // Support: IE8 Chris@0: // Boolean attributes and "value" are not treated correctly Chris@0: if ( !el.querySelectorAll("[selected]").length ) { Chris@0: rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); Chris@0: } Chris@0: Chris@0: // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ Chris@0: if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { Chris@0: rbuggyQSA.push("~="); Chris@0: } Chris@0: Chris@0: // Webkit/Opera - :checked should return selected option elements Chris@0: // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked Chris@0: // IE8 throws error here and will not see later tests Chris@0: if ( !el.querySelectorAll(":checked").length ) { Chris@0: rbuggyQSA.push(":checked"); Chris@0: } Chris@0: Chris@0: // Support: Safari 8+, iOS 8+ Chris@0: // https://bugs.webkit.org/show_bug.cgi?id=136851 Chris@0: // In-page `selector#id sibling-combinator selector` fails Chris@0: if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { Chris@0: rbuggyQSA.push(".#.+[+~]"); Chris@0: } Chris@0: }); Chris@0: Chris@0: assert(function( el ) { Chris@0: el.innerHTML = "" + Chris@0: ""; Chris@0: Chris@0: // Support: Windows 8 Native Apps Chris@0: // The type and name attributes are restricted during .innerHTML assignment Chris@0: var input = document.createElement("input"); Chris@0: input.setAttribute( "type", "hidden" ); Chris@0: el.appendChild( input ).setAttribute( "name", "D" ); Chris@0: Chris@0: // Support: IE8 Chris@0: // Enforce case-sensitivity of name attribute Chris@0: if ( el.querySelectorAll("[name=d]").length ) { Chris@0: rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); Chris@0: } Chris@0: Chris@0: // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) Chris@0: // IE8 throws error here and will not see later tests Chris@0: if ( el.querySelectorAll(":enabled").length !== 2 ) { Chris@0: rbuggyQSA.push( ":enabled", ":disabled" ); Chris@0: } Chris@0: Chris@0: // Support: IE9-11+ Chris@0: // IE's :disabled selector does not pick up the children of disabled fieldsets Chris@0: docElem.appendChild( el ).disabled = true; Chris@0: if ( el.querySelectorAll(":disabled").length !== 2 ) { Chris@0: rbuggyQSA.push( ":enabled", ":disabled" ); Chris@0: } Chris@0: Chris@0: // Opera 10-11 does not throw on post-comma invalid pseudos Chris@0: el.querySelectorAll("*,:x"); Chris@0: rbuggyQSA.push(",.*:"); Chris@0: }); Chris@0: } Chris@0: Chris@0: if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || Chris@0: docElem.webkitMatchesSelector || Chris@0: docElem.mozMatchesSelector || Chris@0: docElem.oMatchesSelector || Chris@0: docElem.msMatchesSelector) )) ) { Chris@0: Chris@0: assert(function( el ) { Chris@0: // Check to see if it's possible to do matchesSelector Chris@0: // on a disconnected node (IE 9) Chris@0: support.disconnectedMatch = matches.call( el, "*" ); Chris@0: Chris@0: // This should fail with an exception Chris@0: // Gecko does not error, returns false instead Chris@0: matches.call( el, "[s!='']:x" ); Chris@0: rbuggyMatches.push( "!=", pseudos ); Chris@0: }); Chris@0: } Chris@0: Chris@0: rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); Chris@0: rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); Chris@0: Chris@0: /* Contains Chris@0: ---------------------------------------------------------------------- */ Chris@0: hasCompare = rnative.test( docElem.compareDocumentPosition ); Chris@0: Chris@0: // Element contains another Chris@0: // Purposefully self-exclusive Chris@0: // As in, an element does not contain itself Chris@0: contains = hasCompare || rnative.test( docElem.contains ) ? Chris@0: function( a, b ) { Chris@0: var adown = a.nodeType === 9 ? a.documentElement : a, Chris@0: bup = b && b.parentNode; Chris@0: return a === bup || !!( bup && bup.nodeType === 1 && ( Chris@0: adown.contains ? Chris@0: adown.contains( bup ) : Chris@0: a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 Chris@0: )); Chris@0: } : Chris@0: function( a, b ) { Chris@0: if ( b ) { Chris@0: while ( (b = b.parentNode) ) { Chris@0: if ( b === a ) { Chris@0: return true; Chris@0: } Chris@0: } Chris@0: } Chris@0: return false; Chris@0: }; Chris@0: Chris@0: /* Sorting Chris@0: ---------------------------------------------------------------------- */ Chris@0: Chris@0: // Document order sorting Chris@0: sortOrder = hasCompare ? Chris@0: function( a, b ) { Chris@0: Chris@0: // Flag for duplicate removal Chris@0: if ( a === b ) { Chris@0: hasDuplicate = true; Chris@0: return 0; Chris@0: } Chris@0: Chris@0: // Sort on method existence if only one input has compareDocumentPosition Chris@0: var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; Chris@0: if ( compare ) { Chris@0: return compare; Chris@0: } Chris@0: Chris@0: // Calculate position if both inputs belong to the same document Chris@0: compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? Chris@0: a.compareDocumentPosition( b ) : Chris@0: Chris@0: // Otherwise we know they are disconnected Chris@0: 1; Chris@0: Chris@0: // Disconnected nodes Chris@0: if ( compare & 1 || Chris@0: (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { Chris@0: Chris@0: // Choose the first element that is related to our preferred document Chris@0: if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { Chris@0: return -1; Chris@0: } Chris@0: if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { Chris@0: return 1; Chris@0: } Chris@0: Chris@0: // Maintain original order Chris@0: return sortInput ? Chris@0: ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : Chris@0: 0; Chris@0: } Chris@0: Chris@0: return compare & 4 ? -1 : 1; Chris@0: } : Chris@0: function( a, b ) { Chris@0: // Exit early if the nodes are identical Chris@0: if ( a === b ) { Chris@0: hasDuplicate = true; Chris@0: return 0; Chris@0: } Chris@0: Chris@0: var cur, Chris@0: i = 0, Chris@0: aup = a.parentNode, Chris@0: bup = b.parentNode, Chris@0: ap = [ a ], Chris@0: bp = [ b ]; Chris@0: Chris@0: // Parentless nodes are either documents or disconnected Chris@0: if ( !aup || !bup ) { Chris@0: return a === document ? -1 : Chris@0: b === document ? 1 : Chris@0: aup ? -1 : Chris@0: bup ? 1 : Chris@0: sortInput ? Chris@0: ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : Chris@0: 0; Chris@0: Chris@0: // If the nodes are siblings, we can do a quick check Chris@0: } else if ( aup === bup ) { Chris@0: return siblingCheck( a, b ); Chris@0: } Chris@0: Chris@0: // Otherwise we need full lists of their ancestors for comparison Chris@0: cur = a; Chris@0: while ( (cur = cur.parentNode) ) { Chris@0: ap.unshift( cur ); Chris@0: } Chris@0: cur = b; Chris@0: while ( (cur = cur.parentNode) ) { Chris@0: bp.unshift( cur ); Chris@0: } Chris@0: Chris@0: // Walk down the tree looking for a discrepancy Chris@0: while ( ap[i] === bp[i] ) { Chris@0: i++; Chris@0: } Chris@0: Chris@0: return i ? Chris@0: // Do a sibling check if the nodes have a common ancestor Chris@0: siblingCheck( ap[i], bp[i] ) : Chris@0: Chris@0: // Otherwise nodes in our document sort first Chris@0: ap[i] === preferredDoc ? -1 : Chris@0: bp[i] === preferredDoc ? 1 : Chris@0: 0; Chris@0: }; Chris@0: Chris@0: return document; Chris@0: }; Chris@0: Chris@0: Sizzle.matches = function( expr, elements ) { Chris@0: return Sizzle( expr, null, null, elements ); Chris@0: }; Chris@0: Chris@0: Sizzle.matchesSelector = function( elem, expr ) { Chris@0: // Set document vars if needed Chris@0: if ( ( elem.ownerDocument || elem ) !== document ) { Chris@0: setDocument( elem ); Chris@0: } Chris@0: Chris@0: // Make sure that attribute selectors are quoted Chris@0: expr = expr.replace( rattributeQuotes, "='$1']" ); Chris@0: Chris@0: if ( support.matchesSelector && documentIsHTML && Chris@0: !compilerCache[ expr + " " ] && Chris@0: ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && Chris@0: ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { Chris@0: Chris@0: try { Chris@0: var ret = matches.call( elem, expr ); Chris@0: Chris@0: // IE 9's matchesSelector returns false on disconnected nodes Chris@0: if ( ret || support.disconnectedMatch || Chris@0: // As well, disconnected nodes are said to be in a document Chris@0: // fragment in IE 9 Chris@0: elem.document && elem.document.nodeType !== 11 ) { Chris@0: return ret; Chris@0: } Chris@0: } catch (e) {} Chris@0: } Chris@0: Chris@0: return Sizzle( expr, document, null, [ elem ] ).length > 0; Chris@0: }; Chris@0: Chris@0: Sizzle.contains = function( context, elem ) { Chris@0: // Set document vars if needed Chris@0: if ( ( context.ownerDocument || context ) !== document ) { Chris@0: setDocument( context ); Chris@0: } Chris@0: return contains( context, elem ); Chris@0: }; Chris@0: Chris@0: Sizzle.attr = function( elem, name ) { Chris@0: // Set document vars if needed Chris@0: if ( ( elem.ownerDocument || elem ) !== document ) { Chris@0: setDocument( elem ); Chris@0: } Chris@0: Chris@0: var fn = Expr.attrHandle[ name.toLowerCase() ], Chris@0: // Don't get fooled by Object.prototype properties (jQuery #13807) Chris@0: val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? Chris@0: fn( elem, name, !documentIsHTML ) : Chris@0: undefined; Chris@0: Chris@0: return val !== undefined ? Chris@0: val : Chris@0: support.attributes || !documentIsHTML ? Chris@0: elem.getAttribute( name ) : Chris@0: (val = elem.getAttributeNode(name)) && val.specified ? Chris@0: val.value : Chris@0: null; Chris@0: }; Chris@0: Chris@0: Sizzle.escape = function( sel ) { Chris@0: return (sel + "").replace( rcssescape, fcssescape ); Chris@0: }; Chris@0: Chris@0: Sizzle.error = function( msg ) { Chris@0: throw new Error( "Syntax error, unrecognized expression: " + msg ); Chris@0: }; Chris@0: Chris@0: /** Chris@0: * Document sorting and removing duplicates Chris@0: * @param {ArrayLike} results Chris@0: */ Chris@0: Sizzle.uniqueSort = function( results ) { Chris@0: var elem, Chris@0: duplicates = [], Chris@0: j = 0, Chris@0: i = 0; Chris@0: Chris@0: // Unless we *know* we can detect duplicates, assume their presence Chris@0: hasDuplicate = !support.detectDuplicates; Chris@0: sortInput = !support.sortStable && results.slice( 0 ); Chris@0: results.sort( sortOrder ); Chris@0: Chris@0: if ( hasDuplicate ) { Chris@0: while ( (elem = results[i++]) ) { Chris@0: if ( elem === results[ i ] ) { Chris@0: j = duplicates.push( i ); Chris@0: } Chris@0: } Chris@0: while ( j-- ) { Chris@0: results.splice( duplicates[ j ], 1 ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Clear input after sorting to release objects Chris@0: // See https://github.com/jquery/sizzle/pull/225 Chris@0: sortInput = null; Chris@0: Chris@0: return results; Chris@0: }; Chris@0: Chris@0: /** Chris@0: * Utility function for retrieving the text value of an array of DOM nodes Chris@0: * @param {Array|Element} elem Chris@0: */ Chris@0: getText = Sizzle.getText = function( elem ) { Chris@0: var node, Chris@0: ret = "", Chris@0: i = 0, Chris@0: nodeType = elem.nodeType; Chris@0: Chris@0: if ( !nodeType ) { Chris@0: // If no nodeType, this is expected to be an array Chris@0: while ( (node = elem[i++]) ) { Chris@0: // Do not traverse comment nodes Chris@0: ret += getText( node ); Chris@0: } Chris@0: } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { Chris@0: // Use textContent for elements Chris@0: // innerText usage removed for consistency of new lines (jQuery #11153) Chris@0: if ( typeof elem.textContent === "string" ) { Chris@0: return elem.textContent; Chris@0: } else { Chris@0: // Traverse its children Chris@0: for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { Chris@0: ret += getText( elem ); Chris@0: } Chris@0: } Chris@0: } else if ( nodeType === 3 || nodeType === 4 ) { Chris@0: return elem.nodeValue; Chris@0: } Chris@0: // Do not include comment or processing instruction nodes Chris@0: Chris@0: return ret; Chris@0: }; Chris@0: Chris@0: Expr = Sizzle.selectors = { Chris@0: Chris@0: // Can be adjusted by the user Chris@0: cacheLength: 50, Chris@0: Chris@0: createPseudo: markFunction, Chris@0: Chris@0: match: matchExpr, Chris@0: Chris@0: attrHandle: {}, Chris@0: Chris@0: find: {}, Chris@0: Chris@0: relative: { Chris@0: ">": { dir: "parentNode", first: true }, Chris@0: " ": { dir: "parentNode" }, Chris@0: "+": { dir: "previousSibling", first: true }, Chris@0: "~": { dir: "previousSibling" } Chris@0: }, Chris@0: Chris@0: preFilter: { Chris@0: "ATTR": function( match ) { Chris@0: match[1] = match[1].replace( runescape, funescape ); Chris@0: Chris@0: // Move the given value to match[3] whether quoted or unquoted Chris@0: match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); Chris@0: Chris@0: if ( match[2] === "~=" ) { Chris@0: match[3] = " " + match[3] + " "; Chris@0: } Chris@0: Chris@0: return match.slice( 0, 4 ); Chris@0: }, Chris@0: Chris@0: "CHILD": function( match ) { Chris@0: /* matches from matchExpr["CHILD"] Chris@0: 1 type (only|nth|...) Chris@0: 2 what (child|of-type) Chris@0: 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) Chris@0: 4 xn-component of xn+y argument ([+-]?\d*n|) Chris@0: 5 sign of xn-component Chris@0: 6 x of xn-component Chris@0: 7 sign of y-component Chris@0: 8 y of y-component Chris@0: */ Chris@0: match[1] = match[1].toLowerCase(); Chris@0: Chris@0: if ( match[1].slice( 0, 3 ) === "nth" ) { Chris@0: // nth-* requires argument Chris@0: if ( !match[3] ) { Chris@0: Sizzle.error( match[0] ); Chris@0: } Chris@0: Chris@0: // numeric x and y parameters for Expr.filter.CHILD Chris@0: // remember that false/true cast respectively to 0/1 Chris@0: match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); Chris@0: match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); Chris@0: Chris@0: // other types prohibit arguments Chris@0: } else if ( match[3] ) { Chris@0: Sizzle.error( match[0] ); Chris@0: } Chris@0: Chris@0: return match; Chris@0: }, Chris@0: Chris@0: "PSEUDO": function( match ) { Chris@0: var excess, Chris@0: unquoted = !match[6] && match[2]; Chris@0: Chris@0: if ( matchExpr["CHILD"].test( match[0] ) ) { Chris@0: return null; Chris@0: } Chris@0: Chris@0: // Accept quoted arguments as-is Chris@0: if ( match[3] ) { Chris@0: match[2] = match[4] || match[5] || ""; Chris@0: Chris@0: // Strip excess characters from unquoted arguments Chris@0: } else if ( unquoted && rpseudo.test( unquoted ) && Chris@0: // Get excess from tokenize (recursively) Chris@0: (excess = tokenize( unquoted, true )) && Chris@0: // advance to the next closing parenthesis Chris@0: (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { Chris@0: Chris@0: // excess is a negative index Chris@0: match[0] = match[0].slice( 0, excess ); Chris@0: match[2] = unquoted.slice( 0, excess ); Chris@0: } Chris@0: Chris@0: // Return only captures needed by the pseudo filter method (type and argument) Chris@0: return match.slice( 0, 3 ); Chris@0: } Chris@0: }, Chris@0: Chris@0: filter: { Chris@0: Chris@0: "TAG": function( nodeNameSelector ) { Chris@0: var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); Chris@0: return nodeNameSelector === "*" ? Chris@0: function() { return true; } : Chris@0: function( elem ) { Chris@0: return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; Chris@0: }; Chris@0: }, Chris@0: Chris@0: "CLASS": function( className ) { Chris@0: var pattern = classCache[ className + " " ]; Chris@0: Chris@0: return pattern || Chris@0: (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && Chris@0: classCache( className, function( elem ) { Chris@0: return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); Chris@0: }); Chris@0: }, Chris@0: Chris@0: "ATTR": function( name, operator, check ) { Chris@0: return function( elem ) { Chris@0: var result = Sizzle.attr( elem, name ); Chris@0: Chris@0: if ( result == null ) { Chris@0: return operator === "!="; Chris@0: } Chris@0: if ( !operator ) { Chris@0: return true; Chris@0: } Chris@0: Chris@0: result += ""; Chris@0: Chris@0: return operator === "=" ? result === check : Chris@0: operator === "!=" ? result !== check : Chris@0: operator === "^=" ? check && result.indexOf( check ) === 0 : Chris@0: operator === "*=" ? check && result.indexOf( check ) > -1 : Chris@0: operator === "$=" ? check && result.slice( -check.length ) === check : Chris@0: operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : Chris@0: operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : Chris@0: false; Chris@0: }; Chris@0: }, Chris@0: Chris@0: "CHILD": function( type, what, argument, first, last ) { Chris@0: var simple = type.slice( 0, 3 ) !== "nth", Chris@0: forward = type.slice( -4 ) !== "last", Chris@0: ofType = what === "of-type"; Chris@0: Chris@0: return first === 1 && last === 0 ? Chris@0: Chris@0: // Shortcut for :nth-*(n) Chris@0: function( elem ) { Chris@0: return !!elem.parentNode; Chris@0: } : Chris@0: Chris@0: function( elem, context, xml ) { Chris@0: var cache, uniqueCache, outerCache, node, nodeIndex, start, Chris@0: dir = simple !== forward ? "nextSibling" : "previousSibling", Chris@0: parent = elem.parentNode, Chris@0: name = ofType && elem.nodeName.toLowerCase(), Chris@0: useCache = !xml && !ofType, Chris@0: diff = false; Chris@0: Chris@0: if ( parent ) { Chris@0: Chris@0: // :(first|last|only)-(child|of-type) Chris@0: if ( simple ) { Chris@0: while ( dir ) { Chris@0: node = elem; Chris@0: while ( (node = node[ dir ]) ) { Chris@0: if ( ofType ? Chris@0: node.nodeName.toLowerCase() === name : Chris@0: node.nodeType === 1 ) { Chris@0: Chris@0: return false; Chris@0: } Chris@0: } Chris@0: // Reverse direction for :only-* (if we haven't yet done so) Chris@0: start = dir = type === "only" && !start && "nextSibling"; Chris@0: } Chris@0: return true; Chris@0: } Chris@0: Chris@0: start = [ forward ? parent.firstChild : parent.lastChild ]; Chris@0: Chris@0: // non-xml :nth-child(...) stores cache data on `parent` Chris@0: if ( forward && useCache ) { Chris@0: Chris@0: // Seek `elem` from a previously-cached index Chris@0: Chris@0: // ...in a gzip-friendly way Chris@0: node = parent; Chris@0: outerCache = node[ expando ] || (node[ expando ] = {}); Chris@0: Chris@0: // Support: IE <9 only Chris@0: // Defend against cloned attroperties (jQuery gh-1709) Chris@0: uniqueCache = outerCache[ node.uniqueID ] || Chris@0: (outerCache[ node.uniqueID ] = {}); Chris@0: Chris@0: cache = uniqueCache[ type ] || []; Chris@0: nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; Chris@0: diff = nodeIndex && cache[ 2 ]; Chris@0: node = nodeIndex && parent.childNodes[ nodeIndex ]; Chris@0: Chris@0: while ( (node = ++nodeIndex && node && node[ dir ] || Chris@0: Chris@0: // Fallback to seeking `elem` from the start Chris@0: (diff = nodeIndex = 0) || start.pop()) ) { Chris@0: Chris@0: // When found, cache indexes on `parent` and break Chris@0: if ( node.nodeType === 1 && ++diff && node === elem ) { Chris@0: uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; Chris@0: break; Chris@0: } Chris@0: } Chris@0: Chris@0: } else { Chris@0: // Use previously-cached element index if available Chris@0: if ( useCache ) { Chris@0: // ...in a gzip-friendly way Chris@0: node = elem; Chris@0: outerCache = node[ expando ] || (node[ expando ] = {}); Chris@0: Chris@0: // Support: IE <9 only Chris@0: // Defend against cloned attroperties (jQuery gh-1709) Chris@0: uniqueCache = outerCache[ node.uniqueID ] || Chris@0: (outerCache[ node.uniqueID ] = {}); Chris@0: Chris@0: cache = uniqueCache[ type ] || []; Chris@0: nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; Chris@0: diff = nodeIndex; Chris@0: } Chris@0: Chris@0: // xml :nth-child(...) Chris@0: // or :nth-last-child(...) or :nth(-last)?-of-type(...) Chris@0: if ( diff === false ) { Chris@0: // Use the same loop as above to seek `elem` from the start Chris@0: while ( (node = ++nodeIndex && node && node[ dir ] || Chris@0: (diff = nodeIndex = 0) || start.pop()) ) { Chris@0: Chris@0: if ( ( ofType ? Chris@0: node.nodeName.toLowerCase() === name : Chris@0: node.nodeType === 1 ) && Chris@0: ++diff ) { Chris@0: Chris@0: // Cache the index of each encountered element Chris@0: if ( useCache ) { Chris@0: outerCache = node[ expando ] || (node[ expando ] = {}); Chris@0: Chris@0: // Support: IE <9 only Chris@0: // Defend against cloned attroperties (jQuery gh-1709) Chris@0: uniqueCache = outerCache[ node.uniqueID ] || Chris@0: (outerCache[ node.uniqueID ] = {}); Chris@0: Chris@0: uniqueCache[ type ] = [ dirruns, diff ]; Chris@0: } Chris@0: Chris@0: if ( node === elem ) { Chris@0: break; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Incorporate the offset, then check against cycle size Chris@0: diff -= last; Chris@0: return diff === first || ( diff % first === 0 && diff / first >= 0 ); Chris@0: } Chris@0: }; Chris@0: }, Chris@0: Chris@0: "PSEUDO": function( pseudo, argument ) { Chris@0: // pseudo-class names are case-insensitive Chris@0: // http://www.w3.org/TR/selectors/#pseudo-classes Chris@0: // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters Chris@0: // Remember that setFilters inherits from pseudos Chris@0: var args, Chris@0: fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || Chris@0: Sizzle.error( "unsupported pseudo: " + pseudo ); Chris@0: Chris@0: // The user may use createPseudo to indicate that Chris@0: // arguments are needed to create the filter function Chris@0: // just as Sizzle does Chris@0: if ( fn[ expando ] ) { Chris@0: return fn( argument ); Chris@0: } Chris@0: Chris@0: // But maintain support for old signatures Chris@0: if ( fn.length > 1 ) { Chris@0: args = [ pseudo, pseudo, "", argument ]; Chris@0: return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? Chris@0: markFunction(function( seed, matches ) { Chris@0: var idx, Chris@0: matched = fn( seed, argument ), Chris@0: i = matched.length; Chris@0: while ( i-- ) { Chris@0: idx = indexOf( seed, matched[i] ); Chris@0: seed[ idx ] = !( matches[ idx ] = matched[i] ); Chris@0: } Chris@0: }) : Chris@0: function( elem ) { Chris@0: return fn( elem, 0, args ); Chris@0: }; Chris@0: } Chris@0: Chris@0: return fn; Chris@0: } Chris@0: }, Chris@0: Chris@0: pseudos: { Chris@0: // Potentially complex pseudos Chris@0: "not": markFunction(function( selector ) { Chris@0: // Trim the selector passed to compile Chris@0: // to avoid treating leading and trailing Chris@0: // spaces as combinators Chris@0: var input = [], Chris@0: results = [], Chris@0: matcher = compile( selector.replace( rtrim, "$1" ) ); Chris@0: Chris@0: return matcher[ expando ] ? Chris@0: markFunction(function( seed, matches, context, xml ) { Chris@0: var elem, Chris@0: unmatched = matcher( seed, null, xml, [] ), Chris@0: i = seed.length; Chris@0: Chris@0: // Match elements unmatched by `matcher` Chris@0: while ( i-- ) { Chris@0: if ( (elem = unmatched[i]) ) { Chris@0: seed[i] = !(matches[i] = elem); Chris@0: } Chris@0: } Chris@0: }) : Chris@0: function( elem, context, xml ) { Chris@0: input[0] = elem; Chris@0: matcher( input, null, xml, results ); Chris@0: // Don't keep the element (issue #299) Chris@0: input[0] = null; Chris@0: return !results.pop(); Chris@0: }; Chris@0: }), Chris@0: Chris@0: "has": markFunction(function( selector ) { Chris@0: return function( elem ) { Chris@0: return Sizzle( selector, elem ).length > 0; Chris@0: }; Chris@0: }), Chris@0: Chris@0: "contains": markFunction(function( text ) { Chris@0: text = text.replace( runescape, funescape ); Chris@0: return function( elem ) { Chris@0: return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; Chris@0: }; Chris@0: }), Chris@0: Chris@0: // "Whether an element is represented by a :lang() selector Chris@0: // is based solely on the element's language value Chris@0: // being equal to the identifier C, Chris@0: // or beginning with the identifier C immediately followed by "-". Chris@0: // The matching of C against the element's language value is performed case-insensitively. Chris@0: // The identifier C does not have to be a valid language name." Chris@0: // http://www.w3.org/TR/selectors/#lang-pseudo Chris@0: "lang": markFunction( function( lang ) { Chris@0: // lang value must be a valid identifier Chris@0: if ( !ridentifier.test(lang || "") ) { Chris@0: Sizzle.error( "unsupported lang: " + lang ); Chris@0: } Chris@0: lang = lang.replace( runescape, funescape ).toLowerCase(); Chris@0: return function( elem ) { Chris@0: var elemLang; Chris@0: do { Chris@0: if ( (elemLang = documentIsHTML ? Chris@0: elem.lang : Chris@0: elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { Chris@0: Chris@0: elemLang = elemLang.toLowerCase(); Chris@0: return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; Chris@0: } Chris@0: } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); Chris@0: return false; Chris@0: }; Chris@0: }), Chris@0: Chris@0: // Miscellaneous Chris@0: "target": function( elem ) { Chris@0: var hash = window.location && window.location.hash; Chris@0: return hash && hash.slice( 1 ) === elem.id; Chris@0: }, Chris@0: Chris@0: "root": function( elem ) { Chris@0: return elem === docElem; Chris@0: }, Chris@0: Chris@0: "focus": function( elem ) { Chris@0: return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); Chris@0: }, Chris@0: Chris@0: // Boolean properties Chris@0: "enabled": createDisabledPseudo( false ), Chris@0: "disabled": createDisabledPseudo( true ), Chris@0: Chris@0: "checked": function( elem ) { Chris@0: // In CSS3, :checked should return both checked and selected elements Chris@0: // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked Chris@0: var nodeName = elem.nodeName.toLowerCase(); Chris@0: return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); Chris@0: }, Chris@0: Chris@0: "selected": function( elem ) { Chris@0: // Accessing this property makes selected-by-default Chris@0: // options in Safari work properly Chris@0: if ( elem.parentNode ) { Chris@0: elem.parentNode.selectedIndex; Chris@0: } Chris@0: Chris@0: return elem.selected === true; Chris@0: }, Chris@0: Chris@0: // Contents Chris@0: "empty": function( elem ) { Chris@0: // http://www.w3.org/TR/selectors/#empty-pseudo Chris@0: // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), Chris@0: // but not by others (comment: 8; processing instruction: 7; etc.) Chris@0: // nodeType < 6 works because attributes (2) do not appear as children Chris@0: for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { Chris@0: if ( elem.nodeType < 6 ) { Chris@0: return false; Chris@0: } Chris@0: } Chris@0: return true; Chris@0: }, Chris@0: Chris@0: "parent": function( elem ) { Chris@0: return !Expr.pseudos["empty"]( elem ); Chris@0: }, Chris@0: Chris@0: // Element/input types Chris@0: "header": function( elem ) { Chris@0: return rheader.test( elem.nodeName ); Chris@0: }, Chris@0: Chris@0: "input": function( elem ) { Chris@0: return rinputs.test( elem.nodeName ); Chris@0: }, Chris@0: Chris@0: "button": function( elem ) { Chris@0: var name = elem.nodeName.toLowerCase(); Chris@0: return name === "input" && elem.type === "button" || name === "button"; Chris@0: }, Chris@0: Chris@0: "text": function( elem ) { Chris@0: var attr; Chris@0: return elem.nodeName.toLowerCase() === "input" && Chris@0: elem.type === "text" && Chris@0: Chris@0: // Support: IE<8 Chris@0: // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" Chris@0: ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); Chris@0: }, Chris@0: Chris@0: // Position-in-collection Chris@0: "first": createPositionalPseudo(function() { Chris@0: return [ 0 ]; Chris@0: }), Chris@0: Chris@0: "last": createPositionalPseudo(function( matchIndexes, length ) { Chris@0: return [ length - 1 ]; Chris@0: }), Chris@0: Chris@0: "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { Chris@0: return [ argument < 0 ? argument + length : argument ]; Chris@0: }), Chris@0: Chris@0: "even": createPositionalPseudo(function( matchIndexes, length ) { Chris@0: var i = 0; Chris@0: for ( ; i < length; i += 2 ) { Chris@0: matchIndexes.push( i ); Chris@0: } Chris@0: return matchIndexes; Chris@0: }), Chris@0: Chris@0: "odd": createPositionalPseudo(function( matchIndexes, length ) { Chris@0: var i = 1; Chris@0: for ( ; i < length; i += 2 ) { Chris@0: matchIndexes.push( i ); Chris@0: } Chris@0: return matchIndexes; Chris@0: }), Chris@0: Chris@0: "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { Chris@0: var i = argument < 0 ? argument + length : argument; Chris@0: for ( ; --i >= 0; ) { Chris@0: matchIndexes.push( i ); Chris@0: } Chris@0: return matchIndexes; Chris@0: }), Chris@0: Chris@0: "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { Chris@0: var i = argument < 0 ? argument + length : argument; Chris@0: for ( ; ++i < length; ) { Chris@0: matchIndexes.push( i ); Chris@0: } Chris@0: return matchIndexes; Chris@0: }) Chris@0: } Chris@0: }; Chris@0: Chris@0: Expr.pseudos["nth"] = Expr.pseudos["eq"]; Chris@0: Chris@0: // Add button/input type pseudos Chris@0: for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { Chris@0: Expr.pseudos[ i ] = createInputPseudo( i ); Chris@0: } Chris@0: for ( i in { submit: true, reset: true } ) { Chris@0: Expr.pseudos[ i ] = createButtonPseudo( i ); Chris@0: } Chris@0: Chris@0: // Easy API for creating new setFilters Chris@0: function setFilters() {} Chris@0: setFilters.prototype = Expr.filters = Expr.pseudos; Chris@0: Expr.setFilters = new setFilters(); Chris@0: Chris@0: tokenize = Sizzle.tokenize = function( selector, parseOnly ) { Chris@0: var matched, match, tokens, type, Chris@0: soFar, groups, preFilters, Chris@0: cached = tokenCache[ selector + " " ]; Chris@0: Chris@0: if ( cached ) { Chris@0: return parseOnly ? 0 : cached.slice( 0 ); Chris@0: } Chris@0: Chris@0: soFar = selector; Chris@0: groups = []; Chris@0: preFilters = Expr.preFilter; Chris@0: Chris@0: while ( soFar ) { Chris@0: Chris@0: // Comma and first run Chris@0: if ( !matched || (match = rcomma.exec( soFar )) ) { Chris@0: if ( match ) { Chris@0: // Don't consume trailing commas as valid Chris@0: soFar = soFar.slice( match[0].length ) || soFar; Chris@0: } Chris@0: groups.push( (tokens = []) ); Chris@0: } Chris@0: Chris@0: matched = false; Chris@0: Chris@0: // Combinators Chris@0: if ( (match = rcombinators.exec( soFar )) ) { Chris@0: matched = match.shift(); Chris@0: tokens.push({ Chris@0: value: matched, Chris@0: // Cast descendant combinators to space Chris@0: type: match[0].replace( rtrim, " " ) Chris@0: }); Chris@0: soFar = soFar.slice( matched.length ); Chris@0: } Chris@0: Chris@0: // Filters Chris@0: for ( type in Expr.filter ) { Chris@0: if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || Chris@0: (match = preFilters[ type ]( match ))) ) { Chris@0: matched = match.shift(); Chris@0: tokens.push({ Chris@0: value: matched, Chris@0: type: type, Chris@0: matches: match Chris@0: }); Chris@0: soFar = soFar.slice( matched.length ); Chris@0: } Chris@0: } Chris@0: Chris@0: if ( !matched ) { Chris@0: break; Chris@0: } Chris@0: } Chris@0: Chris@0: // Return the length of the invalid excess Chris@0: // if we're just parsing Chris@0: // Otherwise, throw an error or return tokens Chris@0: return parseOnly ? Chris@0: soFar.length : Chris@0: soFar ? Chris@0: Sizzle.error( selector ) : Chris@0: // Cache the tokens Chris@0: tokenCache( selector, groups ).slice( 0 ); Chris@0: }; Chris@0: Chris@0: function toSelector( tokens ) { Chris@0: var i = 0, Chris@0: len = tokens.length, Chris@0: selector = ""; Chris@0: for ( ; i < len; i++ ) { Chris@0: selector += tokens[i].value; Chris@0: } Chris@0: return selector; Chris@0: } Chris@0: Chris@0: function addCombinator( matcher, combinator, base ) { Chris@0: var dir = combinator.dir, Chris@0: skip = combinator.next, Chris@0: key = skip || dir, Chris@0: checkNonElements = base && key === "parentNode", Chris@0: doneName = done++; Chris@0: Chris@0: return combinator.first ? Chris@0: // Check against closest ancestor/preceding element Chris@0: function( elem, context, xml ) { Chris@0: while ( (elem = elem[ dir ]) ) { Chris@0: if ( elem.nodeType === 1 || checkNonElements ) { Chris@0: return matcher( elem, context, xml ); Chris@0: } Chris@0: } Chris@0: return false; Chris@0: } : Chris@0: Chris@0: // Check against all ancestor/preceding elements Chris@0: function( elem, context, xml ) { Chris@0: var oldCache, uniqueCache, outerCache, Chris@0: newCache = [ dirruns, doneName ]; Chris@0: Chris@0: // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching Chris@0: if ( xml ) { Chris@0: while ( (elem = elem[ dir ]) ) { Chris@0: if ( elem.nodeType === 1 || checkNonElements ) { Chris@0: if ( matcher( elem, context, xml ) ) { Chris@0: return true; Chris@0: } Chris@0: } Chris@0: } Chris@0: } else { Chris@0: while ( (elem = elem[ dir ]) ) { Chris@0: if ( elem.nodeType === 1 || checkNonElements ) { Chris@0: outerCache = elem[ expando ] || (elem[ expando ] = {}); Chris@0: Chris@0: // Support: IE <9 only Chris@0: // Defend against cloned attroperties (jQuery gh-1709) Chris@0: uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {}); Chris@0: Chris@0: if ( skip && skip === elem.nodeName.toLowerCase() ) { Chris@0: elem = elem[ dir ] || elem; Chris@0: } else if ( (oldCache = uniqueCache[ key ]) && Chris@0: oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { Chris@0: Chris@0: // Assign to newCache so results back-propagate to previous elements Chris@0: return (newCache[ 2 ] = oldCache[ 2 ]); Chris@0: } else { Chris@0: // Reuse newcache so results back-propagate to previous elements Chris@0: uniqueCache[ key ] = newCache; Chris@0: Chris@0: // A match means we're done; a fail means we have to keep checking Chris@0: if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { Chris@0: return true; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: return false; Chris@0: }; Chris@0: } Chris@0: Chris@0: function elementMatcher( matchers ) { Chris@0: return matchers.length > 1 ? Chris@0: function( elem, context, xml ) { Chris@0: var i = matchers.length; Chris@0: while ( i-- ) { Chris@0: if ( !matchers[i]( elem, context, xml ) ) { Chris@0: return false; Chris@0: } Chris@0: } Chris@0: return true; Chris@0: } : Chris@0: matchers[0]; Chris@0: } Chris@0: Chris@0: function multipleContexts( selector, contexts, results ) { Chris@0: var i = 0, Chris@0: len = contexts.length; Chris@0: for ( ; i < len; i++ ) { Chris@0: Sizzle( selector, contexts[i], results ); Chris@0: } Chris@0: return results; Chris@0: } Chris@0: Chris@0: function condense( unmatched, map, filter, context, xml ) { Chris@0: var elem, Chris@0: newUnmatched = [], Chris@0: i = 0, Chris@0: len = unmatched.length, Chris@0: mapped = map != null; Chris@0: Chris@0: for ( ; i < len; i++ ) { Chris@0: if ( (elem = unmatched[i]) ) { Chris@0: if ( !filter || filter( elem, context, xml ) ) { Chris@0: newUnmatched.push( elem ); Chris@0: if ( mapped ) { Chris@0: map.push( i ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return newUnmatched; Chris@0: } Chris@0: Chris@0: function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { Chris@0: if ( postFilter && !postFilter[ expando ] ) { Chris@0: postFilter = setMatcher( postFilter ); Chris@0: } Chris@0: if ( postFinder && !postFinder[ expando ] ) { Chris@0: postFinder = setMatcher( postFinder, postSelector ); Chris@0: } Chris@0: return markFunction(function( seed, results, context, xml ) { Chris@0: var temp, i, elem, Chris@0: preMap = [], Chris@0: postMap = [], Chris@0: preexisting = results.length, Chris@0: Chris@0: // Get initial elements from seed or context Chris@0: elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), Chris@0: Chris@0: // Prefilter to get matcher input, preserving a map for seed-results synchronization Chris@0: matcherIn = preFilter && ( seed || !selector ) ? Chris@0: condense( elems, preMap, preFilter, context, xml ) : Chris@0: elems, Chris@0: Chris@0: matcherOut = matcher ? Chris@0: // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, Chris@0: postFinder || ( seed ? preFilter : preexisting || postFilter ) ? Chris@0: Chris@0: // ...intermediate processing is necessary Chris@0: [] : Chris@0: Chris@0: // ...otherwise use results directly Chris@0: results : Chris@0: matcherIn; Chris@0: Chris@0: // Find primary matches Chris@0: if ( matcher ) { Chris@0: matcher( matcherIn, matcherOut, context, xml ); Chris@0: } Chris@0: Chris@0: // Apply postFilter Chris@0: if ( postFilter ) { Chris@0: temp = condense( matcherOut, postMap ); Chris@0: postFilter( temp, [], context, xml ); Chris@0: Chris@0: // Un-match failing elements by moving them back to matcherIn Chris@0: i = temp.length; Chris@0: while ( i-- ) { Chris@0: if ( (elem = temp[i]) ) { Chris@0: matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: if ( seed ) { Chris@0: if ( postFinder || preFilter ) { Chris@0: if ( postFinder ) { Chris@0: // Get the final matcherOut by condensing this intermediate into postFinder contexts Chris@0: temp = []; Chris@0: i = matcherOut.length; Chris@0: while ( i-- ) { Chris@0: if ( (elem = matcherOut[i]) ) { Chris@0: // Restore matcherIn since elem is not yet a final match Chris@0: temp.push( (matcherIn[i] = elem) ); Chris@0: } Chris@0: } Chris@0: postFinder( null, (matcherOut = []), temp, xml ); Chris@0: } Chris@0: Chris@0: // Move matched elements from seed to results to keep them synchronized Chris@0: i = matcherOut.length; Chris@0: while ( i-- ) { Chris@0: if ( (elem = matcherOut[i]) && Chris@0: (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { Chris@0: Chris@0: seed[temp] = !(results[temp] = elem); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Add elements to results, through postFinder if defined Chris@0: } else { Chris@0: matcherOut = condense( Chris@0: matcherOut === results ? Chris@0: matcherOut.splice( preexisting, matcherOut.length ) : Chris@0: matcherOut Chris@0: ); Chris@0: if ( postFinder ) { Chris@0: postFinder( null, results, matcherOut, xml ); Chris@0: } else { Chris@0: push.apply( results, matcherOut ); Chris@0: } Chris@0: } Chris@0: }); Chris@0: } Chris@0: Chris@0: function matcherFromTokens( tokens ) { Chris@0: var checkContext, matcher, j, Chris@0: len = tokens.length, Chris@0: leadingRelative = Expr.relative[ tokens[0].type ], Chris@0: implicitRelative = leadingRelative || Expr.relative[" "], Chris@0: i = leadingRelative ? 1 : 0, Chris@0: Chris@0: // The foundational matcher ensures that elements are reachable from top-level context(s) Chris@0: matchContext = addCombinator( function( elem ) { Chris@0: return elem === checkContext; Chris@0: }, implicitRelative, true ), Chris@0: matchAnyContext = addCombinator( function( elem ) { Chris@0: return indexOf( checkContext, elem ) > -1; Chris@0: }, implicitRelative, true ), Chris@0: matchers = [ function( elem, context, xml ) { Chris@0: var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( Chris@0: (checkContext = context).nodeType ? Chris@0: matchContext( elem, context, xml ) : Chris@0: matchAnyContext( elem, context, xml ) ); Chris@0: // Avoid hanging onto element (issue #299) Chris@0: checkContext = null; Chris@0: return ret; Chris@0: } ]; Chris@0: Chris@0: for ( ; i < len; i++ ) { Chris@0: if ( (matcher = Expr.relative[ tokens[i].type ]) ) { Chris@0: matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; Chris@0: } else { Chris@0: matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); Chris@0: Chris@0: // Return special upon seeing a positional matcher Chris@0: if ( matcher[ expando ] ) { Chris@0: // Find the next relative operator (if any) for proper handling Chris@0: j = ++i; Chris@0: for ( ; j < len; j++ ) { Chris@0: if ( Expr.relative[ tokens[j].type ] ) { Chris@0: break; Chris@0: } Chris@0: } Chris@0: return setMatcher( Chris@0: i > 1 && elementMatcher( matchers ), Chris@0: i > 1 && toSelector( Chris@0: // If the preceding token was a descendant combinator, insert an implicit any-element `*` Chris@0: tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) Chris@0: ).replace( rtrim, "$1" ), Chris@0: matcher, Chris@0: i < j && matcherFromTokens( tokens.slice( i, j ) ), Chris@0: j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), Chris@0: j < len && toSelector( tokens ) Chris@0: ); Chris@0: } Chris@0: matchers.push( matcher ); Chris@0: } Chris@0: } Chris@0: Chris@0: return elementMatcher( matchers ); Chris@0: } Chris@0: Chris@0: function matcherFromGroupMatchers( elementMatchers, setMatchers ) { Chris@0: var bySet = setMatchers.length > 0, Chris@0: byElement = elementMatchers.length > 0, Chris@0: superMatcher = function( seed, context, xml, results, outermost ) { Chris@0: var elem, j, matcher, Chris@0: matchedCount = 0, Chris@0: i = "0", Chris@0: unmatched = seed && [], Chris@0: setMatched = [], Chris@0: contextBackup = outermostContext, Chris@0: // We must always have either seed elements or outermost context Chris@0: elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), Chris@0: // Use integer dirruns iff this is the outermost matcher Chris@0: dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), Chris@0: len = elems.length; Chris@0: Chris@0: if ( outermost ) { Chris@0: outermostContext = context === document || context || outermost; Chris@0: } Chris@0: Chris@0: // Add elements passing elementMatchers directly to results Chris@0: // Support: IE<9, Safari Chris@0: // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id Chris@0: for ( ; i !== len && (elem = elems[i]) != null; i++ ) { Chris@0: if ( byElement && elem ) { Chris@0: j = 0; Chris@0: if ( !context && elem.ownerDocument !== document ) { Chris@0: setDocument( elem ); Chris@0: xml = !documentIsHTML; Chris@0: } Chris@0: while ( (matcher = elementMatchers[j++]) ) { Chris@0: if ( matcher( elem, context || document, xml) ) { Chris@0: results.push( elem ); Chris@0: break; Chris@0: } Chris@0: } Chris@0: if ( outermost ) { Chris@0: dirruns = dirrunsUnique; Chris@0: } Chris@0: } Chris@0: Chris@0: // Track unmatched elements for set filters Chris@0: if ( bySet ) { Chris@0: // They will have gone through all possible matchers Chris@0: if ( (elem = !matcher && elem) ) { Chris@0: matchedCount--; Chris@0: } Chris@0: Chris@0: // Lengthen the array for every element, matched or not Chris@0: if ( seed ) { Chris@0: unmatched.push( elem ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // `i` is now the count of elements visited above, and adding it to `matchedCount` Chris@0: // makes the latter nonnegative. Chris@0: matchedCount += i; Chris@0: Chris@0: // Apply set filters to unmatched elements Chris@0: // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` Chris@0: // equals `i`), unless we didn't visit _any_ elements in the above loop because we have Chris@0: // no element matchers and no seed. Chris@0: // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that Chris@0: // case, which will result in a "00" `matchedCount` that differs from `i` but is also Chris@0: // numerically zero. Chris@0: if ( bySet && i !== matchedCount ) { Chris@0: j = 0; Chris@0: while ( (matcher = setMatchers[j++]) ) { Chris@0: matcher( unmatched, setMatched, context, xml ); Chris@0: } Chris@0: Chris@0: if ( seed ) { Chris@0: // Reintegrate element matches to eliminate the need for sorting Chris@0: if ( matchedCount > 0 ) { Chris@0: while ( i-- ) { Chris@0: if ( !(unmatched[i] || setMatched[i]) ) { Chris@0: setMatched[i] = pop.call( results ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Discard index placeholder values to get only actual matches Chris@0: setMatched = condense( setMatched ); Chris@0: } Chris@0: Chris@0: // Add matches to results Chris@0: push.apply( results, setMatched ); Chris@0: Chris@0: // Seedless set matches succeeding multiple successful matchers stipulate sorting Chris@0: if ( outermost && !seed && setMatched.length > 0 && Chris@0: ( matchedCount + setMatchers.length ) > 1 ) { Chris@0: Chris@0: Sizzle.uniqueSort( results ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Override manipulation of globals by nested matchers Chris@0: if ( outermost ) { Chris@0: dirruns = dirrunsUnique; Chris@0: outermostContext = contextBackup; Chris@0: } Chris@0: Chris@0: return unmatched; Chris@0: }; Chris@0: Chris@0: return bySet ? Chris@0: markFunction( superMatcher ) : Chris@0: superMatcher; Chris@0: } Chris@0: Chris@0: compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { Chris@0: var i, Chris@0: setMatchers = [], Chris@0: elementMatchers = [], Chris@0: cached = compilerCache[ selector + " " ]; Chris@0: Chris@0: if ( !cached ) { Chris@0: // Generate a function of recursive functions that can be used to check each element Chris@0: if ( !match ) { Chris@0: match = tokenize( selector ); Chris@0: } Chris@0: i = match.length; Chris@0: while ( i-- ) { Chris@0: cached = matcherFromTokens( match[i] ); Chris@0: if ( cached[ expando ] ) { Chris@0: setMatchers.push( cached ); Chris@0: } else { Chris@0: elementMatchers.push( cached ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Cache the compiled function Chris@0: cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); Chris@0: Chris@0: // Save selector and tokenization Chris@0: cached.selector = selector; Chris@0: } Chris@0: return cached; Chris@0: }; Chris@0: Chris@0: /** Chris@0: * A low-level selection function that works with Sizzle's compiled Chris@0: * selector functions Chris@0: * @param {String|Function} selector A selector or a pre-compiled Chris@0: * selector function built with Sizzle.compile Chris@0: * @param {Element} context Chris@0: * @param {Array} [results] Chris@0: * @param {Array} [seed] A set of elements to match against Chris@0: */ Chris@0: select = Sizzle.select = function( selector, context, results, seed ) { Chris@0: var i, tokens, token, type, find, Chris@0: compiled = typeof selector === "function" && selector, Chris@0: match = !seed && tokenize( (selector = compiled.selector || selector) ); Chris@0: Chris@0: results = results || []; Chris@0: Chris@0: // Try to minimize operations if there is only one selector in the list and no seed Chris@0: // (the latter of which guarantees us context) Chris@0: if ( match.length === 1 ) { Chris@0: Chris@0: // Reduce context if the leading compound selector is an ID Chris@0: tokens = match[0] = match[0].slice( 0 ); Chris@0: if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && Chris@0: context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) { Chris@0: Chris@0: context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; Chris@0: if ( !context ) { Chris@0: return results; Chris@0: Chris@0: // Precompiled matchers will still verify ancestry, so step up a level Chris@0: } else if ( compiled ) { Chris@0: context = context.parentNode; Chris@0: } Chris@0: Chris@0: selector = selector.slice( tokens.shift().value.length ); Chris@0: } Chris@0: Chris@0: // Fetch a seed set for right-to-left matching Chris@0: i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; Chris@0: while ( i-- ) { Chris@0: token = tokens[i]; Chris@0: Chris@0: // Abort if we hit a combinator Chris@0: if ( Expr.relative[ (type = token.type) ] ) { Chris@0: break; Chris@0: } Chris@0: if ( (find = Expr.find[ type ]) ) { Chris@0: // Search, expanding context for leading sibling combinators Chris@0: if ( (seed = find( Chris@0: token.matches[0].replace( runescape, funescape ), Chris@0: rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context Chris@0: )) ) { Chris@0: Chris@0: // If seed is empty or no tokens remain, we can return early Chris@0: tokens.splice( i, 1 ); Chris@0: selector = seed.length && toSelector( tokens ); Chris@0: if ( !selector ) { Chris@0: push.apply( results, seed ); Chris@0: return results; Chris@0: } Chris@0: Chris@0: break; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Compile and execute a filtering function if one is not provided Chris@0: // Provide `match` to avoid retokenization if we modified the selector above Chris@0: ( compiled || compile( selector, match ) )( Chris@0: seed, Chris@0: context, Chris@0: !documentIsHTML, Chris@0: results, Chris@0: !context || rsibling.test( selector ) && testContext( context.parentNode ) || context Chris@0: ); Chris@0: return results; Chris@0: }; Chris@0: Chris@0: // One-time assignments Chris@0: Chris@0: // Sort stability Chris@0: support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; Chris@0: Chris@0: // Support: Chrome 14-35+ Chris@0: // Always assume duplicates if they aren't passed to the comparison function Chris@0: support.detectDuplicates = !!hasDuplicate; Chris@0: Chris@0: // Initialize against the default document Chris@0: setDocument(); Chris@0: Chris@0: // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) Chris@0: // Detached nodes confoundingly follow *each other* Chris@0: support.sortDetached = assert(function( el ) { Chris@0: // Should return 1, but returns 4 (following) Chris@0: return el.compareDocumentPosition( document.createElement("fieldset") ) & 1; Chris@0: }); Chris@0: Chris@0: // Support: IE<8 Chris@0: // Prevent attribute/property "interpolation" Chris@0: // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx Chris@0: if ( !assert(function( el ) { Chris@0: el.innerHTML = ""; Chris@0: return el.firstChild.getAttribute("href") === "#" ; Chris@0: }) ) { Chris@0: addHandle( "type|href|height|width", function( elem, name, isXML ) { Chris@0: if ( !isXML ) { Chris@0: return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); Chris@0: } Chris@0: }); Chris@0: } Chris@0: Chris@0: // Support: IE<9 Chris@0: // Use defaultValue in place of getAttribute("value") Chris@0: if ( !support.attributes || !assert(function( el ) { Chris@0: el.innerHTML = ""; Chris@0: el.firstChild.setAttribute( "value", "" ); Chris@0: return el.firstChild.getAttribute( "value" ) === ""; Chris@0: }) ) { Chris@0: addHandle( "value", function( elem, name, isXML ) { Chris@0: if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { Chris@0: return elem.defaultValue; Chris@0: } Chris@0: }); Chris@0: } Chris@0: Chris@0: // Support: IE<9 Chris@0: // Use getAttributeNode to fetch booleans when getAttribute lies Chris@0: if ( !assert(function( el ) { Chris@0: return el.getAttribute("disabled") == null; Chris@0: }) ) { Chris@0: addHandle( booleans, function( elem, name, isXML ) { Chris@0: var val; Chris@0: if ( !isXML ) { Chris@0: return elem[ name ] === true ? name.toLowerCase() : Chris@0: (val = elem.getAttributeNode( name )) && val.specified ? Chris@0: val.value : Chris@0: null; Chris@0: } Chris@0: }); Chris@0: } Chris@0: Chris@0: return Sizzle; Chris@0: Chris@0: })( window ); Chris@0: Chris@0: Chris@0: Chris@0: jQuery.find = Sizzle; Chris@0: jQuery.expr = Sizzle.selectors; Chris@0: Chris@0: // Deprecated Chris@0: jQuery.expr[ ":" ] = jQuery.expr.pseudos; Chris@0: jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; Chris@0: jQuery.text = Sizzle.getText; Chris@0: jQuery.isXMLDoc = Sizzle.isXML; Chris@0: jQuery.contains = Sizzle.contains; Chris@0: jQuery.escapeSelector = Sizzle.escape; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: var dir = function( elem, dir, until ) { Chris@0: var matched = [], Chris@0: truncate = until !== undefined; Chris@0: Chris@0: while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { Chris@0: if ( elem.nodeType === 1 ) { Chris@0: if ( truncate && jQuery( elem ).is( until ) ) { Chris@0: break; Chris@0: } Chris@0: matched.push( elem ); Chris@0: } Chris@0: } Chris@0: return matched; Chris@0: }; Chris@0: Chris@0: Chris@0: var siblings = function( n, elem ) { Chris@0: var matched = []; Chris@0: Chris@0: for ( ; n; n = n.nextSibling ) { Chris@0: if ( n.nodeType === 1 && n !== elem ) { Chris@0: matched.push( n ); Chris@0: } Chris@0: } Chris@0: Chris@0: return matched; Chris@0: }; Chris@0: Chris@0: Chris@0: var rneedsContext = jQuery.expr.match.needsContext; Chris@0: Chris@0: Chris@0: Chris@0: function nodeName( elem, name ) { Chris@0: Chris@0: return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); Chris@0: Chris@0: }; Chris@0: var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); Chris@0: Chris@0: Chris@0: Chris@0: var risSimple = /^.[^:#\[\.,]*$/; Chris@0: Chris@0: // Implement the identical functionality for filter and not Chris@0: function winnow( elements, qualifier, not ) { Chris@0: if ( jQuery.isFunction( qualifier ) ) { Chris@0: return jQuery.grep( elements, function( elem, i ) { Chris@0: return !!qualifier.call( elem, i, elem ) !== not; Chris@0: } ); Chris@0: } Chris@0: Chris@0: // Single element Chris@0: if ( qualifier.nodeType ) { Chris@0: return jQuery.grep( elements, function( elem ) { Chris@0: return ( elem === qualifier ) !== not; Chris@0: } ); Chris@0: } Chris@0: Chris@0: // Arraylike of elements (jQuery, arguments, Array) Chris@0: if ( typeof qualifier !== "string" ) { Chris@0: return jQuery.grep( elements, function( elem ) { Chris@0: return ( indexOf.call( qualifier, elem ) > -1 ) !== not; Chris@0: } ); Chris@0: } Chris@0: Chris@0: // Simple selector that can be filtered directly, removing non-Elements Chris@0: if ( risSimple.test( qualifier ) ) { Chris@0: return jQuery.filter( qualifier, elements, not ); Chris@0: } Chris@0: Chris@0: // Complex selector, compare the two sets, removing non-Elements Chris@0: qualifier = jQuery.filter( qualifier, elements ); Chris@0: return jQuery.grep( elements, function( elem ) { Chris@0: return ( indexOf.call( qualifier, elem ) > -1 ) !== not && elem.nodeType === 1; Chris@0: } ); Chris@0: } Chris@0: Chris@0: jQuery.filter = function( expr, elems, not ) { Chris@0: var elem = elems[ 0 ]; Chris@0: Chris@0: if ( not ) { Chris@0: expr = ":not(" + expr + ")"; Chris@0: } Chris@0: Chris@0: if ( elems.length === 1 && elem.nodeType === 1 ) { Chris@0: return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; Chris@0: } Chris@0: Chris@0: return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { Chris@0: return elem.nodeType === 1; Chris@0: } ) ); Chris@0: }; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: find: function( selector ) { Chris@0: var i, ret, Chris@0: len = this.length, Chris@0: self = this; Chris@0: Chris@0: if ( typeof selector !== "string" ) { Chris@0: return this.pushStack( jQuery( selector ).filter( function() { Chris@0: for ( i = 0; i < len; i++ ) { Chris@0: if ( jQuery.contains( self[ i ], this ) ) { Chris@0: return true; Chris@0: } Chris@0: } Chris@0: } ) ); Chris@0: } Chris@0: Chris@0: ret = this.pushStack( [] ); Chris@0: Chris@0: for ( i = 0; i < len; i++ ) { Chris@0: jQuery.find( selector, self[ i ], ret ); Chris@0: } Chris@0: Chris@0: return len > 1 ? jQuery.uniqueSort( ret ) : ret; Chris@0: }, Chris@0: filter: function( selector ) { Chris@0: return this.pushStack( winnow( this, selector || [], false ) ); Chris@0: }, Chris@0: not: function( selector ) { Chris@0: return this.pushStack( winnow( this, selector || [], true ) ); Chris@0: }, Chris@0: is: function( selector ) { Chris@0: return !!winnow( Chris@0: this, Chris@0: Chris@0: // If this is a positional/relative selector, check membership in the returned set Chris@0: // so $("p:first").is("p:last") won't return true for a doc with two "p". Chris@0: typeof selector === "string" && rneedsContext.test( selector ) ? Chris@0: jQuery( selector ) : Chris@0: selector || [], Chris@0: false Chris@0: ).length; Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: // Initialize a jQuery object Chris@0: Chris@0: Chris@0: // A central reference to the root jQuery(document) Chris@0: var rootjQuery, Chris@0: Chris@0: // A simple way to check for HTML strings Chris@0: // Prioritize #id over to avoid XSS via location.hash (#9521) Chris@0: // Strict HTML recognition (#11290: must start with <) Chris@0: // Shortcut simple #id case for speed Chris@0: rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, Chris@0: Chris@0: init = jQuery.fn.init = function( selector, context, root ) { Chris@0: var match, elem; Chris@0: Chris@0: // HANDLE: $(""), $(null), $(undefined), $(false) Chris@0: if ( !selector ) { Chris@0: return this; Chris@0: } Chris@0: Chris@0: // Method init() accepts an alternate rootjQuery Chris@0: // so migrate can support jQuery.sub (gh-2101) Chris@0: root = root || rootjQuery; Chris@0: Chris@0: // Handle HTML strings Chris@0: if ( typeof selector === "string" ) { Chris@0: if ( selector[ 0 ] === "<" && Chris@0: selector[ selector.length - 1 ] === ">" && Chris@0: selector.length >= 3 ) { Chris@0: Chris@0: // Assume that strings that start and end with <> are HTML and skip the regex check Chris@0: match = [ null, selector, null ]; Chris@0: Chris@0: } else { Chris@0: match = rquickExpr.exec( selector ); Chris@0: } Chris@0: Chris@0: // Match html or make sure no context is specified for #id Chris@0: if ( match && ( match[ 1 ] || !context ) ) { Chris@0: Chris@0: // HANDLE: $(html) -> $(array) Chris@0: if ( match[ 1 ] ) { Chris@0: context = context instanceof jQuery ? context[ 0 ] : context; Chris@0: Chris@0: // Option to run scripts is true for back-compat Chris@0: // Intentionally let the error be thrown if parseHTML is not present Chris@0: jQuery.merge( this, jQuery.parseHTML( Chris@0: match[ 1 ], Chris@0: context && context.nodeType ? context.ownerDocument || context : document, Chris@0: true Chris@0: ) ); Chris@0: Chris@0: // HANDLE: $(html, props) Chris@0: if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { Chris@0: for ( match in context ) { Chris@0: Chris@0: // Properties of context are called as methods if possible Chris@0: if ( jQuery.isFunction( this[ match ] ) ) { Chris@0: this[ match ]( context[ match ] ); Chris@0: Chris@0: // ...and otherwise set as attributes Chris@0: } else { Chris@0: this.attr( match, context[ match ] ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return this; Chris@0: Chris@0: // HANDLE: $(#id) Chris@0: } else { Chris@0: elem = document.getElementById( match[ 2 ] ); Chris@0: Chris@0: if ( elem ) { Chris@0: Chris@0: // Inject the element directly into the jQuery object Chris@0: this[ 0 ] = elem; Chris@0: this.length = 1; Chris@0: } Chris@0: return this; Chris@0: } Chris@0: Chris@0: // HANDLE: $(expr, $(...)) Chris@0: } else if ( !context || context.jquery ) { Chris@0: return ( context || root ).find( selector ); Chris@0: Chris@0: // HANDLE: $(expr, context) Chris@0: // (which is just equivalent to: $(context).find(expr) Chris@0: } else { Chris@0: return this.constructor( context ).find( selector ); Chris@0: } Chris@0: Chris@0: // HANDLE: $(DOMElement) Chris@0: } else if ( selector.nodeType ) { Chris@0: this[ 0 ] = selector; Chris@0: this.length = 1; Chris@0: return this; Chris@0: Chris@0: // HANDLE: $(function) Chris@0: // Shortcut for document ready Chris@0: } else if ( jQuery.isFunction( selector ) ) { Chris@0: return root.ready !== undefined ? Chris@0: root.ready( selector ) : Chris@0: Chris@0: // Execute immediately if ready is not present Chris@0: selector( jQuery ); Chris@0: } Chris@0: Chris@0: return jQuery.makeArray( selector, this ); Chris@0: }; Chris@0: Chris@0: // Give the init function the jQuery prototype for later instantiation Chris@0: init.prototype = jQuery.fn; Chris@0: Chris@0: // Initialize central reference Chris@0: rootjQuery = jQuery( document ); Chris@0: Chris@0: Chris@0: var rparentsprev = /^(?:parents|prev(?:Until|All))/, Chris@0: Chris@0: // Methods guaranteed to produce a unique set when starting from a unique set Chris@0: guaranteedUnique = { Chris@0: children: true, Chris@0: contents: true, Chris@0: next: true, Chris@0: prev: true Chris@0: }; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: has: function( target ) { Chris@0: var targets = jQuery( target, this ), Chris@0: l = targets.length; Chris@0: Chris@0: return this.filter( function() { Chris@0: var i = 0; Chris@0: for ( ; i < l; i++ ) { Chris@0: if ( jQuery.contains( this, targets[ i ] ) ) { Chris@0: return true; Chris@0: } Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: closest: function( selectors, context ) { Chris@0: var cur, Chris@0: i = 0, Chris@0: l = this.length, Chris@0: matched = [], Chris@0: targets = typeof selectors !== "string" && jQuery( selectors ); Chris@0: Chris@0: // Positional selectors never match, since there's no _selection_ context Chris@0: if ( !rneedsContext.test( selectors ) ) { Chris@0: for ( ; i < l; i++ ) { Chris@0: for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { Chris@0: Chris@0: // Always skip document fragments Chris@0: if ( cur.nodeType < 11 && ( targets ? Chris@0: targets.index( cur ) > -1 : Chris@0: Chris@0: // Don't pass non-elements to Sizzle Chris@0: cur.nodeType === 1 && Chris@0: jQuery.find.matchesSelector( cur, selectors ) ) ) { Chris@0: Chris@0: matched.push( cur ); Chris@0: break; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); Chris@0: }, Chris@0: Chris@0: // Determine the position of an element within the set Chris@0: index: function( elem ) { Chris@0: Chris@0: // No argument, return index in parent Chris@0: if ( !elem ) { Chris@0: return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; Chris@0: } Chris@0: Chris@0: // Index in selector Chris@0: if ( typeof elem === "string" ) { Chris@0: return indexOf.call( jQuery( elem ), this[ 0 ] ); Chris@0: } Chris@0: Chris@0: // Locate the position of the desired element Chris@0: return indexOf.call( this, Chris@0: Chris@0: // If it receives a jQuery object, the first element is used Chris@0: elem.jquery ? elem[ 0 ] : elem Chris@0: ); Chris@0: }, Chris@0: Chris@0: add: function( selector, context ) { Chris@0: return this.pushStack( Chris@0: jQuery.uniqueSort( Chris@0: jQuery.merge( this.get(), jQuery( selector, context ) ) Chris@0: ) Chris@0: ); Chris@0: }, Chris@0: Chris@0: addBack: function( selector ) { Chris@0: return this.add( selector == null ? Chris@0: this.prevObject : this.prevObject.filter( selector ) Chris@0: ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: function sibling( cur, dir ) { Chris@0: while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} Chris@0: return cur; Chris@0: } Chris@0: Chris@0: jQuery.each( { Chris@0: parent: function( elem ) { Chris@0: var parent = elem.parentNode; Chris@0: return parent && parent.nodeType !== 11 ? parent : null; Chris@0: }, Chris@0: parents: function( elem ) { Chris@0: return dir( elem, "parentNode" ); Chris@0: }, Chris@0: parentsUntil: function( elem, i, until ) { Chris@0: return dir( elem, "parentNode", until ); Chris@0: }, Chris@0: next: function( elem ) { Chris@0: return sibling( elem, "nextSibling" ); Chris@0: }, Chris@0: prev: function( elem ) { Chris@0: return sibling( elem, "previousSibling" ); Chris@0: }, Chris@0: nextAll: function( elem ) { Chris@0: return dir( elem, "nextSibling" ); Chris@0: }, Chris@0: prevAll: function( elem ) { Chris@0: return dir( elem, "previousSibling" ); Chris@0: }, Chris@0: nextUntil: function( elem, i, until ) { Chris@0: return dir( elem, "nextSibling", until ); Chris@0: }, Chris@0: prevUntil: function( elem, i, until ) { Chris@0: return dir( elem, "previousSibling", until ); Chris@0: }, Chris@0: siblings: function( elem ) { Chris@0: return siblings( ( elem.parentNode || {} ).firstChild, elem ); Chris@0: }, Chris@0: children: function( elem ) { Chris@0: return siblings( elem.firstChild ); Chris@0: }, Chris@0: contents: function( elem ) { Chris@0: if ( nodeName( elem, "iframe" ) ) { Chris@0: return elem.contentDocument; Chris@0: } Chris@0: Chris@0: // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only Chris@0: // Treat the template element as a regular one in browsers that Chris@0: // don't support it. Chris@0: if ( nodeName( elem, "template" ) ) { Chris@0: elem = elem.content || elem; Chris@0: } Chris@0: Chris@0: return jQuery.merge( [], elem.childNodes ); Chris@0: } Chris@0: }, function( name, fn ) { Chris@0: jQuery.fn[ name ] = function( until, selector ) { Chris@0: var matched = jQuery.map( this, fn, until ); Chris@0: Chris@0: if ( name.slice( -5 ) !== "Until" ) { Chris@0: selector = until; Chris@0: } Chris@0: Chris@0: if ( selector && typeof selector === "string" ) { Chris@0: matched = jQuery.filter( selector, matched ); Chris@0: } Chris@0: Chris@0: if ( this.length > 1 ) { Chris@0: Chris@0: // Remove duplicates Chris@0: if ( !guaranteedUnique[ name ] ) { Chris@0: jQuery.uniqueSort( matched ); Chris@0: } Chris@0: Chris@0: // Reverse order for parents* and prev-derivatives Chris@0: if ( rparentsprev.test( name ) ) { Chris@0: matched.reverse(); Chris@0: } Chris@0: } Chris@0: Chris@0: return this.pushStack( matched ); Chris@0: }; Chris@0: } ); Chris@0: var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); Chris@0: Chris@0: Chris@0: Chris@0: // Convert String-formatted options into Object-formatted ones Chris@0: function createOptions( options ) { Chris@0: var object = {}; Chris@0: jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { Chris@0: object[ flag ] = true; Chris@0: } ); Chris@0: return object; Chris@0: } Chris@0: Chris@0: /* Chris@0: * Create a callback list using the following parameters: Chris@0: * Chris@0: * options: an optional list of space-separated options that will change how Chris@0: * the callback list behaves or a more traditional option object Chris@0: * Chris@0: * By default a callback list will act like an event callback list and can be Chris@0: * "fired" multiple times. Chris@0: * Chris@0: * Possible options: Chris@0: * Chris@0: * once: will ensure the callback list can only be fired once (like a Deferred) Chris@0: * Chris@0: * memory: will keep track of previous values and will call any callback added Chris@0: * after the list has been fired right away with the latest "memorized" Chris@0: * values (like a Deferred) Chris@0: * Chris@0: * unique: will ensure a callback can only be added once (no duplicate in the list) Chris@0: * Chris@0: * stopOnFalse: interrupt callings when a callback returns false Chris@0: * Chris@0: */ Chris@0: jQuery.Callbacks = function( options ) { Chris@0: Chris@0: // Convert options from String-formatted to Object-formatted if needed Chris@0: // (we check in cache first) Chris@0: options = typeof options === "string" ? Chris@0: createOptions( options ) : Chris@0: jQuery.extend( {}, options ); Chris@0: Chris@0: var // Flag to know if list is currently firing Chris@0: firing, Chris@0: Chris@0: // Last fire value for non-forgettable lists Chris@0: memory, Chris@0: Chris@0: // Flag to know if list was already fired Chris@0: fired, Chris@0: Chris@0: // Flag to prevent firing Chris@0: locked, Chris@0: Chris@0: // Actual callback list Chris@0: list = [], Chris@0: Chris@0: // Queue of execution data for repeatable lists Chris@0: queue = [], Chris@0: Chris@0: // Index of currently firing callback (modified by add/remove as needed) Chris@0: firingIndex = -1, Chris@0: Chris@0: // Fire callbacks Chris@0: fire = function() { Chris@0: Chris@0: // Enforce single-firing Chris@0: locked = locked || options.once; Chris@0: Chris@0: // Execute callbacks for all pending executions, Chris@0: // respecting firingIndex overrides and runtime changes Chris@0: fired = firing = true; Chris@0: for ( ; queue.length; firingIndex = -1 ) { Chris@0: memory = queue.shift(); Chris@0: while ( ++firingIndex < list.length ) { Chris@0: Chris@0: // Run callback and check for early termination Chris@0: if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && Chris@0: options.stopOnFalse ) { Chris@0: Chris@0: // Jump to end and forget the data so .add doesn't re-fire Chris@0: firingIndex = list.length; Chris@0: memory = false; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Forget the data if we're done with it Chris@0: if ( !options.memory ) { Chris@0: memory = false; Chris@0: } Chris@0: Chris@0: firing = false; Chris@0: Chris@0: // Clean up if we're done firing for good Chris@0: if ( locked ) { Chris@0: Chris@0: // Keep an empty list if we have data for future add calls Chris@0: if ( memory ) { Chris@0: list = []; Chris@0: Chris@0: // Otherwise, this object is spent Chris@0: } else { Chris@0: list = ""; Chris@0: } Chris@0: } Chris@0: }, Chris@0: Chris@0: // Actual Callbacks object Chris@0: self = { Chris@0: Chris@0: // Add a callback or a collection of callbacks to the list Chris@0: add: function() { Chris@0: if ( list ) { Chris@0: Chris@0: // If we have memory from a past run, we should fire after adding Chris@0: if ( memory && !firing ) { Chris@0: firingIndex = list.length - 1; Chris@0: queue.push( memory ); Chris@0: } Chris@0: Chris@0: ( function add( args ) { Chris@0: jQuery.each( args, function( _, arg ) { Chris@0: if ( jQuery.isFunction( arg ) ) { Chris@0: if ( !options.unique || !self.has( arg ) ) { Chris@0: list.push( arg ); Chris@0: } Chris@0: } else if ( arg && arg.length && jQuery.type( arg ) !== "string" ) { Chris@0: Chris@0: // Inspect recursively Chris@0: add( arg ); Chris@0: } Chris@0: } ); Chris@0: } )( arguments ); Chris@0: Chris@0: if ( memory && !firing ) { Chris@0: fire(); Chris@0: } Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Remove a callback from the list Chris@0: remove: function() { Chris@0: jQuery.each( arguments, function( _, arg ) { Chris@0: var index; Chris@0: while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { Chris@0: list.splice( index, 1 ); Chris@0: Chris@0: // Handle firing indexes Chris@0: if ( index <= firingIndex ) { Chris@0: firingIndex--; Chris@0: } Chris@0: } Chris@0: } ); Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Check if a given callback is in the list. Chris@0: // If no argument is given, return whether or not list has callbacks attached. Chris@0: has: function( fn ) { Chris@0: return fn ? Chris@0: jQuery.inArray( fn, list ) > -1 : Chris@0: list.length > 0; Chris@0: }, Chris@0: Chris@0: // Remove all callbacks from the list Chris@0: empty: function() { Chris@0: if ( list ) { Chris@0: list = []; Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Disable .fire and .add Chris@0: // Abort any current/pending executions Chris@0: // Clear all callbacks and values Chris@0: disable: function() { Chris@0: locked = queue = []; Chris@0: list = memory = ""; Chris@0: return this; Chris@0: }, Chris@0: disabled: function() { Chris@0: return !list; Chris@0: }, Chris@0: Chris@0: // Disable .fire Chris@0: // Also disable .add unless we have memory (since it would have no effect) Chris@0: // Abort any pending executions Chris@0: lock: function() { Chris@0: locked = queue = []; Chris@0: if ( !memory && !firing ) { Chris@0: list = memory = ""; Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: locked: function() { Chris@0: return !!locked; Chris@0: }, Chris@0: Chris@0: // Call all callbacks with the given context and arguments Chris@0: fireWith: function( context, args ) { Chris@0: if ( !locked ) { Chris@0: args = args || []; Chris@0: args = [ context, args.slice ? args.slice() : args ]; Chris@0: queue.push( args ); Chris@0: if ( !firing ) { Chris@0: fire(); Chris@0: } Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Call all the callbacks with the given arguments Chris@0: fire: function() { Chris@0: self.fireWith( this, arguments ); Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // To know if the callbacks have already been called at least once Chris@0: fired: function() { Chris@0: return !!fired; Chris@0: } Chris@0: }; Chris@0: Chris@0: return self; Chris@0: }; Chris@0: Chris@0: Chris@0: function Identity( v ) { Chris@0: return v; Chris@0: } Chris@0: function Thrower( ex ) { Chris@0: throw ex; Chris@0: } Chris@0: Chris@0: function adoptValue( value, resolve, reject, noValue ) { Chris@0: var method; Chris@0: Chris@0: try { Chris@0: Chris@0: // Check for promise aspect first to privilege synchronous behavior Chris@0: if ( value && jQuery.isFunction( ( method = value.promise ) ) ) { Chris@0: method.call( value ).done( resolve ).fail( reject ); Chris@0: Chris@0: // Other thenables Chris@0: } else if ( value && jQuery.isFunction( ( method = value.then ) ) ) { Chris@0: method.call( value, resolve, reject ); Chris@0: Chris@0: // Other non-thenables Chris@0: } else { Chris@0: Chris@0: // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: Chris@0: // * false: [ value ].slice( 0 ) => resolve( value ) Chris@0: // * true: [ value ].slice( 1 ) => resolve() Chris@0: resolve.apply( undefined, [ value ].slice( noValue ) ); Chris@0: } Chris@0: Chris@0: // For Promises/A+, convert exceptions into rejections Chris@0: // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in Chris@0: // Deferred#then to conditionally suppress rejection. Chris@0: } catch ( value ) { Chris@0: Chris@0: // Support: Android 4.0 only Chris@0: // Strict mode functions invoked without .call/.apply get global-object context Chris@0: reject.apply( undefined, [ value ] ); Chris@0: } Chris@0: } Chris@0: Chris@0: jQuery.extend( { Chris@0: Chris@0: Deferred: function( func ) { Chris@0: var tuples = [ Chris@0: Chris@0: // action, add listener, callbacks, Chris@0: // ... .then handlers, argument index, [final state] Chris@0: [ "notify", "progress", jQuery.Callbacks( "memory" ), Chris@0: jQuery.Callbacks( "memory" ), 2 ], Chris@0: [ "resolve", "done", jQuery.Callbacks( "once memory" ), Chris@0: jQuery.Callbacks( "once memory" ), 0, "resolved" ], Chris@0: [ "reject", "fail", jQuery.Callbacks( "once memory" ), Chris@0: jQuery.Callbacks( "once memory" ), 1, "rejected" ] Chris@0: ], Chris@0: state = "pending", Chris@0: promise = { Chris@0: state: function() { Chris@0: return state; Chris@0: }, Chris@0: always: function() { Chris@0: deferred.done( arguments ).fail( arguments ); Chris@0: return this; Chris@0: }, Chris@0: "catch": function( fn ) { Chris@0: return promise.then( null, fn ); Chris@0: }, Chris@0: Chris@0: // Keep pipe for back-compat Chris@0: pipe: function( /* fnDone, fnFail, fnProgress */ ) { Chris@0: var fns = arguments; Chris@0: Chris@0: return jQuery.Deferred( function( newDefer ) { Chris@0: jQuery.each( tuples, function( i, tuple ) { Chris@0: Chris@0: // Map tuples (progress, done, fail) to arguments (done, fail, progress) Chris@0: var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; Chris@0: Chris@0: // deferred.progress(function() { bind to newDefer or newDefer.notify }) Chris@0: // deferred.done(function() { bind to newDefer or newDefer.resolve }) Chris@0: // deferred.fail(function() { bind to newDefer or newDefer.reject }) Chris@0: deferred[ tuple[ 1 ] ]( function() { Chris@0: var returned = fn && fn.apply( this, arguments ); Chris@0: if ( returned && jQuery.isFunction( returned.promise ) ) { Chris@0: returned.promise() Chris@0: .progress( newDefer.notify ) Chris@0: .done( newDefer.resolve ) Chris@0: .fail( newDefer.reject ); Chris@0: } else { Chris@0: newDefer[ tuple[ 0 ] + "With" ]( Chris@0: this, Chris@0: fn ? [ returned ] : arguments Chris@0: ); Chris@0: } Chris@0: } ); Chris@0: } ); Chris@0: fns = null; Chris@0: } ).promise(); Chris@0: }, Chris@0: then: function( onFulfilled, onRejected, onProgress ) { Chris@0: var maxDepth = 0; Chris@0: function resolve( depth, deferred, handler, special ) { Chris@0: return function() { Chris@0: var that = this, Chris@0: args = arguments, Chris@0: mightThrow = function() { Chris@0: var returned, then; Chris@0: Chris@0: // Support: Promises/A+ section 2.3.3.3.3 Chris@0: // https://promisesaplus.com/#point-59 Chris@0: // Ignore double-resolution attempts Chris@0: if ( depth < maxDepth ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: returned = handler.apply( that, args ); Chris@0: Chris@0: // Support: Promises/A+ section 2.3.1 Chris@0: // https://promisesaplus.com/#point-48 Chris@0: if ( returned === deferred.promise() ) { Chris@0: throw new TypeError( "Thenable self-resolution" ); Chris@0: } Chris@0: Chris@0: // Support: Promises/A+ sections 2.3.3.1, 3.5 Chris@0: // https://promisesaplus.com/#point-54 Chris@0: // https://promisesaplus.com/#point-75 Chris@0: // Retrieve `then` only once Chris@0: then = returned && Chris@0: Chris@0: // Support: Promises/A+ section 2.3.4 Chris@0: // https://promisesaplus.com/#point-64 Chris@0: // Only check objects and functions for thenability Chris@0: ( typeof returned === "object" || Chris@0: typeof returned === "function" ) && Chris@0: returned.then; Chris@0: Chris@0: // Handle a returned thenable Chris@0: if ( jQuery.isFunction( then ) ) { Chris@0: Chris@0: // Special processors (notify) just wait for resolution Chris@0: if ( special ) { Chris@0: then.call( Chris@0: returned, Chris@0: resolve( maxDepth, deferred, Identity, special ), Chris@0: resolve( maxDepth, deferred, Thrower, special ) Chris@0: ); Chris@0: Chris@0: // Normal processors (resolve) also hook into progress Chris@0: } else { Chris@0: Chris@0: // ...and disregard older resolution values Chris@0: maxDepth++; Chris@0: Chris@0: then.call( Chris@0: returned, Chris@0: resolve( maxDepth, deferred, Identity, special ), Chris@0: resolve( maxDepth, deferred, Thrower, special ), Chris@0: resolve( maxDepth, deferred, Identity, Chris@0: deferred.notifyWith ) Chris@0: ); Chris@0: } Chris@0: Chris@0: // Handle all other returned values Chris@0: } else { Chris@0: Chris@0: // Only substitute handlers pass on context Chris@0: // and multiple values (non-spec behavior) Chris@0: if ( handler !== Identity ) { Chris@0: that = undefined; Chris@0: args = [ returned ]; Chris@0: } Chris@0: Chris@0: // Process the value(s) Chris@0: // Default process is resolve Chris@0: ( special || deferred.resolveWith )( that, args ); Chris@0: } Chris@0: }, Chris@0: Chris@0: // Only normal processors (resolve) catch and reject exceptions Chris@0: process = special ? Chris@0: mightThrow : Chris@0: function() { Chris@0: try { Chris@0: mightThrow(); Chris@0: } catch ( e ) { Chris@0: Chris@0: if ( jQuery.Deferred.exceptionHook ) { Chris@0: jQuery.Deferred.exceptionHook( e, Chris@0: process.stackTrace ); Chris@0: } Chris@0: Chris@0: // Support: Promises/A+ section 2.3.3.3.4.1 Chris@0: // https://promisesaplus.com/#point-61 Chris@0: // Ignore post-resolution exceptions Chris@0: if ( depth + 1 >= maxDepth ) { Chris@0: Chris@0: // Only substitute handlers pass on context Chris@0: // and multiple values (non-spec behavior) Chris@0: if ( handler !== Thrower ) { Chris@0: that = undefined; Chris@0: args = [ e ]; Chris@0: } Chris@0: Chris@0: deferred.rejectWith( that, args ); Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: // Support: Promises/A+ section 2.3.3.3.1 Chris@0: // https://promisesaplus.com/#point-57 Chris@0: // Re-resolve promises immediately to dodge false rejection from Chris@0: // subsequent errors Chris@0: if ( depth ) { Chris@0: process(); Chris@0: } else { Chris@0: Chris@0: // Call an optional hook to record the stack, in case of exception Chris@0: // since it's otherwise lost when execution goes async Chris@0: if ( jQuery.Deferred.getStackHook ) { Chris@0: process.stackTrace = jQuery.Deferred.getStackHook(); Chris@0: } Chris@0: window.setTimeout( process ); Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: return jQuery.Deferred( function( newDefer ) { Chris@0: Chris@0: // progress_handlers.add( ... ) Chris@0: tuples[ 0 ][ 3 ].add( Chris@0: resolve( Chris@0: 0, Chris@0: newDefer, Chris@0: jQuery.isFunction( onProgress ) ? Chris@0: onProgress : Chris@0: Identity, Chris@0: newDefer.notifyWith Chris@0: ) Chris@0: ); Chris@0: Chris@0: // fulfilled_handlers.add( ... ) Chris@0: tuples[ 1 ][ 3 ].add( Chris@0: resolve( Chris@0: 0, Chris@0: newDefer, Chris@0: jQuery.isFunction( onFulfilled ) ? Chris@0: onFulfilled : Chris@0: Identity Chris@0: ) Chris@0: ); Chris@0: Chris@0: // rejected_handlers.add( ... ) Chris@0: tuples[ 2 ][ 3 ].add( Chris@0: resolve( Chris@0: 0, Chris@0: newDefer, Chris@0: jQuery.isFunction( onRejected ) ? Chris@0: onRejected : Chris@0: Thrower Chris@0: ) Chris@0: ); Chris@0: } ).promise(); Chris@0: }, Chris@0: Chris@0: // Get a promise for this deferred Chris@0: // If obj is provided, the promise aspect is added to the object Chris@0: promise: function( obj ) { Chris@0: return obj != null ? jQuery.extend( obj, promise ) : promise; Chris@0: } Chris@0: }, Chris@0: deferred = {}; Chris@0: Chris@0: // Add list-specific methods Chris@0: jQuery.each( tuples, function( i, tuple ) { Chris@0: var list = tuple[ 2 ], Chris@0: stateString = tuple[ 5 ]; Chris@0: Chris@0: // promise.progress = list.add Chris@0: // promise.done = list.add Chris@0: // promise.fail = list.add Chris@0: promise[ tuple[ 1 ] ] = list.add; Chris@0: Chris@0: // Handle state Chris@0: if ( stateString ) { Chris@0: list.add( Chris@0: function() { Chris@0: Chris@0: // state = "resolved" (i.e., fulfilled) Chris@0: // state = "rejected" Chris@0: state = stateString; Chris@0: }, Chris@0: Chris@0: // rejected_callbacks.disable Chris@0: // fulfilled_callbacks.disable Chris@0: tuples[ 3 - i ][ 2 ].disable, Chris@0: Chris@0: // progress_callbacks.lock Chris@0: tuples[ 0 ][ 2 ].lock Chris@0: ); Chris@0: } Chris@0: Chris@0: // progress_handlers.fire Chris@0: // fulfilled_handlers.fire Chris@0: // rejected_handlers.fire Chris@0: list.add( tuple[ 3 ].fire ); Chris@0: Chris@0: // deferred.notify = function() { deferred.notifyWith(...) } Chris@0: // deferred.resolve = function() { deferred.resolveWith(...) } Chris@0: // deferred.reject = function() { deferred.rejectWith(...) } Chris@0: deferred[ tuple[ 0 ] ] = function() { Chris@0: deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); Chris@0: return this; Chris@0: }; Chris@0: Chris@0: // deferred.notifyWith = list.fireWith Chris@0: // deferred.resolveWith = list.fireWith Chris@0: // deferred.rejectWith = list.fireWith Chris@0: deferred[ tuple[ 0 ] + "With" ] = list.fireWith; Chris@0: } ); Chris@0: Chris@0: // Make the deferred a promise Chris@0: promise.promise( deferred ); Chris@0: Chris@0: // Call given func if any Chris@0: if ( func ) { Chris@0: func.call( deferred, deferred ); Chris@0: } Chris@0: Chris@0: // All done! Chris@0: return deferred; Chris@0: }, Chris@0: Chris@0: // Deferred helper Chris@0: when: function( singleValue ) { Chris@0: var Chris@0: Chris@0: // count of uncompleted subordinates Chris@0: remaining = arguments.length, Chris@0: Chris@0: // count of unprocessed arguments Chris@0: i = remaining, Chris@0: Chris@0: // subordinate fulfillment data Chris@0: resolveContexts = Array( i ), Chris@0: resolveValues = slice.call( arguments ), Chris@0: Chris@0: // the master Deferred Chris@0: master = jQuery.Deferred(), Chris@0: Chris@0: // subordinate callback factory Chris@0: updateFunc = function( i ) { Chris@0: return function( value ) { Chris@0: resolveContexts[ i ] = this; Chris@0: resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; Chris@0: if ( !( --remaining ) ) { Chris@0: master.resolveWith( resolveContexts, resolveValues ); Chris@0: } Chris@0: }; Chris@0: }; Chris@0: Chris@0: // Single- and empty arguments are adopted like Promise.resolve Chris@0: if ( remaining <= 1 ) { Chris@0: adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, Chris@0: !remaining ); Chris@0: Chris@0: // Use .then() to unwrap secondary thenables (cf. gh-3000) Chris@0: if ( master.state() === "pending" || Chris@0: jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { Chris@0: Chris@0: return master.then(); Chris@0: } Chris@0: } Chris@0: Chris@0: // Multiple arguments are aggregated like Promise.all array elements Chris@0: while ( i-- ) { Chris@0: adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); Chris@0: } Chris@0: Chris@0: return master.promise(); Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: // These usually indicate a programmer mistake during development, Chris@0: // warn about them ASAP rather than swallowing them by default. Chris@0: var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; Chris@0: Chris@0: jQuery.Deferred.exceptionHook = function( error, stack ) { Chris@0: Chris@0: // Support: IE 8 - 9 only Chris@0: // Console exists when dev tools are open, which can happen at any time Chris@0: if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { Chris@0: window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); Chris@0: } Chris@0: }; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: jQuery.readyException = function( error ) { Chris@0: window.setTimeout( function() { Chris@0: throw error; Chris@0: } ); Chris@0: }; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: // The deferred used on DOM ready Chris@0: var readyList = jQuery.Deferred(); Chris@0: Chris@0: jQuery.fn.ready = function( fn ) { Chris@0: Chris@0: readyList Chris@0: .then( fn ) Chris@0: Chris@0: // Wrap jQuery.readyException in a function so that the lookup Chris@0: // happens at the time of error handling instead of callback Chris@0: // registration. Chris@0: .catch( function( error ) { Chris@0: jQuery.readyException( error ); Chris@0: } ); Chris@0: Chris@0: return this; Chris@0: }; Chris@0: Chris@0: jQuery.extend( { Chris@0: Chris@0: // Is the DOM ready to be used? Set to true once it occurs. Chris@0: isReady: false, Chris@0: Chris@0: // A counter to track how many items to wait for before Chris@0: // the ready event fires. See #6781 Chris@0: readyWait: 1, Chris@0: Chris@0: // Handle when the DOM is ready Chris@0: ready: function( wait ) { Chris@0: Chris@0: // Abort if there are pending holds or we're already ready Chris@0: if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Remember that the DOM is ready Chris@0: jQuery.isReady = true; Chris@0: Chris@0: // If a normal DOM Ready event fired, decrement, and wait if need be Chris@0: if ( wait !== true && --jQuery.readyWait > 0 ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // If there are functions bound, to execute Chris@0: readyList.resolveWith( document, [ jQuery ] ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.ready.then = readyList.then; Chris@0: Chris@0: // The ready event handler and self cleanup method Chris@0: function completed() { Chris@0: document.removeEventListener( "DOMContentLoaded", completed ); Chris@0: window.removeEventListener( "load", completed ); Chris@0: jQuery.ready(); Chris@0: } Chris@0: Chris@0: // Catch cases where $(document).ready() is called Chris@0: // after the browser event has already occurred. Chris@0: // Support: IE <=9 - 10 only Chris@0: // Older IE sometimes signals "interactive" too soon Chris@0: if ( document.readyState === "complete" || Chris@0: ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { Chris@0: Chris@0: // Handle it asynchronously to allow scripts the opportunity to delay ready Chris@0: window.setTimeout( jQuery.ready ); Chris@0: Chris@0: } else { Chris@0: Chris@0: // Use the handy event callback Chris@0: document.addEventListener( "DOMContentLoaded", completed ); Chris@0: Chris@0: // A fallback to window.onload, that will always work Chris@0: window.addEventListener( "load", completed ); Chris@0: } Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: // Multifunctional method to get and set values of a collection Chris@0: // The value/s can optionally be executed if it's a function Chris@0: var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { Chris@0: var i = 0, Chris@0: len = elems.length, Chris@0: bulk = key == null; Chris@0: Chris@0: // Sets many values Chris@0: if ( jQuery.type( key ) === "object" ) { Chris@0: chainable = true; Chris@0: for ( i in key ) { Chris@0: access( elems, fn, i, key[ i ], true, emptyGet, raw ); Chris@0: } Chris@0: Chris@0: // Sets one value Chris@0: } else if ( value !== undefined ) { Chris@0: chainable = true; Chris@0: Chris@0: if ( !jQuery.isFunction( value ) ) { Chris@0: raw = true; Chris@0: } Chris@0: Chris@0: if ( bulk ) { Chris@0: Chris@0: // Bulk operations run against the entire set Chris@0: if ( raw ) { Chris@0: fn.call( elems, value ); Chris@0: fn = null; Chris@0: Chris@0: // ...except when executing function values Chris@0: } else { Chris@0: bulk = fn; Chris@0: fn = function( elem, key, value ) { Chris@0: return bulk.call( jQuery( elem ), value ); Chris@0: }; Chris@0: } Chris@0: } Chris@0: Chris@0: if ( fn ) { Chris@0: for ( ; i < len; i++ ) { Chris@0: fn( Chris@0: elems[ i ], key, raw ? Chris@0: value : Chris@0: value.call( elems[ i ], i, fn( elems[ i ], key ) ) Chris@0: ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: if ( chainable ) { Chris@0: return elems; Chris@0: } Chris@0: Chris@0: // Gets Chris@0: if ( bulk ) { Chris@0: return fn.call( elems ); Chris@0: } Chris@0: Chris@0: return len ? fn( elems[ 0 ], key ) : emptyGet; Chris@0: }; Chris@0: var acceptData = function( owner ) { Chris@0: Chris@0: // Accepts only: Chris@0: // - Node Chris@0: // - Node.ELEMENT_NODE Chris@0: // - Node.DOCUMENT_NODE Chris@0: // - Object Chris@0: // - Any Chris@0: return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); Chris@0: }; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: function Data() { Chris@0: this.expando = jQuery.expando + Data.uid++; Chris@0: } Chris@0: Chris@0: Data.uid = 1; Chris@0: Chris@0: Data.prototype = { Chris@0: Chris@0: cache: function( owner ) { Chris@0: Chris@0: // Check if the owner object already has a cache Chris@0: var value = owner[ this.expando ]; Chris@0: Chris@0: // If not, create one Chris@0: if ( !value ) { Chris@0: value = {}; Chris@0: Chris@0: // We can accept data for non-element nodes in modern browsers, Chris@0: // but we should not, see #8335. Chris@0: // Always return an empty object. Chris@0: if ( acceptData( owner ) ) { Chris@0: Chris@0: // If it is a node unlikely to be stringify-ed or looped over Chris@0: // use plain assignment Chris@0: if ( owner.nodeType ) { Chris@0: owner[ this.expando ] = value; Chris@0: Chris@0: // Otherwise secure it in a non-enumerable property Chris@0: // configurable must be true to allow the property to be Chris@0: // deleted when data is removed Chris@0: } else { Chris@0: Object.defineProperty( owner, this.expando, { Chris@0: value: value, Chris@0: configurable: true Chris@0: } ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return value; Chris@0: }, Chris@0: set: function( owner, data, value ) { Chris@0: var prop, Chris@0: cache = this.cache( owner ); Chris@0: Chris@0: // Handle: [ owner, key, value ] args Chris@0: // Always use camelCase key (gh-2257) Chris@0: if ( typeof data === "string" ) { Chris@0: cache[ jQuery.camelCase( data ) ] = value; Chris@0: Chris@0: // Handle: [ owner, { properties } ] args Chris@0: } else { Chris@0: Chris@0: // Copy the properties one-by-one to the cache object Chris@0: for ( prop in data ) { Chris@0: cache[ jQuery.camelCase( prop ) ] = data[ prop ]; Chris@0: } Chris@0: } Chris@0: return cache; Chris@0: }, Chris@0: get: function( owner, key ) { Chris@0: return key === undefined ? Chris@0: this.cache( owner ) : Chris@0: Chris@0: // Always use camelCase key (gh-2257) Chris@0: owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ]; Chris@0: }, Chris@0: access: function( owner, key, value ) { Chris@0: Chris@0: // In cases where either: Chris@0: // Chris@0: // 1. No key was specified Chris@0: // 2. A string key was specified, but no value provided Chris@0: // Chris@0: // Take the "read" path and allow the get method to determine Chris@0: // which value to return, respectively either: Chris@0: // Chris@0: // 1. The entire cache object Chris@0: // 2. The data stored at the key Chris@0: // Chris@0: if ( key === undefined || Chris@0: ( ( key && typeof key === "string" ) && value === undefined ) ) { Chris@0: Chris@0: return this.get( owner, key ); Chris@0: } Chris@0: Chris@0: // When the key is not a string, or both a key and value Chris@0: // are specified, set or extend (existing objects) with either: Chris@0: // Chris@0: // 1. An object of properties Chris@0: // 2. A key and value Chris@0: // Chris@0: this.set( owner, key, value ); Chris@0: Chris@0: // Since the "set" path can have two possible entry points Chris@0: // return the expected data based on which path was taken[*] Chris@0: return value !== undefined ? value : key; Chris@0: }, Chris@0: remove: function( owner, key ) { Chris@0: var i, Chris@0: cache = owner[ this.expando ]; Chris@0: Chris@0: if ( cache === undefined ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: if ( key !== undefined ) { Chris@0: Chris@0: // Support array or space separated string of keys Chris@0: if ( Array.isArray( key ) ) { Chris@0: Chris@0: // If key is an array of keys... Chris@0: // We always set camelCase keys, so remove that. Chris@0: key = key.map( jQuery.camelCase ); Chris@0: } else { Chris@0: key = jQuery.camelCase( key ); Chris@0: Chris@0: // If a key with the spaces exists, use it. Chris@0: // Otherwise, create an array by matching non-whitespace Chris@0: key = key in cache ? Chris@0: [ key ] : Chris@0: ( key.match( rnothtmlwhite ) || [] ); Chris@0: } Chris@0: Chris@0: i = key.length; Chris@0: Chris@0: while ( i-- ) { Chris@0: delete cache[ key[ i ] ]; Chris@0: } Chris@0: } Chris@0: Chris@0: // Remove the expando if there's no more data Chris@0: if ( key === undefined || jQuery.isEmptyObject( cache ) ) { Chris@0: Chris@0: // Support: Chrome <=35 - 45 Chris@0: // Webkit & Blink performance suffers when deleting properties Chris@0: // from DOM nodes, so set to undefined instead Chris@0: // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) Chris@0: if ( owner.nodeType ) { Chris@0: owner[ this.expando ] = undefined; Chris@0: } else { Chris@0: delete owner[ this.expando ]; Chris@0: } Chris@0: } Chris@0: }, Chris@0: hasData: function( owner ) { Chris@0: var cache = owner[ this.expando ]; Chris@0: return cache !== undefined && !jQuery.isEmptyObject( cache ); Chris@0: } Chris@0: }; Chris@0: var dataPriv = new Data(); Chris@0: Chris@0: var dataUser = new Data(); Chris@0: Chris@0: Chris@0: Chris@0: // Implementation Summary Chris@0: // Chris@0: // 1. Enforce API surface and semantic compatibility with 1.9.x branch Chris@0: // 2. Improve the module's maintainability by reducing the storage Chris@0: // paths to a single mechanism. Chris@0: // 3. Use the same single mechanism to support "private" and "user" data. Chris@0: // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) Chris@0: // 5. Avoid exposing implementation details on user objects (eg. expando properties) Chris@0: // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 Chris@0: Chris@0: var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, Chris@0: rmultiDash = /[A-Z]/g; Chris@0: Chris@0: function getData( data ) { Chris@0: if ( data === "true" ) { Chris@0: return true; Chris@0: } Chris@0: Chris@0: if ( data === "false" ) { Chris@0: return false; Chris@0: } Chris@0: Chris@0: if ( data === "null" ) { Chris@0: return null; Chris@0: } Chris@0: Chris@0: // Only convert to a number if it doesn't change the string Chris@0: if ( data === +data + "" ) { Chris@0: return +data; Chris@0: } Chris@0: Chris@0: if ( rbrace.test( data ) ) { Chris@0: return JSON.parse( data ); Chris@0: } Chris@0: Chris@0: return data; Chris@0: } Chris@0: Chris@0: function dataAttr( elem, key, data ) { Chris@0: var name; Chris@0: Chris@0: // If nothing was found internally, try to fetch any Chris@0: // data from the HTML5 data-* attribute Chris@0: if ( data === undefined && elem.nodeType === 1 ) { Chris@0: name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); Chris@0: data = elem.getAttribute( name ); Chris@0: Chris@0: if ( typeof data === "string" ) { Chris@0: try { Chris@0: data = getData( data ); Chris@0: } catch ( e ) {} Chris@0: Chris@0: // Make sure we set the data so it isn't changed later Chris@0: dataUser.set( elem, key, data ); Chris@0: } else { Chris@0: data = undefined; Chris@0: } Chris@0: } Chris@0: return data; Chris@0: } Chris@0: Chris@0: jQuery.extend( { Chris@0: hasData: function( elem ) { Chris@0: return dataUser.hasData( elem ) || dataPriv.hasData( elem ); Chris@0: }, Chris@0: Chris@0: data: function( elem, name, data ) { Chris@0: return dataUser.access( elem, name, data ); Chris@0: }, Chris@0: Chris@0: removeData: function( elem, name ) { Chris@0: dataUser.remove( elem, name ); Chris@0: }, Chris@0: Chris@0: // TODO: Now that all calls to _data and _removeData have been replaced Chris@0: // with direct calls to dataPriv methods, these can be deprecated. Chris@0: _data: function( elem, name, data ) { Chris@0: return dataPriv.access( elem, name, data ); Chris@0: }, Chris@0: Chris@0: _removeData: function( elem, name ) { Chris@0: dataPriv.remove( elem, name ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: data: function( key, value ) { Chris@0: var i, name, data, Chris@0: elem = this[ 0 ], Chris@0: attrs = elem && elem.attributes; Chris@0: Chris@0: // Gets all values Chris@0: if ( key === undefined ) { Chris@0: if ( this.length ) { Chris@0: data = dataUser.get( elem ); Chris@0: Chris@0: if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { Chris@0: i = attrs.length; Chris@0: while ( i-- ) { Chris@0: Chris@0: // Support: IE 11 only Chris@0: // The attrs elements can be null (#14894) Chris@0: if ( attrs[ i ] ) { Chris@0: name = attrs[ i ].name; Chris@0: if ( name.indexOf( "data-" ) === 0 ) { Chris@0: name = jQuery.camelCase( name.slice( 5 ) ); Chris@0: dataAttr( elem, name, data[ name ] ); Chris@0: } Chris@0: } Chris@0: } Chris@0: dataPriv.set( elem, "hasDataAttrs", true ); Chris@0: } Chris@0: } Chris@0: Chris@0: return data; Chris@0: } Chris@0: Chris@0: // Sets multiple values Chris@0: if ( typeof key === "object" ) { Chris@0: return this.each( function() { Chris@0: dataUser.set( this, key ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: return access( this, function( value ) { Chris@0: var data; Chris@0: Chris@0: // The calling jQuery object (element matches) is not empty Chris@0: // (and therefore has an element appears at this[ 0 ]) and the Chris@0: // `value` parameter was not undefined. An empty jQuery object Chris@0: // will result in `undefined` for elem = this[ 0 ] which will Chris@0: // throw an exception if an attempt to read a data cache is made. Chris@0: if ( elem && value === undefined ) { Chris@0: Chris@0: // Attempt to get data from the cache Chris@0: // The key will always be camelCased in Data Chris@0: data = dataUser.get( elem, key ); Chris@0: if ( data !== undefined ) { Chris@0: return data; Chris@0: } Chris@0: Chris@0: // Attempt to "discover" the data in Chris@0: // HTML5 custom data-* attrs Chris@0: data = dataAttr( elem, key ); Chris@0: if ( data !== undefined ) { Chris@0: return data; Chris@0: } Chris@0: Chris@0: // We tried really hard, but the data doesn't exist. Chris@0: return; Chris@0: } Chris@0: Chris@0: // Set the data... Chris@0: this.each( function() { Chris@0: Chris@0: // We always store the camelCased key Chris@0: dataUser.set( this, key, value ); Chris@0: } ); Chris@0: }, null, value, arguments.length > 1, null, true ); Chris@0: }, Chris@0: Chris@0: removeData: function( key ) { Chris@0: return this.each( function() { Chris@0: dataUser.remove( this, key ); Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: jQuery.extend( { Chris@0: queue: function( elem, type, data ) { Chris@0: var queue; Chris@0: Chris@0: if ( elem ) { Chris@0: type = ( type || "fx" ) + "queue"; Chris@0: queue = dataPriv.get( elem, type ); Chris@0: Chris@0: // Speed up dequeue by getting out quickly if this is just a lookup Chris@0: if ( data ) { Chris@0: if ( !queue || Array.isArray( data ) ) { Chris@0: queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); Chris@0: } else { Chris@0: queue.push( data ); Chris@0: } Chris@0: } Chris@0: return queue || []; Chris@0: } Chris@0: }, Chris@0: Chris@0: dequeue: function( elem, type ) { Chris@0: type = type || "fx"; Chris@0: Chris@0: var queue = jQuery.queue( elem, type ), Chris@0: startLength = queue.length, Chris@0: fn = queue.shift(), Chris@0: hooks = jQuery._queueHooks( elem, type ), Chris@0: next = function() { Chris@0: jQuery.dequeue( elem, type ); Chris@0: }; Chris@0: Chris@0: // If the fx queue is dequeued, always remove the progress sentinel Chris@0: if ( fn === "inprogress" ) { Chris@0: fn = queue.shift(); Chris@0: startLength--; Chris@0: } Chris@0: Chris@0: if ( fn ) { Chris@0: Chris@0: // Add a progress sentinel to prevent the fx queue from being Chris@0: // automatically dequeued Chris@0: if ( type === "fx" ) { Chris@0: queue.unshift( "inprogress" ); Chris@0: } Chris@0: Chris@0: // Clear up the last queue stop function Chris@0: delete hooks.stop; Chris@0: fn.call( elem, next, hooks ); Chris@0: } Chris@0: Chris@0: if ( !startLength && hooks ) { Chris@0: hooks.empty.fire(); Chris@0: } Chris@0: }, Chris@0: Chris@0: // Not public - generate a queueHooks object, or return the current one Chris@0: _queueHooks: function( elem, type ) { Chris@0: var key = type + "queueHooks"; Chris@0: return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { Chris@0: empty: jQuery.Callbacks( "once memory" ).add( function() { Chris@0: dataPriv.remove( elem, [ type + "queue", key ] ); Chris@0: } ) Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: queue: function( type, data ) { Chris@0: var setter = 2; Chris@0: Chris@0: if ( typeof type !== "string" ) { Chris@0: data = type; Chris@0: type = "fx"; Chris@0: setter--; Chris@0: } Chris@0: Chris@0: if ( arguments.length < setter ) { Chris@0: return jQuery.queue( this[ 0 ], type ); Chris@0: } Chris@0: Chris@0: return data === undefined ? Chris@0: this : Chris@0: this.each( function() { Chris@0: var queue = jQuery.queue( this, type, data ); Chris@0: Chris@0: // Ensure a hooks for this queue Chris@0: jQuery._queueHooks( this, type ); Chris@0: Chris@0: if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { Chris@0: jQuery.dequeue( this, type ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: dequeue: function( type ) { Chris@0: return this.each( function() { Chris@0: jQuery.dequeue( this, type ); Chris@0: } ); Chris@0: }, Chris@0: clearQueue: function( type ) { Chris@0: return this.queue( type || "fx", [] ); Chris@0: }, Chris@0: Chris@0: // Get a promise resolved when queues of a certain type Chris@0: // are emptied (fx is the type by default) Chris@0: promise: function( type, obj ) { Chris@0: var tmp, Chris@0: count = 1, Chris@0: defer = jQuery.Deferred(), Chris@0: elements = this, Chris@0: i = this.length, Chris@0: resolve = function() { Chris@0: if ( !( --count ) ) { Chris@0: defer.resolveWith( elements, [ elements ] ); Chris@0: } Chris@0: }; Chris@0: Chris@0: if ( typeof type !== "string" ) { Chris@0: obj = type; Chris@0: type = undefined; Chris@0: } Chris@0: type = type || "fx"; Chris@0: Chris@0: while ( i-- ) { Chris@0: tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); Chris@0: if ( tmp && tmp.empty ) { Chris@0: count++; Chris@0: tmp.empty.add( resolve ); Chris@0: } Chris@0: } Chris@0: resolve(); Chris@0: return defer.promise( obj ); Chris@0: } Chris@0: } ); Chris@0: var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; Chris@0: Chris@0: var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); Chris@0: Chris@0: Chris@0: var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; Chris@0: Chris@0: var isHiddenWithinTree = function( elem, el ) { Chris@0: Chris@0: // isHiddenWithinTree might be called from jQuery#filter function; Chris@0: // in that case, element will be second argument Chris@0: elem = el || elem; Chris@0: Chris@0: // Inline style trumps all Chris@0: return elem.style.display === "none" || Chris@0: elem.style.display === "" && Chris@0: Chris@0: // Otherwise, check computed style Chris@0: // Support: Firefox <=43 - 45 Chris@0: // Disconnected elements can have computed display: none, so first confirm that elem is Chris@0: // in the document. Chris@0: jQuery.contains( elem.ownerDocument, elem ) && Chris@0: Chris@0: jQuery.css( elem, "display" ) === "none"; Chris@0: }; Chris@0: Chris@0: var swap = function( elem, options, callback, args ) { Chris@0: var ret, name, Chris@0: old = {}; Chris@0: Chris@0: // Remember the old values, and insert the new ones Chris@0: for ( name in options ) { Chris@0: old[ name ] = elem.style[ name ]; Chris@0: elem.style[ name ] = options[ name ]; Chris@0: } Chris@0: Chris@0: ret = callback.apply( elem, args || [] ); Chris@0: Chris@0: // Revert the old values Chris@0: for ( name in options ) { Chris@0: elem.style[ name ] = old[ name ]; Chris@0: } Chris@0: Chris@0: return ret; Chris@0: }; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: function adjustCSS( elem, prop, valueParts, tween ) { Chris@0: var adjusted, Chris@0: scale = 1, Chris@0: maxIterations = 20, Chris@0: currentValue = tween ? Chris@0: function() { Chris@0: return tween.cur(); Chris@0: } : Chris@0: function() { Chris@0: return jQuery.css( elem, prop, "" ); Chris@0: }, Chris@0: initial = currentValue(), Chris@0: unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), Chris@0: Chris@0: // Starting value computation is required for potential unit mismatches Chris@0: initialInUnit = ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && Chris@0: rcssNum.exec( jQuery.css( elem, prop ) ); Chris@0: Chris@0: if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { Chris@0: Chris@0: // Trust units reported by jQuery.css Chris@0: unit = unit || initialInUnit[ 3 ]; Chris@0: Chris@0: // Make sure we update the tween properties later on Chris@0: valueParts = valueParts || []; Chris@0: Chris@0: // Iteratively approximate from a nonzero starting point Chris@0: initialInUnit = +initial || 1; Chris@0: Chris@0: do { Chris@0: Chris@0: // If previous iteration zeroed out, double until we get *something*. Chris@0: // Use string for doubling so we don't accidentally see scale as unchanged below Chris@0: scale = scale || ".5"; Chris@0: Chris@0: // Adjust and apply Chris@0: initialInUnit = initialInUnit / scale; Chris@0: jQuery.style( elem, prop, initialInUnit + unit ); Chris@0: Chris@0: // Update scale, tolerating zero or NaN from tween.cur() Chris@0: // Break the loop if scale is unchanged or perfect, or if we've just had enough. Chris@0: } while ( Chris@0: scale !== ( scale = currentValue() / initial ) && scale !== 1 && --maxIterations Chris@0: ); Chris@0: } Chris@0: Chris@0: if ( valueParts ) { Chris@0: initialInUnit = +initialInUnit || +initial || 0; Chris@0: Chris@0: // Apply relative offset (+=/-=) if specified Chris@0: adjusted = valueParts[ 1 ] ? Chris@0: initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : Chris@0: +valueParts[ 2 ]; Chris@0: if ( tween ) { Chris@0: tween.unit = unit; Chris@0: tween.start = initialInUnit; Chris@0: tween.end = adjusted; Chris@0: } Chris@0: } Chris@0: return adjusted; Chris@0: } Chris@0: Chris@0: Chris@0: var defaultDisplayMap = {}; Chris@0: Chris@0: function getDefaultDisplay( elem ) { Chris@0: var temp, Chris@0: doc = elem.ownerDocument, Chris@0: nodeName = elem.nodeName, Chris@0: display = defaultDisplayMap[ nodeName ]; Chris@0: Chris@0: if ( display ) { Chris@0: return display; Chris@0: } Chris@0: Chris@0: temp = doc.body.appendChild( doc.createElement( nodeName ) ); Chris@0: display = jQuery.css( temp, "display" ); Chris@0: Chris@0: temp.parentNode.removeChild( temp ); Chris@0: Chris@0: if ( display === "none" ) { Chris@0: display = "block"; Chris@0: } Chris@0: defaultDisplayMap[ nodeName ] = display; Chris@0: Chris@0: return display; Chris@0: } Chris@0: Chris@0: function showHide( elements, show ) { Chris@0: var display, elem, Chris@0: values = [], Chris@0: index = 0, Chris@0: length = elements.length; Chris@0: Chris@0: // Determine new display value for elements that need to change Chris@0: for ( ; index < length; index++ ) { Chris@0: elem = elements[ index ]; Chris@0: if ( !elem.style ) { Chris@0: continue; Chris@0: } Chris@0: Chris@0: display = elem.style.display; Chris@0: if ( show ) { Chris@0: Chris@0: // Since we force visibility upon cascade-hidden elements, an immediate (and slow) Chris@0: // check is required in this first loop unless we have a nonempty display value (either Chris@0: // inline or about-to-be-restored) Chris@0: if ( display === "none" ) { Chris@0: values[ index ] = dataPriv.get( elem, "display" ) || null; Chris@0: if ( !values[ index ] ) { Chris@0: elem.style.display = ""; Chris@0: } Chris@0: } Chris@0: if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { Chris@0: values[ index ] = getDefaultDisplay( elem ); Chris@0: } Chris@0: } else { Chris@0: if ( display !== "none" ) { Chris@0: values[ index ] = "none"; Chris@0: Chris@0: // Remember what we're overwriting Chris@0: dataPriv.set( elem, "display", display ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Set the display of the elements in a second loop to avoid constant reflow Chris@0: for ( index = 0; index < length; index++ ) { Chris@0: if ( values[ index ] != null ) { Chris@0: elements[ index ].style.display = values[ index ]; Chris@0: } Chris@0: } Chris@0: Chris@0: return elements; Chris@0: } Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: show: function() { Chris@0: return showHide( this, true ); Chris@0: }, Chris@0: hide: function() { Chris@0: return showHide( this ); Chris@0: }, Chris@0: toggle: function( state ) { Chris@0: if ( typeof state === "boolean" ) { Chris@0: return state ? this.show() : this.hide(); Chris@0: } Chris@0: Chris@0: return this.each( function() { Chris@0: if ( isHiddenWithinTree( this ) ) { Chris@0: jQuery( this ).show(); Chris@0: } else { Chris@0: jQuery( this ).hide(); Chris@0: } Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: var rcheckableType = ( /^(?:checkbox|radio)$/i ); Chris@0: Chris@0: var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]+)/i ); Chris@0: Chris@0: var rscriptType = ( /^$|\/(?:java|ecma)script/i ); Chris@0: Chris@0: Chris@0: Chris@0: // We have to close these tags to support XHTML (#13200) Chris@0: var wrapMap = { Chris@0: Chris@0: // Support: IE <=9 only Chris@0: option: [ 1, "" ], Chris@0: Chris@0: // XHTML parsers do not magically insert elements in the Chris@0: // same way that tag soup parsers do. So we cannot shorten Chris@0: // this by omitting or other required elements. Chris@0: thead: [ 1, "", "
" ], Chris@0: col: [ 2, "", "
" ], Chris@0: tr: [ 2, "", "
" ], Chris@0: td: [ 3, "", "
" ], Chris@0: Chris@0: _default: [ 0, "", "" ] Chris@0: }; Chris@0: Chris@0: // Support: IE <=9 only Chris@0: wrapMap.optgroup = wrapMap.option; Chris@0: Chris@0: wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; Chris@0: wrapMap.th = wrapMap.td; Chris@0: Chris@0: Chris@0: function getAll( context, tag ) { Chris@0: Chris@0: // Support: IE <=9 - 11 only Chris@0: // Use typeof to avoid zero-argument method invocation on host objects (#15151) Chris@0: var ret; Chris@0: Chris@0: if ( typeof context.getElementsByTagName !== "undefined" ) { Chris@0: ret = context.getElementsByTagName( tag || "*" ); Chris@0: Chris@0: } else if ( typeof context.querySelectorAll !== "undefined" ) { Chris@0: ret = context.querySelectorAll( tag || "*" ); Chris@0: Chris@0: } else { Chris@0: ret = []; Chris@0: } Chris@0: Chris@0: if ( tag === undefined || tag && nodeName( context, tag ) ) { Chris@0: return jQuery.merge( [ context ], ret ); Chris@0: } Chris@0: Chris@0: return ret; Chris@0: } Chris@0: Chris@0: Chris@0: // Mark scripts as having already been evaluated Chris@0: function setGlobalEval( elems, refElements ) { Chris@0: var i = 0, Chris@0: l = elems.length; Chris@0: Chris@0: for ( ; i < l; i++ ) { Chris@0: dataPriv.set( Chris@0: elems[ i ], Chris@0: "globalEval", Chris@0: !refElements || dataPriv.get( refElements[ i ], "globalEval" ) Chris@0: ); Chris@0: } Chris@0: } Chris@0: Chris@0: Chris@0: var rhtml = /<|&#?\w+;/; Chris@0: Chris@0: function buildFragment( elems, context, scripts, selection, ignored ) { Chris@0: var elem, tmp, tag, wrap, contains, j, Chris@0: fragment = context.createDocumentFragment(), Chris@0: nodes = [], Chris@0: i = 0, Chris@0: l = elems.length; Chris@0: Chris@0: for ( ; i < l; i++ ) { Chris@0: elem = elems[ i ]; Chris@0: Chris@0: if ( elem || elem === 0 ) { Chris@0: Chris@0: // Add nodes directly Chris@0: if ( jQuery.type( elem ) === "object" ) { Chris@0: Chris@0: // Support: Android <=4.0 only, PhantomJS 1 only Chris@0: // push.apply(_, arraylike) throws on ancient WebKit Chris@0: jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); Chris@0: Chris@0: // Convert non-html into a text node Chris@0: } else if ( !rhtml.test( elem ) ) { Chris@0: nodes.push( context.createTextNode( elem ) ); Chris@0: Chris@0: // Convert html into DOM nodes Chris@0: } else { Chris@0: tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); Chris@0: Chris@0: // Deserialize a standard representation Chris@0: tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); Chris@0: wrap = wrapMap[ tag ] || wrapMap._default; Chris@0: tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; Chris@0: Chris@0: // Descend through wrappers to the right content Chris@0: j = wrap[ 0 ]; Chris@0: while ( j-- ) { Chris@0: tmp = tmp.lastChild; Chris@0: } Chris@0: Chris@0: // Support: Android <=4.0 only, PhantomJS 1 only Chris@0: // push.apply(_, arraylike) throws on ancient WebKit Chris@0: jQuery.merge( nodes, tmp.childNodes ); Chris@0: Chris@0: // Remember the top-level container Chris@0: tmp = fragment.firstChild; Chris@0: Chris@0: // Ensure the created nodes are orphaned (#12392) Chris@0: tmp.textContent = ""; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Remove wrapper from fragment Chris@0: fragment.textContent = ""; Chris@0: Chris@0: i = 0; Chris@0: while ( ( elem = nodes[ i++ ] ) ) { Chris@0: Chris@0: // Skip elements already in the context collection (trac-4087) Chris@0: if ( selection && jQuery.inArray( elem, selection ) > -1 ) { Chris@0: if ( ignored ) { Chris@0: ignored.push( elem ); Chris@0: } Chris@0: continue; Chris@0: } Chris@0: Chris@0: contains = jQuery.contains( elem.ownerDocument, elem ); Chris@0: Chris@0: // Append to fragment Chris@0: tmp = getAll( fragment.appendChild( elem ), "script" ); Chris@0: Chris@0: // Preserve script evaluation history Chris@0: if ( contains ) { Chris@0: setGlobalEval( tmp ); Chris@0: } Chris@0: Chris@0: // Capture executables Chris@0: if ( scripts ) { Chris@0: j = 0; Chris@0: while ( ( elem = tmp[ j++ ] ) ) { Chris@0: if ( rscriptType.test( elem.type || "" ) ) { Chris@0: scripts.push( elem ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return fragment; Chris@0: } Chris@0: Chris@0: Chris@0: ( function() { Chris@0: var fragment = document.createDocumentFragment(), Chris@0: div = fragment.appendChild( document.createElement( "div" ) ), Chris@0: input = document.createElement( "input" ); Chris@0: Chris@0: // Support: Android 4.0 - 4.3 only Chris@0: // Check state lost if the name is set (#11217) Chris@0: // Support: Windows Web Apps (WWA) Chris@0: // `name` and `type` must use .setAttribute for WWA (#14901) Chris@0: input.setAttribute( "type", "radio" ); Chris@0: input.setAttribute( "checked", "checked" ); Chris@0: input.setAttribute( "name", "t" ); Chris@0: Chris@0: div.appendChild( input ); Chris@0: Chris@0: // Support: Android <=4.1 only Chris@0: // Older WebKit doesn't clone checked state correctly in fragments Chris@0: support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; Chris@0: Chris@0: // Support: IE <=11 only Chris@0: // Make sure textarea (and checkbox) defaultValue is properly cloned Chris@0: div.innerHTML = ""; Chris@0: support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; Chris@0: } )(); Chris@0: var documentElement = document.documentElement; Chris@0: Chris@0: Chris@0: Chris@0: var Chris@0: rkeyEvent = /^key/, Chris@0: rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/, Chris@0: rtypenamespace = /^([^.]*)(?:\.(.+)|)/; Chris@0: Chris@0: function returnTrue() { Chris@0: return true; Chris@0: } Chris@0: Chris@0: function returnFalse() { Chris@0: return false; Chris@0: } Chris@0: Chris@0: // Support: IE <=9 only Chris@0: // See #13393 for more info Chris@0: function safeActiveElement() { Chris@0: try { Chris@0: return document.activeElement; Chris@0: } catch ( err ) { } Chris@0: } Chris@0: Chris@0: function on( elem, types, selector, data, fn, one ) { Chris@0: var origFn, type; Chris@0: Chris@0: // Types can be a map of types/handlers Chris@0: if ( typeof types === "object" ) { Chris@0: Chris@0: // ( types-Object, selector, data ) Chris@0: if ( typeof selector !== "string" ) { Chris@0: Chris@0: // ( types-Object, data ) Chris@0: data = data || selector; Chris@0: selector = undefined; Chris@0: } Chris@0: for ( type in types ) { Chris@0: on( elem, type, selector, data, types[ type ], one ); Chris@0: } Chris@0: return elem; Chris@0: } Chris@0: Chris@0: if ( data == null && fn == null ) { Chris@0: Chris@0: // ( types, fn ) Chris@0: fn = selector; Chris@0: data = selector = undefined; Chris@0: } else if ( fn == null ) { Chris@0: if ( typeof selector === "string" ) { Chris@0: Chris@0: // ( types, selector, fn ) Chris@0: fn = data; Chris@0: data = undefined; Chris@0: } else { Chris@0: Chris@0: // ( types, data, fn ) Chris@0: fn = data; Chris@0: data = selector; Chris@0: selector = undefined; Chris@0: } Chris@0: } Chris@0: if ( fn === false ) { Chris@0: fn = returnFalse; Chris@0: } else if ( !fn ) { Chris@0: return elem; Chris@0: } Chris@0: Chris@0: if ( one === 1 ) { Chris@0: origFn = fn; Chris@0: fn = function( event ) { Chris@0: Chris@0: // Can use an empty set, since event contains the info Chris@0: jQuery().off( event ); Chris@0: return origFn.apply( this, arguments ); Chris@0: }; Chris@0: Chris@0: // Use same guid so caller can remove using origFn Chris@0: fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); Chris@0: } Chris@0: return elem.each( function() { Chris@0: jQuery.event.add( this, types, fn, data, selector ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: /* Chris@0: * Helper functions for managing events -- not part of the public interface. Chris@0: * Props to Dean Edwards' addEvent library for many of the ideas. Chris@0: */ Chris@0: jQuery.event = { Chris@0: Chris@0: global: {}, Chris@0: Chris@0: add: function( elem, types, handler, data, selector ) { Chris@0: Chris@0: var handleObjIn, eventHandle, tmp, Chris@0: events, t, handleObj, Chris@0: special, handlers, type, namespaces, origType, Chris@0: elemData = dataPriv.get( elem ); Chris@0: Chris@0: // Don't attach events to noData or text/comment nodes (but allow plain objects) Chris@0: if ( !elemData ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Caller can pass in an object of custom data in lieu of the handler Chris@0: if ( handler.handler ) { Chris@0: handleObjIn = handler; Chris@0: handler = handleObjIn.handler; Chris@0: selector = handleObjIn.selector; Chris@0: } Chris@0: Chris@0: // Ensure that invalid selectors throw exceptions at attach time Chris@0: // Evaluate against documentElement in case elem is a non-element node (e.g., document) Chris@0: if ( selector ) { Chris@0: jQuery.find.matchesSelector( documentElement, selector ); Chris@0: } Chris@0: Chris@0: // Make sure that the handler has a unique ID, used to find/remove it later Chris@0: if ( !handler.guid ) { Chris@0: handler.guid = jQuery.guid++; Chris@0: } Chris@0: Chris@0: // Init the element's event structure and main handler, if this is the first Chris@0: if ( !( events = elemData.events ) ) { Chris@0: events = elemData.events = {}; Chris@0: } Chris@0: if ( !( eventHandle = elemData.handle ) ) { Chris@0: eventHandle = elemData.handle = function( e ) { Chris@0: Chris@0: // Discard the second event of a jQuery.event.trigger() and Chris@0: // when an event is called after a page has unloaded Chris@0: return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? Chris@0: jQuery.event.dispatch.apply( elem, arguments ) : undefined; Chris@0: }; Chris@0: } Chris@0: Chris@0: // Handle multiple events separated by a space Chris@0: types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; Chris@0: t = types.length; Chris@0: while ( t-- ) { Chris@0: tmp = rtypenamespace.exec( types[ t ] ) || []; Chris@0: type = origType = tmp[ 1 ]; Chris@0: namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); Chris@0: Chris@0: // There *must* be a type, no attaching namespace-only handlers Chris@0: if ( !type ) { Chris@0: continue; Chris@0: } Chris@0: Chris@0: // If event changes its type, use the special event handlers for the changed type Chris@0: special = jQuery.event.special[ type ] || {}; Chris@0: Chris@0: // If selector defined, determine special event api type, otherwise given type Chris@0: type = ( selector ? special.delegateType : special.bindType ) || type; Chris@0: Chris@0: // Update special based on newly reset type Chris@0: special = jQuery.event.special[ type ] || {}; Chris@0: Chris@0: // handleObj is passed to all event handlers Chris@0: handleObj = jQuery.extend( { Chris@0: type: type, Chris@0: origType: origType, Chris@0: data: data, Chris@0: handler: handler, Chris@0: guid: handler.guid, Chris@0: selector: selector, Chris@0: needsContext: selector && jQuery.expr.match.needsContext.test( selector ), Chris@0: namespace: namespaces.join( "." ) Chris@0: }, handleObjIn ); Chris@0: Chris@0: // Init the event handler queue if we're the first Chris@0: if ( !( handlers = events[ type ] ) ) { Chris@0: handlers = events[ type ] = []; Chris@0: handlers.delegateCount = 0; Chris@0: Chris@0: // Only use addEventListener if the special events handler returns false Chris@0: if ( !special.setup || Chris@0: special.setup.call( elem, data, namespaces, eventHandle ) === false ) { Chris@0: Chris@0: if ( elem.addEventListener ) { Chris@0: elem.addEventListener( type, eventHandle ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: if ( special.add ) { Chris@0: special.add.call( elem, handleObj ); Chris@0: Chris@0: if ( !handleObj.handler.guid ) { Chris@0: handleObj.handler.guid = handler.guid; Chris@0: } Chris@0: } Chris@0: Chris@0: // Add to the element's handler list, delegates in front Chris@0: if ( selector ) { Chris@0: handlers.splice( handlers.delegateCount++, 0, handleObj ); Chris@0: } else { Chris@0: handlers.push( handleObj ); Chris@0: } Chris@0: Chris@0: // Keep track of which events have ever been used, for event optimization Chris@0: jQuery.event.global[ type ] = true; Chris@0: } Chris@0: Chris@0: }, Chris@0: Chris@0: // Detach an event or set of events from an element Chris@0: remove: function( elem, types, handler, selector, mappedTypes ) { Chris@0: Chris@0: var j, origCount, tmp, Chris@0: events, t, handleObj, Chris@0: special, handlers, type, namespaces, origType, Chris@0: elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); Chris@0: Chris@0: if ( !elemData || !( events = elemData.events ) ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Once for each type.namespace in types; type may be omitted Chris@0: types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; Chris@0: t = types.length; Chris@0: while ( t-- ) { Chris@0: tmp = rtypenamespace.exec( types[ t ] ) || []; Chris@0: type = origType = tmp[ 1 ]; Chris@0: namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); Chris@0: Chris@0: // Unbind all events (on this namespace, if provided) for the element Chris@0: if ( !type ) { Chris@0: for ( type in events ) { Chris@0: jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); Chris@0: } Chris@0: continue; Chris@0: } Chris@0: Chris@0: special = jQuery.event.special[ type ] || {}; Chris@0: type = ( selector ? special.delegateType : special.bindType ) || type; Chris@0: handlers = events[ type ] || []; Chris@0: tmp = tmp[ 2 ] && Chris@0: new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); Chris@0: Chris@0: // Remove matching events Chris@0: origCount = j = handlers.length; Chris@0: while ( j-- ) { Chris@0: handleObj = handlers[ j ]; Chris@0: Chris@0: if ( ( mappedTypes || origType === handleObj.origType ) && Chris@0: ( !handler || handler.guid === handleObj.guid ) && Chris@0: ( !tmp || tmp.test( handleObj.namespace ) ) && Chris@0: ( !selector || selector === handleObj.selector || Chris@0: selector === "**" && handleObj.selector ) ) { Chris@0: handlers.splice( j, 1 ); Chris@0: Chris@0: if ( handleObj.selector ) { Chris@0: handlers.delegateCount--; Chris@0: } Chris@0: if ( special.remove ) { Chris@0: special.remove.call( elem, handleObj ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Remove generic event handler if we removed something and no more handlers exist Chris@0: // (avoids potential for endless recursion during removal of special event handlers) Chris@0: if ( origCount && !handlers.length ) { Chris@0: if ( !special.teardown || Chris@0: special.teardown.call( elem, namespaces, elemData.handle ) === false ) { Chris@0: Chris@0: jQuery.removeEvent( elem, type, elemData.handle ); Chris@0: } Chris@0: Chris@0: delete events[ type ]; Chris@0: } Chris@0: } Chris@0: Chris@0: // Remove data and the expando if it's no longer used Chris@0: if ( jQuery.isEmptyObject( events ) ) { Chris@0: dataPriv.remove( elem, "handle events" ); Chris@0: } Chris@0: }, Chris@0: Chris@0: dispatch: function( nativeEvent ) { Chris@0: Chris@0: // Make a writable jQuery.Event from the native event object Chris@0: var event = jQuery.event.fix( nativeEvent ); Chris@0: Chris@0: var i, j, ret, matched, handleObj, handlerQueue, Chris@0: args = new Array( arguments.length ), Chris@0: handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [], Chris@0: special = jQuery.event.special[ event.type ] || {}; Chris@0: Chris@0: // Use the fix-ed jQuery.Event rather than the (read-only) native event Chris@0: args[ 0 ] = event; Chris@0: Chris@0: for ( i = 1; i < arguments.length; i++ ) { Chris@0: args[ i ] = arguments[ i ]; Chris@0: } Chris@0: Chris@0: event.delegateTarget = this; Chris@0: Chris@0: // Call the preDispatch hook for the mapped type, and let it bail if desired Chris@0: if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Determine handlers Chris@0: handlerQueue = jQuery.event.handlers.call( this, event, handlers ); Chris@0: Chris@0: // Run delegates first; they may want to stop propagation beneath us Chris@0: i = 0; Chris@0: while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { Chris@0: event.currentTarget = matched.elem; Chris@0: Chris@0: j = 0; Chris@0: while ( ( handleObj = matched.handlers[ j++ ] ) && Chris@0: !event.isImmediatePropagationStopped() ) { Chris@0: Chris@0: // Triggered event must either 1) have no namespace, or 2) have namespace(s) Chris@0: // a subset or equal to those in the bound event (both can have no namespace). Chris@0: if ( !event.rnamespace || event.rnamespace.test( handleObj.namespace ) ) { Chris@0: Chris@0: event.handleObj = handleObj; Chris@0: event.data = handleObj.data; Chris@0: Chris@0: ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || Chris@0: handleObj.handler ).apply( matched.elem, args ); Chris@0: Chris@0: if ( ret !== undefined ) { Chris@0: if ( ( event.result = ret ) === false ) { Chris@0: event.preventDefault(); Chris@0: event.stopPropagation(); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Call the postDispatch hook for the mapped type Chris@0: if ( special.postDispatch ) { Chris@0: special.postDispatch.call( this, event ); Chris@0: } Chris@0: Chris@0: return event.result; Chris@0: }, Chris@0: Chris@0: handlers: function( event, handlers ) { Chris@0: var i, handleObj, sel, matchedHandlers, matchedSelectors, Chris@0: handlerQueue = [], Chris@0: delegateCount = handlers.delegateCount, Chris@0: cur = event.target; Chris@0: Chris@0: // Find delegate handlers Chris@0: if ( delegateCount && Chris@0: Chris@0: // Support: IE <=9 Chris@0: // Black-hole SVG instance trees (trac-13180) Chris@0: cur.nodeType && Chris@0: Chris@0: // Support: Firefox <=42 Chris@0: // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) Chris@0: // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click Chris@0: // Support: IE 11 only Chris@0: // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) Chris@0: !( event.type === "click" && event.button >= 1 ) ) { Chris@0: Chris@0: for ( ; cur !== this; cur = cur.parentNode || this ) { Chris@0: Chris@0: // Don't check non-elements (#13208) Chris@0: // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) Chris@0: if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { Chris@0: matchedHandlers = []; Chris@0: matchedSelectors = {}; Chris@0: for ( i = 0; i < delegateCount; i++ ) { Chris@0: handleObj = handlers[ i ]; Chris@0: Chris@0: // Don't conflict with Object.prototype properties (#13203) Chris@0: sel = handleObj.selector + " "; Chris@0: Chris@0: if ( matchedSelectors[ sel ] === undefined ) { Chris@0: matchedSelectors[ sel ] = handleObj.needsContext ? Chris@0: jQuery( sel, this ).index( cur ) > -1 : Chris@0: jQuery.find( sel, this, null, [ cur ] ).length; Chris@0: } Chris@0: if ( matchedSelectors[ sel ] ) { Chris@0: matchedHandlers.push( handleObj ); Chris@0: } Chris@0: } Chris@0: if ( matchedHandlers.length ) { Chris@0: handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Add the remaining (directly-bound) handlers Chris@0: cur = this; Chris@0: if ( delegateCount < handlers.length ) { Chris@0: handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); Chris@0: } Chris@0: Chris@0: return handlerQueue; Chris@0: }, Chris@0: Chris@0: addProp: function( name, hook ) { Chris@0: Object.defineProperty( jQuery.Event.prototype, name, { Chris@0: enumerable: true, Chris@0: configurable: true, Chris@0: Chris@0: get: jQuery.isFunction( hook ) ? Chris@0: function() { Chris@0: if ( this.originalEvent ) { Chris@0: return hook( this.originalEvent ); Chris@0: } Chris@0: } : Chris@0: function() { Chris@0: if ( this.originalEvent ) { Chris@0: return this.originalEvent[ name ]; Chris@0: } Chris@0: }, Chris@0: Chris@0: set: function( value ) { Chris@0: Object.defineProperty( this, name, { Chris@0: enumerable: true, Chris@0: configurable: true, Chris@0: writable: true, Chris@0: value: value Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: fix: function( originalEvent ) { Chris@0: return originalEvent[ jQuery.expando ] ? Chris@0: originalEvent : Chris@0: new jQuery.Event( originalEvent ); Chris@0: }, Chris@0: Chris@0: special: { Chris@0: load: { Chris@0: Chris@0: // Prevent triggered image.load events from bubbling to window.load Chris@0: noBubble: true Chris@0: }, Chris@0: focus: { Chris@0: Chris@0: // Fire native event if possible so blur/focus sequence is correct Chris@0: trigger: function() { Chris@0: if ( this !== safeActiveElement() && this.focus ) { Chris@0: this.focus(); Chris@0: return false; Chris@0: } Chris@0: }, Chris@0: delegateType: "focusin" Chris@0: }, Chris@0: blur: { Chris@0: trigger: function() { Chris@0: if ( this === safeActiveElement() && this.blur ) { Chris@0: this.blur(); Chris@0: return false; Chris@0: } Chris@0: }, Chris@0: delegateType: "focusout" Chris@0: }, Chris@0: click: { Chris@0: Chris@0: // For checkbox, fire native event so checked state will be right Chris@0: trigger: function() { Chris@0: if ( this.type === "checkbox" && this.click && nodeName( this, "input" ) ) { Chris@0: this.click(); Chris@0: return false; Chris@0: } Chris@0: }, Chris@0: Chris@0: // For cross-browser consistency, don't fire native .click() on links Chris@0: _default: function( event ) { Chris@0: return nodeName( event.target, "a" ); Chris@0: } Chris@0: }, Chris@0: Chris@0: beforeunload: { Chris@0: postDispatch: function( event ) { Chris@0: Chris@0: // Support: Firefox 20+ Chris@0: // Firefox doesn't alert if the returnValue field is not set. Chris@0: if ( event.result !== undefined && event.originalEvent ) { Chris@0: event.originalEvent.returnValue = event.result; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: jQuery.removeEvent = function( elem, type, handle ) { Chris@0: Chris@0: // This "if" is needed for plain objects Chris@0: if ( elem.removeEventListener ) { Chris@0: elem.removeEventListener( type, handle ); Chris@0: } Chris@0: }; Chris@0: Chris@0: jQuery.Event = function( src, props ) { Chris@0: Chris@0: // Allow instantiation without the 'new' keyword Chris@0: if ( !( this instanceof jQuery.Event ) ) { Chris@0: return new jQuery.Event( src, props ); Chris@0: } Chris@0: Chris@0: // Event object Chris@0: if ( src && src.type ) { Chris@0: this.originalEvent = src; Chris@0: this.type = src.type; Chris@0: Chris@0: // Events bubbling up the document may have been marked as prevented Chris@0: // by a handler lower down the tree; reflect the correct value. Chris@0: this.isDefaultPrevented = src.defaultPrevented || Chris@0: src.defaultPrevented === undefined && Chris@0: Chris@0: // Support: Android <=2.3 only Chris@0: src.returnValue === false ? Chris@0: returnTrue : Chris@0: returnFalse; Chris@0: Chris@0: // Create target properties Chris@0: // Support: Safari <=6 - 7 only Chris@0: // Target should not be a text node (#504, #13143) Chris@0: this.target = ( src.target && src.target.nodeType === 3 ) ? Chris@0: src.target.parentNode : Chris@0: src.target; Chris@0: Chris@0: this.currentTarget = src.currentTarget; Chris@0: this.relatedTarget = src.relatedTarget; Chris@0: Chris@0: // Event type Chris@0: } else { Chris@0: this.type = src; Chris@0: } Chris@0: Chris@0: // Put explicitly provided properties onto the event object Chris@0: if ( props ) { Chris@0: jQuery.extend( this, props ); Chris@0: } Chris@0: Chris@0: // Create a timestamp if incoming event doesn't have one Chris@0: this.timeStamp = src && src.timeStamp || jQuery.now(); Chris@0: Chris@0: // Mark it as fixed Chris@0: this[ jQuery.expando ] = true; Chris@0: }; Chris@0: Chris@0: // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding Chris@0: // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html Chris@0: jQuery.Event.prototype = { Chris@0: constructor: jQuery.Event, Chris@0: isDefaultPrevented: returnFalse, Chris@0: isPropagationStopped: returnFalse, Chris@0: isImmediatePropagationStopped: returnFalse, Chris@0: isSimulated: false, Chris@0: Chris@0: preventDefault: function() { Chris@0: var e = this.originalEvent; Chris@0: Chris@0: this.isDefaultPrevented = returnTrue; Chris@0: Chris@0: if ( e && !this.isSimulated ) { Chris@0: e.preventDefault(); Chris@0: } Chris@0: }, Chris@0: stopPropagation: function() { Chris@0: var e = this.originalEvent; Chris@0: Chris@0: this.isPropagationStopped = returnTrue; Chris@0: Chris@0: if ( e && !this.isSimulated ) { Chris@0: e.stopPropagation(); Chris@0: } Chris@0: }, Chris@0: stopImmediatePropagation: function() { Chris@0: var e = this.originalEvent; Chris@0: Chris@0: this.isImmediatePropagationStopped = returnTrue; Chris@0: Chris@0: if ( e && !this.isSimulated ) { Chris@0: e.stopImmediatePropagation(); Chris@0: } Chris@0: Chris@0: this.stopPropagation(); Chris@0: } Chris@0: }; Chris@0: Chris@0: // Includes all common event props including KeyEvent and MouseEvent specific props Chris@0: jQuery.each( { Chris@0: altKey: true, Chris@0: bubbles: true, Chris@0: cancelable: true, Chris@0: changedTouches: true, Chris@0: ctrlKey: true, Chris@0: detail: true, Chris@0: eventPhase: true, Chris@0: metaKey: true, Chris@0: pageX: true, Chris@0: pageY: true, Chris@0: shiftKey: true, Chris@0: view: true, Chris@0: "char": true, Chris@0: charCode: true, Chris@0: key: true, Chris@0: keyCode: true, Chris@0: button: true, Chris@0: buttons: true, Chris@0: clientX: true, Chris@0: clientY: true, Chris@0: offsetX: true, Chris@0: offsetY: true, Chris@0: pointerId: true, Chris@0: pointerType: true, Chris@0: screenX: true, Chris@0: screenY: true, Chris@0: targetTouches: true, Chris@0: toElement: true, Chris@0: touches: true, Chris@0: Chris@0: which: function( event ) { Chris@0: var button = event.button; Chris@0: Chris@0: // Add which for key events Chris@0: if ( event.which == null && rkeyEvent.test( event.type ) ) { Chris@0: return event.charCode != null ? event.charCode : event.keyCode; Chris@0: } Chris@0: Chris@0: // Add which for click: 1 === left; 2 === middle; 3 === right Chris@0: if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) { Chris@0: if ( button & 1 ) { Chris@0: return 1; Chris@0: } Chris@0: Chris@0: if ( button & 2 ) { Chris@0: return 3; Chris@0: } Chris@0: Chris@0: if ( button & 4 ) { Chris@0: return 2; Chris@0: } Chris@0: Chris@0: return 0; Chris@0: } Chris@0: Chris@0: return event.which; Chris@0: } Chris@0: }, jQuery.event.addProp ); Chris@0: Chris@0: // Create mouseenter/leave events using mouseover/out and event-time checks Chris@0: // so that event delegation works in jQuery. Chris@0: // Do the same for pointerenter/pointerleave and pointerover/pointerout Chris@0: // Chris@0: // Support: Safari 7 only Chris@0: // Safari sends mouseenter too often; see: Chris@0: // https://bugs.chromium.org/p/chromium/issues/detail?id=470258 Chris@0: // for the description of the bug (it existed in older Chrome versions as well). Chris@0: jQuery.each( { Chris@0: mouseenter: "mouseover", Chris@0: mouseleave: "mouseout", Chris@0: pointerenter: "pointerover", Chris@0: pointerleave: "pointerout" Chris@0: }, function( orig, fix ) { Chris@0: jQuery.event.special[ orig ] = { Chris@0: delegateType: fix, Chris@0: bindType: fix, Chris@0: Chris@0: handle: function( event ) { Chris@0: var ret, Chris@0: target = this, Chris@0: related = event.relatedTarget, Chris@0: handleObj = event.handleObj; Chris@0: Chris@0: // For mouseenter/leave call the handler if related is outside the target. Chris@0: // NB: No relatedTarget if the mouse left/entered the browser window Chris@0: if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { Chris@0: event.type = handleObj.origType; Chris@0: ret = handleObj.handler.apply( this, arguments ); Chris@0: event.type = fix; Chris@0: } Chris@0: return ret; Chris@0: } Chris@0: }; Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: Chris@0: on: function( types, selector, data, fn ) { Chris@0: return on( this, types, selector, data, fn ); Chris@0: }, Chris@0: one: function( types, selector, data, fn ) { Chris@0: return on( this, types, selector, data, fn, 1 ); Chris@0: }, Chris@0: off: function( types, selector, fn ) { Chris@0: var handleObj, type; Chris@0: if ( types && types.preventDefault && types.handleObj ) { Chris@0: Chris@0: // ( event ) dispatched jQuery.Event Chris@0: handleObj = types.handleObj; Chris@0: jQuery( types.delegateTarget ).off( Chris@0: handleObj.namespace ? Chris@0: handleObj.origType + "." + handleObj.namespace : Chris@0: handleObj.origType, Chris@0: handleObj.selector, Chris@0: handleObj.handler Chris@0: ); Chris@0: return this; Chris@0: } Chris@0: if ( typeof types === "object" ) { Chris@0: Chris@0: // ( types-object [, selector] ) Chris@0: for ( type in types ) { Chris@0: this.off( type, selector, types[ type ] ); Chris@0: } Chris@0: return this; Chris@0: } Chris@0: if ( selector === false || typeof selector === "function" ) { Chris@0: Chris@0: // ( types [, fn] ) Chris@0: fn = selector; Chris@0: selector = undefined; Chris@0: } Chris@0: if ( fn === false ) { Chris@0: fn = returnFalse; Chris@0: } Chris@0: return this.each( function() { Chris@0: jQuery.event.remove( this, types, fn, selector ); Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: var Chris@0: Chris@0: /* eslint-disable max-len */ Chris@0: Chris@0: // See https://github.com/eslint/eslint/issues/3229 Chris@0: rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi, Chris@0: Chris@0: /* eslint-enable */ Chris@0: Chris@0: // Support: IE <=10 - 11, Edge 12 - 13 Chris@0: // In IE/Edge using regex groups here causes severe slowdowns. Chris@0: // See https://connect.microsoft.com/IE/feedback/details/1736512/ Chris@0: rnoInnerhtml = /\s*$/g; Chris@0: Chris@0: // Prefer a tbody over its parent table for containing new rows Chris@0: function manipulationTarget( elem, content ) { Chris@0: if ( nodeName( elem, "table" ) && Chris@0: nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { Chris@0: Chris@0: return jQuery( ">tbody", elem )[ 0 ] || elem; Chris@0: } Chris@0: Chris@0: return elem; Chris@0: } Chris@0: Chris@0: // Replace/restore the type attribute of script elements for safe DOM manipulation Chris@0: function disableScript( elem ) { Chris@0: elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; Chris@0: return elem; Chris@0: } Chris@0: function restoreScript( elem ) { Chris@0: var match = rscriptTypeMasked.exec( elem.type ); Chris@0: Chris@0: if ( match ) { Chris@0: elem.type = match[ 1 ]; Chris@0: } else { Chris@0: elem.removeAttribute( "type" ); Chris@0: } Chris@0: Chris@0: return elem; Chris@0: } Chris@0: Chris@0: function cloneCopyEvent( src, dest ) { Chris@0: var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; Chris@0: Chris@0: if ( dest.nodeType !== 1 ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // 1. Copy private data: events, handlers, etc. Chris@0: if ( dataPriv.hasData( src ) ) { Chris@0: pdataOld = dataPriv.access( src ); Chris@0: pdataCur = dataPriv.set( dest, pdataOld ); Chris@0: events = pdataOld.events; Chris@0: Chris@0: if ( events ) { Chris@0: delete pdataCur.handle; Chris@0: pdataCur.events = {}; Chris@0: Chris@0: for ( type in events ) { Chris@0: for ( i = 0, l = events[ type ].length; i < l; i++ ) { Chris@0: jQuery.event.add( dest, type, events[ type ][ i ] ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // 2. Copy user data Chris@0: if ( dataUser.hasData( src ) ) { Chris@0: udataOld = dataUser.access( src ); Chris@0: udataCur = jQuery.extend( {}, udataOld ); Chris@0: Chris@0: dataUser.set( dest, udataCur ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Fix IE bugs, see support tests Chris@0: function fixInput( src, dest ) { Chris@0: var nodeName = dest.nodeName.toLowerCase(); Chris@0: Chris@0: // Fails to persist the checked state of a cloned checkbox or radio button. Chris@0: if ( nodeName === "input" && rcheckableType.test( src.type ) ) { Chris@0: dest.checked = src.checked; Chris@0: Chris@0: // Fails to return the selected option to the default selected state when cloning options Chris@0: } else if ( nodeName === "input" || nodeName === "textarea" ) { Chris@0: dest.defaultValue = src.defaultValue; Chris@0: } Chris@0: } Chris@0: Chris@0: function domManip( collection, args, callback, ignored ) { Chris@0: Chris@0: // Flatten any nested arrays Chris@0: args = concat.apply( [], args ); Chris@0: Chris@0: var fragment, first, scripts, hasScripts, node, doc, Chris@0: i = 0, Chris@0: l = collection.length, Chris@0: iNoClone = l - 1, Chris@0: value = args[ 0 ], Chris@0: isFunction = jQuery.isFunction( value ); Chris@0: Chris@0: // We can't cloneNode fragments that contain checked, in WebKit Chris@0: if ( isFunction || Chris@0: ( l > 1 && typeof value === "string" && Chris@0: !support.checkClone && rchecked.test( value ) ) ) { Chris@0: return collection.each( function( index ) { Chris@0: var self = collection.eq( index ); Chris@0: if ( isFunction ) { Chris@0: args[ 0 ] = value.call( this, index, self.html() ); Chris@0: } Chris@0: domManip( self, args, callback, ignored ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: if ( l ) { Chris@0: fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); Chris@0: first = fragment.firstChild; Chris@0: Chris@0: if ( fragment.childNodes.length === 1 ) { Chris@0: fragment = first; Chris@0: } Chris@0: Chris@0: // Require either new content or an interest in ignored elements to invoke the callback Chris@0: if ( first || ignored ) { Chris@0: scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); Chris@0: hasScripts = scripts.length; Chris@0: Chris@0: // Use the original fragment for the last item Chris@0: // instead of the first because it can end up Chris@0: // being emptied incorrectly in certain situations (#8070). Chris@0: for ( ; i < l; i++ ) { Chris@0: node = fragment; Chris@0: Chris@0: if ( i !== iNoClone ) { Chris@0: node = jQuery.clone( node, true, true ); Chris@0: Chris@0: // Keep references to cloned scripts for later restoration Chris@0: if ( hasScripts ) { Chris@0: Chris@0: // Support: Android <=4.0 only, PhantomJS 1 only Chris@0: // push.apply(_, arraylike) throws on ancient WebKit Chris@0: jQuery.merge( scripts, getAll( node, "script" ) ); Chris@0: } Chris@0: } Chris@0: Chris@0: callback.call( collection[ i ], node, i ); Chris@0: } Chris@0: Chris@0: if ( hasScripts ) { Chris@0: doc = scripts[ scripts.length - 1 ].ownerDocument; Chris@0: Chris@0: // Reenable scripts Chris@0: jQuery.map( scripts, restoreScript ); Chris@0: Chris@0: // Evaluate executable scripts on first document insertion Chris@0: for ( i = 0; i < hasScripts; i++ ) { Chris@0: node = scripts[ i ]; Chris@0: if ( rscriptType.test( node.type || "" ) && Chris@0: !dataPriv.access( node, "globalEval" ) && Chris@0: jQuery.contains( doc, node ) ) { Chris@0: Chris@0: if ( node.src ) { Chris@0: Chris@0: // Optional AJAX dependency, but won't run scripts if not present Chris@0: if ( jQuery._evalUrl ) { Chris@0: jQuery._evalUrl( node.src ); Chris@0: } Chris@0: } else { Chris@0: DOMEval( node.textContent.replace( rcleanScript, "" ), doc ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return collection; Chris@0: } Chris@0: Chris@0: function remove( elem, selector, keepData ) { Chris@0: var node, Chris@0: nodes = selector ? jQuery.filter( selector, elem ) : elem, Chris@0: i = 0; Chris@0: Chris@0: for ( ; ( node = nodes[ i ] ) != null; i++ ) { Chris@0: if ( !keepData && node.nodeType === 1 ) { Chris@0: jQuery.cleanData( getAll( node ) ); Chris@0: } Chris@0: Chris@0: if ( node.parentNode ) { Chris@0: if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { Chris@0: setGlobalEval( getAll( node, "script" ) ); Chris@0: } Chris@0: node.parentNode.removeChild( node ); Chris@0: } Chris@0: } Chris@0: Chris@0: return elem; Chris@0: } Chris@0: Chris@0: jQuery.extend( { Chris@0: htmlPrefilter: function( html ) { Chris@0: return html.replace( rxhtmlTag, "<$1>" ); Chris@0: }, Chris@0: Chris@0: clone: function( elem, dataAndEvents, deepDataAndEvents ) { Chris@0: var i, l, srcElements, destElements, Chris@0: clone = elem.cloneNode( true ), Chris@0: inPage = jQuery.contains( elem.ownerDocument, elem ); Chris@0: Chris@0: // Fix IE cloning issues Chris@0: if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && Chris@0: !jQuery.isXMLDoc( elem ) ) { Chris@0: Chris@0: // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 Chris@0: destElements = getAll( clone ); Chris@0: srcElements = getAll( elem ); Chris@0: Chris@0: for ( i = 0, l = srcElements.length; i < l; i++ ) { Chris@0: fixInput( srcElements[ i ], destElements[ i ] ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Copy the events from the original to the clone Chris@0: if ( dataAndEvents ) { Chris@0: if ( deepDataAndEvents ) { Chris@0: srcElements = srcElements || getAll( elem ); Chris@0: destElements = destElements || getAll( clone ); Chris@0: Chris@0: for ( i = 0, l = srcElements.length; i < l; i++ ) { Chris@0: cloneCopyEvent( srcElements[ i ], destElements[ i ] ); Chris@0: } Chris@0: } else { Chris@0: cloneCopyEvent( elem, clone ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Preserve script evaluation history Chris@0: destElements = getAll( clone, "script" ); Chris@0: if ( destElements.length > 0 ) { Chris@0: setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); Chris@0: } Chris@0: Chris@0: // Return the cloned set Chris@0: return clone; Chris@0: }, Chris@0: Chris@0: cleanData: function( elems ) { Chris@0: var data, elem, type, Chris@0: special = jQuery.event.special, Chris@0: i = 0; Chris@0: Chris@0: for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { Chris@0: if ( acceptData( elem ) ) { Chris@0: if ( ( data = elem[ dataPriv.expando ] ) ) { Chris@0: if ( data.events ) { Chris@0: for ( type in data.events ) { Chris@0: if ( special[ type ] ) { Chris@0: jQuery.event.remove( elem, type ); Chris@0: Chris@0: // This is a shortcut to avoid jQuery.event.remove's overhead Chris@0: } else { Chris@0: jQuery.removeEvent( elem, type, data.handle ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Support: Chrome <=35 - 45+ Chris@0: // Assign undefined instead of using delete, see Data#remove Chris@0: elem[ dataPriv.expando ] = undefined; Chris@0: } Chris@0: if ( elem[ dataUser.expando ] ) { Chris@0: Chris@0: // Support: Chrome <=35 - 45+ Chris@0: // Assign undefined instead of using delete, see Data#remove Chris@0: elem[ dataUser.expando ] = undefined; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: detach: function( selector ) { Chris@0: return remove( this, selector, true ); Chris@0: }, Chris@0: Chris@0: remove: function( selector ) { Chris@0: return remove( this, selector ); Chris@0: }, Chris@0: Chris@0: text: function( value ) { Chris@0: return access( this, function( value ) { Chris@0: return value === undefined ? Chris@0: jQuery.text( this ) : Chris@0: this.empty().each( function() { Chris@0: if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { Chris@0: this.textContent = value; Chris@0: } Chris@0: } ); Chris@0: }, null, value, arguments.length ); Chris@0: }, Chris@0: Chris@0: append: function() { Chris@0: return domManip( this, arguments, function( elem ) { Chris@0: if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { Chris@0: var target = manipulationTarget( this, elem ); Chris@0: target.appendChild( elem ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: prepend: function() { Chris@0: return domManip( this, arguments, function( elem ) { Chris@0: if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { Chris@0: var target = manipulationTarget( this, elem ); Chris@0: target.insertBefore( elem, target.firstChild ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: before: function() { Chris@0: return domManip( this, arguments, function( elem ) { Chris@0: if ( this.parentNode ) { Chris@0: this.parentNode.insertBefore( elem, this ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: after: function() { Chris@0: return domManip( this, arguments, function( elem ) { Chris@0: if ( this.parentNode ) { Chris@0: this.parentNode.insertBefore( elem, this.nextSibling ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: empty: function() { Chris@0: var elem, Chris@0: i = 0; Chris@0: Chris@0: for ( ; ( elem = this[ i ] ) != null; i++ ) { Chris@0: if ( elem.nodeType === 1 ) { Chris@0: Chris@0: // Prevent memory leaks Chris@0: jQuery.cleanData( getAll( elem, false ) ); Chris@0: Chris@0: // Remove any remaining nodes Chris@0: elem.textContent = ""; Chris@0: } Chris@0: } Chris@0: Chris@0: return this; Chris@0: }, Chris@0: Chris@0: clone: function( dataAndEvents, deepDataAndEvents ) { Chris@0: dataAndEvents = dataAndEvents == null ? false : dataAndEvents; Chris@0: deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; Chris@0: Chris@0: return this.map( function() { Chris@0: return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); Chris@0: } ); Chris@0: }, Chris@0: Chris@0: html: function( value ) { Chris@0: return access( this, function( value ) { Chris@0: var elem = this[ 0 ] || {}, Chris@0: i = 0, Chris@0: l = this.length; Chris@0: Chris@0: if ( value === undefined && elem.nodeType === 1 ) { Chris@0: return elem.innerHTML; Chris@0: } Chris@0: Chris@0: // See if we can take a shortcut and just use innerHTML Chris@0: if ( typeof value === "string" && !rnoInnerhtml.test( value ) && Chris@0: !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { Chris@0: Chris@0: value = jQuery.htmlPrefilter( value ); Chris@0: Chris@0: try { Chris@0: for ( ; i < l; i++ ) { Chris@0: elem = this[ i ] || {}; Chris@0: Chris@0: // Remove element nodes and prevent memory leaks Chris@0: if ( elem.nodeType === 1 ) { Chris@0: jQuery.cleanData( getAll( elem, false ) ); Chris@0: elem.innerHTML = value; Chris@0: } Chris@0: } Chris@0: Chris@0: elem = 0; Chris@0: Chris@0: // If using innerHTML throws an exception, use the fallback method Chris@0: } catch ( e ) {} Chris@0: } Chris@0: Chris@0: if ( elem ) { Chris@0: this.empty().append( value ); Chris@0: } Chris@0: }, null, value, arguments.length ); Chris@0: }, Chris@0: Chris@0: replaceWith: function() { Chris@0: var ignored = []; Chris@0: Chris@0: // Make the changes, replacing each non-ignored context element with the new content Chris@0: return domManip( this, arguments, function( elem ) { Chris@0: var parent = this.parentNode; Chris@0: Chris@0: if ( jQuery.inArray( this, ignored ) < 0 ) { Chris@0: jQuery.cleanData( getAll( this ) ); Chris@0: if ( parent ) { Chris@0: parent.replaceChild( elem, this ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Force callback invocation Chris@0: }, ignored ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.each( { Chris@0: appendTo: "append", Chris@0: prependTo: "prepend", Chris@0: insertBefore: "before", Chris@0: insertAfter: "after", Chris@0: replaceAll: "replaceWith" Chris@0: }, function( name, original ) { Chris@0: jQuery.fn[ name ] = function( selector ) { Chris@0: var elems, Chris@0: ret = [], Chris@0: insert = jQuery( selector ), Chris@0: last = insert.length - 1, Chris@0: i = 0; Chris@0: Chris@0: for ( ; i <= last; i++ ) { Chris@0: elems = i === last ? this : this.clone( true ); Chris@0: jQuery( insert[ i ] )[ original ]( elems ); Chris@0: Chris@0: // Support: Android <=4.0 only, PhantomJS 1 only Chris@0: // .get() because push.apply(_, arraylike) throws on ancient WebKit Chris@0: push.apply( ret, elems.get() ); Chris@0: } Chris@0: Chris@0: return this.pushStack( ret ); Chris@0: }; Chris@0: } ); Chris@0: var rmargin = ( /^margin/ ); Chris@0: Chris@0: var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); Chris@0: Chris@0: var getStyles = function( elem ) { Chris@0: Chris@0: // Support: IE <=11 only, Firefox <=30 (#15098, #14150) Chris@0: // IE throws on elements created in popups Chris@0: // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" Chris@0: var view = elem.ownerDocument.defaultView; Chris@0: Chris@0: if ( !view || !view.opener ) { Chris@0: view = window; Chris@0: } Chris@0: Chris@0: return view.getComputedStyle( elem ); Chris@0: }; Chris@0: Chris@0: Chris@0: Chris@0: ( function() { Chris@0: Chris@0: // Executing both pixelPosition & boxSizingReliable tests require only one layout Chris@0: // so they're executed at the same time to save the second computation. Chris@0: function computeStyleTests() { Chris@0: Chris@0: // This is a singleton, we need to execute it only once Chris@0: if ( !div ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: div.style.cssText = Chris@0: "box-sizing:border-box;" + Chris@0: "position:relative;display:block;" + Chris@0: "margin:auto;border:1px;padding:1px;" + Chris@0: "top:1%;width:50%"; Chris@0: div.innerHTML = ""; Chris@0: documentElement.appendChild( container ); Chris@0: Chris@0: var divStyle = window.getComputedStyle( div ); Chris@0: pixelPositionVal = divStyle.top !== "1%"; Chris@0: Chris@0: // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 Chris@0: reliableMarginLeftVal = divStyle.marginLeft === "2px"; Chris@0: boxSizingReliableVal = divStyle.width === "4px"; Chris@0: Chris@0: // Support: Android 4.0 - 4.3 only Chris@0: // Some styles come back with percentage values, even though they shouldn't Chris@0: div.style.marginRight = "50%"; Chris@0: pixelMarginRightVal = divStyle.marginRight === "4px"; Chris@0: Chris@0: documentElement.removeChild( container ); Chris@0: Chris@0: // Nullify the div so it wouldn't be stored in the memory and Chris@0: // it will also be a sign that checks already performed Chris@0: div = null; Chris@0: } Chris@0: Chris@0: var pixelPositionVal, boxSizingReliableVal, pixelMarginRightVal, reliableMarginLeftVal, Chris@0: container = document.createElement( "div" ), Chris@0: div = document.createElement( "div" ); Chris@0: Chris@0: // Finish early in limited (non-browser) environments Chris@0: if ( !div.style ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Support: IE <=9 - 11 only Chris@0: // Style of cloned element affects source element cloned (#8908) Chris@0: div.style.backgroundClip = "content-box"; Chris@0: div.cloneNode( true ).style.backgroundClip = ""; Chris@0: support.clearCloneStyle = div.style.backgroundClip === "content-box"; Chris@0: Chris@0: container.style.cssText = "border:0;width:8px;height:0;top:0;left:-9999px;" + Chris@0: "padding:0;margin-top:1px;position:absolute"; Chris@0: container.appendChild( div ); Chris@0: Chris@0: jQuery.extend( support, { Chris@0: pixelPosition: function() { Chris@0: computeStyleTests(); Chris@0: return pixelPositionVal; Chris@0: }, Chris@0: boxSizingReliable: function() { Chris@0: computeStyleTests(); Chris@0: return boxSizingReliableVal; Chris@0: }, Chris@0: pixelMarginRight: function() { Chris@0: computeStyleTests(); Chris@0: return pixelMarginRightVal; Chris@0: }, Chris@0: reliableMarginLeft: function() { Chris@0: computeStyleTests(); Chris@0: return reliableMarginLeftVal; Chris@0: } Chris@0: } ); Chris@0: } )(); Chris@0: Chris@0: Chris@0: function curCSS( elem, name, computed ) { Chris@0: var width, minWidth, maxWidth, ret, Chris@0: Chris@0: // Support: Firefox 51+ Chris@0: // Retrieving style before computed somehow Chris@0: // fixes an issue with getting wrong values Chris@0: // on detached elements Chris@0: style = elem.style; Chris@0: Chris@0: computed = computed || getStyles( elem ); Chris@0: Chris@0: // getPropertyValue is needed for: Chris@0: // .css('filter') (IE 9 only, #12537) Chris@0: // .css('--customProperty) (#3144) Chris@0: if ( computed ) { Chris@0: ret = computed.getPropertyValue( name ) || computed[ name ]; Chris@0: Chris@0: if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) { Chris@0: ret = jQuery.style( elem, name ); Chris@0: } Chris@0: Chris@0: // A tribute to the "awesome hack by Dean Edwards" Chris@0: // Android Browser returns percentage for some values, Chris@0: // but width seems to be reliably pixels. Chris@0: // This is against the CSSOM draft spec: Chris@0: // https://drafts.csswg.org/cssom/#resolved-values Chris@0: if ( !support.pixelMarginRight() && rnumnonpx.test( ret ) && rmargin.test( name ) ) { Chris@0: Chris@0: // Remember the original values Chris@0: width = style.width; Chris@0: minWidth = style.minWidth; Chris@0: maxWidth = style.maxWidth; Chris@0: Chris@0: // Put in the new values to get a computed value out Chris@0: style.minWidth = style.maxWidth = style.width = ret; Chris@0: ret = computed.width; Chris@0: Chris@0: // Revert the changed values Chris@0: style.width = width; Chris@0: style.minWidth = minWidth; Chris@0: style.maxWidth = maxWidth; Chris@0: } Chris@0: } Chris@0: Chris@0: return ret !== undefined ? Chris@0: Chris@0: // Support: IE <=9 - 11 only Chris@0: // IE returns zIndex value as an integer. Chris@0: ret + "" : Chris@0: ret; Chris@0: } Chris@0: Chris@0: Chris@0: function addGetHookIf( conditionFn, hookFn ) { Chris@0: Chris@0: // Define the hook, we'll check on the first run if it's really needed. Chris@0: return { Chris@0: get: function() { Chris@0: if ( conditionFn() ) { Chris@0: Chris@0: // Hook not needed (or it's not possible to use it due Chris@0: // to missing dependency), remove it. Chris@0: delete this.get; Chris@0: return; Chris@0: } Chris@0: Chris@0: // Hook needed; redefine it so that the support test is not executed again. Chris@0: return ( this.get = hookFn ).apply( this, arguments ); Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: Chris@0: var Chris@0: Chris@0: // Swappable if display is none or starts with table Chris@0: // except "table", "table-cell", or "table-caption" Chris@0: // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display Chris@0: rdisplayswap = /^(none|table(?!-c[ea]).+)/, Chris@0: rcustomProp = /^--/, Chris@0: cssShow = { position: "absolute", visibility: "hidden", display: "block" }, Chris@0: cssNormalTransform = { Chris@0: letterSpacing: "0", Chris@0: fontWeight: "400" Chris@0: }, Chris@0: Chris@0: cssPrefixes = [ "Webkit", "Moz", "ms" ], Chris@0: emptyStyle = document.createElement( "div" ).style; Chris@0: Chris@0: // Return a css property mapped to a potentially vendor prefixed property Chris@0: function vendorPropName( name ) { Chris@0: Chris@0: // Shortcut for names that are not vendor prefixed Chris@0: if ( name in emptyStyle ) { Chris@0: return name; Chris@0: } Chris@0: Chris@0: // Check for vendor prefixed names Chris@0: var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), Chris@0: i = cssPrefixes.length; Chris@0: Chris@0: while ( i-- ) { Chris@0: name = cssPrefixes[ i ] + capName; Chris@0: if ( name in emptyStyle ) { Chris@0: return name; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Return a property mapped along what jQuery.cssProps suggests or to Chris@0: // a vendor prefixed property. Chris@0: function finalPropName( name ) { Chris@0: var ret = jQuery.cssProps[ name ]; Chris@0: if ( !ret ) { Chris@0: ret = jQuery.cssProps[ name ] = vendorPropName( name ) || name; Chris@0: } Chris@0: return ret; Chris@0: } Chris@0: Chris@0: function setPositiveNumber( elem, value, subtract ) { Chris@0: Chris@0: // Any relative (+/-) values have already been Chris@0: // normalized at this point Chris@0: var matches = rcssNum.exec( value ); Chris@0: return matches ? Chris@0: Chris@0: // Guard against undefined "subtract", e.g., when used as in cssHooks Chris@0: Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : Chris@0: value; Chris@0: } Chris@0: Chris@0: function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { Chris@0: var i, Chris@0: val = 0; Chris@0: Chris@0: // If we already have the right measurement, avoid augmentation Chris@0: if ( extra === ( isBorderBox ? "border" : "content" ) ) { Chris@0: i = 4; Chris@0: Chris@0: // Otherwise initialize for horizontal or vertical properties Chris@0: } else { Chris@0: i = name === "width" ? 1 : 0; Chris@0: } Chris@0: Chris@0: for ( ; i < 4; i += 2 ) { Chris@0: Chris@0: // Both box models exclude margin, so add it if we want it Chris@0: if ( extra === "margin" ) { Chris@0: val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); Chris@0: } Chris@0: Chris@0: if ( isBorderBox ) { Chris@0: Chris@0: // border-box includes padding, so remove it if we want content Chris@0: if ( extra === "content" ) { Chris@0: val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); Chris@0: } Chris@0: Chris@0: // At this point, extra isn't border nor margin, so remove border Chris@0: if ( extra !== "margin" ) { Chris@0: val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); Chris@0: } Chris@0: } else { Chris@0: Chris@0: // At this point, extra isn't content, so add padding Chris@0: val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); Chris@0: Chris@0: // At this point, extra isn't content nor padding, so add border Chris@0: if ( extra !== "padding" ) { Chris@0: val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return val; Chris@0: } Chris@0: Chris@0: function getWidthOrHeight( elem, name, extra ) { Chris@0: Chris@0: // Start with computed style Chris@0: var valueIsBorderBox, Chris@0: styles = getStyles( elem ), Chris@0: val = curCSS( elem, name, styles ), Chris@0: isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; Chris@0: Chris@0: // Computed unit is not pixels. Stop here and return. Chris@0: if ( rnumnonpx.test( val ) ) { Chris@0: return val; Chris@0: } Chris@0: Chris@0: // Check for style in case a browser which returns unreliable values Chris@0: // for getComputedStyle silently falls back to the reliable elem.style Chris@0: valueIsBorderBox = isBorderBox && Chris@0: ( support.boxSizingReliable() || val === elem.style[ name ] ); Chris@0: Chris@0: // Fall back to offsetWidth/Height when value is "auto" Chris@0: // This happens for inline elements with no explicit setting (gh-3571) Chris@0: if ( val === "auto" ) { Chris@0: val = elem[ "offset" + name[ 0 ].toUpperCase() + name.slice( 1 ) ]; Chris@0: } Chris@0: Chris@0: // Normalize "", auto, and prepare for extra Chris@0: val = parseFloat( val ) || 0; Chris@0: Chris@0: // Use the active box-sizing model to add/subtract irrelevant styles Chris@0: return ( val + Chris@0: augmentWidthOrHeight( Chris@0: elem, Chris@0: name, Chris@0: extra || ( isBorderBox ? "border" : "content" ), Chris@0: valueIsBorderBox, Chris@0: styles Chris@0: ) Chris@0: ) + "px"; Chris@0: } Chris@0: Chris@0: jQuery.extend( { Chris@0: Chris@0: // Add in style property hooks for overriding the default Chris@0: // behavior of getting and setting a style property Chris@0: cssHooks: { Chris@0: opacity: { Chris@0: get: function( elem, computed ) { Chris@0: if ( computed ) { Chris@0: Chris@0: // We should always get a number back from opacity Chris@0: var ret = curCSS( elem, "opacity" ); Chris@0: return ret === "" ? "1" : ret; Chris@0: } Chris@0: } Chris@0: } Chris@0: }, Chris@0: Chris@0: // Don't automatically add "px" to these possibly-unitless properties Chris@0: cssNumber: { Chris@0: "animationIterationCount": true, Chris@0: "columnCount": true, Chris@0: "fillOpacity": true, Chris@0: "flexGrow": true, Chris@0: "flexShrink": true, Chris@0: "fontWeight": true, Chris@0: "lineHeight": true, Chris@0: "opacity": true, Chris@0: "order": true, Chris@0: "orphans": true, Chris@0: "widows": true, Chris@0: "zIndex": true, Chris@0: "zoom": true Chris@0: }, Chris@0: Chris@0: // Add in properties whose names you wish to fix before Chris@0: // setting or getting the value Chris@0: cssProps: { Chris@0: "float": "cssFloat" Chris@0: }, Chris@0: Chris@0: // Get and set the style property on a DOM Node Chris@0: style: function( elem, name, value, extra ) { Chris@0: Chris@0: // Don't set styles on text and comment nodes Chris@0: if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Make sure that we're working with the right name Chris@0: var ret, type, hooks, Chris@0: origName = jQuery.camelCase( name ), Chris@0: isCustomProp = rcustomProp.test( name ), Chris@0: style = elem.style; Chris@0: Chris@0: // Make sure that we're working with the right name. We don't Chris@0: // want to query the value if it is a CSS custom property Chris@0: // since they are user-defined. Chris@0: if ( !isCustomProp ) { Chris@0: name = finalPropName( origName ); Chris@0: } Chris@0: Chris@0: // Gets hook for the prefixed version, then unprefixed version Chris@0: hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; Chris@0: Chris@0: // Check if we're setting a value Chris@0: if ( value !== undefined ) { Chris@0: type = typeof value; Chris@0: Chris@0: // Convert "+=" or "-=" to relative numbers (#7345) Chris@0: if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { Chris@0: value = adjustCSS( elem, name, ret ); Chris@0: Chris@0: // Fixes bug #9237 Chris@0: type = "number"; Chris@0: } Chris@0: Chris@0: // Make sure that null and NaN values aren't set (#7116) Chris@0: if ( value == null || value !== value ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // If a number was passed in, add the unit (except for certain CSS properties) Chris@0: if ( type === "number" ) { Chris@0: value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); Chris@0: } Chris@0: Chris@0: // background-* props affect original clone's values Chris@0: if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { Chris@0: style[ name ] = "inherit"; Chris@0: } Chris@0: Chris@0: // If a hook was provided, use that value, otherwise just set the specified value Chris@0: if ( !hooks || !( "set" in hooks ) || Chris@0: ( value = hooks.set( elem, value, extra ) ) !== undefined ) { Chris@0: Chris@0: if ( isCustomProp ) { Chris@0: style.setProperty( name, value ); Chris@0: } else { Chris@0: style[ name ] = value; Chris@0: } Chris@0: } Chris@0: Chris@0: } else { Chris@0: Chris@0: // If a hook was provided get the non-computed value from there Chris@0: if ( hooks && "get" in hooks && Chris@0: ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { Chris@0: Chris@0: return ret; Chris@0: } Chris@0: Chris@0: // Otherwise just get the value from the style object Chris@0: return style[ name ]; Chris@0: } Chris@0: }, Chris@0: Chris@0: css: function( elem, name, extra, styles ) { Chris@0: var val, num, hooks, Chris@0: origName = jQuery.camelCase( name ), Chris@0: isCustomProp = rcustomProp.test( name ); Chris@0: Chris@0: // Make sure that we're working with the right name. We don't Chris@0: // want to modify the value if it is a CSS custom property Chris@0: // since they are user-defined. Chris@0: if ( !isCustomProp ) { Chris@0: name = finalPropName( origName ); Chris@0: } Chris@0: Chris@0: // Try prefixed name followed by the unprefixed name Chris@0: hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; Chris@0: Chris@0: // If a hook was provided get the computed value from there Chris@0: if ( hooks && "get" in hooks ) { Chris@0: val = hooks.get( elem, true, extra ); Chris@0: } Chris@0: Chris@0: // Otherwise, if a way to get the computed value exists, use that Chris@0: if ( val === undefined ) { Chris@0: val = curCSS( elem, name, styles ); Chris@0: } Chris@0: Chris@0: // Convert "normal" to computed value Chris@0: if ( val === "normal" && name in cssNormalTransform ) { Chris@0: val = cssNormalTransform[ name ]; Chris@0: } Chris@0: Chris@0: // Make numeric if forced or a qualifier was provided and val looks numeric Chris@0: if ( extra === "" || extra ) { Chris@0: num = parseFloat( val ); Chris@0: return extra === true || isFinite( num ) ? num || 0 : val; Chris@0: } Chris@0: Chris@0: return val; Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.each( [ "height", "width" ], function( i, name ) { Chris@0: jQuery.cssHooks[ name ] = { Chris@0: get: function( elem, computed, extra ) { Chris@0: if ( computed ) { Chris@0: Chris@0: // Certain elements can have dimension info if we invisibly show them Chris@0: // but it must have a current display style that would benefit Chris@0: return rdisplayswap.test( jQuery.css( elem, "display" ) ) && Chris@0: Chris@0: // Support: Safari 8+ Chris@0: // Table columns in Safari have non-zero offsetWidth & zero Chris@0: // getBoundingClientRect().width unless display is changed. Chris@0: // Support: IE <=11 only Chris@0: // Running getBoundingClientRect on a disconnected node Chris@0: // in IE throws an error. Chris@0: ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? Chris@0: swap( elem, cssShow, function() { Chris@0: return getWidthOrHeight( elem, name, extra ); Chris@0: } ) : Chris@0: getWidthOrHeight( elem, name, extra ); Chris@0: } Chris@0: }, Chris@0: Chris@0: set: function( elem, value, extra ) { Chris@0: var matches, Chris@0: styles = extra && getStyles( elem ), Chris@0: subtract = extra && augmentWidthOrHeight( Chris@0: elem, Chris@0: name, Chris@0: extra, Chris@0: jQuery.css( elem, "boxSizing", false, styles ) === "border-box", Chris@0: styles Chris@0: ); Chris@0: Chris@0: // Convert to pixels if value adjustment is needed Chris@0: if ( subtract && ( matches = rcssNum.exec( value ) ) && Chris@0: ( matches[ 3 ] || "px" ) !== "px" ) { Chris@0: Chris@0: elem.style[ name ] = value; Chris@0: value = jQuery.css( elem, name ); Chris@0: } Chris@0: Chris@0: return setPositiveNumber( elem, value, subtract ); Chris@0: } Chris@0: }; Chris@0: } ); Chris@0: Chris@0: jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, Chris@0: function( elem, computed ) { Chris@0: if ( computed ) { Chris@0: return ( parseFloat( curCSS( elem, "marginLeft" ) ) || Chris@0: elem.getBoundingClientRect().left - Chris@0: swap( elem, { marginLeft: 0 }, function() { Chris@0: return elem.getBoundingClientRect().left; Chris@0: } ) Chris@0: ) + "px"; Chris@0: } Chris@0: } Chris@0: ); Chris@0: Chris@0: // These hooks are used by animate to expand properties Chris@0: jQuery.each( { Chris@0: margin: "", Chris@0: padding: "", Chris@0: border: "Width" Chris@0: }, function( prefix, suffix ) { Chris@0: jQuery.cssHooks[ prefix + suffix ] = { Chris@0: expand: function( value ) { Chris@0: var i = 0, Chris@0: expanded = {}, Chris@0: Chris@0: // Assumes a single number if not a string Chris@0: parts = typeof value === "string" ? value.split( " " ) : [ value ]; Chris@0: Chris@0: for ( ; i < 4; i++ ) { Chris@0: expanded[ prefix + cssExpand[ i ] + suffix ] = Chris@0: parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; Chris@0: } Chris@0: Chris@0: return expanded; Chris@0: } Chris@0: }; Chris@0: Chris@0: if ( !rmargin.test( prefix ) ) { Chris@0: jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: css: function( name, value ) { Chris@0: return access( this, function( elem, name, value ) { Chris@0: var styles, len, Chris@0: map = {}, Chris@0: i = 0; Chris@0: Chris@0: if ( Array.isArray( name ) ) { Chris@0: styles = getStyles( elem ); Chris@0: len = name.length; Chris@0: Chris@0: for ( ; i < len; i++ ) { Chris@0: map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); Chris@0: } Chris@0: Chris@0: return map; Chris@0: } Chris@0: Chris@0: return value !== undefined ? Chris@0: jQuery.style( elem, name, value ) : Chris@0: jQuery.css( elem, name ); Chris@0: }, name, value, arguments.length > 1 ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: function Tween( elem, options, prop, end, easing ) { Chris@0: return new Tween.prototype.init( elem, options, prop, end, easing ); Chris@0: } Chris@0: jQuery.Tween = Tween; Chris@0: Chris@0: Tween.prototype = { Chris@0: constructor: Tween, Chris@0: init: function( elem, options, prop, end, easing, unit ) { Chris@0: this.elem = elem; Chris@0: this.prop = prop; Chris@0: this.easing = easing || jQuery.easing._default; Chris@0: this.options = options; Chris@0: this.start = this.now = this.cur(); Chris@0: this.end = end; Chris@0: this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); Chris@0: }, Chris@0: cur: function() { Chris@0: var hooks = Tween.propHooks[ this.prop ]; Chris@0: Chris@0: return hooks && hooks.get ? Chris@0: hooks.get( this ) : Chris@0: Tween.propHooks._default.get( this ); Chris@0: }, Chris@0: run: function( percent ) { Chris@0: var eased, Chris@0: hooks = Tween.propHooks[ this.prop ]; Chris@0: Chris@0: if ( this.options.duration ) { Chris@0: this.pos = eased = jQuery.easing[ this.easing ]( Chris@0: percent, this.options.duration * percent, 0, 1, this.options.duration Chris@0: ); Chris@0: } else { Chris@0: this.pos = eased = percent; Chris@0: } Chris@0: this.now = ( this.end - this.start ) * eased + this.start; Chris@0: Chris@0: if ( this.options.step ) { Chris@0: this.options.step.call( this.elem, this.now, this ); Chris@0: } Chris@0: Chris@0: if ( hooks && hooks.set ) { Chris@0: hooks.set( this ); Chris@0: } else { Chris@0: Tween.propHooks._default.set( this ); Chris@0: } Chris@0: return this; Chris@0: } Chris@0: }; Chris@0: Chris@0: Tween.prototype.init.prototype = Tween.prototype; Chris@0: Chris@0: Tween.propHooks = { Chris@0: _default: { Chris@0: get: function( tween ) { Chris@0: var result; Chris@0: Chris@0: // Use a property on the element directly when it is not a DOM element, Chris@0: // or when there is no matching style property that exists. Chris@0: if ( tween.elem.nodeType !== 1 || Chris@0: tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { Chris@0: return tween.elem[ tween.prop ]; Chris@0: } Chris@0: Chris@0: // Passing an empty string as a 3rd parameter to .css will automatically Chris@0: // attempt a parseFloat and fallback to a string if the parse fails. Chris@0: // Simple values such as "10px" are parsed to Float; Chris@0: // complex values such as "rotate(1rad)" are returned as-is. Chris@0: result = jQuery.css( tween.elem, tween.prop, "" ); Chris@0: Chris@0: // Empty strings, null, undefined and "auto" are converted to 0. Chris@0: return !result || result === "auto" ? 0 : result; Chris@0: }, Chris@0: set: function( tween ) { Chris@0: Chris@0: // Use step hook for back compat. Chris@0: // Use cssHook if its there. Chris@0: // Use .style if available and use plain properties where available. Chris@0: if ( jQuery.fx.step[ tween.prop ] ) { Chris@0: jQuery.fx.step[ tween.prop ]( tween ); Chris@0: } else if ( tween.elem.nodeType === 1 && Chris@0: ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || Chris@0: jQuery.cssHooks[ tween.prop ] ) ) { Chris@0: jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); Chris@0: } else { Chris@0: tween.elem[ tween.prop ] = tween.now; Chris@0: } Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: // Support: IE <=9 only Chris@0: // Panic based approach to setting things on disconnected nodes Chris@0: Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { Chris@0: set: function( tween ) { Chris@0: if ( tween.elem.nodeType && tween.elem.parentNode ) { Chris@0: tween.elem[ tween.prop ] = tween.now; Chris@0: } Chris@0: } Chris@0: }; Chris@0: Chris@0: jQuery.easing = { Chris@0: linear: function( p ) { Chris@0: return p; Chris@0: }, Chris@0: swing: function( p ) { Chris@0: return 0.5 - Math.cos( p * Math.PI ) / 2; Chris@0: }, Chris@0: _default: "swing" Chris@0: }; Chris@0: Chris@0: jQuery.fx = Tween.prototype.init; Chris@0: Chris@0: // Back compat <1.8 extension point Chris@0: jQuery.fx.step = {}; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: var Chris@0: fxNow, inProgress, Chris@0: rfxtypes = /^(?:toggle|show|hide)$/, Chris@0: rrun = /queueHooks$/; Chris@0: Chris@0: function schedule() { Chris@0: if ( inProgress ) { Chris@0: if ( document.hidden === false && window.requestAnimationFrame ) { Chris@0: window.requestAnimationFrame( schedule ); Chris@0: } else { Chris@0: window.setTimeout( schedule, jQuery.fx.interval ); Chris@0: } Chris@0: Chris@0: jQuery.fx.tick(); Chris@0: } Chris@0: } Chris@0: Chris@0: // Animations created synchronously will run synchronously Chris@0: function createFxNow() { Chris@0: window.setTimeout( function() { Chris@0: fxNow = undefined; Chris@0: } ); Chris@0: return ( fxNow = jQuery.now() ); Chris@0: } Chris@0: Chris@0: // Generate parameters to create a standard animation Chris@0: function genFx( type, includeWidth ) { Chris@0: var which, Chris@0: i = 0, Chris@0: attrs = { height: type }; Chris@0: Chris@0: // If we include width, step value is 1 to do all cssExpand values, Chris@0: // otherwise step value is 2 to skip over Left and Right Chris@0: includeWidth = includeWidth ? 1 : 0; Chris@0: for ( ; i < 4; i += 2 - includeWidth ) { Chris@0: which = cssExpand[ i ]; Chris@0: attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; Chris@0: } Chris@0: Chris@0: if ( includeWidth ) { Chris@0: attrs.opacity = attrs.width = type; Chris@0: } Chris@0: Chris@0: return attrs; Chris@0: } Chris@0: Chris@0: function createTween( value, prop, animation ) { Chris@0: var tween, Chris@0: collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), Chris@0: index = 0, Chris@0: length = collection.length; Chris@0: for ( ; index < length; index++ ) { Chris@0: if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { Chris@0: Chris@0: // We're done with this property Chris@0: return tween; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: function defaultPrefilter( elem, props, opts ) { Chris@0: var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, Chris@0: isBox = "width" in props || "height" in props, Chris@0: anim = this, Chris@0: orig = {}, Chris@0: style = elem.style, Chris@0: hidden = elem.nodeType && isHiddenWithinTree( elem ), Chris@0: dataShow = dataPriv.get( elem, "fxshow" ); Chris@0: Chris@0: // Queue-skipping animations hijack the fx hooks Chris@0: if ( !opts.queue ) { Chris@0: hooks = jQuery._queueHooks( elem, "fx" ); Chris@0: if ( hooks.unqueued == null ) { Chris@0: hooks.unqueued = 0; Chris@0: oldfire = hooks.empty.fire; Chris@0: hooks.empty.fire = function() { Chris@0: if ( !hooks.unqueued ) { Chris@0: oldfire(); Chris@0: } Chris@0: }; Chris@0: } Chris@0: hooks.unqueued++; Chris@0: Chris@0: anim.always( function() { Chris@0: Chris@0: // Ensure the complete handler is called before this completes Chris@0: anim.always( function() { Chris@0: hooks.unqueued--; Chris@0: if ( !jQuery.queue( elem, "fx" ).length ) { Chris@0: hooks.empty.fire(); Chris@0: } Chris@0: } ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: // Detect show/hide animations Chris@0: for ( prop in props ) { Chris@0: value = props[ prop ]; Chris@0: if ( rfxtypes.test( value ) ) { Chris@0: delete props[ prop ]; Chris@0: toggle = toggle || value === "toggle"; Chris@0: if ( value === ( hidden ? "hide" : "show" ) ) { Chris@0: Chris@0: // Pretend to be hidden if this is a "show" and Chris@0: // there is still data from a stopped show/hide Chris@0: if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { Chris@0: hidden = true; Chris@0: Chris@0: // Ignore all other no-op show/hide data Chris@0: } else { Chris@0: continue; Chris@0: } Chris@0: } Chris@0: orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Bail out if this is a no-op like .hide().hide() Chris@0: propTween = !jQuery.isEmptyObject( props ); Chris@0: if ( !propTween && jQuery.isEmptyObject( orig ) ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Restrict "overflow" and "display" styles during box animations Chris@0: if ( isBox && elem.nodeType === 1 ) { Chris@0: Chris@0: // Support: IE <=9 - 11, Edge 12 - 13 Chris@0: // Record all 3 overflow attributes because IE does not infer the shorthand Chris@0: // from identically-valued overflowX and overflowY Chris@0: opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; Chris@0: Chris@0: // Identify a display type, preferring old show/hide data over the CSS cascade Chris@0: restoreDisplay = dataShow && dataShow.display; Chris@0: if ( restoreDisplay == null ) { Chris@0: restoreDisplay = dataPriv.get( elem, "display" ); Chris@0: } Chris@0: display = jQuery.css( elem, "display" ); Chris@0: if ( display === "none" ) { Chris@0: if ( restoreDisplay ) { Chris@0: display = restoreDisplay; Chris@0: } else { Chris@0: Chris@0: // Get nonempty value(s) by temporarily forcing visibility Chris@0: showHide( [ elem ], true ); Chris@0: restoreDisplay = elem.style.display || restoreDisplay; Chris@0: display = jQuery.css( elem, "display" ); Chris@0: showHide( [ elem ] ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Animate inline elements as inline-block Chris@0: if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { Chris@0: if ( jQuery.css( elem, "float" ) === "none" ) { Chris@0: Chris@0: // Restore the original display value at the end of pure show/hide animations Chris@0: if ( !propTween ) { Chris@0: anim.done( function() { Chris@0: style.display = restoreDisplay; Chris@0: } ); Chris@0: if ( restoreDisplay == null ) { Chris@0: display = style.display; Chris@0: restoreDisplay = display === "none" ? "" : display; Chris@0: } Chris@0: } Chris@0: style.display = "inline-block"; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: if ( opts.overflow ) { Chris@0: style.overflow = "hidden"; Chris@0: anim.always( function() { Chris@0: style.overflow = opts.overflow[ 0 ]; Chris@0: style.overflowX = opts.overflow[ 1 ]; Chris@0: style.overflowY = opts.overflow[ 2 ]; Chris@0: } ); Chris@0: } Chris@0: Chris@0: // Implement show/hide animations Chris@0: propTween = false; Chris@0: for ( prop in orig ) { Chris@0: Chris@0: // General show/hide setup for this element animation Chris@0: if ( !propTween ) { Chris@0: if ( dataShow ) { Chris@0: if ( "hidden" in dataShow ) { Chris@0: hidden = dataShow.hidden; Chris@0: } Chris@0: } else { Chris@0: dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); Chris@0: } Chris@0: Chris@0: // Store hidden/visible for toggle so `.stop().toggle()` "reverses" Chris@0: if ( toggle ) { Chris@0: dataShow.hidden = !hidden; Chris@0: } Chris@0: Chris@0: // Show elements before animating them Chris@0: if ( hidden ) { Chris@0: showHide( [ elem ], true ); Chris@0: } Chris@0: Chris@0: /* eslint-disable no-loop-func */ Chris@0: Chris@0: anim.done( function() { Chris@0: Chris@0: /* eslint-enable no-loop-func */ Chris@0: Chris@0: // The final step of a "hide" animation is actually hiding the element Chris@0: if ( !hidden ) { Chris@0: showHide( [ elem ] ); Chris@0: } Chris@0: dataPriv.remove( elem, "fxshow" ); Chris@0: for ( prop in orig ) { Chris@0: jQuery.style( elem, prop, orig[ prop ] ); Chris@0: } Chris@0: } ); Chris@0: } Chris@0: Chris@0: // Per-property setup Chris@0: propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); Chris@0: if ( !( prop in dataShow ) ) { Chris@0: dataShow[ prop ] = propTween.start; Chris@0: if ( hidden ) { Chris@0: propTween.end = propTween.start; Chris@0: propTween.start = 0; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: function propFilter( props, specialEasing ) { Chris@0: var index, name, easing, value, hooks; Chris@0: Chris@0: // camelCase, specialEasing and expand cssHook pass Chris@0: for ( index in props ) { Chris@0: name = jQuery.camelCase( index ); Chris@0: easing = specialEasing[ name ]; Chris@0: value = props[ index ]; Chris@0: if ( Array.isArray( value ) ) { Chris@0: easing = value[ 1 ]; Chris@0: value = props[ index ] = value[ 0 ]; Chris@0: } Chris@0: Chris@0: if ( index !== name ) { Chris@0: props[ name ] = value; Chris@0: delete props[ index ]; Chris@0: } Chris@0: Chris@0: hooks = jQuery.cssHooks[ name ]; Chris@0: if ( hooks && "expand" in hooks ) { Chris@0: value = hooks.expand( value ); Chris@0: delete props[ name ]; Chris@0: Chris@0: // Not quite $.extend, this won't overwrite existing keys. Chris@0: // Reusing 'index' because we have the correct "name" Chris@0: for ( index in value ) { Chris@0: if ( !( index in props ) ) { Chris@0: props[ index ] = value[ index ]; Chris@0: specialEasing[ index ] = easing; Chris@0: } Chris@0: } Chris@0: } else { Chris@0: specialEasing[ name ] = easing; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: function Animation( elem, properties, options ) { Chris@0: var result, Chris@0: stopped, Chris@0: index = 0, Chris@0: length = Animation.prefilters.length, Chris@0: deferred = jQuery.Deferred().always( function() { Chris@0: Chris@0: // Don't match elem in the :animated selector Chris@0: delete tick.elem; Chris@0: } ), Chris@0: tick = function() { Chris@0: if ( stopped ) { Chris@0: return false; Chris@0: } Chris@0: var currentTime = fxNow || createFxNow(), Chris@0: remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), Chris@0: Chris@0: // Support: Android 2.3 only Chris@0: // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) Chris@0: temp = remaining / animation.duration || 0, Chris@0: percent = 1 - temp, Chris@0: index = 0, Chris@0: length = animation.tweens.length; Chris@0: Chris@0: for ( ; index < length; index++ ) { Chris@0: animation.tweens[ index ].run( percent ); Chris@0: } Chris@0: Chris@0: deferred.notifyWith( elem, [ animation, percent, remaining ] ); Chris@0: Chris@0: // If there's more to do, yield Chris@0: if ( percent < 1 && length ) { Chris@0: return remaining; Chris@0: } Chris@0: Chris@0: // If this was an empty animation, synthesize a final progress notification Chris@0: if ( !length ) { Chris@0: deferred.notifyWith( elem, [ animation, 1, 0 ] ); Chris@0: } Chris@0: Chris@0: // Resolve the animation and report its conclusion Chris@0: deferred.resolveWith( elem, [ animation ] ); Chris@0: return false; Chris@0: }, Chris@0: animation = deferred.promise( { Chris@0: elem: elem, Chris@0: props: jQuery.extend( {}, properties ), Chris@0: opts: jQuery.extend( true, { Chris@0: specialEasing: {}, Chris@0: easing: jQuery.easing._default Chris@0: }, options ), Chris@0: originalProperties: properties, Chris@0: originalOptions: options, Chris@0: startTime: fxNow || createFxNow(), Chris@0: duration: options.duration, Chris@0: tweens: [], Chris@0: createTween: function( prop, end ) { Chris@0: var tween = jQuery.Tween( elem, animation.opts, prop, end, Chris@0: animation.opts.specialEasing[ prop ] || animation.opts.easing ); Chris@0: animation.tweens.push( tween ); Chris@0: return tween; Chris@0: }, Chris@0: stop: function( gotoEnd ) { Chris@0: var index = 0, Chris@0: Chris@0: // If we are going to the end, we want to run all the tweens Chris@0: // otherwise we skip this part Chris@0: length = gotoEnd ? animation.tweens.length : 0; Chris@0: if ( stopped ) { Chris@0: return this; Chris@0: } Chris@0: stopped = true; Chris@0: for ( ; index < length; index++ ) { Chris@0: animation.tweens[ index ].run( 1 ); Chris@0: } Chris@0: Chris@0: // Resolve when we played the last frame; otherwise, reject Chris@0: if ( gotoEnd ) { Chris@0: deferred.notifyWith( elem, [ animation, 1, 0 ] ); Chris@0: deferred.resolveWith( elem, [ animation, gotoEnd ] ); Chris@0: } else { Chris@0: deferred.rejectWith( elem, [ animation, gotoEnd ] ); Chris@0: } Chris@0: return this; Chris@0: } Chris@0: } ), Chris@0: props = animation.props; Chris@0: Chris@0: propFilter( props, animation.opts.specialEasing ); Chris@0: Chris@0: for ( ; index < length; index++ ) { Chris@0: result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); Chris@0: if ( result ) { Chris@0: if ( jQuery.isFunction( result.stop ) ) { Chris@0: jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = Chris@0: jQuery.proxy( result.stop, result ); Chris@0: } Chris@0: return result; Chris@0: } Chris@0: } Chris@0: Chris@0: jQuery.map( props, createTween, animation ); Chris@0: Chris@0: if ( jQuery.isFunction( animation.opts.start ) ) { Chris@0: animation.opts.start.call( elem, animation ); Chris@0: } Chris@0: Chris@0: // Attach callbacks from options Chris@0: animation Chris@0: .progress( animation.opts.progress ) Chris@0: .done( animation.opts.done, animation.opts.complete ) Chris@0: .fail( animation.opts.fail ) Chris@0: .always( animation.opts.always ); Chris@0: Chris@0: jQuery.fx.timer( Chris@0: jQuery.extend( tick, { Chris@0: elem: elem, Chris@0: anim: animation, Chris@0: queue: animation.opts.queue Chris@0: } ) Chris@0: ); Chris@0: Chris@0: return animation; Chris@0: } Chris@0: Chris@0: jQuery.Animation = jQuery.extend( Animation, { Chris@0: Chris@0: tweeners: { Chris@0: "*": [ function( prop, value ) { Chris@0: var tween = this.createTween( prop, value ); Chris@0: adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); Chris@0: return tween; Chris@0: } ] Chris@0: }, Chris@0: Chris@0: tweener: function( props, callback ) { Chris@0: if ( jQuery.isFunction( props ) ) { Chris@0: callback = props; Chris@0: props = [ "*" ]; Chris@0: } else { Chris@0: props = props.match( rnothtmlwhite ); Chris@0: } Chris@0: Chris@0: var prop, Chris@0: index = 0, Chris@0: length = props.length; Chris@0: Chris@0: for ( ; index < length; index++ ) { Chris@0: prop = props[ index ]; Chris@0: Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; Chris@0: Animation.tweeners[ prop ].unshift( callback ); Chris@0: } Chris@0: }, Chris@0: Chris@0: prefilters: [ defaultPrefilter ], Chris@0: Chris@0: prefilter: function( callback, prepend ) { Chris@0: if ( prepend ) { Chris@0: Animation.prefilters.unshift( callback ); Chris@0: } else { Chris@0: Animation.prefilters.push( callback ); Chris@0: } Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.speed = function( speed, easing, fn ) { Chris@0: var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { Chris@0: complete: fn || !fn && easing || Chris@0: jQuery.isFunction( speed ) && speed, Chris@0: duration: speed, Chris@0: easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing Chris@0: }; Chris@0: Chris@0: // Go to the end state if fx are off Chris@0: if ( jQuery.fx.off ) { Chris@0: opt.duration = 0; Chris@0: Chris@0: } else { Chris@0: if ( typeof opt.duration !== "number" ) { Chris@0: if ( opt.duration in jQuery.fx.speeds ) { Chris@0: opt.duration = jQuery.fx.speeds[ opt.duration ]; Chris@0: Chris@0: } else { Chris@0: opt.duration = jQuery.fx.speeds._default; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Normalize opt.queue - true/undefined/null -> "fx" Chris@0: if ( opt.queue == null || opt.queue === true ) { Chris@0: opt.queue = "fx"; Chris@0: } Chris@0: Chris@0: // Queueing Chris@0: opt.old = opt.complete; Chris@0: Chris@0: opt.complete = function() { Chris@0: if ( jQuery.isFunction( opt.old ) ) { Chris@0: opt.old.call( this ); Chris@0: } Chris@0: Chris@0: if ( opt.queue ) { Chris@0: jQuery.dequeue( this, opt.queue ); Chris@0: } Chris@0: }; Chris@0: Chris@0: return opt; Chris@0: }; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: fadeTo: function( speed, to, easing, callback ) { Chris@0: Chris@0: // Show any hidden elements after setting opacity to 0 Chris@0: return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() Chris@0: Chris@0: // Animate to the value specified Chris@0: .end().animate( { opacity: to }, speed, easing, callback ); Chris@0: }, Chris@0: animate: function( prop, speed, easing, callback ) { Chris@0: var empty = jQuery.isEmptyObject( prop ), Chris@0: optall = jQuery.speed( speed, easing, callback ), Chris@0: doAnimation = function() { Chris@0: Chris@0: // Operate on a copy of prop so per-property easing won't be lost Chris@0: var anim = Animation( this, jQuery.extend( {}, prop ), optall ); Chris@0: Chris@0: // Empty animations, or finishing resolves immediately Chris@0: if ( empty || dataPriv.get( this, "finish" ) ) { Chris@0: anim.stop( true ); Chris@0: } Chris@0: }; Chris@0: doAnimation.finish = doAnimation; Chris@0: Chris@0: return empty || optall.queue === false ? Chris@0: this.each( doAnimation ) : Chris@0: this.queue( optall.queue, doAnimation ); Chris@0: }, Chris@0: stop: function( type, clearQueue, gotoEnd ) { Chris@0: var stopQueue = function( hooks ) { Chris@0: var stop = hooks.stop; Chris@0: delete hooks.stop; Chris@0: stop( gotoEnd ); Chris@0: }; Chris@0: Chris@0: if ( typeof type !== "string" ) { Chris@0: gotoEnd = clearQueue; Chris@0: clearQueue = type; Chris@0: type = undefined; Chris@0: } Chris@0: if ( clearQueue && type !== false ) { Chris@0: this.queue( type || "fx", [] ); Chris@0: } Chris@0: Chris@0: return this.each( function() { Chris@0: var dequeue = true, Chris@0: index = type != null && type + "queueHooks", Chris@0: timers = jQuery.timers, Chris@0: data = dataPriv.get( this ); Chris@0: Chris@0: if ( index ) { Chris@0: if ( data[ index ] && data[ index ].stop ) { Chris@0: stopQueue( data[ index ] ); Chris@0: } Chris@0: } else { Chris@0: for ( index in data ) { Chris@0: if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { Chris@0: stopQueue( data[ index ] ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: for ( index = timers.length; index--; ) { Chris@0: if ( timers[ index ].elem === this && Chris@0: ( type == null || timers[ index ].queue === type ) ) { Chris@0: Chris@0: timers[ index ].anim.stop( gotoEnd ); Chris@0: dequeue = false; Chris@0: timers.splice( index, 1 ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Start the next in the queue if the last step wasn't forced. Chris@0: // Timers currently will call their complete callbacks, which Chris@0: // will dequeue but only if they were gotoEnd. Chris@0: if ( dequeue || !gotoEnd ) { Chris@0: jQuery.dequeue( this, type ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: finish: function( type ) { Chris@0: if ( type !== false ) { Chris@0: type = type || "fx"; Chris@0: } Chris@0: return this.each( function() { Chris@0: var index, Chris@0: data = dataPriv.get( this ), Chris@0: queue = data[ type + "queue" ], Chris@0: hooks = data[ type + "queueHooks" ], Chris@0: timers = jQuery.timers, Chris@0: length = queue ? queue.length : 0; Chris@0: Chris@0: // Enable finishing flag on private data Chris@0: data.finish = true; Chris@0: Chris@0: // Empty the queue first Chris@0: jQuery.queue( this, type, [] ); Chris@0: Chris@0: if ( hooks && hooks.stop ) { Chris@0: hooks.stop.call( this, true ); Chris@0: } Chris@0: Chris@0: // Look for any active animations, and finish them Chris@0: for ( index = timers.length; index--; ) { Chris@0: if ( timers[ index ].elem === this && timers[ index ].queue === type ) { Chris@0: timers[ index ].anim.stop( true ); Chris@0: timers.splice( index, 1 ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Look for any animations in the old queue and finish them Chris@0: for ( index = 0; index < length; index++ ) { Chris@0: if ( queue[ index ] && queue[ index ].finish ) { Chris@0: queue[ index ].finish.call( this ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Turn off finishing flag Chris@0: delete data.finish; Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) { Chris@0: var cssFn = jQuery.fn[ name ]; Chris@0: jQuery.fn[ name ] = function( speed, easing, callback ) { Chris@0: return speed == null || typeof speed === "boolean" ? Chris@0: cssFn.apply( this, arguments ) : Chris@0: this.animate( genFx( name, true ), speed, easing, callback ); Chris@0: }; Chris@0: } ); Chris@0: Chris@0: // Generate shortcuts for custom animations Chris@0: jQuery.each( { Chris@0: slideDown: genFx( "show" ), Chris@0: slideUp: genFx( "hide" ), Chris@0: slideToggle: genFx( "toggle" ), Chris@0: fadeIn: { opacity: "show" }, Chris@0: fadeOut: { opacity: "hide" }, Chris@0: fadeToggle: { opacity: "toggle" } Chris@0: }, function( name, props ) { Chris@0: jQuery.fn[ name ] = function( speed, easing, callback ) { Chris@0: return this.animate( props, speed, easing, callback ); Chris@0: }; Chris@0: } ); Chris@0: Chris@0: jQuery.timers = []; Chris@0: jQuery.fx.tick = function() { Chris@0: var timer, Chris@0: i = 0, Chris@0: timers = jQuery.timers; Chris@0: Chris@0: fxNow = jQuery.now(); Chris@0: Chris@0: for ( ; i < timers.length; i++ ) { Chris@0: timer = timers[ i ]; Chris@0: Chris@0: // Run the timer and safely remove it when done (allowing for external removal) Chris@0: if ( !timer() && timers[ i ] === timer ) { Chris@0: timers.splice( i--, 1 ); Chris@0: } Chris@0: } Chris@0: Chris@0: if ( !timers.length ) { Chris@0: jQuery.fx.stop(); Chris@0: } Chris@0: fxNow = undefined; Chris@0: }; Chris@0: Chris@0: jQuery.fx.timer = function( timer ) { Chris@0: jQuery.timers.push( timer ); Chris@0: jQuery.fx.start(); Chris@0: }; Chris@0: Chris@0: jQuery.fx.interval = 13; Chris@0: jQuery.fx.start = function() { Chris@0: if ( inProgress ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: inProgress = true; Chris@0: schedule(); Chris@0: }; Chris@0: Chris@0: jQuery.fx.stop = function() { Chris@0: inProgress = null; Chris@0: }; Chris@0: Chris@0: jQuery.fx.speeds = { Chris@0: slow: 600, Chris@0: fast: 200, Chris@0: Chris@0: // Default speed Chris@0: _default: 400 Chris@0: }; Chris@0: Chris@0: Chris@0: // Based off of the plugin by Clint Helfers, with permission. Chris@0: // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ Chris@0: jQuery.fn.delay = function( time, type ) { Chris@0: time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; Chris@0: type = type || "fx"; Chris@0: Chris@0: return this.queue( type, function( next, hooks ) { Chris@0: var timeout = window.setTimeout( next, time ); Chris@0: hooks.stop = function() { Chris@0: window.clearTimeout( timeout ); Chris@0: }; Chris@0: } ); Chris@0: }; Chris@0: Chris@0: Chris@0: ( function() { Chris@0: var input = document.createElement( "input" ), Chris@0: select = document.createElement( "select" ), Chris@0: opt = select.appendChild( document.createElement( "option" ) ); Chris@0: Chris@0: input.type = "checkbox"; Chris@0: Chris@0: // Support: Android <=4.3 only Chris@0: // Default value for a checkbox should be "on" Chris@0: support.checkOn = input.value !== ""; Chris@0: Chris@0: // Support: IE <=11 only Chris@0: // Must access selectedIndex to make default options select Chris@0: support.optSelected = opt.selected; Chris@0: Chris@0: // Support: IE <=11 only Chris@0: // An input loses its value after becoming a radio Chris@0: input = document.createElement( "input" ); Chris@0: input.value = "t"; Chris@0: input.type = "radio"; Chris@0: support.radioValue = input.value === "t"; Chris@0: } )(); Chris@0: Chris@0: Chris@0: var boolHook, Chris@0: attrHandle = jQuery.expr.attrHandle; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: attr: function( name, value ) { Chris@0: return access( this, jQuery.attr, name, value, arguments.length > 1 ); Chris@0: }, Chris@0: Chris@0: removeAttr: function( name ) { Chris@0: return this.each( function() { Chris@0: jQuery.removeAttr( this, name ); Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.extend( { Chris@0: attr: function( elem, name, value ) { Chris@0: var ret, hooks, Chris@0: nType = elem.nodeType; Chris@0: Chris@0: // Don't get/set attributes on text, comment and attribute nodes Chris@0: if ( nType === 3 || nType === 8 || nType === 2 ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Fallback to prop when attributes are not supported Chris@0: if ( typeof elem.getAttribute === "undefined" ) { Chris@0: return jQuery.prop( elem, name, value ); Chris@0: } Chris@0: Chris@0: // Attribute hooks are determined by the lowercase version Chris@0: // Grab necessary hook if one is defined Chris@0: if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { Chris@0: hooks = jQuery.attrHooks[ name.toLowerCase() ] || Chris@0: ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); Chris@0: } Chris@0: Chris@0: if ( value !== undefined ) { Chris@0: if ( value === null ) { Chris@0: jQuery.removeAttr( elem, name ); Chris@0: return; Chris@0: } Chris@0: Chris@0: if ( hooks && "set" in hooks && Chris@0: ( ret = hooks.set( elem, value, name ) ) !== undefined ) { Chris@0: return ret; Chris@0: } Chris@0: Chris@0: elem.setAttribute( name, value + "" ); Chris@0: return value; Chris@0: } Chris@0: Chris@0: if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { Chris@0: return ret; Chris@0: } Chris@0: Chris@0: ret = jQuery.find.attr( elem, name ); Chris@0: Chris@0: // Non-existent attributes return null, we normalize to undefined Chris@0: return ret == null ? undefined : ret; Chris@0: }, Chris@0: Chris@0: attrHooks: { Chris@0: type: { Chris@0: set: function( elem, value ) { Chris@0: if ( !support.radioValue && value === "radio" && Chris@0: nodeName( elem, "input" ) ) { Chris@0: var val = elem.value; Chris@0: elem.setAttribute( "type", value ); Chris@0: if ( val ) { Chris@0: elem.value = val; Chris@0: } Chris@0: return value; Chris@0: } Chris@0: } Chris@0: } Chris@0: }, Chris@0: Chris@0: removeAttr: function( elem, value ) { Chris@0: var name, Chris@0: i = 0, Chris@0: Chris@0: // Attribute names can contain non-HTML whitespace characters Chris@0: // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 Chris@0: attrNames = value && value.match( rnothtmlwhite ); Chris@0: Chris@0: if ( attrNames && elem.nodeType === 1 ) { Chris@0: while ( ( name = attrNames[ i++ ] ) ) { Chris@0: elem.removeAttribute( name ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } ); Chris@0: Chris@0: // Hooks for boolean attributes Chris@0: boolHook = { Chris@0: set: function( elem, value, name ) { Chris@0: if ( value === false ) { Chris@0: Chris@0: // Remove boolean attributes when set to false Chris@0: jQuery.removeAttr( elem, name ); Chris@0: } else { Chris@0: elem.setAttribute( name, name ); Chris@0: } Chris@0: return name; Chris@0: } Chris@0: }; Chris@0: Chris@0: jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) { Chris@0: var getter = attrHandle[ name ] || jQuery.find.attr; Chris@0: Chris@0: attrHandle[ name ] = function( elem, name, isXML ) { Chris@0: var ret, handle, Chris@0: lowercaseName = name.toLowerCase(); Chris@0: Chris@0: if ( !isXML ) { Chris@0: Chris@0: // Avoid an infinite loop by temporarily removing this function from the getter Chris@0: handle = attrHandle[ lowercaseName ]; Chris@0: attrHandle[ lowercaseName ] = ret; Chris@0: ret = getter( elem, name, isXML ) != null ? Chris@0: lowercaseName : Chris@0: null; Chris@0: attrHandle[ lowercaseName ] = handle; Chris@0: } Chris@0: return ret; Chris@0: }; Chris@0: } ); Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: var rfocusable = /^(?:input|select|textarea|button)$/i, Chris@0: rclickable = /^(?:a|area)$/i; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: prop: function( name, value ) { Chris@0: return access( this, jQuery.prop, name, value, arguments.length > 1 ); Chris@0: }, Chris@0: Chris@0: removeProp: function( name ) { Chris@0: return this.each( function() { Chris@0: delete this[ jQuery.propFix[ name ] || name ]; Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.extend( { Chris@0: prop: function( elem, name, value ) { Chris@0: var ret, hooks, Chris@0: nType = elem.nodeType; Chris@0: Chris@0: // Don't get/set properties on text, comment and attribute nodes Chris@0: if ( nType === 3 || nType === 8 || nType === 2 ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { Chris@0: Chris@0: // Fix name and attach hooks Chris@0: name = jQuery.propFix[ name ] || name; Chris@0: hooks = jQuery.propHooks[ name ]; Chris@0: } Chris@0: Chris@0: if ( value !== undefined ) { Chris@0: if ( hooks && "set" in hooks && Chris@0: ( ret = hooks.set( elem, value, name ) ) !== undefined ) { Chris@0: return ret; Chris@0: } Chris@0: Chris@0: return ( elem[ name ] = value ); Chris@0: } Chris@0: Chris@0: if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { Chris@0: return ret; Chris@0: } Chris@0: Chris@0: return elem[ name ]; Chris@0: }, Chris@0: Chris@0: propHooks: { Chris@0: tabIndex: { Chris@0: get: function( elem ) { Chris@0: Chris@0: // Support: IE <=9 - 11 only Chris@0: // elem.tabIndex doesn't always return the Chris@0: // correct value when it hasn't been explicitly set Chris@0: // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ Chris@0: // Use proper attribute retrieval(#12072) Chris@0: var tabindex = jQuery.find.attr( elem, "tabindex" ); Chris@0: Chris@0: if ( tabindex ) { Chris@0: return parseInt( tabindex, 10 ); Chris@0: } Chris@0: Chris@0: if ( Chris@0: rfocusable.test( elem.nodeName ) || Chris@0: rclickable.test( elem.nodeName ) && Chris@0: elem.href Chris@0: ) { Chris@0: return 0; Chris@0: } Chris@0: Chris@0: return -1; Chris@0: } Chris@0: } Chris@0: }, Chris@0: Chris@0: propFix: { Chris@0: "for": "htmlFor", Chris@0: "class": "className" Chris@0: } Chris@0: } ); Chris@0: Chris@0: // Support: IE <=11 only Chris@0: // Accessing the selectedIndex property Chris@0: // forces the browser to respect setting selected Chris@0: // on the option Chris@0: // The getter ensures a default option is selected Chris@0: // when in an optgroup Chris@0: // eslint rule "no-unused-expressions" is disabled for this code Chris@0: // since it considers such accessions noop Chris@0: if ( !support.optSelected ) { Chris@0: jQuery.propHooks.selected = { Chris@0: get: function( elem ) { Chris@0: Chris@0: /* eslint no-unused-expressions: "off" */ Chris@0: Chris@0: var parent = elem.parentNode; Chris@0: if ( parent && parent.parentNode ) { Chris@0: parent.parentNode.selectedIndex; Chris@0: } Chris@0: return null; Chris@0: }, Chris@0: set: function( elem ) { Chris@0: Chris@0: /* eslint no-unused-expressions: "off" */ Chris@0: Chris@0: var parent = elem.parentNode; Chris@0: if ( parent ) { Chris@0: parent.selectedIndex; Chris@0: Chris@0: if ( parent.parentNode ) { Chris@0: parent.parentNode.selectedIndex; Chris@0: } Chris@0: } Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: jQuery.each( [ Chris@0: "tabIndex", Chris@0: "readOnly", Chris@0: "maxLength", Chris@0: "cellSpacing", Chris@0: "cellPadding", Chris@0: "rowSpan", Chris@0: "colSpan", Chris@0: "useMap", Chris@0: "frameBorder", Chris@0: "contentEditable" Chris@0: ], function() { Chris@0: jQuery.propFix[ this.toLowerCase() ] = this; Chris@0: } ); Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: // Strip and collapse whitespace according to HTML spec Chris@0: // https://html.spec.whatwg.org/multipage/infrastructure.html#strip-and-collapse-whitespace Chris@0: function stripAndCollapse( value ) { Chris@0: var tokens = value.match( rnothtmlwhite ) || []; Chris@0: return tokens.join( " " ); Chris@0: } Chris@0: Chris@0: Chris@0: function getClass( elem ) { Chris@0: return elem.getAttribute && elem.getAttribute( "class" ) || ""; Chris@0: } Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: addClass: function( value ) { Chris@0: var classes, elem, cur, curValue, clazz, j, finalValue, Chris@0: i = 0; Chris@0: Chris@0: if ( jQuery.isFunction( value ) ) { Chris@0: return this.each( function( j ) { Chris@0: jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: if ( typeof value === "string" && value ) { Chris@0: classes = value.match( rnothtmlwhite ) || []; Chris@0: Chris@0: while ( ( elem = this[ i++ ] ) ) { Chris@0: curValue = getClass( elem ); Chris@0: cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); Chris@0: Chris@0: if ( cur ) { Chris@0: j = 0; Chris@0: while ( ( clazz = classes[ j++ ] ) ) { Chris@0: if ( cur.indexOf( " " + clazz + " " ) < 0 ) { Chris@0: cur += clazz + " "; Chris@0: } Chris@0: } Chris@0: Chris@0: // Only assign if different to avoid unneeded rendering. Chris@0: finalValue = stripAndCollapse( cur ); Chris@0: if ( curValue !== finalValue ) { Chris@0: elem.setAttribute( "class", finalValue ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return this; Chris@0: }, Chris@0: Chris@0: removeClass: function( value ) { Chris@0: var classes, elem, cur, curValue, clazz, j, finalValue, Chris@0: i = 0; Chris@0: Chris@0: if ( jQuery.isFunction( value ) ) { Chris@0: return this.each( function( j ) { Chris@0: jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: if ( !arguments.length ) { Chris@0: return this.attr( "class", "" ); Chris@0: } Chris@0: Chris@0: if ( typeof value === "string" && value ) { Chris@0: classes = value.match( rnothtmlwhite ) || []; Chris@0: Chris@0: while ( ( elem = this[ i++ ] ) ) { Chris@0: curValue = getClass( elem ); Chris@0: Chris@0: // This expression is here for better compressibility (see addClass) Chris@0: cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); Chris@0: Chris@0: if ( cur ) { Chris@0: j = 0; Chris@0: while ( ( clazz = classes[ j++ ] ) ) { Chris@0: Chris@0: // Remove *all* instances Chris@0: while ( cur.indexOf( " " + clazz + " " ) > -1 ) { Chris@0: cur = cur.replace( " " + clazz + " ", " " ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Only assign if different to avoid unneeded rendering. Chris@0: finalValue = stripAndCollapse( cur ); Chris@0: if ( curValue !== finalValue ) { Chris@0: elem.setAttribute( "class", finalValue ); Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return this; Chris@0: }, Chris@0: Chris@0: toggleClass: function( value, stateVal ) { Chris@0: var type = typeof value; Chris@0: Chris@0: if ( typeof stateVal === "boolean" && type === "string" ) { Chris@0: return stateVal ? this.addClass( value ) : this.removeClass( value ); Chris@0: } Chris@0: Chris@0: if ( jQuery.isFunction( value ) ) { Chris@0: return this.each( function( i ) { Chris@0: jQuery( this ).toggleClass( Chris@0: value.call( this, i, getClass( this ), stateVal ), Chris@0: stateVal Chris@0: ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: return this.each( function() { Chris@0: var className, i, self, classNames; Chris@0: Chris@0: if ( type === "string" ) { Chris@0: Chris@0: // Toggle individual class names Chris@0: i = 0; Chris@0: self = jQuery( this ); Chris@0: classNames = value.match( rnothtmlwhite ) || []; Chris@0: Chris@0: while ( ( className = classNames[ i++ ] ) ) { Chris@0: Chris@0: // Check each className given, space separated list Chris@0: if ( self.hasClass( className ) ) { Chris@0: self.removeClass( className ); Chris@0: } else { Chris@0: self.addClass( className ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Toggle whole class name Chris@0: } else if ( value === undefined || type === "boolean" ) { Chris@0: className = getClass( this ); Chris@0: if ( className ) { Chris@0: Chris@0: // Store className if set Chris@0: dataPriv.set( this, "__className__", className ); Chris@0: } Chris@0: Chris@0: // If the element has a class name or if we're passed `false`, Chris@0: // then remove the whole classname (if there was one, the above saved it). Chris@0: // Otherwise bring back whatever was previously saved (if anything), Chris@0: // falling back to the empty string if nothing was stored. Chris@0: if ( this.setAttribute ) { Chris@0: this.setAttribute( "class", Chris@0: className || value === false ? Chris@0: "" : Chris@0: dataPriv.get( this, "__className__" ) || "" Chris@0: ); Chris@0: } Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: hasClass: function( selector ) { Chris@0: var className, elem, Chris@0: i = 0; Chris@0: Chris@0: className = " " + selector + " "; Chris@0: while ( ( elem = this[ i++ ] ) ) { Chris@0: if ( elem.nodeType === 1 && Chris@0: ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { Chris@0: return true; Chris@0: } Chris@0: } Chris@0: Chris@0: return false; Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: var rreturn = /\r/g; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: val: function( value ) { Chris@0: var hooks, ret, isFunction, Chris@0: elem = this[ 0 ]; Chris@0: Chris@0: if ( !arguments.length ) { Chris@0: if ( elem ) { Chris@0: hooks = jQuery.valHooks[ elem.type ] || Chris@0: jQuery.valHooks[ elem.nodeName.toLowerCase() ]; Chris@0: Chris@0: if ( hooks && Chris@0: "get" in hooks && Chris@0: ( ret = hooks.get( elem, "value" ) ) !== undefined Chris@0: ) { Chris@0: return ret; Chris@0: } Chris@0: Chris@0: ret = elem.value; Chris@0: Chris@0: // Handle most common string cases Chris@0: if ( typeof ret === "string" ) { Chris@0: return ret.replace( rreturn, "" ); Chris@0: } Chris@0: Chris@0: // Handle cases where value is null/undef or number Chris@0: return ret == null ? "" : ret; Chris@0: } Chris@0: Chris@0: return; Chris@0: } Chris@0: Chris@0: isFunction = jQuery.isFunction( value ); Chris@0: Chris@0: return this.each( function( i ) { Chris@0: var val; Chris@0: Chris@0: if ( this.nodeType !== 1 ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: if ( isFunction ) { Chris@0: val = value.call( this, i, jQuery( this ).val() ); Chris@0: } else { Chris@0: val = value; Chris@0: } Chris@0: Chris@0: // Treat null/undefined as ""; convert numbers to string Chris@0: if ( val == null ) { Chris@0: val = ""; Chris@0: Chris@0: } else if ( typeof val === "number" ) { Chris@0: val += ""; Chris@0: Chris@0: } else if ( Array.isArray( val ) ) { Chris@0: val = jQuery.map( val, function( value ) { Chris@0: return value == null ? "" : value + ""; Chris@0: } ); Chris@0: } Chris@0: Chris@0: hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; Chris@0: Chris@0: // If set returns undefined, fall back to normal setting Chris@0: if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { Chris@0: this.value = val; Chris@0: } Chris@0: } ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.extend( { Chris@0: valHooks: { Chris@0: option: { Chris@0: get: function( elem ) { Chris@0: Chris@0: var val = jQuery.find.attr( elem, "value" ); Chris@0: return val != null ? Chris@0: val : Chris@0: Chris@0: // Support: IE <=10 - 11 only Chris@0: // option.text throws exceptions (#14686, #14858) Chris@0: // Strip and collapse whitespace Chris@0: // https://html.spec.whatwg.org/#strip-and-collapse-whitespace Chris@0: stripAndCollapse( jQuery.text( elem ) ); Chris@0: } Chris@0: }, Chris@0: select: { Chris@0: get: function( elem ) { Chris@0: var value, option, i, Chris@0: options = elem.options, Chris@0: index = elem.selectedIndex, Chris@0: one = elem.type === "select-one", Chris@0: values = one ? null : [], Chris@0: max = one ? index + 1 : options.length; Chris@0: Chris@0: if ( index < 0 ) { Chris@0: i = max; Chris@0: Chris@0: } else { Chris@0: i = one ? index : 0; Chris@0: } Chris@0: Chris@0: // Loop through all the selected options Chris@0: for ( ; i < max; i++ ) { Chris@0: option = options[ i ]; Chris@0: Chris@0: // Support: IE <=9 only Chris@0: // IE8-9 doesn't update selected after form reset (#2551) Chris@0: if ( ( option.selected || i === index ) && Chris@0: Chris@0: // Don't return options that are disabled or in a disabled optgroup Chris@0: !option.disabled && Chris@0: ( !option.parentNode.disabled || Chris@0: !nodeName( option.parentNode, "optgroup" ) ) ) { Chris@0: Chris@0: // Get the specific value for the option Chris@0: value = jQuery( option ).val(); Chris@0: Chris@0: // We don't need an array for one selects Chris@0: if ( one ) { Chris@0: return value; Chris@0: } Chris@0: Chris@0: // Multi-Selects return an array Chris@0: values.push( value ); Chris@0: } Chris@0: } Chris@0: Chris@0: return values; Chris@0: }, Chris@0: Chris@0: set: function( elem, value ) { Chris@0: var optionSet, option, Chris@0: options = elem.options, Chris@0: values = jQuery.makeArray( value ), Chris@0: i = options.length; Chris@0: Chris@0: while ( i-- ) { Chris@0: option = options[ i ]; Chris@0: Chris@0: /* eslint-disable no-cond-assign */ Chris@0: Chris@0: if ( option.selected = Chris@0: jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 Chris@0: ) { Chris@0: optionSet = true; Chris@0: } Chris@0: Chris@0: /* eslint-enable no-cond-assign */ Chris@0: } Chris@0: Chris@0: // Force browsers to behave consistently when non-matching value is set Chris@0: if ( !optionSet ) { Chris@0: elem.selectedIndex = -1; Chris@0: } Chris@0: return values; Chris@0: } Chris@0: } Chris@0: } Chris@0: } ); Chris@0: Chris@0: // Radios and checkboxes getter/setter Chris@0: jQuery.each( [ "radio", "checkbox" ], function() { Chris@0: jQuery.valHooks[ this ] = { Chris@0: set: function( elem, value ) { Chris@0: if ( Array.isArray( value ) ) { Chris@0: return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); Chris@0: } Chris@0: } Chris@0: }; Chris@0: if ( !support.checkOn ) { Chris@0: jQuery.valHooks[ this ].get = function( elem ) { Chris@0: return elem.getAttribute( "value" ) === null ? "on" : elem.value; Chris@0: }; Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: // Return jQuery for attributes-only inclusion Chris@0: Chris@0: Chris@0: var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; Chris@0: Chris@0: jQuery.extend( jQuery.event, { Chris@0: Chris@0: trigger: function( event, data, elem, onlyHandlers ) { Chris@0: Chris@0: var i, cur, tmp, bubbleType, ontype, handle, special, Chris@0: eventPath = [ elem || document ], Chris@0: type = hasOwn.call( event, "type" ) ? event.type : event, Chris@0: namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; Chris@0: Chris@0: cur = tmp = elem = elem || document; Chris@0: Chris@0: // Don't do events on text and comment nodes Chris@0: if ( elem.nodeType === 3 || elem.nodeType === 8 ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // focus/blur morphs to focusin/out; ensure we're not firing them right now Chris@0: if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: if ( type.indexOf( "." ) > -1 ) { Chris@0: Chris@0: // Namespaced trigger; create a regexp to match event type in handle() Chris@0: namespaces = type.split( "." ); Chris@0: type = namespaces.shift(); Chris@0: namespaces.sort(); Chris@0: } Chris@0: ontype = type.indexOf( ":" ) < 0 && "on" + type; Chris@0: Chris@0: // Caller can pass in a jQuery.Event object, Object, or just an event type string Chris@0: event = event[ jQuery.expando ] ? Chris@0: event : Chris@0: new jQuery.Event( type, typeof event === "object" && event ); Chris@0: Chris@0: // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) Chris@0: event.isTrigger = onlyHandlers ? 2 : 3; Chris@0: event.namespace = namespaces.join( "." ); Chris@0: event.rnamespace = event.namespace ? Chris@0: new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : Chris@0: null; Chris@0: Chris@0: // Clean up the event in case it is being reused Chris@0: event.result = undefined; Chris@0: if ( !event.target ) { Chris@0: event.target = elem; Chris@0: } Chris@0: Chris@0: // Clone any incoming data and prepend the event, creating the handler arg list Chris@0: data = data == null ? Chris@0: [ event ] : Chris@0: jQuery.makeArray( data, [ event ] ); Chris@0: Chris@0: // Allow special events to draw outside the lines Chris@0: special = jQuery.event.special[ type ] || {}; Chris@0: if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: // Determine event propagation path in advance, per W3C events spec (#9951) Chris@0: // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) Chris@0: if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { Chris@0: Chris@0: bubbleType = special.delegateType || type; Chris@0: if ( !rfocusMorph.test( bubbleType + type ) ) { Chris@0: cur = cur.parentNode; Chris@0: } Chris@0: for ( ; cur; cur = cur.parentNode ) { Chris@0: eventPath.push( cur ); Chris@0: tmp = cur; Chris@0: } Chris@0: Chris@0: // Only add window if we got to document (e.g., not plain obj or detached DOM) Chris@0: if ( tmp === ( elem.ownerDocument || document ) ) { Chris@0: eventPath.push( tmp.defaultView || tmp.parentWindow || window ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Fire handlers on the event path Chris@0: i = 0; Chris@0: while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { Chris@0: Chris@0: event.type = i > 1 ? Chris@0: bubbleType : Chris@0: special.bindType || type; Chris@0: Chris@0: // jQuery handler Chris@0: handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] && Chris@0: dataPriv.get( cur, "handle" ); Chris@0: if ( handle ) { Chris@0: handle.apply( cur, data ); Chris@0: } Chris@0: Chris@0: // Native handler Chris@0: handle = ontype && cur[ ontype ]; Chris@0: if ( handle && handle.apply && acceptData( cur ) ) { Chris@0: event.result = handle.apply( cur, data ); Chris@0: if ( event.result === false ) { Chris@0: event.preventDefault(); Chris@0: } Chris@0: } Chris@0: } Chris@0: event.type = type; Chris@0: Chris@0: // If nobody prevented the default action, do it now Chris@0: if ( !onlyHandlers && !event.isDefaultPrevented() ) { Chris@0: Chris@0: if ( ( !special._default || Chris@0: special._default.apply( eventPath.pop(), data ) === false ) && Chris@0: acceptData( elem ) ) { Chris@0: Chris@0: // Call a native DOM method on the target with the same name as the event. Chris@0: // Don't do default actions on window, that's where global variables be (#6170) Chris@0: if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { Chris@0: Chris@0: // Don't re-trigger an onFOO event when we call its FOO() method Chris@0: tmp = elem[ ontype ]; Chris@0: Chris@0: if ( tmp ) { Chris@0: elem[ ontype ] = null; Chris@0: } Chris@0: Chris@0: // Prevent re-triggering of the same event, since we already bubbled it above Chris@0: jQuery.event.triggered = type; Chris@0: elem[ type ](); Chris@0: jQuery.event.triggered = undefined; Chris@0: Chris@0: if ( tmp ) { Chris@0: elem[ ontype ] = tmp; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return event.result; Chris@0: }, Chris@0: Chris@0: // Piggyback on a donor event to simulate a different one Chris@0: // Used only for `focus(in | out)` events Chris@0: simulate: function( type, elem, event ) { Chris@0: var e = jQuery.extend( Chris@0: new jQuery.Event(), Chris@0: event, Chris@0: { Chris@0: type: type, Chris@0: isSimulated: true Chris@0: } Chris@0: ); Chris@0: Chris@0: jQuery.event.trigger( e, null, elem ); Chris@0: } Chris@0: Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: Chris@0: trigger: function( type, data ) { Chris@0: return this.each( function() { Chris@0: jQuery.event.trigger( type, data, this ); Chris@0: } ); Chris@0: }, Chris@0: triggerHandler: function( type, data ) { Chris@0: var elem = this[ 0 ]; Chris@0: if ( elem ) { Chris@0: return jQuery.event.trigger( type, data, elem, true ); Chris@0: } Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " + Chris@0: "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + Chris@0: "change select submit keydown keypress keyup contextmenu" ).split( " " ), Chris@0: function( i, name ) { Chris@0: Chris@0: // Handle event binding Chris@0: jQuery.fn[ name ] = function( data, fn ) { Chris@0: return arguments.length > 0 ? Chris@0: this.on( name, null, data, fn ) : Chris@0: this.trigger( name ); Chris@0: }; Chris@0: } ); Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: hover: function( fnOver, fnOut ) { Chris@0: return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: support.focusin = "onfocusin" in window; Chris@0: Chris@0: Chris@0: // Support: Firefox <=44 Chris@0: // Firefox doesn't have focus(in | out) events Chris@0: // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 Chris@0: // Chris@0: // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 Chris@0: // focus(in | out) events fire after focus & blur events, Chris@0: // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order Chris@0: // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 Chris@0: if ( !support.focusin ) { Chris@0: jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { Chris@0: Chris@0: // Attach a single capturing handler on the document while someone wants focusin/focusout Chris@0: var handler = function( event ) { Chris@0: jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); Chris@0: }; Chris@0: Chris@0: jQuery.event.special[ fix ] = { Chris@0: setup: function() { Chris@0: var doc = this.ownerDocument || this, Chris@0: attaches = dataPriv.access( doc, fix ); Chris@0: Chris@0: if ( !attaches ) { Chris@0: doc.addEventListener( orig, handler, true ); Chris@0: } Chris@0: dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); Chris@0: }, Chris@0: teardown: function() { Chris@0: var doc = this.ownerDocument || this, Chris@0: attaches = dataPriv.access( doc, fix ) - 1; Chris@0: Chris@0: if ( !attaches ) { Chris@0: doc.removeEventListener( orig, handler, true ); Chris@0: dataPriv.remove( doc, fix ); Chris@0: Chris@0: } else { Chris@0: dataPriv.access( doc, fix, attaches ); Chris@0: } Chris@0: } Chris@0: }; Chris@0: } ); Chris@0: } Chris@0: var location = window.location; Chris@0: Chris@0: var nonce = jQuery.now(); Chris@0: Chris@0: var rquery = ( /\?/ ); Chris@0: Chris@0: Chris@0: Chris@0: // Cross-browser xml parsing Chris@0: jQuery.parseXML = function( data ) { Chris@0: var xml; Chris@0: if ( !data || typeof data !== "string" ) { Chris@0: return null; Chris@0: } Chris@0: Chris@0: // Support: IE 9 - 11 only Chris@0: // IE throws on parseFromString with invalid input. Chris@0: try { Chris@0: xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); Chris@0: } catch ( e ) { Chris@0: xml = undefined; Chris@0: } Chris@0: Chris@0: if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { Chris@0: jQuery.error( "Invalid XML: " + data ); Chris@0: } Chris@0: return xml; Chris@0: }; Chris@0: Chris@0: Chris@0: var Chris@0: rbracket = /\[\]$/, Chris@0: rCRLF = /\r?\n/g, Chris@0: rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, Chris@0: rsubmittable = /^(?:input|select|textarea|keygen)/i; Chris@0: Chris@0: function buildParams( prefix, obj, traditional, add ) { Chris@0: var name; Chris@0: Chris@0: if ( Array.isArray( obj ) ) { Chris@0: Chris@0: // Serialize array item. Chris@0: jQuery.each( obj, function( i, v ) { Chris@0: if ( traditional || rbracket.test( prefix ) ) { Chris@0: Chris@0: // Treat each array item as a scalar. Chris@0: add( prefix, v ); Chris@0: Chris@0: } else { Chris@0: Chris@0: // Item is non-scalar (array or object), encode its numeric index. Chris@0: buildParams( Chris@0: prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", Chris@0: v, Chris@0: traditional, Chris@0: add Chris@0: ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: } else if ( !traditional && jQuery.type( obj ) === "object" ) { Chris@0: Chris@0: // Serialize object item. Chris@0: for ( name in obj ) { Chris@0: buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); Chris@0: } Chris@0: Chris@0: } else { Chris@0: Chris@0: // Serialize scalar item. Chris@0: add( prefix, obj ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Serialize an array of form elements or a set of Chris@0: // key/values into a query string Chris@0: jQuery.param = function( a, traditional ) { Chris@0: var prefix, Chris@0: s = [], Chris@0: add = function( key, valueOrFunction ) { Chris@0: Chris@0: // If value is a function, invoke it and use its return value Chris@0: var value = jQuery.isFunction( valueOrFunction ) ? Chris@0: valueOrFunction() : Chris@0: valueOrFunction; Chris@0: Chris@0: s[ s.length ] = encodeURIComponent( key ) + "=" + Chris@0: encodeURIComponent( value == null ? "" : value ); Chris@0: }; Chris@0: Chris@0: // If an array was passed in, assume that it is an array of form elements. Chris@0: if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { Chris@0: Chris@0: // Serialize the form elements Chris@0: jQuery.each( a, function() { Chris@0: add( this.name, this.value ); Chris@0: } ); Chris@0: Chris@0: } else { Chris@0: Chris@0: // If traditional, encode the "old" way (the way 1.3.2 or older Chris@0: // did it), otherwise encode params recursively. Chris@0: for ( prefix in a ) { Chris@0: buildParams( prefix, a[ prefix ], traditional, add ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Return the resulting serialization Chris@0: return s.join( "&" ); Chris@0: }; Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: serialize: function() { Chris@0: return jQuery.param( this.serializeArray() ); Chris@0: }, Chris@0: serializeArray: function() { Chris@0: return this.map( function() { Chris@0: Chris@0: // Can add propHook for "elements" to filter or add form elements Chris@0: var elements = jQuery.prop( this, "elements" ); Chris@0: return elements ? jQuery.makeArray( elements ) : this; Chris@0: } ) Chris@0: .filter( function() { Chris@0: var type = this.type; Chris@0: Chris@0: // Use .is( ":disabled" ) so that fieldset[disabled] works Chris@0: return this.name && !jQuery( this ).is( ":disabled" ) && Chris@0: rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && Chris@0: ( this.checked || !rcheckableType.test( type ) ); Chris@0: } ) Chris@0: .map( function( i, elem ) { Chris@0: var val = jQuery( this ).val(); Chris@0: Chris@0: if ( val == null ) { Chris@0: return null; Chris@0: } Chris@0: Chris@0: if ( Array.isArray( val ) ) { Chris@0: return jQuery.map( val, function( val ) { Chris@0: return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; Chris@0: } ); Chris@0: } Chris@0: Chris@0: return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; Chris@0: } ).get(); Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: var Chris@0: r20 = /%20/g, Chris@0: rhash = /#.*$/, Chris@0: rantiCache = /([?&])_=[^&]*/, Chris@0: rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, Chris@0: Chris@0: // #7653, #8125, #8152: local protocol detection Chris@0: rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, Chris@0: rnoContent = /^(?:GET|HEAD)$/, Chris@0: rprotocol = /^\/\//, Chris@0: Chris@0: /* Prefilters Chris@0: * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) Chris@0: * 2) These are called: Chris@0: * - BEFORE asking for a transport Chris@0: * - AFTER param serialization (s.data is a string if s.processData is true) Chris@0: * 3) key is the dataType Chris@0: * 4) the catchall symbol "*" can be used Chris@0: * 5) execution will start with transport dataType and THEN continue down to "*" if needed Chris@0: */ Chris@0: prefilters = {}, Chris@0: Chris@0: /* Transports bindings Chris@0: * 1) key is the dataType Chris@0: * 2) the catchall symbol "*" can be used Chris@0: * 3) selection will start with transport dataType and THEN go to "*" if needed Chris@0: */ Chris@0: transports = {}, Chris@0: Chris@0: // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression Chris@0: allTypes = "*/".concat( "*" ), Chris@0: Chris@0: // Anchor tag for parsing the document origin Chris@0: originAnchor = document.createElement( "a" ); Chris@0: originAnchor.href = location.href; Chris@0: Chris@0: // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport Chris@0: function addToPrefiltersOrTransports( structure ) { Chris@0: Chris@0: // dataTypeExpression is optional and defaults to "*" Chris@0: return function( dataTypeExpression, func ) { Chris@0: Chris@0: if ( typeof dataTypeExpression !== "string" ) { Chris@0: func = dataTypeExpression; Chris@0: dataTypeExpression = "*"; Chris@0: } Chris@0: Chris@0: var dataType, Chris@0: i = 0, Chris@0: dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; Chris@0: Chris@0: if ( jQuery.isFunction( func ) ) { Chris@0: Chris@0: // For each dataType in the dataTypeExpression Chris@0: while ( ( dataType = dataTypes[ i++ ] ) ) { Chris@0: Chris@0: // Prepend if requested Chris@0: if ( dataType[ 0 ] === "+" ) { Chris@0: dataType = dataType.slice( 1 ) || "*"; Chris@0: ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); Chris@0: Chris@0: // Otherwise append Chris@0: } else { Chris@0: ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); Chris@0: } Chris@0: } Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: // Base inspection function for prefilters and transports Chris@0: function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { Chris@0: Chris@0: var inspected = {}, Chris@0: seekingTransport = ( structure === transports ); Chris@0: Chris@0: function inspect( dataType ) { Chris@0: var selected; Chris@0: inspected[ dataType ] = true; Chris@0: jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { Chris@0: var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); Chris@0: if ( typeof dataTypeOrTransport === "string" && Chris@0: !seekingTransport && !inspected[ dataTypeOrTransport ] ) { Chris@0: Chris@0: options.dataTypes.unshift( dataTypeOrTransport ); Chris@0: inspect( dataTypeOrTransport ); Chris@0: return false; Chris@0: } else if ( seekingTransport ) { Chris@0: return !( selected = dataTypeOrTransport ); Chris@0: } Chris@0: } ); Chris@0: return selected; Chris@0: } Chris@0: Chris@0: return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); Chris@0: } Chris@0: Chris@0: // A special extend for ajax options Chris@0: // that takes "flat" options (not to be deep extended) Chris@0: // Fixes #9887 Chris@0: function ajaxExtend( target, src ) { Chris@0: var key, deep, Chris@0: flatOptions = jQuery.ajaxSettings.flatOptions || {}; Chris@0: Chris@0: for ( key in src ) { Chris@0: if ( src[ key ] !== undefined ) { Chris@0: ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; Chris@0: } Chris@0: } Chris@0: if ( deep ) { Chris@0: jQuery.extend( true, target, deep ); Chris@0: } Chris@0: Chris@0: return target; Chris@0: } Chris@0: Chris@0: /* Handles responses to an ajax request: Chris@0: * - finds the right dataType (mediates between content-type and expected dataType) Chris@0: * - returns the corresponding response Chris@0: */ Chris@0: function ajaxHandleResponses( s, jqXHR, responses ) { Chris@0: Chris@0: var ct, type, finalDataType, firstDataType, Chris@0: contents = s.contents, Chris@0: dataTypes = s.dataTypes; Chris@0: Chris@0: // Remove auto dataType and get content-type in the process Chris@0: while ( dataTypes[ 0 ] === "*" ) { Chris@0: dataTypes.shift(); Chris@0: if ( ct === undefined ) { Chris@0: ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Check if we're dealing with a known content-type Chris@0: if ( ct ) { Chris@0: for ( type in contents ) { Chris@0: if ( contents[ type ] && contents[ type ].test( ct ) ) { Chris@0: dataTypes.unshift( type ); Chris@0: break; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Check to see if we have a response for the expected dataType Chris@0: if ( dataTypes[ 0 ] in responses ) { Chris@0: finalDataType = dataTypes[ 0 ]; Chris@0: } else { Chris@0: Chris@0: // Try convertible dataTypes Chris@0: for ( type in responses ) { Chris@0: if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { Chris@0: finalDataType = type; Chris@0: break; Chris@0: } Chris@0: if ( !firstDataType ) { Chris@0: firstDataType = type; Chris@0: } Chris@0: } Chris@0: Chris@0: // Or just use first one Chris@0: finalDataType = finalDataType || firstDataType; Chris@0: } Chris@0: Chris@0: // If we found a dataType Chris@0: // We add the dataType to the list if needed Chris@0: // and return the corresponding response Chris@0: if ( finalDataType ) { Chris@0: if ( finalDataType !== dataTypes[ 0 ] ) { Chris@0: dataTypes.unshift( finalDataType ); Chris@0: } Chris@0: return responses[ finalDataType ]; Chris@0: } Chris@0: } Chris@0: Chris@0: /* Chain conversions given the request and the original response Chris@0: * Also sets the responseXXX fields on the jqXHR instance Chris@0: */ Chris@0: function ajaxConvert( s, response, jqXHR, isSuccess ) { Chris@0: var conv2, current, conv, tmp, prev, Chris@0: converters = {}, Chris@0: Chris@0: // Work with a copy of dataTypes in case we need to modify it for conversion Chris@0: dataTypes = s.dataTypes.slice(); Chris@0: Chris@0: // Create converters map with lowercased keys Chris@0: if ( dataTypes[ 1 ] ) { Chris@0: for ( conv in s.converters ) { Chris@0: converters[ conv.toLowerCase() ] = s.converters[ conv ]; Chris@0: } Chris@0: } Chris@0: Chris@0: current = dataTypes.shift(); Chris@0: Chris@0: // Convert to each sequential dataType Chris@0: while ( current ) { Chris@0: Chris@0: if ( s.responseFields[ current ] ) { Chris@0: jqXHR[ s.responseFields[ current ] ] = response; Chris@0: } Chris@0: Chris@0: // Apply the dataFilter if provided Chris@0: if ( !prev && isSuccess && s.dataFilter ) { Chris@0: response = s.dataFilter( response, s.dataType ); Chris@0: } Chris@0: Chris@0: prev = current; Chris@0: current = dataTypes.shift(); Chris@0: Chris@0: if ( current ) { Chris@0: Chris@0: // There's only work to do if current dataType is non-auto Chris@0: if ( current === "*" ) { Chris@0: Chris@0: current = prev; Chris@0: Chris@0: // Convert response if prev dataType is non-auto and differs from current Chris@0: } else if ( prev !== "*" && prev !== current ) { Chris@0: Chris@0: // Seek a direct converter Chris@0: conv = converters[ prev + " " + current ] || converters[ "* " + current ]; Chris@0: Chris@0: // If none found, seek a pair Chris@0: if ( !conv ) { Chris@0: for ( conv2 in converters ) { Chris@0: Chris@0: // If conv2 outputs current Chris@0: tmp = conv2.split( " " ); Chris@0: if ( tmp[ 1 ] === current ) { Chris@0: Chris@0: // If prev can be converted to accepted input Chris@0: conv = converters[ prev + " " + tmp[ 0 ] ] || Chris@0: converters[ "* " + tmp[ 0 ] ]; Chris@0: if ( conv ) { Chris@0: Chris@0: // Condense equivalence converters Chris@0: if ( conv === true ) { Chris@0: conv = converters[ conv2 ]; Chris@0: Chris@0: // Otherwise, insert the intermediate dataType Chris@0: } else if ( converters[ conv2 ] !== true ) { Chris@0: current = tmp[ 0 ]; Chris@0: dataTypes.unshift( tmp[ 1 ] ); Chris@0: } Chris@0: break; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Apply converter (if not an equivalence) Chris@0: if ( conv !== true ) { Chris@0: Chris@0: // Unless errors are allowed to bubble, catch and return them Chris@0: if ( conv && s.throws ) { Chris@0: response = conv( response ); Chris@0: } else { Chris@0: try { Chris@0: response = conv( response ); Chris@0: } catch ( e ) { Chris@0: return { Chris@0: state: "parsererror", Chris@0: error: conv ? e : "No conversion from " + prev + " to " + current Chris@0: }; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return { state: "success", data: response }; Chris@0: } Chris@0: Chris@0: jQuery.extend( { Chris@0: Chris@0: // Counter for holding the number of active queries Chris@0: active: 0, Chris@0: Chris@0: // Last-Modified header cache for next request Chris@0: lastModified: {}, Chris@0: etag: {}, Chris@0: Chris@0: ajaxSettings: { Chris@0: url: location.href, Chris@0: type: "GET", Chris@0: isLocal: rlocalProtocol.test( location.protocol ), Chris@0: global: true, Chris@0: processData: true, Chris@0: async: true, Chris@0: contentType: "application/x-www-form-urlencoded; charset=UTF-8", Chris@0: Chris@0: /* Chris@0: timeout: 0, Chris@0: data: null, Chris@0: dataType: null, Chris@0: username: null, Chris@0: password: null, Chris@0: cache: null, Chris@0: throws: false, Chris@0: traditional: false, Chris@0: headers: {}, Chris@0: */ Chris@0: Chris@0: accepts: { Chris@0: "*": allTypes, Chris@0: text: "text/plain", Chris@0: html: "text/html", Chris@0: xml: "application/xml, text/xml", Chris@0: json: "application/json, text/javascript" Chris@0: }, Chris@0: Chris@0: contents: { Chris@0: xml: /\bxml\b/, Chris@0: html: /\bhtml/, Chris@0: json: /\bjson\b/ Chris@0: }, Chris@0: Chris@0: responseFields: { Chris@0: xml: "responseXML", Chris@0: text: "responseText", Chris@0: json: "responseJSON" Chris@0: }, Chris@0: Chris@0: // Data converters Chris@0: // Keys separate source (or catchall "*") and destination types with a single space Chris@0: converters: { Chris@0: Chris@0: // Convert anything to text Chris@0: "* text": String, Chris@0: Chris@0: // Text to html (true = no transformation) Chris@0: "text html": true, Chris@0: Chris@0: // Evaluate text as a json expression Chris@0: "text json": JSON.parse, Chris@0: Chris@0: // Parse text as xml Chris@0: "text xml": jQuery.parseXML Chris@0: }, Chris@0: Chris@0: // For options that shouldn't be deep extended: Chris@0: // you can add your own custom options here if Chris@0: // and when you create one that shouldn't be Chris@0: // deep extended (see ajaxExtend) Chris@0: flatOptions: { Chris@0: url: true, Chris@0: context: true Chris@0: } Chris@0: }, Chris@0: Chris@0: // Creates a full fledged settings object into target Chris@0: // with both ajaxSettings and settings fields. Chris@0: // If target is omitted, writes into ajaxSettings. Chris@0: ajaxSetup: function( target, settings ) { Chris@0: return settings ? Chris@0: Chris@0: // Building a settings object Chris@0: ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : Chris@0: Chris@0: // Extending ajaxSettings Chris@0: ajaxExtend( jQuery.ajaxSettings, target ); Chris@0: }, Chris@0: Chris@0: ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), Chris@0: ajaxTransport: addToPrefiltersOrTransports( transports ), Chris@0: Chris@0: // Main method Chris@0: ajax: function( url, options ) { Chris@0: Chris@0: // If url is an object, simulate pre-1.5 signature Chris@0: if ( typeof url === "object" ) { Chris@0: options = url; Chris@0: url = undefined; Chris@0: } Chris@0: Chris@0: // Force options to be an object Chris@0: options = options || {}; Chris@0: Chris@0: var transport, Chris@0: Chris@0: // URL without anti-cache param Chris@0: cacheURL, Chris@0: Chris@0: // Response headers Chris@0: responseHeadersString, Chris@0: responseHeaders, Chris@0: Chris@0: // timeout handle Chris@0: timeoutTimer, Chris@0: Chris@0: // Url cleanup var Chris@0: urlAnchor, Chris@0: Chris@0: // Request state (becomes false upon send and true upon completion) Chris@0: completed, Chris@0: Chris@0: // To know if global events are to be dispatched Chris@0: fireGlobals, Chris@0: Chris@0: // Loop variable Chris@0: i, Chris@0: Chris@0: // uncached part of the url Chris@0: uncached, Chris@0: Chris@0: // Create the final options object Chris@0: s = jQuery.ajaxSetup( {}, options ), Chris@0: Chris@0: // Callbacks context Chris@0: callbackContext = s.context || s, Chris@0: Chris@0: // Context for global events is callbackContext if it is a DOM node or jQuery collection Chris@0: globalEventContext = s.context && Chris@0: ( callbackContext.nodeType || callbackContext.jquery ) ? Chris@0: jQuery( callbackContext ) : Chris@0: jQuery.event, Chris@0: Chris@0: // Deferreds Chris@0: deferred = jQuery.Deferred(), Chris@0: completeDeferred = jQuery.Callbacks( "once memory" ), Chris@0: Chris@0: // Status-dependent callbacks Chris@0: statusCode = s.statusCode || {}, Chris@0: Chris@0: // Headers (they are sent all at once) Chris@0: requestHeaders = {}, Chris@0: requestHeadersNames = {}, Chris@0: Chris@0: // Default abort message Chris@0: strAbort = "canceled", Chris@0: Chris@0: // Fake xhr Chris@0: jqXHR = { Chris@0: readyState: 0, Chris@0: Chris@0: // Builds headers hashtable if needed Chris@0: getResponseHeader: function( key ) { Chris@0: var match; Chris@0: if ( completed ) { Chris@0: if ( !responseHeaders ) { Chris@0: responseHeaders = {}; Chris@0: while ( ( match = rheaders.exec( responseHeadersString ) ) ) { Chris@0: responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ]; Chris@0: } Chris@0: } Chris@0: match = responseHeaders[ key.toLowerCase() ]; Chris@0: } Chris@0: return match == null ? null : match; Chris@0: }, Chris@0: Chris@0: // Raw string Chris@0: getAllResponseHeaders: function() { Chris@0: return completed ? responseHeadersString : null; Chris@0: }, Chris@0: Chris@0: // Caches the header Chris@0: setRequestHeader: function( name, value ) { Chris@0: if ( completed == null ) { Chris@0: name = requestHeadersNames[ name.toLowerCase() ] = Chris@0: requestHeadersNames[ name.toLowerCase() ] || name; Chris@0: requestHeaders[ name ] = value; Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Overrides response content-type header Chris@0: overrideMimeType: function( type ) { Chris@0: if ( completed == null ) { Chris@0: s.mimeType = type; Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Status-dependent callbacks Chris@0: statusCode: function( map ) { Chris@0: var code; Chris@0: if ( map ) { Chris@0: if ( completed ) { Chris@0: Chris@0: // Execute the appropriate callbacks Chris@0: jqXHR.always( map[ jqXHR.status ] ); Chris@0: } else { Chris@0: Chris@0: // Lazy-add the new callbacks in a way that preserves old ones Chris@0: for ( code in map ) { Chris@0: statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; Chris@0: } Chris@0: } Chris@0: } Chris@0: return this; Chris@0: }, Chris@0: Chris@0: // Cancel the request Chris@0: abort: function( statusText ) { Chris@0: var finalText = statusText || strAbort; Chris@0: if ( transport ) { Chris@0: transport.abort( finalText ); Chris@0: } Chris@0: done( 0, finalText ); Chris@0: return this; Chris@0: } Chris@0: }; Chris@0: Chris@0: // Attach deferreds Chris@0: deferred.promise( jqXHR ); Chris@0: Chris@0: // Add protocol if not provided (prefilters might expect it) Chris@0: // Handle falsy url in the settings object (#10093: consistency with old signature) Chris@0: // We also use the url parameter if available Chris@0: s.url = ( ( url || s.url || location.href ) + "" ) Chris@0: .replace( rprotocol, location.protocol + "//" ); Chris@0: Chris@0: // Alias method option to type as per ticket #12004 Chris@0: s.type = options.method || options.type || s.method || s.type; Chris@0: Chris@0: // Extract dataTypes list Chris@0: s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; Chris@0: Chris@0: // A cross-domain request is in order when the origin doesn't match the current origin. Chris@0: if ( s.crossDomain == null ) { Chris@0: urlAnchor = document.createElement( "a" ); Chris@0: Chris@0: // Support: IE <=8 - 11, Edge 12 - 13 Chris@0: // IE throws exception on accessing the href property if url is malformed, Chris@0: // e.g. http://example.com:80x/ Chris@0: try { Chris@0: urlAnchor.href = s.url; Chris@0: Chris@0: // Support: IE <=8 - 11 only Chris@0: // Anchor's host property isn't correctly set when s.url is relative Chris@0: urlAnchor.href = urlAnchor.href; Chris@0: s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== Chris@0: urlAnchor.protocol + "//" + urlAnchor.host; Chris@0: } catch ( e ) { Chris@0: Chris@0: // If there is an error parsing the URL, assume it is crossDomain, Chris@0: // it can be rejected by the transport if it is invalid Chris@0: s.crossDomain = true; Chris@0: } Chris@0: } Chris@0: Chris@0: // Convert data if not already a string Chris@0: if ( s.data && s.processData && typeof s.data !== "string" ) { Chris@0: s.data = jQuery.param( s.data, s.traditional ); Chris@0: } Chris@0: Chris@0: // Apply prefilters Chris@0: inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); Chris@0: Chris@0: // If request was aborted inside a prefilter, stop there Chris@0: if ( completed ) { Chris@0: return jqXHR; Chris@0: } Chris@0: Chris@0: // We can fire global events as of now if asked to Chris@0: // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) Chris@0: fireGlobals = jQuery.event && s.global; Chris@0: Chris@0: // Watch for a new set of requests Chris@0: if ( fireGlobals && jQuery.active++ === 0 ) { Chris@0: jQuery.event.trigger( "ajaxStart" ); Chris@0: } Chris@0: Chris@0: // Uppercase the type Chris@0: s.type = s.type.toUpperCase(); Chris@0: Chris@0: // Determine if request has content Chris@0: s.hasContent = !rnoContent.test( s.type ); Chris@0: Chris@0: // Save the URL in case we're toying with the If-Modified-Since Chris@0: // and/or If-None-Match header later on Chris@0: // Remove hash to simplify url manipulation Chris@0: cacheURL = s.url.replace( rhash, "" ); Chris@0: Chris@0: // More options handling for requests with no content Chris@0: if ( !s.hasContent ) { Chris@0: Chris@0: // Remember the hash so we can put it back Chris@0: uncached = s.url.slice( cacheURL.length ); Chris@0: Chris@0: // If data is available, append data to url Chris@0: if ( s.data ) { Chris@0: cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; Chris@0: Chris@0: // #9682: remove data so that it's not used in an eventual retry Chris@0: delete s.data; Chris@0: } Chris@0: Chris@0: // Add or update anti-cache param if needed Chris@0: if ( s.cache === false ) { Chris@0: cacheURL = cacheURL.replace( rantiCache, "$1" ); Chris@0: uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached; Chris@0: } Chris@0: Chris@0: // Put hash and anti-cache on the URL that will be requested (gh-1732) Chris@0: s.url = cacheURL + uncached; Chris@0: Chris@0: // Change '%20' to '+' if this is encoded form body content (gh-2658) Chris@0: } else if ( s.data && s.processData && Chris@0: ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { Chris@0: s.data = s.data.replace( r20, "+" ); Chris@0: } Chris@0: Chris@0: // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. Chris@0: if ( s.ifModified ) { Chris@0: if ( jQuery.lastModified[ cacheURL ] ) { Chris@0: jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); Chris@0: } Chris@0: if ( jQuery.etag[ cacheURL ] ) { Chris@0: jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Set the correct header, if data is being sent Chris@0: if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { Chris@0: jqXHR.setRequestHeader( "Content-Type", s.contentType ); Chris@0: } Chris@0: Chris@0: // Set the Accepts header for the server, depending on the dataType Chris@0: jqXHR.setRequestHeader( Chris@0: "Accept", Chris@0: s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? Chris@0: s.accepts[ s.dataTypes[ 0 ] ] + Chris@0: ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : Chris@0: s.accepts[ "*" ] Chris@0: ); Chris@0: Chris@0: // Check for headers option Chris@0: for ( i in s.headers ) { Chris@0: jqXHR.setRequestHeader( i, s.headers[ i ] ); Chris@0: } Chris@0: Chris@0: // Allow custom headers/mimetypes and early abort Chris@0: if ( s.beforeSend && Chris@0: ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { Chris@0: Chris@0: // Abort if not done already and return Chris@0: return jqXHR.abort(); Chris@0: } Chris@0: Chris@0: // Aborting is no longer a cancellation Chris@0: strAbort = "abort"; Chris@0: Chris@0: // Install callbacks on deferreds Chris@0: completeDeferred.add( s.complete ); Chris@0: jqXHR.done( s.success ); Chris@0: jqXHR.fail( s.error ); Chris@0: Chris@0: // Get transport Chris@0: transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); Chris@0: Chris@0: // If no transport, we auto-abort Chris@0: if ( !transport ) { Chris@0: done( -1, "No Transport" ); Chris@0: } else { Chris@0: jqXHR.readyState = 1; Chris@0: Chris@0: // Send global event Chris@0: if ( fireGlobals ) { Chris@0: globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); Chris@0: } Chris@0: Chris@0: // If request was aborted inside ajaxSend, stop there Chris@0: if ( completed ) { Chris@0: return jqXHR; Chris@0: } Chris@0: Chris@0: // Timeout Chris@0: if ( s.async && s.timeout > 0 ) { Chris@0: timeoutTimer = window.setTimeout( function() { Chris@0: jqXHR.abort( "timeout" ); Chris@0: }, s.timeout ); Chris@0: } Chris@0: Chris@0: try { Chris@0: completed = false; Chris@0: transport.send( requestHeaders, done ); Chris@0: } catch ( e ) { Chris@0: Chris@0: // Rethrow post-completion exceptions Chris@0: if ( completed ) { Chris@0: throw e; Chris@0: } Chris@0: Chris@0: // Propagate others as results Chris@0: done( -1, e ); Chris@0: } Chris@0: } Chris@0: Chris@0: // Callback for when everything is done Chris@0: function done( status, nativeStatusText, responses, headers ) { Chris@0: var isSuccess, success, error, response, modified, Chris@0: statusText = nativeStatusText; Chris@0: Chris@0: // Ignore repeat invocations Chris@0: if ( completed ) { Chris@0: return; Chris@0: } Chris@0: Chris@0: completed = true; Chris@0: Chris@0: // Clear timeout if it exists Chris@0: if ( timeoutTimer ) { Chris@0: window.clearTimeout( timeoutTimer ); Chris@0: } Chris@0: Chris@0: // Dereference transport for early garbage collection Chris@0: // (no matter how long the jqXHR object will be used) Chris@0: transport = undefined; Chris@0: Chris@0: // Cache response headers Chris@0: responseHeadersString = headers || ""; Chris@0: Chris@0: // Set readyState Chris@0: jqXHR.readyState = status > 0 ? 4 : 0; Chris@0: Chris@0: // Determine if successful Chris@0: isSuccess = status >= 200 && status < 300 || status === 304; Chris@0: Chris@0: // Get response data Chris@0: if ( responses ) { Chris@0: response = ajaxHandleResponses( s, jqXHR, responses ); Chris@0: } Chris@0: Chris@0: // Convert no matter what (that way responseXXX fields are always set) Chris@0: response = ajaxConvert( s, response, jqXHR, isSuccess ); Chris@0: Chris@0: // If successful, handle type chaining Chris@0: if ( isSuccess ) { Chris@0: Chris@0: // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. Chris@0: if ( s.ifModified ) { Chris@0: modified = jqXHR.getResponseHeader( "Last-Modified" ); Chris@0: if ( modified ) { Chris@0: jQuery.lastModified[ cacheURL ] = modified; Chris@0: } Chris@0: modified = jqXHR.getResponseHeader( "etag" ); Chris@0: if ( modified ) { Chris@0: jQuery.etag[ cacheURL ] = modified; Chris@0: } Chris@0: } Chris@0: Chris@0: // if no content Chris@0: if ( status === 204 || s.type === "HEAD" ) { Chris@0: statusText = "nocontent"; Chris@0: Chris@0: // if not modified Chris@0: } else if ( status === 304 ) { Chris@0: statusText = "notmodified"; Chris@0: Chris@0: // If we have data, let's convert it Chris@0: } else { Chris@0: statusText = response.state; Chris@0: success = response.data; Chris@0: error = response.error; Chris@0: isSuccess = !error; Chris@0: } Chris@0: } else { Chris@0: Chris@0: // Extract error from statusText and normalize for non-aborts Chris@0: error = statusText; Chris@0: if ( status || !statusText ) { Chris@0: statusText = "error"; Chris@0: if ( status < 0 ) { Chris@0: status = 0; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: // Set data for the fake xhr object Chris@0: jqXHR.status = status; Chris@0: jqXHR.statusText = ( nativeStatusText || statusText ) + ""; Chris@0: Chris@0: // Success/Error Chris@0: if ( isSuccess ) { Chris@0: deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); Chris@0: } else { Chris@0: deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); Chris@0: } Chris@0: Chris@0: // Status-dependent callbacks Chris@0: jqXHR.statusCode( statusCode ); Chris@0: statusCode = undefined; Chris@0: Chris@0: if ( fireGlobals ) { Chris@0: globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", Chris@0: [ jqXHR, s, isSuccess ? success : error ] ); Chris@0: } Chris@0: Chris@0: // Complete Chris@0: completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); Chris@0: Chris@0: if ( fireGlobals ) { Chris@0: globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); Chris@0: Chris@0: // Handle the global AJAX counter Chris@0: if ( !( --jQuery.active ) ) { Chris@0: jQuery.event.trigger( "ajaxStop" ); Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: return jqXHR; Chris@0: }, Chris@0: Chris@0: getJSON: function( url, data, callback ) { Chris@0: return jQuery.get( url, data, callback, "json" ); Chris@0: }, Chris@0: Chris@0: getScript: function( url, callback ) { Chris@0: return jQuery.get( url, undefined, callback, "script" ); Chris@0: } Chris@0: } ); Chris@0: Chris@0: jQuery.each( [ "get", "post" ], function( i, method ) { Chris@0: jQuery[ method ] = function( url, data, callback, type ) { Chris@0: Chris@0: // Shift arguments if data argument was omitted Chris@0: if ( jQuery.isFunction( data ) ) { Chris@0: type = type || callback; Chris@0: callback = data; Chris@0: data = undefined; Chris@0: } Chris@0: Chris@0: // The url can be an options object (which then must have .url) Chris@0: return jQuery.ajax( jQuery.extend( { Chris@0: url: url, Chris@0: type: method, Chris@0: dataType: type, Chris@0: data: data, Chris@0: success: callback Chris@0: }, jQuery.isPlainObject( url ) && url ) ); Chris@0: }; Chris@0: } ); Chris@0: Chris@0: Chris@0: jQuery._evalUrl = function( url ) { Chris@0: return jQuery.ajax( { Chris@0: url: url, Chris@0: Chris@0: // Make this explicit, since user can override this through ajaxSetup (#11264) Chris@0: type: "GET", Chris@0: dataType: "script", Chris@0: cache: true, Chris@0: async: false, Chris@0: global: false, Chris@0: "throws": true Chris@0: } ); Chris@0: }; Chris@0: Chris@0: Chris@0: jQuery.fn.extend( { Chris@0: wrapAll: function( html ) { Chris@0: var wrap; Chris@0: Chris@0: if ( this[ 0 ] ) { Chris@0: if ( jQuery.isFunction( html ) ) { Chris@0: html = html.call( this[ 0 ] ); Chris@0: } Chris@0: Chris@0: // The elements to wrap the target around Chris@0: wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); Chris@0: Chris@0: if ( this[ 0 ].parentNode ) { Chris@0: wrap.insertBefore( this[ 0 ] ); Chris@0: } Chris@0: Chris@0: wrap.map( function() { Chris@0: var elem = this; Chris@0: Chris@0: while ( elem.firstElementChild ) { Chris@0: elem = elem.firstElementChild; Chris@0: } Chris@0: Chris@0: return elem; Chris@0: } ).append( this ); Chris@0: } Chris@0: Chris@0: return this; Chris@0: }, Chris@0: Chris@0: wrapInner: function( html ) { Chris@0: if ( jQuery.isFunction( html ) ) { Chris@0: return this.each( function( i ) { Chris@0: jQuery( this ).wrapInner( html.call( this, i ) ); Chris@0: } ); Chris@0: } Chris@0: Chris@0: return this.each( function() { Chris@0: var self = jQuery( this ), Chris@0: contents = self.contents(); Chris@0: Chris@0: if ( contents.length ) { Chris@0: contents.wrapAll( html ); Chris@0: Chris@0: } else { Chris@0: self.append( html ); Chris@0: } Chris@0: } ); Chris@0: }, Chris@0: Chris@0: wrap: function( html ) { Chris@0: var isFunction = jQuery.isFunction( html ); Chris@0: Chris@0: return this.each( function( i ) { Chris@0: jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html ); Chris@0: } ); Chris@0: }, Chris@0: Chris@0: unwrap: function( selector ) { Chris@0: this.parent( selector ).not( "body" ).each( function() { Chris@0: jQuery( this ).replaceWith( this.childNodes ); Chris@0: } ); Chris@0: return this; Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: jQuery.expr.pseudos.hidden = function( elem ) { Chris@0: return !jQuery.expr.pseudos.visible( elem ); Chris@0: }; Chris@0: jQuery.expr.pseudos.visible = function( elem ) { Chris@0: return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); Chris@0: }; Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: jQuery.ajaxSettings.xhr = function() { Chris@0: try { Chris@0: return new window.XMLHttpRequest(); Chris@0: } catch ( e ) {} Chris@0: }; Chris@0: Chris@0: var xhrSuccessStatus = { Chris@0: Chris@0: // File protocol always yields status code 0, assume 200 Chris@0: 0: 200, Chris@0: Chris@0: // Support: IE <=9 only Chris@0: // #1450: sometimes IE returns 1223 when it should be 204 Chris@0: 1223: 204 Chris@0: }, Chris@0: xhrSupported = jQuery.ajaxSettings.xhr(); Chris@0: Chris@0: support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); Chris@0: support.ajax = xhrSupported = !!xhrSupported; Chris@0: Chris@0: jQuery.ajaxTransport( function( options ) { Chris@0: var callback, errorCallback; Chris@0: Chris@0: // Cross domain only allowed if supported through XMLHttpRequest Chris@0: if ( support.cors || xhrSupported && !options.crossDomain ) { Chris@0: return { Chris@0: send: function( headers, complete ) { Chris@0: var i, Chris@0: xhr = options.xhr(); Chris@0: Chris@0: xhr.open( Chris@0: options.type, Chris@0: options.url, Chris@0: options.async, Chris@0: options.username, Chris@0: options.password Chris@0: ); Chris@0: Chris@0: // Apply custom fields if provided Chris@0: if ( options.xhrFields ) { Chris@0: for ( i in options.xhrFields ) { Chris@0: xhr[ i ] = options.xhrFields[ i ]; Chris@0: } Chris@0: } Chris@0: Chris@0: // Override mime type if needed Chris@0: if ( options.mimeType && xhr.overrideMimeType ) { Chris@0: xhr.overrideMimeType( options.mimeType ); Chris@0: } Chris@0: Chris@0: // X-Requested-With header Chris@0: // For cross-domain requests, seeing as conditions for a preflight are Chris@0: // akin to a jigsaw puzzle, we simply never set it to be sure. Chris@0: // (it can always be set on a per-request basis or even using ajaxSetup) Chris@0: // For same-domain requests, won't change header if already provided. Chris@0: if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { Chris@0: headers[ "X-Requested-With" ] = "XMLHttpRequest"; Chris@0: } Chris@0: Chris@0: // Set headers Chris@0: for ( i in headers ) { Chris@0: xhr.setRequestHeader( i, headers[ i ] ); Chris@0: } Chris@0: Chris@0: // Callback Chris@0: callback = function( type ) { Chris@0: return function() { Chris@0: if ( callback ) { Chris@0: callback = errorCallback = xhr.onload = Chris@0: xhr.onerror = xhr.onabort = xhr.onreadystatechange = null; Chris@0: Chris@0: if ( type === "abort" ) { Chris@0: xhr.abort(); Chris@0: } else if ( type === "error" ) { Chris@0: Chris@0: // Support: IE <=9 only Chris@0: // On a manual native abort, IE9 throws Chris@0: // errors on any property access that is not readyState Chris@0: if ( typeof xhr.status !== "number" ) { Chris@0: complete( 0, "error" ); Chris@0: } else { Chris@0: complete( Chris@0: Chris@0: // File: protocol always yields status 0; see #8605, #14207 Chris@0: xhr.status, Chris@0: xhr.statusText Chris@0: ); Chris@0: } Chris@0: } else { Chris@0: complete( Chris@0: xhrSuccessStatus[ xhr.status ] || xhr.status, Chris@0: xhr.statusText, Chris@0: Chris@0: // Support: IE <=9 only Chris@0: // IE9 has no XHR2 but throws on binary (trac-11426) Chris@0: // For XHR2 non-text, let the caller handle it (gh-2498) Chris@0: ( xhr.responseType || "text" ) !== "text" || Chris@0: typeof xhr.responseText !== "string" ? Chris@0: { binary: xhr.response } : Chris@0: { text: xhr.responseText }, Chris@0: xhr.getAllResponseHeaders() Chris@0: ); Chris@0: } Chris@0: } Chris@0: }; Chris@0: }; Chris@0: Chris@0: // Listen to events Chris@0: xhr.onload = callback(); Chris@0: errorCallback = xhr.onerror = callback( "error" ); Chris@0: Chris@0: // Support: IE 9 only Chris@0: // Use onreadystatechange to replace onabort Chris@0: // to handle uncaught aborts Chris@0: if ( xhr.onabort !== undefined ) { Chris@0: xhr.onabort = errorCallback; Chris@0: } else { Chris@0: xhr.onreadystatechange = function() { Chris@0: Chris@0: // Check readyState before timeout as it changes Chris@0: if ( xhr.readyState === 4 ) { Chris@0: Chris@0: // Allow onerror to be called first, Chris@0: // but that will not handle a native abort Chris@0: // Also, save errorCallback to a variable Chris@0: // as xhr.onerror cannot be accessed Chris@0: window.setTimeout( function() { Chris@0: if ( callback ) { Chris@0: errorCallback(); Chris@0: } Chris@0: } ); Chris@0: } Chris@0: }; Chris@0: } Chris@0: Chris@0: // Create the abort callback Chris@0: callback = callback( "abort" ); Chris@0: Chris@0: try { Chris@0: Chris@0: // Do send the request (this may raise an exception) Chris@0: xhr.send( options.hasContent && options.data || null ); Chris@0: } catch ( e ) { Chris@0: Chris@0: // #14683: Only rethrow if this hasn't been notified as an error yet Chris@0: if ( callback ) { Chris@0: throw e; Chris@0: } Chris@0: } Chris@0: }, Chris@0: Chris@0: abort: function() { Chris@0: if ( callback ) { Chris@0: callback(); Chris@0: } Chris@0: } Chris@0: }; Chris@0: } Chris@0: } ); Chris@0: Chris@0: Chris@0: Chris@0: Chris@0: // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) Chris@0: jQuery.ajaxPrefilter( function( s ) { Chris@0: if ( s.crossDomain ) { Chris@0: s.contents.script = false; Chris@0: } Chris@0: } ); Chris@0: Chris@0: // Install script dataType Chris@0: jQuery.ajaxSetup( { Chris@0: accepts: { Chris@0: script: "text/javascript, application/javascript, " + Chris@0: "application/ecmascript, application/x-ecmascript" Chris@0: }, Chris@0: contents: { Chris@0: script: /\b(?:java|ecma)script\b/ Chris@0: }, Chris@0: converters: { Chris@0: "text script": function( text ) { Chris@0: jQuery.globalEval( text ); Chris@0: return text; Chris@0: } Chris@0: } Chris@0: } ); Chris@0: Chris@0: // Handle cache's special case and crossDomain Chris@0: jQuery.ajaxPrefilter( "script", function( s ) { Chris@0: if ( s.cache === undefined ) { Chris@0: s.cache = false; Chris@0: } Chris@0: if ( s.crossDomain ) { Chris@0: s.type = "GET"; Chris@0: } Chris@0: } ); Chris@0: Chris@0: // Bind script tag hack transport Chris@0: jQuery.ajaxTransport( "script", function( s ) { Chris@0: Chris@0: // This transport only deals with cross domain requests Chris@0: if ( s.crossDomain ) { Chris@0: var script, callback; Chris@0: return { Chris@0: send: function( _, complete ) { Chris@0: script = jQuery( "