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