gyorgy@0: /*!
gyorgy@0: * jQuery JavaScript Library v1.6.1
gyorgy@0: * http://jquery.com/
gyorgy@0: *
gyorgy@0: * Copyright 2011, John Resig
gyorgy@0: * Dual licensed under the MIT or GPL Version 2 licenses.
gyorgy@0: * http://jquery.org/license
gyorgy@0: *
gyorgy@0: * Includes Sizzle.js
gyorgy@0: * http://sizzlejs.com/
gyorgy@0: * Copyright 2011, The Dojo Foundation
gyorgy@0: * Released under the MIT, BSD, and GPL Licenses.
gyorgy@0: *
gyorgy@0: * Date: Thu May 12 15:04:36 2011 -0400
gyorgy@0: */
gyorgy@0: (function( window, undefined ) {
gyorgy@0:
gyorgy@0: // Use the correct document accordingly with window argument (sandbox)
gyorgy@0: var document = window.document,
gyorgy@0: navigator = window.navigator,
gyorgy@0: location = window.location;
gyorgy@0: var jQuery = (function() {
gyorgy@0:
gyorgy@0: // Define a local copy of jQuery
gyorgy@0: var jQuery = function( selector, context ) {
gyorgy@0: // The jQuery object is actually just the init constructor 'enhanced'
gyorgy@0: return new jQuery.fn.init( selector, context, rootjQuery );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Map over jQuery in case of overwrite
gyorgy@0: _jQuery = window.jQuery,
gyorgy@0:
gyorgy@0: // Map over the $ in case of overwrite
gyorgy@0: _$ = window.$,
gyorgy@0:
gyorgy@0: // A central reference to the root jQuery(document)
gyorgy@0: rootjQuery,
gyorgy@0:
gyorgy@0: // A simple way to check for HTML strings or ID strings
gyorgy@0: // (both of which we optimize for)
gyorgy@0: quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
gyorgy@0:
gyorgy@0: // Check if a string has a non-whitespace character in it
gyorgy@0: rnotwhite = /\S/,
gyorgy@0:
gyorgy@0: // Used for trimming whitespace
gyorgy@0: trimLeft = /^\s+/,
gyorgy@0: trimRight = /\s+$/,
gyorgy@0:
gyorgy@0: // Check for digits
gyorgy@0: rdigit = /\d/,
gyorgy@0:
gyorgy@0: // Match a standalone tag
gyorgy@0: rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
gyorgy@0:
gyorgy@0: // JSON RegExp
gyorgy@0: rvalidchars = /^[\],:{}\s]*$/,
gyorgy@0: rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
gyorgy@0: rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
gyorgy@0: rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
gyorgy@0:
gyorgy@0: // Useragent RegExp
gyorgy@0: rwebkit = /(webkit)[ \/]([\w.]+)/,
gyorgy@0: ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
gyorgy@0: rmsie = /(msie) ([\w.]+)/,
gyorgy@0: rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
gyorgy@0:
gyorgy@0: // Keep a UserAgent string for use with jQuery.browser
gyorgy@0: userAgent = navigator.userAgent,
gyorgy@0:
gyorgy@0: // For matching the engine and version of the browser
gyorgy@0: browserMatch,
gyorgy@0:
gyorgy@0: // The deferred used on DOM ready
gyorgy@0: readyList,
gyorgy@0:
gyorgy@0: // The ready event handler
gyorgy@0: DOMContentLoaded,
gyorgy@0:
gyorgy@0: // Save a reference to some core methods
gyorgy@0: toString = Object.prototype.toString,
gyorgy@0: hasOwn = Object.prototype.hasOwnProperty,
gyorgy@0: push = Array.prototype.push,
gyorgy@0: slice = Array.prototype.slice,
gyorgy@0: trim = String.prototype.trim,
gyorgy@0: indexOf = Array.prototype.indexOf,
gyorgy@0:
gyorgy@0: // [[Class]] -> type pairs
gyorgy@0: class2type = {};
gyorgy@0:
gyorgy@0: jQuery.fn = jQuery.prototype = {
gyorgy@0: constructor: jQuery,
gyorgy@0: init: function( selector, context, rootjQuery ) {
gyorgy@0: var match, elem, ret, doc;
gyorgy@0:
gyorgy@0: // Handle $(""), $(null), or $(undefined)
gyorgy@0: if ( !selector ) {
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Handle $(DOMElement)
gyorgy@0: if ( selector.nodeType ) {
gyorgy@0: this.context = this[0] = selector;
gyorgy@0: this.length = 1;
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // The body element only exists once, optimize finding it
gyorgy@0: if ( selector === "body" && !context && document.body ) {
gyorgy@0: this.context = document;
gyorgy@0: this[0] = document.body;
gyorgy@0: this.selector = selector;
gyorgy@0: this.length = 1;
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Handle HTML strings
gyorgy@0: if ( typeof selector === "string" ) {
gyorgy@0: // Are we dealing with HTML string or an ID?
gyorgy@0: if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
gyorgy@0: // Assume that strings that start and end with <> are HTML and skip the regex check
gyorgy@0: match = [ null, selector, null ];
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: match = quickExpr.exec( selector );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Verify a match, and that no context was specified for #id
gyorgy@0: if ( match && (match[1] || !context) ) {
gyorgy@0:
gyorgy@0: // HANDLE: $(html) -> $(array)
gyorgy@0: if ( match[1] ) {
gyorgy@0: context = context instanceof jQuery ? context[0] : context;
gyorgy@0: doc = (context ? context.ownerDocument || context : document);
gyorgy@0:
gyorgy@0: // If a single string is passed in and it's a single tag
gyorgy@0: // just do a createElement and skip the rest
gyorgy@0: ret = rsingleTag.exec( selector );
gyorgy@0:
gyorgy@0: if ( ret ) {
gyorgy@0: if ( jQuery.isPlainObject( context ) ) {
gyorgy@0: selector = [ document.createElement( ret[1] ) ];
gyorgy@0: jQuery.fn.attr.call( selector, context, true );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: selector = [ doc.createElement( ret[1] ) ];
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
gyorgy@0: selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return jQuery.merge( this, selector );
gyorgy@0:
gyorgy@0: // HANDLE: $("#id")
gyorgy@0: } else {
gyorgy@0: elem = document.getElementById( match[2] );
gyorgy@0:
gyorgy@0: // Check parentNode to catch when Blackberry 4.6 returns
gyorgy@0: // nodes that are no longer in the document #6963
gyorgy@0: if ( elem && elem.parentNode ) {
gyorgy@0: // Handle the case where IE and Opera return items
gyorgy@0: // by name instead of ID
gyorgy@0: if ( elem.id !== match[2] ) {
gyorgy@0: return rootjQuery.find( selector );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Otherwise, we inject the element directly into the jQuery object
gyorgy@0: this.length = 1;
gyorgy@0: this[0] = elem;
gyorgy@0: }
gyorgy@0:
gyorgy@0: this.context = document;
gyorgy@0: this.selector = selector;
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // HANDLE: $(expr, $(...))
gyorgy@0: } else if ( !context || context.jquery ) {
gyorgy@0: return (context || rootjQuery).find( selector );
gyorgy@0:
gyorgy@0: // HANDLE: $(expr, context)
gyorgy@0: // (which is just equivalent to: $(context).find(expr)
gyorgy@0: } else {
gyorgy@0: return this.constructor( context ).find( selector );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // HANDLE: $(function)
gyorgy@0: // Shortcut for document ready
gyorgy@0: } else if ( jQuery.isFunction( selector ) ) {
gyorgy@0: return rootjQuery.ready( selector );
gyorgy@0: }
gyorgy@0:
gyorgy@0: if (selector.selector !== undefined) {
gyorgy@0: this.selector = selector.selector;
gyorgy@0: this.context = selector.context;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return jQuery.makeArray( selector, this );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Start with an empty selector
gyorgy@0: selector: "",
gyorgy@0:
gyorgy@0: // The current version of jQuery being used
gyorgy@0: jquery: "1.6.1",
gyorgy@0:
gyorgy@0: // The default length of a jQuery object is 0
gyorgy@0: length: 0,
gyorgy@0:
gyorgy@0: // The number of elements contained in the matched element set
gyorgy@0: size: function() {
gyorgy@0: return this.length;
gyorgy@0: },
gyorgy@0:
gyorgy@0: toArray: function() {
gyorgy@0: return slice.call( this, 0 );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Get the Nth element in the matched element set OR
gyorgy@0: // Get the whole matched element set as a clean array
gyorgy@0: get: function( num ) {
gyorgy@0: return num == null ?
gyorgy@0:
gyorgy@0: // Return a 'clean' array
gyorgy@0: this.toArray() :
gyorgy@0:
gyorgy@0: // Return just the object
gyorgy@0: ( num < 0 ? this[ this.length + num ] : this[ num ] );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Take an array of elements and push it onto the stack
gyorgy@0: // (returning the new matched element set)
gyorgy@0: pushStack: function( elems, name, selector ) {
gyorgy@0: // Build a new jQuery matched element set
gyorgy@0: var ret = this.constructor();
gyorgy@0:
gyorgy@0: if ( jQuery.isArray( elems ) ) {
gyorgy@0: push.apply( ret, elems );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: jQuery.merge( ret, elems );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add the old object onto the stack (as a reference)
gyorgy@0: ret.prevObject = this;
gyorgy@0:
gyorgy@0: ret.context = this.context;
gyorgy@0:
gyorgy@0: if ( name === "find" ) {
gyorgy@0: ret.selector = this.selector + (this.selector ? " " : "") + selector;
gyorgy@0: } else if ( name ) {
gyorgy@0: ret.selector = this.selector + "." + name + "(" + selector + ")";
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Return the newly-formed element set
gyorgy@0: return ret;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Execute a callback for every element in the matched set.
gyorgy@0: // (You can seed the arguments with an array of args, but this is
gyorgy@0: // only used internally.)
gyorgy@0: each: function( callback, args ) {
gyorgy@0: return jQuery.each( this, callback, args );
gyorgy@0: },
gyorgy@0:
gyorgy@0: ready: function( fn ) {
gyorgy@0: // Attach the listeners
gyorgy@0: jQuery.bindReady();
gyorgy@0:
gyorgy@0: // Add the callback
gyorgy@0: readyList.done( fn );
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: eq: function( i ) {
gyorgy@0: return i === -1 ?
gyorgy@0: this.slice( i ) :
gyorgy@0: this.slice( i, +i + 1 );
gyorgy@0: },
gyorgy@0:
gyorgy@0: first: function() {
gyorgy@0: return this.eq( 0 );
gyorgy@0: },
gyorgy@0:
gyorgy@0: last: function() {
gyorgy@0: return this.eq( -1 );
gyorgy@0: },
gyorgy@0:
gyorgy@0: slice: function() {
gyorgy@0: return this.pushStack( slice.apply( this, arguments ),
gyorgy@0: "slice", slice.call(arguments).join(",") );
gyorgy@0: },
gyorgy@0:
gyorgy@0: map: function( callback ) {
gyorgy@0: return this.pushStack( jQuery.map(this, function( elem, i ) {
gyorgy@0: return callback.call( elem, i, elem );
gyorgy@0: }));
gyorgy@0: },
gyorgy@0:
gyorgy@0: end: function() {
gyorgy@0: return this.prevObject || this.constructor(null);
gyorgy@0: },
gyorgy@0:
gyorgy@0: // For internal use only.
gyorgy@0: // Behaves like an Array's method, not like a jQuery method.
gyorgy@0: push: push,
gyorgy@0: sort: [].sort,
gyorgy@0: splice: [].splice
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Give the init function the jQuery prototype for later instantiation
gyorgy@0: jQuery.fn.init.prototype = jQuery.fn;
gyorgy@0:
gyorgy@0: jQuery.extend = jQuery.fn.extend = function() {
gyorgy@0: var options, name, src, copy, copyIsArray, clone,
gyorgy@0: target = arguments[0] || {},
gyorgy@0: i = 1,
gyorgy@0: length = arguments.length,
gyorgy@0: deep = false;
gyorgy@0:
gyorgy@0: // Handle a deep copy situation
gyorgy@0: if ( typeof target === "boolean" ) {
gyorgy@0: deep = target;
gyorgy@0: target = arguments[1] || {};
gyorgy@0: // skip the boolean and the target
gyorgy@0: i = 2;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Handle case when target is a string or something (possible in deep copy)
gyorgy@0: if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
gyorgy@0: target = {};
gyorgy@0: }
gyorgy@0:
gyorgy@0: // extend jQuery itself if only one argument is passed
gyorgy@0: if ( length === i ) {
gyorgy@0: target = this;
gyorgy@0: --i;
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( ; i < length; i++ ) {
gyorgy@0: // Only deal with non-null/undefined values
gyorgy@0: if ( (options = arguments[ i ]) != null ) {
gyorgy@0: // Extend the base object
gyorgy@0: for ( name in options ) {
gyorgy@0: src = target[ name ];
gyorgy@0: copy = options[ name ];
gyorgy@0:
gyorgy@0: // Prevent never-ending loop
gyorgy@0: if ( target === copy ) {
gyorgy@0: continue;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Recurse if we're merging plain objects or arrays
gyorgy@0: if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
gyorgy@0: if ( copyIsArray ) {
gyorgy@0: copyIsArray = false;
gyorgy@0: clone = src && jQuery.isArray(src) ? src : [];
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: clone = src && jQuery.isPlainObject(src) ? src : {};
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Never move original objects, clone them
gyorgy@0: target[ name ] = jQuery.extend( deep, clone, copy );
gyorgy@0:
gyorgy@0: // Don't bring in undefined values
gyorgy@0: } else if ( copy !== undefined ) {
gyorgy@0: target[ name ] = copy;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Return the modified object
gyorgy@0: return target;
gyorgy@0: };
gyorgy@0:
gyorgy@0: jQuery.extend({
gyorgy@0: noConflict: function( deep ) {
gyorgy@0: if ( window.$ === jQuery ) {
gyorgy@0: window.$ = _$;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( deep && window.jQuery === jQuery ) {
gyorgy@0: window.jQuery = _jQuery;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return jQuery;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Is the DOM ready to be used? Set to true once it occurs.
gyorgy@0: isReady: false,
gyorgy@0:
gyorgy@0: // A counter to track how many items to wait for before
gyorgy@0: // the ready event fires. See #6781
gyorgy@0: readyWait: 1,
gyorgy@0:
gyorgy@0: // Hold (or release) the ready event
gyorgy@0: holdReady: function( hold ) {
gyorgy@0: if ( hold ) {
gyorgy@0: jQuery.readyWait++;
gyorgy@0: } else {
gyorgy@0: jQuery.ready( true );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Handle when the DOM is ready
gyorgy@0: ready: function( wait ) {
gyorgy@0: // Either a released hold or an DOMready/load event and not yet ready
gyorgy@0: if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
gyorgy@0: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
gyorgy@0: if ( !document.body ) {
gyorgy@0: return setTimeout( jQuery.ready, 1 );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Remember that the DOM is ready
gyorgy@0: jQuery.isReady = true;
gyorgy@0:
gyorgy@0: // If a normal DOM Ready event fired, decrement, and wait if need be
gyorgy@0: if ( wait !== true && --jQuery.readyWait > 0 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // If there are functions bound, to execute
gyorgy@0: readyList.resolveWith( document, [ jQuery ] );
gyorgy@0:
gyorgy@0: // Trigger any bound ready events
gyorgy@0: if ( jQuery.fn.trigger ) {
gyorgy@0: jQuery( document ).trigger( "ready" ).unbind( "ready" );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: bindReady: function() {
gyorgy@0: if ( readyList ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: readyList = jQuery._Deferred();
gyorgy@0:
gyorgy@0: // Catch cases where $(document).ready() is called after the
gyorgy@0: // browser event has already occurred.
gyorgy@0: if ( document.readyState === "complete" ) {
gyorgy@0: // Handle it asynchronously to allow scripts the opportunity to delay ready
gyorgy@0: return setTimeout( jQuery.ready, 1 );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Mozilla, Opera and webkit nightlies currently support this event
gyorgy@0: if ( document.addEventListener ) {
gyorgy@0: // Use the handy event callback
gyorgy@0: document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
gyorgy@0:
gyorgy@0: // A fallback to window.onload, that will always work
gyorgy@0: window.addEventListener( "load", jQuery.ready, false );
gyorgy@0:
gyorgy@0: // If IE event model is used
gyorgy@0: } else if ( document.attachEvent ) {
gyorgy@0: // ensure firing before onload,
gyorgy@0: // maybe late but safe also for iframes
gyorgy@0: document.attachEvent( "onreadystatechange", DOMContentLoaded );
gyorgy@0:
gyorgy@0: // A fallback to window.onload, that will always work
gyorgy@0: window.attachEvent( "onload", jQuery.ready );
gyorgy@0:
gyorgy@0: // If IE and not a frame
gyorgy@0: // continually check to see if the document is ready
gyorgy@0: var toplevel = false;
gyorgy@0:
gyorgy@0: try {
gyorgy@0: toplevel = window.frameElement == null;
gyorgy@0: } catch(e) {}
gyorgy@0:
gyorgy@0: if ( document.documentElement.doScroll && toplevel ) {
gyorgy@0: doScrollCheck();
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // See test/unit/core.js for details concerning isFunction.
gyorgy@0: // Since version 1.3, DOM methods and functions like alert
gyorgy@0: // aren't supported. They return false on IE (#2968).
gyorgy@0: isFunction: function( obj ) {
gyorgy@0: return jQuery.type(obj) === "function";
gyorgy@0: },
gyorgy@0:
gyorgy@0: isArray: Array.isArray || function( obj ) {
gyorgy@0: return jQuery.type(obj) === "array";
gyorgy@0: },
gyorgy@0:
gyorgy@0: // A crude way of determining if an object is a window
gyorgy@0: isWindow: function( obj ) {
gyorgy@0: return obj && typeof obj === "object" && "setInterval" in obj;
gyorgy@0: },
gyorgy@0:
gyorgy@0: isNaN: function( obj ) {
gyorgy@0: return obj == null || !rdigit.test( obj ) || isNaN( obj );
gyorgy@0: },
gyorgy@0:
gyorgy@0: type: function( obj ) {
gyorgy@0: return obj == null ?
gyorgy@0: String( obj ) :
gyorgy@0: class2type[ toString.call(obj) ] || "object";
gyorgy@0: },
gyorgy@0:
gyorgy@0: isPlainObject: function( obj ) {
gyorgy@0: // Must be an Object.
gyorgy@0: // Because of IE, we also have to check the presence of the constructor property.
gyorgy@0: // Make sure that DOM nodes and window objects don't pass through, as well
gyorgy@0: if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Not own constructor property must be Object
gyorgy@0: if ( obj.constructor &&
gyorgy@0: !hasOwn.call(obj, "constructor") &&
gyorgy@0: !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Own properties are enumerated firstly, so to speed up,
gyorgy@0: // if last one is own, then all properties are own.
gyorgy@0:
gyorgy@0: var key;
gyorgy@0: for ( key in obj ) {}
gyorgy@0:
gyorgy@0: return key === undefined || hasOwn.call( obj, key );
gyorgy@0: },
gyorgy@0:
gyorgy@0: isEmptyObject: function( obj ) {
gyorgy@0: for ( var name in obj ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: return true;
gyorgy@0: },
gyorgy@0:
gyorgy@0: error: function( msg ) {
gyorgy@0: throw msg;
gyorgy@0: },
gyorgy@0:
gyorgy@0: parseJSON: function( data ) {
gyorgy@0: if ( typeof data !== "string" || !data ) {
gyorgy@0: return null;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Make sure leading/trailing whitespace is removed (IE can't handle it)
gyorgy@0: data = jQuery.trim( data );
gyorgy@0:
gyorgy@0: // Attempt to parse using the native JSON parser first
gyorgy@0: if ( window.JSON && window.JSON.parse ) {
gyorgy@0: return window.JSON.parse( data );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Make sure the incoming data is actual JSON
gyorgy@0: // Logic borrowed from http://json.org/json2.js
gyorgy@0: if ( rvalidchars.test( data.replace( rvalidescape, "@" )
gyorgy@0: .replace( rvalidtokens, "]" )
gyorgy@0: .replace( rvalidbraces, "")) ) {
gyorgy@0:
gyorgy@0: return (new Function( "return " + data ))();
gyorgy@0:
gyorgy@0: }
gyorgy@0: jQuery.error( "Invalid JSON: " + data );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Cross-browser xml parsing
gyorgy@0: // (xml & tmp used internally)
gyorgy@0: parseXML: function( data , xml , tmp ) {
gyorgy@0:
gyorgy@0: if ( window.DOMParser ) { // Standard
gyorgy@0: tmp = new DOMParser();
gyorgy@0: xml = tmp.parseFromString( data , "text/xml" );
gyorgy@0: } else { // IE
gyorgy@0: xml = new ActiveXObject( "Microsoft.XMLDOM" );
gyorgy@0: xml.async = "false";
gyorgy@0: xml.loadXML( data );
gyorgy@0: }
gyorgy@0:
gyorgy@0: tmp = xml.documentElement;
gyorgy@0:
gyorgy@0: if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
gyorgy@0: jQuery.error( "Invalid XML: " + data );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return xml;
gyorgy@0: },
gyorgy@0:
gyorgy@0: noop: function() {},
gyorgy@0:
gyorgy@0: // Evaluates a script in a global context
gyorgy@0: // Workarounds based on findings by Jim Driscoll
gyorgy@0: // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
gyorgy@0: globalEval: function( data ) {
gyorgy@0: if ( data && rnotwhite.test( data ) ) {
gyorgy@0: // We use execScript on Internet Explorer
gyorgy@0: // We use an anonymous function so that context is window
gyorgy@0: // rather than jQuery in Firefox
gyorgy@0: ( window.execScript || function( data ) {
gyorgy@0: window[ "eval" ].call( window, data );
gyorgy@0: } )( data );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: nodeName: function( elem, name ) {
gyorgy@0: return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
gyorgy@0: },
gyorgy@0:
gyorgy@0: // args is for internal usage only
gyorgy@0: each: function( object, callback, args ) {
gyorgy@0: var name, i = 0,
gyorgy@0: length = object.length,
gyorgy@0: isObj = length === undefined || jQuery.isFunction( object );
gyorgy@0:
gyorgy@0: if ( args ) {
gyorgy@0: if ( isObj ) {
gyorgy@0: for ( name in object ) {
gyorgy@0: if ( callback.apply( object[ name ], args ) === false ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: } else {
gyorgy@0: for ( ; i < length; ) {
gyorgy@0: if ( callback.apply( object[ i++ ], args ) === false ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // A special, fast, case for the most common use of each
gyorgy@0: } else {
gyorgy@0: if ( isObj ) {
gyorgy@0: for ( name in object ) {
gyorgy@0: if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: } else {
gyorgy@0: for ( ; i < length; ) {
gyorgy@0: if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return object;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Use native String.trim function wherever possible
gyorgy@0: trim: trim ?
gyorgy@0: function( text ) {
gyorgy@0: return text == null ?
gyorgy@0: "" :
gyorgy@0: trim.call( text );
gyorgy@0: } :
gyorgy@0:
gyorgy@0: // Otherwise use our own trimming functionality
gyorgy@0: function( text ) {
gyorgy@0: return text == null ?
gyorgy@0: "" :
gyorgy@0: text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // results is for internal usage only
gyorgy@0: makeArray: function( array, results ) {
gyorgy@0: var ret = results || [];
gyorgy@0:
gyorgy@0: if ( array != null ) {
gyorgy@0: // The window, strings (and functions) also have 'length'
gyorgy@0: // The extra typeof function check is to prevent crashes
gyorgy@0: // in Safari 2 (See: #3039)
gyorgy@0: // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
gyorgy@0: var type = jQuery.type( array );
gyorgy@0:
gyorgy@0: if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
gyorgy@0: push.call( ret, array );
gyorgy@0: } else {
gyorgy@0: jQuery.merge( ret, array );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret;
gyorgy@0: },
gyorgy@0:
gyorgy@0: inArray: function( elem, array ) {
gyorgy@0:
gyorgy@0: if ( indexOf ) {
gyorgy@0: return indexOf.call( array, elem );
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( var i = 0, length = array.length; i < length; i++ ) {
gyorgy@0: if ( array[ i ] === elem ) {
gyorgy@0: return i;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return -1;
gyorgy@0: },
gyorgy@0:
gyorgy@0: merge: function( first, second ) {
gyorgy@0: var i = first.length,
gyorgy@0: j = 0;
gyorgy@0:
gyorgy@0: if ( typeof second.length === "number" ) {
gyorgy@0: for ( var l = second.length; j < l; j++ ) {
gyorgy@0: first[ i++ ] = second[ j ];
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: while ( second[j] !== undefined ) {
gyorgy@0: first[ i++ ] = second[ j++ ];
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: first.length = i;
gyorgy@0:
gyorgy@0: return first;
gyorgy@0: },
gyorgy@0:
gyorgy@0: grep: function( elems, callback, inv ) {
gyorgy@0: var ret = [], retVal;
gyorgy@0: inv = !!inv;
gyorgy@0:
gyorgy@0: // Go through the array, only saving the items
gyorgy@0: // that pass the validator function
gyorgy@0: for ( var i = 0, length = elems.length; i < length; i++ ) {
gyorgy@0: retVal = !!callback( elems[ i ], i );
gyorgy@0: if ( inv !== retVal ) {
gyorgy@0: ret.push( elems[ i ] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // arg is for internal usage only
gyorgy@0: map: function( elems, callback, arg ) {
gyorgy@0: var value, key, ret = [],
gyorgy@0: i = 0,
gyorgy@0: length = elems.length,
gyorgy@0: // jquery objects are treated as arrays
gyorgy@0: isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
gyorgy@0:
gyorgy@0: // Go through the array, translating each of the items to their
gyorgy@0: if ( isArray ) {
gyorgy@0: for ( ; i < length; i++ ) {
gyorgy@0: value = callback( elems[ i ], i, arg );
gyorgy@0:
gyorgy@0: if ( value != null ) {
gyorgy@0: ret[ ret.length ] = value;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Go through every key on the object,
gyorgy@0: } else {
gyorgy@0: for ( key in elems ) {
gyorgy@0: value = callback( elems[ key ], key, arg );
gyorgy@0:
gyorgy@0: if ( value != null ) {
gyorgy@0: ret[ ret.length ] = value;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Flatten any nested arrays
gyorgy@0: return ret.concat.apply( [], ret );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // A global GUID counter for objects
gyorgy@0: guid: 1,
gyorgy@0:
gyorgy@0: // Bind a function to a context, optionally partially applying any
gyorgy@0: // arguments.
gyorgy@0: proxy: function( fn, context ) {
gyorgy@0: if ( typeof context === "string" ) {
gyorgy@0: var tmp = fn[ context ];
gyorgy@0: context = fn;
gyorgy@0: fn = tmp;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Quick check to determine if target is callable, in the spec
gyorgy@0: // this throws a TypeError, but we will just return undefined.
gyorgy@0: if ( !jQuery.isFunction( fn ) ) {
gyorgy@0: return undefined;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Simulated bind
gyorgy@0: var args = slice.call( arguments, 2 ),
gyorgy@0: proxy = function() {
gyorgy@0: return fn.apply( context, args.concat( slice.call( arguments ) ) );
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Set the guid of unique handler to the same of original handler, so it can be removed
gyorgy@0: proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
gyorgy@0:
gyorgy@0: return proxy;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Mutifunctional method to get and set values to a collection
gyorgy@0: // The value/s can be optionally by executed if its a function
gyorgy@0: access: function( elems, key, value, exec, fn, pass ) {
gyorgy@0: var length = elems.length;
gyorgy@0:
gyorgy@0: // Setting many attributes
gyorgy@0: if ( typeof key === "object" ) {
gyorgy@0: for ( var k in key ) {
gyorgy@0: jQuery.access( elems, k, key[k], exec, fn, value );
gyorgy@0: }
gyorgy@0: return elems;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Setting one attribute
gyorgy@0: if ( value !== undefined ) {
gyorgy@0: // Optionally, function values get executed if exec is true
gyorgy@0: exec = !pass && exec && jQuery.isFunction(value);
gyorgy@0:
gyorgy@0: for ( var i = 0; i < length; i++ ) {
gyorgy@0: fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return elems;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Getting an attribute
gyorgy@0: return length ? fn( elems[0], key ) : undefined;
gyorgy@0: },
gyorgy@0:
gyorgy@0: now: function() {
gyorgy@0: return (new Date()).getTime();
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Use of jQuery.browser is frowned upon.
gyorgy@0: // More details: http://docs.jquery.com/Utilities/jQuery.browser
gyorgy@0: uaMatch: function( ua ) {
gyorgy@0: ua = ua.toLowerCase();
gyorgy@0:
gyorgy@0: var match = rwebkit.exec( ua ) ||
gyorgy@0: ropera.exec( ua ) ||
gyorgy@0: rmsie.exec( ua ) ||
gyorgy@0: ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
gyorgy@0: [];
gyorgy@0:
gyorgy@0: return { browser: match[1] || "", version: match[2] || "0" };
gyorgy@0: },
gyorgy@0:
gyorgy@0: sub: function() {
gyorgy@0: function jQuerySub( selector, context ) {
gyorgy@0: return new jQuerySub.fn.init( selector, context );
gyorgy@0: }
gyorgy@0: jQuery.extend( true, jQuerySub, this );
gyorgy@0: jQuerySub.superclass = this;
gyorgy@0: jQuerySub.fn = jQuerySub.prototype = this();
gyorgy@0: jQuerySub.fn.constructor = jQuerySub;
gyorgy@0: jQuerySub.sub = this.sub;
gyorgy@0: jQuerySub.fn.init = function init( selector, context ) {
gyorgy@0: if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
gyorgy@0: context = jQuerySub( context );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
gyorgy@0: };
gyorgy@0: jQuerySub.fn.init.prototype = jQuerySub.fn;
gyorgy@0: var rootjQuerySub = jQuerySub(document);
gyorgy@0: return jQuerySub;
gyorgy@0: },
gyorgy@0:
gyorgy@0: browser: {}
gyorgy@0: });
gyorgy@0:
gyorgy@0: // Populate the class2type map
gyorgy@0: jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
gyorgy@0: class2type[ "[object " + name + "]" ] = name.toLowerCase();
gyorgy@0: });
gyorgy@0:
gyorgy@0: browserMatch = jQuery.uaMatch( userAgent );
gyorgy@0: if ( browserMatch.browser ) {
gyorgy@0: jQuery.browser[ browserMatch.browser ] = true;
gyorgy@0: jQuery.browser.version = browserMatch.version;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Deprecated, use jQuery.browser.webkit instead
gyorgy@0: if ( jQuery.browser.webkit ) {
gyorgy@0: jQuery.browser.safari = true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // IE doesn't match non-breaking spaces with \s
gyorgy@0: if ( rnotwhite.test( "\xA0" ) ) {
gyorgy@0: trimLeft = /^[\s\xA0]+/;
gyorgy@0: trimRight = /[\s\xA0]+$/;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // All jQuery objects should point back to these
gyorgy@0: rootjQuery = jQuery(document);
gyorgy@0:
gyorgy@0: // Cleanup functions for the document ready method
gyorgy@0: if ( document.addEventListener ) {
gyorgy@0: DOMContentLoaded = function() {
gyorgy@0: document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
gyorgy@0: jQuery.ready();
gyorgy@0: };
gyorgy@0:
gyorgy@0: } else if ( document.attachEvent ) {
gyorgy@0: DOMContentLoaded = function() {
gyorgy@0: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
gyorgy@0: if ( document.readyState === "complete" ) {
gyorgy@0: document.detachEvent( "onreadystatechange", DOMContentLoaded );
gyorgy@0: jQuery.ready();
gyorgy@0: }
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: // The DOM ready check for Internet Explorer
gyorgy@0: function doScrollCheck() {
gyorgy@0: if ( jQuery.isReady ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: try {
gyorgy@0: // If IE is used, use the trick by Diego Perini
gyorgy@0: // http://javascript.nwbox.com/IEContentLoaded/
gyorgy@0: document.documentElement.doScroll("left");
gyorgy@0: } catch(e) {
gyorgy@0: setTimeout( doScrollCheck, 1 );
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // and execute any waiting functions
gyorgy@0: jQuery.ready();
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Expose jQuery to the global object
gyorgy@0: return jQuery;
gyorgy@0:
gyorgy@0: })();
gyorgy@0:
gyorgy@0:
gyorgy@0: var // Promise methods
gyorgy@0: promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
gyorgy@0: // Static reference to slice
gyorgy@0: sliceDeferred = [].slice;
gyorgy@0:
gyorgy@0: jQuery.extend({
gyorgy@0: // Create a simple deferred (one callbacks list)
gyorgy@0: _Deferred: function() {
gyorgy@0: var // callbacks list
gyorgy@0: callbacks = [],
gyorgy@0: // stored [ context , args ]
gyorgy@0: fired,
gyorgy@0: // to avoid firing when already doing so
gyorgy@0: firing,
gyorgy@0: // flag to know if the deferred has been cancelled
gyorgy@0: cancelled,
gyorgy@0: // the deferred itself
gyorgy@0: deferred = {
gyorgy@0:
gyorgy@0: // done( f1, f2, ...)
gyorgy@0: done: function() {
gyorgy@0: if ( !cancelled ) {
gyorgy@0: var args = arguments,
gyorgy@0: i,
gyorgy@0: length,
gyorgy@0: elem,
gyorgy@0: type,
gyorgy@0: _fired;
gyorgy@0: if ( fired ) {
gyorgy@0: _fired = fired;
gyorgy@0: fired = 0;
gyorgy@0: }
gyorgy@0: for ( i = 0, length = args.length; i < length; i++ ) {
gyorgy@0: elem = args[ i ];
gyorgy@0: type = jQuery.type( elem );
gyorgy@0: if ( type === "array" ) {
gyorgy@0: deferred.done.apply( deferred, elem );
gyorgy@0: } else if ( type === "function" ) {
gyorgy@0: callbacks.push( elem );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: if ( _fired ) {
gyorgy@0: deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // resolve with given context and args
gyorgy@0: resolveWith: function( context, args ) {
gyorgy@0: if ( !cancelled && !fired && !firing ) {
gyorgy@0: // make sure args are available (#8421)
gyorgy@0: args = args || [];
gyorgy@0: firing = 1;
gyorgy@0: try {
gyorgy@0: while( callbacks[ 0 ] ) {
gyorgy@0: callbacks.shift().apply( context, args );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: finally {
gyorgy@0: fired = [ context, args ];
gyorgy@0: firing = 0;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // resolve with this as context and given arguments
gyorgy@0: resolve: function() {
gyorgy@0: deferred.resolveWith( this, arguments );
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Has this deferred been resolved?
gyorgy@0: isResolved: function() {
gyorgy@0: return !!( firing || fired );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Cancel
gyorgy@0: cancel: function() {
gyorgy@0: cancelled = 1;
gyorgy@0: callbacks = [];
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: return deferred;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Full fledged deferred (two callbacks list)
gyorgy@0: Deferred: function( func ) {
gyorgy@0: var deferred = jQuery._Deferred(),
gyorgy@0: failDeferred = jQuery._Deferred(),
gyorgy@0: promise;
gyorgy@0: // Add errorDeferred methods, then and promise
gyorgy@0: jQuery.extend( deferred, {
gyorgy@0: then: function( doneCallbacks, failCallbacks ) {
gyorgy@0: deferred.done( doneCallbacks ).fail( failCallbacks );
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0: always: function() {
gyorgy@0: return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
gyorgy@0: },
gyorgy@0: fail: failDeferred.done,
gyorgy@0: rejectWith: failDeferred.resolveWith,
gyorgy@0: reject: failDeferred.resolve,
gyorgy@0: isRejected: failDeferred.isResolved,
gyorgy@0: pipe: function( fnDone, fnFail ) {
gyorgy@0: return jQuery.Deferred(function( newDefer ) {
gyorgy@0: jQuery.each( {
gyorgy@0: done: [ fnDone, "resolve" ],
gyorgy@0: fail: [ fnFail, "reject" ]
gyorgy@0: }, function( handler, data ) {
gyorgy@0: var fn = data[ 0 ],
gyorgy@0: action = data[ 1 ],
gyorgy@0: returned;
gyorgy@0: if ( jQuery.isFunction( fn ) ) {
gyorgy@0: deferred[ handler ](function() {
gyorgy@0: returned = fn.apply( this, arguments );
gyorgy@0: if ( returned && jQuery.isFunction( returned.promise ) ) {
gyorgy@0: returned.promise().then( newDefer.resolve, newDefer.reject );
gyorgy@0: } else {
gyorgy@0: newDefer[ action ]( returned );
gyorgy@0: }
gyorgy@0: });
gyorgy@0: } else {
gyorgy@0: deferred[ handler ]( newDefer[ action ] );
gyorgy@0: }
gyorgy@0: });
gyorgy@0: }).promise();
gyorgy@0: },
gyorgy@0: // Get a promise for this deferred
gyorgy@0: // If obj is provided, the promise aspect is added to the object
gyorgy@0: promise: function( obj ) {
gyorgy@0: if ( obj == null ) {
gyorgy@0: if ( promise ) {
gyorgy@0: return promise;
gyorgy@0: }
gyorgy@0: promise = obj = {};
gyorgy@0: }
gyorgy@0: var i = promiseMethods.length;
gyorgy@0: while( i-- ) {
gyorgy@0: obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
gyorgy@0: }
gyorgy@0: return obj;
gyorgy@0: }
gyorgy@0: });
gyorgy@0: // Make sure only one callback list will be used
gyorgy@0: deferred.done( failDeferred.cancel ).fail( deferred.cancel );
gyorgy@0: // Unexpose cancel
gyorgy@0: delete deferred.cancel;
gyorgy@0: // Call given func if any
gyorgy@0: if ( func ) {
gyorgy@0: func.call( deferred, deferred );
gyorgy@0: }
gyorgy@0: return deferred;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Deferred helper
gyorgy@0: when: function( firstParam ) {
gyorgy@0: var args = arguments,
gyorgy@0: i = 0,
gyorgy@0: length = args.length,
gyorgy@0: count = length,
gyorgy@0: deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
gyorgy@0: firstParam :
gyorgy@0: jQuery.Deferred();
gyorgy@0: function resolveFunc( i ) {
gyorgy@0: return function( value ) {
gyorgy@0: args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
gyorgy@0: if ( !( --count ) ) {
gyorgy@0: // Strange bug in FF4:
gyorgy@0: // Values changed onto the arguments object sometimes end up as undefined values
gyorgy@0: // outside the $.when method. Cloning the object into a fresh array solves the issue
gyorgy@0: deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
gyorgy@0: }
gyorgy@0: };
gyorgy@0: }
gyorgy@0: if ( length > 1 ) {
gyorgy@0: for( ; i < length; i++ ) {
gyorgy@0: if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
gyorgy@0: args[ i ].promise().then( resolveFunc(i), deferred.reject );
gyorgy@0: } else {
gyorgy@0: --count;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: if ( !count ) {
gyorgy@0: deferred.resolveWith( deferred, args );
gyorgy@0: }
gyorgy@0: } else if ( deferred !== firstParam ) {
gyorgy@0: deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
gyorgy@0: }
gyorgy@0: return deferred.promise();
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: jQuery.support = (function() {
gyorgy@0:
gyorgy@0: var div = document.createElement( "div" ),
gyorgy@0: documentElement = document.documentElement,
gyorgy@0: all,
gyorgy@0: a,
gyorgy@0: select,
gyorgy@0: opt,
gyorgy@0: input,
gyorgy@0: marginDiv,
gyorgy@0: support,
gyorgy@0: fragment,
gyorgy@0: body,
gyorgy@0: bodyStyle,
gyorgy@0: tds,
gyorgy@0: events,
gyorgy@0: eventName,
gyorgy@0: i,
gyorgy@0: isSupported;
gyorgy@0:
gyorgy@0: // Preliminary tests
gyorgy@0: div.setAttribute("className", "t");
gyorgy@0: div.innerHTML = "
a";
gyorgy@0:
gyorgy@0: all = div.getElementsByTagName( "*" );
gyorgy@0: a = div.getElementsByTagName( "a" )[ 0 ];
gyorgy@0:
gyorgy@0: // Can't get basic test support
gyorgy@0: if ( !all || !all.length || !a ) {
gyorgy@0: return {};
gyorgy@0: }
gyorgy@0:
gyorgy@0: // First batch of supports tests
gyorgy@0: select = document.createElement( "select" );
gyorgy@0: opt = select.appendChild( document.createElement("option") );
gyorgy@0: input = div.getElementsByTagName( "input" )[ 0 ];
gyorgy@0:
gyorgy@0: support = {
gyorgy@0: // IE strips leading whitespace when .innerHTML is used
gyorgy@0: leadingWhitespace: ( div.firstChild.nodeType === 3 ),
gyorgy@0:
gyorgy@0: // Make sure that tbody elements aren't automatically inserted
gyorgy@0: // IE will insert them into empty tables
gyorgy@0: tbody: !div.getElementsByTagName( "tbody" ).length,
gyorgy@0:
gyorgy@0: // Make sure that link elements get serialized correctly by innerHTML
gyorgy@0: // This requires a wrapper element in IE
gyorgy@0: htmlSerialize: !!div.getElementsByTagName( "link" ).length,
gyorgy@0:
gyorgy@0: // Get the style information from getAttribute
gyorgy@0: // (IE uses .cssText instead)
gyorgy@0: style: /top/.test( a.getAttribute("style") ),
gyorgy@0:
gyorgy@0: // Make sure that URLs aren't manipulated
gyorgy@0: // (IE normalizes it by default)
gyorgy@0: hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
gyorgy@0:
gyorgy@0: // Make sure that element opacity exists
gyorgy@0: // (IE uses filter instead)
gyorgy@0: // Use a regex to work around a WebKit issue. See #5145
gyorgy@0: opacity: /^0.55$/.test( a.style.opacity ),
gyorgy@0:
gyorgy@0: // Verify style float existence
gyorgy@0: // (IE uses styleFloat instead of cssFloat)
gyorgy@0: cssFloat: !!a.style.cssFloat,
gyorgy@0:
gyorgy@0: // Make sure that if no value is specified for a checkbox
gyorgy@0: // that it defaults to "on".
gyorgy@0: // (WebKit defaults to "" instead)
gyorgy@0: checkOn: ( input.value === "on" ),
gyorgy@0:
gyorgy@0: // Make sure that a selected-by-default option has a working selected property.
gyorgy@0: // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
gyorgy@0: optSelected: opt.selected,
gyorgy@0:
gyorgy@0: // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
gyorgy@0: getSetAttribute: div.className !== "t",
gyorgy@0:
gyorgy@0: // Will be defined later
gyorgy@0: submitBubbles: true,
gyorgy@0: changeBubbles: true,
gyorgy@0: focusinBubbles: false,
gyorgy@0: deleteExpando: true,
gyorgy@0: noCloneEvent: true,
gyorgy@0: inlineBlockNeedsLayout: false,
gyorgy@0: shrinkWrapBlocks: false,
gyorgy@0: reliableMarginRight: true
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Make sure checked status is properly cloned
gyorgy@0: input.checked = true;
gyorgy@0: support.noCloneChecked = input.cloneNode( true ).checked;
gyorgy@0:
gyorgy@0: // Make sure that the options inside disabled selects aren't marked as disabled
gyorgy@0: // (WebKit marks them as disabled)
gyorgy@0: select.disabled = true;
gyorgy@0: support.optDisabled = !opt.disabled;
gyorgy@0:
gyorgy@0: // Test to see if it's possible to delete an expando from an element
gyorgy@0: // Fails in Internet Explorer
gyorgy@0: try {
gyorgy@0: delete div.test;
gyorgy@0: } catch( e ) {
gyorgy@0: support.deleteExpando = false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
gyorgy@0: div.attachEvent( "onclick", function click() {
gyorgy@0: // Cloning a node shouldn't copy over any
gyorgy@0: // bound event handlers (IE does this)
gyorgy@0: support.noCloneEvent = false;
gyorgy@0: div.detachEvent( "onclick", click );
gyorgy@0: });
gyorgy@0: div.cloneNode( true ).fireEvent( "onclick" );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Check if a radio maintains it's value
gyorgy@0: // after being appended to the DOM
gyorgy@0: input = document.createElement("input");
gyorgy@0: input.value = "t";
gyorgy@0: input.setAttribute("type", "radio");
gyorgy@0: support.radioValue = input.value === "t";
gyorgy@0:
gyorgy@0: input.setAttribute("checked", "checked");
gyorgy@0: div.appendChild( input );
gyorgy@0: fragment = document.createDocumentFragment();
gyorgy@0: fragment.appendChild( div.firstChild );
gyorgy@0:
gyorgy@0: // WebKit doesn't clone checked state correctly in fragments
gyorgy@0: support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
gyorgy@0:
gyorgy@0: div.innerHTML = "";
gyorgy@0:
gyorgy@0: // Figure out if the W3C box model works as expected
gyorgy@0: div.style.width = div.style.paddingLeft = "1px";
gyorgy@0:
gyorgy@0: // We use our own, invisible, body
gyorgy@0: body = document.createElement( "body" );
gyorgy@0: bodyStyle = {
gyorgy@0: visibility: "hidden",
gyorgy@0: width: 0,
gyorgy@0: height: 0,
gyorgy@0: border: 0,
gyorgy@0: margin: 0,
gyorgy@0: // Set background to avoid IE crashes when removing (#9028)
gyorgy@0: background: "none"
gyorgy@0: };
gyorgy@0: for ( i in bodyStyle ) {
gyorgy@0: body.style[ i ] = bodyStyle[ i ];
gyorgy@0: }
gyorgy@0: body.appendChild( div );
gyorgy@0: documentElement.insertBefore( body, documentElement.firstChild );
gyorgy@0:
gyorgy@0: // Check if a disconnected checkbox will retain its checked
gyorgy@0: // value of true after appended to the DOM (IE6/7)
gyorgy@0: support.appendChecked = input.checked;
gyorgy@0:
gyorgy@0: support.boxModel = div.offsetWidth === 2;
gyorgy@0:
gyorgy@0: if ( "zoom" in div.style ) {
gyorgy@0: // Check if natively block-level elements act like inline-block
gyorgy@0: // elements when setting their display to 'inline' and giving
gyorgy@0: // them layout
gyorgy@0: // (IE < 8 does this)
gyorgy@0: div.style.display = "inline";
gyorgy@0: div.style.zoom = 1;
gyorgy@0: support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
gyorgy@0:
gyorgy@0: // Check if elements with layout shrink-wrap their children
gyorgy@0: // (IE 6 does this)
gyorgy@0: div.style.display = "";
gyorgy@0: div.innerHTML = "";
gyorgy@0: support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
gyorgy@0: }
gyorgy@0:
gyorgy@0: div.innerHTML = "
t
";
gyorgy@0: tds = div.getElementsByTagName( "td" );
gyorgy@0:
gyorgy@0: // Check if table cells still have offsetWidth/Height when they are set
gyorgy@0: // to display:none and there are still other visible table cells in a
gyorgy@0: // table row; if so, offsetWidth/Height are not reliable for use when
gyorgy@0: // determining if an element has been hidden directly using
gyorgy@0: // display:none (it is still safe to use offsets if a parent element is
gyorgy@0: // hidden; don safety goggles and see bug #4512 for more information).
gyorgy@0: // (only IE 8 fails this test)
gyorgy@0: isSupported = ( tds[ 0 ].offsetHeight === 0 );
gyorgy@0:
gyorgy@0: tds[ 0 ].style.display = "";
gyorgy@0: tds[ 1 ].style.display = "none";
gyorgy@0:
gyorgy@0: // Check if empty table cells still have offsetWidth/Height
gyorgy@0: // (IE < 8 fail this test)
gyorgy@0: support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
gyorgy@0: div.innerHTML = "";
gyorgy@0:
gyorgy@0: // Check if div with explicit width and no margin-right incorrectly
gyorgy@0: // gets computed margin-right based on width of container. For more
gyorgy@0: // info see bug #3333
gyorgy@0: // Fails in WebKit before Feb 2011 nightlies
gyorgy@0: // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
gyorgy@0: if ( document.defaultView && document.defaultView.getComputedStyle ) {
gyorgy@0: marginDiv = document.createElement( "div" );
gyorgy@0: marginDiv.style.width = "0";
gyorgy@0: marginDiv.style.marginRight = "0";
gyorgy@0: div.appendChild( marginDiv );
gyorgy@0: support.reliableMarginRight =
gyorgy@0: ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Remove the body element we added
gyorgy@0: body.innerHTML = "";
gyorgy@0: documentElement.removeChild( body );
gyorgy@0:
gyorgy@0: // Technique from Juriy Zaytsev
gyorgy@0: // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
gyorgy@0: // We only care about the case where non-standard event systems
gyorgy@0: // are used, namely in IE. Short-circuiting here helps us to
gyorgy@0: // avoid an eval call (in setAttribute) which can cause CSP
gyorgy@0: // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
gyorgy@0: if ( div.attachEvent ) {
gyorgy@0: for( i in {
gyorgy@0: submit: 1,
gyorgy@0: change: 1,
gyorgy@0: focusin: 1
gyorgy@0: } ) {
gyorgy@0: eventName = "on" + i;
gyorgy@0: isSupported = ( eventName in div );
gyorgy@0: if ( !isSupported ) {
gyorgy@0: div.setAttribute( eventName, "return;" );
gyorgy@0: isSupported = ( typeof div[ eventName ] === "function" );
gyorgy@0: }
gyorgy@0: support[ i + "Bubbles" ] = isSupported;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return support;
gyorgy@0: })();
gyorgy@0:
gyorgy@0: // Keep track of boxModel
gyorgy@0: jQuery.boxModel = jQuery.support.boxModel;
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: var rbrace = /^(?:\{.*\}|\[.*\])$/,
gyorgy@0: rmultiDash = /([a-z])([A-Z])/g;
gyorgy@0:
gyorgy@0: jQuery.extend({
gyorgy@0: cache: {},
gyorgy@0:
gyorgy@0: // Please use with caution
gyorgy@0: uuid: 0,
gyorgy@0:
gyorgy@0: // Unique for each copy of jQuery on the page
gyorgy@0: // Non-digits removed to match rinlinejQuery
gyorgy@0: expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
gyorgy@0:
gyorgy@0: // The following elements throw uncatchable exceptions if you
gyorgy@0: // attempt to add expando properties to them.
gyorgy@0: noData: {
gyorgy@0: "embed": true,
gyorgy@0: // Ban all objects except for Flash (which handle expandos)
gyorgy@0: "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
gyorgy@0: "applet": true
gyorgy@0: },
gyorgy@0:
gyorgy@0: hasData: function( elem ) {
gyorgy@0: elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
gyorgy@0:
gyorgy@0: return !!elem && !isEmptyDataObject( elem );
gyorgy@0: },
gyorgy@0:
gyorgy@0: data: function( elem, name, data, pvt /* Internal Use Only */ ) {
gyorgy@0: if ( !jQuery.acceptData( elem ) ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
gyorgy@0:
gyorgy@0: // We have to handle DOM nodes and JS objects differently because IE6-7
gyorgy@0: // can't GC object references properly across the DOM-JS boundary
gyorgy@0: isNode = elem.nodeType,
gyorgy@0:
gyorgy@0: // Only DOM nodes need the global jQuery cache; JS object data is
gyorgy@0: // attached directly to the object so GC can occur automatically
gyorgy@0: cache = isNode ? jQuery.cache : elem,
gyorgy@0:
gyorgy@0: // Only defining an ID for JS objects if its cache already exists allows
gyorgy@0: // the code to shortcut on the same path as a DOM node with no cache
gyorgy@0: id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
gyorgy@0:
gyorgy@0: // Avoid doing any more work than we need to when trying to get data on an
gyorgy@0: // object that has no data at all
gyorgy@0: if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !id ) {
gyorgy@0: // Only DOM nodes need a new unique ID for each element since their data
gyorgy@0: // ends up in the global cache
gyorgy@0: if ( isNode ) {
gyorgy@0: elem[ jQuery.expando ] = id = ++jQuery.uuid;
gyorgy@0: } else {
gyorgy@0: id = jQuery.expando;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !cache[ id ] ) {
gyorgy@0: cache[ id ] = {};
gyorgy@0:
gyorgy@0: // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
gyorgy@0: // metadata on plain JS objects when the object is serialized using
gyorgy@0: // JSON.stringify
gyorgy@0: if ( !isNode ) {
gyorgy@0: cache[ id ].toJSON = jQuery.noop;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // An object can be passed to jQuery.data instead of a key/value pair; this gets
gyorgy@0: // shallow copied over onto the existing cache
gyorgy@0: if ( typeof name === "object" || typeof name === "function" ) {
gyorgy@0: if ( pvt ) {
gyorgy@0: cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
gyorgy@0: } else {
gyorgy@0: cache[ id ] = jQuery.extend(cache[ id ], name);
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: thisCache = cache[ id ];
gyorgy@0:
gyorgy@0: // Internal jQuery data is stored in a separate object inside the object's data
gyorgy@0: // cache in order to avoid key collisions between internal data and user-defined
gyorgy@0: // data
gyorgy@0: if ( pvt ) {
gyorgy@0: if ( !thisCache[ internalKey ] ) {
gyorgy@0: thisCache[ internalKey ] = {};
gyorgy@0: }
gyorgy@0:
gyorgy@0: thisCache = thisCache[ internalKey ];
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( data !== undefined ) {
gyorgy@0: thisCache[ jQuery.camelCase( name ) ] = data;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
gyorgy@0: // not attempt to inspect the internal events object using jQuery.data, as this
gyorgy@0: // internal data object is undocumented and subject to change.
gyorgy@0: if ( name === "events" && !thisCache[name] ) {
gyorgy@0: return thisCache[ internalKey ] && thisCache[ internalKey ].events;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
gyorgy@0: },
gyorgy@0:
gyorgy@0: removeData: function( elem, name, pvt /* Internal Use Only */ ) {
gyorgy@0: if ( !jQuery.acceptData( elem ) ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var internalKey = jQuery.expando, isNode = elem.nodeType,
gyorgy@0:
gyorgy@0: // See jQuery.data for more information
gyorgy@0: cache = isNode ? jQuery.cache : elem,
gyorgy@0:
gyorgy@0: // See jQuery.data for more information
gyorgy@0: id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
gyorgy@0:
gyorgy@0: // If there is already no cache entry for this object, there is no
gyorgy@0: // purpose in continuing
gyorgy@0: if ( !cache[ id ] ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( name ) {
gyorgy@0: var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
gyorgy@0:
gyorgy@0: if ( thisCache ) {
gyorgy@0: delete thisCache[ name ];
gyorgy@0:
gyorgy@0: // If there is no data left in the cache, we want to continue
gyorgy@0: // and let the cache object itself get destroyed
gyorgy@0: if ( !isEmptyDataObject(thisCache) ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // See jQuery.data for more information
gyorgy@0: if ( pvt ) {
gyorgy@0: delete cache[ id ][ internalKey ];
gyorgy@0:
gyorgy@0: // Don't destroy the parent cache unless the internal data object
gyorgy@0: // had been the only thing left in it
gyorgy@0: if ( !isEmptyDataObject(cache[ id ]) ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: var internalCache = cache[ id ][ internalKey ];
gyorgy@0:
gyorgy@0: // Browsers that fail expando deletion also refuse to delete expandos on
gyorgy@0: // the window, but it will allow it on all other JS objects; other browsers
gyorgy@0: // don't care
gyorgy@0: if ( jQuery.support.deleteExpando || cache != window ) {
gyorgy@0: delete cache[ id ];
gyorgy@0: } else {
gyorgy@0: cache[ id ] = null;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // We destroyed the entire user cache at once because it's faster than
gyorgy@0: // iterating through each key, but we need to continue to persist internal
gyorgy@0: // data if it existed
gyorgy@0: if ( internalCache ) {
gyorgy@0: cache[ id ] = {};
gyorgy@0: // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
gyorgy@0: // metadata on plain JS objects when the object is serialized using
gyorgy@0: // JSON.stringify
gyorgy@0: if ( !isNode ) {
gyorgy@0: cache[ id ].toJSON = jQuery.noop;
gyorgy@0: }
gyorgy@0:
gyorgy@0: cache[ id ][ internalKey ] = internalCache;
gyorgy@0:
gyorgy@0: // Otherwise, we need to eliminate the expando on the node to avoid
gyorgy@0: // false lookups in the cache for entries that no longer exist
gyorgy@0: } else if ( isNode ) {
gyorgy@0: // IE does not allow us to delete expando properties from nodes,
gyorgy@0: // nor does it have a removeAttribute function on Document nodes;
gyorgy@0: // we must handle all of these cases
gyorgy@0: if ( jQuery.support.deleteExpando ) {
gyorgy@0: delete elem[ jQuery.expando ];
gyorgy@0: } else if ( elem.removeAttribute ) {
gyorgy@0: elem.removeAttribute( jQuery.expando );
gyorgy@0: } else {
gyorgy@0: elem[ jQuery.expando ] = null;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // For internal use only.
gyorgy@0: _data: function( elem, name, data ) {
gyorgy@0: return jQuery.data( elem, name, data, true );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // A method for determining if a DOM node can handle the data expando
gyorgy@0: acceptData: function( elem ) {
gyorgy@0: if ( elem.nodeName ) {
gyorgy@0: var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
gyorgy@0:
gyorgy@0: if ( match ) {
gyorgy@0: return !(match === true || elem.getAttribute("classid") !== match);
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: jQuery.fn.extend({
gyorgy@0: data: function( key, value ) {
gyorgy@0: var data = null;
gyorgy@0:
gyorgy@0: if ( typeof key === "undefined" ) {
gyorgy@0: if ( this.length ) {
gyorgy@0: data = jQuery.data( this[0] );
gyorgy@0:
gyorgy@0: if ( this[0].nodeType === 1 ) {
gyorgy@0: var attr = this[0].attributes, name;
gyorgy@0: for ( var i = 0, l = attr.length; i < l; i++ ) {
gyorgy@0: name = attr[i].name;
gyorgy@0:
gyorgy@0: if ( name.indexOf( "data-" ) === 0 ) {
gyorgy@0: name = jQuery.camelCase( name.substring(5) );
gyorgy@0:
gyorgy@0: dataAttr( this[0], name, data[ name ] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return data;
gyorgy@0:
gyorgy@0: } else if ( typeof key === "object" ) {
gyorgy@0: return this.each(function() {
gyorgy@0: jQuery.data( this, key );
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: var parts = key.split(".");
gyorgy@0: parts[1] = parts[1] ? "." + parts[1] : "";
gyorgy@0:
gyorgy@0: if ( value === undefined ) {
gyorgy@0: data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
gyorgy@0:
gyorgy@0: // Try to fetch any internally stored data first
gyorgy@0: if ( data === undefined && this.length ) {
gyorgy@0: data = jQuery.data( this[0], key );
gyorgy@0: data = dataAttr( this[0], key, data );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return data === undefined && parts[1] ?
gyorgy@0: this.data( parts[0] ) :
gyorgy@0: data;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return this.each(function() {
gyorgy@0: var $this = jQuery( this ),
gyorgy@0: args = [ parts[0], value ];
gyorgy@0:
gyorgy@0: $this.triggerHandler( "setData" + parts[1] + "!", args );
gyorgy@0: jQuery.data( this, key, value );
gyorgy@0: $this.triggerHandler( "changeData" + parts[1] + "!", args );
gyorgy@0: });
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: removeData: function( key ) {
gyorgy@0: return this.each(function() {
gyorgy@0: jQuery.removeData( this, key );
gyorgy@0: });
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: function dataAttr( elem, key, data ) {
gyorgy@0: // If nothing was found internally, try to fetch any
gyorgy@0: // data from the HTML5 data-* attribute
gyorgy@0: if ( data === undefined && elem.nodeType === 1 ) {
gyorgy@0: var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
gyorgy@0:
gyorgy@0: data = elem.getAttribute( name );
gyorgy@0:
gyorgy@0: if ( typeof data === "string" ) {
gyorgy@0: try {
gyorgy@0: data = data === "true" ? true :
gyorgy@0: data === "false" ? false :
gyorgy@0: data === "null" ? null :
gyorgy@0: !jQuery.isNaN( data ) ? parseFloat( data ) :
gyorgy@0: rbrace.test( data ) ? jQuery.parseJSON( data ) :
gyorgy@0: data;
gyorgy@0: } catch( e ) {}
gyorgy@0:
gyorgy@0: // Make sure we set the data so it isn't changed later
gyorgy@0: jQuery.data( elem, key, data );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: data = undefined;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return data;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
gyorgy@0: // property to be considered empty objects; this property always exists in
gyorgy@0: // order to make sure JSON.stringify does not expose internal metadata
gyorgy@0: function isEmptyDataObject( obj ) {
gyorgy@0: for ( var name in obj ) {
gyorgy@0: if ( name !== "toJSON" ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: function handleQueueMarkDefer( elem, type, src ) {
gyorgy@0: var deferDataKey = type + "defer",
gyorgy@0: queueDataKey = type + "queue",
gyorgy@0: markDataKey = type + "mark",
gyorgy@0: defer = jQuery.data( elem, deferDataKey, undefined, true );
gyorgy@0: if ( defer &&
gyorgy@0: ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
gyorgy@0: ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
gyorgy@0: // Give room for hard-coded callbacks to fire first
gyorgy@0: // and eventually mark/queue something else on the element
gyorgy@0: setTimeout( function() {
gyorgy@0: if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
gyorgy@0: !jQuery.data( elem, markDataKey, undefined, true ) ) {
gyorgy@0: jQuery.removeData( elem, deferDataKey, true );
gyorgy@0: defer.resolve();
gyorgy@0: }
gyorgy@0: }, 0 );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: jQuery.extend({
gyorgy@0:
gyorgy@0: _mark: function( elem, type ) {
gyorgy@0: if ( elem ) {
gyorgy@0: type = (type || "fx") + "mark";
gyorgy@0: jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: _unmark: function( force, elem, type ) {
gyorgy@0: if ( force !== true ) {
gyorgy@0: type = elem;
gyorgy@0: elem = force;
gyorgy@0: force = false;
gyorgy@0: }
gyorgy@0: if ( elem ) {
gyorgy@0: type = type || "fx";
gyorgy@0: var key = type + "mark",
gyorgy@0: count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
gyorgy@0: if ( count ) {
gyorgy@0: jQuery.data( elem, key, count, true );
gyorgy@0: } else {
gyorgy@0: jQuery.removeData( elem, key, true );
gyorgy@0: handleQueueMarkDefer( elem, type, "mark" );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: queue: function( elem, type, data ) {
gyorgy@0: if ( elem ) {
gyorgy@0: type = (type || "fx") + "queue";
gyorgy@0: var q = jQuery.data( elem, type, undefined, true );
gyorgy@0: // Speed up dequeue by getting out quickly if this is just a lookup
gyorgy@0: if ( data ) {
gyorgy@0: if ( !q || jQuery.isArray(data) ) {
gyorgy@0: q = jQuery.data( elem, type, jQuery.makeArray(data), true );
gyorgy@0: } else {
gyorgy@0: q.push( data );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: return q || [];
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: dequeue: function( elem, type ) {
gyorgy@0: type = type || "fx";
gyorgy@0:
gyorgy@0: var queue = jQuery.queue( elem, type ),
gyorgy@0: fn = queue.shift(),
gyorgy@0: defer;
gyorgy@0:
gyorgy@0: // If the fx queue is dequeued, always remove the progress sentinel
gyorgy@0: if ( fn === "inprogress" ) {
gyorgy@0: fn = queue.shift();
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( fn ) {
gyorgy@0: // Add a progress sentinel to prevent the fx queue from being
gyorgy@0: // automatically dequeued
gyorgy@0: if ( type === "fx" ) {
gyorgy@0: queue.unshift("inprogress");
gyorgy@0: }
gyorgy@0:
gyorgy@0: fn.call(elem, function() {
gyorgy@0: jQuery.dequeue(elem, type);
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !queue.length ) {
gyorgy@0: jQuery.removeData( elem, type + "queue", true );
gyorgy@0: handleQueueMarkDefer( elem, type, "queue" );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: jQuery.fn.extend({
gyorgy@0: queue: function( type, data ) {
gyorgy@0: if ( typeof type !== "string" ) {
gyorgy@0: data = type;
gyorgy@0: type = "fx";
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( data === undefined ) {
gyorgy@0: return jQuery.queue( this[0], type );
gyorgy@0: }
gyorgy@0: return this.each(function() {
gyorgy@0: var queue = jQuery.queue( this, type, data );
gyorgy@0:
gyorgy@0: if ( type === "fx" && queue[0] !== "inprogress" ) {
gyorgy@0: jQuery.dequeue( this, type );
gyorgy@0: }
gyorgy@0: });
gyorgy@0: },
gyorgy@0: dequeue: function( type ) {
gyorgy@0: return this.each(function() {
gyorgy@0: jQuery.dequeue( this, type );
gyorgy@0: });
gyorgy@0: },
gyorgy@0: // Based off of the plugin by Clint Helfers, with permission.
gyorgy@0: // http://blindsignals.com/index.php/2009/07/jquery-delay/
gyorgy@0: delay: function( time, type ) {
gyorgy@0: time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
gyorgy@0: type = type || "fx";
gyorgy@0:
gyorgy@0: return this.queue( type, function() {
gyorgy@0: var elem = this;
gyorgy@0: setTimeout(function() {
gyorgy@0: jQuery.dequeue( elem, type );
gyorgy@0: }, time );
gyorgy@0: });
gyorgy@0: },
gyorgy@0: clearQueue: function( type ) {
gyorgy@0: return this.queue( type || "fx", [] );
gyorgy@0: },
gyorgy@0: // Get a promise resolved when queues of a certain type
gyorgy@0: // are emptied (fx is the type by default)
gyorgy@0: promise: function( type, object ) {
gyorgy@0: if ( typeof type !== "string" ) {
gyorgy@0: object = type;
gyorgy@0: type = undefined;
gyorgy@0: }
gyorgy@0: type = type || "fx";
gyorgy@0: var defer = jQuery.Deferred(),
gyorgy@0: elements = this,
gyorgy@0: i = elements.length,
gyorgy@0: count = 1,
gyorgy@0: deferDataKey = type + "defer",
gyorgy@0: queueDataKey = type + "queue",
gyorgy@0: markDataKey = type + "mark",
gyorgy@0: tmp;
gyorgy@0: function resolve() {
gyorgy@0: if ( !( --count ) ) {
gyorgy@0: defer.resolveWith( elements, [ elements ] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: while( i-- ) {
gyorgy@0: if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
gyorgy@0: ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
gyorgy@0: jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
gyorgy@0: jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
gyorgy@0: count++;
gyorgy@0: tmp.done( resolve );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: resolve();
gyorgy@0: return defer.promise();
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: var rclass = /[\n\t\r]/g,
gyorgy@0: rspace = /\s+/,
gyorgy@0: rreturn = /\r/g,
gyorgy@0: rtype = /^(?:button|input)$/i,
gyorgy@0: rfocusable = /^(?:button|input|object|select|textarea)$/i,
gyorgy@0: rclickable = /^a(?:rea)?$/i,
gyorgy@0: rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
gyorgy@0: rinvalidChar = /\:/,
gyorgy@0: formHook, boolHook;
gyorgy@0:
gyorgy@0: jQuery.fn.extend({
gyorgy@0: attr: function( name, value ) {
gyorgy@0: return jQuery.access( this, name, value, true, jQuery.attr );
gyorgy@0: },
gyorgy@0:
gyorgy@0: removeAttr: function( name ) {
gyorgy@0: return this.each(function() {
gyorgy@0: jQuery.removeAttr( this, name );
gyorgy@0: });
gyorgy@0: },
gyorgy@0:
gyorgy@0: prop: function( name, value ) {
gyorgy@0: return jQuery.access( this, name, value, true, jQuery.prop );
gyorgy@0: },
gyorgy@0:
gyorgy@0: removeProp: function( name ) {
gyorgy@0: name = jQuery.propFix[ name ] || name;
gyorgy@0: return this.each(function() {
gyorgy@0: // try/catch handles cases where IE balks (such as removing a property on window)
gyorgy@0: try {
gyorgy@0: this[ name ] = undefined;
gyorgy@0: delete this[ name ];
gyorgy@0: } catch( e ) {}
gyorgy@0: });
gyorgy@0: },
gyorgy@0:
gyorgy@0: addClass: function( value ) {
gyorgy@0: if ( jQuery.isFunction( value ) ) {
gyorgy@0: return this.each(function(i) {
gyorgy@0: var self = jQuery(this);
gyorgy@0: self.addClass( value.call(this, i, self.attr("class") || "") );
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( value && typeof value === "string" ) {
gyorgy@0: var classNames = (value || "").split( rspace );
gyorgy@0:
gyorgy@0: for ( var i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: var elem = this[i];
gyorgy@0:
gyorgy@0: if ( elem.nodeType === 1 ) {
gyorgy@0: if ( !elem.className ) {
gyorgy@0: elem.className = value;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: var className = " " + elem.className + " ",
gyorgy@0: setClass = elem.className;
gyorgy@0:
gyorgy@0: for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
gyorgy@0: if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
gyorgy@0: setClass += " " + classNames[c];
gyorgy@0: }
gyorgy@0: }
gyorgy@0: elem.className = jQuery.trim( setClass );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: removeClass: function( value ) {
gyorgy@0: if ( jQuery.isFunction(value) ) {
gyorgy@0: return this.each(function(i) {
gyorgy@0: var self = jQuery(this);
gyorgy@0: self.removeClass( value.call(this, i, self.attr("class")) );
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( (value && typeof value === "string") || value === undefined ) {
gyorgy@0: var classNames = (value || "").split( rspace );
gyorgy@0:
gyorgy@0: for ( var i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: var elem = this[i];
gyorgy@0:
gyorgy@0: if ( elem.nodeType === 1 && elem.className ) {
gyorgy@0: if ( value ) {
gyorgy@0: var className = (" " + elem.className + " ").replace(rclass, " ");
gyorgy@0: for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
gyorgy@0: className = className.replace(" " + classNames[c] + " ", " ");
gyorgy@0: }
gyorgy@0: elem.className = jQuery.trim( className );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: elem.className = "";
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: toggleClass: function( value, stateVal ) {
gyorgy@0: var type = typeof value,
gyorgy@0: isBool = typeof stateVal === "boolean";
gyorgy@0:
gyorgy@0: if ( jQuery.isFunction( value ) ) {
gyorgy@0: return this.each(function(i) {
gyorgy@0: var self = jQuery(this);
gyorgy@0: self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this.each(function() {
gyorgy@0: if ( type === "string" ) {
gyorgy@0: // toggle individual class names
gyorgy@0: var className,
gyorgy@0: i = 0,
gyorgy@0: self = jQuery( this ),
gyorgy@0: state = stateVal,
gyorgy@0: classNames = value.split( rspace );
gyorgy@0:
gyorgy@0: while ( (className = classNames[ i++ ]) ) {
gyorgy@0: // check each className given, space seperated list
gyorgy@0: state = isBool ? state : !self.hasClass( className );
gyorgy@0: self[ state ? "addClass" : "removeClass" ]( className );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else if ( type === "undefined" || type === "boolean" ) {
gyorgy@0: if ( this.className ) {
gyorgy@0: // store className if set
gyorgy@0: jQuery._data( this, "__className__", this.className );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // toggle whole className
gyorgy@0: this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
gyorgy@0: }
gyorgy@0: });
gyorgy@0: },
gyorgy@0:
gyorgy@0: hasClass: function( selector ) {
gyorgy@0: var className = " " + selector + " ";
gyorgy@0: for ( var i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return false;
gyorgy@0: },
gyorgy@0:
gyorgy@0: val: function( value ) {
gyorgy@0: var hooks, ret,
gyorgy@0: elem = this[0];
gyorgy@0:
gyorgy@0: if ( !arguments.length ) {
gyorgy@0: if ( elem ) {
gyorgy@0: hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
gyorgy@0:
gyorgy@0: if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
gyorgy@0: return ret;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return (elem.value || "").replace(rreturn, "");
gyorgy@0: }
gyorgy@0:
gyorgy@0: return undefined;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var isFunction = jQuery.isFunction( value );
gyorgy@0:
gyorgy@0: return this.each(function( i ) {
gyorgy@0: var self = jQuery(this), val;
gyorgy@0:
gyorgy@0: if ( this.nodeType !== 1 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( isFunction ) {
gyorgy@0: val = value.call( this, i, self.val() );
gyorgy@0: } else {
gyorgy@0: val = value;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Treat null/undefined as ""; convert numbers to string
gyorgy@0: if ( val == null ) {
gyorgy@0: val = "";
gyorgy@0: } else if ( typeof val === "number" ) {
gyorgy@0: val += "";
gyorgy@0: } else if ( jQuery.isArray( val ) ) {
gyorgy@0: val = jQuery.map(val, function ( value ) {
gyorgy@0: return value == null ? "" : value + "";
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
gyorgy@0:
gyorgy@0: // If set returns undefined, fall back to normal setting
gyorgy@0: if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
gyorgy@0: this.value = val;
gyorgy@0: }
gyorgy@0: });
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: jQuery.extend({
gyorgy@0: valHooks: {
gyorgy@0: option: {
gyorgy@0: get: function( elem ) {
gyorgy@0: // attributes.value is undefined in Blackberry 4.7 but
gyorgy@0: // uses .value. See #6932
gyorgy@0: var val = elem.attributes.value;
gyorgy@0: return !val || val.specified ? elem.value : elem.text;
gyorgy@0: }
gyorgy@0: },
gyorgy@0: select: {
gyorgy@0: get: function( elem ) {
gyorgy@0: var value,
gyorgy@0: index = elem.selectedIndex,
gyorgy@0: values = [],
gyorgy@0: options = elem.options,
gyorgy@0: one = elem.type === "select-one";
gyorgy@0:
gyorgy@0: // Nothing was selected
gyorgy@0: if ( index < 0 ) {
gyorgy@0: return null;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Loop through all the selected options
gyorgy@0: for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
gyorgy@0: var option = options[ i ];
gyorgy@0:
gyorgy@0: // Don't return options that are disabled or in a disabled optgroup
gyorgy@0: if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
gyorgy@0: (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
gyorgy@0:
gyorgy@0: // Get the specific value for the option
gyorgy@0: value = jQuery( option ).val();
gyorgy@0:
gyorgy@0: // We don't need an array for one selects
gyorgy@0: if ( one ) {
gyorgy@0: return value;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Multi-Selects return an array
gyorgy@0: values.push( value );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
gyorgy@0: if ( one && !values.length && options.length ) {
gyorgy@0: return jQuery( options[ index ] ).val();
gyorgy@0: }
gyorgy@0:
gyorgy@0: return values;
gyorgy@0: },
gyorgy@0:
gyorgy@0: set: function( elem, value ) {
gyorgy@0: var values = jQuery.makeArray( value );
gyorgy@0:
gyorgy@0: jQuery(elem).find("option").each(function() {
gyorgy@0: this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
gyorgy@0: });
gyorgy@0:
gyorgy@0: if ( !values.length ) {
gyorgy@0: elem.selectedIndex = -1;
gyorgy@0: }
gyorgy@0: return values;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: attrFn: {
gyorgy@0: val: true,
gyorgy@0: css: true,
gyorgy@0: html: true,
gyorgy@0: text: true,
gyorgy@0: data: true,
gyorgy@0: width: true,
gyorgy@0: height: true,
gyorgy@0: offset: true
gyorgy@0: },
gyorgy@0:
gyorgy@0: attrFix: {
gyorgy@0: // Always normalize to ensure hook usage
gyorgy@0: tabindex: "tabIndex"
gyorgy@0: },
gyorgy@0:
gyorgy@0: attr: function( elem, name, value, pass ) {
gyorgy@0: var nType = elem.nodeType;
gyorgy@0:
gyorgy@0: // don't get/set attributes on text, comment and attribute nodes
gyorgy@0: if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
gyorgy@0: return undefined;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( pass && name in jQuery.attrFn ) {
gyorgy@0: return jQuery( elem )[ name ]( value );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Fallback to prop when attributes are not supported
gyorgy@0: if ( !("getAttribute" in elem) ) {
gyorgy@0: return jQuery.prop( elem, name, value );
gyorgy@0: }
gyorgy@0:
gyorgy@0: var ret, hooks,
gyorgy@0: notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
gyorgy@0:
gyorgy@0: // Normalize the name if needed
gyorgy@0: name = notxml && jQuery.attrFix[ name ] || name;
gyorgy@0:
gyorgy@0: hooks = jQuery.attrHooks[ name ];
gyorgy@0:
gyorgy@0: if ( !hooks ) {
gyorgy@0: // Use boolHook for boolean attributes
gyorgy@0: if ( rboolean.test( name ) &&
gyorgy@0: (typeof value === "boolean" || value === undefined || value.toLowerCase() === name.toLowerCase()) ) {
gyorgy@0:
gyorgy@0: hooks = boolHook;
gyorgy@0:
gyorgy@0: // Use formHook for forms and if the name contains certain characters
gyorgy@0: } else if ( formHook && (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) {
gyorgy@0: hooks = formHook;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( value !== undefined ) {
gyorgy@0:
gyorgy@0: if ( value === null ) {
gyorgy@0: jQuery.removeAttr( elem, name );
gyorgy@0: return undefined;
gyorgy@0:
gyorgy@0: } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
gyorgy@0: return ret;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: elem.setAttribute( name, "" + value );
gyorgy@0: return value;
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else if ( hooks && "get" in hooks && notxml ) {
gyorgy@0: return hooks.get( elem, name );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0:
gyorgy@0: ret = elem.getAttribute( name );
gyorgy@0:
gyorgy@0: // Non-existent attributes return null, we normalize to undefined
gyorgy@0: return ret === null ?
gyorgy@0: undefined :
gyorgy@0: ret;
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: removeAttr: function( elem, name ) {
gyorgy@0: var propName;
gyorgy@0: if ( elem.nodeType === 1 ) {
gyorgy@0: name = jQuery.attrFix[ name ] || name;
gyorgy@0:
gyorgy@0: if ( jQuery.support.getSetAttribute ) {
gyorgy@0: // Use removeAttribute in browsers that support it
gyorgy@0: elem.removeAttribute( name );
gyorgy@0: } else {
gyorgy@0: jQuery.attr( elem, name, "" );
gyorgy@0: elem.removeAttributeNode( elem.getAttributeNode( name ) );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Set corresponding property to false for boolean attributes
gyorgy@0: if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
gyorgy@0: elem[ propName ] = false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: attrHooks: {
gyorgy@0: type: {
gyorgy@0: set: function( elem, value ) {
gyorgy@0: // We can't allow the type property to be changed (since it causes problems in IE)
gyorgy@0: if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
gyorgy@0: jQuery.error( "type property can't be changed" );
gyorgy@0: } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
gyorgy@0: // Setting the type on a radio button after the value resets the value in IE6-9
gyorgy@0: // Reset value to it's default in case type is set after value
gyorgy@0: // This is for element creation
gyorgy@0: var val = elem.value;
gyorgy@0: elem.setAttribute( "type", value );
gyorgy@0: if ( val ) {
gyorgy@0: elem.value = val;
gyorgy@0: }
gyorgy@0: return value;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0: tabIndex: {
gyorgy@0: get: function( elem ) {
gyorgy@0: // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
gyorgy@0: // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
gyorgy@0: var attributeNode = elem.getAttributeNode("tabIndex");
gyorgy@0:
gyorgy@0: return attributeNode && attributeNode.specified ?
gyorgy@0: parseInt( attributeNode.value, 10 ) :
gyorgy@0: rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
gyorgy@0: 0 :
gyorgy@0: undefined;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: propFix: {
gyorgy@0: tabindex: "tabIndex",
gyorgy@0: readonly: "readOnly",
gyorgy@0: "for": "htmlFor",
gyorgy@0: "class": "className",
gyorgy@0: maxlength: "maxLength",
gyorgy@0: cellspacing: "cellSpacing",
gyorgy@0: cellpadding: "cellPadding",
gyorgy@0: rowspan: "rowSpan",
gyorgy@0: colspan: "colSpan",
gyorgy@0: usemap: "useMap",
gyorgy@0: frameborder: "frameBorder",
gyorgy@0: contenteditable: "contentEditable"
gyorgy@0: },
gyorgy@0:
gyorgy@0: prop: function( elem, name, value ) {
gyorgy@0: var nType = elem.nodeType;
gyorgy@0:
gyorgy@0: // don't get/set properties on text, comment and attribute nodes
gyorgy@0: if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
gyorgy@0: return undefined;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var ret, hooks,
gyorgy@0: notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
gyorgy@0:
gyorgy@0: // Try to normalize/fix the name
gyorgy@0: name = notxml && jQuery.propFix[ name ] || name;
gyorgy@0:
gyorgy@0: hooks = jQuery.propHooks[ name ];
gyorgy@0:
gyorgy@0: if ( value !== undefined ) {
gyorgy@0: if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
gyorgy@0: return ret;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return (elem[ name ] = value);
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) {
gyorgy@0: return ret;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return elem[ name ];
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: propHooks: {}
gyorgy@0: });
gyorgy@0:
gyorgy@0: // Hook for boolean attributes
gyorgy@0: boolHook = {
gyorgy@0: get: function( elem, name ) {
gyorgy@0: // Align boolean attributes with corresponding properties
gyorgy@0: return elem[ jQuery.propFix[ name ] || name ] ?
gyorgy@0: name.toLowerCase() :
gyorgy@0: undefined;
gyorgy@0: },
gyorgy@0: set: function( elem, value, name ) {
gyorgy@0: var propName;
gyorgy@0: if ( value === false ) {
gyorgy@0: // Remove boolean attributes when set to false
gyorgy@0: jQuery.removeAttr( elem, name );
gyorgy@0: } else {
gyorgy@0: // value is true since we know at this point it's type boolean and not false
gyorgy@0: // Set boolean attributes to the same name and set the DOM property
gyorgy@0: propName = jQuery.propFix[ name ] || name;
gyorgy@0: if ( propName in elem ) {
gyorgy@0: // Only set the IDL specifically if it already exists on the element
gyorgy@0: elem[ propName ] = value;
gyorgy@0: }
gyorgy@0:
gyorgy@0: elem.setAttribute( name, name.toLowerCase() );
gyorgy@0: }
gyorgy@0: return name;
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Use the value property for back compat
gyorgy@0: // Use the formHook for button elements in IE6/7 (#1954)
gyorgy@0: jQuery.attrHooks.value = {
gyorgy@0: get: function( elem, name ) {
gyorgy@0: if ( formHook && jQuery.nodeName( elem, "button" ) ) {
gyorgy@0: return formHook.get( elem, name );
gyorgy@0: }
gyorgy@0: return elem.value;
gyorgy@0: },
gyorgy@0: set: function( elem, value, name ) {
gyorgy@0: if ( formHook && jQuery.nodeName( elem, "button" ) ) {
gyorgy@0: return formHook.set( elem, value, name );
gyorgy@0: }
gyorgy@0: // Does not return so that setAttribute is also used
gyorgy@0: elem.value = value;
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: // IE6/7 do not support getting/setting some attributes with get/setAttribute
gyorgy@0: if ( !jQuery.support.getSetAttribute ) {
gyorgy@0:
gyorgy@0: // propFix is more comprehensive and contains all fixes
gyorgy@0: jQuery.attrFix = jQuery.propFix;
gyorgy@0:
gyorgy@0: // Use this for any attribute on a form in IE6/7
gyorgy@0: formHook = jQuery.attrHooks.name = jQuery.valHooks.button = {
gyorgy@0: get: function( elem, name ) {
gyorgy@0: var ret;
gyorgy@0: ret = elem.getAttributeNode( name );
gyorgy@0: // Return undefined if nodeValue is empty string
gyorgy@0: return ret && ret.nodeValue !== "" ?
gyorgy@0: ret.nodeValue :
gyorgy@0: undefined;
gyorgy@0: },
gyorgy@0: set: function( elem, value, name ) {
gyorgy@0: // Check form objects in IE (multiple bugs related)
gyorgy@0: // Only use nodeValue if the attribute node exists on the form
gyorgy@0: var ret = elem.getAttributeNode( name );
gyorgy@0: if ( ret ) {
gyorgy@0: ret.nodeValue = value;
gyorgy@0: return value;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Set width and height to auto instead of 0 on empty string( Bug #8150 )
gyorgy@0: // This is for removals
gyorgy@0: jQuery.each([ "width", "height" ], function( i, name ) {
gyorgy@0: jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
gyorgy@0: set: function( elem, value ) {
gyorgy@0: if ( value === "" ) {
gyorgy@0: elem.setAttribute( name, "auto" );
gyorgy@0: return value;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0:
gyorgy@0: // Some attributes require a special call on IE
gyorgy@0: if ( !jQuery.support.hrefNormalized ) {
gyorgy@0: jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
gyorgy@0: jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
gyorgy@0: get: function( elem ) {
gyorgy@0: var ret = elem.getAttribute( name, 2 );
gyorgy@0: return ret === null ? undefined : ret;
gyorgy@0: }
gyorgy@0: });
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !jQuery.support.style ) {
gyorgy@0: jQuery.attrHooks.style = {
gyorgy@0: get: function( elem ) {
gyorgy@0: // Return undefined in the case of empty string
gyorgy@0: // Normalize to lowercase since IE uppercases css property names
gyorgy@0: return elem.style.cssText.toLowerCase() || undefined;
gyorgy@0: },
gyorgy@0: set: function( elem, value ) {
gyorgy@0: return (elem.style.cssText = "" + value);
gyorgy@0: }
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Safari mis-reports the default selected property of an option
gyorgy@0: // Accessing the parent's selectedIndex property fixes it
gyorgy@0: if ( !jQuery.support.optSelected ) {
gyorgy@0: jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
gyorgy@0: get: function( elem ) {
gyorgy@0: var parent = elem.parentNode;
gyorgy@0:
gyorgy@0: if ( parent ) {
gyorgy@0: parent.selectedIndex;
gyorgy@0:
gyorgy@0: // Make sure that it also works with optgroups, see #5701
gyorgy@0: if ( parent.parentNode ) {
gyorgy@0: parent.parentNode.selectedIndex;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Radios and checkboxes getter/setter
gyorgy@0: if ( !jQuery.support.checkOn ) {
gyorgy@0: jQuery.each([ "radio", "checkbox" ], function() {
gyorgy@0: jQuery.valHooks[ this ] = {
gyorgy@0: get: function( elem ) {
gyorgy@0: // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
gyorgy@0: return elem.getAttribute("value") === null ? "on" : elem.value;
gyorgy@0: }
gyorgy@0: };
gyorgy@0: });
gyorgy@0: }
gyorgy@0: jQuery.each([ "radio", "checkbox" ], function() {
gyorgy@0: jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
gyorgy@0: set: function( elem, value ) {
gyorgy@0: if ( jQuery.isArray( value ) ) {
gyorgy@0: return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0: });
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: var hasOwn = Object.prototype.hasOwnProperty,
gyorgy@0: rnamespaces = /\.(.*)$/,
gyorgy@0: rformElems = /^(?:textarea|input|select)$/i,
gyorgy@0: rperiod = /\./g,
gyorgy@0: rspaces = / /g,
gyorgy@0: rescape = /[^\w\s.|`]/g,
gyorgy@0: fcleanup = function( nm ) {
gyorgy@0: return nm.replace(rescape, "\\$&");
gyorgy@0: };
gyorgy@0:
gyorgy@0: /*
gyorgy@0: * A number of helper functions used for managing events.
gyorgy@0: * Many of the ideas behind this code originated from
gyorgy@0: * Dean Edwards' addEvent library.
gyorgy@0: */
gyorgy@0: jQuery.event = {
gyorgy@0:
gyorgy@0: // Bind an event to an element
gyorgy@0: // Original by Dean Edwards
gyorgy@0: add: function( elem, types, handler, data ) {
gyorgy@0: if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( handler === false ) {
gyorgy@0: handler = returnFalse;
gyorgy@0: } else if ( !handler ) {
gyorgy@0: // Fixes bug #7229. Fix recommended by jdalton
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var handleObjIn, handleObj;
gyorgy@0:
gyorgy@0: if ( handler.handler ) {
gyorgy@0: handleObjIn = handler;
gyorgy@0: handler = handleObjIn.handler;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Make sure that the function being executed has a unique ID
gyorgy@0: if ( !handler.guid ) {
gyorgy@0: handler.guid = jQuery.guid++;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Init the element's event structure
gyorgy@0: var elemData = jQuery._data( elem );
gyorgy@0:
gyorgy@0: // If no elemData is found then we must be trying to bind to one of the
gyorgy@0: // banned noData elements
gyorgy@0: if ( !elemData ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var events = elemData.events,
gyorgy@0: eventHandle = elemData.handle;
gyorgy@0:
gyorgy@0: if ( !events ) {
gyorgy@0: elemData.events = events = {};
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !eventHandle ) {
gyorgy@0: elemData.handle = eventHandle = function( e ) {
gyorgy@0: // Discard the second event of a jQuery.event.trigger() and
gyorgy@0: // when an event is called after a page has unloaded
gyorgy@0: return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
gyorgy@0: jQuery.event.handle.apply( eventHandle.elem, arguments ) :
gyorgy@0: undefined;
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add elem as a property of the handle function
gyorgy@0: // This is to prevent a memory leak with non-native events in IE.
gyorgy@0: eventHandle.elem = elem;
gyorgy@0:
gyorgy@0: // Handle multiple events separated by a space
gyorgy@0: // jQuery(...).bind("mouseover mouseout", fn);
gyorgy@0: types = types.split(" ");
gyorgy@0:
gyorgy@0: var type, i = 0, namespaces;
gyorgy@0:
gyorgy@0: while ( (type = types[ i++ ]) ) {
gyorgy@0: handleObj = handleObjIn ?
gyorgy@0: jQuery.extend({}, handleObjIn) :
gyorgy@0: { handler: handler, data: data };
gyorgy@0:
gyorgy@0: // Namespaced event handlers
gyorgy@0: if ( type.indexOf(".") > -1 ) {
gyorgy@0: namespaces = type.split(".");
gyorgy@0: type = namespaces.shift();
gyorgy@0: handleObj.namespace = namespaces.slice(0).sort().join(".");
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: namespaces = [];
gyorgy@0: handleObj.namespace = "";
gyorgy@0: }
gyorgy@0:
gyorgy@0: handleObj.type = type;
gyorgy@0: if ( !handleObj.guid ) {
gyorgy@0: handleObj.guid = handler.guid;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Get the current list of functions bound to this event
gyorgy@0: var handlers = events[ type ],
gyorgy@0: special = jQuery.event.special[ type ] || {};
gyorgy@0:
gyorgy@0: // Init the event handler queue
gyorgy@0: if ( !handlers ) {
gyorgy@0: handlers = events[ type ] = [];
gyorgy@0:
gyorgy@0: // Check for a special event handler
gyorgy@0: // Only use addEventListener/attachEvent if the special
gyorgy@0: // events handler returns false
gyorgy@0: if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
gyorgy@0: // Bind the global event handler to the element
gyorgy@0: if ( elem.addEventListener ) {
gyorgy@0: elem.addEventListener( type, eventHandle, false );
gyorgy@0:
gyorgy@0: } else if ( elem.attachEvent ) {
gyorgy@0: elem.attachEvent( "on" + type, eventHandle );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( special.add ) {
gyorgy@0: special.add.call( elem, handleObj );
gyorgy@0:
gyorgy@0: if ( !handleObj.handler.guid ) {
gyorgy@0: handleObj.handler.guid = handler.guid;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add the function to the element's handler list
gyorgy@0: handlers.push( handleObj );
gyorgy@0:
gyorgy@0: // Keep track of which events have been used, for event optimization
gyorgy@0: jQuery.event.global[ type ] = true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Nullify elem to prevent memory leaks in IE
gyorgy@0: elem = null;
gyorgy@0: },
gyorgy@0:
gyorgy@0: global: {},
gyorgy@0:
gyorgy@0: // Detach an event or set of events from an element
gyorgy@0: remove: function( elem, types, handler, pos ) {
gyorgy@0: // don't do events on text and comment nodes
gyorgy@0: if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( handler === false ) {
gyorgy@0: handler = returnFalse;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
gyorgy@0: elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
gyorgy@0: events = elemData && elemData.events;
gyorgy@0:
gyorgy@0: if ( !elemData || !events ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // types is actually an event object here
gyorgy@0: if ( types && types.type ) {
gyorgy@0: handler = types.handler;
gyorgy@0: types = types.type;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Unbind all events for the element
gyorgy@0: if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
gyorgy@0: types = types || "";
gyorgy@0:
gyorgy@0: for ( type in events ) {
gyorgy@0: jQuery.event.remove( elem, type + types );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Handle multiple events separated by a space
gyorgy@0: // jQuery(...).unbind("mouseover mouseout", fn);
gyorgy@0: types = types.split(" ");
gyorgy@0:
gyorgy@0: while ( (type = types[ i++ ]) ) {
gyorgy@0: origType = type;
gyorgy@0: handleObj = null;
gyorgy@0: all = type.indexOf(".") < 0;
gyorgy@0: namespaces = [];
gyorgy@0:
gyorgy@0: if ( !all ) {
gyorgy@0: // Namespaced event handlers
gyorgy@0: namespaces = type.split(".");
gyorgy@0: type = namespaces.shift();
gyorgy@0:
gyorgy@0: namespace = new RegExp("(^|\\.)" +
gyorgy@0: jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
gyorgy@0: }
gyorgy@0:
gyorgy@0: eventType = events[ type ];
gyorgy@0:
gyorgy@0: if ( !eventType ) {
gyorgy@0: continue;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !handler ) {
gyorgy@0: for ( j = 0; j < eventType.length; j++ ) {
gyorgy@0: handleObj = eventType[ j ];
gyorgy@0:
gyorgy@0: if ( all || namespace.test( handleObj.namespace ) ) {
gyorgy@0: jQuery.event.remove( elem, origType, handleObj.handler, j );
gyorgy@0: eventType.splice( j--, 1 );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: continue;
gyorgy@0: }
gyorgy@0:
gyorgy@0: special = jQuery.event.special[ type ] || {};
gyorgy@0:
gyorgy@0: for ( j = pos || 0; j < eventType.length; j++ ) {
gyorgy@0: handleObj = eventType[ j ];
gyorgy@0:
gyorgy@0: if ( handler.guid === handleObj.guid ) {
gyorgy@0: // remove the given handler for the given type
gyorgy@0: if ( all || namespace.test( handleObj.namespace ) ) {
gyorgy@0: if ( pos == null ) {
gyorgy@0: eventType.splice( j--, 1 );
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( special.remove ) {
gyorgy@0: special.remove.call( elem, handleObj );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( pos != null ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // remove generic event handler if no more handlers exist
gyorgy@0: if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
gyorgy@0: if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
gyorgy@0: jQuery.removeEvent( elem, type, elemData.handle );
gyorgy@0: }
gyorgy@0:
gyorgy@0: ret = null;
gyorgy@0: delete events[ type ];
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Remove the expando if it's no longer used
gyorgy@0: if ( jQuery.isEmptyObject( events ) ) {
gyorgy@0: var handle = elemData.handle;
gyorgy@0: if ( handle ) {
gyorgy@0: handle.elem = null;
gyorgy@0: }
gyorgy@0:
gyorgy@0: delete elemData.events;
gyorgy@0: delete elemData.handle;
gyorgy@0:
gyorgy@0: if ( jQuery.isEmptyObject( elemData ) ) {
gyorgy@0: jQuery.removeData( elem, undefined, true );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Events that are safe to short-circuit if no handlers are attached.
gyorgy@0: // Native DOM events should not be added, they may have inline handlers.
gyorgy@0: customEvent: {
gyorgy@0: "getData": true,
gyorgy@0: "setData": true,
gyorgy@0: "changeData": true
gyorgy@0: },
gyorgy@0:
gyorgy@0: trigger: function( event, data, elem, onlyHandlers ) {
gyorgy@0: // Event object or event type
gyorgy@0: var type = event.type || event,
gyorgy@0: namespaces = [],
gyorgy@0: exclusive;
gyorgy@0:
gyorgy@0: if ( type.indexOf("!") >= 0 ) {
gyorgy@0: // Exclusive events trigger only for the exact event (no namespaces)
gyorgy@0: type = type.slice(0, -1);
gyorgy@0: exclusive = true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( type.indexOf(".") >= 0 ) {
gyorgy@0: // Namespaced trigger; create a regexp to match event type in handle()
gyorgy@0: namespaces = type.split(".");
gyorgy@0: type = namespaces.shift();
gyorgy@0: namespaces.sort();
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
gyorgy@0: // No jQuery handlers for this event type, and it can't have inline handlers
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Caller can pass in an Event, Object, or just an event type string
gyorgy@0: event = typeof event === "object" ?
gyorgy@0: // jQuery.Event object
gyorgy@0: event[ jQuery.expando ] ? event :
gyorgy@0: // Object literal
gyorgy@0: new jQuery.Event( type, event ) :
gyorgy@0: // Just the event type (string)
gyorgy@0: new jQuery.Event( type );
gyorgy@0:
gyorgy@0: event.type = type;
gyorgy@0: event.exclusive = exclusive;
gyorgy@0: event.namespace = namespaces.join(".");
gyorgy@0: event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
gyorgy@0:
gyorgy@0: // triggerHandler() and global events don't bubble or run the default action
gyorgy@0: if ( onlyHandlers || !elem ) {
gyorgy@0: event.preventDefault();
gyorgy@0: event.stopPropagation();
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Handle a global trigger
gyorgy@0: if ( !elem ) {
gyorgy@0: // TODO: Stop taunting the data cache; remove global events and always attach to document
gyorgy@0: jQuery.each( jQuery.cache, function() {
gyorgy@0: // internalKey variable is just used to make it easier to find
gyorgy@0: // and potentially change this stuff later; currently it just
gyorgy@0: // points to jQuery.expando
gyorgy@0: var internalKey = jQuery.expando,
gyorgy@0: internalCache = this[ internalKey ];
gyorgy@0: if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
gyorgy@0: jQuery.event.trigger( event, data, internalCache.handle.elem );
gyorgy@0: }
gyorgy@0: });
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Don't do events on text and comment nodes
gyorgy@0: if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Clean up the event in case it is being reused
gyorgy@0: event.result = undefined;
gyorgy@0: event.target = elem;
gyorgy@0:
gyorgy@0: // Clone any incoming data and prepend the event, creating the handler arg list
gyorgy@0: data = data ? jQuery.makeArray( data ) : [];
gyorgy@0: data.unshift( event );
gyorgy@0:
gyorgy@0: var cur = elem,
gyorgy@0: // IE doesn't like method names with a colon (#3533, #8272)
gyorgy@0: ontype = type.indexOf(":") < 0 ? "on" + type : "";
gyorgy@0:
gyorgy@0: // Fire event on the current element, then bubble up the DOM tree
gyorgy@0: do {
gyorgy@0: var handle = jQuery._data( cur, "handle" );
gyorgy@0:
gyorgy@0: event.currentTarget = cur;
gyorgy@0: if ( handle ) {
gyorgy@0: handle.apply( cur, data );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Trigger an inline bound script
gyorgy@0: if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
gyorgy@0: event.result = false;
gyorgy@0: event.preventDefault();
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Bubble up to document, then to window
gyorgy@0: cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
gyorgy@0: } while ( cur && !event.isPropagationStopped() );
gyorgy@0:
gyorgy@0: // If nobody prevented the default action, do it now
gyorgy@0: if ( !event.isDefaultPrevented() ) {
gyorgy@0: var old,
gyorgy@0: special = jQuery.event.special[ type ] || {};
gyorgy@0:
gyorgy@0: if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
gyorgy@0: !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
gyorgy@0:
gyorgy@0: // Call a native DOM method on the target with the same name name as the event.
gyorgy@0: // Can't use an .isFunction)() check here because IE6/7 fails that test.
gyorgy@0: // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
gyorgy@0: try {
gyorgy@0: if ( ontype && elem[ type ] ) {
gyorgy@0: // Don't re-trigger an onFOO event when we call its FOO() method
gyorgy@0: old = elem[ ontype ];
gyorgy@0:
gyorgy@0: if ( old ) {
gyorgy@0: elem[ ontype ] = null;
gyorgy@0: }
gyorgy@0:
gyorgy@0: jQuery.event.triggered = type;
gyorgy@0: elem[ type ]();
gyorgy@0: }
gyorgy@0: } catch ( ieError ) {}
gyorgy@0:
gyorgy@0: if ( old ) {
gyorgy@0: elem[ ontype ] = old;
gyorgy@0: }
gyorgy@0:
gyorgy@0: jQuery.event.triggered = undefined;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return event.result;
gyorgy@0: },
gyorgy@0:
gyorgy@0: handle: function( event ) {
gyorgy@0: event = jQuery.event.fix( event || window.event );
gyorgy@0: // Snapshot the handlers list since a called handler may add/remove events.
gyorgy@0: var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
gyorgy@0: run_all = !event.exclusive && !event.namespace,
gyorgy@0: args = Array.prototype.slice.call( arguments, 0 );
gyorgy@0:
gyorgy@0: // Use the fix-ed Event rather than the (read-only) native event
gyorgy@0: args[0] = event;
gyorgy@0: event.currentTarget = this;
gyorgy@0:
gyorgy@0: for ( var j = 0, l = handlers.length; j < l; j++ ) {
gyorgy@0: var handleObj = handlers[ j ];
gyorgy@0:
gyorgy@0: // Triggered event must 1) be non-exclusive and have no namespace, or
gyorgy@0: // 2) have namespace(s) a subset or equal to those in the bound event.
gyorgy@0: if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
gyorgy@0: // Pass in a reference to the handler function itself
gyorgy@0: // So that we can later remove it
gyorgy@0: event.handler = handleObj.handler;
gyorgy@0: event.data = handleObj.data;
gyorgy@0: event.handleObj = handleObj;
gyorgy@0:
gyorgy@0: var ret = handleObj.handler.apply( this, args );
gyorgy@0:
gyorgy@0: if ( ret !== undefined ) {
gyorgy@0: event.result = ret;
gyorgy@0: if ( ret === false ) {
gyorgy@0: event.preventDefault();
gyorgy@0: event.stopPropagation();
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( event.isImmediatePropagationStopped() ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: return event.result;
gyorgy@0: },
gyorgy@0:
gyorgy@0: 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(" "),
gyorgy@0:
gyorgy@0: fix: function( event ) {
gyorgy@0: if ( event[ jQuery.expando ] ) {
gyorgy@0: return event;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // store a copy of the original event object
gyorgy@0: // and "clone" to set read-only properties
gyorgy@0: var originalEvent = event;
gyorgy@0: event = jQuery.Event( originalEvent );
gyorgy@0:
gyorgy@0: for ( var i = this.props.length, prop; i; ) {
gyorgy@0: prop = this.props[ --i ];
gyorgy@0: event[ prop ] = originalEvent[ prop ];
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Fix target property, if necessary
gyorgy@0: if ( !event.target ) {
gyorgy@0: // Fixes #1925 where srcElement might not be defined either
gyorgy@0: event.target = event.srcElement || document;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // check if target is a textnode (safari)
gyorgy@0: if ( event.target.nodeType === 3 ) {
gyorgy@0: event.target = event.target.parentNode;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add relatedTarget, if necessary
gyorgy@0: if ( !event.relatedTarget && event.fromElement ) {
gyorgy@0: event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Calculate pageX/Y if missing and clientX/Y available
gyorgy@0: if ( event.pageX == null && event.clientX != null ) {
gyorgy@0: var eventDocument = event.target.ownerDocument || document,
gyorgy@0: doc = eventDocument.documentElement,
gyorgy@0: body = eventDocument.body;
gyorgy@0:
gyorgy@0: event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
gyorgy@0: event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add which for key events
gyorgy@0: if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
gyorgy@0: event.which = event.charCode != null ? event.charCode : event.keyCode;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
gyorgy@0: if ( !event.metaKey && event.ctrlKey ) {
gyorgy@0: event.metaKey = event.ctrlKey;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Add which for click: 1 === left; 2 === middle; 3 === right
gyorgy@0: // Note: button is not normalized, so don't use it
gyorgy@0: if ( !event.which && event.button !== undefined ) {
gyorgy@0: event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
gyorgy@0: }
gyorgy@0:
gyorgy@0: return event;
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Deprecated, use jQuery.guid instead
gyorgy@0: guid: 1E8,
gyorgy@0:
gyorgy@0: // Deprecated, use jQuery.proxy instead
gyorgy@0: proxy: jQuery.proxy,
gyorgy@0:
gyorgy@0: special: {
gyorgy@0: ready: {
gyorgy@0: // Make sure the ready event is setup
gyorgy@0: setup: jQuery.bindReady,
gyorgy@0: teardown: jQuery.noop
gyorgy@0: },
gyorgy@0:
gyorgy@0: live: {
gyorgy@0: add: function( handleObj ) {
gyorgy@0: jQuery.event.add( this,
gyorgy@0: liveConvert( handleObj.origType, handleObj.selector ),
gyorgy@0: jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
gyorgy@0: },
gyorgy@0:
gyorgy@0: remove: function( handleObj ) {
gyorgy@0: jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: beforeunload: {
gyorgy@0: setup: function( data, namespaces, eventHandle ) {
gyorgy@0: // We only want to do this special case on windows
gyorgy@0: if ( jQuery.isWindow( this ) ) {
gyorgy@0: this.onbeforeunload = eventHandle;
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: teardown: function( namespaces, eventHandle ) {
gyorgy@0: if ( this.onbeforeunload === eventHandle ) {
gyorgy@0: this.onbeforeunload = null;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: jQuery.removeEvent = document.removeEventListener ?
gyorgy@0: function( elem, type, handle ) {
gyorgy@0: if ( elem.removeEventListener ) {
gyorgy@0: elem.removeEventListener( type, handle, false );
gyorgy@0: }
gyorgy@0: } :
gyorgy@0: function( elem, type, handle ) {
gyorgy@0: if ( elem.detachEvent ) {
gyorgy@0: elem.detachEvent( "on" + type, handle );
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: jQuery.Event = function( src, props ) {
gyorgy@0: // Allow instantiation without the 'new' keyword
gyorgy@0: if ( !this.preventDefault ) {
gyorgy@0: return new jQuery.Event( src, props );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Event object
gyorgy@0: if ( src && src.type ) {
gyorgy@0: this.originalEvent = src;
gyorgy@0: this.type = src.type;
gyorgy@0:
gyorgy@0: // Events bubbling up the document may have been marked as prevented
gyorgy@0: // by a handler lower down the tree; reflect the correct value.
gyorgy@0: this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
gyorgy@0: src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
gyorgy@0:
gyorgy@0: // Event type
gyorgy@0: } else {
gyorgy@0: this.type = src;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Put explicitly provided properties onto the event object
gyorgy@0: if ( props ) {
gyorgy@0: jQuery.extend( this, props );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // timeStamp is buggy for some events on Firefox(#3843)
gyorgy@0: // So we won't rely on the native value
gyorgy@0: this.timeStamp = jQuery.now();
gyorgy@0:
gyorgy@0: // Mark it as fixed
gyorgy@0: this[ jQuery.expando ] = true;
gyorgy@0: };
gyorgy@0:
gyorgy@0: function returnFalse() {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: function returnTrue() {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
gyorgy@0: // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
gyorgy@0: jQuery.Event.prototype = {
gyorgy@0: preventDefault: function() {
gyorgy@0: this.isDefaultPrevented = returnTrue;
gyorgy@0:
gyorgy@0: var e = this.originalEvent;
gyorgy@0: if ( !e ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // if preventDefault exists run it on the original event
gyorgy@0: if ( e.preventDefault ) {
gyorgy@0: e.preventDefault();
gyorgy@0:
gyorgy@0: // otherwise set the returnValue property of the original event to false (IE)
gyorgy@0: } else {
gyorgy@0: e.returnValue = false;
gyorgy@0: }
gyorgy@0: },
gyorgy@0: stopPropagation: function() {
gyorgy@0: this.isPropagationStopped = returnTrue;
gyorgy@0:
gyorgy@0: var e = this.originalEvent;
gyorgy@0: if ( !e ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0: // if stopPropagation exists run it on the original event
gyorgy@0: if ( e.stopPropagation ) {
gyorgy@0: e.stopPropagation();
gyorgy@0: }
gyorgy@0: // otherwise set the cancelBubble property of the original event to true (IE)
gyorgy@0: e.cancelBubble = true;
gyorgy@0: },
gyorgy@0: stopImmediatePropagation: function() {
gyorgy@0: this.isImmediatePropagationStopped = returnTrue;
gyorgy@0: this.stopPropagation();
gyorgy@0: },
gyorgy@0: isDefaultPrevented: returnFalse,
gyorgy@0: isPropagationStopped: returnFalse,
gyorgy@0: isImmediatePropagationStopped: returnFalse
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Checks if an event happened on an element within another element
gyorgy@0: // Used in jQuery.event.special.mouseenter and mouseleave handlers
gyorgy@0: var withinElement = function( event ) {
gyorgy@0: // Check if mouse(over|out) are still within the same parent element
gyorgy@0: var parent = event.relatedTarget;
gyorgy@0:
gyorgy@0: // set the correct event type
gyorgy@0: event.type = event.data;
gyorgy@0:
gyorgy@0: // Firefox sometimes assigns relatedTarget a XUL element
gyorgy@0: // which we cannot access the parentNode property of
gyorgy@0: try {
gyorgy@0:
gyorgy@0: // Chrome does something similar, the parentNode property
gyorgy@0: // can be accessed but is null.
gyorgy@0: if ( parent && parent !== document && !parent.parentNode ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Traverse up the tree
gyorgy@0: while ( parent && parent !== this ) {
gyorgy@0: parent = parent.parentNode;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( parent !== this ) {
gyorgy@0: // handle event if we actually just moused on to a non sub-element
gyorgy@0: jQuery.event.handle.apply( this, arguments );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // assuming we've left the element since we most likely mousedover a xul element
gyorgy@0: } catch(e) { }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // In case of event delegation, we only need to rename the event.type,
gyorgy@0: // liveHandler will take care of the rest.
gyorgy@0: delegate = function( event ) {
gyorgy@0: event.type = event.data;
gyorgy@0: jQuery.event.handle.apply( this, arguments );
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Create mouseenter and mouseleave events
gyorgy@0: jQuery.each({
gyorgy@0: mouseenter: "mouseover",
gyorgy@0: mouseleave: "mouseout"
gyorgy@0: }, function( orig, fix ) {
gyorgy@0: jQuery.event.special[ orig ] = {
gyorgy@0: setup: function( data ) {
gyorgy@0: jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
gyorgy@0: },
gyorgy@0: teardown: function( data ) {
gyorgy@0: jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
gyorgy@0: }
gyorgy@0: };
gyorgy@0: });
gyorgy@0:
gyorgy@0: // submit delegation
gyorgy@0: if ( !jQuery.support.submitBubbles ) {
gyorgy@0:
gyorgy@0: jQuery.event.special.submit = {
gyorgy@0: setup: function( data, namespaces ) {
gyorgy@0: if ( !jQuery.nodeName( this, "form" ) ) {
gyorgy@0: jQuery.event.add(this, "click.specialSubmit", function( e ) {
gyorgy@0: var elem = e.target,
gyorgy@0: type = elem.type;
gyorgy@0:
gyorgy@0: if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
gyorgy@0: trigger( "submit", this, arguments );
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
gyorgy@0: var elem = e.target,
gyorgy@0: type = elem.type;
gyorgy@0:
gyorgy@0: if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
gyorgy@0: trigger( "submit", this, arguments );
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: teardown: function( namespaces ) {
gyorgy@0: jQuery.event.remove( this, ".specialSubmit" );
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: }
gyorgy@0:
gyorgy@0: // change delegation, happens here so we have bind.
gyorgy@0: if ( !jQuery.support.changeBubbles ) {
gyorgy@0:
gyorgy@0: var changeFilters,
gyorgy@0:
gyorgy@0: getVal = function( elem ) {
gyorgy@0: var type = elem.type, val = elem.value;
gyorgy@0:
gyorgy@0: if ( type === "radio" || type === "checkbox" ) {
gyorgy@0: val = elem.checked;
gyorgy@0:
gyorgy@0: } else if ( type === "select-multiple" ) {
gyorgy@0: val = elem.selectedIndex > -1 ?
gyorgy@0: jQuery.map( elem.options, function( elem ) {
gyorgy@0: return elem.selected;
gyorgy@0: }).join("-") :
gyorgy@0: "";
gyorgy@0:
gyorgy@0: } else if ( jQuery.nodeName( elem, "select" ) ) {
gyorgy@0: val = elem.selectedIndex;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return val;
gyorgy@0: },
gyorgy@0:
gyorgy@0: testChange = function testChange( e ) {
gyorgy@0: var elem = e.target, data, val;
gyorgy@0:
gyorgy@0: if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: data = jQuery._data( elem, "_change_data" );
gyorgy@0: val = getVal(elem);
gyorgy@0:
gyorgy@0: // the current data will be also retrieved by beforeactivate
gyorgy@0: if ( e.type !== "focusout" || elem.type !== "radio" ) {
gyorgy@0: jQuery._data( elem, "_change_data", val );
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( data === undefined || val === data ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( data != null || val ) {
gyorgy@0: e.type = "change";
gyorgy@0: e.liveFired = undefined;
gyorgy@0: jQuery.event.trigger( e, arguments[1], elem );
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: jQuery.event.special.change = {
gyorgy@0: filters: {
gyorgy@0: focusout: testChange,
gyorgy@0:
gyorgy@0: beforedeactivate: testChange,
gyorgy@0:
gyorgy@0: click: function( e ) {
gyorgy@0: var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
gyorgy@0:
gyorgy@0: if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
gyorgy@0: testChange.call( this, e );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Change has to be called before submit
gyorgy@0: // Keydown will be called before keypress, which is used in submit-event delegation
gyorgy@0: keydown: function( e ) {
gyorgy@0: var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
gyorgy@0:
gyorgy@0: if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
gyorgy@0: (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
gyorgy@0: type === "select-multiple" ) {
gyorgy@0: testChange.call( this, e );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Beforeactivate happens also before the previous element is blurred
gyorgy@0: // with this event you can't trigger a change event, but you can store
gyorgy@0: // information
gyorgy@0: beforeactivate: function( e ) {
gyorgy@0: var elem = e.target;
gyorgy@0: jQuery._data( elem, "_change_data", getVal(elem) );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: setup: function( data, namespaces ) {
gyorgy@0: if ( this.type === "file" ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( var type in changeFilters ) {
gyorgy@0: jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return rformElems.test( this.nodeName );
gyorgy@0: },
gyorgy@0:
gyorgy@0: teardown: function( namespaces ) {
gyorgy@0: jQuery.event.remove( this, ".specialChange" );
gyorgy@0:
gyorgy@0: return rformElems.test( this.nodeName );
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: changeFilters = jQuery.event.special.change.filters;
gyorgy@0:
gyorgy@0: // Handle when the input is .focus()'d
gyorgy@0: changeFilters.focus = changeFilters.beforeactivate;
gyorgy@0: }
gyorgy@0:
gyorgy@0: function trigger( type, elem, args ) {
gyorgy@0: // Piggyback on a donor event to simulate a different one.
gyorgy@0: // Fake originalEvent to avoid donor's stopPropagation, but if the
gyorgy@0: // simulated event prevents default then we do the same on the donor.
gyorgy@0: // Don't pass args or remember liveFired; they apply to the donor event.
gyorgy@0: var event = jQuery.extend( {}, args[ 0 ] );
gyorgy@0: event.type = type;
gyorgy@0: event.originalEvent = {};
gyorgy@0: event.liveFired = undefined;
gyorgy@0: jQuery.event.handle.call( elem, event );
gyorgy@0: if ( event.isDefaultPrevented() ) {
gyorgy@0: args[ 0 ].preventDefault();
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Create "bubbling" focus and blur events
gyorgy@0: if ( !jQuery.support.focusinBubbles ) {
gyorgy@0: jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
gyorgy@0:
gyorgy@0: // Attach a single capturing handler while someone wants focusin/focusout
gyorgy@0: var attaches = 0;
gyorgy@0:
gyorgy@0: jQuery.event.special[ fix ] = {
gyorgy@0: setup: function() {
gyorgy@0: if ( attaches++ === 0 ) {
gyorgy@0: document.addEventListener( orig, handler, true );
gyorgy@0: }
gyorgy@0: },
gyorgy@0: teardown: function() {
gyorgy@0: if ( --attaches === 0 ) {
gyorgy@0: document.removeEventListener( orig, handler, true );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: function handler( donor ) {
gyorgy@0: // Donor event is always a native one; fix it and switch its type.
gyorgy@0: // Let focusin/out handler cancel the donor focus/blur event.
gyorgy@0: var e = jQuery.event.fix( donor );
gyorgy@0: e.type = fix;
gyorgy@0: e.originalEvent = {};
gyorgy@0: jQuery.event.trigger( e, null, e.target );
gyorgy@0: if ( e.isDefaultPrevented() ) {
gyorgy@0: donor.preventDefault();
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: jQuery.each(["bind", "one"], function( i, name ) {
gyorgy@0: jQuery.fn[ name ] = function( type, data, fn ) {
gyorgy@0: var handler;
gyorgy@0:
gyorgy@0: // Handle object literals
gyorgy@0: if ( typeof type === "object" ) {
gyorgy@0: for ( var key in type ) {
gyorgy@0: this[ name ](key, data, type[key], fn);
gyorgy@0: }
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( arguments.length === 2 || data === false ) {
gyorgy@0: fn = data;
gyorgy@0: data = undefined;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( name === "one" ) {
gyorgy@0: handler = function( event ) {
gyorgy@0: jQuery( this ).unbind( event, handler );
gyorgy@0: return fn.apply( this, arguments );
gyorgy@0: };
gyorgy@0: handler.guid = fn.guid || jQuery.guid++;
gyorgy@0: } else {
gyorgy@0: handler = fn;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( type === "unload" && name !== "one" ) {
gyorgy@0: this.one( type, data, fn );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: for ( var i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: jQuery.event.add( this[i], type, handler, data );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: };
gyorgy@0: });
gyorgy@0:
gyorgy@0: jQuery.fn.extend({
gyorgy@0: unbind: function( type, fn ) {
gyorgy@0: // Handle object literals
gyorgy@0: if ( typeof type === "object" && !type.preventDefault ) {
gyorgy@0: for ( var key in type ) {
gyorgy@0: this.unbind(key, type[key]);
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: for ( var i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: jQuery.event.remove( this[i], type, fn );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: },
gyorgy@0:
gyorgy@0: delegate: function( selector, types, data, fn ) {
gyorgy@0: return this.live( types, data, fn, selector );
gyorgy@0: },
gyorgy@0:
gyorgy@0: undelegate: function( selector, types, fn ) {
gyorgy@0: if ( arguments.length === 0 ) {
gyorgy@0: return this.unbind( "live" );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return this.die( types, null, fn, selector );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: trigger: function( type, data ) {
gyorgy@0: return this.each(function() {
gyorgy@0: jQuery.event.trigger( type, data, this );
gyorgy@0: });
gyorgy@0: },
gyorgy@0:
gyorgy@0: triggerHandler: function( type, data ) {
gyorgy@0: if ( this[0] ) {
gyorgy@0: return jQuery.event.trigger( type, data, this[0], true );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: toggle: function( fn ) {
gyorgy@0: // Save reference to arguments for access in closure
gyorgy@0: var args = arguments,
gyorgy@0: guid = fn.guid || jQuery.guid++,
gyorgy@0: i = 0,
gyorgy@0: toggler = function( event ) {
gyorgy@0: // Figure out which function to execute
gyorgy@0: var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
gyorgy@0: jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
gyorgy@0:
gyorgy@0: // Make sure that clicks stop
gyorgy@0: event.preventDefault();
gyorgy@0:
gyorgy@0: // and execute the function
gyorgy@0: return args[ lastToggle ].apply( this, arguments ) || false;
gyorgy@0: };
gyorgy@0:
gyorgy@0: // link all the functions, so any of them can unbind this click handler
gyorgy@0: toggler.guid = guid;
gyorgy@0: while ( i < args.length ) {
gyorgy@0: args[ i++ ].guid = guid;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this.click( toggler );
gyorgy@0: },
gyorgy@0:
gyorgy@0: hover: function( fnOver, fnOut ) {
gyorgy@0: return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: var liveMap = {
gyorgy@0: focus: "focusin",
gyorgy@0: blur: "focusout",
gyorgy@0: mouseenter: "mouseover",
gyorgy@0: mouseleave: "mouseout"
gyorgy@0: };
gyorgy@0:
gyorgy@0: jQuery.each(["live", "die"], function( i, name ) {
gyorgy@0: jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
gyorgy@0: var type, i = 0, match, namespaces, preType,
gyorgy@0: selector = origSelector || this.selector,
gyorgy@0: context = origSelector ? this : jQuery( this.context );
gyorgy@0:
gyorgy@0: if ( typeof types === "object" && !types.preventDefault ) {
gyorgy@0: for ( var key in types ) {
gyorgy@0: context[ name ]( key, data, types[key], selector );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( name === "die" && !types &&
gyorgy@0: origSelector && origSelector.charAt(0) === "." ) {
gyorgy@0:
gyorgy@0: context.unbind( origSelector );
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( data === false || jQuery.isFunction( data ) ) {
gyorgy@0: fn = data || returnFalse;
gyorgy@0: data = undefined;
gyorgy@0: }
gyorgy@0:
gyorgy@0: types = (types || "").split(" ");
gyorgy@0:
gyorgy@0: while ( (type = types[ i++ ]) != null ) {
gyorgy@0: match = rnamespaces.exec( type );
gyorgy@0: namespaces = "";
gyorgy@0:
gyorgy@0: if ( match ) {
gyorgy@0: namespaces = match[0];
gyorgy@0: type = type.replace( rnamespaces, "" );
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( type === "hover" ) {
gyorgy@0: types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
gyorgy@0: continue;
gyorgy@0: }
gyorgy@0:
gyorgy@0: preType = type;
gyorgy@0:
gyorgy@0: if ( liveMap[ type ] ) {
gyorgy@0: types.push( liveMap[ type ] + namespaces );
gyorgy@0: type = type + namespaces;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: type = (liveMap[ type ] || type) + namespaces;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( name === "live" ) {
gyorgy@0: // bind live handler
gyorgy@0: for ( var j = 0, l = context.length; j < l; j++ ) {
gyorgy@0: jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
gyorgy@0: { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: // unbind live handler
gyorgy@0: context.unbind( "live." + liveConvert( type, selector ), fn );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this;
gyorgy@0: };
gyorgy@0: });
gyorgy@0:
gyorgy@0: function liveHandler( event ) {
gyorgy@0: var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
gyorgy@0: elems = [],
gyorgy@0: selectors = [],
gyorgy@0: events = jQuery._data( this, "events" );
gyorgy@0:
gyorgy@0: // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
gyorgy@0: if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( event.namespace ) {
gyorgy@0: namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
gyorgy@0: }
gyorgy@0:
gyorgy@0: event.liveFired = this;
gyorgy@0:
gyorgy@0: var live = events.live.slice(0);
gyorgy@0:
gyorgy@0: for ( j = 0; j < live.length; j++ ) {
gyorgy@0: handleObj = live[j];
gyorgy@0:
gyorgy@0: if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
gyorgy@0: selectors.push( handleObj.selector );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: live.splice( j--, 1 );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: match = jQuery( event.target ).closest( selectors, event.currentTarget );
gyorgy@0:
gyorgy@0: for ( i = 0, l = match.length; i < l; i++ ) {
gyorgy@0: close = match[i];
gyorgy@0:
gyorgy@0: for ( j = 0; j < live.length; j++ ) {
gyorgy@0: handleObj = live[j];
gyorgy@0:
gyorgy@0: if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
gyorgy@0: elem = close.elem;
gyorgy@0: related = null;
gyorgy@0:
gyorgy@0: // Those two events require additional checking
gyorgy@0: if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
gyorgy@0: event.type = handleObj.preType;
gyorgy@0: related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
gyorgy@0:
gyorgy@0: // Make sure not to accidentally match a child element with the same selector
gyorgy@0: if ( related && jQuery.contains( elem, related ) ) {
gyorgy@0: related = elem;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !related || related !== elem ) {
gyorgy@0: elems.push({ elem: elem, handleObj: handleObj, level: close.level });
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( i = 0, l = elems.length; i < l; i++ ) {
gyorgy@0: match = elems[i];
gyorgy@0:
gyorgy@0: if ( maxLevel && match.level > maxLevel ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0:
gyorgy@0: event.currentTarget = match.elem;
gyorgy@0: event.data = match.handleObj.data;
gyorgy@0: event.handleObj = match.handleObj;
gyorgy@0:
gyorgy@0: ret = match.handleObj.origHandler.apply( match.elem, arguments );
gyorgy@0:
gyorgy@0: if ( ret === false || event.isPropagationStopped() ) {
gyorgy@0: maxLevel = match.level;
gyorgy@0:
gyorgy@0: if ( ret === false ) {
gyorgy@0: stop = false;
gyorgy@0: }
gyorgy@0: if ( event.isImmediatePropagationStopped() ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return stop;
gyorgy@0: }
gyorgy@0:
gyorgy@0: function liveConvert( type, selector ) {
gyorgy@0: return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
gyorgy@0: }
gyorgy@0:
gyorgy@0: jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
gyorgy@0: "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
gyorgy@0: "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
gyorgy@0:
gyorgy@0: // Handle event binding
gyorgy@0: jQuery.fn[ name ] = function( data, fn ) {
gyorgy@0: if ( fn == null ) {
gyorgy@0: fn = data;
gyorgy@0: data = null;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return arguments.length > 0 ?
gyorgy@0: this.bind( name, data, fn ) :
gyorgy@0: this.trigger( name );
gyorgy@0: };
gyorgy@0:
gyorgy@0: if ( jQuery.attrFn ) {
gyorgy@0: jQuery.attrFn[ name ] = true;
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: /*!
gyorgy@0: * Sizzle CSS Selector Engine
gyorgy@0: * Copyright 2011, The Dojo Foundation
gyorgy@0: * Released under the MIT, BSD, and GPL Licenses.
gyorgy@0: * More information: http://sizzlejs.com/
gyorgy@0: */
gyorgy@0: (function(){
gyorgy@0:
gyorgy@0: var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
gyorgy@0: done = 0,
gyorgy@0: toString = Object.prototype.toString,
gyorgy@0: hasDuplicate = false,
gyorgy@0: baseHasDuplicate = true,
gyorgy@0: rBackslash = /\\/g,
gyorgy@0: rNonWord = /\W/;
gyorgy@0:
gyorgy@0: // Here we check if the JavaScript engine is using some sort of
gyorgy@0: // optimization where it does not always call our comparision
gyorgy@0: // function. If that is the case, discard the hasDuplicate value.
gyorgy@0: // Thus far that includes Google Chrome.
gyorgy@0: [0, 0].sort(function() {
gyorgy@0: baseHasDuplicate = false;
gyorgy@0: return 0;
gyorgy@0: });
gyorgy@0:
gyorgy@0: var Sizzle = function( selector, context, results, seed ) {
gyorgy@0: results = results || [];
gyorgy@0: context = context || document;
gyorgy@0:
gyorgy@0: var origContext = context;
gyorgy@0:
gyorgy@0: if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
gyorgy@0: return [];
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !selector || typeof selector !== "string" ) {
gyorgy@0: return results;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var m, set, checkSet, extra, ret, cur, pop, i,
gyorgy@0: prune = true,
gyorgy@0: contextXML = Sizzle.isXML( context ),
gyorgy@0: parts = [],
gyorgy@0: soFar = selector;
gyorgy@0:
gyorgy@0: // Reset the position of the chunker regexp (start from head)
gyorgy@0: do {
gyorgy@0: chunker.exec( "" );
gyorgy@0: m = chunker.exec( soFar );
gyorgy@0:
gyorgy@0: if ( m ) {
gyorgy@0: soFar = m[3];
gyorgy@0:
gyorgy@0: parts.push( m[1] );
gyorgy@0:
gyorgy@0: if ( m[2] ) {
gyorgy@0: extra = m[3];
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: } while ( m );
gyorgy@0:
gyorgy@0: if ( parts.length > 1 && origPOS.exec( selector ) ) {
gyorgy@0:
gyorgy@0: if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
gyorgy@0: set = posProcess( parts[0] + parts[1], context );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: set = Expr.relative[ parts[0] ] ?
gyorgy@0: [ context ] :
gyorgy@0: Sizzle( parts.shift(), context );
gyorgy@0:
gyorgy@0: while ( parts.length ) {
gyorgy@0: selector = parts.shift();
gyorgy@0:
gyorgy@0: if ( Expr.relative[ selector ] ) {
gyorgy@0: selector += parts.shift();
gyorgy@0: }
gyorgy@0:
gyorgy@0: set = posProcess( selector, set );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: // Take a shortcut and set the context if the root selector is an ID
gyorgy@0: // (but not if it'll be faster if the inner selector is an ID)
gyorgy@0: if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
gyorgy@0: Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
gyorgy@0:
gyorgy@0: ret = Sizzle.find( parts.shift(), context, contextXML );
gyorgy@0: context = ret.expr ?
gyorgy@0: Sizzle.filter( ret.expr, ret.set )[0] :
gyorgy@0: ret.set[0];
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( context ) {
gyorgy@0: ret = seed ?
gyorgy@0: { expr: parts.pop(), set: makeArray(seed) } :
gyorgy@0: Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
gyorgy@0:
gyorgy@0: set = ret.expr ?
gyorgy@0: Sizzle.filter( ret.expr, ret.set ) :
gyorgy@0: ret.set;
gyorgy@0:
gyorgy@0: if ( parts.length > 0 ) {
gyorgy@0: checkSet = makeArray( set );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: prune = false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: while ( parts.length ) {
gyorgy@0: cur = parts.pop();
gyorgy@0: pop = cur;
gyorgy@0:
gyorgy@0: if ( !Expr.relative[ cur ] ) {
gyorgy@0: cur = "";
gyorgy@0: } else {
gyorgy@0: pop = parts.pop();
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( pop == null ) {
gyorgy@0: pop = context;
gyorgy@0: }
gyorgy@0:
gyorgy@0: Expr.relative[ cur ]( checkSet, pop, contextXML );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: checkSet = parts = [];
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !checkSet ) {
gyorgy@0: checkSet = set;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !checkSet ) {
gyorgy@0: Sizzle.error( cur || selector );
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( toString.call(checkSet) === "[object Array]" ) {
gyorgy@0: if ( !prune ) {
gyorgy@0: results.push.apply( results, checkSet );
gyorgy@0:
gyorgy@0: } else if ( context && context.nodeType === 1 ) {
gyorgy@0: for ( i = 0; checkSet[i] != null; i++ ) {
gyorgy@0: if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
gyorgy@0: results.push( set[i] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: for ( i = 0; checkSet[i] != null; i++ ) {
gyorgy@0: if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
gyorgy@0: results.push( set[i] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: makeArray( checkSet, results );
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( extra ) {
gyorgy@0: Sizzle( extra, origContext, results, seed );
gyorgy@0: Sizzle.uniqueSort( results );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return results;
gyorgy@0: };
gyorgy@0:
gyorgy@0: Sizzle.uniqueSort = function( results ) {
gyorgy@0: if ( sortOrder ) {
gyorgy@0: hasDuplicate = baseHasDuplicate;
gyorgy@0: results.sort( sortOrder );
gyorgy@0:
gyorgy@0: if ( hasDuplicate ) {
gyorgy@0: for ( var i = 1; i < results.length; i++ ) {
gyorgy@0: if ( results[i] === results[ i - 1 ] ) {
gyorgy@0: results.splice( i--, 1 );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return results;
gyorgy@0: };
gyorgy@0:
gyorgy@0: Sizzle.matches = function( expr, set ) {
gyorgy@0: return Sizzle( expr, null, null, set );
gyorgy@0: };
gyorgy@0:
gyorgy@0: Sizzle.matchesSelector = function( node, expr ) {
gyorgy@0: return Sizzle( expr, null, null, [node] ).length > 0;
gyorgy@0: };
gyorgy@0:
gyorgy@0: Sizzle.find = function( expr, context, isXML ) {
gyorgy@0: var set;
gyorgy@0:
gyorgy@0: if ( !expr ) {
gyorgy@0: return [];
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
gyorgy@0: var match,
gyorgy@0: type = Expr.order[i];
gyorgy@0:
gyorgy@0: if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
gyorgy@0: var left = match[1];
gyorgy@0: match.splice( 1, 1 );
gyorgy@0:
gyorgy@0: if ( left.substr( left.length - 1 ) !== "\\" ) {
gyorgy@0: match[1] = (match[1] || "").replace( rBackslash, "" );
gyorgy@0: set = Expr.find[ type ]( match, context, isXML );
gyorgy@0:
gyorgy@0: if ( set != null ) {
gyorgy@0: expr = expr.replace( Expr.match[ type ], "" );
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !set ) {
gyorgy@0: set = typeof context.getElementsByTagName !== "undefined" ?
gyorgy@0: context.getElementsByTagName( "*" ) :
gyorgy@0: [];
gyorgy@0: }
gyorgy@0:
gyorgy@0: return { set: set, expr: expr };
gyorgy@0: };
gyorgy@0:
gyorgy@0: Sizzle.filter = function( expr, set, inplace, not ) {
gyorgy@0: var match, anyFound,
gyorgy@0: old = expr,
gyorgy@0: result = [],
gyorgy@0: curLoop = set,
gyorgy@0: isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
gyorgy@0:
gyorgy@0: while ( expr && set.length ) {
gyorgy@0: for ( var type in Expr.filter ) {
gyorgy@0: if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
gyorgy@0: var found, item,
gyorgy@0: filter = Expr.filter[ type ],
gyorgy@0: left = match[1];
gyorgy@0:
gyorgy@0: anyFound = false;
gyorgy@0:
gyorgy@0: match.splice(1,1);
gyorgy@0:
gyorgy@0: if ( left.substr( left.length - 1 ) === "\\" ) {
gyorgy@0: continue;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( curLoop === result ) {
gyorgy@0: result = [];
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( Expr.preFilter[ type ] ) {
gyorgy@0: match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
gyorgy@0:
gyorgy@0: if ( !match ) {
gyorgy@0: anyFound = found = true;
gyorgy@0:
gyorgy@0: } else if ( match === true ) {
gyorgy@0: continue;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( match ) {
gyorgy@0: for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
gyorgy@0: if ( item ) {
gyorgy@0: found = filter( item, match, i, curLoop );
gyorgy@0: var pass = not ^ !!found;
gyorgy@0:
gyorgy@0: if ( inplace && found != null ) {
gyorgy@0: if ( pass ) {
gyorgy@0: anyFound = true;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: curLoop[i] = false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else if ( pass ) {
gyorgy@0: result.push( item );
gyorgy@0: anyFound = true;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( found !== undefined ) {
gyorgy@0: if ( !inplace ) {
gyorgy@0: curLoop = result;
gyorgy@0: }
gyorgy@0:
gyorgy@0: expr = expr.replace( Expr.match[ type ], "" );
gyorgy@0:
gyorgy@0: if ( !anyFound ) {
gyorgy@0: return [];
gyorgy@0: }
gyorgy@0:
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Improper expression
gyorgy@0: if ( expr === old ) {
gyorgy@0: if ( anyFound == null ) {
gyorgy@0: Sizzle.error( expr );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: old = expr;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return curLoop;
gyorgy@0: };
gyorgy@0:
gyorgy@0: Sizzle.error = function( msg ) {
gyorgy@0: throw "Syntax error, unrecognized expression: " + msg;
gyorgy@0: };
gyorgy@0:
gyorgy@0: var Expr = Sizzle.selectors = {
gyorgy@0: order: [ "ID", "NAME", "TAG" ],
gyorgy@0:
gyorgy@0: match: {
gyorgy@0: ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
gyorgy@0: CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
gyorgy@0: NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
gyorgy@0: ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
gyorgy@0: TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
gyorgy@0: CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
gyorgy@0: POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
gyorgy@0: PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
gyorgy@0: },
gyorgy@0:
gyorgy@0: leftMatch: {},
gyorgy@0:
gyorgy@0: attrMap: {
gyorgy@0: "class": "className",
gyorgy@0: "for": "htmlFor"
gyorgy@0: },
gyorgy@0:
gyorgy@0: attrHandle: {
gyorgy@0: href: function( elem ) {
gyorgy@0: return elem.getAttribute( "href" );
gyorgy@0: },
gyorgy@0: type: function( elem ) {
gyorgy@0: return elem.getAttribute( "type" );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: relative: {
gyorgy@0: "+": function(checkSet, part){
gyorgy@0: var isPartStr = typeof part === "string",
gyorgy@0: isTag = isPartStr && !rNonWord.test( part ),
gyorgy@0: isPartStrNotTag = isPartStr && !isTag;
gyorgy@0:
gyorgy@0: if ( isTag ) {
gyorgy@0: part = part.toLowerCase();
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
gyorgy@0: if ( (elem = checkSet[i]) ) {
gyorgy@0: while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
gyorgy@0:
gyorgy@0: checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
gyorgy@0: elem || false :
gyorgy@0: elem === part;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( isPartStrNotTag ) {
gyorgy@0: Sizzle.filter( part, checkSet, true );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: ">": function( checkSet, part ) {
gyorgy@0: var elem,
gyorgy@0: isPartStr = typeof part === "string",
gyorgy@0: i = 0,
gyorgy@0: l = checkSet.length;
gyorgy@0:
gyorgy@0: if ( isPartStr && !rNonWord.test( part ) ) {
gyorgy@0: part = part.toLowerCase();
gyorgy@0:
gyorgy@0: for ( ; i < l; i++ ) {
gyorgy@0: elem = checkSet[i];
gyorgy@0:
gyorgy@0: if ( elem ) {
gyorgy@0: var parent = elem.parentNode;
gyorgy@0: checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: for ( ; i < l; i++ ) {
gyorgy@0: elem = checkSet[i];
gyorgy@0:
gyorgy@0: if ( elem ) {
gyorgy@0: checkSet[i] = isPartStr ?
gyorgy@0: elem.parentNode :
gyorgy@0: elem.parentNode === part;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( isPartStr ) {
gyorgy@0: Sizzle.filter( part, checkSet, true );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: "": function(checkSet, part, isXML){
gyorgy@0: var nodeCheck,
gyorgy@0: doneName = done++,
gyorgy@0: checkFn = dirCheck;
gyorgy@0:
gyorgy@0: if ( typeof part === "string" && !rNonWord.test( part ) ) {
gyorgy@0: part = part.toLowerCase();
gyorgy@0: nodeCheck = part;
gyorgy@0: checkFn = dirNodeCheck;
gyorgy@0: }
gyorgy@0:
gyorgy@0: checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
gyorgy@0: },
gyorgy@0:
gyorgy@0: "~": function( checkSet, part, isXML ) {
gyorgy@0: var nodeCheck,
gyorgy@0: doneName = done++,
gyorgy@0: checkFn = dirCheck;
gyorgy@0:
gyorgy@0: if ( typeof part === "string" && !rNonWord.test( part ) ) {
gyorgy@0: part = part.toLowerCase();
gyorgy@0: nodeCheck = part;
gyorgy@0: checkFn = dirNodeCheck;
gyorgy@0: }
gyorgy@0:
gyorgy@0: checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: find: {
gyorgy@0: ID: function( match, context, isXML ) {
gyorgy@0: if ( typeof context.getElementById !== "undefined" && !isXML ) {
gyorgy@0: var m = context.getElementById(match[1]);
gyorgy@0: // Check parentNode to catch when Blackberry 4.6 returns
gyorgy@0: // nodes that are no longer in the document #6963
gyorgy@0: return m && m.parentNode ? [m] : [];
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: NAME: function( match, context ) {
gyorgy@0: if ( typeof context.getElementsByName !== "undefined" ) {
gyorgy@0: var ret = [],
gyorgy@0: results = context.getElementsByName( match[1] );
gyorgy@0:
gyorgy@0: for ( var i = 0, l = results.length; i < l; i++ ) {
gyorgy@0: if ( results[i].getAttribute("name") === match[1] ) {
gyorgy@0: ret.push( results[i] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret.length === 0 ? null : ret;
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: TAG: function( match, context ) {
gyorgy@0: if ( typeof context.getElementsByTagName !== "undefined" ) {
gyorgy@0: return context.getElementsByTagName( match[1] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0: preFilter: {
gyorgy@0: CLASS: function( match, curLoop, inplace, result, not, isXML ) {
gyorgy@0: match = " " + match[1].replace( rBackslash, "" ) + " ";
gyorgy@0:
gyorgy@0: if ( isXML ) {
gyorgy@0: return match;
gyorgy@0: }
gyorgy@0:
gyorgy@0: for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
gyorgy@0: if ( elem ) {
gyorgy@0: if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
gyorgy@0: if ( !inplace ) {
gyorgy@0: result.push( elem );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else if ( inplace ) {
gyorgy@0: curLoop[i] = false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return false;
gyorgy@0: },
gyorgy@0:
gyorgy@0: ID: function( match ) {
gyorgy@0: return match[1].replace( rBackslash, "" );
gyorgy@0: },
gyorgy@0:
gyorgy@0: TAG: function( match, curLoop ) {
gyorgy@0: return match[1].replace( rBackslash, "" ).toLowerCase();
gyorgy@0: },
gyorgy@0:
gyorgy@0: CHILD: function( match ) {
gyorgy@0: if ( match[1] === "nth" ) {
gyorgy@0: if ( !match[2] ) {
gyorgy@0: Sizzle.error( match[0] );
gyorgy@0: }
gyorgy@0:
gyorgy@0: match[2] = match[2].replace(/^\+|\s*/g, '');
gyorgy@0:
gyorgy@0: // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
gyorgy@0: var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
gyorgy@0: match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
gyorgy@0: !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
gyorgy@0:
gyorgy@0: // calculate the numbers (first)n+(last) including if they are negative
gyorgy@0: match[2] = (test[1] + (test[2] || 1)) - 0;
gyorgy@0: match[3] = test[3] - 0;
gyorgy@0: }
gyorgy@0: else if ( match[2] ) {
gyorgy@0: Sizzle.error( match[0] );
gyorgy@0: }
gyorgy@0:
gyorgy@0: // TODO: Move to normal caching system
gyorgy@0: match[0] = done++;
gyorgy@0:
gyorgy@0: return match;
gyorgy@0: },
gyorgy@0:
gyorgy@0: ATTR: function( match, curLoop, inplace, result, not, isXML ) {
gyorgy@0: var name = match[1] = match[1].replace( rBackslash, "" );
gyorgy@0:
gyorgy@0: if ( !isXML && Expr.attrMap[name] ) {
gyorgy@0: match[1] = Expr.attrMap[name];
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Handle if an un-quoted value was used
gyorgy@0: match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
gyorgy@0:
gyorgy@0: if ( match[2] === "~=" ) {
gyorgy@0: match[4] = " " + match[4] + " ";
gyorgy@0: }
gyorgy@0:
gyorgy@0: return match;
gyorgy@0: },
gyorgy@0:
gyorgy@0: PSEUDO: function( match, curLoop, inplace, result, not ) {
gyorgy@0: if ( match[1] === "not" ) {
gyorgy@0: // If we're dealing with a complex expression, or a simple one
gyorgy@0: if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
gyorgy@0: match[3] = Sizzle(match[3], null, null, curLoop);
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
gyorgy@0:
gyorgy@0: if ( !inplace ) {
gyorgy@0: result.push.apply( result, ret );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return match;
gyorgy@0: },
gyorgy@0:
gyorgy@0: POS: function( match ) {
gyorgy@0: match.unshift( true );
gyorgy@0:
gyorgy@0: return match;
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: filters: {
gyorgy@0: enabled: function( elem ) {
gyorgy@0: return elem.disabled === false && elem.type !== "hidden";
gyorgy@0: },
gyorgy@0:
gyorgy@0: disabled: function( elem ) {
gyorgy@0: return elem.disabled === true;
gyorgy@0: },
gyorgy@0:
gyorgy@0: checked: function( elem ) {
gyorgy@0: return elem.checked === true;
gyorgy@0: },
gyorgy@0:
gyorgy@0: selected: function( elem ) {
gyorgy@0: // Accessing this property makes selected-by-default
gyorgy@0: // options in Safari work properly
gyorgy@0: if ( elem.parentNode ) {
gyorgy@0: elem.parentNode.selectedIndex;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return elem.selected === true;
gyorgy@0: },
gyorgy@0:
gyorgy@0: parent: function( elem ) {
gyorgy@0: return !!elem.firstChild;
gyorgy@0: },
gyorgy@0:
gyorgy@0: empty: function( elem ) {
gyorgy@0: return !elem.firstChild;
gyorgy@0: },
gyorgy@0:
gyorgy@0: has: function( elem, i, match ) {
gyorgy@0: return !!Sizzle( match[3], elem ).length;
gyorgy@0: },
gyorgy@0:
gyorgy@0: header: function( elem ) {
gyorgy@0: return (/h\d/i).test( elem.nodeName );
gyorgy@0: },
gyorgy@0:
gyorgy@0: text: function( elem ) {
gyorgy@0: var attr = elem.getAttribute( "type" ), type = elem.type;
gyorgy@0: // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
gyorgy@0: // use getAttribute instead to test this case
gyorgy@0: return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
gyorgy@0: },
gyorgy@0:
gyorgy@0: radio: function( elem ) {
gyorgy@0: return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: checkbox: function( elem ) {
gyorgy@0: return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: file: function( elem ) {
gyorgy@0: return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: password: function( elem ) {
gyorgy@0: return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: submit: function( elem ) {
gyorgy@0: var name = elem.nodeName.toLowerCase();
gyorgy@0: return (name === "input" || name === "button") && "submit" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: image: function( elem ) {
gyorgy@0: return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: reset: function( elem ) {
gyorgy@0: var name = elem.nodeName.toLowerCase();
gyorgy@0: return (name === "input" || name === "button") && "reset" === elem.type;
gyorgy@0: },
gyorgy@0:
gyorgy@0: button: function( elem ) {
gyorgy@0: var name = elem.nodeName.toLowerCase();
gyorgy@0: return name === "input" && "button" === elem.type || name === "button";
gyorgy@0: },
gyorgy@0:
gyorgy@0: input: function( elem ) {
gyorgy@0: return (/input|select|textarea|button/i).test( elem.nodeName );
gyorgy@0: },
gyorgy@0:
gyorgy@0: focus: function( elem ) {
gyorgy@0: return elem === elem.ownerDocument.activeElement;
gyorgy@0: }
gyorgy@0: },
gyorgy@0: setFilters: {
gyorgy@0: first: function( elem, i ) {
gyorgy@0: return i === 0;
gyorgy@0: },
gyorgy@0:
gyorgy@0: last: function( elem, i, match, array ) {
gyorgy@0: return i === array.length - 1;
gyorgy@0: },
gyorgy@0:
gyorgy@0: even: function( elem, i ) {
gyorgy@0: return i % 2 === 0;
gyorgy@0: },
gyorgy@0:
gyorgy@0: odd: function( elem, i ) {
gyorgy@0: return i % 2 === 1;
gyorgy@0: },
gyorgy@0:
gyorgy@0: lt: function( elem, i, match ) {
gyorgy@0: return i < match[3] - 0;
gyorgy@0: },
gyorgy@0:
gyorgy@0: gt: function( elem, i, match ) {
gyorgy@0: return i > match[3] - 0;
gyorgy@0: },
gyorgy@0:
gyorgy@0: nth: function( elem, i, match ) {
gyorgy@0: return match[3] - 0 === i;
gyorgy@0: },
gyorgy@0:
gyorgy@0: eq: function( elem, i, match ) {
gyorgy@0: return match[3] - 0 === i;
gyorgy@0: }
gyorgy@0: },
gyorgy@0: filter: {
gyorgy@0: PSEUDO: function( elem, match, i, array ) {
gyorgy@0: var name = match[1],
gyorgy@0: filter = Expr.filters[ name ];
gyorgy@0:
gyorgy@0: if ( filter ) {
gyorgy@0: return filter( elem, i, match, array );
gyorgy@0:
gyorgy@0: } else if ( name === "contains" ) {
gyorgy@0: return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
gyorgy@0:
gyorgy@0: } else if ( name === "not" ) {
gyorgy@0: var not = match[3];
gyorgy@0:
gyorgy@0: for ( var j = 0, l = not.length; j < l; j++ ) {
gyorgy@0: if ( not[j] === elem ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return true;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: Sizzle.error( name );
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: CHILD: function( elem, match ) {
gyorgy@0: var type = match[1],
gyorgy@0: node = elem;
gyorgy@0:
gyorgy@0: switch ( type ) {
gyorgy@0: case "only":
gyorgy@0: case "first":
gyorgy@0: while ( (node = node.previousSibling) ) {
gyorgy@0: if ( node.nodeType === 1 ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( type === "first" ) {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: node = elem;
gyorgy@0:
gyorgy@0: case "last":
gyorgy@0: while ( (node = node.nextSibling) ) {
gyorgy@0: if ( node.nodeType === 1 ) {
gyorgy@0: return false;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return true;
gyorgy@0:
gyorgy@0: case "nth":
gyorgy@0: var first = match[2],
gyorgy@0: last = match[3];
gyorgy@0:
gyorgy@0: if ( first === 1 && last === 0 ) {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var doneName = match[0],
gyorgy@0: parent = elem.parentNode;
gyorgy@0:
gyorgy@0: if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
gyorgy@0: var count = 0;
gyorgy@0:
gyorgy@0: for ( node = parent.firstChild; node; node = node.nextSibling ) {
gyorgy@0: if ( node.nodeType === 1 ) {
gyorgy@0: node.nodeIndex = ++count;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: parent.sizcache = doneName;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var diff = elem.nodeIndex - last;
gyorgy@0:
gyorgy@0: if ( first === 0 ) {
gyorgy@0: return diff === 0;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return ( diff % first === 0 && diff / first >= 0 );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: },
gyorgy@0:
gyorgy@0: ID: function( elem, match ) {
gyorgy@0: return elem.nodeType === 1 && elem.getAttribute("id") === match;
gyorgy@0: },
gyorgy@0:
gyorgy@0: TAG: function( elem, match ) {
gyorgy@0: return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
gyorgy@0: },
gyorgy@0:
gyorgy@0: CLASS: function( elem, match ) {
gyorgy@0: return (" " + (elem.className || elem.getAttribute("class")) + " ")
gyorgy@0: .indexOf( match ) > -1;
gyorgy@0: },
gyorgy@0:
gyorgy@0: ATTR: function( elem, match ) {
gyorgy@0: var name = match[1],
gyorgy@0: result = Expr.attrHandle[ name ] ?
gyorgy@0: Expr.attrHandle[ name ]( elem ) :
gyorgy@0: elem[ name ] != null ?
gyorgy@0: elem[ name ] :
gyorgy@0: elem.getAttribute( name ),
gyorgy@0: value = result + "",
gyorgy@0: type = match[2],
gyorgy@0: check = match[4];
gyorgy@0:
gyorgy@0: return result == null ?
gyorgy@0: type === "!=" :
gyorgy@0: type === "=" ?
gyorgy@0: value === check :
gyorgy@0: type === "*=" ?
gyorgy@0: value.indexOf(check) >= 0 :
gyorgy@0: type === "~=" ?
gyorgy@0: (" " + value + " ").indexOf(check) >= 0 :
gyorgy@0: !check ?
gyorgy@0: value && result !== false :
gyorgy@0: type === "!=" ?
gyorgy@0: value !== check :
gyorgy@0: type === "^=" ?
gyorgy@0: value.indexOf(check) === 0 :
gyorgy@0: type === "$=" ?
gyorgy@0: value.substr(value.length - check.length) === check :
gyorgy@0: type === "|=" ?
gyorgy@0: value === check || value.substr(0, check.length + 1) === check + "-" :
gyorgy@0: false;
gyorgy@0: },
gyorgy@0:
gyorgy@0: POS: function( elem, match, i, array ) {
gyorgy@0: var name = match[2],
gyorgy@0: filter = Expr.setFilters[ name ];
gyorgy@0:
gyorgy@0: if ( filter ) {
gyorgy@0: return filter( elem, i, match, array );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: var origPOS = Expr.match.POS,
gyorgy@0: fescape = function(all, num){
gyorgy@0: return "\\" + (num - 0 + 1);
gyorgy@0: };
gyorgy@0:
gyorgy@0: for ( var type in Expr.match ) {
gyorgy@0: Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
gyorgy@0: Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
gyorgy@0: }
gyorgy@0:
gyorgy@0: var makeArray = function( array, results ) {
gyorgy@0: array = Array.prototype.slice.call( array, 0 );
gyorgy@0:
gyorgy@0: if ( results ) {
gyorgy@0: results.push.apply( results, array );
gyorgy@0: return results;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return array;
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Perform a simple check to determine if the browser is capable of
gyorgy@0: // converting a NodeList to an array using builtin methods.
gyorgy@0: // Also verifies that the returned array holds DOM nodes
gyorgy@0: // (which is not the case in the Blackberry browser)
gyorgy@0: try {
gyorgy@0: Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
gyorgy@0:
gyorgy@0: // Provide a fallback method if it does not work
gyorgy@0: } catch( e ) {
gyorgy@0: makeArray = function( array, results ) {
gyorgy@0: var i = 0,
gyorgy@0: ret = results || [];
gyorgy@0:
gyorgy@0: if ( toString.call(array) === "[object Array]" ) {
gyorgy@0: Array.prototype.push.apply( ret, array );
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: if ( typeof array.length === "number" ) {
gyorgy@0: for ( var l = array.length; i < l; i++ ) {
gyorgy@0: ret.push( array[i] );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: for ( ; array[i]; i++ ) {
gyorgy@0: ret.push( array[i] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret;
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: var sortOrder, siblingCheck;
gyorgy@0:
gyorgy@0: if ( document.documentElement.compareDocumentPosition ) {
gyorgy@0: sortOrder = function( a, b ) {
gyorgy@0: if ( a === b ) {
gyorgy@0: hasDuplicate = true;
gyorgy@0: return 0;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
gyorgy@0: return a.compareDocumentPosition ? -1 : 1;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return a.compareDocumentPosition(b) & 4 ? -1 : 1;
gyorgy@0: };
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: sortOrder = function( a, b ) {
gyorgy@0: // The nodes are identical, we can exit early
gyorgy@0: if ( a === b ) {
gyorgy@0: hasDuplicate = true;
gyorgy@0: return 0;
gyorgy@0:
gyorgy@0: // Fallback to using sourceIndex (in IE) if it's available on both nodes
gyorgy@0: } else if ( a.sourceIndex && b.sourceIndex ) {
gyorgy@0: return a.sourceIndex - b.sourceIndex;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var al, bl,
gyorgy@0: ap = [],
gyorgy@0: bp = [],
gyorgy@0: aup = a.parentNode,
gyorgy@0: bup = b.parentNode,
gyorgy@0: cur = aup;
gyorgy@0:
gyorgy@0: // If the nodes are siblings (or identical) we can do a quick check
gyorgy@0: if ( aup === bup ) {
gyorgy@0: return siblingCheck( a, b );
gyorgy@0:
gyorgy@0: // If no parents were found then the nodes are disconnected
gyorgy@0: } else if ( !aup ) {
gyorgy@0: return -1;
gyorgy@0:
gyorgy@0: } else if ( !bup ) {
gyorgy@0: return 1;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Otherwise they're somewhere else in the tree so we need
gyorgy@0: // to build up a full list of the parentNodes for comparison
gyorgy@0: while ( cur ) {
gyorgy@0: ap.unshift( cur );
gyorgy@0: cur = cur.parentNode;
gyorgy@0: }
gyorgy@0:
gyorgy@0: cur = bup;
gyorgy@0:
gyorgy@0: while ( cur ) {
gyorgy@0: bp.unshift( cur );
gyorgy@0: cur = cur.parentNode;
gyorgy@0: }
gyorgy@0:
gyorgy@0: al = ap.length;
gyorgy@0: bl = bp.length;
gyorgy@0:
gyorgy@0: // Start walking down the tree looking for a discrepancy
gyorgy@0: for ( var i = 0; i < al && i < bl; i++ ) {
gyorgy@0: if ( ap[i] !== bp[i] ) {
gyorgy@0: return siblingCheck( ap[i], bp[i] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: // We ended someplace up the tree so do a sibling check
gyorgy@0: return i === al ?
gyorgy@0: siblingCheck( a, bp[i], -1 ) :
gyorgy@0: siblingCheck( ap[i], b, 1 );
gyorgy@0: };
gyorgy@0:
gyorgy@0: siblingCheck = function( a, b, ret ) {
gyorgy@0: if ( a === b ) {
gyorgy@0: return ret;
gyorgy@0: }
gyorgy@0:
gyorgy@0: var cur = a.nextSibling;
gyorgy@0:
gyorgy@0: while ( cur ) {
gyorgy@0: if ( cur === b ) {
gyorgy@0: return -1;
gyorgy@0: }
gyorgy@0:
gyorgy@0: cur = cur.nextSibling;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return 1;
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Utility function for retreiving the text value of an array of DOM nodes
gyorgy@0: Sizzle.getText = function( elems ) {
gyorgy@0: var ret = "", elem;
gyorgy@0:
gyorgy@0: for ( var i = 0; elems[i]; i++ ) {
gyorgy@0: elem = elems[i];
gyorgy@0:
gyorgy@0: // Get the text from text nodes and CDATA nodes
gyorgy@0: if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
gyorgy@0: ret += elem.nodeValue;
gyorgy@0:
gyorgy@0: // Traverse everything else, except comment nodes
gyorgy@0: } else if ( elem.nodeType !== 8 ) {
gyorgy@0: ret += Sizzle.getText( elem.childNodes );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret;
gyorgy@0: };
gyorgy@0:
gyorgy@0: // Check to see if the browser returns elements by name when
gyorgy@0: // querying by getElementById (and provide a workaround)
gyorgy@0: (function(){
gyorgy@0: // We're going to inject a fake input element with a specified name
gyorgy@0: var form = document.createElement("div"),
gyorgy@0: id = "script" + (new Date()).getTime(),
gyorgy@0: root = document.documentElement;
gyorgy@0:
gyorgy@0: form.innerHTML = "";
gyorgy@0:
gyorgy@0: // Inject it into the root element, check its status, and remove it quickly
gyorgy@0: root.insertBefore( form, root.firstChild );
gyorgy@0:
gyorgy@0: // The workaround has to do additional checks after a getElementById
gyorgy@0: // Which slows things down for other browsers (hence the branching)
gyorgy@0: if ( document.getElementById( id ) ) {
gyorgy@0: Expr.find.ID = function( match, context, isXML ) {
gyorgy@0: if ( typeof context.getElementById !== "undefined" && !isXML ) {
gyorgy@0: var m = context.getElementById(match[1]);
gyorgy@0:
gyorgy@0: return m ?
gyorgy@0: m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
gyorgy@0: [m] :
gyorgy@0: undefined :
gyorgy@0: [];
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: Expr.filter.ID = function( elem, match ) {
gyorgy@0: var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
gyorgy@0:
gyorgy@0: return elem.nodeType === 1 && node && node.nodeValue === match;
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: root.removeChild( form );
gyorgy@0:
gyorgy@0: // release memory in IE
gyorgy@0: root = form = null;
gyorgy@0: })();
gyorgy@0:
gyorgy@0: (function(){
gyorgy@0: // Check to see if the browser returns only elements
gyorgy@0: // when doing getElementsByTagName("*")
gyorgy@0:
gyorgy@0: // Create a fake element
gyorgy@0: var div = document.createElement("div");
gyorgy@0: div.appendChild( document.createComment("") );
gyorgy@0:
gyorgy@0: // Make sure no comments are found
gyorgy@0: if ( div.getElementsByTagName("*").length > 0 ) {
gyorgy@0: Expr.find.TAG = function( match, context ) {
gyorgy@0: var results = context.getElementsByTagName( match[1] );
gyorgy@0:
gyorgy@0: // Filter out possible comments
gyorgy@0: if ( match[1] === "*" ) {
gyorgy@0: var tmp = [];
gyorgy@0:
gyorgy@0: for ( var i = 0; results[i]; i++ ) {
gyorgy@0: if ( results[i].nodeType === 1 ) {
gyorgy@0: tmp.push( results[i] );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: results = tmp;
gyorgy@0: }
gyorgy@0:
gyorgy@0: return results;
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Check to see if an attribute returns normalized href attributes
gyorgy@0: div.innerHTML = "";
gyorgy@0:
gyorgy@0: if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
gyorgy@0: div.firstChild.getAttribute("href") !== "#" ) {
gyorgy@0:
gyorgy@0: Expr.attrHandle.href = function( elem ) {
gyorgy@0: return elem.getAttribute( "href", 2 );
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: // release memory in IE
gyorgy@0: div = null;
gyorgy@0: })();
gyorgy@0:
gyorgy@0: if ( document.querySelectorAll ) {
gyorgy@0: (function(){
gyorgy@0: var oldSizzle = Sizzle,
gyorgy@0: div = document.createElement("div"),
gyorgy@0: id = "__sizzle__";
gyorgy@0:
gyorgy@0: div.innerHTML = "";
gyorgy@0:
gyorgy@0: // Safari can't handle uppercase or unicode characters when
gyorgy@0: // in quirks mode.
gyorgy@0: if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: Sizzle = function( query, context, extra, seed ) {
gyorgy@0: context = context || document;
gyorgy@0:
gyorgy@0: // Only use querySelectorAll on non-XML documents
gyorgy@0: // (ID selectors don't work in non-HTML documents)
gyorgy@0: if ( !seed && !Sizzle.isXML(context) ) {
gyorgy@0: // See if we find a selector to speed up
gyorgy@0: var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
gyorgy@0:
gyorgy@0: if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
gyorgy@0: // Speed-up: Sizzle("TAG")
gyorgy@0: if ( match[1] ) {
gyorgy@0: return makeArray( context.getElementsByTagName( query ), extra );
gyorgy@0:
gyorgy@0: // Speed-up: Sizzle(".CLASS")
gyorgy@0: } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
gyorgy@0: return makeArray( context.getElementsByClassName( match[2] ), extra );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( context.nodeType === 9 ) {
gyorgy@0: // Speed-up: Sizzle("body")
gyorgy@0: // The body element only exists once, optimize finding it
gyorgy@0: if ( query === "body" && context.body ) {
gyorgy@0: return makeArray( [ context.body ], extra );
gyorgy@0:
gyorgy@0: // Speed-up: Sizzle("#ID")
gyorgy@0: } else if ( match && match[3] ) {
gyorgy@0: var elem = context.getElementById( match[3] );
gyorgy@0:
gyorgy@0: // Check parentNode to catch when Blackberry 4.6 returns
gyorgy@0: // nodes that are no longer in the document #6963
gyorgy@0: if ( elem && elem.parentNode ) {
gyorgy@0: // Handle the case where IE and Opera return items
gyorgy@0: // by name instead of ID
gyorgy@0: if ( elem.id === match[3] ) {
gyorgy@0: return makeArray( [ elem ], extra );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: return makeArray( [], extra );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: try {
gyorgy@0: return makeArray( context.querySelectorAll(query), extra );
gyorgy@0: } catch(qsaError) {}
gyorgy@0:
gyorgy@0: // qSA works strangely on Element-rooted queries
gyorgy@0: // We can work around this by specifying an extra ID on the root
gyorgy@0: // and working up from there (Thanks to Andrew Dupont for the technique)
gyorgy@0: // IE 8 doesn't work on object elements
gyorgy@0: } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
gyorgy@0: var oldContext = context,
gyorgy@0: old = context.getAttribute( "id" ),
gyorgy@0: nid = old || id,
gyorgy@0: hasParent = context.parentNode,
gyorgy@0: relativeHierarchySelector = /^\s*[+~]/.test( query );
gyorgy@0:
gyorgy@0: if ( !old ) {
gyorgy@0: context.setAttribute( "id", nid );
gyorgy@0: } else {
gyorgy@0: nid = nid.replace( /'/g, "\\$&" );
gyorgy@0: }
gyorgy@0: if ( relativeHierarchySelector && hasParent ) {
gyorgy@0: context = context.parentNode;
gyorgy@0: }
gyorgy@0:
gyorgy@0: try {
gyorgy@0: if ( !relativeHierarchySelector || hasParent ) {
gyorgy@0: return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
gyorgy@0: }
gyorgy@0:
gyorgy@0: } catch(pseudoError) {
gyorgy@0: } finally {
gyorgy@0: if ( !old ) {
gyorgy@0: oldContext.removeAttribute( "id" );
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return oldSizzle(query, context, extra, seed);
gyorgy@0: };
gyorgy@0:
gyorgy@0: for ( var prop in oldSizzle ) {
gyorgy@0: Sizzle[ prop ] = oldSizzle[ prop ];
gyorgy@0: }
gyorgy@0:
gyorgy@0: // release memory in IE
gyorgy@0: div = null;
gyorgy@0: })();
gyorgy@0: }
gyorgy@0:
gyorgy@0: (function(){
gyorgy@0: var html = document.documentElement,
gyorgy@0: matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
gyorgy@0:
gyorgy@0: if ( matches ) {
gyorgy@0: // Check to see if it's possible to do matchesSelector
gyorgy@0: // on a disconnected node (IE 9 fails this)
gyorgy@0: var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
gyorgy@0: pseudoWorks = false;
gyorgy@0:
gyorgy@0: try {
gyorgy@0: // This should fail with an exception
gyorgy@0: // Gecko does not error, returns false instead
gyorgy@0: matches.call( document.documentElement, "[test!='']:sizzle" );
gyorgy@0:
gyorgy@0: } catch( pseudoError ) {
gyorgy@0: pseudoWorks = true;
gyorgy@0: }
gyorgy@0:
gyorgy@0: Sizzle.matchesSelector = function( node, expr ) {
gyorgy@0: // Make sure that attribute selectors are quoted
gyorgy@0: expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
gyorgy@0:
gyorgy@0: if ( !Sizzle.isXML( node ) ) {
gyorgy@0: try {
gyorgy@0: if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
gyorgy@0: var ret = matches.call( node, expr );
gyorgy@0:
gyorgy@0: // IE 9's matchesSelector returns false on disconnected nodes
gyorgy@0: if ( ret || !disconnectedMatch ||
gyorgy@0: // As well, disconnected nodes are said to be in a document
gyorgy@0: // fragment in IE 9, so check for that
gyorgy@0: node.document && node.document.nodeType !== 11 ) {
gyorgy@0: return ret;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: } catch(e) {}
gyorgy@0: }
gyorgy@0:
gyorgy@0: return Sizzle(expr, null, null, [node]).length > 0;
gyorgy@0: };
gyorgy@0: }
gyorgy@0: })();
gyorgy@0:
gyorgy@0: (function(){
gyorgy@0: var div = document.createElement("div");
gyorgy@0:
gyorgy@0: div.innerHTML = "";
gyorgy@0:
gyorgy@0: // Opera can't find a second classname (in 9.6)
gyorgy@0: // Also, make sure that getElementsByClassName actually exists
gyorgy@0: if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // Safari caches class attributes, doesn't catch changes (in 3.2)
gyorgy@0: div.lastChild.className = "e";
gyorgy@0:
gyorgy@0: if ( div.getElementsByClassName("e").length === 1 ) {
gyorgy@0: return;
gyorgy@0: }
gyorgy@0:
gyorgy@0: Expr.order.splice(1, 0, "CLASS");
gyorgy@0: Expr.find.CLASS = function( match, context, isXML ) {
gyorgy@0: if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
gyorgy@0: return context.getElementsByClassName(match[1]);
gyorgy@0: }
gyorgy@0: };
gyorgy@0:
gyorgy@0: // release memory in IE
gyorgy@0: div = null;
gyorgy@0: })();
gyorgy@0:
gyorgy@0: function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
gyorgy@0: for ( var i = 0, l = checkSet.length; i < l; i++ ) {
gyorgy@0: var elem = checkSet[i];
gyorgy@0:
gyorgy@0: if ( elem ) {
gyorgy@0: var match = false;
gyorgy@0:
gyorgy@0: elem = elem[dir];
gyorgy@0:
gyorgy@0: while ( elem ) {
gyorgy@0: if ( elem.sizcache === doneName ) {
gyorgy@0: match = checkSet[elem.sizset];
gyorgy@0: break;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( elem.nodeType === 1 && !isXML ){
gyorgy@0: elem.sizcache = doneName;
gyorgy@0: elem.sizset = i;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( elem.nodeName.toLowerCase() === cur ) {
gyorgy@0: match = elem;
gyorgy@0: break;
gyorgy@0: }
gyorgy@0:
gyorgy@0: elem = elem[dir];
gyorgy@0: }
gyorgy@0:
gyorgy@0: checkSet[i] = match;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
gyorgy@0: for ( var i = 0, l = checkSet.length; i < l; i++ ) {
gyorgy@0: var elem = checkSet[i];
gyorgy@0:
gyorgy@0: if ( elem ) {
gyorgy@0: var match = false;
gyorgy@0:
gyorgy@0: elem = elem[dir];
gyorgy@0:
gyorgy@0: while ( elem ) {
gyorgy@0: if ( elem.sizcache === doneName ) {
gyorgy@0: match = checkSet[elem.sizset];
gyorgy@0: break;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( elem.nodeType === 1 ) {
gyorgy@0: if ( !isXML ) {
gyorgy@0: elem.sizcache = doneName;
gyorgy@0: elem.sizset = i;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( typeof cur !== "string" ) {
gyorgy@0: if ( elem === cur ) {
gyorgy@0: match = true;
gyorgy@0: break;
gyorgy@0: }
gyorgy@0:
gyorgy@0: } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
gyorgy@0: match = elem;
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: elem = elem[dir];
gyorgy@0: }
gyorgy@0:
gyorgy@0: checkSet[i] = match;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( document.documentElement.contains ) {
gyorgy@0: Sizzle.contains = function( a, b ) {
gyorgy@0: return a !== b && (a.contains ? a.contains(b) : true);
gyorgy@0: };
gyorgy@0:
gyorgy@0: } else if ( document.documentElement.compareDocumentPosition ) {
gyorgy@0: Sizzle.contains = function( a, b ) {
gyorgy@0: return !!(a.compareDocumentPosition(b) & 16);
gyorgy@0: };
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: Sizzle.contains = function() {
gyorgy@0: return false;
gyorgy@0: };
gyorgy@0: }
gyorgy@0:
gyorgy@0: Sizzle.isXML = function( elem ) {
gyorgy@0: // documentElement is verified for cases where it doesn't yet exist
gyorgy@0: // (such as loading iframes in IE - #4833)
gyorgy@0: var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
gyorgy@0:
gyorgy@0: return documentElement ? documentElement.nodeName !== "HTML" : false;
gyorgy@0: };
gyorgy@0:
gyorgy@0: var posProcess = function( selector, context ) {
gyorgy@0: var match,
gyorgy@0: tmpSet = [],
gyorgy@0: later = "",
gyorgy@0: root = context.nodeType ? [context] : context;
gyorgy@0:
gyorgy@0: // Position selectors must be done after the filter
gyorgy@0: // And so must :not(positional) so we move all PSEUDOs to the end
gyorgy@0: while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
gyorgy@0: later += match[0];
gyorgy@0: selector = selector.replace( Expr.match.PSEUDO, "" );
gyorgy@0: }
gyorgy@0:
gyorgy@0: selector = Expr.relative[selector] ? selector + "*" : selector;
gyorgy@0:
gyorgy@0: for ( var i = 0, l = root.length; i < l; i++ ) {
gyorgy@0: Sizzle( selector, root[i], tmpSet );
gyorgy@0: }
gyorgy@0:
gyorgy@0: return Sizzle.filter( later, tmpSet );
gyorgy@0: };
gyorgy@0:
gyorgy@0: // EXPOSE
gyorgy@0: jQuery.find = Sizzle;
gyorgy@0: jQuery.expr = Sizzle.selectors;
gyorgy@0: jQuery.expr[":"] = jQuery.expr.filters;
gyorgy@0: jQuery.unique = Sizzle.uniqueSort;
gyorgy@0: jQuery.text = Sizzle.getText;
gyorgy@0: jQuery.isXMLDoc = Sizzle.isXML;
gyorgy@0: jQuery.contains = Sizzle.contains;
gyorgy@0:
gyorgy@0:
gyorgy@0: })();
gyorgy@0:
gyorgy@0:
gyorgy@0: var runtil = /Until$/,
gyorgy@0: rparentsprev = /^(?:parents|prevUntil|prevAll)/,
gyorgy@0: // Note: This RegExp should be improved, or likely pulled from Sizzle
gyorgy@0: rmultiselector = /,/,
gyorgy@0: isSimple = /^.[^:#\[\.,]*$/,
gyorgy@0: slice = Array.prototype.slice,
gyorgy@0: POS = jQuery.expr.match.POS,
gyorgy@0: // methods guaranteed to produce a unique set when starting from a unique set
gyorgy@0: guaranteedUnique = {
gyorgy@0: children: true,
gyorgy@0: contents: true,
gyorgy@0: next: true,
gyorgy@0: prev: true
gyorgy@0: };
gyorgy@0:
gyorgy@0: jQuery.fn.extend({
gyorgy@0: find: function( selector ) {
gyorgy@0: var self = this,
gyorgy@0: i, l;
gyorgy@0:
gyorgy@0: if ( typeof selector !== "string" ) {
gyorgy@0: return jQuery( selector ).filter(function() {
gyorgy@0: for ( i = 0, l = self.length; i < l; i++ ) {
gyorgy@0: if ( jQuery.contains( self[ i ], this ) ) {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0: var ret = this.pushStack( "", "find", selector ),
gyorgy@0: length, n, r;
gyorgy@0:
gyorgy@0: for ( i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: length = ret.length;
gyorgy@0: jQuery.find( selector, this[i], ret );
gyorgy@0:
gyorgy@0: if ( i > 0 ) {
gyorgy@0: // Make sure that the results are unique
gyorgy@0: for ( n = length; n < ret.length; n++ ) {
gyorgy@0: for ( r = 0; r < length; r++ ) {
gyorgy@0: if ( ret[r] === ret[n] ) {
gyorgy@0: ret.splice(n--, 1);
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret;
gyorgy@0: },
gyorgy@0:
gyorgy@0: has: function( target ) {
gyorgy@0: var targets = jQuery( target );
gyorgy@0: return this.filter(function() {
gyorgy@0: for ( var i = 0, l = targets.length; i < l; i++ ) {
gyorgy@0: if ( jQuery.contains( this, targets[i] ) ) {
gyorgy@0: return true;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: });
gyorgy@0: },
gyorgy@0:
gyorgy@0: not: function( selector ) {
gyorgy@0: return this.pushStack( winnow(this, selector, false), "not", selector);
gyorgy@0: },
gyorgy@0:
gyorgy@0: filter: function( selector ) {
gyorgy@0: return this.pushStack( winnow(this, selector, true), "filter", selector );
gyorgy@0: },
gyorgy@0:
gyorgy@0: is: function( selector ) {
gyorgy@0: return !!selector && ( typeof selector === "string" ?
gyorgy@0: jQuery.filter( selector, this ).length > 0 :
gyorgy@0: this.filter( selector ).length > 0 );
gyorgy@0: },
gyorgy@0:
gyorgy@0: closest: function( selectors, context ) {
gyorgy@0: var ret = [], i, l, cur = this[0];
gyorgy@0:
gyorgy@0: // Array
gyorgy@0: if ( jQuery.isArray( selectors ) ) {
gyorgy@0: var match, selector,
gyorgy@0: matches = {},
gyorgy@0: level = 1;
gyorgy@0:
gyorgy@0: if ( cur && selectors.length ) {
gyorgy@0: for ( i = 0, l = selectors.length; i < l; i++ ) {
gyorgy@0: selector = selectors[i];
gyorgy@0:
gyorgy@0: if ( !matches[ selector ] ) {
gyorgy@0: matches[ selector ] = POS.test( selector ) ?
gyorgy@0: jQuery( selector, context || this.context ) :
gyorgy@0: selector;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: while ( cur && cur.ownerDocument && cur !== context ) {
gyorgy@0: for ( selector in matches ) {
gyorgy@0: match = matches[ selector ];
gyorgy@0:
gyorgy@0: if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
gyorgy@0: ret.push({ selector: selector, elem: cur, level: level });
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: cur = cur.parentNode;
gyorgy@0: level++;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return ret;
gyorgy@0: }
gyorgy@0:
gyorgy@0: // String
gyorgy@0: var pos = POS.test( selectors ) || typeof selectors !== "string" ?
gyorgy@0: jQuery( selectors, context || this.context ) :
gyorgy@0: 0;
gyorgy@0:
gyorgy@0: for ( i = 0, l = this.length; i < l; i++ ) {
gyorgy@0: cur = this[i];
gyorgy@0:
gyorgy@0: while ( cur ) {
gyorgy@0: if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
gyorgy@0: ret.push( cur );
gyorgy@0: break;
gyorgy@0:
gyorgy@0: } else {
gyorgy@0: cur = cur.parentNode;
gyorgy@0: if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
gyorgy@0:
gyorgy@0: return this.pushStack( ret, "closest", selectors );
gyorgy@0: },
gyorgy@0:
gyorgy@0: // Determine the position of an element within
gyorgy@0: // the matched set of elements
gyorgy@0: index: function( elem ) {
gyorgy@0: if ( !elem || typeof elem === "string" ) {
gyorgy@0: return jQuery.inArray( this[0],
gyorgy@0: // If it receives a string, the selector is used
gyorgy@0: // If it receives nothing, the siblings are used
gyorgy@0: elem ? jQuery( elem ) : this.parent().children() );
gyorgy@0: }
gyorgy@0: // Locate the position of the desired element
gyorgy@0: return jQuery.inArray(
gyorgy@0: // If it receives a jQuery object, the first element is used
gyorgy@0: elem.jquery ? elem[0] : elem, this );
gyorgy@0: },
gyorgy@0:
gyorgy@0: add: function( selector, context ) {
gyorgy@0: var set = typeof selector === "string" ?
gyorgy@0: jQuery( selector, context ) :
gyorgy@0: jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
gyorgy@0: all = jQuery.merge( this.get(), set );
gyorgy@0:
gyorgy@0: return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
gyorgy@0: all :
gyorgy@0: jQuery.unique( all ) );
gyorgy@0: },
gyorgy@0:
gyorgy@0: andSelf: function() {
gyorgy@0: return this.add( this.prevObject );
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: // A painfully simple check to see if an element is disconnected
gyorgy@0: // from a document (should be improved, where feasible).
gyorgy@0: function isDisconnected( node ) {
gyorgy@0: return !node || !node.parentNode || node.parentNode.nodeType === 11;
gyorgy@0: }
gyorgy@0:
gyorgy@0: jQuery.each({
gyorgy@0: parent: function( elem ) {
gyorgy@0: var parent = elem.parentNode;
gyorgy@0: return parent && parent.nodeType !== 11 ? parent : null;
gyorgy@0: },
gyorgy@0: parents: function( elem ) {
gyorgy@0: return jQuery.dir( elem, "parentNode" );
gyorgy@0: },
gyorgy@0: parentsUntil: function( elem, i, until ) {
gyorgy@0: return jQuery.dir( elem, "parentNode", until );
gyorgy@0: },
gyorgy@0: next: function( elem ) {
gyorgy@0: return jQuery.nth( elem, 2, "nextSibling" );
gyorgy@0: },
gyorgy@0: prev: function( elem ) {
gyorgy@0: return jQuery.nth( elem, 2, "previousSibling" );
gyorgy@0: },
gyorgy@0: nextAll: function( elem ) {
gyorgy@0: return jQuery.dir( elem, "nextSibling" );
gyorgy@0: },
gyorgy@0: prevAll: function( elem ) {
gyorgy@0: return jQuery.dir( elem, "previousSibling" );
gyorgy@0: },
gyorgy@0: nextUntil: function( elem, i, until ) {
gyorgy@0: return jQuery.dir( elem, "nextSibling", until );
gyorgy@0: },
gyorgy@0: prevUntil: function( elem, i, until ) {
gyorgy@0: return jQuery.dir( elem, "previousSibling", until );
gyorgy@0: },
gyorgy@0: siblings: function( elem ) {
gyorgy@0: return jQuery.sibling( elem.parentNode.firstChild, elem );
gyorgy@0: },
gyorgy@0: children: function( elem ) {
gyorgy@0: return jQuery.sibling( elem.firstChild );
gyorgy@0: },
gyorgy@0: contents: function( elem ) {
gyorgy@0: return jQuery.nodeName( elem, "iframe" ) ?
gyorgy@0: elem.contentDocument || elem.contentWindow.document :
gyorgy@0: jQuery.makeArray( elem.childNodes );
gyorgy@0: }
gyorgy@0: }, function( name, fn ) {
gyorgy@0: jQuery.fn[ name ] = function( until, selector ) {
gyorgy@0: var ret = jQuery.map( this, fn, until ),
gyorgy@0: // The variable 'args' was introduced in
gyorgy@0: // https://github.com/jquery/jquery/commit/52a0238
gyorgy@0: // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
gyorgy@0: // http://code.google.com/p/v8/issues/detail?id=1050
gyorgy@0: args = slice.call(arguments);
gyorgy@0:
gyorgy@0: if ( !runtil.test( name ) ) {
gyorgy@0: selector = until;
gyorgy@0: }
gyorgy@0:
gyorgy@0: if ( selector && typeof selector === "string" ) {
gyorgy@0: ret = jQuery.filter( selector, ret );
gyorgy@0: }
gyorgy@0:
gyorgy@0: ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
gyorgy@0:
gyorgy@0: if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
gyorgy@0: ret = ret.reverse();
gyorgy@0: }
gyorgy@0:
gyorgy@0: return this.pushStack( ret, name, args.join(",") );
gyorgy@0: };
gyorgy@0: });
gyorgy@0:
gyorgy@0: jQuery.extend({
gyorgy@0: filter: function( expr, elems, not ) {
gyorgy@0: if ( not ) {
gyorgy@0: expr = ":not(" + expr + ")";
gyorgy@0: }
gyorgy@0:
gyorgy@0: return elems.length === 1 ?
gyorgy@0: jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
gyorgy@0: jQuery.find.matches(expr, elems);
gyorgy@0: },
gyorgy@0:
gyorgy@0: dir: function( elem, dir, until ) {
gyorgy@0: var matched = [],
gyorgy@0: cur = elem[ dir ];
gyorgy@0:
gyorgy@0: while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
gyorgy@0: if ( cur.nodeType === 1 ) {
gyorgy@0: matched.push( cur );
gyorgy@0: }
gyorgy@0: cur = cur[dir];
gyorgy@0: }
gyorgy@0: return matched;
gyorgy@0: },
gyorgy@0:
gyorgy@0: nth: function( cur, result, dir, elem ) {
gyorgy@0: result = result || 1;
gyorgy@0: var num = 0;
gyorgy@0:
gyorgy@0: for ( ; cur; cur = cur[dir] ) {
gyorgy@0: if ( cur.nodeType === 1 && ++num === result ) {
gyorgy@0: break;
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return cur;
gyorgy@0: },
gyorgy@0:
gyorgy@0: sibling: function( n, elem ) {
gyorgy@0: var r = [];
gyorgy@0:
gyorgy@0: for ( ; n; n = n.nextSibling ) {
gyorgy@0: if ( n.nodeType === 1 && n !== elem ) {
gyorgy@0: r.push( n );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return r;
gyorgy@0: }
gyorgy@0: });
gyorgy@0:
gyorgy@0: // Implement the identical functionality for filter and not
gyorgy@0: function winnow( elements, qualifier, keep ) {
gyorgy@0:
gyorgy@0: // Can't pass null or undefined to indexOf in Firefox 4
gyorgy@0: // Set to 0 to skip string check
gyorgy@0: qualifier = qualifier || 0;
gyorgy@0:
gyorgy@0: if ( jQuery.isFunction( qualifier ) ) {
gyorgy@0: return jQuery.grep(elements, function( elem, i ) {
gyorgy@0: var retVal = !!qualifier.call( elem, i, elem );
gyorgy@0: return retVal === keep;
gyorgy@0: });
gyorgy@0:
gyorgy@0: } else if ( qualifier.nodeType ) {
gyorgy@0: return jQuery.grep(elements, function( elem, i ) {
gyorgy@0: return (elem === qualifier) === keep;
gyorgy@0: });
gyorgy@0:
gyorgy@0: } else if ( typeof qualifier === "string" ) {
gyorgy@0: var filtered = jQuery.grep(elements, function( elem ) {
gyorgy@0: return elem.nodeType === 1;
gyorgy@0: });
gyorgy@0:
gyorgy@0: if ( isSimple.test( qualifier ) ) {
gyorgy@0: return jQuery.filter(qualifier, filtered, !keep);
gyorgy@0: } else {
gyorgy@0: qualifier = jQuery.filter( qualifier, filtered );
gyorgy@0: }
gyorgy@0: }
gyorgy@0:
gyorgy@0: return jQuery.grep(elements, function( elem, i ) {
gyorgy@0: return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
gyorgy@0: });
gyorgy@0: }
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0:
gyorgy@0: var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
gyorgy@0: rleadingWhitespace = /^\s+/,
gyorgy@0: rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
gyorgy@0: rtagName = /<([\w:]+)/,
gyorgy@0: rtbody = /", "" ],
gyorgy@0: legend: [ 1, "" ],
gyorgy@0: thead: [ 1, "