From 530f7af25aa4f8261d580d6c0ba7b666bf3f1442 Mon Sep 17 00:00:00 2001 From: Killy Date: Thu, 26 Oct 2017 23:32:38 +0300 Subject: www: photo remove and reattach fix --- juick-www/src/main/static/scripts.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'juick-www/src/main/static/scripts.js') diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js index e08d8351..06fd78c7 100644 --- a/juick-www/src/main/static/scripts.js +++ b/juick-www/src/main/static/scripts.js @@ -379,16 +379,17 @@ function attachInput() { } function attachCommentPhoto(div) { - if (div.children.length === 1) { - let inp = attachInput(); - inp.addEventListener('change', function () { + let input = div.querySelector('input'); + if (input) { + input.remove(); + div.classList.remove('attach-photo-active'); + } else { + let newInput = attachInput(); + newInput.addEventListener('change', function () { div.classList.add('attach-photo-active'); }); - inp.click(); - div.appendChild(inp); - } else { - div.innerHTML = null; - div.classList.remove('attach-photo-active'); + newInput.click(); + div.appendChild(newInput); } } -- cgit v1.2.3