moved inline javascript to it's own file
This commit is contained in:
parent
5813d200dc
commit
26f3d5d033
2 changed files with 26 additions and 24 deletions
24
community_backup/static/webui/js/webui.js
Normal file
24
community_backup/static/webui/js/webui.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// Activation script for the bulma burger menu.
|
||||||
|
// Copied from https://bulma.io/documentation/components/navbar/
|
||||||
|
//
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
|
// Get all "navbar-burger" elements
|
||||||
|
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||||
|
|
||||||
|
// Add a click event on each of them
|
||||||
|
$navbarBurgers.forEach( el => {
|
||||||
|
el.addEventListener('click', () => {
|
||||||
|
|
||||||
|
// Get the target from the "data-target" attribute
|
||||||
|
const target = el.dataset.target;
|
||||||
|
const $target = document.getElementById(target);
|
||||||
|
|
||||||
|
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
||||||
|
el.classList.toggle('is-active');
|
||||||
|
$target.classList.toggle('is-active');
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -2,35 +2,13 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="{% static 'vendored/css/bulma.min.css' %}">
|
<link rel="stylesheet" href="{% static 'vendored/css/bulma.min.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'webui/css/webui.css' %}">
|
<link rel="stylesheet" href="{% static 'webui/css/webui.css' %}">
|
||||||
<link rel="icon" href="{% static 'webui/logo.png'%}" type="image/png"/>
|
<link rel="icon" href="{% static 'webui/logo.png'%}" type="image/png"/>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Community Backup</title>
|
<title>Community Backup</title>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript" src={% static 'webui/js/webui.js' %}></script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
|
|
||||||
// Get all "navbar-burger" elements
|
|
||||||
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
|
||||||
|
|
||||||
// Add a click event on each of them
|
|
||||||
$navbarBurgers.forEach( el => {
|
|
||||||
el.addEventListener('click', () => {
|
|
||||||
|
|
||||||
// Get the target from the "data-target" attribute
|
|
||||||
const target = el.dataset.target;
|
|
||||||
const $target = document.getElementById(target);
|
|
||||||
|
|
||||||
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
|
||||||
el.classList.toggle('is-active');
|
|
||||||
$target.classList.toggle('is-active');
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar" role="navigation" aria-label="main navigation" >
|
<nav class="navbar" role="navigation" aria-label="main navigation" >
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue