1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-02 12:57:35 +01:00

quick-post-controls.js: format

This commit is contained in:
Zankaria 2024-08-24 00:52:29 +02:00
parent b6d16c7cd2
commit 8302a121e5

View File

@ -10,33 +10,31 @@
* Usage: * Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/quick-post-controls.js'; * $config['additional_javascript'][] = 'js/quick-post-controls.js';
*
*/ */
$(document).ready(function(){ $(document).ready(function() {
var open_form = function() { let open_form = function() {
var thread = $(this).parent().parent().hasClass('op'); let thread = $(this).parent().parent().hasClass('op');
var id = $(this).attr('name').match(/^delete_(\d+)$/)[1]; let id = $(this).attr('name').match(/^delete_(\d+)$/)[1];
var submitButton;
if (this.checked) {
if(this.checked) { let post_form = $('<form class="post-actions" method="post" style="margin:10px 0 0 0">' +
var post_form = $('<form class="post-actions" method="post" style="margin:10px 0 0 0">' +
'<div style="text-align:right">' + '<div style="text-align:right">' +
(!thread ? '<hr>' : '') + (!thread ? '<hr>' : '') +
'<input type="hidden" name="delete_' + id + '">' + '<input type="hidden" name="delete_' + id + '">' +
'<label for="password_' + id + '">'+_("Password")+'</label>: ' + '<label for="password_' + id + '">'+_("Password")+'</label>: ' +
'<input id="password_' + id + '" type="password" name="password" size="11" maxlength="18">' + '<input id="password_' + id + '" type="password" name="password" size="11" maxlength="18">' +
'<input title="'+_('Delete file only')+'" type="checkbox" name="file" id="delete_file_' + id + '">' + '<input title="'+_('Delete file only')+'" type="checkbox" name="file" id="delete_file_' + id + '">' +
'<label for="delete_file_' + id + '">'+_('File')+'</label>' + '<label for="delete_file_' + id + '">' + _('File') + '</label>' +
' <input type="submit" name="delete" value="'+_('Delete')+'">' + ' <input type="submit" name="delete" value="' + _('Delete') + '">' +
'<br>' + '<br>' +
'<label for="reason_' + id + '">'+_('Reason')+'</label>: ' + '<label for="reason_' + id + '">' + _('Reason') + '</label>: ' +
'<input id="reason_' + id + '" type="text" name="reason" size="20" maxlength="100">' + '<input id="reason_' + id + '" type="text" name="reason" size="20" maxlength="100">' +
' <input type="submit" name="report" value="'+_('Report')+'">' + ' <input type="submit" name="report" value="' + _('Report') + '">' +
'</div>' + '</div>' +
'</form>'); '</form>');
post_form post_form
@ -50,35 +48,36 @@ $(document).ready(function(){
} else if($(this).attr('name') == 'reason') { } else if($(this).attr('name') == 'reason') {
post_form.find('input[name=report]').click(); post_form.find('input[name=report]').click();
} }
return false; return false;
} }
return true; return true;
}); });
post_form.find('input[type="password"]').val(localStorage.password); post_form.find('input[type="password"]').val(localStorage.password);
if(thread) { if (thread) {
post_form.prependTo($(this).parent().parent().find('div.body')); post_form.prependTo($(this).parent().parent().find('div.body'));
} else { } else {
post_form.appendTo($(this).parent().parent()); post_form.appendTo($(this).parent().parent());
//post_form.insertBefore($(this));
} }
$(window).trigger('quick-post-controls', post_form); $(window).trigger('quick-post-controls', post_form);
} else { } else {
var elm = $(this).parent().parent().find('form'); let elm = $(this).parent().parent().find('form');
if(elm.attr('class') == 'post-actions') if (elm.attr('class') == 'post-actions') {
elm.remove(); elm.remove();
}
} }
}; };
var init_qpc = function() { let init_qpc = function() {
$(this).change(open_form); $(this).change(open_form);
if(this.checked) if (this.checked) {
$(this).trigger('change'); $(this).trigger('change');
}
}; };
$('div.post input[type=checkbox].delete').each(init_qpc); $('div.post input[type=checkbox].delete').each(init_qpc);
@ -87,4 +86,3 @@ $(document).ready(function(){
$(post).find('input[type=checkbox].delete').each(init_qpc); $(post).find('input[type=checkbox].delete').each(init_qpc);
}); });
}); });