From b5fb48a55fbb5baff82fbcb63081b58630b969aa Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 30 Jul 2019 14:16:33 +0200 Subject: [PATCH] Widget: Remove confusion with resuming sessions --- .../static/pretixpresale/js/widget/widget.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/widget/widget.js b/src/pretix/static/pretixpresale/js/widget/widget.js index 1e3e4031b4..7988b4f7ae 100644 --- a/src/pretix/static/pretixpresale/js/widget/widget.js +++ b/src/pretix/static/pretixpresale/js/widget/widget.js @@ -462,7 +462,7 @@ var shared_methods = { return; } if (this.$root.is_button && this.$root.items.length === 0) { - this.resume(this.$root.voucher_code); + this.voucher_open(this.$root.voucher_code); } else { var url = this.$root.formTarget + "&locale=" + lang + "&ajax=1"; this.$root.overlay.frame_loading = true; @@ -546,15 +546,25 @@ var shared_methods = { this.$root.overlay.frame_loading = true; iframe.src = redirect_url; }, + voucher_open: function (voucher) { + var redirect_url; + redirect_url = this.$root.voucherFormTarget + '&voucher=' + voucher; + if (this.$root.widget_data) { + redirect_url += '&widget_data=' + escape(this.$root.widget_data_json); + } + if (this.$root.useIframe) { + var iframe = this.$root.overlay.$children[0].$refs['frame-container'].children[0]; + this.$root.overlay.frame_loading = true; + iframe.src = redirect_url; + } else { + window.open(redirect_url); + } + }, resume: function (voucher) { var redirect_url; - if (voucher) { - redirect_url = this.$root.voucherFormTarget + '&voucher=' + voucher; - } else { - redirect_url = this.$root.target_url + 'w/' + widget_id + '/?iframe=1&locale=' + lang; - if (this.$root.cart_id) { - redirect_url += '&take_cart_id=' + this.$root.cart_id; - } + redirect_url = this.$root.target_url + 'w/' + widget_id + '/?iframe=1&locale=' + lang; + if (this.$root.cart_id) { + redirect_url += '&take_cart_id=' + this.$root.cart_id; } if (this.$root.widget_data) { redirect_url += '&widget_data=' + escape(this.$root.widget_data_json);