Refactor Mailpoet.Modal to allow not rendering overlay

[MAILPOET-1974]
This commit is contained in:
Ján Mikláš
2019-05-01 10:34:46 +02:00
committed by M. Shull
parent cdd0c69779
commit 63caaeddaa
2 changed files with 12 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ body.mailpoet_modal_opened {
z-index: 100001 !important; z-index: 100001 !important;
} }
.mailpoet_modal_overlay.mailpoet_overlay_hidden { .mailpoet_modal_overlay.mailpoet_overlay_transparent {
background-color: transparent; background-color: transparent;
} }
@@ -73,7 +73,7 @@ body.mailpoet_modal_opened {
z-index: 0; z-index: 0;
} }
.mailpoet_overlay_hidden .mailpoet_popup_wrapper { .mailpoet_overlay_transparent .mailpoet_popup_wrapper {
border: 1px solid #333; border: 1px solid #333;
} }

View File

@@ -66,7 +66,8 @@ MailPoet.Modal = {
height: 'auto', height: 'auto',
// display overlay // display overlay
overlay: false, overlay: false, // Controls background of overlay, false means transparent
overlayRender: true, // Controls display property, false means hidden
// focus upon displaying // focus upon displaying
focus: true, focus: true,
@@ -133,7 +134,7 @@ MailPoet.Modal = {
this.initOverlay(); this.initOverlay();
// toggle overlay // toggle overlay
this.toggleOverlay(this.options.overlay); this.setOverlay(this.options.overlay);
if (this.options.type !== null) { if (this.options.type !== null) {
// insert modal depending on its type // insert modal depending on its type
@@ -193,15 +194,14 @@ MailPoet.Modal = {
} }
return this; return this;
}, },
toggleOverlay: function (toggle) { setOverlay: function (showBackground) {
if (toggle === true) { if (showBackground === true) {
jQuery('#mailpoet_modal_overlay') jQuery('#mailpoet_modal_overlay')
.removeClass('mailpoet_overlay_hidden'); .removeClass('mailpoet_overlay_transparent');
} else { } else {
jQuery('#mailpoet_modal_overlay') jQuery('#mailpoet_modal_overlay')
.addClass('mailpoet_overlay_hidden'); .addClass('mailpoet_overlay_transparent');
} }
return this; return this;
}, },
setupEvents: function () { setupEvents: function () {
@@ -453,6 +453,9 @@ MailPoet.Modal = {
return this; return this;
}, },
showOverlay: function () { showOverlay: function () {
if (!this.options.overlayRender) {
return this;
}
jQuery('#mailpoet_modal_overlay').show(); jQuery('#mailpoet_modal_overlay').show();
jQuery('body').addClass('mailpoet_modal_opened'); jQuery('body').addClass('mailpoet_modal_opened');
return this; return this;