From 139393fe0978e79c427ad13f1a03a10431ef95e5 Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 4 Sep 2007 01:57:35 +0000 Subject: [PATCH] Removed all inline documentation. The current version of all documentation is stored online, on the wiki: http://docs.jquery.com/ --- src/ajax/ajax.js | 451 ----------- src/event/event.js | 579 +------------- src/fx/fx.js | 248 ------ src/jquery/jquery.js | 1544 -------------------------------------- src/selector/selector.js | 36 - 5 files changed, 10 insertions(+), 2848 deletions(-) diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js index 0b965e4a1..62785f355 100644 --- a/src/ajax/ajax.js +++ b/src/ajax/ajax.js @@ -1,49 +1,9 @@ jQuery.fn.extend({ - - /** - * Load HTML from a remote file and inject it into the DOM, only if it's - * been modified by the server. - * - * @example $("#feeds").loadIfModified("feeds.html"); - * @before
- * @result
45 feeds found.
- * - * @name loadIfModified - * @type jQuery - * @param String url The URL of the HTML file to load. - * @param Map params (optional) Key/value pairs that will be sent to the server. - * @param Function callback (optional) A function to be executed whenever the data is loaded (parameters: responseText, status and response itself). - * @cat Ajax - */ // DEPRECATED loadIfModified: function( url, params, callback ) { this.load( url, params, callback, 1 ); }, - /** - * Load HTML from a remote file and inject it into the DOM. - * - * Note: Avoid to use this to load scripts, instead use $.getScript. - * IE strips script tags when there aren't any other characters in front of it. - * - * @example $("#feeds").load("feeds.html"); - * @before
- * @result
45 feeds found.
- * - * @example $("#feeds").load("feeds.html", - * {limit: 25}, - * function() { alert("The last 25 entries in the feed have been loaded"); } - * ); - * @desc Same as above, but with an additional parameter - * and a callback that is executed when the data was loaded. - * - * @name load - * @type jQuery - * @param String url The URL of the HTML file to load. - * @param Object params (optional) A set of key/value pairs that will be sent as data to the server. - * @param Function callback (optional) A function to be executed whenever the data is loaded (parameters: responseText, status and response itself). - * @cat Ajax - */ load: function( url, params, callback, ifModified ) { if ( jQuery.isFunction( url ) ) return this.bind("load", url); @@ -107,25 +67,6 @@ jQuery.fn.extend({ return this; }, - /** - * Serializes a set of input elements into a string of data. - * This will serialize all given elements. - * - * A serialization similar to the form submit of a browser is - * provided by the [http://www.malsup.com/jquery/form/ Form Plugin]. - * It also takes multiple-selects - * into account, while this method recognizes only a single option. - * - * @example $("input[@type=text]").serialize(); - * @before - * - * @after name=John&location=Boston - * @desc Serialize a selection of input elements to a string - * - * @name serialize - * @type String - * @cat Ajax - */ serialize: function() { return jQuery.param( this ); }, @@ -138,106 +79,6 @@ jQuery.fn.extend({ }); // Attach a bunch of functions for handling common AJAX events - -/** - * Attach a function to be executed whenever an AJAX request begins - * and there is none already active. - * - * @example $("#loading").ajaxStart(function(){ - * $(this).show(); - * }); - * @desc Show a loading message whenever an AJAX request starts - * (and none is already active). - * - * @name ajaxStart - * @type jQuery - * @param Function callback The function to execute. - * @cat Ajax - */ - -/** - * Attach a function to be executed whenever all AJAX requests have ended. - * - * @example $("#loading").ajaxStop(function(){ - * $(this).hide(); - * }); - * @desc Hide a loading message after all the AJAX requests have stopped. - * - * @name ajaxStop - * @type jQuery - * @param Function callback The function to execute. - * @cat Ajax - */ - -/** - * Attach a function to be executed whenever an AJAX request completes. - * - * The XMLHttpRequest and settings used for that request are passed - * as arguments to the callback. - * - * @example $("#msg").ajaxComplete(function(request, settings){ - * $(this).append("
  • Request Complete.
  • "); - * }); - * @desc Show a message when an AJAX request completes. - * - * @name ajaxComplete - * @type jQuery - * @param Function callback The function to execute. - * @cat Ajax - */ - -/** - * Attach a function to be executed whenever an AJAX request completes - * successfully. - * - * The XMLHttpRequest and settings used for that request are passed - * as arguments to the callback. - * - * @example $("#msg").ajaxSuccess(function(request, settings){ - * $(this).append("
  • Successful Request!
  • "); - * }); - * @desc Show a message when an AJAX request completes successfully. - * - * @name ajaxSuccess - * @type jQuery - * @param Function callback The function to execute. - * @cat Ajax - */ - -/** - * Attach a function to be executed whenever an AJAX request fails. - * - * The XMLHttpRequest and settings used for that request are passed - * as arguments to the callback. A third argument, an exception object, - * is passed if an exception occured while processing the request. - * - * @example $("#msg").ajaxError(function(request, settings){ - * $(this).append("
  • Error requesting page " + settings.url + "
  • "); - * }); - * @desc Show a message when an AJAX request fails. - * - * @name ajaxError - * @type jQuery - * @param Function callback The function to execute. - * @cat Ajax - */ - -/** - * Attach a function to be executed before an AJAX request is sent. - * - * The XMLHttpRequest and settings used for that request are passed - * as arguments to the callback. - * - * @example $("#msg").ajaxSend(function(request, settings){ - * $(this).append("
  • Starting request at " + settings.url + "
  • "); - * }); - * @desc Show a message before an AJAX request is sent. - * - * @name ajaxSend - * @type jQuery - * @param Function callback The function to execute. - * @cat Ajax - */ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ jQuery.fn[o] = function(f){ return this.bind(o, f); @@ -247,39 +88,6 @@ jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".sp var jsc = (new Date).getTime(); jQuery.extend({ - - /** - * Load a remote page using an HTTP GET request. - * - * This is an easy way to send a simple GET request to a server - * without having to use the more complex $.ajax function. It - * allows a single callback function to be specified that will - * be executed when the request is complete (and only if the response - * has a successful response code). If you need to have both error - * and success callbacks, you may want to use $.ajax. - * - * @example $.get("test.cgi"); - * - * @example $.get("test.cgi", { name: "John", time: "2pm" } ); - * - * @example $.get("test.cgi", function(data){ - * alert("Data Loaded: " + data); - * }); - * - * @example $.get("test.cgi", - * { name: "John", time: "2pm" }, - * function(data){ - * alert("Data Loaded: " + data); - * } - * ); - * - * @name $.get - * @type XMLHttpRequest - * @param String url The URL of the page to load. - * @param Map params (optional) Key/value pairs that will be sent to the server. - * @param Function callback (optional) A function to be executed whenever the data is loaded successfully. - * @cat Ajax - */ get: function( url, data, callback, type, ifModified ) { // shift arguments if data argument was ommited if ( jQuery.isFunction( data ) ) { @@ -297,110 +105,19 @@ jQuery.extend({ }); }, - /** - * Load a remote page using an HTTP GET request, only if it hasn't - * been modified since it was last retrieved. - * - * @example $.getIfModified("test.html"); - * - * @example $.getIfModified("test.html", { name: "John", time: "2pm" } ); - * - * @example $.getIfModified("test.cgi", function(data){ - * alert("Data Loaded: " + data); - * }); - * - * @example $.getifModified("test.cgi", - * { name: "John", time: "2pm" }, - * function(data){ - * alert("Data Loaded: " + data); - * } - * ); - * - * @name $.getIfModified - * @type XMLHttpRequest - * @param String url The URL of the page to load. - * @param Map params (optional) Key/value pairs that will be sent to the server. - * @param Function callback (optional) A function to be executed whenever the data is loaded successfully. - * @cat Ajax - */ // DEPRECATED getIfModified: function( url, data, callback, type ) { return jQuery.get(url, data, callback, type, 1); }, - /** - * Loads, and executes, a remote JavaScript file using an HTTP GET request. - * - * Warning: Safari <= 2.0.x is unable to evaluate scripts in a global - * context synchronously. If you load functions via getScript, make sure - * to call them after a delay. - * - * @example $.getScript("test.js"); - * - * @example $.getScript("test.js", function(){ - * alert("Script loaded and executed."); - * }); - * - * @name $.getScript - * @type XMLHttpRequest - * @param String url The URL of the page to load. - * @param Function callback (optional) A function to be executed whenever the data is loaded successfully. - * @cat Ajax - */ getScript: function( url, callback ) { return jQuery.get(url, null, callback, "script"); }, - /** - * Load JSON data using an HTTP GET request. - * - * @example $.getJSON("test.js", function(json){ - * alert("JSON Data: " + json.users[3].name); - * }); - * - * @example $.getJSON("test.js", - * { name: "John", time: "2pm" }, - * function(json){ - * alert("JSON Data: " + json.users[3].name); - * } - * ); - * - * @name $.getJSON - * @type XMLHttpRequest - * @param String url The URL of the page to load. - * @param Map params (optional) Key/value pairs that will be sent to the server. - * @param Function callback A function to be executed whenever the data is loaded successfully. - * @cat Ajax - */ getJSON: function( url, data, callback ) { return jQuery.get(url, data, callback, "json"); }, - /** - * Load a remote page using an HTTP POST request. - * - * @example $.post("test.cgi"); - * - * @example $.post("test.cgi", { name: "John", time: "2pm" } ); - * - * @example $.post("test.cgi", function(data){ - * alert("Data Loaded: " + data); - * }); - * - * @example $.post("test.cgi", - * { name: "John", time: "2pm" }, - * function(data){ - * alert("Data Loaded: " + data); - * } - * ); - * - * @name $.post - * @type XMLHttpRequest - * @param String url The URL of the page to load. - * @param Map params (optional) Key/value pairs that will be sent to the server. - * @param Function callback (optional) A function to be executed whenever the data is loaded successfully. - * @cat Ajax - */ post: function( url, data, callback, type ) { if ( jQuery.isFunction( data ) ) { callback = data; @@ -416,51 +133,11 @@ jQuery.extend({ }); }, - /** - * Set the timeout in milliseconds of all AJAX requests to a specific amount of time. - * This will make all future AJAX requests timeout after a specified amount - * of time. - * - * Set to null or 0 to disable timeouts (default). - * - * You can manually abort requests with the XMLHttpRequest's (returned by - * all ajax functions) abort() method. - * - * Deprecated. Use $.ajaxSetup instead. - * - * @example $.ajaxTimeout( 5000 ); - * @desc Make all AJAX requests timeout after 5 seconds. - * - * @name $.ajaxTimeout - * @type undefined - * @param Number time How long before an AJAX request times out, in milliseconds. - * @cat Ajax - */ // DEPRECATED ajaxTimeout: function( timeout ) { jQuery.ajaxSettings.timeout = timeout; }, - /** - * Setup global settings for AJAX requests. - * - * See $.ajax for a description of all available options. - * - * @example $.ajaxSetup( { - * url: "/xmlhttp/", - * global: false, - * type: "POST" - * } ); - * $.ajax({ data: myData }); - * @desc Sets the defaults for AJAX requests to the url "/xmlhttp/", - * disables global handlers and uses POST instead of GET. The following - * AJAX requests then sends some data without having to set anything else. - * - * @name $.ajaxSetup - * @type undefined - * @param Map settings Key/value pairs to use for all AJAX requests - * @cat Ajax - */ ajaxSetup: function( settings ) { jQuery.extend( jQuery.ajaxSettings, settings ); }, @@ -478,128 +155,6 @@ jQuery.extend({ // Last-Modified header cache for next request lastModified: {}, - /** - * Load a remote page using an HTTP request. - * - * This is jQuery's low-level AJAX implementation. See $.get, $.post etc. for - * higher-level abstractions that are often easier to understand and use, - * but don't offer as much functionality (such as error callbacks). - * - * $.ajax() returns the XMLHttpRequest that it creates. In most cases you won't - * need that object to manipulate directly, but it is available if you need to - * abort the request manually. - * - * '''Note:''' If you specify the dataType option described below, make sure - * the server sends the correct MIME type in the response (eg. xml as "text/xml"). - * Sending the wrong MIME type can lead to unexpected problems in your script. - * See [[Specifying the Data Type for AJAX Requests]] for more information. - * - * Supported datatypes are (see dataType option): - * - * "xml": Returns a XML document that can be processed via jQuery. - * - * "html": Returns HTML as plain text, included script tags are evaluated. - * - * "script": Evaluates the response as Javascript and returns it as plain text. - * - * "json": Evaluates the response as JSON and returns a Javascript Object - * - * $.ajax() takes one argument, an object of key/value pairs, that are - * used to initalize and handle the request. These are all the key/values that can - * be used: - * - * (String) url - The URL to request. - * - * (String) type - The type of request to make ("POST" or "GET"), default is "GET". - * - * (String) dataType - The type of data that you're expecting back from - * the server. No default: If the server sends xml, the responseXML, otherwise - * the responseText is passed to the success callback. - * - * (Boolean) ifModified - Allow the request to be successful only if the - * response has changed since the last request. This is done by checking the - * Last-Modified header. Default value is false, ignoring the header. - * - * (Number) timeout - Local timeout in milliseconds to override global timeout, eg. to give a - * single request a longer timeout while all others timeout after 1 second. - * See $.ajaxTimeout() for global timeouts. - * - * (Boolean) global - Whether to trigger global AJAX event handlers for - * this request, default is true. Set to false to prevent that global handlers - * like ajaxStart or ajaxStop are triggered. - * - * (Function) error - A function to be called if the request fails. The - * function gets passed tree arguments: The XMLHttpRequest object, a - * string describing the type of error that occurred and an optional - * exception object, if one occured. - * - * (Function) success - A function to be called if the request succeeds. The - * function gets passed one argument: The data returned from the server, - * formatted according to the 'dataType' parameter. - * - * (Function) complete - A function to be called when the request finishes. The - * function gets passed two arguments: The XMLHttpRequest object and a - * string describing the type of success of the request. - * - * (Object|String) data - Data to be sent to the server. Converted to a query - * string, if not already a string. Is appended to the url for GET-requests. - * See processData option to prevent this automatic processing. - * - * (String) contentType - When sending data to the server, use this content-type. - * Default is "application/x-www-form-urlencoded", which is fine for most cases. - * - * (Boolean) processData - By default, data passed in to the data option as an object - * other as string will be processed and transformed into a query string, fitting to - * the default content-type "application/x-www-form-urlencoded". If you want to send - * DOMDocuments, set this option to false. - * - * (Boolean) async - By default, all requests are sent asynchronous (set to true). - * If you need synchronous requests, set this option to false. - * - * (Function) beforeSend - A pre-callback to set custom headers etc., the - * XMLHttpRequest is passed as the only argument. - * - * @example $.ajax({ - * type: "GET", - * url: "test.js", - * dataType: "script" - * }) - * @desc Load and execute a JavaScript file. - * - * @example $.ajax({ - * type: "POST", - * url: "some.php", - * data: "name=John&location=Boston", - * success: function(msg){ - * alert( "Data Saved: " + msg ); - * } - * }); - * @desc Save some data to the server and notify the user once its complete. - * - * @example var html = $.ajax({ - * url: "some.php", - * async: false - * }).responseText; - * @desc Loads data synchronously. Blocks the browser while the requests is active. - * It is better to block user interaction by other means when synchronization is - * necessary. - * - * @example var xmlDocument = [create xml document]; - * $.ajax({ - * url: "page.php", - * processData: false, - * data: xmlDocument, - * success: handleResponse - * }); - * @desc Sends an xml document as data to the server. By setting the processData - * option to false, the automatic conversion of data to strings is prevented. - * - * @name $.ajax - * @type XMLHttpRequest - * @param Map properties Key/value pairs to initialize the request with. - * @cat Ajax - * @see ajaxSetup(Map) - */ ajax: function( s ) { var jsonp, jsre = /=(\?|%3F)/g, status, data; @@ -862,12 +417,6 @@ jQuery.extend({ return false; }, - /* Get the data out of an XMLHttpRequest. - * Return parsed XML if content-type header is "xml" and type is "xml" or omitted, - * otherwise return plain text. - * (String) data - The type of data that you're expecting back, - * (e.g. "xml", "html", "script") - */ httpData: function( r, type ) { var ct = r.getResponseHeader("content-type"); var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0; diff --git a/src/event/event.js b/src/event/event.js index 6224d13bc..df982ec40 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -285,88 +285,12 @@ jQuery.event = { }; jQuery.fn.extend({ - - /** - * Binds a handler to a particular event (like click) for each matched element. - * The event handler is passed an event object that you can use to prevent - * default behaviour. To stop both default action and event bubbling, your handler - * has to return false. - * - * In most cases, you can define your event handlers as anonymous functions - * (see first example). In cases where that is not possible, you can pass additional - * data as the second parameter (and the handler function as the third), see - * second example. - * - * Calling bind with an event type of "unload" will automatically - * use the one method instead of bind to prevent memory leaks. - * - * @example $("p").bind("click", function(){ - * alert( $(this).text() ); - * }); - * @before

    Hello

    - * @result alert("Hello") - * - * @example function handler(event) { - * alert(event.data.foo); - * } - * $("p").bind("click", {foo: "bar"}, handler) - * @result alert("bar") - * @desc Pass some additional data to the event handler. - * - * @example $("form").bind("submit", function() { return false; }) - * @desc Cancel a default action and prevent it from bubbling by returning false - * from your function. - * - * @example $("form").bind("submit", function(event){ - * event.preventDefault(); - * }); - * @desc Cancel only the default action by using the preventDefault method. - * - * - * @example $("form").bind("submit", function(event){ - * event.stopPropagation(); - * }); - * @desc Stop only an event from bubbling by using the stopPropagation method. - * - * @name bind - * @type jQuery - * @param String type An event type - * @param Object data (optional) Additional data passed to the event handler as event.data - * @param Function fn A function to bind to the event on each of the set of matched elements - * @cat Events - */ bind: function( type, data, fn ) { return type == "unload" ? this.one(type, data, fn) : this.each(function(){ jQuery.event.add( this, type, fn || data, fn && data ); }); }, - /** - * Binds a handler to a particular event (like click) for each matched element. - * The handler is executed only once for each element. Otherwise, the same rules - * as described in bind() apply. - * The event handler is passed an event object that you can use to prevent - * default behaviour. To stop both default action and event bubbling, your handler - * has to return false. - * - * In most cases, you can define your event handlers as anonymous functions - * (see first example). In cases where that is not possible, you can pass additional - * data as the second paramter (and the handler function as the third), see - * second example. - * - * @example $("p").one("click", function(){ - * alert( $(this).text() ); - * }); - * @before

    Hello

    - * @result alert("Hello") - * - * @name one - * @type jQuery - * @param String type An event type - * @param Object data (optional) Additional data passed to the event handler as event.data - * @param Function fn A function to bind to the event on each of the set of matched elements - * @cat Events - */ one: function( type, data, fn ) { return this.each(function(){ jQuery.event.add( this, type, function(event) { @@ -376,73 +300,12 @@ jQuery.fn.extend({ }); }, - /** - * The opposite of bind, removes a bound event from each of the matched - * elements. - * - * Without any arguments, all bound events are removed. - * - * If the type is provided, all bound events of that type are removed. - * - * If the function that was passed to bind is provided as the second argument, - * only that specific event handler is removed. - * - * @example $("p").unbind() - * @before

    Hello

    - * @result [

    Hello

    ] - * - * @example $("p").unbind( "click" ) - * @before

    Hello

    - * @result [

    Hello

    ] - * - * @example $("p").unbind( "click", function() { alert("Hello"); } ) - * @before

    Hello

    - * @result [

    Hello

    ] - * - * @name unbind - * @type jQuery - * @param String type (optional) An event type - * @param Function fn (optional) A function to unbind from the event on each of the set of matched elements - * @cat Events - */ unbind: function( type, fn ) { return this.each(function(){ jQuery.event.remove( this, type, fn ); }); }, - /** - * Trigger a type of event on every matched element. This will also cause - * the default action of the browser with the same name (if one exists) - * to be executed. For example, passing 'submit' to the trigger() - * function will also cause the browser to submit the form. This - * default action can be prevented by returning false from one of - * the functions bound to the event. - * - * You can also trigger custom events registered with bind. - * - * @example $("p").trigger("click") - * @before

    Hello

    - * @result alert('hello') - * - * @example $("p").click(function(event, a, b) { - * // when a normal click fires, a and b are undefined - * // for a trigger like below a refers too "foo" and b refers to "bar" - * }).trigger("click", ["foo", "bar"]); - * @desc Example of how to pass arbitrary data to an event - * - * @example $("p").bind("myEvent",function(event,message1,message2) { - * alert(message1 + ' ' + message2); - * }); - * $("p").trigger("myEvent",["Hello","World"]); - * @result alert('Hello World') // One for each paragraph - * - * @name trigger - * @type jQuery - * @param String type An event type to trigger. - * @param Array data (optional) Additional data to pass as arguments (after the event object) to the event handler - * @cat Events - */ trigger: function( type, data, fn ) { return this.each(function(){ jQuery.event.trigger( type, data, this, true, fn ); @@ -454,26 +317,6 @@ jQuery.fn.extend({ return jQuery.event.trigger( type, data, this[0], false, fn ); }, - /** - * Toggle between two function calls every other click. - * Whenever a matched element is clicked, the first specified function - * is fired, when clicked again, the second is fired. All subsequent - * clicks continue to rotate through the two functions. - * - * Use unbind("click") to remove. - * - * @example $("p").toggle(function(){ - * $(this).addClass("selected"); - * },function(){ - * $(this).removeClass("selected"); - * }); - * - * @name toggle - * @type jQuery - * @param Function even The function to execute on every even click. - * @param Function odd The function to execute on every odd click. - * @cat Events - */ toggle: function() { // Save reference to arguments for access in closure var a = arguments; @@ -489,32 +332,7 @@ jQuery.fn.extend({ return a[this.lastToggle].apply( this, [e] ) || false; }); }, - - /** - * A method for simulating hovering (moving the mouse on, and off, - * an object). This is a custom method which provides an 'in' to a - * frequent task. - * - * Whenever the mouse cursor is moved over a matched - * element, the first specified function is fired. Whenever the mouse - * moves off of the element, the second specified function fires. - * Additionally, checks are in place to see if the mouse is still within - * the specified element itself (for example, an image inside of a div), - * and if it is, it will continue to 'hover', and not move out - * (a common error in using a mouseout event handler). - * - * @example $("p").hover(function(){ - * $(this).addClass("hover"); - * },function(){ - * $(this).removeClass("hover"); - * }); - * - * @name hover - * @type jQuery - * @param Function over The function to fire whenever the mouse is moved over a matched element. - * @param Function out The function to fire whenever the mouse is moved off of a matched element. - * @cat Events - */ + hover: function(f,g) { // A private function for handling mouse 'hovering' @@ -536,43 +354,6 @@ jQuery.fn.extend({ return this.mouseover(handleHover).mouseout(handleHover); }, - /** - * Bind a function to be executed whenever the DOM is ready to be - * traversed and manipulated. This is probably the most important - * function included in the event module, as it can greatly improve - * the response times of your web applications. - * - * In a nutshell, this is a solid replacement for using window.onload, - * and attaching a function to that. By using this method, your bound function - * will be called the instant the DOM is ready to be read and manipulated, - * which is when what 99.99% of all JavaScript code needs to run. - * - * There is one argument passed to the ready event handler: A reference to - * the jQuery function. You can name that argument whatever you like, and - * can therefore stick with the $ alias without risk of naming collisions. - * - * Please ensure you have no code in your <body> onload event handler, - * otherwise $(document).ready() may not fire. - * - * You can have as many $(document).ready events on your page as you like. - * The functions are then executed in the order they were added. - * - * @example $(document).ready(function(){ Your code here... }); - * - * @example jQuery(function($) { - * // Your code using failsafe $ alias here... - * }); - * @desc Uses both the [[Core#.24.28_fn_.29|shortcut]] for $(document).ready() and the argument - * to write failsafe jQuery code using the $ alias, without relying on the - * global alias. - * - * @name ready - * @type jQuery - * @param Function fn The function to be executed when the DOM is ready. - * @cat Events - * @see $.noConflict() - * @see $(Function) - */ ready: function(f) { // Attach the listeners bindReady(); @@ -626,356 +407,16 @@ jQuery.extend({ } }); - /** - * Bind a function to the scroll event of each matched element. - * - * @example $("p").scroll( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name scroll - * @type jQuery - * @param Function fn A function to bind to the scroll event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the submit event of each matched element. - * - * @example $("#myform").submit( function() { - * return $("input", this).val().length > 0; - * } ); - * @before
    - * @desc Prevents the form submission when the input has no value entered. - * - * @name submit - * @type jQuery - * @param Function fn A function to bind to the submit event on each of the matched elements. - * @cat Events - */ - - /** - * Trigger the submit event of each matched element. This causes all of the functions - * that have been bound to that submit event to be executed, and calls the browser's - * default submit action on the matching element(s). This default action can be prevented - * by returning false from one of the functions bound to the submit event. - * - * Note: This does not execute the submit method of the form element! If you need to - * submit the form via code, you have to use the DOM method, eg. $("form")[0].submit(); - * - * @example $("form").submit(); - * @desc Triggers all submit events registered to the matched form(s), and submits them. - * - * @name submit - * @type jQuery - * @cat Events - */ - - /** - * Bind a function to the focus event of each matched element. - * - * @example $("p").focus( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name focus - * @type jQuery - * @param Function fn A function to bind to the focus event on each of the matched elements. - * @cat Events - */ - - /** - * Trigger the focus event of each matched element. This causes all of the functions - * that have been bound to thet focus event to be executed. - * - * Note: This does not execute the focus method of the underlying elements! If you need to - * focus an element via code, you have to use the DOM method, eg. $("#myinput")[0].focus(); - * - * @example $("p").focus(); - * @before

    Hello

    - * @result alert('Hello'); - * - * @name focus - * @type jQuery - * @cat Events - */ - - /** - * Bind a function to the keydown event of each matched element. - * - * @example $("p").keydown( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name keydown - * @type jQuery - * @param Function fn A function to bind to the keydown event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the dblclick event of each matched element. - * - * @example $("p").dblclick( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name dblclick - * @type jQuery - * @param Function fn A function to bind to the dblclick event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the keypress event of each matched element. - * - * @example $("p").keypress( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name keypress - * @type jQuery - * @param Function fn A function to bind to the keypress event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the error event of each matched element. - * - * @example $("p").error( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name error - * @type jQuery - * @param Function fn A function to bind to the error event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the blur event of each matched element. - * - * @example $("p").blur( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name blur - * @type jQuery - * @param Function fn A function to bind to the blur event on each of the matched elements. - * @cat Events - */ - - /** - * Trigger the blur event of each matched element. This causes all of the functions - * that have been bound to that blur event to be executed, and calls the browser's - * default blur action on the matching element(s). This default action can be prevented - * by returning false from one of the functions bound to the blur event. - * - * Note: This does not execute the blur method of the underlying elements! If you need to - * blur an element via code, you have to use the DOM method, eg. $("#myinput")[0].blur(); - * - * @example $("p").blur(); - * @before

    Hello

    - * @result alert('Hello'); - * - * @name blur - * @type jQuery - * @cat Events - */ - - /** - * Bind a function to the load event of each matched element. - * - * @example $("p").load( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name load - * @type jQuery - * @param Function fn A function to bind to the load event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the select event of each matched element. - * - * @example $("p").select( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name select - * @type jQuery - * @param Function fn A function to bind to the select event on each of the matched elements. - * @cat Events - */ - - /** - * Trigger the select event of each matched element. This causes all of the functions - * that have been bound to that select event to be executed, and calls the browser's - * default select action on the matching element(s). This default action can be prevented - * by returning false from one of the functions bound to the select event. - * - * @example $("p").select(); - * @before

    Hello

    - * @result alert('Hello'); - * - * @name select - * @type jQuery - * @cat Events - */ - - /** - * Bind a function to the mouseup event of each matched element. - * - * @example $("p").mouseup( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name mouseup - * @type jQuery - * @param Function fn A function to bind to the mouseup event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the unload event of each matched element. - * - * @example $("p").unload( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name unload - * @type jQuery - * @param Function fn A function to bind to the unload event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the change event of each matched element. - * - * @example $("p").change( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name change - * @type jQuery - * @param Function fn A function to bind to the change event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the mouseout event of each matched element. - * - * @example $("p").mouseout( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name mouseout - * @type jQuery - * @param Function fn A function to bind to the mouseout event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the keyup event of each matched element. - * - * @example $("p").keyup( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name keyup - * @type jQuery - * @param Function fn A function to bind to the keyup event on each of the matched elements. - * @cat Events - */ - /** - * Bind a function to the click event of each matched element. - * - * @example $("p").click( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name click - * @type jQuery - * @param Function fn A function to bind to the click event on each of the matched elements. - * @cat Events - */ - - /** - * Trigger the click event of each matched element. This causes all of the functions - * that have been bound to thet click event to be executed. - * - * @example $("p").click(); - * @before

    Hello

    - * @result alert('Hello'); - * - * @name click - * @type jQuery - * @cat Events - */ - - /** - * Bind a function to the resize event of each matched element. - * - * @example $("p").resize( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name resize - * @type jQuery - * @param Function fn A function to bind to the resize event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the mousemove event of each matched element. - * - * @example $("p").mousemove( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name mousemove - * @type jQuery - * @param Function fn A function to bind to the mousemove event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the mousedown event of each matched element. - * - * @example $("p").mousedown( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name mousedown - * @type jQuery - * @param Function fn A function to bind to the mousedown event on each of the matched elements. - * @cat Events - */ - - /** - * Bind a function to the mouseover event of each matched element. - * - * @example $("p").mouseover( function() { alert("Hello"); } ); - * @before

    Hello

    - * @result

    Hello

    - * - * @name mouseover - * @type jQuery - * @param Function fn A function to bind to the mousedown event on each of the matched elements. - * @cat Events - */ - jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + - "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + - "submit,keydown,keypress,keyup,error").split(","), function(i,o){ - - // Handle event binding - jQuery.fn[o] = function(f){ - return f ? this.bind(o, f) : this.trigger(o); - }; - - }); +jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + + "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," + + "submit,keydown,keypress,keyup,error").split(","), function(i,o){ + + // Handle event binding + jQuery.fn[o] = function(f){ + return f ? this.bind(o, f) : this.trigger(o); + }; +}); var readyBound = false; diff --git a/src/fx/fx.js b/src/fx/fx.js index 69885e890..7c5ba4455 100644 --- a/src/fx/fx.js +++ b/src/fx/fx.js @@ -1,37 +1,4 @@ jQuery.fn.extend({ - - /** - * Displays each of the set of matched elements if they are hidden. - * - * @example $("p").show() - * @before

    Hello

    - * @result [

    Hello

    ] - * - * @name show - * @type jQuery - * @cat Effects - */ - - /** - * Show all matched elements using a graceful animation and firing an - * optional callback after completion. - * - * The height, width, and opacity of each of the matched elements - * are changed dynamically according to the specified speed. - * - * @example $("p").show("slow"); - * - * @example $("p").show("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name show - * @type jQuery - * @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see hide(String|Number,Function) - */ show: function(speed,callback){ return speed ? this.animate({ @@ -45,38 +12,6 @@ jQuery.fn.extend({ }).end(); }, - /** - * Hides each of the set of matched elements if they are shown. - * - * @example $("p").hide() - * @before

    Hello

    - * @result [

    Hello

    ] - * - * @name hide - * @type jQuery - * @cat Effects - */ - - /** - * Hide all matched elements using a graceful animation and firing an - * optional callback after completion. - * - * The height, width, and opacity of each of the matched elements - * are changed dynamically according to the specified speed. - * - * @example $("p").hide("slow"); - * - * @example $("p").hide("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name hide - * @type jQuery - * @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see show(String|Number,Function) - */ hide: function(speed,callback){ return speed ? this.animate({ @@ -94,19 +29,6 @@ jQuery.fn.extend({ // Save the old toggle function _toggle: jQuery.fn.toggle, - /** - * Toggles each of the set of matched elements. If they are shown, - * toggle makes them hidden. If they are hidden, toggle - * makes them shown. - * - * @example $("p").toggle() - * @before

    Hello

    Hello Again

    - * @result [

    Hello

    ,

    Hello Again

    ] - * - * @name toggle - * @type jQuery - * @cat Effects - */ toggle: function( fn, fn2 ){ return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? this._toggle( fn, fn2 ) : @@ -119,196 +41,30 @@ jQuery.fn.extend({ }); }, - /** - * Reveal all matched elements by adjusting their height and firing an - * optional callback after completion. - * - * Only the height is adjusted for this animation, causing all matched - * elements to be revealed in a "sliding" manner. - * - * @example $("p").slideDown("slow"); - * - * @example $("p").slideDown("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name slideDown - * @type jQuery - * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see slideUp(String|Number,Function) - * @see slideToggle(String|Number,Function) - */ slideDown: function(speed,callback){ return this.animate({height: "show"}, speed, callback); }, - /** - * Hide all matched elements by adjusting their height and firing an - * optional callback after completion. - * - * Only the height is adjusted for this animation, causing all matched - * elements to be hidden in a "sliding" manner. - * - * @example $("p").slideUp("slow"); - * - * @example $("p").slideUp("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name slideUp - * @type jQuery - * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see slideDown(String|Number,Function) - * @see slideToggle(String|Number,Function) - */ slideUp: function(speed,callback){ return this.animate({height: "hide"}, speed, callback); }, - /** - * Toggle the visibility of all matched elements by adjusting their height and firing an - * optional callback after completion. - * - * Only the height is adjusted for this animation, causing all matched - * elements to be hidden in a "sliding" manner. - * - * @example $("p").slideToggle("slow"); - * - * @example $("p").slideToggle("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name slideToggle - * @type jQuery - * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see slideDown(String|Number,Function) - * @see slideUp(String|Number,Function) - */ slideToggle: function(speed, callback){ return this.animate({height: "toggle"}, speed, callback); }, - /** - * Fade in all matched elements by adjusting their opacity and firing an - * optional callback after completion. - * - * Only the opacity is adjusted for this animation, meaning that - * all of the matched elements should already have some form of height - * and width associated with them. - * - * @example $("p").fadeIn("slow"); - * - * @example $("p").fadeIn("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name fadeIn - * @type jQuery - * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see fadeOut(String|Number,Function) - * @see fadeTo(String|Number,Number,Function) - */ fadeIn: function(speed, callback){ return this.animate({opacity: "show"}, speed, callback); }, - /** - * Fade out all matched elements by adjusting their opacity and firing an - * optional callback after completion. - * - * Only the opacity is adjusted for this animation, meaning that - * all of the matched elements should already have some form of height - * and width associated with them. - * - * @example $("p").fadeOut("slow"); - * - * @example $("p").fadeOut("slow",function(){ - * alert("Animation Done."); - * }); - * - * @name fadeOut - * @type jQuery - * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see fadeIn(String|Number,Function) - * @see fadeTo(String|Number,Number,Function) - */ fadeOut: function(speed, callback){ return this.animate({opacity: "hide"}, speed, callback); }, - /** - * Fade the opacity of all matched elements to a specified opacity and firing an - * optional callback after completion. - * - * Only the opacity is adjusted for this animation, meaning that - * all of the matched elements should already have some form of height - * and width associated with them. - * - * @example $("p").fadeTo("slow", 0.5); - * - * @example $("p").fadeTo("slow", 0.5, function(){ - * alert("Animation Done."); - * }); - * - * @name fadeTo - * @type jQuery - * @param String|Number speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param Number opacity The opacity to fade to (a number from 0 to 1). - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - * @see fadeIn(String|Number,Function) - * @see fadeOut(String|Number,Function) - */ fadeTo: function(speed,to,callback){ return this.animate({opacity: to}, speed, callback); }, - /** - * A function for making your own, custom animations. The key aspect of - * this function is the object of style properties that will be animated, - * and to what end. Each key within the object represents a style property - * that will also be animated (for example: "height", "top", or "opacity"). - * - * Note that properties should be specified using camel case - * eg. marginLeft instead of margin-left. - * - * The value associated with the key represents to what end the property - * will be animated. If a number is provided as the value, then the style - * property will be transitioned from its current state to that new number. - * Otherwise if the string "hide", "show", or "toggle" is provided, a default - * animation will be constructed for that property. - * - * @example $("p").animate({ - * height: 'toggle', opacity: 'toggle' - * }, "slow"); - * - * @example $("p").animate({ - * left: 50, opacity: 'show' - * }, 500); - * - * @example $("p").animate({ - * opacity: 'show' - * }, "slow", "easein"); - * @desc An example of using an 'easing' function to provide a different style of animation. This will only work if you have a plugin that provides this easing function (Only "swing" and "linear" are provided by default, with jQuery). - * - * @name animate - * @type jQuery - * @param Hash params A set of style attributes that you wish to animate, and to what end. - * @param String|Number speed (optional) A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). - * @param String easing (optional) The name of the easing effect that you want to use (e.g. "swing" or "linear"). Defaults to "swing". - * @param Function callback (optional) A function to be executed whenever the animation completes. - * @cat Effects - */ animate: function( prop, speed, easing, callback ) { return this.queue(function(){ var hidden = jQuery(this).is(":hidden"), @@ -346,10 +102,6 @@ jQuery.fn.extend({ }); }, - /** - * - * @private - */ queue: function(type,fn){ if ( !fn ) { fn = type; diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 8f8a1763d..338df7f96 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -9,17 +9,6 @@ * $Rev$ */ -/** - * Create a new jQuery Object - * - * @constructor - * @private - * @name jQuery - * @param String|Function|Element|Array|jQuery a selector - * @param jQuery|Element|Array c context - * @cat Core - */ - // Map over jQuery in case of overwrite if ( typeof jQuery != "undefined" ) var _jQuery = jQuery; @@ -41,118 +30,7 @@ window.$ = jQuery; var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/; -/** - * This function accepts a string containing a CSS or - * basic XPath selector which is then used to match a set of elements. - * - * The core functionality of jQuery centers around this function. - * Everything in jQuery is based upon this, or uses this in some way. - * The most basic use of this function is to pass in an expression - * (usually consisting of CSS or XPath), which then finds all matching - * elements. - * - * By default, if no context is specified, $() looks for DOM elements within the context of the - * current HTML document. If you do specify a context, such as a DOM - * element or jQuery object, the expression will be matched against - * the contents of that context. - * - * See [[DOM/Traversing/Selectors]] for the allowed CSS/XPath syntax for expressions. - * - * @example $("div > p") - * @desc Finds all p elements that are children of a div element. - * @before

    one

    two

    three

    - * @result [

    two

    ] - * - * @example $("input:radio", document.forms[0]) - * @desc Searches for all inputs of type radio within the first form in the document - * - * @example $("div", xml.responseXML) - * @desc This finds all div elements within the specified XML document. - * - * @name $ - * @param String expr An expression to search with - * @param Element|jQuery context (optional) A DOM Element, Document or jQuery to use as context - * @cat Core - * @type jQuery - * @see $(Element) - * @see $(Element) - */ - -/** - * Create DOM elements on-the-fly from the provided String of raw HTML. - * - * @example $("

    Hello

    ").appendTo("body") - * @desc Creates a div element (and all of its contents) dynamically, - * and appends it to the body element. Internally, an - * element is created and its innerHTML property set to the given markup. - * It is therefore both quite flexible and limited. - * - * @name $ - * @param String html A string of HTML to create on the fly. - * @cat Core - * @type jQuery - * @see appendTo(String) - */ - -/** - * Wrap jQuery functionality around a single or multiple DOM Element(s). - * - * This function also accepts XML Documents and Window objects - * as valid arguments (even though they are not DOM Elements). - * - * @example $(document.body).css( "background", "black" ); - * @desc Sets the background color of the page to black. - * - * @example $( myForm.elements ).hide() - * @desc Hides all the input elements within a form - * - * @name $ - * @param Element|Array elems DOM element(s) to be encapsulated by a jQuery object. - * @cat Core - * @type jQuery - */ - -/** - * A shorthand for $(document).ready(), allowing you to bind a function - * to be executed when the DOM document has finished loading. This function - * behaves just like $(document).ready(), in that it should be used to wrap - * other $() operations on your page that depend on the DOM being ready to be - * operated on. While this function is, technically, chainable - there really - * isn't much use for chaining against it. - * - * You can have as many $(document).ready events on your page as you like. - * - * See ready(Function) for details about the ready event. - * - * @example $(function(){ - * // Document is ready - * }); - * @desc Executes the function when the DOM is ready to be used. - * - * @example jQuery(function($) { - * // Your code using failsafe $ alias here... - * }); - * @desc Uses both the shortcut for $(document).ready() and the argument - * to write failsafe jQuery code using the $ alias, without relying on the - * global alias. - * - * @name $ - * @param Function fn The function to execute when the DOM is ready. - * @cat Core - * @type jQuery - * @see ready(Function) - */ - jQuery.fn = jQuery.prototype = { - /** - * Initialize a new jQuery object - * - * @private - * @name init - * @param String|Function|Element|Array|jQuery a selector - * @param jQuery|Element|Array c context - * @cat Core - */ init: function(a,c) { // Make sure that a selection was provided a = a || document; @@ -203,80 +81,14 @@ jQuery.fn = jQuery.prototype = { [ a ] ); }, - /** - * The current version of jQuery. - * - * @private - * @property - * @name jquery - * @type String - * @cat Core - */ jquery: "@VERSION", - /** - * The number of elements currently matched. The size function will return the same value. - * - * @example $("img").length; - * @before - * @result 2 - * - * @property - * @name length - * @type Number - * @cat Core - */ - - /** - * Get the number of elements currently matched. This returns the same - * number as the 'length' property of the jQuery object. - * - * @example $("img").size(); - * @before - * @result 2 - * - * @name size - * @type Number - * @cat Core - */ size: function() { return this.length; }, length: 0, - /** - * Access all matched DOM elements. This serves as a backwards-compatible - * way of accessing all matched elements (other than the jQuery object - * itself, which is, in fact, an array of elements). - * - * It is useful if you need to operate on the DOM elements themselves instead of using built-in jQuery functions. - * - * @example $("img").get(); - * @before - * @result [ ] - * @desc Selects all images in the document and returns the DOM Elements as an Array - * - * @name get - * @type Array - * @cat Core - */ - - /** - * Access a single matched DOM element at a specified index in the matched set. - * This allows you to extract the actual DOM element and operate on it - * directly without necessarily using jQuery functionality on it. - * - * @example $("img").get(0); - * @before - * @result - * @desc Selects all images in the document and returns the first one - * - * @name get - * @type Element - * @param Number num Access the element in the Nth position. - * @cat Core - */ get: function( num ) { return num == undefined ? @@ -287,96 +99,22 @@ jQuery.fn = jQuery.prototype = { this[num]; }, - /** - * Set the jQuery object to an array of elements, while maintaining - * the stack. - * - * @example $("img").pushStack([ document.body ]); - * @result $("img").pushStack() == [ document.body ] - * - * @private - * @name pushStack - * @type jQuery - * @param Elements elems An array of elements - * @cat Core - */ pushStack: function( a ) { var ret = jQuery(a); ret.prevObject = this; return ret; }, - /** - * Set the jQuery object to an array of elements. This operation is - * completely destructive - be sure to use .pushStack() if you wish to maintain - * the jQuery stack. - * - * @example $("img").setArray([ document.body ]); - * @result $("img").setArray() == [ document.body ] - * - * @private - * @name setArray - * @type jQuery - * @param Elements elems An array of elements - * @cat Core - */ setArray: function( a ) { this.length = 0; Array.prototype.push.apply( this, a ); return this; }, - /** - * Execute a function within the context of every matched element. - * This means that every time the passed-in function is executed - * (which is once for every element matched) the 'this' keyword - * points to the specific DOM element. - * - * Additionally, the function, when executed, is passed a single - * argument representing the position of the element in the matched - * set (integer, zero-index). - * - * @example $("img").each(function(i){ - * this.src = "test" + i + ".jpg"; - * }); - * @before - * @result - * @desc Iterates over two images and sets their src property - * - * @name each - * @type jQuery - * @param Function fn A function to execute - * @cat Core - */ each: function( fn, args ) { return jQuery.each( this, fn, args ); }, - /** - * Searches every matched element for the object and returns - * the index of the element, if found, starting with zero. - * Returns -1 if the object wasn't found. - * - * @example $("*").index( $('#foobar')[0] ) - * @before
    - * @result 0 - * @desc Returns the index for the element with ID foobar - * - * @example $("*").index( $('#foo')[0] ) - * @before
    - * @result 2 - * @desc Returns the index for the element with ID foo within another element - * - * @example $("*").index( $('#bar')[0] ) - * @before
    - * @result -1 - * @desc Returns -1, as there is no element with ID bar - * - * @name index - * @type Number - * @param Element subject Object to search for - * @cat Core - */ index: function( obj ) { var pos = -1; this.each(function(i){ @@ -385,85 +123,6 @@ jQuery.fn = jQuery.prototype = { return pos; }, - /** - * Access a property on the first matched element. - * This method makes it easy to retrieve a property value - * from the first matched element. - * - * If the element does not have an attribute with such a - * name, undefined is returned. - * - * @example $("img").attr("src"); - * @before - * @result test.jpg - * @desc Returns the src attribute from the first image in the document. - * - * @name attr - * @type Object - * @param String name The name of the property to access. - * @cat DOM/Attributes - */ - - /** - * Set a key/value object as properties to all matched elements. - * - * This serves as the best way to set a large number of properties - * on all matched elements. - * - * @example $("img").attr({ src: "test.jpg", alt: "Test Image" }); - * @before - * @result Test Image - * @desc Sets src and alt attributes to all images. - * - * @name attr - * @type jQuery - * @param Map properties Key/value pairs to set as object properties. - * @cat DOM/Attributes - */ - - /** - * Set a single property to a value, on all matched elements. - * - * Note that you can't set the name property of input elements in IE. - * Use $(html) or .append(html) or .html(html) to create elements - * on the fly including the name property. - * - * @example $("img").attr("src","test.jpg"); - * @before - * @result - * @desc Sets src attribute to all images. - * - * @name attr - * @type jQuery - * @param String key The name of the property to set. - * @param Object value The value to set the property to. - * @cat DOM/Attributes - */ - - /** - * Set a single property to a computed value, on all matched elements. - * - * Instead of supplying a string value as described - * [[DOM/Attributes#attr.28_key.2C_value_.29|above]], - * a function is provided that computes the value. - * - * @example $("img").attr("title", function() { return this.src }); - * @before - * @result - * @desc Sets title attribute from src attribute. - * - * @example $("img").attr("title", function(index) { return this.title + (i + 1); }); - * @before - * @result - * @desc Enumerate title attribute. - * - * @name attr - * @type jQuery - * @param String key The name of the property to set. - * @param Function value A function returning the value to set. - * Scope: Current element, argument: Index of current element - * @cat DOM/Attributes - */ attr: function( key, value, type ) { var obj = key; @@ -487,104 +146,10 @@ jQuery.fn = jQuery.prototype = { }); }, - /** - * Access a style property on the first matched element. - * This method makes it easy to retrieve a style property value - * from the first matched element. - * - * @example $("p").css("color"); - * @before

    Test Paragraph.

    - * @result "red" - * @desc Retrieves the color style of the first paragraph - * - * @example $("p").css("font-weight"); - * @before

    Test Paragraph.

    - * @result "bold" - * @desc Retrieves the font-weight style of the first paragraph. - * - * @name css - * @type String - * @param String name The name of the property to access. - * @cat CSS - */ - - /** - * Set a key/value object as style properties to all matched elements. - * - * This serves as the best way to set a large number of style properties - * on all matched elements. - * - * @example $("p").css({ color: "red", background: "blue" }); - * @before

    Test Paragraph.

    - * @result

    Test Paragraph.

    - * @desc Sets color and background styles to all p elements. - * - * @name css - * @type jQuery - * @param Map properties Key/value pairs to set as style properties. - * @cat CSS - */ - - /** - * Set a single style property to a value, on all matched elements. - * If a number is provided, it is automatically converted into a pixel value. - * - * @example $("p").css("color","red"); - * @before

    Test Paragraph.

    - * @result

    Test Paragraph.

    - * @desc Changes the color of all paragraphs to red - * - * @example $("p").css("left",30); - * @before

    Test Paragraph.

    - * @result

    Test Paragraph.

    - * @desc Changes the left of all paragraphs to "30px" - * - * @name css - * @type jQuery - * @param String key The name of the property to set. - * @param String|Number value The value to set the property to. - * @cat CSS - */ css: function( key, value ) { return this.attr( key, value, "curCSS" ); }, - /** - * Get the text contents of all matched elements. The result is - * a string that contains the combined text contents of all matched - * elements. This method works on both HTML and XML documents. - * - * @example $("p").text(); - * @before

    Test Paragraph.

    Paraparagraph

    - * @result Test Paragraph.Paraparagraph - * @desc Gets the concatenated text of all paragraphs - * - * @name text - * @type String - * @cat DOM/Attributes - */ - - /** - * Set the text contents of all matched elements. - * - * Similar to html(), but escapes HTML (replace "<" and ">" with their - * HTML entities). - * - * @example $("p").text("Some new text."); - * @before

    Test Paragraph.

    - * @result

    <b>Some</b> new text.

    - * @desc Sets the text of all paragraphs. - * - * @example $("p").text("Some new text.", true); - * @before

    Test Paragraph.

    - * @result

    Some new text.

    - * @desc Sets the text of all paragraphs. - * - * @name text - * @type String - * @param String val The text value to set the contents of the element to. - * @cat DOM/Attributes - */ text: function(e) { if ( typeof e != "object" && e != null ) return this.empty().append( document.createTextNode( e ) ); @@ -600,52 +165,6 @@ jQuery.fn = jQuery.prototype = { return t; }, - /** - * Wrap all matched elements with a structure of other elements. - * This wrapping process is most useful for injecting additional - * stucture into a document, without ruining the original semantic - * qualities of a document. - * - * This works by going through the first element - * provided (which is generated, on the fly, from the provided HTML) - * and finds the deepest ancestor element within its - * structure - it is that element that will en-wrap everything else. - * - * This does not work with elements that contain text. Any necessary text - * must be added after the wrapping is done. - * - * @example $("p").wrap("
    "); - * @before

    Test Paragraph.

    - * @result

    Test Paragraph.

    - * - * @name wrap - * @type jQuery - * @param String html A string of HTML, that will be created on the fly and wrapped around the target. - * @cat DOM/Manipulation - */ - - /** - * Wrap all matched elements with a structure of other elements. - * This wrapping process is most useful for injecting additional - * stucture into a document, without ruining the original semantic - * qualities of a document. - * - * This works by going through the first element - * provided and finding the deepest ancestor element within its - * structure - it is that element that will en-wrap everything else. - * - * This does not work with elements that contain text. Any necessary text - * must be added after the wrapping is done. - * - * @example $("p").wrap( document.getElementById('content') ); - * @before

    Test Paragraph.

    - * @result

    Test Paragraph.

    - * - * @name wrap - * @type jQuery - * @param Element elem A DOM element that will be wrapped around the target. - * @cat DOM/Manipulation - */ wrapAll: function(html) { if ( this[0] ) // The elements to wrap the target around @@ -675,208 +194,40 @@ jQuery.fn = jQuery.prototype = { }); }, - /** - * Append content to the inside of every matched element. - * - * This operation is similar to doing an appendChild to all the - * specified elements, adding them into the document. - * - * @example $("p").append("Hello"); - * @before

    I would like to say:

    - * @result

    I would like to say: Hello

    - * @desc Appends some HTML to all paragraphs. - * - * @example $("p").append( $("#foo")[0] ); - * @before

    I would like to say:

    Hello - * @result

    I would like to say: Hello

    - * @desc Appends an Element to all paragraphs. - * - * @example $("p").append( $("b") ); - * @before

    I would like to say:

    Hello - * @result

    I would like to say: Hello

    - * @desc Appends a jQuery object (similar to an Array of DOM Elements) to all paragraphs. - * - * @name append - * @type jQuery - * @param content Content to append to the target - * @cat DOM/Manipulation - * @see prepend() - * @see before() - * @see after() - */ append: function() { return this.domManip(arguments, true, 1, function(a){ this.appendChild( a ); }); }, - /** - * Prepend content to the inside of every matched element. - * - * This operation is the best way to insert elements - * inside, at the beginning, of all matched elements. - * - * @example $("p").prepend("Hello"); - * @before

    I would like to say:

    - * @result

    HelloI would like to say:

    - * @desc Prepends some HTML to all paragraphs. - * - * @example $("p").prepend( $("#foo")[0] ); - * @before

    I would like to say:

    Hello - * @result

    HelloI would like to say:

    - * @desc Prepends an Element to all paragraphs. - * - * @example $("p").prepend( $("b") ); - * @before

    I would like to say:

    Hello - * @result

    HelloI would like to say:

    - * @desc Prepends a jQuery object (similar to an Array of DOM Elements) to all paragraphs. - * - * @name prepend - * @type jQuery - * @param content Content to prepend to the target. - * @cat DOM/Manipulation - * @see append() - * @see before() - * @see after() - */ prepend: function() { return this.domManip(arguments, true, -1, function(a){ this.insertBefore( a, this.firstChild ); }); }, - /** - * Insert content before each of the matched elements. - * - * @example $("p").before("Hello"); - * @before

    I would like to say:

    - * @result Hello

    I would like to say:

    - * @desc Inserts some HTML before all paragraphs. - * - * @example $("p").before( $("#foo")[0] ); - * @before

    I would like to say:

    Hello - * @result Hello

    I would like to say:

    - * @desc Inserts an Element before all paragraphs. - * - * @example $("p").before( $("b") ); - * @before

    I would like to say:

    Hello - * @result Hello

    I would like to say:

    - * @desc Inserts a jQuery object (similar to an Array of DOM Elements) before all paragraphs. - * - * @name before - * @type jQuery - * @param content Content to insert before each target. - * @cat DOM/Manipulation - * @see append() - * @see prepend() - * @see after() - */ before: function() { return this.domManip(arguments, false, 1, function(a){ this.parentNode.insertBefore( a, this ); }); }, - /** - * Insert content after each of the matched elements. - * - * @example $("p").after("Hello"); - * @before

    I would like to say:

    - * @result

    I would like to say:

    Hello - * @desc Inserts some HTML after all paragraphs. - * - * @example $("p").after( $("#foo")[0] ); - * @before Hello

    I would like to say:

    - * @result

    I would like to say:

    Hello - * @desc Inserts an Element after all paragraphs. - * - * @example $("p").after( $("b") ); - * @before Hello

    I would like to say:

    - * @result

    I would like to say:

    Hello - * @desc Inserts a jQuery object (similar to an Array of DOM Elements) after all paragraphs. - * - * @name after - * @type jQuery - * @param content Content to insert after each target. - * @cat DOM/Manipulation - * @see append() - * @see prepend() - * @see before() - */ after: function() { return this.domManip(arguments, false, -1, function(a){ this.parentNode.insertBefore( a, this.nextSibling ); }); }, - /** - * Revert the most recent 'destructive' operation, changing the set of matched elements - * to its previous state (right before the destructive operation). - * - * If there was no destructive operation before, an empty set is returned. - * - * A 'destructive' operation is any operation that changes the set of - * matched jQuery elements. These functions are: add, - * children, clone, filter, - * find, not, next, - * parent, parents, prev and siblings. - * - * @example $("p").find("span").end(); - * @before

    Hello, how are you?

    - * @result [

    ...

    ] - * @desc Selects all paragraphs, finds span elements inside these, and reverts the - * selection back to the paragraphs. - * - * @name end - * @type jQuery - * @cat DOM/Traversing - */ end: function() { return this.prevObject || jQuery([]); }, - /** - * Searches for all elements that match the specified expression. - * - * This method is a good way to find additional descendant - * elements with which to process. - * - * All searching is done using a jQuery expression. The expression can be - * written using CSS 1-3 Selector syntax, or basic XPath. - * - * @example $("p").find("span"); - * @before

    Hello, how are you?

    - * @result [ Hello ] - * @desc Starts with all paragraphs and searches for descendant span - * elements, same as $("p span") - * - * @name find - * @type jQuery - * @param String expr An expression to search with. - * @cat DOM/Traversing - */ find: function(t) { var data = jQuery.map(this, function(a){ return jQuery.find(t,a); }); return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ? jQuery.unique( data ) : data ); }, - /** - * Clone matched DOM Elements and select the clones. - * - * This is useful for moving copies of the elements to another - * location in the DOM. - * - * @example $("b").clone().prependTo("p"); - * @before Hello

    , how are you?

    - * @result Hello

    Hello, how are you?

    - * @desc Clones all b elements (and selects the clones) and prepends them to all paragraphs. - * - * @name clone - * @type jQuery - * @param Boolean deep (Optional) Set to false if you don't want to clone all descendant nodes, in addition to the element itself. - * @cat DOM/Manipulation - */ clone: function(deep) { deep = deep != undefined ? deep : true; var $this = this.add(this.find("*")); @@ -920,46 +271,6 @@ jQuery.fn = jQuery.prototype = { return r; }, - /** - * Removes all elements from the set of matched elements that do not - * match the specified expression(s). This method is used to narrow down - * the results of a search. - * - * Provide a comma-separated list of expressions to apply multiple filters at once. - * - * @example $("p").filter(".selected") - * @before

    Hello

    How are you?

    - * @result [

    Hello

    ] - * @desc Selects all paragraphs and removes those without a class "selected". - * - * @example $("p").filter(".selected, :first") - * @before

    Hello

    Hello Again

    And Again

    - * @result [

    Hello

    ,

    And Again

    ] - * @desc Selects all paragraphs and removes those without class "selected" and being the first one. - * - * @name filter - * @type jQuery - * @param String expression Expression(s) to search with. - * @cat DOM/Traversing - */ - - /** - * Removes all elements from the set of matched elements that do not - * pass the specified filter. This method is used to narrow down - * the results of a search. - * - * @example $("p").filter(function(index) { - * return $("ol", this).length == 0; - * }) - * @before

    1. Hello

    How are you?

    - * @result [

    How are you?

    ] - * @desc Remove all elements that have a child ol element - * - * @name filter - * @type jQuery - * @param Function filter A function to use for filtering - * @cat DOM/Traversing - */ filter: function(t) { return this.pushStack( jQuery.isFunction( t ) && @@ -970,55 +281,6 @@ jQuery.fn = jQuery.prototype = { jQuery.multiFilter(t,this) ); }, - /** - * Removes the specified Element from the set of matched elements. This - * method is used to remove a single Element from a jQuery object. - * - * @example $("p").not( $("#selected")[0] ) - * @before

    Hello

    Hello Again

    - * @result [

    Hello

    ] - * @desc Removes the element with the ID "selected" from the set of all paragraphs. - * - * @name not - * @type jQuery - * @param Element el An element to remove from the set - * @cat DOM/Traversing - */ - - /** - * Removes elements matching the specified expression from the set - * of matched elements. This method is used to remove one or more - * elements from a jQuery object. - * - * @example $("p").not("#selected") - * @before

    Hello

    Hello Again

    - * @result [

    Hello

    ] - * @desc Removes the element with the ID "selected" from the set of all paragraphs. - * - * @name not - * @type jQuery - * @param String expr An expression with which to remove matching elements - * @cat DOM/Traversing - */ - - /** - * Removes any elements inside the array of elements from the set - * of matched elements. This method is used to remove one or more - * elements from a jQuery object. - * - * Please note: the expression cannot use a reference to the - * element name. See the two examples below. - * - * @example $("p").not( $("div p.selected") ) - * @before

    Hello

    Hello Again

    - * @result [

    Hello

    ] - * @desc Removes all elements that match "div p.selected" from the total set of all paragraphs. - * - * @name not - * @type jQuery - * @param jQuery elems A set of elements to remove from the jQuery set of matched elements. - * @cat DOM/Traversing - */ not: function(t) { return this.pushStack( t.constructor == String && @@ -1032,54 +294,6 @@ jQuery.fn = jQuery.prototype = { ); }, - /** - * Adds more elements, matched by the given expression, - * to the set of matched elements. - * - * @example $("p").add("span") - * @before (HTML)

    Hello

    Hello Again - * @result (jQuery object matching 2 elements) [

    Hello

    , Hello Again ] - * @desc Compare the above result to the result of $('p'), - * which would just result in [

    Hello

    ]
    . - * Using add(), matched elements of $('span') are simply - * added to the returned jQuery-object. - * - * @name add - * @type jQuery - * @param String expr An expression whose matched elements are added - * @cat DOM/Traversing - */ - - /** - * Adds more elements, created on the fly, to the set of - * matched elements. - * - * @example $("p").add("Again") - * @before

    Hello

    - * @result [

    Hello

    , Again ] - * - * @name add - * @type jQuery - * @param String html A string of HTML to create on the fly. - * @cat DOM/Traversing - */ - - /** - * Adds one or more Elements to the set of matched elements. - * - * @example $("p").add( document.getElementById("a") ) - * @before

    Hello

    Hello Again

    - * @result [

    Hello

    , Hello Again ] - * - * @example $("p").add( document.forms[0].elements ) - * @before

    Hello