Widget: Introduce addCloseListener (#2569)

This commit is contained in:
Maico Timmerman
2022-04-05 11:04:54 +02:00
committed by GitHub
parent 6768bbb486
commit 4b0c38e4ee
2 changed files with 20 additions and 5 deletions

View File

@@ -747,6 +747,7 @@ Vue.component('pretix-overlay', {
this.$root.frame_shown = false;
this.$root.parent.frame_dismissed = true;
this.$root.parent.reload();
this.$root.trigger_close_callback();
},
iframeLoaded: function () {
if (this.$root.frame_loading) {
@@ -1368,6 +1369,13 @@ var shared_root_methods = {
}
});
},
trigger_close_callback: function () {
this.$nextTick(function () {
for (var i = 0; i < window.PretixWidget._closed.length; i++) {
window.PretixWidget._closed[i]()
}
});
},
reload: function () {
var url;
if (this.$root.is_button) {
@@ -1791,9 +1799,13 @@ var create_button = function (element) {
widgetlist = [];
buttonlist = [];
window.PretixWidget._loaded = [];
window.PretixWidget._closed = [];
window.PretixWidget.addLoadListener = function (f) {
window.PretixWidget._loaded.push(f);
}
window.PretixWidget.addCloseListener = function (f) {
window.PretixWidget._closed.push(f);
}
window.PretixWidget.buildWidgets = function () {
document.createElement("pretix-widget");
document.createElement("pretix-button");