mirror of
https://github.com/pretix/pretix.git
synced 2026-05-16 17:03:58 +00:00
open closed cart (either details or sneak-peek) onsubmit
This commit is contained in:
@@ -11,11 +11,18 @@ setup_collapsible_details = function (el) {
|
|||||||
content.classList.remove('sneak-peek-content');
|
content.classList.remove('sneak-peek-content');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
function openSneekPeakOnSubmit() {
|
||||||
|
$(button).trigger("click");
|
||||||
|
}
|
||||||
|
var $buttons = $("button:enabled", content).prop("disabled", true);
|
||||||
|
var $forms = $("form", content).on("submit", openSneekPeakOnSubmit);
|
||||||
content.setAttribute('aria-hidden', 'true');
|
content.setAttribute('aria-hidden', 'true');
|
||||||
button.setAttribute('aria-expanded', 'false');
|
button.setAttribute('aria-expanded', 'false');
|
||||||
button.addEventListener('click', function (e) {
|
button.addEventListener('click', function (e) {
|
||||||
button.setAttribute('aria-expanded', 'true');
|
button.setAttribute('aria-expanded', 'true');
|
||||||
content.setAttribute('aria-hidden', 'false');
|
content.setAttribute('aria-hidden', 'false');
|
||||||
|
$buttons.prop("disabled", false);
|
||||||
|
$forms.off("submit", openSneekPeakOnSubmit);
|
||||||
|
|
||||||
content.addEventListener('transitionend', function() {
|
content.addEventListener('transitionend', function() {
|
||||||
content.classList.remove('sneak-peek-content');
|
content.classList.remove('sneak-peek-content');
|
||||||
@@ -29,8 +36,14 @@ setup_collapsible_details = function (el) {
|
|||||||
// this will be called by screenreader users if they kept focus on the button after expanding
|
// this will be called by screenreader users if they kept focus on the button after expanding
|
||||||
// we need to keep the trigger/button in the DOM to not irritate screenreaders toggling visibility
|
// we need to keep the trigger/button in the DOM to not irritate screenreaders toggling visibility
|
||||||
var expanded = button.getAttribute('aria-expanded') == 'true';
|
var expanded = button.getAttribute('aria-expanded') == 'true';
|
||||||
button.setAttribute('aria-expanded', !expanded);
|
button.setAttribute('aria-expanded', !expanded ? 'true' : 'false');
|
||||||
content.setAttribute('aria-hidden', expanded);
|
content.setAttribute('aria-hidden', expanded ? 'true' : 'false');
|
||||||
|
$buttons.prop("disabled", expanded);
|
||||||
|
if (expanded) {
|
||||||
|
$forms.on("submit", openSneekPeakOnSubmit);
|
||||||
|
} else {
|
||||||
|
$forms.off("submit", openSneekPeakOnSubmit);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
button.addEventListener('blur', function (e) {
|
button.addEventListener('blur', function (e) {
|
||||||
// if content is visible and the user leaves the button, we can safely remove the trigger/button
|
// if content is visible and the user leaves the button, we can safely remove the trigger/button
|
||||||
@@ -48,6 +61,8 @@ setup_collapsible_details = function (el) {
|
|||||||
trigger.remove();
|
trigger.remove();
|
||||||
content.removeAttribute('aria-hidden');
|
content.removeAttribute('aria-hidden');
|
||||||
content.classList.remove('sneak-peek-content');
|
content.classList.remove('sneak-peek-content');
|
||||||
|
$buttons.prop("disabled", false);
|
||||||
|
$forms.off("submit", openSneekPeakOnSubmit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container.addEventListener("toggle", removeSneekPeakWhenClosed);
|
container.addEventListener("toggle", removeSneekPeakWhenClosed);
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ $(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#dialog-cart-extend form").submit(function() {
|
$("#dialog-cart-extend form").submit(function() {
|
||||||
|
$("#cart-extend-form").closest("details:not([open])").find("summary").trigger("click");
|
||||||
$("#cart-extend-form").submit();
|
$("#cart-extend-form").submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user