mirror of
https://github.com/chylex/Nextcloud-News.git
synced 2025-04-09 10:15:44 +02:00
add s and i for starring item, u for keeping it unread, fix #52
This commit is contained in:
parent
4ca4b190c8
commit
cca3ff47f0
@ -78,6 +78,8 @@ Keyboard shortcuts
|
||||
------------------
|
||||
* **Next item**: n/j/right arrow
|
||||
* **Previous item**: p/k/left arrow
|
||||
* **Star current item**: s/i
|
||||
* **Keep current item unread**: u
|
||||
|
||||
Performance Notices
|
||||
-------------------
|
||||
|
@ -50,7 +50,7 @@
|
||||
*/
|
||||
.feed_item {
|
||||
border-top: 1px solid #ccc;
|
||||
min-height: 100px;
|
||||
min-height: 120px;
|
||||
background-image: linear-gradient(top, rgb(248,248,248) 0, rgb(255,255,255) 84px);
|
||||
background-image: -o-linear-gradient(top, rgb(248,248,248) 0, rgb(255,255,255) 84px);
|
||||
background-image: -moz-linear-gradient(top, rgb(248,248,248) 0, rgb(255,255,255) 84px);
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
]
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user