Added first version of election map feature

Signed-off-by: Jim Martens <github@2martens.de>
This commit is contained in:
2019-04-30 21:07:12 +02:00
parent e241e7b137
commit 24582be4a6
5 changed files with 201 additions and 7 deletions

View File

@ -1,6 +1,6 @@
"use strict";
$(function() {
$(function () {
let mainMenu = $("#mainmenuNavbar");
mainMenu.on("show.bs.collapse", function () {
$("#submenuNavbar").addClass("invisible");
@ -34,11 +34,13 @@ $(function() {
});
let countdownSpan = $("#countdown");
countdown.setFormat({singular: " Millisekunde| Sekunde| Minute| Stunde| Tag| Woche| Monat| Jahr| Jahrzehnt| Jahrhundert| Jahrtausend",
plural: " Millisekunden| Sekunden| Minuten| Stunden| Tage| Wochen| Monate| Jahre| Jahrzehnte| Jahrhunderte| Jahrtausende",
last: " und ",
delim: ", "});
let counterID = countdown(function(timestamp) {
countdown.setFormat({
singular: " Millisekunde| Sekunde| Minute| Stunde| Tag| Woche| Monat| Jahr| Jahrzehnt| Jahrhundert| Jahrtausend",
plural: " Millisekunden| Sekunden| Minuten| Stunden| Tage| Wochen| Monate| Jahre| Jahrzehnte| Jahrhunderte| Jahrtausende",
last: " und ",
delim: ", "
});
let counterID = countdown(function (timestamp) {
countdownSpan.html(timestamp.toString());
}, new Date(2019, 4, 26, 18, 0),
countdown.DAYS |
@ -47,4 +49,46 @@ $(function() {
countdown.SECONDS
);
// election map feature
// v0.1
let stadtteil_svg = $("#election_map g.stadtteil");
stadtteil_svg.mouseenter(function (e) {
const region_data = $(this).data();
let tooltip = $("<div id='info_panel' class=\"info_panel\"><span class='font-weight-bold'>" + region_data.name + "</span><br>" +
region_data.platz1 + "<br>" +
region_data.platz2 + "</div>"
);
let mouseX = e.pageX, //X coordinates of mouse
mouseY = e.pageY; //Y coordinates of mouse
tooltip.appendTo("body");
tooltip.css({
top: mouseY - 60,
left: mouseX - (tooltip.width() / 2)
});
});
stadtteil_svg
// deactivate links for now
/*.click(function (e) {
e.preventDefault();
const region_data = $(this).data();
window.location.href = region_data.link;
})*/
.mouseout(function (e) {
$("#info_panel").remove();
})
.mousemove(function (e) {
let mouseX = e.pageX, //X coordinates of mouse
mouseY = e.pageY; //Y coordinates of mouse
let info_panel = $("#info_panel");
info_panel.css({
top: mouseY - 60,
left: mouseX - (info_panel.width() / 2)
});
});
});