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