Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
212 lines (147 loc) · 4.33 KB
/
Copy pathmain.js
File metadata and controls
212 lines (147 loc) · 4.33 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
Astral by HTML5 UP
html5up.net | @ajlkn
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
*/
(function($) {
var $window = $(window),
$body = $('body'),
$wrapper = $('#wrapper'),
$main = $('#main'),
$panels = $main.children('.panel'),
$nav = $('#nav'), $nav_links = $nav.children('a');
// Breakpoints.
breakpoints({
xlarge: [ '1281px', '1680px' ],
large: [ '981px', '1280px' ],
medium: [ '737px', '980px' ],
small: [ '361px', '736px' ],
xsmall: [ null, '360px' ]
});
// Play initial animations on page load.
$window.on('load', function() {
window.setTimeout(function() {
$body.removeClass('is-preload');
}, 100);
});
// Nav.
$nav_links
.on('click', function(event) {
var href = $(this).attr('href');
// Not a panel link? Bail.
if (href.charAt(0) != '#'
|| $panels.filter(href).length == 0)
return;
// Prevent default.
event.preventDefault();
event.stopPropagation();
// Change panels.
if (window.location.hash != href)
window.location.hash = href;
});
// Panels.
// Initialize.
(function() {
var $panel, $link;
// Get panel, link.
if (window.location.hash) {
$panel = $panels.filter(window.location.hash);
$link = $nav_links.filter('[href="' + window.location.hash + '"]');
}
// No panel/link? Default to first.
if (!$panel
|| $panel.length == 0) {
$panel = $panels.first();
$link = $nav_links.first();
}
// Deactivate all panels except this one.
$panels.not($panel)
.addClass('inactive')
.hide();
// Activate link.
$link
.addClass('active');
// Reset scroll.
$window.scrollTop(0);
})();
// Hashchange event.
$window.on('hashchange', function(event) {
var $panel, $link;
// Get panel, link.
if (window.location.hash) {
$panel = $panels.filter(window.location.hash);
$link = $nav_links.filter('[href="' + window.location.hash + '"]');
// No target panel? Bail.
if ($panel.length == 0)
return;
}
// No panel/link? Default to first.
else {
$panel = $panels.first();
$link = $nav_links.first();
}
// Deactivate all panels.
$panels.addClass('inactive');
// Deactivate all links.
$nav_links.removeClass('active');
// Activate target link.
$link.addClass('active');
// Set max/min height.
$main
.css('max-height', $main.height() + 'px')
.css('min-height', $main.height() + 'px');
// Delay.
setTimeout(function() {
// Hide all panels.
$panels.hide();
// Show target panel.
$panel.show();
// Set new max/min height.
$main
.css('max-height', $panel.outerHeight() + 'px')
.css('min-height', $panel.outerHeight() + 'px');
// Reset scroll.
$window.scrollTop(0);
// Delay.
window.setTimeout(function() {
// Activate target panel.
$panel.removeClass('inactive');
// Clear max/min height.
$main
.css('max-height', '')
.css('min-height', '');
// IE: Refresh.
$window.triggerHandler('--refresh');
// Unlock.
locked = false;
}, (breakpoints.active('small') ? 0 : 500));
}, 250);
});
// IE: Fixes.
if (browser.name == 'ie') {
// Fix min-height/flexbox.
$window.on('--refresh', function() {
$wrapper.css('height', 'auto');
window.setTimeout(function() {
var h = $wrapper.height(),
wh = $window.height();
if (h < wh)
$wrapper.css('height', '100vh');
}, 0);
});
$window.on('resize load', function() {
$window.triggerHandler('--refresh');
});
// Fix intro pic.
$('.panel.intro').each(function() {
var $pic = $(this).children('.pic'),
$img = $pic.children('img');
$pic
.css('background-image', 'url(' + $img.attr('src') + ')')
.css('background-size', 'cover')
.css('background-position', 'center');
$img
.css('visibility', 'hidden');
});
}
})(jQuery);