From 4291a370128902296d3773b4f647557d12aca0da Mon Sep 17 00:00:00 2001 From: eight Date: Tue, 5 Dec 2017 04:01:52 +0800 Subject: [PATCH] WIP: resize body when messagebox is used in the popup --- msgbox/msgbox.css | 12 ++++++++++++ msgbox/msgbox.js | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/msgbox/msgbox.css b/msgbox/msgbox.css index da232671..a46cec8e 100644 --- a/msgbox/msgbox.css +++ b/msgbox/msgbox.css @@ -132,6 +132,18 @@ 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 { from { opacity: 0; diff --git a/msgbox/msgbox.js b/msgbox/msgbox.js index cbe3b44f..5dd9face 100644 --- a/msgbox/msgbox.js +++ b/msgbox/msgbox.js @@ -11,6 +11,12 @@ function messageBox({ initOwnListeners(); bindGlobalListeners(); 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); if (onshow) { onshow(messageBox.element); @@ -96,6 +102,12 @@ function messageBox({ messageBox.element.remove(); messageBox.element = 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; + } } }