You are here

public static function WebformDialogHelper::getModalDialogAttributes in Webform 8.5

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

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.

33 calls to WebformDialogHelper::getModalDialogAttributes()
template_preprocess_webform_submission_information in includes/webform.theme.template.inc
Prepares variables for webform submission information template.
WebformAccessGroupForm::actions in modules/webform_access/src/WebformAccessGroupForm.php
Returns an array of supported actions for the current entity form.
WebformAccessGroupListBuilder::getDefaultOperations in modules/webform_access/src/WebformAccessGroupListBuilder.php
Gets this list's default operations.
WebformAccessTypeForm::actions in modules/webform_access/src/WebformAccessTypeForm.php
Returns an array of supported actions for the current entity form.
WebformAccessTypeListBuilder::getDefaultOperations in modules/webform_access/src/WebformAccessTypeListBuilder.php
Gets this list's default operations.

... See full list

File

src/Utility/WebformDialogHelper.php, line 85

Class

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

Namespace

Drupal\webform\Utility

Code

public static function getModalDialogAttributes($width = self::DIALOG_NORMAL, array $class = []) {
  if (\Drupal::config('webform.settings')
    ->get('ui.dialog_disabled')) {
    return $class ? [
      'class' => $class,
    ] : [];
  }
  $dialog_widths = [
    static::DIALOG_WIDE => 1000,
    static::DIALOG_NORMAL => 800,
    static::DIALOG_NARROW => 700,
  ];
  $width = isset($dialog_widths[$width]) ? $dialog_widths[$width] : $width;
  $class[] = 'webform-ajax-link';
  return [
    'class' => $class,
    'data-dialog-type' => 'modal',
    'data-dialog-options' => Json::encode([
      'width' => $width,
      // .webform-ui-dialog is used to set the dialog's top position.
      // @see modules/sandbox/webform/css/webform.ajax.css
      'dialogClass' => 'webform-ui-dialog',
    ]),
  ];
}