##// END OF EJS Templates
JS formatting panel refactoring
neko259 -
r1084:86aa132a default
parent child Browse files
Show More
@@ -46,15 +46,20 b' function resetFormPosition() {'
46 }
46 }
47
47
48 function addQuickReply(postId) {
48 function addQuickReply(postId) {
49 var postLinkRaw = '[post]' + postId + '[/post]'
50
49 var textToAdd = '';
51 var textToAdd = '';
50 var blockToInsert = null;
52 var blockToInsert = null;
51
53
54 var textAreaJq = $('textarea');
55
52 if (postId != null) {
56 if (postId != null) {
53 var post = $('#' + postId);
57 var post = $('#' + postId);
54
58
55 // If this is not OP, add reflink to the post
59 // If this is not OP, add reflink to the post. If there already is
56 if (!post.is(':first-child')) {
60 // the same reflink, don't add it again.
57 textToAdd += '[post]' + postId + '[/post]\n';
61 if (!post.is(':first-child') && !textAreaJq.val().contains(postLinkRaw)) {
62 textToAdd += postLinkRaw + '\n';
58 }
63 }
59
64
60 blockToInsert = post;
65 blockToInsert = post;
@@ -67,15 +72,14 b' function addQuickReply(postId) {'
67 textToAdd += '[quote]' + selection + '[/quote]\n';
72 textToAdd += '[quote]' + selection + '[/quote]\n';
68 }
73 }
69
74
70 var textAreaId = 'textarea';
75 textAreaJq.val(textAreaJq.val()+ textToAdd);
71 $(textAreaId).val($(textAreaId).val()+ textToAdd);
72
76
73 var form = getForm();
77 var form = getForm();
74 form.insertAfter(blockToInsert);
78 form.insertAfter(blockToInsert);
75 form.show();
79 form.show();
76
80
81 textAreaJq.focus();
77 var textarea = document.getElementsByTagName('textarea')[0];
82 var textarea = document.getElementsByTagName('textarea')[0];
78 $(textAreaId).focus();
79 moveCaretToEnd(textarea);
83 moveCaretToEnd(textarea);
80 }
84 }
81
85
General Comments 0
You need to be logged in to leave comments. Login now