diff --git a/apps/reader/views.py b/apps/reader/views.py index e21a55985..84866dc6d 100644 --- a/apps/reader/views.py +++ b/apps/reader/views.py @@ -163,8 +163,14 @@ def load_feeds(request): for f in feeds: if 'not_yet_fetched' not in feeds[f]: feeds[f]['not_yet_fetched'] = False - - data = dict(feeds=feeds, folders=json.decode(folders.folders)) + + starred_count = MStarredStory.objects(user_id=request.user.pk).count() + + data = { + 'feeds': feeds, + 'folders': json.decode(folders.folders), + 'starred_count': starred_count, + } return data @ajax_login_required diff --git a/media/css/reader.css b/media/css/reader.css index fe2a950fa..c54aea2e6 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -1407,7 +1407,19 @@ background: transparent; /* = Header - Starred Stories = */ /* ============================ */ -.NB-feeds-header-container .NB-feeds-header-starred { +.NB-feeds-header-starred-container { + position: relative; + height: 20px; + display: none; + overflow: hidden; +} + +.NB-feeds-header-starred { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 18px; border-top: 1px solid #303030; border-bottom: 1px solid #E9E9E9; padding-right: 2px; @@ -1416,22 +1428,22 @@ background: transparent; cursor: pointer; } -.NB-feeds-header-container .NB-feeds-header-starred.NB-selected { +.NB-feeds-header-starred.NB-selected { background: #f6a828 url('../theme/images/ui-bg_highlight-hard_35_f6a828_1x100.png') 0 50% repeat-x; } -.NB-feeds-header-container .NB-feeds-header-starred .NB-feeds-header-starred-icon { +.NB-feeds-header-starred .NB-feeds-header-starred-icon { position: absolute; - top: 2px; + top: 1px; left: 2px; background: transparent url('../img/reader/star_blue.png') no-repeat 0 0; width: 16px; height: 16px; } -.NB-feeds-header-container .NB-feeds-header-starred .NB-feeds-header-starred-title { +.NB-feeds-header-starred .NB-feeds-header-starred-title { display: block; - padding: 4px 40px 2px 23px; + padding: 3px 40px 2px 23px; text-decoration: none; color: #F0F0F0; line-height: 1.3em; @@ -1441,19 +1453,24 @@ background: transparent; text-transform: uppercase; } -.NB-feeds-header-container .NB-feeds-header-starred:hover .NB-feeds-header-starred-title { +.NB-feeds-header-starred:hover .NB-feeds-header-starred-title { color: #DCDCDC; } -.NB-feeds-header-container .NB-feeds-header-starred.NB-selected .NB-feeds-header-starred-title { +.NB-feeds-header-starred.NB-selected .NB-feeds-header-starred-title { text-shadow: 0 1px 0 #FFC97D; color: #000000; } -.NB-feeds-header-container .NB-feeds-header-starred-count { +.NB-feeds-header-starred .NB-feeds-header-starred-count { background-color: #11448B; display: block; padding: 0 4px; + margin-top: 2px; +} + +.NB-feeds-header-starred.NB-empty .NB-feeds-header-starred-count { + display: none; } /* ============ */ diff --git a/media/js/newsblur/assetmodel.js b/media/js/newsblur/assetmodel.js index f3f72d475..29495691d 100644 --- a/media/js/newsblur/assetmodel.js +++ b/media/js/newsblur/assetmodel.js @@ -22,6 +22,7 @@ NEWSBLUR.AssetModel.Reader = function() { this.read_stories = {}; this.classifiers = {}; this.starred_stories = []; + this.starred_count = 0; this.DEFAULT_VIEW = NEWSBLUR.Preferences.default_view || 'page'; }; @@ -169,6 +170,7 @@ NEWSBLUR.AssetModel.Reader.prototype = { } }); self.folders = subscriptions.folders; + self.starred_count = subscriptions.starred_count; callback(); }; diff --git a/media/js/newsblur/reader.js b/media/js/newsblur/reader.js index 2cb54a236..487cb0a62 100644 --- a/media/js/newsblur/reader.js +++ b/media/js/newsblur/reader.js @@ -21,7 +21,8 @@ $mouse_indicator: $('#mouse-indicator'), $feed_link_loader: $('#NB-feeds-list-loader'), $feeds_progress: $('#NB-progress'), - $header: $(".NB-feeds-header") + $header: $('.NB-feeds-header'), + $starred_header: $('.NB-feeds-header-starred') }; this.flags = { 'feed_view_images_loaded': {}, @@ -618,6 +619,7 @@ $('.feed', $feed_list).tsort('.feed_title'); $('.folder', $feed_list).tsort('.folder_title_text'); this.update_header_counts(); + _.delay(_.bind(this.update_starred_count, this), 250); } }, @@ -646,6 +648,22 @@ }); }, + update_starred_count: function() { + var starred_count = this.model.starred_count; + var $starred_count = $('.NB-feeds-header-starred-count', this.$s.$starred_header); + var $starred_container = this.$s.$starred_header.closest('.NB-feeds-header-starred-container'); + + if (starred_count <= 0) { + this.$s.$starred_header.addClass('NB-empty'); + $starred_count.text(''); + $starred_container.slideUp(350); + } else if (starred_count > 0) { + $starred_count.text(starred_count); + this.$s.$starred_header.removeClass('NB-empty'); + $starred_container.slideDown(350); + } + }, + detect_all_inactive_feeds: function() { var feeds = this.model.feeds; var has_chosen_feeds = _.any(feeds, function(feed) { diff --git a/templates/reader/feeds.xhtml b/templates/reader/feeds.xhtml index 8f944976a..9707ea9fc 100644 --- a/templates/reader/feeds.xhtml +++ b/templates/reader/feeds.xhtml @@ -330,11 +330,13 @@ $(document).ready(function() {