- Patch #1056108 by 1V: consistent use of 'JavaScript' and 'Ajax'.
parent
7205ff14ca
commit
fa39282ef7
|
@ -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 @@ class DrupalFakeCache extends DrupalDatabaseCache implements DrupalCacheInterfac
|
|||
// 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
|
||||
* 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
|
||||
* 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
|
||||
|
@ -254,7 +254,7 @@ function drupal_get_form($form_id) {
|
|||
* - must_validate: Ordinarily, a form is only validated once but there are
|
||||
* times when a form is resubmitted internally and should be validated
|
||||
* 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
|
||||
* 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
|
||||
|
@ -396,9 +396,9 @@ function form_state_defaults() {
|
|||
* function is called to generate a new $form, the next step in the form
|
||||
* 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()
|
||||
* for more information about creating AJAX-enabled forms.
|
||||
* for more information about creating Ajax-enabled forms.
|
||||
*
|
||||
* @param $form_id
|
||||
* The unique string identifying the desired form. If a function
|
||||
|
@ -411,7 +411,7 @@ function form_state_defaults() {
|
|||
* A keyed array containing the current state of the form.
|
||||
* @param $old_form
|
||||
* (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
|
||||
* $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.
|
||||
|
@ -427,7 +427,7 @@ function form_state_defaults() {
|
|||
function drupal_rebuild_form($form_id, &$form_state, $old_form = NULL) {
|
||||
$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
|
||||
// manually update the hidden 'build_id' input element.
|
||||
// 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) {
|
|||
$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
|
||||
// #action needs to be retained.
|
||||
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) {
|
|||
// 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
|
||||
// $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
|
||||
// $form_state['rebuild']. It would not make sense to redisplay the
|
||||
// identical form without an error for the user to correct, so we also
|
||||
// rebuild error-free non-executed forms, regardless of
|
||||
// $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
|
||||
// divergent form execution based on whether the triggering element has
|
||||
// #executes_submit_callback set to TRUE.
|
||||
|
@ -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
|
||||
* built the form explicitly disallows any redirection, regardless of the
|
||||
* 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
|
||||
* be altered by form builder functions or form validation/submit handlers.
|
||||
* - If $form_state['programmed'] is TRUE, the form submission was usually
|
||||
|
@ -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
|
||||
// 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,
|
||||
// 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
|
||||
// #limit_validation_errors property. For button element types,
|
||||
// #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) {
|
|||
// form_state_values_clean(). Enforce the same input processing restrictions
|
||||
// as above.
|
||||
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)) {
|
||||
$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
|
||||
// button within the constraints of how browsers provide this information.
|
||||
if (isset($element['#button_type'])) {
|
||||
|
@ -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.
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
|
@ -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
|
||||
* 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
|
||||
* submissions from Internet Explorer in response to an ENTER key pressed in a
|
||||
* textfield (form_builder() has extra code for that).
|
||||
|
|
|
@ -104,7 +104,7 @@ function drupal_theme_initialize() {
|
|||
drupal_static_reset('drupal_alter');
|
||||
|
||||
// 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()
|
||||
$setting['ajaxPageState'] = array(
|
||||
'theme' => $theme_key,
|
||||
|
|
40
misc/ajax.js
40
misc/ajax.js
|
@ -2,25 +2,25 @@
|
|||
(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
|
||||
* then executed to make any changes that are necessary to the page.
|
||||
*
|
||||
* Drupal uses this file to enhance form elements with #ajax['path'] and
|
||||
* #ajax['wrapper'] properties. If set, this file will automatically be included
|
||||
* to provide AJAX capabilities.
|
||||
* to provide Ajax capabilities.
|
||||
*/
|
||||
|
||||
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 = {
|
||||
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) {
|
||||
if (!$('#' + base + '.ajax-processed').length) {
|
||||
var element_settings = settings.ajax[base];
|
||||
|
@ -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 () {
|
||||
var element_settings = {};
|
||||
// Clicked links look better with the throbber than the progress bar.
|
||||
|
@ -53,11 +53,11 @@ Drupal.behaviors.AJAX = {
|
|||
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 () {
|
||||
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.
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
// Form submit button clicks need to tell the form what was clicked so
|
||||
|
@ -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
|
||||
* 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
|
||||
* (inside a Drupal.behaviors attach block):
|
||||
* @code
|
||||
|
@ -134,7 +134,7 @@ Drupal.ajax = function (base, element, element_settings) {
|
|||
this.wrapper = '#' + element_settings.wrapper;
|
||||
|
||||
// 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) {
|
||||
this.form = $(this.element.form);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ Drupal.ajax = function (base, element, element_settings) {
|
|||
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
|
||||
// action.
|
||||
if (element_settings.keypress) {
|
||||
|
@ -192,7 +192,7 @@ Drupal.ajax = function (base, element, element_settings) {
|
|||
/**
|
||||
* 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
|
||||
* 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
|
||||
|
@ -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
|
||||
* perform the actual AJAX call. It is bound to the event using
|
||||
* When an event that triggers an Ajax response happens, this method will
|
||||
* perform the actual Ajax call. It is bound to the event using
|
||||
* bind() in the constructor, and it uses the options specified on the
|
||||
* ajax object.
|
||||
*/
|
||||
|
@ -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) {
|
||||
// For forms without file inputs, the jQuery Form plugin serializes the form
|
||||
|
@ -347,7 +347,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
|
|||
}
|
||||
|
||||
// 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
|
||||
// from changing its value.
|
||||
$(this.element).addClass('progress-disabled').attr('disabled', true);
|
||||
|
@ -488,7 +488,7 @@ Drupal.ajax.prototype.commands = {
|
|||
// sufficiently tested whether attachBehaviors() can be successfully called
|
||||
// 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
|
||||
// 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
|
||||
// content satisfies the requirement of a single top-level element, and
|
||||
// only use the container DIV created above when it doesn't. For more
|
||||
|
|
|
@ -11,7 +11,7 @@ jQuery.noConflict();
|
|||
* Attach all registered behaviors to a page element.
|
||||
*
|
||||
* 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:
|
||||
* @code
|
||||
* Drupal.behaviors.behaviorName = {
|
||||
|
@ -25,7 +25,7 @@ jQuery.noConflict();
|
|||
* @endcode
|
||||
*
|
||||
* 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
|
||||
* loaded, feeding in an element to be processed, in order to attach all
|
||||
* behaviors to the new content.
|
||||
|
@ -61,7 +61,7 @@ Drupal.attachBehaviors = function (context, settings) {
|
|||
/**
|
||||
* Detach registered behaviors from a page element.
|
||||
*
|
||||
* Developers implementing AHAH/AJAX in their solutions should call this
|
||||
* Developers implementing AHAH/Ajax in their solutions should call this
|
||||
* function before page content is about to be removed, feeding in an element
|
||||
* to be processed, in order to allow special behaviors to detach from the
|
||||
* content.
|
||||
|
@ -89,7 +89,7 @@ Drupal.attachBehaviors = function (context, settings) {
|
|||
* IFRAME elements reload their "src" when being moved within the DOM,
|
||||
* behaviors bound to IFRAME elements (like WYSIWYG editors) may need to
|
||||
* take some action.
|
||||
* - serialize: When an AJAX form is submitted, this is called with the
|
||||
* - serialize: When an Ajax form is submitted, this is called with the
|
||||
* form as the context. This provides every behavior within the form an
|
||||
* opportunity to ensure that the field elements have correct content
|
||||
* in them before the form is serialized. The canonical use-case is so
|
||||
|
@ -302,7 +302,7 @@ Drupal.getSelection = function (element) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Build an error message from an AJAX response.
|
||||
* Build an error message from an Ajax response.
|
||||
*/
|
||||
Drupal.ajaxError = function (xmlhttp, uri) {
|
||||
var statusCode, statusText, pathText, responseText, readyStateText, message;
|
||||
|
|
|
@ -419,7 +419,7 @@ function book_form_node_form_alter(&$form, &$form_state, $form_id) {
|
|||
* rebuild so that the "Parent item" options are changed to reflect the newly
|
||||
* selected book. When JavaScript is enabled, the submit button that triggers
|
||||
* this handler is hidden, and the "Book" dropdown directly triggers the
|
||||
* book_form_update() AJAX callback instead.
|
||||
* book_form_update() Ajax callback instead.
|
||||
*
|
||||
* @see book_form_update()
|
||||
*/
|
||||
|
@ -432,7 +432,7 @@ function book_pick_book_nojs_submit($form, &$form_state) {
|
|||
* Build the parent selection form element for the node form or outline tab.
|
||||
*
|
||||
* This function is also called when generating a new set of options during the
|
||||
* AJAX callback, so an array is returned that can be used to replace an existing
|
||||
* Ajax callback, so an array is returned that can be used to replace an existing
|
||||
* form element.
|
||||
*/
|
||||
function _book_parent_select($book_link) {
|
||||
|
@ -479,7 +479,7 @@ function _book_parent_select($book_link) {
|
|||
* Build the common elements of the book form for the node and outline forms.
|
||||
*/
|
||||
function _book_add_form_elements(&$form, &$form_state, $node) {
|
||||
// If the form is being processed during the AJAX callback of our book bid
|
||||
// If the form is being processed during the Ajax callback of our book bid
|
||||
// dropdown, then $form_state will hold the value that was selected.
|
||||
if (isset($form_state['values']['book'])) {
|
||||
$node->book = $form_state['values']['book'];
|
||||
|
@ -563,7 +563,7 @@ function _book_add_form_elements(&$form, &$form_state, $node) {
|
|||
/**
|
||||
* Renders a new parent page select element when the book selection changes.
|
||||
*
|
||||
* This function is called via AJAX when the selected book is changed on a node
|
||||
* This function is called via Ajax when the selected book is changed on a node
|
||||
* or book outline form.
|
||||
*
|
||||
* @return
|
||||
|
|
|
@ -486,7 +486,7 @@ function dashboard_dashboard_regions() {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback to show disabled blocks in the dashboard customization mode.
|
||||
* Ajax callback to show disabled blocks in the dashboard customization mode.
|
||||
*/
|
||||
function dashboard_show_disabled() {
|
||||
global $theme_key;
|
||||
|
@ -507,7 +507,7 @@ function dashboard_show_disabled() {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback to display the rendered contents of a specific block.
|
||||
* Ajax callback to display the rendered contents of a specific block.
|
||||
*
|
||||
* @param $module
|
||||
* The block's module name.
|
||||
|
|
|
@ -414,7 +414,7 @@ function field_add_more_js($form, $form_state) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Add a DIV around the delta receiving the AJAX effect.
|
||||
// Add a DIV around the delta receiving the Ajax effect.
|
||||
$delta = $element['#max_delta'];
|
||||
$element[$delta]['#prefix'] = '<div class="ajax-new-content">' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : '');
|
||||
$element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '</div>';
|
||||
|
|
|
@ -1497,7 +1497,7 @@ class FieldFormTestCase extends FieldTestCase {
|
|||
$field_values[$weight]['value'] = (string) $value;
|
||||
$pattern[$weight] = "<input [^>]*value=\"$value\" [^>]*";
|
||||
}
|
||||
// Press 'add more' button through AJAX, and place the expected HTML result
|
||||
// Press 'add more' button through Ajax, and place the expected HTML result
|
||||
// as the tested content.
|
||||
$commands = $this->drupalPostAJAX(NULL, $edit, $this->field_name . '_add_more');
|
||||
$this->content = $commands[1]['data'];
|
||||
|
@ -1694,7 +1694,7 @@ class FieldFormTestCase extends FieldTestCase {
|
|||
$this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NONE, array(3, 2));
|
||||
$this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NONE, array(13, 12));
|
||||
|
||||
// Test the 'add more' buttons. Only AJAX submission is tested, because
|
||||
// Test the 'add more' buttons. Only Ajax submission is tested, because
|
||||
// the two 'add more' buttons present in the form have the same #value,
|
||||
// which confuses drupalPost().
|
||||
// 'Add more' button in the first entity:
|
||||
|
|
|
@ -875,7 +875,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
|
|||
'class' => array('field-ui-overview'),
|
||||
'id' => 'field-display-overview',
|
||||
),
|
||||
// Add AJAX wrapper.
|
||||
// Add Ajax wrapper.
|
||||
'#prefix' => '<div id="field-display-overview-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
@ -1157,7 +1157,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
|
|||
'callback' => 'field_ui_display_overview_multistep_js',
|
||||
'wrapper' => 'field-display-overview-wrapper',
|
||||
'effect' => 'fade',
|
||||
// The button stays hidden, so we hide the AJAX spinner too. Ad-hoc
|
||||
// The button stays hidden, so we hide the Ajax spinner too. Ad-hoc
|
||||
// spinners will be added manually by the client-side script.
|
||||
'progress' => 'none',
|
||||
),
|
||||
|
@ -1218,7 +1218,7 @@ function field_ui_display_overview_multistep_submit($form, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX handler for multistep buttons on the 'Manage display' screen.
|
||||
* Ajax handler for multistep buttons on the 'Manage display' screen.
|
||||
*/
|
||||
function field_ui_display_overview_multistep_js($form, &$form_state) {
|
||||
$trigger = $form_state['triggering_element'];
|
||||
|
|
|
@ -167,7 +167,7 @@ Drupal.fieldUIOverview = {
|
|||
refreshRows = rowHandler.regionChange(region);
|
||||
// Update the row region.
|
||||
rowHandler.region = region;
|
||||
// AJAX-update the rows.
|
||||
// Ajax-update the rows.
|
||||
Drupal.fieldUIOverview.AJAXRefreshRows(refreshRows);
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ Drupal.fieldUIOverview = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Triggers AJAX refresh of selected rows.
|
||||
* Triggers Ajax refresh of selected rows.
|
||||
*
|
||||
* The 'format type' selects can trigger a series of changes in child rows.
|
||||
* The #ajax behavior is therefore not attached directly to the selects, but
|
||||
|
@ -215,7 +215,7 @@ Drupal.fieldUIOverview = {
|
|||
* @param rows
|
||||
* A hash object, whose keys are the names of the rows to refresh (they
|
||||
* will receive the 'ajax-new-content' effect on the server side), and
|
||||
* whose values are the DOM element in the row that should get an AJAX
|
||||
* whose values are the DOM element in the row that should get an Ajax
|
||||
* throbber.
|
||||
*/
|
||||
AJAXRefreshRows: function (rows) {
|
||||
|
@ -234,7 +234,7 @@ Drupal.fieldUIOverview = {
|
|||
.addClass('progress-disabled')
|
||||
.after($throbber);
|
||||
|
||||
// Fire the AJAX update.
|
||||
// Fire the Ajax update.
|
||||
$('input[name=refresh_rows]').val(rowNames.join(' '));
|
||||
$('input#edit-refresh').mousedown();
|
||||
|
||||
|
@ -295,7 +295,7 @@ Drupal.fieldUIDisplayOverview.field.prototype = {
|
|||
* @param region
|
||||
* The name of the new region for the row.
|
||||
* @return
|
||||
* A hash object indicating which rows should be AJAX-updated as a result
|
||||
* A hash object indicating which rows should be Ajax-updated as a result
|
||||
* of the change, in the format expected by
|
||||
* Drupal.displayOverview.AJAXRefreshRows().
|
||||
*/
|
||||
|
|
|
@ -448,7 +448,7 @@ function file_field_widget_form(&$form, &$form_state, $field, $instance, $langco
|
|||
'description' => '',
|
||||
);
|
||||
|
||||
// Retrieve any values set in $form_state, as will be the case during AJAX
|
||||
// Retrieve any values set in $form_state, as will be the case during Ajax
|
||||
// rebuilds of this form.
|
||||
if (isset($form_state['values'])) {
|
||||
$path = array_merge($element['#field_parents'], array($field['field_name'], $langcode));
|
||||
|
@ -650,7 +650,7 @@ function file_field_widget_process($element, &$form_state, $form) {
|
|||
);
|
||||
}
|
||||
|
||||
// Adjust the AJAX settings so that on upload and remove of any individual
|
||||
// Adjust the Ajax settings so that on upload and remove of any individual
|
||||
// file, the entire group of file fields is updated together.
|
||||
if ($field['cardinality'] != 1) {
|
||||
$parents = array_slice($element['#array_parents'], 0, -1);
|
||||
|
@ -681,7 +681,7 @@ function file_field_widget_process($element, &$form_state, $form) {
|
|||
/**
|
||||
* An element #process callback for a group of file_generic fields.
|
||||
*
|
||||
* Adds the weight field to each row so it can be ordered and adds a new AJAX
|
||||
* Adds the weight field to each row so it can be ordered and adds a new Ajax
|
||||
* wrapper around the entire group so it can be replaced all at once.
|
||||
*/
|
||||
function file_field_widget_process_multiple($element, &$form_state, $form) {
|
||||
|
@ -710,7 +710,7 @@ function file_field_widget_process_multiple($element, &$form_state, $form) {
|
|||
}
|
||||
}
|
||||
|
||||
// Add a new wrapper around all the elements for AJAX replacement.
|
||||
// Add a new wrapper around all the elements for Ajax replacement.
|
||||
$element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">';
|
||||
$element['#suffix'] = '</div>';
|
||||
|
||||
|
@ -770,7 +770,7 @@ function theme_file_widget($variables) {
|
|||
$element = $variables['element'];
|
||||
$output = '';
|
||||
|
||||
// The "form-managed-file" class is required for proper AJAX functionality.
|
||||
// The "form-managed-file" class is required for proper Ajax functionality.
|
||||
$output .= '<div class="file-widget form-managed-file clearfix">';
|
||||
if ($element['fid']['#value'] != 0) {
|
||||
// Add the file size after the file name.
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Provides JavaScript additions to the managed file field type.
|
||||
*
|
||||
* This file provides progress bar support (if available), popup windows for
|
||||
* file previews, and disabling of other file fields during AJAX uploads (which
|
||||
* file previews, and disabling of other file fields during Ajax uploads (which
|
||||
* prevents separate file fields from accidentally uploading files).
|
||||
*/
|
||||
|
||||
|
@ -90,7 +90,7 @@ Drupal.file = Drupal.file || {
|
|||
disableFields: function (event){
|
||||
var clickedButton = this;
|
||||
|
||||
// Only disable upload fields for AJAX buttons.
|
||||
// Only disable upload fields for Ajax buttons.
|
||||
if (!$(clickedButton).hasClass('ajax-processed')) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ Drupal.file = Drupal.file || {
|
|||
// working with. Filter out fields that are already disabled so that they
|
||||
// do not get enabled when we re-enable these fields at the end of behavior
|
||||
// processing. Re-enable in a setTimeout set to a relatively short amount
|
||||
// of time (1 second). All the other mousedown handlers (like Drupal's AJAX
|
||||
// of time (1 second). All the other mousedown handlers (like Drupal's Ajax
|
||||
// behaviors) are excuted before any timeout functions are called, so we
|
||||
// don't have to worry about the fields being re-enabled too soon.
|
||||
// @todo If the previous sentence is true, why not set the timeout to 0?
|
||||
|
|
|
@ -221,7 +221,7 @@ function file_file_download($uri, $field_type = 'file') {
|
|||
}
|
||||
|
||||
/**
|
||||
* Menu callback; Shared AJAX callback for file uploads and deletions.
|
||||
* Menu callback; Shared Ajax callback for file uploads and deletions.
|
||||
*
|
||||
* This rebuilds the form element for a particular field item. As long as the
|
||||
* form processing is properly encapsulated in the widget element the form
|
||||
|
@ -265,7 +265,7 @@ function file_ajax_upload() {
|
|||
$form = $form[$parent];
|
||||
}
|
||||
|
||||
// Add the special AJAX class if a new file was added.
|
||||
// Add the special Ajax class if a new file was added.
|
||||
if (isset($form['#file_upload_delta']) && $current_file_count < $form['#file_upload_delta']) {
|
||||
$form[$current_file_count]['#attributes']['class'][] = 'ajax-new-content';
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ function file_managed_file_process($element, &$form_state, $form) {
|
|||
);
|
||||
}
|
||||
|
||||
// Prefix and suffix used for AJAX replacement.
|
||||
// Prefix and suffix used for Ajax replacement.
|
||||
$element['#prefix'] = '<div id="' . $element['#id'] . '-ajax-wrapper">';
|
||||
$element['#suffix'] = '</div>';
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ class FileManagedFileElementTestCase extends FileFieldTestCase {
|
|||
$this->drupalPost($path . '/' . $last_fid, array(), t('Save'));
|
||||
$this->assertRaw(t('The file id is %fid.', array('%fid' => $last_fid)), t('Empty submission did not change an existing file.'));
|
||||
|
||||
// Now, test the Upload and Remove buttons, with and without AJAX.
|
||||
// Now, test the Upload and Remove buttons, with and without Ajax.
|
||||
foreach (array(FALSE, TRUE) as $ajax) {
|
||||
// Upload, then Submit.
|
||||
$last_fid_prior = $this->getLastFileId();
|
||||
|
@ -302,7 +302,7 @@ class FileManagedFileElementTestCase extends FileFieldTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test class to test file field widget, single and multi-valued, with and without AJAX, with public and private files.
|
||||
* Test class to test file field widget, single and multi-valued, with and without Ajax, with public and private files.
|
||||
*/
|
||||
class FileFieldWidgetTestCase extends FileFieldTestCase {
|
||||
public static function getInfo() {
|
||||
|
@ -314,7 +314,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests upload and remove buttons, with and without AJAX, for a single-valued File field.
|
||||
* Tests upload and remove buttons, with and without Ajax, for a single-valued File field.
|
||||
*/
|
||||
function testSingleValuedWidget() {
|
||||
// Use 'page' instead of 'article', so that the 'article' image field does
|
||||
|
@ -371,7 +371,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests upload and remove buttons, with and without AJAX, for a multi-valued File field.
|
||||
* Tests upload and remove buttons, with and without Ajax, for a multi-valued File field.
|
||||
*/
|
||||
function testMultiValuedWidget() {
|
||||
// Use 'page' instead of 'article', so that the 'article' image field does
|
||||
|
@ -390,7 +390,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase {
|
|||
// Visit the node creation form, and upload 3 files. Since the field has
|
||||
// cardinality of 3, ensure the "Upload" button is displayed until after
|
||||
// the 3rd file, and after that, isn't displayed.
|
||||
// @todo This is only testing a non-AJAX upload, because drupalPostAJAX()
|
||||
// @todo This is only testing a non-Ajax upload, because drupalPostAJAX()
|
||||
// does not yet emulate jQuery's file upload.
|
||||
$this->drupalGet("node/add/$type_name");
|
||||
for ($delta = 0; $delta < 3; $delta++) {
|
||||
|
|
|
@ -352,7 +352,7 @@ function menu_parent_options($menus, $item) {
|
|||
|
||||
/**
|
||||
* Page callback.
|
||||
* Get all available menus and menu items as Javascript array.
|
||||
* Get all the available menus and menu items as a JavaScript array.
|
||||
*/
|
||||
function menu_parent_options_js() {
|
||||
$available_menus = array();
|
||||
|
|
|
@ -678,7 +678,7 @@ Drupal.overlay.eventhandlerDispatchEvent = function (event) {
|
|||
* Make a regular admin link into a URL that will trigger the overlay to open.
|
||||
*
|
||||
* @param link
|
||||
* A Javascript Link object (i.e. an <a> element).
|
||||
* A JavaScript Link object (i.e. an <a> element).
|
||||
* @param parentLocation
|
||||
* (optional) URL to override the parent window's location with.
|
||||
*
|
||||
|
|
|
@ -626,7 +626,7 @@ function overlay_overlay_parent_initialize() {
|
|||
$type = str_replace('<front>', variable_get('site_frontpage', 'node'), $type);
|
||||
}
|
||||
drupal_add_js(array('overlay' => array('paths' => $paths)), 'setting');
|
||||
// Pass along the AJAX callback for rerendering sections of the parent window.
|
||||
// Pass along the Ajax callback for rerendering sections of the parent window.
|
||||
drupal_add_js(array('overlay' => array('ajaxCallback' => 'overlay-ajax')), 'setting');
|
||||
}
|
||||
|
||||
|
@ -643,7 +643,7 @@ function overlay_overlay_child_initialize() {
|
|||
// the initial rendered content of those regions here, so that we can compare
|
||||
// it to the same content rendered in overlay_exit(), at the end of the page
|
||||
// request. This allows us to check if anything actually did change, and, if
|
||||
// so, trigger an immediate AJAX refresh of the parent window.
|
||||
// so, trigger an immediate Ajax refresh of the parent window.
|
||||
if (!empty($_POST) || isset($_GET['token'])) {
|
||||
foreach (overlay_supplemental_regions() as $region) {
|
||||
overlay_store_rendered_content($region, overlay_render_region($region));
|
||||
|
@ -945,7 +945,7 @@ function overlay_trigger_refresh() {
|
|||
/**
|
||||
* Prints the markup obtained by rendering a single region of the page.
|
||||
*
|
||||
* This function is intended to be called via AJAX.
|
||||
* This function is intended to be called via Ajax.
|
||||
*
|
||||
* @param $region
|
||||
* The name of the page region to render.
|
||||
|
|
|
@ -242,7 +242,7 @@ function poll_form($node, &$form_state) {
|
|||
$type = node_type_get_type($node);
|
||||
|
||||
// The submit handlers to add more poll choices require that this form is
|
||||
// cached, regardless of whether AJAX is used.
|
||||
// cached, regardless of whether Ajax is used.
|
||||
$form_state['cache'] = TRUE;
|
||||
|
||||
$form['title'] = array(
|
||||
|
@ -296,7 +296,7 @@ function poll_form($node, &$form_state) {
|
|||
}
|
||||
|
||||
// We name our button 'poll_more' to avoid conflicts with other modules using
|
||||
// AJAX-enabled buttons with the id 'more'.
|
||||
// Ajax-enabled buttons with the id 'more'.
|
||||
$form['choice_wrapper']['poll_more'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('More choices'),
|
||||
|
@ -362,7 +362,7 @@ function poll_form($node, &$form_state) {
|
|||
* return just the changed part of the form.
|
||||
*/
|
||||
function poll_more_choices_submit($form, &$form_state) {
|
||||
// If this is a AJAX POST, add 1, otherwise add 5 more choices to the form.
|
||||
// If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
|
||||
if ($form_state['values']['poll_more']) {
|
||||
$n = $_GET['q'] == 'system/ajax' ? 1 : 5;
|
||||
$form_state['choice_count'] = count($form_state['values']['choice']) + $n;
|
||||
|
|
|
@ -426,7 +426,7 @@ class PollJSAddChoice extends DrupalWebTestCase {
|
|||
'choice[new:1][chtext]' => $this->randomName(),
|
||||
);
|
||||
|
||||
// Press 'add choice' button through AJAX, and place the expected HTML result
|
||||
// Press 'add choice' button through Ajax, and place the expected HTML result
|
||||
// as the tested content.
|
||||
$commands = $this->drupalPostAJAX(NULL, $edit, array('op' => t('More choices')));
|
||||
$this->content = $commands[1]['data'];
|
||||
|
|
|
@ -1769,17 +1769,17 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
* button with the value t('Delete'), and execute different code depending
|
||||
* on which one is clicked.
|
||||
*
|
||||
* This function can also be called to emulate an AJAX submission. In this
|
||||
* This function can also be called to emulate an Ajax submission. In this
|
||||
* case, this value needs to be an array with the following keys:
|
||||
* - path: A path to submit the form values to for AJAX-specific processing,
|
||||
* - path: A path to submit the form values to for Ajax-specific processing,
|
||||
* which is likely different than the $path parameter used for retrieving
|
||||
* the initial form. Defaults to 'system/ajax'.
|
||||
* - triggering_element: If the value for the 'path' key is 'system/ajax' or
|
||||
* another generic AJAX processing path, this needs to be set to the name
|
||||
* another generic Ajax processing path, this needs to be set to the name
|
||||
* of the element. If the name doesn't identify the element uniquely, then
|
||||
* this should instead be an array with a single key/value pair,
|
||||
* corresponding to the element name and value. The callback for the
|
||||
* generic AJAX processing path uses this to find the #ajax information
|
||||
* generic Ajax processing path uses this to find the #ajax information
|
||||
* for the element, including which specific callback to use for
|
||||
* processing the request.
|
||||
*
|
||||
|
@ -1829,7 +1829,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
$action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : $this->getUrl();
|
||||
if ($ajax) {
|
||||
$action = $this->getAbsoluteUrl(!empty($submit['path']) ? $submit['path'] : 'system/ajax');
|
||||
// AJAX callbacks verify the triggering element if necessary, so while
|
||||
// Ajax callbacks verify the triggering element if necessary, so while
|
||||
// we may eventually want extra code that verifies it in the
|
||||
// handleForm() function, it's not currently a requirement.
|
||||
$submit_matches = TRUE;
|
||||
|
@ -1886,26 +1886,26 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Execute an AJAX submission.
|
||||
* Execute an Ajax submission.
|
||||
*
|
||||
* This executes a POST as ajax.js does. It uses the returned JSON data, an
|
||||
* array of commands, to update $this->content using equivalent DOM
|
||||
* manipulation as is used by ajax.js. It also returns the array of commands.
|
||||
*
|
||||
* @param $path
|
||||
* Location of the form containing the AJAX enabled element to test. Can be
|
||||
* Location of the form containing the Ajax enabled element to test. Can be
|
||||
* either a Drupal path or an absolute path or NULL to use the current page.
|
||||
* @param $edit
|
||||
* Field data in an associative array. Changes the current input fields
|
||||
* (where possible) to the values indicated.
|
||||
* @param $triggering_element
|
||||
* The name of the form element that is responsible for triggering the AJAX
|
||||
* The name of the form element that is responsible for triggering the Ajax
|
||||
* functionality to test. May be a string or, if the triggering element is
|
||||
* a button, an associative array where the key is the name of the button
|
||||
* and the value is the button label. i.e.) array('op' => t('Refresh')).
|
||||
* @param $ajax_path
|
||||
* (optional) Override the path set by the AJAX settings of the triggering
|
||||
* element. In the absence of both the triggering element's AJAX path and
|
||||
* (optional) Override the path set by the Ajax settings of the triggering
|
||||
* element. In the absence of both the triggering element's Ajax path and
|
||||
* $ajax_path 'system/ajax' will be used.
|
||||
* @param $options
|
||||
* (optional) Options to be forwarded to url().
|
||||
|
@ -1918,11 +1918,11 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
* element is not enough to identify the form. Note this is not the Drupal
|
||||
* ID of the form but rather the HTML ID of the form.
|
||||
* @param $ajax_settings
|
||||
* (optional) An array of AJAX settings which if specified will be used in
|
||||
* place of the AJAX settings of the triggering element.
|
||||
* (optional) An array of Ajax settings which if specified will be used in
|
||||
* place of the Ajax settings of the triggering element.
|
||||
*
|
||||
* @return
|
||||
* An array of AJAX commands.
|
||||
* An array of Ajax commands.
|
||||
*
|
||||
* @see drupalPost()
|
||||
* @see ajax.js
|
||||
|
@ -1936,7 +1936,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
$content = $this->content;
|
||||
$drupal_settings = $this->drupalSettings;
|
||||
|
||||
// Get the AJAX settings bound to the triggering element.
|
||||
// Get the Ajax settings bound to the triggering element.
|
||||
if (!isset($ajax_settings)) {
|
||||
if (is_array($triggering_element)) {
|
||||
$xpath = '//*[@name="' . key($triggering_element) . '" and @value="' . current($triggering_element) . '"]';
|
||||
|
@ -1965,7 +1965,7 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
}
|
||||
|
||||
// Unless a particular path is specified, use the one specified by the
|
||||
// AJAX settings, or else 'system/ajax'.
|
||||
// Ajax settings, or else 'system/ajax'.
|
||||
if (!isset($ajax_path)) {
|
||||
$ajax_path = isset($ajax_settings['url']) ? $ajax_settings['url'] : 'system/ajax';
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ class AJAXTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Assert that a command with the required properties exists within the array of AJAX commands returned by the server.
|
||||
* Assert that a command with the required properties exists within the array of Ajax commands returned by the server.
|
||||
*
|
||||
* The AJAX framework, via the ajax_deliver() and ajax_render() functions,
|
||||
* The Ajax framework, via the ajax_deliver() and ajax_render() functions,
|
||||
* returns an array of commands. This array sometimes includes commands
|
||||
* automatically provided by the framework in addition to commands returned by
|
||||
* a particular page callback. During testing, we're usually interested that a
|
||||
|
@ -28,7 +28,7 @@ class AJAXTestCase extends DrupalWebTestCase {
|
|||
* additional settings that aren't part of $needle.
|
||||
*
|
||||
* @param $haystack
|
||||
* An array of AJAX commands returned by the server.
|
||||
* An array of Ajax commands returned by the server.
|
||||
* @param $needle
|
||||
* Array of info we're expecting in one of those commands.
|
||||
* @param $message
|
||||
|
@ -56,7 +56,7 @@ class AJAXTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests primary AJAX framework functions.
|
||||
* Tests primary Ajax framework functions.
|
||||
*/
|
||||
class AJAXFrameworkTestCase extends AJAXTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
@ -87,7 +87,7 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
|
|||
);
|
||||
$this->assertCommand($commands, $expected, t('ajax_render() loads settings added with drupal_add_js().'));
|
||||
|
||||
// Verify that AJAX settings are loaded for #type 'link'.
|
||||
// Verify that Ajax settings are loaded for #type 'link'.
|
||||
$this->drupalGet('ajax-test/link');
|
||||
$settings = $this->drupalGetSettings();
|
||||
$this->assertEqual($settings['ajax']['ajax-link']['url'], url('filter/tips'));
|
||||
|
@ -120,7 +120,7 @@ class AJAXFrameworkTestCase extends AJAXTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests AJAX framework commands.
|
||||
* Tests Ajax framework commands.
|
||||
*/
|
||||
class AJAXCommandsTestCase extends AJAXTestCase {
|
||||
public static function getInfo() {
|
||||
|
@ -132,7 +132,7 @@ class AJAXCommandsTestCase extends AJAXTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test the various AJAX Commands.
|
||||
* Test the various Ajax Commands.
|
||||
*/
|
||||
function testAJAXCommands() {
|
||||
$form_path = 'ajax_forms_test_ajax_commands_form';
|
||||
|
@ -324,7 +324,7 @@ class AJAXFormValuesTestCase extends AJAXTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that AJAX-enabled forms work when multiple instances of the same form are on a page.
|
||||
* Tests that Ajax-enabled forms work when multiple instances of the same form are on a page.
|
||||
*/
|
||||
class AJAXMultiFormTestCase extends AJAXTestCase {
|
||||
public static function getInfo() {
|
||||
|
@ -338,7 +338,7 @@ class AJAXMultiFormTestCase extends AJAXTestCase {
|
|||
function setUp() {
|
||||
parent::setUp(array('form_test'));
|
||||
|
||||
// Create a multi-valued field for 'page' nodes to use for AJAX testing.
|
||||
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
|
||||
$field_name = 'field_ajax_test';
|
||||
$field = array(
|
||||
'field_name' => $field_name,
|
||||
|
@ -363,7 +363,7 @@ class AJAXMultiFormTestCase extends AJAXTestCase {
|
|||
*/
|
||||
function testMultiForm() {
|
||||
// HTML IDs for elements within the field are potentially modified with
|
||||
// each AJAX submission, but these variables are stable and help target the
|
||||
// each Ajax submission, but these variables are stable and help target the
|
||||
// desired elements.
|
||||
$field_name = 'field_ajax_test';
|
||||
$field_xpaths = array(
|
||||
|
@ -399,7 +399,7 @@ class AJAXMultiFormTestCase extends AJAXTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Miscellaneous AJAX tests using ajax_test module.
|
||||
* Miscellaneous Ajax tests using ajax_test module.
|
||||
*/
|
||||
class AJAXElementValidation extends AJAXTestCase {
|
||||
public static function getInfo() {
|
||||
|
@ -411,12 +411,12 @@ class AJAXElementValidation extends AJAXTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Try to post an AJAX change to a form that has a validated element.
|
||||
* Try to post an Ajax change to a form that has a validated element.
|
||||
*
|
||||
* The drivertext field is AJAX-enabled. An additional field is not, but
|
||||
* The drivertext field is Ajax-enabled. An additional field is not, but
|
||||
* is set to be a required field. In this test the required field is not
|
||||
* filled in, and we want to see if the activation of the "drivertext"
|
||||
* AJAX-enabled field fails due to the required field being empty.
|
||||
* Ajax-enabled field fails due to the required field being empty.
|
||||
*/
|
||||
function testAJAXElementValidation() {
|
||||
$web_user = $this->drupalCreateUser();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Simpletest mock module for AJAX forms testing.
|
||||
* Simpletest mock module for Ajax forms testing.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ function ajax_forms_test_simple_form($form, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback triggered by select.
|
||||
* Ajax callback triggered by select.
|
||||
*/
|
||||
function ajax_forms_test_simple_form_select_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -77,7 +77,7 @@ function ajax_forms_test_simple_form_select_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback triggered by checkbox.
|
||||
* Ajax callback triggered by checkbox.
|
||||
*/
|
||||
function ajax_forms_test_simple_form_checkbox_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -88,7 +88,7 @@ function ajax_forms_test_simple_form_checkbox_callback($form, $form_state) {
|
|||
|
||||
|
||||
/**
|
||||
* Form to display the AJAX Commands.
|
||||
* Form to display the Ajax Commands.
|
||||
* @param $form
|
||||
* @param $form_state
|
||||
* @return unknown_type
|
||||
|
@ -154,7 +154,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
),
|
||||
);
|
||||
|
||||
// Shows the AJAX 'css' command.
|
||||
// Shows the Ajax 'css' command.
|
||||
$form['css_command_example'] = array(
|
||||
'#value' => t("Set the the '#box' div to be blue."),
|
||||
'#type' => 'submit',
|
||||
|
@ -165,7 +165,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
);
|
||||
|
||||
|
||||
// Shows the AJAX 'data' command. But there is no use of this information,
|
||||
// Shows the Ajax 'data' command. But there is no use of this information,
|
||||
// as this would require a javascript client to use the data.
|
||||
$form['data_command_example'] = array(
|
||||
'#value' => t("AJAX data command: Issue command."),
|
||||
|
@ -176,7 +176,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
'#suffix' => '<div id="data_div">Data attached to this div.</div>',
|
||||
);
|
||||
|
||||
// Shows the AJAX 'invoke' command.
|
||||
// Shows the Ajax 'invoke' command.
|
||||
$form['invoke_command_example'] = array(
|
||||
'#value' => t("AJAX invoke command: Invoke addClass() method."),
|
||||
'#type' => 'submit',
|
||||
|
@ -186,7 +186,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
'#suffix' => '<div id="invoke_div">Original contents</div>',
|
||||
);
|
||||
|
||||
// Shows the AJAX 'html' command.
|
||||
// Shows the Ajax 'html' command.
|
||||
$form['html_command_example'] = array(
|
||||
'#value' => t("AJAX html: Replace the HTML in a selector."),
|
||||
'#type' => 'submit',
|
||||
|
@ -196,7 +196,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
'#suffix' => '<div id="html_div">Original contents</div>',
|
||||
);
|
||||
|
||||
// Shows the AJAX 'insert' command.
|
||||
// Shows the Ajax 'insert' command.
|
||||
$form['insert_command_example'] = array(
|
||||
'#value' => t("AJAX insert: Let client insert based on #ajax['method']."),
|
||||
'#type' => 'submit',
|
||||
|
@ -207,7 +207,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
'#suffix' => '<div id="insert_div">Original contents</div>',
|
||||
);
|
||||
|
||||
// Shows the AJAX 'prepend' command.
|
||||
// Shows the Ajax 'prepend' command.
|
||||
$form['prepend_command_example'] = array(
|
||||
'#value' => t("AJAX 'prepend': Click to prepend something"),
|
||||
'#type' => 'submit',
|
||||
|
@ -217,7 +217,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
'#suffix' => '<div id="prepend_div">Something will be prepended to this div. </div>',
|
||||
);
|
||||
|
||||
// Shows the AJAX 'remove' command.
|
||||
// Shows the Ajax 'remove' command.
|
||||
$form['remove_command_example'] = array(
|
||||
'#value' => t("AJAX 'remove': Click to remove text"),
|
||||
'#type' => 'submit',
|
||||
|
@ -227,7 +227,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
'#suffix' => '<div id="remove_div"><div id="remove_text">text to be removed</div></div>',
|
||||
);
|
||||
|
||||
// Shows the AJAX 'restripe' command.
|
||||
// Shows the Ajax 'restripe' command.
|
||||
$form['restripe_command_example'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t("AJAX 'restripe' command"),
|
||||
|
@ -242,7 +242,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
</div>',
|
||||
);
|
||||
|
||||
// Demonstrates the AJAX 'settings' command. The 'settings' command has
|
||||
// Demonstrates the Ajax 'settings' command. The 'settings' command has
|
||||
// nothing visual to "show", but it can be tested via SimpleTest and via
|
||||
// Firebug.
|
||||
$form['settings_command_example'] = array(
|
||||
|
@ -262,7 +262,7 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'after'.
|
||||
* Ajax callback for 'after'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_after_callback($form, $form_state) {
|
||||
$selector = '#after_div';
|
||||
|
@ -273,7 +273,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'alert'.
|
||||
* Ajax callback for 'alert'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_alert_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -282,7 +282,7 @@ function ajax_forms_test_advanced_commands_alert_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'append'.
|
||||
* Ajax callback for 'append'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_append_callback($form, $form_state) {
|
||||
$selector = '#append_div';
|
||||
|
@ -292,7 +292,7 @@ function ajax_forms_test_advanced_commands_append_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'before'.
|
||||
* Ajax callback for 'before'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_before_callback($form, $form_state) {
|
||||
$selector = '#before_div';
|
||||
|
@ -303,14 +303,14 @@ function ajax_forms_test_advanced_commands_before_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'changed'.
|
||||
* Ajax callback for 'changed'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_changed_callback($form, $form_state) {
|
||||
$commands[] = ajax_command_changed('#changed_div');
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
/**
|
||||
* AJAX callback for 'changed' with asterisk marking inner div.
|
||||
* Ajax callback for 'changed' with asterisk marking inner div.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -319,7 +319,7 @@ function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $for
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'css'.
|
||||
* Ajax callback for 'css'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_css_callback($form, $form_state) {
|
||||
$selector = '#css_div';
|
||||
|
@ -331,7 +331,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'data'.
|
||||
* Ajax callback for 'data'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_data_callback($form, $form_state) {
|
||||
$selector = '#data_div';
|
||||
|
@ -342,7 +342,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'invoke'.
|
||||
* Ajax callback for 'invoke'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_invoke_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -351,7 +351,7 @@ function ajax_forms_test_advanced_commands_invoke_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'html'.
|
||||
* Ajax callback for 'html'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_html_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -360,7 +360,7 @@ function ajax_forms_test_advanced_commands_html_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'insert'.
|
||||
* Ajax callback for 'insert'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_insert_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -369,7 +369,7 @@ function ajax_forms_test_advanced_commands_insert_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'prepend'.
|
||||
* Ajax callback for 'prepend'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_prepend_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -378,7 +378,7 @@ function ajax_forms_test_advanced_commands_prepend_callback($form, $form_state)
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'remove'.
|
||||
* Ajax callback for 'remove'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_remove_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -387,7 +387,7 @@ function ajax_forms_test_advanced_commands_remove_callback($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'restripe'.
|
||||
* Ajax callback for 'restripe'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_restripe_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -396,7 +396,7 @@ function ajax_forms_test_advanced_commands_restripe_callback($form, $form_state)
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for 'settings'.
|
||||
* Ajax callback for 'settings'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_settings_callback($form, $form_state) {
|
||||
$commands = array();
|
||||
|
@ -407,12 +407,12 @@ function ajax_forms_test_advanced_commands_settings_callback($form, $form_state)
|
|||
|
||||
/**
|
||||
* This form and its related submit and callback functions demonstrate
|
||||
* not validating another form element when a single AJAX element is triggered.
|
||||
* not validating another form element when a single Ajax element is triggered.
|
||||
*
|
||||
* The "drivertext" element is an AJAX-enabled textfield, free-form.
|
||||
* The "drivertext" element is an Ajax-enabled textfield, free-form.
|
||||
* The "required_field" element is a textfield marked required.
|
||||
*
|
||||
* The correct behavior is that the AJAX-enabled drivertext element should
|
||||
* The correct behavior is that the Ajax-enabled drivertext element should
|
||||
* be able to trigger without causing validation of the "required_field".
|
||||
*/
|
||||
function ajax_forms_test_validation_form($form, &$form_state) {
|
||||
|
@ -451,7 +451,7 @@ function ajax_forms_test_validation_form_submit($form, $form_state) {
|
|||
}
|
||||
|
||||
/**
|
||||
* AJAX callback for the 'drivertext' element of the validation form.
|
||||
* Ajax callback for the 'drivertext' element of the validation form.
|
||||
*/
|
||||
function ajax_forms_test_validation_form_callback($form, $form_state) {
|
||||
drupal_set_message("ajax_forms_test_validation_form_callback invoked");
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for AJAX framework tests.
|
||||
* Helper module for Ajax framework tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ function ajax_test_render() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Menu callback; Returns AJAX element with #error property set.
|
||||
* Menu callback; Returns Ajax element with #error property set.
|
||||
*/
|
||||
function ajax_test_error() {
|
||||
$message = '';
|
||||
|
|
|
@ -1132,13 +1132,13 @@ class FormsRebuildTestCase extends DrupalWebTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that a form's action is retained after an AJAX submission.
|
||||
* Tests that a form's action is retained after an Ajax submission.
|
||||
*
|
||||
* The 'action' attribute of a form should not change after an AJAX submission
|
||||
* followed by a non-AJAX submission, which triggers a validation error.
|
||||
* The 'action' attribute of a form should not change after an Ajax submission
|
||||
* followed by a non-Ajax submission, which triggers a validation error.
|
||||
*/
|
||||
function testPreserveFormActionAfterAJAX() {
|
||||
// Create a multi-valued field for 'page' nodes to use for AJAX testing.
|
||||
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
|
||||
$field_name = 'field_ajax_test';
|
||||
$field = array(
|
||||
'field_name' => $field_name,
|
||||
|
@ -1157,14 +1157,14 @@ class FormsRebuildTestCase extends DrupalWebTestCase {
|
|||
$this->web_user = $this->drupalCreateUser(array('create page content'));
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
||||
// Get the form for adding a 'page' node. Submit an "add another item" AJAX
|
||||
// Get the form for adding a 'page' node. Submit an "add another item" Ajax
|
||||
// submission and verify it worked by ensuring the updated page has two text
|
||||
// field items in the field for which we just added an item.
|
||||
$this->drupalGet('node/add/page');
|
||||
$this->drupalPostAJAX(NULL, array(), array('field_ajax_test_add_more' => t('Add another item')), 'system/ajax', array(), array(), 'page-node-form');
|
||||
$this->assert(count($this->xpath('//div[contains(@class, "field-name-field-ajax-test")]//input[@type="text"]')) == 2, t('AJAX submission succeeded.'));
|
||||
|
||||
// Submit the form with the non-AJAX "Save" button, leaving the title field
|
||||
// Submit the form with the non-Ajax "Save" button, leaving the title field
|
||||
// blank to trigger a validation error, and ensure that a validation error
|
||||
// occurred, because this test is for testing what happens when a form is
|
||||
// re-rendered without being re-built, which is what happens when there's
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* hook_menu().
|
||||
*/
|
||||
function form_test_load_include_menu($form, &$form_state) {
|
||||
// Submit the form via AJAX. That way the FAPI has to care about including
|
||||
// Submit the form via Ajax. That way the FAPI has to care about including
|
||||
// the file specified in hook_menu().
|
||||
$ajax_wrapper_id = drupal_html_id('form-test-load-include-menu-ajax-wrapper');
|
||||
$form['ajax_wrapper'] = array(
|
||||
|
@ -43,7 +43,7 @@ function form_test_load_include_submit($form, $form_state) {
|
|||
function form_test_load_include_menu_ajax($form) {
|
||||
// We don't need to return anything, since #ajax['method'] is 'append', which
|
||||
// does not remove the original #ajax['wrapper'] element, and status messages
|
||||
// are automatically added by the AJAX framework as long as there's a wrapper
|
||||
// are automatically added by the Ajax framework as long as there's a wrapper
|
||||
// element to add them to.
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -824,7 +824,7 @@ function hook_css_alter(&$css) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Alter the commands that are sent to the user through the AJAX framework.
|
||||
* Alter the commands that are sent to the user through the Ajax framework.
|
||||
*
|
||||
* @param $commands
|
||||
* An array of all commands that will be sent to the user.
|
||||
|
@ -3894,7 +3894,7 @@ function hook_date_formats_alter(&$formats) {
|
|||
function hook_page_delivery_callback_alter(&$callback) {
|
||||
// jQuery sets a HTTP_X_REQUESTED_WITH header of 'XMLHttpRequest'.
|
||||
// If a page would normally be delivered as an html page, and it is called
|
||||
// from jQuery, deliver it instead as an AJAX response.
|
||||
// from jQuery, deliver it instead as an Ajax response.
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && $callback == 'drupal_deliver_html_page') {
|
||||
$callback = 'ajax_deliver';
|
||||
}
|
||||
|
|
|
@ -295,10 +295,10 @@ function system_element_info() {
|
|||
'#theme' => 'page',
|
||||
'#theme_wrappers' => array('html'),
|
||||
);
|
||||
// By default, we don't want AJAX commands being rendered in the context of an
|
||||
// By default, we don't want Ajax commands being rendered in the context of an
|
||||
// HTML page, so we don't provide defaults for #theme or #theme_wrappers.
|
||||
// However, modules can set these properties (for example, to provide an HTML
|
||||
// debugging page that displays rather than executes AJAX commands).
|
||||
// debugging page that displays rather than executes Ajax commands).
|
||||
$types['ajax'] = array(
|
||||
'#header' => TRUE,
|
||||
'#commands' => array(),
|
||||
|
@ -1079,7 +1079,7 @@ function _system_batch_theme() {
|
|||
* Implements hook_library().
|
||||
*/
|
||||
function system_library() {
|
||||
// Drupal's AJAX framework.
|
||||
// Drupal's Ajax framework.
|
||||
$libraries['drupal.ajax'] = array(
|
||||
'title' => 'Drupal AJAX',
|
||||
'website' => 'http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax/7',
|
||||
|
@ -3451,7 +3451,7 @@ function system_page_alter(&$page) {
|
|||
*/
|
||||
function system_run_automated_cron() {
|
||||
// If the site is not fully installed, suppress the automated cron run.
|
||||
// Otherwise it could be triggered prematurely by AJAX requests during
|
||||
// Otherwise it could be triggered prematurely by Ajax requests during
|
||||
// installation.
|
||||
if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') {
|
||||
$cron_last = variable_get('cron_last', NULL);
|
||||
|
|
Loading…
Reference in New Issue