mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add helpers
This commit is contained in:
parent
91b07f9cc7
commit
d7bb32b760
6 changed files with 76 additions and 110 deletions
47
dashboard-ui/bower_components/emby-webcomponents/dom.js
vendored
Normal file
47
dashboard-ui/bower_components/emby-webcomponents/dom.js
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
define([], function () {
|
||||
|
||||
function parentWithAttribute(elem, name, value) {
|
||||
|
||||
while ((value ? elem.getAttribute(name) != value : !elem.getAttribute(name))) {
|
||||
elem = elem.parentNode;
|
||||
|
||||
if (!elem || !elem.getAttribute) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
function parentWithTag(elem, tagName) {
|
||||
|
||||
while (elem.tagName != tagName) {
|
||||
elem = elem.parentNode;
|
||||
|
||||
if (!elem) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
function parentWithClass(elem, className) {
|
||||
|
||||
while (!elem.classList || !elem.classList.contains(className)) {
|
||||
elem = elem.parentNode;
|
||||
|
||||
if (!elem) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
return {
|
||||
parentWithAttribute: parentWithAttribute,
|
||||
parentWithClass: parentWithClass,
|
||||
parentWithTag: parentWithTag
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue