diff options
| author | czaks <marcin@6irc.net> | 2013-08-05 06:03:40 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-08-05 06:03:40 -0400 |
| commit | a84c4510fccfdc0cfb6f187633daea10dc70f326 (patch) | |
| tree | 6077f5211196ae40cac0184bb7cc67b81d320b0b /js/expand.js | |
| parent | 33c7abf11f3a9b5c0964a2d7a25533c2849dbc78 (diff) | |
| parent | a8327c3a37fd22d2aa5d63061c9d3eaa30ae425a (diff) | |
Merge branch 'master' of github.com:vichan-devel/Tinyboard
Conflicts:
js/post-hider.js
Diffstat (limited to 'js/expand.js')
| -rw-r--r-- | js/expand.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/js/expand.js b/js/expand.js index 6371f92c..44f5ae80 100644 --- a/js/expand.js +++ b/js/expand.js @@ -3,7 +3,7 @@ * https://github.com/savetheinternet/Tinyboard/blob/master/js/expand.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> + * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org> * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; @@ -14,8 +14,8 @@ $(document).ready(function(){ if($('div.banner').length != 0) return; // not index - - $('div.post.op span.omitted').each(function() { + + var do_expand = function() { $(this) .html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.')) .find('a').click(function() { @@ -27,15 +27,17 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - if($('#' + $(this).attr('id')).length == 0) { + var post_in_doc = thread.find('#' + $(this).attr('id')); + if(post_in_doc.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); - $(document).trigger('new_post', this); + } else { + last_expanded = post_in_doc; } }); $('<span class="omitted"><a href="javascript:void(0)">' + _('Hide expanded replies') + '</a>.</span>') @@ -48,5 +50,13 @@ $(document).ready(function(){ } }); }); + } + + $('div.post.op span.omitted').each(do_expand); + + $(document).bind("new_post", function(e, post) { + if (!$(post).hasClass("reply")) { + $(post).find('div.post.op span.omitted').each(do_expand); + } }); }); |
