The version of vichan running on lainchan.org
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

70 рядки
2.3KB

  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(window.expand_fun = function() {
  22. var thread = $(this).parents('[id^="thread_"]');
  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. thread.find("span.omitted").css('display', 'none');
  45. $('<span class="omitted hide-expanded"><a href="javascript:void(0)">' + _('Hide expanded replies') + '</a>.</span>')
  46. .insertAfter(thread.find('.op div.body, .op span.omitted').last())
  47. .click(function() {
  48. thread.find('.expanded').remove();
  49. $(this).parent().find(".omitted:not(.hide-expanded)").css('display', '');
  50. $(this).parent().find(".hide-expanded").remove();
  51. });
  52. }
  53. });
  54. });
  55. }
  56. $('div.post.op span.omitted').each(do_expand);
  57. $(document).on("new_post", function(e, post) {
  58. if (!$(post).hasClass("reply")) {
  59. $(post).find('div.post.op span.omitted').each(do_expand);
  60. }
  61. });
  62. });