mirror of
https://github.com/pretix/pretix.git
synced 2026-05-16 17:03:58 +00:00
add cart expiry notification
This commit is contained in:
@@ -44,6 +44,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="cart-extend-modal" class="modal-wrapper" hidden aria-live="polite" role="dialog"
|
||||
aria-labelledby="cart-extend-modal-title" aria-describedby="cart-extend-modal-desc">
|
||||
<dialog class="modal-card" id="cart-extend-modal">
|
||||
<div class="modal-card-icon">
|
||||
<i class="fa fa-clock-o big-icon" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="modal-card-content">
|
||||
<h3 id="cart-extend-modal-title">{% trans "Please let us know you're still there" %}</h3>
|
||||
<div>
|
||||
<p id="cart-extend-modal-desc">
|
||||
{% trans "Your cart is about to expire. If you want to continue, please click here:" %}
|
||||
</p>
|
||||
<p><button class="btn btn-lg btn-primary">{% trans "Continue" %}</button></p>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
</div>
|
||||
{% if request.organizer and request.organizer.settings.cookie_consent %}
|
||||
<script type="text/plain" id="cookie-consent-storage-key">cookie-consent-{{ request.organizer.slug }}</script>
|
||||
{% if cookie_consent_from_widget %}
|
||||
|
||||
@@ -20,6 +20,18 @@ var cart = {
|
||||
cart._time_offset = server_time - client_time;
|
||||
},
|
||||
|
||||
show_expiry_notification: function () {
|
||||
$("#cart-extend-modal").show();
|
||||
$("#cart-extend-modal button").focus();
|
||||
$("body").addClass("has-modal-dialog");
|
||||
cart._expiry_notified = true;
|
||||
},
|
||||
|
||||
hide_expiry_notification: function () {
|
||||
$("#cart-extend-modal").hide();
|
||||
$("body").removeClass("has-modal-dialog");
|
||||
},
|
||||
|
||||
draw_deadline: function () {
|
||||
function pad(n, width, z) {
|
||||
z = z || '0';
|
||||
@@ -57,9 +69,9 @@ var cart = {
|
||||
pad(diff_minutes.toString(), 2) + ':' + pad(diff_seconds.toString(), 2)
|
||||
);
|
||||
}
|
||||
$("#cart-extend-button").toggle(diff_minutes < 3);
|
||||
var can_extend_cart = diff_minutes < 3 && (diff_total_seconds < 0 || cart._deadline < cart._max_extend);
|
||||
$("#cart-extend-button").toggle(can_extend_cart);
|
||||
if (can_extend_cart && diff_minutes < 1 && !cart._expiry_notified) cart.show_expiry_notification();
|
||||
},
|
||||
|
||||
init: function () {
|
||||
@@ -93,6 +105,11 @@ $(function () {
|
||||
cart.set_deadline(data.expiry, data.max_expiry_extend);
|
||||
});
|
||||
|
||||
$("#cart-extend-modal button").click(function() {
|
||||
cart.hide_expiry_notification();
|
||||
$("#cart-extend-form").submit();
|
||||
});
|
||||
|
||||
$(".toggle-container").each(function() {
|
||||
var summary = $(".toggle-summary", this);
|
||||
var content = $("> :not(.toggle-summary)", this);
|
||||
|
||||
Reference in New Issue
Block a user