website/js/datacoop.js
Mikkel Munch Mortensen 89cce7d85c
Improve the service listing
* Show service logos next to their names.
 * Make the details toggles more explicit, by also including the
   service names.
2019-02-12 14:12:19 +01:00

17 lines
795 B
JavaScript

window.onload = function(e) {
var details = document.querySelectorAll("section.service-details");
for (var detail of details) {
var toggle = document.createElement("a");
var service_name = detail.previousElementSibling.querySelector("a").text;
toggle.text = "Læs mere om " + service_name;
toggle.onclick = function(e) {
e.preventDefault();
var service_name = e.target.previousElementSibling.previousElementSibling.querySelector("a").text;
var hide = e.target.previousElementSibling.classList.toggle("hidden");
e.target.text = (hide ? "Læs mere om " : "Skjul detaljer om ") + service_name;
}
detail.insertAdjacentElement('afterend', toggle);
detail.classList.add("hidden");
}
}