diff options
| author | 2014-02-15 20:24:07 +0100 | |
|---|---|---|
| committer | 2014-02-15 20:29:22 +0100 | |
| commit | 9e23ced0bf50c8af96d39dd68068e0564d593a92 (patch) | |
| tree | 4eb7bd85fa924b238352aeb93d651d60e6fbc2a1 | |
| parent | 1ab5fa83c3b25d773b203a54e319eb71bd3a69da (diff) | |
Improve behaviour category / feed shortcuts
- code improved
- possibility to move directly from "all" category
- when there is no selected feed and we want the "next one", first feed is
selected (last before). Same for categories
See #256
| -rw-r--r-- | app/layout/aside_flux.phtml | 4 | ||||
| -rw-r--r-- | p/scripts/main.js | 69 |
2 files changed, 46 insertions, 27 deletions
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 8454b4459..817dae676 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -20,7 +20,7 @@ } ?> <li> - <div class="category all"> + <div class="category all<?php echo $this->get_c == 'a' ? ' active' : ''; ?>"> <a data-unread="<?php echo formatNumber($this->nb_not_read); ?>" class="btn<?php echo $this->get_c == 'a' ? ' active' : ''; ?>" href="<?php echo Minz_Url::display($arUrl); ?>"> <?php echo FreshRSS_Themes::icon('all'); ?> <?php echo Minz_Translate::t ('main_stream'); ?> @@ -29,7 +29,7 @@ </li> <li> - <div class="category favorites"> + <div class="category favorites<?php echo $this->get_c == 's' ? ' active' : ''; ?>"> <a data-unread="<?php echo formatNumber($this->nb_favorites['unread']); ?>" class="btn<?php echo $this->get_c == 's' ? ' active' : ''; ?>" href="<?php $arUrl['params']['get'] = 's'; echo Minz_Url::display($arUrl); ?>"> <?php echo FreshRSS_Themes::icon('bookmark'); ?> <?php echo Minz_Translate::t('favorite_feeds', formatNumber($this->nb_favorites['all'])); ?> diff --git a/p/scripts/main.js b/p/scripts/main.js index 92f98ab28..130407f2c 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -284,64 +284,83 @@ function next_entry() { } function prev_feed() { - if ($('li.active').length > 0) { - var pf = $('li.active').prev().find('a.feed'); - if (pf.length > 0) { - pf[0].click(); + var active_feed = $("#aside_flux .feeds li.active"); + if (active_feed.length > 0) { + var prev_feed = active_feed.prev().find('a.feed'); + if (prev_feed.length > 0) { + prev_feed[0].click(); } } else { - first_feed(); + last_feed(); } } function next_feed() { - if ($('li.active').length > 0) { - var nf = $('li.active').next().find('a.feed'); - if (nf.length > 0) { - nf[0].click(); + var active_feed = $("#aside_flux .feeds li.active"); + if (active_feed.length > 0) { + var next_feed = active_feed.next().find('a.feed'); + if (next_feed.length > 0) { + next_feed[0].click(); } } else { - last_feed(); + first_feed(); } } function first_feed() { - $('.feeds.active li').first().find('a')[1].click(); + var feed = $("#aside_flux .feeds.active li:first"); + if (feed.length > 0) { + feed.find('a')[1].click(); + } } function last_feed() { - $('.feeds.active li').last().find('a')[1].click(); + var feed = $("#aside_flux .feeds.active li:last"); + if (feed.length > 0) { + feed.find('a')[1].click(); + } } function prev_category() { - if ($('div.active').length > 0) { - var pc = $('div.active').parent('li').prev().find('div.stick a.btn'); - if (pc.length > 0) { - pc[0].click(); - return; + var active_cat = $("#aside_flux .category.active"); + + if (active_cat.length > 0) { + var prev_cat = active_cat.parent('li').prev().find('.category a.btn'); + if (prev_cat.length > 0) { + prev_cat[0].click(); } } else { - first_category(); + last_category(); } + return; } function next_category() { - if ($('div.active').length > 0) { - var nc = $('div.active').parent('li').next().find('div.stick a.btn'); - if (nc.length > 0) { - nc[0].click(); + var active_cat = $("#aside_flux .category.active"); + + if (active_cat.length > 0) { + var next_cat = active_cat.parent('li').next().find('.category a.btn'); + if (next_cat.length > 0) { + next_cat[0].click(); } } else { - last_category(); + first_category(); } + return; } function first_category() { - $('div.category.stick').first().find('a.btn')[0].click(); + var cat = $("#aside_flux .category:first"); + if (cat.length > 0) { + cat.find('a.btn')[0].click(); + } } function last_category() { - $('div.category.stick').last().find('a.btn')[0].click(); + var cat = $("#aside_flux .category:last"); + if (cat.length > 0) { + cat.find('a.btn')[0].click(); + } } function collapse_entry() { |
