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'); + }); +}); +