diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-25 12:55:19 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-25 12:55:19 +0200 |
commit | cca3ff47f0c88a6bf77def34a7d6fce11a359063 (patch) | |
tree | 1956042927aa68aa45d2efc2a1c26dab9029bde9 /js/public | |
parent | 4ca4b190c831163572491e1afbc42f2799652d76 (diff) |
add s and i for starring item, u for keeping it unread, fix #52
Diffstat (limited to 'js/public')
-rw-r--r-- | js/public/app.js | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/js/public/app.js b/js/public/app.js index 2962731f3..18aadc4c7 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -147,7 +147,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. angular.module('News').directive('itemShortcuts', [ '$window', function($window) { return function(scope, elm, attr) { - var jumpTo, jumpToNextItem, jumpToPreviousItem; + var getCurrentItem, jumpTo, jumpToNextItem, jumpToPreviousItem, keepUnreadCurrentItem, starCurrentItem; jumpTo = function($scrollArea, $item) { var position; @@ -195,6 +195,31 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. } return _results; }; + getCurrentItem = function(scrollArea) { + var $item, $items, $scrollArea, item, _i, _len; + + $scrollArea = $(scrollArea); + $items = $scrollArea.find('.feed_item'); + for (_i = 0, _len = $items.length; _i < _len; _i++) { + item = $items[_i]; + $item = $(item); + if (($item.height() + $item.position().top) > 110) { + return $item; + } + } + }; + keepUnreadCurrentItem = function(scrollArea) { + var $item; + + $item = getCurrentItem(scrollArea); + return $item.find('.keep_unread').trigger('click'); + }; + starCurrentItem = function(scrollArea) { + var $item; + + $item = getCurrentItem(scrollArea); + return $item.find('.star').trigger('click'); + }; return $($window.document).keydown(function(e) { var focused, scrollArea; @@ -205,6 +230,10 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>. return jumpToNextItem(scrollArea); } else if (e.keyCode === 75 || e.keyCode === 37 || e.keyCode === 80) { return jumpToPreviousItem(scrollArea); + } else if (e.keyCode === 85) { + return keepUnreadCurrentItem(scrollArea); + } else if (e.keyCode === 73 || e.keyCode === 83) { + return starCurrentItem(scrollArea); } } }); |