-
Notifications
You must be signed in to change notification settings - Fork 1
/
scripts.js
executable file
·212 lines (187 loc) · 5.59 KB
/
scripts.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
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
// ==========================================
// SMOOTH SCROLL MENU
// ==========================================
function pageScroll(){
// Select all links with hashes
$('a[href*="#"]')
// Remove links that don't actually link to anything
.not('[href="#"]')
.not('[href="#0"]')
.not('[href^="#s01"]')
.click(function(event) {
// On-page links
if (
location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
&&
location.hostname == this.hostname
) {
// Figure out element to scroll to
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
// Does a scroll target exist?
if (target.length) {
// Only prevent default if animation is actually gonna happen
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, 1000, function() {
// Callback after animation
// Must change focus!
var $target = $(target);
$target.focus();
if ($target.is(":focus")) { // Checking if the target was focused
return false;
} else {
$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
$target.focus(); // Set focus again
};
});
}
}
});
}
// ==========================================
// SCROLL TO TOP OF PAGE
// ==========================================
function scrollUp(){
var offset = 250;
var duration = 1000;
$(window).scroll(function() {
if ($(this).scrollTop() > offset) {
$(".back-to-top").fadeIn(duration);
} else {
$(".back-to-top").fadeOut(duration);
}
});
$(".back-to-top").click(function(event) {
event.preventDefault();
$("html, body").animate({scrollTop: 0}, duration);
$(".navbar-toggler").addClass("collapsed");
$(".navbar-toggler").attr("aria-expanded", "false");
$(".navbar-collapse").removeClass("show");
return false;
});
}
// ===================================================
// REMOVE COLLAPSIBLE CLASSES TO DISPLAY FULL CONTENT
// ===================================================
function epCollapse(){
if ($(".width-tester").css("width") == "768px") {
$(".ep-more").removeClass("show");
if(!$(".collapse.ep-desc").hasClass( "show" )){
$('.ep-icon, .ep-desc, .ep-video').addClass("show");
}
} else {
if($(".collapse.ep-desc" ).hasClass( "show" )){
// $('.ep-icon, .ep-desc, .ep-video, .ep-close').removeClass("show");
$('.ep-icon, .ep-desc, .ep-video').removeClass("show");
}
}
}
// ===================================================
// CHANGE "more" LINK TEXT WHEN CLICKED (SHOW MORE/SHOW LESS)
// ===================================================
function changeLink(){
$("a.more").click(function () {
var more = $(this).attr("moretext");
if (typeof more !== typeof undefined && more !== false) {
$(this).text(function(i, text){
return text === "show less" ? more : "show less";
})
}
});
}
// ===================================================
// ROTATE COLLAPSE ARROW
// ===================================================
function rotateArrow(){
// $(".collapse-toggle, .ep-close").click(function () {
$(".collapse-toggle").click(function () {
var thisSection = $(this).closest("[id]").prop("id");
// console.log(thisSection);
$("#" + thisSection + " .collapse-toggle").toggleClass("rotate");
$(".collapse-toggle").not(this).removeClass("rotate");
});
}
// ===================================================
// FUNCTION CALLS
// ===================================================
$(document).ready(function(){
changeLink();
epCollapse();
rotateArrow();
pageScroll();
scrollUp();
// ======================================
// "HOW" SECTION SLIDER INITIALIZER START
// ======================================
$('.slider-how').slick({
infinite: true,
slidesToScroll: 1,
slidesToShow: 1,
centerMode: false,
autoplay: false,
mobileFirst: true,
dots: true,
prevArrow: "<i class='fa fa-angle-left slick-prev' aria-hidden='true'></i>",
nextArrow: "<i class='fa fa-angle-right slick-next' aria-hidden='true'></i>"
});
// ======================================
// "WHO" SECTION SLIDER INITIALIZER START
// ======================================
$('.slider-who').slick({
infinite: true,
slidesToScroll: 1,
slidesToShow: 2,
centerMode: false,
autoplaySpeed: 5000,
mobileFirst: true,
prevArrow: "<i class='fa fa-angle-left slick-prev' aria-hidden='true'></i>",
nextArrow: "<i class='fa fa-angle-right slick-next' aria-hidden='true'></i>"
,
responsive: [
{
breakpoint: 490,
settings: {
slidesToShow: 2
}
}
,
{
breakpoint: 600,
settings: {
slidesToShow: 3
}
}
,
{
breakpoint: 767,
settings: {
slidesToShow: 4
}
}
,
{
breakpoint: 991,
settings: {
slidesToShow: 6
}
},
{
breakpoint: 1199,
settings: {
slidesToShow: 7
}
}
]
});
$('.collapse').on('shown.bs.collapse', function(e) {
var $card = $(this).closest('.card');
$('html,body').animate({
scrollTop: $card.offset().top
}, 500);
});
});
// $(window).on('resize', function(){
// epCollapse();
// });