aboutsummaryrefslogtreecommitdiff
path: root/app/views/javascript/main.phtml
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-17 12:08:28 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-03-17 12:08:28 +0100
commit82c550c7aa69b64880f432b4bfe6b95d8238e232 (patch)
treea533c1ebc287c2634158f3d932a6463827b89c9f /app/views/javascript/main.phtml
parente83a3063d16e4095417fe8a39e48789d39a1ef4c (diff)
Déplacement fonctions de raccourcis + amélioration système toggleContent lorsque clic sur l'en-tête d'un article (slide() -> toggleContent())
Diffstat (limited to 'app/views/javascript/main.phtml')
-rw-r--r--app/views/javascript/main.phtml46
1 files changed, 26 insertions, 20 deletions
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml
index bae7cdcc5..b77e25c83 100644
--- a/app/views/javascript/main.phtml
+++ b/app/views/javascript/main.phtml
@@ -19,15 +19,20 @@ function redirect (url, new_tab) {
}
}
-function slide (new_active, old_active) {
+function toggleContent (new_active, old_active) {
old_active.removeClass ("active");
- new_active.addClass ("active");
+ if (old_active[0] != new_active[0]) {
+ new_active.addClass ("active");
+ }
if (hide_posts) {
old_active.children (".content").toggle (0);
- new_active.children (".content").toggle (0, function () {
- $("html,body").scrollTop (new_active.position ().top);
- });
+
+ if (old_active[0] != new_active[0]) {
+ new_active.children (".content").toggle (0, function () {
+ $("html,body").scrollTop (new_active.position ().top);
+ });
+ }
} else {
$("html,body").scrollTop (new_active.position ().top);
}
@@ -125,13 +130,11 @@ function init_posts () {
$(".flux:not(.active) .content").hide ();
}
- $(".flux").click (function () {
+ $(".flux .flux_header").click (function () {
old_active = $(".flux.active");
- new_active = $(this);
+ new_active = $(this).parent ();
- if (old_active[0] != new_active[0]) {
- slide (new_active, old_active);
- }
+ toggleContent (new_active, old_active);
});
$(".flux a.read").click (function () {
@@ -174,10 +177,7 @@ function init_column_categories () {
});
}
-$(document).ready (function () {
- init_posts ();
- init_column_categories ();
-
+function init_shortcuts () {
// Touches de manipulation
shortcut.add("<?php echo $s['mark_read']; ?>", function () {
// on marque comme lu ou non lu
@@ -208,10 +208,10 @@ $(document).ready (function () {
new_active = old_active.prevAll (".flux:first");
if (new_active.hasClass("flux")) {
- slide (new_active, old_active);
+ toggleContent (new_active, old_active);
} else if (old_active[0] === undefined &&
new_active[0] === undefined) {
- slide (last_active, old_active);
+ toggleContent (last_active, old_active);
}
}, {
'disable_in_input':true
@@ -221,7 +221,7 @@ $(document).ready (function () {
first = $(".flux:first");
if (first.hasClass("flux")) {
- slide (first, old_active);
+ toggleContent (first, old_active);
}
}, {
'disable_in_input':true
@@ -232,10 +232,10 @@ $(document).ready (function () {
new_active = old_active.nextAll (".flux:first");
if (new_active.hasClass("flux")) {
- slide (new_active, old_active);
+ toggleContent (new_active, old_active);
} else if (old_active[0] === undefined &&
new_active[0] === undefined) {
- slide (first_active, old_active);
+ toggleContent (first_active, old_active);
}
}, {
'disable_in_input':true
@@ -245,7 +245,7 @@ $(document).ready (function () {
last = $(".flux:last");
if (last.hasClass("flux")) {
- slide (last, old_active);
+ toggleContent (last, old_active);
}
}, {
'disable_in_input':true
@@ -275,4 +275,10 @@ $(document).ready (function () {
}, {
'disable_in_input':true
});
+}
+
+$(document).ready (function () {
+ init_posts ();
+ init_column_categories ();
+ init_shortcuts ();
});