Μετάβαση στο περιεχόμενο
document.addEventListener('DOMContentLoaded', function () {
var t1 = document.getElementById('wrapper-tmpl1');
var t2 = document.getElementById('wrapper-tmpl2');
var buttons = document.querySelectorAll('.inea-btn');
// fail safe
if (!t1 || !t2 || !buttons.length) {
console.log('Toggle: required elements not found.');
return;
}
// CLICK EVENTS
for (var i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('click', function () {
var tmpl = this.getAttribute('data-template');
if (tmpl === 'tmpl1') {
t1.style.display = 'block';
t2.style.display = 'none';
} else {
t1.style.display = 'none';
t2.style.display = 'block';
}
// remove active from all
for (var j = 0; j < buttons.length; j++) {
buttons[j].classList.remove('active');
}
// add active to clicked
this.classList.add('active');
});
}
});