From 4fb2d4cad66b24efff2913c3058e2ed581bbef39 Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Wed, 12 Mar 2014 02:20:20 +0700 Subject: New post form --- web/scripts3.js | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'web/scripts3.js') 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('

Пожалуйста, введите теги сообщения

'); + return false; + } else if($('#newmessage textarea').val().length==0) { + openDialog('

Пожалуйста, введите текст сообщения

'); + 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('
'); $(this).parent().after(''); $(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(''); $(this).off('click'); }); + unfoldPostForm(); unfoldReply(); + $(window).bind('hashchange',unfoldPostForm); $(window).bind('hashchange',unfoldReply); }); -- cgit v1.2.3