Frames

Untitled

0
1// ------------------------------------------------------------------
2// SCRIPTS
3// ------------------------------------------------------------------
4
5document.addEventListener("DOMContentLoaded", function () {
6 'use strict';
7
8 this.onclick = function (e) {
9 e.preventDefault();
10
11 var tabs = this.querySelectorAll(".js-tab"),
12 sliders = this.querySelectorAll(".js-slide"),
13 clickedElement = e.srcElement,
14 sliderhash = clickedElement.hash,
15 closestLi = clickedElement.closest("li");
16
17 if (e.srcElement.className === "js-tab tabs__link") {
18
19 tabs.forEach(function (item) {
20 item.closest("li").className = "tabs__item";
21 });
22
23 closestLi.classList.contains("is-active") ?
24 closestLi.className += "tabs__item is-active" :
25 closestLi.className += " is-active";
26
27 sliders.forEach(function (item) {
28 item.id === sliderhash ?
29 item.className = "js-slide slide__item is-active" :
30 item.className = "js-slide slide__item is-hidden";
31 });
32
33 }
34 };
35});
36