9989d91f652745abb9cd4f84d3776d82c0feadb0
[yaffs-website] / web / core / modules / outside_in / src / Ajax / OpenOffCanvasDialogCommand.php
1 <?php
2
3 namespace Drupal\outside_in\Ajax;
4
5 use Drupal\Core\Ajax\OpenDialogCommand;
6
7 /**
8  * Defines an AJAX command to open content in a dialog in a off-canvas dialog.
9  *
10  * @ingroup ajax
11  */
12 class OpenOffCanvasDialogCommand extends OpenDialogCommand {
13
14   /**
15    * Constructs an OpenOffCanvasDialogCommand object.
16    *
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.
21    *
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
26    *   or an HTML string.
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.
34    */
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'] = [];
45   }
46
47   /**
48    * {@inheritdoc}
49    */
50   public function render() {
51     $build = parent::render();
52     $build['effect'] = 'fade';
53     $build['speed'] = 1000;
54     return $build;
55   }
56
57 }