EyeTrackVR-Docs/docs/_includes/custom/FAQ/faq_template.html
ZanzyTHEbar 00dd1b25a7 update
- Fix accordion height
2022-06-04 14:47:15 +02:00

108 lines
3.2 KiB
HTML

<!-- Do not edit this file - it is a template. Please edit the faq.yml file -->
<style>
.accordion {
width: 100%;
margin: 1px auto;
padding: 5px 5px;
}
.accordion .container {
position: relative;
margin: 5px 5px;
}
/* Positions the labels relative to the .container. Adds padding to the top and bottom and increases font size. Also makes its cursor a pointer */
.accordion .question {
position: relative;
padding: 5px 0;
font-size: 30px;
cursor: pointer;
}
/* Positions the plus sign 5px from the right. Centers it using the transform property. */
.accordion .question::before {
content: '\2304';
position: absolute;
top: 50%;
right: -5px;
font-size: 30px;
transform: translateY(-50%);
}
/* Hides the content (height: 0), decreases font size, justifies text and adds transition */
.accordion .answer {
position: relative;
height: 0;
font-size: 20px;
text-align: justify;
width: 100%;
transition: 0.5s;
overflow: hidden;
}
/* Adds a horizontal line between the contents */
.accordion hr {
width: 100%;
margin-left: 0;
border: 1px solid grey;
}
/* Unhides the content part when active. Sets the height */
.accordion .container.active .answer {
height: 180px;
}
/* Changes from plus sign to negative sign once active */
.accordion .container.active .question::before {
content: '';
font-size: 30px;
}
</style>
<h1 class="fs-6 fw-500" align="center">Frequently Asked Questions <br> Welcome to our FAQ!</h1>
<div class="accordion-body">
{% for faq in site.data.faq_yaml.frequently_asked_questions %}
<div class="accordion">
<hr>
<div class="container">
<div class="question fw-400">
<h1 class="fs-5 fw-500">
{{ faq.question }}
</h1>
</div>
<div class="answer">
<blockquote>
<span class="answer-span">
{{ faq.answer }}
</span>
</blockquote>
</div>
</div>
</div>
{% endfor %}
</div>
<script type="text/javascript">
const accordion = document.getElementsByClassName('container');
window.addEventListener('load', function () {
createElement();
});
for (i = 0; i < accordion.length; i++) {
accordion[i].addEventListener('click', function () {
this.classList.toggle('active');
})
}
function replaceLink(str) {
const link = document.querySelectorAll('.answer-span');
const all_link = link.forEach(function (link) {
const hyper_link = link.innerHTML;
link.innerHTML = hyper_link.replace(/aaaa./g, str);
});
}
function createElement() {
for (let x in accordion) {
replaceLink('<a href="https://dammedia.osram.info/media/bin/osram-dam-2496608/AN002_Details%20on%20photobiological%20safety%20of%20LED%20light%20sources.pdf" target="_blank">here is a pdf with safety information</a>');
}
}
</script>