main.phtml 6.4 KB

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