diff --git a/core/misc/ajax.js b/core/misc/ajax.js index d599799..5b21376 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -1,9 +1,5 @@ -(function ($) { - -"use strict"; - /** - * Provides Ajax page updating via jQuery $.ajax (Asynchronous JavaScript and XML). + * @fileOverview JavaScript for Ajax page updating. * * Ajax is a method of making a request via JavaScript while viewing an HTML * page. The request returns an array of commands encoded in JSON, which is @@ -14,12 +10,24 @@ * to provide Ajax capabilities. */ +/** + * @lends Drupal + */ +(function ($) { + +"use strict"; + Drupal.ajax = Drupal.ajax || {}; /** * Attaches the Ajax behavior to each Ajax form element. + * + * @class */ Drupal.behaviors.AJAX = { + /** + * Attaches the behavior. + */ attach: function (context, settings) { // Load all Ajax behaviors specified in the settings. for (var base in settings.ajax) { @@ -71,7 +79,7 @@ Drupal.behaviors.AJAX = { }; /** - * Ajax object. + * Provides Ajax page updating via jQuery $.ajax. * * All Ajax objects on a page are accessible through the global Drupal.ajax * object and are keyed by the submit button's ID. You can access them from @@ -91,6 +99,8 @@ Drupal.behaviors.AJAX = { * } * }; * @endcode + * + * @class */ Drupal.ajax = function (base, element, element_settings) { var defaults = { @@ -189,7 +199,7 @@ Drupal.ajax = function (base, element, element_settings) { }; /** - * Handle a key press. + * Handles a key press. * * The Ajax object will, if instructed, bind to a key press response. This * will test to see if the key press is valid to trigger this event and @@ -213,7 +223,7 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) { }; /** - * Handle an event that triggers an Ajax response. + * Handles an event that triggers an Ajax response. * * When an event that triggers an Ajax response happens, this method will * perform the actual Ajax call. It is bound to the event using @@ -267,7 +277,7 @@ Drupal.ajax.prototype.eventResponse = function (element, event) { }; /** - * Handler for the form serialization. + * Preprocesses form serialization. * * Runs before the beforeSend() handler (see below), and unlike that one, runs * before field data is collected. @@ -306,7 +316,7 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) { }; /** - * Modify form values prior to form submission. + * Modifies form values prior to form submission. */ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { // This function is left empty to make it simple to override for modules @@ -314,7 +324,7 @@ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { }; /** - * Prepare the Ajax request before it is sent. + * Prepares the Ajax request before it is sent. */ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { // For forms without file inputs, the jQuery Form plugin serializes the form @@ -374,7 +384,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { }; /** - * Handler for the form redirection completion. + * Handles form redirection completion. */ Drupal.ajax.prototype.success = function (response, status) { // Remove the progress element. @@ -411,7 +421,7 @@ Drupal.ajax.prototype.success = function (response, status) { }; /** - * Build an effect object which tells us how to apply the effect when adding new HTML. + * Builds an effect object, telling what to do when adding new HTML. */ Drupal.ajax.prototype.getEffect = function (response) { var type = response.effect || this.effect; @@ -438,7 +448,7 @@ Drupal.ajax.prototype.getEffect = function (response) { }; /** - * Handler for the form redirection error. + * Handles form redirection errors. */ Drupal.ajax.prototype.error = function (response, uri) { alert(Drupal.ajaxError(response, uri)); @@ -461,11 +471,13 @@ Drupal.ajax.prototype.error = function (response, uri) { }; /** - * Provide a series of commands that the server can request the client perform. + * Provides a series of commands that the server can request the client perform. + * + * @class */ Drupal.ajax.prototype.commands = { /** - * Command to insert new content into the DOM. + * Inserts new content into the DOM. */ insert: function (ajax, response, status) { // Get information from the response. If it is not there, default to @@ -537,7 +549,7 @@ Drupal.ajax.prototype.commands = { }, /** - * Command to remove a chunk from the page. + * Removes a chunk from the page. */ remove: function (ajax, response, status) { var settings = response.settings || ajax.settings || Drupal.settings; @@ -546,7 +558,7 @@ Drupal.ajax.prototype.commands = { }, /** - * Command to mark a chunk changed. + * Marks a chunk changed. */ changed: function (ajax, response, status) { if (!$(response.selector).hasClass('ajax-changed')) { @@ -558,21 +570,21 @@ Drupal.ajax.prototype.commands = { }, /** - * Command to provide an alert. + * Provides an alert. */ alert: function (ajax, response, status) { alert(response.text, response.title); }, /** - * Command to provide the jQuery css() function. + * Povides the jQuery css() function. */ css: function (ajax, response, status) { $(response.selector).css(response.argument); }, /** - * Command to set the settings that will be used for other commands in this response. + * Sets the settings that will be used for other commands in this response. */ settings: function (ajax, response, status) { if (response.merge) { @@ -584,14 +596,14 @@ Drupal.ajax.prototype.commands = { }, /** - * Command to attach data using jQuery's data API. + * Attaches data using jQuery's data API. */ data: function (ajax, response, status) { $(response.selector).data(response.name, response.value); }, /** - * Command to apply a jQuery method. + * Applies a jQuery method. */ invoke: function (ajax, response, status) { var $element = $(response.selector); @@ -599,7 +611,7 @@ Drupal.ajax.prototype.commands = { }, /** - * Command to restripe a table. + * Restripes a table. */ restripe: function (ajax, response, status) { // :even and :odd are reversed because jQuery counts from 0 and diff --git a/core/misc/autocomplete.js b/core/misc/autocomplete.js index 8b0dd72..9ce147c 100644 --- a/core/misc/autocomplete.js +++ b/core/misc/autocomplete.js @@ -1,11 +1,23 @@ +/** + * @fileOverview JavaScript for autocomplete form fields. + */ + +/** + * @lends Drupal + */ (function ($) { "use strict"; /** * Attaches the autocomplete behavior to all required fields. + * + * @class */ Drupal.behaviors.autocomplete = { + /** + * Attaches the behavior. + */ attach: function (context, settings) { var acdb = []; $(context).find('input.autocomplete').once('autocomplete', function () { @@ -28,6 +40,8 @@ Drupal.behaviors.autocomplete = { }; /** + * Handles submission of the autocomplete form. + * * Prevents the form from submitting if the suggestions popup is open * and closes the suggestions popup when doing so. */ @@ -40,7 +54,9 @@ Drupal.autocompleteSubmit = function () { }; /** - * An AutoComplete object. + * Represents an autocomplete object. + * + * @class */ Drupal.jsAC = function ($input, db) { var ac = this; @@ -55,7 +71,7 @@ Drupal.jsAC = function ($input, db) { }; /** - * Handler for the "keydown" event. + * Handles the "keydown" event. */ Drupal.jsAC.prototype.onkeydown = function (input, e) { if (!e) { @@ -74,7 +90,7 @@ Drupal.jsAC.prototype.onkeydown = function (input, e) { }; /** - * Handler for the "keyup" event. + * Handles the "keyup" event. */ Drupal.jsAC.prototype.onkeyup = function (input, e) { if (!e) { @@ -246,6 +262,9 @@ Drupal.jsAC.prototype.found = function (matches) { } }; +/** + * Sets the status. + */ Drupal.jsAC.prototype.setStatus = function (status) { switch (status) { case 'begin': @@ -261,7 +280,9 @@ Drupal.jsAC.prototype.setStatus = function (status) { }; /** - * An AutoComplete DataBase object. + * Represents an autocomplete database object. + * + * @class */ Drupal.ACDB = function (uri) { this.uri = uri; diff --git a/core/misc/drupal.js b/core/misc/drupal.js index 75767d5..083d222 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -1,10 +1,40 @@ -var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} }; +/** + * @fileOverview Defines the base Drupal JavaScript object. + */ + +/** + * Holds JavaScript settings and other information for Drupal. + * + * @class + */ +var Drupal = Drupal || /** @lends Drupal */ { + /** + * Holds settings for Drupal. + * @class + */ + 'settings': {}, + + /** + * Holds behaviors for Drupal. + * @class + */ + 'behaviors': {}, + + /** + * Holds locale information for Drupal. + * @class + */ +'locale': {} +}; // Allow other JavaScript libraries to use $. jQuery.noConflict(); // JavaScript should be made compatible with libraries other than jQuery by // wrapping it in an anonymous closure. +/** + * @lends Drupal + */ (function ($, Drupal, window, document, undefined) { "use strict";