2012-03-15 18:14:54 +11:00
|
|
|
/*
|
|
|
|
* quick-posts-controls.js
|
2012-03-31 11:13:11 +11:00
|
|
|
* https://github.com/savetheinternet/Tinyboard/blob/master/js/quick-posts-controls.js
|
2012-03-15 18:14:54 +11:00
|
|
|
*
|
|
|
|
* Released under the MIT license
|
|
|
|
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
|
2014-01-19 14:27:24 +01:00
|
|
|
* Copyright (c) 2013 undido <firekid109@hotmail.com>
|
|
|
|
* Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
|
2012-03-15 18:14:54 +11:00
|
|
|
*
|
|
|
|
* Usage:
|
|
|
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
|
|
|
* $config['additional_javascript'][] = 'js/quick-post-controls.js';
|
|
|
|
*/
|
|
|
|
|
2024-08-24 00:52:29 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
let open_form = function() {
|
|
|
|
let id = $(this).attr('name').match(/^delete_(\d+)$/)[1];
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
let post_form = $('<form class="post-actions" method="post" style="margin:10px 0 0 0">' +
|
2024-08-24 00:47:18 +02:00
|
|
|
'<div style="text-align:right"><hr>' +
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2012-03-15 18:14:54 +11:00
|
|
|
'<input type="hidden" name="delete_' + id + '">' +
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2024-08-24 00:47:18 +02:00
|
|
|
'<label for="password_' + id + '">' + _("Password")+'</label>: ' +
|
2012-03-15 18:14:54 +11:00
|
|
|
'<input id="password_' + id + '" type="password" name="password" size="11" maxlength="18">' +
|
2024-08-24 00:47:18 +02:00
|
|
|
'<input title="' + _('Delete file only') + '" type="checkbox" name="file" id="delete_file_' + id + '">' +
|
2024-08-24 00:52:29 +02:00
|
|
|
'<label for="delete_file_' + id + '">' + _('File') + '</label>' +
|
|
|
|
' <input type="submit" name="delete" value="' + _('Delete') + '">' +
|
|
|
|
|
2012-03-15 18:14:54 +11:00
|
|
|
'<br>' +
|
2024-08-24 00:52:29 +02:00
|
|
|
|
|
|
|
'<label for="reason_' + id + '">' + _('Reason') + '</label>: ' +
|
2012-03-15 18:14:54 +11:00
|
|
|
'<input id="reason_' + id + '" type="text" name="reason" size="20" maxlength="100">' +
|
2024-08-24 00:52:29 +02:00
|
|
|
' <input type="submit" name="report" value="' + _('Report') + '">' +
|
2012-03-15 18:14:54 +11:00
|
|
|
'</div>' +
|
|
|
|
'</form>');
|
|
|
|
post_form
|
2013-09-27 21:30:25 -03:00
|
|
|
.attr('action', $('form[name="post"]:first').attr('action'))
|
2012-03-16 20:22:26 +11:00
|
|
|
.append($('input[name=board]:first').clone())
|
2012-03-15 18:14:54 +11:00
|
|
|
.find('input:not([type="checkbox"]):not([type="submit"]):not([type="hidden"])').keypress(function(e) {
|
|
|
|
if(e.which == 13) {
|
|
|
|
e.preventDefault();
|
|
|
|
if($(this).attr('name') == 'password') {
|
|
|
|
post_form.find('input[name=delete]').click();
|
|
|
|
} else if($(this).attr('name') == 'reason') {
|
|
|
|
post_form.find('input[name=report]').click();
|
|
|
|
}
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2012-03-15 18:14:54 +11:00
|
|
|
return false;
|
|
|
|
}
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2012-03-15 18:14:54 +11:00
|
|
|
return true;
|
|
|
|
});
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2012-03-16 02:04:17 +11:00
|
|
|
post_form.find('input[type="password"]').val(localStorage.password);
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2024-08-24 00:47:18 +02:00
|
|
|
post_form.appendTo($(this).parent().parent());
|
2024-08-24 00:52:29 +02:00
|
|
|
|
2013-09-16 04:42:13 +10:00
|
|
|
$(window).trigger('quick-post-controls', post_form);
|
2012-03-15 18:14:54 +11:00
|
|
|
} else {
|
2024-08-24 00:52:29 +02:00
|
|
|
let elm = $(this).parent().parent().find('form');
|
|
|
|
|
|
|
|
if (elm.attr('class') == 'post-actions') {
|
2012-03-15 18:14:54 +11:00
|
|
|
elm.remove();
|
2024-08-24 00:52:29 +02:00
|
|
|
}
|
2012-03-15 18:14:54 +11:00
|
|
|
}
|
|
|
|
};
|
2024-08-24 00:52:29 +02:00
|
|
|
|
|
|
|
let init_qpc = function() {
|
2012-03-15 18:14:54 +11:00
|
|
|
$(this).change(open_form);
|
2024-08-24 00:52:29 +02:00
|
|
|
if (this.checked) {
|
2012-03-15 18:14:54 +11:00
|
|
|
$(this).trigger('change');
|
2024-08-24 00:52:29 +02:00
|
|
|
}
|
2013-08-04 01:53:37 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
$('div.post input[type=checkbox].delete').each(init_qpc);
|
|
|
|
|
2014-01-21 19:25:11 +01:00
|
|
|
$(document).on('new_post', function(e, post) {
|
2013-08-04 01:53:37 -04:00
|
|
|
$(post).find('input[type=checkbox].delete').each(init_qpc);
|
2012-03-15 18:14:54 +11:00
|
|
|
});
|
|
|
|
});
|