main.phtml 6.2 KB

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