diff options
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/ajax_forms_test.module | 28 | ||||
-rw-r--r-- | modules/simpletest/tests/ajax_test.module | 18 |
2 files changed, 22 insertions, 24 deletions
diff --git a/modules/simpletest/tests/ajax_forms_test.module b/modules/simpletest/tests/ajax_forms_test.module index 176f0697d..040a1d9b8 100644 --- a/modules/simpletest/tests/ajax_forms_test.module +++ b/modules/simpletest/tests/ajax_forms_test.module @@ -67,7 +67,7 @@ function ajax_forms_test_simple_form_select_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_html('#ajax_selected_color', $form_state['values']['select']); $commands[] = ajax_command_data('#ajax_selected_color', 'form_state_value_select', $form_state['values']['select']); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -77,7 +77,7 @@ function ajax_forms_test_simple_form_checkbox_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_html('#ajax_checkbox_value', (int)$form_state['values']['checkbox']); $commands[] = ajax_command_data('#ajax_checkbox_value', 'form_state_value_select', (int)$form_state['values']['checkbox']); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } @@ -233,7 +233,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_after($selector, "This will be placed after"); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -242,7 +242,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, $form_state) { function ajax_forms_test_advanced_commands_alert_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_alert("Alert"); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -252,7 +252,7 @@ function ajax_forms_test_advanced_commands_append_callback($form, $form_state) { $selector = '#append_div'; $commands = array(); $commands[] = ajax_command_append($selector, "Appended text"); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -263,7 +263,7 @@ function ajax_forms_test_advanced_commands_before_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_before($selector, "Before text"); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -271,7 +271,7 @@ function ajax_forms_test_advanced_commands_before_callback($form, $form_state) { */ function ajax_forms_test_advanced_commands_changed_callback($form, $form_state) { $commands[] = ajax_command_changed('#changed_div'); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** * AJAX callback for 'changed' with asterisk marking inner div. @@ -279,7 +279,7 @@ function ajax_forms_test_advanced_commands_changed_callback($form, $form_state) function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_changed('#changed_div', '#changed_div_mark_this'); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -291,7 +291,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_css($selector, array('background-color' => $color)); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -302,7 +302,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_data($selector, 'testkey', 'testvalue'); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -311,7 +311,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, $form_state) { function ajax_forms_test_advanced_commands_html_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_html('#html_div', 'replacement text'); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -320,7 +320,7 @@ function ajax_forms_test_advanced_commands_html_callback($form, $form_state) { function ajax_forms_test_advanced_commands_prepend_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_prepend('#prepend_div', "prepended text"); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -329,7 +329,7 @@ function ajax_forms_test_advanced_commands_prepend_callback($form, $form_state) function ajax_forms_test_advanced_commands_remove_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_remove('#remove_text'); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** @@ -338,5 +338,5 @@ function ajax_forms_test_advanced_commands_remove_callback($form, $form_state) { function ajax_forms_test_advanced_commands_restripe_callback($form, $form_state) { $commands = array(); $commands[] = ajax_command_restripe('#restripe_table'); - return array('#type' => 'ajax_commands', '#ajax_commands' => $commands); + return array('#type' => 'ajax', '#commands' => $commands); } diff --git a/modules/simpletest/tests/ajax_test.module b/modules/simpletest/tests/ajax_test.module index 958617041..44c20f515 100644 --- a/modules/simpletest/tests/ajax_test.module +++ b/modules/simpletest/tests/ajax_test.module @@ -13,12 +13,14 @@ function ajax_test_menu() { $items['ajax-test/render'] = array( 'title' => 'ajax_render', 'page callback' => 'ajax_test_render', + 'delivery callback' => 'ajax_deliver', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); $items['ajax-test/render-error'] = array( 'title' => 'ajax_render_error', - 'page callback' => 'ajax_test_render_error', + 'page callback' => 'ajax_test_error', + 'delivery callback' => 'ajax_deliver', 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); @@ -26,7 +28,7 @@ function ajax_test_menu() { } /** - * Menu callback; Copies $_GET['commands'] into $commands and ajax_render()s that. + * Menu callback; Returns $_GET['commands'] suitable for use by ajax_deliver(). * * Additionally ensures that ajax_render() incorporates JavaScript settings * by invoking drupal_add_js() with a dummy setting. @@ -40,20 +42,16 @@ function ajax_test_render() { // Add a dummy JS setting. drupal_add_js(array('ajax' => 'test'), 'setting'); - // Output AJAX commands and end the request. - ajax_render($commands); + return array('#type' => 'ajax', '#commands' => $commands); } /** - * Menu callback; Invokes ajax_render_error(). - * - * Optionally passes $_GET['message'] to ajax_render_error(). + * Menu callback; Returns AJAX element with #error property set. */ -function ajax_test_render_error() { +function ajax_test_error() { $message = ''; if (!empty($_GET['message'])) { $message = $_GET['message']; } - ajax_render_error($message); + return array('#type' => 'ajax', '#error' => $message); } - |