From 5aa54d1217790a481c69391549385343b05e4640 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 16 Jul 2023 18:15:56 +0000 Subject: [PATCH] shift/ctrl-click improvements: * always enable shift-click selection in list-view * shift-clicking thumbnails opens in new window by default as expected * enable shift-select in grid-view when multiselect is on * invert select when the same shift-select is made repeatedly --- copyparty/web/baguettebox.js | 2 +- copyparty/web/browser.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/copyparty/web/baguettebox.js b/copyparty/web/baguettebox.js index 6f3e8037..681a1cf8 100644 --- a/copyparty/web/baguettebox.js +++ b/copyparty/web/baguettebox.js @@ -127,7 +127,7 @@ window.baguetteBox = (function () { var gallery = []; [].forEach.call(tagsNodeList, function (imageElement, imageIndex) { var imageElementClickHandler = function (e) { - if (ctrl(e)) + if (ctrl(e) || e && e.shiftKey) return true; e.preventDefault ? e.preventDefault() : e.returnValue = false; diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 333da965..454e579f 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -189,8 +189,8 @@ var Ls = { "cl_hpick": "click one column header to hide in the table below", "cl_hcancel": "column hiding aborted", - "ct_thumb": "in icon view, toggle icons or thumbnails$NHotkey: T", - "ct_csel": "use CTRL and SHIFT for file selection", + "ct_thumb": "in grid-view, toggle icons or thumbnails$NHotkey: T", + "ct_csel": "use CTRL and SHIFT for file selection in grid-view", "ct_dots": "show hidden files (if server permits)", "ct_dir1st": "sort folders before files", "ct_readme": "show README.md in folder listings", @@ -652,7 +652,7 @@ var Ls = { "cl_hcancel": "kolonne-skjuling avbrutt", "ct_thumb": "vis miniatyrbilder istedenfor ikoner$NSnarvei: T", - "ct_csel": "bruk tastene CTRL og SHIFT for markering av filer", + "ct_csel": "bruk tastene CTRL og SHIFT for markering av filer i ikonvisning", "ct_dots": "vis skjulte filer (gitt at serveren tillater det)", "ct_dir1st": "sorter slik at mapper kommer foran filer", "ct_readme": "vis README.md nedenfor filene", @@ -4300,7 +4300,7 @@ var thegrid = (function () { setsz(); function gclick1(e) { - if (ctrl(e) && !treectl.csel) + if (ctrl(e) && !treectl.csel && !r.sel) return true; return gclick.bind(this)(e, false); @@ -4324,7 +4324,7 @@ var thegrid = (function () { td = oth.closest('td').nextSibling, tr = td.parentNode; - if (r.sel && !dbl || treectl.csel && (e.shiftKey || ctrl(e))) { + if ((r.sel && !dbl && !ctrl(e)) || (treectl.csel && (e.shiftKey || ctrl(e)))) { td.onclick.bind(td)(e); if (e.shiftKey) return r.loadsel(); @@ -6749,7 +6749,7 @@ var msel = (function () { var tr = this.parentNode, id = tr2id(tr); - if (treectl.csel && e.shiftKey && r.so && id && r.so != id) { + if ((treectl.csel || !thegrid.en || thegrid.sel) && e.shiftKey && r.so && id && r.so != id) { var o1 = -1, o2 = -1; for (a = 0; a < r.all.length; a++) { var ai = r.all[a].id; @@ -6762,11 +6762,16 @@ var msel = (function () { if (o1 > o2) o2 = [o1, o1 = o2][0]; - if (r.pr) + if (r.pr) { // invert previous range, in case it was narrowed for (var a = r.pr[0]; a <= r.pr[1]; a++) clmod(ebi(r.all[a].id).closest('tr'), 'sel', !st); + // and invert current selection if repeated + if (r.pr[0] === o1 && r.pr[1] === o2) + st = !st; + } + for (var a = o1; a <= o2; a++) clmod(ebi(r.all[a].id).closest('tr'), 'sel', st);