mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-23 00:45:16 +00:00
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
|
var BLACKLIST = ['template', 'script', 'style'];
|
||
|
|
||
|
var isHidable = function isHidable(_ref) {
|
||
|
var nodeType = _ref.nodeType,
|
||
|
tagName = _ref.tagName;
|
||
|
return nodeType === 1 && BLACKLIST.indexOf(tagName.toLowerCase()) === -1;
|
||
|
};
|
||
|
|
||
|
var siblings = function siblings(container, exclude, cb) {
|
||
|
[].forEach.call(container.children, function (node) {
|
||
|
if (exclude.indexOf(node) === -1 && isHidable(node)) {
|
||
|
cb(node);
|
||
|
}
|
||
|
});
|
||
|
};
|
||
|
|
||
|
export function ariaHidden(hide, node) {
|
||
|
if (!node) return;
|
||
|
|
||
|
if (hide) {
|
||
|
node.setAttribute('aria-hidden', 'true');
|
||
|
} else {
|
||
|
node.removeAttribute('aria-hidden');
|
||
|
}
|
||
|
}
|
||
|
export function hideSiblings(container, _ref2) {
|
||
|
var dialog = _ref2.dialog,
|
||
|
backdrop = _ref2.backdrop;
|
||
|
siblings(container, [dialog, backdrop], function (node) {
|
||
|
return ariaHidden(true, node);
|
||
|
});
|
||
|
}
|
||
|
export function showSiblings(container, _ref3) {
|
||
|
var dialog = _ref3.dialog,
|
||
|
backdrop = _ref3.backdrop;
|
||
|
siblings(container, [dialog, backdrop], function (node) {
|
||
|
return ariaHidden(false, node);
|
||
|
});
|
||
|
}
|