Widget: Introduce disable-iframe parameter

This commit is contained in:
Raphael Michel
2021-02-04 10:58:15 +01:00
parent 03f1016cc7
commit 7a496da945
2 changed files with 17 additions and 3 deletions

View File

@@ -88,6 +88,15 @@ website. If you confident to have a good reason for not using SSL, you can overr
<pretix-widget event="https://pretix.eu/demo/democon/" skip-ssl-check></pretix-widget> <pretix-widget event="https://pretix.eu/demo/democon/" skip-ssl-check></pretix-widget>
Always open a new tab
---------------------
If you want the checkout process to always open a new tab regardless of screen size, you can pass the ``disable-iframe``
attribute::
<pretix-widget event="https://pretix.eu/demo/democon/" disable-iframe></pretix-widget>
Pre-selecting a voucher Pre-selecting a voucher
----------------------- -----------------------
@@ -200,7 +209,7 @@ items, if the items have variations. If you omit the ``items`` attribute, the ge
In case you are using an event-series, you will need to specify the subevent for which the item(s) should be put in the In case you are using an event-series, you will need to specify the subevent for which the item(s) should be put in the
cart. This can be done by specifying the ``subevent``-attribute. cart. This can be done by specifying the ``subevent``-attribute.
Just as the widget, the button supports the optional attributes ``voucher`` and ``skip-ssl-check``. Just as the widget, the button supports the optional attributes ``voucher``, ``disable-iframe``, and ``skip-ssl-check``.
You can style the button using the ``pretix-button`` CSS class. You can style the button using the ``pretix-button`` CSS class.

View File

@@ -1503,7 +1503,7 @@ var shared_root_computed = {
return form_target return form_target
}, },
useIframe: function () { useIframe: function () {
return Math.min(screen.width, window.innerWidth) >= 800 && (this.skip_ssl || site_is_secure()); return !this.disable_iframe && Math.min(screen.width, window.innerWidth) >= 800 && (this.skip_ssl || site_is_secure());
}, },
showPrices: function () { showPrices: function () {
var has_priced = false; var has_priced = false;
@@ -1574,6 +1574,7 @@ var create_widget = function (element) {
var subevent = element.attributes.subevent ? element.attributes.subevent.value : null; var subevent = element.attributes.subevent ? element.attributes.subevent.value : null;
var style = element.attributes.style ? element.attributes.style.value : null; var style = element.attributes.style ? element.attributes.style.value : null;
var skip_ssl = element.attributes["skip-ssl-check"] ? true : false; var skip_ssl = element.attributes["skip-ssl-check"] ? true : false;
var disable_iframe = element.attributes["disable-iframe"] ? true : false;
var disable_vouchers = element.attributes["disable-vouchers"] ? true : false; var disable_vouchers = element.attributes["disable-vouchers"] ? true : false;
var widget_data = JSON.parse(JSON.stringify(window.PretixWidget.widget_data)); var widget_data = JSON.parse(JSON.stringify(window.PretixWidget.widget_data));
var filter = element.attributes.filter ? element.attributes.filter.value : null; var filter = element.attributes.filter ? element.attributes.filter.value : null;
@@ -1611,6 +1612,7 @@ var create_widget = function (element) {
voucher_explanation_text: null, voucher_explanation_text: null,
show_variations_expanded: false, show_variations_expanded: false,
skip_ssl: skip_ssl, skip_ssl: skip_ssl,
disable_iframe: disable_iframe,
style: style, style: style,
error: null, error: null,
weeks: null, weeks: null,
@@ -1652,6 +1654,7 @@ var create_button = function (element) {
var subevent = element.attributes.subevent ? element.attributes.subevent.value : null; var subevent = element.attributes.subevent ? element.attributes.subevent.value : null;
var raw_items = element.attributes.items ? element.attributes.items.value : ""; var raw_items = element.attributes.items ? element.attributes.items.value : "";
var skip_ssl = element.attributes["skip-ssl-check"] ? true : false; var skip_ssl = element.attributes["skip-ssl-check"] ? true : false;
var disable_iframe = element.attributes["disable-iframe"] ? true : false;
var button_text = element.innerHTML; var button_text = element.innerHTML;
var widget_data = JSON.parse(JSON.stringify(window.PretixWidget.widget_data)); var widget_data = JSON.parse(JSON.stringify(window.PretixWidget.widget_data));
for (var i = 0; i < element.attributes.length; i++) { for (var i = 0; i < element.attributes.length; i++) {
@@ -1682,6 +1685,7 @@ var create_button = function (element) {
subevent: subevent, subevent: subevent,
is_button: true, is_button: true,
skip_ssl: skip_ssl, skip_ssl: skip_ssl,
disable_iframe: disable_iframe,
voucher_code: voucher, voucher_code: voucher,
items: items, items: items,
error: null, error: null,
@@ -1728,7 +1732,7 @@ window.PretixWidget.buildWidgets = function () {
}); });
}; };
window.PretixWidget.open = function (target_url, voucher, subevent, items, widget_data, skip_ssl_check) { window.PretixWidget.open = function (target_url, voucher, subevent, items, widget_data, skip_ssl_check, disable_iframe) {
if (!target_url.match(/\/$/)) { if (!target_url.match(/\/$/)) {
target_url += "/"; target_url += "/";
} }
@@ -1749,6 +1753,7 @@ window.PretixWidget.open = function (target_url, voucher, subevent, items, widge
subevent: subevent || null, subevent: subevent || null,
is_button: true, is_button: true,
skip_ssl: skip_ssl_check || false, skip_ssl: skip_ssl_check || false,
disable_iframe: disable_iframe || false,
voucher_code: voucher || null, voucher_code: voucher || null,
items: items || [], items: items || [],
error: null, error: null,