Skip to content

Commit

Permalink
fix issue where nested static modal removes the overlay from its parent
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetty committed May 11, 2022
1 parent fac0372 commit ccb425f
Show file tree
Hide file tree
Showing 6 changed files with 2,273 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Modal v1.17.10
# Modal v1.17.11

Library for opening content in a modal window. Built to be used with web applications and ajax.

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "modal",
"version": "1.17.10",
"version": "1.17.11",
"license": "MIT",
"private": true,
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.modal.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "modal",
"version": "1.17.10",
"version": "1.17.11",
"main": "src/jquery.modal.js",
"repository": {
"type": "git",
Expand Down
20 changes: 15 additions & 5 deletions src/jquery.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,23 @@
this.modalOpen = false;

if (this.staticModal || modalCount <= 1) {
this.$overlay.removeClass('show in');
this.$modal.removeClass('show in');

if (this.staticModal && !this.$modal.closest('.' + self.settings.modalDialogName).length) {
this.$overlay.removeClass('show in');
}

this.$modal.animate({ top: -(this.$modal.outerHeight(true) * 2) }, function () {
self.$modal.removeAttr('data-modal2-active');
self.$modal.css({ top: '0' });
self.removeEvents();

if (self.staticModal) {
self.$modal.hide();
self.$overlay.hide();

if (!self.$modal.closest('.' + self.settings.modalDialogName).length) {
self.$overlay.hide();
}
} else {
self.$modal.remove();
self.$overlay.remove();
Expand Down Expand Up @@ -334,10 +340,14 @@
this.$modal = $el;
this.$modalInside = $('.' + this.settings.modalContentName, $el);
this.$modalDialog = $('.' + this.settings.modalDialogName, $el);
this.$overlay = ($overlay && $overlay.length) ? $overlay : $('<div class="' + this.settings.backdropName + ' fade" data-modal2-overlay-active></div>');

// Append modal
this.$modal.before(this.$overlay);
// Append modal backdrop if one doesnt already exist
if (!($overlay && $overlay.length)) {
this.$overlay = $('<div class="' + this.settings.backdropName + ' fade" data-modal2-overlay-active></div>');
this.$modal.before(this.$overlay);
} else {
this.$overlay = $overlay;
}

// Set to static modal if we cloned the $el
this.staticModal = true;
Expand Down
Loading

0 comments on commit ccb425f

Please sign in to comment.