Add loading callback to widget

This commit is contained in:
Raphael Michel
2019-10-23 15:09:20 +02:00
parent 277b7ad71c
commit 08460f9918
2 changed files with 29 additions and 0 deletions

View File

@@ -784,6 +784,7 @@ Vue.component('pretix-widget-event-form', {
this.$root.target_url = this.$root.parent_stack.pop();
this.$root.error = null;
this.$root.subevent = null;
this.$root.trigger_load_callback();
if (this.$root.events !== undefined) {
this.$root.view = "events";
} else {
@@ -1086,6 +1087,13 @@ var shared_root_methods = {
return;
}
},
trigger_load_callback: function () {
this.$nextTick(function () {
for (var i = 0; i < window.PretixWidget._loaded.length; i++) {
window.PretixWidget._loaded[i]()
}
});
},
reload: function () {
var url;
if (this.$root.subevent) {
@@ -1148,6 +1156,7 @@ var shared_root_methods = {
}
if (root.loading > 0) {
root.loading--;
root.trigger_load_callback();
}
}, function (error) {
root.categories = [];
@@ -1155,6 +1164,7 @@ var shared_root_methods = {
root.error = strings['loading_error'];
if (root.loading > 0) {
root.loading--;
root.trigger_load_callback();
}
});
},
@@ -1385,6 +1395,10 @@ var create_button = function (element) {
/* Find all widgets on the page and render them */
widgetlist = [];
buttonlist = [];
window.PretixWidget._loaded = [];
window.PretixWidget.addLoadListener = function (f) {
window.PretixWidget._loaded.push(f);
}
window.PretixWidget.buildWidgets = function () {
document.createElement("pretix-widget");
document.createElement("pretix-button");