From 2d1187b6a3cc1ac58efd1c905118554423b1f0c0 Mon Sep 17 00:00:00 2001 From: Massimo Melina Date: Sun, 2 Aug 2020 17:44:02 +0200 Subject: [PATCH] tpl: moved archive button to "selection" sub-menu --- default.tpl | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/default.tpl b/default.tpl index 5fdab32..077a53c 100644 --- a/default.tpl +++ b/default.tpl @@ -109,14 +109,6 @@ $domReady(()=>{ {.!Toggle timestamp.} - {.if|{.get|can archive.}| - - .} {.if| {.get|can upload.} |{: + {.if|{.get|can archive.}| + + .} @@ -1273,6 +1271,12 @@ function $icon(name, title, opts) { return $create('i.fa.fa-'+name, Object.assign({ title },opts)) } +function mustSelect() { + return getSelectedItems().length + || showError(`{.!You need to select some files first.}`) + && 0 +} + $domReady(()=>{ if (!$sel('#menu-panel')) // this is an error page return @@ -1328,10 +1332,15 @@ $domReady(()=>{ }) $click('#select-mask', selectionMask) - $click('#move-selection',()=> moveFiles(getSelectedItemsName()) ) + $click('#move-selection',()=> + mustSelect() && moveFiles(getSelectedItemsName()) ) $toggle('move-selection', $sel('.can-delete')) - $click('#delete-selection', ()=> deleteFiles(getSelectedItemsName()) ) + $click('#delete-selection', ()=> + mustSelect() && deleteFiles(getSelectedItemsName()) ) $toggle('delete-selection', $sel('.can-delete')) + $click('#archive', ()=> + mustSelect() && ask("{.!Downloading many files as archive can be a lengthy operation, and the result is a TAR file. Continue?.}", ()=> + submit({ selection: getSelectedItemsName() }, "{.get|url|mode=archive|recursive.}") )) $msel('#files .cannot-access .item-link img', x=> x.insertAdjacentElement('afterend', $icon('lock', "{.!No access.}") ))