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