mirror of
https://github.com/pretix/pretix.git
synced 2026-05-08 15:44:02 +00:00
A11y improvements (#2081)
Co-authored-by: Raphael Michel <michel@rami.io> Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
committed by
GitHub
parent
cc13ca1c3f
commit
3dcfa57b70
@@ -35,16 +35,20 @@ var cart = {
|
||||
var now = cart._get_now();
|
||||
var diff_minutes = Math.floor(cart._deadline.diff(now) / 1000 / 60);
|
||||
var diff_seconds = Math.floor(cart._deadline.diff(now) / 1000 % 60);
|
||||
|
||||
if (diff_minutes < 2 || diff_minutes == 5) $("#cart-deadline").get(0).setAttribute("aria-live", "polite");
|
||||
else $("#cart-deadline").get(0).removeAttribute("aria-live");
|
||||
|
||||
if (diff_minutes < 0) {
|
||||
$("#cart-deadline").text(gettext("The items in your cart are no longer reserved for you."));
|
||||
$("#cart-deadline").text(gettext("The items in your cart are no longer reserved for you. You can still complete your order as long as they’re available."));
|
||||
$("#cart-deadline-short").text(
|
||||
gettext("Cart expired")
|
||||
);
|
||||
window.clearInterval(cart._deadline_interval);
|
||||
} else {
|
||||
$("#cart-deadline").text(ngettext(
|
||||
"The items in your cart are reserved for you for one minute.",
|
||||
"The items in your cart are reserved for you for {num} minutes.",
|
||||
"The items in your cart are reserved for you for one minute.",
|
||||
"The items in your cart are reserved for you for {num} minutes.",
|
||||
diff_minutes
|
||||
).replace(/\{num\}/g, diff_minutes));
|
||||
$("#cart-deadline-short").text(
|
||||
@@ -71,13 +75,17 @@ $(function () {
|
||||
cart.init();
|
||||
}
|
||||
|
||||
$(".apply-voucher").hide();
|
||||
$(".apply-voucher-toggle").click(function (e) {
|
||||
$(".apply-voucher-toggle").hide();
|
||||
$(".apply-voucher").show();
|
||||
$(".apply-voucher input[type=text]").first().focus();
|
||||
e.preventDefault();
|
||||
return true;
|
||||
$(".toggle-container").each(function() {
|
||||
var summary = $(".toggle-summary", this);
|
||||
var content = $("> :not(.toggle-summary)", this);
|
||||
var toggle = summary.find(".toggle").on("click", function(e) {
|
||||
this.ariaExpanded = !this.ariaExpanded;
|
||||
if (this.classList.contains("toggle-remove")) summary.attr("hidden", true);
|
||||
content.show().find(":input:visible").first().focus();
|
||||
});
|
||||
if (toggle.attr("aria-expanded")) {
|
||||
content.hide();
|
||||
}
|
||||
});
|
||||
|
||||
$(".cart-icon-details.collapse-lines").each(function () {
|
||||
|
||||
@@ -119,7 +119,7 @@ var form_handlers = function (el) {
|
||||
width: $(this).attr("data-size") ? parseInt($(this).attr("data-size")) : 256,
|
||||
height: $(this).attr("data-size") ? parseInt($(this).attr("data-size")) : 256,
|
||||
}
|
||||
);
|
||||
).find("canvas").attr("role", "img").attr("aria-label", this.getAttribute("data-desc"));
|
||||
});
|
||||
|
||||
el.find("input[data-exclusive-prefix]").each(function () {
|
||||
@@ -180,6 +180,11 @@ $(function () {
|
||||
|
||||
$("body").removeClass("nojs");
|
||||
|
||||
$(".accordion-radio").click(function() {
|
||||
var $input = $("input", this);
|
||||
if (!$input.prop("checked")) $input.prop('checked', true).trigger("change");
|
||||
});
|
||||
|
||||
$("input[data-toggle=radiocollapse]").change(function () {
|
||||
$($(this).attr("data-parent")).find(".collapse.in").collapse('hide');
|
||||
$($(this).attr("data-target")).collapse('show');
|
||||
@@ -191,6 +196,27 @@ $(function () {
|
||||
$(".has-error, .alert-danger").each(function () {
|
||||
$(this).closest("div.panel-collapse").collapse("show");
|
||||
});
|
||||
$(".has-error").first().each(function(){
|
||||
if ($(this).is(':input')) this.focus();
|
||||
else $(":input", this).get(0).focus();
|
||||
});
|
||||
$(".alert-danger").first().each(function() {
|
||||
var content = $("<ul></ul>").click(function(e) {
|
||||
var input = $(e.target.hash).get(0);
|
||||
if (input) input.focus();
|
||||
input.scrollIntoView({block: "center"});
|
||||
e.preventDefault();
|
||||
});
|
||||
$(".has-error").each(function() {
|
||||
var target = target = $(":input", this);
|
||||
var desc = $("#" + target.attr("aria-describedby").split(' ', 1)[0]);
|
||||
// multi-input fields have a role=group with aria-labelledby
|
||||
var label = this.hasAttribute("aria-labelledby") ? $("#" + this.getAttribute("aria-labelledby")) : $("[for="+target.attr("id")+"]");
|
||||
|
||||
content.append("<li><a href='#" + target.attr("id") + "'>" + label.get(0).childNodes[0].nodeValue + "</a>: "+desc.text()+"</li>");
|
||||
});
|
||||
$(this).append(content);
|
||||
});
|
||||
|
||||
$("#voucher-box").hide();
|
||||
$("#voucher-toggle").show();
|
||||
@@ -280,9 +306,9 @@ $(function () {
|
||||
// Subevent choice
|
||||
if ($(".subevent-toggle").length) {
|
||||
$(".subevent-list").hide();
|
||||
$(".subevent-toggle").css("display", "block").click(function () {
|
||||
$(".subevent-toggle").show().click(function () {
|
||||
$(".subevent-list").slideToggle(300);
|
||||
$(".subevent-toggle").slideToggle(300)
|
||||
$(this).slideToggle(300).attr("aria-expanded", true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -320,7 +346,7 @@ $(function () {
|
||||
|
||||
$(".table-calendar td.has-events").click(function () {
|
||||
var $tr = $(this).closest(".table-calendar").find(".selected-day");
|
||||
$tr.find("td").html($(this).find(".events").html());
|
||||
$tr.find("td").html($(this).find(".events").clone());
|
||||
$tr.find("td").prepend($("<h3>").text($(this).attr("data-date")));
|
||||
$tr.removeClass("hidden");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user