event-timeline/app/templates/timeline.html

182 lines
5.1 KiB
HTML
Raw Normal View History

2022-04-12 13:50:11 +00:00
<!doctype html>{% load sass_tags static %}
<html>
2021-11-12 18:23:11 +00:00
<head>
2022-04-25 16:31:17 +00:00
<title>{{ settings.TITLE }}</title>
2021-11-12 18:23:11 +00:00
<meta charset="utf-8">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
2022-04-12 13:50:11 +00:00
<link href="{% sass_src 'css/style.scss' %}" rel="stylesheet" type="text/css">
2022-04-12 13:54:56 +00:00
<base target="_blank" >
2021-11-12 18:23:11 +00:00
<link rel="stylesheet" href="{% static 'timeline/css/timeline.css' %}">
<link rel="stylesheet" href="{% static 'timeline/css/fonts/font.default.css' %}">
<style>
html, body {
height:100%;
width:100%;
padding: 0px;
margin: 0px;
}
2022-04-26 14:25:34 +00:00
#timeline, #tl {
height: 100%;
width:100%;
}
#tl {
display: block;
}
2021-11-12 18:23:11 +00:00
.tl-timeline {
}
2022-04-12 13:50:11 +00:00
.tl-attribution {
display: none !important;
}
2022-04-19 12:11:16 +00:00
.tl-timeline h1, .tl-timeline h2, .tl-timeline h3, .tl-timeline h4, .tl-timeline h5, .tl-timeline h6 {
text-transform: initial !important;
}
2022-04-26 11:54:23 +00:00
.tl-timeline .tl-timegroup-message {
2022-04-26 11:55:48 +00:00
color: #000 !important;
2022-04-26 11:54:23 +00:00
}
2021-11-12 18:23:11 +00:00
</style>
2022-04-12 13:50:11 +00:00
</head>
<body>
2022-04-26 14:25:34 +00:00
<div id="title" class="page tl-timeline">
<div class="content">
{{ title.body | safe }}
</div>
</div>
<div id="about" class="page tl-timeline">
<br>
<br>
{{ about.body | safe }}
</div>
<div id="timeline" class="page">
<div id="tl"></div>
2022-04-12 13:50:11 +00:00
</div>
2022-04-26 14:25:34 +00:00
<div id="imprint" class="page tl-timeline">
<br>
<br>
{{ imprint.body | safe }}
</div>
<div id="contact" class="page tl-timeline">
2022-04-25 16:24:42 +00:00
<div class="content">
<form class="contact-form" action="/disabled" method="post">
<input type="text" placeholder="Your name" name="name" required><br>
<input type="text" placeholder="Your email" name="email" required><br>
<textarea placeholder="Message" name="message" required></textarea><br>
<input type="submit" value="Send message" />
{% csrf_token %}
2022-04-12 13:50:11 +00:00
</form>
2022-04-25 16:24:42 +00:00
</div>
2022-04-12 13:50:11 +00:00
</div>
2022-04-26 14:25:34 +00:00
<div id="menu-overlay" class="tl-timeline">
<ul>
<li><a href="#start" target="_self">timeline</a></li>
<li><a href="#about" target="_self">about</a></li>
<li><a href="#contact" target="_self">contact</a></li>
<li><a href="#imprint" target="_self">imprint</a></li>
</ul>
</div>
<div id="menu">
<svg viewBox="0 0 100 100" width="64" height="64">
<rect y="20" width="80" height="10"></rect>
<rect y="40" width="80" height="10"></rect>
<rect y="60" width="80" height="10"></rect>
</svg>
</div>
2021-11-12 18:23:11 +00:00
<script src="{% static 'timeline/js/timeline.js' %}"></script>
<script>
2022-04-25 16:24:42 +00:00
function submitContact(event) {
event.preventDefault()
event.stopPropagation()
var data = {}
var form = document.querySelector('.contact-form')
form.querySelectorAll('input,textarea').forEach(input => {
if (input.name) {
data[input.name] = input.value
}
})
fetch('/contact/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRFToken': data.csrfmiddlewaretoken,
},
body: JSON.stringify(data)
}).then(response => response.json()).then(response => {
if (response.sent) {
var content = document.querySelector('#contact .content')
content.innerHTML = `
Thank you for taking the time to send us a message, we will get back to you soon.
<br><br>
<a href="/" target="_self">Back to Timeline</a>
`
}
})
}
document.querySelector('#contact .contact-form').addEventListener('submit', submitContact)
2021-11-12 18:23:11 +00:00
var data = {{ timeline_json | safe }};
2022-04-12 13:50:11 +00:00
var timeline
function load_timeline() {
2022-04-26 14:25:34 +00:00
timeline = new TL.Timeline('tl', data, {
2022-04-12 13:50:11 +00:00
hash_bookmark: true,
debug: false,
timenav_height: 100,
});
}
2022-04-26 14:25:34 +00:00
function openPage(qs) {
var active = document.querySelector(qs)
document.querySelectorAll('.page').forEach(page => {
if (page != active) {
if (page.classList.contains('active')) {
page.classList.remove('active')
active.classList.add('active')
}
}
})
active.classList.add('active')
}
document.querySelector('#about a[href="#title"]').addEventListener('click', event => {
openPage('#timeline')
2022-04-12 13:50:11 +00:00
load_timeline()
})
function hashchange(event) {
console.log('hc', document.location.hash.slice(1).length, document.location.hash.slice(1))
2022-04-26 14:25:34 +00:00
var page
if (document.location.hash.slice(1).length) {
page = document.querySelector(document.location.hash + '.page')
}
if (page) {
openPage(document.location.hash)
2022-04-12 13:50:11 +00:00
} else if (document.location.hash.slice(1).length) {
2022-04-26 14:25:34 +00:00
openPage('#timeline')
if (!timeline) {
load_timeline()
}
2022-04-12 13:50:11 +00:00
} else {
2022-04-26 14:25:34 +00:00
openPage("#title")
2022-04-12 13:50:11 +00:00
}
}
window.addEventListener('hashchange', hashchange)
hashchange()
2022-04-26 14:25:34 +00:00
document.querySelector('#menu').addEventListener('click', event => {
var overlay = document.querySelector('#menu-overlay')
if (overlay.classList.contains('active')) {
overlay.classList.remove('active')
} else {
overlay.classList.add('active')
}
})
document.querySelectorAll('#menu-overlay a').forEach(a => {
a.addEventListener('click', event => {
var overlay = document.querySelector('#menu-overlay')
overlay.classList.remove('active')
})
})
2021-11-12 18:23:11 +00:00
</script>
</body>
</html>