-
Notifications
You must be signed in to change notification settings - Fork 2
/
core.js
128 lines (124 loc) · 4.91 KB
/
core.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
if (window.jQuery){
//highlights current nav element based on which anchor was just passed
$(window).scroll(function(){
var aboutAnchor=$("#ABOUT").get();
var aboutAnchorPosition=$(aboutAnchor).offset().top;
var aboutNav=$("#About").get();
var contactAnchor=$("#CONTACT").get();
var contactAnchorPosition=$(contactAnchor).offset().top;
var contactNav=$("#Contact").get();
var conferenceNav=$("#Conference").get();
var eventsNav=$("#Events").get();
var storiesNav=$("#Stories").get()
var nahaniNav=$("#Nahani").get()
var xploreNav=$("#Xplore").get()
var top_window=$(window).scrollTop()+$(window).height()*0.08; //approximate proportion of anchor position and nav height
if (top_window>aboutAnchorPosition){
$(aboutNav).addClass('current');
$(contactNav).removeClass('current');
$(conferenceNav).removeClass('current');
$(eventsNav).removeClass('current');
$(storiesNav).removeClass('current');
$(nahaniNav).removeClass('current');
$(xploreNav).removeClass('current');
}
else $(aboutNav).removeClass('current');
if (top_window>contactAnchorPosition){
$(aboutNav).removeClass('current');
$(contactNav).addClass('current');
$(conferenceNav).removeClass('current');
$(eventsNav).removeClass('current');
$(storiesNav).removeClass('current');
$(nahaniNav).removeClass('current');
$(xploreNav).removeClass('current');
}
if (location.pathname.split(/[\\\/]+/).pop()=="conferences.html"){
$(aboutNav).removeClass('current');
$(contactNav).removeClass('current');
$(conferenceNav).addClass('current');
$(eventsNav).removeClass('current');
$(storiesNav).removeClass('current');
$(nahaniNav).removeClass('current');
$(xploreNav).removeClass('current');
}
if (location.pathname.split(/[\\\/]+/).pop()=="events.html"){
$(aboutNav).removeClass('current');
$(contactNav).removeClass('current');
$(conferenceNav).removeClass('current');
$(eventsNav).addClass('current');
$(storiesNav).removeClass('current');
$(nahaniNav).removeClass('current');
$(xploreNav).removeClass('current');
}
if (location.pathname.split(/[\\\/]+/).pop()=="stories.html"){
$(aboutNav).removeClass('current');
$(contactNav).removeClass('current');
$(conferenceNav).removeClass('current');
$(eventsNav).removeClass('current');
$(storiesNav).addClass('current');
$(nahaniNav).removeClass('current');
$(xploreNav).removeClass('current');
}
if (location.pathname.split(/[\\\/]+/).pop()=="xplore.html"){
$(aboutNav).removeClass('current');
$(contactNav).removeClass('current');
$(conferenceNav).removeClass('current');
$(eventsNav).removeClass('current');
$(storiesNav).removeClass('current');
$(nahaniNav).removeClass('current');
$(xploreNav).addClass('current');
}
if (location.pathname.split(/[\\\/]+/).pop()=="nahanirobots.html"){
$(aboutNav).removeClass('current');
$(contactNav).removeClass('current');
$(conferenceNav).removeClass('current');
$(eventsNav).removeClass('current');
$(storiesNav).removeClass('current');
$(xploreNav).removeClass('current');
$(nahaniNav).addClass('current');
}
});
//changes appearance of nav by adding class 'scrolled'
$(window).scroll(function(){
var top_object=$("#title").offset().top;
var top_window=$(window).scrollTop()+$(window).height()*0.05; //approximate proportion of nav to screen
if (top_window>top_object) $('#nav').addClass('scrolled');
else $('#nav').removeClass('scrolled');
});
//fades in pics of core5 once scrolled
$(window).scroll(function(){
var n=parseInt($('.fadeIn').css('top'),10); //accounts for different between exec and fadeIn top positioning
$('.exec').each(function(i){
var top_object=$(this).offset().top-(parseInt($(this).css('top'),10)-n);
var bottom_window=$(window).scrollTop()+$(window).height();
if (bottom_window>top_object){
$(this).addClass('popIn');
}
});
});
//fades in elements as scroll down
$(window).scroll(function(){
$('.fadeIn').each(function(i){
var top_object=$(this).offset().top;
var top_window=$(window).scrollTop()+$(window).height();
if (top_window>top_object){
$(this).addClass('popIn');
}
});
});
//animated scroll to anchors on page
$(document).ready(function(){
$('a[href*=#]:not([href=#])').click(function(){
if (location.pathname.replace(/^\//,'')==this.pathname.replace(/^\//,'')&&location.hostname==this.hostname){
var target=$(this.hash);
target=target.length?target:$('[name='+this.hash.slice(1)+']');
if (target.length){
$('html,body').stop().animate({
scrollTop:target.offset().top
},500,'swing');
return false;
}
}
});
});
}