rlm@79: /*!
rlm@79: * jQuery JavaScript Library v1.4.2
rlm@79: * http://jquery.com/
rlm@79: *
rlm@79: * Copyright 2010, John Resig
rlm@79: * Dual licensed under the MIT or GPL Version 2 licenses.
rlm@79: * http://jquery.org/license
rlm@79: *
rlm@79: * Includes Sizzle.js
rlm@79: * http://sizzlejs.com/
rlm@79: * Copyright 2010, The Dojo Foundation
rlm@79: * Released under the MIT, BSD, and GPL Licenses.
rlm@79: *
rlm@79: * Date: Sat Feb 13 22:33:48 2010 -0500
rlm@79: */
rlm@79: (function( window, undefined ) {
rlm@79:
rlm@79: // Define a local copy of jQuery
rlm@79: var jQuery = function( selector, context ) {
rlm@79: // The jQuery object is actually just the init constructor 'enhanced'
rlm@79: return new jQuery.fn.init( selector, context );
rlm@79: },
rlm@79:
rlm@79: // Map over jQuery in case of overwrite
rlm@79: _jQuery = window.jQuery,
rlm@79:
rlm@79: // Map over the $ in case of overwrite
rlm@79: _$ = window.$,
rlm@79:
rlm@79: // Use the correct document accordingly with window argument (sandbox)
rlm@79: document = window.document,
rlm@79:
rlm@79: // A central reference to the root jQuery(document)
rlm@79: rootjQuery,
rlm@79:
rlm@79: // A simple way to check for HTML strings or ID strings
rlm@79: // (both of which we optimize for)
rlm@79: quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
rlm@79:
rlm@79: // Is it a simple selector
rlm@79: isSimple = /^.[^:#\[\.,]*$/,
rlm@79:
rlm@79: // Check if a string has a non-whitespace character in it
rlm@79: rnotwhite = /\S/,
rlm@79:
rlm@79: // Used for trimming whitespace
rlm@79: rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
rlm@79:
rlm@79: // Match a standalone tag
rlm@79: rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
rlm@79:
rlm@79: // Keep a UserAgent string for use with jQuery.browser
rlm@79: userAgent = navigator.userAgent,
rlm@79:
rlm@79: // For matching the engine and version of the browser
rlm@79: browserMatch,
rlm@79:
rlm@79: // Has the ready events already been bound?
rlm@79: readyBound = false,
rlm@79:
rlm@79: // The functions to execute on DOM ready
rlm@79: readyList = [],
rlm@79:
rlm@79: // The ready event handler
rlm@79: DOMContentLoaded,
rlm@79:
rlm@79: // Save a reference to some core methods
rlm@79: toString = Object.prototype.toString,
rlm@79: hasOwnProperty = Object.prototype.hasOwnProperty,
rlm@79: push = Array.prototype.push,
rlm@79: slice = Array.prototype.slice,
rlm@79: indexOf = Array.prototype.indexOf;
rlm@79:
rlm@79: jQuery.fn = jQuery.prototype = {
rlm@79: init: function( selector, context ) {
rlm@79: var match, elem, ret, doc;
rlm@79:
rlm@79: // Handle $(""), $(null), or $(undefined)
rlm@79: if ( !selector ) {
rlm@79: return this;
rlm@79: }
rlm@79:
rlm@79: // Handle $(DOMElement)
rlm@79: if ( selector.nodeType ) {
rlm@79: this.context = this[0] = selector;
rlm@79: this.length = 1;
rlm@79: return this;
rlm@79: }
rlm@79:
rlm@79: // The body element only exists once, optimize finding it
rlm@79: if ( selector === "body" && !context ) {
rlm@79: this.context = document;
rlm@79: this[0] = document.body;
rlm@79: this.selector = "body";
rlm@79: this.length = 1;
rlm@79: return this;
rlm@79: }
rlm@79:
rlm@79: // Handle HTML strings
rlm@79: if ( typeof selector === "string" ) {
rlm@79: // Are we dealing with HTML string or an ID?
rlm@79: match = quickExpr.exec( selector );
rlm@79:
rlm@79: // Verify a match, and that no context was specified for #id
rlm@79: if ( match && (match[1] || !context) ) {
rlm@79:
rlm@79: // HANDLE: $(html) -> $(array)
rlm@79: if ( match[1] ) {
rlm@79: doc = (context ? context.ownerDocument || context : document);
rlm@79:
rlm@79: // If a single string is passed in and it's a single tag
rlm@79: // just do a createElement and skip the rest
rlm@79: ret = rsingleTag.exec( selector );
rlm@79:
rlm@79: if ( ret ) {
rlm@79: if ( jQuery.isPlainObject( context ) ) {
rlm@79: selector = [ document.createElement( ret[1] ) ];
rlm@79: jQuery.fn.attr.call( selector, context, true );
rlm@79:
rlm@79: } else {
rlm@79: selector = [ doc.createElement( ret[1] ) ];
rlm@79: }
rlm@79:
rlm@79: } else {
rlm@79: ret = buildFragment( [ match[1] ], [ doc ] );
rlm@79: selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
rlm@79: }
rlm@79:
rlm@79: return jQuery.merge( this, selector );
rlm@79:
rlm@79: // HANDLE: $("#id")
rlm@79: } else {
rlm@79: elem = document.getElementById( match[2] );
rlm@79:
rlm@79: if ( elem ) {
rlm@79: // Handle the case where IE and Opera return items
rlm@79: // by name instead of ID
rlm@79: if ( elem.id !== match[2] ) {
rlm@79: return rootjQuery.find( selector );
rlm@79: }
rlm@79:
rlm@79: // Otherwise, we inject the element directly into the jQuery object
rlm@79: this.length = 1;
rlm@79: this[0] = elem;
rlm@79: }
rlm@79:
rlm@79: this.context = document;
rlm@79: this.selector = selector;
rlm@79: return this;
rlm@79: }
rlm@79:
rlm@79: // HANDLE: $("TAG")
rlm@79: } else if ( !context && /^\w+$/.test( selector ) ) {
rlm@79: this.selector = selector;
rlm@79: this.context = document;
rlm@79: selector = document.getElementsByTagName( selector );
rlm@79: return jQuery.merge( this, selector );
rlm@79:
rlm@79: // HANDLE: $(expr, $(...))
rlm@79: } else if ( !context || context.jquery ) {
rlm@79: return (context || rootjQuery).find( selector );
rlm@79:
rlm@79: // HANDLE: $(expr, context)
rlm@79: // (which is just equivalent to: $(context).find(expr)
rlm@79: } else {
rlm@79: return jQuery( context ).find( selector );
rlm@79: }
rlm@79:
rlm@79: // HANDLE: $(function)
rlm@79: // Shortcut for document ready
rlm@79: } else if ( jQuery.isFunction( selector ) ) {
rlm@79: return rootjQuery.ready( selector );
rlm@79: }
rlm@79:
rlm@79: if (selector.selector !== undefined) {
rlm@79: this.selector = selector.selector;
rlm@79: this.context = selector.context;
rlm@79: }
rlm@79:
rlm@79: return jQuery.makeArray( selector, this );
rlm@79: },
rlm@79:
rlm@79: // Start with an empty selector
rlm@79: selector: "",
rlm@79:
rlm@79: // The current version of jQuery being used
rlm@79: jquery: "1.4.2",
rlm@79:
rlm@79: // The default length of a jQuery object is 0
rlm@79: length: 0,
rlm@79:
rlm@79: // The number of elements contained in the matched element set
rlm@79: size: function() {
rlm@79: return this.length;
rlm@79: },
rlm@79:
rlm@79: toArray: function() {
rlm@79: return slice.call( this, 0 );
rlm@79: },
rlm@79:
rlm@79: // Get the Nth element in the matched element set OR
rlm@79: // Get the whole matched element set as a clean array
rlm@79: get: function( num ) {
rlm@79: return num == null ?
rlm@79:
rlm@79: // Return a 'clean' array
rlm@79: this.toArray() :
rlm@79:
rlm@79: // Return just the object
rlm@79: ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
rlm@79: },
rlm@79:
rlm@79: // Take an array of elements and push it onto the stack
rlm@79: // (returning the new matched element set)
rlm@79: pushStack: function( elems, name, selector ) {
rlm@79: // Build a new jQuery matched element set
rlm@79: var ret = jQuery();
rlm@79:
rlm@79: if ( jQuery.isArray( elems ) ) {
rlm@79: push.apply( ret, elems );
rlm@79:
rlm@79: } else {
rlm@79: jQuery.merge( ret, elems );
rlm@79: }
rlm@79:
rlm@79: // Add the old object onto the stack (as a reference)
rlm@79: ret.prevObject = this;
rlm@79:
rlm@79: ret.context = this.context;
rlm@79:
rlm@79: if ( name === "find" ) {
rlm@79: ret.selector = this.selector + (this.selector ? " " : "") + selector;
rlm@79: } else if ( name ) {
rlm@79: ret.selector = this.selector + "." + name + "(" + selector + ")";
rlm@79: }
rlm@79:
rlm@79: // Return the newly-formed element set
rlm@79: return ret;
rlm@79: },
rlm@79:
rlm@79: // Execute a callback for every element in the matched set.
rlm@79: // (You can seed the arguments with an array of args, but this is
rlm@79: // only used internally.)
rlm@79: each: function( callback, args ) {
rlm@79: return jQuery.each( this, callback, args );
rlm@79: },
rlm@79:
rlm@79: ready: function( fn ) {
rlm@79: // Attach the listeners
rlm@79: jQuery.bindReady();
rlm@79:
rlm@79: // If the DOM is already ready
rlm@79: if ( jQuery.isReady ) {
rlm@79: // Execute the function immediately
rlm@79: fn.call( document, jQuery );
rlm@79:
rlm@79: // Otherwise, remember the function for later
rlm@79: } else if ( readyList ) {
rlm@79: // Add the function to the wait list
rlm@79: readyList.push( fn );
rlm@79: }
rlm@79:
rlm@79: return this;
rlm@79: },
rlm@79:
rlm@79: eq: function( i ) {
rlm@79: return i === -1 ?
rlm@79: this.slice( i ) :
rlm@79: this.slice( i, +i + 1 );
rlm@79: },
rlm@79:
rlm@79: first: function() {
rlm@79: return this.eq( 0 );
rlm@79: },
rlm@79:
rlm@79: last: function() {
rlm@79: return this.eq( -1 );
rlm@79: },
rlm@79:
rlm@79: slice: function() {
rlm@79: return this.pushStack( slice.apply( this, arguments ),
rlm@79: "slice", slice.call(arguments).join(",") );
rlm@79: },
rlm@79:
rlm@79: map: function( callback ) {
rlm@79: return this.pushStack( jQuery.map(this, function( elem, i ) {
rlm@79: return callback.call( elem, i, elem );
rlm@79: }));
rlm@79: },
rlm@79:
rlm@79: end: function() {
rlm@79: return this.prevObject || jQuery(null);
rlm@79: },
rlm@79:
rlm@79: // For internal use only.
rlm@79: // Behaves like an Array's method, not like a jQuery method.
rlm@79: push: push,
rlm@79: sort: [].sort,
rlm@79: splice: [].splice
rlm@79: };
rlm@79:
rlm@79: // Give the init function the jQuery prototype for later instantiation
rlm@79: jQuery.fn.init.prototype = jQuery.fn;
rlm@79:
rlm@79: jQuery.extend = jQuery.fn.extend = function() {
rlm@79: // copy reference to target object
rlm@79: var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
rlm@79:
rlm@79: // Handle a deep copy situation
rlm@79: if ( typeof target === "boolean" ) {
rlm@79: deep = target;
rlm@79: target = arguments[1] || {};
rlm@79: // skip the boolean and the target
rlm@79: i = 2;
rlm@79: }
rlm@79:
rlm@79: // Handle case when target is a string or something (possible in deep copy)
rlm@79: if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
rlm@79: target = {};
rlm@79: }
rlm@79:
rlm@79: // extend jQuery itself if only one argument is passed
rlm@79: if ( length === i ) {
rlm@79: target = this;
rlm@79: --i;
rlm@79: }
rlm@79:
rlm@79: for ( ; i < length; i++ ) {
rlm@79: // Only deal with non-null/undefined values
rlm@79: if ( (options = arguments[ i ]) != null ) {
rlm@79: // Extend the base object
rlm@79: for ( name in options ) {
rlm@79: src = target[ name ];
rlm@79: copy = options[ name ];
rlm@79:
rlm@79: // Prevent never-ending loop
rlm@79: if ( target === copy ) {
rlm@79: continue;
rlm@79: }
rlm@79:
rlm@79: // Recurse if we're merging object literal values or arrays
rlm@79: if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
rlm@79: var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
rlm@79: : jQuery.isArray(copy) ? [] : {};
rlm@79:
rlm@79: // Never move original objects, clone them
rlm@79: target[ name ] = jQuery.extend( deep, clone, copy );
rlm@79:
rlm@79: // Don't bring in undefined values
rlm@79: } else if ( copy !== undefined ) {
rlm@79: target[ name ] = copy;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Return the modified object
rlm@79: return target;
rlm@79: };
rlm@79:
rlm@79: jQuery.extend({
rlm@79: noConflict: function( deep ) {
rlm@79: window.$ = _$;
rlm@79:
rlm@79: if ( deep ) {
rlm@79: window.jQuery = _jQuery;
rlm@79: }
rlm@79:
rlm@79: return jQuery;
rlm@79: },
rlm@79:
rlm@79: // Is the DOM ready to be used? Set to true once it occurs.
rlm@79: isReady: false,
rlm@79:
rlm@79: // Handle when the DOM is ready
rlm@79: ready: function() {
rlm@79: // Make sure that the DOM is not already loaded
rlm@79: if ( !jQuery.isReady ) {
rlm@79: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
rlm@79: if ( !document.body ) {
rlm@79: return setTimeout( jQuery.ready, 13 );
rlm@79: }
rlm@79:
rlm@79: // Remember that the DOM is ready
rlm@79: jQuery.isReady = true;
rlm@79:
rlm@79: // If there are functions bound, to execute
rlm@79: if ( readyList ) {
rlm@79: // Execute all of them
rlm@79: var fn, i = 0;
rlm@79: while ( (fn = readyList[ i++ ]) ) {
rlm@79: fn.call( document, jQuery );
rlm@79: }
rlm@79:
rlm@79: // Reset the list of functions
rlm@79: readyList = null;
rlm@79: }
rlm@79:
rlm@79: // Trigger any bound ready events
rlm@79: if ( jQuery.fn.triggerHandler ) {
rlm@79: jQuery( document ).triggerHandler( "ready" );
rlm@79: }
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: bindReady: function() {
rlm@79: if ( readyBound ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: readyBound = true;
rlm@79:
rlm@79: // Catch cases where $(document).ready() is called after the
rlm@79: // browser event has already occurred.
rlm@79: if ( document.readyState === "complete" ) {
rlm@79: return jQuery.ready();
rlm@79: }
rlm@79:
rlm@79: // Mozilla, Opera and webkit nightlies currently support this event
rlm@79: if ( document.addEventListener ) {
rlm@79: // Use the handy event callback
rlm@79: document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
rlm@79:
rlm@79: // A fallback to window.onload, that will always work
rlm@79: window.addEventListener( "load", jQuery.ready, false );
rlm@79:
rlm@79: // If IE event model is used
rlm@79: } else if ( document.attachEvent ) {
rlm@79: // ensure firing before onload,
rlm@79: // maybe late but safe also for iframes
rlm@79: document.attachEvent("onreadystatechange", DOMContentLoaded);
rlm@79:
rlm@79: // A fallback to window.onload, that will always work
rlm@79: window.attachEvent( "onload", jQuery.ready );
rlm@79:
rlm@79: // If IE and not a frame
rlm@79: // continually check to see if the document is ready
rlm@79: var toplevel = false;
rlm@79:
rlm@79: try {
rlm@79: toplevel = window.frameElement == null;
rlm@79: } catch(e) {}
rlm@79:
rlm@79: if ( document.documentElement.doScroll && toplevel ) {
rlm@79: doScrollCheck();
rlm@79: }
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: // See test/unit/core.js for details concerning isFunction.
rlm@79: // Since version 1.3, DOM methods and functions like alert
rlm@79: // aren't supported. They return false on IE (#2968).
rlm@79: isFunction: function( obj ) {
rlm@79: return toString.call(obj) === "[object Function]";
rlm@79: },
rlm@79:
rlm@79: isArray: function( obj ) {
rlm@79: return toString.call(obj) === "[object Array]";
rlm@79: },
rlm@79:
rlm@79: isPlainObject: function( obj ) {
rlm@79: // Must be an Object.
rlm@79: // Because of IE, we also have to check the presence of the constructor property.
rlm@79: // Make sure that DOM nodes and window objects don't pass through, as well
rlm@79: if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
rlm@79: return false;
rlm@79: }
rlm@79:
rlm@79: // Not own constructor property must be Object
rlm@79: if ( obj.constructor
rlm@79: && !hasOwnProperty.call(obj, "constructor")
rlm@79: && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
rlm@79: return false;
rlm@79: }
rlm@79:
rlm@79: // Own properties are enumerated firstly, so to speed up,
rlm@79: // if last one is own, then all properties are own.
rlm@79:
rlm@79: var key;
rlm@79: for ( key in obj ) {}
rlm@79:
rlm@79: return key === undefined || hasOwnProperty.call( obj, key );
rlm@79: },
rlm@79:
rlm@79: isEmptyObject: function( obj ) {
rlm@79: for ( var name in obj ) {
rlm@79: return false;
rlm@79: }
rlm@79: return true;
rlm@79: },
rlm@79:
rlm@79: error: function( msg ) {
rlm@79: throw msg;
rlm@79: },
rlm@79:
rlm@79: parseJSON: function( data ) {
rlm@79: if ( typeof data !== "string" || !data ) {
rlm@79: return null;
rlm@79: }
rlm@79:
rlm@79: // Make sure leading/trailing whitespace is removed (IE can't handle it)
rlm@79: data = jQuery.trim( data );
rlm@79:
rlm@79: // Make sure the incoming data is actual JSON
rlm@79: // Logic borrowed from http://json.org/json2.js
rlm@79: if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
rlm@79: .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
rlm@79: .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
rlm@79:
rlm@79: // Try to use the native JSON parser first
rlm@79: return window.JSON && window.JSON.parse ?
rlm@79: window.JSON.parse( data ) :
rlm@79: (new Function("return " + data))();
rlm@79:
rlm@79: } else {
rlm@79: jQuery.error( "Invalid JSON: " + data );
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: noop: function() {},
rlm@79:
rlm@79: // Evalulates a script in a global context
rlm@79: globalEval: function( data ) {
rlm@79: if ( data && rnotwhite.test(data) ) {
rlm@79: // Inspired by code by Andrea Giammarchi
rlm@79: // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
rlm@79: var head = document.getElementsByTagName("head")[0] || document.documentElement,
rlm@79: script = document.createElement("script");
rlm@79:
rlm@79: script.type = "text/javascript";
rlm@79:
rlm@79: if ( jQuery.support.scriptEval ) {
rlm@79: script.appendChild( document.createTextNode( data ) );
rlm@79: } else {
rlm@79: script.text = data;
rlm@79: }
rlm@79:
rlm@79: // Use insertBefore instead of appendChild to circumvent an IE6 bug.
rlm@79: // This arises when a base node is used (#2709).
rlm@79: head.insertBefore( script, head.firstChild );
rlm@79: head.removeChild( script );
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: nodeName: function( elem, name ) {
rlm@79: return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
rlm@79: },
rlm@79:
rlm@79: // args is for internal usage only
rlm@79: each: function( object, callback, args ) {
rlm@79: var name, i = 0,
rlm@79: length = object.length,
rlm@79: isObj = length === undefined || jQuery.isFunction(object);
rlm@79:
rlm@79: if ( args ) {
rlm@79: if ( isObj ) {
rlm@79: for ( name in object ) {
rlm@79: if ( callback.apply( object[ name ], args ) === false ) {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: } else {
rlm@79: for ( ; i < length; ) {
rlm@79: if ( callback.apply( object[ i++ ], args ) === false ) {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // A special, fast, case for the most common use of each
rlm@79: } else {
rlm@79: if ( isObj ) {
rlm@79: for ( name in object ) {
rlm@79: if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: } else {
rlm@79: for ( var value = object[0];
rlm@79: i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return object;
rlm@79: },
rlm@79:
rlm@79: trim: function( text ) {
rlm@79: return (text || "").replace( rtrim, "" );
rlm@79: },
rlm@79:
rlm@79: // results is for internal usage only
rlm@79: makeArray: function( array, results ) {
rlm@79: var ret = results || [];
rlm@79:
rlm@79: if ( array != null ) {
rlm@79: // The window, strings (and functions) also have 'length'
rlm@79: // The extra typeof function check is to prevent crashes
rlm@79: // in Safari 2 (See: #3039)
rlm@79: if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
rlm@79: push.call( ret, array );
rlm@79: } else {
rlm@79: jQuery.merge( ret, array );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret;
rlm@79: },
rlm@79:
rlm@79: inArray: function( elem, array ) {
rlm@79: if ( array.indexOf ) {
rlm@79: return array.indexOf( elem );
rlm@79: }
rlm@79:
rlm@79: for ( var i = 0, length = array.length; i < length; i++ ) {
rlm@79: if ( array[ i ] === elem ) {
rlm@79: return i;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return -1;
rlm@79: },
rlm@79:
rlm@79: merge: function( first, second ) {
rlm@79: var i = first.length, j = 0;
rlm@79:
rlm@79: if ( typeof second.length === "number" ) {
rlm@79: for ( var l = second.length; j < l; j++ ) {
rlm@79: first[ i++ ] = second[ j ];
rlm@79: }
rlm@79:
rlm@79: } else {
rlm@79: while ( second[j] !== undefined ) {
rlm@79: first[ i++ ] = second[ j++ ];
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: first.length = i;
rlm@79:
rlm@79: return first;
rlm@79: },
rlm@79:
rlm@79: grep: function( elems, callback, inv ) {
rlm@79: var ret = [];
rlm@79:
rlm@79: // Go through the array, only saving the items
rlm@79: // that pass the validator function
rlm@79: for ( var i = 0, length = elems.length; i < length; i++ ) {
rlm@79: if ( !inv !== !callback( elems[ i ], i ) ) {
rlm@79: ret.push( elems[ i ] );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret;
rlm@79: },
rlm@79:
rlm@79: // arg is for internal usage only
rlm@79: map: function( elems, callback, arg ) {
rlm@79: var ret = [], value;
rlm@79:
rlm@79: // Go through the array, translating each of the items to their
rlm@79: // new value (or values).
rlm@79: for ( var i = 0, length = elems.length; i < length; i++ ) {
rlm@79: value = callback( elems[ i ], i, arg );
rlm@79:
rlm@79: if ( value != null ) {
rlm@79: ret[ ret.length ] = value;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret.concat.apply( [], ret );
rlm@79: },
rlm@79:
rlm@79: // A global GUID counter for objects
rlm@79: guid: 1,
rlm@79:
rlm@79: proxy: function( fn, proxy, thisObject ) {
rlm@79: if ( arguments.length === 2 ) {
rlm@79: if ( typeof proxy === "string" ) {
rlm@79: thisObject = fn;
rlm@79: fn = thisObject[ proxy ];
rlm@79: proxy = undefined;
rlm@79:
rlm@79: } else if ( proxy && !jQuery.isFunction( proxy ) ) {
rlm@79: thisObject = proxy;
rlm@79: proxy = undefined;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( !proxy && fn ) {
rlm@79: proxy = function() {
rlm@79: return fn.apply( thisObject || this, arguments );
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: // Set the guid of unique handler to the same of original handler, so it can be removed
rlm@79: if ( fn ) {
rlm@79: proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
rlm@79: }
rlm@79:
rlm@79: // So proxy can be declared as an argument
rlm@79: return proxy;
rlm@79: },
rlm@79:
rlm@79: // Use of jQuery.browser is frowned upon.
rlm@79: // More details: http://docs.jquery.com/Utilities/jQuery.browser
rlm@79: uaMatch: function( ua ) {
rlm@79: ua = ua.toLowerCase();
rlm@79:
rlm@79: var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
rlm@79: /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
rlm@79: /(msie) ([\w.]+)/.exec( ua ) ||
rlm@79: !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
rlm@79: [];
rlm@79:
rlm@79: return { browser: match[1] || "", version: match[2] || "0" };
rlm@79: },
rlm@79:
rlm@79: browser: {}
rlm@79: });
rlm@79:
rlm@79: browserMatch = jQuery.uaMatch( userAgent );
rlm@79: if ( browserMatch.browser ) {
rlm@79: jQuery.browser[ browserMatch.browser ] = true;
rlm@79: jQuery.browser.version = browserMatch.version;
rlm@79: }
rlm@79:
rlm@79: // Deprecated, use jQuery.browser.webkit instead
rlm@79: if ( jQuery.browser.webkit ) {
rlm@79: jQuery.browser.safari = true;
rlm@79: }
rlm@79:
rlm@79: if ( indexOf ) {
rlm@79: jQuery.inArray = function( elem, array ) {
rlm@79: return indexOf.call( array, elem );
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: // All jQuery objects should point back to these
rlm@79: rootjQuery = jQuery(document);
rlm@79:
rlm@79: // Cleanup functions for the document ready method
rlm@79: if ( document.addEventListener ) {
rlm@79: DOMContentLoaded = function() {
rlm@79: document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
rlm@79: jQuery.ready();
rlm@79: };
rlm@79:
rlm@79: } else if ( document.attachEvent ) {
rlm@79: DOMContentLoaded = function() {
rlm@79: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
rlm@79: if ( document.readyState === "complete" ) {
rlm@79: document.detachEvent( "onreadystatechange", DOMContentLoaded );
rlm@79: jQuery.ready();
rlm@79: }
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: // The DOM ready check for Internet Explorer
rlm@79: function doScrollCheck() {
rlm@79: if ( jQuery.isReady ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: try {
rlm@79: // If IE is used, use the trick by Diego Perini
rlm@79: // http://javascript.nwbox.com/IEContentLoaded/
rlm@79: document.documentElement.doScroll("left");
rlm@79: } catch( error ) {
rlm@79: setTimeout( doScrollCheck, 1 );
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: // and execute any waiting functions
rlm@79: jQuery.ready();
rlm@79: }
rlm@79:
rlm@79: function evalScript( i, elem ) {
rlm@79: if ( elem.src ) {
rlm@79: jQuery.ajax({
rlm@79: url: elem.src,
rlm@79: async: false,
rlm@79: dataType: "script"
rlm@79: });
rlm@79: } else {
rlm@79: jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
rlm@79: }
rlm@79:
rlm@79: if ( elem.parentNode ) {
rlm@79: elem.parentNode.removeChild( elem );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Mutifunctional method to get and set values to a collection
rlm@79: // The value/s can be optionally by executed if its a function
rlm@79: function access( elems, key, value, exec, fn, pass ) {
rlm@79: var length = elems.length;
rlm@79:
rlm@79: // Setting many attributes
rlm@79: if ( typeof key === "object" ) {
rlm@79: for ( var k in key ) {
rlm@79: access( elems, k, key[k], exec, fn, value );
rlm@79: }
rlm@79: return elems;
rlm@79: }
rlm@79:
rlm@79: // Setting one attribute
rlm@79: if ( value !== undefined ) {
rlm@79: // Optionally, function values get executed if exec is true
rlm@79: exec = !pass && exec && jQuery.isFunction(value);
rlm@79:
rlm@79: for ( var i = 0; i < length; i++ ) {
rlm@79: fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
rlm@79: }
rlm@79:
rlm@79: return elems;
rlm@79: }
rlm@79:
rlm@79: // Getting an attribute
rlm@79: return length ? fn( elems[0], key ) : undefined;
rlm@79: }
rlm@79:
rlm@79: function now() {
rlm@79: return (new Date).getTime();
rlm@79: }
rlm@79: (function() {
rlm@79:
rlm@79: jQuery.support = {};
rlm@79:
rlm@79: var root = document.documentElement,
rlm@79: script = document.createElement("script"),
rlm@79: div = document.createElement("div"),
rlm@79: id = "script" + now();
rlm@79:
rlm@79: div.style.display = "none";
rlm@79: div.innerHTML = "
a";
rlm@79:
rlm@79: var all = div.getElementsByTagName("*"),
rlm@79: a = div.getElementsByTagName("a")[0];
rlm@79:
rlm@79: // Can't get basic test support
rlm@79: if ( !all || !all.length || !a ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: jQuery.support = {
rlm@79: // IE strips leading whitespace when .innerHTML is used
rlm@79: leadingWhitespace: div.firstChild.nodeType === 3,
rlm@79:
rlm@79: // Make sure that tbody elements aren't automatically inserted
rlm@79: // IE will insert them into empty tables
rlm@79: tbody: !div.getElementsByTagName("tbody").length,
rlm@79:
rlm@79: // Make sure that link elements get serialized correctly by innerHTML
rlm@79: // This requires a wrapper element in IE
rlm@79: htmlSerialize: !!div.getElementsByTagName("link").length,
rlm@79:
rlm@79: // Get the style information from getAttribute
rlm@79: // (IE uses .cssText insted)
rlm@79: style: /red/.test( a.getAttribute("style") ),
rlm@79:
rlm@79: // Make sure that URLs aren't manipulated
rlm@79: // (IE normalizes it by default)
rlm@79: hrefNormalized: a.getAttribute("href") === "/a",
rlm@79:
rlm@79: // Make sure that element opacity exists
rlm@79: // (IE uses filter instead)
rlm@79: // Use a regex to work around a WebKit issue. See #5145
rlm@79: opacity: /^0.55$/.test( a.style.opacity ),
rlm@79:
rlm@79: // Verify style float existence
rlm@79: // (IE uses styleFloat instead of cssFloat)
rlm@79: cssFloat: !!a.style.cssFloat,
rlm@79:
rlm@79: // Make sure that if no value is specified for a checkbox
rlm@79: // that it defaults to "on".
rlm@79: // (WebKit defaults to "" instead)
rlm@79: checkOn: div.getElementsByTagName("input")[0].value === "on",
rlm@79:
rlm@79: // Make sure that a selected-by-default option has a working selected property.
rlm@79: // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
rlm@79: optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
rlm@79:
rlm@79: parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null,
rlm@79:
rlm@79: // Will be defined later
rlm@79: deleteExpando: true,
rlm@79: checkClone: false,
rlm@79: scriptEval: false,
rlm@79: noCloneEvent: true,
rlm@79: boxModel: null
rlm@79: };
rlm@79:
rlm@79: script.type = "text/javascript";
rlm@79: try {
rlm@79: script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
rlm@79: } catch(e) {}
rlm@79:
rlm@79: root.insertBefore( script, root.firstChild );
rlm@79:
rlm@79: // Make sure that the execution of code works by injecting a script
rlm@79: // tag with appendChild/createTextNode
rlm@79: // (IE doesn't support this, fails, and uses .text instead)
rlm@79: if ( window[ id ] ) {
rlm@79: jQuery.support.scriptEval = true;
rlm@79: delete window[ id ];
rlm@79: }
rlm@79:
rlm@79: // Test to see if it's possible to delete an expando from an element
rlm@79: // Fails in Internet Explorer
rlm@79: try {
rlm@79: delete script.test;
rlm@79:
rlm@79: } catch(e) {
rlm@79: jQuery.support.deleteExpando = false;
rlm@79: }
rlm@79:
rlm@79: root.removeChild( script );
rlm@79:
rlm@79: if ( div.attachEvent && div.fireEvent ) {
rlm@79: div.attachEvent("onclick", function click() {
rlm@79: // Cloning a node shouldn't copy over any
rlm@79: // bound event handlers (IE does this)
rlm@79: jQuery.support.noCloneEvent = false;
rlm@79: div.detachEvent("onclick", click);
rlm@79: });
rlm@79: div.cloneNode(true).fireEvent("onclick");
rlm@79: }
rlm@79:
rlm@79: div = document.createElement("div");
rlm@79: div.innerHTML = "";
rlm@79:
rlm@79: var fragment = document.createDocumentFragment();
rlm@79: fragment.appendChild( div.firstChild );
rlm@79:
rlm@79: // WebKit doesn't clone checked state correctly in fragments
rlm@79: jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
rlm@79:
rlm@79: // Figure out if the W3C box model works as expected
rlm@79: // document.body must exist before we can do this
rlm@79: jQuery(function() {
rlm@79: var div = document.createElement("div");
rlm@79: div.style.width = div.style.paddingLeft = "1px";
rlm@79:
rlm@79: document.body.appendChild( div );
rlm@79: jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
rlm@79: document.body.removeChild( div ).style.display = 'none';
rlm@79:
rlm@79: div = null;
rlm@79: });
rlm@79:
rlm@79: // Technique from Juriy Zaytsev
rlm@79: // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
rlm@79: var eventSupported = function( eventName ) {
rlm@79: var el = document.createElement("div");
rlm@79: eventName = "on" + eventName;
rlm@79:
rlm@79: var isSupported = (eventName in el);
rlm@79: if ( !isSupported ) {
rlm@79: el.setAttribute(eventName, "return;");
rlm@79: isSupported = typeof el[eventName] === "function";
rlm@79: }
rlm@79: el = null;
rlm@79:
rlm@79: return isSupported;
rlm@79: };
rlm@79:
rlm@79: jQuery.support.submitBubbles = eventSupported("submit");
rlm@79: jQuery.support.changeBubbles = eventSupported("change");
rlm@79:
rlm@79: // release memory in IE
rlm@79: root = script = div = all = a = null;
rlm@79: })();
rlm@79:
rlm@79: jQuery.props = {
rlm@79: "for": "htmlFor",
rlm@79: "class": "className",
rlm@79: readonly: "readOnly",
rlm@79: maxlength: "maxLength",
rlm@79: cellspacing: "cellSpacing",
rlm@79: rowspan: "rowSpan",
rlm@79: colspan: "colSpan",
rlm@79: tabindex: "tabIndex",
rlm@79: usemap: "useMap",
rlm@79: frameborder: "frameBorder"
rlm@79: };
rlm@79: var expando = "jQuery" + now(), uuid = 0, windowData = {};
rlm@79:
rlm@79: jQuery.extend({
rlm@79: cache: {},
rlm@79:
rlm@79: expando:expando,
rlm@79:
rlm@79: // The following elements throw uncatchable exceptions if you
rlm@79: // attempt to add expando properties to them.
rlm@79: noData: {
rlm@79: "embed": true,
rlm@79: "object": true,
rlm@79: "applet": true
rlm@79: },
rlm@79:
rlm@79: data: function( elem, name, data ) {
rlm@79: if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: elem = elem == window ?
rlm@79: windowData :
rlm@79: elem;
rlm@79:
rlm@79: var id = elem[ expando ], cache = jQuery.cache, thisCache;
rlm@79:
rlm@79: if ( !id && typeof name === "string" && data === undefined ) {
rlm@79: return null;
rlm@79: }
rlm@79:
rlm@79: // Compute a unique ID for the element
rlm@79: if ( !id ) {
rlm@79: id = ++uuid;
rlm@79: }
rlm@79:
rlm@79: // Avoid generating a new cache unless none exists and we
rlm@79: // want to manipulate it.
rlm@79: if ( typeof name === "object" ) {
rlm@79: elem[ expando ] = id;
rlm@79: thisCache = cache[ id ] = jQuery.extend(true, {}, name);
rlm@79:
rlm@79: } else if ( !cache[ id ] ) {
rlm@79: elem[ expando ] = id;
rlm@79: cache[ id ] = {};
rlm@79: }
rlm@79:
rlm@79: thisCache = cache[ id ];
rlm@79:
rlm@79: // Prevent overriding the named cache with undefined values
rlm@79: if ( data !== undefined ) {
rlm@79: thisCache[ name ] = data;
rlm@79: }
rlm@79:
rlm@79: return typeof name === "string" ? thisCache[ name ] : thisCache;
rlm@79: },
rlm@79:
rlm@79: removeData: function( elem, name ) {
rlm@79: if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: elem = elem == window ?
rlm@79: windowData :
rlm@79: elem;
rlm@79:
rlm@79: var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
rlm@79:
rlm@79: // If we want to remove a specific section of the element's data
rlm@79: if ( name ) {
rlm@79: if ( thisCache ) {
rlm@79: // Remove the section of cache data
rlm@79: delete thisCache[ name ];
rlm@79:
rlm@79: // If we've removed all the data, remove the element's cache
rlm@79: if ( jQuery.isEmptyObject(thisCache) ) {
rlm@79: jQuery.removeData( elem );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Otherwise, we want to remove all of the element's data
rlm@79: } else {
rlm@79: if ( jQuery.support.deleteExpando ) {
rlm@79: delete elem[ jQuery.expando ];
rlm@79:
rlm@79: } else if ( elem.removeAttribute ) {
rlm@79: elem.removeAttribute( jQuery.expando );
rlm@79: }
rlm@79:
rlm@79: // Completely remove the data cache
rlm@79: delete cache[ id ];
rlm@79: }
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: jQuery.fn.extend({
rlm@79: data: function( key, value ) {
rlm@79: if ( typeof key === "undefined" && this.length ) {
rlm@79: return jQuery.data( this[0] );
rlm@79:
rlm@79: } else if ( typeof key === "object" ) {
rlm@79: return this.each(function() {
rlm@79: jQuery.data( this, key );
rlm@79: });
rlm@79: }
rlm@79:
rlm@79: var parts = key.split(".");
rlm@79: parts[1] = parts[1] ? "." + parts[1] : "";
rlm@79:
rlm@79: if ( value === undefined ) {
rlm@79: var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
rlm@79:
rlm@79: if ( data === undefined && this.length ) {
rlm@79: data = jQuery.data( this[0], key );
rlm@79: }
rlm@79: return data === undefined && parts[1] ?
rlm@79: this.data( parts[0] ) :
rlm@79: data;
rlm@79: } else {
rlm@79: return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
rlm@79: jQuery.data( this, key, value );
rlm@79: });
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: removeData: function( key ) {
rlm@79: return this.each(function() {
rlm@79: jQuery.removeData( this, key );
rlm@79: });
rlm@79: }
rlm@79: });
rlm@79: jQuery.extend({
rlm@79: queue: function( elem, type, data ) {
rlm@79: if ( !elem ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: type = (type || "fx") + "queue";
rlm@79: var q = jQuery.data( elem, type );
rlm@79:
rlm@79: // Speed up dequeue by getting out quickly if this is just a lookup
rlm@79: if ( !data ) {
rlm@79: return q || [];
rlm@79: }
rlm@79:
rlm@79: if ( !q || jQuery.isArray(data) ) {
rlm@79: q = jQuery.data( elem, type, jQuery.makeArray(data) );
rlm@79:
rlm@79: } else {
rlm@79: q.push( data );
rlm@79: }
rlm@79:
rlm@79: return q;
rlm@79: },
rlm@79:
rlm@79: dequeue: function( elem, type ) {
rlm@79: type = type || "fx";
rlm@79:
rlm@79: var queue = jQuery.queue( elem, type ), fn = queue.shift();
rlm@79:
rlm@79: // If the fx queue is dequeued, always remove the progress sentinel
rlm@79: if ( fn === "inprogress" ) {
rlm@79: fn = queue.shift();
rlm@79: }
rlm@79:
rlm@79: if ( fn ) {
rlm@79: // Add a progress sentinel to prevent the fx queue from being
rlm@79: // automatically dequeued
rlm@79: if ( type === "fx" ) {
rlm@79: queue.unshift("inprogress");
rlm@79: }
rlm@79:
rlm@79: fn.call(elem, function() {
rlm@79: jQuery.dequeue(elem, type);
rlm@79: });
rlm@79: }
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: jQuery.fn.extend({
rlm@79: queue: function( type, data ) {
rlm@79: if ( typeof type !== "string" ) {
rlm@79: data = type;
rlm@79: type = "fx";
rlm@79: }
rlm@79:
rlm@79: if ( data === undefined ) {
rlm@79: return jQuery.queue( this[0], type );
rlm@79: }
rlm@79: return this.each(function( i, elem ) {
rlm@79: var queue = jQuery.queue( this, type, data );
rlm@79:
rlm@79: if ( type === "fx" && queue[0] !== "inprogress" ) {
rlm@79: jQuery.dequeue( this, type );
rlm@79: }
rlm@79: });
rlm@79: },
rlm@79: dequeue: function( type ) {
rlm@79: return this.each(function() {
rlm@79: jQuery.dequeue( this, type );
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: // Based off of the plugin by Clint Helfers, with permission.
rlm@79: // http://blindsignals.com/index.php/2009/07/jquery-delay/
rlm@79: delay: function( time, type ) {
rlm@79: time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
rlm@79: type = type || "fx";
rlm@79:
rlm@79: return this.queue( type, function() {
rlm@79: var elem = this;
rlm@79: setTimeout(function() {
rlm@79: jQuery.dequeue( elem, type );
rlm@79: }, time );
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: clearQueue: function( type ) {
rlm@79: return this.queue( type || "fx", [] );
rlm@79: }
rlm@79: });
rlm@79: var rclass = /[\n\t]/g,
rlm@79: rspace = /\s+/,
rlm@79: rreturn = /\r/g,
rlm@79: rspecialurl = /href|src|style/,
rlm@79: rtype = /(button|input)/i,
rlm@79: rfocusable = /(button|input|object|select|textarea)/i,
rlm@79: rclickable = /^(a|area)$/i,
rlm@79: rradiocheck = /radio|checkbox/;
rlm@79:
rlm@79: jQuery.fn.extend({
rlm@79: attr: function( name, value ) {
rlm@79: return access( this, name, value, true, jQuery.attr );
rlm@79: },
rlm@79:
rlm@79: removeAttr: function( name, fn ) {
rlm@79: return this.each(function(){
rlm@79: jQuery.attr( this, name, "" );
rlm@79: if ( this.nodeType === 1 ) {
rlm@79: this.removeAttribute( name );
rlm@79: }
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: addClass: function( value ) {
rlm@79: if ( jQuery.isFunction(value) ) {
rlm@79: return this.each(function(i) {
rlm@79: var self = jQuery(this);
rlm@79: self.addClass( value.call(this, i, self.attr("class")) );
rlm@79: });
rlm@79: }
rlm@79:
rlm@79: if ( value && typeof value === "string" ) {
rlm@79: var classNames = (value || "").split( rspace );
rlm@79:
rlm@79: for ( var i = 0, l = this.length; i < l; i++ ) {
rlm@79: var elem = this[i];
rlm@79:
rlm@79: if ( elem.nodeType === 1 ) {
rlm@79: if ( !elem.className ) {
rlm@79: elem.className = value;
rlm@79:
rlm@79: } else {
rlm@79: var className = " " + elem.className + " ", setClass = elem.className;
rlm@79: for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
rlm@79: if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
rlm@79: setClass += " " + classNames[c];
rlm@79: }
rlm@79: }
rlm@79: elem.className = jQuery.trim( setClass );
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return this;
rlm@79: },
rlm@79:
rlm@79: removeClass: function( value ) {
rlm@79: if ( jQuery.isFunction(value) ) {
rlm@79: return this.each(function(i) {
rlm@79: var self = jQuery(this);
rlm@79: self.removeClass( value.call(this, i, self.attr("class")) );
rlm@79: });
rlm@79: }
rlm@79:
rlm@79: if ( (value && typeof value === "string") || value === undefined ) {
rlm@79: var classNames = (value || "").split(rspace);
rlm@79:
rlm@79: for ( var i = 0, l = this.length; i < l; i++ ) {
rlm@79: var elem = this[i];
rlm@79:
rlm@79: if ( elem.nodeType === 1 && elem.className ) {
rlm@79: if ( value ) {
rlm@79: var className = (" " + elem.className + " ").replace(rclass, " ");
rlm@79: for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
rlm@79: className = className.replace(" " + classNames[c] + " ", " ");
rlm@79: }
rlm@79: elem.className = jQuery.trim( className );
rlm@79:
rlm@79: } else {
rlm@79: elem.className = "";
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return this;
rlm@79: },
rlm@79:
rlm@79: toggleClass: function( value, stateVal ) {
rlm@79: var type = typeof value, isBool = typeof stateVal === "boolean";
rlm@79:
rlm@79: if ( jQuery.isFunction( value ) ) {
rlm@79: return this.each(function(i) {
rlm@79: var self = jQuery(this);
rlm@79: self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
rlm@79: });
rlm@79: }
rlm@79:
rlm@79: return this.each(function() {
rlm@79: if ( type === "string" ) {
rlm@79: // toggle individual class names
rlm@79: var className, i = 0, self = jQuery(this),
rlm@79: state = stateVal,
rlm@79: classNames = value.split( rspace );
rlm@79:
rlm@79: while ( (className = classNames[ i++ ]) ) {
rlm@79: // check each className given, space seperated list
rlm@79: state = isBool ? state : !self.hasClass( className );
rlm@79: self[ state ? "addClass" : "removeClass" ]( className );
rlm@79: }
rlm@79:
rlm@79: } else if ( type === "undefined" || type === "boolean" ) {
rlm@79: if ( this.className ) {
rlm@79: // store className if set
rlm@79: jQuery.data( this, "__className__", this.className );
rlm@79: }
rlm@79:
rlm@79: // toggle whole className
rlm@79: this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
rlm@79: }
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: hasClass: function( selector ) {
rlm@79: var className = " " + selector + " ";
rlm@79: for ( var i = 0, l = this.length; i < l; i++ ) {
rlm@79: if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
rlm@79: return true;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return false;
rlm@79: },
rlm@79:
rlm@79: val: function( value ) {
rlm@79: if ( value === undefined ) {
rlm@79: var elem = this[0];
rlm@79:
rlm@79: if ( elem ) {
rlm@79: if ( jQuery.nodeName( elem, "option" ) ) {
rlm@79: return (elem.attributes.value || {}).specified ? elem.value : elem.text;
rlm@79: }
rlm@79:
rlm@79: // We need to handle select boxes special
rlm@79: if ( jQuery.nodeName( elem, "select" ) ) {
rlm@79: var index = elem.selectedIndex,
rlm@79: values = [],
rlm@79: options = elem.options,
rlm@79: one = elem.type === "select-one";
rlm@79:
rlm@79: // Nothing was selected
rlm@79: if ( index < 0 ) {
rlm@79: return null;
rlm@79: }
rlm@79:
rlm@79: // Loop through all the selected options
rlm@79: for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
rlm@79: var option = options[ i ];
rlm@79:
rlm@79: if ( option.selected ) {
rlm@79: // Get the specifc value for the option
rlm@79: value = jQuery(option).val();
rlm@79:
rlm@79: // We don't need an array for one selects
rlm@79: if ( one ) {
rlm@79: return value;
rlm@79: }
rlm@79:
rlm@79: // Multi-Selects return an array
rlm@79: values.push( value );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return values;
rlm@79: }
rlm@79:
rlm@79: // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
rlm@79: if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
rlm@79: return elem.getAttribute("value") === null ? "on" : elem.value;
rlm@79: }
rlm@79:
rlm@79:
rlm@79: // Everything else, we just grab the value
rlm@79: return (elem.value || "").replace(rreturn, "");
rlm@79:
rlm@79: }
rlm@79:
rlm@79: return undefined;
rlm@79: }
rlm@79:
rlm@79: var isFunction = jQuery.isFunction(value);
rlm@79:
rlm@79: return this.each(function(i) {
rlm@79: var self = jQuery(this), val = value;
rlm@79:
rlm@79: if ( this.nodeType !== 1 ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: if ( isFunction ) {
rlm@79: val = value.call(this, i, self.val());
rlm@79: }
rlm@79:
rlm@79: // Typecast each time if the value is a Function and the appended
rlm@79: // value is therefore different each time.
rlm@79: if ( typeof val === "number" ) {
rlm@79: val += "";
rlm@79: }
rlm@79:
rlm@79: if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
rlm@79: this.checked = jQuery.inArray( self.val(), val ) >= 0;
rlm@79:
rlm@79: } else if ( jQuery.nodeName( this, "select" ) ) {
rlm@79: var values = jQuery.makeArray(val);
rlm@79:
rlm@79: jQuery( "option", this ).each(function() {
rlm@79: this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
rlm@79: });
rlm@79:
rlm@79: if ( !values.length ) {
rlm@79: this.selectedIndex = -1;
rlm@79: }
rlm@79:
rlm@79: } else {
rlm@79: this.value = val;
rlm@79: }
rlm@79: });
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: jQuery.extend({
rlm@79: attrFn: {
rlm@79: val: true,
rlm@79: css: true,
rlm@79: html: true,
rlm@79: text: true,
rlm@79: data: true,
rlm@79: width: true,
rlm@79: height: true,
rlm@79: offset: true
rlm@79: },
rlm@79:
rlm@79: attr: function( elem, name, value, pass ) {
rlm@79: // don't set attributes on text and comment nodes
rlm@79: if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
rlm@79: return undefined;
rlm@79: }
rlm@79:
rlm@79: if ( pass && name in jQuery.attrFn ) {
rlm@79: return jQuery(elem)[name](value);
rlm@79: }
rlm@79:
rlm@79: var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
rlm@79: // Whether we are setting (or getting)
rlm@79: set = value !== undefined;
rlm@79:
rlm@79: // Try to normalize/fix the name
rlm@79: name = notxml && jQuery.props[ name ] || name;
rlm@79:
rlm@79: // Only do all the following if this is a node (faster for style)
rlm@79: if ( elem.nodeType === 1 ) {
rlm@79: // These attributes require special treatment
rlm@79: var special = rspecialurl.test( name );
rlm@79:
rlm@79: // Safari mis-reports the default selected property of an option
rlm@79: // Accessing the parent's selectedIndex property fixes it
rlm@79: if ( name === "selected" && !jQuery.support.optSelected ) {
rlm@79: var parent = elem.parentNode;
rlm@79: if ( parent ) {
rlm@79: parent.selectedIndex;
rlm@79:
rlm@79: // Make sure that it also works with optgroups, see #5701
rlm@79: if ( parent.parentNode ) {
rlm@79: parent.parentNode.selectedIndex;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // If applicable, access the attribute via the DOM 0 way
rlm@79: if ( name in elem && notxml && !special ) {
rlm@79: if ( set ) {
rlm@79: // We can't allow the type property to be changed (since it causes problems in IE)
rlm@79: if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
rlm@79: jQuery.error( "type property can't be changed" );
rlm@79: }
rlm@79:
rlm@79: elem[ name ] = value;
rlm@79: }
rlm@79:
rlm@79: // browsers index elements by id/name on forms, give priority to attributes.
rlm@79: if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
rlm@79: return elem.getAttributeNode( name ).nodeValue;
rlm@79: }
rlm@79:
rlm@79: // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
rlm@79: // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
rlm@79: if ( name === "tabIndex" ) {
rlm@79: var attributeNode = elem.getAttributeNode( "tabIndex" );
rlm@79:
rlm@79: return attributeNode && attributeNode.specified ?
rlm@79: attributeNode.value :
rlm@79: rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
rlm@79: 0 :
rlm@79: undefined;
rlm@79: }
rlm@79:
rlm@79: return elem[ name ];
rlm@79: }
rlm@79:
rlm@79: if ( !jQuery.support.style && notxml && name === "style" ) {
rlm@79: if ( set ) {
rlm@79: elem.style.cssText = "" + value;
rlm@79: }
rlm@79:
rlm@79: return elem.style.cssText;
rlm@79: }
rlm@79:
rlm@79: if ( set ) {
rlm@79: // convert the value to a string (all browsers do this but IE) see #1070
rlm@79: elem.setAttribute( name, "" + value );
rlm@79: }
rlm@79:
rlm@79: var attr = !jQuery.support.hrefNormalized && notxml && special ?
rlm@79: // Some attributes require a special call on IE
rlm@79: elem.getAttribute( name, 2 ) :
rlm@79: elem.getAttribute( name );
rlm@79:
rlm@79: // Non-existent attributes return null, we normalize to undefined
rlm@79: return attr === null ? undefined : attr;
rlm@79: }
rlm@79:
rlm@79: // elem is actually elem.style ... set the style
rlm@79: // Using attr for specific style information is now deprecated. Use style instead.
rlm@79: return jQuery.style( elem, name, value );
rlm@79: }
rlm@79: });
rlm@79: var rnamespaces = /\.(.*)$/,
rlm@79: fcleanup = function( nm ) {
rlm@79: return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
rlm@79: return "\\" + ch;
rlm@79: });
rlm@79: };
rlm@79:
rlm@79: /*
rlm@79: * A number of helper functions used for managing events.
rlm@79: * Many of the ideas behind this code originated from
rlm@79: * Dean Edwards' addEvent library.
rlm@79: */
rlm@79: jQuery.event = {
rlm@79:
rlm@79: // Bind an event to an element
rlm@79: // Original by Dean Edwards
rlm@79: add: function( elem, types, handler, data ) {
rlm@79: if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: // For whatever reason, IE has trouble passing the window object
rlm@79: // around, causing it to be cloned in the process
rlm@79: if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
rlm@79: elem = window;
rlm@79: }
rlm@79:
rlm@79: var handleObjIn, handleObj;
rlm@79:
rlm@79: if ( handler.handler ) {
rlm@79: handleObjIn = handler;
rlm@79: handler = handleObjIn.handler;
rlm@79: }
rlm@79:
rlm@79: // Make sure that the function being executed has a unique ID
rlm@79: if ( !handler.guid ) {
rlm@79: handler.guid = jQuery.guid++;
rlm@79: }
rlm@79:
rlm@79: // Init the element's event structure
rlm@79: var elemData = jQuery.data( elem );
rlm@79:
rlm@79: // If no elemData is found then we must be trying to bind to one of the
rlm@79: // banned noData elements
rlm@79: if ( !elemData ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: var events = elemData.events = elemData.events || {},
rlm@79: eventHandle = elemData.handle, eventHandle;
rlm@79:
rlm@79: if ( !eventHandle ) {
rlm@79: elemData.handle = eventHandle = function() {
rlm@79: // Handle the second event of a trigger and when
rlm@79: // an event is called after a page has unloaded
rlm@79: return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
rlm@79: jQuery.event.handle.apply( eventHandle.elem, arguments ) :
rlm@79: undefined;
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: // Add elem as a property of the handle function
rlm@79: // This is to prevent a memory leak with non-native events in IE.
rlm@79: eventHandle.elem = elem;
rlm@79:
rlm@79: // Handle multiple events separated by a space
rlm@79: // jQuery(...).bind("mouseover mouseout", fn);
rlm@79: types = types.split(" ");
rlm@79:
rlm@79: var type, i = 0, namespaces;
rlm@79:
rlm@79: while ( (type = types[ i++ ]) ) {
rlm@79: handleObj = handleObjIn ?
rlm@79: jQuery.extend({}, handleObjIn) :
rlm@79: { handler: handler, data: data };
rlm@79:
rlm@79: // Namespaced event handlers
rlm@79: if ( type.indexOf(".") > -1 ) {
rlm@79: namespaces = type.split(".");
rlm@79: type = namespaces.shift();
rlm@79: handleObj.namespace = namespaces.slice(0).sort().join(".");
rlm@79:
rlm@79: } else {
rlm@79: namespaces = [];
rlm@79: handleObj.namespace = "";
rlm@79: }
rlm@79:
rlm@79: handleObj.type = type;
rlm@79: handleObj.guid = handler.guid;
rlm@79:
rlm@79: // Get the current list of functions bound to this event
rlm@79: var handlers = events[ type ],
rlm@79: special = jQuery.event.special[ type ] || {};
rlm@79:
rlm@79: // Init the event handler queue
rlm@79: if ( !handlers ) {
rlm@79: handlers = events[ type ] = [];
rlm@79:
rlm@79: // Check for a special event handler
rlm@79: // Only use addEventListener/attachEvent if the special
rlm@79: // events handler returns false
rlm@79: if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
rlm@79: // Bind the global event handler to the element
rlm@79: if ( elem.addEventListener ) {
rlm@79: elem.addEventListener( type, eventHandle, false );
rlm@79:
rlm@79: } else if ( elem.attachEvent ) {
rlm@79: elem.attachEvent( "on" + type, eventHandle );
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( special.add ) {
rlm@79: special.add.call( elem, handleObj );
rlm@79:
rlm@79: if ( !handleObj.handler.guid ) {
rlm@79: handleObj.handler.guid = handler.guid;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Add the function to the element's handler list
rlm@79: handlers.push( handleObj );
rlm@79:
rlm@79: // Keep track of which events have been used, for global triggering
rlm@79: jQuery.event.global[ type ] = true;
rlm@79: }
rlm@79:
rlm@79: // Nullify elem to prevent memory leaks in IE
rlm@79: elem = null;
rlm@79: },
rlm@79:
rlm@79: global: {},
rlm@79:
rlm@79: // Detach an event or set of events from an element
rlm@79: remove: function( elem, types, handler, pos ) {
rlm@79: // don't do events on text and comment nodes
rlm@79: if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
rlm@79: elemData = jQuery.data( elem ),
rlm@79: events = elemData && elemData.events;
rlm@79:
rlm@79: if ( !elemData || !events ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: // types is actually an event object here
rlm@79: if ( types && types.type ) {
rlm@79: handler = types.handler;
rlm@79: types = types.type;
rlm@79: }
rlm@79:
rlm@79: // Unbind all events for the element
rlm@79: if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
rlm@79: types = types || "";
rlm@79:
rlm@79: for ( type in events ) {
rlm@79: jQuery.event.remove( elem, type + types );
rlm@79: }
rlm@79:
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: // Handle multiple events separated by a space
rlm@79: // jQuery(...).unbind("mouseover mouseout", fn);
rlm@79: types = types.split(" ");
rlm@79:
rlm@79: while ( (type = types[ i++ ]) ) {
rlm@79: origType = type;
rlm@79: handleObj = null;
rlm@79: all = type.indexOf(".") < 0;
rlm@79: namespaces = [];
rlm@79:
rlm@79: if ( !all ) {
rlm@79: // Namespaced event handlers
rlm@79: namespaces = type.split(".");
rlm@79: type = namespaces.shift();
rlm@79:
rlm@79: namespace = new RegExp("(^|\\.)" +
rlm@79: jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)")
rlm@79: }
rlm@79:
rlm@79: eventType = events[ type ];
rlm@79:
rlm@79: if ( !eventType ) {
rlm@79: continue;
rlm@79: }
rlm@79:
rlm@79: if ( !handler ) {
rlm@79: for ( var j = 0; j < eventType.length; j++ ) {
rlm@79: handleObj = eventType[ j ];
rlm@79:
rlm@79: if ( all || namespace.test( handleObj.namespace ) ) {
rlm@79: jQuery.event.remove( elem, origType, handleObj.handler, j );
rlm@79: eventType.splice( j--, 1 );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: continue;
rlm@79: }
rlm@79:
rlm@79: special = jQuery.event.special[ type ] || {};
rlm@79:
rlm@79: for ( var j = pos || 0; j < eventType.length; j++ ) {
rlm@79: handleObj = eventType[ j ];
rlm@79:
rlm@79: if ( handler.guid === handleObj.guid ) {
rlm@79: // remove the given handler for the given type
rlm@79: if ( all || namespace.test( handleObj.namespace ) ) {
rlm@79: if ( pos == null ) {
rlm@79: eventType.splice( j--, 1 );
rlm@79: }
rlm@79:
rlm@79: if ( special.remove ) {
rlm@79: special.remove.call( elem, handleObj );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( pos != null ) {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // remove generic event handler if no more handlers exist
rlm@79: if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
rlm@79: if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
rlm@79: removeEvent( elem, type, elemData.handle );
rlm@79: }
rlm@79:
rlm@79: ret = null;
rlm@79: delete events[ type ];
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Remove the expando if it's no longer used
rlm@79: if ( jQuery.isEmptyObject( events ) ) {
rlm@79: var handle = elemData.handle;
rlm@79: if ( handle ) {
rlm@79: handle.elem = null;
rlm@79: }
rlm@79:
rlm@79: delete elemData.events;
rlm@79: delete elemData.handle;
rlm@79:
rlm@79: if ( jQuery.isEmptyObject( elemData ) ) {
rlm@79: jQuery.removeData( elem );
rlm@79: }
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: // bubbling is internal
rlm@79: trigger: function( event, data, elem /*, bubbling */ ) {
rlm@79: // Event object or event type
rlm@79: var type = event.type || event,
rlm@79: bubbling = arguments[3];
rlm@79:
rlm@79: if ( !bubbling ) {
rlm@79: event = typeof event === "object" ?
rlm@79: // jQuery.Event object
rlm@79: event[expando] ? event :
rlm@79: // Object literal
rlm@79: jQuery.extend( jQuery.Event(type), event ) :
rlm@79: // Just the event type (string)
rlm@79: jQuery.Event(type);
rlm@79:
rlm@79: if ( type.indexOf("!") >= 0 ) {
rlm@79: event.type = type = type.slice(0, -1);
rlm@79: event.exclusive = true;
rlm@79: }
rlm@79:
rlm@79: // Handle a global trigger
rlm@79: if ( !elem ) {
rlm@79: // Don't bubble custom events when global (to avoid too much overhead)
rlm@79: event.stopPropagation();
rlm@79:
rlm@79: // Only trigger if we've ever bound an event for it
rlm@79: if ( jQuery.event.global[ type ] ) {
rlm@79: jQuery.each( jQuery.cache, function() {
rlm@79: if ( this.events && this.events[type] ) {
rlm@79: jQuery.event.trigger( event, data, this.handle.elem );
rlm@79: }
rlm@79: });
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Handle triggering a single element
rlm@79:
rlm@79: // don't do events on text and comment nodes
rlm@79: if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
rlm@79: return undefined;
rlm@79: }
rlm@79:
rlm@79: // Clean up in case it is reused
rlm@79: event.result = undefined;
rlm@79: event.target = elem;
rlm@79:
rlm@79: // Clone the incoming data, if any
rlm@79: data = jQuery.makeArray( data );
rlm@79: data.unshift( event );
rlm@79: }
rlm@79:
rlm@79: event.currentTarget = elem;
rlm@79:
rlm@79: // Trigger the event, it is assumed that "handle" is a function
rlm@79: var handle = jQuery.data( elem, "handle" );
rlm@79: if ( handle ) {
rlm@79: handle.apply( elem, data );
rlm@79: }
rlm@79:
rlm@79: var parent = elem.parentNode || elem.ownerDocument;
rlm@79:
rlm@79: // Trigger an inline bound script
rlm@79: try {
rlm@79: if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
rlm@79: if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
rlm@79: event.result = false;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // prevent IE from throwing an error for some elements with some event types, see #3533
rlm@79: } catch (e) {}
rlm@79:
rlm@79: if ( !event.isPropagationStopped() && parent ) {
rlm@79: jQuery.event.trigger( event, data, parent, true );
rlm@79:
rlm@79: } else if ( !event.isDefaultPrevented() ) {
rlm@79: var target = event.target, old,
rlm@79: isClick = jQuery.nodeName(target, "a") && type === "click",
rlm@79: special = jQuery.event.special[ type ] || {};
rlm@79:
rlm@79: if ( (!special._default || special._default.call( elem, event ) === false) &&
rlm@79: !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
rlm@79:
rlm@79: try {
rlm@79: if ( target[ type ] ) {
rlm@79: // Make sure that we don't accidentally re-trigger the onFOO events
rlm@79: old = target[ "on" + type ];
rlm@79:
rlm@79: if ( old ) {
rlm@79: target[ "on" + type ] = null;
rlm@79: }
rlm@79:
rlm@79: jQuery.event.triggered = true;
rlm@79: target[ type ]();
rlm@79: }
rlm@79:
rlm@79: // prevent IE from throwing an error for some elements with some event types, see #3533
rlm@79: } catch (e) {}
rlm@79:
rlm@79: if ( old ) {
rlm@79: target[ "on" + type ] = old;
rlm@79: }
rlm@79:
rlm@79: jQuery.event.triggered = false;
rlm@79: }
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: handle: function( event ) {
rlm@79: var all, handlers, namespaces, namespace, events;
rlm@79:
rlm@79: event = arguments[0] = jQuery.event.fix( event || window.event );
rlm@79: event.currentTarget = this;
rlm@79:
rlm@79: // Namespaced event handlers
rlm@79: all = event.type.indexOf(".") < 0 && !event.exclusive;
rlm@79:
rlm@79: if ( !all ) {
rlm@79: namespaces = event.type.split(".");
rlm@79: event.type = namespaces.shift();
rlm@79: namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
rlm@79: }
rlm@79:
rlm@79: var events = jQuery.data(this, "events"), handlers = events[ event.type ];
rlm@79:
rlm@79: if ( events && handlers ) {
rlm@79: // Clone the handlers to prevent manipulation
rlm@79: handlers = handlers.slice(0);
rlm@79:
rlm@79: for ( var j = 0, l = handlers.length; j < l; j++ ) {
rlm@79: var handleObj = handlers[ j ];
rlm@79:
rlm@79: // Filter the functions by class
rlm@79: if ( all || namespace.test( handleObj.namespace ) ) {
rlm@79: // Pass in a reference to the handler function itself
rlm@79: // So that we can later remove it
rlm@79: event.handler = handleObj.handler;
rlm@79: event.data = handleObj.data;
rlm@79: event.handleObj = handleObj;
rlm@79:
rlm@79: var ret = handleObj.handler.apply( this, arguments );
rlm@79:
rlm@79: if ( ret !== undefined ) {
rlm@79: event.result = ret;
rlm@79: if ( ret === false ) {
rlm@79: event.preventDefault();
rlm@79: event.stopPropagation();
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( event.isImmediatePropagationStopped() ) {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return event.result;
rlm@79: },
rlm@79:
rlm@79: props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
rlm@79:
rlm@79: fix: function( event ) {
rlm@79: if ( event[ expando ] ) {
rlm@79: return event;
rlm@79: }
rlm@79:
rlm@79: // store a copy of the original event object
rlm@79: // and "clone" to set read-only properties
rlm@79: var originalEvent = event;
rlm@79: event = jQuery.Event( originalEvent );
rlm@79:
rlm@79: for ( var i = this.props.length, prop; i; ) {
rlm@79: prop = this.props[ --i ];
rlm@79: event[ prop ] = originalEvent[ prop ];
rlm@79: }
rlm@79:
rlm@79: // Fix target property, if necessary
rlm@79: if ( !event.target ) {
rlm@79: event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
rlm@79: }
rlm@79:
rlm@79: // check if target is a textnode (safari)
rlm@79: if ( event.target.nodeType === 3 ) {
rlm@79: event.target = event.target.parentNode;
rlm@79: }
rlm@79:
rlm@79: // Add relatedTarget, if necessary
rlm@79: if ( !event.relatedTarget && event.fromElement ) {
rlm@79: event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
rlm@79: }
rlm@79:
rlm@79: // Calculate pageX/Y if missing and clientX/Y available
rlm@79: if ( event.pageX == null && event.clientX != null ) {
rlm@79: var doc = document.documentElement, body = document.body;
rlm@79: event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
rlm@79: event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
rlm@79: }
rlm@79:
rlm@79: // Add which for key events
rlm@79: if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
rlm@79: event.which = event.charCode || event.keyCode;
rlm@79: }
rlm@79:
rlm@79: // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
rlm@79: if ( !event.metaKey && event.ctrlKey ) {
rlm@79: event.metaKey = event.ctrlKey;
rlm@79: }
rlm@79:
rlm@79: // Add which for click: 1 === left; 2 === middle; 3 === right
rlm@79: // Note: button is not normalized, so don't use it
rlm@79: if ( !event.which && event.button !== undefined ) {
rlm@79: event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
rlm@79: }
rlm@79:
rlm@79: return event;
rlm@79: },
rlm@79:
rlm@79: // Deprecated, use jQuery.guid instead
rlm@79: guid: 1E8,
rlm@79:
rlm@79: // Deprecated, use jQuery.proxy instead
rlm@79: proxy: jQuery.proxy,
rlm@79:
rlm@79: special: {
rlm@79: ready: {
rlm@79: // Make sure the ready event is setup
rlm@79: setup: jQuery.bindReady,
rlm@79: teardown: jQuery.noop
rlm@79: },
rlm@79:
rlm@79: live: {
rlm@79: add: function( handleObj ) {
rlm@79: jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) );
rlm@79: },
rlm@79:
rlm@79: remove: function( handleObj ) {
rlm@79: var remove = true,
rlm@79: type = handleObj.origType.replace(rnamespaces, "");
rlm@79:
rlm@79: jQuery.each( jQuery.data(this, "events").live || [], function() {
rlm@79: if ( type === this.origType.replace(rnamespaces, "") ) {
rlm@79: remove = false;
rlm@79: return false;
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: if ( remove ) {
rlm@79: jQuery.event.remove( this, handleObj.origType, liveHandler );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: },
rlm@79:
rlm@79: beforeunload: {
rlm@79: setup: function( data, namespaces, eventHandle ) {
rlm@79: // We only want to do this special case on windows
rlm@79: if ( this.setInterval ) {
rlm@79: this.onbeforeunload = eventHandle;
rlm@79: }
rlm@79:
rlm@79: return false;
rlm@79: },
rlm@79: teardown: function( namespaces, eventHandle ) {
rlm@79: if ( this.onbeforeunload === eventHandle ) {
rlm@79: this.onbeforeunload = null;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: var removeEvent = document.removeEventListener ?
rlm@79: function( elem, type, handle ) {
rlm@79: elem.removeEventListener( type, handle, false );
rlm@79: } :
rlm@79: function( elem, type, handle ) {
rlm@79: elem.detachEvent( "on" + type, handle );
rlm@79: };
rlm@79:
rlm@79: jQuery.Event = function( src ) {
rlm@79: // Allow instantiation without the 'new' keyword
rlm@79: if ( !this.preventDefault ) {
rlm@79: return new jQuery.Event( src );
rlm@79: }
rlm@79:
rlm@79: // Event object
rlm@79: if ( src && src.type ) {
rlm@79: this.originalEvent = src;
rlm@79: this.type = src.type;
rlm@79: // Event type
rlm@79: } else {
rlm@79: this.type = src;
rlm@79: }
rlm@79:
rlm@79: // timeStamp is buggy for some events on Firefox(#3843)
rlm@79: // So we won't rely on the native value
rlm@79: this.timeStamp = now();
rlm@79:
rlm@79: // Mark it as fixed
rlm@79: this[ expando ] = true;
rlm@79: };
rlm@79:
rlm@79: function returnFalse() {
rlm@79: return false;
rlm@79: }
rlm@79: function returnTrue() {
rlm@79: return true;
rlm@79: }
rlm@79:
rlm@79: // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
rlm@79: // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
rlm@79: jQuery.Event.prototype = {
rlm@79: preventDefault: function() {
rlm@79: this.isDefaultPrevented = returnTrue;
rlm@79:
rlm@79: var e = this.originalEvent;
rlm@79: if ( !e ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: // if preventDefault exists run it on the original event
rlm@79: if ( e.preventDefault ) {
rlm@79: e.preventDefault();
rlm@79: }
rlm@79: // otherwise set the returnValue property of the original event to false (IE)
rlm@79: e.returnValue = false;
rlm@79: },
rlm@79: stopPropagation: function() {
rlm@79: this.isPropagationStopped = returnTrue;
rlm@79:
rlm@79: var e = this.originalEvent;
rlm@79: if ( !e ) {
rlm@79: return;
rlm@79: }
rlm@79: // if stopPropagation exists run it on the original event
rlm@79: if ( e.stopPropagation ) {
rlm@79: e.stopPropagation();
rlm@79: }
rlm@79: // otherwise set the cancelBubble property of the original event to true (IE)
rlm@79: e.cancelBubble = true;
rlm@79: },
rlm@79: stopImmediatePropagation: function() {
rlm@79: this.isImmediatePropagationStopped = returnTrue;
rlm@79: this.stopPropagation();
rlm@79: },
rlm@79: isDefaultPrevented: returnFalse,
rlm@79: isPropagationStopped: returnFalse,
rlm@79: isImmediatePropagationStopped: returnFalse
rlm@79: };
rlm@79:
rlm@79: // Checks if an event happened on an element within another element
rlm@79: // Used in jQuery.event.special.mouseenter and mouseleave handlers
rlm@79: var withinElement = function( event ) {
rlm@79: // Check if mouse(over|out) are still within the same parent element
rlm@79: var parent = event.relatedTarget;
rlm@79:
rlm@79: // Firefox sometimes assigns relatedTarget a XUL element
rlm@79: // which we cannot access the parentNode property of
rlm@79: try {
rlm@79: // Traverse up the tree
rlm@79: while ( parent && parent !== this ) {
rlm@79: parent = parent.parentNode;
rlm@79: }
rlm@79:
rlm@79: if ( parent !== this ) {
rlm@79: // set the correct event type
rlm@79: event.type = event.data;
rlm@79:
rlm@79: // handle event if we actually just moused on to a non sub-element
rlm@79: jQuery.event.handle.apply( this, arguments );
rlm@79: }
rlm@79:
rlm@79: // assuming we've left the element since we most likely mousedover a xul element
rlm@79: } catch(e) { }
rlm@79: },
rlm@79:
rlm@79: // In case of event delegation, we only need to rename the event.type,
rlm@79: // liveHandler will take care of the rest.
rlm@79: delegate = function( event ) {
rlm@79: event.type = event.data;
rlm@79: jQuery.event.handle.apply( this, arguments );
rlm@79: };
rlm@79:
rlm@79: // Create mouseenter and mouseleave events
rlm@79: jQuery.each({
rlm@79: mouseenter: "mouseover",
rlm@79: mouseleave: "mouseout"
rlm@79: }, function( orig, fix ) {
rlm@79: jQuery.event.special[ orig ] = {
rlm@79: setup: function( data ) {
rlm@79: jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
rlm@79: },
rlm@79: teardown: function( data ) {
rlm@79: jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
rlm@79: }
rlm@79: };
rlm@79: });
rlm@79:
rlm@79: // submit delegation
rlm@79: if ( !jQuery.support.submitBubbles ) {
rlm@79:
rlm@79: jQuery.event.special.submit = {
rlm@79: setup: function( data, namespaces ) {
rlm@79: if ( this.nodeName.toLowerCase() !== "form" ) {
rlm@79: jQuery.event.add(this, "click.specialSubmit", function( e ) {
rlm@79: var elem = e.target, type = elem.type;
rlm@79:
rlm@79: if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
rlm@79: return trigger( "submit", this, arguments );
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
rlm@79: var elem = e.target, type = elem.type;
rlm@79:
rlm@79: if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
rlm@79: return trigger( "submit", this, arguments );
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: } else {
rlm@79: return false;
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: teardown: function( namespaces ) {
rlm@79: jQuery.event.remove( this, ".specialSubmit" );
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: }
rlm@79:
rlm@79: // change delegation, happens here so we have bind.
rlm@79: if ( !jQuery.support.changeBubbles ) {
rlm@79:
rlm@79: var formElems = /textarea|input|select/i,
rlm@79:
rlm@79: changeFilters,
rlm@79:
rlm@79: getVal = function( elem ) {
rlm@79: var type = elem.type, val = elem.value;
rlm@79:
rlm@79: if ( type === "radio" || type === "checkbox" ) {
rlm@79: val = elem.checked;
rlm@79:
rlm@79: } else if ( type === "select-multiple" ) {
rlm@79: val = elem.selectedIndex > -1 ?
rlm@79: jQuery.map( elem.options, function( elem ) {
rlm@79: return elem.selected;
rlm@79: }).join("-") :
rlm@79: "";
rlm@79:
rlm@79: } else if ( elem.nodeName.toLowerCase() === "select" ) {
rlm@79: val = elem.selectedIndex;
rlm@79: }
rlm@79:
rlm@79: return val;
rlm@79: },
rlm@79:
rlm@79: testChange = function testChange( e ) {
rlm@79: var elem = e.target, data, val;
rlm@79:
rlm@79: if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: data = jQuery.data( elem, "_change_data" );
rlm@79: val = getVal(elem);
rlm@79:
rlm@79: // the current data will be also retrieved by beforeactivate
rlm@79: if ( e.type !== "focusout" || elem.type !== "radio" ) {
rlm@79: jQuery.data( elem, "_change_data", val );
rlm@79: }
rlm@79:
rlm@79: if ( data === undefined || val === data ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: if ( data != null || val ) {
rlm@79: e.type = "change";
rlm@79: return jQuery.event.trigger( e, arguments[1], elem );
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: jQuery.event.special.change = {
rlm@79: filters: {
rlm@79: focusout: testChange,
rlm@79:
rlm@79: click: function( e ) {
rlm@79: var elem = e.target, type = elem.type;
rlm@79:
rlm@79: if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
rlm@79: return testChange.call( this, e );
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: // Change has to be called before submit
rlm@79: // Keydown will be called before keypress, which is used in submit-event delegation
rlm@79: keydown: function( e ) {
rlm@79: var elem = e.target, type = elem.type;
rlm@79:
rlm@79: if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
rlm@79: (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
rlm@79: type === "select-multiple" ) {
rlm@79: return testChange.call( this, e );
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: // Beforeactivate happens also before the previous element is blurred
rlm@79: // with this event you can't trigger a change event, but you can store
rlm@79: // information/focus[in] is not needed anymore
rlm@79: beforeactivate: function( e ) {
rlm@79: var elem = e.target;
rlm@79: jQuery.data( elem, "_change_data", getVal(elem) );
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: setup: function( data, namespaces ) {
rlm@79: if ( this.type === "file" ) {
rlm@79: return false;
rlm@79: }
rlm@79:
rlm@79: for ( var type in changeFilters ) {
rlm@79: jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
rlm@79: }
rlm@79:
rlm@79: return formElems.test( this.nodeName );
rlm@79: },
rlm@79:
rlm@79: teardown: function( namespaces ) {
rlm@79: jQuery.event.remove( this, ".specialChange" );
rlm@79:
rlm@79: return formElems.test( this.nodeName );
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: changeFilters = jQuery.event.special.change.filters;
rlm@79: }
rlm@79:
rlm@79: function trigger( type, elem, args ) {
rlm@79: args[0].type = type;
rlm@79: return jQuery.event.handle.apply( elem, args );
rlm@79: }
rlm@79:
rlm@79: // Create "bubbling" focus and blur events
rlm@79: if ( document.addEventListener ) {
rlm@79: jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
rlm@79: jQuery.event.special[ fix ] = {
rlm@79: setup: function() {
rlm@79: this.addEventListener( orig, handler, true );
rlm@79: },
rlm@79: teardown: function() {
rlm@79: this.removeEventListener( orig, handler, true );
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: function handler( e ) {
rlm@79: e = jQuery.event.fix( e );
rlm@79: e.type = fix;
rlm@79: return jQuery.event.handle.call( this, e );
rlm@79: }
rlm@79: });
rlm@79: }
rlm@79:
rlm@79: jQuery.each(["bind", "one"], function( i, name ) {
rlm@79: jQuery.fn[ name ] = function( type, data, fn ) {
rlm@79: // Handle object literals
rlm@79: if ( typeof type === "object" ) {
rlm@79: for ( var key in type ) {
rlm@79: this[ name ](key, data, type[key], fn);
rlm@79: }
rlm@79: return this;
rlm@79: }
rlm@79:
rlm@79: if ( jQuery.isFunction( data ) ) {
rlm@79: fn = data;
rlm@79: data = undefined;
rlm@79: }
rlm@79:
rlm@79: var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
rlm@79: jQuery( this ).unbind( event, handler );
rlm@79: return fn.apply( this, arguments );
rlm@79: }) : fn;
rlm@79:
rlm@79: if ( type === "unload" && name !== "one" ) {
rlm@79: this.one( type, data, fn );
rlm@79:
rlm@79: } else {
rlm@79: for ( var i = 0, l = this.length; i < l; i++ ) {
rlm@79: jQuery.event.add( this[i], type, handler, data );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return this;
rlm@79: };
rlm@79: });
rlm@79:
rlm@79: jQuery.fn.extend({
rlm@79: unbind: function( type, fn ) {
rlm@79: // Handle object literals
rlm@79: if ( typeof type === "object" && !type.preventDefault ) {
rlm@79: for ( var key in type ) {
rlm@79: this.unbind(key, type[key]);
rlm@79: }
rlm@79:
rlm@79: } else {
rlm@79: for ( var i = 0, l = this.length; i < l; i++ ) {
rlm@79: jQuery.event.remove( this[i], type, fn );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return this;
rlm@79: },
rlm@79:
rlm@79: delegate: function( selector, types, data, fn ) {
rlm@79: return this.live( types, data, fn, selector );
rlm@79: },
rlm@79:
rlm@79: undelegate: function( selector, types, fn ) {
rlm@79: if ( arguments.length === 0 ) {
rlm@79: return this.unbind( "live" );
rlm@79:
rlm@79: } else {
rlm@79: return this.die( types, null, fn, selector );
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: trigger: function( type, data ) {
rlm@79: return this.each(function() {
rlm@79: jQuery.event.trigger( type, data, this );
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: triggerHandler: function( type, data ) {
rlm@79: if ( this[0] ) {
rlm@79: var event = jQuery.Event( type );
rlm@79: event.preventDefault();
rlm@79: event.stopPropagation();
rlm@79: jQuery.event.trigger( event, data, this[0] );
rlm@79: return event.result;
rlm@79: }
rlm@79: },
rlm@79:
rlm@79: toggle: function( fn ) {
rlm@79: // Save reference to arguments for access in closure
rlm@79: var args = arguments, i = 1;
rlm@79:
rlm@79: // link all the functions, so any of them can unbind this click handler
rlm@79: while ( i < args.length ) {
rlm@79: jQuery.proxy( fn, args[ i++ ] );
rlm@79: }
rlm@79:
rlm@79: return this.click( jQuery.proxy( fn, function( event ) {
rlm@79: // Figure out which function to execute
rlm@79: var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
rlm@79: jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
rlm@79:
rlm@79: // Make sure that clicks stop
rlm@79: event.preventDefault();
rlm@79:
rlm@79: // and execute the function
rlm@79: return args[ lastToggle ].apply( this, arguments ) || false;
rlm@79: }));
rlm@79: },
rlm@79:
rlm@79: hover: function( fnOver, fnOut ) {
rlm@79: return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: var liveMap = {
rlm@79: focus: "focusin",
rlm@79: blur: "focusout",
rlm@79: mouseenter: "mouseover",
rlm@79: mouseleave: "mouseout"
rlm@79: };
rlm@79:
rlm@79: jQuery.each(["live", "die"], function( i, name ) {
rlm@79: jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
rlm@79: var type, i = 0, match, namespaces, preType,
rlm@79: selector = origSelector || this.selector,
rlm@79: context = origSelector ? this : jQuery( this.context );
rlm@79:
rlm@79: if ( jQuery.isFunction( data ) ) {
rlm@79: fn = data;
rlm@79: data = undefined;
rlm@79: }
rlm@79:
rlm@79: types = (types || "").split(" ");
rlm@79:
rlm@79: while ( (type = types[ i++ ]) != null ) {
rlm@79: match = rnamespaces.exec( type );
rlm@79: namespaces = "";
rlm@79:
rlm@79: if ( match ) {
rlm@79: namespaces = match[0];
rlm@79: type = type.replace( rnamespaces, "" );
rlm@79: }
rlm@79:
rlm@79: if ( type === "hover" ) {
rlm@79: types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
rlm@79: continue;
rlm@79: }
rlm@79:
rlm@79: preType = type;
rlm@79:
rlm@79: if ( type === "focus" || type === "blur" ) {
rlm@79: types.push( liveMap[ type ] + namespaces );
rlm@79: type = type + namespaces;
rlm@79:
rlm@79: } else {
rlm@79: type = (liveMap[ type ] || type) + namespaces;
rlm@79: }
rlm@79:
rlm@79: if ( name === "live" ) {
rlm@79: // bind live handler
rlm@79: context.each(function(){
rlm@79: jQuery.event.add( this, liveConvert( type, selector ),
rlm@79: { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
rlm@79: });
rlm@79:
rlm@79: } else {
rlm@79: // unbind live handler
rlm@79: context.unbind( liveConvert( type, selector ), fn );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return this;
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: function liveHandler( event ) {
rlm@79: var stop, elems = [], selectors = [], args = arguments,
rlm@79: related, match, handleObj, elem, j, i, l, data,
rlm@79: events = jQuery.data( this, "events" );
rlm@79:
rlm@79: // Make sure we avoid non-left-click bubbling in Firefox (#3861)
rlm@79: if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: event.liveFired = this;
rlm@79:
rlm@79: var live = events.live.slice(0);
rlm@79:
rlm@79: for ( j = 0; j < live.length; j++ ) {
rlm@79: handleObj = live[j];
rlm@79:
rlm@79: if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
rlm@79: selectors.push( handleObj.selector );
rlm@79:
rlm@79: } else {
rlm@79: live.splice( j--, 1 );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: match = jQuery( event.target ).closest( selectors, event.currentTarget );
rlm@79:
rlm@79: for ( i = 0, l = match.length; i < l; i++ ) {
rlm@79: for ( j = 0; j < live.length; j++ ) {
rlm@79: handleObj = live[j];
rlm@79:
rlm@79: if ( match[i].selector === handleObj.selector ) {
rlm@79: elem = match[i].elem;
rlm@79: related = null;
rlm@79:
rlm@79: // Those two events require additional checking
rlm@79: if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
rlm@79: related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
rlm@79: }
rlm@79:
rlm@79: if ( !related || related !== elem ) {
rlm@79: elems.push({ elem: elem, handleObj: handleObj });
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: for ( i = 0, l = elems.length; i < l; i++ ) {
rlm@79: match = elems[i];
rlm@79: event.currentTarget = match.elem;
rlm@79: event.data = match.handleObj.data;
rlm@79: event.handleObj = match.handleObj;
rlm@79:
rlm@79: if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) {
rlm@79: stop = false;
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return stop;
rlm@79: }
rlm@79:
rlm@79: function liveConvert( type, selector ) {
rlm@79: return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
rlm@79: }
rlm@79:
rlm@79: jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
rlm@79: "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
rlm@79: "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
rlm@79:
rlm@79: // Handle event binding
rlm@79: jQuery.fn[ name ] = function( fn ) {
rlm@79: return fn ? this.bind( name, fn ) : this.trigger( name );
rlm@79: };
rlm@79:
rlm@79: if ( jQuery.attrFn ) {
rlm@79: jQuery.attrFn[ name ] = true;
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: // Prevent memory leaks in IE
rlm@79: // Window isn't included so as not to unbind existing unload events
rlm@79: // More info:
rlm@79: // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
rlm@79: if ( window.attachEvent && !window.addEventListener ) {
rlm@79: window.attachEvent("onunload", function() {
rlm@79: for ( var id in jQuery.cache ) {
rlm@79: if ( jQuery.cache[ id ].handle ) {
rlm@79: // Try/Catch is to handle iframes being unloaded, see #4280
rlm@79: try {
rlm@79: jQuery.event.remove( jQuery.cache[ id ].handle.elem );
rlm@79: } catch(e) {}
rlm@79: }
rlm@79: }
rlm@79: });
rlm@79: }
rlm@79: /*!
rlm@79: * Sizzle CSS Selector Engine - v1.0
rlm@79: * Copyright 2009, The Dojo Foundation
rlm@79: * Released under the MIT, BSD, and GPL Licenses.
rlm@79: * More information: http://sizzlejs.com/
rlm@79: */
rlm@79: (function(){
rlm@79:
rlm@79: var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
rlm@79: done = 0,
rlm@79: toString = Object.prototype.toString,
rlm@79: hasDuplicate = false,
rlm@79: baseHasDuplicate = true;
rlm@79:
rlm@79: // Here we check if the JavaScript engine is using some sort of
rlm@79: // optimization where it does not always call our comparision
rlm@79: // function. If that is the case, discard the hasDuplicate value.
rlm@79: // Thus far that includes Google Chrome.
rlm@79: [0, 0].sort(function(){
rlm@79: baseHasDuplicate = false;
rlm@79: return 0;
rlm@79: });
rlm@79:
rlm@79: var Sizzle = function(selector, context, results, seed) {
rlm@79: results = results || [];
rlm@79: var origContext = context = context || document;
rlm@79:
rlm@79: if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
rlm@79: return [];
rlm@79: }
rlm@79:
rlm@79: if ( !selector || typeof selector !== "string" ) {
rlm@79: return results;
rlm@79: }
rlm@79:
rlm@79: var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
rlm@79: soFar = selector;
rlm@79:
rlm@79: // Reset the position of the chunker regexp (start from head)
rlm@79: while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
rlm@79: soFar = m[3];
rlm@79:
rlm@79: parts.push( m[1] );
rlm@79:
rlm@79: if ( m[2] ) {
rlm@79: extra = m[3];
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( parts.length > 1 && origPOS.exec( selector ) ) {
rlm@79: if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
rlm@79: set = posProcess( parts[0] + parts[1], context );
rlm@79: } else {
rlm@79: set = Expr.relative[ parts[0] ] ?
rlm@79: [ context ] :
rlm@79: Sizzle( parts.shift(), context );
rlm@79:
rlm@79: while ( parts.length ) {
rlm@79: selector = parts.shift();
rlm@79:
rlm@79: if ( Expr.relative[ selector ] ) {
rlm@79: selector += parts.shift();
rlm@79: }
rlm@79:
rlm@79: set = posProcess( selector, set );
rlm@79: }
rlm@79: }
rlm@79: } else {
rlm@79: // Take a shortcut and set the context if the root selector is an ID
rlm@79: // (but not if it'll be faster if the inner selector is an ID)
rlm@79: if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
rlm@79: Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
rlm@79: var ret = Sizzle.find( parts.shift(), context, contextXML );
rlm@79: context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
rlm@79: }
rlm@79:
rlm@79: if ( context ) {
rlm@79: var ret = seed ?
rlm@79: { expr: parts.pop(), set: makeArray(seed) } :
rlm@79: Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
rlm@79: set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
rlm@79:
rlm@79: if ( parts.length > 0 ) {
rlm@79: checkSet = makeArray(set);
rlm@79: } else {
rlm@79: prune = false;
rlm@79: }
rlm@79:
rlm@79: while ( parts.length ) {
rlm@79: var cur = parts.pop(), pop = cur;
rlm@79:
rlm@79: if ( !Expr.relative[ cur ] ) {
rlm@79: cur = "";
rlm@79: } else {
rlm@79: pop = parts.pop();
rlm@79: }
rlm@79:
rlm@79: if ( pop == null ) {
rlm@79: pop = context;
rlm@79: }
rlm@79:
rlm@79: Expr.relative[ cur ]( checkSet, pop, contextXML );
rlm@79: }
rlm@79: } else {
rlm@79: checkSet = parts = [];
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( !checkSet ) {
rlm@79: checkSet = set;
rlm@79: }
rlm@79:
rlm@79: if ( !checkSet ) {
rlm@79: Sizzle.error( cur || selector );
rlm@79: }
rlm@79:
rlm@79: if ( toString.call(checkSet) === "[object Array]" ) {
rlm@79: if ( !prune ) {
rlm@79: results.push.apply( results, checkSet );
rlm@79: } else if ( context && context.nodeType === 1 ) {
rlm@79: for ( var i = 0; checkSet[i] != null; i++ ) {
rlm@79: if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
rlm@79: results.push( set[i] );
rlm@79: }
rlm@79: }
rlm@79: } else {
rlm@79: for ( var i = 0; checkSet[i] != null; i++ ) {
rlm@79: if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
rlm@79: results.push( set[i] );
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: } else {
rlm@79: makeArray( checkSet, results );
rlm@79: }
rlm@79:
rlm@79: if ( extra ) {
rlm@79: Sizzle( extra, origContext, results, seed );
rlm@79: Sizzle.uniqueSort( results );
rlm@79: }
rlm@79:
rlm@79: return results;
rlm@79: };
rlm@79:
rlm@79: Sizzle.uniqueSort = function(results){
rlm@79: if ( sortOrder ) {
rlm@79: hasDuplicate = baseHasDuplicate;
rlm@79: results.sort(sortOrder);
rlm@79:
rlm@79: if ( hasDuplicate ) {
rlm@79: for ( var i = 1; i < results.length; i++ ) {
rlm@79: if ( results[i] === results[i-1] ) {
rlm@79: results.splice(i--, 1);
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return results;
rlm@79: };
rlm@79:
rlm@79: Sizzle.matches = function(expr, set){
rlm@79: return Sizzle(expr, null, null, set);
rlm@79: };
rlm@79:
rlm@79: Sizzle.find = function(expr, context, isXML){
rlm@79: var set, match;
rlm@79:
rlm@79: if ( !expr ) {
rlm@79: return [];
rlm@79: }
rlm@79:
rlm@79: for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
rlm@79: var type = Expr.order[i], match;
rlm@79:
rlm@79: if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
rlm@79: var left = match[1];
rlm@79: match.splice(1,1);
rlm@79:
rlm@79: if ( left.substr( left.length - 1 ) !== "\\" ) {
rlm@79: match[1] = (match[1] || "").replace(/\\/g, "");
rlm@79: set = Expr.find[ type ]( match, context, isXML );
rlm@79: if ( set != null ) {
rlm@79: expr = expr.replace( Expr.match[ type ], "" );
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( !set ) {
rlm@79: set = context.getElementsByTagName("*");
rlm@79: }
rlm@79:
rlm@79: return {set: set, expr: expr};
rlm@79: };
rlm@79:
rlm@79: Sizzle.filter = function(expr, set, inplace, not){
rlm@79: var old = expr, result = [], curLoop = set, match, anyFound,
rlm@79: isXMLFilter = set && set[0] && isXML(set[0]);
rlm@79:
rlm@79: while ( expr && set.length ) {
rlm@79: for ( var type in Expr.filter ) {
rlm@79: if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
rlm@79: var filter = Expr.filter[ type ], found, item, left = match[1];
rlm@79: anyFound = false;
rlm@79:
rlm@79: match.splice(1,1);
rlm@79:
rlm@79: if ( left.substr( left.length - 1 ) === "\\" ) {
rlm@79: continue;
rlm@79: }
rlm@79:
rlm@79: if ( curLoop === result ) {
rlm@79: result = [];
rlm@79: }
rlm@79:
rlm@79: if ( Expr.preFilter[ type ] ) {
rlm@79: match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
rlm@79:
rlm@79: if ( !match ) {
rlm@79: anyFound = found = true;
rlm@79: } else if ( match === true ) {
rlm@79: continue;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( match ) {
rlm@79: for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
rlm@79: if ( item ) {
rlm@79: found = filter( item, match, i, curLoop );
rlm@79: var pass = not ^ !!found;
rlm@79:
rlm@79: if ( inplace && found != null ) {
rlm@79: if ( pass ) {
rlm@79: anyFound = true;
rlm@79: } else {
rlm@79: curLoop[i] = false;
rlm@79: }
rlm@79: } else if ( pass ) {
rlm@79: result.push( item );
rlm@79: anyFound = true;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( found !== undefined ) {
rlm@79: if ( !inplace ) {
rlm@79: curLoop = result;
rlm@79: }
rlm@79:
rlm@79: expr = expr.replace( Expr.match[ type ], "" );
rlm@79:
rlm@79: if ( !anyFound ) {
rlm@79: return [];
rlm@79: }
rlm@79:
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: // Improper expression
rlm@79: if ( expr === old ) {
rlm@79: if ( anyFound == null ) {
rlm@79: Sizzle.error( expr );
rlm@79: } else {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: old = expr;
rlm@79: }
rlm@79:
rlm@79: return curLoop;
rlm@79: };
rlm@79:
rlm@79: Sizzle.error = function( msg ) {
rlm@79: throw "Syntax error, unrecognized expression: " + msg;
rlm@79: };
rlm@79:
rlm@79: var Expr = Sizzle.selectors = {
rlm@79: order: [ "ID", "NAME", "TAG" ],
rlm@79: match: {
rlm@79: ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
rlm@79: CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
rlm@79: NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
rlm@79: ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
rlm@79: TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
rlm@79: CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
rlm@79: POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
rlm@79: PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
rlm@79: },
rlm@79: leftMatch: {},
rlm@79: attrMap: {
rlm@79: "class": "className",
rlm@79: "for": "htmlFor"
rlm@79: },
rlm@79: attrHandle: {
rlm@79: href: function(elem){
rlm@79: return elem.getAttribute("href");
rlm@79: }
rlm@79: },
rlm@79: relative: {
rlm@79: "+": function(checkSet, part){
rlm@79: var isPartStr = typeof part === "string",
rlm@79: isTag = isPartStr && !/\W/.test(part),
rlm@79: isPartStrNotTag = isPartStr && !isTag;
rlm@79:
rlm@79: if ( isTag ) {
rlm@79: part = part.toLowerCase();
rlm@79: }
rlm@79:
rlm@79: for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
rlm@79: if ( (elem = checkSet[i]) ) {
rlm@79: while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
rlm@79:
rlm@79: checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
rlm@79: elem || false :
rlm@79: elem === part;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( isPartStrNotTag ) {
rlm@79: Sizzle.filter( part, checkSet, true );
rlm@79: }
rlm@79: },
rlm@79: ">": function(checkSet, part){
rlm@79: var isPartStr = typeof part === "string";
rlm@79:
rlm@79: if ( isPartStr && !/\W/.test(part) ) {
rlm@79: part = part.toLowerCase();
rlm@79:
rlm@79: for ( var i = 0, l = checkSet.length; i < l; i++ ) {
rlm@79: var elem = checkSet[i];
rlm@79: if ( elem ) {
rlm@79: var parent = elem.parentNode;
rlm@79: checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
rlm@79: }
rlm@79: }
rlm@79: } else {
rlm@79: for ( var i = 0, l = checkSet.length; i < l; i++ ) {
rlm@79: var elem = checkSet[i];
rlm@79: if ( elem ) {
rlm@79: checkSet[i] = isPartStr ?
rlm@79: elem.parentNode :
rlm@79: elem.parentNode === part;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: if ( isPartStr ) {
rlm@79: Sizzle.filter( part, checkSet, true );
rlm@79: }
rlm@79: }
rlm@79: },
rlm@79: "": function(checkSet, part, isXML){
rlm@79: var doneName = done++, checkFn = dirCheck;
rlm@79:
rlm@79: if ( typeof part === "string" && !/\W/.test(part) ) {
rlm@79: var nodeCheck = part = part.toLowerCase();
rlm@79: checkFn = dirNodeCheck;
rlm@79: }
rlm@79:
rlm@79: checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
rlm@79: },
rlm@79: "~": function(checkSet, part, isXML){
rlm@79: var doneName = done++, checkFn = dirCheck;
rlm@79:
rlm@79: if ( typeof part === "string" && !/\W/.test(part) ) {
rlm@79: var nodeCheck = part = part.toLowerCase();
rlm@79: checkFn = dirNodeCheck;
rlm@79: }
rlm@79:
rlm@79: checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
rlm@79: }
rlm@79: },
rlm@79: find: {
rlm@79: ID: function(match, context, isXML){
rlm@79: if ( typeof context.getElementById !== "undefined" && !isXML ) {
rlm@79: var m = context.getElementById(match[1]);
rlm@79: return m ? [m] : [];
rlm@79: }
rlm@79: },
rlm@79: NAME: function(match, context){
rlm@79: if ( typeof context.getElementsByName !== "undefined" ) {
rlm@79: var ret = [], results = context.getElementsByName(match[1]);
rlm@79:
rlm@79: for ( var i = 0, l = results.length; i < l; i++ ) {
rlm@79: if ( results[i].getAttribute("name") === match[1] ) {
rlm@79: ret.push( results[i] );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret.length === 0 ? null : ret;
rlm@79: }
rlm@79: },
rlm@79: TAG: function(match, context){
rlm@79: return context.getElementsByTagName(match[1]);
rlm@79: }
rlm@79: },
rlm@79: preFilter: {
rlm@79: CLASS: function(match, curLoop, inplace, result, not, isXML){
rlm@79: match = " " + match[1].replace(/\\/g, "") + " ";
rlm@79:
rlm@79: if ( isXML ) {
rlm@79: return match;
rlm@79: }
rlm@79:
rlm@79: for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
rlm@79: if ( elem ) {
rlm@79: if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
rlm@79: if ( !inplace ) {
rlm@79: result.push( elem );
rlm@79: }
rlm@79: } else if ( inplace ) {
rlm@79: curLoop[i] = false;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return false;
rlm@79: },
rlm@79: ID: function(match){
rlm@79: return match[1].replace(/\\/g, "");
rlm@79: },
rlm@79: TAG: function(match, curLoop){
rlm@79: return match[1].toLowerCase();
rlm@79: },
rlm@79: CHILD: function(match){
rlm@79: if ( match[1] === "nth" ) {
rlm@79: // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
rlm@79: var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
rlm@79: match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
rlm@79: !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
rlm@79:
rlm@79: // calculate the numbers (first)n+(last) including if they are negative
rlm@79: match[2] = (test[1] + (test[2] || 1)) - 0;
rlm@79: match[3] = test[3] - 0;
rlm@79: }
rlm@79:
rlm@79: // TODO: Move to normal caching system
rlm@79: match[0] = done++;
rlm@79:
rlm@79: return match;
rlm@79: },
rlm@79: ATTR: function(match, curLoop, inplace, result, not, isXML){
rlm@79: var name = match[1].replace(/\\/g, "");
rlm@79:
rlm@79: if ( !isXML && Expr.attrMap[name] ) {
rlm@79: match[1] = Expr.attrMap[name];
rlm@79: }
rlm@79:
rlm@79: if ( match[2] === "~=" ) {
rlm@79: match[4] = " " + match[4] + " ";
rlm@79: }
rlm@79:
rlm@79: return match;
rlm@79: },
rlm@79: PSEUDO: function(match, curLoop, inplace, result, not){
rlm@79: if ( match[1] === "not" ) {
rlm@79: // If we're dealing with a complex expression, or a simple one
rlm@79: if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
rlm@79: match[3] = Sizzle(match[3], null, null, curLoop);
rlm@79: } else {
rlm@79: var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
rlm@79: if ( !inplace ) {
rlm@79: result.push.apply( result, ret );
rlm@79: }
rlm@79: return false;
rlm@79: }
rlm@79: } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
rlm@79: return true;
rlm@79: }
rlm@79:
rlm@79: return match;
rlm@79: },
rlm@79: POS: function(match){
rlm@79: match.unshift( true );
rlm@79: return match;
rlm@79: }
rlm@79: },
rlm@79: filters: {
rlm@79: enabled: function(elem){
rlm@79: return elem.disabled === false && elem.type !== "hidden";
rlm@79: },
rlm@79: disabled: function(elem){
rlm@79: return elem.disabled === true;
rlm@79: },
rlm@79: checked: function(elem){
rlm@79: return elem.checked === true;
rlm@79: },
rlm@79: selected: function(elem){
rlm@79: // Accessing this property makes selected-by-default
rlm@79: // options in Safari work properly
rlm@79: elem.parentNode.selectedIndex;
rlm@79: return elem.selected === true;
rlm@79: },
rlm@79: parent: function(elem){
rlm@79: return !!elem.firstChild;
rlm@79: },
rlm@79: empty: function(elem){
rlm@79: return !elem.firstChild;
rlm@79: },
rlm@79: has: function(elem, i, match){
rlm@79: return !!Sizzle( match[3], elem ).length;
rlm@79: },
rlm@79: header: function(elem){
rlm@79: return /h\d/i.test( elem.nodeName );
rlm@79: },
rlm@79: text: function(elem){
rlm@79: return "text" === elem.type;
rlm@79: },
rlm@79: radio: function(elem){
rlm@79: return "radio" === elem.type;
rlm@79: },
rlm@79: checkbox: function(elem){
rlm@79: return "checkbox" === elem.type;
rlm@79: },
rlm@79: file: function(elem){
rlm@79: return "file" === elem.type;
rlm@79: },
rlm@79: password: function(elem){
rlm@79: return "password" === elem.type;
rlm@79: },
rlm@79: submit: function(elem){
rlm@79: return "submit" === elem.type;
rlm@79: },
rlm@79: image: function(elem){
rlm@79: return "image" === elem.type;
rlm@79: },
rlm@79: reset: function(elem){
rlm@79: return "reset" === elem.type;
rlm@79: },
rlm@79: button: function(elem){
rlm@79: return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
rlm@79: },
rlm@79: input: function(elem){
rlm@79: return /input|select|textarea|button/i.test(elem.nodeName);
rlm@79: }
rlm@79: },
rlm@79: setFilters: {
rlm@79: first: function(elem, i){
rlm@79: return i === 0;
rlm@79: },
rlm@79: last: function(elem, i, match, array){
rlm@79: return i === array.length - 1;
rlm@79: },
rlm@79: even: function(elem, i){
rlm@79: return i % 2 === 0;
rlm@79: },
rlm@79: odd: function(elem, i){
rlm@79: return i % 2 === 1;
rlm@79: },
rlm@79: lt: function(elem, i, match){
rlm@79: return i < match[3] - 0;
rlm@79: },
rlm@79: gt: function(elem, i, match){
rlm@79: return i > match[3] - 0;
rlm@79: },
rlm@79: nth: function(elem, i, match){
rlm@79: return match[3] - 0 === i;
rlm@79: },
rlm@79: eq: function(elem, i, match){
rlm@79: return match[3] - 0 === i;
rlm@79: }
rlm@79: },
rlm@79: filter: {
rlm@79: PSEUDO: function(elem, match, i, array){
rlm@79: var name = match[1], filter = Expr.filters[ name ];
rlm@79:
rlm@79: if ( filter ) {
rlm@79: return filter( elem, i, match, array );
rlm@79: } else if ( name === "contains" ) {
rlm@79: return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
rlm@79: } else if ( name === "not" ) {
rlm@79: var not = match[3];
rlm@79:
rlm@79: for ( var i = 0, l = not.length; i < l; i++ ) {
rlm@79: if ( not[i] === elem ) {
rlm@79: return false;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return true;
rlm@79: } else {
rlm@79: Sizzle.error( "Syntax error, unrecognized expression: " + name );
rlm@79: }
rlm@79: },
rlm@79: CHILD: function(elem, match){
rlm@79: var type = match[1], node = elem;
rlm@79: switch (type) {
rlm@79: case 'only':
rlm@79: case 'first':
rlm@79: while ( (node = node.previousSibling) ) {
rlm@79: if ( node.nodeType === 1 ) {
rlm@79: return false;
rlm@79: }
rlm@79: }
rlm@79: if ( type === "first" ) {
rlm@79: return true;
rlm@79: }
rlm@79: node = elem;
rlm@79: case 'last':
rlm@79: while ( (node = node.nextSibling) ) {
rlm@79: if ( node.nodeType === 1 ) {
rlm@79: return false;
rlm@79: }
rlm@79: }
rlm@79: return true;
rlm@79: case 'nth':
rlm@79: var first = match[2], last = match[3];
rlm@79:
rlm@79: if ( first === 1 && last === 0 ) {
rlm@79: return true;
rlm@79: }
rlm@79:
rlm@79: var doneName = match[0],
rlm@79: parent = elem.parentNode;
rlm@79:
rlm@79: if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
rlm@79: var count = 0;
rlm@79: for ( node = parent.firstChild; node; node = node.nextSibling ) {
rlm@79: if ( node.nodeType === 1 ) {
rlm@79: node.nodeIndex = ++count;
rlm@79: }
rlm@79: }
rlm@79: parent.sizcache = doneName;
rlm@79: }
rlm@79:
rlm@79: var diff = elem.nodeIndex - last;
rlm@79: if ( first === 0 ) {
rlm@79: return diff === 0;
rlm@79: } else {
rlm@79: return ( diff % first === 0 && diff / first >= 0 );
rlm@79: }
rlm@79: }
rlm@79: },
rlm@79: ID: function(elem, match){
rlm@79: return elem.nodeType === 1 && elem.getAttribute("id") === match;
rlm@79: },
rlm@79: TAG: function(elem, match){
rlm@79: return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
rlm@79: },
rlm@79: CLASS: function(elem, match){
rlm@79: return (" " + (elem.className || elem.getAttribute("class")) + " ")
rlm@79: .indexOf( match ) > -1;
rlm@79: },
rlm@79: ATTR: function(elem, match){
rlm@79: var name = match[1],
rlm@79: result = Expr.attrHandle[ name ] ?
rlm@79: Expr.attrHandle[ name ]( elem ) :
rlm@79: elem[ name ] != null ?
rlm@79: elem[ name ] :
rlm@79: elem.getAttribute( name ),
rlm@79: value = result + "",
rlm@79: type = match[2],
rlm@79: check = match[4];
rlm@79:
rlm@79: return result == null ?
rlm@79: type === "!=" :
rlm@79: type === "=" ?
rlm@79: value === check :
rlm@79: type === "*=" ?
rlm@79: value.indexOf(check) >= 0 :
rlm@79: type === "~=" ?
rlm@79: (" " + value + " ").indexOf(check) >= 0 :
rlm@79: !check ?
rlm@79: value && result !== false :
rlm@79: type === "!=" ?
rlm@79: value !== check :
rlm@79: type === "^=" ?
rlm@79: value.indexOf(check) === 0 :
rlm@79: type === "$=" ?
rlm@79: value.substr(value.length - check.length) === check :
rlm@79: type === "|=" ?
rlm@79: value === check || value.substr(0, check.length + 1) === check + "-" :
rlm@79: false;
rlm@79: },
rlm@79: POS: function(elem, match, i, array){
rlm@79: var name = match[2], filter = Expr.setFilters[ name ];
rlm@79:
rlm@79: if ( filter ) {
rlm@79: return filter( elem, i, match, array );
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: var origPOS = Expr.match.POS;
rlm@79:
rlm@79: for ( var type in Expr.match ) {
rlm@79: Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
rlm@79: Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
rlm@79: return "\\" + (num - 0 + 1);
rlm@79: }));
rlm@79: }
rlm@79:
rlm@79: var makeArray = function(array, results) {
rlm@79: array = Array.prototype.slice.call( array, 0 );
rlm@79:
rlm@79: if ( results ) {
rlm@79: results.push.apply( results, array );
rlm@79: return results;
rlm@79: }
rlm@79:
rlm@79: return array;
rlm@79: };
rlm@79:
rlm@79: // Perform a simple check to determine if the browser is capable of
rlm@79: // converting a NodeList to an array using builtin methods.
rlm@79: // Also verifies that the returned array holds DOM nodes
rlm@79: // (which is not the case in the Blackberry browser)
rlm@79: try {
rlm@79: Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
rlm@79:
rlm@79: // Provide a fallback method if it does not work
rlm@79: } catch(e){
rlm@79: makeArray = function(array, results) {
rlm@79: var ret = results || [];
rlm@79:
rlm@79: if ( toString.call(array) === "[object Array]" ) {
rlm@79: Array.prototype.push.apply( ret, array );
rlm@79: } else {
rlm@79: if ( typeof array.length === "number" ) {
rlm@79: for ( var i = 0, l = array.length; i < l; i++ ) {
rlm@79: ret.push( array[i] );
rlm@79: }
rlm@79: } else {
rlm@79: for ( var i = 0; array[i]; i++ ) {
rlm@79: ret.push( array[i] );
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret;
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: var sortOrder;
rlm@79:
rlm@79: if ( document.documentElement.compareDocumentPosition ) {
rlm@79: sortOrder = function( a, b ) {
rlm@79: if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
rlm@79: if ( a == b ) {
rlm@79: hasDuplicate = true;
rlm@79: }
rlm@79: return a.compareDocumentPosition ? -1 : 1;
rlm@79: }
rlm@79:
rlm@79: var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
rlm@79: if ( ret === 0 ) {
rlm@79: hasDuplicate = true;
rlm@79: }
rlm@79: return ret;
rlm@79: };
rlm@79: } else if ( "sourceIndex" in document.documentElement ) {
rlm@79: sortOrder = function( a, b ) {
rlm@79: if ( !a.sourceIndex || !b.sourceIndex ) {
rlm@79: if ( a == b ) {
rlm@79: hasDuplicate = true;
rlm@79: }
rlm@79: return a.sourceIndex ? -1 : 1;
rlm@79: }
rlm@79:
rlm@79: var ret = a.sourceIndex - b.sourceIndex;
rlm@79: if ( ret === 0 ) {
rlm@79: hasDuplicate = true;
rlm@79: }
rlm@79: return ret;
rlm@79: };
rlm@79: } else if ( document.createRange ) {
rlm@79: sortOrder = function( a, b ) {
rlm@79: if ( !a.ownerDocument || !b.ownerDocument ) {
rlm@79: if ( a == b ) {
rlm@79: hasDuplicate = true;
rlm@79: }
rlm@79: return a.ownerDocument ? -1 : 1;
rlm@79: }
rlm@79:
rlm@79: var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
rlm@79: aRange.setStart(a, 0);
rlm@79: aRange.setEnd(a, 0);
rlm@79: bRange.setStart(b, 0);
rlm@79: bRange.setEnd(b, 0);
rlm@79: var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
rlm@79: if ( ret === 0 ) {
rlm@79: hasDuplicate = true;
rlm@79: }
rlm@79: return ret;
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: // Utility function for retreiving the text value of an array of DOM nodes
rlm@79: function getText( elems ) {
rlm@79: var ret = "", elem;
rlm@79:
rlm@79: for ( var i = 0; elems[i]; i++ ) {
rlm@79: elem = elems[i];
rlm@79:
rlm@79: // Get the text from text nodes and CDATA nodes
rlm@79: if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
rlm@79: ret += elem.nodeValue;
rlm@79:
rlm@79: // Traverse everything else, except comment nodes
rlm@79: } else if ( elem.nodeType !== 8 ) {
rlm@79: ret += getText( elem.childNodes );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret;
rlm@79: }
rlm@79:
rlm@79: // Check to see if the browser returns elements by name when
rlm@79: // querying by getElementById (and provide a workaround)
rlm@79: (function(){
rlm@79: // We're going to inject a fake input element with a specified name
rlm@79: var form = document.createElement("div"),
rlm@79: id = "script" + (new Date).getTime();
rlm@79: form.innerHTML = "";
rlm@79:
rlm@79: // Inject it into the root element, check its status, and remove it quickly
rlm@79: var root = document.documentElement;
rlm@79: root.insertBefore( form, root.firstChild );
rlm@79:
rlm@79: // The workaround has to do additional checks after a getElementById
rlm@79: // Which slows things down for other browsers (hence the branching)
rlm@79: if ( document.getElementById( id ) ) {
rlm@79: Expr.find.ID = function(match, context, isXML){
rlm@79: if ( typeof context.getElementById !== "undefined" && !isXML ) {
rlm@79: var m = context.getElementById(match[1]);
rlm@79: return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: Expr.filter.ID = function(elem, match){
rlm@79: var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
rlm@79: return elem.nodeType === 1 && node && node.nodeValue === match;
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: root.removeChild( form );
rlm@79: root = form = null; // release memory in IE
rlm@79: })();
rlm@79:
rlm@79: (function(){
rlm@79: // Check to see if the browser returns only elements
rlm@79: // when doing getElementsByTagName("*")
rlm@79:
rlm@79: // Create a fake element
rlm@79: var div = document.createElement("div");
rlm@79: div.appendChild( document.createComment("") );
rlm@79:
rlm@79: // Make sure no comments are found
rlm@79: if ( div.getElementsByTagName("*").length > 0 ) {
rlm@79: Expr.find.TAG = function(match, context){
rlm@79: var results = context.getElementsByTagName(match[1]);
rlm@79:
rlm@79: // Filter out possible comments
rlm@79: if ( match[1] === "*" ) {
rlm@79: var tmp = [];
rlm@79:
rlm@79: for ( var i = 0; results[i]; i++ ) {
rlm@79: if ( results[i].nodeType === 1 ) {
rlm@79: tmp.push( results[i] );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: results = tmp;
rlm@79: }
rlm@79:
rlm@79: return results;
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: // Check to see if an attribute returns normalized href attributes
rlm@79: div.innerHTML = "";
rlm@79: if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
rlm@79: div.firstChild.getAttribute("href") !== "#" ) {
rlm@79: Expr.attrHandle.href = function(elem){
rlm@79: return elem.getAttribute("href", 2);
rlm@79: };
rlm@79: }
rlm@79:
rlm@79: div = null; // release memory in IE
rlm@79: })();
rlm@79:
rlm@79: if ( document.querySelectorAll ) {
rlm@79: (function(){
rlm@79: var oldSizzle = Sizzle, div = document.createElement("div");
rlm@79: div.innerHTML = "";
rlm@79:
rlm@79: // Safari can't handle uppercase or unicode characters when
rlm@79: // in quirks mode.
rlm@79: if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: Sizzle = function(query, context, extra, seed){
rlm@79: context = context || document;
rlm@79:
rlm@79: // Only use querySelectorAll on non-XML documents
rlm@79: // (ID selectors don't work in non-HTML documents)
rlm@79: if ( !seed && context.nodeType === 9 && !isXML(context) ) {
rlm@79: try {
rlm@79: return makeArray( context.querySelectorAll(query), extra );
rlm@79: } catch(e){}
rlm@79: }
rlm@79:
rlm@79: return oldSizzle(query, context, extra, seed);
rlm@79: };
rlm@79:
rlm@79: for ( var prop in oldSizzle ) {
rlm@79: Sizzle[ prop ] = oldSizzle[ prop ];
rlm@79: }
rlm@79:
rlm@79: div = null; // release memory in IE
rlm@79: })();
rlm@79: }
rlm@79:
rlm@79: (function(){
rlm@79: var div = document.createElement("div");
rlm@79:
rlm@79: div.innerHTML = "";
rlm@79:
rlm@79: // Opera can't find a second classname (in 9.6)
rlm@79: // Also, make sure that getElementsByClassName actually exists
rlm@79: if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: // Safari caches class attributes, doesn't catch changes (in 3.2)
rlm@79: div.lastChild.className = "e";
rlm@79:
rlm@79: if ( div.getElementsByClassName("e").length === 1 ) {
rlm@79: return;
rlm@79: }
rlm@79:
rlm@79: Expr.order.splice(1, 0, "CLASS");
rlm@79: Expr.find.CLASS = function(match, context, isXML) {
rlm@79: if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
rlm@79: return context.getElementsByClassName(match[1]);
rlm@79: }
rlm@79: };
rlm@79:
rlm@79: div = null; // release memory in IE
rlm@79: })();
rlm@79:
rlm@79: function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
rlm@79: for ( var i = 0, l = checkSet.length; i < l; i++ ) {
rlm@79: var elem = checkSet[i];
rlm@79: if ( elem ) {
rlm@79: elem = elem[dir];
rlm@79: var match = false;
rlm@79:
rlm@79: while ( elem ) {
rlm@79: if ( elem.sizcache === doneName ) {
rlm@79: match = checkSet[elem.sizset];
rlm@79: break;
rlm@79: }
rlm@79:
rlm@79: if ( elem.nodeType === 1 && !isXML ){
rlm@79: elem.sizcache = doneName;
rlm@79: elem.sizset = i;
rlm@79: }
rlm@79:
rlm@79: if ( elem.nodeName.toLowerCase() === cur ) {
rlm@79: match = elem;
rlm@79: break;
rlm@79: }
rlm@79:
rlm@79: elem = elem[dir];
rlm@79: }
rlm@79:
rlm@79: checkSet[i] = match;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
rlm@79: for ( var i = 0, l = checkSet.length; i < l; i++ ) {
rlm@79: var elem = checkSet[i];
rlm@79: if ( elem ) {
rlm@79: elem = elem[dir];
rlm@79: var match = false;
rlm@79:
rlm@79: while ( elem ) {
rlm@79: if ( elem.sizcache === doneName ) {
rlm@79: match = checkSet[elem.sizset];
rlm@79: break;
rlm@79: }
rlm@79:
rlm@79: if ( elem.nodeType === 1 ) {
rlm@79: if ( !isXML ) {
rlm@79: elem.sizcache = doneName;
rlm@79: elem.sizset = i;
rlm@79: }
rlm@79: if ( typeof cur !== "string" ) {
rlm@79: if ( elem === cur ) {
rlm@79: match = true;
rlm@79: break;
rlm@79: }
rlm@79:
rlm@79: } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
rlm@79: match = elem;
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: elem = elem[dir];
rlm@79: }
rlm@79:
rlm@79: checkSet[i] = match;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: var contains = document.compareDocumentPosition ? function(a, b){
rlm@79: return !!(a.compareDocumentPosition(b) & 16);
rlm@79: } : function(a, b){
rlm@79: return a !== b && (a.contains ? a.contains(b) : true);
rlm@79: };
rlm@79:
rlm@79: var isXML = function(elem){
rlm@79: // documentElement is verified for cases where it doesn't yet exist
rlm@79: // (such as loading iframes in IE - #4833)
rlm@79: var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
rlm@79: return documentElement ? documentElement.nodeName !== "HTML" : false;
rlm@79: };
rlm@79:
rlm@79: var posProcess = function(selector, context){
rlm@79: var tmpSet = [], later = "", match,
rlm@79: root = context.nodeType ? [context] : context;
rlm@79:
rlm@79: // Position selectors must be done after the filter
rlm@79: // And so must :not(positional) so we move all PSEUDOs to the end
rlm@79: while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
rlm@79: later += match[0];
rlm@79: selector = selector.replace( Expr.match.PSEUDO, "" );
rlm@79: }
rlm@79:
rlm@79: selector = Expr.relative[selector] ? selector + "*" : selector;
rlm@79:
rlm@79: for ( var i = 0, l = root.length; i < l; i++ ) {
rlm@79: Sizzle( selector, root[i], tmpSet );
rlm@79: }
rlm@79:
rlm@79: return Sizzle.filter( later, tmpSet );
rlm@79: };
rlm@79:
rlm@79: // EXPOSE
rlm@79: jQuery.find = Sizzle;
rlm@79: jQuery.expr = Sizzle.selectors;
rlm@79: jQuery.expr[":"] = jQuery.expr.filters;
rlm@79: jQuery.unique = Sizzle.uniqueSort;
rlm@79: jQuery.text = getText;
rlm@79: jQuery.isXMLDoc = isXML;
rlm@79: jQuery.contains = contains;
rlm@79:
rlm@79: return;
rlm@79:
rlm@79: window.Sizzle = Sizzle;
rlm@79:
rlm@79: })();
rlm@79: var runtil = /Until$/,
rlm@79: rparentsprev = /^(?:parents|prevUntil|prevAll)/,
rlm@79: // Note: This RegExp should be improved, or likely pulled from Sizzle
rlm@79: rmultiselector = /,/,
rlm@79: slice = Array.prototype.slice;
rlm@79:
rlm@79: // Implement the identical functionality for filter and not
rlm@79: var winnow = function( elements, qualifier, keep ) {
rlm@79: if ( jQuery.isFunction( qualifier ) ) {
rlm@79: return jQuery.grep(elements, function( elem, i ) {
rlm@79: return !!qualifier.call( elem, i, elem ) === keep;
rlm@79: });
rlm@79:
rlm@79: } else if ( qualifier.nodeType ) {
rlm@79: return jQuery.grep(elements, function( elem, i ) {
rlm@79: return (elem === qualifier) === keep;
rlm@79: });
rlm@79:
rlm@79: } else if ( typeof qualifier === "string" ) {
rlm@79: var filtered = jQuery.grep(elements, function( elem ) {
rlm@79: return elem.nodeType === 1;
rlm@79: });
rlm@79:
rlm@79: if ( isSimple.test( qualifier ) ) {
rlm@79: return jQuery.filter(qualifier, filtered, !keep);
rlm@79: } else {
rlm@79: qualifier = jQuery.filter( qualifier, filtered );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return jQuery.grep(elements, function( elem, i ) {
rlm@79: return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
rlm@79: });
rlm@79: };
rlm@79:
rlm@79: jQuery.fn.extend({
rlm@79: find: function( selector ) {
rlm@79: var ret = this.pushStack( "", "find", selector ), length = 0;
rlm@79:
rlm@79: for ( var i = 0, l = this.length; i < l; i++ ) {
rlm@79: length = ret.length;
rlm@79: jQuery.find( selector, this[i], ret );
rlm@79:
rlm@79: if ( i > 0 ) {
rlm@79: // Make sure that the results are unique
rlm@79: for ( var n = length; n < ret.length; n++ ) {
rlm@79: for ( var r = 0; r < length; r++ ) {
rlm@79: if ( ret[r] === ret[n] ) {
rlm@79: ret.splice(n--, 1);
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret;
rlm@79: },
rlm@79:
rlm@79: has: function( target ) {
rlm@79: var targets = jQuery( target );
rlm@79: return this.filter(function() {
rlm@79: for ( var i = 0, l = targets.length; i < l; i++ ) {
rlm@79: if ( jQuery.contains( this, targets[i] ) ) {
rlm@79: return true;
rlm@79: }
rlm@79: }
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: not: function( selector ) {
rlm@79: return this.pushStack( winnow(this, selector, false), "not", selector);
rlm@79: },
rlm@79:
rlm@79: filter: function( selector ) {
rlm@79: return this.pushStack( winnow(this, selector, true), "filter", selector );
rlm@79: },
rlm@79:
rlm@79: is: function( selector ) {
rlm@79: return !!selector && jQuery.filter( selector, this ).length > 0;
rlm@79: },
rlm@79:
rlm@79: closest: function( selectors, context ) {
rlm@79: if ( jQuery.isArray( selectors ) ) {
rlm@79: var ret = [], cur = this[0], match, matches = {}, selector;
rlm@79:
rlm@79: if ( cur && selectors.length ) {
rlm@79: for ( var i = 0, l = selectors.length; i < l; i++ ) {
rlm@79: selector = selectors[i];
rlm@79:
rlm@79: if ( !matches[selector] ) {
rlm@79: matches[selector] = jQuery.expr.match.POS.test( selector ) ?
rlm@79: jQuery( selector, context || this.context ) :
rlm@79: selector;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: while ( cur && cur.ownerDocument && cur !== context ) {
rlm@79: for ( selector in matches ) {
rlm@79: match = matches[selector];
rlm@79:
rlm@79: if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
rlm@79: ret.push({ selector: selector, elem: cur });
rlm@79: delete matches[selector];
rlm@79: }
rlm@79: }
rlm@79: cur = cur.parentNode;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return ret;
rlm@79: }
rlm@79:
rlm@79: var pos = jQuery.expr.match.POS.test( selectors ) ?
rlm@79: jQuery( selectors, context || this.context ) : null;
rlm@79:
rlm@79: return this.map(function( i, cur ) {
rlm@79: while ( cur && cur.ownerDocument && cur !== context ) {
rlm@79: if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
rlm@79: return cur;
rlm@79: }
rlm@79: cur = cur.parentNode;
rlm@79: }
rlm@79: return null;
rlm@79: });
rlm@79: },
rlm@79:
rlm@79: // Determine the position of an element within
rlm@79: // the matched set of elements
rlm@79: index: function( elem ) {
rlm@79: if ( !elem || typeof elem === "string" ) {
rlm@79: return jQuery.inArray( this[0],
rlm@79: // If it receives a string, the selector is used
rlm@79: // If it receives nothing, the siblings are used
rlm@79: elem ? jQuery( elem ) : this.parent().children() );
rlm@79: }
rlm@79: // Locate the position of the desired element
rlm@79: return jQuery.inArray(
rlm@79: // If it receives a jQuery object, the first element is used
rlm@79: elem.jquery ? elem[0] : elem, this );
rlm@79: },
rlm@79:
rlm@79: add: function( selector, context ) {
rlm@79: var set = typeof selector === "string" ?
rlm@79: jQuery( selector, context || this.context ) :
rlm@79: jQuery.makeArray( selector ),
rlm@79: all = jQuery.merge( this.get(), set );
rlm@79:
rlm@79: return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
rlm@79: all :
rlm@79: jQuery.unique( all ) );
rlm@79: },
rlm@79:
rlm@79: andSelf: function() {
rlm@79: return this.add( this.prevObject );
rlm@79: }
rlm@79: });
rlm@79:
rlm@79: // A painfully simple check to see if an element is disconnected
rlm@79: // from a document (should be improved, where feasible).
rlm@79: function isDisconnected( node ) {
rlm@79: return !node || !node.parentNode || node.parentNode.nodeType === 11;
rlm@79: }
rlm@79:
rlm@79: jQuery.each({
rlm@79: parent: function( elem ) {
rlm@79: var parent = elem.parentNode;
rlm@79: return parent && parent.nodeType !== 11 ? parent : null;
rlm@79: },
rlm@79: parents: function( elem ) {
rlm@79: return jQuery.dir( elem, "parentNode" );
rlm@79: },
rlm@79: parentsUntil: function( elem, i, until ) {
rlm@79: return jQuery.dir( elem, "parentNode", until );
rlm@79: },
rlm@79: next: function( elem ) {
rlm@79: return jQuery.nth( elem, 2, "nextSibling" );
rlm@79: },
rlm@79: prev: function( elem ) {
rlm@79: return jQuery.nth( elem, 2, "previousSibling" );
rlm@79: },
rlm@79: nextAll: function( elem ) {
rlm@79: return jQuery.dir( elem, "nextSibling" );
rlm@79: },
rlm@79: prevAll: function( elem ) {
rlm@79: return jQuery.dir( elem, "previousSibling" );
rlm@79: },
rlm@79: nextUntil: function( elem, i, until ) {
rlm@79: return jQuery.dir( elem, "nextSibling", until );
rlm@79: },
rlm@79: prevUntil: function( elem, i, until ) {
rlm@79: return jQuery.dir( elem, "previousSibling", until );
rlm@79: },
rlm@79: siblings: function( elem ) {
rlm@79: return jQuery.sibling( elem.parentNode.firstChild, elem );
rlm@79: },
rlm@79: children: function( elem ) {
rlm@79: return jQuery.sibling( elem.firstChild );
rlm@79: },
rlm@79: contents: function( elem ) {
rlm@79: return jQuery.nodeName( elem, "iframe" ) ?
rlm@79: elem.contentDocument || elem.contentWindow.document :
rlm@79: jQuery.makeArray( elem.childNodes );
rlm@79: }
rlm@79: }, function( name, fn ) {
rlm@79: jQuery.fn[ name ] = function( until, selector ) {
rlm@79: var ret = jQuery.map( this, fn, until );
rlm@79:
rlm@79: if ( !runtil.test( name ) ) {
rlm@79: selector = until;
rlm@79: }
rlm@79:
rlm@79: if ( selector && typeof selector === "string" ) {
rlm@79: ret = jQuery.filter( selector, ret );
rlm@79: }
rlm@79:
rlm@79: ret = this.length > 1 ? jQuery.unique( ret ) : ret;
rlm@79:
rlm@79: if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
rlm@79: ret = ret.reverse();
rlm@79: }
rlm@79:
rlm@79: return this.pushStack( ret, name, slice.call(arguments).join(",") );
rlm@79: };
rlm@79: });
rlm@79:
rlm@79: jQuery.extend({
rlm@79: filter: function( expr, elems, not ) {
rlm@79: if ( not ) {
rlm@79: expr = ":not(" + expr + ")";
rlm@79: }
rlm@79:
rlm@79: return jQuery.find.matches(expr, elems);
rlm@79: },
rlm@79:
rlm@79: dir: function( elem, dir, until ) {
rlm@79: var matched = [], cur = elem[dir];
rlm@79: while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
rlm@79: if ( cur.nodeType === 1 ) {
rlm@79: matched.push( cur );
rlm@79: }
rlm@79: cur = cur[dir];
rlm@79: }
rlm@79: return matched;
rlm@79: },
rlm@79:
rlm@79: nth: function( cur, result, dir, elem ) {
rlm@79: result = result || 1;
rlm@79: var num = 0;
rlm@79:
rlm@79: for ( ; cur; cur = cur[dir] ) {
rlm@79: if ( cur.nodeType === 1 && ++num === result ) {
rlm@79: break;
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return cur;
rlm@79: },
rlm@79:
rlm@79: sibling: function( n, elem ) {
rlm@79: var r = [];
rlm@79:
rlm@79: for ( ; n; n = n.nextSibling ) {
rlm@79: if ( n.nodeType === 1 && n !== elem ) {
rlm@79: r.push( n );
rlm@79: }
rlm@79: }
rlm@79:
rlm@79: return r;
rlm@79: }
rlm@79: });
rlm@79: var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rlm@79: rleadingWhitespace = /^\s+/,
rlm@79: rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
rlm@79: rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
rlm@79: rtagName = /<([\w:]+)/,
rlm@79: rtbody = /" + tag + ">";
rlm@79: },
rlm@79: wrapMap = {
rlm@79: option: [ 1, "" ],
rlm@79: legend: [ 1, "" ],
rlm@79: thead: [ 1, "" ],
rlm@79: tr: [ 2, "" ],
rlm@79: td: [ 3, "" ],
rlm@79: col: [ 2, "" ],
rlm@79: area: [ 1, "" ],
rlm@79: _default: [ 0, "", "" ]
rlm@79: };
rlm@79:
rlm@79: wrapMap.optgroup = wrapMap.option;
rlm@79: wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
rlm@79: wrapMap.th = wrapMap.td;
rlm@79:
rlm@79: // IE can't serialize and