mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 00:46:05 +00:00
refactor(templates): the shared page scripts load from static files
A step towards a Content-Security-Policy without inline scripts. The scripts every page or many pages share now load from static files: the error focus of base.html, the please-wait dialog, the sign-in forms' password toggle and busy button, the jobs pages' reload while a job runs, and the start of the job panel and of the VM list's state poll, whose values come as json_script data. Cancel links go back through a data-history-back attribute instead of a javascript: URL. The IE8 html5shiv/respond.js block, X-UA-Compatible and shrink-to-fit are gone: no supported browser reads them.
This commit is contained in:
parent
ab15fafe9c
commit
393aecb8f1
23 changed files with 112 additions and 137 deletions
|
|
@ -5,8 +5,7 @@
|
|||
{% get_current_language as LANGUAGE_CODE %}<html lang="{{ LANGUAGE_CODE }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="WebVirtCloud panel for manage virtual machine">
|
||||
<meta name="author" content="anatoliy.guskov@gmail.com">
|
||||
|
||||
|
|
@ -25,12 +24,6 @@
|
|||
<!-- Custom Fonts -->
|
||||
<link href="{% static "css/bootstrap-icons.min.css" %}" rel="stylesheet" type="text/css">
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<link rel="shortcut icon" href="{% static 'favicon.ico' %}">
|
||||
</head>
|
||||
|
||||
|
|
@ -90,28 +83,8 @@
|
|||
<script src="{% static 'js/tablesort.min.js' %}"></script>
|
||||
<script src="{% static 'js/tablesort.number.min.js' %}"></script>
|
||||
<script src="{% static 'js/sort_tables.js' %}"></script>
|
||||
<script>
|
||||
// After a refused submission, start at the error. The places an error
|
||||
// can be, most specific first: a refused field, its form's summary, an
|
||||
// open dialog's copy of the messages (the page's are behind it), the
|
||||
// page's messages. A page that sets itself up first has
|
||||
// data-error-focus="manual" and calls this when it is ready.
|
||||
const ERROR_PLACES = [".is-invalid", ".form-errors", ".modal.show .modal-messages .alert-danger",
|
||||
"#messages .alert-danger"];
|
||||
|
||||
function focusFirstError() {
|
||||
for (const selector of ERROR_PLACES) {
|
||||
const target = [...document.querySelectorAll(selector)].find(e => e.offsetParent !== null);
|
||||
if (target) {
|
||||
if (!target.matches("input, select, textarea")) target.tabIndex = -1;
|
||||
target.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
window.focusFirstError = focusFirstError;
|
||||
if (document.body.dataset.errorFocus !== "manual") focusFirstError();
|
||||
</script>
|
||||
<script src="{% static 'js/error_focus.js' %}"></script>
|
||||
<script src="{% static 'js/back_links.js' %}"></script>
|
||||
{% block script %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue