3 * Views dialog behaviors.
6 (function($, Drupal, drupalSettings) {
7 function handleDialogResize(e) {
8 const $modal = $(e.currentTarget);
9 const $viewsOverride = $modal.find('[data-drupal-views-offset]');
10 const $scroll = $modal.find('[data-drupal-views-scroll]');
14 // Add a class to do some styles adjustments.
15 $modal.closest('.views-ui-dialog').addClass('views-ui-dialog-scroll');
16 // Let scroll element take all the height available.
17 $scroll.css({ overflow: 'visible', height: 'auto' });
18 modalHeight = $modal.height();
19 $viewsOverride.each(function() {
20 offset += $(this).outerHeight();
23 // Take internal padding into account.
24 const scrollOffset = $scroll.outerHeight() - $scroll.height();
25 $scroll.height(modalHeight - offset - scrollOffset);
26 // Reset scrolling properties.
27 $modal.css('overflow', 'hidden');
28 $scroll.css('overflow', 'auto');
33 * Functionality for views modals.
35 * @type {Drupal~behavior}
37 * @prop {Drupal~behaviorAttach} attach
38 * Attaches modal functionality for views.
39 * @prop {Drupal~behaviorDetach} detach
40 * Detaches the modal functionality.
42 Drupal.behaviors.viewsModalContent = {
47 'dialogContentResize.viewsDialog',
51 // When expanding details, make sure the modal is resized.
54 .once('detailsUpdate')
55 .on('click', 'summary', e => {
56 $(e.currentTarget).trigger('dialogContentResize');
59 detach(context, settings, trigger) {
60 if (trigger === 'unload') {
62 .removeOnce('viewsDialog')
67 })(jQuery, Drupal, drupalSettings);