mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
Widget: fix running different versions of Vue on the same page
This commit is contained in:
committed by
GitHub
parent
9efb1653ee
commit
66ae5d1af2
@@ -11,7 +11,6 @@ window.PretixWidget = {
|
||||
};
|
||||
|
||||
var Vue = module.exports;
|
||||
Vue.component('resize-observer', VueResize.ResizeObserver)
|
||||
|
||||
var strings = {
|
||||
'quantity': django.pgettext('widget', 'Quantity'),
|
||||
@@ -736,9 +735,6 @@ var shared_methods = {
|
||||
window.open(redirect_url);
|
||||
}
|
||||
},
|
||||
handleResize: function () {
|
||||
this.mobile = this.$refs.wrapper.clientWidth <= 800;
|
||||
}
|
||||
};
|
||||
|
||||
var shared_widget_data = function () {
|
||||
@@ -1493,7 +1489,6 @@ Vue.component('pretix-widget-event-week-calendar', {
|
||||
Vue.component('pretix-widget', {
|
||||
template: ('<div class="pretix-widget-wrapper" ref="wrapper">'
|
||||
+ '<div :class="classObject">'
|
||||
+ '<resize-observer @notify="handleResize" />'
|
||||
+ shared_loading_fragment
|
||||
+ '<div class="pretix-widget-error-message" v-if="$root.error && $root.view !== \'event\'">{{ $root.error }}</div>'
|
||||
+ '<div class="pretix-widget-error-action" v-if="$root.error && $root.connection_error"><a :href="$root.newTabTarget" class="pretix-widget-button" target="_blank">'
|
||||
@@ -1513,7 +1508,22 @@ Vue.component('pretix-widget', {
|
||||
data: shared_widget_data,
|
||||
methods: shared_methods,
|
||||
mounted: function () {
|
||||
this.mobile = this.$refs.wrapper.clientWidth <= 600;
|
||||
var thisObj = this;
|
||||
if ("ResizeObserver" in window) {
|
||||
var resizeObserver = new ResizeObserver(function(entries) {
|
||||
thisObj.mobile = entries[0].contentRect.width <= 800;
|
||||
});
|
||||
resizeObserver.observe(this.$refs.wrapper);
|
||||
} else {
|
||||
this.mobile = this.$refs.wrapper.clientWidth <= 800;
|
||||
var debounce;
|
||||
window.addEventListener("resize", function() {
|
||||
if (debounce) clearTimeout(debounce);
|
||||
debounce = setTimeout(function () {
|
||||
thisObj.mobile = thisObj.$refs.wrapper.clientWidth <= 800;
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classObject: function () {
|
||||
|
||||
@@ -1000,6 +1000,3 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/Akryum/vue-resize/blob/master/dist/vue-resize.css
|
||||
.resize-observer[data-v-b329ee4c]{position:absolute;top:0;left:0;z-index:-1;width:100%;height:100%;border:none;background-color:transparent;pointer-events:none;display:block;overflow:hidden;opacity:0}.resize-observer[data-v-b329ee4c] object{display:block;position:absolute;top:0;left:0;height:100%;width:100%;overflow:hidden;pointer-events:none;z-index:-1}
|
||||
|
||||
Reference in New Issue
Block a user