summaryrefslogtreecommitdiffstats
path: root/js/items.js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-09-03 00:25:51 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-09-03 00:26:04 +0200
commit144da1ca88f905910b9be63b8710ccab16a04df2 (patch)
tree9eea83286422533b2eb3a855cadd4363ab4c42a5 /js/items.js
parentf8ce1854ba4678c001cb317329bde46008dcd1ea (diff)
j jumps to next entry, k to previous if no dialog is open
Diffstat (limited to 'js/items.js')
-rw-r--r--js/items.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/js/items.js b/js/items.js
index 87f79ae0b..146f70a01 100644
--- a/js/items.js
+++ b/js/items.js
@@ -106,6 +106,56 @@ var t = t || function(app, string){ return string; }; // mock translation for lo
};
/**
+ * Jumps to the next visible element
+ */
+ Items.prototype.jumpToNext = function() {
+ var self = this;
+ var notJumped = true;
+ $('.feed_item').each(function(){
+ if(notJumped && $(this).position().top > 1){
+ console.log(this);
+ self._jumpToElemenId($(this).data('id'));
+ notJumped = false;
+ }
+ });
+ };
+
+ /**
+ * Jumps to the previous visible element
+ */
+ Items.prototype.jumpToPrevious = function() {
+ var self = this;
+ var notJumped = true;
+ $('.feed_item').each(function(){
+ if(notJumped && $(this).position().top >= 0){
+ var previous = $(this).prev();
+ if(previous.length > 0){
+ self._jumpToElemenId(previous.data('id'));
+ }
+ notJumped = false;
+ }
+ });
+ };
+
+ /**
+ * Jump to the next element in the list
+ * @param $elem the jquery elem to which we want to jump
+ */
+ Items.prototype._getNextJump = function($elem){
+ return $elem.position().top > 1;
+ }
+
+ /**
+ * Jumps to an element in the article list
+ * @param number the number of the item starting with 0
+ */
+ Items.prototype._jumpToElemenId = function(id) {
+ this._$articleList.scrollTop(
+ $('.feed_item[data-id=' + id + ']').offset().top -
+ this._$articleList.offset().top + this._$articleList.scrollTop());
+ };
+
+ /**
* Empties the item cache
*/
Items.prototype.emptyItemCache = function() {