keybinds for delete modal + bugs

master
Kit Kasune 3 years ago
parent 0bfd17bec5
commit 0f5e7eeb73
  1. 19
      scripts/contextmenu/delete-folder.js
  2. 10
      scripts/modal/post.js

@ -8,7 +8,6 @@ const postModal = require('../modal/post');
const showError = require('../modal/common/error'); const showError = require('../modal/common/error');
const clearModals = require('../modal/clearmodals'); const clearModals = require('../modal/clearmodals');
const newToast = require('../toast/createtoast'); const newToast = require('../toast/createtoast');
const refresh = require('../fileview/refresh');
module.exports = () => { module.exports = () => {
if (window.kade.modal) {return;} if (window.kade.modal) {return;}
@ -33,26 +32,34 @@ module.exports = () => {
conf.innerHTML = 'Delete it!'; conf.innerHTML = 'Delete it!';
let cxl = document.createElement('button'); let cxl = document.createElement('button');
cxl.innerHTML = "Nevermind"; cxl.innerHTML = "Nevermind";
modal.appendChild(cxl); cxl.onclick = () => {
lightRefresh();
modalOut.remove();
postModal(modalOut.id);
};
conf.onclick = () => { conf.onclick = () => {
try { try {
fs.rmdirSync(path.join(window.kade.cpath, window.kade.currentFolder)); fs.rmdirSync(path.join(window.kade.cpath, window.kade.currentFolder));
refresh(window.kade.cpath); postModal(modalOut.id);
modalOut.remove();
lightRefresh(window.kade.cpath);
newToast("Folder Deleted", "Your folder has been deleted successfully."); newToast("Folder Deleted", "Your folder has been deleted successfully.");
} catch { } catch {
newToast("Folder not Deleted", "An error caused that folder to not be deleted.", "#b24355", false, 5, () => {showError("Folder Deletion", "There was an unknown error while trying to delete that folder. It may be a permissions issue, or the host folder doesn't exist anymore.");}); newToast("Folder not Deleted", "An error caused that folder to not be deleted.", "#b24355", false, 5, () => {showError("Folder Deletion", "There was an unknown error while trying to delete that folder. It may be a permissions issue, or the host folder doesn't exist anymore.");});
clearModals(); clearModals();
try {modalOut.remove();} catch {}
postModal(modalOut.id);
} }
postModal(modalOut.id);
}; };
cont.appendChild(conf); cont.appendChild(conf);
let msm = new Mousetrap(modal); cont.appendChild(cxl);
let msm = new Mousetrap();
msm.bind('esc', () => { msm.bind('esc', () => {
lightRefresh(); lightRefresh();
modalOut.remove(); modalOut.remove();
postModal(modalOut.id); postModal(modalOut.id);
}); });
msm.bind('enter', () => {conf.click();}); msm.bind('enter', () => {conf.click(); console.log('hewwo');});
let close = document.createElement('a'); let close = document.createElement('a');
close.className = 'close-button'; close.className = 'close-button';
close.onclick = () => { close.onclick = () => {

@ -1,8 +1,10 @@
const transit = require("./transit"); const transit = require("./transit");
module.exports = (id) => { module.exports = (id) => {
document.getElementById('modal-block').remove(); try {
window.kade.modal = false; try {document.getElementById('modal-block').remove();} catch {}
document.body.style.overflowY = 'overlay'; window.kade.modal = false;
transit(id, false); document.body.style.overflowY = 'overlay';
transit(id, false);
} catch {}
}; };
Loading…
Cancel
Save