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