Show More
@@ -34,24 +34,31 b' function addMarkToMsg(start, end) {' | |||
|
34 | 34 | return addTextToEachLineOfSelection(start); |
|
35 | 35 | } |
|
36 | 36 | |
|
37 |
var textareas = |
|
|
37 | var textareas = $('textarea'); | |
|
38 | 38 | |
|
39 | 39 | for (var i = 0; i < textareas.length; i++) { |
|
40 | 40 | var textarea = textareas[i]; |
|
41 | 41 | |
|
42 |
if( |
|
|
42 | if (document.selection) { | |
|
43 | 43 | textarea.focus(); |
|
44 | ||
|
44 | 45 | var sel = document.selection.createRange(); |
|
45 | 46 | sel.text = start + sel.text + end; |
|
46 | } else if(textarea.selectionStart || textarea.selectionStart == '0') { | |
|
47 | } else if (textarea.selectionStart || textarea.selectionStart == '0') { | |
|
47 | 48 | textarea.focus(); |
|
49 | ||
|
48 | 50 | var startPos = textarea.selectionStart; |
|
49 | 51 | var endPos = textarea.selectionEnd; |
|
50 | textarea.value = textarea.value.substring(0, startPos) + start + textarea.value.substring(startPos, endPos) + end + textarea.value.substring( endPos, textarea.value.length ); | |
|
52 | ||
|
53 | var oldValue = textarea.value; | |
|
54 | textarea.value = oldValue.substring(0, startPos) + start + | |
|
55 | oldValue.substring(startPos, endPos) + end + | |
|
56 | oldValue.substring(endPos, oldValue.length); | |
|
51 | 57 | } else { |
|
52 | 58 | textarea.value += start + end; |
|
53 | 59 | } |
|
54 | 60 | } |
|
61 | ||
|
55 | 62 | return false; |
|
56 | 63 | } |
|
57 | 64 | |
@@ -117,4 +124,4 b' function getLinesRange(start, end, value' | |||
|
117 | 124 | rangeEnd = i; |
|
118 | 125 | } |
|
119 | 126 | return [rangeStart, rangeEnd]; |
|
120 | } No newline at end of file | |
|
127 | } |
General Comments 0
You need to be logged in to leave comments.
Login now