The version of vichan running on lainchan.org
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

67 行
2.2KB

  1. /*
  2. * inline-expanding.js
  3. * https://github.com/savetheinternet/Tinyboard/blob/master/js/inline-expanding.js
  4. *
  5. * Released under the MIT license
  6. * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org>
  7. * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  8. *
  9. * Usage:
  10. * // $config['additional_javascript'][] = 'js/jquery.min.js';
  11. * $config['additional_javascript'][] = 'js/inline-expanding.js';
  12. *
  13. */
  14. onready(function(){
  15. var inline_expand_post = function() {
  16. var link = this.getElementsByTagName('a');
  17. for (var i = 0; i < link.length; i++) {
  18. if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) {
  19. link[i].childNodes[0].style.maxWidth = '95%';
  20. link[i].onclick = function(e) {
  21. if (this.childNodes[0].className == 'hidden')
  22. return false;
  23. if (e.which == 2 || e.metaKey)
  24. return true;
  25. if (!this.dataset.src) {
  26. this.dataset.expanded = 'true';
  27. this.dataset.src= this.childNodes[0].src;
  28. this.dataset.width = this.childNodes[0].style.width;
  29. this.dataset.height = this.childNodes[0].style.height;
  30. this.childNodes[0].src = this.href;
  31. this.childNodes[0].style.width = 'auto';
  32. this.childNodes[0].style.height = 'auto';
  33. this.childNodes[0].style.opacity = '0.4';
  34. this.childNodes[0].style.filter = 'alpha(opacity=40)';
  35. this.childNodes[0].onload = function() {
  36. this.style.opacity = '';
  37. delete this.style.filter;
  38. }
  39. } else {
  40. this.childNodes[0].src = this.dataset.src;
  41. this.childNodes[0].style.width = this.dataset.width;
  42. this.childNodes[0].style.height = this.dataset.height;
  43. delete this.dataset.expanded;
  44. delete this.dataset.src;
  45. delete this.childNodes[0].style.opacity;
  46. delete this.childNodes[0].style.filter;
  47. }
  48. return false;
  49. }
  50. }
  51. }
  52. }
  53. if (window.jQuery) {
  54. $('div[id^="thread_"]').each(inline_expand_post);
  55. // allow to work with auto-reload.js, etc.
  56. $(document).on('new_post', function(e, post) {
  57. inline_expand_post.call(post);
  58. });
  59. } else {
  60. inline_expand_post.call(document);
  61. }
  62. });