From a6cedb9c67284ebdf7e475c1b9fdab63b5a44c79 Mon Sep 17 00:00:00 2001 From: Alex Vitkov Date: Sat, 13 Feb 2021 00:01:53 +0200 Subject: Minor UI tweaks --- loggedin.js | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/loggedin.js b/loggedin.js index be1b04d..c84f650 100644 --- a/loggedin.js +++ b/loggedin.js @@ -218,7 +218,7 @@ function add_file_visuals(fileview) { var img = document.createElement('img'); var filename = document.createElement('div'); - if (fileview.is_directory!=0) { + if (fileview.is_directory) { img.src="/mimeicons/directory.png"; visuals.onclick = () => { pwd.push(fileview.filename); @@ -229,20 +229,22 @@ function add_file_visuals(fileview) { } visuals.oncontextmenu = (e) => { - context(e, [ - ['Open', () => { - if (is_directory) { - pwd.push(fileview.filename); - load_dir(); - } else { - alert('not implemented'); - } - }], - ['Rename', () => { rename_file(fileview.filename); }], - ['Share', () => {alert('not implemented')}], - ['Delete', () => { delete_file(fileview.filename); }], - ]); + if (!dragging) { + context(e, [ + ['Open', () => { + if (fileview.is_directory) { pwd.push(fileview.filename); + load_dir(); + } else { + alert('not implemented'); + } + }], + ['Rename', () => { rename_file(fileview.filename); }], + ['Share', () => {alert('not implemented')}], + ['Delete', () => { delete_file(fileview.filename); }], + ]); + } e.preventDefault(); + e.stopPropagation(); } visuals.ondragstart = (e) => { @@ -321,4 +323,13 @@ document.body.onmouseup = (e) => { end_drag(); } +document.body.oncontextmenu = (e) => { + if (dragging) { + end_drag(); + e.preventDefault(); + } + if (context_menu) + context_menu.remove(); +} + load_dir(); -- cgit v1.2.3