aboutsummaryrefslogtreecommitdiff
path: root/juick-www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-08-30 16:11:03 +0300
committerGravatar Vitaly Takmazov2017-08-30 16:11:03 +0300
commit8acd28f14a0df911e104c675c2bae2bcb0d36a9b (patch)
treeaf0375430d0d3854b3988d24dec5a824715bec4e /juick-www
parentfeea15b5878edd01935c2bde8d8e472441489dd4 (diff)
www: dom fixes
Diffstat (limited to 'juick-www')
-rw-r--r--juick-www/src/main/static/scripts.js24
1 files changed, 13 insertions, 11 deletions
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('<p class="dialogtxt">' + i18n('postForm.pleaseInputMessageText') + '</p>');
- return false;
+ document.querySelector('#newmessage').insertAdjacentHTML('afterbegin', `<p class="dialogtxt">${i18n('postForm.pleaseInputMessageText')}</p>`);
+ 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);
});