conf->displayPosts () == 'no') { ?> var hide_posts = true; var hide_posts = false; 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 (200); new_active.children (".content").slideDown (200, function () { $.smoothScroll({ offset: new_active.position ().top + 25 }); }); } else { $.smoothScroll({ offset: new_active.position ().top + 25 }); } } function add_not_read (nb) { span_not_read = $("#main_aside #menu a span.nb_not_read"); html = span_not_read.html (); if (html == "" && nb > 0) { nb_not_read = nb; } else if (html != "") { regex = /\((\d+) non lus?\)/; nb_not_read = parseInt (regex.exec (html)[1]) + nb; } else { nb_not_read = 0; } pluriel = ""; if (nb_not_read > 1) { pluriel = "s"; } if (nb_not_read > 0) { span_not_read.html ("(" + nb_not_read + " non lu" + pluriel + ")"); } else { span_not_read.html (""); } } function mark_read (active) { if (active[0] === undefined) { return false; } url = active.find ("a.read").attr ("href"); $.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"); $.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"); } }); } $(document).ready (function () { if (hide_posts) { $(".post.flux .content").slideToggle (); } $(".post.flux").click (function () { old_active = $(".post.flux.active"); new_active = $(this); if (old_active[0] != new_active[0]) { slide (new_active, old_active); } else { old_active.removeClass ("active"); if (hide_posts) { old_active.children (".content").slideUp (200); } } }); $(".post.flux a.read").click (function () { active = $(this).parents (".post.flux"); mark_read (active); return false; }); $(".post.flux a.bookmark").click (function () { active = $(this).parents (".post.flux"); mark_favorite (active); return false; }); $(".post.flux .content a").click (function () { url = $(this).attr ("href"); redirect (url, true); return false; }); // Touches de manipulation shortcut.add("", function () { // on marque comme lu ou non lu active = $(".post.flux.active"); mark_read (active); }); shortcut.add("shift+", function () { // on marque tout comme lu url = $("#top a.read_all").attr ("href"); redirect (url, false); }); shortcut.add("", function () { // on marque comme favori ou non favori active = $(".post.flux.active"); mark_favorite (active); }); // Touches de navigation shortcut.add("", function () { old_active = $(".post.flux.active"); last_active = $(".post.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+", function () { old_active = $(".post.flux.active"); first = $(".post.flux:first"); if (first[0] instanceof HTMLDivElement) { slide (first, old_active); } }); shortcut.add("", function () { old_active = $(".post.flux.active"); first_active = $(".post.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+", function () { old_active = $(".post.flux.active"); last = $(".post.flux:last"); if (last[0] instanceof HTMLDivElement) { slide (last, old_active); } }); shortcut.add("", function () { url = $(".pager-next a").attr ("href"); redirect (url, false); }); shortcut.add("shift+", function () { url = $(".pager-last a").attr ("href"); redirect (url, false); }); shortcut.add("", function () { url = $(".pager-previous a").attr ("href"); redirect (url, false); }); shortcut.add("shift+", function () { url = $(".pager-first a").attr ("href"); redirect (url, false); }); shortcut.add("", function () { url = $(".post.flux.active h1.title a").attr ("href"); redirect (url, true); }); });