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