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

@@ -26,38 +26,3 @@
@endisset
</div>
</div>
@once
<script>
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)
}
}));
});
</script>
@endonce

View File

@@ -76,7 +76,7 @@
});
var ajax_url = "{{ url('/ajax') }}";
</script>
<script src="{{ asset('js/librenms.js?ver=22052024') }}"></script>
<script src="{{ asset('js/librenms.js?ver=29092024') }}"></script>
<script type="text/javascript" src="{{ asset('js/overlib_mini.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/toastr.min.js?ver=05072021') }}"></script>
<script type="text/javascript" src="{{ asset('js/boot.js?ver=10272021') }}"></script>