diff options
| author | 2013-10-26 17:21:11 +0200 | |
|---|---|---|
| committer | 2013-10-26 17:21:11 +0200 | |
| commit | e7dd4829799e9e14456e1b1fc3aca20412394798 (patch) | |
| tree | 86ae5ab0fb167120ba61fe559646cf863570283d /app/layout | |
| parent | dd5273871a74d01d87fa1eaad7aa53bc1c148f85 (diff) | |
Mise à jour automatique des nombres d'articles non lus et favoris
En JavaScript, sans requête au serveur, décrémente ou incrémente le
nombre d'articles non lus ou en favoris suite à une action de
l'utilisateur.
Utilise un nouvel attribut data-unread pour stocker le nombre d'articles
non-lus et du pur CSS pour afficher cette valeur.
Nouvel attribut data-priority (pour savoir s'il faut inclure le flux ou
pas dans les nombres d'articles non lus).
Légère simplification CSS au passage (d'autres optimisations des
performances CSS seraient souhaitables en évitant les règles contenant
trop de sélecteurs universels imbriqués genre ".categories .favorites
.btn" et en évitant les changements de style en JavaScript lors du
chargement - j'essayerai de faire une proposition dans un patch séparé).
Bug connu : une catégorie finissant par une espace suivi d'un nombre
entre parenthèses comme "Exemple (2)" cause actuellement un léger bug
d'affichage dans le <title> s'il y a 0 article non lu et que
l'utilisateur en marque un comme "non lu". Il faudra une modification
pour utiliser data-unread aussi pour le <title>
Diffstat (limited to 'app/layout')
| -rw-r--r-- | app/layout/aside_flux.phtml | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 8928ffca0..22f52d25a 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -30,20 +30,16 @@ <?php } ?> <li> - <div class="all"> - <a class="btn<?php echo $this->get_c == 'all' ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index'); ?>"> - <i class="icon i_all"></i> - <?php echo Translate::t ('all_feeds', $this->nb_total); ?> - <?php if ($this->nb_not_read > 0) { ?> - <span class="notRead"><?php echo $this->nb_not_read > 1 ? Translate::t ('not_reads', $this->nb_not_read) : Translate::t ('not_read', $this->nb_not_read); ?></span> - <?php } ?> + <div class="category all"> + <a data-unread="<?php echo $this->nb_not_read; ?>" class="btn<?php echo $this->get_c == 'all' ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index'); ?>"> + <i class="icon i_all"></i><?php echo Translate::t ('all_feeds', $this->nb_total); ?> </a> </div> </li> <li> - <div class="favorites"> - <a class="btn<?php echo $this->get_c == 'favoris' ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index', 'get', 'favoris'); ?>"> + <div class="category favorites"> + <a data-unread="0" class="btn<?php echo $this->get_c == 'favoris' ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index', 'get', 'favoris'); ?>"> <i class="icon i_bookmark"></i> <?php echo Translate::t ('favorite_feeds', $this->nb_favorites); ?> </a> @@ -51,36 +47,27 @@ </li> <?php foreach ($this->cat_aside as $cat) { ?> - <?php $feeds = $cat->feeds (); $catNotRead = $cat->nbNotRead (); ?> + <?php $feeds = $cat->feeds (); ?> <?php if (!empty ($feeds)) { ?> <li> <?php $c_active = false; if ($this->get_c == $cat->id ()) { $c_active = true; } ?> <div class="category<?php echo $c_active ? ' active' : ''; ?>"> - <a class="btn<?php echo $c_active ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>"> - <?php echo $cat->name (); ?> - <?php if ($catNotRead > 0) { ?> - <span class="notRead" title="<?php echo $catNotRead > 1 ? Translate::t ('not_reads', $catNotRead) : Translate::t ('not_read', $catNotRead); ?>"><?php echo $catNotRead ; ?></span> - <?php } ?> - </a> + <a data-unread="<?php echo $cat->nbNotRead (); ?>" class="btn<?php echo $c_active ? ' active' : ''; ?>" href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>"><?php echo $cat->name (); ?></a> </div> <ul class="feeds<?php echo $c_active ? ' active' : ''; ?>"> - <?php foreach ($feeds as $feed) { ?> - <?php $nbEntries = $feed->nbEntries (); ?> - <?php $f_active = false; if ($this->get_f == $feed->id ()) { $f_active = true; } ?> - <li class="item<?php echo $f_active ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?><?php echo $nbEntries == 0 ? ' empty' : ''; ?>"> + <?php foreach ($feeds as $feed) { + $feed_id = $feed->id (); $nbEntries = $feed->nbEntries (); + $f_active = ($this->get_f == $feed_id); + ?> + <li id="f_<?php echo $feed_id; ?>" class="item<?php echo $f_active ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?><?php echo $nbEntries == 0 ? ' empty' : ''; ?>"> <div class="dropdown"> <div class="dropdown-target"></div> - <a class="dropdown-toggle" data-fid="<?php echo $feed->id (); ?>" data-fweb="<?php echo $feed->website (); ?>"><i class="icon i_configure"></i></a> + <a class="dropdown-toggle" data-fweb="<?php echo $feed->website (); ?>"><i class="icon i_configure"></i></a> <?php /* feed_config_template */ ?> </div> - <?php $not_read = $feed->nbNotRead (); ?> - <img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" /> - <?php echo $not_read > 0 ? '<b>' : ''; ?> - <a class="feed" href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed->id ()); ?>"> - <?php echo ($not_read > 0 ? '(' . $not_read . ') ' : ''), $feed->name(); ?> - </a> - <?php echo $not_read > 0 ? '</b>' : ''; ?> + <img class="favicon" src="<?php echo $feed->favicon (); ?>" /> + <a class="feed" data-unread="<?php echo $feed->nbNotRead (); ?>" data-priority="<?php echo $feed->priority (); ?>" href="<?php echo _url ('index', 'index', 'get', 'f_' . $feed_id); ?>"><?php echo $feed->name(); ?></a> </li> <?php } ?> </ul> @@ -94,13 +81,13 @@ <script id="feed_config_template" type="text/html"> <ul class="dropdown-menu"> <li class="dropdown-close"><a href="#close"> </a></li> - <li class="item"><a href="<?php echo _url ('index', 'index', 'get', 'f_' . '!!!!!!'); ?>"><?php echo Translate::t ('filter'); ?></a></li> + <li class="item"><a href="<?php echo _url ('index', 'index', 'get', 'f_!!!!!!'); ?>"><?php echo Translate::t ('filter'); ?></a></li> <li class="item"><a target="_blank" href="http://example.net/"><?php echo Translate::t ('see_website'); ?></a></li> <?php if (!login_is_conf ($this->conf) || is_logged ()) { ?> <li class="separator"></li> <li class="item"><a href="<?php echo _url ('configure', 'feed', 'id', '!!!!!!'); ?>"><?php echo Translate::t ('administration'); ?></a></li> <li class="item"><a href="<?php echo _url ('feed', 'actualize', 'id', '!!!!!!'); ?>"><?php echo Translate::t ('actualize'); ?></a></li> - <li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', 'f_' . '!!!!!!'); ?>"><?php echo Translate::t ('mark_read'); ?></a></li> + <li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', 'f_!!!!!!'); ?>"><?php echo Translate::t ('mark_read'); ?></a></li> <?php } ?> </ul> </script> |
