-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
53 lines (36 loc) · 1.14 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class TabLink {
constructor(student) {
this.student = student;
this.data = student.dataset.tab;
console.log(this.data);
this.itemElement = document.querySelector(`.tabs-item[data-tab="${this.data}"]`);
this.TabItem = new TabItem(this.itemElement)
this.student.addEventListener('click', () => this.select());
};
select() {
console.log('LOGGED');
const links = document.querySelectorAll('.tab-link');
links.forEach(function(current){
current.classList.remove('tab-link-selected');
})
this.student.classList.add('tab-link-selected');
this.TabItem.select();
}
}
class TabItem {
constructor(info) {
this.info = info;
}
select() {
console.log('LOGGED');
const items = document.querySelectorAll('.tabs-item');
items.forEach(function(current) {
current.classList.remove('tabs-item-selected');
});
this.info.classList.add('tabs-item-selected');
}
}
let links = document.querySelectorAll('.tab-link');
links.forEach(function(link) {
return new TabLink(link);
});