From b63ab15bf90c71ac488b8071d5beb01ddd00e901 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 5 Jun 2021 03:27:44 +0200 Subject: [PATCH] gallery links in new tab if a selection is atcive --- copyparty/web/browser.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 68726477..80188f6b 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -803,7 +803,10 @@ var thegrid = (function () { r.sz = v; swrite('gridsz', r.sz); } - document.documentElement.style.setProperty('--grid-sz', r.sz + 'em'); + try { + document.documentElement.style.setProperty('--grid-sz', r.sz + 'em'); + } + catch (ex) { } } setsz(); @@ -820,10 +823,18 @@ var thegrid = (function () { this.setAttribute('class', tr.getAttribute('class')); } + function bgopen(e) { + ev(e); + var url = this.getAttribute('href'); + window.open(url, '_blank'); + } + r.loadsel = function () { - var ths = QSA('#ggrid>a'); + var ths = QSA('#ggrid>a'), + have_sel = !!QS('#files tr.sel'); + for (var a = 0, aa = ths.length; a < aa; a++) { - ths[a].onclick = r.sel ? seltgl : null; + ths[a].onclick = r.sel ? seltgl : have_sel ? bgopen : null; ths[a].setAttribute('class', ebi(ths[a].getAttribute('ref')).parentNode.parentNode.getAttribute('class')); } var uns = QS('#ggrid a[ref="unsearch"]');