mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
add ui
This commit is contained in:
1 parent
777a4bc927
commit
9c45527522
396 files changed
+13772
No files matched your search
@@ -0,0 +1,30 @@
|
||||
import { AutoloadPage } from 'vj/misc/PageLoader';
|
||||
import Tooltip from './Tooltip';
|
||||
|
||||
function getClosestTooltipElement(element) {
|
||||
const MAX_DEPTH = 3;
|
||||
for (let i = 0, e = element; i < MAX_DEPTH && e !== null && e !== document; e = e.parentNode, i++) {
|
||||
if (e.getAttribute('data-tooltip')) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
const tooltipPage = new AutoloadPage('tooltipPage', () => {
|
||||
$(document).on('mouseover', (e) => {
|
||||
const element = getClosestTooltipElement(e.target);
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
const $element = $(element);
|
||||
const options = {};
|
||||
if ($element.attr('data-tooltip-pos')) {
|
||||
options.position = $element.attr('data-tooltip-pos');
|
||||
}
|
||||
const tooltip = Tooltip.getOrConstruct($element, options);
|
||||
tooltip.open();
|
||||
});
|
||||
});
|
||||
|
||||
export default tooltipPage;
|
||||
Reference in new issue
Block a user