diff --git a/includes/common.inc b/includes/common.inc
index d356a61651e48c4481c04a61432963b66412e26b..a3579c1f803feae4c959ae11acd7732131a99480 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3549,6 +3549,7 @@ function _drupal_bootstrap_full() {
require_once DRUPAL_ROOT . '/includes/form.inc';
require_once DRUPAL_ROOT . '/includes/mail.inc';
require_once DRUPAL_ROOT . '/includes/actions.inc';
+ require_once DRUPAL_ROOT . '/includes/ajax.inc';
// Set the Drupal custom error handler.
set_error_handler('_drupal_error_handler');
set_exception_handler('_drupal_exception_handler');
diff --git a/includes/form.inc b/includes/form.inc
index 6f7d96305473e1de595d610d4d0a268f58575a79..d6552b04329c05c3573cd9caeb2662516870bb2d 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -1800,48 +1800,6 @@ function weight_value(&$form) {
}
}
-/**
- * Menu callback for AHAH callbacks through the #ahah['callback'] FAPI property.
- */
-function form_ahah_callback() {
- $form_state = form_state_defaults();
-
- $form_build_id = $_POST['form_build_id'];
-
- // Get the form from the cache.
- $form = form_get_cache($form_build_id, $form_state);
- if (!$form) {
- // If $form cannot be loaded from the cache, the form_build_id in $_POST must
- // be invalid, which means that someone performed a POST request onto
- // system/ahah without actually viewing the concerned form in the browser.
- // This is likely a hacking attempt as it never happens under normal
- // circumstances, so we just do nothing.
- exit;
- }
-
- // We will run some of the submit handlers so we need to disable redirecting.
- $form['#redirect'] = FALSE;
-
- // We need to process the form, prepare for that by setting a few internals
- // variables.
- $form_state['input'] = $_POST;
- $form_state['args'] = $form['#args'];
- $form_id = $form['#form_id'];
-
- // Build, validate and if possible, submit the form.
- drupal_process_form($form_id, $form, $form_state);
-
- // This call recreates the form relying solely on the form_state that the
- // drupal_process_form set up.
- $form = drupal_rebuild_form($form_id, $form_state, $form_build_id);
-
- // Get the callback function from the clicked button.
- $callback = $form_state['clicked_button']['#ahah']['callback'];
- if (drupal_function_exists($callback)) {
- $callback($form, $form_state);
- }
-}
-
/**
* Roll out a single radios element to a list of radios,
* using the options array as index.
@@ -1861,7 +1819,7 @@ function form_process_radios($element) {
'#attributes' => $element['#attributes'],
'#parents' => $element['#parents'],
'#id' => form_clean_id('edit-' . implode('-', $parents_for_id)),
- '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
+ '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
);
}
}
@@ -1970,91 +1928,6 @@ function theme_text_format_wrapper($element) {
return $output;
}
-/**
- * Add AHAH information about a form element to the page to communicate with
- * javascript. If #ahah[path] is set on an element, this additional javascript is
- * added to the page header to attach the AHAH behaviors. See ahah.js for more
- * information.
- *
- * @param $element
- * An associative array containing the properties of the element.
- * Properties used: ahah_event, ahah_path, ahah_wrapper, ahah_parameters,
- * ahah_effect.
- * @return
- * None. Additional code is added to the header of the page using
- * drupal_add_js.
- */
-function form_process_ahah($element) {
- $js_added = &drupal_static(__FUNCTION__, array());
- // Add a reasonable default event handler if none specified.
- if (isset($element['#ahah']) && !isset($element['#ahah']['event'])) {
- switch ($element['#type']) {
- case 'submit':
- case 'button':
- 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 AHAH behaviors.
- $element['#ahah']['event'] = 'mousedown';
- // Attach an additional event handler so that AHAH behaviors
- // can be triggered still via keyboard input.
- $element['#ahah']['keypress'] = TRUE;
- break;
- case 'password':
- case 'textfield':
- case 'textarea':
- $element['#ahah']['event'] = 'blur';
- break;
- case 'radio':
- case 'checkbox':
- case 'select':
- $element['#ahah']['event'] = 'change';
- break;
- default:
- return $element;
- }
- }
-
- // Adding the same javascript settings twice will cause a recursion error,
- // we avoid the problem by checking if the javascript has already been added.
- if ((isset($element['#ahah']['callback']) || isset($element['#ahah']['path'])) && isset($element['#ahah']['event']) && !isset($js_added[$element['#id']])) {
- drupal_add_library('system', 'form');
- drupal_add_js('misc/ahah.js');
-
- $ahah_binding = array(
- 'url' => isset($element['#ahah']['callback']) ? url('system/ahah') : url($element['#ahah']['path']),
- 'event' => $element['#ahah']['event'],
- 'keypress' => empty($element['#ahah']['keypress']) ? NULL : $element['#ahah']['keypress'],
- 'wrapper' => empty($element['#ahah']['wrapper']) ? NULL : $element['#ahah']['wrapper'],
- 'selector' => empty($element['#ahah']['selector']) ? '#' . $element['#id'] : $element['#ahah']['selector'],
- 'effect' => empty($element['#ahah']['effect']) ? 'none' : $element['#ahah']['effect'],
- 'method' => empty($element['#ahah']['method']) ? 'replace' : $element['#ahah']['method'],
- 'progress' => empty($element['#ahah']['progress']) ? array('type' => 'throbber') : $element['#ahah']['progress'],
- 'button' => isset($element['#executes_submit_callback']) ? array($element['#name'] => $element['#value']) : FALSE,
- );
-
- // Convert a simple #ahah[progress] type string into an array.
- if (is_string($ahah_binding['progress'])) {
- $ahah_binding['progress'] = array('type' => $ahah_binding['progress']);
- }
- // Change progress path to a full url.
- if (isset($ahah_binding['progress']['path'])) {
- $ahah_binding['progress']['url'] = url($ahah_binding['progress']['path']);
- }
-
- // Add progress.js if we're doing a bar display.
- if ($ahah_binding['progress']['type'] == 'bar') {
- drupal_add_js('misc/progress.js', array('cache' => FALSE));
- }
-
- drupal_add_js(array('ahah' => array($element['#id'] => $ahah_binding)), 'setting');
-
- $js_added[$element['#id']] = TRUE;
- $element['#cache'] = TRUE;
- }
- return $element;
-}
-
/**
* Format a checkbox.
*
@@ -2132,7 +2005,7 @@ function form_process_checkboxes($element) {
'#return_value' => $key,
'#default_value' => isset($value[$key]),
'#attributes' => $element['#attributes'],
- '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
+ '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
);
}
}
@@ -2245,7 +2118,7 @@ function form_process_tableselect($element) {
'#return_value' => $key,
'#default_value' => isset($value[$key]),
'#attributes' => $element['#attributes'],
- '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
+ '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
);
}
else {
@@ -2260,7 +2133,7 @@ function form_process_tableselect($element) {
'#attributes' => $element['#attributes'],
'#parents' => $element['#parents'],
'#id' => form_clean_id('edit-' . implode('-', $parents_for_id)),
- '#ahah' => isset($element['#ahah']) ? $element['#ahah'] : NULL,
+ '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
);
}
}
diff --git a/misc/ahah.js b/misc/ahah.js
deleted file mode 100644
index 84ff070827555858faea5c91af71c7d6b9c6e365..0000000000000000000000000000000000000000
--- a/misc/ahah.js
+++ /dev/null
@@ -1,259 +0,0 @@
-// $Id$
-(function ($) {
-
-/**
- * Provides AJAX-like page updating via AHAH (Asynchronous HTML and HTTP).
- *
- * AHAH is a method of making a request via Javascript while viewing an HTML
- * page. The request returns a small chunk of HTML, which is then directly
- * injected into the page.
- *
- * Drupal uses this file to enhance form elements with #ahah[path] and
- * #ahah[wrapper] properties. If set, this file will automatically be included
- * to provide AHAH capabilities.
- */
-
-Drupal.ahah = Drupal.ahah || {};
-
-/**
- * Attaches the ahah behavior to each ahah form element.
- */
-Drupal.behaviors.ahah = {
- attach: function (context, settings) {
- for (var base in settings.ahah) {
- if (!$('#' + base + '.ahah-processed').size()) {
- var element_settings = settings.ahah[base];
-
- $(element_settings.selector).each(function () {
- element_settings.element = this;
- Drupal.ahah[base] = new Drupal.ahah(base, element_settings);
- });
-
- $('#' + base).addClass('ahah-processed');
- }
- }
- }
-};
-
-/**
- * AHAH object.
- *
- * All AHAH objects on a page are accessible through the global Drupal.ahah 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 AHAH 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
- * Drupal.behaviors.myCustomAhahStuff = {
- * attach: function(context, settings) {
- * Drupal.ahah['edit-submit'].insertNewContent = function(response, status) {
- * new_content = $(response.data);
- * $('#my-wrapper').append(new_content);
- * alert('New content was appended to #my-wrapper');
- * }
- * }
- * };
- * @endcode
- */
-Drupal.ahah = function (base, element_settings) {
- // Set the properties for this object.
- this.element = element_settings.element;
- this.selector = element_settings.selector;
- this.event = element_settings.event;
- this.keypress = element_settings.keypress;
- this.url = element_settings.url;
- this.wrapper = '#' + element_settings.wrapper;
- this.effect = element_settings.effect;
- this.method = element_settings.method;
- this.progress = element_settings.progress;
- this.button = element_settings.button || { };
-
- if (this.effect == 'none') {
- this.showEffect = 'show';
- this.hideEffect = 'hide';
- this.showSpeed = '';
- }
- else if (this.effect == 'fade') {
- this.showEffect = 'fadeIn';
- this.hideEffect = 'fadeOut';
- this.showSpeed = 'slow';
- }
- else {
- this.showEffect = this.effect + 'Toggle';
- this.hideEffect = this.effect + 'Toggle';
- this.showSpeed = 'slow';
- }
-
- // Record the form action and target, needed for iFrame file uploads.
- var form = $(this.element).parents('form');
- this.form_action = form.attr('action');
- this.form_target = form.attr('target');
- this.form_encattr = form.attr('encattr');
-
- // Set the options for the ajaxSubmit function.
- // The 'this' variable will not persist inside of the options object.
- var ahah = this;
- var options = {
- url: ahah.url,
- data: ahah.button,
- beforeSubmit: function (form_values, element_settings, options) {
- return ahah.beforeSubmit(form_values, element_settings, options);
- },
- success: function (response, status) {
- // Sanity check for browser support (object expected).
- // When using iFrame uploads, responses must be returned as a string.
- if (typeof response == 'string') {
- response = Drupal.parseJson(response);
- }
- return ahah.success(response, status);
- },
- complete: function (response, status) {
- if (status == 'error' || status == 'parsererror') {
- return ahah.error(response, ahah.url);
- }
- },
- dataType: 'json',
- type: 'POST'
- };
-
- // Bind the ajaxSubmit function to the element event.
- $(element_settings.element).bind(element_settings.event, function () {
- $(element_settings.element).parents('form').ajaxSubmit(options);
- return false;
- });
- // If necessary, enable keyboard submission so that AHAH behaviors
- // can be triggered through keyboard input as well as e.g. a mousedown
- // action.
- if (element_settings.keypress) {
- $(element_settings.element).keypress(function (event) {
- // Detect enter key.
- if (event.keyCode == 13) {
- $(element_settings.element).trigger(element_settings.event);
- return false;
- }
- });
- }
-};
-
-/**
- * Handler for the form redirection submission.
- */
-Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) {
- // Disable the element that received the change.
- $(this.element).addClass('progress-disabled').attr('disabled', true);
-
- // Insert progressbar or throbber.
- if (this.progress.type == 'bar') {
- var progressBar = new Drupal.progressBar('ahah-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback));
- if (this.progress.message) {
- progressBar.setProgress(-1, this.progress.message);
- }
- if (this.progress.url) {
- progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500);
- }
- this.progress.element = $(progressBar.element).addClass('ahah-progress ahah-progress-bar');
- this.progress.object = progressBar;
- $(this.element).after(this.progress.element);
- }
- else if (this.progress.type == 'throbber') {
- this.progress.element = $('
' . (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
+ // Add a DIV around the new field to receive the AJAX effect.
+ $field_form[$delta]['#prefix'] = '
' . (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
$field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') . '
';
// Prevent duplicate wrapper.
unset($field_form['#prefix'], $field_form['#suffix']);
- // If a newly inserted widget contains AHAH behaviors, they normally won't
- // work because AHAH doesn't know about those - it just attaches to the exact
- // form elements that were initially specified in the Drupal.settings object.
- // The new ones didn't exist then, so we need to update Drupal.settings
- // by ourselves in order to let AHAH know about those new form elements.
- $javascript = drupal_add_js(NULL, NULL);
- $output_js = isset($javascript['setting']) ? '' : '';
-
- $output = theme('status_messages') . drupal_render($field_form) . $output_js;
- drupal_json(array('status' => TRUE, 'data' => $output));
- exit;
+ $output = theme('status_messages') . drupal_render($field_form);
+
+ $commands = array();
+ $commands[] = ajax_command_replace(NULL, $output);
+ ajax_render($commands);
}
diff --git a/modules/field/field.test b/modules/field/field.test
index fce0fd8c273a32927b956f0586157d766e3f6e6a..49a1694bf68c6a59c112bcd01b6134731d5e696b 100644
--- a/modules/field/field.test
+++ b/modules/field/field.test
@@ -1336,12 +1336,19 @@ class FieldFormTestCase extends DrupalWebTestCase {
unset($this->additionalCurlOptions[CURLOPT_URL]);
// The response is drupal_json, so we need to undo some escaping.
- $response = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
- $this->assertTrue(is_object($response), t('The response is an object'));
- $this->assertIdentical($response->status, TRUE, t('Response status is true'));
+ $commands = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
+
+ // The JSON response will be two AJAX commands. The first is a settings
+ // command and the second is the replace command.
+ $settings = reset($commands);
+ $replace = next($commands);
+
+ $this->assertTrue(is_object($settings), t('The response settings command is an object'));
+ $this->assertTrue(is_object($replace), t('The response replace command is an object'));
+
// This response data is valid HTML so we will can reuse everything we have
// for HTML pages.
- $this->content = $response->data;
+ $this->content = $replace->data;
// Needs to be emptied out so the new content will be parsed.
$this->elements = '';
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 26236fd7d01c44f6c83118e40a0fde8356dddce3..b8493a3978bb967723bc5fdc58b7ee24b67065b8 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -263,14 +263,14 @@ function poll_form($node, $form_state) {
}
// We name our button 'poll_more' to avoid conflicts with other modules using
- // AHAH-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'),
'#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
'#weight' => 1,
'#submit' => array('poll_more_choices_submit'), // If no javascript action.
- '#ahah' => array(
+ '#ajax' => array(
'callback' => 'poll_choice_js',
'wrapper' => 'poll-choices',
'method' => 'replace',
@@ -320,7 +320,7 @@ function poll_more_choices_submit($form, &$form_state) {
// Make the changes we want to the form state.
if ($form_state['values']['poll_more']) {
- $n = $_GET['q'] == 'system/ahah' ? 1 : 5;
+ $n = $_GET['q'] == 'system/ajax' ? 1 : 5;
$form_state['choice_count'] = count($form_state['values']['choice']) + $n;
}
}
@@ -373,9 +373,7 @@ function poll_choice_js($form, $form_state) {
// Prevent duplicate wrappers.
unset($choice_form['#prefix'], $choice_form['#suffix']);
- $output = theme('status_messages') . drupal_render($choice_form);
-
- drupal_json(array('status' => TRUE, 'data' => $output));
+ return theme('status_messages') . drupal_render($choice_form);
}
/**
diff --git a/modules/poll/poll.test b/modules/poll/poll.test
index f5b018095aab95fcb5e47ab06b5575b5694151c1..a5f668efaaa765e635f842f63a60fff060efabf9 100644
--- a/modules/poll/poll.test
+++ b/modules/poll/poll.test
@@ -340,17 +340,24 @@ class PollJSAddChoice extends DrupalWebTestCase {
// @TODO: the framework should make it possible to submit a form to a
// different URL than its action or the current. For now, we can just force
// it.
- $this->additionalCurlOptions[CURLOPT_URL] = url('system/ahah', array('absolute' => TRUE));
+ $this->additionalCurlOptions[CURLOPT_URL] = url('system/ajax', array('absolute' => TRUE));
$this->drupalPost(NULL, $edit, t('More choices'));
unset($this->additionalCurlOptions[CURLOPT_URL]);
// The response is drupal_json, so we need to undo some escaping.
- $response = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
- $this->assertTrue(is_object($response), t('The response is an object'));
- $this->assertIdentical($response->status, TRUE, t('Response status is true'));
- // This response data is valid HTML so we will can reuse everything we have
+ $commands = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
+
+ // The JSON response will be two AJAX commands. The first is a settings
+ // command and the second is the replace command.
+ $settings = reset($commands);
+ $replace = next($commands);
+
+ $this->assertTrue(is_object($settings), t('The response settings command is an object'));
+ $this->assertTrue(is_object($replace), t('The response replace command is an object'));
+
+ // This replace data is valid HTML so we will can reuse everything we have
// for HTML pages.
- $this->content = $response->data;
+ $this->content = $replace->data;
// Needs to be emptied out so the new content will be parsed.
$this->elements = '';
diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module
index 34b495f5df81550cd113ee5d9086efc5f28268b0..6646e85a8b97d79700cc8d99f15a8f1ec92bdfec 100644
--- a/modules/simpletest/tests/form_test.module
+++ b/modules/simpletest/tests/form_test.module
@@ -294,7 +294,7 @@ function form_test_mock_form_submit($form, &$form_state) {
* It uses two steps for editing a virtual "thing". Any changes to it are saved
* in the form storage and have to be present during any step. By setting the
* request parameter "cache" the form can be tested with caching enabled, as
- * it would be the case, if the form would contain some #ahah callbacks.
+ * it would be the case, if the form would contain some #ajax callbacks.
*
* @see form_storage_test_form_submit().
*/
diff --git a/modules/system/system-rtl.css b/modules/system/system-rtl.css
index 0983da8dc275f48d944e723d4fd076c589e1af1a..511143a04000e6e3099725df6645abf2496b33f0 100644
--- a/modules/system/system-rtl.css
+++ b/modules/system/system-rtl.css
@@ -81,10 +81,10 @@ div.teaser-button-wrapper {
.progress-disabled {
float: right;
}
-.ahah-progress {
+.ajax-progress {
float: right;
}
-.ahah-progress .throbber {
+.ajax-progress .throbber {
float: right;
}
input.password-field {
diff --git a/modules/system/system.css b/modules/system/system.css
index 8e020a33e7952c18bd45d008a98e02b36c748588..531ae65edb78083a4278830bb5c0be5765d4e90e 100644
--- a/modules/system/system.css
+++ b/modules/system/system.css
@@ -450,20 +450,20 @@ html.js .no-js {
.progress-disabled {
float: left; /* LTR */
}
-.ahah-progress {
+.ajax-progress {
float: left; /* LTR */
}
-.ahah-progress .throbber {
+.ajax-progress .throbber {
width: 15px;
height: 15px;
margin: 2px;
background: transparent url(../../misc/throbber.gif) no-repeat 0px -18px;
float: left; /* LTR */
}
-tr .ahah-progress .throbber {
+tr .ajax-progress .throbber {
margin: 0 2px;
}
-.ahah-progress-bar {
+.ajax-progress-bar {
width: 16em;
}
diff --git a/modules/system/system.module b/modules/system/system.module
index d6a4ab3ee51cf1d45cb08b9265c1914a485123c1..001949c0417662ae7d2c3f5af419704a999533e5 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -286,7 +286,7 @@ function system_elements() {
'#name' => 'op',
'#button_type' => 'submit',
'#executes_submit_callback' => TRUE,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme_wrappers' => array('button'),
);
@@ -295,7 +295,7 @@ function system_elements() {
'#name' => 'op',
'#button_type' => 'submit',
'#executes_submit_callback' => FALSE,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme_wrappers' => array('button'),
);
@@ -303,7 +303,7 @@ function system_elements() {
'#input' => TRUE,
'#button_type' => 'submit',
'#executes_submit_callback' => TRUE,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#return_value' => TRUE,
'#has_garbage_value' => TRUE,
'#src' => NULL,
@@ -315,7 +315,7 @@ function system_elements() {
'#size' => 60,
'#maxlength' => 128,
'#autocomplete_path' => FALSE,
- '#process' => array('form_process_text_format', 'form_process_ahah'),
+ '#process' => array('form_process_text_format', 'ajax_process_form'),
'#theme' => 'textfield',
'#theme_wrappers' => array('form_element'),
);
@@ -324,7 +324,7 @@ function system_elements() {
'#input' => TRUE,
'#size' => 60,
'#maxlength' => 128,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'password',
'#theme_wrappers' => array('form_element'),
);
@@ -340,7 +340,7 @@ function system_elements() {
'#cols' => 60,
'#rows' => 5,
'#resizable' => TRUE,
- '#process' => array('form_process_text_format', 'form_process_ahah'),
+ '#process' => array('form_process_text_format', 'ajax_process_form'),
'#theme' => 'textarea',
'#theme_wrappers' => array('form_element'),
);
@@ -355,7 +355,7 @@ function system_elements() {
$type['radio'] = array(
'#input' => TRUE,
'#default_value' => NULL,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'radio',
'#theme_wrappers' => array('form_element'),
'#form_element_skip_title' => TRUE,
@@ -372,7 +372,7 @@ function system_elements() {
$type['checkbox'] = array(
'#input' => TRUE,
'#return_value' => 1,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'checkbox',
'#theme_wrappers' => array('form_element'),
'#form_element_skip_title' => TRUE,
@@ -382,7 +382,7 @@ function system_elements() {
'#input' => TRUE,
'#size' => 0,
'#multiple' => FALSE,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'select',
'#theme_wrappers' => array('form_element'),
);
@@ -391,7 +391,7 @@ function system_elements() {
'#input' => TRUE,
'#delta' => 10,
'#default_value' => 0,
- '#process' => array('form_process_weight', 'form_process_ahah'),
+ '#process' => array('form_process_weight', 'ajax_process_form'),
);
$type['date'] = array(
@@ -430,7 +430,7 @@ function system_elements() {
$type['hidden'] = array(
'#input' => TRUE,
- '#process' => array('form_process_ahah'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'hidden',
);
@@ -447,7 +447,7 @@ function system_elements() {
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#value' => NULL,
- '#process' => array('form_process_fieldset', 'form_process_ahah'),
+ '#process' => array('form_process_fieldset', 'ajax_process_form'),
'#pre_render' => array('form_pre_render_fieldset'),
'#theme_wrappers' => array('fieldset'),
);
@@ -476,9 +476,9 @@ function system_menu() {
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
- $items['system/ahah'] = array(
+ $items['system/ajax'] = array(
'title' => 'AHAH callback',
- 'page callback' => 'form_ahah_callback',
+ 'page callback' => 'ajax_form_callback',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index b04b92894cd6bd620664b7e4effdafeed46a8c59..772e329ed94d64d44f11989e578bdc389ff5c389 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -60,7 +60,7 @@ function upload_permission() {
*/
function upload_node_links($node, $build_mode) {
$links = array();
-
+
// Display a link with the number of attachments
$num_files = 0;
foreach ($node->files as $file) {
@@ -236,7 +236,7 @@ function upload_form_alter(&$form, $form_state, $form_id) {
'#weight' => 30,
);
- // Wrapper for fieldset contents (used by ahah.js).
+ // Wrapper for fieldset contents (used by ajax.js).
$form['attachments']['wrapper'] = array(
'#prefix' => '
',
'#suffix' => '
',
@@ -582,7 +582,7 @@ function _upload_form($node) {
'#type' => 'submit',
'#value' => t('Attach'),
'#name' => 'attach',
- '#ahah' => array(
+ '#ajax' => array(
'path' => 'upload/js',
'wrapper' => 'attach-wrapper',
'progress' => array('type' => 'bar', 'message' => t('Please wait...')),
@@ -692,9 +692,11 @@ function upload_js() {
$form = form_builder('upload_js', $form, $form_state);
$output = theme('status_messages') . drupal_render($form);
- // We send the updated file attachments form.
- // Don't call drupal_json(). ahah.js uses an iframe and
- // the header output by drupal_json() causes problems in some browsers.
- print drupal_to_js(array('status' => TRUE, 'data' => $output));
- exit;
+ $commands = array();
+ $commands[] = ajax_command_replace(NULL, $output);
+
+ // AJAX uploads use an