From dff85f9a304a6ff2ede764a8f62024e7b4ff074e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 23 Jun 2013 15:05:39 +0200 Subject: Ajout d'une barre de navigation en version mobile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix issue #57 : pas d'effet de slide (effet trop bling-bling) mais ajout d'une barre de navigation permettant d'aller à l'article suivant / précédent ou de remonter en haut de la page --- app/views/javascript/main.phtml | 64 +++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 24 deletions(-) (limited to 'app/views/javascript/main.phtml') diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index e290e02d3..e51cf978e 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -105,6 +105,32 @@ function mark_favorite (active) { }); } +function prev_entry() { + old_active = $(".flux.active"); + last_active = $(".flux:last"); + new_active = old_active.prevAll (".flux:first"); + + if (new_active.hasClass("flux")) { + toggleContent (new_active, old_active); + } else if (old_active[0] === undefined && + new_active[0] === undefined) { + toggleContent (last_active, old_active); + } +} + +function next_entry() { + old_active = $(".flux.active"); + first_active = $(".flux:first"); + new_active = old_active.nextAll (".flux:first"); + + if (new_active.hasClass("flux")) { + toggleContent (new_active, old_active); + } else if (old_active[0] === undefined && + new_active[0] === undefined) { + toggleContent (first_active, old_active); + } +} + function init_img () { $(".flux_content .content img").each (function () { if ($(this).width () > ($(".flux_content .content").width()) / 2) { @@ -206,18 +232,7 @@ function init_shortcuts () { }); // Touches de navigation - shortcut.add("", function () { - old_active = $(".flux.active"); - last_active = $(".flux:last"); - new_active = old_active.prevAll (".flux:first"); - - if (new_active.hasClass("flux")) { - toggleContent (new_active, old_active); - } else if (old_active[0] === undefined && - new_active[0] === undefined) { - toggleContent (last_active, old_active); - } - }, { + shortcut.add("", prev_entry, { 'disable_in_input':true }); shortcut.add("shift+", function () { @@ -230,18 +245,7 @@ function init_shortcuts () { }, { 'disable_in_input':true }); - shortcut.add("", function () { - old_active = $(".flux.active"); - first_active = $(".flux:first"); - new_active = old_active.nextAll (".flux:first"); - - if (new_active.hasClass("flux")) { - toggleContent (new_active, old_active); - } else if (old_active[0] === undefined && - new_active[0] === undefined) { - toggleContent (first_active, old_active); - } - }, { + shortcut.add("", next_entry, { 'disable_in_input':true }); shortcut.add("shift+", function () { @@ -281,6 +285,17 @@ function init_shortcuts () { }); } +function init_nav_entries() { + $('.nav_entries a.previous_entry').click(function() { + prev_entry(); + return false; + }); + $('.nav_entries a.next_entry').click(function() { + next_entry(); + return false; + }); +} + $(document).ready (function () { if(is_reader_mode()) { hide_posts = false; @@ -288,4 +303,5 @@ $(document).ready (function () { init_posts (); init_column_categories (); init_shortcuts (); + init_nav_entries(); }); -- cgit v1.2.3