nicholas@103: /*! nicholas@103: * jQuery JavaScript Library v2.1.4 nicholas@103: * http://jquery.com/ nicholas@103: * nicholas@103: * Includes Sizzle.js nicholas@103: * http://sizzlejs.com/ nicholas@103: * nicholas@103: * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors nicholas@103: * Released under the MIT license nicholas@103: * http://jquery.org/license nicholas@103: * nicholas@103: * Date: 2015-04-28T16:01Z nicholas@103: */ nicholas@103: nicholas@103: (function( global, factory ) { nicholas@103: nicholas@103: if ( typeof module === "object" && typeof module.exports === "object" ) { nicholas@103: // For CommonJS and CommonJS-like environments where a proper `window` nicholas@103: // is present, execute the factory and get jQuery. nicholas@103: // For environments that do not have a `window` with a `document` nicholas@103: // (such as Node.js), expose a factory as module.exports. nicholas@103: // This accentuates the need for the creation of a real `window`. nicholas@103: // e.g. var jQuery = require("jquery")(window); nicholas@103: // See ticket #14549 for more info. nicholas@103: module.exports = global.document ? nicholas@103: factory( global, true ) : nicholas@103: function( w ) { nicholas@103: if ( !w.document ) { nicholas@103: throw new Error( "jQuery requires a window with a document" ); nicholas@103: } nicholas@103: return factory( w ); nicholas@103: }; nicholas@103: } else { nicholas@103: factory( global ); nicholas@103: } nicholas@103: nicholas@103: // Pass this if window is not defined yet nicholas@103: }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { nicholas@103: nicholas@103: // Support: Firefox 18+ nicholas@103: // Can't be in strict mode, several libs including ASP.NET trace nicholas@103: // the stack via arguments.caller.callee and Firefox dies if nicholas@103: // you try to trace through "use strict" call chains. (#13335) nicholas@103: // nicholas@103: nicholas@103: var arr = []; nicholas@103: nicholas@103: var slice = arr.slice; nicholas@103: nicholas@103: var concat = arr.concat; nicholas@103: nicholas@103: var push = arr.push; nicholas@103: nicholas@103: var indexOf = arr.indexOf; nicholas@103: nicholas@103: var class2type = {}; nicholas@103: nicholas@103: var toString = class2type.toString; nicholas@103: nicholas@103: var hasOwn = class2type.hasOwnProperty; nicholas@103: nicholas@103: var support = {}; nicholas@103: nicholas@103: nicholas@103: nicholas@103: var nicholas@103: // Use the correct document accordingly with window argument (sandbox) nicholas@103: document = window.document, nicholas@103: nicholas@103: version = "2.1.4", nicholas@103: nicholas@103: // Define a local copy of jQuery nicholas@103: jQuery = function( selector, context ) { nicholas@103: // The jQuery object is actually just the init constructor 'enhanced' nicholas@103: // Need init if jQuery is called (just allow error to be thrown if not included) nicholas@103: return new jQuery.fn.init( selector, context ); nicholas@103: }, nicholas@103: nicholas@103: // Support: Android<4.1 nicholas@103: // Make sure we trim BOM and NBSP nicholas@103: rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, nicholas@103: nicholas@103: // Matches dashed string for camelizing nicholas@103: rmsPrefix = /^-ms-/, nicholas@103: rdashAlpha = /-([\da-z])/gi, nicholas@103: nicholas@103: // Used by jQuery.camelCase as callback to replace() nicholas@103: fcamelCase = function( all, letter ) { nicholas@103: return letter.toUpperCase(); nicholas@103: }; nicholas@103: nicholas@103: jQuery.fn = jQuery.prototype = { nicholas@103: // The current version of jQuery being used nicholas@103: jquery: version, nicholas@103: nicholas@103: constructor: jQuery, nicholas@103: nicholas@103: // Start with an empty selector nicholas@103: selector: "", nicholas@103: nicholas@103: // The default length of a jQuery object is 0 nicholas@103: length: 0, nicholas@103: nicholas@103: toArray: function() { nicholas@103: return slice.call( this ); nicholas@103: }, nicholas@103: nicholas@103: // Get the Nth element in the matched element set OR nicholas@103: // Get the whole matched element set as a clean array nicholas@103: get: function( num ) { nicholas@103: return num != null ? nicholas@103: nicholas@103: // Return just the one element from the set nicholas@103: ( num < 0 ? this[ num + this.length ] : this[ num ] ) : nicholas@103: nicholas@103: // Return all the elements in a clean array nicholas@103: slice.call( this ); nicholas@103: }, nicholas@103: nicholas@103: // Take an array of elements and push it onto the stack nicholas@103: // (returning the new matched element set) nicholas@103: pushStack: function( elems ) { nicholas@103: nicholas@103: // Build a new jQuery matched element set nicholas@103: var ret = jQuery.merge( this.constructor(), elems ); nicholas@103: nicholas@103: // Add the old object onto the stack (as a reference) nicholas@103: ret.prevObject = this; nicholas@103: ret.context = this.context; nicholas@103: nicholas@103: // Return the newly-formed element set nicholas@103: return ret; nicholas@103: }, nicholas@103: nicholas@103: // Execute a callback for every element in the matched set. nicholas@103: // (You can seed the arguments with an array of args, but this is nicholas@103: // only used internally.) nicholas@103: each: function( callback, args ) { nicholas@103: return jQuery.each( this, callback, args ); nicholas@103: }, nicholas@103: nicholas@103: map: function( callback ) { nicholas@103: return this.pushStack( jQuery.map(this, function( elem, i ) { nicholas@103: return callback.call( elem, i, elem ); nicholas@103: })); nicholas@103: }, nicholas@103: nicholas@103: slice: function() { nicholas@103: return this.pushStack( slice.apply( this, arguments ) ); nicholas@103: }, nicholas@103: nicholas@103: first: function() { nicholas@103: return this.eq( 0 ); nicholas@103: }, nicholas@103: nicholas@103: last: function() { nicholas@103: return this.eq( -1 ); nicholas@103: }, nicholas@103: nicholas@103: eq: function( i ) { nicholas@103: var len = this.length, nicholas@103: j = +i + ( i < 0 ? len : 0 ); nicholas@103: return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); nicholas@103: }, nicholas@103: nicholas@103: end: function() { nicholas@103: return this.prevObject || this.constructor(null); nicholas@103: }, nicholas@103: nicholas@103: // For internal use only. nicholas@103: // Behaves like an Array's method, not like a jQuery method. nicholas@103: push: push, nicholas@103: sort: arr.sort, nicholas@103: splice: arr.splice nicholas@103: }; nicholas@103: nicholas@103: jQuery.extend = jQuery.fn.extend = function() { nicholas@103: var options, name, src, copy, copyIsArray, clone, nicholas@103: target = arguments[0] || {}, nicholas@103: i = 1, nicholas@103: length = arguments.length, nicholas@103: deep = false; nicholas@103: nicholas@103: // Handle a deep copy situation nicholas@103: if ( typeof target === "boolean" ) { nicholas@103: deep = target; nicholas@103: nicholas@103: // Skip the boolean and the target nicholas@103: target = arguments[ i ] || {}; nicholas@103: i++; nicholas@103: } nicholas@103: nicholas@103: // Handle case when target is a string or something (possible in deep copy) nicholas@103: if ( typeof target !== "object" && !jQuery.isFunction(target) ) { nicholas@103: target = {}; nicholas@103: } nicholas@103: nicholas@103: // Extend jQuery itself if only one argument is passed nicholas@103: if ( i === length ) { nicholas@103: target = this; nicholas@103: i--; nicholas@103: } nicholas@103: nicholas@103: for ( ; i < length; i++ ) { nicholas@103: // Only deal with non-null/undefined values nicholas@103: if ( (options = arguments[ i ]) != null ) { nicholas@103: // Extend the base object nicholas@103: for ( name in options ) { nicholas@103: src = target[ name ]; nicholas@103: copy = options[ name ]; nicholas@103: nicholas@103: // Prevent never-ending loop nicholas@103: if ( target === copy ) { nicholas@103: continue; nicholas@103: } nicholas@103: nicholas@103: // Recurse if we're merging plain objects or arrays nicholas@103: if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { nicholas@103: if ( copyIsArray ) { nicholas@103: copyIsArray = false; nicholas@103: clone = src && jQuery.isArray(src) ? src : []; nicholas@103: nicholas@103: } else { nicholas@103: clone = src && jQuery.isPlainObject(src) ? src : {}; nicholas@103: } nicholas@103: nicholas@103: // Never move original objects, clone them nicholas@103: target[ name ] = jQuery.extend( deep, clone, copy ); nicholas@103: nicholas@103: // Don't bring in undefined values nicholas@103: } else if ( copy !== undefined ) { nicholas@103: target[ name ] = copy; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Return the modified object nicholas@103: return target; nicholas@103: }; nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: // Unique for each copy of jQuery on the page nicholas@103: expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), nicholas@103: nicholas@103: // Assume jQuery is ready without the ready module nicholas@103: isReady: true, nicholas@103: nicholas@103: error: function( msg ) { nicholas@103: throw new Error( msg ); nicholas@103: }, nicholas@103: nicholas@103: noop: function() {}, nicholas@103: nicholas@103: isFunction: function( obj ) { nicholas@103: return jQuery.type(obj) === "function"; nicholas@103: }, nicholas@103: nicholas@103: isArray: Array.isArray, nicholas@103: nicholas@103: isWindow: function( obj ) { nicholas@103: return obj != null && obj === obj.window; nicholas@103: }, nicholas@103: nicholas@103: isNumeric: function( obj ) { nicholas@103: // parseFloat NaNs numeric-cast false positives (null|true|false|"") nicholas@103: // ...but misinterprets leading-number strings, particularly hex literals ("0x...") nicholas@103: // subtraction forces infinities to NaN nicholas@103: // adding 1 corrects loss of precision from parseFloat (#15100) nicholas@103: return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0; nicholas@103: }, nicholas@103: nicholas@103: isPlainObject: function( obj ) { nicholas@103: // Not plain objects: nicholas@103: // - Any object or value whose internal [[Class]] property is not "[object Object]" nicholas@103: // - DOM nodes nicholas@103: // - window nicholas@103: if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { nicholas@103: return false; nicholas@103: } nicholas@103: nicholas@103: if ( obj.constructor && nicholas@103: !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { nicholas@103: return false; nicholas@103: } nicholas@103: nicholas@103: // If the function hasn't returned already, we're confident that nicholas@103: // |obj| is a plain object, created by {} or constructed with new Object nicholas@103: return true; nicholas@103: }, nicholas@103: nicholas@103: isEmptyObject: function( obj ) { nicholas@103: var name; nicholas@103: for ( name in obj ) { nicholas@103: return false; nicholas@103: } nicholas@103: return true; nicholas@103: }, nicholas@103: nicholas@103: type: function( obj ) { nicholas@103: if ( obj == null ) { nicholas@103: return obj + ""; nicholas@103: } nicholas@103: // Support: Android<4.0, iOS<6 (functionish RegExp) nicholas@103: return typeof obj === "object" || typeof obj === "function" ? nicholas@103: class2type[ toString.call(obj) ] || "object" : nicholas@103: typeof obj; nicholas@103: }, nicholas@103: nicholas@103: // Evaluates a script in a global context nicholas@103: globalEval: function( code ) { nicholas@103: var script, nicholas@103: indirect = eval; nicholas@103: nicholas@103: code = jQuery.trim( code ); nicholas@103: nicholas@103: if ( code ) { nicholas@103: // If the code includes a valid, prologue position nicholas@103: // strict mode pragma, execute code by injecting a nicholas@103: // script tag into the document. nicholas@103: if ( code.indexOf("use strict") === 1 ) { nicholas@103: script = document.createElement("script"); nicholas@103: script.text = code; nicholas@103: document.head.appendChild( script ).parentNode.removeChild( script ); nicholas@103: } else { nicholas@103: // Otherwise, avoid the DOM node creation, insertion nicholas@103: // and removal by using an indirect global eval nicholas@103: indirect( code ); nicholas@103: } nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: // Convert dashed to camelCase; used by the css and data modules nicholas@103: // Support: IE9-11+ nicholas@103: // Microsoft forgot to hump their vendor prefix (#9572) nicholas@103: camelCase: function( string ) { nicholas@103: return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); nicholas@103: }, nicholas@103: nicholas@103: nodeName: function( elem, name ) { nicholas@103: return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); nicholas@103: }, nicholas@103: nicholas@103: // args is for internal usage only nicholas@103: each: function( obj, callback, args ) { nicholas@103: var value, nicholas@103: i = 0, nicholas@103: length = obj.length, nicholas@103: isArray = isArraylike( obj ); nicholas@103: nicholas@103: if ( args ) { nicholas@103: if ( isArray ) { nicholas@103: for ( ; i < length; i++ ) { nicholas@103: value = callback.apply( obj[ i ], args ); nicholas@103: nicholas@103: if ( value === false ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } else { nicholas@103: for ( i in obj ) { nicholas@103: value = callback.apply( obj[ i ], args ); nicholas@103: nicholas@103: if ( value === false ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // A special, fast, case for the most common use of each nicholas@103: } else { nicholas@103: if ( isArray ) { nicholas@103: for ( ; i < length; i++ ) { nicholas@103: value = callback.call( obj[ i ], i, obj[ i ] ); nicholas@103: nicholas@103: if ( value === false ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } else { nicholas@103: for ( i in obj ) { nicholas@103: value = callback.call( obj[ i ], i, obj[ i ] ); nicholas@103: nicholas@103: if ( value === false ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return obj; nicholas@103: }, nicholas@103: nicholas@103: // Support: Android<4.1 nicholas@103: trim: function( text ) { nicholas@103: return text == null ? nicholas@103: "" : nicholas@103: ( text + "" ).replace( rtrim, "" ); nicholas@103: }, nicholas@103: nicholas@103: // results is for internal usage only nicholas@103: makeArray: function( arr, results ) { nicholas@103: var ret = results || []; nicholas@103: nicholas@103: if ( arr != null ) { nicholas@103: if ( isArraylike( Object(arr) ) ) { nicholas@103: jQuery.merge( ret, nicholas@103: typeof arr === "string" ? nicholas@103: [ arr ] : arr nicholas@103: ); nicholas@103: } else { nicholas@103: push.call( ret, arr ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return ret; nicholas@103: }, nicholas@103: nicholas@103: inArray: function( elem, arr, i ) { nicholas@103: return arr == null ? -1 : indexOf.call( arr, elem, i ); nicholas@103: }, nicholas@103: nicholas@103: merge: function( first, second ) { nicholas@103: var len = +second.length, nicholas@103: j = 0, nicholas@103: i = first.length; nicholas@103: nicholas@103: for ( ; j < len; j++ ) { nicholas@103: first[ i++ ] = second[ j ]; nicholas@103: } nicholas@103: nicholas@103: first.length = i; nicholas@103: nicholas@103: return first; nicholas@103: }, nicholas@103: nicholas@103: grep: function( elems, callback, invert ) { nicholas@103: var callbackInverse, nicholas@103: matches = [], nicholas@103: i = 0, nicholas@103: length = elems.length, nicholas@103: callbackExpect = !invert; nicholas@103: nicholas@103: // Go through the array, only saving the items nicholas@103: // that pass the validator function nicholas@103: for ( ; i < length; i++ ) { nicholas@103: callbackInverse = !callback( elems[ i ], i ); nicholas@103: if ( callbackInverse !== callbackExpect ) { nicholas@103: matches.push( elems[ i ] ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return matches; nicholas@103: }, nicholas@103: nicholas@103: // arg is for internal usage only nicholas@103: map: function( elems, callback, arg ) { nicholas@103: var value, nicholas@103: i = 0, nicholas@103: length = elems.length, nicholas@103: isArray = isArraylike( elems ), nicholas@103: ret = []; nicholas@103: nicholas@103: // Go through the array, translating each of the items to their new values nicholas@103: if ( isArray ) { nicholas@103: for ( ; i < length; i++ ) { nicholas@103: value = callback( elems[ i ], i, arg ); nicholas@103: nicholas@103: if ( value != null ) { nicholas@103: ret.push( value ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Go through every key on the object, nicholas@103: } else { nicholas@103: for ( i in elems ) { nicholas@103: value = callback( elems[ i ], i, arg ); nicholas@103: nicholas@103: if ( value != null ) { nicholas@103: ret.push( value ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Flatten any nested arrays nicholas@103: return concat.apply( [], ret ); nicholas@103: }, nicholas@103: nicholas@103: // A global GUID counter for objects nicholas@103: guid: 1, nicholas@103: nicholas@103: // Bind a function to a context, optionally partially applying any nicholas@103: // arguments. nicholas@103: proxy: function( fn, context ) { nicholas@103: var tmp, args, proxy; nicholas@103: nicholas@103: if ( typeof context === "string" ) { nicholas@103: tmp = fn[ context ]; nicholas@103: context = fn; nicholas@103: fn = tmp; nicholas@103: } nicholas@103: nicholas@103: // Quick check to determine if target is callable, in the spec nicholas@103: // this throws a TypeError, but we will just return undefined. nicholas@103: if ( !jQuery.isFunction( fn ) ) { nicholas@103: return undefined; nicholas@103: } nicholas@103: nicholas@103: // Simulated bind nicholas@103: args = slice.call( arguments, 2 ); nicholas@103: proxy = function() { nicholas@103: return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); nicholas@103: }; nicholas@103: nicholas@103: // Set the guid of unique handler to the same of original handler, so it can be removed nicholas@103: proxy.guid = fn.guid = fn.guid || jQuery.guid++; nicholas@103: nicholas@103: return proxy; nicholas@103: }, nicholas@103: nicholas@103: now: Date.now, nicholas@103: nicholas@103: // jQuery.support is not used in Core but other projects attach their nicholas@103: // properties to it so it needs to exist. nicholas@103: support: support nicholas@103: }); nicholas@103: nicholas@103: // Populate the class2type map nicholas@103: jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { nicholas@103: class2type[ "[object " + name + "]" ] = name.toLowerCase(); nicholas@103: }); nicholas@103: nicholas@103: function isArraylike( obj ) { nicholas@103: nicholas@103: // Support: iOS 8.2 (not reproducible in simulator) nicholas@103: // `in` check used to prevent JIT error (gh-2145) nicholas@103: // hasOwn isn't used here due to false negatives nicholas@103: // regarding Nodelist length in IE nicholas@103: var length = "length" in obj && obj.length, nicholas@103: type = jQuery.type( obj ); nicholas@103: nicholas@103: if ( type === "function" || jQuery.isWindow( obj ) ) { nicholas@103: return false; nicholas@103: } nicholas@103: nicholas@103: if ( obj.nodeType === 1 && length ) { nicholas@103: return true; nicholas@103: } nicholas@103: nicholas@103: return type === "array" || length === 0 || nicholas@103: typeof length === "number" && length > 0 && ( length - 1 ) in obj; nicholas@103: } nicholas@103: var Sizzle = nicholas@103: /*! nicholas@103: * Sizzle CSS Selector Engine v2.2.0-pre nicholas@103: * http://sizzlejs.com/ nicholas@103: * nicholas@103: * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors nicholas@103: * Released under the MIT license nicholas@103: * http://jquery.org/license nicholas@103: * nicholas@103: * Date: 2014-12-16 nicholas@103: */ nicholas@103: (function( window ) { nicholas@103: nicholas@103: var i, nicholas@103: support, nicholas@103: Expr, nicholas@103: getText, nicholas@103: isXML, nicholas@103: tokenize, nicholas@103: compile, nicholas@103: select, nicholas@103: outermostContext, nicholas@103: sortInput, nicholas@103: hasDuplicate, nicholas@103: nicholas@103: // Local document vars nicholas@103: setDocument, nicholas@103: document, nicholas@103: docElem, nicholas@103: documentIsHTML, nicholas@103: rbuggyQSA, nicholas@103: rbuggyMatches, nicholas@103: matches, nicholas@103: contains, nicholas@103: nicholas@103: // Instance-specific data nicholas@103: expando = "sizzle" + 1 * new Date(), nicholas@103: preferredDoc = window.document, nicholas@103: dirruns = 0, nicholas@103: done = 0, nicholas@103: classCache = createCache(), nicholas@103: tokenCache = createCache(), nicholas@103: compilerCache = createCache(), nicholas@103: sortOrder = function( a, b ) { nicholas@103: if ( a === b ) { nicholas@103: hasDuplicate = true; nicholas@103: } nicholas@103: return 0; nicholas@103: }, nicholas@103: nicholas@103: // General-purpose constants nicholas@103: MAX_NEGATIVE = 1 << 31, nicholas@103: nicholas@103: // Instance methods nicholas@103: hasOwn = ({}).hasOwnProperty, nicholas@103: arr = [], nicholas@103: pop = arr.pop, nicholas@103: push_native = arr.push, nicholas@103: push = arr.push, nicholas@103: slice = arr.slice, nicholas@103: // Use a stripped-down indexOf as it's faster than native nicholas@103: // http://jsperf.com/thor-indexof-vs-for/5 nicholas@103: indexOf = function( list, elem ) { nicholas@103: var i = 0, nicholas@103: len = list.length; nicholas@103: for ( ; i < len; i++ ) { nicholas@103: if ( list[i] === elem ) { nicholas@103: return i; nicholas@103: } nicholas@103: } nicholas@103: return -1; nicholas@103: }, nicholas@103: nicholas@103: booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", nicholas@103: nicholas@103: // Regular expressions nicholas@103: nicholas@103: // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace nicholas@103: whitespace = "[\\x20\\t\\r\\n\\f]", nicholas@103: // http://www.w3.org/TR/css3-syntax/#characters nicholas@103: characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", nicholas@103: nicholas@103: // Loosely modeled on CSS identifier characters nicholas@103: // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors nicholas@103: // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier nicholas@103: identifier = characterEncoding.replace( "w", "w#" ), nicholas@103: nicholas@103: // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors nicholas@103: attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + nicholas@103: // Operator (capture 2) nicholas@103: "*([*^$|!~]?=)" + whitespace + nicholas@103: // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" nicholas@103: "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + nicholas@103: "*\\]", nicholas@103: nicholas@103: pseudos = ":(" + characterEncoding + ")(?:\\((" + nicholas@103: // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: nicholas@103: // 1. quoted (capture 3; capture 4 or capture 5) nicholas@103: "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + nicholas@103: // 2. simple (capture 6) nicholas@103: "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + nicholas@103: // 3. anything else (capture 2) nicholas@103: ".*" + nicholas@103: ")\\)|)", nicholas@103: nicholas@103: // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter nicholas@103: rwhitespace = new RegExp( whitespace + "+", "g" ), nicholas@103: rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), nicholas@103: nicholas@103: rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), nicholas@103: rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), nicholas@103: nicholas@103: rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), nicholas@103: nicholas@103: rpseudo = new RegExp( pseudos ), nicholas@103: ridentifier = new RegExp( "^" + identifier + "$" ), nicholas@103: nicholas@103: matchExpr = { nicholas@103: "ID": new RegExp( "^#(" + characterEncoding + ")" ), nicholas@103: "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), nicholas@103: "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), nicholas@103: "ATTR": new RegExp( "^" + attributes ), nicholas@103: "PSEUDO": new RegExp( "^" + pseudos ), nicholas@103: "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + nicholas@103: "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + nicholas@103: "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), nicholas@103: "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), nicholas@103: // For use in libraries implementing .is() nicholas@103: // We use this for POS matching in `select` nicholas@103: "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + nicholas@103: whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) nicholas@103: }, nicholas@103: nicholas@103: rinputs = /^(?:input|select|textarea|button)$/i, nicholas@103: rheader = /^h\d$/i, nicholas@103: nicholas@103: rnative = /^[^{]+\{\s*\[native \w/, nicholas@103: nicholas@103: // Easily-parseable/retrievable ID or TAG or CLASS selectors nicholas@103: rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, nicholas@103: nicholas@103: rsibling = /[+~]/, nicholas@103: rescape = /'|\\/g, nicholas@103: nicholas@103: // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters nicholas@103: runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), nicholas@103: funescape = function( _, escaped, escapedWhitespace ) { nicholas@103: var high = "0x" + escaped - 0x10000; nicholas@103: // NaN means non-codepoint nicholas@103: // Support: Firefox<24 nicholas@103: // Workaround erroneous numeric interpretation of +"0x" nicholas@103: return high !== high || escapedWhitespace ? nicholas@103: escaped : nicholas@103: high < 0 ? nicholas@103: // BMP codepoint nicholas@103: String.fromCharCode( high + 0x10000 ) : nicholas@103: // Supplemental Plane codepoint (surrogate pair) nicholas@103: String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); nicholas@103: }, nicholas@103: nicholas@103: // Used for iframes nicholas@103: // See setDocument() nicholas@103: // Removing the function wrapper causes a "Permission Denied" nicholas@103: // error in IE nicholas@103: unloadHandler = function() { nicholas@103: setDocument(); nicholas@103: }; nicholas@103: nicholas@103: // Optimize for push.apply( _, NodeList ) nicholas@103: try { nicholas@103: push.apply( nicholas@103: (arr = slice.call( preferredDoc.childNodes )), nicholas@103: preferredDoc.childNodes nicholas@103: ); nicholas@103: // Support: Android<4.0 nicholas@103: // Detect silently failing push.apply nicholas@103: arr[ preferredDoc.childNodes.length ].nodeType; nicholas@103: } catch ( e ) { nicholas@103: push = { apply: arr.length ? nicholas@103: nicholas@103: // Leverage slice if possible nicholas@103: function( target, els ) { nicholas@103: push_native.apply( target, slice.call(els) ); nicholas@103: } : nicholas@103: nicholas@103: // Support: IE<9 nicholas@103: // Otherwise append directly nicholas@103: function( target, els ) { nicholas@103: var j = target.length, nicholas@103: i = 0; nicholas@103: // Can't trust NodeList.length nicholas@103: while ( (target[j++] = els[i++]) ) {} nicholas@103: target.length = j - 1; nicholas@103: } nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: function Sizzle( selector, context, results, seed ) { nicholas@103: var match, elem, m, nodeType, nicholas@103: // QSA vars nicholas@103: i, groups, old, nid, newContext, newSelector; nicholas@103: nicholas@103: if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { nicholas@103: setDocument( context ); nicholas@103: } nicholas@103: nicholas@103: context = context || document; nicholas@103: results = results || []; nicholas@103: nodeType = context.nodeType; nicholas@103: nicholas@103: if ( typeof selector !== "string" || !selector || nicholas@103: nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { nicholas@103: nicholas@103: return results; nicholas@103: } nicholas@103: nicholas@103: if ( !seed && documentIsHTML ) { nicholas@103: nicholas@103: // Try to shortcut find operations when possible (e.g., not under DocumentFragment) nicholas@103: if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) { nicholas@103: // Speed-up: Sizzle("#ID") nicholas@103: if ( (m = match[1]) ) { nicholas@103: if ( nodeType === 9 ) { nicholas@103: elem = context.getElementById( m ); nicholas@103: // Check parentNode to catch when Blackberry 4.6 returns nicholas@103: // nodes that are no longer in the document (jQuery #6963) nicholas@103: if ( elem && elem.parentNode ) { nicholas@103: // Handle the case where IE, Opera, and Webkit return items nicholas@103: // by name instead of ID nicholas@103: if ( elem.id === m ) { nicholas@103: results.push( elem ); nicholas@103: return results; nicholas@103: } nicholas@103: } else { nicholas@103: return results; nicholas@103: } nicholas@103: } else { nicholas@103: // Context is not a document nicholas@103: if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && nicholas@103: contains( context, elem ) && elem.id === m ) { nicholas@103: results.push( elem ); nicholas@103: return results; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Speed-up: Sizzle("TAG") nicholas@103: } else if ( match[2] ) { nicholas@103: push.apply( results, context.getElementsByTagName( selector ) ); nicholas@103: return results; nicholas@103: nicholas@103: // Speed-up: Sizzle(".CLASS") nicholas@103: } else if ( (m = match[3]) && support.getElementsByClassName ) { nicholas@103: push.apply( results, context.getElementsByClassName( m ) ); nicholas@103: return results; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // QSA path nicholas@103: if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { nicholas@103: nid = old = expando; nicholas@103: newContext = context; nicholas@103: newSelector = nodeType !== 1 && selector; nicholas@103: nicholas@103: // qSA works strangely on Element-rooted queries nicholas@103: // We can work around this by specifying an extra ID on the root nicholas@103: // and working up from there (Thanks to Andrew Dupont for the technique) nicholas@103: // IE 8 doesn't work on object elements nicholas@103: if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { nicholas@103: groups = tokenize( selector ); nicholas@103: nicholas@103: if ( (old = context.getAttribute("id")) ) { nicholas@103: nid = old.replace( rescape, "\\$&" ); nicholas@103: } else { nicholas@103: context.setAttribute( "id", nid ); nicholas@103: } nicholas@103: nid = "[id='" + nid + "'] "; nicholas@103: nicholas@103: i = groups.length; nicholas@103: while ( i-- ) { nicholas@103: groups[i] = nid + toSelector( groups[i] ); nicholas@103: } nicholas@103: newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; nicholas@103: newSelector = groups.join(","); nicholas@103: } nicholas@103: nicholas@103: if ( newSelector ) { nicholas@103: try { nicholas@103: push.apply( results, nicholas@103: newContext.querySelectorAll( newSelector ) nicholas@103: ); nicholas@103: return results; nicholas@103: } catch(qsaError) { nicholas@103: } finally { nicholas@103: if ( !old ) { nicholas@103: context.removeAttribute("id"); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // All others nicholas@103: return select( selector.replace( rtrim, "$1" ), context, results, seed ); nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Create key-value caches of limited size nicholas@103: * @returns {Function(string, Object)} Returns the Object data after storing it on itself with nicholas@103: * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) nicholas@103: * deleting the oldest entry nicholas@103: */ nicholas@103: function createCache() { nicholas@103: var keys = []; nicholas@103: nicholas@103: function cache( key, value ) { nicholas@103: // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) nicholas@103: if ( keys.push( key + " " ) > Expr.cacheLength ) { nicholas@103: // Only keep the most recent entries nicholas@103: delete cache[ keys.shift() ]; nicholas@103: } nicholas@103: return (cache[ key + " " ] = value); nicholas@103: } nicholas@103: return cache; nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Mark a function for special use by Sizzle nicholas@103: * @param {Function} fn The function to mark nicholas@103: */ nicholas@103: function markFunction( fn ) { nicholas@103: fn[ expando ] = true; nicholas@103: return fn; nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Support testing using an element nicholas@103: * @param {Function} fn Passed the created div and expects a boolean result nicholas@103: */ nicholas@103: function assert( fn ) { nicholas@103: var div = document.createElement("div"); nicholas@103: nicholas@103: try { nicholas@103: return !!fn( div ); nicholas@103: } catch (e) { nicholas@103: return false; nicholas@103: } finally { nicholas@103: // Remove from its parent by default nicholas@103: if ( div.parentNode ) { nicholas@103: div.parentNode.removeChild( div ); nicholas@103: } nicholas@103: // release memory in IE nicholas@103: div = null; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Adds the same handler for all of the specified attrs nicholas@103: * @param {String} attrs Pipe-separated list of attributes nicholas@103: * @param {Function} handler The method that will be applied nicholas@103: */ nicholas@103: function addHandle( attrs, handler ) { nicholas@103: var arr = attrs.split("|"), nicholas@103: i = attrs.length; nicholas@103: nicholas@103: while ( i-- ) { nicholas@103: Expr.attrHandle[ arr[i] ] = handler; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Checks document order of two siblings nicholas@103: * @param {Element} a nicholas@103: * @param {Element} b nicholas@103: * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b nicholas@103: */ nicholas@103: function siblingCheck( a, b ) { nicholas@103: var cur = b && a, nicholas@103: diff = cur && a.nodeType === 1 && b.nodeType === 1 && nicholas@103: ( ~b.sourceIndex || MAX_NEGATIVE ) - nicholas@103: ( ~a.sourceIndex || MAX_NEGATIVE ); nicholas@103: nicholas@103: // Use IE sourceIndex if available on both nodes nicholas@103: if ( diff ) { nicholas@103: return diff; nicholas@103: } nicholas@103: nicholas@103: // Check if b follows a nicholas@103: if ( cur ) { nicholas@103: while ( (cur = cur.nextSibling) ) { nicholas@103: if ( cur === b ) { nicholas@103: return -1; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return a ? 1 : -1; nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Returns a function to use in pseudos for input types nicholas@103: * @param {String} type nicholas@103: */ nicholas@103: function createInputPseudo( type ) { nicholas@103: return function( elem ) { nicholas@103: var name = elem.nodeName.toLowerCase(); nicholas@103: return name === "input" && elem.type === type; nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Returns a function to use in pseudos for buttons nicholas@103: * @param {String} type nicholas@103: */ nicholas@103: function createButtonPseudo( type ) { nicholas@103: return function( elem ) { nicholas@103: var name = elem.nodeName.toLowerCase(); nicholas@103: return (name === "input" || name === "button") && elem.type === type; nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Returns a function to use in pseudos for positionals nicholas@103: * @param {Function} fn nicholas@103: */ nicholas@103: function createPositionalPseudo( fn ) { nicholas@103: return markFunction(function( argument ) { nicholas@103: argument = +argument; nicholas@103: return markFunction(function( seed, matches ) { nicholas@103: var j, nicholas@103: matchIndexes = fn( [], seed.length, argument ), nicholas@103: i = matchIndexes.length; nicholas@103: nicholas@103: // Match elements found at the specified indexes nicholas@103: while ( i-- ) { nicholas@103: if ( seed[ (j = matchIndexes[i]) ] ) { nicholas@103: seed[j] = !(matches[j] = seed[j]); nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Checks a node for validity as a Sizzle context nicholas@103: * @param {Element|Object=} context nicholas@103: * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value nicholas@103: */ nicholas@103: function testContext( context ) { nicholas@103: return context && typeof context.getElementsByTagName !== "undefined" && context; nicholas@103: } nicholas@103: nicholas@103: // Expose support vars for convenience nicholas@103: support = Sizzle.support = {}; nicholas@103: nicholas@103: /** nicholas@103: * Detects XML nodes nicholas@103: * @param {Element|Object} elem An element or a document nicholas@103: * @returns {Boolean} True iff elem is a non-HTML XML node nicholas@103: */ nicholas@103: isXML = Sizzle.isXML = function( elem ) { nicholas@103: // documentElement is verified for cases where it doesn't yet exist nicholas@103: // (such as loading iframes in IE - #4833) nicholas@103: var documentElement = elem && (elem.ownerDocument || elem).documentElement; nicholas@103: return documentElement ? documentElement.nodeName !== "HTML" : false; nicholas@103: }; nicholas@103: nicholas@103: /** nicholas@103: * Sets document-related variables once based on the current document nicholas@103: * @param {Element|Object} [doc] An element or document object to use to set the document nicholas@103: * @returns {Object} Returns the current document nicholas@103: */ nicholas@103: setDocument = Sizzle.setDocument = function( node ) { nicholas@103: var hasCompare, parent, nicholas@103: doc = node ? node.ownerDocument || node : preferredDoc; nicholas@103: nicholas@103: // If no document and documentElement is available, return nicholas@103: if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { nicholas@103: return document; nicholas@103: } nicholas@103: nicholas@103: // Set our document nicholas@103: document = doc; nicholas@103: docElem = doc.documentElement; nicholas@103: parent = doc.defaultView; nicholas@103: nicholas@103: // Support: IE>8 nicholas@103: // If iframe document is assigned to "document" variable and if iframe has been reloaded, nicholas@103: // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 nicholas@103: // IE6-8 do not support the defaultView property so parent will be undefined nicholas@103: if ( parent && parent !== parent.top ) { nicholas@103: // IE11 does not have attachEvent, so all must suffer nicholas@103: if ( parent.addEventListener ) { nicholas@103: parent.addEventListener( "unload", unloadHandler, false ); nicholas@103: } else if ( parent.attachEvent ) { nicholas@103: parent.attachEvent( "onunload", unloadHandler ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: /* Support tests nicholas@103: ---------------------------------------------------------------------- */ nicholas@103: documentIsHTML = !isXML( doc ); nicholas@103: nicholas@103: /* Attributes nicholas@103: ---------------------------------------------------------------------- */ nicholas@103: nicholas@103: // Support: IE<8 nicholas@103: // Verify that getAttribute really returns attributes and not properties nicholas@103: // (excepting IE8 booleans) nicholas@103: support.attributes = assert(function( div ) { nicholas@103: div.className = "i"; nicholas@103: return !div.getAttribute("className"); nicholas@103: }); nicholas@103: nicholas@103: /* getElement(s)By* nicholas@103: ---------------------------------------------------------------------- */ nicholas@103: nicholas@103: // Check if getElementsByTagName("*") returns only elements nicholas@103: support.getElementsByTagName = assert(function( div ) { nicholas@103: div.appendChild( doc.createComment("") ); nicholas@103: return !div.getElementsByTagName("*").length; nicholas@103: }); nicholas@103: nicholas@103: // Support: IE<9 nicholas@103: support.getElementsByClassName = rnative.test( doc.getElementsByClassName ); nicholas@103: nicholas@103: // Support: IE<10 nicholas@103: // Check if getElementById returns elements by name nicholas@103: // The broken getElementById methods don't pick up programatically-set names, nicholas@103: // so use a roundabout getElementsByName test nicholas@103: support.getById = assert(function( div ) { nicholas@103: docElem.appendChild( div ).id = expando; nicholas@103: return !doc.getElementsByName || !doc.getElementsByName( expando ).length; nicholas@103: }); nicholas@103: nicholas@103: // ID find and filter nicholas@103: if ( support.getById ) { nicholas@103: Expr.find["ID"] = function( id, context ) { nicholas@103: if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { nicholas@103: var m = context.getElementById( id ); nicholas@103: // Check parentNode to catch when Blackberry 4.6 returns nicholas@103: // nodes that are no longer in the document #6963 nicholas@103: return m && m.parentNode ? [ m ] : []; nicholas@103: } nicholas@103: }; nicholas@103: Expr.filter["ID"] = function( id ) { nicholas@103: var attrId = id.replace( runescape, funescape ); nicholas@103: return function( elem ) { nicholas@103: return elem.getAttribute("id") === attrId; nicholas@103: }; nicholas@103: }; nicholas@103: } else { nicholas@103: // Support: IE6/7 nicholas@103: // getElementById is not reliable as a find shortcut nicholas@103: delete Expr.find["ID"]; nicholas@103: nicholas@103: Expr.filter["ID"] = function( id ) { nicholas@103: var attrId = id.replace( runescape, funescape ); nicholas@103: return function( elem ) { nicholas@103: var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); nicholas@103: return node && node.value === attrId; nicholas@103: }; nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: // Tag nicholas@103: Expr.find["TAG"] = support.getElementsByTagName ? nicholas@103: function( tag, context ) { nicholas@103: if ( typeof context.getElementsByTagName !== "undefined" ) { nicholas@103: return context.getElementsByTagName( tag ); nicholas@103: nicholas@103: // DocumentFragment nodes don't have gEBTN nicholas@103: } else if ( support.qsa ) { nicholas@103: return context.querySelectorAll( tag ); nicholas@103: } nicholas@103: } : nicholas@103: nicholas@103: function( tag, context ) { nicholas@103: var elem, nicholas@103: tmp = [], nicholas@103: i = 0, nicholas@103: // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too nicholas@103: results = context.getElementsByTagName( tag ); nicholas@103: nicholas@103: // Filter out possible comments nicholas@103: if ( tag === "*" ) { nicholas@103: while ( (elem = results[i++]) ) { nicholas@103: if ( elem.nodeType === 1 ) { nicholas@103: tmp.push( elem ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return tmp; nicholas@103: } nicholas@103: return results; nicholas@103: }; nicholas@103: nicholas@103: // Class nicholas@103: Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { nicholas@103: if ( documentIsHTML ) { nicholas@103: return context.getElementsByClassName( className ); nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: /* QSA/matchesSelector nicholas@103: ---------------------------------------------------------------------- */ nicholas@103: nicholas@103: // QSA and matchesSelector support nicholas@103: nicholas@103: // matchesSelector(:active) reports false when true (IE9/Opera 11.5) nicholas@103: rbuggyMatches = []; nicholas@103: nicholas@103: // qSa(:focus) reports false when true (Chrome 21) nicholas@103: // We allow this because of a bug in IE8/9 that throws an error nicholas@103: // whenever `document.activeElement` is accessed on an iframe nicholas@103: // So, we allow :focus to pass through QSA all the time to avoid the IE error nicholas@103: // See http://bugs.jquery.com/ticket/13378 nicholas@103: rbuggyQSA = []; nicholas@103: nicholas@103: if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { nicholas@103: // Build QSA regex nicholas@103: // Regex strategy adopted from Diego Perini nicholas@103: assert(function( div ) { nicholas@103: // Select is set to empty string on purpose nicholas@103: // This is to test IE's treatment of not explicitly nicholas@103: // setting a boolean content attribute, nicholas@103: // since its presence should be enough nicholas@103: // http://bugs.jquery.com/ticket/12359 nicholas@103: docElem.appendChild( div ).innerHTML = "" + nicholas@103: ""; nicholas@103: nicholas@103: // Support: IE8, Opera 11-12.16 nicholas@103: // Nothing should be selected when empty strings follow ^= or $= or *= nicholas@103: // The test attribute must be unknown in Opera but "safe" for WinRT nicholas@103: // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section nicholas@103: if ( div.querySelectorAll("[msallowcapture^='']").length ) { nicholas@103: rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); nicholas@103: } nicholas@103: nicholas@103: // Support: IE8 nicholas@103: // Boolean attributes and "value" are not treated correctly nicholas@103: if ( !div.querySelectorAll("[selected]").length ) { nicholas@103: rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); nicholas@103: } nicholas@103: nicholas@103: // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+ nicholas@103: if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) { nicholas@103: rbuggyQSA.push("~="); nicholas@103: } nicholas@103: nicholas@103: // Webkit/Opera - :checked should return selected option elements nicholas@103: // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked nicholas@103: // IE8 throws error here and will not see later tests nicholas@103: if ( !div.querySelectorAll(":checked").length ) { nicholas@103: rbuggyQSA.push(":checked"); nicholas@103: } nicholas@103: nicholas@103: // Support: Safari 8+, iOS 8+ nicholas@103: // https://bugs.webkit.org/show_bug.cgi?id=136851 nicholas@103: // In-page `selector#id sibing-combinator selector` fails nicholas@103: if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) { nicholas@103: rbuggyQSA.push(".#.+[+~]"); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: assert(function( div ) { nicholas@103: // Support: Windows 8 Native Apps nicholas@103: // The type and name attributes are restricted during .innerHTML assignment nicholas@103: var input = doc.createElement("input"); nicholas@103: input.setAttribute( "type", "hidden" ); nicholas@103: div.appendChild( input ).setAttribute( "name", "D" ); nicholas@103: nicholas@103: // Support: IE8 nicholas@103: // Enforce case-sensitivity of name attribute nicholas@103: if ( div.querySelectorAll("[name=d]").length ) { nicholas@103: rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); nicholas@103: } nicholas@103: nicholas@103: // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) nicholas@103: // IE8 throws error here and will not see later tests nicholas@103: if ( !div.querySelectorAll(":enabled").length ) { nicholas@103: rbuggyQSA.push( ":enabled", ":disabled" ); nicholas@103: } nicholas@103: nicholas@103: // Opera 10-11 does not throw on post-comma invalid pseudos nicholas@103: div.querySelectorAll("*,:x"); nicholas@103: rbuggyQSA.push(",.*:"); nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || nicholas@103: docElem.webkitMatchesSelector || nicholas@103: docElem.mozMatchesSelector || nicholas@103: docElem.oMatchesSelector || nicholas@103: docElem.msMatchesSelector) )) ) { nicholas@103: nicholas@103: assert(function( div ) { nicholas@103: // Check to see if it's possible to do matchesSelector nicholas@103: // on a disconnected node (IE 9) nicholas@103: support.disconnectedMatch = matches.call( div, "div" ); nicholas@103: nicholas@103: // This should fail with an exception nicholas@103: // Gecko does not error, returns false instead nicholas@103: matches.call( div, "[s!='']:x" ); nicholas@103: rbuggyMatches.push( "!=", pseudos ); nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); nicholas@103: rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); nicholas@103: nicholas@103: /* Contains nicholas@103: ---------------------------------------------------------------------- */ nicholas@103: hasCompare = rnative.test( docElem.compareDocumentPosition ); nicholas@103: nicholas@103: // Element contains another nicholas@103: // Purposefully does not implement inclusive descendent nicholas@103: // As in, an element does not contain itself nicholas@103: contains = hasCompare || rnative.test( docElem.contains ) ? nicholas@103: function( a, b ) { nicholas@103: var adown = a.nodeType === 9 ? a.documentElement : a, nicholas@103: bup = b && b.parentNode; nicholas@103: return a === bup || !!( bup && bup.nodeType === 1 && ( nicholas@103: adown.contains ? nicholas@103: adown.contains( bup ) : nicholas@103: a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 nicholas@103: )); nicholas@103: } : nicholas@103: function( a, b ) { nicholas@103: if ( b ) { nicholas@103: while ( (b = b.parentNode) ) { nicholas@103: if ( b === a ) { nicholas@103: return true; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: return false; nicholas@103: }; nicholas@103: nicholas@103: /* Sorting nicholas@103: ---------------------------------------------------------------------- */ nicholas@103: nicholas@103: // Document order sorting nicholas@103: sortOrder = hasCompare ? nicholas@103: function( a, b ) { nicholas@103: nicholas@103: // Flag for duplicate removal nicholas@103: if ( a === b ) { nicholas@103: hasDuplicate = true; nicholas@103: return 0; nicholas@103: } nicholas@103: nicholas@103: // Sort on method existence if only one input has compareDocumentPosition nicholas@103: var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; nicholas@103: if ( compare ) { nicholas@103: return compare; nicholas@103: } nicholas@103: nicholas@103: // Calculate position if both inputs belong to the same document nicholas@103: compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? nicholas@103: a.compareDocumentPosition( b ) : nicholas@103: nicholas@103: // Otherwise we know they are disconnected nicholas@103: 1; nicholas@103: nicholas@103: // Disconnected nodes nicholas@103: if ( compare & 1 || nicholas@103: (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { nicholas@103: nicholas@103: // Choose the first element that is related to our preferred document nicholas@103: if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { nicholas@103: return -1; nicholas@103: } nicholas@103: if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { nicholas@103: return 1; nicholas@103: } nicholas@103: nicholas@103: // Maintain original order nicholas@103: return sortInput ? nicholas@103: ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : nicholas@103: 0; nicholas@103: } nicholas@103: nicholas@103: return compare & 4 ? -1 : 1; nicholas@103: } : nicholas@103: function( a, b ) { nicholas@103: // Exit early if the nodes are identical nicholas@103: if ( a === b ) { nicholas@103: hasDuplicate = true; nicholas@103: return 0; nicholas@103: } nicholas@103: nicholas@103: var cur, nicholas@103: i = 0, nicholas@103: aup = a.parentNode, nicholas@103: bup = b.parentNode, nicholas@103: ap = [ a ], nicholas@103: bp = [ b ]; nicholas@103: nicholas@103: // Parentless nodes are either documents or disconnected nicholas@103: if ( !aup || !bup ) { nicholas@103: return a === doc ? -1 : nicholas@103: b === doc ? 1 : nicholas@103: aup ? -1 : nicholas@103: bup ? 1 : nicholas@103: sortInput ? nicholas@103: ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : nicholas@103: 0; nicholas@103: nicholas@103: // If the nodes are siblings, we can do a quick check nicholas@103: } else if ( aup === bup ) { nicholas@103: return siblingCheck( a, b ); nicholas@103: } nicholas@103: nicholas@103: // Otherwise we need full lists of their ancestors for comparison nicholas@103: cur = a; nicholas@103: while ( (cur = cur.parentNode) ) { nicholas@103: ap.unshift( cur ); nicholas@103: } nicholas@103: cur = b; nicholas@103: while ( (cur = cur.parentNode) ) { nicholas@103: bp.unshift( cur ); nicholas@103: } nicholas@103: nicholas@103: // Walk down the tree looking for a discrepancy nicholas@103: while ( ap[i] === bp[i] ) { nicholas@103: i++; nicholas@103: } nicholas@103: nicholas@103: return i ? nicholas@103: // Do a sibling check if the nodes have a common ancestor nicholas@103: siblingCheck( ap[i], bp[i] ) : nicholas@103: nicholas@103: // Otherwise nodes in our document sort first nicholas@103: ap[i] === preferredDoc ? -1 : nicholas@103: bp[i] === preferredDoc ? 1 : nicholas@103: 0; nicholas@103: }; nicholas@103: nicholas@103: return doc; nicholas@103: }; nicholas@103: nicholas@103: Sizzle.matches = function( expr, elements ) { nicholas@103: return Sizzle( expr, null, null, elements ); nicholas@103: }; nicholas@103: nicholas@103: Sizzle.matchesSelector = function( elem, expr ) { nicholas@103: // Set document vars if needed nicholas@103: if ( ( elem.ownerDocument || elem ) !== document ) { nicholas@103: setDocument( elem ); nicholas@103: } nicholas@103: nicholas@103: // Make sure that attribute selectors are quoted nicholas@103: expr = expr.replace( rattributeQuotes, "='$1']" ); nicholas@103: nicholas@103: if ( support.matchesSelector && documentIsHTML && nicholas@103: ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && nicholas@103: ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { nicholas@103: nicholas@103: try { nicholas@103: var ret = matches.call( elem, expr ); nicholas@103: nicholas@103: // IE 9's matchesSelector returns false on disconnected nodes nicholas@103: if ( ret || support.disconnectedMatch || nicholas@103: // As well, disconnected nodes are said to be in a document nicholas@103: // fragment in IE 9 nicholas@103: elem.document && elem.document.nodeType !== 11 ) { nicholas@103: return ret; nicholas@103: } nicholas@103: } catch (e) {} nicholas@103: } nicholas@103: nicholas@103: return Sizzle( expr, document, null, [ elem ] ).length > 0; nicholas@103: }; nicholas@103: nicholas@103: Sizzle.contains = function( context, elem ) { nicholas@103: // Set document vars if needed nicholas@103: if ( ( context.ownerDocument || context ) !== document ) { nicholas@103: setDocument( context ); nicholas@103: } nicholas@103: return contains( context, elem ); nicholas@103: }; nicholas@103: nicholas@103: Sizzle.attr = function( elem, name ) { nicholas@103: // Set document vars if needed nicholas@103: if ( ( elem.ownerDocument || elem ) !== document ) { nicholas@103: setDocument( elem ); nicholas@103: } nicholas@103: nicholas@103: var fn = Expr.attrHandle[ name.toLowerCase() ], nicholas@103: // Don't get fooled by Object.prototype properties (jQuery #13807) nicholas@103: val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? nicholas@103: fn( elem, name, !documentIsHTML ) : nicholas@103: undefined; nicholas@103: nicholas@103: return val !== undefined ? nicholas@103: val : nicholas@103: support.attributes || !documentIsHTML ? nicholas@103: elem.getAttribute( name ) : nicholas@103: (val = elem.getAttributeNode(name)) && val.specified ? nicholas@103: val.value : nicholas@103: null; nicholas@103: }; nicholas@103: nicholas@103: Sizzle.error = function( msg ) { nicholas@103: throw new Error( "Syntax error, unrecognized expression: " + msg ); nicholas@103: }; nicholas@103: nicholas@103: /** nicholas@103: * Document sorting and removing duplicates nicholas@103: * @param {ArrayLike} results nicholas@103: */ nicholas@103: Sizzle.uniqueSort = function( results ) { nicholas@103: var elem, nicholas@103: duplicates = [], nicholas@103: j = 0, nicholas@103: i = 0; nicholas@103: nicholas@103: // Unless we *know* we can detect duplicates, assume their presence nicholas@103: hasDuplicate = !support.detectDuplicates; nicholas@103: sortInput = !support.sortStable && results.slice( 0 ); nicholas@103: results.sort( sortOrder ); nicholas@103: nicholas@103: if ( hasDuplicate ) { nicholas@103: while ( (elem = results[i++]) ) { nicholas@103: if ( elem === results[ i ] ) { nicholas@103: j = duplicates.push( i ); nicholas@103: } nicholas@103: } nicholas@103: while ( j-- ) { nicholas@103: results.splice( duplicates[ j ], 1 ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Clear input after sorting to release objects nicholas@103: // See https://github.com/jquery/sizzle/pull/225 nicholas@103: sortInput = null; nicholas@103: nicholas@103: return results; nicholas@103: }; nicholas@103: nicholas@103: /** nicholas@103: * Utility function for retrieving the text value of an array of DOM nodes nicholas@103: * @param {Array|Element} elem nicholas@103: */ nicholas@103: getText = Sizzle.getText = function( elem ) { nicholas@103: var node, nicholas@103: ret = "", nicholas@103: i = 0, nicholas@103: nodeType = elem.nodeType; nicholas@103: nicholas@103: if ( !nodeType ) { nicholas@103: // If no nodeType, this is expected to be an array nicholas@103: while ( (node = elem[i++]) ) { nicholas@103: // Do not traverse comment nodes nicholas@103: ret += getText( node ); nicholas@103: } nicholas@103: } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { nicholas@103: // Use textContent for elements nicholas@103: // innerText usage removed for consistency of new lines (jQuery #11153) nicholas@103: if ( typeof elem.textContent === "string" ) { nicholas@103: return elem.textContent; nicholas@103: } else { nicholas@103: // Traverse its children nicholas@103: for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { nicholas@103: ret += getText( elem ); nicholas@103: } nicholas@103: } nicholas@103: } else if ( nodeType === 3 || nodeType === 4 ) { nicholas@103: return elem.nodeValue; nicholas@103: } nicholas@103: // Do not include comment or processing instruction nodes nicholas@103: nicholas@103: return ret; nicholas@103: }; nicholas@103: nicholas@103: Expr = Sizzle.selectors = { nicholas@103: nicholas@103: // Can be adjusted by the user nicholas@103: cacheLength: 50, nicholas@103: nicholas@103: createPseudo: markFunction, nicholas@103: nicholas@103: match: matchExpr, nicholas@103: nicholas@103: attrHandle: {}, nicholas@103: nicholas@103: find: {}, nicholas@103: nicholas@103: relative: { nicholas@103: ">": { dir: "parentNode", first: true }, nicholas@103: " ": { dir: "parentNode" }, nicholas@103: "+": { dir: "previousSibling", first: true }, nicholas@103: "~": { dir: "previousSibling" } nicholas@103: }, nicholas@103: nicholas@103: preFilter: { nicholas@103: "ATTR": function( match ) { nicholas@103: match[1] = match[1].replace( runescape, funescape ); nicholas@103: nicholas@103: // Move the given value to match[3] whether quoted or unquoted nicholas@103: match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); nicholas@103: nicholas@103: if ( match[2] === "~=" ) { nicholas@103: match[3] = " " + match[3] + " "; nicholas@103: } nicholas@103: nicholas@103: return match.slice( 0, 4 ); nicholas@103: }, nicholas@103: nicholas@103: "CHILD": function( match ) { nicholas@103: /* matches from matchExpr["CHILD"] nicholas@103: 1 type (only|nth|...) nicholas@103: 2 what (child|of-type) nicholas@103: 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) nicholas@103: 4 xn-component of xn+y argument ([+-]?\d*n|) nicholas@103: 5 sign of xn-component nicholas@103: 6 x of xn-component nicholas@103: 7 sign of y-component nicholas@103: 8 y of y-component nicholas@103: */ nicholas@103: match[1] = match[1].toLowerCase(); nicholas@103: nicholas@103: if ( match[1].slice( 0, 3 ) === "nth" ) { nicholas@103: // nth-* requires argument nicholas@103: if ( !match[3] ) { nicholas@103: Sizzle.error( match[0] ); nicholas@103: } nicholas@103: nicholas@103: // numeric x and y parameters for Expr.filter.CHILD nicholas@103: // remember that false/true cast respectively to 0/1 nicholas@103: match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); nicholas@103: match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); nicholas@103: nicholas@103: // other types prohibit arguments nicholas@103: } else if ( match[3] ) { nicholas@103: Sizzle.error( match[0] ); nicholas@103: } nicholas@103: nicholas@103: return match; nicholas@103: }, nicholas@103: nicholas@103: "PSEUDO": function( match ) { nicholas@103: var excess, nicholas@103: unquoted = !match[6] && match[2]; nicholas@103: nicholas@103: if ( matchExpr["CHILD"].test( match[0] ) ) { nicholas@103: return null; nicholas@103: } nicholas@103: nicholas@103: // Accept quoted arguments as-is nicholas@103: if ( match[3] ) { nicholas@103: match[2] = match[4] || match[5] || ""; nicholas@103: nicholas@103: // Strip excess characters from unquoted arguments nicholas@103: } else if ( unquoted && rpseudo.test( unquoted ) && nicholas@103: // Get excess from tokenize (recursively) nicholas@103: (excess = tokenize( unquoted, true )) && nicholas@103: // advance to the next closing parenthesis nicholas@103: (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { nicholas@103: nicholas@103: // excess is a negative index nicholas@103: match[0] = match[0].slice( 0, excess ); nicholas@103: match[2] = unquoted.slice( 0, excess ); nicholas@103: } nicholas@103: nicholas@103: // Return only captures needed by the pseudo filter method (type and argument) nicholas@103: return match.slice( 0, 3 ); nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: filter: { nicholas@103: nicholas@103: "TAG": function( nodeNameSelector ) { nicholas@103: var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); nicholas@103: return nodeNameSelector === "*" ? nicholas@103: function() { return true; } : nicholas@103: function( elem ) { nicholas@103: return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; nicholas@103: }; nicholas@103: }, nicholas@103: nicholas@103: "CLASS": function( className ) { nicholas@103: var pattern = classCache[ className + " " ]; nicholas@103: nicholas@103: return pattern || nicholas@103: (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && nicholas@103: classCache( className, function( elem ) { nicholas@103: return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" ); nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: "ATTR": function( name, operator, check ) { nicholas@103: return function( elem ) { nicholas@103: var result = Sizzle.attr( elem, name ); nicholas@103: nicholas@103: if ( result == null ) { nicholas@103: return operator === "!="; nicholas@103: } nicholas@103: if ( !operator ) { nicholas@103: return true; nicholas@103: } nicholas@103: nicholas@103: result += ""; nicholas@103: nicholas@103: return operator === "=" ? result === check : nicholas@103: operator === "!=" ? result !== check : nicholas@103: operator === "^=" ? check && result.indexOf( check ) === 0 : nicholas@103: operator === "*=" ? check && result.indexOf( check ) > -1 : nicholas@103: operator === "$=" ? check && result.slice( -check.length ) === check : nicholas@103: operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : nicholas@103: operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : nicholas@103: false; nicholas@103: }; nicholas@103: }, nicholas@103: nicholas@103: "CHILD": function( type, what, argument, first, last ) { nicholas@103: var simple = type.slice( 0, 3 ) !== "nth", nicholas@103: forward = type.slice( -4 ) !== "last", nicholas@103: ofType = what === "of-type"; nicholas@103: nicholas@103: return first === 1 && last === 0 ? nicholas@103: nicholas@103: // Shortcut for :nth-*(n) nicholas@103: function( elem ) { nicholas@103: return !!elem.parentNode; nicholas@103: } : nicholas@103: nicholas@103: function( elem, context, xml ) { nicholas@103: var cache, outerCache, node, diff, nodeIndex, start, nicholas@103: dir = simple !== forward ? "nextSibling" : "previousSibling", nicholas@103: parent = elem.parentNode, nicholas@103: name = ofType && elem.nodeName.toLowerCase(), nicholas@103: useCache = !xml && !ofType; nicholas@103: nicholas@103: if ( parent ) { nicholas@103: nicholas@103: // :(first|last|only)-(child|of-type) nicholas@103: if ( simple ) { nicholas@103: while ( dir ) { nicholas@103: node = elem; nicholas@103: while ( (node = node[ dir ]) ) { nicholas@103: if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { nicholas@103: return false; nicholas@103: } nicholas@103: } nicholas@103: // Reverse direction for :only-* (if we haven't yet done so) nicholas@103: start = dir = type === "only" && !start && "nextSibling"; nicholas@103: } nicholas@103: return true; nicholas@103: } nicholas@103: nicholas@103: start = [ forward ? parent.firstChild : parent.lastChild ]; nicholas@103: nicholas@103: // non-xml :nth-child(...) stores cache data on `parent` nicholas@103: if ( forward && useCache ) { nicholas@103: // Seek `elem` from a previously-cached index nicholas@103: outerCache = parent[ expando ] || (parent[ expando ] = {}); nicholas@103: cache = outerCache[ type ] || []; nicholas@103: nodeIndex = cache[0] === dirruns && cache[1]; nicholas@103: diff = cache[0] === dirruns && cache[2]; nicholas@103: node = nodeIndex && parent.childNodes[ nodeIndex ]; nicholas@103: nicholas@103: while ( (node = ++nodeIndex && node && node[ dir ] || nicholas@103: nicholas@103: // Fallback to seeking `elem` from the start nicholas@103: (diff = nodeIndex = 0) || start.pop()) ) { nicholas@103: nicholas@103: // When found, cache indexes on `parent` and break nicholas@103: if ( node.nodeType === 1 && ++diff && node === elem ) { nicholas@103: outerCache[ type ] = [ dirruns, nodeIndex, diff ]; nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Use previously-cached element index if available nicholas@103: } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { nicholas@103: diff = cache[1]; nicholas@103: nicholas@103: // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) nicholas@103: } else { nicholas@103: // Use the same loop as above to seek `elem` from the start nicholas@103: while ( (node = ++nodeIndex && node && node[ dir ] || nicholas@103: (diff = nodeIndex = 0) || start.pop()) ) { nicholas@103: nicholas@103: if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { nicholas@103: // Cache the index of each encountered element nicholas@103: if ( useCache ) { nicholas@103: (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; nicholas@103: } nicholas@103: nicholas@103: if ( node === elem ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Incorporate the offset, then check against cycle size nicholas@103: diff -= last; nicholas@103: return diff === first || ( diff % first === 0 && diff / first >= 0 ); nicholas@103: } nicholas@103: }; nicholas@103: }, nicholas@103: nicholas@103: "PSEUDO": function( pseudo, argument ) { nicholas@103: // pseudo-class names are case-insensitive nicholas@103: // http://www.w3.org/TR/selectors/#pseudo-classes nicholas@103: // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters nicholas@103: // Remember that setFilters inherits from pseudos nicholas@103: var args, nicholas@103: fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || nicholas@103: Sizzle.error( "unsupported pseudo: " + pseudo ); nicholas@103: nicholas@103: // The user may use createPseudo to indicate that nicholas@103: // arguments are needed to create the filter function nicholas@103: // just as Sizzle does nicholas@103: if ( fn[ expando ] ) { nicholas@103: return fn( argument ); nicholas@103: } nicholas@103: nicholas@103: // But maintain support for old signatures nicholas@103: if ( fn.length > 1 ) { nicholas@103: args = [ pseudo, pseudo, "", argument ]; nicholas@103: return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? nicholas@103: markFunction(function( seed, matches ) { nicholas@103: var idx, nicholas@103: matched = fn( seed, argument ), nicholas@103: i = matched.length; nicholas@103: while ( i-- ) { nicholas@103: idx = indexOf( seed, matched[i] ); nicholas@103: seed[ idx ] = !( matches[ idx ] = matched[i] ); nicholas@103: } nicholas@103: }) : nicholas@103: function( elem ) { nicholas@103: return fn( elem, 0, args ); nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: return fn; nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: pseudos: { nicholas@103: // Potentially complex pseudos nicholas@103: "not": markFunction(function( selector ) { nicholas@103: // Trim the selector passed to compile nicholas@103: // to avoid treating leading and trailing nicholas@103: // spaces as combinators nicholas@103: var input = [], nicholas@103: results = [], nicholas@103: matcher = compile( selector.replace( rtrim, "$1" ) ); nicholas@103: nicholas@103: return matcher[ expando ] ? nicholas@103: markFunction(function( seed, matches, context, xml ) { nicholas@103: var elem, nicholas@103: unmatched = matcher( seed, null, xml, [] ), nicholas@103: i = seed.length; nicholas@103: nicholas@103: // Match elements unmatched by `matcher` nicholas@103: while ( i-- ) { nicholas@103: if ( (elem = unmatched[i]) ) { nicholas@103: seed[i] = !(matches[i] = elem); nicholas@103: } nicholas@103: } nicholas@103: }) : nicholas@103: function( elem, context, xml ) { nicholas@103: input[0] = elem; nicholas@103: matcher( input, null, xml, results ); nicholas@103: // Don't keep the element (issue #299) nicholas@103: input[0] = null; nicholas@103: return !results.pop(); nicholas@103: }; nicholas@103: }), nicholas@103: nicholas@103: "has": markFunction(function( selector ) { nicholas@103: return function( elem ) { nicholas@103: return Sizzle( selector, elem ).length > 0; nicholas@103: }; nicholas@103: }), nicholas@103: nicholas@103: "contains": markFunction(function( text ) { nicholas@103: text = text.replace( runescape, funescape ); nicholas@103: return function( elem ) { nicholas@103: return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; nicholas@103: }; nicholas@103: }), nicholas@103: nicholas@103: // "Whether an element is represented by a :lang() selector nicholas@103: // is based solely on the element's language value nicholas@103: // being equal to the identifier C, nicholas@103: // or beginning with the identifier C immediately followed by "-". nicholas@103: // The matching of C against the element's language value is performed case-insensitively. nicholas@103: // The identifier C does not have to be a valid language name." nicholas@103: // http://www.w3.org/TR/selectors/#lang-pseudo nicholas@103: "lang": markFunction( function( lang ) { nicholas@103: // lang value must be a valid identifier nicholas@103: if ( !ridentifier.test(lang || "") ) { nicholas@103: Sizzle.error( "unsupported lang: " + lang ); nicholas@103: } nicholas@103: lang = lang.replace( runescape, funescape ).toLowerCase(); nicholas@103: return function( elem ) { nicholas@103: var elemLang; nicholas@103: do { nicholas@103: if ( (elemLang = documentIsHTML ? nicholas@103: elem.lang : nicholas@103: elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { nicholas@103: nicholas@103: elemLang = elemLang.toLowerCase(); nicholas@103: return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; nicholas@103: } nicholas@103: } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); nicholas@103: return false; nicholas@103: }; nicholas@103: }), nicholas@103: nicholas@103: // Miscellaneous nicholas@103: "target": function( elem ) { nicholas@103: var hash = window.location && window.location.hash; nicholas@103: return hash && hash.slice( 1 ) === elem.id; nicholas@103: }, nicholas@103: nicholas@103: "root": function( elem ) { nicholas@103: return elem === docElem; nicholas@103: }, nicholas@103: nicholas@103: "focus": function( elem ) { nicholas@103: return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); nicholas@103: }, nicholas@103: nicholas@103: // Boolean properties nicholas@103: "enabled": function( elem ) { nicholas@103: return elem.disabled === false; nicholas@103: }, nicholas@103: nicholas@103: "disabled": function( elem ) { nicholas@103: return elem.disabled === true; nicholas@103: }, nicholas@103: nicholas@103: "checked": function( elem ) { nicholas@103: // In CSS3, :checked should return both checked and selected elements nicholas@103: // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked nicholas@103: var nodeName = elem.nodeName.toLowerCase(); nicholas@103: return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); nicholas@103: }, nicholas@103: nicholas@103: "selected": function( elem ) { nicholas@103: // Accessing this property makes selected-by-default nicholas@103: // options in Safari work properly nicholas@103: if ( elem.parentNode ) { nicholas@103: elem.parentNode.selectedIndex; nicholas@103: } nicholas@103: nicholas@103: return elem.selected === true; nicholas@103: }, nicholas@103: nicholas@103: // Contents nicholas@103: "empty": function( elem ) { nicholas@103: // http://www.w3.org/TR/selectors/#empty-pseudo nicholas@103: // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), nicholas@103: // but not by others (comment: 8; processing instruction: 7; etc.) nicholas@103: // nodeType < 6 works because attributes (2) do not appear as children nicholas@103: for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { nicholas@103: if ( elem.nodeType < 6 ) { nicholas@103: return false; nicholas@103: } nicholas@103: } nicholas@103: return true; nicholas@103: }, nicholas@103: nicholas@103: "parent": function( elem ) { nicholas@103: return !Expr.pseudos["empty"]( elem ); nicholas@103: }, nicholas@103: nicholas@103: // Element/input types nicholas@103: "header": function( elem ) { nicholas@103: return rheader.test( elem.nodeName ); nicholas@103: }, nicholas@103: nicholas@103: "input": function( elem ) { nicholas@103: return rinputs.test( elem.nodeName ); nicholas@103: }, nicholas@103: nicholas@103: "button": function( elem ) { nicholas@103: var name = elem.nodeName.toLowerCase(); nicholas@103: return name === "input" && elem.type === "button" || name === "button"; nicholas@103: }, nicholas@103: nicholas@103: "text": function( elem ) { nicholas@103: var attr; nicholas@103: return elem.nodeName.toLowerCase() === "input" && nicholas@103: elem.type === "text" && nicholas@103: nicholas@103: // Support: IE<8 nicholas@103: // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" nicholas@103: ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); nicholas@103: }, nicholas@103: nicholas@103: // Position-in-collection nicholas@103: "first": createPositionalPseudo(function() { nicholas@103: return [ 0 ]; nicholas@103: }), nicholas@103: nicholas@103: "last": createPositionalPseudo(function( matchIndexes, length ) { nicholas@103: return [ length - 1 ]; nicholas@103: }), nicholas@103: nicholas@103: "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { nicholas@103: return [ argument < 0 ? argument + length : argument ]; nicholas@103: }), nicholas@103: nicholas@103: "even": createPositionalPseudo(function( matchIndexes, length ) { nicholas@103: var i = 0; nicholas@103: for ( ; i < length; i += 2 ) { nicholas@103: matchIndexes.push( i ); nicholas@103: } nicholas@103: return matchIndexes; nicholas@103: }), nicholas@103: nicholas@103: "odd": createPositionalPseudo(function( matchIndexes, length ) { nicholas@103: var i = 1; nicholas@103: for ( ; i < length; i += 2 ) { nicholas@103: matchIndexes.push( i ); nicholas@103: } nicholas@103: return matchIndexes; nicholas@103: }), nicholas@103: nicholas@103: "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { nicholas@103: var i = argument < 0 ? argument + length : argument; nicholas@103: for ( ; --i >= 0; ) { nicholas@103: matchIndexes.push( i ); nicholas@103: } nicholas@103: return matchIndexes; nicholas@103: }), nicholas@103: nicholas@103: "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { nicholas@103: var i = argument < 0 ? argument + length : argument; nicholas@103: for ( ; ++i < length; ) { nicholas@103: matchIndexes.push( i ); nicholas@103: } nicholas@103: return matchIndexes; nicholas@103: }) nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: Expr.pseudos["nth"] = Expr.pseudos["eq"]; nicholas@103: nicholas@103: // Add button/input type pseudos nicholas@103: for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { nicholas@103: Expr.pseudos[ i ] = createInputPseudo( i ); nicholas@103: } nicholas@103: for ( i in { submit: true, reset: true } ) { nicholas@103: Expr.pseudos[ i ] = createButtonPseudo( i ); nicholas@103: } nicholas@103: nicholas@103: // Easy API for creating new setFilters nicholas@103: function setFilters() {} nicholas@103: setFilters.prototype = Expr.filters = Expr.pseudos; nicholas@103: Expr.setFilters = new setFilters(); nicholas@103: nicholas@103: tokenize = Sizzle.tokenize = function( selector, parseOnly ) { nicholas@103: var matched, match, tokens, type, nicholas@103: soFar, groups, preFilters, nicholas@103: cached = tokenCache[ selector + " " ]; nicholas@103: nicholas@103: if ( cached ) { nicholas@103: return parseOnly ? 0 : cached.slice( 0 ); nicholas@103: } nicholas@103: nicholas@103: soFar = selector; nicholas@103: groups = []; nicholas@103: preFilters = Expr.preFilter; nicholas@103: nicholas@103: while ( soFar ) { nicholas@103: nicholas@103: // Comma and first run nicholas@103: if ( !matched || (match = rcomma.exec( soFar )) ) { nicholas@103: if ( match ) { nicholas@103: // Don't consume trailing commas as valid nicholas@103: soFar = soFar.slice( match[0].length ) || soFar; nicholas@103: } nicholas@103: groups.push( (tokens = []) ); nicholas@103: } nicholas@103: nicholas@103: matched = false; nicholas@103: nicholas@103: // Combinators nicholas@103: if ( (match = rcombinators.exec( soFar )) ) { nicholas@103: matched = match.shift(); nicholas@103: tokens.push({ nicholas@103: value: matched, nicholas@103: // Cast descendant combinators to space nicholas@103: type: match[0].replace( rtrim, " " ) nicholas@103: }); nicholas@103: soFar = soFar.slice( matched.length ); nicholas@103: } nicholas@103: nicholas@103: // Filters nicholas@103: for ( type in Expr.filter ) { nicholas@103: if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || nicholas@103: (match = preFilters[ type ]( match ))) ) { nicholas@103: matched = match.shift(); nicholas@103: tokens.push({ nicholas@103: value: matched, nicholas@103: type: type, nicholas@103: matches: match nicholas@103: }); nicholas@103: soFar = soFar.slice( matched.length ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: if ( !matched ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Return the length of the invalid excess nicholas@103: // if we're just parsing nicholas@103: // Otherwise, throw an error or return tokens nicholas@103: return parseOnly ? nicholas@103: soFar.length : nicholas@103: soFar ? nicholas@103: Sizzle.error( selector ) : nicholas@103: // Cache the tokens nicholas@103: tokenCache( selector, groups ).slice( 0 ); nicholas@103: }; nicholas@103: nicholas@103: function toSelector( tokens ) { nicholas@103: var i = 0, nicholas@103: len = tokens.length, nicholas@103: selector = ""; nicholas@103: for ( ; i < len; i++ ) { nicholas@103: selector += tokens[i].value; nicholas@103: } nicholas@103: return selector; nicholas@103: } nicholas@103: nicholas@103: function addCombinator( matcher, combinator, base ) { nicholas@103: var dir = combinator.dir, nicholas@103: checkNonElements = base && dir === "parentNode", nicholas@103: doneName = done++; nicholas@103: nicholas@103: return combinator.first ? nicholas@103: // Check against closest ancestor/preceding element nicholas@103: function( elem, context, xml ) { nicholas@103: while ( (elem = elem[ dir ]) ) { nicholas@103: if ( elem.nodeType === 1 || checkNonElements ) { nicholas@103: return matcher( elem, context, xml ); nicholas@103: } nicholas@103: } nicholas@103: } : nicholas@103: nicholas@103: // Check against all ancestor/preceding elements nicholas@103: function( elem, context, xml ) { nicholas@103: var oldCache, outerCache, nicholas@103: newCache = [ dirruns, doneName ]; nicholas@103: nicholas@103: // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching nicholas@103: if ( xml ) { nicholas@103: while ( (elem = elem[ dir ]) ) { nicholas@103: if ( elem.nodeType === 1 || checkNonElements ) { nicholas@103: if ( matcher( elem, context, xml ) ) { nicholas@103: return true; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } else { nicholas@103: while ( (elem = elem[ dir ]) ) { nicholas@103: if ( elem.nodeType === 1 || checkNonElements ) { nicholas@103: outerCache = elem[ expando ] || (elem[ expando ] = {}); nicholas@103: if ( (oldCache = outerCache[ dir ]) && nicholas@103: oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { nicholas@103: nicholas@103: // Assign to newCache so results back-propagate to previous elements nicholas@103: return (newCache[ 2 ] = oldCache[ 2 ]); nicholas@103: } else { nicholas@103: // Reuse newcache so results back-propagate to previous elements nicholas@103: outerCache[ dir ] = newCache; nicholas@103: nicholas@103: // A match means we're done; a fail means we have to keep checking nicholas@103: if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { nicholas@103: return true; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: function elementMatcher( matchers ) { nicholas@103: return matchers.length > 1 ? nicholas@103: function( elem, context, xml ) { nicholas@103: var i = matchers.length; nicholas@103: while ( i-- ) { nicholas@103: if ( !matchers[i]( elem, context, xml ) ) { nicholas@103: return false; nicholas@103: } nicholas@103: } nicholas@103: return true; nicholas@103: } : nicholas@103: matchers[0]; nicholas@103: } nicholas@103: nicholas@103: function multipleContexts( selector, contexts, results ) { nicholas@103: var i = 0, nicholas@103: len = contexts.length; nicholas@103: for ( ; i < len; i++ ) { nicholas@103: Sizzle( selector, contexts[i], results ); nicholas@103: } nicholas@103: return results; nicholas@103: } nicholas@103: nicholas@103: function condense( unmatched, map, filter, context, xml ) { nicholas@103: var elem, nicholas@103: newUnmatched = [], nicholas@103: i = 0, nicholas@103: len = unmatched.length, nicholas@103: mapped = map != null; nicholas@103: nicholas@103: for ( ; i < len; i++ ) { nicholas@103: if ( (elem = unmatched[i]) ) { nicholas@103: if ( !filter || filter( elem, context, xml ) ) { nicholas@103: newUnmatched.push( elem ); nicholas@103: if ( mapped ) { nicholas@103: map.push( i ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return newUnmatched; nicholas@103: } nicholas@103: nicholas@103: function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { nicholas@103: if ( postFilter && !postFilter[ expando ] ) { nicholas@103: postFilter = setMatcher( postFilter ); nicholas@103: } nicholas@103: if ( postFinder && !postFinder[ expando ] ) { nicholas@103: postFinder = setMatcher( postFinder, postSelector ); nicholas@103: } nicholas@103: return markFunction(function( seed, results, context, xml ) { nicholas@103: var temp, i, elem, nicholas@103: preMap = [], nicholas@103: postMap = [], nicholas@103: preexisting = results.length, nicholas@103: nicholas@103: // Get initial elements from seed or context nicholas@103: elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), nicholas@103: nicholas@103: // Prefilter to get matcher input, preserving a map for seed-results synchronization nicholas@103: matcherIn = preFilter && ( seed || !selector ) ? nicholas@103: condense( elems, preMap, preFilter, context, xml ) : nicholas@103: elems, nicholas@103: nicholas@103: matcherOut = matcher ? nicholas@103: // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, nicholas@103: postFinder || ( seed ? preFilter : preexisting || postFilter ) ? nicholas@103: nicholas@103: // ...intermediate processing is necessary nicholas@103: [] : nicholas@103: nicholas@103: // ...otherwise use results directly nicholas@103: results : nicholas@103: matcherIn; nicholas@103: nicholas@103: // Find primary matches nicholas@103: if ( matcher ) { nicholas@103: matcher( matcherIn, matcherOut, context, xml ); nicholas@103: } nicholas@103: nicholas@103: // Apply postFilter nicholas@103: if ( postFilter ) { nicholas@103: temp = condense( matcherOut, postMap ); nicholas@103: postFilter( temp, [], context, xml ); nicholas@103: nicholas@103: // Un-match failing elements by moving them back to matcherIn nicholas@103: i = temp.length; nicholas@103: while ( i-- ) { nicholas@103: if ( (elem = temp[i]) ) { nicholas@103: matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: if ( seed ) { nicholas@103: if ( postFinder || preFilter ) { nicholas@103: if ( postFinder ) { nicholas@103: // Get the final matcherOut by condensing this intermediate into postFinder contexts nicholas@103: temp = []; nicholas@103: i = matcherOut.length; nicholas@103: while ( i-- ) { nicholas@103: if ( (elem = matcherOut[i]) ) { nicholas@103: // Restore matcherIn since elem is not yet a final match nicholas@103: temp.push( (matcherIn[i] = elem) ); nicholas@103: } nicholas@103: } nicholas@103: postFinder( null, (matcherOut = []), temp, xml ); nicholas@103: } nicholas@103: nicholas@103: // Move matched elements from seed to results to keep them synchronized nicholas@103: i = matcherOut.length; nicholas@103: while ( i-- ) { nicholas@103: if ( (elem = matcherOut[i]) && nicholas@103: (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) { nicholas@103: nicholas@103: seed[temp] = !(results[temp] = elem); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Add elements to results, through postFinder if defined nicholas@103: } else { nicholas@103: matcherOut = condense( nicholas@103: matcherOut === results ? nicholas@103: matcherOut.splice( preexisting, matcherOut.length ) : nicholas@103: matcherOut nicholas@103: ); nicholas@103: if ( postFinder ) { nicholas@103: postFinder( null, results, matcherOut, xml ); nicholas@103: } else { nicholas@103: push.apply( results, matcherOut ); nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: function matcherFromTokens( tokens ) { nicholas@103: var checkContext, matcher, j, nicholas@103: len = tokens.length, nicholas@103: leadingRelative = Expr.relative[ tokens[0].type ], nicholas@103: implicitRelative = leadingRelative || Expr.relative[" "], nicholas@103: i = leadingRelative ? 1 : 0, nicholas@103: nicholas@103: // The foundational matcher ensures that elements are reachable from top-level context(s) nicholas@103: matchContext = addCombinator( function( elem ) { nicholas@103: return elem === checkContext; nicholas@103: }, implicitRelative, true ), nicholas@103: matchAnyContext = addCombinator( function( elem ) { nicholas@103: return indexOf( checkContext, elem ) > -1; nicholas@103: }, implicitRelative, true ), nicholas@103: matchers = [ function( elem, context, xml ) { nicholas@103: var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( nicholas@103: (checkContext = context).nodeType ? nicholas@103: matchContext( elem, context, xml ) : nicholas@103: matchAnyContext( elem, context, xml ) ); nicholas@103: // Avoid hanging onto element (issue #299) nicholas@103: checkContext = null; nicholas@103: return ret; nicholas@103: } ]; nicholas@103: nicholas@103: for ( ; i < len; i++ ) { nicholas@103: if ( (matcher = Expr.relative[ tokens[i].type ]) ) { nicholas@103: matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; nicholas@103: } else { nicholas@103: matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); nicholas@103: nicholas@103: // Return special upon seeing a positional matcher nicholas@103: if ( matcher[ expando ] ) { nicholas@103: // Find the next relative operator (if any) for proper handling nicholas@103: j = ++i; nicholas@103: for ( ; j < len; j++ ) { nicholas@103: if ( Expr.relative[ tokens[j].type ] ) { nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: return setMatcher( nicholas@103: i > 1 && elementMatcher( matchers ), nicholas@103: i > 1 && toSelector( nicholas@103: // If the preceding token was a descendant combinator, insert an implicit any-element `*` nicholas@103: tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) nicholas@103: ).replace( rtrim, "$1" ), nicholas@103: matcher, nicholas@103: i < j && matcherFromTokens( tokens.slice( i, j ) ), nicholas@103: j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), nicholas@103: j < len && toSelector( tokens ) nicholas@103: ); nicholas@103: } nicholas@103: matchers.push( matcher ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return elementMatcher( matchers ); nicholas@103: } nicholas@103: nicholas@103: function matcherFromGroupMatchers( elementMatchers, setMatchers ) { nicholas@103: var bySet = setMatchers.length > 0, nicholas@103: byElement = elementMatchers.length > 0, nicholas@103: superMatcher = function( seed, context, xml, results, outermost ) { nicholas@103: var elem, j, matcher, nicholas@103: matchedCount = 0, nicholas@103: i = "0", nicholas@103: unmatched = seed && [], nicholas@103: setMatched = [], nicholas@103: contextBackup = outermostContext, nicholas@103: // We must always have either seed elements or outermost context nicholas@103: elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), nicholas@103: // Use integer dirruns iff this is the outermost matcher nicholas@103: dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), nicholas@103: len = elems.length; nicholas@103: nicholas@103: if ( outermost ) { nicholas@103: outermostContext = context !== document && context; nicholas@103: } nicholas@103: nicholas@103: // Add elements passing elementMatchers directly to results nicholas@103: // Keep `i` a string if there are no elements so `matchedCount` will be "00" below nicholas@103: // Support: IE<9, Safari nicholas@103: // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id nicholas@103: for ( ; i !== len && (elem = elems[i]) != null; i++ ) { nicholas@103: if ( byElement && elem ) { nicholas@103: j = 0; nicholas@103: while ( (matcher = elementMatchers[j++]) ) { nicholas@103: if ( matcher( elem, context, xml ) ) { nicholas@103: results.push( elem ); nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: if ( outermost ) { nicholas@103: dirruns = dirrunsUnique; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Track unmatched elements for set filters nicholas@103: if ( bySet ) { nicholas@103: // They will have gone through all possible matchers nicholas@103: if ( (elem = !matcher && elem) ) { nicholas@103: matchedCount--; nicholas@103: } nicholas@103: nicholas@103: // Lengthen the array for every element, matched or not nicholas@103: if ( seed ) { nicholas@103: unmatched.push( elem ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Apply set filters to unmatched elements nicholas@103: matchedCount += i; nicholas@103: if ( bySet && i !== matchedCount ) { nicholas@103: j = 0; nicholas@103: while ( (matcher = setMatchers[j++]) ) { nicholas@103: matcher( unmatched, setMatched, context, xml ); nicholas@103: } nicholas@103: nicholas@103: if ( seed ) { nicholas@103: // Reintegrate element matches to eliminate the need for sorting nicholas@103: if ( matchedCount > 0 ) { nicholas@103: while ( i-- ) { nicholas@103: if ( !(unmatched[i] || setMatched[i]) ) { nicholas@103: setMatched[i] = pop.call( results ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Discard index placeholder values to get only actual matches nicholas@103: setMatched = condense( setMatched ); nicholas@103: } nicholas@103: nicholas@103: // Add matches to results nicholas@103: push.apply( results, setMatched ); nicholas@103: nicholas@103: // Seedless set matches succeeding multiple successful matchers stipulate sorting nicholas@103: if ( outermost && !seed && setMatched.length > 0 && nicholas@103: ( matchedCount + setMatchers.length ) > 1 ) { nicholas@103: nicholas@103: Sizzle.uniqueSort( results ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Override manipulation of globals by nested matchers nicholas@103: if ( outermost ) { nicholas@103: dirruns = dirrunsUnique; nicholas@103: outermostContext = contextBackup; nicholas@103: } nicholas@103: nicholas@103: return unmatched; nicholas@103: }; nicholas@103: nicholas@103: return bySet ? nicholas@103: markFunction( superMatcher ) : nicholas@103: superMatcher; nicholas@103: } nicholas@103: nicholas@103: compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { nicholas@103: var i, nicholas@103: setMatchers = [], nicholas@103: elementMatchers = [], nicholas@103: cached = compilerCache[ selector + " " ]; nicholas@103: nicholas@103: if ( !cached ) { nicholas@103: // Generate a function of recursive functions that can be used to check each element nicholas@103: if ( !match ) { nicholas@103: match = tokenize( selector ); nicholas@103: } nicholas@103: i = match.length; nicholas@103: while ( i-- ) { nicholas@103: cached = matcherFromTokens( match[i] ); nicholas@103: if ( cached[ expando ] ) { nicholas@103: setMatchers.push( cached ); nicholas@103: } else { nicholas@103: elementMatchers.push( cached ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Cache the compiled function nicholas@103: cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); nicholas@103: nicholas@103: // Save selector and tokenization nicholas@103: cached.selector = selector; nicholas@103: } nicholas@103: return cached; nicholas@103: }; nicholas@103: nicholas@103: /** nicholas@103: * A low-level selection function that works with Sizzle's compiled nicholas@103: * selector functions nicholas@103: * @param {String|Function} selector A selector or a pre-compiled nicholas@103: * selector function built with Sizzle.compile nicholas@103: * @param {Element} context nicholas@103: * @param {Array} [results] nicholas@103: * @param {Array} [seed] A set of elements to match against nicholas@103: */ nicholas@103: select = Sizzle.select = function( selector, context, results, seed ) { nicholas@103: var i, tokens, token, type, find, nicholas@103: compiled = typeof selector === "function" && selector, nicholas@103: match = !seed && tokenize( (selector = compiled.selector || selector) ); nicholas@103: nicholas@103: results = results || []; nicholas@103: nicholas@103: // Try to minimize operations if there is no seed and only one group nicholas@103: if ( match.length === 1 ) { nicholas@103: nicholas@103: // Take a shortcut and set the context if the root selector is an ID nicholas@103: tokens = match[0] = match[0].slice( 0 ); nicholas@103: if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && nicholas@103: support.getById && context.nodeType === 9 && documentIsHTML && nicholas@103: Expr.relative[ tokens[1].type ] ) { nicholas@103: nicholas@103: context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; nicholas@103: if ( !context ) { nicholas@103: return results; nicholas@103: nicholas@103: // Precompiled matchers will still verify ancestry, so step up a level nicholas@103: } else if ( compiled ) { nicholas@103: context = context.parentNode; nicholas@103: } nicholas@103: nicholas@103: selector = selector.slice( tokens.shift().value.length ); nicholas@103: } nicholas@103: nicholas@103: // Fetch a seed set for right-to-left matching nicholas@103: i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; nicholas@103: while ( i-- ) { nicholas@103: token = tokens[i]; nicholas@103: nicholas@103: // Abort if we hit a combinator nicholas@103: if ( Expr.relative[ (type = token.type) ] ) { nicholas@103: break; nicholas@103: } nicholas@103: if ( (find = Expr.find[ type ]) ) { nicholas@103: // Search, expanding context for leading sibling combinators nicholas@103: if ( (seed = find( nicholas@103: token.matches[0].replace( runescape, funescape ), nicholas@103: rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context nicholas@103: )) ) { nicholas@103: nicholas@103: // If seed is empty or no tokens remain, we can return early nicholas@103: tokens.splice( i, 1 ); nicholas@103: selector = seed.length && toSelector( tokens ); nicholas@103: if ( !selector ) { nicholas@103: push.apply( results, seed ); nicholas@103: return results; nicholas@103: } nicholas@103: nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Compile and execute a filtering function if one is not provided nicholas@103: // Provide `match` to avoid retokenization if we modified the selector above nicholas@103: ( compiled || compile( selector, match ) )( nicholas@103: seed, nicholas@103: context, nicholas@103: !documentIsHTML, nicholas@103: results, nicholas@103: rsibling.test( selector ) && testContext( context.parentNode ) || context nicholas@103: ); nicholas@103: return results; nicholas@103: }; nicholas@103: nicholas@103: // One-time assignments nicholas@103: nicholas@103: // Sort stability nicholas@103: support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; nicholas@103: nicholas@103: // Support: Chrome 14-35+ nicholas@103: // Always assume duplicates if they aren't passed to the comparison function nicholas@103: support.detectDuplicates = !!hasDuplicate; nicholas@103: nicholas@103: // Initialize against the default document nicholas@103: setDocument(); nicholas@103: nicholas@103: // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) nicholas@103: // Detached nodes confoundingly follow *each other* nicholas@103: support.sortDetached = assert(function( div1 ) { nicholas@103: // Should return 1, but returns 4 (following) nicholas@103: return div1.compareDocumentPosition( document.createElement("div") ) & 1; nicholas@103: }); nicholas@103: nicholas@103: // Support: IE<8 nicholas@103: // Prevent attribute/property "interpolation" nicholas@103: // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx nicholas@103: if ( !assert(function( div ) { nicholas@103: div.innerHTML = ""; nicholas@103: return div.firstChild.getAttribute("href") === "#" ; nicholas@103: }) ) { nicholas@103: addHandle( "type|href|height|width", function( elem, name, isXML ) { nicholas@103: if ( !isXML ) { nicholas@103: return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); nicholas@103: } nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: // Support: IE<9 nicholas@103: // Use defaultValue in place of getAttribute("value") nicholas@103: if ( !support.attributes || !assert(function( div ) { nicholas@103: div.innerHTML = ""; nicholas@103: div.firstChild.setAttribute( "value", "" ); nicholas@103: return div.firstChild.getAttribute( "value" ) === ""; nicholas@103: }) ) { nicholas@103: addHandle( "value", function( elem, name, isXML ) { nicholas@103: if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { nicholas@103: return elem.defaultValue; nicholas@103: } nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: // Support: IE<9 nicholas@103: // Use getAttributeNode to fetch booleans when getAttribute lies nicholas@103: if ( !assert(function( div ) { nicholas@103: return div.getAttribute("disabled") == null; nicholas@103: }) ) { nicholas@103: addHandle( booleans, function( elem, name, isXML ) { nicholas@103: var val; nicholas@103: if ( !isXML ) { nicholas@103: return elem[ name ] === true ? name.toLowerCase() : nicholas@103: (val = elem.getAttributeNode( name )) && val.specified ? nicholas@103: val.value : nicholas@103: null; nicholas@103: } nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: return Sizzle; nicholas@103: nicholas@103: })( window ); nicholas@103: nicholas@103: nicholas@103: nicholas@103: jQuery.find = Sizzle; nicholas@103: jQuery.expr = Sizzle.selectors; nicholas@103: jQuery.expr[":"] = jQuery.expr.pseudos; nicholas@103: jQuery.unique = Sizzle.uniqueSort; nicholas@103: jQuery.text = Sizzle.getText; nicholas@103: jQuery.isXMLDoc = Sizzle.isXML; nicholas@103: jQuery.contains = Sizzle.contains; nicholas@103: nicholas@103: nicholas@103: nicholas@103: var rneedsContext = jQuery.expr.match.needsContext; nicholas@103: nicholas@103: var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); nicholas@103: nicholas@103: nicholas@103: nicholas@103: var risSimple = /^.[^:#\[\.,]*$/; nicholas@103: nicholas@103: // Implement the identical functionality for filter and not nicholas@103: function winnow( elements, qualifier, not ) { nicholas@103: if ( jQuery.isFunction( qualifier ) ) { nicholas@103: return jQuery.grep( elements, function( elem, i ) { nicholas@103: /* jshint -W018 */ nicholas@103: return !!qualifier.call( elem, i, elem ) !== not; nicholas@103: }); nicholas@103: nicholas@103: } nicholas@103: nicholas@103: if ( qualifier.nodeType ) { nicholas@103: return jQuery.grep( elements, function( elem ) { nicholas@103: return ( elem === qualifier ) !== not; nicholas@103: }); nicholas@103: nicholas@103: } nicholas@103: nicholas@103: if ( typeof qualifier === "string" ) { nicholas@103: if ( risSimple.test( qualifier ) ) { nicholas@103: return jQuery.filter( qualifier, elements, not ); nicholas@103: } nicholas@103: nicholas@103: qualifier = jQuery.filter( qualifier, elements ); nicholas@103: } nicholas@103: nicholas@103: return jQuery.grep( elements, function( elem ) { nicholas@103: return ( indexOf.call( qualifier, elem ) >= 0 ) !== not; nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: jQuery.filter = function( expr, elems, not ) { nicholas@103: var elem = elems[ 0 ]; nicholas@103: nicholas@103: if ( not ) { nicholas@103: expr = ":not(" + expr + ")"; nicholas@103: } nicholas@103: nicholas@103: return elems.length === 1 && elem.nodeType === 1 ? nicholas@103: jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : nicholas@103: jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { nicholas@103: return elem.nodeType === 1; nicholas@103: })); nicholas@103: }; nicholas@103: nicholas@103: jQuery.fn.extend({ nicholas@103: find: function( selector ) { nicholas@103: var i, nicholas@103: len = this.length, nicholas@103: ret = [], nicholas@103: self = this; nicholas@103: nicholas@103: if ( typeof selector !== "string" ) { nicholas@103: return this.pushStack( jQuery( selector ).filter(function() { nicholas@103: for ( i = 0; i < len; i++ ) { nicholas@103: if ( jQuery.contains( self[ i ], this ) ) { nicholas@103: return true; nicholas@103: } nicholas@103: } nicholas@103: }) ); nicholas@103: } nicholas@103: nicholas@103: for ( i = 0; i < len; i++ ) { nicholas@103: jQuery.find( selector, self[ i ], ret ); nicholas@103: } nicholas@103: nicholas@103: // Needed because $( selector, context ) becomes $( context ).find( selector ) nicholas@103: ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); nicholas@103: ret.selector = this.selector ? this.selector + " " + selector : selector; nicholas@103: return ret; nicholas@103: }, nicholas@103: filter: function( selector ) { nicholas@103: return this.pushStack( winnow(this, selector || [], false) ); nicholas@103: }, nicholas@103: not: function( selector ) { nicholas@103: return this.pushStack( winnow(this, selector || [], true) ); nicholas@103: }, nicholas@103: is: function( selector ) { nicholas@103: return !!winnow( nicholas@103: this, nicholas@103: nicholas@103: // If this is a positional/relative selector, check membership in the returned set nicholas@103: // so $("p:first").is("p:last") won't return true for a doc with two "p". nicholas@103: typeof selector === "string" && rneedsContext.test( selector ) ? nicholas@103: jQuery( selector ) : nicholas@103: selector || [], nicholas@103: false nicholas@103: ).length; nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: nicholas@103: // Initialize a jQuery object nicholas@103: nicholas@103: nicholas@103: // A central reference to the root jQuery(document) nicholas@103: var rootjQuery, nicholas@103: nicholas@103: // A simple way to check for HTML strings nicholas@103: // Prioritize #id over to avoid XSS via location.hash (#9521) nicholas@103: // Strict HTML recognition (#11290: must start with <) nicholas@103: rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, nicholas@103: nicholas@103: init = jQuery.fn.init = function( selector, context ) { nicholas@103: var match, elem; nicholas@103: nicholas@103: // HANDLE: $(""), $(null), $(undefined), $(false) nicholas@103: if ( !selector ) { nicholas@103: return this; nicholas@103: } nicholas@103: nicholas@103: // Handle HTML strings nicholas@103: if ( typeof selector === "string" ) { nicholas@103: if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { nicholas@103: // Assume that strings that start and end with <> are HTML and skip the regex check nicholas@103: match = [ null, selector, null ]; nicholas@103: nicholas@103: } else { nicholas@103: match = rquickExpr.exec( selector ); nicholas@103: } nicholas@103: nicholas@103: // Match html or make sure no context is specified for #id nicholas@103: if ( match && (match[1] || !context) ) { nicholas@103: nicholas@103: // HANDLE: $(html) -> $(array) nicholas@103: if ( match[1] ) { nicholas@103: context = context instanceof jQuery ? context[0] : context; nicholas@103: nicholas@103: // Option to run scripts is true for back-compat nicholas@103: // Intentionally let the error be thrown if parseHTML is not present nicholas@103: jQuery.merge( this, jQuery.parseHTML( nicholas@103: match[1], nicholas@103: context && context.nodeType ? context.ownerDocument || context : document, nicholas@103: true nicholas@103: ) ); nicholas@103: nicholas@103: // HANDLE: $(html, props) nicholas@103: if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { nicholas@103: for ( match in context ) { nicholas@103: // Properties of context are called as methods if possible nicholas@103: if ( jQuery.isFunction( this[ match ] ) ) { nicholas@103: this[ match ]( context[ match ] ); nicholas@103: nicholas@103: // ...and otherwise set as attributes nicholas@103: } else { nicholas@103: this.attr( match, context[ match ] ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return this; nicholas@103: nicholas@103: // HANDLE: $(#id) nicholas@103: } else { nicholas@103: elem = document.getElementById( match[2] ); nicholas@103: nicholas@103: // Support: Blackberry 4.6 nicholas@103: // gEBID returns nodes no longer in the document (#6963) nicholas@103: if ( elem && elem.parentNode ) { nicholas@103: // Inject the element directly into the jQuery object nicholas@103: this.length = 1; nicholas@103: this[0] = elem; nicholas@103: } nicholas@103: nicholas@103: this.context = document; nicholas@103: this.selector = selector; nicholas@103: return this; nicholas@103: } nicholas@103: nicholas@103: // HANDLE: $(expr, $(...)) nicholas@103: } else if ( !context || context.jquery ) { nicholas@103: return ( context || rootjQuery ).find( selector ); nicholas@103: nicholas@103: // HANDLE: $(expr, context) nicholas@103: // (which is just equivalent to: $(context).find(expr) nicholas@103: } else { nicholas@103: return this.constructor( context ).find( selector ); nicholas@103: } nicholas@103: nicholas@103: // HANDLE: $(DOMElement) nicholas@103: } else if ( selector.nodeType ) { nicholas@103: this.context = this[0] = selector; nicholas@103: this.length = 1; nicholas@103: return this; nicholas@103: nicholas@103: // HANDLE: $(function) nicholas@103: // Shortcut for document ready nicholas@103: } else if ( jQuery.isFunction( selector ) ) { nicholas@103: return typeof rootjQuery.ready !== "undefined" ? nicholas@103: rootjQuery.ready( selector ) : nicholas@103: // Execute immediately if ready is not present nicholas@103: selector( jQuery ); nicholas@103: } nicholas@103: nicholas@103: if ( selector.selector !== undefined ) { nicholas@103: this.selector = selector.selector; nicholas@103: this.context = selector.context; nicholas@103: } nicholas@103: nicholas@103: return jQuery.makeArray( selector, this ); nicholas@103: }; nicholas@103: nicholas@103: // Give the init function the jQuery prototype for later instantiation nicholas@103: init.prototype = jQuery.fn; nicholas@103: nicholas@103: // Initialize central reference nicholas@103: rootjQuery = jQuery( document ); nicholas@103: nicholas@103: nicholas@103: var rparentsprev = /^(?:parents|prev(?:Until|All))/, nicholas@103: // Methods guaranteed to produce a unique set when starting from a unique set nicholas@103: guaranteedUnique = { nicholas@103: children: true, nicholas@103: contents: true, nicholas@103: next: true, nicholas@103: prev: true nicholas@103: }; nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: dir: function( elem, dir, until ) { nicholas@103: var matched = [], nicholas@103: truncate = until !== undefined; nicholas@103: nicholas@103: while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) { nicholas@103: if ( elem.nodeType === 1 ) { nicholas@103: if ( truncate && jQuery( elem ).is( until ) ) { nicholas@103: break; nicholas@103: } nicholas@103: matched.push( elem ); nicholas@103: } nicholas@103: } nicholas@103: return matched; nicholas@103: }, nicholas@103: nicholas@103: sibling: function( n, elem ) { nicholas@103: var matched = []; nicholas@103: nicholas@103: for ( ; n; n = n.nextSibling ) { nicholas@103: if ( n.nodeType === 1 && n !== elem ) { nicholas@103: matched.push( n ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return matched; nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: jQuery.fn.extend({ nicholas@103: has: function( target ) { nicholas@103: var targets = jQuery( target, this ), nicholas@103: l = targets.length; nicholas@103: nicholas@103: return this.filter(function() { nicholas@103: var i = 0; nicholas@103: for ( ; i < l; i++ ) { nicholas@103: if ( jQuery.contains( this, targets[i] ) ) { nicholas@103: return true; nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: closest: function( selectors, context ) { nicholas@103: var cur, nicholas@103: i = 0, nicholas@103: l = this.length, nicholas@103: matched = [], nicholas@103: pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? nicholas@103: jQuery( selectors, context || this.context ) : nicholas@103: 0; nicholas@103: nicholas@103: for ( ; i < l; i++ ) { nicholas@103: for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { nicholas@103: // Always skip document fragments nicholas@103: if ( cur.nodeType < 11 && (pos ? nicholas@103: pos.index(cur) > -1 : nicholas@103: nicholas@103: // Don't pass non-elements to Sizzle nicholas@103: cur.nodeType === 1 && nicholas@103: jQuery.find.matchesSelector(cur, selectors)) ) { nicholas@103: nicholas@103: matched.push( cur ); nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); nicholas@103: }, nicholas@103: nicholas@103: // Determine the position of an element within the set nicholas@103: index: function( elem ) { nicholas@103: nicholas@103: // No argument, return index in parent nicholas@103: if ( !elem ) { nicholas@103: return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; nicholas@103: } nicholas@103: nicholas@103: // Index in selector nicholas@103: if ( typeof elem === "string" ) { nicholas@103: return indexOf.call( jQuery( elem ), this[ 0 ] ); nicholas@103: } nicholas@103: nicholas@103: // Locate the position of the desired element nicholas@103: return indexOf.call( this, nicholas@103: nicholas@103: // If it receives a jQuery object, the first element is used nicholas@103: elem.jquery ? elem[ 0 ] : elem nicholas@103: ); nicholas@103: }, nicholas@103: nicholas@103: add: function( selector, context ) { nicholas@103: return this.pushStack( nicholas@103: jQuery.unique( nicholas@103: jQuery.merge( this.get(), jQuery( selector, context ) ) nicholas@103: ) nicholas@103: ); nicholas@103: }, nicholas@103: nicholas@103: addBack: function( selector ) { nicholas@103: return this.add( selector == null ? nicholas@103: this.prevObject : this.prevObject.filter(selector) nicholas@103: ); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: function sibling( cur, dir ) { nicholas@103: while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {} nicholas@103: return cur; nicholas@103: } nicholas@103: nicholas@103: jQuery.each({ nicholas@103: parent: function( elem ) { nicholas@103: var parent = elem.parentNode; nicholas@103: return parent && parent.nodeType !== 11 ? parent : null; nicholas@103: }, nicholas@103: parents: function( elem ) { nicholas@103: return jQuery.dir( elem, "parentNode" ); nicholas@103: }, nicholas@103: parentsUntil: function( elem, i, until ) { nicholas@103: return jQuery.dir( elem, "parentNode", until ); nicholas@103: }, nicholas@103: next: function( elem ) { nicholas@103: return sibling( elem, "nextSibling" ); nicholas@103: }, nicholas@103: prev: function( elem ) { nicholas@103: return sibling( elem, "previousSibling" ); nicholas@103: }, nicholas@103: nextAll: function( elem ) { nicholas@103: return jQuery.dir( elem, "nextSibling" ); nicholas@103: }, nicholas@103: prevAll: function( elem ) { nicholas@103: return jQuery.dir( elem, "previousSibling" ); nicholas@103: }, nicholas@103: nextUntil: function( elem, i, until ) { nicholas@103: return jQuery.dir( elem, "nextSibling", until ); nicholas@103: }, nicholas@103: prevUntil: function( elem, i, until ) { nicholas@103: return jQuery.dir( elem, "previousSibling", until ); nicholas@103: }, nicholas@103: siblings: function( elem ) { nicholas@103: return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); nicholas@103: }, nicholas@103: children: function( elem ) { nicholas@103: return jQuery.sibling( elem.firstChild ); nicholas@103: }, nicholas@103: contents: function( elem ) { nicholas@103: return elem.contentDocument || jQuery.merge( [], elem.childNodes ); nicholas@103: } nicholas@103: }, function( name, fn ) { nicholas@103: jQuery.fn[ name ] = function( until, selector ) { nicholas@103: var matched = jQuery.map( this, fn, until ); nicholas@103: nicholas@103: if ( name.slice( -5 ) !== "Until" ) { nicholas@103: selector = until; nicholas@103: } nicholas@103: nicholas@103: if ( selector && typeof selector === "string" ) { nicholas@103: matched = jQuery.filter( selector, matched ); nicholas@103: } nicholas@103: nicholas@103: if ( this.length > 1 ) { nicholas@103: // Remove duplicates nicholas@103: if ( !guaranteedUnique[ name ] ) { nicholas@103: jQuery.unique( matched ); nicholas@103: } nicholas@103: nicholas@103: // Reverse order for parents* and prev-derivatives nicholas@103: if ( rparentsprev.test( name ) ) { nicholas@103: matched.reverse(); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return this.pushStack( matched ); nicholas@103: }; nicholas@103: }); nicholas@103: var rnotwhite = (/\S+/g); nicholas@103: nicholas@103: nicholas@103: nicholas@103: // String to Object options format cache nicholas@103: var optionsCache = {}; nicholas@103: nicholas@103: // Convert String-formatted options into Object-formatted ones and store in cache nicholas@103: function createOptions( options ) { nicholas@103: var object = optionsCache[ options ] = {}; nicholas@103: jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { nicholas@103: object[ flag ] = true; nicholas@103: }); nicholas@103: return object; nicholas@103: } nicholas@103: nicholas@103: /* nicholas@103: * Create a callback list using the following parameters: nicholas@103: * nicholas@103: * options: an optional list of space-separated options that will change how nicholas@103: * the callback list behaves or a more traditional option object nicholas@103: * nicholas@103: * By default a callback list will act like an event callback list and can be nicholas@103: * "fired" multiple times. nicholas@103: * nicholas@103: * Possible options: nicholas@103: * nicholas@103: * once: will ensure the callback list can only be fired once (like a Deferred) nicholas@103: * nicholas@103: * memory: will keep track of previous values and will call any callback added nicholas@103: * after the list has been fired right away with the latest "memorized" nicholas@103: * values (like a Deferred) nicholas@103: * nicholas@103: * unique: will ensure a callback can only be added once (no duplicate in the list) nicholas@103: * nicholas@103: * stopOnFalse: interrupt callings when a callback returns false nicholas@103: * nicholas@103: */ nicholas@103: jQuery.Callbacks = function( options ) { nicholas@103: nicholas@103: // Convert options from String-formatted to Object-formatted if needed nicholas@103: // (we check in cache first) nicholas@103: options = typeof options === "string" ? nicholas@103: ( optionsCache[ options ] || createOptions( options ) ) : nicholas@103: jQuery.extend( {}, options ); nicholas@103: nicholas@103: var // Last fire value (for non-forgettable lists) nicholas@103: memory, nicholas@103: // Flag to know if list was already fired nicholas@103: fired, nicholas@103: // Flag to know if list is currently firing nicholas@103: firing, nicholas@103: // First callback to fire (used internally by add and fireWith) nicholas@103: firingStart, nicholas@103: // End of the loop when firing nicholas@103: firingLength, nicholas@103: // Index of currently firing callback (modified by remove if needed) nicholas@103: firingIndex, nicholas@103: // Actual callback list nicholas@103: list = [], nicholas@103: // Stack of fire calls for repeatable lists nicholas@103: stack = !options.once && [], nicholas@103: // Fire callbacks nicholas@103: fire = function( data ) { nicholas@103: memory = options.memory && data; nicholas@103: fired = true; nicholas@103: firingIndex = firingStart || 0; nicholas@103: firingStart = 0; nicholas@103: firingLength = list.length; nicholas@103: firing = true; nicholas@103: for ( ; list && firingIndex < firingLength; firingIndex++ ) { nicholas@103: if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { nicholas@103: memory = false; // To prevent further calls using add nicholas@103: break; nicholas@103: } nicholas@103: } nicholas@103: firing = false; nicholas@103: if ( list ) { nicholas@103: if ( stack ) { nicholas@103: if ( stack.length ) { nicholas@103: fire( stack.shift() ); nicholas@103: } nicholas@103: } else if ( memory ) { nicholas@103: list = []; nicholas@103: } else { nicholas@103: self.disable(); nicholas@103: } nicholas@103: } nicholas@103: }, nicholas@103: // Actual Callbacks object nicholas@103: self = { nicholas@103: // Add a callback or a collection of callbacks to the list nicholas@103: add: function() { nicholas@103: if ( list ) { nicholas@103: // First, we save the current length nicholas@103: var start = list.length; nicholas@103: (function add( args ) { nicholas@103: jQuery.each( args, function( _, arg ) { nicholas@103: var type = jQuery.type( arg ); nicholas@103: if ( type === "function" ) { nicholas@103: if ( !options.unique || !self.has( arg ) ) { nicholas@103: list.push( arg ); nicholas@103: } nicholas@103: } else if ( arg && arg.length && type !== "string" ) { nicholas@103: // Inspect recursively nicholas@103: add( arg ); nicholas@103: } nicholas@103: }); nicholas@103: })( arguments ); nicholas@103: // Do we need to add the callbacks to the nicholas@103: // current firing batch? nicholas@103: if ( firing ) { nicholas@103: firingLength = list.length; nicholas@103: // With memory, if we're not firing then nicholas@103: // we should call right away nicholas@103: } else if ( memory ) { nicholas@103: firingStart = start; nicholas@103: fire( memory ); nicholas@103: } nicholas@103: } nicholas@103: return this; nicholas@103: }, nicholas@103: // Remove a callback from the list nicholas@103: remove: function() { nicholas@103: if ( list ) { nicholas@103: jQuery.each( arguments, function( _, arg ) { nicholas@103: var index; nicholas@103: while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { nicholas@103: list.splice( index, 1 ); nicholas@103: // Handle firing indexes nicholas@103: if ( firing ) { nicholas@103: if ( index <= firingLength ) { nicholas@103: firingLength--; nicholas@103: } nicholas@103: if ( index <= firingIndex ) { nicholas@103: firingIndex--; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: } nicholas@103: return this; nicholas@103: }, nicholas@103: // Check if a given callback is in the list. nicholas@103: // If no argument is given, return whether or not list has callbacks attached. nicholas@103: has: function( fn ) { nicholas@103: return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); nicholas@103: }, nicholas@103: // Remove all callbacks from the list nicholas@103: empty: function() { nicholas@103: list = []; nicholas@103: firingLength = 0; nicholas@103: return this; nicholas@103: }, nicholas@103: // Have the list do nothing anymore nicholas@103: disable: function() { nicholas@103: list = stack = memory = undefined; nicholas@103: return this; nicholas@103: }, nicholas@103: // Is it disabled? nicholas@103: disabled: function() { nicholas@103: return !list; nicholas@103: }, nicholas@103: // Lock the list in its current state nicholas@103: lock: function() { nicholas@103: stack = undefined; nicholas@103: if ( !memory ) { nicholas@103: self.disable(); nicholas@103: } nicholas@103: return this; nicholas@103: }, nicholas@103: // Is it locked? nicholas@103: locked: function() { nicholas@103: return !stack; nicholas@103: }, nicholas@103: // Call all callbacks with the given context and arguments nicholas@103: fireWith: function( context, args ) { nicholas@103: if ( list && ( !fired || stack ) ) { nicholas@103: args = args || []; nicholas@103: args = [ context, args.slice ? args.slice() : args ]; nicholas@103: if ( firing ) { nicholas@103: stack.push( args ); nicholas@103: } else { nicholas@103: fire( args ); nicholas@103: } nicholas@103: } nicholas@103: return this; nicholas@103: }, nicholas@103: // Call all the callbacks with the given arguments nicholas@103: fire: function() { nicholas@103: self.fireWith( this, arguments ); nicholas@103: return this; nicholas@103: }, nicholas@103: // To know if the callbacks have already been called at least once nicholas@103: fired: function() { nicholas@103: return !!fired; nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: return self; nicholas@103: }; nicholas@103: nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: nicholas@103: Deferred: function( func ) { nicholas@103: var tuples = [ nicholas@103: // action, add listener, listener list, final state nicholas@103: [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], nicholas@103: [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], nicholas@103: [ "notify", "progress", jQuery.Callbacks("memory") ] nicholas@103: ], nicholas@103: state = "pending", nicholas@103: promise = { nicholas@103: state: function() { nicholas@103: return state; nicholas@103: }, nicholas@103: always: function() { nicholas@103: deferred.done( arguments ).fail( arguments ); nicholas@103: return this; nicholas@103: }, nicholas@103: then: function( /* fnDone, fnFail, fnProgress */ ) { nicholas@103: var fns = arguments; nicholas@103: return jQuery.Deferred(function( newDefer ) { nicholas@103: jQuery.each( tuples, function( i, tuple ) { nicholas@103: var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; nicholas@103: // deferred[ done | fail | progress ] for forwarding actions to newDefer nicholas@103: deferred[ tuple[1] ](function() { nicholas@103: var returned = fn && fn.apply( this, arguments ); nicholas@103: if ( returned && jQuery.isFunction( returned.promise ) ) { nicholas@103: returned.promise() nicholas@103: .done( newDefer.resolve ) nicholas@103: .fail( newDefer.reject ) nicholas@103: .progress( newDefer.notify ); nicholas@103: } else { nicholas@103: newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); nicholas@103: } nicholas@103: }); nicholas@103: }); nicholas@103: fns = null; nicholas@103: }).promise(); nicholas@103: }, nicholas@103: // Get a promise for this deferred nicholas@103: // If obj is provided, the promise aspect is added to the object nicholas@103: promise: function( obj ) { nicholas@103: return obj != null ? jQuery.extend( obj, promise ) : promise; nicholas@103: } nicholas@103: }, nicholas@103: deferred = {}; nicholas@103: nicholas@103: // Keep pipe for back-compat nicholas@103: promise.pipe = promise.then; nicholas@103: nicholas@103: // Add list-specific methods nicholas@103: jQuery.each( tuples, function( i, tuple ) { nicholas@103: var list = tuple[ 2 ], nicholas@103: stateString = tuple[ 3 ]; nicholas@103: nicholas@103: // promise[ done | fail | progress ] = list.add nicholas@103: promise[ tuple[1] ] = list.add; nicholas@103: nicholas@103: // Handle state nicholas@103: if ( stateString ) { nicholas@103: list.add(function() { nicholas@103: // state = [ resolved | rejected ] nicholas@103: state = stateString; nicholas@103: nicholas@103: // [ reject_list | resolve_list ].disable; progress_list.lock nicholas@103: }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); nicholas@103: } nicholas@103: nicholas@103: // deferred[ resolve | reject | notify ] nicholas@103: deferred[ tuple[0] ] = function() { nicholas@103: deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); nicholas@103: return this; nicholas@103: }; nicholas@103: deferred[ tuple[0] + "With" ] = list.fireWith; nicholas@103: }); nicholas@103: nicholas@103: // Make the deferred a promise nicholas@103: promise.promise( deferred ); nicholas@103: nicholas@103: // Call given func if any nicholas@103: if ( func ) { nicholas@103: func.call( deferred, deferred ); nicholas@103: } nicholas@103: nicholas@103: // All done! nicholas@103: return deferred; nicholas@103: }, nicholas@103: nicholas@103: // Deferred helper nicholas@103: when: function( subordinate /* , ..., subordinateN */ ) { nicholas@103: var i = 0, nicholas@103: resolveValues = slice.call( arguments ), nicholas@103: length = resolveValues.length, nicholas@103: nicholas@103: // the count of uncompleted subordinates nicholas@103: remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, nicholas@103: nicholas@103: // the master Deferred. If resolveValues consist of only a single Deferred, just use that. nicholas@103: deferred = remaining === 1 ? subordinate : jQuery.Deferred(), nicholas@103: nicholas@103: // Update function for both resolve and progress values nicholas@103: updateFunc = function( i, contexts, values ) { nicholas@103: return function( value ) { nicholas@103: contexts[ i ] = this; nicholas@103: values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; nicholas@103: if ( values === progressValues ) { nicholas@103: deferred.notifyWith( contexts, values ); nicholas@103: } else if ( !( --remaining ) ) { nicholas@103: deferred.resolveWith( contexts, values ); nicholas@103: } nicholas@103: }; nicholas@103: }, nicholas@103: nicholas@103: progressValues, progressContexts, resolveContexts; nicholas@103: nicholas@103: // Add listeners to Deferred subordinates; treat others as resolved nicholas@103: if ( length > 1 ) { nicholas@103: progressValues = new Array( length ); nicholas@103: progressContexts = new Array( length ); nicholas@103: resolveContexts = new Array( length ); nicholas@103: for ( ; i < length; i++ ) { nicholas@103: if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { nicholas@103: resolveValues[ i ].promise() nicholas@103: .done( updateFunc( i, resolveContexts, resolveValues ) ) nicholas@103: .fail( deferred.reject ) nicholas@103: .progress( updateFunc( i, progressContexts, progressValues ) ); nicholas@103: } else { nicholas@103: --remaining; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // If we're not waiting on anything, resolve the master nicholas@103: if ( !remaining ) { nicholas@103: deferred.resolveWith( resolveContexts, resolveValues ); nicholas@103: } nicholas@103: nicholas@103: return deferred.promise(); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: nicholas@103: // The deferred used on DOM ready nicholas@103: var readyList; nicholas@103: nicholas@103: jQuery.fn.ready = function( fn ) { nicholas@103: // Add the callback nicholas@103: jQuery.ready.promise().done( fn ); nicholas@103: nicholas@103: return this; nicholas@103: }; nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: // Is the DOM ready to be used? Set to true once it occurs. nicholas@103: isReady: false, nicholas@103: nicholas@103: // A counter to track how many items to wait for before nicholas@103: // the ready event fires. See #6781 nicholas@103: readyWait: 1, nicholas@103: nicholas@103: // Hold (or release) the ready event nicholas@103: holdReady: function( hold ) { nicholas@103: if ( hold ) { nicholas@103: jQuery.readyWait++; nicholas@103: } else { nicholas@103: jQuery.ready( true ); nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: // Handle when the DOM is ready nicholas@103: ready: function( wait ) { nicholas@103: nicholas@103: // Abort if there are pending holds or we're already ready nicholas@103: if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // Remember that the DOM is ready nicholas@103: jQuery.isReady = true; nicholas@103: nicholas@103: // If a normal DOM Ready event fired, decrement, and wait if need be nicholas@103: if ( wait !== true && --jQuery.readyWait > 0 ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // If there are functions bound, to execute nicholas@103: readyList.resolveWith( document, [ jQuery ] ); nicholas@103: nicholas@103: // Trigger any bound ready events nicholas@103: if ( jQuery.fn.triggerHandler ) { nicholas@103: jQuery( document ).triggerHandler( "ready" ); nicholas@103: jQuery( document ).off( "ready" ); nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: /** nicholas@103: * The ready event handler and self cleanup method nicholas@103: */ nicholas@103: function completed() { nicholas@103: document.removeEventListener( "DOMContentLoaded", completed, false ); nicholas@103: window.removeEventListener( "load", completed, false ); nicholas@103: jQuery.ready(); nicholas@103: } nicholas@103: nicholas@103: jQuery.ready.promise = function( obj ) { nicholas@103: if ( !readyList ) { nicholas@103: nicholas@103: readyList = jQuery.Deferred(); nicholas@103: nicholas@103: // Catch cases where $(document).ready() is called after the browser event has already occurred. nicholas@103: // We once tried to use readyState "interactive" here, but it caused issues like the one nicholas@103: // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 nicholas@103: if ( document.readyState === "complete" ) { nicholas@103: // Handle it asynchronously to allow scripts the opportunity to delay ready nicholas@103: setTimeout( jQuery.ready ); nicholas@103: nicholas@103: } else { nicholas@103: nicholas@103: // Use the handy event callback nicholas@103: document.addEventListener( "DOMContentLoaded", completed, false ); nicholas@103: nicholas@103: // A fallback to window.onload, that will always work nicholas@103: window.addEventListener( "load", completed, false ); nicholas@103: } nicholas@103: } nicholas@103: return readyList.promise( obj ); nicholas@103: }; nicholas@103: nicholas@103: // Kick off the DOM ready check even if the user does not nicholas@103: jQuery.ready.promise(); nicholas@103: nicholas@103: nicholas@103: nicholas@103: nicholas@103: // Multifunctional method to get and set values of a collection nicholas@103: // The value/s can optionally be executed if it's a function nicholas@103: var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { nicholas@103: var i = 0, nicholas@103: len = elems.length, nicholas@103: bulk = key == null; nicholas@103: nicholas@103: // Sets many values nicholas@103: if ( jQuery.type( key ) === "object" ) { nicholas@103: chainable = true; nicholas@103: for ( i in key ) { nicholas@103: jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); nicholas@103: } nicholas@103: nicholas@103: // Sets one value nicholas@103: } else if ( value !== undefined ) { nicholas@103: chainable = true; nicholas@103: nicholas@103: if ( !jQuery.isFunction( value ) ) { nicholas@103: raw = true; nicholas@103: } nicholas@103: nicholas@103: if ( bulk ) { nicholas@103: // Bulk operations run against the entire set nicholas@103: if ( raw ) { nicholas@103: fn.call( elems, value ); nicholas@103: fn = null; nicholas@103: nicholas@103: // ...except when executing function values nicholas@103: } else { nicholas@103: bulk = fn; nicholas@103: fn = function( elem, key, value ) { nicholas@103: return bulk.call( jQuery( elem ), value ); nicholas@103: }; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: if ( fn ) { nicholas@103: for ( ; i < len; i++ ) { nicholas@103: fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return chainable ? nicholas@103: elems : nicholas@103: nicholas@103: // Gets nicholas@103: bulk ? nicholas@103: fn.call( elems ) : nicholas@103: len ? fn( elems[0], key ) : emptyGet; nicholas@103: }; nicholas@103: nicholas@103: nicholas@103: /** nicholas@103: * Determines whether an object can have data nicholas@103: */ nicholas@103: jQuery.acceptData = function( owner ) { nicholas@103: // Accepts only: nicholas@103: // - Node nicholas@103: // - Node.ELEMENT_NODE nicholas@103: // - Node.DOCUMENT_NODE nicholas@103: // - Object nicholas@103: // - Any nicholas@103: /* jshint -W018 */ nicholas@103: return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); nicholas@103: }; nicholas@103: nicholas@103: nicholas@103: function Data() { nicholas@103: // Support: Android<4, nicholas@103: // Old WebKit does not have Object.preventExtensions/freeze method, nicholas@103: // return new empty object instead with no [[set]] accessor nicholas@103: Object.defineProperty( this.cache = {}, 0, { nicholas@103: get: function() { nicholas@103: return {}; nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: this.expando = jQuery.expando + Data.uid++; nicholas@103: } nicholas@103: nicholas@103: Data.uid = 1; nicholas@103: Data.accepts = jQuery.acceptData; nicholas@103: nicholas@103: Data.prototype = { nicholas@103: key: function( owner ) { nicholas@103: // We can accept data for non-element nodes in modern browsers, nicholas@103: // but we should not, see #8335. nicholas@103: // Always return the key for a frozen object. nicholas@103: if ( !Data.accepts( owner ) ) { nicholas@103: return 0; nicholas@103: } nicholas@103: nicholas@103: var descriptor = {}, nicholas@103: // Check if the owner object already has a cache key nicholas@103: unlock = owner[ this.expando ]; nicholas@103: nicholas@103: // If not, create one nicholas@103: if ( !unlock ) { nicholas@103: unlock = Data.uid++; nicholas@103: nicholas@103: // Secure it in a non-enumerable, non-writable property nicholas@103: try { nicholas@103: descriptor[ this.expando ] = { value: unlock }; nicholas@103: Object.defineProperties( owner, descriptor ); nicholas@103: nicholas@103: // Support: Android<4 nicholas@103: // Fallback to a less secure definition nicholas@103: } catch ( e ) { nicholas@103: descriptor[ this.expando ] = unlock; nicholas@103: jQuery.extend( owner, descriptor ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Ensure the cache object nicholas@103: if ( !this.cache[ unlock ] ) { nicholas@103: this.cache[ unlock ] = {}; nicholas@103: } nicholas@103: nicholas@103: return unlock; nicholas@103: }, nicholas@103: set: function( owner, data, value ) { nicholas@103: var prop, nicholas@103: // There may be an unlock assigned to this node, nicholas@103: // if there is no entry for this "owner", create one inline nicholas@103: // and set the unlock as though an owner entry had always existed nicholas@103: unlock = this.key( owner ), nicholas@103: cache = this.cache[ unlock ]; nicholas@103: nicholas@103: // Handle: [ owner, key, value ] args nicholas@103: if ( typeof data === "string" ) { nicholas@103: cache[ data ] = value; nicholas@103: nicholas@103: // Handle: [ owner, { properties } ] args nicholas@103: } else { nicholas@103: // Fresh assignments by object are shallow copied nicholas@103: if ( jQuery.isEmptyObject( cache ) ) { nicholas@103: jQuery.extend( this.cache[ unlock ], data ); nicholas@103: // Otherwise, copy the properties one-by-one to the cache object nicholas@103: } else { nicholas@103: for ( prop in data ) { nicholas@103: cache[ prop ] = data[ prop ]; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: return cache; nicholas@103: }, nicholas@103: get: function( owner, key ) { nicholas@103: // Either a valid cache is found, or will be created. nicholas@103: // New caches will be created and the unlock returned, nicholas@103: // allowing direct access to the newly created nicholas@103: // empty data object. A valid owner object must be provided. nicholas@103: var cache = this.cache[ this.key( owner ) ]; nicholas@103: nicholas@103: return key === undefined ? nicholas@103: cache : cache[ key ]; nicholas@103: }, nicholas@103: access: function( owner, key, value ) { nicholas@103: var stored; nicholas@103: // In cases where either: nicholas@103: // nicholas@103: // 1. No key was specified nicholas@103: // 2. A string key was specified, but no value provided nicholas@103: // nicholas@103: // Take the "read" path and allow the get method to determine nicholas@103: // which value to return, respectively either: nicholas@103: // nicholas@103: // 1. The entire cache object nicholas@103: // 2. The data stored at the key nicholas@103: // nicholas@103: if ( key === undefined || nicholas@103: ((key && typeof key === "string") && value === undefined) ) { nicholas@103: nicholas@103: stored = this.get( owner, key ); nicholas@103: nicholas@103: return stored !== undefined ? nicholas@103: stored : this.get( owner, jQuery.camelCase(key) ); nicholas@103: } nicholas@103: nicholas@103: // [*]When the key is not a string, or both a key and value nicholas@103: // are specified, set or extend (existing objects) with either: nicholas@103: // nicholas@103: // 1. An object of properties nicholas@103: // 2. A key and value nicholas@103: // nicholas@103: this.set( owner, key, value ); nicholas@103: nicholas@103: // Since the "set" path can have two possible entry points nicholas@103: // return the expected data based on which path was taken[*] nicholas@103: return value !== undefined ? value : key; nicholas@103: }, nicholas@103: remove: function( owner, key ) { nicholas@103: var i, name, camel, nicholas@103: unlock = this.key( owner ), nicholas@103: cache = this.cache[ unlock ]; nicholas@103: nicholas@103: if ( key === undefined ) { nicholas@103: this.cache[ unlock ] = {}; nicholas@103: nicholas@103: } else { nicholas@103: // Support array or space separated string of keys nicholas@103: if ( jQuery.isArray( key ) ) { nicholas@103: // If "name" is an array of keys... nicholas@103: // When data is initially created, via ("key", "val") signature, nicholas@103: // keys will be converted to camelCase. nicholas@103: // Since there is no way to tell _how_ a key was added, remove nicholas@103: // both plain key and camelCase key. #12786 nicholas@103: // This will only penalize the array argument path. nicholas@103: name = key.concat( key.map( jQuery.camelCase ) ); nicholas@103: } else { nicholas@103: camel = jQuery.camelCase( key ); nicholas@103: // Try the string as a key before any manipulation nicholas@103: if ( key in cache ) { nicholas@103: name = [ key, camel ]; nicholas@103: } else { nicholas@103: // If a key with the spaces exists, use it. nicholas@103: // Otherwise, create an array by matching non-whitespace nicholas@103: name = camel; nicholas@103: name = name in cache ? nicholas@103: [ name ] : ( name.match( rnotwhite ) || [] ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: i = name.length; nicholas@103: while ( i-- ) { nicholas@103: delete cache[ name[ i ] ]; nicholas@103: } nicholas@103: } nicholas@103: }, nicholas@103: hasData: function( owner ) { nicholas@103: return !jQuery.isEmptyObject( nicholas@103: this.cache[ owner[ this.expando ] ] || {} nicholas@103: ); nicholas@103: }, nicholas@103: discard: function( owner ) { nicholas@103: if ( owner[ this.expando ] ) { nicholas@103: delete this.cache[ owner[ this.expando ] ]; nicholas@103: } nicholas@103: } nicholas@103: }; nicholas@103: var data_priv = new Data(); nicholas@103: nicholas@103: var data_user = new Data(); nicholas@103: nicholas@103: nicholas@103: nicholas@103: // Implementation Summary nicholas@103: // nicholas@103: // 1. Enforce API surface and semantic compatibility with 1.9.x branch nicholas@103: // 2. Improve the module's maintainability by reducing the storage nicholas@103: // paths to a single mechanism. nicholas@103: // 3. Use the same single mechanism to support "private" and "user" data. nicholas@103: // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) nicholas@103: // 5. Avoid exposing implementation details on user objects (eg. expando properties) nicholas@103: // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 nicholas@103: nicholas@103: var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, nicholas@103: rmultiDash = /([A-Z])/g; nicholas@103: nicholas@103: function dataAttr( elem, key, data ) { nicholas@103: var name; nicholas@103: nicholas@103: // If nothing was found internally, try to fetch any nicholas@103: // data from the HTML5 data-* attribute nicholas@103: if ( data === undefined && elem.nodeType === 1 ) { nicholas@103: name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); nicholas@103: data = elem.getAttribute( name ); nicholas@103: nicholas@103: if ( typeof data === "string" ) { nicholas@103: try { nicholas@103: data = data === "true" ? true : nicholas@103: data === "false" ? false : nicholas@103: data === "null" ? null : nicholas@103: // Only convert to a number if it doesn't change the string nicholas@103: +data + "" === data ? +data : nicholas@103: rbrace.test( data ) ? jQuery.parseJSON( data ) : nicholas@103: data; nicholas@103: } catch( e ) {} nicholas@103: nicholas@103: // Make sure we set the data so it isn't changed later nicholas@103: data_user.set( elem, key, data ); nicholas@103: } else { nicholas@103: data = undefined; nicholas@103: } nicholas@103: } nicholas@103: return data; nicholas@103: } nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: hasData: function( elem ) { nicholas@103: return data_user.hasData( elem ) || data_priv.hasData( elem ); nicholas@103: }, nicholas@103: nicholas@103: data: function( elem, name, data ) { nicholas@103: return data_user.access( elem, name, data ); nicholas@103: }, nicholas@103: nicholas@103: removeData: function( elem, name ) { nicholas@103: data_user.remove( elem, name ); nicholas@103: }, nicholas@103: nicholas@103: // TODO: Now that all calls to _data and _removeData have been replaced nicholas@103: // with direct calls to data_priv methods, these can be deprecated. nicholas@103: _data: function( elem, name, data ) { nicholas@103: return data_priv.access( elem, name, data ); nicholas@103: }, nicholas@103: nicholas@103: _removeData: function( elem, name ) { nicholas@103: data_priv.remove( elem, name ); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: jQuery.fn.extend({ nicholas@103: data: function( key, value ) { nicholas@103: var i, name, data, nicholas@103: elem = this[ 0 ], nicholas@103: attrs = elem && elem.attributes; nicholas@103: nicholas@103: // Gets all values nicholas@103: if ( key === undefined ) { nicholas@103: if ( this.length ) { nicholas@103: data = data_user.get( elem ); nicholas@103: nicholas@103: if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { nicholas@103: i = attrs.length; nicholas@103: while ( i-- ) { nicholas@103: nicholas@103: // Support: IE11+ nicholas@103: // The attrs elements can be null (#14894) nicholas@103: if ( attrs[ i ] ) { nicholas@103: name = attrs[ i ].name; nicholas@103: if ( name.indexOf( "data-" ) === 0 ) { nicholas@103: name = jQuery.camelCase( name.slice(5) ); nicholas@103: dataAttr( elem, name, data[ name ] ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: data_priv.set( elem, "hasDataAttrs", true ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return data; nicholas@103: } nicholas@103: nicholas@103: // Sets multiple values nicholas@103: if ( typeof key === "object" ) { nicholas@103: return this.each(function() { nicholas@103: data_user.set( this, key ); nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: return access( this, function( value ) { nicholas@103: var data, nicholas@103: camelKey = jQuery.camelCase( key ); nicholas@103: nicholas@103: // The calling jQuery object (element matches) is not empty nicholas@103: // (and therefore has an element appears at this[ 0 ]) and the nicholas@103: // `value` parameter was not undefined. An empty jQuery object nicholas@103: // will result in `undefined` for elem = this[ 0 ] which will nicholas@103: // throw an exception if an attempt to read a data cache is made. nicholas@103: if ( elem && value === undefined ) { nicholas@103: // Attempt to get data from the cache nicholas@103: // with the key as-is nicholas@103: data = data_user.get( elem, key ); nicholas@103: if ( data !== undefined ) { nicholas@103: return data; nicholas@103: } nicholas@103: nicholas@103: // Attempt to get data from the cache nicholas@103: // with the key camelized nicholas@103: data = data_user.get( elem, camelKey ); nicholas@103: if ( data !== undefined ) { nicholas@103: return data; nicholas@103: } nicholas@103: nicholas@103: // Attempt to "discover" the data in nicholas@103: // HTML5 custom data-* attrs nicholas@103: data = dataAttr( elem, camelKey, undefined ); nicholas@103: if ( data !== undefined ) { nicholas@103: return data; nicholas@103: } nicholas@103: nicholas@103: // We tried really hard, but the data doesn't exist. nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // Set the data... nicholas@103: this.each(function() { nicholas@103: // First, attempt to store a copy or reference of any nicholas@103: // data that might've been store with a camelCased key. nicholas@103: var data = data_user.get( this, camelKey ); nicholas@103: nicholas@103: // For HTML5 data-* attribute interop, we have to nicholas@103: // store property names with dashes in a camelCase form. nicholas@103: // This might not apply to all properties...* nicholas@103: data_user.set( this, camelKey, value ); nicholas@103: nicholas@103: // *... In the case of properties that might _actually_ nicholas@103: // have dashes, we need to also store a copy of that nicholas@103: // unchanged property. nicholas@103: if ( key.indexOf("-") !== -1 && data !== undefined ) { nicholas@103: data_user.set( this, key, value ); nicholas@103: } nicholas@103: }); nicholas@103: }, null, value, arguments.length > 1, null, true ); nicholas@103: }, nicholas@103: nicholas@103: removeData: function( key ) { nicholas@103: return this.each(function() { nicholas@103: data_user.remove( this, key ); nicholas@103: }); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: queue: function( elem, type, data ) { nicholas@103: var queue; nicholas@103: nicholas@103: if ( elem ) { nicholas@103: type = ( type || "fx" ) + "queue"; nicholas@103: queue = data_priv.get( elem, type ); nicholas@103: nicholas@103: // Speed up dequeue by getting out quickly if this is just a lookup nicholas@103: if ( data ) { nicholas@103: if ( !queue || jQuery.isArray( data ) ) { nicholas@103: queue = data_priv.access( elem, type, jQuery.makeArray(data) ); nicholas@103: } else { nicholas@103: queue.push( data ); nicholas@103: } nicholas@103: } nicholas@103: return queue || []; nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: dequeue: function( elem, type ) { nicholas@103: type = type || "fx"; nicholas@103: nicholas@103: var queue = jQuery.queue( elem, type ), nicholas@103: startLength = queue.length, nicholas@103: fn = queue.shift(), nicholas@103: hooks = jQuery._queueHooks( elem, type ), nicholas@103: next = function() { nicholas@103: jQuery.dequeue( elem, type ); nicholas@103: }; nicholas@103: nicholas@103: // If the fx queue is dequeued, always remove the progress sentinel nicholas@103: if ( fn === "inprogress" ) { nicholas@103: fn = queue.shift(); nicholas@103: startLength--; nicholas@103: } nicholas@103: nicholas@103: if ( fn ) { nicholas@103: nicholas@103: // Add a progress sentinel to prevent the fx queue from being nicholas@103: // automatically dequeued nicholas@103: if ( type === "fx" ) { nicholas@103: queue.unshift( "inprogress" ); nicholas@103: } nicholas@103: nicholas@103: // Clear up the last queue stop function nicholas@103: delete hooks.stop; nicholas@103: fn.call( elem, next, hooks ); nicholas@103: } nicholas@103: nicholas@103: if ( !startLength && hooks ) { nicholas@103: hooks.empty.fire(); nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: // Not public - generate a queueHooks object, or return the current one nicholas@103: _queueHooks: function( elem, type ) { nicholas@103: var key = type + "queueHooks"; nicholas@103: return data_priv.get( elem, key ) || data_priv.access( elem, key, { nicholas@103: empty: jQuery.Callbacks("once memory").add(function() { nicholas@103: data_priv.remove( elem, [ type + "queue", key ] ); nicholas@103: }) nicholas@103: }); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: jQuery.fn.extend({ nicholas@103: queue: function( type, data ) { nicholas@103: var setter = 2; nicholas@103: nicholas@103: if ( typeof type !== "string" ) { nicholas@103: data = type; nicholas@103: type = "fx"; nicholas@103: setter--; nicholas@103: } nicholas@103: nicholas@103: if ( arguments.length < setter ) { nicholas@103: return jQuery.queue( this[0], type ); nicholas@103: } nicholas@103: nicholas@103: return data === undefined ? nicholas@103: this : nicholas@103: this.each(function() { nicholas@103: var queue = jQuery.queue( this, type, data ); nicholas@103: nicholas@103: // Ensure a hooks for this queue nicholas@103: jQuery._queueHooks( this, type ); nicholas@103: nicholas@103: if ( type === "fx" && queue[0] !== "inprogress" ) { nicholas@103: jQuery.dequeue( this, type ); nicholas@103: } nicholas@103: }); nicholas@103: }, nicholas@103: dequeue: function( type ) { nicholas@103: return this.each(function() { nicholas@103: jQuery.dequeue( this, type ); nicholas@103: }); nicholas@103: }, nicholas@103: clearQueue: function( type ) { nicholas@103: return this.queue( type || "fx", [] ); nicholas@103: }, nicholas@103: // Get a promise resolved when queues of a certain type nicholas@103: // are emptied (fx is the type by default) nicholas@103: promise: function( type, obj ) { nicholas@103: var tmp, nicholas@103: count = 1, nicholas@103: defer = jQuery.Deferred(), nicholas@103: elements = this, nicholas@103: i = this.length, nicholas@103: resolve = function() { nicholas@103: if ( !( --count ) ) { nicholas@103: defer.resolveWith( elements, [ elements ] ); nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: if ( typeof type !== "string" ) { nicholas@103: obj = type; nicholas@103: type = undefined; nicholas@103: } nicholas@103: type = type || "fx"; nicholas@103: nicholas@103: while ( i-- ) { nicholas@103: tmp = data_priv.get( elements[ i ], type + "queueHooks" ); nicholas@103: if ( tmp && tmp.empty ) { nicholas@103: count++; nicholas@103: tmp.empty.add( resolve ); nicholas@103: } nicholas@103: } nicholas@103: resolve(); nicholas@103: return defer.promise( obj ); nicholas@103: } nicholas@103: }); nicholas@103: var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; nicholas@103: nicholas@103: var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; nicholas@103: nicholas@103: var isHidden = function( elem, el ) { nicholas@103: // isHidden might be called from jQuery#filter function; nicholas@103: // in that case, element will be second argument nicholas@103: elem = el || elem; nicholas@103: return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); nicholas@103: }; nicholas@103: nicholas@103: var rcheckableType = (/^(?:checkbox|radio)$/i); nicholas@103: nicholas@103: nicholas@103: nicholas@103: (function() { nicholas@103: var fragment = document.createDocumentFragment(), nicholas@103: div = fragment.appendChild( document.createElement( "div" ) ), nicholas@103: input = document.createElement( "input" ); nicholas@103: nicholas@103: // Support: Safari<=5.1 nicholas@103: // Check state lost if the name is set (#11217) nicholas@103: // Support: Windows Web Apps (WWA) nicholas@103: // `name` and `type` must use .setAttribute for WWA (#14901) nicholas@103: input.setAttribute( "type", "radio" ); nicholas@103: input.setAttribute( "checked", "checked" ); nicholas@103: input.setAttribute( "name", "t" ); nicholas@103: nicholas@103: div.appendChild( input ); nicholas@103: nicholas@103: // Support: Safari<=5.1, Android<4.2 nicholas@103: // Older WebKit doesn't clone checked state correctly in fragments nicholas@103: support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; nicholas@103: nicholas@103: // Support: IE<=11+ nicholas@103: // Make sure textarea (and checkbox) defaultValue is properly cloned nicholas@103: div.innerHTML = ""; nicholas@103: support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; nicholas@103: })(); nicholas@103: var strundefined = typeof undefined; nicholas@103: nicholas@103: nicholas@103: nicholas@103: support.focusinBubbles = "onfocusin" in window; nicholas@103: nicholas@103: nicholas@103: var nicholas@103: rkeyEvent = /^key/, nicholas@103: rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, nicholas@103: rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, nicholas@103: rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; nicholas@103: nicholas@103: function returnTrue() { nicholas@103: return true; nicholas@103: } nicholas@103: nicholas@103: function returnFalse() { nicholas@103: return false; nicholas@103: } nicholas@103: nicholas@103: function safeActiveElement() { nicholas@103: try { nicholas@103: return document.activeElement; nicholas@103: } catch ( err ) { } nicholas@103: } nicholas@103: nicholas@103: /* nicholas@103: * Helper functions for managing events -- not part of the public interface. nicholas@103: * Props to Dean Edwards' addEvent library for many of the ideas. nicholas@103: */ nicholas@103: jQuery.event = { nicholas@103: nicholas@103: global: {}, nicholas@103: nicholas@103: add: function( elem, types, handler, data, selector ) { nicholas@103: nicholas@103: var handleObjIn, eventHandle, tmp, nicholas@103: events, t, handleObj, nicholas@103: special, handlers, type, namespaces, origType, nicholas@103: elemData = data_priv.get( elem ); nicholas@103: nicholas@103: // Don't attach events to noData or text/comment nodes (but allow plain objects) nicholas@103: if ( !elemData ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // Caller can pass in an object of custom data in lieu of the handler nicholas@103: if ( handler.handler ) { nicholas@103: handleObjIn = handler; nicholas@103: handler = handleObjIn.handler; nicholas@103: selector = handleObjIn.selector; nicholas@103: } nicholas@103: nicholas@103: // Make sure that the handler has a unique ID, used to find/remove it later nicholas@103: if ( !handler.guid ) { nicholas@103: handler.guid = jQuery.guid++; nicholas@103: } nicholas@103: nicholas@103: // Init the element's event structure and main handler, if this is the first nicholas@103: if ( !(events = elemData.events) ) { nicholas@103: events = elemData.events = {}; nicholas@103: } nicholas@103: if ( !(eventHandle = elemData.handle) ) { nicholas@103: eventHandle = elemData.handle = function( e ) { nicholas@103: // Discard the second event of a jQuery.event.trigger() and nicholas@103: // when an event is called after a page has unloaded nicholas@103: return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ? nicholas@103: jQuery.event.dispatch.apply( elem, arguments ) : undefined; nicholas@103: }; nicholas@103: } nicholas@103: nicholas@103: // Handle multiple events separated by a space nicholas@103: types = ( types || "" ).match( rnotwhite ) || [ "" ]; nicholas@103: t = types.length; nicholas@103: while ( t-- ) { nicholas@103: tmp = rtypenamespace.exec( types[t] ) || []; nicholas@103: type = origType = tmp[1]; nicholas@103: namespaces = ( tmp[2] || "" ).split( "." ).sort(); nicholas@103: nicholas@103: // There *must* be a type, no attaching namespace-only handlers nicholas@103: if ( !type ) { nicholas@103: continue; nicholas@103: } nicholas@103: nicholas@103: // If event changes its type, use the special event handlers for the changed type nicholas@103: special = jQuery.event.special[ type ] || {}; nicholas@103: nicholas@103: // If selector defined, determine special event api type, otherwise given type nicholas@103: type = ( selector ? special.delegateType : special.bindType ) || type; nicholas@103: nicholas@103: // Update special based on newly reset type nicholas@103: special = jQuery.event.special[ type ] || {}; nicholas@103: nicholas@103: // handleObj is passed to all event handlers nicholas@103: handleObj = jQuery.extend({ nicholas@103: type: type, nicholas@103: origType: origType, nicholas@103: data: data, nicholas@103: handler: handler, nicholas@103: guid: handler.guid, nicholas@103: selector: selector, nicholas@103: needsContext: selector && jQuery.expr.match.needsContext.test( selector ), nicholas@103: namespace: namespaces.join(".") nicholas@103: }, handleObjIn ); nicholas@103: nicholas@103: // Init the event handler queue if we're the first nicholas@103: if ( !(handlers = events[ type ]) ) { nicholas@103: handlers = events[ type ] = []; nicholas@103: handlers.delegateCount = 0; nicholas@103: nicholas@103: // Only use addEventListener if the special events handler returns false nicholas@103: if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { nicholas@103: if ( elem.addEventListener ) { nicholas@103: elem.addEventListener( type, eventHandle, false ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: if ( special.add ) { nicholas@103: special.add.call( elem, handleObj ); nicholas@103: nicholas@103: if ( !handleObj.handler.guid ) { nicholas@103: handleObj.handler.guid = handler.guid; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Add to the element's handler list, delegates in front nicholas@103: if ( selector ) { nicholas@103: handlers.splice( handlers.delegateCount++, 0, handleObj ); nicholas@103: } else { nicholas@103: handlers.push( handleObj ); nicholas@103: } nicholas@103: nicholas@103: // Keep track of which events have ever been used, for event optimization nicholas@103: jQuery.event.global[ type ] = true; nicholas@103: } nicholas@103: nicholas@103: }, nicholas@103: nicholas@103: // Detach an event or set of events from an element nicholas@103: remove: function( elem, types, handler, selector, mappedTypes ) { nicholas@103: nicholas@103: var j, origCount, tmp, nicholas@103: events, t, handleObj, nicholas@103: special, handlers, type, namespaces, origType, nicholas@103: elemData = data_priv.hasData( elem ) && data_priv.get( elem ); nicholas@103: nicholas@103: if ( !elemData || !(events = elemData.events) ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // Once for each type.namespace in types; type may be omitted nicholas@103: types = ( types || "" ).match( rnotwhite ) || [ "" ]; nicholas@103: t = types.length; nicholas@103: while ( t-- ) { nicholas@103: tmp = rtypenamespace.exec( types[t] ) || []; nicholas@103: type = origType = tmp[1]; nicholas@103: namespaces = ( tmp[2] || "" ).split( "." ).sort(); nicholas@103: nicholas@103: // Unbind all events (on this namespace, if provided) for the element nicholas@103: if ( !type ) { nicholas@103: for ( type in events ) { nicholas@103: jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); nicholas@103: } nicholas@103: continue; nicholas@103: } nicholas@103: nicholas@103: special = jQuery.event.special[ type ] || {}; nicholas@103: type = ( selector ? special.delegateType : special.bindType ) || type; nicholas@103: handlers = events[ type ] || []; nicholas@103: tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); nicholas@103: nicholas@103: // Remove matching events nicholas@103: origCount = j = handlers.length; nicholas@103: while ( j-- ) { nicholas@103: handleObj = handlers[ j ]; nicholas@103: nicholas@103: if ( ( mappedTypes || origType === handleObj.origType ) && nicholas@103: ( !handler || handler.guid === handleObj.guid ) && nicholas@103: ( !tmp || tmp.test( handleObj.namespace ) ) && nicholas@103: ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { nicholas@103: handlers.splice( j, 1 ); nicholas@103: nicholas@103: if ( handleObj.selector ) { nicholas@103: handlers.delegateCount--; nicholas@103: } nicholas@103: if ( special.remove ) { nicholas@103: special.remove.call( elem, handleObj ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Remove generic event handler if we removed something and no more handlers exist nicholas@103: // (avoids potential for endless recursion during removal of special event handlers) nicholas@103: if ( origCount && !handlers.length ) { nicholas@103: if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { nicholas@103: jQuery.removeEvent( elem, type, elemData.handle ); nicholas@103: } nicholas@103: nicholas@103: delete events[ type ]; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Remove the expando if it's no longer used nicholas@103: if ( jQuery.isEmptyObject( events ) ) { nicholas@103: delete elemData.handle; nicholas@103: data_priv.remove( elem, "events" ); nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: trigger: function( event, data, elem, onlyHandlers ) { nicholas@103: nicholas@103: var i, cur, tmp, bubbleType, ontype, handle, special, nicholas@103: eventPath = [ elem || document ], nicholas@103: type = hasOwn.call( event, "type" ) ? event.type : event, nicholas@103: namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; nicholas@103: nicholas@103: cur = tmp = elem = elem || document; nicholas@103: nicholas@103: // Don't do events on text and comment nodes nicholas@103: if ( elem.nodeType === 3 || elem.nodeType === 8 ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // focus/blur morphs to focusin/out; ensure we're not firing them right now nicholas@103: if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: if ( type.indexOf(".") >= 0 ) { nicholas@103: // Namespaced trigger; create a regexp to match event type in handle() nicholas@103: namespaces = type.split("."); nicholas@103: type = namespaces.shift(); nicholas@103: namespaces.sort(); nicholas@103: } nicholas@103: ontype = type.indexOf(":") < 0 && "on" + type; nicholas@103: nicholas@103: // Caller can pass in a jQuery.Event object, Object, or just an event type string nicholas@103: event = event[ jQuery.expando ] ? nicholas@103: event : nicholas@103: new jQuery.Event( type, typeof event === "object" && event ); nicholas@103: nicholas@103: // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) nicholas@103: event.isTrigger = onlyHandlers ? 2 : 3; nicholas@103: event.namespace = namespaces.join("."); nicholas@103: event.namespace_re = event.namespace ? nicholas@103: new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : nicholas@103: null; nicholas@103: nicholas@103: // Clean up the event in case it is being reused nicholas@103: event.result = undefined; nicholas@103: if ( !event.target ) { nicholas@103: event.target = elem; nicholas@103: } nicholas@103: nicholas@103: // Clone any incoming data and prepend the event, creating the handler arg list nicholas@103: data = data == null ? nicholas@103: [ event ] : nicholas@103: jQuery.makeArray( data, [ event ] ); nicholas@103: nicholas@103: // Allow special events to draw outside the lines nicholas@103: special = jQuery.event.special[ type ] || {}; nicholas@103: if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // Determine event propagation path in advance, per W3C events spec (#9951) nicholas@103: // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) nicholas@103: if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { nicholas@103: nicholas@103: bubbleType = special.delegateType || type; nicholas@103: if ( !rfocusMorph.test( bubbleType + type ) ) { nicholas@103: cur = cur.parentNode; nicholas@103: } nicholas@103: for ( ; cur; cur = cur.parentNode ) { nicholas@103: eventPath.push( cur ); nicholas@103: tmp = cur; nicholas@103: } nicholas@103: nicholas@103: // Only add window if we got to document (e.g., not plain obj or detached DOM) nicholas@103: if ( tmp === (elem.ownerDocument || document) ) { nicholas@103: eventPath.push( tmp.defaultView || tmp.parentWindow || window ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Fire handlers on the event path nicholas@103: i = 0; nicholas@103: while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { nicholas@103: nicholas@103: event.type = i > 1 ? nicholas@103: bubbleType : nicholas@103: special.bindType || type; nicholas@103: nicholas@103: // jQuery handler nicholas@103: handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" ); nicholas@103: if ( handle ) { nicholas@103: handle.apply( cur, data ); nicholas@103: } nicholas@103: nicholas@103: // Native handler nicholas@103: handle = ontype && cur[ ontype ]; nicholas@103: if ( handle && handle.apply && jQuery.acceptData( cur ) ) { nicholas@103: event.result = handle.apply( cur, data ); nicholas@103: if ( event.result === false ) { nicholas@103: event.preventDefault(); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: event.type = type; nicholas@103: nicholas@103: // If nobody prevented the default action, do it now nicholas@103: if ( !onlyHandlers && !event.isDefaultPrevented() ) { nicholas@103: nicholas@103: if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && nicholas@103: jQuery.acceptData( elem ) ) { nicholas@103: nicholas@103: // Call a native DOM method on the target with the same name name as the event. nicholas@103: // Don't do default actions on window, that's where global variables be (#6170) nicholas@103: if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { nicholas@103: nicholas@103: // Don't re-trigger an onFOO event when we call its FOO() method nicholas@103: tmp = elem[ ontype ]; nicholas@103: nicholas@103: if ( tmp ) { nicholas@103: elem[ ontype ] = null; nicholas@103: } nicholas@103: nicholas@103: // Prevent re-triggering of the same event, since we already bubbled it above nicholas@103: jQuery.event.triggered = type; nicholas@103: elem[ type ](); nicholas@103: jQuery.event.triggered = undefined; nicholas@103: nicholas@103: if ( tmp ) { nicholas@103: elem[ ontype ] = tmp; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return event.result; nicholas@103: }, nicholas@103: nicholas@103: dispatch: function( event ) { nicholas@103: nicholas@103: // Make a writable jQuery.Event from the native event object nicholas@103: event = jQuery.event.fix( event ); nicholas@103: nicholas@103: var i, j, ret, matched, handleObj, nicholas@103: handlerQueue = [], nicholas@103: args = slice.call( arguments ), nicholas@103: handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [], nicholas@103: special = jQuery.event.special[ event.type ] || {}; nicholas@103: nicholas@103: // Use the fix-ed jQuery.Event rather than the (read-only) native event nicholas@103: args[0] = event; nicholas@103: event.delegateTarget = this; nicholas@103: nicholas@103: // Call the preDispatch hook for the mapped type, and let it bail if desired nicholas@103: if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // Determine handlers nicholas@103: handlerQueue = jQuery.event.handlers.call( this, event, handlers ); nicholas@103: nicholas@103: // Run delegates first; they may want to stop propagation beneath us nicholas@103: i = 0; nicholas@103: while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { nicholas@103: event.currentTarget = matched.elem; nicholas@103: nicholas@103: j = 0; nicholas@103: while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { nicholas@103: nicholas@103: // Triggered event must either 1) have no namespace, or 2) have namespace(s) nicholas@103: // a subset or equal to those in the bound event (both can have no namespace). nicholas@103: if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { nicholas@103: nicholas@103: event.handleObj = handleObj; nicholas@103: event.data = handleObj.data; nicholas@103: nicholas@103: ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) nicholas@103: .apply( matched.elem, args ); nicholas@103: nicholas@103: if ( ret !== undefined ) { nicholas@103: if ( (event.result = ret) === false ) { nicholas@103: event.preventDefault(); nicholas@103: event.stopPropagation(); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Call the postDispatch hook for the mapped type nicholas@103: if ( special.postDispatch ) { nicholas@103: special.postDispatch.call( this, event ); nicholas@103: } nicholas@103: nicholas@103: return event.result; nicholas@103: }, nicholas@103: nicholas@103: handlers: function( event, handlers ) { nicholas@103: var i, matches, sel, handleObj, nicholas@103: handlerQueue = [], nicholas@103: delegateCount = handlers.delegateCount, nicholas@103: cur = event.target; nicholas@103: nicholas@103: // Find delegate handlers nicholas@103: // Black-hole SVG instance trees (#13180) nicholas@103: // Avoid non-left-click bubbling in Firefox (#3861) nicholas@103: if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { nicholas@103: nicholas@103: for ( ; cur !== this; cur = cur.parentNode || this ) { nicholas@103: nicholas@103: // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) nicholas@103: if ( cur.disabled !== true || event.type !== "click" ) { nicholas@103: matches = []; nicholas@103: for ( i = 0; i < delegateCount; i++ ) { nicholas@103: handleObj = handlers[ i ]; nicholas@103: nicholas@103: // Don't conflict with Object.prototype properties (#13203) nicholas@103: sel = handleObj.selector + " "; nicholas@103: nicholas@103: if ( matches[ sel ] === undefined ) { nicholas@103: matches[ sel ] = handleObj.needsContext ? nicholas@103: jQuery( sel, this ).index( cur ) >= 0 : nicholas@103: jQuery.find( sel, this, null, [ cur ] ).length; nicholas@103: } nicholas@103: if ( matches[ sel ] ) { nicholas@103: matches.push( handleObj ); nicholas@103: } nicholas@103: } nicholas@103: if ( matches.length ) { nicholas@103: handlerQueue.push({ elem: cur, handlers: matches }); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Add the remaining (directly-bound) handlers nicholas@103: if ( delegateCount < handlers.length ) { nicholas@103: handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); nicholas@103: } nicholas@103: nicholas@103: return handlerQueue; nicholas@103: }, nicholas@103: nicholas@103: // Includes some event props shared by KeyEvent and MouseEvent nicholas@103: props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), nicholas@103: nicholas@103: fixHooks: {}, nicholas@103: nicholas@103: keyHooks: { nicholas@103: props: "char charCode key keyCode".split(" "), nicholas@103: filter: function( event, original ) { nicholas@103: nicholas@103: // Add which for key events nicholas@103: if ( event.which == null ) { nicholas@103: event.which = original.charCode != null ? original.charCode : original.keyCode; nicholas@103: } nicholas@103: nicholas@103: return event; nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: mouseHooks: { nicholas@103: props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), nicholas@103: filter: function( event, original ) { nicholas@103: var eventDoc, doc, body, nicholas@103: button = original.button; nicholas@103: nicholas@103: // Calculate pageX/Y if missing and clientX/Y available nicholas@103: if ( event.pageX == null && original.clientX != null ) { nicholas@103: eventDoc = event.target.ownerDocument || document; nicholas@103: doc = eventDoc.documentElement; nicholas@103: body = eventDoc.body; nicholas@103: nicholas@103: event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); nicholas@103: event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); nicholas@103: } nicholas@103: nicholas@103: // Add which for click: 1 === left; 2 === middle; 3 === right nicholas@103: // Note: button is not normalized, so don't use it nicholas@103: if ( !event.which && button !== undefined ) { nicholas@103: event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); nicholas@103: } nicholas@103: nicholas@103: return event; nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: fix: function( event ) { nicholas@103: if ( event[ jQuery.expando ] ) { nicholas@103: return event; nicholas@103: } nicholas@103: nicholas@103: // Create a writable copy of the event object and normalize some properties nicholas@103: var i, prop, copy, nicholas@103: type = event.type, nicholas@103: originalEvent = event, nicholas@103: fixHook = this.fixHooks[ type ]; nicholas@103: nicholas@103: if ( !fixHook ) { nicholas@103: this.fixHooks[ type ] = fixHook = nicholas@103: rmouseEvent.test( type ) ? this.mouseHooks : nicholas@103: rkeyEvent.test( type ) ? this.keyHooks : nicholas@103: {}; nicholas@103: } nicholas@103: copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; nicholas@103: nicholas@103: event = new jQuery.Event( originalEvent ); nicholas@103: nicholas@103: i = copy.length; nicholas@103: while ( i-- ) { nicholas@103: prop = copy[ i ]; nicholas@103: event[ prop ] = originalEvent[ prop ]; nicholas@103: } nicholas@103: nicholas@103: // Support: Cordova 2.5 (WebKit) (#13255) nicholas@103: // All events should have a target; Cordova deviceready doesn't nicholas@103: if ( !event.target ) { nicholas@103: event.target = document; nicholas@103: } nicholas@103: nicholas@103: // Support: Safari 6.0+, Chrome<28 nicholas@103: // Target should not be a text node (#504, #13143) nicholas@103: if ( event.target.nodeType === 3 ) { nicholas@103: event.target = event.target.parentNode; nicholas@103: } nicholas@103: nicholas@103: return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; nicholas@103: }, nicholas@103: nicholas@103: special: { nicholas@103: load: { nicholas@103: // Prevent triggered image.load events from bubbling to window.load nicholas@103: noBubble: true nicholas@103: }, nicholas@103: focus: { nicholas@103: // Fire native event if possible so blur/focus sequence is correct nicholas@103: trigger: function() { nicholas@103: if ( this !== safeActiveElement() && this.focus ) { nicholas@103: this.focus(); nicholas@103: return false; nicholas@103: } nicholas@103: }, nicholas@103: delegateType: "focusin" nicholas@103: }, nicholas@103: blur: { nicholas@103: trigger: function() { nicholas@103: if ( this === safeActiveElement() && this.blur ) { nicholas@103: this.blur(); nicholas@103: return false; nicholas@103: } nicholas@103: }, nicholas@103: delegateType: "focusout" nicholas@103: }, nicholas@103: click: { nicholas@103: // For checkbox, fire native event so checked state will be right nicholas@103: trigger: function() { nicholas@103: if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) { nicholas@103: this.click(); nicholas@103: return false; nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: // For cross-browser consistency, don't fire native .click() on links nicholas@103: _default: function( event ) { nicholas@103: return jQuery.nodeName( event.target, "a" ); nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: beforeunload: { nicholas@103: postDispatch: function( event ) { nicholas@103: nicholas@103: // Support: Firefox 20+ nicholas@103: // Firefox doesn't alert if the returnValue field is not set. nicholas@103: if ( event.result !== undefined && event.originalEvent ) { nicholas@103: event.originalEvent.returnValue = event.result; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: }, nicholas@103: nicholas@103: simulate: function( type, elem, event, bubble ) { nicholas@103: // Piggyback on a donor event to simulate a different one. nicholas@103: // Fake originalEvent to avoid donor's stopPropagation, but if the nicholas@103: // simulated event prevents default then we do the same on the donor. nicholas@103: var e = jQuery.extend( nicholas@103: new jQuery.Event(), nicholas@103: event, nicholas@103: { nicholas@103: type: type, nicholas@103: isSimulated: true, nicholas@103: originalEvent: {} nicholas@103: } nicholas@103: ); nicholas@103: if ( bubble ) { nicholas@103: jQuery.event.trigger( e, null, elem ); nicholas@103: } else { nicholas@103: jQuery.event.dispatch.call( elem, e ); nicholas@103: } nicholas@103: if ( e.isDefaultPrevented() ) { nicholas@103: event.preventDefault(); nicholas@103: } nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: jQuery.removeEvent = function( elem, type, handle ) { nicholas@103: if ( elem.removeEventListener ) { nicholas@103: elem.removeEventListener( type, handle, false ); nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: jQuery.Event = function( src, props ) { nicholas@103: // Allow instantiation without the 'new' keyword nicholas@103: if ( !(this instanceof jQuery.Event) ) { nicholas@103: return new jQuery.Event( src, props ); nicholas@103: } nicholas@103: nicholas@103: // Event object nicholas@103: if ( src && src.type ) { nicholas@103: this.originalEvent = src; nicholas@103: this.type = src.type; nicholas@103: nicholas@103: // Events bubbling up the document may have been marked as prevented nicholas@103: // by a handler lower down the tree; reflect the correct value. nicholas@103: this.isDefaultPrevented = src.defaultPrevented || nicholas@103: src.defaultPrevented === undefined && nicholas@103: // Support: Android<4.0 nicholas@103: src.returnValue === false ? nicholas@103: returnTrue : nicholas@103: returnFalse; nicholas@103: nicholas@103: // Event type nicholas@103: } else { nicholas@103: this.type = src; nicholas@103: } nicholas@103: nicholas@103: // Put explicitly provided properties onto the event object nicholas@103: if ( props ) { nicholas@103: jQuery.extend( this, props ); nicholas@103: } nicholas@103: nicholas@103: // Create a timestamp if incoming event doesn't have one nicholas@103: this.timeStamp = src && src.timeStamp || jQuery.now(); nicholas@103: nicholas@103: // Mark it as fixed nicholas@103: this[ jQuery.expando ] = true; nicholas@103: }; nicholas@103: nicholas@103: // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding nicholas@103: // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html nicholas@103: jQuery.Event.prototype = { nicholas@103: isDefaultPrevented: returnFalse, nicholas@103: isPropagationStopped: returnFalse, nicholas@103: isImmediatePropagationStopped: returnFalse, nicholas@103: nicholas@103: preventDefault: function() { nicholas@103: var e = this.originalEvent; nicholas@103: nicholas@103: this.isDefaultPrevented = returnTrue; nicholas@103: nicholas@103: if ( e && e.preventDefault ) { nicholas@103: e.preventDefault(); nicholas@103: } nicholas@103: }, nicholas@103: stopPropagation: function() { nicholas@103: var e = this.originalEvent; nicholas@103: nicholas@103: this.isPropagationStopped = returnTrue; nicholas@103: nicholas@103: if ( e && e.stopPropagation ) { nicholas@103: e.stopPropagation(); nicholas@103: } nicholas@103: }, nicholas@103: stopImmediatePropagation: function() { nicholas@103: var e = this.originalEvent; nicholas@103: nicholas@103: this.isImmediatePropagationStopped = returnTrue; nicholas@103: nicholas@103: if ( e && e.stopImmediatePropagation ) { nicholas@103: e.stopImmediatePropagation(); nicholas@103: } nicholas@103: nicholas@103: this.stopPropagation(); nicholas@103: } nicholas@103: }; nicholas@103: nicholas@103: // Create mouseenter/leave events using mouseover/out and event-time checks nicholas@103: // Support: Chrome 15+ nicholas@103: jQuery.each({ nicholas@103: mouseenter: "mouseover", nicholas@103: mouseleave: "mouseout", nicholas@103: pointerenter: "pointerover", nicholas@103: pointerleave: "pointerout" nicholas@103: }, function( orig, fix ) { nicholas@103: jQuery.event.special[ orig ] = { nicholas@103: delegateType: fix, nicholas@103: bindType: fix, nicholas@103: nicholas@103: handle: function( event ) { nicholas@103: var ret, nicholas@103: target = this, nicholas@103: related = event.relatedTarget, nicholas@103: handleObj = event.handleObj; nicholas@103: nicholas@103: // For mousenter/leave call the handler if related is outside the target. nicholas@103: // NB: No relatedTarget if the mouse left/entered the browser window nicholas@103: if ( !related || (related !== target && !jQuery.contains( target, related )) ) { nicholas@103: event.type = handleObj.origType; nicholas@103: ret = handleObj.handler.apply( this, arguments ); nicholas@103: event.type = fix; nicholas@103: } nicholas@103: return ret; nicholas@103: } nicholas@103: }; nicholas@103: }); nicholas@103: nicholas@103: // Support: Firefox, Chrome, Safari nicholas@103: // Create "bubbling" focus and blur events nicholas@103: if ( !support.focusinBubbles ) { nicholas@103: jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { nicholas@103: nicholas@103: // Attach a single capturing handler on the document while someone wants focusin/focusout nicholas@103: var handler = function( event ) { nicholas@103: jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); nicholas@103: }; nicholas@103: nicholas@103: jQuery.event.special[ fix ] = { nicholas@103: setup: function() { nicholas@103: var doc = this.ownerDocument || this, nicholas@103: attaches = data_priv.access( doc, fix ); nicholas@103: nicholas@103: if ( !attaches ) { nicholas@103: doc.addEventListener( orig, handler, true ); nicholas@103: } nicholas@103: data_priv.access( doc, fix, ( attaches || 0 ) + 1 ); nicholas@103: }, nicholas@103: teardown: function() { nicholas@103: var doc = this.ownerDocument || this, nicholas@103: attaches = data_priv.access( doc, fix ) - 1; nicholas@103: nicholas@103: if ( !attaches ) { nicholas@103: doc.removeEventListener( orig, handler, true ); nicholas@103: data_priv.remove( doc, fix ); nicholas@103: nicholas@103: } else { nicholas@103: data_priv.access( doc, fix, attaches ); nicholas@103: } nicholas@103: } nicholas@103: }; nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: jQuery.fn.extend({ nicholas@103: nicholas@103: on: function( types, selector, data, fn, /*INTERNAL*/ one ) { nicholas@103: var origFn, type; nicholas@103: nicholas@103: // Types can be a map of types/handlers nicholas@103: if ( typeof types === "object" ) { nicholas@103: // ( types-Object, selector, data ) nicholas@103: if ( typeof selector !== "string" ) { nicholas@103: // ( types-Object, data ) nicholas@103: data = data || selector; nicholas@103: selector = undefined; nicholas@103: } nicholas@103: for ( type in types ) { nicholas@103: this.on( type, selector, data, types[ type ], one ); nicholas@103: } nicholas@103: return this; nicholas@103: } nicholas@103: nicholas@103: if ( data == null && fn == null ) { nicholas@103: // ( types, fn ) nicholas@103: fn = selector; nicholas@103: data = selector = undefined; nicholas@103: } else if ( fn == null ) { nicholas@103: if ( typeof selector === "string" ) { nicholas@103: // ( types, selector, fn ) nicholas@103: fn = data; nicholas@103: data = undefined; nicholas@103: } else { nicholas@103: // ( types, data, fn ) nicholas@103: fn = data; nicholas@103: data = selector; nicholas@103: selector = undefined; nicholas@103: } nicholas@103: } nicholas@103: if ( fn === false ) { nicholas@103: fn = returnFalse; nicholas@103: } else if ( !fn ) { nicholas@103: return this; nicholas@103: } nicholas@103: nicholas@103: if ( one === 1 ) { nicholas@103: origFn = fn; nicholas@103: fn = function( event ) { nicholas@103: // Can use an empty set, since event contains the info nicholas@103: jQuery().off( event ); nicholas@103: return origFn.apply( this, arguments ); nicholas@103: }; nicholas@103: // Use same guid so caller can remove using origFn nicholas@103: fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); nicholas@103: } nicholas@103: return this.each( function() { nicholas@103: jQuery.event.add( this, types, fn, data, selector ); nicholas@103: }); nicholas@103: }, nicholas@103: one: function( types, selector, data, fn ) { nicholas@103: return this.on( types, selector, data, fn, 1 ); nicholas@103: }, nicholas@103: off: function( types, selector, fn ) { nicholas@103: var handleObj, type; nicholas@103: if ( types && types.preventDefault && types.handleObj ) { nicholas@103: // ( event ) dispatched jQuery.Event nicholas@103: handleObj = types.handleObj; nicholas@103: jQuery( types.delegateTarget ).off( nicholas@103: handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, nicholas@103: handleObj.selector, nicholas@103: handleObj.handler nicholas@103: ); nicholas@103: return this; nicholas@103: } nicholas@103: if ( typeof types === "object" ) { nicholas@103: // ( types-object [, selector] ) nicholas@103: for ( type in types ) { nicholas@103: this.off( type, selector, types[ type ] ); nicholas@103: } nicholas@103: return this; nicholas@103: } nicholas@103: if ( selector === false || typeof selector === "function" ) { nicholas@103: // ( types [, fn] ) nicholas@103: fn = selector; nicholas@103: selector = undefined; nicholas@103: } nicholas@103: if ( fn === false ) { nicholas@103: fn = returnFalse; nicholas@103: } nicholas@103: return this.each(function() { nicholas@103: jQuery.event.remove( this, types, fn, selector ); nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: trigger: function( type, data ) { nicholas@103: return this.each(function() { nicholas@103: jQuery.event.trigger( type, data, this ); nicholas@103: }); nicholas@103: }, nicholas@103: triggerHandler: function( type, data ) { nicholas@103: var elem = this[0]; nicholas@103: if ( elem ) { nicholas@103: return jQuery.event.trigger( type, data, elem, true ); nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: nicholas@103: var nicholas@103: rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, nicholas@103: rtagName = /<([\w:]+)/, nicholas@103: rhtml = /<|&#?\w+;/, nicholas@103: rnoInnerhtml = /<(?:script|style|link)/i, nicholas@103: // checked="checked" or checked nicholas@103: rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, nicholas@103: rscriptType = /^$|\/(?:java|ecma)script/i, nicholas@103: rscriptTypeMasked = /^true\/(.*)/, nicholas@103: rcleanScript = /^\s*\s*$/g, nicholas@103: nicholas@103: // We have to close these tags to support XHTML (#13200) nicholas@103: wrapMap = { nicholas@103: nicholas@103: // Support: IE9 nicholas@103: option: [ 1, "" ], nicholas@103: nicholas@103: thead: [ 1, "", "
" ], nicholas@103: col: [ 2, "", "
" ], nicholas@103: tr: [ 2, "", "
" ], nicholas@103: td: [ 3, "", "
" ], nicholas@103: nicholas@103: _default: [ 0, "", "" ] nicholas@103: }; nicholas@103: nicholas@103: // Support: IE9 nicholas@103: wrapMap.optgroup = wrapMap.option; nicholas@103: nicholas@103: wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; nicholas@103: wrapMap.th = wrapMap.td; nicholas@103: nicholas@103: // Support: 1.x compatibility nicholas@103: // Manipulating tables requires a tbody nicholas@103: function manipulationTarget( elem, content ) { nicholas@103: return jQuery.nodeName( elem, "table" ) && nicholas@103: jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? nicholas@103: nicholas@103: elem.getElementsByTagName("tbody")[0] || nicholas@103: elem.appendChild( elem.ownerDocument.createElement("tbody") ) : nicholas@103: elem; nicholas@103: } nicholas@103: nicholas@103: // Replace/restore the type attribute of script elements for safe DOM manipulation nicholas@103: function disableScript( elem ) { nicholas@103: elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type; nicholas@103: return elem; nicholas@103: } nicholas@103: function restoreScript( elem ) { nicholas@103: var match = rscriptTypeMasked.exec( elem.type ); nicholas@103: nicholas@103: if ( match ) { nicholas@103: elem.type = match[ 1 ]; nicholas@103: } else { nicholas@103: elem.removeAttribute("type"); nicholas@103: } nicholas@103: nicholas@103: return elem; nicholas@103: } nicholas@103: nicholas@103: // Mark scripts as having already been evaluated nicholas@103: function setGlobalEval( elems, refElements ) { nicholas@103: var i = 0, nicholas@103: l = elems.length; nicholas@103: nicholas@103: for ( ; i < l; i++ ) { nicholas@103: data_priv.set( nicholas@103: elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" ) nicholas@103: ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: function cloneCopyEvent( src, dest ) { nicholas@103: var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; nicholas@103: nicholas@103: if ( dest.nodeType !== 1 ) { nicholas@103: return; nicholas@103: } nicholas@103: nicholas@103: // 1. Copy private data: events, handlers, etc. nicholas@103: if ( data_priv.hasData( src ) ) { nicholas@103: pdataOld = data_priv.access( src ); nicholas@103: pdataCur = data_priv.set( dest, pdataOld ); nicholas@103: events = pdataOld.events; nicholas@103: nicholas@103: if ( events ) { nicholas@103: delete pdataCur.handle; nicholas@103: pdataCur.events = {}; nicholas@103: nicholas@103: for ( type in events ) { nicholas@103: for ( i = 0, l = events[ type ].length; i < l; i++ ) { nicholas@103: jQuery.event.add( dest, type, events[ type ][ i ] ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // 2. Copy user data nicholas@103: if ( data_user.hasData( src ) ) { nicholas@103: udataOld = data_user.access( src ); nicholas@103: udataCur = jQuery.extend( {}, udataOld ); nicholas@103: nicholas@103: data_user.set( dest, udataCur ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: function getAll( context, tag ) { nicholas@103: var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) : nicholas@103: context.querySelectorAll ? context.querySelectorAll( tag || "*" ) : nicholas@103: []; nicholas@103: nicholas@103: return tag === undefined || tag && jQuery.nodeName( context, tag ) ? nicholas@103: jQuery.merge( [ context ], ret ) : nicholas@103: ret; nicholas@103: } nicholas@103: nicholas@103: // Fix IE bugs, see support tests nicholas@103: function fixInput( src, dest ) { nicholas@103: var nodeName = dest.nodeName.toLowerCase(); nicholas@103: nicholas@103: // Fails to persist the checked state of a cloned checkbox or radio button. nicholas@103: if ( nodeName === "input" && rcheckableType.test( src.type ) ) { nicholas@103: dest.checked = src.checked; nicholas@103: nicholas@103: // Fails to return the selected option to the default selected state when cloning options nicholas@103: } else if ( nodeName === "input" || nodeName === "textarea" ) { nicholas@103: dest.defaultValue = src.defaultValue; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: jQuery.extend({ nicholas@103: clone: function( elem, dataAndEvents, deepDataAndEvents ) { nicholas@103: var i, l, srcElements, destElements, nicholas@103: clone = elem.cloneNode( true ), nicholas@103: inPage = jQuery.contains( elem.ownerDocument, elem ); nicholas@103: nicholas@103: // Fix IE cloning issues nicholas@103: if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && nicholas@103: !jQuery.isXMLDoc( elem ) ) { nicholas@103: nicholas@103: // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 nicholas@103: destElements = getAll( clone ); nicholas@103: srcElements = getAll( elem ); nicholas@103: nicholas@103: for ( i = 0, l = srcElements.length; i < l; i++ ) { nicholas@103: fixInput( srcElements[ i ], destElements[ i ] ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Copy the events from the original to the clone nicholas@103: if ( dataAndEvents ) { nicholas@103: if ( deepDataAndEvents ) { nicholas@103: srcElements = srcElements || getAll( elem ); nicholas@103: destElements = destElements || getAll( clone ); nicholas@103: nicholas@103: for ( i = 0, l = srcElements.length; i < l; i++ ) { nicholas@103: cloneCopyEvent( srcElements[ i ], destElements[ i ] ); nicholas@103: } nicholas@103: } else { nicholas@103: cloneCopyEvent( elem, clone ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Preserve script evaluation history nicholas@103: destElements = getAll( clone, "script" ); nicholas@103: if ( destElements.length > 0 ) { nicholas@103: setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); nicholas@103: } nicholas@103: nicholas@103: // Return the cloned set nicholas@103: return clone; nicholas@103: }, nicholas@103: nicholas@103: buildFragment: function( elems, context, scripts, selection ) { nicholas@103: var elem, tmp, tag, wrap, contains, j, nicholas@103: fragment = context.createDocumentFragment(), nicholas@103: nodes = [], nicholas@103: i = 0, nicholas@103: l = elems.length; nicholas@103: nicholas@103: for ( ; i < l; i++ ) { nicholas@103: elem = elems[ i ]; nicholas@103: nicholas@103: if ( elem || elem === 0 ) { nicholas@103: nicholas@103: // Add nodes directly nicholas@103: if ( jQuery.type( elem ) === "object" ) { nicholas@103: // Support: QtWebKit, PhantomJS nicholas@103: // push.apply(_, arraylike) throws on ancient WebKit nicholas@103: jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); nicholas@103: nicholas@103: // Convert non-html into a text node nicholas@103: } else if ( !rhtml.test( elem ) ) { nicholas@103: nodes.push( context.createTextNode( elem ) ); nicholas@103: nicholas@103: // Convert html into DOM nodes nicholas@103: } else { nicholas@103: tmp = tmp || fragment.appendChild( context.createElement("div") ); nicholas@103: nicholas@103: // Deserialize a standard representation nicholas@103: tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); nicholas@103: wrap = wrapMap[ tag ] || wrapMap._default; nicholas@103: tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[ 2 ]; nicholas@103: nicholas@103: // Descend through wrappers to the right content nicholas@103: j = wrap[ 0 ]; nicholas@103: while ( j-- ) { nicholas@103: tmp = tmp.lastChild; nicholas@103: } nicholas@103: nicholas@103: // Support: QtWebKit, PhantomJS nicholas@103: // push.apply(_, arraylike) throws on ancient WebKit nicholas@103: jQuery.merge( nodes, tmp.childNodes ); nicholas@103: nicholas@103: // Remember the top-level container nicholas@103: tmp = fragment.firstChild; nicholas@103: nicholas@103: // Ensure the created nodes are orphaned (#12392) nicholas@103: tmp.textContent = ""; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: // Remove wrapper from fragment nicholas@103: fragment.textContent = ""; nicholas@103: nicholas@103: i = 0; nicholas@103: while ( (elem = nodes[ i++ ]) ) { nicholas@103: nicholas@103: // #4087 - If origin and destination elements are the same, and this is nicholas@103: // that element, do not do anything nicholas@103: if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { nicholas@103: continue; nicholas@103: } nicholas@103: nicholas@103: contains = jQuery.contains( elem.ownerDocument, elem ); nicholas@103: nicholas@103: // Append to fragment nicholas@103: tmp = getAll( fragment.appendChild( elem ), "script" ); nicholas@103: nicholas@103: // Preserve script evaluation history nicholas@103: if ( contains ) { nicholas@103: setGlobalEval( tmp ); nicholas@103: } nicholas@103: nicholas@103: // Capture executables nicholas@103: if ( scripts ) { nicholas@103: j = 0; nicholas@103: while ( (elem = tmp[ j++ ]) ) { nicholas@103: if ( rscriptType.test( elem.type || "" ) ) { nicholas@103: scripts.push( elem ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return fragment; nicholas@103: }, nicholas@103: nicholas@103: cleanData: function( elems ) { nicholas@103: var data, elem, type, key, nicholas@103: special = jQuery.event.special, nicholas@103: i = 0; nicholas@103: nicholas@103: for ( ; (elem = elems[ i ]) !== undefined; i++ ) { nicholas@103: if ( jQuery.acceptData( elem ) ) { nicholas@103: key = elem[ data_priv.expando ]; nicholas@103: nicholas@103: if ( key && (data = data_priv.cache[ key ]) ) { nicholas@103: if ( data.events ) { nicholas@103: for ( type in data.events ) { nicholas@103: if ( special[ type ] ) { nicholas@103: jQuery.event.remove( elem, type ); nicholas@103: nicholas@103: // This is a shortcut to avoid jQuery.event.remove's overhead nicholas@103: } else { nicholas@103: jQuery.removeEvent( elem, type, data.handle ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: if ( data_priv.cache[ key ] ) { nicholas@103: // Discard any remaining `private` data nicholas@103: delete data_priv.cache[ key ]; nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: // Discard any remaining `user` data nicholas@103: delete data_user.cache[ elem[ data_user.expando ] ]; nicholas@103: } nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: jQuery.fn.extend({ nicholas@103: text: function( value ) { nicholas@103: return access( this, function( value ) { nicholas@103: return value === undefined ? nicholas@103: jQuery.text( this ) : nicholas@103: this.empty().each(function() { nicholas@103: if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { nicholas@103: this.textContent = value; nicholas@103: } nicholas@103: }); nicholas@103: }, null, value, arguments.length ); nicholas@103: }, nicholas@103: nicholas@103: append: function() { nicholas@103: return this.domManip( arguments, function( elem ) { nicholas@103: if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { nicholas@103: var target = manipulationTarget( this, elem ); nicholas@103: target.appendChild( elem ); nicholas@103: } nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: prepend: function() { nicholas@103: return this.domManip( arguments, function( elem ) { nicholas@103: if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { nicholas@103: var target = manipulationTarget( this, elem ); nicholas@103: target.insertBefore( elem, target.firstChild ); nicholas@103: } nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: before: function() { nicholas@103: return this.domManip( arguments, function( elem ) { nicholas@103: if ( this.parentNode ) { nicholas@103: this.parentNode.insertBefore( elem, this ); nicholas@103: } nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: after: function() { nicholas@103: return this.domManip( arguments, function( elem ) { nicholas@103: if ( this.parentNode ) { nicholas@103: this.parentNode.insertBefore( elem, this.nextSibling ); nicholas@103: } nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: remove: function( selector, keepData /* Internal Use Only */ ) { nicholas@103: var elem, nicholas@103: elems = selector ? jQuery.filter( selector, this ) : this, nicholas@103: i = 0; nicholas@103: nicholas@103: for ( ; (elem = elems[i]) != null; i++ ) { nicholas@103: if ( !keepData && elem.nodeType === 1 ) { nicholas@103: jQuery.cleanData( getAll( elem ) ); nicholas@103: } nicholas@103: nicholas@103: if ( elem.parentNode ) { nicholas@103: if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { nicholas@103: setGlobalEval( getAll( elem, "script" ) ); nicholas@103: } nicholas@103: elem.parentNode.removeChild( elem ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return this; nicholas@103: }, nicholas@103: nicholas@103: empty: function() { nicholas@103: var elem, nicholas@103: i = 0; nicholas@103: nicholas@103: for ( ; (elem = this[i]) != null; i++ ) { nicholas@103: if ( elem.nodeType === 1 ) { nicholas@103: nicholas@103: // Prevent memory leaks nicholas@103: jQuery.cleanData( getAll( elem, false ) ); nicholas@103: nicholas@103: // Remove any remaining nodes nicholas@103: elem.textContent = ""; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return this; nicholas@103: }, nicholas@103: nicholas@103: clone: function( dataAndEvents, deepDataAndEvents ) { nicholas@103: dataAndEvents = dataAndEvents == null ? false : dataAndEvents; nicholas@103: deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; nicholas@103: nicholas@103: return this.map(function() { nicholas@103: return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); nicholas@103: }); nicholas@103: }, nicholas@103: nicholas@103: html: function( value ) { nicholas@103: return access( this, function( value ) { nicholas@103: var elem = this[ 0 ] || {}, nicholas@103: i = 0, nicholas@103: l = this.length; nicholas@103: nicholas@103: if ( value === undefined && elem.nodeType === 1 ) { nicholas@103: return elem.innerHTML; nicholas@103: } nicholas@103: nicholas@103: // See if we can take a shortcut and just use innerHTML nicholas@103: if ( typeof value === "string" && !rnoInnerhtml.test( value ) && nicholas@103: !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { nicholas@103: nicholas@103: value = value.replace( rxhtmlTag, "<$1>" ); nicholas@103: nicholas@103: try { nicholas@103: for ( ; i < l; i++ ) { nicholas@103: elem = this[ i ] || {}; nicholas@103: nicholas@103: // Remove element nodes and prevent memory leaks nicholas@103: if ( elem.nodeType === 1 ) { nicholas@103: jQuery.cleanData( getAll( elem, false ) ); nicholas@103: elem.innerHTML = value; nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: elem = 0; nicholas@103: nicholas@103: // If using innerHTML throws an exception, use the fallback method nicholas@103: } catch( e ) {} nicholas@103: } nicholas@103: nicholas@103: if ( elem ) { nicholas@103: this.empty().append( value ); nicholas@103: } nicholas@103: }, null, value, arguments.length ); nicholas@103: }, nicholas@103: nicholas@103: replaceWith: function() { nicholas@103: var arg = arguments[ 0 ]; nicholas@103: nicholas@103: // Make the changes, replacing each context element with the new content nicholas@103: this.domManip( arguments, function( elem ) { nicholas@103: arg = this.parentNode; nicholas@103: nicholas@103: jQuery.cleanData( getAll( this ) ); nicholas@103: nicholas@103: if ( arg ) { nicholas@103: arg.replaceChild( elem, this ); nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: // Force removal if there was no new content (e.g., from empty arguments) nicholas@103: return arg && (arg.length || arg.nodeType) ? this : this.remove(); nicholas@103: }, nicholas@103: nicholas@103: detach: function( selector ) { nicholas@103: return this.remove( selector, true ); nicholas@103: }, nicholas@103: nicholas@103: domManip: function( args, callback ) { nicholas@103: nicholas@103: // Flatten any nested arrays nicholas@103: args = concat.apply( [], args ); nicholas@103: nicholas@103: var fragment, first, scripts, hasScripts, node, doc, nicholas@103: i = 0, nicholas@103: l = this.length, nicholas@103: set = this, nicholas@103: iNoClone = l - 1, nicholas@103: value = args[ 0 ], nicholas@103: isFunction = jQuery.isFunction( value ); nicholas@103: nicholas@103: // We can't cloneNode fragments that contain checked, in WebKit nicholas@103: if ( isFunction || nicholas@103: ( l > 1 && typeof value === "string" && nicholas@103: !support.checkClone && rchecked.test( value ) ) ) { nicholas@103: return this.each(function( index ) { nicholas@103: var self = set.eq( index ); nicholas@103: if ( isFunction ) { nicholas@103: args[ 0 ] = value.call( this, index, self.html() ); nicholas@103: } nicholas@103: self.domManip( args, callback ); nicholas@103: }); nicholas@103: } nicholas@103: nicholas@103: if ( l ) { nicholas@103: fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); nicholas@103: first = fragment.firstChild; nicholas@103: nicholas@103: if ( fragment.childNodes.length === 1 ) { nicholas@103: fragment = first; nicholas@103: } nicholas@103: nicholas@103: if ( first ) { nicholas@103: scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); nicholas@103: hasScripts = scripts.length; nicholas@103: nicholas@103: // Use the original fragment for the last item instead of the first because it can end up nicholas@103: // being emptied incorrectly in certain situations (#8070). nicholas@103: for ( ; i < l; i++ ) { nicholas@103: node = fragment; nicholas@103: nicholas@103: if ( i !== iNoClone ) { nicholas@103: node = jQuery.clone( node, true, true ); nicholas@103: nicholas@103: // Keep references to cloned scripts for later restoration nicholas@103: if ( hasScripts ) { nicholas@103: // Support: QtWebKit nicholas@103: // jQuery.merge because push.apply(_, arraylike) throws nicholas@103: jQuery.merge( scripts, getAll( node, "script" ) ); nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: callback.call( this[ i ], node, i ); nicholas@103: } nicholas@103: nicholas@103: if ( hasScripts ) { nicholas@103: doc = scripts[ scripts.length - 1 ].ownerDocument; nicholas@103: nicholas@103: // Reenable scripts nicholas@103: jQuery.map( scripts, restoreScript ); nicholas@103: nicholas@103: // Evaluate executable scripts on first document insertion nicholas@103: for ( i = 0; i < hasScripts; i++ ) { nicholas@103: node = scripts[ i ]; nicholas@103: if ( rscriptType.test( node.type || "" ) && nicholas@103: !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) { nicholas@103: nicholas@103: if ( node.src ) { nicholas@103: // Optional AJAX dependency, but won't run scripts if not present nicholas@103: if ( jQuery._evalUrl ) { nicholas@103: jQuery._evalUrl( node.src ); nicholas@103: } nicholas@103: } else { nicholas@103: jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: } nicholas@103: nicholas@103: return this; nicholas@103: } nicholas@103: }); nicholas@103: nicholas@103: jQuery.each({ nicholas@103: appendTo: "append", nicholas@103: prependTo: "prepend", nicholas@103: insertBefore: "before", nicholas@103: insertAfter: "after", nicholas@103: replaceAll: "replaceWith" nicholas@103: }, function( name, original ) { nicholas@103: jQuery.fn[ name ] = function( selector ) { nicholas@103: var elems, nicholas@103: ret = [], nicholas@103: insert = jQuery( selector ), nicholas@103: last = insert.length - 1, nicholas@103: i = 0; nicholas@103: nicholas@103: for ( ; i <= last; i++ ) { nicholas@103: elems = i === last ? this : this.clone( true ); nicholas@103: jQuery( insert[ i ] )[ original ]( elems ); nicholas@103: nicholas@103: // Support: QtWebKit nicholas@103: // .get() because push.apply(_, arraylike) throws nicholas@103: push.apply( ret, elems.get() ); nicholas@103: } nicholas@103: nicholas@103: return this.pushStack( ret ); nicholas@103: }; nicholas@103: }); nicholas@103: nicholas@103: nicholas@103: var iframe, nicholas@103: elemdisplay = {}; nicholas@103: nicholas@103: /** nicholas@103: * Retrieve the actual display of a element nicholas@103: * @param {String} name nodeName of the element nicholas@103: * @param {Object} doc Document object nicholas@103: */ nicholas@103: // Called only from within defaultDisplay nicholas@103: function actualDisplay( name, doc ) { nicholas@103: var style, nicholas@103: elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), nicholas@103: nicholas@103: // getDefaultComputedStyle might be reliably used only on attached element nicholas@103: display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? nicholas@103: nicholas@103: // Use of this method is a temporary fix (more like optimization) until something better comes along, nicholas@103: // since it was removed from specification and supported only in FF nicholas@103: style.display : jQuery.css( elem[ 0 ], "display" ); nicholas@103: nicholas@103: // We don't have any data stored on the element, nicholas@103: // so use "detach" method as fast way to get rid of the element nicholas@103: elem.detach(); nicholas@103: nicholas@103: return display; nicholas@103: } nicholas@103: nicholas@103: /** nicholas@103: * Try to determine the default display value of an element nicholas@103: * @param {String} nodeName nicholas@103: */ nicholas@103: function defaultDisplay( nodeName ) { nicholas@103: var doc = document, nicholas@103: display = elemdisplay[ nodeName ]; nicholas@103: nicholas@103: if ( !display ) { nicholas@103: display = actualDisplay( nodeName, doc ); nicholas@103: nicholas@103: // If the simple way fails, read from inside an iframe nicholas@103: if ( display === "none" || !display ) { nicholas@103: nicholas@103: // Use the already-created iframe if possible nicholas@103: iframe = (iframe || jQuery( "