mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Disable AutoFocuser on non-TV layouts
This commit is contained in:
parent
3962dcf58e
commit
e588edbcca
1 changed files with 17 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
define(["focusManager"], function (focusManager) {
|
define(["focusManager", "layoutManager"], function (focusManager, layoutManager) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,10 +6,21 @@ define(["focusManager"], function (focusManager) {
|
||||||
*/
|
*/
|
||||||
var activeElement;
|
var activeElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if AutoFocuser is enabled.
|
||||||
|
*/
|
||||||
|
function isEnabled() {
|
||||||
|
return layoutManager.tv;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start AutoFocuser
|
* Start AutoFocuser
|
||||||
*/
|
*/
|
||||||
function enable() {
|
function enable() {
|
||||||
|
if (!isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener("focusin", function (e) {
|
window.addEventListener("focusin", function (e) {
|
||||||
activeElement = e.target;
|
activeElement = e.target;
|
||||||
});
|
});
|
||||||
|
@ -21,6 +32,10 @@ define(["focusManager"], function (focusManager) {
|
||||||
* Set focus on a suitable element, taking into account the previously selected.
|
* Set focus on a suitable element, taking into account the previously selected.
|
||||||
*/
|
*/
|
||||||
function autoFocus(container) {
|
function autoFocus(container) {
|
||||||
|
if (!isEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
container = container || document.body;
|
container = container || document.body;
|
||||||
|
|
||||||
var candidates = [];
|
var candidates = [];
|
||||||
|
@ -67,6 +82,7 @@ define(["focusManager"], function (focusManager) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isEnabled: isEnabled,
|
||||||
enable: enable,
|
enable: enable,
|
||||||
autoFocus: autoFocus
|
autoFocus: autoFocus
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue