moel@348: /*! moel@348: * jQuery JavaScript Library v1.7.2 moel@348: * http://jquery.com/ moel@348: * moel@348: * Copyright 2011, John Resig moel@348: * Dual licensed under the MIT or GPL Version 2 licenses. moel@348: * http://jquery.org/license moel@348: * moel@348: * Includes Sizzle.js moel@348: * http://sizzlejs.com/ moel@348: * Copyright 2011, The Dojo Foundation moel@348: * Released under the MIT, BSD, and GPL Licenses. moel@348: * moel@348: * Date: Wed Mar 21 12:46:34 2012 -0700 moel@348: */ moel@348: (function( window, undefined ) { moel@348: moel@348: // Use the correct document accordingly with window argument (sandbox) moel@348: var document = window.document, moel@348: navigator = window.navigator, moel@348: location = window.location; moel@348: var jQuery = (function() { moel@348: moel@348: // Define a local copy of jQuery moel@348: var jQuery = function( selector, context ) { moel@348: // The jQuery object is actually just the init constructor 'enhanced' moel@348: return new jQuery.fn.init( selector, context, rootjQuery ); moel@348: }, moel@348: moel@348: // Map over jQuery in case of overwrite moel@348: _jQuery = window.jQuery, moel@348: moel@348: // Map over the $ in case of overwrite moel@348: _$ = window.$, moel@348: moel@348: // A central reference to the root jQuery(document) moel@348: rootjQuery, moel@348: moel@348: // A simple way to check for HTML strings or ID strings moel@348: // Prioritize #id over to avoid XSS via location.hash (#9521) moel@348: quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, moel@348: moel@348: // Check if a string has a non-whitespace character in it moel@348: rnotwhite = /\S/, moel@348: moel@348: // Used for trimming whitespace moel@348: trimLeft = /^\s+/, moel@348: trimRight = /\s+$/, moel@348: moel@348: // Match a standalone tag moel@348: rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, moel@348: moel@348: // JSON RegExp moel@348: rvalidchars = /^[\],:{}\s]*$/, moel@348: rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, moel@348: rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, moel@348: rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, moel@348: moel@348: // Useragent RegExp moel@348: rwebkit = /(webkit)[ \/]([\w.]+)/, moel@348: ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, moel@348: rmsie = /(msie) ([\w.]+)/, moel@348: rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, moel@348: moel@348: // Matches dashed string for camelizing moel@348: rdashAlpha = /-([a-z]|[0-9])/ig, moel@348: rmsPrefix = /^-ms-/, moel@348: moel@348: // Used by jQuery.camelCase as callback to replace() moel@348: fcamelCase = function( all, letter ) { moel@348: return ( letter + "" ).toUpperCase(); moel@348: }, moel@348: moel@348: // Keep a UserAgent string for use with jQuery.browser moel@348: userAgent = navigator.userAgent, moel@348: moel@348: // For matching the engine and version of the browser moel@348: browserMatch, moel@348: moel@348: // The deferred used on DOM ready moel@348: readyList, moel@348: moel@348: // The ready event handler moel@348: DOMContentLoaded, moel@348: moel@348: // Save a reference to some core methods moel@348: toString = Object.prototype.toString, moel@348: hasOwn = Object.prototype.hasOwnProperty, moel@348: push = Array.prototype.push, moel@348: slice = Array.prototype.slice, moel@348: trim = String.prototype.trim, moel@348: indexOf = Array.prototype.indexOf, moel@348: moel@348: // [[Class]] -> type pairs moel@348: class2type = {}; moel@348: moel@348: jQuery.fn = jQuery.prototype = { moel@348: constructor: jQuery, moel@348: init: function( selector, context, rootjQuery ) { moel@348: var match, elem, ret, doc; moel@348: moel@348: // Handle $(""), $(null), or $(undefined) moel@348: if ( !selector ) { moel@348: return this; moel@348: } moel@348: moel@348: // Handle $(DOMElement) moel@348: if ( selector.nodeType ) { moel@348: this.context = this[0] = selector; moel@348: this.length = 1; moel@348: return this; moel@348: } moel@348: moel@348: // The body element only exists once, optimize finding it moel@348: if ( selector === "body" && !context && document.body ) { moel@348: this.context = document; moel@348: this[0] = document.body; moel@348: this.selector = selector; moel@348: this.length = 1; moel@348: return this; moel@348: } moel@348: moel@348: // Handle HTML strings moel@348: if ( typeof selector === "string" ) { moel@348: // Are we dealing with HTML string or an ID? moel@348: if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { moel@348: // Assume that strings that start and end with <> are HTML and skip the regex check moel@348: match = [ null, selector, null ]; moel@348: moel@348: } else { moel@348: match = quickExpr.exec( selector ); moel@348: } moel@348: moel@348: // Verify a match, and that no context was specified for #id moel@348: if ( match && (match[1] || !context) ) { moel@348: moel@348: // HANDLE: $(html) -> $(array) moel@348: if ( match[1] ) { moel@348: context = context instanceof jQuery ? context[0] : context; moel@348: doc = ( context ? context.ownerDocument || context : document ); moel@348: moel@348: // If a single string is passed in and it's a single tag moel@348: // just do a createElement and skip the rest moel@348: ret = rsingleTag.exec( selector ); moel@348: moel@348: if ( ret ) { moel@348: if ( jQuery.isPlainObject( context ) ) { moel@348: selector = [ document.createElement( ret[1] ) ]; moel@348: jQuery.fn.attr.call( selector, context, true ); moel@348: moel@348: } else { moel@348: selector = [ doc.createElement( ret[1] ) ]; moel@348: } moel@348: moel@348: } else { moel@348: ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); moel@348: selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; moel@348: } moel@348: moel@348: return jQuery.merge( this, selector ); moel@348: moel@348: // HANDLE: $("#id") moel@348: } else { moel@348: elem = document.getElementById( match[2] ); moel@348: moel@348: // Check parentNode to catch when Blackberry 4.6 returns moel@348: // nodes that are no longer in the document #6963 moel@348: if ( elem && elem.parentNode ) { moel@348: // Handle the case where IE and Opera return items moel@348: // by name instead of ID moel@348: if ( elem.id !== match[2] ) { moel@348: return rootjQuery.find( selector ); moel@348: } moel@348: moel@348: // Otherwise, we inject the element directly into the jQuery object moel@348: this.length = 1; moel@348: this[0] = elem; moel@348: } moel@348: moel@348: this.context = document; moel@348: this.selector = selector; moel@348: return this; moel@348: } moel@348: moel@348: // HANDLE: $(expr, $(...)) moel@348: } else if ( !context || context.jquery ) { moel@348: return ( context || rootjQuery ).find( selector ); moel@348: moel@348: // HANDLE: $(expr, context) moel@348: // (which is just equivalent to: $(context).find(expr) moel@348: } else { moel@348: return this.constructor( context ).find( selector ); moel@348: } moel@348: moel@348: // HANDLE: $(function) moel@348: // Shortcut for document ready moel@348: } else if ( jQuery.isFunction( selector ) ) { moel@348: return rootjQuery.ready( selector ); moel@348: } moel@348: moel@348: if ( selector.selector !== undefined ) { moel@348: this.selector = selector.selector; moel@348: this.context = selector.context; moel@348: } moel@348: moel@348: return jQuery.makeArray( selector, this ); moel@348: }, moel@348: moel@348: // Start with an empty selector moel@348: selector: "", moel@348: moel@348: // The current version of jQuery being used moel@348: jquery: "1.7.2", moel@348: moel@348: // The default length of a jQuery object is 0 moel@348: length: 0, moel@348: moel@348: // The number of elements contained in the matched element set moel@348: size: function() { moel@348: return this.length; moel@348: }, moel@348: moel@348: toArray: function() { moel@348: return slice.call( this, 0 ); moel@348: }, moel@348: moel@348: // Get the Nth element in the matched element set OR moel@348: // Get the whole matched element set as a clean array moel@348: get: function( num ) { moel@348: return num == null ? moel@348: moel@348: // Return a 'clean' array moel@348: this.toArray() : moel@348: moel@348: // Return just the object moel@348: ( num < 0 ? this[ this.length + num ] : this[ num ] ); moel@348: }, moel@348: moel@348: // Take an array of elements and push it onto the stack moel@348: // (returning the new matched element set) moel@348: pushStack: function( elems, name, selector ) { moel@348: // Build a new jQuery matched element set moel@348: var ret = this.constructor(); moel@348: moel@348: if ( jQuery.isArray( elems ) ) { moel@348: push.apply( ret, elems ); moel@348: moel@348: } else { moel@348: jQuery.merge( ret, elems ); moel@348: } moel@348: moel@348: // Add the old object onto the stack (as a reference) moel@348: ret.prevObject = this; moel@348: moel@348: ret.context = this.context; moel@348: moel@348: if ( name === "find" ) { moel@348: ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; moel@348: } else if ( name ) { moel@348: ret.selector = this.selector + "." + name + "(" + selector + ")"; moel@348: } moel@348: moel@348: // Return the newly-formed element set moel@348: return ret; moel@348: }, moel@348: moel@348: // Execute a callback for every element in the matched set. moel@348: // (You can seed the arguments with an array of args, but this is moel@348: // only used internally.) moel@348: each: function( callback, args ) { moel@348: return jQuery.each( this, callback, args ); moel@348: }, moel@348: moel@348: ready: function( fn ) { moel@348: // Attach the listeners moel@348: jQuery.bindReady(); moel@348: moel@348: // Add the callback moel@348: readyList.add( fn ); moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: eq: function( i ) { moel@348: i = +i; moel@348: return i === -1 ? moel@348: this.slice( i ) : moel@348: this.slice( i, i + 1 ); moel@348: }, moel@348: moel@348: first: function() { moel@348: return this.eq( 0 ); moel@348: }, moel@348: moel@348: last: function() { moel@348: return this.eq( -1 ); moel@348: }, moel@348: moel@348: slice: function() { moel@348: return this.pushStack( slice.apply( this, arguments ), moel@348: "slice", slice.call(arguments).join(",") ); moel@348: }, moel@348: moel@348: map: function( callback ) { moel@348: return this.pushStack( jQuery.map(this, function( elem, i ) { moel@348: return callback.call( elem, i, elem ); moel@348: })); moel@348: }, moel@348: moel@348: end: function() { moel@348: return this.prevObject || this.constructor(null); moel@348: }, moel@348: moel@348: // For internal use only. moel@348: // Behaves like an Array's method, not like a jQuery method. moel@348: push: push, moel@348: sort: [].sort, moel@348: splice: [].splice moel@348: }; moel@348: moel@348: // Give the init function the jQuery prototype for later instantiation moel@348: jQuery.fn.init.prototype = jQuery.fn; moel@348: moel@348: jQuery.extend = jQuery.fn.extend = function() { moel@348: var options, name, src, copy, copyIsArray, clone, moel@348: target = arguments[0] || {}, moel@348: i = 1, moel@348: length = arguments.length, moel@348: deep = false; moel@348: moel@348: // Handle a deep copy situation moel@348: if ( typeof target === "boolean" ) { moel@348: deep = target; moel@348: target = arguments[1] || {}; moel@348: // skip the boolean and the target moel@348: i = 2; moel@348: } moel@348: moel@348: // Handle case when target is a string or something (possible in deep copy) moel@348: if ( typeof target !== "object" && !jQuery.isFunction(target) ) { moel@348: target = {}; moel@348: } moel@348: moel@348: // extend jQuery itself if only one argument is passed moel@348: if ( length === i ) { moel@348: target = this; moel@348: --i; moel@348: } moel@348: moel@348: for ( ; i < length; i++ ) { moel@348: // Only deal with non-null/undefined values moel@348: if ( (options = arguments[ i ]) != null ) { moel@348: // Extend the base object moel@348: for ( name in options ) { moel@348: src = target[ name ]; moel@348: copy = options[ name ]; moel@348: moel@348: // Prevent never-ending loop moel@348: if ( target === copy ) { moel@348: continue; moel@348: } moel@348: moel@348: // Recurse if we're merging plain objects or arrays moel@348: if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { moel@348: if ( copyIsArray ) { moel@348: copyIsArray = false; moel@348: clone = src && jQuery.isArray(src) ? src : []; moel@348: moel@348: } else { moel@348: clone = src && jQuery.isPlainObject(src) ? src : {}; moel@348: } moel@348: moel@348: // Never move original objects, clone them moel@348: target[ name ] = jQuery.extend( deep, clone, copy ); moel@348: moel@348: // Don't bring in undefined values moel@348: } else if ( copy !== undefined ) { moel@348: target[ name ] = copy; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Return the modified object moel@348: return target; moel@348: }; moel@348: moel@348: jQuery.extend({ moel@348: noConflict: function( deep ) { moel@348: if ( window.$ === jQuery ) { moel@348: window.$ = _$; moel@348: } moel@348: moel@348: if ( deep && window.jQuery === jQuery ) { moel@348: window.jQuery = _jQuery; moel@348: } moel@348: moel@348: return jQuery; moel@348: }, moel@348: moel@348: // Is the DOM ready to be used? Set to true once it occurs. moel@348: isReady: false, moel@348: moel@348: // A counter to track how many items to wait for before moel@348: // the ready event fires. See #6781 moel@348: readyWait: 1, moel@348: moel@348: // Hold (or release) the ready event moel@348: holdReady: function( hold ) { moel@348: if ( hold ) { moel@348: jQuery.readyWait++; moel@348: } else { moel@348: jQuery.ready( true ); moel@348: } moel@348: }, moel@348: moel@348: // Handle when the DOM is ready moel@348: ready: function( wait ) { moel@348: // Either a released hold or an DOMready/load event and not yet ready moel@348: if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { moel@348: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). moel@348: if ( !document.body ) { moel@348: return setTimeout( jQuery.ready, 1 ); moel@348: } moel@348: moel@348: // Remember that the DOM is ready moel@348: jQuery.isReady = true; moel@348: moel@348: // If a normal DOM Ready event fired, decrement, and wait if need be moel@348: if ( wait !== true && --jQuery.readyWait > 0 ) { moel@348: return; moel@348: } moel@348: moel@348: // If there are functions bound, to execute moel@348: readyList.fireWith( document, [ jQuery ] ); moel@348: moel@348: // Trigger any bound ready events moel@348: if ( jQuery.fn.trigger ) { moel@348: jQuery( document ).trigger( "ready" ).off( "ready" ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: bindReady: function() { moel@348: if ( readyList ) { moel@348: return; moel@348: } moel@348: moel@348: readyList = jQuery.Callbacks( "once memory" ); moel@348: moel@348: // Catch cases where $(document).ready() is called after the moel@348: // browser event has already occurred. moel@348: if ( document.readyState === "complete" ) { moel@348: // Handle it asynchronously to allow scripts the opportunity to delay ready moel@348: return setTimeout( jQuery.ready, 1 ); moel@348: } moel@348: moel@348: // Mozilla, Opera and webkit nightlies currently support this event moel@348: if ( document.addEventListener ) { moel@348: // Use the handy event callback moel@348: document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); moel@348: moel@348: // A fallback to window.onload, that will always work moel@348: window.addEventListener( "load", jQuery.ready, false ); moel@348: moel@348: // If IE event model is used moel@348: } else if ( document.attachEvent ) { moel@348: // ensure firing before onload, moel@348: // maybe late but safe also for iframes moel@348: document.attachEvent( "onreadystatechange", DOMContentLoaded ); moel@348: moel@348: // A fallback to window.onload, that will always work moel@348: window.attachEvent( "onload", jQuery.ready ); moel@348: moel@348: // If IE and not a frame moel@348: // continually check to see if the document is ready moel@348: var toplevel = false; moel@348: moel@348: try { moel@348: toplevel = window.frameElement == null; moel@348: } catch(e) {} moel@348: moel@348: if ( document.documentElement.doScroll && toplevel ) { moel@348: doScrollCheck(); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: // See test/unit/core.js for details concerning isFunction. moel@348: // Since version 1.3, DOM methods and functions like alert moel@348: // aren't supported. They return false on IE (#2968). moel@348: isFunction: function( obj ) { moel@348: return jQuery.type(obj) === "function"; moel@348: }, moel@348: moel@348: isArray: Array.isArray || function( obj ) { moel@348: return jQuery.type(obj) === "array"; moel@348: }, moel@348: moel@348: isWindow: function( obj ) { moel@348: return obj != null && obj == obj.window; moel@348: }, moel@348: moel@348: isNumeric: function( obj ) { moel@348: return !isNaN( parseFloat(obj) ) && isFinite( obj ); moel@348: }, moel@348: moel@348: type: function( obj ) { moel@348: return obj == null ? moel@348: String( obj ) : moel@348: class2type[ toString.call(obj) ] || "object"; moel@348: }, moel@348: moel@348: isPlainObject: function( obj ) { moel@348: // Must be an Object. moel@348: // Because of IE, we also have to check the presence of the constructor property. moel@348: // Make sure that DOM nodes and window objects don't pass through, as well moel@348: if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { moel@348: return false; moel@348: } moel@348: moel@348: try { moel@348: // Not own constructor property must be Object moel@348: if ( obj.constructor && moel@348: !hasOwn.call(obj, "constructor") && moel@348: !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { moel@348: return false; moel@348: } moel@348: } catch ( e ) { moel@348: // IE8,9 Will throw exceptions on certain host objects #9897 moel@348: return false; moel@348: } moel@348: moel@348: // Own properties are enumerated firstly, so to speed up, moel@348: // if last one is own, then all properties are own. moel@348: moel@348: var key; moel@348: for ( key in obj ) {} moel@348: moel@348: return key === undefined || hasOwn.call( obj, key ); moel@348: }, moel@348: moel@348: isEmptyObject: function( obj ) { moel@348: for ( var name in obj ) { moel@348: return false; moel@348: } moel@348: return true; moel@348: }, moel@348: moel@348: error: function( msg ) { moel@348: throw new Error( msg ); moel@348: }, moel@348: moel@348: parseJSON: function( data ) { moel@348: if ( typeof data !== "string" || !data ) { moel@348: return null; moel@348: } moel@348: moel@348: // Make sure leading/trailing whitespace is removed (IE can't handle it) moel@348: data = jQuery.trim( data ); moel@348: moel@348: // Attempt to parse using the native JSON parser first moel@348: if ( window.JSON && window.JSON.parse ) { moel@348: return window.JSON.parse( data ); moel@348: } moel@348: moel@348: // Make sure the incoming data is actual JSON moel@348: // Logic borrowed from http://json.org/json2.js moel@348: if ( rvalidchars.test( data.replace( rvalidescape, "@" ) moel@348: .replace( rvalidtokens, "]" ) moel@348: .replace( rvalidbraces, "")) ) { moel@348: moel@348: return ( new Function( "return " + data ) )(); moel@348: moel@348: } moel@348: jQuery.error( "Invalid JSON: " + data ); moel@348: }, moel@348: moel@348: // Cross-browser xml parsing moel@348: parseXML: function( data ) { moel@348: if ( typeof data !== "string" || !data ) { moel@348: return null; moel@348: } moel@348: var xml, tmp; moel@348: try { moel@348: if ( window.DOMParser ) { // Standard moel@348: tmp = new DOMParser(); moel@348: xml = tmp.parseFromString( data , "text/xml" ); moel@348: } else { // IE moel@348: xml = new ActiveXObject( "Microsoft.XMLDOM" ); moel@348: xml.async = "false"; moel@348: xml.loadXML( data ); moel@348: } moel@348: } catch( e ) { moel@348: xml = undefined; moel@348: } moel@348: if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { moel@348: jQuery.error( "Invalid XML: " + data ); moel@348: } moel@348: return xml; moel@348: }, moel@348: moel@348: noop: function() {}, moel@348: moel@348: // Evaluates a script in a global context moel@348: // Workarounds based on findings by Jim Driscoll moel@348: // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context moel@348: globalEval: function( data ) { moel@348: if ( data && rnotwhite.test( data ) ) { moel@348: // We use execScript on Internet Explorer moel@348: // We use an anonymous function so that context is window moel@348: // rather than jQuery in Firefox moel@348: ( window.execScript || function( data ) { moel@348: window[ "eval" ].call( window, data ); moel@348: } )( data ); moel@348: } moel@348: }, moel@348: moel@348: // Convert dashed to camelCase; used by the css and data modules moel@348: // Microsoft forgot to hump their vendor prefix (#9572) moel@348: camelCase: function( string ) { moel@348: return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); moel@348: }, moel@348: moel@348: nodeName: function( elem, name ) { moel@348: return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); moel@348: }, moel@348: moel@348: // args is for internal usage only moel@348: each: function( object, callback, args ) { moel@348: var name, i = 0, moel@348: length = object.length, moel@348: isObj = length === undefined || jQuery.isFunction( object ); moel@348: moel@348: if ( args ) { moel@348: if ( isObj ) { moel@348: for ( name in object ) { moel@348: if ( callback.apply( object[ name ], args ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } else { moel@348: for ( ; i < length; ) { moel@348: if ( callback.apply( object[ i++ ], args ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // A special, fast, case for the most common use of each moel@348: } else { moel@348: if ( isObj ) { moel@348: for ( name in object ) { moel@348: if ( callback.call( object[ name ], name, object[ name ] ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } else { moel@348: for ( ; i < length; ) { moel@348: if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return object; moel@348: }, moel@348: moel@348: // Use native String.trim function wherever possible moel@348: trim: trim ? moel@348: function( text ) { moel@348: return text == null ? moel@348: "" : moel@348: trim.call( text ); moel@348: } : moel@348: moel@348: // Otherwise use our own trimming functionality moel@348: function( text ) { moel@348: return text == null ? moel@348: "" : moel@348: text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); moel@348: }, moel@348: moel@348: // results is for internal usage only moel@348: makeArray: function( array, results ) { moel@348: var ret = results || []; moel@348: moel@348: if ( array != null ) { moel@348: // The window, strings (and functions) also have 'length' moel@348: // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 moel@348: var type = jQuery.type( array ); moel@348: moel@348: if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { moel@348: push.call( ret, array ); moel@348: } else { moel@348: jQuery.merge( ret, array ); moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: inArray: function( elem, array, i ) { moel@348: var len; moel@348: moel@348: if ( array ) { moel@348: if ( indexOf ) { moel@348: return indexOf.call( array, elem, i ); moel@348: } moel@348: moel@348: len = array.length; moel@348: i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; moel@348: moel@348: for ( ; i < len; i++ ) { moel@348: // Skip accessing in sparse arrays moel@348: if ( i in array && array[ i ] === elem ) { moel@348: return i; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return -1; moel@348: }, moel@348: moel@348: merge: function( first, second ) { moel@348: var i = first.length, moel@348: j = 0; moel@348: moel@348: if ( typeof second.length === "number" ) { moel@348: for ( var l = second.length; j < l; j++ ) { moel@348: first[ i++ ] = second[ j ]; moel@348: } moel@348: moel@348: } else { moel@348: while ( second[j] !== undefined ) { moel@348: first[ i++ ] = second[ j++ ]; moel@348: } moel@348: } moel@348: moel@348: first.length = i; moel@348: moel@348: return first; moel@348: }, moel@348: moel@348: grep: function( elems, callback, inv ) { moel@348: var ret = [], retVal; moel@348: inv = !!inv; moel@348: moel@348: // Go through the array, only saving the items moel@348: // that pass the validator function moel@348: for ( var i = 0, length = elems.length; i < length; i++ ) { moel@348: retVal = !!callback( elems[ i ], i ); moel@348: if ( inv !== retVal ) { moel@348: ret.push( elems[ i ] ); moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: // arg is for internal usage only moel@348: map: function( elems, callback, arg ) { moel@348: var value, key, ret = [], moel@348: i = 0, moel@348: length = elems.length, moel@348: // jquery objects are treated as arrays moel@348: isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; moel@348: moel@348: // Go through the array, translating each of the items to their moel@348: if ( isArray ) { moel@348: for ( ; i < length; i++ ) { moel@348: value = callback( elems[ i ], i, arg ); moel@348: moel@348: if ( value != null ) { moel@348: ret[ ret.length ] = value; moel@348: } moel@348: } moel@348: moel@348: // Go through every key on the object, moel@348: } else { moel@348: for ( key in elems ) { moel@348: value = callback( elems[ key ], key, arg ); moel@348: moel@348: if ( value != null ) { moel@348: ret[ ret.length ] = value; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Flatten any nested arrays moel@348: return ret.concat.apply( [], ret ); moel@348: }, moel@348: moel@348: // A global GUID counter for objects moel@348: guid: 1, moel@348: moel@348: // Bind a function to a context, optionally partially applying any moel@348: // arguments. moel@348: proxy: function( fn, context ) { moel@348: if ( typeof context === "string" ) { moel@348: var tmp = fn[ context ]; moel@348: context = fn; moel@348: fn = tmp; moel@348: } moel@348: moel@348: // Quick check to determine if target is callable, in the spec moel@348: // this throws a TypeError, but we will just return undefined. moel@348: if ( !jQuery.isFunction( fn ) ) { moel@348: return undefined; moel@348: } moel@348: moel@348: // Simulated bind moel@348: var args = slice.call( arguments, 2 ), moel@348: proxy = function() { moel@348: return fn.apply( context, args.concat( slice.call( arguments ) ) ); moel@348: }; moel@348: moel@348: // Set the guid of unique handler to the same of original handler, so it can be removed moel@348: proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; moel@348: moel@348: return proxy; moel@348: }, moel@348: moel@348: // Mutifunctional method to get and set values to a collection moel@348: // The value/s can optionally be executed if it's a function moel@348: access: function( elems, fn, key, value, chainable, emptyGet, pass ) { moel@348: var exec, moel@348: bulk = key == null, moel@348: i = 0, moel@348: length = elems.length; moel@348: moel@348: // Sets many values moel@348: if ( key && typeof key === "object" ) { moel@348: for ( i in key ) { moel@348: jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); moel@348: } moel@348: chainable = 1; moel@348: moel@348: // Sets one value moel@348: } else if ( value !== undefined ) { moel@348: // Optionally, function values get executed if exec is true moel@348: exec = pass === undefined && jQuery.isFunction( value ); moel@348: moel@348: if ( bulk ) { moel@348: // Bulk operations only iterate when executing function values moel@348: if ( exec ) { moel@348: exec = fn; moel@348: fn = function( elem, key, value ) { moel@348: return exec.call( jQuery( elem ), value ); moel@348: }; moel@348: moel@348: // Otherwise they run against the entire set moel@348: } else { moel@348: fn.call( elems, value ); moel@348: fn = null; moel@348: } moel@348: } moel@348: moel@348: if ( fn ) { moel@348: for (; i < length; i++ ) { moel@348: fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); moel@348: } moel@348: } moel@348: moel@348: chainable = 1; moel@348: } moel@348: moel@348: return chainable ? moel@348: elems : moel@348: moel@348: // Gets moel@348: bulk ? moel@348: fn.call( elems ) : moel@348: length ? fn( elems[0], key ) : emptyGet; moel@348: }, moel@348: moel@348: now: function() { moel@348: return ( new Date() ).getTime(); moel@348: }, moel@348: moel@348: // Use of jQuery.browser is frowned upon. moel@348: // More details: http://docs.jquery.com/Utilities/jQuery.browser moel@348: uaMatch: function( ua ) { moel@348: ua = ua.toLowerCase(); moel@348: moel@348: var match = rwebkit.exec( ua ) || moel@348: ropera.exec( ua ) || moel@348: rmsie.exec( ua ) || moel@348: ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || moel@348: []; moel@348: moel@348: return { browser: match[1] || "", version: match[2] || "0" }; moel@348: }, moel@348: moel@348: sub: function() { moel@348: function jQuerySub( selector, context ) { moel@348: return new jQuerySub.fn.init( selector, context ); moel@348: } moel@348: jQuery.extend( true, jQuerySub, this ); moel@348: jQuerySub.superclass = this; moel@348: jQuerySub.fn = jQuerySub.prototype = this(); moel@348: jQuerySub.fn.constructor = jQuerySub; moel@348: jQuerySub.sub = this.sub; moel@348: jQuerySub.fn.init = function init( selector, context ) { moel@348: if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { moel@348: context = jQuerySub( context ); moel@348: } moel@348: moel@348: return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); moel@348: }; moel@348: jQuerySub.fn.init.prototype = jQuerySub.fn; moel@348: var rootjQuerySub = jQuerySub(document); moel@348: return jQuerySub; moel@348: }, moel@348: moel@348: browser: {} moel@348: }); moel@348: moel@348: // Populate the class2type map moel@348: jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { moel@348: class2type[ "[object " + name + "]" ] = name.toLowerCase(); moel@348: }); moel@348: moel@348: browserMatch = jQuery.uaMatch( userAgent ); moel@348: if ( browserMatch.browser ) { moel@348: jQuery.browser[ browserMatch.browser ] = true; moel@348: jQuery.browser.version = browserMatch.version; moel@348: } moel@348: moel@348: // Deprecated, use jQuery.browser.webkit instead moel@348: if ( jQuery.browser.webkit ) { moel@348: jQuery.browser.safari = true; moel@348: } moel@348: moel@348: // IE doesn't match non-breaking spaces with \s moel@348: if ( rnotwhite.test( "\xA0" ) ) { moel@348: trimLeft = /^[\s\xA0]+/; moel@348: trimRight = /[\s\xA0]+$/; moel@348: } moel@348: moel@348: // All jQuery objects should point back to these moel@348: rootjQuery = jQuery(document); moel@348: moel@348: // Cleanup functions for the document ready method moel@348: if ( document.addEventListener ) { moel@348: DOMContentLoaded = function() { moel@348: document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); moel@348: jQuery.ready(); moel@348: }; moel@348: moel@348: } else if ( document.attachEvent ) { moel@348: DOMContentLoaded = function() { moel@348: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). moel@348: if ( document.readyState === "complete" ) { moel@348: document.detachEvent( "onreadystatechange", DOMContentLoaded ); moel@348: jQuery.ready(); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // The DOM ready check for Internet Explorer moel@348: function doScrollCheck() { moel@348: if ( jQuery.isReady ) { moel@348: return; moel@348: } moel@348: moel@348: try { moel@348: // If IE is used, use the trick by Diego Perini moel@348: // http://javascript.nwbox.com/IEContentLoaded/ moel@348: document.documentElement.doScroll("left"); moel@348: } catch(e) { moel@348: setTimeout( doScrollCheck, 1 ); moel@348: return; moel@348: } moel@348: moel@348: // and execute any waiting functions moel@348: jQuery.ready(); moel@348: } moel@348: moel@348: return jQuery; moel@348: moel@348: })(); moel@348: moel@348: moel@348: // String to Object flags format cache moel@348: var flagsCache = {}; moel@348: moel@348: // Convert String-formatted flags into Object-formatted ones and store in cache moel@348: function createFlags( flags ) { moel@348: var object = flagsCache[ flags ] = {}, moel@348: i, length; moel@348: flags = flags.split( /\s+/ ); moel@348: for ( i = 0, length = flags.length; i < length; i++ ) { moel@348: object[ flags[i] ] = true; moel@348: } moel@348: return object; moel@348: } moel@348: moel@348: /* moel@348: * Create a callback list using the following parameters: moel@348: * moel@348: * flags: an optional list of space-separated flags that will change how moel@348: * the callback list behaves moel@348: * moel@348: * By default a callback list will act like an event callback list and can be moel@348: * "fired" multiple times. moel@348: * moel@348: * Possible flags: moel@348: * moel@348: * once: will ensure the callback list can only be fired once (like a Deferred) moel@348: * moel@348: * memory: will keep track of previous values and will call any callback added moel@348: * after the list has been fired right away with the latest "memorized" moel@348: * values (like a Deferred) moel@348: * moel@348: * unique: will ensure a callback can only be added once (no duplicate in the list) moel@348: * moel@348: * stopOnFalse: interrupt callings when a callback returns false moel@348: * moel@348: */ moel@348: jQuery.Callbacks = function( flags ) { moel@348: moel@348: // Convert flags from String-formatted to Object-formatted moel@348: // (we check in cache first) moel@348: flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; moel@348: moel@348: var // Actual callback list moel@348: list = [], moel@348: // Stack of fire calls for repeatable lists moel@348: stack = [], moel@348: // Last fire value (for non-forgettable lists) moel@348: memory, moel@348: // Flag to know if list was already fired moel@348: fired, moel@348: // Flag to know if list is currently firing moel@348: firing, moel@348: // First callback to fire (used internally by add and fireWith) moel@348: firingStart, moel@348: // End of the loop when firing moel@348: firingLength, moel@348: // Index of currently firing callback (modified by remove if needed) moel@348: firingIndex, moel@348: // Add one or several callbacks to the list moel@348: add = function( args ) { moel@348: var i, moel@348: length, moel@348: elem, moel@348: type, moel@348: actual; moel@348: for ( i = 0, length = args.length; i < length; i++ ) { moel@348: elem = args[ i ]; moel@348: type = jQuery.type( elem ); moel@348: if ( type === "array" ) { moel@348: // Inspect recursively moel@348: add( elem ); moel@348: } else if ( type === "function" ) { moel@348: // Add if not in unique mode and callback is not in moel@348: if ( !flags.unique || !self.has( elem ) ) { moel@348: list.push( elem ); moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: // Fire callbacks moel@348: fire = function( context, args ) { moel@348: args = args || []; moel@348: memory = !flags.memory || [ context, args ]; moel@348: fired = true; moel@348: firing = true; moel@348: firingIndex = firingStart || 0; moel@348: firingStart = 0; moel@348: firingLength = list.length; moel@348: for ( ; list && firingIndex < firingLength; firingIndex++ ) { moel@348: if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { moel@348: memory = true; // Mark as halted moel@348: break; moel@348: } moel@348: } moel@348: firing = false; moel@348: if ( list ) { moel@348: if ( !flags.once ) { moel@348: if ( stack && stack.length ) { moel@348: memory = stack.shift(); moel@348: self.fireWith( memory[ 0 ], memory[ 1 ] ); moel@348: } moel@348: } else if ( memory === true ) { moel@348: self.disable(); moel@348: } else { moel@348: list = []; moel@348: } moel@348: } moel@348: }, moel@348: // Actual Callbacks object moel@348: self = { moel@348: // Add a callback or a collection of callbacks to the list moel@348: add: function() { moel@348: if ( list ) { moel@348: var length = list.length; moel@348: add( arguments ); moel@348: // Do we need to add the callbacks to the moel@348: // current firing batch? moel@348: if ( firing ) { moel@348: firingLength = list.length; moel@348: // With memory, if we're not firing then moel@348: // we should call right away, unless previous moel@348: // firing was halted (stopOnFalse) moel@348: } else if ( memory && memory !== true ) { moel@348: firingStart = length; moel@348: fire( memory[ 0 ], memory[ 1 ] ); moel@348: } moel@348: } moel@348: return this; moel@348: }, moel@348: // Remove a callback from the list moel@348: remove: function() { moel@348: if ( list ) { moel@348: var args = arguments, moel@348: argIndex = 0, moel@348: argLength = args.length; moel@348: for ( ; argIndex < argLength ; argIndex++ ) { moel@348: for ( var i = 0; i < list.length; i++ ) { moel@348: if ( args[ argIndex ] === list[ i ] ) { moel@348: // Handle firingIndex and firingLength moel@348: if ( firing ) { moel@348: if ( i <= firingLength ) { moel@348: firingLength--; moel@348: if ( i <= firingIndex ) { moel@348: firingIndex--; moel@348: } moel@348: } moel@348: } moel@348: // Remove the element moel@348: list.splice( i--, 1 ); moel@348: // If we have some unicity property then moel@348: // we only need to do this once moel@348: if ( flags.unique ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: return this; moel@348: }, moel@348: // Control if a given callback is in the list moel@348: has: function( fn ) { moel@348: if ( list ) { moel@348: var i = 0, moel@348: length = list.length; moel@348: for ( ; i < length; i++ ) { moel@348: if ( fn === list[ i ] ) { moel@348: return true; moel@348: } moel@348: } moel@348: } moel@348: return false; moel@348: }, moel@348: // Remove all callbacks from the list moel@348: empty: function() { moel@348: list = []; moel@348: return this; moel@348: }, moel@348: // Have the list do nothing anymore moel@348: disable: function() { moel@348: list = stack = memory = undefined; moel@348: return this; moel@348: }, moel@348: // Is it disabled? moel@348: disabled: function() { moel@348: return !list; moel@348: }, moel@348: // Lock the list in its current state moel@348: lock: function() { moel@348: stack = undefined; moel@348: if ( !memory || memory === true ) { moel@348: self.disable(); moel@348: } moel@348: return this; moel@348: }, moel@348: // Is it locked? moel@348: locked: function() { moel@348: return !stack; moel@348: }, moel@348: // Call all callbacks with the given context and arguments moel@348: fireWith: function( context, args ) { moel@348: if ( stack ) { moel@348: if ( firing ) { moel@348: if ( !flags.once ) { moel@348: stack.push( [ context, args ] ); moel@348: } moel@348: } else if ( !( flags.once && memory ) ) { moel@348: fire( context, args ); moel@348: } moel@348: } moel@348: return this; moel@348: }, moel@348: // Call all the callbacks with the given arguments moel@348: fire: function() { moel@348: self.fireWith( this, arguments ); moel@348: return this; moel@348: }, moel@348: // To know if the callbacks have already been called at least once moel@348: fired: function() { moel@348: return !!fired; moel@348: } moel@348: }; moel@348: moel@348: return self; moel@348: }; moel@348: moel@348: moel@348: moel@348: moel@348: var // Static reference to slice moel@348: sliceDeferred = [].slice; moel@348: moel@348: jQuery.extend({ moel@348: moel@348: Deferred: function( func ) { moel@348: var doneList = jQuery.Callbacks( "once memory" ), moel@348: failList = jQuery.Callbacks( "once memory" ), moel@348: progressList = jQuery.Callbacks( "memory" ), moel@348: state = "pending", moel@348: lists = { moel@348: resolve: doneList, moel@348: reject: failList, moel@348: notify: progressList moel@348: }, moel@348: promise = { moel@348: done: doneList.add, moel@348: fail: failList.add, moel@348: progress: progressList.add, moel@348: moel@348: state: function() { moel@348: return state; moel@348: }, moel@348: moel@348: // Deprecated moel@348: isResolved: doneList.fired, moel@348: isRejected: failList.fired, moel@348: moel@348: then: function( doneCallbacks, failCallbacks, progressCallbacks ) { moel@348: deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); moel@348: return this; moel@348: }, moel@348: always: function() { moel@348: deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); moel@348: return this; moel@348: }, moel@348: pipe: function( fnDone, fnFail, fnProgress ) { moel@348: return jQuery.Deferred(function( newDefer ) { moel@348: jQuery.each( { moel@348: done: [ fnDone, "resolve" ], moel@348: fail: [ fnFail, "reject" ], moel@348: progress: [ fnProgress, "notify" ] moel@348: }, function( handler, data ) { moel@348: var fn = data[ 0 ], moel@348: action = data[ 1 ], moel@348: returned; moel@348: if ( jQuery.isFunction( fn ) ) { moel@348: deferred[ handler ](function() { moel@348: returned = fn.apply( this, arguments ); moel@348: if ( returned && jQuery.isFunction( returned.promise ) ) { moel@348: returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); moel@348: } else { moel@348: newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); moel@348: } moel@348: }); moel@348: } else { moel@348: deferred[ handler ]( newDefer[ action ] ); moel@348: } moel@348: }); moel@348: }).promise(); moel@348: }, moel@348: // Get a promise for this deferred moel@348: // If obj is provided, the promise aspect is added to the object moel@348: promise: function( obj ) { moel@348: if ( obj == null ) { moel@348: obj = promise; moel@348: } else { moel@348: for ( var key in promise ) { moel@348: obj[ key ] = promise[ key ]; moel@348: } moel@348: } moel@348: return obj; moel@348: } moel@348: }, moel@348: deferred = promise.promise({}), moel@348: key; moel@348: moel@348: for ( key in lists ) { moel@348: deferred[ key ] = lists[ key ].fire; moel@348: deferred[ key + "With" ] = lists[ key ].fireWith; moel@348: } moel@348: moel@348: // Handle state moel@348: deferred.done( function() { moel@348: state = "resolved"; moel@348: }, failList.disable, progressList.lock ).fail( function() { moel@348: state = "rejected"; moel@348: }, doneList.disable, progressList.lock ); moel@348: moel@348: // Call given func if any moel@348: if ( func ) { moel@348: func.call( deferred, deferred ); moel@348: } moel@348: moel@348: // All done! moel@348: return deferred; moel@348: }, moel@348: moel@348: // Deferred helper moel@348: when: function( firstParam ) { moel@348: var args = sliceDeferred.call( arguments, 0 ), moel@348: i = 0, moel@348: length = args.length, moel@348: pValues = new Array( length ), moel@348: count = length, moel@348: pCount = length, moel@348: deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? moel@348: firstParam : moel@348: jQuery.Deferred(), moel@348: promise = deferred.promise(); moel@348: function resolveFunc( i ) { moel@348: return function( value ) { moel@348: args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; moel@348: if ( !( --count ) ) { moel@348: deferred.resolveWith( deferred, args ); moel@348: } moel@348: }; moel@348: } moel@348: function progressFunc( i ) { moel@348: return function( value ) { moel@348: pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; moel@348: deferred.notifyWith( promise, pValues ); moel@348: }; moel@348: } moel@348: if ( length > 1 ) { moel@348: for ( ; i < length; i++ ) { moel@348: if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { moel@348: args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); moel@348: } else { moel@348: --count; moel@348: } moel@348: } moel@348: if ( !count ) { moel@348: deferred.resolveWith( deferred, args ); moel@348: } moel@348: } else if ( deferred !== firstParam ) { moel@348: deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); moel@348: } moel@348: return promise; moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: jQuery.support = (function() { moel@348: moel@348: var support, moel@348: all, moel@348: a, moel@348: select, moel@348: opt, moel@348: input, moel@348: fragment, moel@348: tds, moel@348: events, moel@348: eventName, moel@348: i, moel@348: isSupported, moel@348: div = document.createElement( "div" ), moel@348: documentElement = document.documentElement; moel@348: moel@348: // Preliminary tests moel@348: div.setAttribute("className", "t"); moel@348: div.innerHTML = "
a"; moel@348: moel@348: all = div.getElementsByTagName( "*" ); moel@348: a = div.getElementsByTagName( "a" )[ 0 ]; moel@348: moel@348: // Can't get basic test support moel@348: if ( !all || !all.length || !a ) { moel@348: return {}; moel@348: } moel@348: moel@348: // First batch of supports tests moel@348: select = document.createElement( "select" ); moel@348: opt = select.appendChild( document.createElement("option") ); moel@348: input = div.getElementsByTagName( "input" )[ 0 ]; moel@348: moel@348: support = { moel@348: // IE strips leading whitespace when .innerHTML is used moel@348: leadingWhitespace: ( div.firstChild.nodeType === 3 ), moel@348: moel@348: // Make sure that tbody elements aren't automatically inserted moel@348: // IE will insert them into empty tables moel@348: tbody: !div.getElementsByTagName("tbody").length, moel@348: moel@348: // Make sure that link elements get serialized correctly by innerHTML moel@348: // This requires a wrapper element in IE moel@348: htmlSerialize: !!div.getElementsByTagName("link").length, moel@348: moel@348: // Get the style information from getAttribute moel@348: // (IE uses .cssText instead) moel@348: style: /top/.test( a.getAttribute("style") ), moel@348: moel@348: // Make sure that URLs aren't manipulated moel@348: // (IE normalizes it by default) moel@348: hrefNormalized: ( a.getAttribute("href") === "/a" ), moel@348: moel@348: // Make sure that element opacity exists moel@348: // (IE uses filter instead) moel@348: // Use a regex to work around a WebKit issue. See #5145 moel@348: opacity: /^0.55/.test( a.style.opacity ), moel@348: moel@348: // Verify style float existence moel@348: // (IE uses styleFloat instead of cssFloat) moel@348: cssFloat: !!a.style.cssFloat, moel@348: moel@348: // Make sure that if no value is specified for a checkbox moel@348: // that it defaults to "on". moel@348: // (WebKit defaults to "" instead) moel@348: checkOn: ( input.value === "on" ), moel@348: moel@348: // Make sure that a selected-by-default option has a working selected property. moel@348: // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) moel@348: optSelected: opt.selected, moel@348: moel@348: // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) moel@348: getSetAttribute: div.className !== "t", moel@348: moel@348: // Tests for enctype support on a form(#6743) moel@348: enctype: !!document.createElement("form").enctype, moel@348: moel@348: // Makes sure cloning an html5 element does not cause problems moel@348: // Where outerHTML is undefined, this still works moel@348: html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>", moel@348: moel@348: // Will be defined later moel@348: submitBubbles: true, moel@348: changeBubbles: true, moel@348: focusinBubbles: false, moel@348: deleteExpando: true, moel@348: noCloneEvent: true, moel@348: inlineBlockNeedsLayout: false, moel@348: shrinkWrapBlocks: false, moel@348: reliableMarginRight: true, moel@348: pixelMargin: true moel@348: }; moel@348: moel@348: // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead moel@348: jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat"); moel@348: moel@348: // Make sure checked status is properly cloned moel@348: input.checked = true; moel@348: support.noCloneChecked = input.cloneNode( true ).checked; moel@348: moel@348: // Make sure that the options inside disabled selects aren't marked as disabled moel@348: // (WebKit marks them as disabled) moel@348: select.disabled = true; moel@348: support.optDisabled = !opt.disabled; moel@348: moel@348: // Test to see if it's possible to delete an expando from an element moel@348: // Fails in Internet Explorer moel@348: try { moel@348: delete div.test; moel@348: } catch( e ) { moel@348: support.deleteExpando = false; moel@348: } moel@348: moel@348: if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { moel@348: div.attachEvent( "onclick", function() { moel@348: // Cloning a node shouldn't copy over any moel@348: // bound event handlers (IE does this) moel@348: support.noCloneEvent = false; moel@348: }); moel@348: div.cloneNode( true ).fireEvent( "onclick" ); moel@348: } moel@348: moel@348: // Check if a radio maintains its value moel@348: // after being appended to the DOM moel@348: input = document.createElement("input"); moel@348: input.value = "t"; moel@348: input.setAttribute("type", "radio"); moel@348: support.radioValue = input.value === "t"; moel@348: moel@348: input.setAttribute("checked", "checked"); moel@348: moel@348: // #11217 - WebKit loses check when the name is after the checked attribute moel@348: input.setAttribute( "name", "t" ); moel@348: moel@348: div.appendChild( input ); moel@348: fragment = document.createDocumentFragment(); moel@348: fragment.appendChild( div.lastChild ); moel@348: moel@348: // WebKit doesn't clone checked state correctly in fragments moel@348: support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; moel@348: moel@348: // Check if a disconnected checkbox will retain its checked moel@348: // value of true after appended to the DOM (IE6/7) moel@348: support.appendChecked = input.checked; moel@348: moel@348: fragment.removeChild( input ); moel@348: fragment.appendChild( div ); moel@348: moel@348: // Technique from Juriy Zaytsev moel@348: // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ moel@348: // We only care about the case where non-standard event systems moel@348: // are used, namely in IE. Short-circuiting here helps us to moel@348: // avoid an eval call (in setAttribute) which can cause CSP moel@348: // to go haywire. See: https://developer.mozilla.org/en/Security/CSP moel@348: if ( div.attachEvent ) { moel@348: for ( i in { moel@348: submit: 1, moel@348: change: 1, moel@348: focusin: 1 moel@348: }) { moel@348: eventName = "on" + i; moel@348: isSupported = ( eventName in div ); moel@348: if ( !isSupported ) { moel@348: div.setAttribute( eventName, "return;" ); moel@348: isSupported = ( typeof div[ eventName ] === "function" ); moel@348: } moel@348: support[ i + "Bubbles" ] = isSupported; moel@348: } moel@348: } moel@348: moel@348: fragment.removeChild( div ); moel@348: moel@348: // Null elements to avoid leaks in IE moel@348: fragment = select = opt = div = input = null; moel@348: moel@348: // Run tests that need a body at doc ready moel@348: jQuery(function() { moel@348: var container, outer, inner, table, td, offsetSupport, moel@348: marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight, moel@348: paddingMarginBorderVisibility, paddingMarginBorder, moel@348: body = document.getElementsByTagName("body")[0]; moel@348: moel@348: if ( !body ) { moel@348: // Return for frameset docs that don't have a body moel@348: return; moel@348: } moel@348: moel@348: conMarginTop = 1; moel@348: paddingMarginBorder = "padding:0;margin:0;border:"; moel@348: positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;"; moel@348: paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;"; moel@348: style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;"; moel@348: html = "
" + moel@348: "" + moel@348: "
"; moel@348: moel@348: container = document.createElement("div"); moel@348: container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; moel@348: body.insertBefore( container, body.firstChild ); moel@348: moel@348: // Construct the test element moel@348: div = document.createElement("div"); moel@348: container.appendChild( div ); moel@348: moel@348: // Check if table cells still have offsetWidth/Height when they are set moel@348: // to display:none and there are still other visible table cells in a moel@348: // table row; if so, offsetWidth/Height are not reliable for use when moel@348: // determining if an element has been hidden directly using moel@348: // display:none (it is still safe to use offsets if a parent element is moel@348: // hidden; don safety goggles and see bug #4512 for more information). moel@348: // (only IE 8 fails this test) moel@348: div.innerHTML = "
t
"; moel@348: tds = div.getElementsByTagName( "td" ); moel@348: isSupported = ( tds[ 0 ].offsetHeight === 0 ); moel@348: moel@348: tds[ 0 ].style.display = ""; moel@348: tds[ 1 ].style.display = "none"; moel@348: moel@348: // Check if empty table cells still have offsetWidth/Height moel@348: // (IE <= 8 fail this test) moel@348: support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); moel@348: moel@348: // Check if div with explicit width and no margin-right incorrectly moel@348: // gets computed margin-right based on width of container. For more moel@348: // info see bug #3333 moel@348: // Fails in WebKit before Feb 2011 nightlies moel@348: // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right moel@348: if ( window.getComputedStyle ) { moel@348: div.innerHTML = ""; moel@348: marginDiv = document.createElement( "div" ); moel@348: marginDiv.style.width = "0"; moel@348: marginDiv.style.marginRight = "0"; moel@348: div.style.width = "2px"; moel@348: div.appendChild( marginDiv ); moel@348: support.reliableMarginRight = moel@348: ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; moel@348: } moel@348: moel@348: if ( typeof div.style.zoom !== "undefined" ) { moel@348: // Check if natively block-level elements act like inline-block moel@348: // elements when setting their display to 'inline' and giving moel@348: // them layout moel@348: // (IE < 8 does this) moel@348: div.innerHTML = ""; moel@348: div.style.width = div.style.padding = "1px"; moel@348: div.style.border = 0; moel@348: div.style.overflow = "hidden"; moel@348: div.style.display = "inline"; moel@348: div.style.zoom = 1; moel@348: support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); moel@348: moel@348: // Check if elements with layout shrink-wrap their children moel@348: // (IE 6 does this) moel@348: div.style.display = "block"; moel@348: div.style.overflow = "visible"; moel@348: div.innerHTML = "
"; moel@348: support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); moel@348: } moel@348: moel@348: div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility; moel@348: div.innerHTML = html; moel@348: moel@348: outer = div.firstChild; moel@348: inner = outer.firstChild; moel@348: td = outer.nextSibling.firstChild.firstChild; moel@348: moel@348: offsetSupport = { moel@348: doesNotAddBorder: ( inner.offsetTop !== 5 ), moel@348: doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) moel@348: }; moel@348: moel@348: inner.style.position = "fixed"; moel@348: inner.style.top = "20px"; moel@348: moel@348: // safari subtracts parent border width here which is 5px moel@348: offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); moel@348: inner.style.position = inner.style.top = ""; moel@348: moel@348: outer.style.overflow = "hidden"; moel@348: outer.style.position = "relative"; moel@348: moel@348: offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); moel@348: offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); moel@348: moel@348: if ( window.getComputedStyle ) { moel@348: div.style.marginTop = "1%"; moel@348: support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%"; moel@348: } moel@348: moel@348: if ( typeof container.style.zoom !== "undefined" ) { moel@348: container.style.zoom = 1; moel@348: } moel@348: moel@348: body.removeChild( container ); moel@348: marginDiv = div = container = null; moel@348: moel@348: jQuery.extend( support, offsetSupport ); moel@348: }); moel@348: moel@348: return support; moel@348: })(); moel@348: moel@348: moel@348: moel@348: moel@348: var rbrace = /^(?:\{.*\}|\[.*\])$/, moel@348: rmultiDash = /([A-Z])/g; moel@348: moel@348: jQuery.extend({ moel@348: cache: {}, moel@348: moel@348: // Please use with caution moel@348: uuid: 0, moel@348: moel@348: // Unique for each copy of jQuery on the page moel@348: // Non-digits removed to match rinlinejQuery moel@348: expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), moel@348: moel@348: // The following elements throw uncatchable exceptions if you moel@348: // attempt to add expando properties to them. moel@348: noData: { moel@348: "embed": true, moel@348: // Ban all objects except for Flash (which handle expandos) moel@348: "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", moel@348: "applet": true moel@348: }, moel@348: moel@348: hasData: function( elem ) { moel@348: elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; moel@348: return !!elem && !isEmptyDataObject( elem ); moel@348: }, moel@348: moel@348: data: function( elem, name, data, pvt /* Internal Use Only */ ) { moel@348: if ( !jQuery.acceptData( elem ) ) { moel@348: return; moel@348: } moel@348: moel@348: var privateCache, thisCache, ret, moel@348: internalKey = jQuery.expando, moel@348: getByName = typeof name === "string", moel@348: moel@348: // We have to handle DOM nodes and JS objects differently because IE6-7 moel@348: // can't GC object references properly across the DOM-JS boundary moel@348: isNode = elem.nodeType, moel@348: moel@348: // Only DOM nodes need the global jQuery cache; JS object data is moel@348: // attached directly to the object so GC can occur automatically moel@348: cache = isNode ? jQuery.cache : elem, moel@348: moel@348: // Only defining an ID for JS objects if its cache already exists allows moel@348: // the code to shortcut on the same path as a DOM node with no cache moel@348: id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, moel@348: isEvents = name === "events"; moel@348: moel@348: // Avoid doing any more work than we need to when trying to get data on an moel@348: // object that has no data at all moel@348: if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { moel@348: return; moel@348: } moel@348: moel@348: if ( !id ) { moel@348: // Only DOM nodes need a new unique ID for each element since their data moel@348: // ends up in the global cache moel@348: if ( isNode ) { moel@348: elem[ internalKey ] = id = ++jQuery.uuid; moel@348: } else { moel@348: id = internalKey; moel@348: } moel@348: } moel@348: moel@348: if ( !cache[ id ] ) { moel@348: cache[ id ] = {}; moel@348: moel@348: // Avoids exposing jQuery metadata on plain JS objects when the object moel@348: // is serialized using JSON.stringify moel@348: if ( !isNode ) { moel@348: cache[ id ].toJSON = jQuery.noop; moel@348: } moel@348: } moel@348: moel@348: // An object can be passed to jQuery.data instead of a key/value pair; this gets moel@348: // shallow copied over onto the existing cache moel@348: if ( typeof name === "object" || typeof name === "function" ) { moel@348: if ( pvt ) { moel@348: cache[ id ] = jQuery.extend( cache[ id ], name ); moel@348: } else { moel@348: cache[ id ].data = jQuery.extend( cache[ id ].data, name ); moel@348: } moel@348: } moel@348: moel@348: privateCache = thisCache = cache[ id ]; moel@348: moel@348: // jQuery data() is stored in a separate object inside the object's internal data moel@348: // cache in order to avoid key collisions between internal data and user-defined moel@348: // data. moel@348: if ( !pvt ) { moel@348: if ( !thisCache.data ) { moel@348: thisCache.data = {}; moel@348: } moel@348: moel@348: thisCache = thisCache.data; moel@348: } moel@348: moel@348: if ( data !== undefined ) { moel@348: thisCache[ jQuery.camelCase( name ) ] = data; moel@348: } moel@348: moel@348: // Users should not attempt to inspect the internal events object using jQuery.data, moel@348: // it is undocumented and subject to change. But does anyone listen? No. moel@348: if ( isEvents && !thisCache[ name ] ) { moel@348: return privateCache.events; moel@348: } moel@348: moel@348: // Check for both converted-to-camel and non-converted data property names moel@348: // If a data property was specified moel@348: if ( getByName ) { moel@348: moel@348: // First Try to find as-is property data moel@348: ret = thisCache[ name ]; moel@348: moel@348: // Test for null|undefined property data moel@348: if ( ret == null ) { moel@348: moel@348: // Try to find the camelCased property moel@348: ret = thisCache[ jQuery.camelCase( name ) ]; moel@348: } moel@348: } else { moel@348: ret = thisCache; moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: removeData: function( elem, name, pvt /* Internal Use Only */ ) { moel@348: if ( !jQuery.acceptData( elem ) ) { moel@348: return; moel@348: } moel@348: moel@348: var thisCache, i, l, moel@348: moel@348: // Reference to internal data cache key moel@348: internalKey = jQuery.expando, moel@348: moel@348: isNode = elem.nodeType, moel@348: moel@348: // See jQuery.data for more information moel@348: cache = isNode ? jQuery.cache : elem, moel@348: moel@348: // See jQuery.data for more information moel@348: id = isNode ? elem[ internalKey ] : internalKey; moel@348: moel@348: // If there is already no cache entry for this object, there is no moel@348: // purpose in continuing moel@348: if ( !cache[ id ] ) { moel@348: return; moel@348: } moel@348: moel@348: if ( name ) { moel@348: moel@348: thisCache = pvt ? cache[ id ] : cache[ id ].data; moel@348: moel@348: if ( thisCache ) { moel@348: moel@348: // Support array or space separated string names for data keys moel@348: if ( !jQuery.isArray( name ) ) { moel@348: moel@348: // try the string as a key before any manipulation moel@348: if ( name in thisCache ) { moel@348: name = [ name ]; moel@348: } else { moel@348: moel@348: // split the camel cased version by spaces unless a key with the spaces exists moel@348: name = jQuery.camelCase( name ); moel@348: if ( name in thisCache ) { moel@348: name = [ name ]; moel@348: } else { moel@348: name = name.split( " " ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: for ( i = 0, l = name.length; i < l; i++ ) { moel@348: delete thisCache[ name[i] ]; moel@348: } moel@348: moel@348: // If there is no data left in the cache, we want to continue moel@348: // and let the cache object itself get destroyed moel@348: if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { moel@348: return; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // See jQuery.data for more information moel@348: if ( !pvt ) { moel@348: delete cache[ id ].data; moel@348: moel@348: // Don't destroy the parent cache unless the internal data object moel@348: // had been the only thing left in it moel@348: if ( !isEmptyDataObject(cache[ id ]) ) { moel@348: return; moel@348: } moel@348: } moel@348: moel@348: // Browsers that fail expando deletion also refuse to delete expandos on moel@348: // the window, but it will allow it on all other JS objects; other browsers moel@348: // don't care moel@348: // Ensure that `cache` is not a window object #10080 moel@348: if ( jQuery.support.deleteExpando || !cache.setInterval ) { moel@348: delete cache[ id ]; moel@348: } else { moel@348: cache[ id ] = null; moel@348: } moel@348: moel@348: // We destroyed the cache and need to eliminate the expando on the node to avoid moel@348: // false lookups in the cache for entries that no longer exist moel@348: if ( isNode ) { moel@348: // IE does not allow us to delete expando properties from nodes, moel@348: // nor does it have a removeAttribute function on Document nodes; moel@348: // we must handle all of these cases moel@348: if ( jQuery.support.deleteExpando ) { moel@348: delete elem[ internalKey ]; moel@348: } else if ( elem.removeAttribute ) { moel@348: elem.removeAttribute( internalKey ); moel@348: } else { moel@348: elem[ internalKey ] = null; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: // For internal use only. moel@348: _data: function( elem, name, data ) { moel@348: return jQuery.data( elem, name, data, true ); moel@348: }, moel@348: moel@348: // A method for determining if a DOM node can handle the data expando moel@348: acceptData: function( elem ) { moel@348: if ( elem.nodeName ) { moel@348: var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; moel@348: moel@348: if ( match ) { moel@348: return !(match === true || elem.getAttribute("classid") !== match); moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: } moel@348: }); moel@348: moel@348: jQuery.fn.extend({ moel@348: data: function( key, value ) { moel@348: var parts, part, attr, name, l, moel@348: elem = this[0], moel@348: i = 0, moel@348: data = null; moel@348: moel@348: // Gets all values moel@348: if ( key === undefined ) { moel@348: if ( this.length ) { moel@348: data = jQuery.data( elem ); moel@348: moel@348: if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { moel@348: attr = elem.attributes; moel@348: for ( l = attr.length; i < l; i++ ) { moel@348: name = attr[i].name; moel@348: moel@348: if ( name.indexOf( "data-" ) === 0 ) { moel@348: name = jQuery.camelCase( name.substring(5) ); moel@348: moel@348: dataAttr( elem, name, data[ name ] ); moel@348: } moel@348: } moel@348: jQuery._data( elem, "parsedAttrs", true ); moel@348: } moel@348: } moel@348: moel@348: return data; moel@348: } moel@348: moel@348: // Sets multiple values moel@348: if ( typeof key === "object" ) { moel@348: return this.each(function() { moel@348: jQuery.data( this, key ); moel@348: }); moel@348: } moel@348: moel@348: parts = key.split( ".", 2 ); moel@348: parts[1] = parts[1] ? "." + parts[1] : ""; moel@348: part = parts[1] + "!"; moel@348: moel@348: return jQuery.access( this, function( value ) { moel@348: moel@348: if ( value === undefined ) { moel@348: data = this.triggerHandler( "getData" + part, [ parts[0] ] ); moel@348: moel@348: // Try to fetch any internally stored data first moel@348: if ( data === undefined && elem ) { moel@348: data = jQuery.data( elem, key ); moel@348: data = dataAttr( elem, key, data ); moel@348: } moel@348: moel@348: return data === undefined && parts[1] ? moel@348: this.data( parts[0] ) : moel@348: data; moel@348: } moel@348: moel@348: parts[1] = value; moel@348: this.each(function() { moel@348: var self = jQuery( this ); moel@348: moel@348: self.triggerHandler( "setData" + part, parts ); moel@348: jQuery.data( this, key, value ); moel@348: self.triggerHandler( "changeData" + part, parts ); moel@348: }); moel@348: }, null, value, arguments.length > 1, null, false ); moel@348: }, moel@348: moel@348: removeData: function( key ) { moel@348: return this.each(function() { moel@348: jQuery.removeData( this, key ); moel@348: }); moel@348: } moel@348: }); moel@348: moel@348: function dataAttr( elem, key, data ) { moel@348: // If nothing was found internally, try to fetch any moel@348: // data from the HTML5 data-* attribute moel@348: if ( data === undefined && elem.nodeType === 1 ) { moel@348: moel@348: var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); moel@348: moel@348: data = elem.getAttribute( name ); moel@348: moel@348: if ( typeof data === "string" ) { moel@348: try { moel@348: data = data === "true" ? true : moel@348: data === "false" ? false : moel@348: data === "null" ? null : moel@348: jQuery.isNumeric( data ) ? +data : moel@348: rbrace.test( data ) ? jQuery.parseJSON( data ) : moel@348: data; moel@348: } catch( e ) {} moel@348: moel@348: // Make sure we set the data so it isn't changed later moel@348: jQuery.data( elem, key, data ); moel@348: moel@348: } else { moel@348: data = undefined; moel@348: } moel@348: } moel@348: moel@348: return data; moel@348: } moel@348: moel@348: // checks a cache object for emptiness moel@348: function isEmptyDataObject( obj ) { moel@348: for ( var name in obj ) { moel@348: moel@348: // if the public data object is empty, the private is still empty moel@348: if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { moel@348: continue; moel@348: } moel@348: if ( name !== "toJSON" ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: function handleQueueMarkDefer( elem, type, src ) { moel@348: var deferDataKey = type + "defer", moel@348: queueDataKey = type + "queue", moel@348: markDataKey = type + "mark", moel@348: defer = jQuery._data( elem, deferDataKey ); moel@348: if ( defer && moel@348: ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && moel@348: ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { moel@348: // Give room for hard-coded callbacks to fire first moel@348: // and eventually mark/queue something else on the element moel@348: setTimeout( function() { moel@348: if ( !jQuery._data( elem, queueDataKey ) && moel@348: !jQuery._data( elem, markDataKey ) ) { moel@348: jQuery.removeData( elem, deferDataKey, true ); moel@348: defer.fire(); moel@348: } moel@348: }, 0 ); moel@348: } moel@348: } moel@348: moel@348: jQuery.extend({ moel@348: moel@348: _mark: function( elem, type ) { moel@348: if ( elem ) { moel@348: type = ( type || "fx" ) + "mark"; moel@348: jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); moel@348: } moel@348: }, moel@348: moel@348: _unmark: function( force, elem, type ) { moel@348: if ( force !== true ) { moel@348: type = elem; moel@348: elem = force; moel@348: force = false; moel@348: } moel@348: if ( elem ) { moel@348: type = type || "fx"; moel@348: var key = type + "mark", moel@348: count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); moel@348: if ( count ) { moel@348: jQuery._data( elem, key, count ); moel@348: } else { moel@348: jQuery.removeData( elem, key, true ); moel@348: handleQueueMarkDefer( elem, type, "mark" ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: queue: function( elem, type, data ) { moel@348: var q; moel@348: if ( elem ) { moel@348: type = ( type || "fx" ) + "queue"; moel@348: q = jQuery._data( elem, type ); moel@348: moel@348: // Speed up dequeue by getting out quickly if this is just a lookup moel@348: if ( data ) { moel@348: if ( !q || jQuery.isArray(data) ) { moel@348: q = jQuery._data( elem, type, jQuery.makeArray(data) ); moel@348: } else { moel@348: q.push( data ); moel@348: } moel@348: } moel@348: return q || []; moel@348: } moel@348: }, moel@348: moel@348: dequeue: function( elem, type ) { moel@348: type = type || "fx"; moel@348: moel@348: var queue = jQuery.queue( elem, type ), moel@348: fn = queue.shift(), moel@348: hooks = {}; moel@348: moel@348: // If the fx queue is dequeued, always remove the progress sentinel moel@348: if ( fn === "inprogress" ) { moel@348: fn = queue.shift(); moel@348: } moel@348: moel@348: if ( fn ) { moel@348: // Add a progress sentinel to prevent the fx queue from being moel@348: // automatically dequeued moel@348: if ( type === "fx" ) { moel@348: queue.unshift( "inprogress" ); moel@348: } moel@348: moel@348: jQuery._data( elem, type + ".run", hooks ); moel@348: fn.call( elem, function() { moel@348: jQuery.dequeue( elem, type ); moel@348: }, hooks ); moel@348: } moel@348: moel@348: if ( !queue.length ) { moel@348: jQuery.removeData( elem, type + "queue " + type + ".run", true ); moel@348: handleQueueMarkDefer( elem, type, "queue" ); moel@348: } moel@348: } moel@348: }); moel@348: moel@348: jQuery.fn.extend({ moel@348: queue: function( type, data ) { moel@348: var setter = 2; moel@348: moel@348: if ( typeof type !== "string" ) { moel@348: data = type; moel@348: type = "fx"; moel@348: setter--; moel@348: } moel@348: moel@348: if ( arguments.length < setter ) { moel@348: return jQuery.queue( this[0], type ); moel@348: } moel@348: moel@348: return data === undefined ? moel@348: this : moel@348: this.each(function() { moel@348: var queue = jQuery.queue( this, type, data ); moel@348: moel@348: if ( type === "fx" && queue[0] !== "inprogress" ) { moel@348: jQuery.dequeue( this, type ); moel@348: } moel@348: }); moel@348: }, moel@348: dequeue: function( type ) { moel@348: return this.each(function() { moel@348: jQuery.dequeue( this, type ); moel@348: }); moel@348: }, moel@348: // Based off of the plugin by Clint Helfers, with permission. moel@348: // http://blindsignals.com/index.php/2009/07/jquery-delay/ moel@348: delay: function( time, type ) { moel@348: time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; moel@348: type = type || "fx"; moel@348: moel@348: return this.queue( type, function( next, hooks ) { moel@348: var timeout = setTimeout( next, time ); moel@348: hooks.stop = function() { moel@348: clearTimeout( timeout ); moel@348: }; moel@348: }); moel@348: }, moel@348: clearQueue: function( type ) { moel@348: return this.queue( type || "fx", [] ); moel@348: }, moel@348: // Get a promise resolved when queues of a certain type moel@348: // are emptied (fx is the type by default) moel@348: promise: function( type, object ) { moel@348: if ( typeof type !== "string" ) { moel@348: object = type; moel@348: type = undefined; moel@348: } moel@348: type = type || "fx"; moel@348: var defer = jQuery.Deferred(), moel@348: elements = this, moel@348: i = elements.length, moel@348: count = 1, moel@348: deferDataKey = type + "defer", moel@348: queueDataKey = type + "queue", moel@348: markDataKey = type + "mark", moel@348: tmp; moel@348: function resolve() { moel@348: if ( !( --count ) ) { moel@348: defer.resolveWith( elements, [ elements ] ); moel@348: } moel@348: } moel@348: while( i-- ) { moel@348: if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || moel@348: ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || moel@348: jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && moel@348: jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { moel@348: count++; moel@348: tmp.add( resolve ); moel@348: } moel@348: } moel@348: resolve(); moel@348: return defer.promise( object ); moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var rclass = /[\n\t\r]/g, moel@348: rspace = /\s+/, moel@348: rreturn = /\r/g, moel@348: rtype = /^(?:button|input)$/i, moel@348: rfocusable = /^(?:button|input|object|select|textarea)$/i, moel@348: rclickable = /^a(?:rea)?$/i, moel@348: rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, moel@348: getSetAttribute = jQuery.support.getSetAttribute, moel@348: nodeHook, boolHook, fixSpecified; moel@348: moel@348: jQuery.fn.extend({ moel@348: attr: function( name, value ) { moel@348: return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); moel@348: }, moel@348: moel@348: removeAttr: function( name ) { moel@348: return this.each(function() { moel@348: jQuery.removeAttr( this, name ); moel@348: }); moel@348: }, moel@348: moel@348: prop: function( name, value ) { moel@348: return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); moel@348: }, moel@348: moel@348: removeProp: function( name ) { moel@348: name = jQuery.propFix[ name ] || name; moel@348: return this.each(function() { moel@348: // try/catch handles cases where IE balks (such as removing a property on window) moel@348: try { moel@348: this[ name ] = undefined; moel@348: delete this[ name ]; moel@348: } catch( e ) {} moel@348: }); moel@348: }, moel@348: moel@348: addClass: function( value ) { moel@348: var classNames, i, l, elem, moel@348: setClass, c, cl; moel@348: moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function( j ) { moel@348: jQuery( this ).addClass( value.call(this, j, this.className) ); moel@348: }); moel@348: } moel@348: moel@348: if ( value && typeof value === "string" ) { moel@348: classNames = value.split( rspace ); moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: elem = this[ i ]; moel@348: moel@348: if ( elem.nodeType === 1 ) { moel@348: if ( !elem.className && classNames.length === 1 ) { moel@348: elem.className = value; moel@348: moel@348: } else { moel@348: setClass = " " + elem.className + " "; moel@348: moel@348: for ( c = 0, cl = classNames.length; c < cl; c++ ) { moel@348: if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { moel@348: setClass += classNames[ c ] + " "; moel@348: } moel@348: } moel@348: elem.className = jQuery.trim( setClass ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: removeClass: function( value ) { moel@348: var classNames, i, l, elem, className, c, cl; moel@348: moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function( j ) { moel@348: jQuery( this ).removeClass( value.call(this, j, this.className) ); moel@348: }); moel@348: } moel@348: moel@348: if ( (value && typeof value === "string") || value === undefined ) { moel@348: classNames = ( value || "" ).split( rspace ); moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: elem = this[ i ]; moel@348: moel@348: if ( elem.nodeType === 1 && elem.className ) { moel@348: if ( value ) { moel@348: className = (" " + elem.className + " ").replace( rclass, " " ); moel@348: for ( c = 0, cl = classNames.length; c < cl; c++ ) { moel@348: className = className.replace(" " + classNames[ c ] + " ", " "); moel@348: } moel@348: elem.className = jQuery.trim( className ); moel@348: moel@348: } else { moel@348: elem.className = ""; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: toggleClass: function( value, stateVal ) { moel@348: var type = typeof value, moel@348: isBool = typeof stateVal === "boolean"; moel@348: moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function( i ) { moel@348: jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); moel@348: }); moel@348: } moel@348: moel@348: return this.each(function() { moel@348: if ( type === "string" ) { moel@348: // toggle individual class names moel@348: var className, moel@348: i = 0, moel@348: self = jQuery( this ), moel@348: state = stateVal, moel@348: classNames = value.split( rspace ); moel@348: moel@348: while ( (className = classNames[ i++ ]) ) { moel@348: // check each className given, space seperated list moel@348: state = isBool ? state : !self.hasClass( className ); moel@348: self[ state ? "addClass" : "removeClass" ]( className ); moel@348: } moel@348: moel@348: } else if ( type === "undefined" || type === "boolean" ) { moel@348: if ( this.className ) { moel@348: // store className if set moel@348: jQuery._data( this, "__className__", this.className ); moel@348: } moel@348: moel@348: // toggle whole className moel@348: this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: hasClass: function( selector ) { moel@348: var className = " " + selector + " ", moel@348: i = 0, moel@348: l = this.length; moel@348: for ( ; i < l; i++ ) { moel@348: if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { moel@348: return true; moel@348: } moel@348: } moel@348: moel@348: return false; moel@348: }, moel@348: moel@348: val: function( value ) { moel@348: var hooks, ret, isFunction, moel@348: elem = this[0]; moel@348: moel@348: if ( !arguments.length ) { moel@348: if ( elem ) { moel@348: hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; moel@348: moel@348: if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { moel@348: return ret; moel@348: } moel@348: moel@348: ret = elem.value; moel@348: moel@348: return typeof ret === "string" ? moel@348: // handle most common string cases moel@348: ret.replace(rreturn, "") : moel@348: // handle cases where value is null/undef or number moel@348: ret == null ? "" : ret; moel@348: } moel@348: moel@348: return; moel@348: } moel@348: moel@348: isFunction = jQuery.isFunction( value ); moel@348: moel@348: return this.each(function( i ) { moel@348: var self = jQuery(this), val; moel@348: moel@348: if ( this.nodeType !== 1 ) { moel@348: return; moel@348: } moel@348: moel@348: if ( isFunction ) { moel@348: val = value.call( this, i, self.val() ); moel@348: } else { moel@348: val = value; moel@348: } moel@348: moel@348: // Treat null/undefined as ""; convert numbers to string moel@348: if ( val == null ) { moel@348: val = ""; moel@348: } else if ( typeof val === "number" ) { moel@348: val += ""; moel@348: } else if ( jQuery.isArray( val ) ) { moel@348: val = jQuery.map(val, function ( value ) { moel@348: return value == null ? "" : value + ""; moel@348: }); moel@348: } moel@348: moel@348: hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; moel@348: moel@348: // If set returns undefined, fall back to normal setting moel@348: if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { moel@348: this.value = val; moel@348: } moel@348: }); moel@348: } moel@348: }); moel@348: moel@348: jQuery.extend({ moel@348: valHooks: { moel@348: option: { moel@348: get: function( elem ) { moel@348: // attributes.value is undefined in Blackberry 4.7 but moel@348: // uses .value. See #6932 moel@348: var val = elem.attributes.value; moel@348: return !val || val.specified ? elem.value : elem.text; moel@348: } moel@348: }, moel@348: select: { moel@348: get: function( elem ) { moel@348: var value, i, max, option, moel@348: index = elem.selectedIndex, moel@348: values = [], moel@348: options = elem.options, moel@348: one = elem.type === "select-one"; moel@348: moel@348: // Nothing was selected moel@348: if ( index < 0 ) { moel@348: return null; moel@348: } moel@348: moel@348: // Loop through all the selected options moel@348: i = one ? index : 0; moel@348: max = one ? index + 1 : options.length; moel@348: for ( ; i < max; i++ ) { moel@348: option = options[ i ]; moel@348: moel@348: // Don't return options that are disabled or in a disabled optgroup moel@348: if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && moel@348: (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { moel@348: moel@348: // Get the specific value for the option moel@348: value = jQuery( option ).val(); moel@348: moel@348: // We don't need an array for one selects moel@348: if ( one ) { moel@348: return value; moel@348: } moel@348: moel@348: // Multi-Selects return an array moel@348: values.push( value ); moel@348: } moel@348: } moel@348: moel@348: // Fixes Bug #2551 -- select.val() broken in IE after form.reset() moel@348: if ( one && !values.length && options.length ) { moel@348: return jQuery( options[ index ] ).val(); moel@348: } moel@348: moel@348: return values; moel@348: }, moel@348: moel@348: set: function( elem, value ) { moel@348: var values = jQuery.makeArray( value ); moel@348: moel@348: jQuery(elem).find("option").each(function() { moel@348: this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; moel@348: }); moel@348: moel@348: if ( !values.length ) { moel@348: elem.selectedIndex = -1; moel@348: } moel@348: return values; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: attrFn: { moel@348: val: true, moel@348: css: true, moel@348: html: true, moel@348: text: true, moel@348: data: true, moel@348: width: true, moel@348: height: true, moel@348: offset: true moel@348: }, moel@348: moel@348: attr: function( elem, name, value, pass ) { moel@348: var ret, hooks, notxml, moel@348: nType = elem.nodeType; moel@348: moel@348: // don't get/set attributes on text, comment and attribute nodes moel@348: if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { moel@348: return; moel@348: } moel@348: moel@348: if ( pass && name in jQuery.attrFn ) { moel@348: return jQuery( elem )[ name ]( value ); moel@348: } moel@348: moel@348: // Fallback to prop when attributes are not supported moel@348: if ( typeof elem.getAttribute === "undefined" ) { moel@348: return jQuery.prop( elem, name, value ); moel@348: } moel@348: moel@348: notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); moel@348: moel@348: // All attributes are lowercase moel@348: // Grab necessary hook if one is defined moel@348: if ( notxml ) { moel@348: name = name.toLowerCase(); moel@348: hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); moel@348: } moel@348: moel@348: if ( value !== undefined ) { moel@348: moel@348: if ( value === null ) { moel@348: jQuery.removeAttr( elem, name ); moel@348: return; moel@348: moel@348: } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: elem.setAttribute( name, "" + value ); moel@348: return value; moel@348: } moel@348: moel@348: } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: moel@348: ret = elem.getAttribute( name ); moel@348: moel@348: // Non-existent attributes return null, we normalize to undefined moel@348: return ret === null ? moel@348: undefined : moel@348: ret; moel@348: } moel@348: }, moel@348: moel@348: removeAttr: function( elem, value ) { moel@348: var propName, attrNames, name, l, isBool, moel@348: i = 0; moel@348: moel@348: if ( value && elem.nodeType === 1 ) { moel@348: attrNames = value.toLowerCase().split( rspace ); moel@348: l = attrNames.length; moel@348: moel@348: for ( ; i < l; i++ ) { moel@348: name = attrNames[ i ]; moel@348: moel@348: if ( name ) { moel@348: propName = jQuery.propFix[ name ] || name; moel@348: isBool = rboolean.test( name ); moel@348: moel@348: // See #9699 for explanation of this approach (setting first, then removal) moel@348: // Do not do this for boolean attributes (see #10870) moel@348: if ( !isBool ) { moel@348: jQuery.attr( elem, name, "" ); moel@348: } moel@348: elem.removeAttribute( getSetAttribute ? name : propName ); moel@348: moel@348: // Set corresponding property to false for boolean attributes moel@348: if ( isBool && propName in elem ) { moel@348: elem[ propName ] = false; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: moel@348: attrHooks: { moel@348: type: { moel@348: set: function( elem, value ) { moel@348: // We can't allow the type property to be changed (since it causes problems in IE) moel@348: if ( rtype.test( elem.nodeName ) && elem.parentNode ) { moel@348: jQuery.error( "type property can't be changed" ); moel@348: } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { moel@348: // Setting the type on a radio button after the value resets the value in IE6-9 moel@348: // Reset value to it's default in case type is set after value moel@348: // This is for element creation moel@348: var val = elem.value; moel@348: elem.setAttribute( "type", value ); moel@348: if ( val ) { moel@348: elem.value = val; moel@348: } moel@348: return value; moel@348: } moel@348: } moel@348: }, moel@348: // Use the value property for back compat moel@348: // Use the nodeHook for button elements in IE6/7 (#1954) moel@348: value: { moel@348: get: function( elem, name ) { moel@348: if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { moel@348: return nodeHook.get( elem, name ); moel@348: } moel@348: return name in elem ? moel@348: elem.value : moel@348: null; moel@348: }, moel@348: set: function( elem, value, name ) { moel@348: if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { moel@348: return nodeHook.set( elem, value, name ); moel@348: } moel@348: // Does not return so that setAttribute is also used moel@348: elem.value = value; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: propFix: { moel@348: tabindex: "tabIndex", moel@348: readonly: "readOnly", moel@348: "for": "htmlFor", moel@348: "class": "className", moel@348: maxlength: "maxLength", moel@348: cellspacing: "cellSpacing", moel@348: cellpadding: "cellPadding", moel@348: rowspan: "rowSpan", moel@348: colspan: "colSpan", moel@348: usemap: "useMap", moel@348: frameborder: "frameBorder", moel@348: contenteditable: "contentEditable" moel@348: }, moel@348: moel@348: prop: function( elem, name, value ) { moel@348: var ret, hooks, notxml, moel@348: nType = elem.nodeType; moel@348: moel@348: // don't get/set properties on text, comment and attribute nodes moel@348: if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { moel@348: return; moel@348: } moel@348: moel@348: notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); moel@348: moel@348: if ( notxml ) { moel@348: // Fix name and attach hooks moel@348: name = jQuery.propFix[ name ] || name; moel@348: hooks = jQuery.propHooks[ name ]; moel@348: } moel@348: moel@348: if ( value !== undefined ) { moel@348: if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: return ( elem[ name ] = value ); moel@348: } moel@348: moel@348: } else { moel@348: if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: return elem[ name ]; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: propHooks: { moel@348: tabIndex: { moel@348: get: function( elem ) { moel@348: // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set moel@348: // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ moel@348: var attributeNode = elem.getAttributeNode("tabindex"); moel@348: moel@348: return attributeNode && attributeNode.specified ? moel@348: parseInt( attributeNode.value, 10 ) : moel@348: rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? moel@348: 0 : moel@348: undefined; moel@348: } moel@348: } moel@348: } moel@348: }); moel@348: moel@348: // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) moel@348: jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; moel@348: moel@348: // Hook for boolean attributes moel@348: boolHook = { moel@348: get: function( elem, name ) { moel@348: // Align boolean attributes with corresponding properties moel@348: // Fall back to attribute presence where some booleans are not supported moel@348: var attrNode, moel@348: property = jQuery.prop( elem, name ); moel@348: return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? moel@348: name.toLowerCase() : moel@348: undefined; moel@348: }, moel@348: set: function( elem, value, name ) { moel@348: var propName; moel@348: if ( value === false ) { moel@348: // Remove boolean attributes when set to false moel@348: jQuery.removeAttr( elem, name ); moel@348: } else { moel@348: // value is true since we know at this point it's type boolean and not false moel@348: // Set boolean attributes to the same name and set the DOM property moel@348: propName = jQuery.propFix[ name ] || name; moel@348: if ( propName in elem ) { moel@348: // Only set the IDL specifically if it already exists on the element moel@348: elem[ propName ] = true; moel@348: } moel@348: moel@348: elem.setAttribute( name, name.toLowerCase() ); moel@348: } moel@348: return name; moel@348: } moel@348: }; moel@348: moel@348: // IE6/7 do not support getting/setting some attributes with get/setAttribute moel@348: if ( !getSetAttribute ) { moel@348: moel@348: fixSpecified = { moel@348: name: true, moel@348: id: true, moel@348: coords: true moel@348: }; moel@348: moel@348: // Use this for any attribute in IE6/7 moel@348: // This fixes almost every IE6/7 issue moel@348: nodeHook = jQuery.valHooks.button = { moel@348: get: function( elem, name ) { moel@348: var ret; moel@348: ret = elem.getAttributeNode( name ); moel@348: return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? moel@348: ret.nodeValue : moel@348: undefined; moel@348: }, moel@348: set: function( elem, value, name ) { moel@348: // Set the existing or create a new attribute node moel@348: var ret = elem.getAttributeNode( name ); moel@348: if ( !ret ) { moel@348: ret = document.createAttribute( name ); moel@348: elem.setAttributeNode( ret ); moel@348: } moel@348: return ( ret.nodeValue = value + "" ); moel@348: } moel@348: }; moel@348: moel@348: // Apply the nodeHook to tabindex moel@348: jQuery.attrHooks.tabindex.set = nodeHook.set; moel@348: moel@348: // Set width and height to auto instead of 0 on empty string( Bug #8150 ) moel@348: // This is for removals moel@348: jQuery.each([ "width", "height" ], function( i, name ) { moel@348: jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { moel@348: set: function( elem, value ) { moel@348: if ( value === "" ) { moel@348: elem.setAttribute( name, "auto" ); moel@348: return value; moel@348: } moel@348: } moel@348: }); moel@348: }); moel@348: moel@348: // Set contenteditable to false on removals(#10429) moel@348: // Setting to empty string throws an error as an invalid value moel@348: jQuery.attrHooks.contenteditable = { moel@348: get: nodeHook.get, moel@348: set: function( elem, value, name ) { moel@348: if ( value === "" ) { moel@348: value = "false"; moel@348: } moel@348: nodeHook.set( elem, value, name ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: moel@348: // Some attributes require a special call on IE moel@348: if ( !jQuery.support.hrefNormalized ) { moel@348: jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { moel@348: jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { moel@348: get: function( elem ) { moel@348: var ret = elem.getAttribute( name, 2 ); moel@348: return ret === null ? undefined : ret; moel@348: } moel@348: }); moel@348: }); moel@348: } moel@348: moel@348: if ( !jQuery.support.style ) { moel@348: jQuery.attrHooks.style = { moel@348: get: function( elem ) { moel@348: // Return undefined in the case of empty string moel@348: // Normalize to lowercase since IE uppercases css property names moel@348: return elem.style.cssText.toLowerCase() || undefined; moel@348: }, moel@348: set: function( elem, value ) { moel@348: return ( elem.style.cssText = "" + value ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // Safari mis-reports the default selected property of an option moel@348: // Accessing the parent's selectedIndex property fixes it moel@348: if ( !jQuery.support.optSelected ) { moel@348: jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { moel@348: get: function( elem ) { moel@348: var parent = elem.parentNode; moel@348: moel@348: if ( parent ) { moel@348: parent.selectedIndex; moel@348: moel@348: // Make sure that it also works with optgroups, see #5701 moel@348: if ( parent.parentNode ) { moel@348: parent.parentNode.selectedIndex; moel@348: } moel@348: } moel@348: return null; moel@348: } moel@348: }); moel@348: } moel@348: moel@348: // IE6/7 call enctype encoding moel@348: if ( !jQuery.support.enctype ) { moel@348: jQuery.propFix.enctype = "encoding"; moel@348: } moel@348: moel@348: // Radios and checkboxes getter/setter moel@348: if ( !jQuery.support.checkOn ) { moel@348: jQuery.each([ "radio", "checkbox" ], function() { moel@348: jQuery.valHooks[ this ] = { moel@348: get: function( elem ) { moel@348: // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified moel@348: return elem.getAttribute("value") === null ? "on" : elem.value; moel@348: } moel@348: }; moel@348: }); moel@348: } moel@348: jQuery.each([ "radio", "checkbox" ], function() { moel@348: jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { moel@348: set: function( elem, value ) { moel@348: if ( jQuery.isArray( value ) ) { moel@348: return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); moel@348: } moel@348: } moel@348: }); moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var rformElems = /^(?:textarea|input|select)$/i, moel@348: rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, moel@348: rhoverHack = /(?:^|\s)hover(\.\S+)?\b/, moel@348: rkeyEvent = /^key/, moel@348: rmouseEvent = /^(?:mouse|contextmenu)|click/, moel@348: rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, moel@348: rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, moel@348: quickParse = function( selector ) { moel@348: var quick = rquickIs.exec( selector ); moel@348: if ( quick ) { moel@348: // 0 1 2 3 moel@348: // [ _, tag, id, class ] moel@348: quick[1] = ( quick[1] || "" ).toLowerCase(); moel@348: quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); moel@348: } moel@348: return quick; moel@348: }, moel@348: quickIs = function( elem, m ) { moel@348: var attrs = elem.attributes || {}; moel@348: return ( moel@348: (!m[1] || elem.nodeName.toLowerCase() === m[1]) && moel@348: (!m[2] || (attrs.id || {}).value === m[2]) && moel@348: (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) moel@348: ); moel@348: }, moel@348: hoverHack = function( events ) { moel@348: return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); moel@348: }; moel@348: moel@348: /* moel@348: * Helper functions for managing events -- not part of the public interface. moel@348: * Props to Dean Edwards' addEvent library for many of the ideas. moel@348: */ moel@348: jQuery.event = { moel@348: moel@348: add: function( elem, types, handler, data, selector ) { moel@348: moel@348: var elemData, eventHandle, events, moel@348: t, tns, type, namespaces, handleObj, moel@348: handleObjIn, quick, handlers, special; moel@348: moel@348: // Don't attach events to noData or text/comment nodes (allow plain objects tho) moel@348: if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { moel@348: return; moel@348: } moel@348: moel@348: // Caller can pass in an object of custom data in lieu of the handler moel@348: if ( handler.handler ) { moel@348: handleObjIn = handler; moel@348: handler = handleObjIn.handler; moel@348: selector = handleObjIn.selector; moel@348: } moel@348: moel@348: // Make sure that the handler has a unique ID, used to find/remove it later moel@348: if ( !handler.guid ) { moel@348: handler.guid = jQuery.guid++; moel@348: } moel@348: moel@348: // Init the element's event structure and main handler, if this is the first moel@348: events = elemData.events; moel@348: if ( !events ) { moel@348: elemData.events = events = {}; moel@348: } moel@348: eventHandle = elemData.handle; moel@348: if ( !eventHandle ) { moel@348: elemData.handle = eventHandle = function( e ) { moel@348: // Discard the second event of a jQuery.event.trigger() and moel@348: // when an event is called after a page has unloaded moel@348: return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? moel@348: jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : moel@348: undefined; moel@348: }; moel@348: // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events moel@348: eventHandle.elem = elem; moel@348: } moel@348: moel@348: // Handle multiple events separated by a space moel@348: // jQuery(...).bind("mouseover mouseout", fn); moel@348: types = jQuery.trim( hoverHack(types) ).split( " " ); moel@348: for ( t = 0; t < types.length; t++ ) { moel@348: moel@348: tns = rtypenamespace.exec( types[t] ) || []; moel@348: type = tns[1]; moel@348: namespaces = ( tns[2] || "" ).split( "." ).sort(); moel@348: moel@348: // If event changes its type, use the special event handlers for the changed type moel@348: special = jQuery.event.special[ type ] || {}; moel@348: moel@348: // If selector defined, determine special event api type, otherwise given type moel@348: type = ( selector ? special.delegateType : special.bindType ) || type; moel@348: moel@348: // Update special based on newly reset type moel@348: special = jQuery.event.special[ type ] || {}; moel@348: moel@348: // handleObj is passed to all event handlers moel@348: handleObj = jQuery.extend({ moel@348: type: type, moel@348: origType: tns[1], moel@348: data: data, moel@348: handler: handler, moel@348: guid: handler.guid, moel@348: selector: selector, moel@348: quick: selector && quickParse( selector ), moel@348: namespace: namespaces.join(".") moel@348: }, handleObjIn ); moel@348: moel@348: // Init the event handler queue if we're the first moel@348: handlers = events[ type ]; moel@348: if ( !handlers ) { moel@348: handlers = events[ type ] = []; moel@348: handlers.delegateCount = 0; moel@348: moel@348: // Only use addEventListener/attachEvent if the special events handler returns false moel@348: if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { moel@348: // Bind the global event handler to the element moel@348: if ( elem.addEventListener ) { moel@348: elem.addEventListener( type, eventHandle, false ); moel@348: moel@348: } else if ( elem.attachEvent ) { moel@348: elem.attachEvent( "on" + type, eventHandle ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( special.add ) { moel@348: special.add.call( elem, handleObj ); moel@348: moel@348: if ( !handleObj.handler.guid ) { moel@348: handleObj.handler.guid = handler.guid; moel@348: } moel@348: } moel@348: moel@348: // Add to the element's handler list, delegates in front moel@348: if ( selector ) { moel@348: handlers.splice( handlers.delegateCount++, 0, handleObj ); moel@348: } else { moel@348: handlers.push( handleObj ); moel@348: } moel@348: moel@348: // Keep track of which events have ever been used, for event optimization moel@348: jQuery.event.global[ type ] = true; moel@348: } moel@348: moel@348: // Nullify elem to prevent memory leaks in IE moel@348: elem = null; moel@348: }, moel@348: moel@348: global: {}, moel@348: moel@348: // Detach an event or set of events from an element moel@348: remove: function( elem, types, handler, selector, mappedTypes ) { moel@348: moel@348: var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), moel@348: t, tns, type, origType, namespaces, origCount, moel@348: j, events, special, handle, eventType, handleObj; moel@348: moel@348: if ( !elemData || !(events = elemData.events) ) { moel@348: return; moel@348: } moel@348: moel@348: // Once for each type.namespace in types; type may be omitted moel@348: types = jQuery.trim( hoverHack( types || "" ) ).split(" "); moel@348: for ( t = 0; t < types.length; t++ ) { moel@348: tns = rtypenamespace.exec( types[t] ) || []; moel@348: type = origType = tns[1]; moel@348: namespaces = tns[2]; moel@348: moel@348: // Unbind all events (on this namespace, if provided) for the element moel@348: if ( !type ) { moel@348: for ( type in events ) { moel@348: jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); moel@348: } moel@348: continue; moel@348: } moel@348: moel@348: special = jQuery.event.special[ type ] || {}; moel@348: type = ( selector? special.delegateType : special.bindType ) || type; moel@348: eventType = events[ type ] || []; moel@348: origCount = eventType.length; moel@348: namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; moel@348: moel@348: // Remove matching events moel@348: for ( j = 0; j < eventType.length; j++ ) { moel@348: handleObj = eventType[ j ]; moel@348: moel@348: if ( ( mappedTypes || origType === handleObj.origType ) && moel@348: ( !handler || handler.guid === handleObj.guid ) && moel@348: ( !namespaces || namespaces.test( handleObj.namespace ) ) && moel@348: ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { moel@348: eventType.splice( j--, 1 ); moel@348: moel@348: if ( handleObj.selector ) { moel@348: eventType.delegateCount--; moel@348: } moel@348: if ( special.remove ) { moel@348: special.remove.call( elem, handleObj ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Remove generic event handler if we removed something and no more handlers exist moel@348: // (avoids potential for endless recursion during removal of special event handlers) moel@348: if ( eventType.length === 0 && origCount !== eventType.length ) { moel@348: if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { moel@348: jQuery.removeEvent( elem, type, elemData.handle ); moel@348: } moel@348: moel@348: delete events[ type ]; moel@348: } moel@348: } moel@348: moel@348: // Remove the expando if it's no longer used moel@348: if ( jQuery.isEmptyObject( events ) ) { moel@348: handle = elemData.handle; moel@348: if ( handle ) { moel@348: handle.elem = null; moel@348: } moel@348: moel@348: // removeData also checks for emptiness and clears the expando if empty moel@348: // so use it instead of delete moel@348: jQuery.removeData( elem, [ "events", "handle" ], true ); moel@348: } moel@348: }, moel@348: moel@348: // Events that are safe to short-circuit if no handlers are attached. moel@348: // Native DOM events should not be added, they may have inline handlers. moel@348: customEvent: { moel@348: "getData": true, moel@348: "setData": true, moel@348: "changeData": true moel@348: }, moel@348: moel@348: trigger: function( event, data, elem, onlyHandlers ) { moel@348: // Don't do events on text and comment nodes moel@348: if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { moel@348: return; moel@348: } moel@348: moel@348: // Event object or event type moel@348: var type = event.type || event, moel@348: namespaces = [], moel@348: cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; moel@348: moel@348: // focus/blur morphs to focusin/out; ensure we're not firing them right now moel@348: if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { moel@348: return; moel@348: } moel@348: moel@348: if ( type.indexOf( "!" ) >= 0 ) { moel@348: // Exclusive events trigger only for the exact event (no namespaces) moel@348: type = type.slice(0, -1); moel@348: exclusive = true; moel@348: } moel@348: moel@348: if ( type.indexOf( "." ) >= 0 ) { moel@348: // Namespaced trigger; create a regexp to match event type in handle() moel@348: namespaces = type.split("."); moel@348: type = namespaces.shift(); moel@348: namespaces.sort(); moel@348: } moel@348: moel@348: if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { moel@348: // No jQuery handlers for this event type, and it can't have inline handlers moel@348: return; moel@348: } moel@348: moel@348: // Caller can pass in an Event, Object, or just an event type string moel@348: event = typeof event === "object" ? moel@348: // jQuery.Event object moel@348: event[ jQuery.expando ] ? event : moel@348: // Object literal moel@348: new jQuery.Event( type, event ) : moel@348: // Just the event type (string) moel@348: new jQuery.Event( type ); moel@348: moel@348: event.type = type; moel@348: event.isTrigger = true; moel@348: event.exclusive = exclusive; moel@348: event.namespace = namespaces.join( "." ); moel@348: event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; moel@348: ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; moel@348: moel@348: // Handle a global trigger moel@348: if ( !elem ) { moel@348: moel@348: // TODO: Stop taunting the data cache; remove global events and always attach to document moel@348: cache = jQuery.cache; moel@348: for ( i in cache ) { moel@348: if ( cache[ i ].events && cache[ i ].events[ type ] ) { moel@348: jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); moel@348: } moel@348: } moel@348: return; moel@348: } moel@348: moel@348: // Clean up the event in case it is being reused moel@348: event.result = undefined; moel@348: if ( !event.target ) { moel@348: event.target = elem; moel@348: } moel@348: moel@348: // Clone any incoming data and prepend the event, creating the handler arg list moel@348: data = data != null ? jQuery.makeArray( data ) : []; moel@348: data.unshift( event ); moel@348: moel@348: // Allow special events to draw outside the lines moel@348: special = jQuery.event.special[ type ] || {}; moel@348: if ( special.trigger && special.trigger.apply( elem, data ) === false ) { moel@348: return; moel@348: } moel@348: moel@348: // Determine event propagation path in advance, per W3C events spec (#9951) moel@348: // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) moel@348: eventPath = [[ elem, special.bindType || type ]]; moel@348: if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { moel@348: moel@348: bubbleType = special.delegateType || type; moel@348: cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; moel@348: old = null; moel@348: for ( ; cur; cur = cur.parentNode ) { moel@348: eventPath.push([ cur, bubbleType ]); moel@348: old = cur; moel@348: } moel@348: moel@348: // Only add window if we got to document (e.g., not plain obj or detached DOM) moel@348: if ( old && old === elem.ownerDocument ) { moel@348: eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); moel@348: } moel@348: } moel@348: moel@348: // Fire handlers on the event path moel@348: for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { moel@348: moel@348: cur = eventPath[i][0]; moel@348: event.type = eventPath[i][1]; moel@348: moel@348: handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); moel@348: if ( handle ) { moel@348: handle.apply( cur, data ); moel@348: } moel@348: // Note that this is a bare JS function and not a jQuery handler moel@348: handle = ontype && cur[ ontype ]; moel@348: if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { moel@348: event.preventDefault(); moel@348: } moel@348: } moel@348: event.type = type; moel@348: moel@348: // If nobody prevented the default action, do it now moel@348: if ( !onlyHandlers && !event.isDefaultPrevented() ) { moel@348: moel@348: if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && moel@348: !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { moel@348: moel@348: // Call a native DOM method on the target with the same name name as the event. moel@348: // Can't use an .isFunction() check here because IE6/7 fails that test. moel@348: // Don't do default actions on window, that's where global variables be (#6170) moel@348: // IE<9 dies on focus/blur to hidden element (#1486) moel@348: if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { moel@348: moel@348: // Don't re-trigger an onFOO event when we call its FOO() method moel@348: old = elem[ ontype ]; moel@348: moel@348: if ( old ) { moel@348: elem[ ontype ] = null; moel@348: } moel@348: moel@348: // Prevent re-triggering of the same event, since we already bubbled it above moel@348: jQuery.event.triggered = type; moel@348: elem[ type ](); moel@348: jQuery.event.triggered = undefined; moel@348: moel@348: if ( old ) { moel@348: elem[ ontype ] = old; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return event.result; moel@348: }, moel@348: moel@348: dispatch: function( event ) { moel@348: moel@348: // Make a writable jQuery.Event from the native event object moel@348: event = jQuery.event.fix( event || window.event ); moel@348: moel@348: var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), moel@348: delegateCount = handlers.delegateCount, moel@348: args = [].slice.call( arguments, 0 ), moel@348: run_all = !event.exclusive && !event.namespace, moel@348: special = jQuery.event.special[ event.type ] || {}, moel@348: handlerQueue = [], moel@348: i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; moel@348: moel@348: // Use the fix-ed jQuery.Event rather than the (read-only) native event moel@348: args[0] = event; moel@348: event.delegateTarget = this; moel@348: moel@348: // Call the preDispatch hook for the mapped type, and let it bail if desired moel@348: if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { moel@348: return; moel@348: } moel@348: moel@348: // Determine handlers that should run if there are delegated events moel@348: // Avoid non-left-click bubbling in Firefox (#3861) moel@348: if ( delegateCount && !(event.button && event.type === "click") ) { moel@348: moel@348: // Pregenerate a single jQuery object for reuse with .is() moel@348: jqcur = jQuery(this); moel@348: jqcur.context = this.ownerDocument || this; moel@348: moel@348: for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { moel@348: moel@348: // Don't process events on disabled elements (#6911, #8165) moel@348: if ( cur.disabled !== true ) { moel@348: selMatch = {}; moel@348: matches = []; moel@348: jqcur[0] = cur; moel@348: for ( i = 0; i < delegateCount; i++ ) { moel@348: handleObj = handlers[ i ]; moel@348: sel = handleObj.selector; moel@348: moel@348: if ( selMatch[ sel ] === undefined ) { moel@348: selMatch[ sel ] = ( moel@348: handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) moel@348: ); moel@348: } moel@348: if ( selMatch[ sel ] ) { moel@348: matches.push( handleObj ); moel@348: } moel@348: } moel@348: if ( matches.length ) { moel@348: handlerQueue.push({ elem: cur, matches: matches }); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Add the remaining (directly-bound) handlers moel@348: if ( handlers.length > delegateCount ) { moel@348: handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); moel@348: } moel@348: moel@348: // Run delegates first; they may want to stop propagation beneath us moel@348: for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { moel@348: matched = handlerQueue[ i ]; moel@348: event.currentTarget = matched.elem; moel@348: moel@348: for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { moel@348: handleObj = matched.matches[ j ]; moel@348: moel@348: // Triggered event must either 1) be non-exclusive and have no namespace, or moel@348: // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). moel@348: if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { moel@348: moel@348: event.data = handleObj.data; moel@348: event.handleObj = handleObj; moel@348: moel@348: ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) moel@348: .apply( matched.elem, args ); moel@348: moel@348: if ( ret !== undefined ) { moel@348: event.result = ret; moel@348: if ( ret === false ) { moel@348: event.preventDefault(); moel@348: event.stopPropagation(); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Call the postDispatch hook for the mapped type moel@348: if ( special.postDispatch ) { moel@348: special.postDispatch.call( this, event ); moel@348: } moel@348: moel@348: return event.result; moel@348: }, moel@348: moel@348: // Includes some event props shared by KeyEvent and MouseEvent moel@348: // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** moel@348: props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), moel@348: moel@348: fixHooks: {}, moel@348: moel@348: keyHooks: { moel@348: props: "char charCode key keyCode".split(" "), moel@348: filter: function( event, original ) { moel@348: moel@348: // Add which for key events moel@348: if ( event.which == null ) { moel@348: event.which = original.charCode != null ? original.charCode : original.keyCode; moel@348: } moel@348: moel@348: return event; moel@348: } moel@348: }, moel@348: moel@348: mouseHooks: { moel@348: props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), moel@348: filter: function( event, original ) { moel@348: var eventDoc, doc, body, moel@348: button = original.button, moel@348: fromElement = original.fromElement; moel@348: moel@348: // Calculate pageX/Y if missing and clientX/Y available moel@348: if ( event.pageX == null && original.clientX != null ) { moel@348: eventDoc = event.target.ownerDocument || document; moel@348: doc = eventDoc.documentElement; moel@348: body = eventDoc.body; moel@348: moel@348: event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); moel@348: event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); moel@348: } moel@348: moel@348: // Add relatedTarget, if necessary moel@348: if ( !event.relatedTarget && fromElement ) { moel@348: event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; moel@348: } moel@348: moel@348: // Add which for click: 1 === left; 2 === middle; 3 === right moel@348: // Note: button is not normalized, so don't use it moel@348: if ( !event.which && button !== undefined ) { moel@348: event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); moel@348: } moel@348: moel@348: return event; moel@348: } moel@348: }, moel@348: moel@348: fix: function( event ) { moel@348: if ( event[ jQuery.expando ] ) { moel@348: return event; moel@348: } moel@348: moel@348: // Create a writable copy of the event object and normalize some properties moel@348: var i, prop, moel@348: originalEvent = event, moel@348: fixHook = jQuery.event.fixHooks[ event.type ] || {}, moel@348: copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; moel@348: moel@348: event = jQuery.Event( originalEvent ); moel@348: moel@348: for ( i = copy.length; i; ) { moel@348: prop = copy[ --i ]; moel@348: event[ prop ] = originalEvent[ prop ]; moel@348: } moel@348: moel@348: // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) moel@348: if ( !event.target ) { moel@348: event.target = originalEvent.srcElement || document; moel@348: } moel@348: moel@348: // Target should not be a text node (#504, Safari) moel@348: if ( event.target.nodeType === 3 ) { moel@348: event.target = event.target.parentNode; moel@348: } moel@348: moel@348: // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) moel@348: if ( event.metaKey === undefined ) { moel@348: event.metaKey = event.ctrlKey; moel@348: } moel@348: moel@348: return fixHook.filter? fixHook.filter( event, originalEvent ) : event; moel@348: }, moel@348: moel@348: special: { moel@348: ready: { moel@348: // Make sure the ready event is setup moel@348: setup: jQuery.bindReady moel@348: }, moel@348: moel@348: load: { moel@348: // Prevent triggered image.load events from bubbling to window.load moel@348: noBubble: true moel@348: }, moel@348: moel@348: focus: { moel@348: delegateType: "focusin" moel@348: }, moel@348: blur: { moel@348: delegateType: "focusout" moel@348: }, moel@348: moel@348: beforeunload: { moel@348: setup: function( data, namespaces, eventHandle ) { moel@348: // We only want to do this special case on windows moel@348: if ( jQuery.isWindow( this ) ) { moel@348: this.onbeforeunload = eventHandle; moel@348: } moel@348: }, moel@348: moel@348: teardown: function( namespaces, eventHandle ) { moel@348: if ( this.onbeforeunload === eventHandle ) { moel@348: this.onbeforeunload = null; moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: moel@348: simulate: function( type, elem, event, bubble ) { moel@348: // Piggyback on a donor event to simulate a different one. moel@348: // Fake originalEvent to avoid donor's stopPropagation, but if the moel@348: // simulated event prevents default then we do the same on the donor. moel@348: var e = jQuery.extend( moel@348: new jQuery.Event(), moel@348: event, moel@348: { type: type, moel@348: isSimulated: true, moel@348: originalEvent: {} moel@348: } moel@348: ); moel@348: if ( bubble ) { moel@348: jQuery.event.trigger( e, null, elem ); moel@348: } else { moel@348: jQuery.event.dispatch.call( elem, e ); moel@348: } moel@348: if ( e.isDefaultPrevented() ) { moel@348: event.preventDefault(); moel@348: } moel@348: } moel@348: }; moel@348: moel@348: // Some plugins are using, but it's undocumented/deprecated and will be removed. moel@348: // The 1.7 special event interface should provide all the hooks needed now. moel@348: jQuery.event.handle = jQuery.event.dispatch; moel@348: moel@348: jQuery.removeEvent = document.removeEventListener ? moel@348: function( elem, type, handle ) { moel@348: if ( elem.removeEventListener ) { moel@348: elem.removeEventListener( type, handle, false ); moel@348: } moel@348: } : moel@348: function( elem, type, handle ) { moel@348: if ( elem.detachEvent ) { moel@348: elem.detachEvent( "on" + type, handle ); moel@348: } moel@348: }; moel@348: moel@348: jQuery.Event = function( src, props ) { moel@348: // Allow instantiation without the 'new' keyword moel@348: if ( !(this instanceof jQuery.Event) ) { moel@348: return new jQuery.Event( src, props ); moel@348: } moel@348: moel@348: // Event object moel@348: if ( src && src.type ) { moel@348: this.originalEvent = src; moel@348: this.type = src.type; moel@348: moel@348: // Events bubbling up the document may have been marked as prevented moel@348: // by a handler lower down the tree; reflect the correct value. moel@348: this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || moel@348: src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; moel@348: moel@348: // Event type moel@348: } else { moel@348: this.type = src; moel@348: } moel@348: moel@348: // Put explicitly provided properties onto the event object moel@348: if ( props ) { moel@348: jQuery.extend( this, props ); moel@348: } moel@348: moel@348: // Create a timestamp if incoming event doesn't have one moel@348: this.timeStamp = src && src.timeStamp || jQuery.now(); moel@348: moel@348: // Mark it as fixed moel@348: this[ jQuery.expando ] = true; moel@348: }; moel@348: moel@348: function returnFalse() { moel@348: return false; moel@348: } moel@348: function returnTrue() { moel@348: return true; moel@348: } moel@348: moel@348: // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding moel@348: // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html moel@348: jQuery.Event.prototype = { moel@348: preventDefault: function() { moel@348: this.isDefaultPrevented = returnTrue; moel@348: moel@348: var e = this.originalEvent; moel@348: if ( !e ) { moel@348: return; moel@348: } moel@348: moel@348: // if preventDefault exists run it on the original event moel@348: if ( e.preventDefault ) { moel@348: e.preventDefault(); moel@348: moel@348: // otherwise set the returnValue property of the original event to false (IE) moel@348: } else { moel@348: e.returnValue = false; moel@348: } moel@348: }, moel@348: stopPropagation: function() { moel@348: this.isPropagationStopped = returnTrue; moel@348: moel@348: var e = this.originalEvent; moel@348: if ( !e ) { moel@348: return; moel@348: } moel@348: // if stopPropagation exists run it on the original event moel@348: if ( e.stopPropagation ) { moel@348: e.stopPropagation(); moel@348: } moel@348: // otherwise set the cancelBubble property of the original event to true (IE) moel@348: e.cancelBubble = true; moel@348: }, moel@348: stopImmediatePropagation: function() { moel@348: this.isImmediatePropagationStopped = returnTrue; moel@348: this.stopPropagation(); moel@348: }, moel@348: isDefaultPrevented: returnFalse, moel@348: isPropagationStopped: returnFalse, moel@348: isImmediatePropagationStopped: returnFalse moel@348: }; moel@348: moel@348: // Create mouseenter/leave events using mouseover/out and event-time checks moel@348: jQuery.each({ moel@348: mouseenter: "mouseover", moel@348: mouseleave: "mouseout" moel@348: }, function( orig, fix ) { moel@348: jQuery.event.special[ orig ] = { moel@348: delegateType: fix, moel@348: bindType: fix, moel@348: moel@348: handle: function( event ) { moel@348: var target = this, moel@348: related = event.relatedTarget, moel@348: handleObj = event.handleObj, moel@348: selector = handleObj.selector, moel@348: ret; moel@348: moel@348: // For mousenter/leave call the handler if related is outside the target. moel@348: // NB: No relatedTarget if the mouse left/entered the browser window moel@348: if ( !related || (related !== target && !jQuery.contains( target, related )) ) { moel@348: event.type = handleObj.origType; moel@348: ret = handleObj.handler.apply( this, arguments ); moel@348: event.type = fix; moel@348: } moel@348: return ret; moel@348: } moel@348: }; moel@348: }); moel@348: moel@348: // IE submit delegation moel@348: if ( !jQuery.support.submitBubbles ) { moel@348: moel@348: jQuery.event.special.submit = { moel@348: setup: function() { moel@348: // Only need this for delegated form submit events moel@348: if ( jQuery.nodeName( this, "form" ) ) { moel@348: return false; moel@348: } moel@348: moel@348: // Lazy-add a submit handler when a descendant form may potentially be submitted moel@348: jQuery.event.add( this, "click._submit keypress._submit", function( e ) { moel@348: // Node name check avoids a VML-related crash in IE (#9807) moel@348: var elem = e.target, moel@348: form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; moel@348: if ( form && !form._submit_attached ) { moel@348: jQuery.event.add( form, "submit._submit", function( event ) { moel@348: event._submit_bubble = true; moel@348: }); moel@348: form._submit_attached = true; moel@348: } moel@348: }); moel@348: // return undefined since we don't need an event listener moel@348: }, moel@348: moel@348: postDispatch: function( event ) { moel@348: // If form was submitted by the user, bubble the event up the tree moel@348: if ( event._submit_bubble ) { moel@348: delete event._submit_bubble; moel@348: if ( this.parentNode && !event.isTrigger ) { moel@348: jQuery.event.simulate( "submit", this.parentNode, event, true ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: teardown: function() { moel@348: // Only need this for delegated form submit events moel@348: if ( jQuery.nodeName( this, "form" ) ) { moel@348: return false; moel@348: } moel@348: moel@348: // Remove delegated handlers; cleanData eventually reaps submit handlers attached above moel@348: jQuery.event.remove( this, "._submit" ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // IE change delegation and checkbox/radio fix moel@348: if ( !jQuery.support.changeBubbles ) { moel@348: moel@348: jQuery.event.special.change = { moel@348: moel@348: setup: function() { moel@348: moel@348: if ( rformElems.test( this.nodeName ) ) { moel@348: // IE doesn't fire change on a check/radio until blur; trigger it on click moel@348: // after a propertychange. Eat the blur-change in special.change.handle. moel@348: // This still fires onchange a second time for check/radio after blur. moel@348: if ( this.type === "checkbox" || this.type === "radio" ) { moel@348: jQuery.event.add( this, "propertychange._change", function( event ) { moel@348: if ( event.originalEvent.propertyName === "checked" ) { moel@348: this._just_changed = true; moel@348: } moel@348: }); moel@348: jQuery.event.add( this, "click._change", function( event ) { moel@348: if ( this._just_changed && !event.isTrigger ) { moel@348: this._just_changed = false; moel@348: jQuery.event.simulate( "change", this, event, true ); moel@348: } moel@348: }); moel@348: } moel@348: return false; moel@348: } moel@348: // Delegated event; lazy-add a change handler on descendant inputs moel@348: jQuery.event.add( this, "beforeactivate._change", function( e ) { moel@348: var elem = e.target; moel@348: moel@348: if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { moel@348: jQuery.event.add( elem, "change._change", function( event ) { moel@348: if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { moel@348: jQuery.event.simulate( "change", this.parentNode, event, true ); moel@348: } moel@348: }); moel@348: elem._change_attached = true; moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: handle: function( event ) { moel@348: var elem = event.target; moel@348: moel@348: // Swallow native change events from checkbox/radio, we already triggered them above moel@348: if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { moel@348: return event.handleObj.handler.apply( this, arguments ); moel@348: } moel@348: }, moel@348: moel@348: teardown: function() { moel@348: jQuery.event.remove( this, "._change" ); moel@348: moel@348: return rformElems.test( this.nodeName ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // Create "bubbling" focus and blur events moel@348: if ( !jQuery.support.focusinBubbles ) { moel@348: jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { moel@348: moel@348: // Attach a single capturing handler while someone wants focusin/focusout moel@348: var attaches = 0, moel@348: handler = function( event ) { moel@348: jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); moel@348: }; moel@348: moel@348: jQuery.event.special[ fix ] = { moel@348: setup: function() { moel@348: if ( attaches++ === 0 ) { moel@348: document.addEventListener( orig, handler, true ); moel@348: } moel@348: }, moel@348: teardown: function() { moel@348: if ( --attaches === 0 ) { moel@348: document.removeEventListener( orig, handler, true ); moel@348: } moel@348: } moel@348: }; moel@348: }); moel@348: } moel@348: moel@348: jQuery.fn.extend({ moel@348: moel@348: on: function( types, selector, data, fn, /*INTERNAL*/ one ) { moel@348: var origFn, type; moel@348: moel@348: // Types can be a map of types/handlers moel@348: if ( typeof types === "object" ) { moel@348: // ( types-Object, selector, data ) moel@348: if ( typeof selector !== "string" ) { // && selector != null moel@348: // ( types-Object, data ) moel@348: data = data || selector; moel@348: selector = undefined; moel@348: } moel@348: for ( type in types ) { moel@348: this.on( type, selector, data, types[ type ], one ); moel@348: } moel@348: return this; moel@348: } moel@348: moel@348: if ( data == null && fn == null ) { moel@348: // ( types, fn ) moel@348: fn = selector; moel@348: data = selector = undefined; moel@348: } else if ( fn == null ) { moel@348: if ( typeof selector === "string" ) { moel@348: // ( types, selector, fn ) moel@348: fn = data; moel@348: data = undefined; moel@348: } else { moel@348: // ( types, data, fn ) moel@348: fn = data; moel@348: data = selector; moel@348: selector = undefined; moel@348: } moel@348: } moel@348: if ( fn === false ) { moel@348: fn = returnFalse; moel@348: } else if ( !fn ) { moel@348: return this; moel@348: } moel@348: moel@348: if ( one === 1 ) { moel@348: origFn = fn; moel@348: fn = function( event ) { moel@348: // Can use an empty set, since event contains the info moel@348: jQuery().off( event ); moel@348: return origFn.apply( this, arguments ); moel@348: }; moel@348: // Use same guid so caller can remove using origFn moel@348: fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); moel@348: } moel@348: return this.each( function() { moel@348: jQuery.event.add( this, types, fn, data, selector ); moel@348: }); moel@348: }, moel@348: one: function( types, selector, data, fn ) { moel@348: return this.on( types, selector, data, fn, 1 ); moel@348: }, moel@348: off: function( types, selector, fn ) { moel@348: if ( types && types.preventDefault && types.handleObj ) { moel@348: // ( event ) dispatched jQuery.Event moel@348: var handleObj = types.handleObj; moel@348: jQuery( types.delegateTarget ).off( moel@348: handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, moel@348: handleObj.selector, moel@348: handleObj.handler moel@348: ); moel@348: return this; moel@348: } moel@348: if ( typeof types === "object" ) { moel@348: // ( types-object [, selector] ) moel@348: for ( var type in types ) { moel@348: this.off( type, selector, types[ type ] ); moel@348: } moel@348: return this; moel@348: } moel@348: if ( selector === false || typeof selector === "function" ) { moel@348: // ( types [, fn] ) moel@348: fn = selector; moel@348: selector = undefined; moel@348: } moel@348: if ( fn === false ) { moel@348: fn = returnFalse; moel@348: } moel@348: return this.each(function() { moel@348: jQuery.event.remove( this, types, fn, selector ); moel@348: }); moel@348: }, moel@348: moel@348: bind: function( types, data, fn ) { moel@348: return this.on( types, null, data, fn ); moel@348: }, moel@348: unbind: function( types, fn ) { moel@348: return this.off( types, null, fn ); moel@348: }, moel@348: moel@348: live: function( types, data, fn ) { moel@348: jQuery( this.context ).on( types, this.selector, data, fn ); moel@348: return this; moel@348: }, moel@348: die: function( types, fn ) { moel@348: jQuery( this.context ).off( types, this.selector || "**", fn ); moel@348: return this; moel@348: }, moel@348: moel@348: delegate: function( selector, types, data, fn ) { moel@348: return this.on( types, selector, data, fn ); moel@348: }, moel@348: undelegate: function( selector, types, fn ) { moel@348: // ( namespace ) or ( selector, types [, fn] ) moel@348: return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); moel@348: }, moel@348: moel@348: trigger: function( type, data ) { moel@348: return this.each(function() { moel@348: jQuery.event.trigger( type, data, this ); moel@348: }); moel@348: }, moel@348: triggerHandler: function( type, data ) { moel@348: if ( this[0] ) { moel@348: return jQuery.event.trigger( type, data, this[0], true ); moel@348: } moel@348: }, moel@348: moel@348: toggle: function( fn ) { moel@348: // Save reference to arguments for access in closure moel@348: var args = arguments, moel@348: guid = fn.guid || jQuery.guid++, moel@348: i = 0, moel@348: toggler = function( event ) { moel@348: // Figure out which function to execute moel@348: var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; moel@348: jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); moel@348: moel@348: // Make sure that clicks stop moel@348: event.preventDefault(); moel@348: moel@348: // and execute the function moel@348: return args[ lastToggle ].apply( this, arguments ) || false; moel@348: }; moel@348: moel@348: // link all the functions, so any of them can unbind this click handler moel@348: toggler.guid = guid; moel@348: while ( i < args.length ) { moel@348: args[ i++ ].guid = guid; moel@348: } moel@348: moel@348: return this.click( toggler ); moel@348: }, moel@348: moel@348: hover: function( fnOver, fnOut ) { moel@348: return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); moel@348: } moel@348: }); moel@348: moel@348: jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + moel@348: "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + moel@348: "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { moel@348: moel@348: // Handle event binding moel@348: jQuery.fn[ name ] = function( data, fn ) { moel@348: if ( fn == null ) { moel@348: fn = data; moel@348: data = null; moel@348: } moel@348: moel@348: return arguments.length > 0 ? moel@348: this.on( name, null, data, fn ) : moel@348: this.trigger( name ); moel@348: }; moel@348: moel@348: if ( jQuery.attrFn ) { moel@348: jQuery.attrFn[ name ] = true; moel@348: } moel@348: moel@348: if ( rkeyEvent.test( name ) ) { moel@348: jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; moel@348: } moel@348: moel@348: if ( rmouseEvent.test( name ) ) { moel@348: jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: /*! moel@348: * Sizzle CSS Selector Engine moel@348: * Copyright 2011, The Dojo Foundation moel@348: * Released under the MIT, BSD, and GPL Licenses. moel@348: * More information: http://sizzlejs.com/ moel@348: */ moel@348: (function(){ moel@348: moel@348: var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, moel@348: expando = "sizcache" + (Math.random() + '').replace('.', ''), moel@348: done = 0, moel@348: toString = Object.prototype.toString, moel@348: hasDuplicate = false, moel@348: baseHasDuplicate = true, moel@348: rBackslash = /\\/g, moel@348: rReturn = /\r\n/g, moel@348: rNonWord = /\W/; moel@348: moel@348: // Here we check if the JavaScript engine is using some sort of moel@348: // optimization where it does not always call our comparision moel@348: // function. If that is the case, discard the hasDuplicate value. moel@348: // Thus far that includes Google Chrome. moel@348: [0, 0].sort(function() { moel@348: baseHasDuplicate = false; moel@348: return 0; moel@348: }); moel@348: moel@348: var Sizzle = function( selector, context, results, seed ) { moel@348: results = results || []; moel@348: context = context || document; moel@348: moel@348: var origContext = context; moel@348: moel@348: if ( context.nodeType !== 1 && context.nodeType !== 9 ) { moel@348: return []; moel@348: } moel@348: moel@348: if ( !selector || typeof selector !== "string" ) { moel@348: return results; moel@348: } moel@348: moel@348: var m, set, checkSet, extra, ret, cur, pop, i, moel@348: prune = true, moel@348: contextXML = Sizzle.isXML( context ), moel@348: parts = [], moel@348: soFar = selector; moel@348: moel@348: // Reset the position of the chunker regexp (start from head) moel@348: do { moel@348: chunker.exec( "" ); moel@348: m = chunker.exec( soFar ); moel@348: moel@348: if ( m ) { moel@348: soFar = m[3]; moel@348: moel@348: parts.push( m[1] ); moel@348: moel@348: if ( m[2] ) { moel@348: extra = m[3]; moel@348: break; moel@348: } moel@348: } moel@348: } while ( m ); moel@348: moel@348: if ( parts.length > 1 && origPOS.exec( selector ) ) { moel@348: moel@348: if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { moel@348: set = posProcess( parts[0] + parts[1], context, seed ); moel@348: moel@348: } else { moel@348: set = Expr.relative[ parts[0] ] ? moel@348: [ context ] : moel@348: Sizzle( parts.shift(), context ); moel@348: moel@348: while ( parts.length ) { moel@348: selector = parts.shift(); moel@348: moel@348: if ( Expr.relative[ selector ] ) { moel@348: selector += parts.shift(); moel@348: } moel@348: moel@348: set = posProcess( selector, set, seed ); moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: // Take a shortcut and set the context if the root selector is an ID moel@348: // (but not if it'll be faster if the inner selector is an ID) moel@348: if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && moel@348: Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { moel@348: moel@348: ret = Sizzle.find( parts.shift(), context, contextXML ); moel@348: context = ret.expr ? moel@348: Sizzle.filter( ret.expr, ret.set )[0] : moel@348: ret.set[0]; moel@348: } moel@348: moel@348: if ( context ) { moel@348: ret = seed ? moel@348: { expr: parts.pop(), set: makeArray(seed) } : moel@348: Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); moel@348: moel@348: set = ret.expr ? moel@348: Sizzle.filter( ret.expr, ret.set ) : moel@348: ret.set; moel@348: moel@348: if ( parts.length > 0 ) { moel@348: checkSet = makeArray( set ); moel@348: moel@348: } else { moel@348: prune = false; moel@348: } moel@348: moel@348: while ( parts.length ) { moel@348: cur = parts.pop(); moel@348: pop = cur; moel@348: moel@348: if ( !Expr.relative[ cur ] ) { moel@348: cur = ""; moel@348: } else { moel@348: pop = parts.pop(); moel@348: } moel@348: moel@348: if ( pop == null ) { moel@348: pop = context; moel@348: } moel@348: moel@348: Expr.relative[ cur ]( checkSet, pop, contextXML ); moel@348: } moel@348: moel@348: } else { moel@348: checkSet = parts = []; moel@348: } moel@348: } moel@348: moel@348: if ( !checkSet ) { moel@348: checkSet = set; moel@348: } moel@348: moel@348: if ( !checkSet ) { moel@348: Sizzle.error( cur || selector ); moel@348: } moel@348: moel@348: if ( toString.call(checkSet) === "[object Array]" ) { moel@348: if ( !prune ) { moel@348: results.push.apply( results, checkSet ); moel@348: moel@348: } else if ( context && context.nodeType === 1 ) { moel@348: for ( i = 0; checkSet[i] != null; i++ ) { moel@348: if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { moel@348: results.push( set[i] ); moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: for ( i = 0; checkSet[i] != null; i++ ) { moel@348: if ( checkSet[i] && checkSet[i].nodeType === 1 ) { moel@348: results.push( set[i] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: makeArray( checkSet, results ); moel@348: } moel@348: moel@348: if ( extra ) { moel@348: Sizzle( extra, origContext, results, seed ); moel@348: Sizzle.uniqueSort( results ); moel@348: } moel@348: moel@348: return results; moel@348: }; moel@348: moel@348: Sizzle.uniqueSort = function( results ) { moel@348: if ( sortOrder ) { moel@348: hasDuplicate = baseHasDuplicate; moel@348: results.sort( sortOrder ); moel@348: moel@348: if ( hasDuplicate ) { moel@348: for ( var i = 1; i < results.length; i++ ) { moel@348: if ( results[i] === results[ i - 1 ] ) { moel@348: results.splice( i--, 1 ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return results; moel@348: }; moel@348: moel@348: Sizzle.matches = function( expr, set ) { moel@348: return Sizzle( expr, null, null, set ); moel@348: }; moel@348: moel@348: Sizzle.matchesSelector = function( node, expr ) { moel@348: return Sizzle( expr, null, null, [node] ).length > 0; moel@348: }; moel@348: moel@348: Sizzle.find = function( expr, context, isXML ) { moel@348: var set, i, len, match, type, left; moel@348: moel@348: if ( !expr ) { moel@348: return []; moel@348: } moel@348: moel@348: for ( i = 0, len = Expr.order.length; i < len; i++ ) { moel@348: type = Expr.order[i]; moel@348: moel@348: if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { moel@348: left = match[1]; moel@348: match.splice( 1, 1 ); moel@348: moel@348: if ( left.substr( left.length - 1 ) !== "\\" ) { moel@348: match[1] = (match[1] || "").replace( rBackslash, "" ); moel@348: set = Expr.find[ type ]( match, context, isXML ); moel@348: moel@348: if ( set != null ) { moel@348: expr = expr.replace( Expr.match[ type ], "" ); moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( !set ) { moel@348: set = typeof context.getElementsByTagName !== "undefined" ? moel@348: context.getElementsByTagName( "*" ) : moel@348: []; moel@348: } moel@348: moel@348: return { set: set, expr: expr }; moel@348: }; moel@348: moel@348: Sizzle.filter = function( expr, set, inplace, not ) { moel@348: var match, anyFound, moel@348: type, found, item, filter, left, moel@348: i, pass, moel@348: old = expr, moel@348: result = [], moel@348: curLoop = set, moel@348: isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); moel@348: moel@348: while ( expr && set.length ) { moel@348: for ( type in Expr.filter ) { moel@348: if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { moel@348: filter = Expr.filter[ type ]; moel@348: left = match[1]; moel@348: moel@348: anyFound = false; moel@348: moel@348: match.splice(1,1); moel@348: moel@348: if ( left.substr( left.length - 1 ) === "\\" ) { moel@348: continue; moel@348: } moel@348: moel@348: if ( curLoop === result ) { moel@348: result = []; moel@348: } moel@348: moel@348: if ( Expr.preFilter[ type ] ) { moel@348: match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); moel@348: moel@348: if ( !match ) { moel@348: anyFound = found = true; moel@348: moel@348: } else if ( match === true ) { moel@348: continue; moel@348: } moel@348: } moel@348: moel@348: if ( match ) { moel@348: for ( i = 0; (item = curLoop[i]) != null; i++ ) { moel@348: if ( item ) { moel@348: found = filter( item, match, i, curLoop ); moel@348: pass = not ^ found; moel@348: moel@348: if ( inplace && found != null ) { moel@348: if ( pass ) { moel@348: anyFound = true; moel@348: moel@348: } else { moel@348: curLoop[i] = false; moel@348: } moel@348: moel@348: } else if ( pass ) { moel@348: result.push( item ); moel@348: anyFound = true; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( found !== undefined ) { moel@348: if ( !inplace ) { moel@348: curLoop = result; moel@348: } moel@348: moel@348: expr = expr.replace( Expr.match[ type ], "" ); moel@348: moel@348: if ( !anyFound ) { moel@348: return []; moel@348: } moel@348: moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Improper expression moel@348: if ( expr === old ) { moel@348: if ( anyFound == null ) { moel@348: Sizzle.error( expr ); moel@348: moel@348: } else { moel@348: break; moel@348: } moel@348: } moel@348: moel@348: old = expr; moel@348: } moel@348: moel@348: return curLoop; moel@348: }; moel@348: moel@348: Sizzle.error = function( msg ) { moel@348: throw new Error( "Syntax error, unrecognized expression: " + msg ); moel@348: }; moel@348: moel@348: /** moel@348: * Utility function for retreiving the text value of an array of DOM nodes moel@348: * @param {Array|Element} elem moel@348: */ moel@348: var getText = Sizzle.getText = function( elem ) { moel@348: var i, node, moel@348: nodeType = elem.nodeType, moel@348: ret = ""; moel@348: moel@348: if ( nodeType ) { moel@348: if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { moel@348: // Use textContent || innerText for elements moel@348: if ( typeof elem.textContent === 'string' ) { moel@348: return elem.textContent; moel@348: } else if ( typeof elem.innerText === 'string' ) { moel@348: // Replace IE's carriage returns moel@348: return elem.innerText.replace( rReturn, '' ); moel@348: } else { moel@348: // Traverse it's children moel@348: for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { moel@348: ret += getText( elem ); moel@348: } moel@348: } moel@348: } else if ( nodeType === 3 || nodeType === 4 ) { moel@348: return elem.nodeValue; moel@348: } moel@348: } else { moel@348: moel@348: // If no nodeType, this is expected to be an array moel@348: for ( i = 0; (node = elem[i]); i++ ) { moel@348: // Do not traverse comment nodes moel@348: if ( node.nodeType !== 8 ) { moel@348: ret += getText( node ); moel@348: } moel@348: } moel@348: } moel@348: return ret; moel@348: }; moel@348: moel@348: var Expr = Sizzle.selectors = { moel@348: order: [ "ID", "NAME", "TAG" ], moel@348: moel@348: match: { moel@348: ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, moel@348: CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, moel@348: NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, moel@348: ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, moel@348: TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, moel@348: CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, moel@348: POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, moel@348: PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ moel@348: }, moel@348: moel@348: leftMatch: {}, moel@348: moel@348: attrMap: { moel@348: "class": "className", moel@348: "for": "htmlFor" moel@348: }, moel@348: moel@348: attrHandle: { moel@348: href: function( elem ) { moel@348: return elem.getAttribute( "href" ); moel@348: }, moel@348: type: function( elem ) { moel@348: return elem.getAttribute( "type" ); moel@348: } moel@348: }, moel@348: moel@348: relative: { moel@348: "+": function(checkSet, part){ moel@348: var isPartStr = typeof part === "string", moel@348: isTag = isPartStr && !rNonWord.test( part ), moel@348: isPartStrNotTag = isPartStr && !isTag; moel@348: moel@348: if ( isTag ) { moel@348: part = part.toLowerCase(); moel@348: } moel@348: moel@348: for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { moel@348: if ( (elem = checkSet[i]) ) { moel@348: while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} moel@348: moel@348: checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? moel@348: elem || false : moel@348: elem === part; moel@348: } moel@348: } moel@348: moel@348: if ( isPartStrNotTag ) { moel@348: Sizzle.filter( part, checkSet, true ); moel@348: } moel@348: }, moel@348: moel@348: ">": function( checkSet, part ) { moel@348: var elem, moel@348: isPartStr = typeof part === "string", moel@348: i = 0, moel@348: l = checkSet.length; moel@348: moel@348: if ( isPartStr && !rNonWord.test( part ) ) { moel@348: part = part.toLowerCase(); moel@348: moel@348: for ( ; i < l; i++ ) { moel@348: elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: var parent = elem.parentNode; moel@348: checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: for ( ; i < l; i++ ) { moel@348: elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: checkSet[i] = isPartStr ? moel@348: elem.parentNode : moel@348: elem.parentNode === part; moel@348: } moel@348: } moel@348: moel@348: if ( isPartStr ) { moel@348: Sizzle.filter( part, checkSet, true ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: "": function(checkSet, part, isXML){ moel@348: var nodeCheck, moel@348: doneName = done++, moel@348: checkFn = dirCheck; moel@348: moel@348: if ( typeof part === "string" && !rNonWord.test( part ) ) { moel@348: part = part.toLowerCase(); moel@348: nodeCheck = part; moel@348: checkFn = dirNodeCheck; moel@348: } moel@348: moel@348: checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); moel@348: }, moel@348: moel@348: "~": function( checkSet, part, isXML ) { moel@348: var nodeCheck, moel@348: doneName = done++, moel@348: checkFn = dirCheck; moel@348: moel@348: if ( typeof part === "string" && !rNonWord.test( part ) ) { moel@348: part = part.toLowerCase(); moel@348: nodeCheck = part; moel@348: checkFn = dirNodeCheck; moel@348: } moel@348: moel@348: checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); moel@348: } moel@348: }, moel@348: moel@348: find: { moel@348: ID: function( match, context, isXML ) { moel@348: if ( typeof context.getElementById !== "undefined" && !isXML ) { moel@348: var m = context.getElementById(match[1]); moel@348: // Check parentNode to catch when Blackberry 4.6 returns moel@348: // nodes that are no longer in the document #6963 moel@348: return m && m.parentNode ? [m] : []; moel@348: } moel@348: }, moel@348: moel@348: NAME: function( match, context ) { moel@348: if ( typeof context.getElementsByName !== "undefined" ) { moel@348: var ret = [], moel@348: results = context.getElementsByName( match[1] ); moel@348: moel@348: for ( var i = 0, l = results.length; i < l; i++ ) { moel@348: if ( results[i].getAttribute("name") === match[1] ) { moel@348: ret.push( results[i] ); moel@348: } moel@348: } moel@348: moel@348: return ret.length === 0 ? null : ret; moel@348: } moel@348: }, moel@348: moel@348: TAG: function( match, context ) { moel@348: if ( typeof context.getElementsByTagName !== "undefined" ) { moel@348: return context.getElementsByTagName( match[1] ); moel@348: } moel@348: } moel@348: }, moel@348: preFilter: { moel@348: CLASS: function( match, curLoop, inplace, result, not, isXML ) { moel@348: match = " " + match[1].replace( rBackslash, "" ) + " "; moel@348: moel@348: if ( isXML ) { moel@348: return match; moel@348: } moel@348: moel@348: for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { moel@348: if ( elem ) { moel@348: if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { moel@348: if ( !inplace ) { moel@348: result.push( elem ); moel@348: } moel@348: moel@348: } else if ( inplace ) { moel@348: curLoop[i] = false; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return false; moel@348: }, moel@348: moel@348: ID: function( match ) { moel@348: return match[1].replace( rBackslash, "" ); moel@348: }, moel@348: moel@348: TAG: function( match, curLoop ) { moel@348: return match[1].replace( rBackslash, "" ).toLowerCase(); moel@348: }, moel@348: moel@348: CHILD: function( match ) { moel@348: if ( match[1] === "nth" ) { moel@348: if ( !match[2] ) { moel@348: Sizzle.error( match[0] ); moel@348: } moel@348: moel@348: match[2] = match[2].replace(/^\+|\s*/g, ''); moel@348: moel@348: // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' moel@348: var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( moel@348: match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || moel@348: !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); moel@348: moel@348: // calculate the numbers (first)n+(last) including if they are negative moel@348: match[2] = (test[1] + (test[2] || 1)) - 0; moel@348: match[3] = test[3] - 0; moel@348: } moel@348: else if ( match[2] ) { moel@348: Sizzle.error( match[0] ); moel@348: } moel@348: moel@348: // TODO: Move to normal caching system moel@348: match[0] = done++; moel@348: moel@348: return match; moel@348: }, moel@348: moel@348: ATTR: function( match, curLoop, inplace, result, not, isXML ) { moel@348: var name = match[1] = match[1].replace( rBackslash, "" ); moel@348: moel@348: if ( !isXML && Expr.attrMap[name] ) { moel@348: match[1] = Expr.attrMap[name]; moel@348: } moel@348: moel@348: // Handle if an un-quoted value was used moel@348: match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); moel@348: moel@348: if ( match[2] === "~=" ) { moel@348: match[4] = " " + match[4] + " "; moel@348: } moel@348: moel@348: return match; moel@348: }, moel@348: moel@348: PSEUDO: function( match, curLoop, inplace, result, not ) { moel@348: if ( match[1] === "not" ) { moel@348: // If we're dealing with a complex expression, or a simple one moel@348: if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { moel@348: match[3] = Sizzle(match[3], null, null, curLoop); moel@348: moel@348: } else { moel@348: var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); moel@348: moel@348: if ( !inplace ) { moel@348: result.push.apply( result, ret ); moel@348: } moel@348: moel@348: return false; moel@348: } moel@348: moel@348: } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { moel@348: return true; moel@348: } moel@348: moel@348: return match; moel@348: }, moel@348: moel@348: POS: function( match ) { moel@348: match.unshift( true ); moel@348: moel@348: return match; moel@348: } moel@348: }, moel@348: moel@348: filters: { moel@348: enabled: function( elem ) { moel@348: return elem.disabled === false && elem.type !== "hidden"; moel@348: }, moel@348: moel@348: disabled: function( elem ) { moel@348: return elem.disabled === true; moel@348: }, moel@348: moel@348: checked: function( elem ) { moel@348: return elem.checked === true; moel@348: }, moel@348: moel@348: selected: function( elem ) { moel@348: // Accessing this property makes selected-by-default moel@348: // options in Safari work properly moel@348: if ( elem.parentNode ) { moel@348: elem.parentNode.selectedIndex; moel@348: } moel@348: moel@348: return elem.selected === true; moel@348: }, moel@348: moel@348: parent: function( elem ) { moel@348: return !!elem.firstChild; moel@348: }, moel@348: moel@348: empty: function( elem ) { moel@348: return !elem.firstChild; moel@348: }, moel@348: moel@348: has: function( elem, i, match ) { moel@348: return !!Sizzle( match[3], elem ).length; moel@348: }, moel@348: moel@348: header: function( elem ) { moel@348: return (/h\d/i).test( elem.nodeName ); moel@348: }, moel@348: moel@348: text: function( elem ) { moel@348: var attr = elem.getAttribute( "type" ), type = elem.type; moel@348: // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) moel@348: // use getAttribute instead to test this case moel@348: return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); moel@348: }, moel@348: moel@348: radio: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; moel@348: }, moel@348: moel@348: checkbox: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; moel@348: }, moel@348: moel@348: file: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; moel@348: }, moel@348: moel@348: password: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; moel@348: }, moel@348: moel@348: submit: function( elem ) { moel@348: var name = elem.nodeName.toLowerCase(); moel@348: return (name === "input" || name === "button") && "submit" === elem.type; moel@348: }, moel@348: moel@348: image: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; moel@348: }, moel@348: moel@348: reset: function( elem ) { moel@348: var name = elem.nodeName.toLowerCase(); moel@348: return (name === "input" || name === "button") && "reset" === elem.type; moel@348: }, moel@348: moel@348: button: function( elem ) { moel@348: var name = elem.nodeName.toLowerCase(); moel@348: return name === "input" && "button" === elem.type || name === "button"; moel@348: }, moel@348: moel@348: input: function( elem ) { moel@348: return (/input|select|textarea|button/i).test( elem.nodeName ); moel@348: }, moel@348: moel@348: focus: function( elem ) { moel@348: return elem === elem.ownerDocument.activeElement; moel@348: } moel@348: }, moel@348: setFilters: { moel@348: first: function( elem, i ) { moel@348: return i === 0; moel@348: }, moel@348: moel@348: last: function( elem, i, match, array ) { moel@348: return i === array.length - 1; moel@348: }, moel@348: moel@348: even: function( elem, i ) { moel@348: return i % 2 === 0; moel@348: }, moel@348: moel@348: odd: function( elem, i ) { moel@348: return i % 2 === 1; moel@348: }, moel@348: moel@348: lt: function( elem, i, match ) { moel@348: return i < match[3] - 0; moel@348: }, moel@348: moel@348: gt: function( elem, i, match ) { moel@348: return i > match[3] - 0; moel@348: }, moel@348: moel@348: nth: function( elem, i, match ) { moel@348: return match[3] - 0 === i; moel@348: }, moel@348: moel@348: eq: function( elem, i, match ) { moel@348: return match[3] - 0 === i; moel@348: } moel@348: }, moel@348: filter: { moel@348: PSEUDO: function( elem, match, i, array ) { moel@348: var name = match[1], moel@348: filter = Expr.filters[ name ]; moel@348: moel@348: if ( filter ) { moel@348: return filter( elem, i, match, array ); moel@348: moel@348: } else if ( name === "contains" ) { moel@348: return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; moel@348: moel@348: } else if ( name === "not" ) { moel@348: var not = match[3]; moel@348: moel@348: for ( var j = 0, l = not.length; j < l; j++ ) { moel@348: if ( not[j] === elem ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: moel@348: } else { moel@348: Sizzle.error( name ); moel@348: } moel@348: }, moel@348: moel@348: CHILD: function( elem, match ) { moel@348: var first, last, moel@348: doneName, parent, cache, moel@348: count, diff, moel@348: type = match[1], moel@348: node = elem; moel@348: moel@348: switch ( type ) { moel@348: case "only": moel@348: case "first": moel@348: while ( (node = node.previousSibling) ) { moel@348: if ( node.nodeType === 1 ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: if ( type === "first" ) { moel@348: return true; moel@348: } moel@348: moel@348: node = elem; moel@348: moel@348: /* falls through */ moel@348: case "last": moel@348: while ( (node = node.nextSibling) ) { moel@348: if ( node.nodeType === 1 ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: moel@348: case "nth": moel@348: first = match[2]; moel@348: last = match[3]; moel@348: moel@348: if ( first === 1 && last === 0 ) { moel@348: return true; moel@348: } moel@348: moel@348: doneName = match[0]; moel@348: parent = elem.parentNode; moel@348: moel@348: if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { moel@348: count = 0; moel@348: moel@348: for ( node = parent.firstChild; node; node = node.nextSibling ) { moel@348: if ( node.nodeType === 1 ) { moel@348: node.nodeIndex = ++count; moel@348: } moel@348: } moel@348: moel@348: parent[ expando ] = doneName; moel@348: } moel@348: moel@348: diff = elem.nodeIndex - last; moel@348: moel@348: if ( first === 0 ) { moel@348: return diff === 0; moel@348: moel@348: } else { moel@348: return ( diff % first === 0 && diff / first >= 0 ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: ID: function( elem, match ) { moel@348: return elem.nodeType === 1 && elem.getAttribute("id") === match; moel@348: }, moel@348: moel@348: TAG: function( elem, match ) { moel@348: return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; moel@348: }, moel@348: moel@348: CLASS: function( elem, match ) { moel@348: return (" " + (elem.className || elem.getAttribute("class")) + " ") moel@348: .indexOf( match ) > -1; moel@348: }, moel@348: moel@348: ATTR: function( elem, match ) { moel@348: var name = match[1], moel@348: result = Sizzle.attr ? moel@348: Sizzle.attr( elem, name ) : moel@348: Expr.attrHandle[ name ] ? moel@348: Expr.attrHandle[ name ]( elem ) : moel@348: elem[ name ] != null ? moel@348: elem[ name ] : moel@348: elem.getAttribute( name ), moel@348: value = result + "", moel@348: type = match[2], moel@348: check = match[4]; moel@348: moel@348: return result == null ? moel@348: type === "!=" : moel@348: !type && Sizzle.attr ? moel@348: result != null : moel@348: type === "=" ? moel@348: value === check : moel@348: type === "*=" ? moel@348: value.indexOf(check) >= 0 : moel@348: type === "~=" ? moel@348: (" " + value + " ").indexOf(check) >= 0 : moel@348: !check ? moel@348: value && result !== false : moel@348: type === "!=" ? moel@348: value !== check : moel@348: type === "^=" ? moel@348: value.indexOf(check) === 0 : moel@348: type === "$=" ? moel@348: value.substr(value.length - check.length) === check : moel@348: type === "|=" ? moel@348: value === check || value.substr(0, check.length + 1) === check + "-" : moel@348: false; moel@348: }, moel@348: moel@348: POS: function( elem, match, i, array ) { moel@348: var name = match[2], moel@348: filter = Expr.setFilters[ name ]; moel@348: moel@348: if ( filter ) { moel@348: return filter( elem, i, match, array ); moel@348: } moel@348: } moel@348: } moel@348: }; moel@348: moel@348: var origPOS = Expr.match.POS, moel@348: fescape = function(all, num){ moel@348: return "\\" + (num - 0 + 1); moel@348: }; moel@348: moel@348: for ( var type in Expr.match ) { moel@348: Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); moel@348: Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); moel@348: } moel@348: // Expose origPOS moel@348: // "global" as in regardless of relation to brackets/parens moel@348: Expr.match.globalPOS = origPOS; moel@348: moel@348: var makeArray = function( array, results ) { moel@348: array = Array.prototype.slice.call( array, 0 ); moel@348: moel@348: if ( results ) { moel@348: results.push.apply( results, array ); moel@348: return results; moel@348: } moel@348: moel@348: return array; moel@348: }; moel@348: moel@348: // Perform a simple check to determine if the browser is capable of moel@348: // converting a NodeList to an array using builtin methods. moel@348: // Also verifies that the returned array holds DOM nodes moel@348: // (which is not the case in the Blackberry browser) moel@348: try { moel@348: Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; moel@348: moel@348: // Provide a fallback method if it does not work moel@348: } catch( e ) { moel@348: makeArray = function( array, results ) { moel@348: var i = 0, moel@348: ret = results || []; moel@348: moel@348: if ( toString.call(array) === "[object Array]" ) { moel@348: Array.prototype.push.apply( ret, array ); moel@348: moel@348: } else { moel@348: if ( typeof array.length === "number" ) { moel@348: for ( var l = array.length; i < l; i++ ) { moel@348: ret.push( array[i] ); moel@348: } moel@348: moel@348: } else { moel@348: for ( ; array[i]; i++ ) { moel@348: ret.push( array[i] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }; moel@348: } moel@348: moel@348: var sortOrder, siblingCheck; moel@348: moel@348: if ( document.documentElement.compareDocumentPosition ) { moel@348: sortOrder = function( a, b ) { moel@348: if ( a === b ) { moel@348: hasDuplicate = true; moel@348: return 0; moel@348: } moel@348: moel@348: if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { moel@348: return a.compareDocumentPosition ? -1 : 1; moel@348: } moel@348: moel@348: return a.compareDocumentPosition(b) & 4 ? -1 : 1; moel@348: }; moel@348: moel@348: } else { moel@348: sortOrder = function( a, b ) { moel@348: // The nodes are identical, we can exit early moel@348: if ( a === b ) { moel@348: hasDuplicate = true; moel@348: return 0; moel@348: moel@348: // Fallback to using sourceIndex (in IE) if it's available on both nodes moel@348: } else if ( a.sourceIndex && b.sourceIndex ) { moel@348: return a.sourceIndex - b.sourceIndex; moel@348: } moel@348: moel@348: var al, bl, moel@348: ap = [], moel@348: bp = [], moel@348: aup = a.parentNode, moel@348: bup = b.parentNode, moel@348: cur = aup; moel@348: moel@348: // If the nodes are siblings (or identical) we can do a quick check moel@348: if ( aup === bup ) { moel@348: return siblingCheck( a, b ); moel@348: moel@348: // If no parents were found then the nodes are disconnected moel@348: } else if ( !aup ) { moel@348: return -1; moel@348: moel@348: } else if ( !bup ) { moel@348: return 1; moel@348: } moel@348: moel@348: // Otherwise they're somewhere else in the tree so we need moel@348: // to build up a full list of the parentNodes for comparison moel@348: while ( cur ) { moel@348: ap.unshift( cur ); moel@348: cur = cur.parentNode; moel@348: } moel@348: moel@348: cur = bup; moel@348: moel@348: while ( cur ) { moel@348: bp.unshift( cur ); moel@348: cur = cur.parentNode; moel@348: } moel@348: moel@348: al = ap.length; moel@348: bl = bp.length; moel@348: moel@348: // Start walking down the tree looking for a discrepancy moel@348: for ( var i = 0; i < al && i < bl; i++ ) { moel@348: if ( ap[i] !== bp[i] ) { moel@348: return siblingCheck( ap[i], bp[i] ); moel@348: } moel@348: } moel@348: moel@348: // We ended someplace up the tree so do a sibling check moel@348: return i === al ? moel@348: siblingCheck( a, bp[i], -1 ) : moel@348: siblingCheck( ap[i], b, 1 ); moel@348: }; moel@348: moel@348: siblingCheck = function( a, b, ret ) { moel@348: if ( a === b ) { moel@348: return ret; moel@348: } moel@348: moel@348: var cur = a.nextSibling; moel@348: moel@348: while ( cur ) { moel@348: if ( cur === b ) { moel@348: return -1; moel@348: } moel@348: moel@348: cur = cur.nextSibling; moel@348: } moel@348: moel@348: return 1; moel@348: }; moel@348: } moel@348: moel@348: // Check to see if the browser returns elements by name when moel@348: // querying by getElementById (and provide a workaround) moel@348: (function(){ moel@348: // We're going to inject a fake input element with a specified name moel@348: var form = document.createElement("div"), moel@348: id = "script" + (new Date()).getTime(), moel@348: root = document.documentElement; moel@348: moel@348: form.innerHTML = ""; moel@348: moel@348: // Inject it into the root element, check its status, and remove it quickly moel@348: root.insertBefore( form, root.firstChild ); moel@348: moel@348: // The workaround has to do additional checks after a getElementById moel@348: // Which slows things down for other browsers (hence the branching) moel@348: if ( document.getElementById( id ) ) { moel@348: Expr.find.ID = function( match, context, isXML ) { moel@348: if ( typeof context.getElementById !== "undefined" && !isXML ) { moel@348: var m = context.getElementById(match[1]); moel@348: moel@348: return m ? moel@348: m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? moel@348: [m] : moel@348: undefined : moel@348: []; moel@348: } moel@348: }; moel@348: moel@348: Expr.filter.ID = function( elem, match ) { moel@348: var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); moel@348: moel@348: return elem.nodeType === 1 && node && node.nodeValue === match; moel@348: }; moel@348: } moel@348: moel@348: root.removeChild( form ); moel@348: moel@348: // release memory in IE moel@348: root = form = null; moel@348: })(); moel@348: moel@348: (function(){ moel@348: // Check to see if the browser returns only elements moel@348: // when doing getElementsByTagName("*") moel@348: moel@348: // Create a fake element moel@348: var div = document.createElement("div"); moel@348: div.appendChild( document.createComment("") ); moel@348: moel@348: // Make sure no comments are found moel@348: if ( div.getElementsByTagName("*").length > 0 ) { moel@348: Expr.find.TAG = function( match, context ) { moel@348: var results = context.getElementsByTagName( match[1] ); moel@348: moel@348: // Filter out possible comments moel@348: if ( match[1] === "*" ) { moel@348: var tmp = []; moel@348: moel@348: for ( var i = 0; results[i]; i++ ) { moel@348: if ( results[i].nodeType === 1 ) { moel@348: tmp.push( results[i] ); moel@348: } moel@348: } moel@348: moel@348: results = tmp; moel@348: } moel@348: moel@348: return results; moel@348: }; moel@348: } moel@348: moel@348: // Check to see if an attribute returns normalized href attributes moel@348: div.innerHTML = ""; moel@348: moel@348: if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && moel@348: div.firstChild.getAttribute("href") !== "#" ) { moel@348: moel@348: Expr.attrHandle.href = function( elem ) { moel@348: return elem.getAttribute( "href", 2 ); moel@348: }; moel@348: } moel@348: moel@348: // release memory in IE moel@348: div = null; moel@348: })(); moel@348: moel@348: if ( document.querySelectorAll ) { moel@348: (function(){ moel@348: var oldSizzle = Sizzle, moel@348: div = document.createElement("div"), moel@348: id = "__sizzle__"; moel@348: moel@348: div.innerHTML = "

"; moel@348: moel@348: // Safari can't handle uppercase or unicode characters when moel@348: // in quirks mode. moel@348: if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { moel@348: return; moel@348: } moel@348: moel@348: Sizzle = function( query, context, extra, seed ) { moel@348: context = context || document; moel@348: moel@348: // Only use querySelectorAll on non-XML documents moel@348: // (ID selectors don't work in non-HTML documents) moel@348: if ( !seed && !Sizzle.isXML(context) ) { moel@348: // See if we find a selector to speed up moel@348: var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); moel@348: moel@348: if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { moel@348: // Speed-up: Sizzle("TAG") moel@348: if ( match[1] ) { moel@348: return makeArray( context.getElementsByTagName( query ), extra ); moel@348: moel@348: // Speed-up: Sizzle(".CLASS") moel@348: } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { moel@348: return makeArray( context.getElementsByClassName( match[2] ), extra ); moel@348: } moel@348: } moel@348: moel@348: if ( context.nodeType === 9 ) { moel@348: // Speed-up: Sizzle("body") moel@348: // The body element only exists once, optimize finding it moel@348: if ( query === "body" && context.body ) { moel@348: return makeArray( [ context.body ], extra ); moel@348: moel@348: // Speed-up: Sizzle("#ID") moel@348: } else if ( match && match[3] ) { moel@348: var elem = context.getElementById( match[3] ); moel@348: moel@348: // Check parentNode to catch when Blackberry 4.6 returns moel@348: // nodes that are no longer in the document #6963 moel@348: if ( elem && elem.parentNode ) { moel@348: // Handle the case where IE and Opera return items moel@348: // by name instead of ID moel@348: if ( elem.id === match[3] ) { moel@348: return makeArray( [ elem ], extra ); moel@348: } moel@348: moel@348: } else { moel@348: return makeArray( [], extra ); moel@348: } moel@348: } moel@348: moel@348: try { moel@348: return makeArray( context.querySelectorAll(query), extra ); moel@348: } catch(qsaError) {} moel@348: moel@348: // qSA works strangely on Element-rooted queries moel@348: // We can work around this by specifying an extra ID on the root moel@348: // and working up from there (Thanks to Andrew Dupont for the technique) moel@348: // IE 8 doesn't work on object elements moel@348: } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { moel@348: var oldContext = context, moel@348: old = context.getAttribute( "id" ), moel@348: nid = old || id, moel@348: hasParent = context.parentNode, moel@348: relativeHierarchySelector = /^\s*[+~]/.test( query ); moel@348: moel@348: if ( !old ) { moel@348: context.setAttribute( "id", nid ); moel@348: } else { moel@348: nid = nid.replace( /'/g, "\\$&" ); moel@348: } moel@348: if ( relativeHierarchySelector && hasParent ) { moel@348: context = context.parentNode; moel@348: } moel@348: moel@348: try { moel@348: if ( !relativeHierarchySelector || hasParent ) { moel@348: return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); moel@348: } moel@348: moel@348: } catch(pseudoError) { moel@348: } finally { moel@348: if ( !old ) { moel@348: oldContext.removeAttribute( "id" ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return oldSizzle(query, context, extra, seed); moel@348: }; moel@348: moel@348: for ( var prop in oldSizzle ) { moel@348: Sizzle[ prop ] = oldSizzle[ prop ]; moel@348: } moel@348: moel@348: // release memory in IE moel@348: div = null; moel@348: })(); moel@348: } moel@348: moel@348: (function(){ moel@348: var html = document.documentElement, moel@348: matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; moel@348: moel@348: if ( matches ) { moel@348: // Check to see if it's possible to do matchesSelector moel@348: // on a disconnected node (IE 9 fails this) moel@348: var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), moel@348: pseudoWorks = false; moel@348: moel@348: try { moel@348: // This should fail with an exception moel@348: // Gecko does not error, returns false instead moel@348: matches.call( document.documentElement, "[test!='']:sizzle" ); moel@348: moel@348: } catch( pseudoError ) { moel@348: pseudoWorks = true; moel@348: } moel@348: moel@348: Sizzle.matchesSelector = function( node, expr ) { moel@348: // Make sure that attribute selectors are quoted moel@348: expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); moel@348: moel@348: if ( !Sizzle.isXML( node ) ) { moel@348: try { moel@348: if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { moel@348: var ret = matches.call( node, expr ); moel@348: moel@348: // IE 9's matchesSelector returns false on disconnected nodes moel@348: if ( ret || !disconnectedMatch || moel@348: // As well, disconnected nodes are said to be in a document moel@348: // fragment in IE 9, so check for that moel@348: node.document && node.document.nodeType !== 11 ) { moel@348: return ret; moel@348: } moel@348: } moel@348: } catch(e) {} moel@348: } moel@348: moel@348: return Sizzle(expr, null, null, [node]).length > 0; moel@348: }; moel@348: } moel@348: })(); moel@348: moel@348: (function(){ moel@348: var div = document.createElement("div"); moel@348: moel@348: div.innerHTML = "
"; moel@348: moel@348: // Opera can't find a second classname (in 9.6) moel@348: // Also, make sure that getElementsByClassName actually exists moel@348: if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { moel@348: return; moel@348: } moel@348: moel@348: // Safari caches class attributes, doesn't catch changes (in 3.2) moel@348: div.lastChild.className = "e"; moel@348: moel@348: if ( div.getElementsByClassName("e").length === 1 ) { moel@348: return; moel@348: } moel@348: moel@348: Expr.order.splice(1, 0, "CLASS"); moel@348: Expr.find.CLASS = function( match, context, isXML ) { moel@348: if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { moel@348: return context.getElementsByClassName(match[1]); moel@348: } moel@348: }; moel@348: moel@348: // release memory in IE moel@348: div = null; moel@348: })(); moel@348: moel@348: function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { moel@348: for ( var i = 0, l = checkSet.length; i < l; i++ ) { moel@348: var elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: var match = false; moel@348: moel@348: elem = elem[dir]; moel@348: moel@348: while ( elem ) { moel@348: if ( elem[ expando ] === doneName ) { moel@348: match = checkSet[elem.sizset]; moel@348: break; moel@348: } moel@348: moel@348: if ( elem.nodeType === 1 && !isXML ){ moel@348: elem[ expando ] = doneName; moel@348: elem.sizset = i; moel@348: } moel@348: moel@348: if ( elem.nodeName.toLowerCase() === cur ) { moel@348: match = elem; moel@348: break; moel@348: } moel@348: moel@348: elem = elem[dir]; moel@348: } moel@348: moel@348: checkSet[i] = match; moel@348: } moel@348: } moel@348: } moel@348: moel@348: function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { moel@348: for ( var i = 0, l = checkSet.length; i < l; i++ ) { moel@348: var elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: var match = false; moel@348: moel@348: elem = elem[dir]; moel@348: moel@348: while ( elem ) { moel@348: if ( elem[ expando ] === doneName ) { moel@348: match = checkSet[elem.sizset]; moel@348: break; moel@348: } moel@348: moel@348: if ( elem.nodeType === 1 ) { moel@348: if ( !isXML ) { moel@348: elem[ expando ] = doneName; moel@348: elem.sizset = i; moel@348: } moel@348: moel@348: if ( typeof cur !== "string" ) { moel@348: if ( elem === cur ) { moel@348: match = true; moel@348: break; moel@348: } moel@348: moel@348: } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { moel@348: match = elem; moel@348: break; moel@348: } moel@348: } moel@348: moel@348: elem = elem[dir]; moel@348: } moel@348: moel@348: checkSet[i] = match; moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( document.documentElement.contains ) { moel@348: Sizzle.contains = function( a, b ) { moel@348: return a !== b && (a.contains ? a.contains(b) : true); moel@348: }; moel@348: moel@348: } else if ( document.documentElement.compareDocumentPosition ) { moel@348: Sizzle.contains = function( a, b ) { moel@348: return !!(a.compareDocumentPosition(b) & 16); moel@348: }; moel@348: moel@348: } else { moel@348: Sizzle.contains = function() { moel@348: return false; moel@348: }; moel@348: } moel@348: moel@348: Sizzle.isXML = function( elem ) { moel@348: // documentElement is verified for cases where it doesn't yet exist moel@348: // (such as loading iframes in IE - #4833) moel@348: var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; moel@348: moel@348: return documentElement ? documentElement.nodeName !== "HTML" : false; moel@348: }; moel@348: moel@348: var posProcess = function( selector, context, seed ) { moel@348: var match, moel@348: tmpSet = [], moel@348: later = "", moel@348: root = context.nodeType ? [context] : context; moel@348: moel@348: // Position selectors must be done after the filter moel@348: // And so must :not(positional) so we move all PSEUDOs to the end moel@348: while ( (match = Expr.match.PSEUDO.exec( selector )) ) { moel@348: later += match[0]; moel@348: selector = selector.replace( Expr.match.PSEUDO, "" ); moel@348: } moel@348: moel@348: selector = Expr.relative[selector] ? selector + "*" : selector; moel@348: moel@348: for ( var i = 0, l = root.length; i < l; i++ ) { moel@348: Sizzle( selector, root[i], tmpSet, seed ); moel@348: } moel@348: moel@348: return Sizzle.filter( later, tmpSet ); moel@348: }; moel@348: moel@348: // EXPOSE moel@348: // Override sizzle attribute retrieval moel@348: Sizzle.attr = jQuery.attr; moel@348: Sizzle.selectors.attrMap = {}; moel@348: jQuery.find = Sizzle; moel@348: jQuery.expr = Sizzle.selectors; moel@348: jQuery.expr[":"] = jQuery.expr.filters; moel@348: jQuery.unique = Sizzle.uniqueSort; moel@348: jQuery.text = Sizzle.getText; moel@348: jQuery.isXMLDoc = Sizzle.isXML; moel@348: jQuery.contains = Sizzle.contains; moel@348: moel@348: moel@348: })(); moel@348: moel@348: moel@348: var runtil = /Until$/, moel@348: rparentsprev = /^(?:parents|prevUntil|prevAll)/, moel@348: // Note: This RegExp should be improved, or likely pulled from Sizzle moel@348: rmultiselector = /,/, moel@348: isSimple = /^.[^:#\[\.,]*$/, moel@348: slice = Array.prototype.slice, moel@348: POS = jQuery.expr.match.globalPOS, moel@348: // methods guaranteed to produce a unique set when starting from a unique set moel@348: guaranteedUnique = { moel@348: children: true, moel@348: contents: true, moel@348: next: true, moel@348: prev: true moel@348: }; moel@348: moel@348: jQuery.fn.extend({ moel@348: find: function( selector ) { moel@348: var self = this, moel@348: i, l; moel@348: moel@348: if ( typeof selector !== "string" ) { moel@348: return jQuery( selector ).filter(function() { moel@348: for ( i = 0, l = self.length; i < l; i++ ) { moel@348: if ( jQuery.contains( self[ i ], this ) ) { moel@348: return true; moel@348: } moel@348: } moel@348: }); moel@348: } moel@348: moel@348: var ret = this.pushStack( "", "find", selector ), moel@348: length, n, r; moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: length = ret.length; moel@348: jQuery.find( selector, this[i], ret ); moel@348: moel@348: if ( i > 0 ) { moel@348: // Make sure that the results are unique moel@348: for ( n = length; n < ret.length; n++ ) { moel@348: for ( r = 0; r < length; r++ ) { moel@348: if ( ret[r] === ret[n] ) { moel@348: ret.splice(n--, 1); moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: has: function( target ) { moel@348: var targets = jQuery( target ); moel@348: return this.filter(function() { moel@348: for ( var i = 0, l = targets.length; i < l; i++ ) { moel@348: if ( jQuery.contains( this, targets[i] ) ) { moel@348: return true; moel@348: } moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: not: function( selector ) { moel@348: return this.pushStack( winnow(this, selector, false), "not", selector); moel@348: }, moel@348: moel@348: filter: function( selector ) { moel@348: return this.pushStack( winnow(this, selector, true), "filter", selector ); moel@348: }, moel@348: moel@348: is: function( selector ) { moel@348: return !!selector && ( moel@348: typeof selector === "string" ? moel@348: // If this is a positional selector, check membership in the returned set moel@348: // so $("p:first").is("p:last") won't return true for a doc with two "p". moel@348: POS.test( selector ) ? moel@348: jQuery( selector, this.context ).index( this[0] ) >= 0 : moel@348: jQuery.filter( selector, this ).length > 0 : moel@348: this.filter( selector ).length > 0 ); moel@348: }, moel@348: moel@348: closest: function( selectors, context ) { moel@348: var ret = [], i, l, cur = this[0]; moel@348: moel@348: // Array (deprecated as of jQuery 1.7) moel@348: if ( jQuery.isArray( selectors ) ) { moel@348: var level = 1; moel@348: moel@348: while ( cur && cur.ownerDocument && cur !== context ) { moel@348: for ( i = 0; i < selectors.length; i++ ) { moel@348: moel@348: if ( jQuery( cur ).is( selectors[ i ] ) ) { moel@348: ret.push({ selector: selectors[ i ], elem: cur, level: level }); moel@348: } moel@348: } moel@348: moel@348: cur = cur.parentNode; moel@348: level++; moel@348: } moel@348: moel@348: return ret; moel@348: } moel@348: moel@348: // String moel@348: var pos = POS.test( selectors ) || typeof selectors !== "string" ? moel@348: jQuery( selectors, context || this.context ) : moel@348: 0; moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: cur = this[i]; moel@348: moel@348: while ( cur ) { moel@348: if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { moel@348: ret.push( cur ); moel@348: break; moel@348: moel@348: } else { moel@348: cur = cur.parentNode; moel@348: if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: ret = ret.length > 1 ? jQuery.unique( ret ) : ret; moel@348: moel@348: return this.pushStack( ret, "closest", selectors ); moel@348: }, moel@348: moel@348: // Determine the position of an element within moel@348: // the matched set of elements moel@348: index: function( elem ) { moel@348: moel@348: // No argument, return index in parent moel@348: if ( !elem ) { moel@348: return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; moel@348: } moel@348: moel@348: // index in selector moel@348: if ( typeof elem === "string" ) { moel@348: return jQuery.inArray( this[0], jQuery( elem ) ); moel@348: } moel@348: moel@348: // Locate the position of the desired element moel@348: return jQuery.inArray( moel@348: // If it receives a jQuery object, the first element is used moel@348: elem.jquery ? elem[0] : elem, this ); moel@348: }, moel@348: moel@348: add: function( selector, context ) { moel@348: var set = typeof selector === "string" ? moel@348: jQuery( selector, context ) : moel@348: jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), moel@348: all = jQuery.merge( this.get(), set ); moel@348: moel@348: return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? moel@348: all : moel@348: jQuery.unique( all ) ); moel@348: }, moel@348: moel@348: andSelf: function() { moel@348: return this.add( this.prevObject ); moel@348: } moel@348: }); moel@348: moel@348: // A painfully simple check to see if an element is disconnected moel@348: // from a document (should be improved, where feasible). moel@348: function isDisconnected( node ) { moel@348: return !node || !node.parentNode || node.parentNode.nodeType === 11; moel@348: } moel@348: moel@348: jQuery.each({ moel@348: parent: function( elem ) { moel@348: var parent = elem.parentNode; moel@348: return parent && parent.nodeType !== 11 ? parent : null; moel@348: }, moel@348: parents: function( elem ) { moel@348: return jQuery.dir( elem, "parentNode" ); moel@348: }, moel@348: parentsUntil: function( elem, i, until ) { moel@348: return jQuery.dir( elem, "parentNode", until ); moel@348: }, moel@348: next: function( elem ) { moel@348: return jQuery.nth( elem, 2, "nextSibling" ); moel@348: }, moel@348: prev: function( elem ) { moel@348: return jQuery.nth( elem, 2, "previousSibling" ); moel@348: }, moel@348: nextAll: function( elem ) { moel@348: return jQuery.dir( elem, "nextSibling" ); moel@348: }, moel@348: prevAll: function( elem ) { moel@348: return jQuery.dir( elem, "previousSibling" ); moel@348: }, moel@348: nextUntil: function( elem, i, until ) { moel@348: return jQuery.dir( elem, "nextSibling", until ); moel@348: }, moel@348: prevUntil: function( elem, i, until ) { moel@348: return jQuery.dir( elem, "previousSibling", until ); moel@348: }, moel@348: siblings: function( elem ) { moel@348: return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); moel@348: }, moel@348: children: function( elem ) { moel@348: return jQuery.sibling( elem.firstChild ); moel@348: }, moel@348: contents: function( elem ) { moel@348: return jQuery.nodeName( elem, "iframe" ) ? moel@348: elem.contentDocument || elem.contentWindow.document : moel@348: jQuery.makeArray( elem.childNodes ); moel@348: } moel@348: }, function( name, fn ) { moel@348: jQuery.fn[ name ] = function( until, selector ) { moel@348: var ret = jQuery.map( this, fn, until ); moel@348: moel@348: if ( !runtil.test( name ) ) { moel@348: selector = until; moel@348: } moel@348: moel@348: if ( selector && typeof selector === "string" ) { moel@348: ret = jQuery.filter( selector, ret ); moel@348: } moel@348: moel@348: ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; moel@348: moel@348: if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { moel@348: ret = ret.reverse(); moel@348: } moel@348: moel@348: return this.pushStack( ret, name, slice.call( arguments ).join(",") ); moel@348: }; moel@348: }); moel@348: moel@348: jQuery.extend({ moel@348: filter: function( expr, elems, not ) { moel@348: if ( not ) { moel@348: expr = ":not(" + expr + ")"; moel@348: } moel@348: moel@348: return elems.length === 1 ? moel@348: jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : moel@348: jQuery.find.matches(expr, elems); moel@348: }, moel@348: moel@348: dir: function( elem, dir, until ) { moel@348: var matched = [], moel@348: cur = elem[ dir ]; moel@348: moel@348: while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { moel@348: if ( cur.nodeType === 1 ) { moel@348: matched.push( cur ); moel@348: } moel@348: cur = cur[dir]; moel@348: } moel@348: return matched; moel@348: }, moel@348: moel@348: nth: function( cur, result, dir, elem ) { moel@348: result = result || 1; moel@348: var num = 0; moel@348: moel@348: for ( ; cur; cur = cur[dir] ) { moel@348: if ( cur.nodeType === 1 && ++num === result ) { moel@348: break; moel@348: } moel@348: } moel@348: moel@348: return cur; moel@348: }, moel@348: moel@348: sibling: function( n, elem ) { moel@348: var r = []; moel@348: moel@348: for ( ; n; n = n.nextSibling ) { moel@348: if ( n.nodeType === 1 && n !== elem ) { moel@348: r.push( n ); moel@348: } moel@348: } moel@348: moel@348: return r; moel@348: } moel@348: }); moel@348: moel@348: // Implement the identical functionality for filter and not moel@348: function winnow( elements, qualifier, keep ) { moel@348: moel@348: // Can't pass null or undefined to indexOf in Firefox 4 moel@348: // Set to 0 to skip string check moel@348: qualifier = qualifier || 0; moel@348: moel@348: if ( jQuery.isFunction( qualifier ) ) { moel@348: return jQuery.grep(elements, function( elem, i ) { moel@348: var retVal = !!qualifier.call( elem, i, elem ); moel@348: return retVal === keep; moel@348: }); moel@348: moel@348: } else if ( qualifier.nodeType ) { moel@348: return jQuery.grep(elements, function( elem, i ) { moel@348: return ( elem === qualifier ) === keep; moel@348: }); moel@348: moel@348: } else if ( typeof qualifier === "string" ) { moel@348: var filtered = jQuery.grep(elements, function( elem ) { moel@348: return elem.nodeType === 1; moel@348: }); moel@348: moel@348: if ( isSimple.test( qualifier ) ) { moel@348: return jQuery.filter(qualifier, filtered, !keep); moel@348: } else { moel@348: qualifier = jQuery.filter( qualifier, filtered ); moel@348: } moel@348: } moel@348: moel@348: return jQuery.grep(elements, function( elem, i ) { moel@348: return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; moel@348: }); moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: function createSafeFragment( document ) { moel@348: var list = nodeNames.split( "|" ), moel@348: safeFrag = document.createDocumentFragment(); moel@348: moel@348: if ( safeFrag.createElement ) { moel@348: while ( list.length ) { moel@348: safeFrag.createElement( moel@348: list.pop() moel@348: ); moel@348: } moel@348: } moel@348: return safeFrag; moel@348: } moel@348: moel@348: var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + moel@348: "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", moel@348: rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, moel@348: rleadingWhitespace = /^\s+/, moel@348: rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, moel@348: rtagName = /<([\w:]+)/, moel@348: rtbody = /]", "i"), moel@348: // checked="checked" or checked moel@348: rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, moel@348: rscriptType = /\/(java|ecma)script/i, moel@348: rcleanScript = /^\s*", "" ], moel@348: legend: [ 1, "
", "
" ], moel@348: thead: [ 1, "", "
" ], moel@348: tr: [ 2, "", "
" ], moel@348: td: [ 3, "", "
" ], moel@348: col: [ 2, "", "
" ], moel@348: area: [ 1, "", "" ], moel@348: _default: [ 0, "", "" ] moel@348: }, moel@348: safeFragment = createSafeFragment( document ); moel@348: moel@348: wrapMap.optgroup = wrapMap.option; moel@348: wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; moel@348: wrapMap.th = wrapMap.td; moel@348: moel@348: // IE can't serialize and