Fix popup javascript (#16459)

Breaking out the code to a script tab seems to have interacted poorly with some code.
Put it in librenms.js for now to avoid issues.
This commit is contained in:
Tony Murray
2024-09-29 18:40:22 -05:00
committed by GitHub
parent cf897d278e
commit 615a5ab92c
3 changed files with 34 additions and 36 deletions

View File

@@ -728,3 +728,36 @@ function popUp(URL)
{
window.open(URL, '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=600');
}
// popup component javascript. Hopefully temporary.
document.addEventListener("alpine:init", () => {
Alpine.data("popup", () => ({
popupShow: false,
showTimeout: null,
hideTimeout: null,
ignoreNextShownEvent: false,
delay: 300,
show(timeout) {
clearTimeout(this.hideTimeout);
this.showTimeout = setTimeout(() => {
this.popupShow = true;
Popper.createPopper(this.$refs.targetRef, this.$refs.popupRef, {
padding: 8
});
// close other popups, except this one
this.ignoreNextShownEvent = true;
this.$dispatch('librenms-popup-shown', this.$el);
}, timeout);
},
hide(timeout) {
if (this.ignoreNextShownEvent) {
this.ignoreNextShownEvent = false;
return;
}
clearTimeout(this.showTimeout);
this.hideTimeout = setTimeout(() => this.popupShow = false, timeout)
}
}));
});