Fix last Firefox issue.

This commit is contained in:
Nicolas Stepien 2011-12-06 21:33:31 +01:00
parent ccad16264d
commit 0c56b42f37
2 changed files with 7 additions and 5 deletions

View File

@ -1647,7 +1647,7 @@
return false;
},
quote: function(e) {
var id, s, selection, selectionID, ta, text, _ref;
var caretPos, id, s, selection, selectionID, ta, text, _ref;
if (e) e.preventDefault();
if (qr.el) {
$('#autohide', qr.el).checked = false;
@ -1665,9 +1665,10 @@
}
}
ta = $('textarea', qr.el);
ta.value = ta.value.slice(0, ta.selectionStart) + text + ta.value.slice(ta.selectionEnd, ta.value.length);
caretPos = ta.selectionStart;
ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd, ta.value.length);
ta.focus();
return ta.selectionStart = ta.selectionEnd = ta.selectionStart + text.length;
return ta.selectionStart = ta.selectionEnd = caretPos + text.length;
},
refresh: function() {
var m, newFile, oldFile, _ref;

View File

@ -1301,11 +1301,12 @@ qr =
text += ">#{s}\n"
ta = $ 'textarea', qr.el
caretPos = ta.selectionStart
#replace selection for text
ta.value = ta.value.slice(0, ta.selectionStart) + text + ta.value.slice(ta.selectionEnd, ta.value.length)
ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd, ta.value.length)
ta.focus()
#move the caret to the end of the new quote
ta.selectionStart = ta.selectionEnd = ta.selectionStart + text.length
ta.selectionStart = ta.selectionEnd = caretPos + text.length
refresh: ->
$('[name=sub]', qr.el).value = ''