forked from data.coop/website
Mikkel Munch Mortensen
89cce7d85c
* Show service logos next to their names. * Make the details toggles more explicit, by also including the service names.
17 lines
795 B
JavaScript
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");
|
|
}
|
|
}
|