mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 21:19:19 +00:00
downgrade keybindings.js to es5
This commit is contained in:
parent
5ec89f4041
commit
af2a01eea2
@ -18,7 +18,7 @@ function scrollto(target, scroll) {
|
|||||||
scroll.scrollTop = Math.round(newPos)
|
scroll.scrollTop = Math.round(newPos)
|
||||||
}
|
}
|
||||||
|
|
||||||
const helperFunctions = {
|
var helperFunctions = {
|
||||||
// navigation helper, navigate relative to selected item
|
// navigation helper, navigate relative to selected item
|
||||||
navigateToItem: function(relativePosition) {
|
navigateToItem: function(relativePosition) {
|
||||||
if (vm.itemSelected == null) {
|
if (vm.itemSelected == null) {
|
||||||
@ -75,20 +75,20 @@ const helperFunctions = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const shortcutFunctions = {
|
var shortcutFunctions = {
|
||||||
toggleItemRead: function() {
|
toggleItemRead: function() {
|
||||||
if(vm.itemSelected != null) {
|
if (vm.itemSelected != null) {
|
||||||
vm.toggleItemRead(vm.itemSelectedDetails)
|
vm.toggleItemRead(vm.itemSelectedDetails)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
markAllRead: function() {
|
markAllRead: function() {
|
||||||
// same condition as 'Mark all read button'
|
// same condition as 'Mark all read button'
|
||||||
if(vm.filterSelected == 'unread'){
|
if (vm.filterSelected == 'unread'){
|
||||||
vm.markItemsRead()
|
vm.markItemsRead()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleItemStarred: function() {
|
toggleItemStarred: function() {
|
||||||
if(vm.itemSelected != null) {
|
if (vm.itemSelected != null) {
|
||||||
vm.toggleItemStarred(vm.itemSelectedDetails)
|
vm.toggleItemStarred(vm.itemSelectedDetails)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -118,8 +118,8 @@ const shortcutFunctions = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you edit, make sure you update README.md and the help modal
|
// If you edit, make sure you update the help modal
|
||||||
const keybindings = {
|
var keybindings = {
|
||||||
"r": shortcutFunctions.toggleItemRead,
|
"r": shortcutFunctions.toggleItemRead,
|
||||||
"R": shortcutFunctions.markAllRead,
|
"R": shortcutFunctions.markAllRead,
|
||||||
"s": shortcutFunctions.toggleItemStarred,
|
"s": shortcutFunctions.toggleItemStarred,
|
||||||
@ -136,22 +136,22 @@ const keybindings = {
|
|||||||
function isTextBox(element) {
|
function isTextBox(element) {
|
||||||
var tagName = element.tagName.toLowerCase()
|
var tagName = element.tagName.toLowerCase()
|
||||||
// Input elements that aren't text
|
// Input elements that aren't text
|
||||||
const inputBlocklist = ['button','checkbox','color','file','hidden','image','radio','range','reset','search','submit']
|
var inputBlocklist = ['button','checkbox','color','file','hidden','image','radio','range','reset','search','submit']
|
||||||
|
|
||||||
return tagName === 'textarea' ||
|
return tagName === 'textarea' ||
|
||||||
( tagName === 'input'
|
( tagName === 'input'
|
||||||
&& !inputBlocklist.includes(element.getAttribute('type').toLowerCase())
|
&& inputBlocklist.indexOf(element.getAttribute('type').toLowerCase()) == -1
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('keydown',function(event) {
|
document.addEventListener('keydown',function(event) {
|
||||||
// Ignore while focused on text or
|
// Ignore while focused on text or
|
||||||
// when using modifier keys (to not clash with browser behaviour)
|
// when using modifier keys (to not clash with browser behaviour)
|
||||||
if(isTextBox(event.target) || event.metaKey || event.ctrlKey) {
|
if (isTextBox(event.target) || event.metaKey || event.ctrlKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const keybindFunction = keybindings[event.key]
|
var keybindFunction = keybindings[event.key]
|
||||||
if(keybindFunction) {
|
if (keybindFunction) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
keybindFunction()
|
keybindFunction()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user