mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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)
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
Reference in New Issue
Block a user