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

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