mirror of
https://github.com/pretix/pretix.git
synced 2026-05-10 16:04:02 +00:00
--------- Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
@@ -314,6 +314,12 @@ function setup_week_calendar() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_label_text_for_id(id) {
|
||||||
|
return $("label[for=" + id +"]").first().contents().filter(function () {
|
||||||
|
return this.nodeType != Node.ELEMENT_NODE || !this.classList.contains("sr-only");
|
||||||
|
}).text().trim();
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@@ -344,7 +350,7 @@ $(function () {
|
|||||||
|
|
||||||
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
$("#ajaxerr").on("click", ".ajaxerr-close", ajaxErrDialog.hide);
|
||||||
|
|
||||||
// Copy answers
|
// Handlers for "Copy answers from above" buttons
|
||||||
$(".js-copy-answers").click(function (e) {
|
$(".js-copy-answers").click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@@ -372,44 +378,37 @@ $(function () {
|
|||||||
copy_answers(elements, answers);
|
copy_answers(elements, answers);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
var copy_to_first_ticket = true;
|
|
||||||
var attendee_address_fields = $("input[id*=attendee_name_parts_], input[id*=attendee_email], .questions-form" +
|
// Automatically copy answers from invoice to first attendee
|
||||||
" input[id$=company], .questions-form[id$=street], .questions-form input[id$=zipcode], .questions-form" +
|
var attendee_address_fields = $("input[id*=attendee_name_parts_], input[id*=attendee_email], " +
|
||||||
" input[id$=city]");
|
".questions-form input[id$=company], .questions-form input[id$=street], " +
|
||||||
attendee_address_fields.each(function () {
|
".questions-form input[id$=zipcode], .questions-form input[id$=city]");
|
||||||
if ($(this).val()) {
|
function copy_to_first_ticket () {
|
||||||
copy_to_first_ticket = false;
|
var source = this;
|
||||||
}
|
var source_label = get_label_text_for_id(source.id);
|
||||||
})
|
|
||||||
$("select[id^=id_name_parts], input[id^=id_name_parts_], #id_email, #id_street, #id_company, #id_zipcode," +
|
var $first_ticket_form = $(".questions-form").first().find("[data-addonidx=0]");
|
||||||
" #id_city, #id_country, #id_state").change(function () {
|
var $candidates = $first_ticket_form.find(source.tagName + ":not([type='checkbox'], [type='radio'])");
|
||||||
if (copy_to_first_ticket) {
|
var $match = $candidates.filter(function() {
|
||||||
var $first_ticket_form = $(".questions-form").first().find("[data-addonidx=0]");
|
return (
|
||||||
$first_ticket_form.find("[id$=" + this.id.substring(3) + "]").val(this.value);
|
this.id.endsWith(source.id.substring(3))
|
||||||
if (this.placeholder) {
|
|| (this.placeholder && this.placeholder === source.placeholder)
|
||||||
$first_ticket_form.find("[placeholder='" + CSS.escape(this.placeholder) + "']").val(this.value);
|
|| (this.placeholder && this.placeholder === source_label)
|
||||||
}
|
|| (source_label && get_label_text_for_id(this.id) === source_label)
|
||||||
var label = $("label[for=" + this.id +"]").first().contents().filter(function () {
|
);
|
||||||
return this.nodeType != Node.ELEMENT_NODE || !this.classList.contains("sr-only");
|
}).first();
|
||||||
}).text().trim();
|
$match.val(this.value).trigger("change");
|
||||||
if (label) {
|
}
|
||||||
// match to placeholder and label
|
function valueIsEmpty(el) { return !el.value; }
|
||||||
$first_ticket_form.find("[placeholder='" + CSS.escape(label) + "']").val(this.value);
|
if (attendee_address_fields.toArray().every(valueIsEmpty)) {
|
||||||
var v = this.value;
|
var invoice_address_fields = $("select[id^=id_name_parts], input[id^=id_name_parts_], #id_email, #id_street, " +
|
||||||
$first_ticket_form.find("label").each(function() {
|
"#id_company, #id_zipcode, #id_city, #id_country, #id_state");
|
||||||
var text = $(this).first().contents().filter(function () {
|
invoice_address_fields.on("change", copy_to_first_ticket).trigger("change");
|
||||||
return this.nodeType != Node.ELEMENT_NODE || !this.classList.contains("sr-only");
|
attendee_address_fields.one("input", function () {
|
||||||
}).text().trim();
|
invoice_address_fields.off("change", copy_to_first_ticket);
|
||||||
if (text == label) {
|
});
|
||||||
$("#" + this.getAttribute("for")).val(v);
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).trigger("change");
|
|
||||||
attendee_address_fields.change(function () {
|
|
||||||
copy_to_first_ticket = false;
|
|
||||||
});
|
|
||||||
questions_init_profiles($("body"));
|
questions_init_profiles($("body"));
|
||||||
|
|
||||||
if (sessionStorage) {
|
if (sessionStorage) {
|
||||||
|
|||||||
Reference in New Issue
Block a user