diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js index 3fc33a19..8a0c7eec 100644 --- a/js/quick-post-controls.js +++ b/js/quick-post-controls.js @@ -13,83 +13,83 @@ * */ -$(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 = $('
'); - if($('form[name="post"]:first').length){ - var board=$(this).parent().parent().parent().attr("data-board"); + + let board = $(this).parent().parent().parent().attr("data-board"); + if ($('form[name="post"]:first').length) { post_form - .attr('action', $('form[name="post"]:first').attr('action')) - .append(''); - }else{ - var board=$(this).parent().parent().parent().attr("data-board"); - if(board){ - post_form.attr('action', '/post.php'); //doesn't respect $config["root"] but... - post_form.append(''); - }else{ - return;//better not to show a form if it isn't going to work + .attr('action', $('form[name="post"]:first').attr('action')) + .append(''); + } else { + if (!board) {//better not to show a form if it isn't going to work + return; } + post_form.attr('action', '/post.php'); //doesn't respect $config["root"] but... + post_form.append(''); } + post_form.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(); - } - - return false; + 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(); } - - return true; - }); - + + 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); @@ -98,4 +98,3 @@ $(document).ready(function(){ $(post).find('input[type=checkbox].delete').each(init_qpc); }); }); -