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/app/directives | |
parent | 4ca4b190c831163572491e1afbc42f2799652d76 (diff) |
add s and i for starring item, u for keeping it unread, fix #52
Diffstat (limited to 'js/app/directives')
-rw-r--r-- | js/app/directives/itemshortcuts.coffee | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/app/directives/itemshortcuts.coffee b/js/app/directives/itemshortcuts.coffee index f80045d42..7c27b281a 100644 --- a/js/app/directives/itemshortcuts.coffee +++ b/js/app/directives/itemshortcuts.coffee @@ -59,6 +59,27 @@ angular.module('News').directive 'itemShortcuts', ['$window', ($window) -> break + getCurrentItem = (scrollArea) -> + $scrollArea = $(scrollArea) + $items = $scrollArea.find('.feed_item') + for item in $items + $item = $(item) + # 130px of the item should be visible + if ($item.height() + $item.position().top) > 110 + return $item + + + keepUnreadCurrentItem = (scrollArea) -> + $item = getCurrentItem(scrollArea) + $item.find('.keep_unread').trigger('click') + + + starCurrentItem = (scrollArea) -> + $item = getCurrentItem(scrollArea) + $item.find('.star').trigger('click') + + + $($window.document).keydown (e) -> # only activate if no input elements is focused focused = $(':focus') @@ -78,5 +99,15 @@ angular.module('News').directive 'itemShortcuts', ['$window', ($window) -> else if e.keyCode == 75 or e.keyCode == 37 or e.keyCode == 80 jumpToPreviousItem(scrollArea) + # u + else if e.keyCode == 85 + keepUnreadCurrentItem(scrollArea) + + # s or i + else if e.keyCode == 73 or e.keyCode == 83 + starCurrentItem(scrollArea) + + + ]
\ No newline at end of file |