Some fixes and enhancements befor javascript rework

This commit is contained in:
Stephan Porada
2020-08-06 10:42:35 +02:00
parent a390fbb0ce
commit 301b090fc0
5 changed files with 82 additions and 38 deletions

View File

@ -55,6 +55,8 @@
</div>
</div>
<!-- Scroll to top element -->
{% include 'interactions/scroll_to_top.html.j2' %}
<!-- Modals -->
{% include 'modals/show_metadata.html.j2' %}
@ -337,6 +339,20 @@
});
// new insepct event listener makeing use of javascript bubbleing
let resultsTable = document.getElementById("query-results");
console.log(resultsTable);
resultsTable.addEventListener("click", (event) => {
let dataIndex;
if (event.target.classList.contains("inspect-btn")) {
dataIndex = parseInt(event.target.closest("tr").dataset.index);
console.log(dataIndex);
results.jsList.inspect([dataIndex], "inspect");
} else if (event.target.classList.contains("add-btn")) {
dataIndex = parseInt(event.target.closest("tr").dataset.index);
results.jsList.addToSubResults(dataIndex);
}
})
// ### Download events and sub-results creation ###
var loadingSpinnerHTML = `
@ -405,5 +421,20 @@
results.jsList.contextData,
downloadInspectContextElement);
};
// scroll to top button if user scrolled down the list
let headline = document.querySelector(".headline");
let scrollToTop = document.querySelector("#menu-scroll-to-top-div");
window.addEventListener("scroll", (event) => {
if (pageYOffset > 250) {
scrollToTop.classList.toggle("hide", false);
} else {
scrollToTop.classList.toggle("hide", true);
}
});
scrollToTop.onclick = () => {
headline.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"});
};
</script>
{% endblock %}