Skip to content
Snippets Groups Projects
Commit fc14e926 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2831924 by tedbow, samuel.mortenson, drpal, Devin Carlson,...

Issue #2831924 by tedbow, samuel.mortenson, drpal, Devin Carlson, tim.plunkett, droplet: Outside In is intermittently unable to bind dialog events to the window
parent 16842fc2
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -100,7 +100,17 @@ ...@@ -100,7 +100,17 @@
} }
} }
$(window).on({ /**
* Attaches off-canvas dialog behaviors.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches event listeners for off-canvas dialogs.
*/
Drupal.behaviors.offCanvasEvents = {
attach: function () {
$(window).once('off-canvas').on({
'dialog:aftercreate': function (event, dialog, $element, settings) { 'dialog:aftercreate': function (event, dialog, $element, settings) {
if ($element.is('#drupal-offcanvas')) { if ($element.is('#drupal-offcanvas')) {
var eventData = {settings: settings, $element: $element}; var eventData = {settings: settings, $element: $element};
...@@ -137,11 +147,14 @@ ...@@ -137,11 +147,14 @@
'dialog:beforeclose': function (event, dialog, $element) { 'dialog:beforeclose': function (event, dialog, $element) {
if ($element.is('#drupal-offcanvas')) { if ($element.is('#drupal-offcanvas')) {
$('body').removeClass('js-tray-open'); $('body').removeClass('js-tray-open');
// Remove all *.offcanvas events
$(document).off('.offcanvas'); $(document).off('.offcanvas');
$(window).off('.offcanvas'); $(window).off('.offcanvas');
$mainCanvasWrapper.css('padding-' + edge, 0); $mainCanvasWrapper.css('padding-' + edge, 0);
} }
} }
}); });
}
};
})(jQuery, Drupal, Drupal.debounce, Drupal.displace); })(jQuery, Drupal, Drupal.debounce, Drupal.displace);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment