mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
Add keyboard compatibility for older browsers (webOS 2/3)
This commit is contained in:
parent
1889dad8cc
commit
ec6ce5aa14
@ -27,6 +27,20 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||||||
10252: "MediaPlayPause" // MediaPlayPause (Tizen)
|
10252: "MediaPlayPause" // MediaPlayPause (Tizen)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var hasFieldKey = false;
|
||||||
|
try {
|
||||||
|
hasFieldKey = "key" in new KeyboardEvent("keydown");
|
||||||
|
} catch (e) {
|
||||||
|
console.log("error checking 'key' field");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasFieldKey) {
|
||||||
|
// Add [a..z]
|
||||||
|
for (var i = 65; i <= 90; i++) {
|
||||||
|
KeyNames[i] = String.fromCharCode(i).toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns key name from event.
|
* Returns key name from event.
|
||||||
*
|
*
|
||||||
@ -104,6 +118,7 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enable: enable
|
enable: enable,
|
||||||
|
getKeyName: getKeyName
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "mediaInfo", "focusManager", "imageLoader", "scrollHelper", "events", "connectionManager", "browser", "globalize", "apphost", "layoutManager", "userSettings", "scrollStyles", "emby-slider", "paper-icon-button-light", "css!assets/css/videoosd"], function (playbackManager, dom, inputManager, datetime, itemHelper, mediaInfo, focusManager, imageLoader, scrollHelper, events, connectionManager, browser, globalize, appHost, layoutManager, userSettings) {
|
define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "mediaInfo", "focusManager", "imageLoader", "scrollHelper", "events", "connectionManager", "browser", "globalize", "apphost", "layoutManager", "userSettings", "keyboardnavigation", "scrollStyles", "emby-slider", "paper-icon-button-light", "css!assets/css/videoosd"], function (playbackManager, dom, inputManager, datetime, itemHelper, mediaInfo, focusManager, imageLoader, scrollHelper, events, connectionManager, browser, globalize, appHost, layoutManager, userSettings, keyboardnavigation) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function seriesImageUrl(item, options) {
|
function seriesImageUrl(item, options) {
|
||||||
@ -1088,25 +1088,26 @@ define(["playbackManager", "dom", "inputManager", "datetime", "itemHelper", "med
|
|||||||
var NavigationKeys = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
|
var NavigationKeys = ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"];
|
||||||
|
|
||||||
function onWindowKeyDown(e) {
|
function onWindowKeyDown(e) {
|
||||||
|
var key = keyboardnavigation.getKeyName(e);
|
||||||
|
|
||||||
if (!currentVisibleMenu && 32 === e.keyCode) {
|
if (!currentVisibleMenu && 32 === e.keyCode) {
|
||||||
playbackManager.playPause(currentPlayer);
|
playbackManager.playPause(currentPlayer);
|
||||||
showOsd();
|
showOsd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layoutManager.tv && NavigationKeys.indexOf(e.key) != -1) {
|
if (layoutManager.tv && NavigationKeys.indexOf(key) != -1) {
|
||||||
showOsd();
|
showOsd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (e.key) {
|
switch (key) {
|
||||||
case "Enter":
|
case "Enter":
|
||||||
showOsd();
|
showOsd();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Escape":
|
case "Escape":
|
||||||
case "RCUBack": // WebOS back
|
case "Back":
|
||||||
case "XF86Back": // Tizen back
|
|
||||||
// Ignore key when some dialog is opened
|
// Ignore key when some dialog is opened
|
||||||
if (currentVisibleMenu === "osd" && !document.querySelector(".dialogContainer")) {
|
if (currentVisibleMenu === "osd" && !document.querySelector(".dialogContainer")) {
|
||||||
hideOsd();
|
hideOsd();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
define(['browser', 'dom', 'layoutManager', 'css!./emby-slider', 'registerElement', 'emby-input'], function (browser, dom, layoutManager) {
|
define(['browser', 'dom', 'layoutManager', 'keyboardnavigation', 'css!./emby-slider', 'registerElement', 'emby-input'], function (browser, dom, layoutManager, keyboardnavigation) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var EmbySliderPrototype = Object.create(HTMLInputElement.prototype);
|
var EmbySliderPrototype = Object.create(HTMLInputElement.prototype);
|
||||||
@ -250,7 +250,7 @@ define(['browser', 'dom', 'layoutManager', 'css!./emby-slider', 'registerElement
|
|||||||
* Handle KeyDown event
|
* Handle KeyDown event
|
||||||
*/
|
*/
|
||||||
function onKeyDown(e) {
|
function onKeyDown(e) {
|
||||||
switch (e.key) {
|
switch (keyboardnavigation.getKeyName(e)) {
|
||||||
case 'ArrowLeft':
|
case 'ArrowLeft':
|
||||||
case 'Left':
|
case 'Left':
|
||||||
stepKeyboard(this, -this.keyboardStepDown || -1);
|
stepKeyboard(this, -this.keyboardStepDown || -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user