diff options
Diffstat (limited to 'templates/main.js')
| -rw-r--r-- | templates/main.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/templates/main.js b/templates/main.js index 984b1976..235b52db 100644 --- a/templates/main.js +++ b/templates/main.js @@ -185,25 +185,27 @@ function dopost(form) { } function citeReply(id, with_link) { - var body = document.getElementById('body'); + var textarea = document.getElementById('body'); if (document.selection) { // IE - body.focus(); + textarea.focus(); var sel = document.selection.createRange(); sel.text = '>>' + id + '\n'; - } else if (body.selectionStart || body.selectionStart == '0') { - // Mozilla - var start = body.selectionStart; - var end = body.selectionEnd; - body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length); + } else if (textarea.selectionStart || textarea.selectionStart == '0') { + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length); + + textarea.selectionStart += ('>>' + id).length + 1; + textarea.selectionEnd = textarea.selectionStart; } else { // ??? - body.value += '>>' + id + '\n'; + textarea.value += '>>' + id + '\n'; } if (typeof $ != 'undefined') { $(window).trigger('cite', [id, with_link]); - $(body).change(); + $(textarea).change(); } } |
