From: Mischa POSLAWSKY Date: Fri, 29 May 2020 05:10:27 +0000 (+0200) Subject: word edit: hide original image until requested X-Git-Tag: v1.13~244 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/cae266f89c2f8b9c192dfbe9b9126ef9ac144e6f word edit: hide original image until requested --- diff --git a/writer.js b/writer.js index 450a8f2..e21b684 100644 --- a/writer.js +++ b/writer.js @@ -31,4 +31,16 @@ document.addEventListener('DOMContentLoaded', () => { }).catch(error => alert(error)); return false; }; + + let imgpreview = document.getElementById('sourcepreview'); + if (imgpreview) { + let imginput = document.getElementById('source'); + let previewbutton = imginput.parentNode.appendChild(document.createElement('button')); + previewbutton.type = 'button'; + previewbutton.append('View'); + previewbutton.onclick = () => { + previewbutton.childNodes[0].nodeValue = imgpreview.hidden ? 'Hide' : 'View'; + imgpreview.hidden = !imgpreview.hidden; + }; + } }); diff --git a/writer.plp b/writer.plp index 2df9e55..206333f 100644 --- a/writer.plp +++ b/writer.plp @@ -40,9 +40,6 @@ input:not([type]) { select { padding: .3rem .2rem; /* TODO: input */ } -form > ul li img { - max-width: 300px; -} ul.popup { display: flex; @@ -108,7 +105,7 @@ my @wordcols = ( form => 'Translation', alt => 'Synonyms', wptitle => 'Wikipedia', - source => 'Image URL', + source => 'Image', thumb => 'Convert options', prio => 'Level', cover => undef, # included with prio @@ -231,12 +228,13 @@ for my $colinfo (pairs @wordcols) { } else { printf '', $col, Entity($val); - -e and printf '%s', $_, $row->{form} for - $col eq 'source' ? "data/word/org/$row->{id}.jpg" : - $col eq 'thumb' ? "data/word/eng/$row->{form}.jpg" : - (); + -e and printf '%s', $_, $row->{form} + for $col eq 'thumb' ? "data/word/eng/$row->{form}.jpg" : (); } print ''; + -e and printf('', + $col, $_, $row->{form} + ) for $col eq 'source' ? "data/word/org/$row->{id}.jpg" : (); say '

'; } :>