From f9dd980c310540a1b731048aa91e7b6ebfece21b Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Tue, 12 Apr 2022 14:59:28 -0600 Subject: [PATCH] error modal is actually closable --- scripts/modal/common/error.js | 35 ++++++++++++++++++++++++++++++----- styles/modal.css | 2 -- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/scripts/modal/common/error.js b/scripts/modal/common/error.js index a63eb4b..6727a81 100644 --- a/scripts/modal/common/error.js +++ b/scripts/modal/common/error.js @@ -1,13 +1,21 @@ -const preModal = require("../pre"); +const mousetrap = require('../../dep/mousetrap'); + +const lightRefresh = require('../../fileview/lightrefresh'); +const preModal = require('../pre'); const postModal = require('../post'); module.exports = (name, text, after = () => {}) => { - preModal('error-modal'); + if (window.kade.modal) {return;} + preModal('error-modal-container'); + let modalOut = document.createElement('div'); + modalOut.className = 'modal'; + modalOut.id = 'error-modal-container' + document.body.appendChild(modalOut); let modal = document.createElement('div'); - modal.className = 'modal'; + modal.className = 'modal-wrapper'; + modalOut.appendChild(modal); modal.classList.add('error-modal'); modal.id = 'error-modal'; - document.body.appendChild(modal); let title = document.createElement('h2'); title.innerHTML = `Error - ${name}`; modal.appendChild(title); @@ -16,4 +24,21 @@ module.exports = (name, text, after = () => {}) => { modal.appendChild(err); after('error-modal'); postModal(); -}; \ No newline at end of file + let msm = new mousetrap(modal); + msm.bind('esc', () => { + lightRefresh(); + modalOut.remove(); + postModal(modalOut.id); + }); + let close = document.createElement('a'); + close.className = 'close-button'; + close.onclick = () => { + lightRefresh(); + modalOut.remove(); + postModal(modalOut.id); + }; + let closeWrap = document.createElement('div'); + closeWrap.className = 'close-button-wrapper'; + modal.appendChild(closeWrap); + closeWrap.appendChild(close); +} \ No newline at end of file diff --git a/styles/modal.css b/styles/modal.css index 798c043..a9ae14a 100644 --- a/styles/modal.css +++ b/styles/modal.css @@ -60,8 +60,6 @@ z-index: 2; } -.error-modal {max-width: 45%;} - .modal-wrapper { margin: 0 0; padding: 0 0;