forked from BhathiyaTK/Tourism-Website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.js
150 lines (132 loc) · 4.37 KB
/
function.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
var collapse1 = document.getElementById("button1");
var collapse2 = document.getElementById("button2");
var collapse3 = document.getElementById("button3");
var collapse4 = document.getElementById("button4");
var collapse5 = document.getElementById("button5");
var collapse6 = document.getElementById("button6");
var content1 = document.getElementById("content1");
var content2 = document.getElementById("content2");
var content3 = document.getElementById("content3");
var content4 = document.getElementById("content4");
var content5 = document.getElementById("content5");
var content6 = document.getElementById("content6");
collapse1.onclick = function(){
this.classList.toggle('active');
collapse2.classList.remove('active');
collapse3.classList.remove('active');
collapse4.classList.remove('active');
collapse5.classList.remove('active');
collapse6.classList.remove('active');
if (content1.style.maxHeight) {
content1.style.maxHeight = null;
} else {
content1.style.maxHeight = content1.scrollHeight + "px";
content2.style.maxHeight = null;
content3.style.maxHeight = null;
content4.style.maxHeight = null;
content5.style.maxHeight = null;
content6.style.maxHeight = null;
}
}
collapse2.onclick = function(){
this.classList.toggle('active');
collapse1.classList.remove('active');
collapse3.classList.remove('active');
collapse4.classList.remove('active');
collapse5.classList.remove('active');
collapse6.classList.remove('active');
if (content2.style.maxHeight) {
content2.style.maxHeight = null;
} else {
content2.style.maxHeight = content2.scrollHeight + "px";
content1.style.maxHeight = null;
content3.style.maxHeight = null;
content4.style.maxHeight = null;
content5.style.maxHeight = null;
content6.style.maxHeight = null;
}
}
collapse3.onclick = function(){
this.classList.toggle('active');
collapse1.classList.remove('active');
collapse2.classList.remove('active');
collapse4.classList.remove('active');
collapse5.classList.remove('active');
collapse6.classList.remove('active');
if (content3.style.maxHeight) {
content3.style.maxHeight = null;
} else {
content3.style.maxHeight = content3.scrollHeight + "px";
content1.style.maxHeight = null;
content2.style.maxHeight = null;
content4.style.maxHeight = null;
content5.style.maxHeight = null;
content6.style.maxHeight = null;
}
}
collapse4.onclick = function(){
this.classList.toggle('active');
collapse1.classList.remove('active');
collapse2.classList.remove('active');
collapse3.classList.remove('active');
collapse5.classList.remove('active');
collapse6.classList.remove('active');
if (content4.style.maxHeight) {
content4.style.maxHeight = null;
} else {
content4.style.maxHeight = content4.scrollHeight + "px";
content1.style.maxHeight = null;
content2.style.maxHeight = null;
content3.style.maxHeight = null;
content5.style.maxHeight = null;
content6.style.maxHeight = null;
}
}
collapse5.onclick = function(){
this.classList.toggle('active');
collapse1.classList.remove('active');
collapse2.classList.remove('active');
collapse3.classList.remove('active');
collapse4.classList.remove('active');
collapse6.classList.remove('active');
if (content5.style.maxHeight) {
content5.style.maxHeight = null;
} else {
content5.style.maxHeight = content5.scrollHeight + "px";
content1.style.maxHeight = null;
content2.style.maxHeight = null;
content3.style.maxHeight = null;
content4.style.maxHeight = null;
content6.style.maxHeight = null;
}
}
collapse6.onclick = function(){
this.classList.toggle('active');
collapse1.classList.remove('active');
collapse2.classList.remove('active');
collapse3.classList.remove('active');
collapse4.classList.remove('active');
collapse5.classList.remove('active');
if (content6.style.maxHeight) {
content6.style.maxHeight = null;
} else {
content6.style.maxHeight = content6.scrollHeight + "px";
content1.style.maxHeight = null;
content2.style.maxHeight = null;
content3.style.maxHeight = null;
content4.style.maxHeight = null;
content5.style.maxHeight = null;
}
}
/*var collapses = document.getElementsByClassName("collapse");
for (var i = 0; i < collapses.length; i++) {
collapses[i].onclick = function () {
this.classList.toggle('active');
var content = this.nextElementSibling;
if (content.style.maxHeight) {
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
}
}*/