зеркало из https://github.com/nextcloud/news.git
fix shortcuts and add shortcut to expand current item
This commit is contained in:
Родитель
8f6ad4aaa7
Коммит
84b5be7f0b
|
@ -128,7 +128,7 @@ Keyboard shortcuts
|
|||
* **Keep current item unread**: u
|
||||
* **Star item and jump to next one**: h
|
||||
* **Open current item**: o
|
||||
|
||||
* **Toggle expand of current item in compact view**: e
|
||||
|
||||
Performance Notices
|
||||
-------------------
|
||||
|
|
|
@ -65,14 +65,13 @@ angular.module('News').directive 'itemShortcuts', ['$window', ($window) ->
|
|||
$scrollArea.scrollTop($scrollArea.prop('scrollHeight'))
|
||||
|
||||
|
||||
|
||||
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
|
||||
if ($item.height() + $item.position().top) > 30
|
||||
return $item
|
||||
|
||||
|
||||
|
@ -85,6 +84,10 @@ angular.module('News').directive 'itemShortcuts', ['$window', ($window) ->
|
|||
$item = getCurrentItem(scrollArea)
|
||||
$item.find('.star').trigger('click')
|
||||
|
||||
expandCurrentItem = (scrollArea) ->
|
||||
$item = getCurrentItem(scrollArea)
|
||||
$item.find('.item_heading a').trigger('click')
|
||||
|
||||
|
||||
openCurrentItem = (scrollArea) ->
|
||||
$item = getCurrentItem(scrollArea).find('.item_title a')
|
||||
|
@ -118,6 +121,11 @@ angular.module('News').directive 'itemShortcuts', ['$window', ($window) ->
|
|||
e.preventDefault()
|
||||
keepUnreadCurrentItem(scrollArea)
|
||||
|
||||
# e
|
||||
else if e.keyCode == 69
|
||||
e.preventDefault()
|
||||
expandCurrentItem(scrollArea)
|
||||
|
||||
# s or i or l
|
||||
else if e.keyCode == 73 or e.keyCode == 83 or e.keyCode == 76
|
||||
e.preventDefault()
|
||||
|
|
|
@ -196,7 +196,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 getCurrentItem, jumpTo, jumpToNextItem, jumpToPreviousItem, keepUnreadCurrentItem, openCurrentItem, starCurrentItem;
|
||||
var expandCurrentItem, getCurrentItem, jumpTo, jumpToNextItem, jumpToPreviousItem, keepUnreadCurrentItem, openCurrentItem, starCurrentItem;
|
||||
jumpTo = function($scrollArea, $item) {
|
||||
var position;
|
||||
position = $item.offset().top - $scrollArea.offset().top + $scrollArea.scrollTop();
|
||||
|
@ -248,7 +248,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
for (_i = 0, _len = $items.length; _i < _len; _i++) {
|
||||
item = $items[_i];
|
||||
$item = $(item);
|
||||
if (($item.height() + $item.position().top) > 110) {
|
||||
if (($item.height() + $item.position().top) > 30) {
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
@ -263,6 +263,11 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
$item = getCurrentItem(scrollArea);
|
||||
return $item.find('.star').trigger('click');
|
||||
};
|
||||
expandCurrentItem = function(scrollArea) {
|
||||
var $item;
|
||||
$item = getCurrentItem(scrollArea);
|
||||
return $item.find('.item_heading a').trigger('click');
|
||||
};
|
||||
openCurrentItem = function(scrollArea) {
|
||||
var $item;
|
||||
$item = getCurrentItem(scrollArea).find('.item_title a');
|
||||
|
@ -283,6 +288,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|||
} else if (e.keyCode === 85) {
|
||||
e.preventDefault();
|
||||
return keepUnreadCurrentItem(scrollArea);
|
||||
} else if (e.keyCode === 69) {
|
||||
e.preventDefault();
|
||||
return expandCurrentItem(scrollArea);
|
||||
} else if (e.keyCode === 73 || e.keyCode === 83 || e.keyCode === 76) {
|
||||
e.preventDefault();
|
||||
return starCurrentItem(scrollArea);
|
||||
|
|
Загрузка…
Ссылка в новой задаче