WIP: resize body when messagebox is used in the popup

This commit is contained in:
eight 2017-12-05 04:01:52 +08:00
parent dcfdce7636
commit 4291a37012
2 changed files with 24 additions and 0 deletions

View File

@ -132,6 +132,18 @@
margin: 0 .375rem; margin: 0 .375rem;
} }
/* popup */
#stylus-popup #message-box {
margin: 0;
align-items: center;
justify-content: center;
}
#stylus-popup #message-box > div {
max-width: 90vh;
top: auto;
right: auto;
}
@keyframes fadein { @keyframes fadein {
from { from {
opacity: 0; opacity: 0;

View File

@ -11,6 +11,12 @@ function messageBox({
initOwnListeners(); initOwnListeners();
bindGlobalListeners(); bindGlobalListeners();
createElement(); createElement();
if (location.href.includes('popup.html')) {
messageBox.bodyWidth = document.body.style.width;
messageBox.bodyHeight = document.body.style.height;
document.body.style.width = '400px';
document.body.style.height = '600px';
}
document.body.appendChild(messageBox.element); document.body.appendChild(messageBox.element);
if (onshow) { if (onshow) {
onshow(messageBox.element); onshow(messageBox.element);
@ -96,6 +102,12 @@ function messageBox({
messageBox.element.remove(); messageBox.element.remove();
messageBox.element = null; messageBox.element = null;
messageBox.resolve = null; messageBox.resolve = null;
if (messageBox.bodyWidth) {
document.body.style.width = messageBox.bodyWidth;
document.body.style.height = messageBox.bodyHeight;
messageBox.bodyWidth = null;
messageBox.bodyHeight = null;
}
} }
} }