From 8acd28f14a0df911e104c675c2bae2bcb0d36a9b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 30 Aug 2017 16:11:03 +0300 Subject: www: dom fixes --- juick-www/src/main/static/scripts.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'juick-www') diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js index 6b4d3f08..48c99287 100644 --- a/juick-www/src/main/static/scripts.js +++ b/juick-www/src/main/static/scripts.js @@ -288,12 +288,14 @@ function closeDialogListener(ev) { } } -function newMessage() { +function newMessage(evt) { + document.querySelectorAll('#newmessage .dialogtxt').forEach(t => { + t.remove(); + }); if (document.querySelector('#newmessage textarea').value.length == 0) { - openDialog('

' + i18n('postForm.pleaseInputMessageText') + '

'); - return false; + document.querySelector('#newmessage').insertAdjacentHTML('afterbegin', `

${i18n('postForm.pleaseInputMessageText')}

`); + evt.preventDefault(); } - return true; } function showMoreReplies(el, id) { @@ -818,18 +820,18 @@ ready(function () { getTags(); var newMessageBlock = document.getElementById('newmessage'); if (newMessageBlock) { - var form = newMessageBlock.parentNode; - form.addEventListener('submit', newMessage); + newMessageBlock.addEventListener('submit', newMessage); let ta = newMessageBlock.querySelector('textarea'); - ta.addEventListener('click', function (e) { - var parent = e.target.parentNode; - e.target.addEventListener('keypress', function (e) { - postformListener(e.target, e); - }); + ta.addEventListener('keypress', function (e) { + postformListener(e.target, e); }); ta.style.minHeight = '70px'; autosize(ta); ta.focus(); + newMessageBlock.querySelector('#tags_input') + .addEventListener('keypress', function (e) { + postformListener(e.target, e); + }); newMessageBlock.querySelector('a').addEventListener('click', function (e) { attachMessagePhoto(e.target); }); -- cgit v1.2.3