From 65cd5489a296b98eb2be839d1c7dafee7dd2d03b Mon Sep 17 00:00:00 2001 From: Killy Date: Tue, 24 Oct 2017 02:37:14 +0300 Subject: www: comment form fixes show form buttons on focus; only focus if there is no hash (reply anchor) in url--- juick-www/src/main/static/scripts.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'juick-www/src') diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js index 4cd1bc82..08c02a9e 100644 --- a/juick-www/src/main/static/scripts.js +++ b/juick-www/src/main/static/scripts.js @@ -659,22 +659,21 @@ ready(function () { autosize(ta); }); - var insertButtons = function (e) { - var textarea = e.target; - textarea.classList.add('narrow'); - var att = document.createElement('div'); + let insertButtons = function (e) { + let textarea = e.target; + let att = document.createElement('div'); att.classList.add('attach-photo'); att.addEventListener('click', function (e) { attachCommentPhoto(e.target); }); textarea.parentNode.insertBefore(att, textarea.nextSibling); textarea.parentNode.insertAdjacentHTML('afterend', ''); - textarea.removeEventListener('click', insertButtons); + textarea.removeEventListener('focus', insertButtons); e.preventDefault(); }; - document.querySelectorAll('textarea.reply').forEach(function (e) { - e.addEventListener('click', insertButtons); - e.addEventListener('keypress', function (e) { + document.querySelectorAll('textarea.reply').forEach(function (ta) { + ta.addEventListener('focus', insertButtons); + ta.addEventListener('keypress', function (e) { postformListener(e.target, e); }); }); @@ -724,7 +723,7 @@ ready(function () { }); }); let threadTextarea = document.querySelector('.msgthread .ta-wrapper textarea'); - if (threadTextarea) { + if (threadTextarea && !window.location.hash) { threadTextarea.focus(); } document.querySelectorAll('.l .a-privacy').forEach(function (e) { -- cgit v1.2.3