##// END OF EJS Templates
Do not close the form when clicking 'reply' again on the same post
neko259 -
r1830:5502a653 default
parent child Browse files
Show More
@@ -57,40 +57,35 b' function showFormAfter(blockToInsertAfte'
57 }
57 }
58
58
59 function addQuickReply(postId) {
59 function addQuickReply(postId) {
60 // If we click "reply" on the same post, it means "cancel"
60 var blockToInsert = null;
61 if (getForm().prev().attr('id') == postId) {
61 var textAreaJq = getPostTextarea();
62 resetFormPosition();
62 var postLinkRaw = '[post]' + postId + '[/post]'
63 } else {
63 var textToAdd = '';
64 var blockToInsert = null;
65 var textAreaJq = getPostTextarea();
66 var postLinkRaw = '[post]' + postId + '[/post]'
67 var textToAdd = '';
68
64
69 if (postId != null) {
65 if (postId != null) {
70 var post = $('#' + postId);
66 var post = $('#' + postId);
71
67
72 // If this is not OP, add reflink to the post. If there already is
68 // If this is not OP, add reflink to the post. If there already is
73 // the same reflink, don't add it again.
69 // the same reflink, don't add it again.
74 var postText = textAreaJq.val();
70 var postText = textAreaJq.val();
75 if (!post.is(':first-child') && postText.indexOf(postLinkRaw) < 0) {
71 if (!post.is(':first-child') && postText.indexOf(postLinkRaw) < 0) {
76 // Insert line break if none is present.
72 // Insert line break if none is present.
77 if (postText.length > 0 && !postText.endsWith('\n') && !postText.endsWith('\r')) {
73 if (postText.length > 0 && !postText.endsWith('\n') && !postText.endsWith('\r')) {
78 textToAdd += '\n';
74 textToAdd += '\n';
79 }
80 textToAdd += postLinkRaw + '\n';
81 }
75 }
76 textToAdd += postLinkRaw + '\n';
77 }
82
78
83 textAreaJq.val(textAreaJq.val()+ textToAdd);
79 textAreaJq.val(textAreaJq.val()+ textToAdd);
84 blockToInsert = post;
80 blockToInsert = post;
85 } else {
81 } else {
86 blockToInsert = $('.thread');
82 blockToInsert = $('.thread');
87 }
83 }
88 showFormAfter(blockToInsert);
84 showFormAfter(blockToInsert);
89
90 textAreaJq.focus();
91
85
92 moveCaretToEnd(textAreaJq);
86 textAreaJq.focus();
93 }
87
88 moveCaretToEnd(textAreaJq);
94 }
89 }
95
90
96 function addQuickQuote() {
91 function addQuickQuote() {
@@ -98,7 +93,7 b' function addQuickQuote() {'
98
93
99 var quoteButton = $("#quote-button");
94 var quoteButton = $("#quote-button");
100 var postId = quoteButton.attr('data-post-id');
95 var postId = quoteButton.attr('data-post-id');
101 if (postId != null && getForm().prev().attr('id') != postId) {
96 if (postId != null) {
102 addQuickReply(postId);
97 addQuickReply(postId);
103 }
98 }
104
99
General Comments 0
You need to be logged in to leave comments. Login now