main.phtml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php if ($this->conf->displayPosts () == 'no') { ?>
  2. var hide_posts = true;
  3. <?php } else { ?>
  4. var hide_posts = false;
  5. <?php } ?>
  6. function redirect (url) {
  7. if (url) {
  8. location.href = url;
  9. }
  10. }
  11. function slide (new_active, old_active) {
  12. old_active.removeClass ("active");
  13. new_active.addClass ("active");
  14. if (hide_posts) {
  15. old_active.children (".content").slideUp (200);
  16. new_active.children (".content").slideDown (200, function () {
  17. $.smoothScroll({
  18. offset: new_active.position ().top + 25
  19. });
  20. });
  21. } else {
  22. $.smoothScroll({
  23. offset: new_active.position ().top + 25
  24. });
  25. }
  26. }
  27. $(document).ready (function () {
  28. if (hide_posts) {
  29. $(".post.flux .content").slideToggle ();
  30. }
  31. // Touches de manipulation
  32. shortcut.add("m", function () {
  33. // on marque comme lu ou non lu
  34. active = $(".post.flux.active");
  35. url = active.find ("a.read").attr ("href");
  36. $.ajax ({
  37. type: 'POST',
  38. url: url,
  39. data : { ajax: true }
  40. }).done (function () {
  41. if (active.hasClass ("not_read")) {
  42. active.removeClass ("not_read");
  43. } else {
  44. active.addClass ("not_read");
  45. }
  46. });
  47. });
  48. shortcut.add("f", function () {
  49. // on marque comme favori ou non favori
  50. active = $(".post.flux.active");
  51. url = active.find ("a.bookmark").attr ("href");
  52. $.ajax ({
  53. type: 'POST',
  54. url: url,
  55. data : { ajax: true }
  56. }).done (function () {
  57. if (active.hasClass ("favorite")) {
  58. active.removeClass ("favorite");
  59. } else {
  60. active.addClass ("favorite");
  61. }
  62. });
  63. });
  64. // Touches de navigation
  65. /*shortcut.add("up", function () {
  66. old_active = $(".post.flux.active");
  67. last_active = $(".post.flux:last");
  68. new_active = old_active.prev ();
  69. if (new_active[0] instanceof HTMLDivElement) {
  70. slide (new_active, old_active);
  71. } else {
  72. slide (last_active, old_active);
  73. }
  74. });*/
  75. shortcut.add("space", function () {
  76. old_active = $(".post.flux.active");
  77. first_active = $(".post.flux:first");
  78. new_active = old_active.next ();
  79. if (new_active[0] instanceof HTMLDivElement) {
  80. slide (new_active, old_active);
  81. } else if (new_active[0] === undefined) {
  82. slide (first_active, old_active);
  83. }
  84. });
  85. shortcut.add("right", function () {
  86. url = $(".pager-next a").attr ("href");
  87. if (url === undefined) {
  88. url = $(".pager-first a").attr ("href");
  89. }
  90. redirect (url);
  91. });
  92. shortcut.add("left", function () {
  93. url = $(".pager-previous a").attr ("href");
  94. if (url === undefined) {
  95. url = $(".pager-last a").attr ("href");
  96. }
  97. redirect (url);
  98. });
  99. $(".post.flux").click (function () {
  100. old_active = $(".post.flux.active");
  101. new_active = $(this);
  102. if (old_active[0] != new_active[0]) {
  103. slide (new_active, old_active);
  104. }
  105. });
  106. });