Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
1b1fb73c
Commit
1b1fb73c
authored
15 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
#623320
by rfay: Implement AJAX 'css' command in misc/ajax.js (with tests).
parent
89f12126
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
misc/ajax.js
+7
-0
7 additions, 0 deletions
misc/ajax.js
modules/simpletest/tests/ajax.test
+4
-1
4 additions, 1 deletion
modules/simpletest/tests/ajax.test
modules/simpletest/tests/ajax_forms_test.module
+3
-5
3 additions, 5 deletions
modules/simpletest/tests/ajax_forms_test.module
with
14 additions
and
6 deletions
misc/ajax.js
+
7
−
0
View file @
1b1fb73c
...
@@ -395,6 +395,13 @@ Drupal.ajax.prototype.commands = {
...
@@ -395,6 +395,13 @@ Drupal.ajax.prototype.commands = {
alert
(
response
.
text
,
response
.
title
);
alert
(
response
.
text
,
response
.
title
);
},
},
/**
* 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.
* Command to set the settings that will be used for other commands in this response.
*/
*/
...
...
This diff is collapsed.
Click to expand it.
modules/simpletest/tests/ajax.test
+
4
−
1
View file @
1b1fb73c
...
@@ -112,7 +112,10 @@ class AJAXCommandsTestCase extends AJAXTestCase {
...
@@ -112,7 +112,10 @@ class AJAXCommandsTestCase extends AJAXTestCase {
$command
=
$commands
[
1
];
$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"
);
$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.
// Tests the 'data' command.
$commands
=
$this
->
drupalPostAJAX
(
$form_path
,
$edit
,
'data_command_example'
);
$commands
=
$this
->
drupalPostAJAX
(
$form_path
,
$edit
,
'data_command_example'
);
...
...
This diff is collapsed.
Click to expand it.
modules/simpletest/tests/ajax_forms_test.module
+
3
−
5
View file @
1b1fb73c
...
@@ -149,11 +149,9 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
...
@@ -149,11 +149,9 @@ function ajax_forms_test_ajax_commands_form($form, &$form_state) {
);
);
// Shows the AJAX 'css' command.
// Shows the AJAX 'css' command.
// @todo Note that this won't work until http://drupal.org/node/623320 lands.
$form
[
'css_command_example'
]
=
array
(
$form
[
'css_command_example'
]
=
array
(
'#title'
=>
t
(
"AJAX CSS: Choose the color you'd like the '#box' div to be."
),
'#value'
=>
t
(
"Set the the '#box' div to be blue."
),
'#type'
=>
'select'
,
'#type'
=>
'submit'
,
'#options'
=>
array
(
'green'
=>
'green'
,
'blue'
=>
'blue'
),
'#ajax'
=>
array
(
'#ajax'
=>
array
(
'callback'
=>
'ajax_forms_test_advanced_commands_css_callback'
,
'callback'
=>
'ajax_forms_test_advanced_commands_css_callback'
,
),
),
...
@@ -289,7 +287,7 @@ function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, $for
...
@@ -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
)
{
function
ajax_forms_test_advanced_commands_css_callback
(
$form
,
$form_state
)
{
$selector
=
'#css_div'
;
$selector
=
'#css_div'
;
$color
=
$form_state
[
'values'
][
'css_command_example'
]
;
$color
=
'blue'
;
$commands
=
array
();
$commands
=
array
();
$commands
[]
=
ajax_command_css
(
$selector
,
array
(
'background-color'
=>
$color
));
$commands
[]
=
ajax_command_css
(
$selector
,
array
(
'background-color'
=>
$color
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment