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 | |
| 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')
| -rw-r--r-- | app/views/configure/display.phtml | 6 | ||||
| -rw-r--r-- | app/views/helpers/normal_view.phtml | 15 | ||||
| -rw-r--r-- | app/views/javascript/main.phtml | 41 |
3 files changed, 47 insertions, 15 deletions
diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 8484a7116..7da5b2947 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -111,9 +111,9 @@ <input type="checkbox" name="mark_open_site" id="check_open_site" value="yes"<?php echo $this->conf->markWhenSite () == 'yes' ? ' checked="checked"' : ''; ?> /> <?php echo Translate::t ('article_open_on_website'); ?> </label> - <label class="checkbox" for="check_open_page"> - <input type="checkbox" name="mark_open_page" id="check_open_page" value="yes"<?php echo $this->conf->markWhenPage () == 'yes' ? ' checked="checked"' : ''; ?> /> - <?php echo Translate::t ('page_loaded'); ?> + <label class="checkbox" for="check_scroll"> + <input type="checkbox" name="mark_scroll" id="check_scroll" value="yes"<?php echo $this->conf->markWhenScroll () == 'yes' ? ' checked="checked"' : ''; ?> /> + <?php echo Translate::t ('scroll'); ?> </label> </div> </div> diff --git a/app/views/helpers/normal_view.phtml b/app/views/helpers/normal_view.phtml index eaf1e4276..126fa5a78 100644 --- a/app/views/helpers/normal_view.phtml +++ b/app/views/helpers/normal_view.phtml @@ -64,6 +64,21 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { </div> <ul class="horizontal-list bottom"> + <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> + <li class="item manage"> + <?php if (!$item->isRead ()) { ?> + <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 1); ?>"> </a> + <?php } else { ?> + <a class="read" href="<?php echo _url ('entry', 'read', 'id', $item->id (), 'is_read', 0); ?>"> </a> + <?php } ?> + + <?php if (!$item->isFavorite ()) { ?> + <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 1); ?>"> </a> + <?php } else { ?> + <a class="bookmark" href="<?php echo _url ('entry', 'bookmark', 'id', $item->id (), 'is_favorite', 0); ?>"> </a> + <?php } ?> + </li> + <?php } ?> <li class="item"> <div class="dropdown"> <div id="dropdown-share-<?php echo $item->id ();?>" class="dropdown-target"></div> 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 () { |
