Merge branch 'sidebar'

modals
Kit Kasune 3 years ago
commit 372147a9f8
  1. 8
      index.html
  2. 4
      scripts/contextmenu/createcontext.js
  3. 35
      scripts/contextmenu/pin.js
  4. 2
      scripts/contextmenu/rename-folder.js
  5. 2
      scripts/startup/changelog.js
  6. 14
      scripts/startup/initsidebar.js
  7. 4
      styles/sidebar.css

@ -26,16 +26,20 @@
<div id="favorites"> <div id="favorites">
<div id="favorites-wrapper"> <div id="favorites-wrapper">
<div> <div>
<h2 class="nosel">Quick Access</h2> <div>
<h2 class="favorites-header nosel">Quick Access</h2>
</div> </div>
<div id="favorites-container"></div> <div id="favorites-container"></div>
</div>
<div> <div>
<h2 class="nosel">Favorites</h2> <div>
<h2 class="favorites-header nosel">Favorites</h2>
</div> </div>
<div id="custom-favorites-container"></div> <div id="custom-favorites-container"></div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id='container'> <div id='container'>
<div id='controls' class='controls'> <div id='controls' class='controls'>
<div id='header-buttons'></div> <div id='header-buttons'></div>

@ -7,8 +7,8 @@ module.exports = (e, target, window) => {
if (target.classList.contains('file') || (target.parentElement && target.parentElement.classList.contains('file'))) { if (target.classList.contains('file') || (target.parentElement && target.parentElement.classList.contains('file'))) {
ctxf.style.display = 'block'; ctxf.style.display = 'block';
ctxf.previousElementSibling.style.display = 'block'; ctxf.previousElementSibling.style.display = 'block';
if (target.classList.contains('file')) {window.kade.currentFolder = target.children[1].innerHTML;} if (target.classList.contains('file')) {window.kade.currentFolder = target.children[1].innerHTML.trim();}
else {window.kade.currentFolder = target.parentElement.children[1].innerHTML;} else {window.kade.currentFolder = target.parentElement.children[1].innerHTML.trim();}
} else { } else {
ctxf.style.display = 'none'; ctxf.style.display = 'none';
ctxf.previousElementSibling.style.display = 'none'; ctxf.previousElementSibling.style.display = 'none';

@ -0,0 +1,35 @@
const fs = require('fs');
const path = require('path');
const createToast = require('../toast/createtoast');
const refresh = require('../fileview/refresh');
const newToast = require("../toast/createtoast");
module.exports = () => {
let pins;
if (fs.existsSync(path.join(__dirname, '../../', '/json/config/favorites.json'))) {
pins = require('../../json/config/favorites.json');
} else {pins = {};}
let fta = window.kade.currentFolder.trim();
if (Object.keys(pins).includes(`${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}`)) {
return createToast("Already pinned", "That folder is already pinned!");
}
let tr = `${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}`;
pins[tr] = fta;
let cfc = document.getElementById('custom-favorites-container');
let fav = document.createElement('div');
['favorites-button', 'folder-pin', 'nosel'].forEach(x => fav.classList.add(x));
fav.innerHTML = fta;
fav.onclick = () => {refresh(tr);};
cfc.appendChild(fav);
createToast(
"Folder Pinned", [`Folder "${fta}" was successfully pinned! You can now access it permanently in your sidebar!"`, `<em>${window.kade.cpath.replace(/\\+/gm, '/')}/${fta}</em>`], undefined, false, 5,
() => {
refresh(tr);
require('electron').clipboard.writeText(`${window.kade.cpath.replace(/\\+/gm, '/')}`);
newToast("Copied!", "<em>The folder's path has been copied to your clipboard.</em>", "#19df46");
}
);
try {fs.writeFileSync(path.join(__dirname, '../../', '/json/config/favorites.json'), JSON.stringify(pins));}
catch {createToast("Error", "Your pin was not saved for some reason. Please restart or reload (ctrl+shift+r) the app and try again.", "#ff557a");}
};

@ -43,7 +43,7 @@ module.exports = () => {
conf.innerHTML = 'Rename'; conf.innerHTML = 'Rename';
conf.onclick = () => { conf.onclick = () => {
try { try {
input.value.trim(); input.value = input.value.trim();
if (!input.value.length) {return;} if (!input.value.length) {return;}
if (fs.existsSync(path.join(window.kade.cpath, input.value))) { if (fs.existsSync(path.join(window.kade.cpath, input.value))) {
if (!input.value.match(/^.+\(\d\)$/gm)) {input.value += ' (1)';} if (!input.value.match(/^.+\(\d\)$/gm)) {input.value += ' (1)';}

@ -59,7 +59,7 @@ module.exports = () => {
}); });
}); });
clww.style = `height: ${modalOut.clientHeight - 6};`; // TODO cry enough tears that they magically make this line work clww.style = `height: ${modalOut.clientHeight - 6};`;
let msm = new Mousetrap(modal); let msm = new Mousetrap(modal);
msm.bind('esc', () => { msm.bind('esc', () => {

@ -2,6 +2,8 @@ const refresh = require('../fileview/refresh');
const qa = require('../../json/qa.json'); const qa = require('../../json/qa.json');
const os = require("os"); const os = require("os");
const fs = require('fs');
const path = require('path');
module.exports = () => { module.exports = () => {
let root let root
@ -24,4 +26,16 @@ module.exports = () => {
quick.classList.add('nosel'); quick.classList.add('nosel');
quickAccess.appendChild(quick); quickAccess.appendChild(quick);
}); });
if (fs.existsSync(path.join(__dirname, '../../', '/json/config/favorites.json'))) {
const pins = require('../../json/config/favorites.json');
let cfc = document.getElementById('custom-favorites-container');
Object.keys(pins).forEach(pin => {
let fav = document.createElement('div');
['favorites-button', 'folder-pin', 'nosel'].forEach(x => fav.classList.add(x));
fav.innerHTML = pins[pin];
fav.onclick = () => {refresh(pin);};
cfc.appendChild(fav);
});
}
}; };

@ -36,3 +36,7 @@
padding-left: 10px; padding-left: 10px;
color: white; color: white;
} }
.favorites-header {
margin-bottom: 7px;
}
Loading…
Cancel
Save