Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\Ajax; | |
4 | |
5 /** | |
6 * Defines an AJAX command to open content in a dialog in a off-canvas dialog. | |
7 * | |
8 * @ingroup ajax | |
9 */ | |
10 class OpenOffCanvasDialogCommand extends OpenDialogCommand { | |
11 | |
12 /** | |
13 * The dialog width to use if none is provided. | |
14 */ | |
15 const DEFAULT_DIALOG_WIDTH = 300; | |
16 | |
17 /** | |
18 * Constructs an OpenOffCanvasDialogCommand object. | |
19 * | |
20 * The off-canvas dialog differs from the normal modal provided by | |
21 * OpenDialogCommand in that a off-canvas has built in positioning and | |
22 * behaviours. Drupal provides a built-in off-canvas dialog for this purpose, | |
23 * so the selector is hard-coded in the call to the parent constructor. | |
24 * | |
25 * @param string $title | |
26 * The title of the dialog. | |
27 * @param string|array $content | |
28 * The content that will be placed in the dialog, either a render array | |
29 * or an HTML string. | |
30 * @param array $dialog_options | |
31 * (optional) Settings to be passed to the dialog implementation. Any | |
32 * jQuery UI option can be used. See http://api.jqueryui.com/dialog. | |
33 * @param array|null $settings | |
34 * (optional) Custom settings that will be passed to the Drupal behaviors | |
35 * on the content of the dialog. If left empty, the settings will be | |
36 * populated automatically from the current request. | |
37 */ | |
38 public function __construct($title, $content, array $dialog_options = [], $settings = NULL) { | |
39 parent::__construct('#drupal-off-canvas', $title, $content, $dialog_options, $settings); | |
40 $this->dialogOptions['modal'] = FALSE; | |
41 $this->dialogOptions['autoResize'] = FALSE; | |
42 $this->dialogOptions['resizable'] = 'w'; | |
43 $this->dialogOptions['draggable'] = FALSE; | |
44 $this->dialogOptions['drupalAutoButtons'] = FALSE; | |
45 // @todo drupal.ajax.js does not respect drupalAutoButtons properly, pass an | |
46 // empty set of buttons until https://www.drupal.org/node/2793343 is in. | |
47 $this->dialogOptions['buttons'] = []; | |
48 if (empty($dialog_options['dialogClass'])) { | |
49 $this->dialogOptions['dialogClass'] = 'ui-dialog-off-canvas'; | |
50 } | |
51 // If no width option is provided then use the default width to avoid the | |
52 // dialog staying at the width of the previous instance when opened | |
53 // more than once, with different widths, on a single page. | |
54 if (!isset($this->dialogOptions['width'])) { | |
55 $this->dialogOptions['width'] = static::DEFAULT_DIALOG_WIDTH; | |
56 } | |
57 } | |
58 | |
59 /** | |
60 * {@inheritdoc} | |
61 */ | |
62 public function render() { | |
63 $build = parent::render(); | |
64 $build['effect'] = 'fade'; | |
65 $build['speed'] = 1000; | |
66 return $build; | |
67 } | |
68 | |
69 } |