Show More
@@ -35,12 +35,7 b' function addMarkToMsg(start, end) {' | |||
|
35 | 35 | for (var i = 0; i < textareas.length; i++) { |
|
36 | 36 | var textarea = textareas[i]; |
|
37 | 37 | |
|
38 | if (document.selection) { | |
|
39 | textarea.focus(); | |
|
40 | ||
|
41 | var sel = document.selection.createRange(); | |
|
42 | sel.text = start + sel.text + end; | |
|
43 | } else if (textarea.selectionStart || textarea.selectionStart == '0') { | |
|
38 | if (textarea.selectionStart || textarea.selectionStart == '0') { | |
|
44 | 39 | textarea.focus(); |
|
45 | 40 | |
|
46 | 41 | var startPos = textarea.selectionStart; |
@@ -50,6 +45,11 b' function addMarkToMsg(start, end) {' | |||
|
50 | 45 | textarea.value = oldValue.substring(0, startPos) + start + |
|
51 | 46 | oldValue.substring(startPos, endPos) + end + |
|
52 | 47 | oldValue.substring(endPos, oldValue.length); |
|
48 | ||
|
49 | if (startPos == endPos) { | |
|
50 | var newPos = startPos + start.length; | |
|
51 | textarea.setSelectionRange(newPos, newPos); | |
|
52 | } | |
|
53 | 53 | } else { |
|
54 | 54 | textarea.value += start + end; |
|
55 | 55 | } |
@@ -30,14 +30,8 b" var REPLY_TO_MSG_ID = '#reply-to-message" | |||
|
30 | 30 | var $html = $("html, body"); |
|
31 | 31 | |
|
32 | 32 | function moveCaretToEnd(el) { |
|
33 | if (typeof el.selectionStart == "number") { | |
|
34 | el.selectionStart = el.selectionEnd = el.value.length; | |
|
35 | } else if (typeof el.createTextRange != "undefined") { | |
|
36 | el.focus(); | |
|
37 | var range = el.createTextRange(); | |
|
38 | range.collapse(false); | |
|
39 | range.select(); | |
|
40 | } | |
|
33 | var newPos = el.val().length; | |
|
34 | el[0].setSelectionRange(newPos, newPos); | |
|
41 | 35 | } |
|
42 | 36 | |
|
43 | 37 | function getForm() { |
@@ -95,8 +89,7 b' function addQuickReply(postId) {' | |||
|
95 | 89 | |
|
96 | 90 | textAreaJq.focus(); |
|
97 | 91 | |
|
98 | var textarea = document.getElementsByTagName('textarea')[0]; | |
|
99 | moveCaretToEnd(textarea); | |
|
92 | moveCaretToEnd(textAreaJq); | |
|
100 | 93 | } |
|
101 | 94 | } |
|
102 | 95 | |
@@ -122,8 +115,7 b' function addQuickQuote() {' | |||
|
122 | 115 | |
|
123 | 116 | textAreaJq.focus(); |
|
124 | 117 | |
|
125 | var textarea = document.getElementsByTagName('textarea')[0]; | |
|
126 | moveCaretToEnd(textarea); | |
|
118 | moveCaretToEnd(textAreaJq); | |
|
127 | 119 | } |
|
128 | 120 | |
|
129 | 121 | function scrollToBottom() { |
General Comments 0
You need to be logged in to leave comments.
Login now