forked from GithubBackups/vichan
Merge pull request #367 from marktaiwan/quick-reply
Minor quick reply and quoting improvements
This commit is contained in:
commit
c895ed6fb5
@ -278,7 +278,13 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment'));
|
$postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment'))
|
||||||
|
.on('keydown', function (e) {
|
||||||
|
//close quick reply when esc is prssed
|
||||||
|
if (e.which === 27) {
|
||||||
|
$('.close-btn').trigger('click');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff);
|
$postForm.find('textarea:not([name="body"]),input[type="hidden"]:not(.captcha_cookie)').removeAttr('id').appendTo($dummyStuff);
|
||||||
|
|
||||||
@ -374,6 +380,7 @@
|
|||||||
$postForm.show();
|
$postForm.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$postForm.find('textarea[name="body"]').focus();
|
||||||
$(window).on('stylesheet', function() {
|
$(window).on('stylesheet', function() {
|
||||||
do_css();
|
do_css();
|
||||||
if ($('link#stylesheet').attr('href')) {
|
if ($('link#stylesheet').attr('href')) {
|
||||||
|
@ -333,16 +333,23 @@ function citeReply(id, with_link) {
|
|||||||
// ???
|
// ???
|
||||||
textarea.value += '>>' + id + '\n';
|
textarea.value += '>>' + id + '\n';
|
||||||
}
|
}
|
||||||
if (typeof $ != 'undefined') {
|
|
||||||
var select = document.getSelection().toString();
|
|
||||||
if (select) {
|
|
||||||
var body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs
|
|
||||||
var index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this
|
|
||||||
if (index > -1) {
|
|
||||||
textarea.value += '>' + select + '\n';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// multiline quotes
|
||||||
|
var select = sessionStorage.quoteClipboard;
|
||||||
|
if (select) {
|
||||||
|
select = select.split('\n');
|
||||||
|
select.forEach(function (str) {
|
||||||
|
if (str !== '') {
|
||||||
|
str = '>' + str + '\n';
|
||||||
|
} else {
|
||||||
|
str = '\n';
|
||||||
|
}
|
||||||
|
textarea.value += str;
|
||||||
|
});
|
||||||
|
delete sessionStorage.quoteClipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof $ != 'undefined') {
|
||||||
$(window).trigger('cite', [id, with_link]);
|
$(window).trigger('cite', [id, with_link]);
|
||||||
$(textarea).change();
|
$(textarea).change();
|
||||||
}
|
}
|
||||||
@ -403,6 +410,11 @@ var script_settings = function(script_name) {
|
|||||||
function init() {
|
function init() {
|
||||||
init_stylechooser();
|
init_stylechooser();
|
||||||
|
|
||||||
|
// store highlighted text for citeReply()
|
||||||
|
document.querySelector('form[name="postcontrols"]').addEventListener('mouseup', function (e) {
|
||||||
|
sessionStorage.quoteClipboard = window.getSelection().toString();
|
||||||
|
});
|
||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
{% if config.allow_delete %}
|
{% if config.allow_delete %}
|
||||||
if (document.forms.postcontrols) {
|
if (document.forms.postcontrols) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user