The version of vichan running on lainchan.org
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

66 rindas
2.2KB

  1. /*
  2. * expand.js
  3. * https://github.com/savetheinternet/Tinyboard/blob/master/js/expand.js
  4. *
  5. * Released under the MIT license
  6. * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org>
  7. * Copyright (c) 2013 Czterooki <czterooki1337@gmail.com>
  8. * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  9. *
  10. * Usage:
  11. * $config['additional_javascript'][] = 'js/jquery.min.js';
  12. * $config['additional_javascript'][] = 'js/expand.js';
  13. *
  14. */
  15. $(document).ready(function(){
  16. if($('span.omitted').length == 0)
  17. return; // nothing to expand
  18. var do_expand = function() {
  19. $(this)
  20. .html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.'))
  21. .find('a').click(function() {
  22. var thread = $(this).parent().parent().parent();
  23. var id = thread.attr('id').replace(/^thread_/, '');
  24. $.ajax({
  25. url: thread.find('p.intro a.post_no:first').attr('href'),
  26. context: document.body,
  27. success: function(data) {
  28. var last_expanded = false;
  29. $(data).find('div.post.reply').each(function() {
  30. thread.find('div.hidden').remove();
  31. var post_in_doc = thread.find('#' + $(this).attr('id'));
  32. if(post_in_doc.length == 0) {
  33. if(last_expanded) {
  34. $(this).addClass('expanded').insertAfter(last_expanded).before('<br class="expanded">');
  35. } else {
  36. $(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">');
  37. }
  38. last_expanded = $(this);
  39. $(document).trigger('new_post', this);
  40. } else {
  41. last_expanded = post_in_doc;
  42. }
  43. });
  44. $('<span class="omitted"><a href="javascript:void(0)">' + _('Hide expanded replies') + '</a>.</span>')
  45. .insertAfter(thread.find('span.omitted').css('display', 'none'))
  46. .click(function() {
  47. thread.find('.expanded').remove();
  48. $(this).prev().css('display', '');
  49. $(this).remove();
  50. });
  51. }
  52. });
  53. });
  54. }
  55. $('div.post.op span.omitted').each(do_expand);
  56. $(document).on("new_post", function(e, post) {
  57. if (!$(post).hasClass("reply")) {
  58. $(post).find('div.post.op span.omitted').each(do_expand);
  59. }
  60. });
  61. });