From bdb69080f8d0bf50aa7d297ba5c5e992f05bdcd0 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 9 Nov 2013 00:46:43 +0100 Subject: [PATCH] Affichage dynamique des favoris non lus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige https://github.com/marienfressinaud/FreshRSS/issues/222 Il reste toujours une situation curieuse lorsqu'on a fini de lire tous les favoris non-lus, mais à voir une autre fois --- app/models/Entry.php | 5 ----- public/scripts/main.js | 23 +++++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/app/models/Entry.php b/app/models/Entry.php index e835f9aed..99edf94b4 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -487,11 +487,6 @@ class EntryDAO extends Model_pdo { return $readUnread; } - public function countFavorites () { //Deprecated: use countUnreadReadFavorites() instead - $unreadRead = $this->countUnreadReadFavorites (); //This makes better use of caching - return $unreadRead['unread'] + $unreadRead['read']; - } - public function optimizeTable() { $sql = 'OPTIMIZE TABLE ' . $this->prefix . 'entry'; $stm = $this->bd->prepare ($sql); diff --git a/public/scripts/main.js b/public/scripts/main.js index 3d4c1f30a..9723e617d 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -72,6 +72,13 @@ function mark_read(active, only_not_read) { elem.setAttribute('data-unread', Math.max(0, feed_unread + inc)); } + //Update unread: favourites + if (active.closest('div').hasClass('favorite')) { + elem = $('#aside_flux .favorites').children(':first').get(0); + feed_unread = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0; + elem.setAttribute('data-unread', Math.max(0, feed_unread + inc)); + } + //Update unread: title document.title = document.title.replace(/((?: \(\d+\))?)( - .*?)((?: \(\d+\))?)$/, function (m, p1, p2, p3) { return incLabel(p1, inc) + p2 + incLabel(p3, feed_priority > 0 ? inc : 0); @@ -112,6 +119,12 @@ function mark_favorite(active) { return incLabel(p1, inc); }); } + + if (active.closest('div').hasClass('not_read')) { + var elem = $('#aside_flux .favorites').children(':first').get(0), + feed_unread = elem ? (parseInt(elem.getAttribute('data-unread'), 10) || 0) : 0; + elem.setAttribute('data-unread', Math.max(0, feed_unread + inc)); + } }); } @@ -193,15 +206,6 @@ function next_entry() { } } -/*function init_img() { - var maxWidth = $(".flux_content .content").width() / 2; - $(".flux_content .content img").each(function () { - if ($(this).width() > maxWidth) { - $(this).addClass("big"); - } - }); -}*/ - function inMarkViewport(flux, box_to_follow, relative_follow) { var top = flux.position().top; if (relative_follow) { @@ -229,7 +233,6 @@ function init_lazyload() { } function init_posts() { - //init_img(); //Alex init_lazyload(); var box_to_follow = $(window),