insert text at cursor
This commit is contained in:
parent
4225a7dfdf
commit
dfd226bd64
@ -1253,8 +1253,20 @@
|
|||||||
return $.bind(quote, 'click', QR.quote);
|
return $.bind(quote, 'click', QR.quote);
|
||||||
},
|
},
|
||||||
quote: function(e) {
|
quote: function(e) {
|
||||||
|
var i, ss, ta, text, v;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return QR.dialog(">>" + this.textContent + "\n");
|
text = ">>" + this.textContent + "\n";
|
||||||
|
if (!QR.el) {
|
||||||
|
QR.dialog(text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ta = $('textarea', QR.el);
|
||||||
|
v = ta.value;
|
||||||
|
ss = ta.selectionStart;
|
||||||
|
ta.value = v.slice(0, ss) + text + v.slice(ss);
|
||||||
|
i = ss + text.length;
|
||||||
|
ta.setSelectionRange(i, i);
|
||||||
|
return ta.focus();
|
||||||
},
|
},
|
||||||
dialog: function(text) {
|
dialog: function(text) {
|
||||||
var l, ta;
|
var l, ta;
|
||||||
|
|||||||
@ -984,7 +984,17 @@ QR =
|
|||||||
$.bind quote, 'click', QR.quote
|
$.bind quote, 'click', QR.quote
|
||||||
quote: (e) ->
|
quote: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
QR.dialog ">>#{@textContent}\n"
|
text = ">>#{@textContent}\n"
|
||||||
|
if not QR.el
|
||||||
|
QR.dialog text
|
||||||
|
return
|
||||||
|
ta = $ 'textarea', QR.el
|
||||||
|
v = ta.value
|
||||||
|
ss = ta.selectionStart
|
||||||
|
ta.value = v[0...ss] + text + v[ss..]
|
||||||
|
i = ss + text.length
|
||||||
|
ta.setSelectionRange i, i
|
||||||
|
ta.focus()
|
||||||
dialog: (text='') ->
|
dialog: (text='') ->
|
||||||
QR.el = ui.dialog 'qr', top: '0', left: '0', "
|
QR.el = ui.dialog 'qr', top: '0', left: '0', "
|
||||||
<a class=close title=close>X</a><input type=checkbox id=autohide title=autohide>
|
<a class=close title=close>X</a><input type=checkbox id=autohide title=autohide>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user