Commit fa39282e authored by Dries's avatar Dries

- Patch #1056108 by 1V: consistent use of 'JavaScript' and 'Ajax'.

parent 7205ff14
......@@ -19,7 +19,7 @@ Drupal 7
Component maintainers
---------------------
AJAX system
Ajax system
- Alex Bronstein 'effulgentsia' <http://drupal.org/user/78040>
- Randy Fay 'rfay' <http://drupal.org/user/30906>
- Earl Miles 'merlinofchaos' <http://drupal.org/user/26979>
......
......@@ -3,15 +3,15 @@
/**
* @file
* Functions for use with Drupal's AJAX framework.
* Functions for use with Drupal's Ajax framework.
*/
/**
* @defgroup ajax AJAX framework
* @defgroup ajax Ajax framework
* @{
* Functions for Drupal's AJAX framework.
* Functions for Drupal's Ajax framework.
*
* Drupal's AJAX framework is used to dynamically update parts of a page's HTML
* Drupal's Ajax framework is used to dynamically update parts of a page's HTML
* based on data from the server. Upon a specified event, such as a button
* click, a callback function is triggered which performs server-side logic and
* may return updated markup, which is then replaced on-the-fly with no page
......@@ -20,33 +20,33 @@
* This framework creates a PHP macro language that allows the server to
* instruct JavaScript to perform actions on the client browser. When using
* forms, it can be used with the #ajax property.
* The #ajax property can be used to bind events to the AJAX framework. By
* The #ajax property can be used to bind events to the Ajax framework. By
* default, #ajax uses 'system/ajax' as its path for submission and thus calls
* ajax_form_callback() and a defined #ajax['callback'] function.
* However, you may optionally specify a different path to request or a
* different callback function to invoke, which can return updated HTML or can
* also return a richer set of @link ajax_commands AJAX framework commands @endlink.
* also return a richer set of @link ajax_commands Ajax framework commands @endlink.
*
* Standard form handling is as follows:
* - A form element has a #ajax property that includes #ajax['callback'] and
* omits #ajax['path']. See below about using #ajax['path'] to implement
* advanced use-cases that require something other than standard form
* handling.
* - On the specified element, AJAX processing is triggered by a change to
* - On the specified element, Ajax processing is triggered by a change to
* that element.
* - The browser submits an HTTP POST request to the 'system/ajax' Drupal
* path.
* - The menu page callback for 'system/ajax', ajax_form_callback(), calls
* drupal_process_form() to process the form submission and rebuild the
* form if necessary. The form is processed in much the same way as if it
* were submitted without AJAX, with the same #process functions and
* were submitted without Ajax, with the same #process functions and
* validation and submission handlers called in either case, making it easy
* to create AJAX-enabled forms that degrade gracefully when JavaScript is
* to create Ajax-enabled forms that degrade gracefully when JavaScript is
* disabled.
* - After form processing is complete, ajax_form_callback() calls the
* function named by #ajax['callback'], which returns the form element that
* has been updated and needs to be returned to the browser, or
* alternatively, an array of custom AJAX commands.
* alternatively, an array of custom Ajax commands.
* - The page delivery callback for 'system/ajax', ajax_deliver(), renders the
* element returned by #ajax['callback'], and returns the JSON string
* created by ajax_render() to the browser.
......@@ -57,7 +57,7 @@
* #ajax['callback'], using a JavaScript animation effect specified by
* #ajax['effect'].
*
* A simple example of basic AJAX use from the
* A simple example of basic Ajax use from the
* @link http://drupal.org/project/examples Examples module @endlink follows:
* @code
* function main_page() {
......@@ -99,28 +99,28 @@
* }
* @endcode
*
* In the above example, the 'changethis' element is AJAX-enabled. The default
* In the above example, the 'changethis' element is Ajax-enabled. The default
* #ajax['event'] is 'change', so when the 'changethis' element changes,
* an AJAX call is made. The form is submitted and reprocessed, and then the
* an Ajax call is made. The form is submitted and reprocessed, and then the
* callback is called. In this case, the form has been automatically
* built changing $form['replace_textfield']['#description'], so the callback
* just returns that part of the form.
*
* To implement AJAX handling in a form, add '#ajax' to the form
* definition of a field. That field will trigger an AJAX event when it is
* To implement Ajax handling in a form, add '#ajax' to the form
* definition of a field. That field will trigger an Ajax event when it is
* clicked (or changed, depending on the kind of field). #ajax supports
* the following parameters (either 'path' or 'callback' is required at least):
* - #ajax['callback']: The callback to invoke to handle the server side of the
* AJAX event, which will receive a $form and $form_state as arguments, and
* Ajax event, which will receive a $form and $form_state as arguments, and
* returns a renderable array (most often a form or form fragment), an HTML
* string, or an array of AJAX commands. If returning a renderable array or
* string, or an array of Ajax commands. If returning a renderable array or
* a string, the value will replace the original element named in
* #ajax['wrapper'], and
* theme_status_messages()
* will be prepended to that
* element. (If the status messages are not wanted, return an array
* of AJAX commands instead.)
* #ajax['wrapper']. If an array of AJAX commands is returned, it will be
* of Ajax commands instead.)
* #ajax['wrapper']. If an array of Ajax commands is returned, it will be
* executed by the calling code.
* - #ajax['path']: The menu path to use for the request. This is often omitted
* and the default is used. This path should map
......@@ -155,21 +155,21 @@
* More information is available in the
* @link http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7 Form API Reference @endlink
*
* In addition to using Form API for doing in-form modification, AJAX may be
* In addition to using Form API for doing in-form modification, Ajax may be
* enabled by adding classes to buttons and links. By adding the 'use-ajax'
* class to a link, the link will be loaded via an AJAX call. When using this
* class to a link, the link will be loaded via an Ajax call. When using this
* method, the href of the link can contain '/nojs/' as part of the path. When
* the AJAX framework makes the request, it will convert this to '/ajax/'.
* the Ajax framework makes the request, it will convert this to '/ajax/'.
* The server is then able to easily tell if this request was made through an
* actual AJAX request or in a degraded state, and respond appropriately.
* actual Ajax request or in a degraded state, and respond appropriately.
*
* Similarly, submit buttons can be given the class 'use-ajax-submit'. The
* form will then be submitted via AJAX to the path specified in the #action.
* form will then be submitted via Ajax to the path specified in the #action.
* Like the ajax-submit class above, this path will have '/nojs/' replaced with
* '/ajax/' so that the submit handler can tell if the form was submitted
* in a degraded state or not.
*
* When responding to AJAX requests, the server should do what it needs to do
* When responding to Ajax requests, the server should do what it needs to do
* for that request, then create a commands array. This commands array will
* be converted to a JSON object and returned to the client, which will then
* iterate over the array and process it like a macro language.
......@@ -189,14 +189,14 @@
* // Add a visual "changed" marker to the '#object-1' element.
* $commands[] = ajax_command_changed('#object-1');
* // Menu 'page callback' and #ajax['callback'] functions are supposed to
* // return render arrays. If returning an AJAX commands array, it must be
* // return render arrays. If returning an Ajax commands array, it must be
* // encapsulated in a render array structure.
* return array('#type' => 'ajax', '#commands' => $commands);
* @endcode
*
* When returning an AJAX command array, it is often useful to have
* When returning an Ajax command array, it is often useful to have
* status messages rendered along with other tasks in the command array.
* In that case the the AJAX commands array may be constructed like this:
* In that case the the Ajax commands array may be constructed like this:
* @code
* $commands = array();
* $commands[] = ajax_command_replace(NULL, $output);
......@@ -204,7 +204,7 @@
* return array('#type' => 'ajax', '#commands' => $commands);
* @endcode
*
* See @link ajax_commands AJAX framework commands @endlink
* See @link ajax_commands Ajax framework commands @endlink
*/
/**
......@@ -215,7 +215,7 @@
* functions.
*/
function ajax_render($commands = array()) {
// AJAX responses aren't rendered with html.tpl.php, so we have to call
// Ajax responses aren't rendered with html.tpl.php, so we have to call
// drupal_get_css() and drupal_get_js() here, in order to have new files added
// during this request to be loaded by the page. We only want to send back
// files that the page hasn't already loaded, so we implement simple diffing
......@@ -235,7 +235,7 @@ function ajax_render($commands = array()) {
// @todo Inline CSS and JS items are indexed numerically. These can't be
// reliably diffed with array_diff_key(), since the number can change
// due to factors unrelated to the inline content, so for now, we strip
// the inline items from AJAX responses, and can add support for them
// the inline items from Ajax responses, and can add support for them
// when drupal_add_css() and drupal_add_js() are changed to using md5()
// or some other hash of the inline content.
foreach ($items[$type] as $key => $item) {
......@@ -251,14 +251,14 @@ function ajax_render($commands = array()) {
// Settings are handled separately, later in this function, so that changes to
// the ajaxPageState setting that occur during drupal_get_css() and
// drupal_get_js() get included, and because the jQuery.extend() code produced
// by drupal_get_js() for adding settings isn't appropriate during an AJAX
// by drupal_get_js() for adding settings isn't appropriate during an Ajax
// response, because it does not pass TRUE for the "deep" parameter, and
// therefore, can clobber existing settings on the page.
if (isset($items['js']['settings'])) {
unset($items['js']['settings']);
}
// Render the HTML to load these files, and add AJAX commands to insert this
// Render the HTML to load these files, and add Ajax commands to insert this
// HTML in the page. We pass TRUE as the $skip_alter argument to prevent the
// data from being altered again, as we already altered it above.
$styles = drupal_get_css($items['css'], TRUE);
......@@ -287,16 +287,16 @@ function ajax_render($commands = array()) {
array_unshift($commands, ajax_command_settings(call_user_func_array('array_merge_recursive', $settings['data']), TRUE));
}
// Allow modules to alter any AJAX response.
// Allow modules to alter any Ajax response.
drupal_alter('ajax_render', $commands);
return drupal_json_encode($commands);
}
/**
* Get a form submitted via #ajax during an AJAX callback.
* Get a form submitted via #ajax during an Ajax callback.
*
* This will load a form from the form cache used during AJAX operations. It
* This will load a form from the form cache used during Ajax operations. It
* pulls the form info from $_POST.
*
* @return
......@@ -326,7 +326,7 @@ function ajax_get_form() {
// Since some of the submit handlers are run, redirects need to be disabled.
$form_state['no_redirect'] = TRUE;
// When a form is rebuilt after AJAX processing, its #build_id and #action
// When a form is rebuilt after Ajax processing, its #build_id and #action
// should not change.
// @see drupal_rebuild_form()
$form_state['rebuild_info']['copy']['#build_id'] = TRUE;
......@@ -341,10 +341,10 @@ function ajax_get_form() {
}
/**
* Menu callback; handles AJAX requests for the #ajax Form API property.
* Menu callback; handles Ajax requests for the #ajax Form API property.
*
* This rebuilds the form from cache and invokes the defined #ajax['callback']
* to return an AJAX command structure for JavaScript. In case no 'callback' has
* to return an Ajax command structure for JavaScript. In case no 'callback' has
* been defined, nothing will happen.
*
* The Form API #ajax property can be set both for buttons and other input
......@@ -361,9 +361,9 @@ function ajax_form_callback() {
// We need to return the part of the form (or some other content) that needs
// to be re-rendered so the browser can update the page with changed content.
// Since this is the generic menu callback used by many AJAX elements, it is
// Since this is the generic menu callback used by many Ajax elements, it is
// up to the #ajax['callback'] function of the element (may or may not be a
// button) that triggered the AJAX request to determine what needs to be
// button) that triggered the Ajax request to determine what needs to be
// rendered.
if (!empty($form_state['triggering_element'])) {
$callback = $form_state['triggering_element']['#ajax']['callback'];
......@@ -374,21 +374,21 @@ function ajax_form_callback() {
}
/**
* Theme callback for AJAX requests.
* Theme callback for Ajax requests.
*
* Many different pages can invoke an AJAX request to system/ajax or another
* generic AJAX path. It is almost always desired for an AJAX response to be
* Many different pages can invoke an Ajax request to system/ajax or another
* generic Ajax path. It is almost always desired for an Ajax response to be
* rendered using the same theme as the base page, because most themes are built
* with the assumption that they control the entire page, so if the CSS for two
* themes are both loaded for a given page, they may conflict with each other.
* For example, Bartik is Drupal's default theme, and Seven is Drupal's default
* administration theme. Depending on whether the "Use the administration theme
* when editing or creating content" checkbox is checked, the node edit form may
* be displayed in either theme, but the AJAX response to the Field module's
* be displayed in either theme, but the Ajax response to the Field module's
* "Add another item" button should be rendered using the same theme as the rest
* of the page. Therefore, system_menu() sets the 'theme callback' for
* 'system/ajax' to this function, and it is recommended that modules
* implementing other generic AJAX paths do the same.
* implementing other generic Ajax paths do the same.
*/
function ajax_base_page_theme() {
if (!empty($_POST['ajax_page_state']['theme']) && !empty($_POST['ajax_page_state']['theme_token'])) {
......@@ -407,9 +407,9 @@ function ajax_base_page_theme() {
}
/**
* Package and send the result of a page callback to the browser as an AJAX response.
* Package and send the result of a page callback to the browser as an Ajax response.
*
* This function is the equivalent of drupal_deliver_html_page(), but for AJAX
* This function is the equivalent of drupal_deliver_html_page(), but for Ajax
* requests. Like that function, it:
* - Adds needed HTTP headers.
* - Prints rendered output.
......@@ -473,7 +473,7 @@ function ajax_deliver($page_callback_result) {
}
/**
* Converts the return value of a page callback into an AJAX commands array.
* Converts the return value of a page callback into an Ajax commands array.
*
* @param $page_callback_result
* The result of a page callback. Can be one of:
......@@ -483,13 +483,13 @@ function ajax_deliver($page_callback_result) {
* - A renderable array of content.
*
* @return
* An AJAX commands array that can be passed to ajax_render().
* An Ajax commands array that can be passed to ajax_render().
*/
function ajax_prepare_response($page_callback_result) {
$commands = array();
if (!isset($page_callback_result)) {
// Simply delivering an empty commands array is sufficient. This results
// in the AJAX request being completed, but nothing being done to the page.
// in the Ajax request being completed, but nothing being done to the page.
}
elseif (is_int($page_callback_result)) {
switch ($page_callback_result) {
......@@ -508,7 +508,7 @@ function ajax_prepare_response($page_callback_result) {
}
}
elseif (is_array($page_callback_result) && isset($page_callback_result['#type']) && ($page_callback_result['#type'] == 'ajax')) {
// Complex AJAX callbacks can return a result that contains an error message
// Complex Ajax callbacks can return a result that contains an error message
// or a specific set of commands to send to the browser.
$page_callback_result += element_info('ajax');
$error = $page_callback_result['#error'];
......@@ -523,7 +523,7 @@ function ajax_prepare_response($page_callback_result) {
}
}
else {
// Like normal page callbacks, simple AJAX callbacks can return HTML
// Like normal page callbacks, simple Ajax callbacks can return HTML
// content, as a string or render array. This HTML is inserted in some
// relationship to #ajax['wrapper'], as determined by which jQuery DOM
// manipulation method is used. The method used is specified by
......@@ -532,7 +532,7 @@ function ajax_prepare_response($page_callback_result) {
$html = is_string($page_callback_result) ? $page_callback_result : drupal_render($page_callback_result);
$commands[] = ajax_command_insert(NULL, $html);
// Add the status messages inside the new content's wrapper element, so that
// on subsequent AJAX requests, it is treated as old content.
// on subsequent Ajax requests, it is treated as old content.
$commands[] = ajax_command_prepend(NULL, theme('status_messages'));
}
......@@ -540,16 +540,16 @@ function ajax_prepare_response($page_callback_result) {
}
/**
* Perform end-of-AJAX-request tasks.
* Perform end-of-Ajax-request tasks.
*
* This function is the equivalent of drupal_page_footer(), but for AJAX
* This function is the equivalent of drupal_page_footer(), but for Ajax
* requests.
*
* @see drupal_page_footer()
*/
function ajax_footer() {
// Even for AJAX requests, invoke hook_exit() implementations. There may be
// modules that need very fast AJAX responses, and therefore, run AJAX
// Even for Ajax requests, invoke hook_exit() implementations. There may be
// modules that need very fast Ajax responses, and therefore, run Ajax
// requests with an early bootstrap.
if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL && (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'update')) {
module_invoke_all('exit');
......@@ -582,10 +582,10 @@ function ajax_process_form($element, &$form_state) {
}
/**
* Add AJAX information about an element to the page to communicate with JavaScript.
* Add Ajax information about an element to the page to communicate with JavaScript.
*
* If #ajax['path'] is set on an element, this additional JavaScript is added
* to the page header to attach the AJAX behaviors. See ajax.js for more
* to the page header to attach the Ajax behaviors. See ajax.js for more
* information.
*
* @param $element
......@@ -622,9 +622,9 @@ function ajax_pre_render_element($element) {
case 'image_button':
// Use the mousedown instead of the click event because form
// submission via pressing the enter key triggers a click event on
// submit inputs, inappropriately triggering AJAX behaviors.
// submit inputs, inappropriately triggering Ajax behaviors.
$element['#ajax']['event'] = 'mousedown';
// Attach an additional event handler so that AJAX behaviors
// Attach an additional event handler so that Ajax behaviors
// can be triggered still via keyboard input.
$element['#ajax']['keypress'] = TRUE;
break;
......@@ -673,7 +673,7 @@ function ajax_pre_render_element($element) {
unset($settings['path'], $settings['options']);
// Add special data to $settings['submit'] so that when this element
// triggers an AJAX submission, Drupal's form processing can determine which
// triggers an Ajax submission, Drupal's form processing can determine which
// element triggered it.
// @see _form_element_triggered_scripted_submission()
if (isset($settings['trigger_as'])) {
......@@ -716,7 +716,7 @@ function ajax_pre_render_element($element) {
'data' => array('ajax' => array($element['#id'] => $settings)),
);
// Indicate that AJAX processing was successful.
// Indicate that Ajax processing was successful.
$element['#ajax_processed'] = TRUE;
}
return $element;
......@@ -727,16 +727,16 @@ function ajax_pre_render_element($element) {
*/
/**
* @defgroup ajax_commands AJAX framework commands
* @defgroup ajax_commands Ajax framework commands
* @{
* Functions to create various AJAX commands.
* Functions to create various Ajax commands.
*
* These functions can be used to create arrays for use with the
* ajax_render() function.
*/
/**
* Creates a Drupal AJAX 'alert' command.
* Creates a Drupal Ajax 'alert' command.
*
* The 'alert' command instructs the client to display a JavaScript alert
* dialog box.
......@@ -758,7 +758,7 @@ function ajax_command_alert($text) {
}
/**
* Creates a Drupal AJAX 'insert' command using the method in #ajax['method'].
* Creates a Drupal Ajax 'insert' command using the method in #ajax['method'].
*
* This command instructs the client to insert the given HTML using whichever
* jQuery DOM manipulation method has been specified in the #ajax['method']
......@@ -789,7 +789,7 @@ function ajax_command_insert($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'insert/replaceWith' command.
* Creates a Drupal Ajax 'insert/replaceWith' command.
*
* The 'insert/replaceWith' command instructs the client to use jQuery's
* replaceWith() method to replace each element matched matched by the given
......@@ -822,7 +822,7 @@ function ajax_command_replace($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'insert/html' command.
* Creates a Drupal Ajax 'insert/html' command.
*
* The 'insert/html' command instructs the client to use jQuery's html()
* method to set the HTML content of each element matched by the given
......@@ -855,7 +855,7 @@ function ajax_command_html($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'insert/prepend' command.
* Creates a Drupal Ajax 'insert/prepend' command.
*
* The 'insert/prepend' command instructs the client to use jQuery's prepend()
* method to prepend the given HTML content to the inside each element matched
......@@ -888,7 +888,7 @@ function ajax_command_prepend($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'insert/append' command.
* Creates a Drupal Ajax 'insert/append' command.
*
* The 'insert/append' command instructs the client to use jQuery's append()
* method to append the given HTML content to the inside of each element matched
......@@ -921,7 +921,7 @@ function ajax_command_append($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'insert/after' command.
* Creates a Drupal Ajax 'insert/after' command.
*
* The 'insert/after' command instructs the client to use jQuery's after()
* method to insert the given HTML content after each element matched by
......@@ -954,7 +954,7 @@ function ajax_command_after($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'insert/before' command.
* Creates a Drupal Ajax 'insert/before' command.
*
* The 'insert/before' command instructs the client to use jQuery's before()
* method to insert the given HTML content before each of elements matched by
......@@ -987,7 +987,7 @@ function ajax_command_before($selector, $html, $settings = NULL) {
}
/**
* Creates a Drupal AJAX 'remove' command.
* Creates a Drupal Ajax 'remove' command.
*
* The 'remove' command instructs the client to use jQuery's remove() method
* to remove each of elements matched by the given selector, and everything
......@@ -1013,7 +1013,7 @@ function ajax_command_remove($selector) {
}
/**
* Creates a Drupal AJAX 'changed' command.
* Creates a Drupal Ajax 'changed' command.
*
* This command instructs the client to mark each of the elements matched by the
* given selector as 'ajax-changed'.
......@@ -1040,7 +1040,7 @@ function ajax_command_changed($selector, $asterisk = '') {
}
/**
* Creates a Drupal AJAX 'css' command.
* Creates a Drupal Ajax 'css' command.
*
* The 'css' command will instruct the client to use the jQuery css() method
* to apply the CSS arguments to elements matched by the given selector.
......@@ -1068,7 +1068,7 @@ function ajax_command_css($selector, $argument) {
}
/**
* Creates a Drupal AJAX 'settings' command.
* Creates a Drupal Ajax 'settings' command.
*
* The 'settings' command instructs the client either to use the given array as
* the settings for ajax-loaded content or to extend Drupal.settings with the
......@@ -1099,7 +1099,7 @@ function ajax_command_settings($argument, $merge = FALSE) {
}
/**
* Creates a Drupal AJAX 'data' command.
* Creates a Drupal Ajax 'data' command.
*
* The 'data' command instructs the client to attach the name=value pair of
* data to the selector via jQuery's data cache.
......@@ -1131,7 +1131,7 @@ function ajax_command_data($selector, $name, $value) {
}
/**
* Creates a Drupal AJAX 'invoke' command.
* Creates a Drupal Ajax 'invoke' command.
*
* The 'invoke' command will instruct the client to invoke the given jQuery
* method with the supplied arguments on the elements matched by the given
......@@ -1162,7 +1162,7 @@ function ajax_command_invoke($selector, $method, array $arguments = array()) {
}
/**
* Creates a Drupal AJAX 'restripe' command.
* Creates a Drupal Ajax 'restripe' command.
*
* The 'restripe' command instructs the client to restripe a table. This is
* usually used after a table has been modified by a replace or append command.
......
......@@ -31,7 +31,7 @@ function clear($cid = NULL, $wildcard = FALSE) {
// If there is a database cache, attempt to clear it whenever possible. The
// reason for doing this is that the database cache can accumulate data
// during installation due to any full bootstraps that may occur at the
// same time (for example, AJAX requests triggered by the installer). If we
// same time (for example, Ajax requests triggered by the installer). If we
// didn't try to clear it whenever this function is called, the data in the
// cache would become stale; for example, the installer sometimes calls
// variable_set(), which updates the {variable} table and then clears the
......
......@@ -2238,7 +2238,7 @@ function drupal_http_header_attributes(array $attributes = array()) {
* drupal_attributes(array('title' => t('<script>steal_cookie();</script>')));
*
* // The statement below demonstrates dangerous use of drupal_attributes, and
* // will return an onmouseout attribute with javascript code that, when used
* // will return an onmouseout attribute with JavaScript code that, when used
* // as attribute in a tag, will cause users to be redirected to another site.
* //
* // In this case, the 'onmouseout' attribute should not be whitelisted --
......@@ -2383,9 +2383,9 @@ function l($text, $path, array $options = array()) {
* basis in hook_page_delivery_callback_alter().
*
* For example, the same page callback function can be used for an HTML
* version of the page and an AJAX version of the page. The page callback
* version of the page and an Ajax version of the page. The page callback
* function just needs to decide what content is to be returned and the
* delivery callback function will send it as an HTML page or an AJAX
* delivery callback function will send it as an HTML page or an Ajax
* response, as appropriate.
*
* In order for page callbacks to be reusable in different delivery formats,
......@@ -3665,17 +3665,17 @@ function drupal_html_class($class) {
* blocks, and other content to be output multiple times on the same page,
* without breaking (X)HTML validation.
*
* For already existing ids, a counter is appended to the id string. Therefore,
* For already existing IDs, a counter is appended to the ID string. Therefore,
* JavaScript and CSS code should not rely on any value that was generated by
* this function and instead should rely on manually added CSS classes or
* similarly reliable constructs.
*
* Two consecutive hyphens separate the counter from the original id. To manage
* uniqueness across multiple AJAX requests on the same page, AJAX requests
* Two consecutive hyphens separate the counter from the original ID. To manage
* uniqueness across multiple Ajax requests on the same page, Ajax requests
* POST an array of all IDs currently present on the page, which are used to
* prime this function's cache upon first invocation.
*
* To allow reverse-parsing of ids submitted via AJAX, any multiple consecutive
* To allow reverse-parsing of IDs submitted via Ajax, any multiple consecutive
* hyphens in the originally passed $id are replaced with a single hyphen.
*
* @param $id
......@@ -3685,10 +3685,10 @@ function drupal_html_class($class) {
* The cleaned ID.
*/
function drupal_html_id($id) {
// If this is an AJAX request, then content returned by this page request will
// be merged with content already on the base page. The HTML ids must be
// If this is an Ajax request, then content returned by this page request will
// be merged with content already on the base page. The HTML IDs must be
// unique for the fully merged content. Therefore, initialize $seen_ids to
// take into account ids that are already in use on the base page.
// take into account IDs that are already in use on the base page.
$seen_ids_init = &drupal_static(__FUNCTION__ . ':init');
if (!isset($seen_ids_init)) {
// Ideally, Drupal would provide an API to persist state information about
......@@ -3696,7 +3696,7 @@ function drupal_html_id($id) {
// function's $seen_ids static variable to that state information in order
// to have it properly initialized for this page request. However, no such
// page state API exists, so instead, ajax.js adds all of the in-use HTML
// ids to the POST data of AJAX submissions. Direct use of $_POST is
// IDs to the POST data of Ajax submissions. Direct use of $_POST is
// normally not recommended as it could open up security risks, but because
// the raw POST data is cast to a number before being returned by this
// function, this usage is safe.
......@@ -3743,7 +3743,7 @@ function drupal_html_id($id) {
// The counter needs to be appended with a delimiter that does not exist in
// the base ID. Requiring a unique delimiter helps ensure that we really do
// return unique IDs and also helps us re-create the $seen_ids array during
// AJAX requests.
// Ajax requests.
if (isset($seen_ids[$id])) {
$id = $id . '--' . ++$seen_ids[$id];
}
......@@ -3761,7 +3761,7 @@ function drupal_html_id($id) {
* page region that is output by the theme (Drupal core already handles this in
* the standard template preprocess implementation). Standardizing the class
* names in this way allows modules to implement certain features, such as
* drag-and-drop or dynamic AJAX loading, in a theme-independent way.
* drag-and-drop or dynamic Ajax loading, in a theme-independent way.
*
* @param $region
* The name of the page region (for example, 'page_top' or 'content').
......@@ -3946,7 +3946,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
if (isset($data)) {
// Add jquery.js and drupal.js, as well as the basePath setting, the
// first time a Javascript file is added.
// first time a JavaScript file is added.
if (empty($javascript)) {
$javascript = array(
'settings' => array(
......@@ -3989,7 +3989,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
default: // 'file' and 'external'
// Local and external files must keep their name as the associative key
// so the same JavaScript file is not be added twice.
// so the same JavaScript file is not added twice.
$javascript[$options['data']] = $options;
}
}
......@@ -4087,13 +4087,13 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
// page request.
$default_query_string = variable_get('css_js_query_string', '0');
// For inline Javascript to validate as XHTML, all Javascript containing
// For inline JavaScript to validate as XHTML, all JavaScript containing
// XHTML needs to be wrapped in CDATA. To make that backwards compatible
// with HTML 4, we need to comment out the CDATA-tag.
$embed_prefix = "\n<!--//--><![CDATA[//><!--\n";
$embed_suffix = "\n//--><!]]>\n";
// Since Javascript may look for arguments in the url and act on them, some
// Since JavaScript may look for arguments in the URL and act on them, some
// third-party code might require the use of a different query string.
$js_version_string = variable_get('drupal_js_version_query_string', 'v=');
......@@ -4311,7 +4311,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
}
// Add additional types of attachments specified in the render() structure.
// Libraries, Javascript and CSS have been added already, as they require
// Libraries, JavaScript and CSS have been added already, as they require
// special handling.
foreach ($elements['#attached'] as $callback => $options) {
if (function_exists($callback)) {
......@@ -4778,7 +4778,7 @@ function drupal_clear_js_cache() {
}
/**
* Converts a PHP variable into its Javascript equivalent.
* Converts a PHP variable into its JavaScript equivalent.
*
* We use HTML-safe strings, i.e. with <, > and & escaped.
*
......@@ -5320,7 +5320,7 @@ function drupal_pre_render_link($element) {
if (!isset($element['#id'])) {
$element['#id'] = $element['#options']['attributes']['id'] = drupal_html_id('ajax-link');
}
// If #ajax['path] was not specified, use the href as AJAX request URL.
// If #ajax['path] was not specified, use the href as Ajax request URL.
if (!isset($element['#ajax']['path'])) {
$element['#ajax']['path'] = $element['#href'];
$element['#ajax']['options'] = $element['#options'];
......@@ -5839,7 +5839,7 @@ function drupal_render_cache_set(&$markup, $elements) {
/**
* Collect #attached for an element and all child elements into a single array.
*
* When caching elements, it is necessary to collect all libraries, javascript
* When caching elements, it is necessary to collect all libraries, JavaScript
* and CSS into a single array, from both the element itself and all child
* elements. This allows drupal_render() to add these back to the page when the
* element is returned from cache.
......
......@@ -128,9 +128,9 @@
* - 'triggering_element': (read-only) The form element that triggered
* submission. This is the same as the deprecated
* $form_state['clicked_button']. It is the element that caused submission,
* which may or may not be a button (in the case of AJAX forms.) This is
* which may or may not be a button (in the case of Ajax forms.) This is
* often used to distinguish between various buttons in a submit handler,
* and is also used in AJAX handlers.
* and is also used in Ajax handlers.
* - 'cache': The typical form workflow involves two page requests. During the
* first page request, a form is built and returned for the user to fill in.
* Then the user fills the form in and submits it, triggering a second page
......@@ -139,9 +139,9 @@
* In some special use-cases, it is necessary or desired to persist the $form
* and $form_state variables from the initial page request to the one that
* processes the submission. A form builder function can set 'cache' to TRUE
* to do this. One example where this is needed is to handle AJAX submissions,
* to do this. One example where this is needed is to handle Ajax submissions,
* so ajax_process_form() sets this for all forms that include an element with