diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js index 10d74f98..c625fa85 100644 --- a/js/quick-post-controls.js +++ b/js/quick-post-controls.js @@ -10,33 +10,31 @@ * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/quick-post-controls.js'; - * */ -$(document).ready(function(){ - var open_form = function() { - var thread = $(this).parent().parent().hasClass('op'); - var id = $(this).attr('name').match(/^delete_(\d+)$/)[1]; - var submitButton; - - if(this.checked) { - var post_form = $('
' + +$(document).ready(function() { + let open_form = function() { + let thread = $(this).parent().parent().hasClass('op'); + let id = $(this).attr('name').match(/^delete_(\d+)$/)[1]; + + if (this.checked) { + let post_form = $('' + '
' + (!thread ? '
' : '') + - + '' + - + ': ' + '' + '' + - '' + - ' ' + - + '' + + ' ' + + '
' + - - ': ' + + + ': ' + '' + - ' ' + + ' ' + '
' + '
'); post_form @@ -50,35 +48,36 @@ $(document).ready(function(){ } else if($(this).attr('name') == 'reason') { post_form.find('input[name=report]').click(); } - + return false; } - + return true; }); - + post_form.find('input[type="password"]').val(localStorage.password); - - if(thread) { + + if (thread) { post_form.prependTo($(this).parent().parent().find('div.body')); } else { post_form.appendTo($(this).parent().parent()); - //post_form.insertBefore($(this)); } - + $(window).trigger('quick-post-controls', post_form); } else { - var elm = $(this).parent().parent().find('form'); - - if(elm.attr('class') == 'post-actions') + let elm = $(this).parent().parent().find('form'); + + if (elm.attr('class') == 'post-actions') { elm.remove(); + } } }; - - var init_qpc = function() { + + let init_qpc = function() { $(this).change(open_form); - if(this.checked) + if (this.checked) { $(this).trigger('change'); + } }; $('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); }); }); -