From 9fab9253a358c96a2fcfa5004da6018901467bf4 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Thu, 15 Mar 2012 18:14:54 +1100 Subject: quick-post-controls.js --- js/quick-post-controls.js | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 js/quick-post-controls.js (limited to 'js/quick-post-controls.js') diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js new file mode 100644 index 00000000..a9cade95 --- /dev/null +++ b/js/quick-post-controls.js @@ -0,0 +1,78 @@ +/* + * quick-posts-controls.js + * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/quick-posts-controls.js + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save + * + * 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 = $('
' + + '
' + + (!thread ? '
' : '') + + + '' + + + ': ' + + '' + + '' + + '' + + ' ' + + + '
' + + + ': ' + + '' + + ' ' + + '
' + + '
'); + post_form + .attr('action', $('form:first').attr('action')) + .append($('input[name=board]:first')) + .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; + } + + return true; + }); + + if(thread) { + post_form.prependTo($(this).parent().parent().find('p.body')); + } else { + post_form.appendTo($(this).parent().parent()); + //post_form.insertBefore($(this)); + } + } else { + var elm = $(this).parent().parent().find('form'); + + if(elm.attr('class') == 'post-actions') + elm.remove(); + } + }; + + $('div.post input[type=checkbox].delete').each(function() { + $(this).change(open_form); + if(this.checked) + $(this).trigger('change'); + }); +}); + -- cgit v1.3 From 53f4bf6136c99e4ca4099357173226c229885844 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 16 Mar 2012 02:04:17 +1100 Subject: quick-posts-controls.js: Fill in password automatically. fix-report-delete-submit.js --- js/fix-report-delete-submit.js | 26 ++++++++++++++++++++++++++ js/quick-post-controls.js | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 js/fix-report-delete-submit.js (limited to 'js/quick-post-controls.js') diff --git a/js/fix-report-delete-submit.js b/js/fix-report-delete-submit.js new file mode 100644 index 00000000..e950721f --- /dev/null +++ b/js/fix-report-delete-submit.js @@ -0,0 +1,26 @@ +/* + * fix-report-delete-submit.js + * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/fix-report-delete-submit.js + * + * Fixes a known bug regarding the delete/report submit buttons. + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/fix-report-delete-submit.js'; + * + */ + +$(document).ready(function(){ + $('form[name="postcontrols"] div.delete input:not([type="checkbox"]):not([type="submit"]):not([type="hidden"])').keypress(function(e) { + if(e.which == 13) { + e.preventDefault(); + $(this).next().click(); + return false; + } + return true; + }); +}); + diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js index a9cade95..f9e53be1 100644 --- a/js/quick-post-controls.js +++ b/js/quick-post-controls.js @@ -18,7 +18,7 @@ $(document).ready(function(){ var submitButton; if(this.checked) { - var post_form = $('
' + + var post_form = $('' + '
' + (!thread ? '
' : '') + @@ -55,6 +55,8 @@ $(document).ready(function(){ return true; }); + post_form.find('input[type="password"]').val(localStorage.password); + if(thread) { post_form.prependTo($(this).parent().parent().find('p.body')); } else { -- cgit v1.3 From ccf17c3d6f0bf8ef28308f31369bacda6ecc41a2 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 16 Mar 2012 20:22:26 +1100 Subject: quick-post-controls.js: clone input element or Tinyboard will consider everyone a bot when posting --- js/quick-post-controls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/quick-post-controls.js') diff --git a/js/quick-post-controls.js b/js/quick-post-controls.js index f9e53be1..90a46cd9 100644 --- a/js/quick-post-controls.js +++ b/js/quick-post-controls.js @@ -39,7 +39,7 @@ $(document).ready(function(){ ''); post_form .attr('action', $('form:first').attr('action')) - .append($('input[name=board]:first')) + .append($('input[name=board]:first').clone()) .find('input:not([type="checkbox"]):not([type="submit"]):not([type="hidden"])').keypress(function(e) { if(e.which == 13) { e.preventDefault(); -- cgit v1.3