You are here

public static function WebformDialogHelper::getOffCanvasDialogAttributes in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Utility/WebformDialogHelper.php \Drupal\webform\Utility\WebformDialogHelper::getOffCanvasDialogAttributes()

Get modal dialog attributes.

Parameters

int|string $width: Width of the modal dialog.

array $class: Additional class names to be included in the dialog's attributes.

Return value

array Modal dialog attributes.

11 calls to WebformDialogHelper::getOffCanvasDialogAttributes()
WebformDialogLocalAction::getOptions in src/Plugin/Menu/LocalAction/WebformDialogLocalAction.php
Returns options for rendering a link for the local action.
WebformEntityHandlersForm::form in src/WebformEntityHandlersForm.php
Gets the actual form array to be built.
WebformEntityVariantsForm::form in src/WebformEntityVariantsForm.php
Gets the actual form array to be built.
WebformPluginHandlerController::listHandlers in src/Controller/WebformPluginHandlerController.php
Shows a list of webform handlers that can be added to a webform.
WebformPluginVariantController::listVariants in src/Controller/WebformPluginVariantController.php
Shows a list of webform variants that can be added to a webform.

... See full list

File

src/Utility/WebformDialogHelper.php, line 121

Class

WebformDialogHelper
Helper class for modal and off-canvas dialog methods.

Namespace

Drupal\webform\Utility

Code

public static function getOffCanvasDialogAttributes($width = self::DIALOG_NORMAL, array $class = []) {
  if (\Drupal::config('webform.settings')
    ->get('ui.dialog_disabled') || $width === self::DIALOG_NONE) {
    return $class ? [
      'class' => $class,
    ] : [];
  }
  if (!static::useOffCanvas()) {
    return self::getModalDialogAttributes($width, $class);
  }
  $dialog_widths = [
    static::DIALOG_WIDE => 800,
    static::DIALOG_NORMAL => 600,
    static::DIALOG_NARROW => 550,
  ];
  $width = isset($dialog_widths[$width]) ? $dialog_widths[$width] : $width;
  $class[] = 'webform-ajax-link';
  return [
    'class' => $class,
    'data-dialog-type' => 'dialog',
    'data-dialog-renderer' => 'off_canvas',
    'data-dialog-options' => Json::encode([
      'width' => $width,
      'dialogClass' => 'ui-dialog-off-canvas webform-off-canvas',
    ]),
  ];
}