summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--misc/ajax.js7
-rw-r--r--modules/simpletest/tests/ajax.test5
-rw-r--r--modules/simpletest/tests/ajax_forms_test.module8
3 files changed, 14 insertions, 6 deletions
diff --git a/misc/ajax.js b/misc/ajax.js
index 9a85ee5e0..b1688e0d4 100644
--- a/misc/ajax.js
+++ b/misc/ajax.js
@@ -396,6 +396,13 @@ Drupal.ajax.prototype.commands = {
},
/**
+ * Command to provide the jQuery css() function.
+ */
+ css: function (ajax, response, status) {
+ $(response.selector).css(response.argument);
+ },
+
+ /**
* Command to set the settings that will be used for other commands in this response.
*/
settings: function (ajax, response, status) {
diff --git a/modules/simpletest/tests/ajax.test b/modules/simpletest/tests/ajax.test
index 580cd4add..13e566bbc 100644
--- a/modules/simpletest/tests/ajax.test
+++ b/modules/simpletest/tests/ajax.test
@@ -112,7 +112,10 @@ class AJAXCommandsTestCase extends AJAXTestCase {
$command = $commands[1];
$this->assertTrue($command['command'] == 'changed' && $command['selector'] == '#changed_div' && $command['asterisk'] == '#changed_div_mark_this', "'changed' AJAX command (with asterisk) issued with correct selector");
- // 'css' command will go here when it is implemented.
+ // Tests the 'css' command.
+ $commands = $this->drupalPostAJAX($form_path, $edit, 'css_command_example');
+ $command = $commands[1];
+ $this->assertTrue($command['command'] == 'css' && $command['selector'] == '#css_div' && $command['argument']['background-color'] == 'blue', "'css' AJAX command issued with correct selector");
// Tests the 'data' command.
$commands = $this->drupalPostAJAX($form_path, $edit, 'data_command_example');
diff --git a/modules/simpletest/tests/ajax_forms_test.module b/modules/simpletest/tests/ajax_forms_test.module
index a0dcfc0e0..176f0697d 100644
--- a/modules/simpletest/tests/ajax_forms_test.module
+++ b/modules/simpletest/tests/ajax_forms_test.module
@@ -149,11 +149,9 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
);
// Shows the AJAX 'css' command.
- // @todo Note that this won't work until http://drupal.org/node/623320 lands.
$form['css_command_example'] = array(
- '#title' => t("AJAX CSS: Choose the color you'd like the '#box' div to be."),
- '#type' => 'select',
- '#options' => array('green' => 'green', 'blue' => 'blue'),
+ '#value' => t("Set the the '#box' div to be blue."),
+ '#type' => 'submit',
'#ajax' => array(
'callback' => 'ajax_forms_test_advanced_commands_css_callback',
),
@@ -289,7 +287,7 @@ function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $for
*/
function ajax_forms_test_advanced_commands_css_callback($form, $form_state) {
$selector = '#css_div';
- $color = $form_state['values']['css_command_example'];
+ $color = 'blue';
$commands = array();
$commands[] = ajax_command_css($selector, array('background-color' => $color));