mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
use shared helper
This commit is contained in:
parent
5a44186eb5
commit
3460f6708d
4 changed files with 14 additions and 66 deletions
|
@ -1,4 +1,4 @@
|
|||
define([], function () {
|
||||
define(['dom'], function (dom) {
|
||||
|
||||
function autoFocus(view, defaultToFirst) {
|
||||
|
||||
|
@ -194,7 +194,7 @@ define([], function () {
|
|||
return;
|
||||
}
|
||||
|
||||
var focusableContainer = parentWithClass(activeElement, 'focusable');
|
||||
var focusableContainer = dom.parentWithClass(activeElement, 'focusable');
|
||||
|
||||
var doc = activeElement.ownerDocument;
|
||||
var windowData = getWindowData(doc.defaultView, doc.documentElement);
|
||||
|
@ -273,9 +273,9 @@ define([], function () {
|
|||
var nearestElement = nearest[0].node;
|
||||
|
||||
// See if there's a focusable container, and if so, send the focus command to that
|
||||
var nearestElementFocusableParent = parentWithClass(nearestElement, 'focusable');
|
||||
var nearestElementFocusableParent = dom.parentWithClass(nearestElement, 'focusable');
|
||||
if (nearestElementFocusableParent && nearestElementFocusableParent != nearestElement && activeElement) {
|
||||
if (parentWithClass(activeElement, 'focusable') != nearestElementFocusableParent) {
|
||||
if (dom.parentWithClass(activeElement, 'focusable') != nearestElementFocusableParent) {
|
||||
nearestElement = nearestElementFocusableParent;
|
||||
}
|
||||
}
|
||||
|
@ -283,19 +283,6 @@ define([], function () {
|
|||
}
|
||||
}
|
||||
|
||||
function parentWithClass(elem, className) {
|
||||
|
||||
while (!elem.classList || !elem.classList.contains(className)) {
|
||||
elem = elem.parentNode;
|
||||
|
||||
if (!elem) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
function intersectsInternal(a1, a2, b1, b2) {
|
||||
|
||||
return (b1 >= a1 && b1 <= a2) || (b2 >= a1 && b2 <= a2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue