1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-17 19:29:28 +01:00

Merge pull request #367 from marktaiwan/quick-reply

Minor quick reply and quoting improvements
This commit is contained in:
Fredrick Brennan 2015-01-29 09:53:48 +08:00
commit c895ed6fb5
2 changed files with 30 additions and 11 deletions

View File

@ -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);
@ -373,7 +379,8 @@
} else {
$postForm.show();
}
$postForm.find('textarea[name="body"]').focus();
$(window).on('stylesheet', function() {
do_css();
if ($('link#stylesheet').attr('href')) {

View File

@ -333,16 +333,23 @@ function citeReply(id, with_link) {
// ???
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]);
$(textarea).change();
}
@ -403,6 +410,11 @@ var script_settings = function(script_name) {
function init() {
init_stylechooser();
// store highlighted text for citeReply()
document.querySelector('form[name="postcontrols"]').addEventListener('mouseup', function (e) {
sessionStorage.quoteClipboard = window.getSelection().toString();
});
{% endraw %}
{% if config.allow_delete %}
if (document.forms.postcontrols) {