-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
47 lines (42 loc) · 995 Bytes
/
script.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
$(document).ready(function(){
//MOUSEOVER EFFECTS
$('.header').mouseenter(function(){
$(this).fadeTo(150,1);
});
$('.header').mouseleave(function(){
$(this).fadeTo(150,0.5);
});
//HOMEMADE ACCORDION
var nDropdowns = $('.dropdown').length;
var ddOpen = [];
for (n=0; n<nDropdowns; n++) {
ddOpen.push($('.dropdown').eq(n).is(':visible'));
}
$('.header').click(function(){
$('.dropdown').slideUp('fast');
var index = $('.header').index(this);
if (!ddClicked(ddOpen)) {
$('.dropdown').eq(index).slideToggle('fast');
reset(ddOpen, nDropdowns);
ddOpen[index] = true;
}
else if (ddOpen[index]) {
ddOpen[index] = false;
return
}
else {
reset(ddOpen, nDropdowns);
ddOpen[index] = true;
$('.dropdown').eq(index).delay('200').slideToggle("fast");
}
});
});
reset = function(dd, nD) {
for (i=0; i<nD; i++) {
dd[i] = false;
}
}
ddClicked = function(dd) {
var allTrue = dd.some(function(item, index, array) {return item});
return allTrue
}