diff options
| author | 2013-06-23 17:40:05 +0200 | |
|---|---|---|
| committer | 2013-06-23 17:40:05 +0200 | |
| commit | 7396b3d89724a6280684f0d2099fe17834a0f923 (patch) | |
| tree | 01ffc794f43f2ee3ced72559db04065895b2301d /app/views/javascript/main.phtml | |
| parent | dff85f9a304a6ff2ede764a8f62024e7b4ff074e (diff) | |
Fix #77 : articles marqués comme lus au défilement
Possibilité de marquer les articles automatiquement comme lus lors
du défilement de la page. Le marquage survient aux 3/4 de l'article
visible.
Ajout d'une option pour activer / désactiver (défaut) la fonctionnalité
et disparition de l'option de marquage au chargement de la page.
Ajout de 2 boutons pour marquer comme lu et en favori en bas des
articles
Diffstat (limited to 'app/views/javascript/main.phtml')
| -rw-r--r-- | app/views/javascript/main.phtml | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/app/views/javascript/main.phtml b/app/views/javascript/main.phtml index e51cf978e..da95f9c04 100644 --- a/app/views/javascript/main.phtml +++ b/app/views/javascript/main.phtml @@ -58,6 +58,12 @@ function mark_read (active, only_not_read) { return false; } + if (active.hasClass ("not_read")) { + active.removeClass ("not_read"); + } else { + active.addClass ("not_read"); + } + url = active.find ("a.read").attr ("href"); if (url === undefined) { return false; @@ -71,11 +77,6 @@ function mark_read (active, only_not_read) { res = jQuery.parseJSON(data); active.find ("a.read").attr ("href", res.url); - if (active.hasClass ("not_read")) { - active.removeClass ("not_read"); - } else { - active.addClass ("not_read"); - } }); } @@ -139,14 +140,19 @@ function init_img () { }); } -function init_posts () { - <?php if ($mark['page'] == 'yes') { ?> - if ($(".flux.not_read")[0] != undefined) { - url = $(".nav_menu a.read_all").attr ("href"); - redirect (url, false); - } - <?php } ?> +function inMarkViewport(flux) { + var top = flux.position().top; + var height = flux.height(); + var begin = top + 3 * height / 4; + var bot = top + height; + + var windowTop = $(window).scrollTop(); + var windowBot = windowTop + $(window).height(); + return (windowBot >= begin && windowBot <= bot); +} + +function init_posts () { init_img (); <?php if($this->conf->lazyload() == 'yes') { ?> $(".flux .content img").lazyload(); @@ -186,6 +192,17 @@ function init_posts () { mark_read($(this).parent().parent().parent(), true); }); <?php } ?> + + <?php if ($mark['scroll'] == 'yes') { ?> + var flux = $('.flux'); + $(window).scroll(function() { + flux.each(function() { + if($(this).hasClass('not_read') && inMarkViewport($(this))) { + mark_read($(this), true); + } + }); + }); + <?php } ?> } function init_column_categories () { |
