multi-line quotes & init no longer uses jQuery

This commit is contained in:
marktaiwan 2015-01-28 22:49:42 +08:00
parent 5acdf16f5e
commit a8312b5196

View File

@ -333,21 +333,23 @@ function citeReply(id, with_link) {
// ??? // ???
textarea.value += '>>' + id + '\n'; textarea.value += '>>' + id + '\n';
} }
if (typeof $ != 'undefined') {
// multiline quotes // multiline quotes
var select = sessionStorage.quoteClipboard; var select = sessionStorage.quoteClipboard;
if (select) { if (select) {
select = select.split('\n'); select = select.split('\n');
$(select).each(function () { select.forEach(function (str) {
if (this !== '') if (str !== '') {
var str = '>'+ this +'\n'; str = '>' + str + '\n';
else } else {
var str = '\n'; str = '\n';
}
textarea.value += str; textarea.value += str;
}); });
delete sessionStorage.quoteClipboard; delete sessionStorage.quoteClipboard;
} }
if (typeof $ != 'undefined') {
$(window).trigger('cite', [id, with_link]); $(window).trigger('cite', [id, with_link]);
$(textarea).change(); $(textarea).change();
} }
@ -408,12 +410,10 @@ var script_settings = function(script_name) {
function init() { function init() {
init_stylechooser(); init_stylechooser();
if (typeof $ != 'undefined') {
// store highlighted text for citeReply() // store highlighted text for citeReply()
$('form[name="postcontrols"]').on('mouseup', function (e) { document.querySelector('form[name="postcontrols"]').addEventListener('mouseup', function (e) {
sessionStorage.quoteClipboard = window.getSelection().toString(); sessionStorage.quoteClipboard = window.getSelection().toString();
}); });
}
{% endraw %} {% endraw %}
{% if config.allow_delete %} {% if config.allow_delete %}