summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-31 21:32:09 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-31 21:32:09 +1100
commitaf3ec3f8c720b90095f1f4cff2eb9931d0fcebf2 (patch)
treee26aeee1f3012f11c5d04ecf6e0427fa9db18f60
parentfe8cafb6ea62bfb2f0fe357dad959033d94322b1 (diff)
expand.js: inline thread expanding
-rw-r--r--js/expand.js51
-rw-r--r--templates/thread.html2
2 files changed, 52 insertions, 1 deletions
diff --git a/js/expand.js b/js/expand.js
new file mode 100644
index 00000000..05aece95
--- /dev/null
+++ b/js/expand.js
@@ -0,0 +1,51 @@
+/*
+ *expand.js
+ * https://github.com/savetheinternet/Tinyboard/blob/master/js/expand.js
+ *
+ * Released under the MIT license
+ * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
+ *
+ * Usage:
+ * $config['additional_javascript'][] = 'js/jquery.min.js';
+ * $config['additional_javascript'][] = 'js/expand.js';
+ *
+ */
+
+$(document).ready(function(){
+ if($('div.banner').length != 0)
+ return; // not index
+
+ $('div.post.op span.omitted').each(function() {
+ $(this)
+ .html($(this).text().replace(/Click reply to view\./, '<a href="javascript:void(0)">Click to expand</a>.'))
+ .find('a').click(function() {
+ var thread = $(this).parent().parent().parent();
+ var id = thread.attr('id').replace(/^thread_/, '');
+ $.ajax({
+ url: thread.find('p.intro a.post_no:first').attr('href'),
+ context: document.body,
+ success: function(data) {
+ var last_expanded = false;
+ $(data).find('div.post.reply').each(function() {
+ if($('#' + $(this).attr('id')).length == 0) {
+ if(last_expanded) {
+ $(this).addClass('expanded').insertAfter(last_expanded).before('<br class="expanded">');
+ } else {
+ $(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">');
+ }
+ last_expanded = $(this);
+
+ }
+ });
+ $('<span class="omitted"><a href="javascript:void(0)">Hide expanded replies</a>.</span>')
+ .insertAfter(thread.find('span.omitted').css('display', 'none'))
+ .click(function() {
+ thread.find('.expanded').remove();
+ $(this).prev().css('display', '');
+ $(this).remove();
+ });
+ }
+ });
+ });
+ });
+});
diff --git a/templates/thread.html b/templates/thread.html
index 1cb9428d..2708b04d 100644
--- a/templates/thread.html
+++ b/templates/thread.html
@@ -63,7 +63,7 @@
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">Powered by <a href="http://tinyboard.org/">Tinyboard</a> {{ config.version }} | <a href="http://tinyboard.org/">Tinyboard</a> Copyright &copy; 2010-2012 Tinyboard Development Group</p>
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
- </footer>>
+ </footer>
<script type="text/javascript">{% raw %}
ready();
{% endraw %}</script>