diff options
author | Killy | 2017-10-26 23:32:38 +0300 |
---|---|---|
committer | Killy | 2017-10-26 23:32:38 +0300 |
commit | 530f7af25aa4f8261d580d6c0ba7b666bf3f1442 (patch) | |
tree | ab61c0979f2749982c5723048cfc171ff19d8449 | |
parent | 8d11b5e2c030d75afb1d144423ec37c7945f9b5d (diff) |
www: photo remove and reattach fix
-rw-r--r-- | juick-www/src/main/static/scripts.js | 17 |
1 files changed, 9 insertions, 8 deletions
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); } } |