main.phtml 6.1 KB

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