From 4c0a26dbf9fca5358320ad11911aac1d5cc530b3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Nov 2020 10:45:35 +0000 Subject: move post_comment() handling via ctrl-enter out of handle_comment_form() - to many issues with multiple triggers --- view/js/main.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 380b2bbf7..bd595dbb3 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -56,7 +56,7 @@ $.ajaxSetup({cache: false}); $(document).ready(function() { - $(document).on('click', '.comment-edit-form', handle_comment_form); + $(document).on('click focus', '.comment-edit-form', handle_comment_form); $(document).on('click', '.conversation-settings-link', getConversationSettings); $(document).on('click', '#settings_module_ajax_submit', postConversationSettings); @@ -69,6 +69,13 @@ $(document).ready(function() { this.autocomplete_handled = true; } + + }); + + $(document).on('keydown', '.comment-edit-form textarea.expanded', function (e) { + if (e.ctrlKey && e.keyCode === 13) { + post_comment(this.id.replace('comment-edit-text-','')); + } }); var tf = new Function('n', 's', 'var k = s.split("/")['+aStr['plural_func']+']; return (k ? k : s);'); @@ -280,6 +287,7 @@ function handle_comment_form(e) { // handle clicked form var form = $(this); + var fields = form.find(':input[type=text], textarea'); var fields_empty = true; @@ -294,9 +302,9 @@ function handle_comment_form(e) { form.find(':not(:visible)').show(); } + // handle click outside of form (close empty forms) $(document).one('click', function(e) { - fields.each(function() { if($(this).val() != '') fields_empty = false; @@ -333,12 +341,6 @@ function handle_comment_form(e) { },10000); }); - $('#' + emptyCommentElm).on('keydown', function (e) { - if (e.ctrlKey && e.keyCode === 13) { - post_comment(convId); - } - }); - function commentSaveChanges(convId, isFinal) { if(typeof isFinal === 'undefined') @@ -1174,7 +1176,7 @@ function doreply(parent, ident, owner, hint) { var sel = 'wall-item-body-' + ident.toString(); var quote = window.getSelection().toString().trim(); form.find('textarea').val("@{" + owner + "}" + ((($(window.getSelection().anchorNode).closest("#" + sel).attr("id") != sel) || (quote.length === 0))? " " : "\n[quote]" + quote + "[/quote]\n")); - $('#comment-edit-text-' + parent.toString()).focus().trigger('click'); + $('#comment-edit-text-' + parent.toString()).focus(); } function doscroll(parent, hidden) { -- cgit v1.2.3