Skip to content

Commit

Permalink
Fixed issue where the overlay was not correctly placed when `overlay_…
Browse files Browse the repository at this point in the history
…container` was used; subsequent dialogs now have increased zIndex
  • Loading branch information
stefangabos committed Apr 12, 2019
1 parent 05693b7 commit c669fbf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/zebra_dialog.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 35 additions & 1 deletion dist/zebra_dialog.src.js
Expand Up @@ -703,7 +703,8 @@
*/
plugin.init = function() {

var ajax_options, button_bar, buttons, canvas, default_options, iframe_options, preloader, $title, tmp, type;
var ajax_options, button_bar, buttons, canvas, default_options, iframe_options, preloader, $title, tmp, type,
$container, container_position, max_zindex = 0;

// the plugin's final properties are the merged default and user-provided options (if any)
plugin.settings = $.extend({}, defaults, options);
Expand Down Expand Up @@ -731,6 +732,25 @@

});

// if the overlay is appended to a different element other than the "body"
if (plugin.settings.overlay_container !== 'body') {

// reference to the container element
$container = plugin.settings.overlay_container;

// get container's position
container_position = $container.offset();

// adjust the overlay's dimensions to match the ones of the parent
plugin.overlay.css({
left: container_position.left,
top: container_position.top,
width: $container.outerWidth(),
height: $container.outerHeight()
});

}

// if dialog box can be closed by clicking the overlay
if (plugin.settings.overlay_close)

Expand Down Expand Up @@ -764,6 +784,20 @@

});

// iterate over any already existing dialogs on the page
$('.ZebraDialog').each(function() {

// get the dialog's zIndex
var zIndex = $(this).css('zIndex');

// if a zIndex is set and it is more than what we have, use that as reference from now on
if (zIndex && zIndex > max_zindex) max_zindex = zIndex;

});

// if another dialog already exists on the page, set the zIndex of this one higher
if (max_zindex > 0) plugin.dialog.css('zIndex', max_zindex + 1);

// if a notification message
if (!plugin.settings.buttons && plugin.settings.auto_close)

Expand Down

0 comments on commit c669fbf

Please sign in to comment.