diff --git a/core/misc/displace.js b/core/misc/displace.js index 72a081c..3f96645 100644 --- a/core/misc/displace.js +++ b/core/misc/displace.js @@ -1,5 +1,5 @@ /** - * + * Manages elements that can offset the size of the viewport. */ (function (window, Drupal, $) { @@ -101,7 +101,7 @@ } // If the offset data attribute contains a displacing value, use it. var value = parseInt($el.attr('data-offset-' + edge), 10); - if (typeof value === 'number') { + if (typeof value === 'number' && !isNaN(value)) { displacement += value; } // If the element's offset data attribute does not contain a value, diff --git a/core/modules/overlay/overlay-child.js b/core/modules/overlay/overlay-child.js index 2de73e0..60964c8 100644 --- a/core/modules/overlay/overlay-child.js +++ b/core/modules/overlay/overlay-child.js @@ -54,15 +54,6 @@ Drupal.behaviors.overlayChild = { parent.Drupal.overlay.refreshRegions(settings.refreshRegions); } - // Workaround because of the way jQuery events works. - // jQuery from the parent frame needs to be used to catch this event. - parent.jQuery(document).on({ - 'drupalViewportOffsetChange': function (event, offsets) { - // Fires an event that the child iframe can listen to. - $(document).trigger('drupalViewportOffsetChange', offsets); - } - }); - // Ok, now we can tell the parent window we're ready. parent.Drupal.overlay.bindChild(window); diff --git a/core/modules/overlay/overlay-parent.js b/core/modules/overlay/overlay-parent.js index fbe1e7f..52de4b4 100644 --- a/core/modules/overlay/overlay-parent.js +++ b/core/modules/overlay/overlay-parent.js @@ -144,11 +144,9 @@ Drupal.overlay.create = function () { ' drupalOverlayBeforeLoad' + eventClass + ' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent')); - if (Drupal.displace.getElements().top.length || Drupal.displace.getElements().bottom.length) { - $(document) - .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements')) - .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements')); - } + $(document) + .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements')) + .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements')); }; /** @@ -464,6 +462,12 @@ Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) { // IE6 doesn't support maxWidth, use width instead. var maxWidthName = 'maxWidth'; + // If either the documentWidth or documentHeight are a zero dimension, abort + // the effort to alter presentation elements. + if (documentWidth === 0 || documentHeight === 0) { + return; + } + if (Drupal.overlay.leftSidedScrollbarOffset === undefined && $(document.documentElement).attr('dir') === 'rtl') { // We can't use element.clientLeft to detect whether scrollbars are placed // on the left side of the element when direction is set to "rtl" as most @@ -487,7 +491,7 @@ Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) { // Consider any element that should be visible above the overlay (such as // a toolbar). - $('.overlay-displace-top, .overlay-displace-bottom').each(function () { + $(Drupal.displace.getElements().top).add(Drupal.displace.getElements().bottom).each(function () { var data = $(this).data(); var maxWidth = documentWidth; // In IE, Shadow filter makes element to overlap the scrollbar with 1px. diff --git a/core/modules/toolbar/js/toolbar.js b/core/modules/toolbar/js/toolbar.js index 267f1b6..33c7133 100644 --- a/core/modules/toolbar/js/toolbar.js +++ b/core/modules/toolbar/js/toolbar.js @@ -190,6 +190,9 @@ Drupal.toolbar.setHeight = function () { /** * Get the height of the active tray and include it in the total * height of the toolbar. + * + * If the height of the bar changed, Drupal.displace is called so that + * elements can adjust to the placement of the bar. */ height += $trays.filter('.active.horizontal').outerHeight() || 0; // Indicate the height of the toolbar in the attribute data-offset-top. @@ -203,6 +206,12 @@ Drupal.toolbar.setHeight = function () { } }; +/** + * Sets the width of a vertical tray in a data attribute. + * + * If the width of the tray changed, Drupal.displace is called so that elements + * can adjust to the placement of the tray. + */ Drupal.toolbar.setTrayWidth = function () { var $tray = $toolbar.find('.tray.active'); var trayWidth = $tray.hasClass('vertical') ? $tray.width() : 0;