diff options
Diffstat (limited to 'web/scripts3.js')
-rw-r--r-- | web/scripts3.js | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/web/scripts3.js b/web/scripts3.js index 3ad5a5cf..626c4020 100644 --- a/web/scripts3.js +++ b/web/scripts3.js @@ -44,7 +44,29 @@ function wsSendKeepAlive() { /******************************************************************************/ function postformListener(formEl,ev) { - if(ev.ctrlKey && (ev.keyCode==10 || ev.keyCode==13)) formEl.submit(); + if(ev.ctrlKey && (ev.keyCode==10 || ev.keyCode==13)) { + if(!formEl.onsubmit || formEl.onsubmit()) { + formEl.submit(); + } + } +} + +function unfoldPostForm() { + if(window.location.pathname==="/" && window.location.hash==="#post") { + $('#newmessage>div').css('display','block'); + $('#newmessage textarea')[0].focus(); + } +} + +function onsubmitNewMessage() { + if($('#newmessage .tags').val().length==0) { + openDialog('<p class="dialogtxt">Пожалуйста, введите теги сообщения</p>'); + return false; + } else if($('#newmessage textarea').val().length==0) { + openDialog('<p class="dialogtxt">Пожалуйста, введите текст сообщения</p>'); + return false; + } + return true; } function showMoreReplies(id) { @@ -490,29 +512,26 @@ jQuery.fn.selectText = function(){ /******************************************************************************/ $(document).ready(function() { - var tareply=$('textarea.reply'); - tareply.autoResize({ + $('textarea').autoResize({ extraSpace: 0, minHeight: 1 }); - tareply.click(function () { + + $('textarea.reply').click(function () { $(this).addClass("narrow"); $(this).after('<div class="attach-photo" onclick="attachCommentPhoto(this)"/>'); $(this).parent().after('<input type="submit" value="OK"/>'); $(this).off('click'); }); - var pmreply=$('textarea.replypm'); - pmreply.autoResize({ - extraSpace: 0, - minHeight: 1 - }); - pmreply.click(function () { + $('textarea.replypm').click(function () { $(this).addClass("narrowpm"); $(this).parent().after('<input type="submit" value="OK"/>'); $(this).off('click'); }); + unfoldPostForm(); unfoldReply(); + $(window).bind('hashchange',unfoldPostForm); $(window).bind('hashchange',unfoldReply); }); |