1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
<?php if ($this->conf->displayPosts () == 'no') { ?>
var hide_posts = true;
<?php } else { ?>
var hide_posts = false;
<?php } ?>
function redirect (url) {
if (url) {
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 mark_read (active) {
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");
} else {
active.addClass ("not_read");
active.find ("a.read").html ("J'ai fini de lire l'article");
}
});
}
function mark_favorite (active) {
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);
}
});
$(".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;
});
// Touches de manipulation
shortcut.add("m", function () {
// on marque comme lu ou non lu
active = $(".post.flux.active");
mark_read (active);
});
shortcut.add("f", function () {
// on marque comme favori ou non favori
active = $(".post.flux.active");
mark_favorite (active);
});
// Touches de navigation
shortcut.add("page_up", 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("page_down", 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("right", function () {
url = $(".pager-next a").attr ("href");
if (url === undefined) {
url = $(".pager-first a").attr ("href");
}
redirect (url);
});
shortcut.add("left", function () {
url = $(".pager-previous a").attr ("href");
if (url === undefined) {
url = $(".pager-last a").attr ("href");
}
redirect (url);
});
});
|