mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge remote-tracking branch 'upstream/master' into servernotifications-fixes
This commit is contained in:
commit
04a3505672
340 changed files with 3843 additions and 2552 deletions
|
@ -1,8 +1,6 @@
|
|||
define(["inputManager", "layoutManager"], function (inputManager, layoutManager) {
|
||||
"use strict";
|
||||
|
||||
console.log("keyboardnavigation");
|
||||
|
||||
/**
|
||||
* Key name mapping.
|
||||
*/
|
||||
|
@ -36,11 +34,16 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||
10252: "MediaPlayPause"
|
||||
};
|
||||
|
||||
/**
|
||||
* Keys used for keyboard navigation.
|
||||
*/
|
||||
var NavigationKeys = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
|
||||
|
||||
var hasFieldKey = false;
|
||||
try {
|
||||
hasFieldKey = "key" in new KeyboardEvent("keydown");
|
||||
} catch (e) {
|
||||
console.log("error checking 'key' field");
|
||||
console.error("error checking 'key' field");
|
||||
}
|
||||
|
||||
if (!hasFieldKey) {
|
||||
|
@ -60,11 +63,28 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||
return KeyNames[event.keyCode] || event.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns _true_ if key is used for navigation.
|
||||
*
|
||||
* @param {string} key name
|
||||
* @return {boolean} _true_ if key is used for navigation
|
||||
*/
|
||||
function isNavigationKey(key) {
|
||||
return NavigationKeys.indexOf(key) != -1;
|
||||
}
|
||||
|
||||
function enable() {
|
||||
document.addEventListener("keydown", function (e) {
|
||||
var key = getKeyName(e);
|
||||
|
||||
// Ignore navigation keys for non-TV
|
||||
if (!layoutManager.tv && isNavigationKey(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var capture = true;
|
||||
|
||||
switch (getKeyName(e)) {
|
||||
switch (key) {
|
||||
case "ArrowLeft":
|
||||
inputManager.handle("left");
|
||||
break;
|
||||
|
@ -120,7 +140,7 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||
}
|
||||
|
||||
if (capture) {
|
||||
console.log("Disabling default event handling");
|
||||
console.debug("disabling default event handling");
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
@ -159,6 +179,7 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||
|
||||
return {
|
||||
enable: enable,
|
||||
getKeyName: getKeyName
|
||||
getKeyName: getKeyName,
|
||||
isNavigationKey: isNavigationKey
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue