diff options
-rw-r--r-- | view/js/main.js | 28 | ||||
-rwxr-xr-x | view/tpl/jot-header.tpl | 29 |
2 files changed, 36 insertions, 21 deletions
diff --git a/view/js/main.js b/view/js/main.js index 560868046..3dae45cff 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -56,7 +56,7 @@ $.ajaxSetup({cache: false}); $(document).ready(function() { - $(document).on('click focus', '.comment-edit-form', handle_comment_form); + $(document).on('click', '.comment-edit-form', handle_comment_form); $(document).on('click', '.conversation-settings-link', getConversationSettings); $(document).on('click', '#settings_module_ajax_submit', postConversationSettings); @@ -95,7 +95,6 @@ $(document).ready(function() { jQuery.timeago.settings.allowFuture = true; - if(sse_enabled) { if(typeof(window.SharedWorker) === 'undefined') { // notifications with multiple tabs open will not work very well in this scenario @@ -244,8 +243,6 @@ $(document).ready(function() { cache_next_page(); }); - - }); function getConversationSettings() { @@ -325,7 +322,8 @@ function handle_comment_form(e) { } // handle click outside of form (close empty forms) - $(document).on('click', function(e) { + $(document).one('click', function(e) { + fields.each(function() { if($(this).val() != '') fields_empty = false; @@ -344,23 +342,30 @@ function handle_comment_form(e) { form.find(':button[type=submit]').prop('title', ''); } }); - + var commentSaveTimer = null; var emptyCommentElm = form.find('.comment-edit-text').attr('id'); var convId = emptyCommentElm.replace('comment-edit-text-',''); - $(document).on('focusout','#' + emptyCommentElm,function(e){ + $('#' + emptyCommentElm).on('focusout',function(e){ if(commentSaveTimer) clearTimeout(commentSaveTimer); commentSaveChanges(convId,true); commentSaveTimer = null; + $('#' + emptyCommentElm).off(); }); - $(document).on('focusin','#' + emptyCommentElm,function(e){ + $('#' + emptyCommentElm).on('focusin', function (e){ commentSaveTimer = setTimeout(function () { commentSaveChanges(convId,false); },10000); }); + $('#' + emptyCommentElm).on('keydown', function (e) { + if (e.ctrlKey && e.keyCode === 13) { + post_comment(convId); + } + }); + function commentSaveChanges(convId, isFinal) { if(typeof isFinal === 'undefined') @@ -379,8 +384,11 @@ function handle_comment_form(e) { } } } + } + + function commentClose(obj, id) { if(obj.value === '') { obj.value = aStr.comment; @@ -1414,7 +1422,7 @@ function post_comment(id) { $(document).unbind( "click.commentOpen"); } if(timer) clearTimeout(timer); - timer = setTimeout(updateInit,1500); + timer = setTimeout(updateInit, 500); } if(data.reload) { window.location.href=data.reload; @@ -1425,6 +1433,8 @@ function post_comment(id) { return false; } + + function preview_comment(id) { $("#comment-preview-inp-" + id).val("1"); $("#comment-edit-preview-" + id).show(); diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index d519fd666..d78907b38 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -61,13 +61,11 @@ var activeCommentText = ''; $('#jot-add-option').on('click', jotAddOption); $(document).on('click', '.poll-option-close', jotRemoveOption); - function jotSetMime() { - var mtype = $('#id_mimetype').val(); - if(mtype == 'text/bbcode') - $('#profile-jot-submit-left').show(); - else - $('#profile-jot-submit-left').hide(); - } + $('#profile-jot-form').keydown(function(e) { + if (e.ctrlKey && e.keyCode === 13) { + $(this).trigger('submit'); + } + }); $('#invisible-wall-file-upload').fileupload({ url: 'wall_attach/{{$nickname}}', @@ -91,11 +89,10 @@ var activeCommentText = ''; $('#wall-file-upload').click(function(event) { event.preventDefault(); $('#invisible-wall-file-upload').trigger('click'); return false;}); $('#wall-file-upload-sub').click(function(event) { event.preventDefault(); $('#invisible-wall-file-upload').trigger('click'); return false;}); - // call initialization file - if (window.File && window.FileList && window.FileReader) { - DragDropUploadInit(); - } - + // call initialization file + if (window.File && window.FileList && window.FileReader) { + DragDropUploadInit(); + } $('#invisible-comment-upload').fileupload({ url: 'wall_attach/{{$nickname}}', @@ -128,6 +125,14 @@ var activeCommentText = ''; }); + function jotSetMime() { + var mtype = $('#id_mimetype').val(); + if(mtype == 'text/bbcode') + $('#profile-jot-submit-left').show(); + else + $('#profile-jot-submit-left').hide(); + } + function deleteCheckedItems() { var checkedstr = ''; |