aboutsummaryrefslogtreecommitdiff
path: root/app/views/javascript
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-28 00:54:52 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-28 00:54:52 +0200
commitb5c39ef5ef10ca80816260030ef6a3e9a6c59acf (patch)
treee0ac65dfecfdfbda1bdf0e971e4514cbb3d8e6bd /app/views/javascript
parente0774203b0027dd4fe794140b9057c9a82f44d07 (diff)
nombre de non lus est màj directement en js
Diffstat (limited to 'app/views/javascript')
-rw-r--r--app/views/javascript/main.phtml34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml
index 7d077d93f..c94526885 100644
--- a/app/views/javascript/main.phtml
+++ b/app/views/javascript/main.phtml
@@ -34,6 +34,31 @@ function slide (new_active, old_active) {
}
}
+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;
@@ -52,9 +77,11 @@ function mark_read (active) {
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);
}
});
}
@@ -104,6 +131,7 @@ $(document).ready (function () {
}
});
+
$(".post.flux a.read").click (function () {
active = $(this).parents (".post.flux");
mark_read (active);
@@ -116,6 +144,12 @@ $(document).ready (function () {
return false;
});
+
+ $(".post.flux .content a").click (function () {
+ url = $(this).attr ("href");
+ redirect (url, true);
+ return false;
+ });
// Touches de manipulation
shortcut.add("<?php echo $s['mark_read']; ?>", function () {