Commit b5d30219 authored by jrockowitz's avatar jrockowitz Committed by jrockowitz

Issue #3001119 by jrockowitz: Resize seven tabs when offcanvas dialog is opened and closed

parent b094a1af
/**
* @file
* JavaScript behaviors for webform off-canvas dialogs.
*
* @see misc/dialog/off-canvas.js
*/
(function ($, Drupal) {
/**
* Attaches webform off-canvas behaviors.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches event listeners to window for off-canvas dialogs.
*/
Drupal.behaviors.webformOffCanvasEvents = {
attach: function () {
// Resize seven.theme tabs when off-canvas dialog opened and closed.
// @see core/themes/seven/js/nav-tabs.js
$(window).once('webform-off-canvas').on({
'dialog:aftercreate': function (event, dialog, $element, settings) {
if (Drupal.offCanvas.isOffCanvas($element)) {
$(window).trigger('resize.tabs');
}
},
'dialog:afterclose': function (event, dialog, $element, settings) {
if (Drupal.offCanvas.isOffCanvas($element)) {
$(window).trigger('resize.tabs');
}
}
});
}
};
})(jQuery, Drupal);
......@@ -54,6 +54,9 @@ class WebformDialogHelper {
*/
public static function attachLibraries(array &$build) {
$build['#attached']['library'][] = 'webform/webform.admin.dialog';
if (static::useOffCanvas()) {
$build['#attached']['library'][] = 'webform/webform.off_canvas';
}
// @see \Drupal\webform\Element\WebformHtmlEditor::preRenderWebformHtmlEditor
if (\Drupal::moduleHandler()->moduleExists('imce') && \Drupal\imce\Imce::access()) {
$build['#attached']['library'][] = 'imce/drupal.imce.ckeditor';
......
......@@ -220,6 +220,16 @@ webform.progress.tracker:
dependencies:
- webform/libraries.progress-tracker
# Off canvas.
webform.off_canvas:
version: VERSION
js:
js/webform.off-canvas.js: {}
dependencies:
- core/drupal.debounce
- core/drupal.dialog.off_canvas
# Promotions.
webform.promotions:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment