mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Script simplification: Greatly clarify element tracking logic
This commit is contained in:
parent
671dcfceb5
commit
b26fc15fa0
1 changed files with 10 additions and 12 deletions
|
|
@ -112,24 +112,22 @@
|
|||
const eventName = parentElement.getAttribute(eventNameAttribute);
|
||||
if (!eventName) return;
|
||||
|
||||
if (parentElement.tagName === 'A') {
|
||||
if (parentElement.tagName === 'BUTTON') {
|
||||
return trackElement(parentElement);
|
||||
}
|
||||
if (parentElement.tagName === 'A' && href) {
|
||||
const external =
|
||||
target === '_blank' ||
|
||||
e.ctrlKey ||
|
||||
e.shiftKey ||
|
||||
e.metaKey ||
|
||||
(e.button && e.button === 1);
|
||||
|
||||
if (eventName && href) {
|
||||
if (!external) e.preventDefault();
|
||||
return trackElement(parentElement).then(() => {
|
||||
if (!external) {
|
||||
(target === '_top' ? top.location : location).href = href;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (parentElement.tagName === 'BUTTON') {
|
||||
return trackElement(parentElement);
|
||||
if (!external) e.preventDefault();
|
||||
return trackElement(parentElement).then(() => {
|
||||
if (!external) {
|
||||
(target === '_top' ? top.location : location).href = href;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue