mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Add loading callback to widget
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user