selection

This commit is contained in:
James Campos 2011-09-03 13:38:07 -07:00
parent a6693e9f3a
commit a10cac59f7
2 changed files with 23 additions and 7 deletions

View File

@ -1392,14 +1392,23 @@
return QR.submit();
},
quote: function(e) {
var i, ss, ta, text, v;
var i, id, qr, s, sel, ss, ta, text, v, _ref;
e.preventDefault();
text = ">>" + this.textContent + "\n";
if (!QR.qr) {
id = this.textContent;
text = ">>" + id + "\n";
sel = getSelection();
if (id === ((_ref = $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)) != null ? _ref.name : void 0)) {
if (s = sel.toString().replace(/\n/g, '\n>')) {
text += ">" + s + "\n";
}
}
qr = QR.qr;
if (!qr) {
QR.dialog(text);
return;
}
ta = $('textarea', QR.qr);
$('#autohide', qr).checked = false;
ta = $('textarea', qr);
v = ta.value;
ss = ta.selectionStart;
ta.value = v.slice(0, ss) + text + v.slice(ss);

View File

@ -1096,11 +1096,18 @@ QR =
QR.submit() #derpy, but prevents calling QR.hasContent twice
quote: (e) ->
e.preventDefault()
text = ">>#{@textContent}\n"
if not QR.qr
id = @textContent
text = ">>#{id}\n"
sel = getSelection()
if id == $.x('preceding::input[@type="checkbox"][1]', sel.anchorNode)?.name
if s = sel.toString().replace /\n/g, '\n>'
text += ">#{s}\n"
{qr} = QR
if not qr
QR.dialog text
return
ta = $ 'textarea', QR.qr
$('#autohide', qr).checked = false
ta = $ 'textarea', qr
v = ta.value
ss = ta.selectionStart
ta.value = v[0...ss] + text + v[ss..]