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