Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/Ajax/ChangedCommand.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Core\Ajax; |
Chris@0 | 4 |
Chris@0 | 5 /** |
Chris@0 | 6 * An AJAX command for marking HTML elements as changed. |
Chris@0 | 7 * |
Chris@0 | 8 * This command instructs the client to mark each of the elements matched by the |
Chris@0 | 9 * given selector as 'ajax-changed'. |
Chris@0 | 10 * |
Chris@0 | 11 * This command is implemented by Drupal.AjaxCommands.prototype.changed() |
Chris@0 | 12 * defined in misc/ajax.js. |
Chris@0 | 13 * |
Chris@0 | 14 * @ingroup ajax |
Chris@0 | 15 */ |
Chris@0 | 16 class ChangedCommand implements CommandInterface { |
Chris@0 | 17 |
Chris@0 | 18 /** |
Chris@0 | 19 * A CSS selector string. |
Chris@0 | 20 * |
Chris@0 | 21 * If the command is a response to a request from an #ajax form element then |
Chris@0 | 22 * this value can be NULL. |
Chris@0 | 23 * |
Chris@0 | 24 * @var string |
Chris@0 | 25 */ |
Chris@0 | 26 protected $selector; |
Chris@0 | 27 |
Chris@0 | 28 /** |
Chris@0 | 29 * An optional CSS selector for elements to which asterisks will be appended. |
Chris@0 | 30 * |
Chris@0 | 31 * @var string |
Chris@0 | 32 */ |
Chris@0 | 33 protected $asterisk; |
Chris@0 | 34 |
Chris@0 | 35 /** |
Chris@0 | 36 * Constructs a ChangedCommand object. |
Chris@0 | 37 * |
Chris@0 | 38 * @param string $selector |
Chris@0 | 39 * CSS selector for elements to be marked as changed. |
Chris@0 | 40 * @param string $asterisk |
Chris@0 | 41 * CSS selector for elements to which an asterisk will be appended. |
Chris@0 | 42 */ |
Chris@0 | 43 public function __construct($selector, $asterisk = '') { |
Chris@0 | 44 $this->selector = $selector; |
Chris@0 | 45 $this->asterisk = $asterisk; |
Chris@0 | 46 } |
Chris@0 | 47 |
Chris@0 | 48 /** |
Chris@0 | 49 * Implements Drupal\Core\Ajax\CommandInterface:render(). |
Chris@0 | 50 */ |
Chris@0 | 51 public function render() { |
Chris@0 | 52 |
Chris@0 | 53 return [ |
Chris@0 | 54 'command' => 'changed', |
Chris@0 | 55 'selector' => $this->selector, |
Chris@0 | 56 'asterisk' => $this->asterisk, |
Chris@0 | 57 ]; |
Chris@0 | 58 } |
Chris@0 | 59 |
Chris@0 | 60 } |