main.phtml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php if ($this->conf->displayPosts () == 'no') { ?>
  2. var hide_posts = true;
  3. <?php } else { ?>
  4. var hide_posts = false;
  5. <?php } ?>
  6. <?php $s = $this->conf->shortcuts (); ?>
  7. function redirect (url, new_tab) {
  8. if (url) {
  9. if (new_tab) {
  10. window.open (url);
  11. } else {
  12. location.href = url;
  13. }
  14. }
  15. }
  16. function slide (new_active, old_active) {
  17. old_active.removeClass ("active");
  18. new_active.addClass ("active");
  19. if (hide_posts) {
  20. old_active.children (".content").slideUp (500);
  21. new_active.children (".content").slideDown (500, function () {
  22. $.smoothScroll({
  23. offset: new_active.position ().top
  24. });
  25. });
  26. } else {
  27. $.smoothScroll({
  28. offset: new_active.position ().top
  29. });
  30. }
  31. }
  32. function mark_read (active) {
  33. if (active[0] === undefined) {
  34. return false;
  35. }
  36. url = active.find ("a.read").attr ("href");
  37. if (url === undefined) {
  38. return false;
  39. }
  40. $.ajax ({
  41. type: 'POST',
  42. url: url,
  43. data : { ajax: true }
  44. }).done (function (data) {
  45. res = jQuery.parseJSON(data);
  46. active.find ("a.read").attr ("href", res.url);
  47. if (active.hasClass ("not_read")) {
  48. active.removeClass ("not_read");
  49. } else {
  50. active.addClass ("not_read");
  51. }
  52. });
  53. }
  54. function mark_favorite (active) {
  55. if (active[0] === undefined) {
  56. return false;
  57. }
  58. url = active.find ("a.bookmark").attr ("href");
  59. if (url === undefined) {
  60. return false;
  61. }
  62. $.ajax ({
  63. type: 'POST',
  64. url: url,
  65. data : { ajax: true }
  66. }).done (function (data) {
  67. res = jQuery.parseJSON(data);
  68. active.find ("a.bookmark").attr ("href", res.url);
  69. if (active.hasClass ("favorite")) {
  70. active.removeClass ("favorite");
  71. } else {
  72. active.addClass ("favorite");
  73. }
  74. });
  75. }
  76. function init_img () {
  77. $(".flux .content img").each (function () {
  78. if ($(this).width () > ($("#stream").width()) / 2) {
  79. $(this).addClass("big");
  80. }
  81. });
  82. }
  83. function init_posts () {
  84. init_img ();
  85. if (hide_posts) {
  86. $(".flux:not(.active) .content").slideUp ();
  87. }
  88. $(".flux").click (function () {
  89. old_active = $(".flux.active");
  90. new_active = $(this);
  91. if (old_active[0] != new_active[0]) {
  92. slide (new_active, old_active);
  93. }
  94. });
  95. $(".flux a.read").click (function () {
  96. active = $(this).parents (".flux");
  97. mark_read (active);
  98. return false;
  99. });
  100. $(".flux a.bookmark").click (function () {
  101. active = $(this).parents (".flux");
  102. mark_favorite (active);
  103. return false;
  104. });
  105. $(".flux .content a").click (function () {
  106. $(this).attr ('target', '_blank');
  107. });
  108. }
  109. function init_column_categories () {
  110. $(".category").addClass ("stick");
  111. $(".categories .category .btn:first-child").width ("160px");
  112. $(".category").append ("<a class=\"btn dropdown-toggle\" href=\"#\"><i class=\"icon i_down\"></i></a>");
  113. $(".category + .feeds").not(".active").hide();
  114. $(".category.active a.dropdown-toggle i").toggleClass ("i_up");
  115. $(".category a.dropdown-toggle").click (function () {
  116. $(this).children ().toggleClass ("i_up");
  117. $(this).parent ().next (".feeds").slideToggle();
  118. return false;
  119. });
  120. }
  121. $(document).ready (function () {
  122. init_posts ();
  123. init_column_categories ();
  124. // Touches de manipulation
  125. shortcut.add("<?php echo $s['mark_read']; ?>", function () {
  126. // on marque comme lu ou non lu
  127. active = $(".flux.active");
  128. mark_read (active);
  129. }, {
  130. 'disable_in_input':true
  131. });
  132. shortcut.add("shift+<?php echo $s['mark_read']; ?>", function () {
  133. // on marque tout comme lu
  134. url = $("#top a.read_all").attr ("href");
  135. redirect (url, false);
  136. }, {
  137. 'disable_in_input':true
  138. });
  139. shortcut.add("<?php echo $s['mark_favorite']; ?>", function () {
  140. // on marque comme favori ou non favori
  141. active = $(".flux.active");
  142. mark_favorite (active);
  143. }, {
  144. 'disable_in_input':true
  145. });
  146. // Touches de navigation
  147. shortcut.add("<?php echo $s['prev_entry']; ?>", function () {
  148. old_active = $(".flux.active");
  149. last_active = $(".flux:last");
  150. new_active = old_active.prevAll (".flux:first");
  151. if (new_active.hasClass("flux")) {
  152. slide (new_active, old_active);
  153. } else if (new_active[0] === undefined) {
  154. slide (last_active, old_active);
  155. }
  156. }, {
  157. 'disable_in_input':true
  158. });
  159. shortcut.add("shift+<?php echo $s['prev_entry']; ?>", function () {
  160. old_active = $(".flux.active");
  161. first = $(".flux:first");
  162. if (first.hasClass("flux")) {
  163. slide (first, old_active);
  164. }
  165. }, {
  166. 'disable_in_input':true
  167. });
  168. shortcut.add("<?php echo $s['next_entry']; ?>", function () {
  169. old_active = $(".flux.active");
  170. first_active = $(".flux:first");
  171. new_active = old_active.nextAll (".flux:first");
  172. if (new_active.hasClass("flux")) {
  173. slide (new_active, old_active);
  174. } else if (new_active[0] === undefined) {
  175. slide (first_active, old_active);
  176. }
  177. }, {
  178. 'disable_in_input':true
  179. });
  180. shortcut.add("shift+<?php echo $s['next_entry']; ?>", function () {
  181. old_active = $(".flux.active");
  182. last = $(".flux:last");
  183. if (last.hasClass("flux")) {
  184. slide (last, old_active);
  185. }
  186. }, {
  187. 'disable_in_input':true
  188. });
  189. shortcut.add("<?php echo $s['next_page']; ?>", function () {
  190. url = $(".pager-next a").attr ("href");
  191. redirect (url, false);
  192. }, {
  193. 'disable_in_input':true
  194. });
  195. shortcut.add("<?php echo $s['prev_page']; ?>", function () {
  196. url = $(".pager-previous a").attr ("href");
  197. redirect (url, false);
  198. }, {
  199. 'disable_in_input':true
  200. });
  201. shortcut.add("<?php echo $s['go_website']; ?>", function () {
  202. url = $(".flux.active .link a").attr ("href");
  203. redirect (url, true);
  204. }, {
  205. 'disable_in_input':true
  206. });
  207. });