diff --git a/core/misc/ajax.js b/core/misc/ajax.js index d599799..7917413 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). + * @file 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. + * + * @namespace */ 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,10 @@ Drupal.behaviors.AJAX = { }; /** - * Ajax object. + * Constructs an Ajax object. + * + * @class + * @classdesc 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 @@ -189,7 +200,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 +224,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 +278,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 +317,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 +325,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 +385,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 +422,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 +449,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 +472,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 +550,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 +559,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 +571,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 +597,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 +612,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..a6a6f81 100644 --- a/core/misc/autocomplete.js +++ b/core/misc/autocomplete.js @@ -1,11 +1,23 @@ +/** + * @file JavaScript for autocomplete form fields. + */ + +/** + * @lends Drupal + */ (function ($) { "use strict"; /** * Attaches the autocomplete behavior to all required fields. + * + * @namespace */ 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,10 @@ Drupal.autocompleteSubmit = function () { }; /** - * An AutoComplete object. + * Constructs an autocomplete object. + * + * @class + * @classdesc Represents an autocomplete object. */ Drupal.jsAC = function ($input, db) { var ac = this; @@ -55,7 +72,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 +91,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 +263,9 @@ Drupal.jsAC.prototype.found = function (matches) { } }; +/** + * Sets the status. + */ Drupal.jsAC.prototype.setStatus = function (status) { switch (status) { case 'begin': @@ -261,7 +281,10 @@ Drupal.jsAC.prototype.setStatus = function (status) { }; /** - * An AutoComplete DataBase object. + * Constructs an autocomplete database object. + * + * @class + * @classdesc Represents an autocomplete database object. */ Drupal.ACDB = function (uri) { this.uri = uri; diff --git a/core/misc/drupal.js b/core/misc/drupal.js index 75767d5..8f31d4b 100644 --- a/core/misc/drupal.js +++ b/core/misc/drupal.js @@ -1,10 +1,40 @@ -var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} }; +/** + * @file Defines the base Drupal JavaScript object. + */ + +/** + * Holds JavaScript settings and other information for Drupal. + * + * @namespace + */ +var Drupal = Drupal || /** @lends Drupal */ { + /** + * Holds settings for Drupal. + * @namespace + */ + 'settings': {}, + + /** + * Holds behaviors for Drupal. + * @namespace + */ + 'behaviors': {}, + + /** + * Holds locale information for Drupal. + * @namespace + */ +'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";