diff --git a/core/misc/message.js b/core/misc/message.js index c17325c..b401ebc 100644 --- a/core/misc/message.js +++ b/core/misc/message.js @@ -1,5 +1,7 @@ /** + * @file * + * Message API. */ (function (Drupal, debounce) { @@ -9,8 +11,7 @@ var messagesElement; /** - * Builds a div element with the aria-live attribute and attaches it - * to the DOM. + * Builds a div element with the aria-live attribute and attaches it to the DOM. */ Drupal.behaviors.drupalMessage = { attach: function () { @@ -23,7 +24,10 @@ } }; - + /** + * Display all queued messages in one pass instead of one after the other. + * @see debouncedProcessMessages + */ function processMessages () { var text = []; var message; @@ -41,6 +45,15 @@ // Debounce the function in case Drupal.message() is used in a loop. var debouncedProcessMessages = debounce(processMessages, 100); + /** + * Display a message on the page. + * + * @param message + * The message to display + * @param type + * Message type, can be either 'status', 'error' or 'warning'. + * Default to 'status' + */ Drupal.message = function (message, type) { // Save the text and priority into a closure variable. Multiple simultaneous // announcements will be concatenated and read in sequence. @@ -51,6 +64,16 @@ debouncedProcessMessages(messages); }; + /** + * Theme function for a message. + * + * @param message + * An object with the following keys: + * - text: The message text + * - type: The message type + * @return + * This function return a string. + */ Drupal.theme.message = function (message) { return '
' + message.text + '
'; };