summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-09-19 22:39:30 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-09-19 22:39:38 +0200
commit5ead2af71798670854217888ba178ba7861f2989 (patch)
tree0c29fe265b327f758e373621f2c800220ad00395 /js
parent48f3774c9709cb341ea07b63e1fa34b02ef24472 (diff)
open all links from the feedbody in a new tab
Diffstat (limited to 'js')
-rw-r--r--js/items.js42
1 files changed, 23 insertions, 19 deletions
diff --git a/js/items.js b/js/items.js
index dbe8ca811..8541b0031 100644
--- a/js/items.js
+++ b/js/items.js
@@ -53,7 +53,7 @@ var News = News || {};
var item = this;
var itemOffset = $(item).position().top;
if(itemOffset <= 0){
- setTimeout(function(){
+ setTimeout(function(){
self._markItemAsReadTimeout(item);
}, self._markReadTimeoutMiliSecs);
}
@@ -63,7 +63,7 @@ var News = News || {};
});
this._itemCache.populate(this._$articleList.children('ul'));
- }
+ };
/**
* Marks an item as read which is called by the timeout
@@ -72,14 +72,14 @@ var News = News || {};
Items.prototype._markItemAsReadTimeout = function(item) {
var itemId = parseInt($(item).data('id'));
var itemOffset = $(item).position().top;
- var item = this._itemCache.getItem(itemId);
+ var cachedItem = this._itemCache.getItem(itemId);
if(itemOffset < 0){
- if(!item.isLocked()){
+ if(!cachedItem.isLocked()){
// lock item to prevent massive request when scrolling
- item.setLocked(true);
- item.setRead(true);
+ cachedItem.setLocked(true);
+ cachedItem.setRead(true);
}
- }
+ }
};
/**
@@ -107,7 +107,7 @@ var News = News || {};
// the post finishes later
if(self._lastActiveFeedType === type && self._lastActiveFeedId === id){
if(jsonData.status == 'success'){
- self._$articleList.empty() // FIXME: does this also removed cached items?
+ self._$articleList.empty(); // FIXME: does this also removed cached items?
self._itemCache.populate(jsonData.data.feedItems);
var $items = self._itemCache.getFeedHtml(type, id);
@@ -162,7 +162,7 @@ var News = News || {};
var $items = $('.feed_item');
if($items.length > 0){
var id = parseInt($items.last().data('id'));
- self._jumpToElemenId(id);
+ self._jumpToElemenId(id);
}
}
};
@@ -204,12 +204,12 @@ var News = News || {};
this._markCurrentlyViewed();
};
- /**
+ /**
* Adds padding to the bottom to be able to scroll the last element beyond
* the top area
*/
Items.prototype._setScrollBottom = function() {
- var padding = this._$articleList.height() - 80;
+ var padding = this._$articleList.height() - 80;
this._$articleList.children('ul').css('padding-bottom', padding + 'px');
};
@@ -252,7 +252,7 @@ var News = News || {};
var ItemCache = function() {
this._items = {};
this._feeds = {};
- }
+ };
/**
* Returns an item from the cache
@@ -269,10 +269,11 @@ var News = News || {};
* @param id the id
*/
ItemCache.prototype.markAllRead = function(type, id) {
+ var itemId;
var ids = this._getItemIdTimestampPairs(type, id);
for(var i=0; i<ids.length; i++){
- var id = ids[i].key;
- this._items[id].setReadLocally();
+ itemId = ids[i].key;
+ this._items[itemId].setReadLocally();
}
};
@@ -301,7 +302,7 @@ var News = News || {};
ItemCache.prototype._getItemIdTimestampPairs = function(type, id) {
- var pairs = new Array();
+ var pairs = [];
if(Object.keys(this._feeds).length === 0 || Object.keys(this._items).length === 0){
return pairs;
}
@@ -416,11 +417,14 @@ var News = News || {};
this._read = this._$html.hasClass('read');
this._locked = false;
this._important = this._$html.find('li.star').hasClass('important');
+ // get timestamp for sorting
var $stamp = this._$html.find('.timestamp');
this._timestamp = parseInt($stamp.html());
$stamp.remove();
+ // open all links in new tabs
+ this._$html.find('.body a').attr('target', '_blank');
this._bindItemEventListeners();
- }
+ };
/**
* @return the id of the item
@@ -520,8 +524,8 @@ var News = News || {};
if(read && this._isKeptUnread()){
this.setLocked(false);
- return;
- }
+ return;
+ }
if(read){
status = 'read';
@@ -602,7 +606,7 @@ var News = News || {};
Item.prototype._toggleKeepUnread = function() {
var checkBox = this._$html.find('.keep_unread input[type=checkbox]');
if(this._isKeptUnread()){
- this._$html.removeClass('keep_unread');
+ this._$html.removeClass('keep_unread');
checkBox.prop("checked", false);
} else {
this.setRead(false);