3 namespace Drupal\outside_in\Ajax;
5 use Drupal\Core\Ajax\OpenDialogCommand;
8 * Defines an AJAX command to open content in a dialog in a off-canvas dialog.
12 class OpenOffCanvasDialogCommand extends OpenDialogCommand {
15 * Constructs an OpenOffCanvasDialogCommand object.
17 * The off-canvas dialog differs from the normal modal provided by
18 * OpenDialogCommand in that a off-canvas has built in positioning and
19 * behaviours. Drupal provides a built-in off-canvas dialog for this purpose,
20 * so the selector is hard-coded in the call to the parent constructor.
22 * @param string $title
23 * The title of the dialog.
24 * @param string|array $content
25 * The content that will be placed in the dialog, either a render array
27 * @param array $dialog_options
28 * (optional) Settings to be passed to the dialog implementation. Any
29 * jQuery UI option can be used. See http://api.jqueryui.com/dialog.
30 * @param array|null $settings
31 * (optional) Custom settings that will be passed to the Drupal behaviors
32 * on the content of the dialog. If left empty, the settings will be
33 * populated automatically from the current request.
35 public function __construct($title, $content, array $dialog_options = [], $settings = NULL) {
36 parent::__construct('#drupal-off-canvas', $title, $content, $dialog_options, $settings);
37 $this->dialogOptions['modal'] = FALSE;
38 $this->dialogOptions['autoResize'] = FALSE;
39 $this->dialogOptions['resizable'] = 'w';
40 $this->dialogOptions['draggable'] = FALSE;
41 $this->dialogOptions['drupalAutoButtons'] = FALSE;
42 // @todo drupal.ajax.js does not respect drupalAutoButtons properly, pass an
43 // empty set of buttons until https://www.drupal.org/node/2793343 is in.
44 $this->dialogOptions['buttons'] = [];
50 public function render() {
51 $build = parent::render();
52 $build['effect'] = 'fade';
53 $build['speed'] = 1000;