summaryrefslogtreecommitdiff
path: root/js/quick-reply.js
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-31 10:59:20 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-31 10:59:20 +1100
commitfef9a3ca82144348924852f68aee35ff4bf6ca25 (patch)
tree2eb7dd277177fcbd572884d15ed3ce100aa61c7c /js/quick-reply.js
parent52443d3da98e992953d8214b7848350f70d02336 (diff)
parent2df1ebd88c266d984cbaa6c26917c2ea89c2ae0e (diff)
Merge branch 'master' of github.com:savetheinternet/Tinyboard-Tools into tools
Conflicts: README.md
Diffstat (limited to 'js/quick-reply.js')
-rw-r--r--js/quick-reply.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/js/quick-reply.js b/js/quick-reply.js
new file mode 100644
index 00000000..cc1a45a2
--- /dev/null
+++ b/js/quick-reply.js
@@ -0,0 +1,46 @@
+/*
+ * quick-reply.js
+ * https://github.com/savetheinternet/Tinyboard-Tools/blob/master/js/quick-reply.js
+ *
+ * Released under the MIT license
+ * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
+ *
+ * Usage:
+ * $config['quick_reply'] = true;
+ * $config['additional_javascript'][] = 'js/jquery.min.js';
+ * $config['additional_javascript'][] = 'js/quick-reply.js';
+ *
+ */
+
+$(document).ready(function(){
+ if($('div.banner').length != 0)
+ return; // not index
+
+ txt_new_topic = $('form[name=post] input[type=submit]').val();
+ txt_new_reply = txt_new_topic == 'Submit' ? txt_new_topic : 'New Reply';
+
+ undo_quick_reply = function() {
+ $('div.banner').remove();
+ $('form[name=post] input[type=submit]').val(txt_new_topic);
+ $('form[name=post] input[name=quick-reply]').remove();
+ }
+
+ $('div.post.op').each(function() {
+ var id = $(this).children('p.intro').children('a.post_no:eq(1)').text();
+ $('<a href="?/b/res/69.html">[Quick reply]</a>').insertAfter($(this).children('p.intro').children('a:last')).click(function() {
+ $('div.banner').remove();
+ $('<div class="banner">Posting mode: Replying to <small>&gt;&gt;' + id + '</small> <a class="unimportant" onclick="undo_quick_reply()" href="javascript:void(0)">[Return]</a></div>')
+ .insertBefore('form[name=post]');
+ $('form[name=post] input[type=submit]').val(txt_new_reply);
+
+ $('<input type="hidden" name="quick-reply" value="' + id + '">').appendTo($('form[name=post]'));
+
+ $('form[name=post] textarea').select();
+
+ window.scrollTo(0, 0);
+
+ return false;
+ });
+ });
+});
+