Skip to content
Snippets Groups Projects

Differentiate resizing behavior based on dialog type.

3 files
+ 39
17
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 19
8
@@ -100,19 +100,30 @@
dialogElement.classList.add(...options.dialogClass.split(' '));
}
// Set the dialog's width and height, using either saved values if available.
const savedWidth = localStorage.getItem('mercury-dialog-dock-width');
const savedHeight = localStorage.getItem('mercury-dialog-dock-height');
let width = savedWidth || options.width;
let height = savedHeight || options.height;
let dialogWidth = savedWidth || options.width;
let dialogHeight = savedHeight || options.height;
// If this not a Layout Paragraphs dialog (i.e., the main Mercury tray),
// then set the width and height based on the saved values.
if (!dialogElement.id.includes('lpb-dialog') && !options.dock) {
dialogElement.setAttribute('width', dialogWidth);
document.documentElement.style.setProperty('--me-dialog-dock-width', dialogWidth);
dialogElement.setAttribute('width', width);
document.documentElement.style.setProperty('--me-dialog-dock-width', width);
dialogElement.setAttribute('height', dialogHeight);
document.documentElement.style.setProperty('--me-dialog-dock-width', dialogHeight);
}
dialogElement.setAttribute('height', height);
document.documentElement.style.setProperty('--me-dialog-dock-width', height);
if (options.dock) {
if (savedWidth && ['right', 'left'].includes(options.dock)) {
dialogElement.setAttribute('width', savedWidth);
}
if (savedHeight && ['top', 'bottom'].includes(options.dock)) {
dialogElement.setAttribute('height', savedHeight);
}
}
if (options.drupalAutoButtons && !options.buttons) {
options.buttons = Drupal.behaviors.mercuryDialog.prepareDialogButtons($(dialogElement));
Loading