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