mirror of
https://github.com/pretix/pretix.git
synced 2026-02-11 03:32:26 +00:00
Compare commits
2 Commits
fix-addon-
...
fix-copy-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a669ab231 | ||
|
|
6a7bc64e11 |
@@ -385,23 +385,30 @@ $(function () {
|
||||
" #id_city, #id_country, #id_state").change(function () {
|
||||
if (copy_to_first_ticket) {
|
||||
var $first_ticket_form = $(".questions-form").first().find("[data-addonidx=0]");
|
||||
$first_ticket_form.find("[id$=" + this.id.substring(3) + "]").val(this.value);
|
||||
$first_ticket_form.find("[id$=" + this.id.substring(3) + "]").val(this.value).trigger("change");
|
||||
|
||||
// when matching by placeholder or label, make sure to always match the tagName of the element
|
||||
// filter any checkbox/radio inputs as copied input is either select or type=email|text, but could be
|
||||
// matched when custom answer options have the same label, see https://github.com/pretix/pretix/issues/4860
|
||||
var selectorPrefix = this.tagName + ":not([type='checkbox'], [type='radio'])";
|
||||
if (this.placeholder) {
|
||||
$first_ticket_form.find("[placeholder='" + CSS.escape(this.placeholder) + "']").val(this.value);
|
||||
$first_ticket_form.find(
|
||||
selectorPrefix + "[placeholder='" + CSS.escape(this.placeholder) + "']"
|
||||
).val(this.value).trigger("change");
|
||||
}
|
||||
var label = $("label[for=" + this.id +"]").first().contents().filter(function () {
|
||||
return this.nodeType != Node.ELEMENT_NODE || !this.classList.contains("sr-only");
|
||||
}).text().trim();
|
||||
if (label) {
|
||||
// match to placeholder and label
|
||||
$first_ticket_form.find("[placeholder='" + CSS.escape(label) + "']").val(this.value);
|
||||
$first_ticket_form.find(selectorPrefix + "[placeholder='" + CSS.escape(label) + "']").val(this.value).trigger("change");
|
||||
var v = this.value;
|
||||
$first_ticket_form.find("label").each(function() {
|
||||
var text = $(this).first().contents().filter(function () {
|
||||
return this.nodeType != Node.ELEMENT_NODE || !this.classList.contains("sr-only");
|
||||
}).text().trim();
|
||||
if (text == label) {
|
||||
$("#" + this.getAttribute("for")).val(v);
|
||||
$(selectorPrefix + "#" + this.getAttribute("for")).val(v).trigger("change");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user