| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <?php if ($this->conf->displayPosts () == 'no') { ?>
- var hide_posts = true;
- <?php } else { ?>
- var hide_posts = false;
- <?php } ?>
- <?php $s = $this->conf->shortcuts (); ?>
- function redirect (url, new_tab) {
- if (url) {
- if (new_tab) {
- window.open (url);
- } else {
- location.href = url;
- }
- }
- }
- function slide (new_active, old_active) {
- old_active.removeClass ("active");
- new_active.addClass ("active");
-
- if (hide_posts) {
- old_active.children (".content").slideUp (500);
- new_active.children (".content").slideDown (500, function () {
- $.smoothScroll({
- offset: new_active.position ().top
- });
- });
- } else {
- $.smoothScroll({
- offset: new_active.position ().top
- });
- }
- }
- function add_not_read (nb) {
- span_not_read = $("#categories li.all span.nb_not_read");
-
- html = span_not_read.html ();
-
- regex = /(\d+)/;
- nb_not_read = parseInt (regex.exec (html)[1]) + nb;
-
- span_not_read.html (nb_not_read);
- }
- function mark_read (active) {
- if (active[0] === undefined) {
- return false;
- }
-
- url = active.find ("a.read").attr ("href");
- if (url === undefined) {
- return false;
- }
-
- $.ajax ({
- type: 'POST',
- url: url,
- data : { ajax: true }
- }).done (function (data) {
- res = jQuery.parseJSON(data);
-
- active.find ("a.read").attr ("href", res.url);
- if (active.hasClass ("not_read")) {
- active.removeClass ("not_read");
- //active.find ("a.read").html ("Marquer comme non lu");
- add_not_read (-1);
- } else {
- active.addClass ("not_read");
- //active.find ("a.read").html ("J'ai fini de lire l'article");
- add_not_read (1);
- }
- });
- }
- function mark_favorite (active) {
- if (active[0] === undefined) {
- return false;
- }
- url = active.find ("a.bookmark").attr ("href");
- if (url === undefined) {
- return false;
- }
-
- $.ajax ({
- type: 'POST',
- url: url,
- data : { ajax: true }
- }).done (function (data) {
- res = jQuery.parseJSON(data);
-
- active.find ("a.bookmark").attr ("href", res.url);
- if (active.hasClass ("favorite")) {
- active.removeClass ("favorite");
- //active.find ("a.bookmark").html ("Ajouter l'article à mes favoris");
- } else {
- active.addClass ("favorite");
- //active.find ("a.bookmark").html ("Retirer l'article de mes favoris");
- }
- });
- }
- function init_img () {
- $(".flux .content img").each (function () {
- if ($(this).width () > ($("#stream").width()) / 2) {
- $(this).addClass("big");
- }
- });
- }
- function init_posts () {
- init_img ();
- if (hide_posts) {
- $(".flux:not(.active) .content").slideUp ();
- }
- $(".flux").click (function () {
- old_active = $(".flux.active");
- new_active = $(this);
-
- if (old_active[0] != new_active[0]) {
- slide (new_active, old_active);
- }
- });
- $(".flux a.read").click (function () {
- active = $(this).parents (".flux");
- mark_read (active);
-
- return false;
- });
- $(".flux a.bookmark").click (function () {
- active = $(this).parents (".flux");
- mark_favorite (active);
-
- return false;
- });
- $(".flux .content a").click (function () {
- $(this).attr ('target', '_blank');
- });
- }
- $(document).ready (function () {
- init_posts ();
- // Touches de manipulation
- shortcut.add("<?php echo $s['mark_read']; ?>", function () {
- // on marque comme lu ou non lu
- active = $(".flux.active");
- mark_read (active);
- });
- shortcut.add("shift+<?php echo $s['mark_read']; ?>", function () {
- // on marque tout comme lu
- url = $("#top a.read_all").attr ("href");
- redirect (url, false);
- });
- shortcut.add("<?php echo $s['mark_favorite']; ?>", function () {
- // on marque comme favori ou non favori
- active = $(".flux.active");
- mark_favorite (active);
- });
-
- // Touches de navigation
- shortcut.add("<?php echo $s['prev_entry']; ?>", function () {
- old_active = $(".flux.active");
- last_active = $(".flux:last");
- new_active = old_active.prev ();
-
- if (new_active[0] instanceof HTMLDivElement) {
- slide (new_active, old_active);
- } else if (new_active[0] === undefined) {
- slide (last_active, old_active);
- }
- });
- shortcut.add("shift+<?php echo $s['prev_entry']; ?>", function () {
- old_active = $(".flux.active");
- first = $(".flux:first");
-
- if (first[0] instanceof HTMLDivElement) {
- slide (first, old_active);
- }
- });
- shortcut.add("<?php echo $s['next_entry']; ?>", function () {
- old_active = $(".flux.active");
- first_active = $(".flux:first");
- new_active = old_active.next ();
-
- if (new_active[0] instanceof HTMLDivElement) {
- slide (new_active, old_active);
- } else if (new_active[0] === undefined) {
- slide (first_active, old_active);
- }
- });
- shortcut.add("shift+<?php echo $s['next_entry']; ?>", function () {
- old_active = $(".flux.active");
- last = $(".flux:last");
-
- if (last[0] instanceof HTMLDivElement) {
- slide (last, old_active);
- }
- });
- shortcut.add("<?php echo $s['next_page']; ?>", function () {
- url = $(".pager-next a").attr ("href");
- redirect (url, false);
- });
- shortcut.add("shift+<?php echo $s['next_page']; ?>", function () {
- url = $(".pager-last a").attr ("href");
- redirect (url, false);
- });
- shortcut.add("<?php echo $s['prev_page']; ?>", function () {
- url = $(".pager-previous a").attr ("href");
- redirect (url, false);
- });
- shortcut.add("shift+<?php echo $s['prev_page']; ?>", function () {
- url = $(".pager-first a").attr ("href");
- redirect (url, false);
- });
- shortcut.add("<?php echo $s['go_website']; ?>", function () {
- url = $(".flux.active .link a").attr ("href");
-
- redirect (url, true);
- });
- });
|