3 namespace Drupal\Core\Ajax;
6 * An AJAX command for calling the jQuery css() method.
8 * The 'css' command will instruct the client to use the jQuery css() method to
9 * apply the CSS arguments to elements matched by the given selector.
11 * This command is implemented by Drupal.AjaxCommands.prototype.css() defined
14 * @see http://docs.jquery.com/CSS/css#properties
18 class CssCommand implements CommandInterface {
21 * A CSS selector string.
23 * If the command is a response to a request from an #ajax form element then
24 * this value can be NULL.
31 * An array of property/value pairs to set in the CSS for the selector.
38 * Constructs a CssCommand object.
40 * @param string $selector
41 * A CSS selector for elements to which the CSS will be applied.
43 * An array of CSS property/value pairs to set.
45 public function __construct($selector, array $css = []) {
46 $this->selector = $selector;
51 * Adds a property/value pair to the CSS to be added to this element.
54 * The CSS property to be changed.
56 * The new value of the CSS property.
60 public function setProperty($property, $value) {
61 $this->css[$property] = $value;
66 * Implements Drupal\Core\Ajax\CommandInterface:render().
68 public function render() {
72 'selector' => $this->selector,
73 'argument' => $this->css,