mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Widget: add unique html_id to use in labels, etc.
This commit is contained in:
committed by
GitHub
parent
e5f29bd592
commit
18801f2d1c
@@ -2028,7 +2028,7 @@ function get_ga_client_id(tracking_id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var create_widget = function (element) {
|
||||
var create_widget = function (element, html_id=null) {
|
||||
var target_url = element.attributes.event.value;
|
||||
if (!target_url.match(/\/$/)) {
|
||||
target_url += "/";
|
||||
@@ -2052,6 +2052,7 @@ var create_widget = function (element) {
|
||||
widget_data[attrib.name.replace(/^data-/, '')] = attrib.value;
|
||||
}
|
||||
}
|
||||
html_id = html_id || element.id || makeid(16);
|
||||
|
||||
var observer = new MutationObserver((mutationList) => {
|
||||
mutationList.forEach((mutation) => {
|
||||
@@ -2111,6 +2112,7 @@ var create_widget = function (element) {
|
||||
widget_data: widget_data,
|
||||
loading: 1,
|
||||
widget_id: 'pretix-widget-' + widget_id,
|
||||
html_id: html_id,
|
||||
vouchers_exist: false,
|
||||
disable_vouchers: disable_vouchers,
|
||||
disable_filters: disable_filters,
|
||||
@@ -2148,7 +2150,7 @@ var create_widget = function (element) {
|
||||
return app;
|
||||
};
|
||||
|
||||
var create_button = function (element) {
|
||||
var create_button = function (element, html_id=null) {
|
||||
var target_url = element.attributes.event.value;
|
||||
if (!target_url.match(/\/$/)) {
|
||||
target_url += "/";
|
||||
@@ -2166,6 +2168,7 @@ var create_button = function (element) {
|
||||
widget_data[attrib.name.replace(/^data-/, '')] = attrib.value;
|
||||
}
|
||||
}
|
||||
html_id = html_id || element.id || makeid(16);
|
||||
|
||||
var observer = new MutationObserver((mutationList) => {
|
||||
mutationList.forEach((mutation) => {
|
||||
@@ -2207,6 +2210,7 @@ var create_button = function (element) {
|
||||
frame_dismissed: false,
|
||||
widget_data: widget_data,
|
||||
widget_id: 'pretix-widget-' + widget_id,
|
||||
html_id: html_id,
|
||||
button_text: button_text
|
||||
}
|
||||
},
|
||||
@@ -2241,14 +2245,14 @@ window.PretixWidget.buildWidgets = function () {
|
||||
var wlength = widgets.length;
|
||||
for (var i = 0; i < wlength; i++) {
|
||||
var widget = widgets[i];
|
||||
widgetlist.push(create_widget(widget));
|
||||
widgetlist.push(create_widget(widget, widget.id || "pretix-widget-"+i));
|
||||
}
|
||||
|
||||
var buttons = document.querySelectorAll("pretix-button, div.pretix-button-compat");
|
||||
var blength = buttons.length;
|
||||
for (var i = 0; i < blength; i++) {
|
||||
var button = buttons[i];
|
||||
buttonlist.push(create_button(button));
|
||||
buttonlist.push(create_button(button, button.id || "pretix-button-"+i));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user