From fb32aa4ef1253573115766bc48068ea1a7db4082 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 17 Mar 2013 02:47:54 +0100 Subject: Amélioration affichage notifications + améliorations divers niveau affichage + ajout options pour auto-marquage des articles comme lus (à l'ouverture de l'article / du site / de la page) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/javascript/main.phtml | 45 +++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) (limited to 'app/views/javascript') diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index a4e3229bf..d2bde2a42 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -4,7 +4,10 @@ var hide_posts = true; var hide_posts = false; -conf->shortcuts (); ?> +conf->shortcuts (); + $mark = $this->conf->markWhen (); +?> function redirect (url, new_tab) { if (url) { @@ -32,13 +35,22 @@ function slide (new_active, old_active) { offset: new_active.position ().top }); } + + + mark_read(new_active, true); + } -function mark_read (active) { - if (active[0] === undefined) { +var load = false; +function mark_read (active, only_not_read) { + if (active[0] === undefined || ( + only_not_read === true && !active.hasClass("not_read")) || + load === true) { return false; } + load = true; + url = active.find ("a.read").attr ("href"); if (url === undefined) { return false; @@ -57,6 +69,8 @@ function mark_read (active) { } else { active.addClass ("not_read"); } + + load = false; }); } @@ -95,6 +109,13 @@ function init_img () { } function init_posts () { + + if ($(".flux.not_read")[0] != undefined) { + url = $(".nav_menu a.read_all").attr ("href"); + redirect (url, false); + } + + init_img (); if (hide_posts) { @@ -112,7 +133,7 @@ function init_posts () { $(".flux a.read").click (function () { active = $(this).parents (".flux"); - mark_read (active); + mark_read (active, false); return false; }); @@ -127,6 +148,12 @@ function init_posts () { $(".flux .content a").click (function () { $(this).attr ('target', '_blank'); }); + + + $(".flux .link a").click (function () { + mark_read($(this).parent().parent().parent(), true); + }); + } function init_column_categories () { @@ -152,13 +179,13 @@ $(document).ready (function () { shortcut.add("", function () { // on marque comme lu ou non lu active = $(".flux.active"); - mark_read (active); + mark_read (active, false); }, { 'disable_in_input':true }); shortcut.add("shift+", function () { // on marque tout comme lu - url = $("#top a.read_all").attr ("href"); + url = $(".nav_menu a.read_all").attr ("href"); redirect (url, false); }, { 'disable_in_input':true @@ -233,6 +260,12 @@ $(document).ready (function () { shortcut.add("", function () { url = $(".flux.active .link a").attr ("href"); + + $(".flux.active").each (function () { + mark_read($(this), true); + }); + + redirect (url, true); }, { 'disable_in_input':true -- cgit v1.2.3