#49 Added base implementation to change tooltip direction

This commit is contained in:
Serraniel 2020-11-15 20:57:21 +01:00
parent be9fdf2448
commit fbddc2bebc
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -10,9 +10,24 @@ export function init() {
core.registerScript(node => { core.registerScript(node => {
// run the scripts // run the scripts
if (helper.isHtmlElement(node)) { if (helper.isHtmlElement(node)) {
if (node.tagName === TOOLTIP_TAG_NAME) {
changeTooltipDirection(node);
}
else {
node.querySelectorAll(TOOLTIP_TAG_NAME).forEach(tooltip => changeTooltipDirection(tooltip));
}
} }
}, "^/profile/[0-9]*\?tab=6$"); }, "^/profile/[0-9]*\?tab=6$");
} }
}); });
} }
function changeTooltipDirection(tooltip) {
const DIRECTION_ATTRIBUTE = 'md-direction';
let directionStr = tooltip.getAttribute(DIRECTION_ATTRIBUTE);
if (directionStr === 'top') {
tooltip.setAttribute(DIRECTION_ATTRIBUTE, 'right');
}
}