diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/news.js | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/js/news.js b/js/news.js index dbe9a53a1..4c57d6cbe 100644 --- a/js/news.js +++ b/js/news.js @@ -251,8 +251,10 @@ News={ var $feedItems = $('#feed_items'); $feedItems.empty(); $feedItems.html(jsonData.data.feedItems); + $feedItems.scrollTop(0); var $feedTitle = $(".feed_controls .feed_title h1"); $feedTitle.html(jsonData.data.feedTitle); + $feedTitle.attr('title', jsonData.data.feedTitle); $('li#selected_feed').attr('id', ''); $('li.feed[data-id="' + feedId + '"]').attr('id', 'selected_feed'); @@ -599,6 +601,14 @@ function bindItemEventListeners(){ handler.setRead(true); }); + // single hover on item should mark it as read too + $('#feed_items .body').click(function(){ + var $item = $(this).parent('.feed_item'); + var itemId = $item.data('id'); + var handler = new News.ItemStatusHandler(itemId); + handler.setRead(true); + }); + // mark or unmark as important $('#feed_items li.star').click(function(){ var $item = $(this).parent().parent().parent('.feed_item'); @@ -640,7 +650,8 @@ $(document).ready(function(){ }); $('#addfeedfolder').click(function(event) { - event.stopPropagation(); + News.DropDownMenu.fade($(this).children('ul')); + event.stopPropagation(); }); $('#settingsbtn').on('click keydown', function() { @@ -670,24 +681,43 @@ $(document).ready(function(){ var boxHeight = $(this).height(); var scrollHeight = $(this).prop('scrollHeight'); var scrolled = $(this).scrollTop() + boxHeight; - + var scrollArea = this; $(this).children('ul').children('.feed_item:not(.read)').each(function(){ + var item = this; var itemOffset = $(this).position().top; if(itemOffset <= 0 || scrolled >= scrollHeight){ - var itemId = parseInt($(this).data('id')); - if(News.Feed.processing[itemId] === undefined || News.Feed.processing[itemId] === false){ - // mark item as processing to prevent unecessary post requests - News.Feed.processing[itemId] = true; - var handler = new News.ItemStatusHandler(itemId); - handler.setRead(true); - } + // wait and check if the item is still under the top edge + setTimeout(function(){ markItemAsRead(scrollArea, item);}, 1000); } }) }); + + $('#feed_items').scrollTop(0); }); +/** + * Marks an item as read which is called by the timeout + * @param item the dom item + */ +function markItemAsRead(scrollArea, item){ + var itemId = parseInt($(item).data('id')); + var itemOffset = $(item).position().top; + var boxHeight = $(scrollArea).height(); + var scrollHeight = $(scrollArea).prop('scrollHeight'); + var scrolled = $(scrollArea).scrollTop() + boxHeight; + if(itemOffset < 0 || scrolled >= scrollHeight){ + console.log(itemOffset); + if(News.Feed.processing[itemId] === undefined || News.Feed.processing[itemId] === false){ + // mark item as processing to prevent unecessary post requests + News.Feed.processing[itemId] = true; + var handler = new News.ItemStatusHandler(itemId); + handler.setRead(true); + } + } +} + $(document).click(function(event) { $('#feedfoldermenu').hide(); }); |