mirror of
https://github.com/pretix/pretix.git
synced 2026-08-13 11:17:01 +00:00
include errors.js by default and make it coop with async_task_replace_page (Z#23236752) (#6284)
* load errors.js as standard and make it coop with async_task_replace_page * scope down event * Update src/pretix/static/pretixbase/js/asynctask.js Co-authored-by: pajowu <engelhardt@pretix.eu> * drop the jquery dependency for error.js Co-authored-by: pajowu <pajowu@pajowu.de> * include errors.js in error.html * include errors.js in control base.html * Update src/pretix/static/pretixbase/js/asynctask.js Co-authored-by: Richard Schreiber <schreiber@pretix.eu> * put errors.js in an IIFE call --------- Co-authored-by: pajowu <engelhardt@pretix.eu> Co-authored-by: pajowu <pajowu@pajowu.de> Co-authored-by: Richard Schreiber <schreiber@pretix.eu>
This commit is contained in:
co-authored by
pajowu
pajowu
Richard Schreiber
parent
ea928ea7d4
commit
694b915d89
@@ -11,6 +11,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link rel="icon" href="{% static "pretixbase/img/favicon.ico" %}">
|
<link rel="icon" href="{% static "pretixbase/img/favicon.ico" %}">
|
||||||
|
<script type="text/javascript" src="{% static "pretixbase/js/errors.js" %}"></script>
|
||||||
{% block custom_header %}{% endblock %}
|
{% block custom_header %}{% endblock %}
|
||||||
{% if css_theme %}
|
{% if css_theme %}
|
||||||
<link rel="stylesheet" type="text/css" href="{{ css_theme }}" />
|
<link rel="stylesheet" type="text/css" href="{{ css_theme }}" />
|
||||||
@@ -20,6 +21,5 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
<script src="{% static "pretixbase/js/errors.js" %}"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
<script type="text/javascript" src="{% static "lightbox/js/lightbox.js" %}"></script>
|
<script type="text/javascript" src="{% static "lightbox/js/lightbox.js" %}"></script>
|
||||||
<script type="text/javascript" src="{% static "are-you-sure/jquery.are-you-sure.js" %}"></script>
|
<script type="text/javascript" src="{% static "are-you-sure/jquery.are-you-sure.js" %}"></script>
|
||||||
<script type="text/javascript" src="{% static "pretixbase/js/addressform.js" %}"></script>
|
<script type="text/javascript" src="{% static "pretixbase/js/addressform.js" %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static "pretixbase/js/errors.js" %}"></script>
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
{{ html_head|safe }}
|
{{ html_head|safe }}
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,5 @@
|
|||||||
<script type="text/javascript" src="{% static "pretixpresale/js/ui/iframe.js" %}"></script>
|
<script type="text/javascript" src="{% static "pretixpresale/js/ui/iframe.js" %}"></script>
|
||||||
<script type="text/javascript" src="{% static "pretixbase/js/addressform.js" %}"></script>
|
<script type="text/javascript" src="{% static "pretixbase/js/addressform.js" %}"></script>
|
||||||
<script type="text/javascript" src="{% static "pretixbase/js/deanonymize_email.js" %}"></script>
|
<script type="text/javascript" src="{% static "pretixbase/js/deanonymize_email.js" %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static "pretixbase/js/errors.js" %}"></script>
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
|||||||
@@ -174,15 +174,16 @@ function async_task_error(jqXHR, textStatus, errorThrown) {
|
|||||||
var respdom = $(jqXHR.responseText);
|
var respdom = $(jqXHR.responseText);
|
||||||
var c = respdom.filter('.container');
|
var c = respdom.filter('.container');
|
||||||
if (respdom.filter('form') && (respdom.filter('.has-error') || respdom.filter('.alert-danger'))) {
|
if (respdom.filter('form') && (respdom.filter('.has-error') || respdom.filter('.alert-danger'))) {
|
||||||
// This is a failed form validation, let's just use it
|
|
||||||
|
|
||||||
if (respdom.filter('#page-wrapper') && $('#page-wrapper').length) {
|
if (respdom.filter('#page-wrapper') && $('#page-wrapper').length) {
|
||||||
|
// This is a failed form validation, let's just use it
|
||||||
async_task_replace_page("#page-wrapper", respdom.find("#page-wrapper").html());
|
async_task_replace_page("#page-wrapper", respdom.find("#page-wrapper").html());
|
||||||
} else {
|
} else {
|
||||||
async_task_replace_page("body", jqXHR.responseText.substring(
|
async_task_replace_page("body", jqXHR.responseText.substring(
|
||||||
jqXHR.responseText.indexOf("<body"),
|
jqXHR.responseText.indexOf("<body"),
|
||||||
jqXHR.responseText.indexOf("</body")
|
jqXHR.responseText.indexOf("</body")
|
||||||
));
|
));
|
||||||
|
document.dispatchEvent(new Event("pretix:async-task-error"))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (c.length > 0) {
|
} else if (c.length > 0) {
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
document.getElementById('goback').onclick =
|
['DOMContentLoaded', 'pretix:async-task-error'].forEach(function (ev) {
|
||||||
function() {window.history.back()};
|
document.addEventListener(ev, function () {
|
||||||
|
document.querySelectorAll('#goback, #reload').forEach(function (element) {
|
||||||
document.getElementById('reload').onclick =
|
const regularLoad = ev === 'DOMContentLoaded' && element.id === 'goback';
|
||||||
function() {window.location.reload(true)};
|
element.addEventListener('click', regularLoad
|
||||||
|
? () => window.history.back()
|
||||||
|
: () => window.location.reload()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user