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 ...@@ -19,7 +19,7 @@ Drupal 7
Component maintainers Component maintainers
--------------------- ---------------------
AJAX system Ajax system
- Alex Bronstein 'effulgentsia' <http://drupal.org/user/78040> - Alex Bronstein 'effulgentsia' <http://drupal.org/user/78040>
- Randy Fay 'rfay' <http://drupal.org/user/30906> - Randy Fay 'rfay' <http://drupal.org/user/30906>
- Earl Miles 'merlinofchaos' <http://drupal.org/user/26979> - Earl Miles 'merlinofchaos' <http://drupal.org/user/26979>
......
This diff is collapsed.
...@@ -31,7 +31,7 @@ function clear($cid = NULL, $wildcard = FALSE) { ...@@ -31,7 +31,7 @@ function clear($cid = NULL, $wildcard = FALSE) {
// If there is a database cache, attempt to clear it whenever possible. The // 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 // reason for doing this is that the database cache can accumulate data
// during installation due to any full bootstraps that may occur at the // 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 // 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 // cache would become stale; for example, the installer sometimes calls
// variable_set(), which updates the {variable} table and then clears the // variable_set(), which updates the {variable} table and then clears the
......
...@@ -2238,7 +2238,7 @@ function drupal_http_header_attributes(array $attributes = array()) { ...@@ -2238,7 +2238,7 @@ function drupal_http_header_attributes(array $attributes = array()) {
* drupal_attributes(array('title' => t('<script>steal_cookie();</script>'))); * drupal_attributes(array('title' => t('<script>steal_cookie();</script>')));
* *
* // The statement below demonstrates dangerous use of drupal_attributes, and * // 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. * // as attribute in a tag, will cause users to be redirected to another site.
* // * //
* // In this case, the 'onmouseout' attribute should not be whitelisted -- * // In this case, the 'onmouseout' attribute should not be whitelisted --
...@@ -2383,9 +2383,9 @@ function l($text, $path, array $options = array()) { ...@@ -2383,9 +2383,9 @@ function l($text, $path, array $options = array()) {
* basis in hook_page_delivery_callback_alter(). * basis in hook_page_delivery_callback_alter().
* *
* For example, the same page callback function can be used for an HTML * 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 * 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. * response, as appropriate.
* *
* In order for page callbacks to be reusable in different delivery formats, * In order for page callbacks to be reusable in different delivery formats,
...@@ -3665,17 +3665,17 @@ function drupal_html_class($class) { ...@@ -3665,17 +3665,17 @@ function drupal_html_class($class) {
* blocks, and other content to be output multiple times on the same page, * blocks, and other content to be output multiple times on the same page,
* without breaking (X)HTML validation. * 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 * 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 * this function and instead should rely on manually added CSS classes or
* similarly reliable constructs. * similarly reliable constructs.
* *
* Two consecutive hyphens separate the counter from the original id. To manage * Two consecutive hyphens separate the counter from the original ID. To manage
* uniqueness across multiple AJAX requests on the same page, AJAX requests * 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 * POST an array of all IDs currently present on the page, which are used to
* prime this function's cache upon first invocation. * 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. * hyphens in the originally passed $id are replaced with a single hyphen.
* *
* @param $id * @param $id
...@@ -3685,10 +3685,10 @@ function drupal_html_class($class) { ...@@ -3685,10 +3685,10 @@ function drupal_html_class($class) {
* The cleaned ID. * The cleaned ID.
*/ */
function drupal_html_id($id) { function drupal_html_id($id) {
// If this is an AJAX request, then content returned by this page request will // 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 // 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 // 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'); $seen_ids_init = &drupal_static(__FUNCTION__ . ':init');
if (!isset($seen_ids_init)) { if (!isset($seen_ids_init)) {
// Ideally, Drupal would provide an API to persist state information about // Ideally, Drupal would provide an API to persist state information about
...@@ -3696,7 +3696,7 @@ function drupal_html_id($id) { ...@@ -3696,7 +3696,7 @@ function drupal_html_id($id) {
// function's $seen_ids static variable to that state information in order // function's $seen_ids static variable to that state information in order
// to have it properly initialized for this page request. However, no such // 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 // 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 // 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 // the raw POST data is cast to a number before being returned by this
// function, this usage is safe. // function, this usage is safe.
...@@ -3743,7 +3743,7 @@ function drupal_html_id($id) { ...@@ -3743,7 +3743,7 @@ function drupal_html_id($id) {
// The counter needs to be appended with a delimiter that does not exist in // 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 // 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 // return unique IDs and also helps us re-create the $seen_ids array during
// AJAX requests. // Ajax requests.
if (isset($seen_ids[$id])) { if (isset($seen_ids[$id])) {
$id = $id . '--' . ++$seen_ids[$id]; $id = $id . '--' . ++$seen_ids[$id];
} }
...@@ -3761,7 +3761,7 @@ function drupal_html_id($id) { ...@@ -3761,7 +3761,7 @@ function drupal_html_id($id) {
* page region that is output by the theme (Drupal core already handles this in * page region that is output by the theme (Drupal core already handles this in
* the standard template preprocess implementation). Standardizing the class * the standard template preprocess implementation). Standardizing the class
* names in this way allows modules to implement certain features, such as * 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 * @param $region
* The name of the page region (for example, 'page_top' or 'content'). * The name of the page region (for example, 'page_top' or 'content').
...@@ -3946,7 +3946,7 @@ function drupal_add_js($data = NULL, $options = NULL) { ...@@ -3946,7 +3946,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
if (isset($data)) { if (isset($data)) {
// Add jquery.js and drupal.js, as well as the basePath setting, the // 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)) { if (empty($javascript)) {
$javascript = array( $javascript = array(
'settings' => array( 'settings' => array(
...@@ -3989,7 +3989,7 @@ function drupal_add_js($data = NULL, $options = NULL) { ...@@ -3989,7 +3989,7 @@ function drupal_add_js($data = NULL, $options = NULL) {
default: // 'file' and 'external' default: // 'file' and 'external'
// Local and external files must keep their name as the associative key // 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; $javascript[$options['data']] = $options;
} }
} }
...@@ -4087,13 +4087,13 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS ...@@ -4087,13 +4087,13 @@ function drupal_get_js($scope = 'header', $javascript = NULL, $skip_alter = FALS
// page request. // page request.
$default_query_string = variable_get('css_js_query_string', '0'); $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 // XHTML needs to be wrapped in CDATA. To make that backwards compatible
// with HTML 4, we need to comment out the CDATA-tag. // with HTML 4, we need to comment out the CDATA-tag.
$embed_prefix = "\n<!--//--><![CDATA[//><!--\n"; $embed_prefix = "\n<!--//--><![CDATA[//><!--\n";
$embed_suffix = "\n//--><!]]>\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. // third-party code might require the use of a different query string.
$js_version_string = variable_get('drupal_js_version_query_string', 'v='); $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 ...@@ -4311,7 +4311,7 @@ function drupal_process_attached($elements, $group = JS_DEFAULT, $dependency_che
} }
// Add additional types of attachments specified in the render() structure. // 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. // special handling.
foreach ($elements['#attached'] as $callback => $options) { foreach ($elements['#attached'] as $callback => $options) {
if (function_exists($callback)) { if (function_exists($callback)) {
...@@ -4778,7 +4778,7 @@ function drupal_clear_js_cache() { ...@@ -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. * We use HTML-safe strings, i.e. with <, > and & escaped.
* *
...@@ -5320,7 +5320,7 @@ function drupal_pre_render_link($element) { ...@@ -5320,7 +5320,7 @@ function drupal_pre_render_link($element) {
if (!isset($element['#id'])) { if (!isset($element['#id'])) {
$element['#id'] = $element['#options']['attributes']['id'] = drupal_html_id('ajax-link'); $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'])) { if (!isset($element['#ajax']['path'])) {
$element['#ajax']['path'] = $element['#href']; $element['#ajax']['path'] = $element['#href'];
$element['#ajax']['options'] = $element['#options']; $element['#ajax']['options'] = $element['#options'];
...@@ -5839,7 +5839,7 @@ function drupal_render_cache_set(&$markup, $elements) { ...@@ -5839,7 +5839,7 @@ function drupal_render_cache_set(&$markup, $elements) {
/** /**
* Collect #attached for an element and all child elements into a single array. * 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 * 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 * elements. This allows drupal_render() to add these back to the page when the
* element is returned from cache. * element is returned from cache.
......
...@@ -128,9 +128,9 @@ ...@@ -128,9 +128,9 @@
* - 'triggering_element': (read-only) The form element that triggered * - 'triggering_element': (read-only) The form element that triggered
* submission. This is the same as the deprecated * submission. This is the same as the deprecated
* $form_state['clicked_button']. It is the element that caused submission, * $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, * 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 * - '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. * 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 * Then the user fills the form in and submits it, triggering a second page
...@@ -139,9 +139,9 @@ ...@@ -139,9 +139,9 @@
* In some special use-cases, it is necessary or desired to persist the $form * 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 * 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 * 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 * so ajax_process_form() sets this for all forms that include an element with
* a #ajax property. (In AJAX, the handler has no way to build the form * a #ajax property. (In Ajax, the handler has no way to build the form
* itself, so must rely on the cached version created on each page load, so * itself, so must rely on the cached version created on each page load, so
* it's a classic example of this use case.) Note that the persistence of * it's a classic example of this use case.) Note that the persistence of
* $form and $form_state across successive submissions of a multi-step form * $form and $form_state across successive submissions of a multi-step form
...@@ -254,7 +254,7 @@ function drupal_get_form($form_id) { ...@@ -254,7 +254,7 @@ function drupal_get_form($form_id) {
* - must_validate: Ordinarily, a form is only validated once but there are * - must_validate: Ordinarily, a form is only validated once but there are
* times when a form is resubmitted internally and should be validated * times when a form is resubmitted internally and should be validated
* again. Setting this to TRUE will force that to happen. This is most * again. Setting this to TRUE will force that to happen. This is most
* likely to occur during AHAH or AJAX operations. * likely to occur during AHAH or Ajax operations.
* - temporary: An array holding temporary data accessible during the current * - temporary: An array holding temporary data accessible during the current
* page request only. It may be used to temporary save any data that doesn't * page request only. It may be used to temporary save any data that doesn't
* need to or shouldn't be cached during the whole form workflow, e.g. data * need to or shouldn't be cached during the whole form workflow, e.g. data
...@@ -396,9 +396,9 @@ function form_state_defaults() { ...@@ -396,9 +396,9 @@ function form_state_defaults() {
* function is called to generate a new $form, the next step in the form * function is called to generate a new $form, the next step in the form
* workflow, to be returned for rendering. * workflow, to be returned for rendering.
* *
* AJAX form submissions are almost always multi-step workflows, so that is one * Ajax form submissions are almost always multi-step workflows, so that is one
* common use-case during which form rebuilding occurs. See ajax_form_callback() * common use-case during which form rebuilding occurs. See ajax_form_callback()
* for more information about creating AJAX-enabled forms. * for more information about creating Ajax-enabled forms.
* *
* @param $form_id * @param $form_id
* The unique string identifying the desired form. If a function * The unique string identifying the desired form. If a function
...@@ -411,7 +411,7 @@ function form_state_defaults() { ...@@ -411,7 +411,7 @@ function form_state_defaults() {
* A keyed array containing the current state of the form. * A keyed array containing the current state of the form.
* @param $old_form * @param $old_form
* (optional) A previously built $form. Used to retain the #build_id and * (optional) A previously built $form. Used to retain the #build_id and
* #action properties in AJAX callbacks and similar partial form rebuilds. The * #action properties in Ajax callbacks and similar partial form rebuilds. The
* only properties copied from $old_form are the ones which both exist in * only properties copied from $old_form are the ones which both exist in
* $old_form and for which $form_state['rebuild_info']['copy'][PROPERTY] is * $old_form and for which $form_state['rebuild_info']['copy'][PROPERTY] is
* TRUE. If $old_form is not passed, the entire $form is rebuilt freshly. * TRUE. If $old_form is not passed, the entire $form is rebuilt freshly.
...@@ -427,7 +427,7 @@ function form_state_defaults() { ...@@ -427,7 +427,7 @@ function form_state_defaults() {
function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) { function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
$form = drupal_retrieve_form($form_id, $form_state); $form = drupal_retrieve_form($form_id, $form_state);
// If only parts of the form will be returned to the browser (e.g. AJAX or // If only parts of the form will be returned to the browser (e.g., Ajax or
// RIA clients), re-use the old #build_id to not require client-side code to // RIA clients), re-use the old #build_id to not require client-side code to
// manually update the hidden 'build_id' input element. // manually update the hidden 'build_id' input element.
// Otherwise, a new #build_id is generated, to not clobber the previous // Otherwise, a new #build_id is generated, to not clobber the previous
...@@ -441,7 +441,7 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) { ...@@ -441,7 +441,7 @@ function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
$form['#build_id'] = 'form-' . drupal_hash_base64(uniqid(mt_rand(), TRUE) . mt_rand()); $form['#build_id'] = 'form-' . drupal_hash_base64(uniqid(mt_rand(), TRUE) . mt_rand());
} }
// #action defaults to request_uri(), but in case of AJAX and other partial // #action defaults to request_uri(), but in case of Ajax and other partial
// rebuilds, the form is submitted to an alternate URL, and the original // rebuilds, the form is submitted to an alternate URL, and the original
// #action needs to be retained. // #action needs to be retained.
if (isset($old_form['#action']) && !empty($form_state['rebuild_info']['copy']['#action'])) { if (isset($old_form['#action']) && !empty($form_state['rebuild_info']['copy']['#action'])) {
...@@ -882,13 +882,13 @@ function drupal_process_form($form_id, &$form, &$form_state) { ...@@ -882,13 +882,13 @@ function drupal_process_form($form_id, &$form, &$form_state) {
// yet complete. A new $form needs to be constructed based on the changes // yet complete. A new $form needs to be constructed based on the changes
// made to $form_state during this request. Normally, a submit handler sets // made to $form_state during this request. Normally, a submit handler sets
// $form_state['rebuild'] if a fully executed form requires another step. // $form_state['rebuild'] if a fully executed form requires another step.
// However, for forms that have not been fully executed (e.g., AJAX // However, for forms that have not been fully executed (e.g., Ajax
// submissions triggered by non-buttons), there is no submit handler to set // submissions triggered by non-buttons), there is no submit handler to set
// $form_state['rebuild']. It would not make sense to redisplay the // $form_state['rebuild']. It would not make sense to redisplay the
// identical form without an error for the user to correct, so we also // identical form without an error for the user to correct, so we also
// rebuild error-free non-executed forms, regardless of // rebuild error-free non-executed forms, regardless of
// $form_state['rebuild']. // $form_state['rebuild'].
// @todo D8: Simplify this logic; considering AJAX and non-HTML front-ends, // @todo D8: Simplify this logic; considering Ajax and non-HTML front-ends,
// along with element-level #submit properties, it makes no sense to have // along with element-level #submit properties, it makes no sense to have
// divergent form execution based on whether the triggering element has // divergent form execution based on whether the triggering element has
// #executes_submit_callback set to TRUE. // #executes_submit_callback set to TRUE.
...@@ -1146,7 +1146,7 @@ function drupal_validate_form($form_id, &$form, &$form_state) { ...@@ -1146,7 +1146,7 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
* - If $form_state['no_redirect'] is TRUE, then the callback that originally * - If $form_state['no_redirect'] is TRUE, then the callback that originally
* built the form explicitly disallows any redirection, regardless of the * built the form explicitly disallows any redirection, regardless of the
* redirection value in $form_state['redirect']. For example, ajax_get_form() * redirection value in $form_state['redirect']. For example, ajax_get_form()
* defines $form_state['no_redirect'] when building a form in an AJAX * defines $form_state['no_redirect'] when building a form in an Ajax
* callback to prevent any redirection. $form_state['no_redirect'] should NOT * callback to prevent any redirection. $form_state['no_redirect'] should NOT
* be altered by form builder functions or form validation/submit handlers. * be altered by form builder functions or form validation/submit handlers.
* - If $form_state['programmed'] is TRUE, the form submission was usually * - If $form_state['programmed'] is TRUE, the form submission was usually
...@@ -1286,7 +1286,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) { ...@@ -1286,7 +1286,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) {
// If submit handlers won't run (due to the submission having been triggered // If submit handlers won't run (due to the submission having been triggered
// by an element whose #executes_submit_callback property isn't TRUE), then // by an element whose #executes_submit_callback property isn't TRUE), then
// it's safe to suppress all validation errors, and we do so by default, // it's safe to suppress all validation errors, and we do so by default,
// which is particularly useful during an AJAX submission triggered by a // which is particularly useful during an Ajax submission triggered by a
// non-button. An element can override this default by setting the // non-button. An element can override this default by setting the
// #limit_validation_errors property. For button element types, // #limit_validation_errors property. For button element types,
// #limit_validation_errors defaults to FALSE (via system_element_info()), // #limit_validation_errors defaults to FALSE (via system_element_info()),
...@@ -1962,12 +1962,12 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) { ...@@ -1962,12 +1962,12 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
// form_state_values_clean(). Enforce the same input processing restrictions // form_state_values_clean(). Enforce the same input processing restrictions
// as above. // as above.
if ($process_input) { if ($process_input) {
// Detect if the element triggered the submission via AJAX. // Detect if the element triggered the submission via Ajax.
if (_form_element_triggered_scripted_submission($element, $form_state)) { if (_form_element_triggered_scripted_submission($element, $form_state)) {
$form_state['triggering_element'] = $element; $form_state['triggering_element'] = $element;
} }
// If the form was submitted by the browser rather than via AJAX, then it // If the form was submitted by the browser rather than via Ajax, then it
// can only have been triggered by a button, and we need to determine which // can only have been triggered by a button, and we need to determine which
// button within the constraints of how browsers provide this information. // button within the constraints of how browsers provide this information.
if (isset($element['#button_type'])) { if (isset($element['#button_type'])) {
...@@ -1992,7 +1992,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) { ...@@ -1992,7 +1992,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) {
* Helper function to handle the convoluted logic of button click detection. * Helper function to handle the convoluted logic of button click detection.
* *
* This detects button or non-button controls that trigger a form submission via * This detects button or non-button controls that trigger a form submission via
* AJAX or some other scriptable environment. These environments can set the * Ajax or some other scriptable environment. These environments can set the
* special input key '_triggering_element_name' to identify the triggering * special input key '_triggering_element_name' to identify the triggering
* element. If the name alone doesn't identify the element uniquely, the input * element. If the name alone doesn't identify the element uniquely, the input
* key '_triggering_element_value' may also be set to require a match on element * key '_triggering_element_value' may also be set to require a match on element
...@@ -2017,7 +2017,7 @@ function _form_element_triggered_scripted_submission($element, &$form_state) { ...@@ -2017,7 +2017,7 @@ function _form_element_triggered_scripted_submission($element, &$form_state) {
* of the POST data, but with extra code to deal with the convoluted way in * of the POST data, but with extra code to deal with the convoluted way in
* which browsers submit data for image button clicks. * which browsers submit data for image button clicks.
* *
* This does not detect button clicks processed by AJAX (that is done in * This does not detect button clicks processed by Ajax (that is done in
* _form_element_triggered_scripted_submission()) and it does not detect form * _form_element_triggered_scripted_submission()) and it does not detect form
* submissions from Internet Explorer in response to an ENTER key pressed in a * submissions from Internet Explorer in response to an ENTER key pressed in a
* textfield (form_builder() has extra code for that). * textfield (form_builder() has extra code for that).
......
...@@ -104,7 +104,7 @@ function drupal_theme_initialize() { ...@@ -104,7 +104,7 @@ function drupal_theme_initialize() {
drupal_static_reset('drupal_alter'); drupal_static_reset('drupal_alter');
// Provide the page with information about the theme that's used, so that a // Provide the page with information about the theme that's used, so that a
// later AJAX request can be rendered using the same theme. // later Ajax request can be rendered using the same theme.
// @see ajax_base_page_theme() // @see ajax_base_page_theme()
$setting['ajaxPageState'] = array( $setting['ajaxPageState'] = array(
'theme' => $theme_key, 'theme' => $theme_key,
......
...@@ -2,25 +2,25 @@ ...@@ -2,25 +2,25 @@
(function ($) { (function ($) {
/** /**
* Provides AJAX page updating via jQuery $.ajax (Asynchronous JavaScript and XML). * Provides Ajax page updating via jQuery $.ajax (Asynchronous JavaScript and XML).
* *
* AJAX is a method of making a request via Javascript while viewing an HTML * 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 * page. The request returns an array of commands encoded in JSON, which is
* then executed to make any changes that are necessary to the page. * then executed to make any changes that are necessary to the page.
* *
* Drupal uses this file to enhance form elements with #ajax['path'] and * Drupal uses this file to enhance form elements with #ajax['path'] and
* #ajax['wrapper'] properties. If set, this file will automatically be included * #ajax['wrapper'] properties. If set, this file will automatically be included
* to provide AJAX capabilities. * to provide Ajax capabilities.
*/ */
Drupal.ajax = Drupal.ajax || {}; Drupal.ajax = Drupal.ajax || {};
/** /**
* Attaches the AJAX behavior to each AJAX form element. * Attaches the Ajax behavior to each Ajax form element.
*/ */
Drupal.behaviors.AJAX = { Drupal.behaviors.AJAX = {
attach: function (context, settings) { attach: function (context, settings) {
// Load all AJAX behaviors specified in the settings. // Load all Ajax behaviors specified in the settings.
for (var base in settings.ajax) { for (var base in settings.ajax) {
if (!$('#' + base + '.ajax-processed').length) { if (!$('#' + base + '.ajax-processed').length) {
var element_settings = settings.ajax[base]; var element_settings = settings.ajax[base];
...@@ -37,7 +37,7 @@ Drupal.behaviors.AJAX = { ...@@ -37,7 +37,7 @@ Drupal.behaviors.AJAX = {
} }
} }
// Bind AJAX behaviors to all items showing the class. // Bind Ajax behaviors to all items showing the class.
$('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () { $('.use-ajax:not(.ajax-processed)').addClass('ajax-processed').each(function () {
var element_settings = {}; var element_settings = {};
// Clicked links look better with the throbber than the progress bar. // Clicked links look better with the throbber than the progress bar.
...@@ -53,11 +53,11 @@ Drupal.behaviors.AJAX = { ...@@ -53,11 +53,11 @@ Drupal.behaviors.AJAX = {
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
}); });
// This class means to submit the form to the action using AJAX. // This class means to submit the form to the action using Ajax.
$('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () { $('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () {
var element_settings = {}; var element_settings = {};
// AJAX submits specified in this manner automatically submit to the // Ajax submits specified in this manner automatically submit to the
// normal form action. // normal form action.
element_settings.url = $(this.form).attr('action'); element_settings.url = $(this.form).attr('action');
// Form submit button clicks need to tell the form what was clicked so // Form submit button clicks need to tell the form what was clicked so
...@@ -75,13 +75,13 @@ Drupal.behaviors.AJAX = { ...@@ -75,13 +75,13 @@ Drupal.behaviors.AJAX = {
}; };
/** /**
* AJAX object. * Ajax object.
* *
* All AJAX objects on a page are accessible through the global Drupal.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 * object and are keyed by the submit button's ID. You can access them from
* your module's JavaScript file to override properties or functions. * your module's JavaScript file to override properties or functions.
* *
* For example, if your AJAX enabled button has the ID 'edit-submit', you can * For example, if your Ajax enabled button has the ID 'edit-submit', you can
* redefine the function that is called to insert the new content like this * redefine the function that is called to insert the new content like this
* (inside a Drupal.behaviors attach block): * (inside a Drupal.behaviors attach block):
* @code * @code
...@@ -134,7 +134,7 @@ Drupal.ajax = function (base, element, element_settings) { ...@@ -134,7 +134,7 @@ Drupal.ajax = function (base, element, element_settings) {
this.wrapper = '#' + element_settings.wrapper; this.wrapper = '#' + element_settings.wrapper;
// If there isn't a form, jQuery.ajax() will be used instead, allowing us to // If there isn't a form, jQuery.ajax() will be used instead, allowing us to
// bind AJAX to links as well. // bind Ajax to links as well.
if (this.element.form) { if (this.element.form) {
this.form = $(this.element.form); this.form = $(this.element.form);
} }
...@@ -179,7 +179,7 @@ Drupal.ajax = function (base, element, element_settings) { ...@@ -179,7 +179,7 @@ Drupal.ajax = function (base, element, element_settings) {
return ajax.eventResponse(this, event); return ajax.eventResponse(this, event);
}); });
// If necessary, enable keyboard submission so that AJAX behaviors // If necessary, enable keyboard submission so that Ajax behaviors
// can be triggered through keyboard input as well as e.g. a mousedown // can be triggered through keyboard input as well as e.g. a mousedown
// action. // action.
if (element_settings.keypress) { if (element_settings.keypress) {
...@@ -192,7 +192,7 @@ Drupal.ajax = function (base, element, element_settings) { ...@@ -192,7 +192,7 @@ Drupal.ajax = function (base, element, element_settings) {
/** /**
* Handle a key press. * Handle a key press.
* *
* The AJAX object will, if instructed, bind to a key press response. This * 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 * will test to see if the key press is valid to trigger this event and
* if it is, trigger it for us and prevent other keypresses from triggering. * if it is, trigger it for us and prevent other keypresses from triggering.
* In this case we're handling RETURN and SPACEBAR keypresses (event codes 13 * In this case we're handling RETURN and SPACEBAR keypresses (event codes 13
...@@ -214,10 +214,10 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) { ...@@ -214,10 +214,10 @@ Drupal.ajax.prototype.keypressResponse = function (element, event) {
}; };
/** /**
* Handle an event that triggers an AJAX response. * Handle an event that triggers an Ajax response.
* *
* When an event that triggers an AJAX response happens, this method will * When an event that triggers an Ajax response happens, this method will
* perform the actual AJAX call. It is bound to the event using * perform the actual Ajax call. It is bound to the event using
* bind() in the constructor, and it uses the options specified on the * bind() in the constructor, and it uses the options specified on the
* ajax object. * ajax object.
*/ */
...@@ -315,7 +315,7 @@ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { ...@@ -315,7 +315,7 @@ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) {
} }
/** /**
* Prepare the AJAX request before it is sent. * Prepare the Ajax request before it is sent.
*/ */
Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
// For forms without file inputs, the jQuery Form plugin serializes the form // For forms without file inputs, the jQuery Form plugin serializes the form
...@@ -347,7 +347,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) { ...@@ -347,7 +347,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
} }
// Disable the element that received the change to prevent user interface // Disable the element that received the change to prevent user interface
// interaction while the AJAX request is in progress. ajax.ajaxing prevents // interaction while the Ajax request is in progress. ajax.ajaxing prevents
// the element from triggering a new request, but does not prevent the user // the element from triggering a new request, but does not prevent the user
// from changing its value. // from changing its value.
$(this.element).addClass('progress-disabled').attr('disabled', true); $(this.element).addClass('progress-disabled').attr('disabled', true);
...@@ -488,7 +488,7 @@ Drupal.ajax.prototype.commands = { ...@@ -488,7 +488,7 @@ Drupal.ajax.prototype.commands = {
// sufficiently tested whether attachBehaviors() can be successfully called // sufficiently tested whether attachBehaviors() can be successfully called
// with a context object that includes top-level text nodes. However, to // with a context object that includes top-level text nodes. However, to
// give developers full control of the HTML appearing in the page, and to // give developers full control of the HTML appearing in the page, and to
// enable AJAX content to be inserted in places where DIV elements are not // enable Ajax content to be inserted in places where DIV elements are not
// allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new // allowed (e.g., within TABLE, TR, and SPAN parents), we check if the new
// content satisfies the requirement of a single top-level element, and // content satisfies the requirement of a single top-level element, and
// only use the container DIV created above when it doesn't. For more // only use the container DIV created above when it doesn't. For more
......
...@@ -11,7 +11,7 @@ jQuery.noConflict(); ...@@ -11,7 +11,7 @@ jQuery.noConflict();
* Attach all registered behaviors to a page element. * Attach all registered behaviors to a page element.
* *
* Behaviors are event-triggered actions that attach to page elements, enhancing * Behaviors are event-triggered actions that attach to page elements, enhancing
* default non-Javascript UIs. Behaviors are registered in the Drupal.behaviors * default non-JavaScript UIs. Behaviors are registered in the Drupal.behaviors
* object using the method 'attach' and optionally also 'detach' as follows: * object using the method 'attach' and optionally also 'detach' as follows:
* @code * @code
* Drupal.behaviors.behaviorName = { * Drupal.behaviors.behaviorName = {
...@@ -25,7 +25,7 @@ jQuery.noConflict(); ...@@ -25,7 +25,7 @@ jQuery.noConflict();
* @endcode * @endcode
* *
* Drupal.attachBehaviors is added below to the jQuery ready event and so * Drupal.attachBehaviors is added below to the jQuery ready event and so
* runs on initial page load. Developers implementing AHAH/AJAX in their * runs on initial page load. Developers implementing AHAH/Ajax in their
* solutions should also call this function after new page content has been * solutions should also call this function after new page content has been
* loaded, feeding in an element to be processed, in order to attach all * loaded, feeding in an element to be processed, in order to attach all
* behaviors to the new content. * behaviors to the new content.
...@@ -61,7 +61,7 @@ Drupal.attachBehaviors = function (context, settings) { ...