The version of vichan running on lainchan.org
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 11 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
il y a 12 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * post-hover.js
  3. * https://github.com/savetheinternet/Tinyboard/blob/master/js/post-hover.js
  4. *
  5. * Released under the MIT license
  6. * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
  7. * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  8. * Copyright (c) 2013 Macil Tech <maciltech@gmail.com>
  9. *
  10. * Usage:
  11. * $config['additional_javascript'][] = 'js/jquery.min.js';
  12. * $config['additional_javascript'][] = 'js/post-hover.js';
  13. *
  14. */
  15. onready(function(){
  16. var dont_fetch_again = [];
  17. init_hover = function() {
  18. var $link = $(this);
  19. var id;
  20. var matches;
  21. if ($link.is('[data-thread]')) {
  22. id = $link.attr('data-thread');
  23. }
  24. else if(matches = $link.text().match(/^>>(?:>\/([^\/]+)\/)?(\d+)$/)) {
  25. id = matches[2];
  26. }
  27. else {
  28. return;
  29. }
  30. var board = $(this);
  31. while (board.data('board') === undefined) {
  32. board = board.parent();
  33. }
  34. var threadid;
  35. if ($link.is('[data-thread]')) threadid = 0;
  36. else threadid = board.attr('id').replace("thread_", "");
  37. board = board.data('board');
  38. var parentboard = board;
  39. if ($link.is('[data-thread]')) parentboard = $('form[name="post"] input[name="board"]').val();
  40. else if (matches[1] !== undefined) board = matches[1];
  41. var $post = false;
  42. var hovering = false;
  43. var hovered_at;
  44. $link.hover(function(e) {
  45. hovering = true;
  46. hovered_at = {'x': e.pageX, 'y': e.pageY};
  47. var start_hover = function($link) {
  48. if($.contains($post[0], $link[0])) {
  49. // link links to itself or to op; ignore
  50. }
  51. else if ($post.is(':visible') &&
  52. $post.offset().top >= $(window).scrollTop() &&
  53. $post.offset().top + $post.height() <= $(window).scrollTop() + $(window).height()) {
  54. // post is in view
  55. $post.addClass('highlighted');
  56. } else {
  57. var $newPost = $post.clone();
  58. $newPost.find('>.reply, >br').remove();
  59. //$newPost.find('span.mentioned').remove();
  60. $newPost.find('a.post_anchor').remove();
  61. $newPost
  62. .attr('id', 'post-hover-' + id)
  63. .attr('data-board', board)
  64. .addClass('post-hover')
  65. .css('border-style', 'solid')
  66. .css('display', 'inline-block')
  67. .css('position', 'absolute')
  68. .css('font-style', 'normal')
  69. .css('z-index', '100')
  70. .css('margin-left', '1em')
  71. .addClass('reply').addClass('post')
  72. .insertAfter($link.parent())
  73. $link.trigger('mousemove');
  74. }
  75. };
  76. $post = $('[data-board="' + board + '"] div.post#reply_' + id + ', [data-board="' + board + '"]div#thread_' + id);
  77. if($post.length > 0) {
  78. start_hover($(this));
  79. } else {
  80. var url = $link.attr('href').replace(/#.*$/, '');
  81. if($.inArray(url, dont_fetch_again) != -1) {
  82. return;
  83. }
  84. dont_fetch_again.push(url);
  85. $.ajax({
  86. url: url,
  87. context: document.body,
  88. success: function(data) {
  89. var mythreadid = $(data).find('div[id^="thread_"]').attr('id').replace("thread_", "");
  90. if (mythreadid == threadid && parentboard == board) {
  91. $(data).find('div.post.reply').each(function() {
  92. if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0) {
  93. $('[data-board="' + board + '"]#thread_' + threadid + " .post.reply:first").before($(this).hide().addClass('hidden'));
  94. }
  95. });
  96. }
  97. else if ($('[data-board="' + board + '"]#thread_'+mythreadid).length > 0) {
  98. $(data).find('div.post.reply').each(function() {
  99. if($('[data-board="' + board + '"] #' + $(this).attr('id')).length == 0) {
  100. $('[data-board="' + board + '"]#thread_' + mythreadid + " .post.reply:first").before($(this).hide().addClass('hidden'));
  101. }
  102. });
  103. }
  104. else {
  105. $(data).find('div[id^="thread_"]').hide().attr('data-cached', 'yes').prependTo('form[name="postcontrols"]');
  106. }
  107. $post = $('[data-board="' + board + '"] div.post#reply_' + id + ', [data-board="' + board + '"]div#thread_' + id);
  108. if(hovering && $post.length > 0) {
  109. start_hover($link);
  110. }
  111. }
  112. });
  113. }
  114. }, function() {
  115. hovering = false;
  116. if(!$post)
  117. return;
  118. $post.removeClass('highlighted');
  119. if($post.hasClass('hidden') || $post.data('cached') == 'yes')
  120. $post.css('display', 'none');
  121. $('.post-hover').remove();
  122. }).mousemove(function(e) {
  123. if(!$post)
  124. return;
  125. var $hover = $('#post-hover-' + id + '[data-board="' + board + '"]');
  126. if($hover.length == 0)
  127. return;
  128. var scrollTop = $(window).scrollTop();
  129. if ($link.is("[data-thread]")) scrollTop = 0;
  130. var epy = e.pageY;
  131. if ($link.is("[data-thread]")) epy -= $(window).scrollTop();
  132. var top = (epy ? epy : hovered_at['y']) - 10;
  133. if(epy < scrollTop + 15) {
  134. top = scrollTop;
  135. } else if(epy > scrollTop + $(window).height() - $hover.height() - 15) {
  136. top = scrollTop + $(window).height() - $hover.height() - 15;
  137. }
  138. var hovery = e.pageY ? e.pageY : hovered_at['y'];
  139. if ( ( hovery - top) > 20){
  140. top = hovery;
  141. }
  142. $hover.css('left', (e.pageX ? e.pageX : hovered_at['x']) + 1).css('top', top);
  143. });
  144. };
  145. $('div.body a:not([rel="nofollow"])').each(init_hover);
  146. // allow to work with auto-reload.js, etc.
  147. $(document).on('new_post', function(e, post) {
  148. $(post).find('div.body a:not([rel="nofollow"])').each(init_hover);
  149. });
  150. });